Homesource Forums

Homeworld Source Editing Talk
It is currently Mon Sep 25, 2017 10:54 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Nov 24, 2006 4:25 pm 
Offline
coder
User avatar

Joined: Tue Dec 14, 2004 3:24 pm
Posts: 324
Location: UK (UTC+0)
That regex isn't quite as rigid as I'd like but it gets the point across: the Homeworld source code has too many #defines related to the maximum length of a filepath. We really should settle on one for consistency. Candidates include:

Code:
/usr/include/sys/syslimits.h:
#define  PATH_MAX  1024

/usr/include/sys/param.h:
#define  MAXPATHLEN  PATH_MAX

/usr/include/limits.h:
#define  _POSIX_PATH_MAX  256        // this isn't actually used in the HW source

homeworld/src/Game/Types.h:
#define  PATH_MAX  MAX_PATH          // only defined for _WIN32

/usr/include/X11/Xos.h:
#define  MAX_PATH  _POSIX_PATH_MAX   // similar to above but for X11 (Linux)

PATH_MAX has the advantage of specifying a real number. MAXPATHLEN is just an alias of PATH_MAX and so is immediately redundant in my book. The same is also true of MAX_PATH but it has the noticable distinction of being defined within the Homeworld source code itself. (I couldn't find a related SDL #define but if anyone knows of one then we should probably use that.)

I'd argue for making MAX_PATH our standard. It reads well and because it's defined in the Homeworld source it helps abstract away any possible platform-specificness that the other #defines may not be able to do.

Any opposing opinions? If not, I'll convert the code base to use MAX_PATH but define it explicitly in Types.h (not really a type but I'll worry about that later...):

Code:
#define MAX_PATH 1024

Can someone check what the _WIN32 definition of MAX_PATH is please? It would be nice to know what it is in case we should actually be coding for 256 buffer sizes.

_________________
MacHomeworld | HomeworldSDL.org


Top
 Profile  
 
PostPosted: Fri Nov 24, 2006 7:02 pm 
Offline
Site Admin
User avatar

Joined: Tue Dec 14, 2004 12:41 am
Posts: 326
lmop wrote:
... the Homeworld source code has too many #defines related to the maximum length of a filepath. We really should settle on one for consistency. Candidates include:

Code:
/usr/include/sys/syslimits.h:
#define  PATH_MAX  1024



When I have to enter a manual def for that I always use 1111 because typing in 1024 is just too much trouble... :twisted:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 2:59 pm 
Offline
coder
User avatar

Joined: Tue Dec 14, 2004 3:24 pm
Posts: 324
Location: UK (UTC+0)
Actually the vast majority of the code uses PATH_MAX (i.e. the defined as number constant) and the redefinition in Types.h (for Windows) simply remaps it to a Windows equivalent. (A bit odd given that it was originlly built on Windows... Related to the use of gcc perhaps?)

Anyway, I'll change the few references of MAXPATHLEN and MAX_PATH to PATH_MAX.

_________________
MacHomeworld | HomeworldSDL.org


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group