From fa424f943fbccc663c46934b1785972d6eb28bc2 Mon Sep 17 00:00:00 2001 From: bernhardheld Date: Fri, 12 Oct 2001 19:06:23 +0000 Subject: [PATCH] replace FILENAME_MAX with PATH_MAX git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1392 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 22 ++++++++++++++++++++++ as/mcs51/asdata.c | 6 +++--- as/mcs51/aslink.h | 10 +++++++++- as/mcs51/asm.h | 16 ++++++++++++---- as/mcs51/asmain.c | 10 +++++----- as/mcs51/asnoice.c | 4 ++-- as/mcs51/lklex.c | 12 ++++++------ as/mcs51/lkmain.c | 6 +++--- src/SDCCglobl.h | 7 ++++++- src/SDCCmacro.c | 2 +- src/SDCCmain.c | 4 ++-- 11 files changed, 71 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7fef2678..c8b25d8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2001-10-11 Bernhard Held + + * as/mcs51/asdata.c: replaced FILENAME_MAX with PATH_MAX + + * as/mcs51/aslink.h: define PATH_MAX + + * as/mcs51/asm.h: define PATH_MAX + + * as/mcs51/asmain.c: replaced FILENAME_MAX with PATH_MAX + + * as/mcs51/asnoice.c: replaced FILENAME_MAX with PATH_MAX + + * as/mcs51/lklex.c: replaced FILENAME_MAX with PATH_MAX + + * as/mcs51/lkmain.c: replaced FILENAME_MAX with PATH_MAX + + * src/SDCCglobl.h: define PATH_MAX + + * src/SDCCmacro.c: replaced FILENAME_MAX with PATH_MAX + + * src/SDCCmain.c: replaced FILENAME_MAX with PATH_MAX + 2001-10-11 Michael Hope * src/z80/gen.c (gencjneshort): Fixed diff --git a/as/mcs51/asdata.c b/as/mcs51/asdata.c index f952d961..07c065ce 100644 --- a/as/mcs51/asdata.c +++ b/as/mcs51/asdata.c @@ -51,13 +51,13 @@ int iflvl[MAXIF+1]; /* array of IF-ELSE-ENDIF flevel * values indexed by tlevel */ -char afn[FILENAME_MAX]; /* afile temporary file name +char afn[PATH_MAX]; /* afile temporary file name */ -char srcfn[MAXFIL][FILENAME_MAX]; /* array of source file names +char srcfn[MAXFIL][PATH_MAX]; /* array of source file names */ int srcline[MAXFIL]; /* source line number */ -char incfn[MAXINC][FILENAME_MAX]; /* array of include file names +char incfn[MAXINC][PATH_MAX]; /* array of include file names */ int incline[MAXINC]; /* include line number */ diff --git a/as/mcs51/aslink.h b/as/mcs51/aslink.h index 12ef9053..0c746ca7 100644 --- a/as/mcs51/aslink.h +++ b/as/mcs51/aslink.h @@ -79,6 +79,14 @@ #define OTHERSYSTEM #endif +/* + * PATH_AMX + */ +#include +#ifndef PATH_MAX /* POSIX, but not required */ +#define PATH_MAX 255 /* define a reasonable value */ +#endif + /* * This file defines the format of the * relocatable binary file. @@ -86,7 +94,7 @@ #define NCPS 80 /* characters per symbol (JLH: change from 8) */ #define NDATA 16 /* actual data */ -#define NINPUT FILENAME_MAX /* Input buffer size (BH: change from 128) */ +#define NINPUT PATH_MAX /* Input buffer size */ #define NHASH 64 /* Buckets in hash table */ #define HMASK 077 /* Hash mask */ #define NLPP 60 /* Lines per page */ diff --git a/as/mcs51/asm.h b/as/mcs51/asm.h index 9134686a..5cfdab99 100644 --- a/as/mcs51/asm.h +++ b/as/mcs51/asm.h @@ -76,6 +76,14 @@ #define OTHERSYSTEM #endif +/* + * PATH_MAX + */ +#include +#ifndef PATH_MAX /* POSIX, but not required */ +#define PATH_MAX /* define a reasonable value */ +#endif + /* * Assembler definitions. */ @@ -85,7 +93,7 @@ #define NCPS 80 /* Chars. per symbol (JLH: change from 8) */ #define HUGE 1000 /* A huge number */ #define NERR 3 /* Errors per line */ -#define NINPUT FILENAME_MAX /* Input buffer size (BH: change from 128) */ +#define NINPUT PATH_MAX /* Input buffer size (BH: change from 128) */ #define NCODE 128 /* Listing code buffer size */ #define NTITL 64 /* Title buffer size */ #define NSBTL 64 /* SubTitle buffer size */ @@ -370,16 +378,16 @@ extern int iflvl[MAXIF+1]; /* array of IF-ELSE-ENDIF flevel * values indexed by tlevel */ extern char - afn[FILENAME_MAX]; /* afile() temporary filespec + afn[PATH_MAX]; /* afile() temporary filespec */ extern char - srcfn[MAXFIL][FILENAME_MAX]; /* array of source file names + srcfn[MAXFIL][PATH_MAX]; /* array of source file names */ extern int srcline[MAXFIL]; /* current source file line */ extern char - incfn[MAXINC][FILENAME_MAX]; /* array of include file names + incfn[MAXINC][PATH_MAX]; /* array of include file names */ extern int incline[MAXINC]; /* current include file line diff --git a/as/mcs51/asmain.c b/as/mcs51/asmain.c index 9947ae3f..bb219428 100644 --- a/as/mcs51/asmain.c +++ b/as/mcs51/asmain.c @@ -479,7 +479,7 @@ asmbl() struct expr e1; char id[NCPS]; char opt[NCPS]; - char fn[FILENAME_MAX]; + char fn[PATH_MAX]; char *p; int d, n, uaf, uf; @@ -911,7 +911,7 @@ loop: d = getnb(); p = fn; while ((c = get()) != d) { - if (p < &fn[FILENAME_MAX-1]) { + if (p < &fn[PATH_MAX-1]) { *p++ = c; } else { break; @@ -1053,8 +1053,8 @@ int wf; p2 = strrchr (afn, FSEPX); // search last '.' if (!p2) p2 = afn + strlen (afn); - if (p2 > &afn[FILENAME_MAX-4]) // truncate filename, if it's too long - p2 = &afn[FILENAME_MAX-4]; + if (p2 > &afn[PATH_MAX-4]) // truncate filename, if it's too long + p2 = &afn[PATH_MAX-4]; *p2++ = FSEPX; // choose a file-extension @@ -1067,7 +1067,7 @@ int wf; } while ((c = *p3++) != 0) { // strncpy - if (p2 < &afn[FILENAME_MAX-1]) + if (p2 < &afn[PATH_MAX-1]) *p2++ = c; } *p2++ = 0; diff --git a/as/mcs51/asnoice.c b/as/mcs51/asnoice.c index a6144969..38d3233f 100644 --- a/as/mcs51/asnoice.c +++ b/as/mcs51/asnoice.c @@ -17,7 +17,7 @@ static char* BaseFileName( int fileNumber ); char* BaseFileName( int fileNumber ) { static int prevFile = -1; - static char baseName[ FILENAME_MAX ]; + static char baseName[ PATH_MAX ]; char *p1, *p2; @@ -85,7 +85,7 @@ void DefineNoICE_Line() { static int prevFile = -1; static struct area *pPrevArea = NULL; - static char baseName[ FILENAME_MAX ]; + static char baseName[ PATH_MAX ]; int j; char *p1, *p2; diff --git a/as/mcs51/lklex.c b/as/mcs51/lklex.c index 5c51c593..4f6c4575 100644 --- a/as/mcs51/lklex.c +++ b/as/mcs51/lklex.c @@ -156,7 +156,7 @@ char *id; /*)Function VOID getfid(fid,c) * * char * str a pointer to a string of - * maximum length FILENAME_MAX + * maximum length PATH_MAX * int c this is first character to * copy to the string buffer * @@ -164,9 +164,9 @@ char *id; * from the current position copying the next string * into the external string buffer (str). The string ends when a * non SPACE type character is found. The maximum number of - * characters copied is FILENAME_MAX. If the input string is larger than - * FILENAME_MAX characters then the string is truncated, if the input string - * is shorter than FILENAME_MAX characters then the string is NULL filled. + * characters copied is PATH_MAX. If the input string is larger than + * PATH_MAX characters then the string is truncated, if the input string + * is shorter than PATH_MAX characters then the string is NULL filled. * * local variables: * char * p pointer to external string buffer @@ -195,11 +195,11 @@ char *str; p = str; do { - if (p < &str[FILENAME_MAX-1]) + if (p < &str[PATH_MAX-1]) *p++ = c; c = get(); } while (c && ((ctype[c] != SPACE)||(c == ':')||(c == '\\'))); - while (p < &str[FILENAME_MAX]) + while (p < &str[PATH_MAX]) *p++ = 0; } diff --git a/as/mcs51/lkmain.c b/as/mcs51/lkmain.c index 17277c2f..58abc721 100644 --- a/as/mcs51/lkmain.c +++ b/as/mcs51/lkmain.c @@ -1045,14 +1045,14 @@ char *ft; register char *p1, *p2, *p3; register int c; FILE *fp; - char fb[FILENAME_MAX]; + char fb[PATH_MAX]; char *omode = (wf ? (wf == 2 ? "a" : "w") : "r"); p1 = fn; p2 = fb; p3 = ft; while ((c = *p1++) != 0 && c != FSEPX) { - if (p2 < &fb[FILENAME_MAX-4]) + if (p2 < &fb[PATH_MAX-4]) *p2++ = c; } *p2++ = FSEPX; @@ -1064,7 +1064,7 @@ char *ft; } } while ((c = *p3++) != 0) { - if (p2 < &fb[FILENAME_MAX-1]) + if (p2 < &fb[PATH_MAX-1]) *p2++ = c; } *p2++ = 0; diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index 07eec1dd..3df24562 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -48,6 +48,11 @@ #define SPACE ' ' #define ZERO 0 +#include /* PATH_MAX */ +#ifndef PATH_MAX /* POSIX, but not required */ +#define PATH_MAX 255 /* define a reasonable value */ +#endif + #define MAX_FNAME_LEN 128 #define MAX_REG_PARMS 1 typedef int bool; @@ -316,6 +321,6 @@ extern struct _dumpFiles dumpFiles[]; /* Buffer which can be used to hold a file name; assume it will * be trashed by any function call within SDCC. */ -extern char scratchFileName[FILENAME_MAX]; +extern char scratchFileName[PATH_MAX]; #endif diff --git a/src/SDCCmacro.c b/src/SDCCmacro.c index 8487178d..eb2b49c1 100644 --- a/src/SDCCmacro.c +++ b/src/SDCCmacro.c @@ -26,7 +26,7 @@ enum { - MAX_STRING_LENGTH = FILENAME_MAX, + MAX_STRING_LENGTH = PATH_MAX, MAX_MACRO_NAME_LENGTH = 128 }; diff --git a/src/SDCCmain.c b/src/SDCCmain.c index e7f5eea4..9ea904fa 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -79,8 +79,8 @@ int ds390_jammed = 0; #endif // Globally accessible scratch buffer for file names. -char scratchFileName[FILENAME_MAX]; -char buffer[FILENAME_MAX]; +char scratchFileName[PATH_MAX]; +char buffer[PATH_MAX]; // In MSC VC6 default search path for exe's to path for this -- 2.30.2