This commit is contained in:
Branimir Karadžić 2018-04-24 20:07:38 -07:00
Родитель 943a4b9f63
Коммит 66cc9da65a
12 изменённых файлов: 832 добавлений и 796 удалений

26
3rdparty/fcpp/cpp.h поставляемый
Просмотреть файл

@ -35,16 +35,16 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifndef toupper #ifndef fpp_toupper
#define toupper(c) ((c) + ('A' - 'a')) #define fpp_toupper(c) ((c) + ('A' - 'a'))
#endif /* no toupper */ #endif /* no fpp_toupper */
#ifndef tolower #ifndef fpp_tolower
#define tolower(c) ((c) + ('a' - 'A')) #define fpp_tolower(c) ((c) + ('a' - 'A'))
#endif /* no tolower */ #endif /* no fpp_tolower */
#ifndef TRUE #ifndef FPP_TRUE
#define TRUE 1 #define FPP_TRUE 1
#define FALSE 0 #define FPP_FALSE 0
#endif #endif
#ifndef EOS #ifndef EOS
/* /*
@ -52,7 +52,7 @@
*/ */
#define EOS '\0' /* End of string */ #define EOS '\0' /* End of string */
#endif #endif
#define EOF_CHAR 0 /* Returned by get() on eof */ #define EOF_CHAR 0 /* Returned by fpp_get() on eof */
#define NULLST ((char *) NULL) /* Pointer to nowhere (linted) */ #define NULLST ((char *) NULL) /* Pointer to nowhere (linted) */
#define DEF_NOARGS (-1) /* #define foo vs #define foo() */ #define DEF_NOARGS (-1) /* #define foo vs #define foo() */
@ -139,9 +139,9 @@
/* /*
* These bits are set in ifstack[] * These bits are set in ifstack[]
*/ */
#define WAS_COMPILING 1 /* TRUE if compile set at entry */ #define WAS_COMPILING 1 /* FPP_TRUE if compile set at entry */
#define ELSE_SEEN 2 /* TRUE when #else processed */ #define ELSE_SEEN 2 /* FPP_TRUE when #else processed */
#define TRUE_SEEN 4 /* TRUE when #if TRUE processed */ #define FPP_TRUE_SEEN 4 /* FPP_TRUE when #if FPP_TRUE processed */
/* /*
* Define bits for the basic types and their adjectives * Define bits for the basic types and their adjectives

186
3rdparty/fcpp/cpp1.c поставляемый
Просмотреть файл

@ -34,9 +34,9 @@ void __stdargs _XCEXIT(long a) { return; }
#endif #endif
#endif #endif
FILE_LOCAL ReturnCode output(struct Global *, int); /* Output one character */ FILE_LOCAL ReturnCode fpp_output(struct Global *, int); /* Output one character */
FILE_LOCAL void sharp(struct Global *); FILE_LOCAL void fpp_sharp(struct Global *);
INLINE FILE_LOCAL ReturnCode cppmain(struct Global *); INLINE FILE_LOCAL ReturnCode fpp_cppmain(struct Global *);
int fppPreProcess(struct fppTag *tags) int fppPreProcess(struct fppTag *tags)
{ {
@ -56,17 +56,17 @@ int fppPreProcess(struct fppTag *tags)
global->wrongline=0; global->wrongline=0;
global->errors=0; global->errors=0;
global->recursion=0; global->recursion=0;
global->rec_recover=TRUE; global->rec_recover=FPP_TRUE;
global->instring=FALSE; global->instring=FPP_FALSE;
global->inmacro=FALSE; global->inmacro=FPP_FALSE;
global->workp=NULL; global->workp=NULL;
global->keepcomments = FALSE; /* Write out comments flag */ global->keepcomments = FPP_FALSE; /* Write out comments flag */
global->cflag = FALSE; /* -C option (keep comments) */ global->cflag = FPP_FALSE; /* -C option (keep comments) */
global->eflag = FALSE; /* -E option (never fail) */ global->eflag = FPP_FALSE; /* -E option (never fail) */
global->nflag = 0; /* -N option (no predefines) */ global->nflag = 0; /* -N option (no predefines) */
global->wflag = FALSE; /* -W option (write #defines) */ global->wflag = FPP_FALSE; /* -W option (write #defines) */
global->ifstack[0]=TRUE; /* #if information */ global->ifstack[0]=FPP_TRUE; /* #if information */
global->ifptr = global->ifstack; global->ifptr = global->ifstack;
global->incend = global->incdir; global->incend = global->incdir;
@ -107,45 +107,46 @@ int fppPreProcess(struct fppTag *tags)
global->first_file=NULL; global->first_file=NULL;
global->userdata=NULL; global->userdata=NULL;
global->linelines=TRUE; global->linelines=FPP_TRUE;
global->warnillegalcpp = FALSE; global->warnillegalcpp = FPP_FALSE;
global->outputLINE = TRUE; global->outputLINE = FPP_TRUE;
global->warnnoinclude = TRUE; global->warnnoinclude = FPP_TRUE;
global->showversion = TRUE; global->showversion = FPP_TRUE;
global->showincluded = FALSE; global->showincluded = FPP_FALSE;
global->showspace = FALSE; global->showspace = FPP_FALSE;
global->nestcomments = FALSE; global->nestcomments = FPP_FALSE;
global->warnnestcomments = FALSE; global->warnnestcomments = FPP_FALSE;
global->outputfile = TRUE; global->outputfile = FPP_TRUE;
global->included = 0; global->included = 0;
global->comment = FALSE; global->comment = FPP_FALSE;
global->rightconcat = FALSE; global->rightconcat = FPP_FALSE;
global->work[0] = '\0'; global->work[0] = '\0';
global->initialfunc = NULL; global->initialfunc = NULL;
global->allowincludelocal = FPP_TRUE;
memset(global->symtab, 0, SBSIZE * sizeof(DEFBUF *)); memset(global->symtab, 0, SBSIZE * sizeof(DEFBUF *));
ret=initdefines(global); /* O.S. specific def's */ ret=fpp_initdefines(global); /* O.S. specific def's */
if(ret) if(ret)
return(ret); return(ret);
dooptions(global, tags); /* Command line -flags */ fpp_dooptions(global, tags); /* Command line -flags */
ret=addfile(global, stdin, global->work); /* "open" main input file */ ret=fpp_addfile(global, stdin, global->work); /* "open" main input file */
global->out = global->outputfile; global->out = global->outputfile;
if(!ret) if(!ret)
ret=cppmain(global); /* Process main file */ ret=fpp_cppmain(global); /* Process main file */
if ((i = (global->ifptr - global->ifstack)) != 0) { if ((i = (global->ifptr - global->ifstack)) != 0) {
#if OLD_PREPROCESSOR #if OLD_PREPROCESSOR
cwarn(global, ERROR_IFDEF_DEPTH, i); fpp_cwarn(global, ERROR_IFDEF_DEPTH, i);
#else #else
cerror(global, ERROR_IFDEF_DEPTH, i); fpp_cerror(global, ERROR_IFDEF_DEPTH, i);
#endif #endif
} }
fflush(stdout); fflush(stdout);
// BK - fclose(stdout); // BK - fclose(stdout);
delalldefines(global); fpp_delalldefines(global);
retVal = IO_NORMAL; retVal = IO_NORMAL;
if (global->errors > 0 && !global->eflag) if (global->errors > 0 && !global->eflag)
@ -158,7 +159,7 @@ int fppPreProcess(struct fppTag *tags)
} }
INLINE FILE_LOCAL INLINE FILE_LOCAL
ReturnCode cppmain(struct Global *global) ReturnCode fpp_cppmain(struct Global *global)
{ {
/* /*
* Main process for cpp -- copies tokens from the current input * Main process for cpp -- copies tokens from the current input
@ -182,7 +183,7 @@ ReturnCode cppmain(struct Global *global)
char define = 0; /* probability of a function define phase in the program */ char define = 0; /* probability of a function define phase in the program */
char prev = 0; /* previous type */ char prev = 0; /* previous type */
char go = 0; char go = 0;
char include = 0; unsigned include = 0;
char initfunc = 0; char initfunc = 0;
/* Initialize for reading tokens */ /* Initialize for reading tokens */
@ -203,7 +204,7 @@ ReturnCode cppmain(struct Global *global)
} }
if(global->showversion) if(global->showversion)
Error(global, VERSION_TEXT); fpp_Error(global, VERSION_TEXT);
/* /*
* Explicitly output a #line at the start of cpp output so * Explicitly output a #line at the start of cpp output so
@ -212,10 +213,10 @@ ReturnCode cppmain(struct Global *global)
* the name of the first #include file instead. * the name of the first #include file instead.
*/ */
if(global->linelines) /* if #line lines are wanted! */ if(global->linelines) /* if #line lines are wanted! */
sharp(global); fpp_sharp(global);
/* /*
* This loop is started "from the top" at the beginning of each line * This loop is started "from the top" at the beginning of each line
* wrongline is set TRUE in many places if it is necessary to write * wrongline is set FPP_TRUE in many places if it is necessary to write
* a #line record. (But we don't write them when expanding macros.) * a #line record. (But we don't write them when expanding macros.)
* *
* The counter variable has two different uses: at * The counter variable has two different uses: at
@ -231,15 +232,15 @@ ReturnCode cppmain(struct Global *global)
include = global->included; include = global->included;
while(include--) { while(include--) {
openinclude(global, global->include[(unsigned)include], TRUE); fpp_openinclude(global, global->include[(unsigned)include], FPP_TRUE);
} }
for (;;) { for (;;) {
counter = 0; /* Count empty lines */ counter = 0; /* Count empty lines */
for (;;) { /* For each line, ... */ for (;;) { /* For each line, ... */
global->comment = FALSE; /* No comment yet! */ global->comment = FPP_FALSE; /* No comment yet! */
global->chpos = 0; /* Count whitespaces */ global->chpos = 0; /* Count whitespaces */
while (type[(c = get(global))] == SPA) /* Skip leading blanks */ while (type[(c = fpp_get(global))] == SPA) /* Skip leading blanks */
if(global->showspace) { if(global->showspace) {
if(global->chpos<MAX_SPACE_SIZE-1) if(global->chpos<MAX_SPACE_SIZE-1)
/* we still have buffer to store this! */ /* we still have buffer to store this! */
@ -248,14 +249,14 @@ ReturnCode cppmain(struct Global *global)
if (c == '\n') { /* If line's all blank, */ if (c == '\n') { /* If line's all blank, */
if(global->comment) { if(global->comment) {
/* A comment was output! */ /* A comment was output! */
Putchar(global, '\n'); fpp_Putchar(global, '\n');
} }
else else
++counter; /* Do nothing now */ ++counter; /* Do nothing now */
} }
else if (c == '#') { /* Is 1st non-space '#' */ else if (c == '#') { /* Is 1st non-space '#' */
global->keepcomments = FALSE; /* Don't pass comments */ global->keepcomments = FPP_FALSE; /* Don't pass comments */
ret = control(global, &counter); /* Yes, do a #command */ ret = fpp_control(global, &counter); /* Yes, do a #command */
if(ret) if(ret)
return(ret); return(ret);
global->keepcomments = (global->cflag && compiling); global->keepcomments = (global->cflag && compiling);
@ -263,7 +264,7 @@ ReturnCode cppmain(struct Global *global)
else if (c == EOF_CHAR) /* At end of file? */ else if (c == EOF_CHAR) /* At end of file? */
break; break;
else if (!compiling) { /* #ifdef false? */ else if (!compiling) { /* #ifdef false? */
skipnl(global); /* Skip to newline */ fpp_skipnl(global); /* Skip to newline */
counter++; /* Count it, too. */ counter++; /* Count it, too. */
} else { } else {
break; /* Actual token */ break; /* Actual token */
@ -278,25 +279,25 @@ ReturnCode cppmain(struct Global *global)
*/ */
if(global->linelines) { /* if #line lines are wanted! */ if(global->linelines) { /* if #line lines are wanted! */
if ((global->wrongline && global->infile->fp != NULL) || counter > 4) if ((global->wrongline && global->infile->fp != NULL) || counter > 4)
sharp(global); /* Output # line number */ fpp_sharp(global); /* Output # line number */
else { /* If just a few, stuff */ else { /* If just a few, stuff */
while (--counter >= 0) /* them out ourselves */ while (--counter >= 0) /* them out ourselves */
Putchar(global, (int)'\n'); fpp_Putchar(global, (int)'\n');
} }
} }
if(global->showspace) { if(global->showspace) {
/* Show all whitespaces! */ /* Show all whitespaces! */
global->spacebuf[global->chpos] = '\0'; global->spacebuf[global->chpos] = '\0';
Putstring(global, global->spacebuf); fpp_Putstring(global, global->spacebuf);
} }
/* /*
* Process each token on this line. * Process each token on this line.
*/ */
unget(global); /* Reread the char. */ fpp_unget(global); /* Reread the char. */
for (;;) { /* For the whole line, */ for (;;) { /* For the whole line, */
do { /* Token concat. loop */ do { /* Token concat. loop */
for (global->chpos = counter = 0; type[(c = get(global))] == SPA;) { for (global->chpos = counter = 0; (type[(c = fpp_get(global))] == SPA);) {
#if COMMENT_INVISIBLE #if COMMENT_INVISIBLE
if (c != COM_SEP) if (c != COM_SEP)
counter++; counter++;
@ -311,15 +312,15 @@ ReturnCode cppmain(struct Global *global)
break; /* Exit line loop */ break; /* Exit line loop */
else if (counter > 0) { /* If we got any spaces */ else if (counter > 0) { /* If we got any spaces */
if(!global->showspace) /* We don't output all spaces */ if(!global->showspace) /* We don't output all spaces */
Putchar(global, (int)' ');/* Output one space */ fpp_Putchar(global, (int)' ');/* Output one space */
else { else {
global->spacebuf[global->chpos] = '\0'; global->spacebuf[global->chpos] = '\0';
Putstring(global, global->spacebuf); /* Output all whitespaces */ fpp_Putstring(global, global->spacebuf); /* Output all whitespaces */
} }
} }
if((ret=macroid(global, &c))) /* Grab the token */ if((ret=fpp_macroid(global, &c))) /* Grab the token */
return(ret); return(ret);
} while (type[c] == LET && catenate(global, &ret) && !ret); } while (type[c] == LET && fpp_catenate(global, 0, &ret) && !ret);
if(ret) if(ret)
/* If the loop was broken because of a fatal error! */ /* If the loop was broken because of a fatal error! */
return(ret); return(ret);
@ -330,7 +331,7 @@ ReturnCode cppmain(struct Global *global)
case LET: case LET:
go =0; go =0;
/* Quite ordinary token */ /* Quite ordinary token */
Putstring(global, global->tokenbuf); fpp_Putstring(global, global->tokenbuf);
if(!define) { if(!define) {
/* Copy the name */ /* Copy the name */
@ -342,7 +343,10 @@ ReturnCode cppmain(struct Global *global)
case DIG: /* Output a number */ case DIG: /* Output a number */
case DOT: /* Dot may begin floats */ case DOT: /* Dot may begin floats */
go = 0; go = 0;
ret=scannumber(global, c, (ReturnCode(*)(struct Global *, int))output); ret=fpp_scannumber(global, c, (ReturnCode(*)(struct Global *, int))fpp_output);
if(ret)
return(ret);
fpp_catenate(global, 1, &ret); /* Check to see if the number is the lhs of a macro concat */
if(ret) if(ret)
return(ret); return(ret);
break; break;
@ -350,8 +354,8 @@ ReturnCode cppmain(struct Global *global)
go = 0; go = 0;
/* Copy it to output */ /* Copy it to output */
if(!global->webmode) { if(!global->webmode) {
ret=scanstring(global, c, ret=fpp_scanstring(global, c,
(ReturnCode(*)(struct Global *, int))output); (ReturnCode(*)(struct Global *, int))fpp_output);
if(ret) if(ret)
return(ret); return(ret);
break; break;
@ -375,7 +379,7 @@ ReturnCode cppmain(struct Global *global)
/* /*
* Output the discovered function name to stderr! * Output the discovered function name to stderr!
*/ */
Error(global, "#> Function defined at line %d: %s <#\n", fpp_Error(global, "#> Function defined at line %d: %s <#\n",
global->line, global->line,
global->functionname); global->functionname);
} }
@ -389,9 +393,9 @@ ReturnCode cppmain(struct Global *global)
break; break;
} }
if(a==global->excluded) { if(a==global->excluded) {
expstuff(global, "__brace__", "{"); fpp_expstuff(global, "__brace__", "{");
expstuff(global, "__init_func__", global->initialfunc); fpp_expstuff(global, "__init_func__", global->initialfunc);
initfunc = TRUE; initfunc = FPP_TRUE;
} }
} }
@ -407,7 +411,7 @@ ReturnCode cppmain(struct Global *global)
define = 1; define = 1;
if(initfunc) { if(initfunc) {
Putchar(global, '}'); fpp_Putchar(global, '}');
bracelevel--; bracelevel--;
initfunc=0; initfunc=0;
} }
@ -469,57 +473,57 @@ ReturnCode cppmain(struct Global *global)
} }
define--; /* decrease function probability */ define--; /* decrease function probability */
Putchar(global, c); /* Just output it */ fpp_Putchar(global, c); /* Just output it */
break; break;
} /* Switch ends */ } /* Switch ends */
prev = type[c]; prev = type[c];
} /* Line for loop */ } /* Line for loop */
if (c == '\n') { /* Compiling at EOL? */ if (c == '\n') { /* Compiling at EOL? */
Putchar(global, '\n'); /* Output newline, if */ fpp_Putchar(global, '\n'); /* Output newline, if */
if (global->infile->fp == NULL) /* Expanding a macro, */ if (global->infile->fp == NULL) /* Expanding a macro, */
global->wrongline = TRUE; /* Output # line later */ global->wrongline = FPP_TRUE; /* Output # line later */
} }
} /* Continue until EOF */ } /* Continue until EOF */
if(global->showbalance) { if(global->showbalance) {
if(bracketlevel) { if(bracketlevel) {
cwarn(global, WARN_BRACKET_DEPTH, bracketlevel); fpp_cwarn(global, WARN_BRACKET_DEPTH, bracketlevel);
} }
if(parenlevel) { if(parenlevel) {
cwarn(global, WARN_PAREN_DEPTH, parenlevel); fpp_cwarn(global, WARN_PAREN_DEPTH, parenlevel);
} }
if(bracelevel) { if(bracelevel) {
cwarn(global, WARN_BRACE_DEPTH, bracelevel); fpp_cwarn(global, WARN_BRACE_DEPTH, bracelevel);
} }
} }
if (global->wflag) { if (global->wflag) {
global->out = TRUE; /* enable output */ global->out = FPP_TRUE; /* enable fpp_output */
outdefines(global); /* Write out #defines */ fpp_outdefines(global); /* Write out #defines */
} }
return(FPP_OK); return(FPP_OK);
} }
FILE_LOCAL FILE_LOCAL
ReturnCode output(struct Global *global, int c) ReturnCode fpp_output(struct Global *global, int c)
{ {
/* /*
* Output one character to stdout -- output() is passed as an * Output one character to stdout -- fpp_output() is passed as an
* argument to scanstring() * argument to fpp_scanstring()
*/ */
#if COMMENT_INVISIBLE #if COMMENT_INVISIBLE
if (c != TOK_SEP && c != COM_SEP) if (c != TOK_SEP && c != COM_SEP)
#else #else
if (c != TOK_SEP) if (c != TOK_SEP)
#endif #endif
Putchar(global, c); fpp_Putchar(global, c);
return(FPP_OK); return(FPP_OK);
} }
void Putchar(struct Global *global, int c) void fpp_Putchar(struct Global *global, int c)
{ {
/* /*
* Output one character to stdout or to output function! * Output one character to stdout or to fpp_output function!
*/ */
if(!global->out) if(!global->out)
return; return;
@ -533,20 +537,20 @@ void Putchar(struct Global *global, int c)
#endif #endif
} }
void Putstring(struct Global *global, char *string) void fpp_Putstring(struct Global *global, char *string)
{ {
/* /*
* Output a string! One letter at a time to the Putchar routine! * Output a string! One letter at a time to the fpp_Putchar routine!
*/ */
if(!string) if(!string)
return; return;
while(*string) while(*string)
Putchar(global, *string++); fpp_Putchar(global, *string++);
} }
void Putint(struct Global *global, int number) void fpp_Putint(struct Global *global, int number)
{ {
/* /*
* Output the number as a string. * Output the number as a string.
@ -558,12 +562,12 @@ void Putint(struct Global *global, int number)
sprintf(buffer, "%d", number); sprintf(buffer, "%d", number);
while(*point) while(*point)
Putchar(global, *point++); fpp_Putchar(global, *point++);
} }
FILE_LOCAL FILE_LOCAL
void sharp(struct Global *global) void fpp_sharp(struct Global *global)
{ {
/* /*
* Output a line number line. * Output a line number line.
@ -571,14 +575,14 @@ void sharp(struct Global *global)
char *name; char *name;
if (global->keepcomments) /* Make sure # comes on */ if (global->keepcomments) /* Make sure # comes on */
Putchar(global, '\n'); /* a fresh, new line. */ fpp_Putchar(global, '\n'); /* a fresh, new line. */
/* printf("#%s %d", LINE_PREFIX, global->line); */ /* printf("#%s %d", LINE_PREFIX, global->line); */
Putchar(global, '#'); fpp_Putchar(global, '#');
if(global->outputLINE) if(global->outputLINE)
Putstring(global, LINE_PREFIX); fpp_Putstring(global, LINE_PREFIX);
Putchar(global, ' '); fpp_Putchar(global, ' ');
Putint(global, global->line); fpp_Putint(global, global->line);
if (global->infile->fp != NULL) { if (global->infile->fp != NULL) {
name = (global->infile->progname != NULL) name = (global->infile->progname != NULL)
@ -587,14 +591,14 @@ void sharp(struct Global *global)
|| (global->sharpfilename != NULL && !streq(name, global->sharpfilename))) { || (global->sharpfilename != NULL && !streq(name, global->sharpfilename))) {
if (global->sharpfilename != NULL) if (global->sharpfilename != NULL)
free(global->sharpfilename); free(global->sharpfilename);
global->sharpfilename = savestring(global, name); global->sharpfilename = fpp_savestring(global, name);
/* printf(" \"%s\"", name); */ /* printf(" \"%s\"", name); */
Putstring(global, " \""); fpp_Putstring(global, " \"");
Putstring(global, name); fpp_Putstring(global, name);
Putchar(global, '\"'); fpp_Putchar(global, '\"');
} }
} }
Putchar(global, '\n'); fpp_Putchar(global, '\n');
global->wrongline = FALSE; global->wrongline = FPP_FALSE;
return; return;
} }

212
3rdparty/fcpp/cpp2.c поставляемый
Просмотреть файл

@ -28,10 +28,10 @@ SOFTWARE.
#include <proto/dos.h> #include <proto/dos.h>
#endif #endif
FILE_LOCAL void dump_line(struct Global *, int *); FILE_LOCAL void fpp_dump_line(struct Global *, int *);
FILE_LOCAL ReturnCode doif(struct Global *, int); FILE_LOCAL ReturnCode fpp_doif(struct Global *, int);
INLINE FILE_LOCAL ReturnCode doinclude(struct Global *); INLINE FILE_LOCAL ReturnCode fpp_doinclude(struct Global *);
INLINE FILE_LOCAL int hasdirectory(char *, char *); INLINE FILE_LOCAL int fpp_hasdirectory(char *, char *);
/* /*
@ -55,7 +55,7 @@ INLINE FILE_LOCAL int hasdirectory(char *, char *);
#define L_pragma ('p' + ('a' << 1)) #define L_pragma ('p' + ('a' << 1))
#define L_undef ('u' + ('d' << 1)) #define L_undef ('u' + ('d' << 1))
ReturnCode control( struct Global *global, ReturnCode fpp_control( struct Global *global,
int *counter ) /* Pending newline counter */ int *counter ) /* Pending newline counter */
{ {
/* /*
@ -73,7 +73,7 @@ ReturnCode control( struct Global *global,
char *ep; char *ep;
ReturnCode ret; ReturnCode ret;
c = skipws( global ); c = fpp_skipws( global );
if( c == '\n' || c == EOF_CHAR ) if( c == '\n' || c == EOF_CHAR )
{ {
@ -83,10 +83,10 @@ ReturnCode control( struct Global *global,
} }
if( !isdigit(c) ) if( !isdigit(c) )
scanid( global, c ); /* Get #word to tokenbuf */ fpp_scanid( global, c ); /* Get #word to tokenbuf */
else else
{ {
unget( global ); /* Hack -- allow #123 as a */ fpp_unget( global ); /* Hack -- allow #123 as a */
strcpy( global->tokenbuf, "line" ); /* synonym for #line 123 */ strcpy( global->tokenbuf, "line" ); /* synonym for #line 123 */
} }
@ -149,7 +149,7 @@ ReturnCode control( struct Global *global,
* control keyword (or L_nogood if we think it's nonsense). * control keyword (or L_nogood if we think it's nonsense).
*/ */
if( global->infile->fp == NULL ) if( global->infile->fp == NULL )
cwarn( global, WARN_CONTROL_LINE_IN_MACRO, global->tokenbuf ); fpp_cwarn( global, WARN_CONTROL_LINE_IN_MACRO, global->tokenbuf );
if( !compiling ) if( !compiling )
{ /* Not compiling now */ { /* Not compiling now */
@ -160,7 +160,7 @@ ReturnCode control( struct Global *global,
case L_ifndef: /* we must nest #if's */ case L_ifndef: /* we must nest #if's */
if( ++global->ifptr >= &global->ifstack[BLK_NEST] ) if( ++global->ifptr >= &global->ifstack[BLK_NEST] )
{ {
cfatal( global, FATAL_TOO_MANY_NESTINGS, global->tokenbuf ); fpp_cfatal( global, FATAL_TOO_MANY_NESTINGS, global->tokenbuf );
return( FPP_TOO_MANY_NESTED_STATEMENTS ); return( FPP_TOO_MANY_NESTED_STATEMENTS );
} }
@ -177,7 +177,7 @@ ReturnCode control( struct Global *global,
case L_undef: /* aren't */ case L_undef: /* aren't */
case L_assert: /* compiling. */ case L_assert: /* compiling. */
case L_error: case L_error:
dump_line( global, counter ); /* Ignore rest of line */ fpp_dump_line( global, counter ); /* Ignore rest of line */
return(FPP_OK); return(FPP_OK);
} }
} }
@ -186,7 +186,7 @@ ReturnCode control( struct Global *global,
*/ */
if( *counter > 0 && (hash == L_line || hash == L_pragma) ) if( *counter > 0 && (hash == L_line || hash == L_pragma) )
{ {
Putchar( global, '\n' ); fpp_Putchar( global, '\n' );
(*counter)--; (*counter)--;
} }
@ -199,21 +199,21 @@ ReturnCode control( struct Global *global,
* field and line number for the next input line. * field and line number for the next input line.
* Set wrongline to force it out later. * Set wrongline to force it out later.
*/ */
c = skipws( global ); c = fpp_skipws( global );
global->workp = global->work; /* Save name in work */ global->workp = global->work; /* Save name in work */
while( c != '\n' && c != EOF_CHAR ) while( c != '\n' && c != EOF_CHAR )
{ {
if( (ret = save( global, c )) ) if( (ret = fpp_save( global, c )) )
return(ret); return(ret);
c = get( global ); c = fpp_get( global );
} }
unget( global ); fpp_unget( global );
if( (ret = save( global, EOS )) ) if( (ret = fpp_save( global, EOS )) )
return(ret); return(ret);
/* /*
@ -240,42 +240,42 @@ ReturnCode control( struct Global *global,
/* Give up the old name if it's allocated. */ /* Give up the old name if it's allocated. */
free( global->infile->progname ); free( global->infile->progname );
global->infile->progname = savestring( global, tp ); global->infile->progname = fpp_savestring( global, tp );
} }
global->wrongline = TRUE; /* Force output later */ global->wrongline = FPP_TRUE; /* Force output later */
break; break;
case L_include: case L_include:
ret = doinclude( global ); ret = fpp_doinclude( global );
if( ret ) if( ret )
return(ret); return(ret);
break; break;
case L_define: case L_define:
ret = dodefine( global ); ret = fpp_dodefine( global );
if( ret ) if( ret )
return(ret); return(ret);
break; break;
case L_undef: case L_undef:
doundef( global ); fpp_doundef( global );
break; break;
case L_else: case L_else:
if( global->ifptr == &global->ifstack[0] ) if( global->ifptr == &global->ifstack[0] )
{ {
cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf ); fpp_cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
dump_line( global, counter ); fpp_dump_line( global, counter );
return( FPP_OK ); return( FPP_OK );
} }
else if( (*global->ifptr & ELSE_SEEN) != 0 ) else if( (*global->ifptr & ELSE_SEEN) != 0 )
{ {
cerror( global, ERROR_STRING_MAY_NOT_FOLLOW_ELSE, global->tokenbuf ); fpp_cerror( global, ERROR_STRING_MAY_NOT_FOLLOW_ELSE, global->tokenbuf );
dump_line( global, counter ); fpp_dump_line( global, counter );
return( FPP_OK ); return( FPP_OK );
} }
@ -284,11 +284,11 @@ ReturnCode control( struct Global *global,
if( (*global->ifptr & WAS_COMPILING) != 0 ) if( (*global->ifptr & WAS_COMPILING) != 0 )
{ {
if( compiling || (*global->ifptr & TRUE_SEEN) != 0 ) if( compiling || (*global->ifptr & FPP_TRUE_SEEN) != 0 )
compiling = FALSE; compiling = FPP_FALSE;
else else
{ {
compiling = TRUE; compiling = FPP_TRUE;
} }
} }
break; break;
@ -296,31 +296,31 @@ ReturnCode control( struct Global *global,
case L_elif: case L_elif:
if( global->ifptr == &global->ifstack[0] ) if( global->ifptr == &global->ifstack[0] )
{ {
cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf ); fpp_cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
dump_line( global, counter ); fpp_dump_line( global, counter );
return( FPP_OK ); return( FPP_OK );
} }
else if( (*global->ifptr & ELSE_SEEN) != 0 ) else if( (*global->ifptr & ELSE_SEEN) != 0 )
{ {
cerror( global, ERROR_STRING_MAY_NOT_FOLLOW_ELSE, global->tokenbuf ); fpp_cerror( global, ERROR_STRING_MAY_NOT_FOLLOW_ELSE, global->tokenbuf );
dump_line( global, counter ); fpp_dump_line( global, counter );
return( FPP_OK ); return( FPP_OK );
} }
if( (*global->ifptr & (WAS_COMPILING | TRUE_SEEN)) != WAS_COMPILING ) if( (*global->ifptr & (WAS_COMPILING | FPP_TRUE_SEEN)) != WAS_COMPILING )
{ {
compiling = FALSE; /* Done compiling stuff */ compiling = FPP_FALSE; /* Done compiling stuff */
dump_line( global, counter ); /* Skip this clause */ fpp_dump_line( global, counter ); /* Skip this clause */
return( FPP_OK ); return( FPP_OK );
} }
ret = doif( global, L_if ); ret = fpp_doif( global, L_if );
if( ret ) if( ret )
return(ret); return(ret);
@ -328,7 +328,7 @@ ReturnCode control( struct Global *global,
break; break;
case L_error: case L_error:
cerror(global, ERROR_ERROR); fpp_cerror(global, ERROR_ERROR);
break; break;
case L_if: case L_if:
@ -338,7 +338,7 @@ ReturnCode control( struct Global *global,
{ {
*global->ifptr = WAS_COMPILING; *global->ifptr = WAS_COMPILING;
ret = doif( global, hash ); ret = fpp_doif( global, hash );
if( ret ) if( ret )
return(ret); return(ret);
@ -346,22 +346,22 @@ ReturnCode control( struct Global *global,
break; break;
} }
cfatal( global, FATAL_TOO_MANY_NESTINGS, global->tokenbuf ); fpp_cfatal( global, FATAL_TOO_MANY_NESTINGS, global->tokenbuf );
return( FPP_TOO_MANY_NESTED_STATEMENTS ); return( FPP_TOO_MANY_NESTED_STATEMENTS );
case L_endif: case L_endif:
if( global->ifptr == &global->ifstack[0] ) if( global->ifptr == &global->ifstack[0] )
{ {
cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf ); fpp_cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
dump_line( global, counter ); fpp_dump_line( global, counter );
return(FPP_OK); return(FPP_OK);
} }
if( !compiling && (*global->ifptr & WAS_COMPILING) != 0 ) if( !compiling && (*global->ifptr & WAS_COMPILING) != 0 )
global->wrongline = TRUE; global->wrongline = FPP_TRUE;
compiling = ((*global->ifptr & WAS_COMPILING) != 0); compiling = ((*global->ifptr & WAS_COMPILING) != 0);
@ -373,13 +373,13 @@ ReturnCode control( struct Global *global,
{ {
int result; int result;
ret = eval( global, &result ); ret = fpp_eval( global, &result );
if(ret) if(ret)
return(ret); return(ret);
if( result == 0 ) if( result == 0 )
cerror( global, ERROR_PREPROC_FAILURE ); fpp_cerror( global, ERROR_PREPROC_FAILURE );
} }
break; break;
@ -388,14 +388,14 @@ ReturnCode control( struct Global *global,
* #pragma is provided to pass "options" to later * #pragma is provided to pass "options" to later
* passes of the compiler. cpp doesn't have any yet. * passes of the compiler. cpp doesn't have any yet.
*/ */
Putstring( global, "#pragma " ); fpp_Putstring( global, "#pragma " );
while( (c = get( global ) ) != '\n' && c != EOF_CHAR ) while( (c = fpp_get( global ) ) != '\n' && c != EOF_CHAR )
Putchar( global, c ); fpp_Putchar( global, c );
unget( global ); fpp_unget( global );
Putchar( global, '\n' ); fpp_Putchar( global, '\n' );
break; break;
@ -407,18 +407,18 @@ ReturnCode control( struct Global *global,
* This would allow #asm or similar extensions. * This would allow #asm or similar extensions.
*/ */
if( global->warnillegalcpp ) if( global->warnillegalcpp )
cwarn( global, WARN_ILLEGAL_COMMAND, global->tokenbuf ); fpp_cwarn( global, WARN_ILLEGAL_COMMAND, global->tokenbuf );
Putchar( global, '#' ); fpp_Putchar( global, '#' );
Putstring( global, global->tokenbuf ); fpp_Putstring( global, global->tokenbuf );
Putchar( global, ' ' ); fpp_Putchar( global, ' ' );
while( (c = get( global ) ) != '\n' && c != EOF_CHAR ) while( (c = fpp_get( global ) ) != '\n' && c != EOF_CHAR )
Putchar( global, c ); fpp_Putchar( global, c );
unget( global ); fpp_unget( global );
Putchar( global, '\n' ); fpp_Putchar( global, '\n' );
break; break;
} }
@ -431,15 +431,15 @@ ReturnCode control( struct Global *global,
* #if foo * #if foo
* #endif foo * #endif foo
*/ */
dump_line( global, counter ); /* Take common exit */ fpp_dump_line( global, counter ); /* Take common exit */
return( FPP_OK ); return( FPP_OK );
#else #else
if( skipws( global ) != '\n' ) if( fpp_skipws( global ) != '\n' )
{ {
cwarn( global, WARN_UNEXPECTED_TEXT_IGNORED ); fpp_cwarn( global, WARN_UNEXPECTED_TEXT_IGNORED );
skipnl( global ); fpp_skipnl( global );
} }
#endif #endif
} }
@ -450,21 +450,21 @@ ReturnCode control( struct Global *global,
} }
FILE_LOCAL FILE_LOCAL
void dump_line(struct Global *global, int *counter) void fpp_dump_line(struct Global *global, int *counter)
{ {
skipnl( global ); /* Ignore rest of line */ fpp_skipnl( global ); /* Ignore rest of line */
(*counter)++; (*counter)++;
} }
FILE_LOCAL FILE_LOCAL
ReturnCode doif(struct Global *global, int hash) ReturnCode fpp_doif(struct Global *global, int hash)
{ {
/* /*
* Process an #if, #ifdef, or #ifndef. The latter two are straightforward, * Process an #if, #ifdef, or #ifndef. The latter two are straightforward,
* while #if needs a subroutine of its own to evaluate the expression. * while #if needs a subroutine of its own to evaluate the expression.
* *
* doif() is called only if compiling is TRUE. If false, compilation * fpp_doif() is called only if compiling is FPP_TRUE. If false, compilation
* is always supressed, so we don't need to evaluate anything. This * is always supressed, so we don't need to evaluate anything. This
* supresses unnecessary warnings. * supresses unnecessary warnings.
*/ */
@ -473,16 +473,16 @@ ReturnCode doif(struct Global *global, int hash)
int found; int found;
ReturnCode ret; ReturnCode ret;
if( (c = skipws( global ) ) == '\n' || c == EOF_CHAR ) if( (c = fpp_skipws( global ) ) == '\n' || c == EOF_CHAR )
{ {
unget( global ); fpp_unget( global );
cerror( global, ERROR_MISSING_ARGUMENT ); fpp_cerror( global, ERROR_MISSING_ARGUMENT );
#if !OLD_PREPROCESSOR #if !OLD_PREPROCESSOR
skipnl( global ); /* Prevent an extra */ fpp_skipnl( global ); /* Prevent an extra */
unget( global ); /* Error message */ fpp_unget( global ); /* Error message */
#endif #endif
return(FPP_OK); return(FPP_OK);
@ -490,14 +490,14 @@ ReturnCode doif(struct Global *global, int hash)
if( hash == L_if ) if( hash == L_if )
{ {
unget( global ); fpp_unget( global );
ret = eval( global, &found ); ret = fpp_eval( global, &found );
if( ret ) if( ret )
return( ret ); return( ret );
found = (found != 0); /* Evaluate expr, != 0 is TRUE */ found = (found != 0); /* Evaluate expr, != 0 is FPP_TRUE */
hash = L_ifdef; /* #if is now like #ifdef */ hash = L_ifdef; /* #if is now like #ifdef */
} }
@ -506,34 +506,34 @@ ReturnCode doif(struct Global *global, int hash)
if( type[c] != LET ) if( type[c] != LET )
{ /* Next non-blank isn't letter */ { /* Next non-blank isn't letter */
/* ... is an error */ /* ... is an error */
cerror( global, ERROR_MISSING_ARGUMENT ); fpp_cerror( global, ERROR_MISSING_ARGUMENT );
#if !OLD_PREPROCESSOR #if !OLD_PREPROCESSOR
skipnl( global ); /* Prevent an extra */ fpp_skipnl( global ); /* Prevent an extra */
unget( global ); /* Error message */ fpp_unget( global ); /* Error message */
#endif #endif
return(FPP_OK); return(FPP_OK);
} }
found = ( lookid( global, c ) != NULL ); /* Look for it in symbol table */ found = ( fpp_lookid( global, c ) != NULL ); /* Look for it in symbol table */
} }
if( found == (hash == L_ifdef) ) if( found == (hash == L_ifdef) )
{ {
compiling = TRUE; compiling = FPP_TRUE;
*global->ifptr |= TRUE_SEEN; *global->ifptr |= FPP_TRUE_SEEN;
} }
else else
compiling = FALSE; compiling = FPP_FALSE;
return(FPP_OK); return(FPP_OK);
} }
INLINE FILE_LOCAL INLINE FILE_LOCAL
ReturnCode doinclude( struct Global *global ) ReturnCode fpp_doinclude( struct Global *global )
{ {
/* /*
* Process the #include control line. * Process the #include control line.
@ -557,14 +557,14 @@ ReturnCode doinclude( struct Global *global )
int delim; int delim;
ReturnCode ret; ReturnCode ret;
delim = skipws( global ); delim = fpp_skipws( global );
if( (ret = macroid( global, &delim )) ) if( (ret = fpp_macroid( global, &delim )) )
return(ret); return(ret);
if( delim != '<' && delim != '"' ) if( delim != '<' && delim != '"' )
{ {
cerror( global, ERROR_INCLUDE_SYNTAX ); fpp_cerror( global, ERROR_INCLUDE_SYNTAX );
return( FPP_OK ); return( FPP_OK );
} }
@ -574,11 +574,11 @@ ReturnCode doinclude( struct Global *global )
global->workp = global->work; global->workp = global->work;
while( (c = get(global)) != '\n' && c != EOF_CHAR ) while( (c = fpp_get(global)) != '\n' && c != EOF_CHAR )
if( (ret = save( global, c )) ) /* Put it away. */ if( (ret = fpp_save( global, c )) ) /* Put it away. */
return( ret ); return( ret );
unget( global ); /* Force nl after include */ fpp_unget( global ); /* Force nl after include */
/* /*
* The draft is unclear if the following should be done. * The draft is unclear if the following should be done.
@ -589,21 +589,21 @@ ReturnCode doinclude( struct Global *global )
if( *global->workp != delim ) if( *global->workp != delim )
{ {
cerror( global, ERROR_INCLUDE_SYNTAX ); fpp_cerror( global, ERROR_INCLUDE_SYNTAX );
return(FPP_OK); return(FPP_OK);
} }
*global->workp = EOS; /* Terminate filename */ *global->workp = EOS; /* Terminate filename */
ret = openinclude( global, global->work, (delim == '"') ); ret = fpp_openinclude( global, global->work, (delim == '"') );
if( ret && global->warnnoinclude ) if( ret && global->warnnoinclude )
{ {
/* /*
* Warn if #include file isn't there. * Warn if #include file isn't there.
*/ */
cwarn( global, WARN_CANNOT_OPEN_INCLUDE, global->work ); fpp_cwarn( global, WARN_CANNOT_OPEN_INCLUDE, global->work );
} }
return( FPP_OK ); return( FPP_OK );
@ -613,13 +613,13 @@ ReturnCode doinclude( struct Global *global )
ReturnCode MultiAssignLoad( struct Global *global, char *incptr, char *filename, char *tmpname ); ReturnCode MultiAssignLoad( struct Global *global, char *incptr, char *filename, char *tmpname );
#endif #endif
ReturnCode openinclude( struct Global *global, ReturnCode fpp_openinclude( struct Global *global,
char *filename, /* Input file name */ char *filename, /* Input file name */
int searchlocal ) /* TRUE if #include "file" */ int searchlocal ) /* FPP_TRUE if #include "file" */
{ {
/* /*
* Actually open an include file. This routine is only called from * Actually open an include file. This routine is only called from
* doinclude() above, but was written as a separate subroutine for * fpp_doinclude() above, but was written as a separate subroutine for
* programmer convenience. It searches the list of directories * programmer convenience. It searches the list of directories
* and actually opens the file, linking it into the list of * and actually opens the file, linking it into the list of
* active files. Returns ReturnCode. No error message is printed. * active files. Returns ReturnCode. No error message is printed.
@ -631,11 +631,11 @@ ReturnCode openinclude( struct Global *global,
if( filename[0] == '/' ) if( filename[0] == '/' )
{ {
if( ! openfile( global, filename ) ) if( ! fpp_openfile( global, filename ) )
return(FPP_OK); return(FPP_OK);
} }
if( searchlocal ) if( searchlocal && global->allowincludelocal )
{ {
/* /*
* Look in local directory first. * Look in local directory first.
@ -645,12 +645,12 @@ ReturnCode openinclude( struct Global *global,
* discarding the last pathname component of the source file * discarding the last pathname component of the source file
* name then tacking on the #include argument. * name then tacking on the #include argument.
*/ */
if( hasdirectory( global->infile->filename, tmpname ) ) if( fpp_hasdirectory( global->infile->filename, tmpname ) )
strcat( tmpname, filename ); strcat( tmpname, filename );
else else
strcpy( tmpname, filename ); strcpy( tmpname, filename );
if( ! openfile( global, tmpname ) ) if( ! fpp_openfile( global, tmpname ) )
return(FPP_OK); return(FPP_OK);
} }
@ -664,7 +664,7 @@ ReturnCode openinclude( struct Global *global,
if( len + strlen(filename) >= sizeof(tmpname) ) if( len + strlen(filename) >= sizeof(tmpname) )
{ {
cfatal( global, FATAL_FILENAME_BUFFER_OVERFLOW ); fpp_cfatal( global, FATAL_FILENAME_BUFFER_OVERFLOW );
return( FPP_FILENAME_BUFFER_OVERFLOW ); return( FPP_FILENAME_BUFFER_OVERFLOW );
} }
@ -675,7 +675,7 @@ ReturnCode openinclude( struct Global *global,
else else
sprintf( tmpname, "%s%s", *incptr, filename ); sprintf( tmpname, "%s%s", *incptr, filename );
if( !openfile( global, tmpname ) ) if( !fpp_openfile( global, tmpname ) )
return(FPP_OK); return(FPP_OK);
} }
} }
@ -684,25 +684,25 @@ ReturnCode openinclude( struct Global *global,
} }
INLINE FILE_LOCAL INLINE FILE_LOCAL
int hasdirectory( char *source, /* Directory to examine */ int fpp_hasdirectory( char *source, /* Directory to examine */
char *result ) /* Put directory stuff here */ char *result ) /* Put directory stuff here */
{ {
/* /*
* If a device or directory is found in the source filename string, the * If a device or directory is found in the source filename string, the
* node/device/directory part of the string is copied to result and * node/device/directory part of the string is copied to result and
* hasdirectory returns TRUE. Else, nothing is copied and it returns FALSE. * fpp_hasdirectory returns FPP_TRUE. Else, nothing is copied and it returns FPP_FALSE.
*/ */
char *tp2; char *tp2;
if( (tp2 = strrchr( source, '/' ) ) == NULL ) if( (tp2 = strrchr( source, '/' ) ) == NULL )
return(FALSE); return(FPP_FALSE);
strncpy( result, source, tp2 - source + 1 ); strncpy( result, source, tp2 - source + 1 );
result[tp2 - source + 1] = EOS; result[tp2 - source + 1] = EOS;
return( TRUE ); return( FPP_TRUE );
} }
#ifdef _AMIGA #ifdef _AMIGA
@ -742,7 +742,7 @@ ReturnCode MultiAssignLoad( struct Global *global, char *incptr, char *filename,
// Normally we would pass the lock and filename // Normally we would pass the lock and filename
// to the Load() routine, which would CD to the // to the Load() routine, which would CD to the
// directory and Open(filename), but in order to // directory and Open(filename), but in order to
// satisfy the exisiting openfile() function, we // satisfy the exisiting fpp_openfile() function, we
// bite the bullet and build the complete pathspec // bite the bullet and build the complete pathspec
// rather than add the standard Load() routine. // rather than add the standard Load() routine.
// //
@ -750,7 +750,7 @@ ReturnCode MultiAssignLoad( struct Global *global, char *incptr, char *filename,
{ {
AddPart( tmpname, filename, NWORK ); AddPart( tmpname, filename, NWORK );
RtnCode = openfile( global, tmpname ); RtnCode = fpp_openfile( global, tmpname );
if( ! RtnCode ) if( ! RtnCode )
break; break;

97
3rdparty/fcpp/cpp3.c поставляемый
Просмотреть файл

@ -25,20 +25,25 @@ SOFTWARE.
#include "cppdef.h" #include "cppdef.h"
#include "cpp.h" #include "cpp.h"
ReturnCode openfile(struct Global *global, char *filename) ReturnCode fpp_openfile(struct Global *global, char *filename)
{ {
/* /*
* Open a file, add it to the linked list of open files. * Open a file, add it to the linked list of open files.
* This is called only from openfile() in cpp2.c. * This is called only from fpp_openfile() in cpp2.c.
*/ */
FILE *fp; FILE *fp;
ReturnCode ret; ReturnCode ret;
if ((fp = fopen(filename, "r")) == NULL) if (global->openfile)
fp = global->openfile(filename, "r", global->userdata);
else
fp = fopen(filename, "r");
if (fp == NULL)
ret=FPP_OPEN_ERROR; ret=FPP_OPEN_ERROR;
else else
ret=addfile(global, fp, filename); ret=fpp_addfile(global, fp, filename);
if(!ret && global->depends) { if(!ret && global->depends) {
global->depends(filename, global->userdata); global->depends(filename, global->userdata);
@ -46,51 +51,51 @@ ReturnCode openfile(struct Global *global, char *filename)
if(!ret && global->showincluded) { if(!ret && global->showincluded) {
/* no error occured! */ /* no error occured! */
Error(global, "cpp: included \""); fpp_Error(global, "cpp: included \"");
Error(global, filename); fpp_Error(global, filename);
Error(global, "\"\n"); fpp_Error(global, "\"\n");
} }
return(ret); return(ret);
} }
ReturnCode addfile(struct Global *global, ReturnCode fpp_addfile(struct Global *global,
FILE *fp, /* Open file pointer */ FILE *fp, /* Open file pointer */
char *filename) /* Name of the file */ char *filename) /* Name of the file */
{ {
/* /*
* Initialize tables for this open file. This is called from openfile() * Initialize tables for this open file. This is called from fpp_openfile()
* above (for #include files), and from the entry to cpp to open the main * above (for #include files), and from the entry to cpp to open the main
* input file. It calls a common routine, getfile() to build the FILEINFO * input file. It calls a common routine, fpp_getfile() to build the FILEINFO
* structure which is used to read characters. (getfile() is also called * structure which is used to read characters. (fpp_getfile() is also called
* to setup a macro replacement.) * to setup a macro replacement.)
*/ */
FILEINFO *file; FILEINFO *file;
ReturnCode ret; ReturnCode ret;
ret = getfile(global, NBUFF, filename, &file); ret = fpp_getfile(global, NBUFF, filename, &file);
if(ret) if(ret)
return(ret); return(ret);
file->fp = fp; /* Better remember FILE * */ file->fp = fp; /* Better remember FILE * */
file->buffer[0] = EOS; /* Initialize for first read */ file->buffer[0] = EOS; /* Initialize for first read */
global->line = 1; /* Working on line 1 now */ global->line = 1; /* Working on line 1 now */
global->wrongline = TRUE; /* Force out initial #line */ global->wrongline = FPP_TRUE; /* Force out initial #line */
return(FPP_OK); return(FPP_OK);
} }
int dooptions(struct Global *global, struct fppTag *tags) int fpp_dooptions(struct Global *global, struct fppTag *tags)
{ {
/* /*
* dooptions is called to process command line arguments (-Detc). * fpp_dooptions is called to process command line arguments (-Detc).
* It is called only at cpp startup. * It is called only at cpp startup.
*/ */
DEFBUF *dp; DEFBUF *dp;
char end=FALSE; /* end of taglist */ char end=FPP_FALSE; /* end of taglist */
while(tags && !end) { while(tags && !end) {
switch(tags->tag) { switch(tags->tag) {
case FPPTAG_END: case FPPTAG_END:
end=TRUE; end=FPP_TRUE;
break; break;
case FPPTAG_INITFUNC: case FPPTAG_INITFUNC:
global->initialfunc = (char *) tags->data; global->initialfunc = (char *) tags->data;
@ -122,7 +127,7 @@ int dooptions(struct Global *global, struct fppTag *tags)
case FPPTAG_OUTPUTINCLUDES: case FPPTAG_OUTPUTINCLUDES:
global->showincluded = tags->data?1:0; global->showincluded = tags->data?1:0;
break; break;
case FPPTAG_IGNOREVERSION: case FPPTAG_SHOWVERSION:
global->showversion = tags->data?1:0; global->showversion = tags->data?1:0;
break; break;
case FPPTAG_WARNILLEGALCPP: case FPPTAG_WARNILLEGALCPP:
@ -133,8 +138,8 @@ int dooptions(struct Global *global, struct fppTag *tags)
break; break;
case FPPTAG_KEEPCOMMENTS: case FPPTAG_KEEPCOMMENTS:
if(tags->data) { if(tags->data) {
global->cflag = TRUE; global->cflag = FPP_TRUE;
global->keepcomments = TRUE; global->keepcomments = FPP_TRUE;
} }
break; break;
case FPPTAG_DEFINE: case FPPTAG_DEFINE:
@ -153,19 +158,19 @@ int dooptions(struct Global *global, struct fppTag *tags)
/* /*
* Now, save the word and its definition. * Now, save the word and its definition.
*/ */
dp = defendel(global, symbol, FALSE); dp = fpp_defendel(global, symbol, FPP_FALSE);
if(!dp) if(!dp)
return(FPP_OUT_OF_MEMORY); return(FPP_OUT_OF_MEMORY);
dp->repl = savestring(global, text); dp->repl = fpp_savestring(global, text);
dp->nargs = DEF_NOARGS; dp->nargs = DEF_NOARGS;
} }
break; break;
case FPPTAG_IGNORE_NONFATAL: case FPPTAG_IGNORE_NONFATAL:
global->eflag = TRUE; global->eflag = FPP_TRUE;
break; break;
case FPPTAG_INCLUDE_DIR: case FPPTAG_INCLUDE_DIR:
if (global->incend >= &global->incdir[NINCLUDE]) { if (global->incend >= &global->incdir[NINCLUDE]) {
cfatal(global, FATAL_TOO_MANY_INCLUDE_DIRS); fpp_cfatal(global, FATAL_TOO_MANY_INCLUDE_DIRS);
return(FPP_TOO_MANY_INCLUDE_DIRS); return(FPP_TOO_MANY_INCLUDE_DIRS);
} }
*global->incend++ = (char *)tags->data; *global->incend++ = (char *)tags->data;
@ -173,7 +178,7 @@ int dooptions(struct Global *global, struct fppTag *tags)
case FPPTAG_INCLUDE_FILE: case FPPTAG_INCLUDE_FILE:
case FPPTAG_INCLUDE_MACRO_FILE: case FPPTAG_INCLUDE_MACRO_FILE:
if (global->included >= NINCLUDE) { if (global->included >= NINCLUDE) {
cfatal(global, FATAL_TOO_MANY_INCLUDE_FILES); fpp_cfatal(global, FATAL_TOO_MANY_INCLUDE_FILES);
return(FPP_TOO_MANY_INCLUDE_FILES); return(FPP_TOO_MANY_INCLUDE_FILES);
} }
global->include[(unsigned)global->included] = (char *)tags->data; global->include[(unsigned)global->included] = (char *)tags->data;
@ -196,7 +201,7 @@ int dooptions(struct Global *global, struct fppTag *tags)
{ {
SIZES *sizp; /* For -S */ SIZES *sizp; /* For -S */
int size; /* For -S */ int size; /* For -S */
int isdatum; /* FALSE for -S* */ int isdatum; /* FPP_FALSE for -S* */
int endtest; /* For -S */ int endtest; /* For -S */
char *text=(char *)tags->data; char *text=(char *)tags->data;
@ -225,14 +230,14 @@ int dooptions(struct Global *global, struct fppTag *tags)
sizp++; sizp++;
} }
if (sizp->bits != endtest) if (sizp->bits != endtest)
cwarn(global, WARN_TOO_FEW_VALUES_TO_SIZEOF, NULL); fpp_cwarn(global, WARN_TOO_FEW_VALUES_TO_SIZEOF, NULL);
else if (*text != EOS) else if (*text != EOS)
cwarn(global, WARN_TOO_MANY_VALUES_TO_SIZEOF, NULL); fpp_cwarn(global, WARN_TOO_MANY_VALUES_TO_SIZEOF, NULL);
} }
break; break;
case FPPTAG_UNDEFINE: case FPPTAG_UNDEFINE:
if (defendel(global, (char *)tags->data, TRUE) == NULL) if (fpp_defendel(global, (char *)tags->data, FPP_TRUE) == NULL)
cwarn(global, WARN_NOT_DEFINED, tags->data); fpp_cwarn(global, WARN_NOT_DEFINED, tags->data);
break; break;
case FPPTAG_OUTPUT_DEFINES: case FPPTAG_OUTPUT_DEFINES:
global->wflag++; global->wflag++;
@ -265,8 +270,14 @@ int dooptions(struct Global *global, struct fppTag *tags)
case FPPTAG_WEBMODE: case FPPTAG_WEBMODE:
global->webmode=(tags->data?1:0); global->webmode=(tags->data?1:0);
break; break;
case FPPTAG_ALLOW_INCLUDE_LOCAL:
global->allowincludelocal=(tags->data?1:0);
break;
case FPPTAG_FILEOPENFUNC:
// global->openfile = (FILE* (*)(char *,char *))tags->data;
break;
default: default:
cwarn(global, WARN_INTERNAL_ERROR, NULL); fpp_cwarn(global, WARN_INTERNAL_ERROR, NULL);
break; break;
} }
tags++; tags++;
@ -274,7 +285,7 @@ int dooptions(struct Global *global, struct fppTag *tags)
return(0); return(0);
} }
ReturnCode initdefines(struct Global *global) ReturnCode fpp_initdefines(struct Global *global)
{ {
/* /*
* Initialize the built-in #define's. There are two flavors: * Initialize the built-in #define's. There are two flavors:
@ -307,23 +318,23 @@ ReturnCode initdefines(struct Global *global)
if (!(global->nflag & NFLAG_BUILTIN)) { if (!(global->nflag & NFLAG_BUILTIN)) {
for (pp = global->preset; *pp != NULL; pp++) { for (pp = global->preset; *pp != NULL; pp++) {
if (*pp[0] != EOS) { if (*pp[0] != EOS) {
dp = defendel(global, *pp, FALSE); dp = fpp_defendel(global, *pp, FPP_FALSE);
if(!dp) if(!dp)
return(FPP_OUT_OF_MEMORY); return(FPP_OUT_OF_MEMORY);
dp->repl = savestring(global, "1"); dp->repl = fpp_savestring(global, "1");
dp->nargs = DEF_NOARGS; dp->nargs = DEF_NOARGS;
} }
} }
} }
/* /*
* The magic pre-defines (__FILE__ and __LINE__ are * The magic pre-defines (__FILE__ and __LINE__ are
* initialized with negative argument counts. expand() * initialized with negative argument counts. fpp_expand()
* notices this and calls the appropriate routine. * notices this and calls the appropriate routine.
* DEF_NOARGS is one greater than the first "magic" definition. * DEF_NOARGS is one greater than the first "magic" definition.
*/ */
if (!(global->nflag & NFLAG_PREDEFINE)) { if (!(global->nflag & NFLAG_PREDEFINE)) {
for (pp = global->magic, i = DEF_NOARGS; *pp != NULL; pp++) { for (pp = global->magic, i = DEF_NOARGS; *pp != NULL; pp++) {
dp = defendel(global, *pp, FALSE); dp = fpp_defendel(global, *pp, FPP_FALSE);
if(!dp) if(!dp)
return(FPP_OUT_OF_MEMORY); return(FPP_OUT_OF_MEMORY);
dp->nargs = --i; dp->nargs = --i;
@ -332,7 +343,7 @@ ReturnCode initdefines(struct Global *global)
/* /*
* Define __DATE__ as today's date. * Define __DATE__ as today's date.
*/ */
dp = defendel(global, "__DATE__", FALSE); dp = fpp_defendel(global, "__DATE__", FPP_FALSE);
tp = malloc(14); tp = malloc(14);
if(!tp || !dp) if(!tp || !dp)
return(FPP_OUT_OF_MEMORY); return(FPP_OUT_OF_MEMORY);
@ -348,7 +359,7 @@ ReturnCode initdefines(struct Global *global)
/* /*
* Define __TIME__ as this moment's time. * Define __TIME__ as this moment's time.
*/ */
dp = defendel(global, "__TIME__", FALSE); dp = fpp_defendel(global, "__TIME__", FPP_FALSE);
tp = malloc(11); tp = malloc(11);
if(!tp || !dp) if(!tp || !dp)
return(FPP_OUT_OF_MEMORY); return(FPP_OUT_OF_MEMORY);
@ -363,7 +374,7 @@ ReturnCode initdefines(struct Global *global)
return(FPP_OK); return(FPP_OK);
} }
void delbuiltindefines(struct Global *global) void fpp_delbuiltindefines(struct Global *global)
{ {
/* /*
* Delete the built-in #define's. * Delete the built-in #define's.
@ -376,25 +387,25 @@ void delbuiltindefines(struct Global *global)
*/ */
if (global->wflag < 2) { if (global->wflag < 2) {
for (pp = global->preset; *pp != NULL; pp++) { for (pp = global->preset; *pp != NULL; pp++) {
defendel(global, *pp, TRUE); fpp_defendel(global, *pp, FPP_TRUE);
} }
} }
/* /*
* The magic pre-defines __FILE__ and __LINE__ * The magic pre-defines __FILE__ and __LINE__
*/ */
for (pp = global->magic; *pp != NULL; pp++) { for (pp = global->magic; *pp != NULL; pp++) {
defendel(global, *pp, TRUE); fpp_defendel(global, *pp, FPP_TRUE);
} }
#if OK_DATE #if OK_DATE
/* /*
* Undefine __DATE__. * Undefine __DATE__.
*/ */
defendel(global, "__DATE__", TRUE); fpp_defendel(global, "__DATE__", FPP_TRUE);
/* /*
* Undefine __TIME__. * Undefine __TIME__.
*/ */
defendel(global, "__TIME__", TRUE); fpp_defendel(global, "__TIME__", FPP_TRUE);
#endif #endif
return; return;
} }

214
3rdparty/fcpp/cpp4.c поставляемый
Просмотреть файл

@ -24,15 +24,15 @@ SOFTWARE.
#include "cppdef.h" #include "cppdef.h"
#include "cpp.h" #include "cpp.h"
INLINE FILE_LOCAL ReturnCode checkparm(struct Global *, int, DEFBUF *, int); INLINE FILE_LOCAL ReturnCode fpp_checkparm(struct Global *, int, DEFBUF *, int);
INLINE FILE_LOCAL ReturnCode stparmscan(struct Global *, int); INLINE FILE_LOCAL ReturnCode fpp_stparmscan(struct Global *, int);
INLINE FILE_LOCAL ReturnCode textput(struct Global *, char *); INLINE FILE_LOCAL ReturnCode fpp_textput(struct Global *, char *);
FILE_LOCAL ReturnCode charput(struct Global *, int); FILE_LOCAL ReturnCode fpp_charput(struct Global *, int);
INLINE FILE_LOCAL ReturnCode expcollect(struct Global *); INLINE FILE_LOCAL ReturnCode fpp_expcollect(struct Global *);
INLINE FILE_LOCAL char *doquoting(char *, char *); INLINE FILE_LOCAL char *fpp_doquoting(char *, char *);
ReturnCode dodefine(struct Global *global) ReturnCode fpp_dodefine(struct Global *global)
{ {
/* /*
* Called from control when a #define is scanned. This module * Called from control when a #define is scanned. This module
@ -61,63 +61,63 @@ ReturnCode dodefine(struct Global *global)
* is not. * is not.
* *
* The following subroutines are called from define(): * The following subroutines are called from define():
* checkparm called when a token is scanned. It checks through the * fpp_checkparm called when a token is scanned. It checks through the
* array of formal parameters. If a match is found, the * array of formal parameters. If a match is found, the
* token is replaced by a control byte which will be used * token is replaced by a control byte which will be used
* to locate the parameter when the macro is expanded. * to locate the parameter when the macro is expanded.
* textput puts a string in the macro work area (parm[]), updating * fpp_textput puts a string in the macro work area (parm[]), updating
* parmp to point to the first free byte in parm[]. * parmp to point to the first free byte in parm[].
* textput() tests for work buffer overflow. * fpp_textput() tests for work buffer overflow.
* charput puts a single character in the macro work area (parm[]) * fpp_charput puts a single character in the macro work area (parm[])
* in a manner analogous to textput(). * in a manner analogous to fpp_textput().
*/ */
int c; int c;
DEFBUF *dp; /* -> new definition */ DEFBUF *dp; /* -> new definition */
int isredefine; /* TRUE if redefined */ int isredefine; /* FPP_TRUE if redefined */
char *old = NULL; /* Remember redefined */ char *old = NULL; /* Remember redefined */
ReturnCode ret; ReturnCode ret;
#if OK_CONCAT #if OK_CONCAT
int quoting; /* Remember we saw a # */ int quoting; /* Remember we saw a # */
#endif #endif
if (type[(c = skipws(global))] != LET) { if (type[(c = fpp_skipws(global))] != LET) {
cerror(global, ERROR_DEFINE_SYNTAX); fpp_cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FALSE; /* Stop <newline> hack */ global->inmacro = FPP_FALSE; /* Stop <newline> hack */
return(FPP_OK); return(FPP_OK);
} }
isredefine = FALSE; /* Set if redefining */ isredefine = FPP_FALSE; /* Set if redefining */
if ((dp = lookid(global, c)) == NULL) { /* If not known now */ if ((dp = fpp_lookid(global, c)) == NULL) { /* If not known now */
dp = defendel(global, global->tokenbuf, FALSE); /* Save the name */ dp = fpp_defendel(global, global->tokenbuf, FPP_FALSE); /* Save the name */
if(!dp) if(!dp)
return(FPP_OUT_OF_MEMORY); return(FPP_OUT_OF_MEMORY);
} else { /* It's known: */ } else { /* It's known: */
isredefine = TRUE; /* Remember this fact */ isredefine = FPP_TRUE; /* Remember this fact */
old = dp->repl; /* Remember replacement */ old = dp->repl; /* Remember replacement */
dp->repl = NULL; /* No replacement now */ dp->repl = NULL; /* No replacement now */
} }
global->parlist[0] = global->parmp = global->parm; /* Setup parm buffer */ global->parlist[0] = global->parmp = global->parm; /* Setup parm buffer */
if ((c = get(global)) == '(') { /* With arguments? */ if ((c = fpp_get(global)) == '(') { /* With arguments? */
global->nargs = 0; /* Init formals counter */ global->nargs = 0; /* Init formals counter */
do { /* Collect formal parms */ do { /* Collect formal parms */
if (global->nargs >= LASTPARM) { if (global->nargs >= LASTPARM) {
cfatal(global, FATAL_TOO_MANY_ARGUMENTS_MACRO); fpp_cfatal(global, FATAL_TOO_MANY_ARGUMENTS_MACRO);
return(FPP_TOO_MANY_ARGUMENTS); return(FPP_TOO_MANY_ARGUMENTS);
} else if ((c = skipws(global)) == ')') } else if ((c = fpp_skipws(global)) == ')')
break; /* Got them all */ break; /* Got them all */
else if (type[c] != LET) { /* Bad formal syntax */ else if (type[c] != LET) { /* Bad formal syntax */
cerror(global, ERROR_DEFINE_SYNTAX); fpp_cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FALSE; /* Stop <newline> hack */ global->inmacro = FPP_FALSE; /* Stop <newline> hack */
return(FPP_OK); return(FPP_OK);
} }
scanid(global, c); /* Get the formal param */ fpp_scanid(global, c); /* Get the formal param */
global->parlist[global->nargs++] = global->parmp; /* Save its start */ global->parlist[global->nargs++] = global->parmp; /* Save its start */
ret=textput(global, global->tokenbuf); /* Save text in parm[] */ ret=fpp_textput(global, global->tokenbuf); /* Save text in parm[] */
if(ret) if(ret)
return(ret); return(ret);
} while ((c = skipws(global)) == ','); /* Get another argument */ } while ((c = fpp_skipws(global)) == ','); /* Get another argument */
if (c != ')') { /* Must end at ) */ if (c != ')') { /* Must end at ) */
cerror(global, ERROR_DEFINE_SYNTAX); fpp_cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FALSE; /* Stop <newline> hack */ global->inmacro = FPP_FALSE; /* Stop <newline> hack */
return(FPP_OK); return(FPP_OK);
} }
c = ' '; /* Will skip to body */ c = ' '; /* Will skip to body */
@ -130,14 +130,14 @@ ReturnCode dodefine(struct Global *global)
global->nargs = DEF_NOARGS; /* No () parameters */ global->nargs = DEF_NOARGS; /* No () parameters */
} }
if (type[c] == SPA) /* At whitespace? */ if (type[c] == SPA) /* At whitespace? */
c = skipws(global); /* Not any more. */ c = fpp_skipws(global); /* Not any more. */
global->workp = global->work; /* Replacement put here */ global->workp = global->work; /* Replacement put here */
global->inmacro = TRUE; /* Keep \<newline> now */ global->inmacro = FPP_TRUE; /* Keep \<newline> now */
quoting = 0; /* No # seen yet. */ quoting = 0; /* No # seen yet. */
while (c != EOF_CHAR && c != '\n') { /* Compile macro body */ while (c != EOF_CHAR && c != '\n') { /* Compile macro body */
#if OK_CONCAT #if OK_CONCAT
if (c == '#') { /* Token concatenation? */ if (c == '#') { /* Token concatenation? */
if ((c = get(global)) != '#') { /* No, not really */ if ((c = fpp_get(global)) != '#') { /* No, not really */
quoting = 1; /* Maybe quoting op. */ quoting = 1; /* Maybe quoting op. */
continue; continue;
} }
@ -145,16 +145,16 @@ ReturnCode dodefine(struct Global *global)
--global->workp; /* Erase leading spaces */ --global->workp; /* Erase leading spaces */
// if ((ret=save(global, TOK_SEP))) /* Stuff a delimiter */ // if ((ret=save(global, TOK_SEP))) /* Stuff a delimiter */
// return(ret); // return(ret);
c = skipws(global); /* Eat whitespace */ c = fpp_skipws(global); /* Eat whitespace */
continue; continue;
} }
#endif #endif
switch (type[c]) { switch (type[c]) {
case LET: case LET:
#if OK_CONCAT #if OK_CONCAT
ret=checkparm(global, c, dp, quoting); /* Might be a formal */ ret=fpp_checkparm(global, c, dp, quoting); /* Might be a formal */
#else #else
ret=checkparm(c, dp); /* Might be a formal */ ret=fpp_checkparm(c, dp); /* Might be a formal */
#endif #endif
if(ret) if(ret)
return(ret); return(ret);
@ -162,24 +162,24 @@ ReturnCode dodefine(struct Global *global)
case DIG: /* Number in mac. body */ case DIG: /* Number in mac. body */
case DOT: /* Maybe a float number */ case DOT: /* Maybe a float number */
ret=scannumber(global, c, save); /* Scan it off */ ret=fpp_scannumber(global, c, fpp_save); /* Scan it off */
if(ret) if(ret)
return(ret); return(ret);
break; break;
case QUO: /* String in mac. body */ case QUO: /* String in mac. body */
ret=stparmscan(global, c); ret=fpp_stparmscan(global, c);
if(ret) if(ret)
return(ret); return(ret);
break; break;
case BSH: /* Backslash */ case BSH: /* Backslash */
ret=save(global, '\\'); ret=fpp_save(global, '\\');
if(ret) if(ret)
return(ret); return(ret);
if ((c = get(global)) == '\n') if ((c = fpp_get(global)) == '\n')
global->wrongline = TRUE; global->wrongline = FPP_TRUE;
ret=save(global, c); ret=fpp_save(global, c);
if(ret) if(ret)
return(ret); return(ret);
break; break;
@ -195,27 +195,27 @@ ReturnCode dodefine(struct Global *global)
c = ' '; /* Normalize tabs */ c = ' '; /* Normalize tabs */
/* Fall through to store character */ /* Fall through to store character */
default: /* Other character */ default: /* Other character */
ret=save(global, c); ret=fpp_save(global, c);
if(ret) if(ret)
return(ret); return(ret);
break; break;
} }
c = get(global); c = fpp_get(global);
quoting = 0; /* Only when immediately*/ quoting = 0; /* Only when immediately*/
/* preceding a formal */ /* preceding a formal */
} }
global->inmacro = FALSE; /* Stop newline hack */ global->inmacro = FPP_FALSE; /* Stop newline hack */
unget(global); /* For control check */ fpp_unget(global); /* For control check */
if (global->workp > global->work && global->workp[-1] == ' ') /* Drop trailing blank */ if (global->workp > global->work && global->workp[-1] == ' ') /* Drop trailing blank */
global->workp--; global->workp--;
*global->workp = EOS; /* Terminate work */ *global->workp = EOS; /* Terminate work */
dp->repl = savestring(global, global->work); /* Save the string */ dp->repl = fpp_savestring(global, global->work); /* Save the string */
dp->nargs = global->nargs; /* Save arg count */ dp->nargs = global->nargs; /* Save arg count */
if (isredefine) { /* Error if redefined */ if (isredefine) { /* Error if redefined */
if ((old != NULL && dp->repl != NULL && !streq(old, dp->repl)) if ((old != NULL && dp->repl != NULL && !streq(old, dp->repl))
|| (old == NULL && dp->repl != NULL) || (old == NULL && dp->repl != NULL)
|| (old != NULL && dp->repl == NULL)) { || (old != NULL && dp->repl == NULL)) {
cerror(global, ERROR_REDEFINE, dp->name); fpp_cerror(global, ERROR_REDEFINE, dp->name);
} }
if (old != NULL) /* We don't need the */ if (old != NULL) /* We don't need the */
free(old); /* old definition now. */ free(old); /* old definition now. */
@ -224,7 +224,7 @@ ReturnCode dodefine(struct Global *global)
} }
INLINE FILE_LOCAL INLINE FILE_LOCAL
ReturnCode checkparm(struct Global *global, ReturnCode fpp_checkparm(struct Global *global,
int c, int c,
DEFBUF *dp, DEFBUF *dp,
int quoting) /* Preceded by a # ? */ int quoting) /* Preceded by a # ? */
@ -233,7 +233,7 @@ ReturnCode checkparm(struct Global *global,
* Replace this param if it's defined. Note that the macro name is a * Replace this param if it's defined. Note that the macro name is a
* possible replacement token. We stuff DEF_MAGIC in front of the token * possible replacement token. We stuff DEF_MAGIC in front of the token
* which is treated as a LETTER by the token scanner and eaten by * which is treated as a LETTER by the token scanner and eaten by
* the output routine. This prevents the macro expander from * the fpp_output routine. This prevents the macro expander from
* looping if someone writes "#define foo foo". * looping if someone writes "#define foo foo".
*/ */
@ -241,29 +241,29 @@ ReturnCode checkparm(struct Global *global,
char *cp; char *cp;
ReturnCode ret=FPP_OK; ReturnCode ret=FPP_OK;
scanid(global, c); /* Get parm to tokenbuf */ fpp_scanid(global, c); /* Get parm to tokenbuf */
for (i = 0; i < global->nargs; i++) { /* For each argument */ for (i = 0; i < global->nargs; i++) { /* For each argument */
if (streq(global->parlist[i], global->tokenbuf)) { /* If it's known */ if (streq(global->parlist[i], global->tokenbuf)) { /* If it's known */
#if OK_CONCAT #if OK_CONCAT
if (quoting) { /* Special handling of */ if (quoting) { /* Special handling of */
ret=save(global, QUOTE_PARM); /* #formal inside defn */ ret=fpp_save(global, QUOTE_PARM); /* #formal inside defn */
if(ret) if(ret)
return(ret); return(ret);
} }
#endif #endif
ret=save(global, i + MAC_PARM); /* Save a magic cookie */ ret=fpp_save(global, i + MAC_PARM); /* Save a magic cookie */
return(ret); /* And exit the search */ return(ret); /* And exit the search */
} }
} }
if (streq(dp->name, global->tokenbuf)) /* Macro name in body? */ if (streq(dp->name, global->tokenbuf)) /* Macro name in body? */
ret=save(global, DEF_MAGIC); /* Save magic marker */ ret=fpp_save(global, DEF_MAGIC); /* Save magic marker */
for (cp = global->tokenbuf; *cp != EOS;) /* And save */ for (cp = global->tokenbuf; *cp != EOS;) /* And fpp_save */
ret=save(global, *cp++); /* The token itself */ ret=fpp_save(global, *cp++); /* The token itself */
return(ret); return(ret);
} }
INLINE FILE_LOCAL INLINE FILE_LOCAL
ReturnCode stparmscan(struct Global *global, int delim) ReturnCode fpp_stparmscan(struct Global *global, int delim)
{ {
/* /*
* Normal string parameter scan. * Normal string parameter scan.
@ -274,9 +274,9 @@ ReturnCode stparmscan(struct Global *global, int delim)
ReturnCode ret; ReturnCode ret;
wp = (unsigned char *)global->workp; /* Here's where it starts */ wp = (unsigned char *)global->workp; /* Here's where it starts */
ret=scanstring(global, delim, save); ret=fpp_scanstring(global, delim, fpp_save);
if(ret) if(ret)
return(ret); /* Exit on scanstring error */ return(ret); /* Exit on fpp_scanstring error */
global->workp[-1] = EOS; /* Erase trailing quote */ global->workp[-1] = EOS; /* Erase trailing quote */
wp++; /* -> first string content byte */ wp++; /* -> first string content byte */
for (i = 0; i < global->nargs; i++) { for (i = 0; i < global->nargs; i++) {
@ -292,23 +292,23 @@ ReturnCode stparmscan(struct Global *global, int delim)
return(FPP_OK); return(FPP_OK);
} }
void doundef(struct Global *global) void fpp_doundef(struct Global *global)
/* /*
* Remove the symbol from the defined list. * Remove the symbol from the defined list.
* Called from the #control processor. * Called from the #control processor.
*/ */
{ {
int c; int c;
if (type[(c = skipws(global))] != LET) if (type[(c = fpp_skipws(global))] != LET)
cerror(global, ERROR_ILLEGAL_UNDEF); fpp_cerror(global, ERROR_ILLEGAL_UNDEF);
else { else {
scanid(global, c); /* Get name to tokenbuf */ fpp_scanid(global, c); /* Get name to tokenbuf */
(void) defendel(global, global->tokenbuf, TRUE); (void) fpp_defendel(global, global->tokenbuf, FPP_TRUE);
} }
} }
INLINE FILE_LOCAL INLINE FILE_LOCAL
ReturnCode textput(struct Global *global, char *text) ReturnCode fpp_textput(struct Global *global, char *text)
{ {
/* /*
* Put the string in the parm[] buffer. * Put the string in the parm[] buffer.
@ -318,7 +318,7 @@ ReturnCode textput(struct Global *global, char *text)
size = strlen(text) + 1; size = strlen(text) + 1;
if ((global->parmp + size) >= &global->parm[NPARMWORK]) { if ((global->parmp + size) >= &global->parm[NPARMWORK]) {
cfatal(global, FATAL_MACRO_AREA_OVERFLOW); fpp_cfatal(global, FATAL_MACRO_AREA_OVERFLOW);
return(FPP_WORK_AREA_OVERFLOW); return(FPP_WORK_AREA_OVERFLOW);
} else { } else {
strcpy(global->parmp, text); strcpy(global->parmp, text);
@ -328,14 +328,14 @@ ReturnCode textput(struct Global *global, char *text)
} }
FILE_LOCAL FILE_LOCAL
ReturnCode charput(struct Global *global, int c) ReturnCode fpp_charput(struct Global *global, int c)
{ {
/* /*
* Put the byte in the parm[] buffer. * Put the byte in the parm[] buffer.
*/ */
if (global->parmp >= &global->parm[NPARMWORK]) { if (global->parmp >= &global->parm[NPARMWORK]) {
cfatal(global, FATAL_MACRO_AREA_OVERFLOW); fpp_cfatal(global, FATAL_MACRO_AREA_OVERFLOW);
return(FPP_WORK_AREA_OVERFLOW); return(FPP_WORK_AREA_OVERFLOW);
} }
*global->parmp++ = c; *global->parmp++ = c;
@ -346,15 +346,15 @@ ReturnCode charput(struct Global *global, int c)
* M a c r o E x p a n s i o n * M a c r o E x p a n s i o n
*/ */
ReturnCode expand(struct Global *global, DEFBUF *tokenp) ReturnCode fpp_expand(struct Global *global, DEFBUF *tokenp)
{ {
/* /*
* Expand a macro. Called from the cpp mainline routine (via subroutine * Expand a macro. Called from the cpp mainline routine (via subroutine
* macroid()) when a token is found in the symbol table. It calls * fpp_macroid()) when a token is found in the symbol table. It calls
* expcollect() to parse actual parameters, checking for the correct number. * fpp_expcollect() to parse actual parameters, checking for the correct number.
* It then creates a "file" containing a single line containing the * It then creates a "file" containing a single line containing the
* macro with actual parameters inserted appropriately. This is * macro with actual parameters inserted appropriately. This is
* "pushed back" onto the input stream. (When the get() routine runs * "pushed back" onto the input stream. (When the fpp_get() routine runs
* off the end of the macro line, it will dismiss the macro itself.) * off the end of the macro line, it will dismiss the macro itself.)
*/ */
int c; int c;
@ -368,12 +368,12 @@ ReturnCode expand(struct Global *global, DEFBUF *tokenp)
if (global->recursion++ == 0) if (global->recursion++ == 0)
global->macro = tokenp; global->macro = tokenp;
else if (global->recursion == RECURSION_LIMIT) { else if (global->recursion == RECURSION_LIMIT) {
cerror(global, ERROR_RECURSIVE_MACRO, tokenp->name, global->macro->name); fpp_cerror(global, ERROR_RECURSIVE_MACRO, tokenp->name, global->macro->name);
if (global->rec_recover) { if (global->rec_recover) {
do { do {
c = get(global); c = fpp_get(global);
} while (global->infile != NULL && global->infile->fp == NULL); } while (global->infile != NULL && global->infile->fp == NULL);
unget(global); fpp_unget(global);
global->recursion = 0; global->recursion = 0;
return(FPP_OK); return(FPP_OK);
} }
@ -396,7 +396,7 @@ ReturnCode expand(struct Global *global, DEFBUF *tokenp)
break; break;
} }
} }
ret=ungetstring(global, global->work); ret=fpp_ungetstring(global, global->work);
if(ret) if(ret)
return(ret); return(ret);
break; break;
@ -406,7 +406,7 @@ ReturnCode expand(struct Global *global, DEFBUF *tokenp)
if (file->fp != NULL) { if (file->fp != NULL) {
sprintf(global->work, "\"%s\"", (file->progname != NULL) sprintf(global->work, "\"%s\"", (file->progname != NULL)
? file->progname : file->filename); ? file->progname : file->filename);
ret=ungetstring(global, global->work); ret=fpp_ungetstring(global, global->work);
if(ret) if(ret)
return(ret); return(ret);
break; break;
@ -417,14 +417,14 @@ ReturnCode expand(struct Global *global, DEFBUF *tokenp)
case (-4): /* __FUNC__ */ case (-4): /* __FUNC__ */
sprintf(global->work, "\"%s\"", global->functionname[0]? sprintf(global->work, "\"%s\"", global->functionname[0]?
global->functionname : "<unknown function>"); global->functionname : "<unknown function>");
ret=ungetstring(global, global->work); ret=fpp_ungetstring(global, global->work);
if(ret) if(ret)
return(ret); return(ret);
break; break;
case (-5): /* __FUNC_LINE__ */ case (-5): /* __FUNC_LINE__ */
sprintf(global->work, "%d", global->funcline); sprintf(global->work, "%d", global->funcline);
ret=ungetstring(global, global->work); ret=fpp_ungetstring(global, global->work);
if(ret) if(ret)
return(ret); return(ret);
break; break;
@ -434,11 +434,11 @@ ReturnCode expand(struct Global *global, DEFBUF *tokenp)
* Nothing funny about this macro. * Nothing funny about this macro.
*/ */
if (tokenp->nargs < 0) { if (tokenp->nargs < 0) {
cfatal(global, FATAL_ILLEGAL_MACRO, tokenp->name); fpp_cfatal(global, FATAL_ILLEGAL_MACRO, tokenp->name);
return(FPP_ILLEGAL_MACRO); return(FPP_ILLEGAL_MACRO);
} }
while ((c = skipws(global)) == '\n') /* Look for (, skipping */ while ((c = fpp_skipws(global)) == '\n') /* Look for (, skipping */
global->wrongline = TRUE; /* spaces and newlines */ global->wrongline = FPP_TRUE; /* spaces and newlines */
if (c != '(') { if (c != '(') {
/* /*
* If the programmer writes * If the programmer writes
@ -447,27 +447,27 @@ ReturnCode expand(struct Global *global, DEFBUF *tokenp)
* foo [no ()] * foo [no ()]
* just write foo to the output stream. * just write foo to the output stream.
*/ */
unget(global); fpp_unget(global);
cwarn(global, WARN_MACRO_NEEDS_ARGUMENTS, tokenp->name); fpp_cwarn(global, WARN_MACRO_NEEDS_ARGUMENTS, tokenp->name);
/* fputs(tokenp->name, stdout); */ /* fputs(tokenp->name, stdout); */
Putstring(global, tokenp->name); fpp_Putstring(global, tokenp->name);
return(FPP_OK); return(FPP_OK);
} else if (!(ret=expcollect(global))) { /* Collect arguments */ } else if (!(ret=fpp_expcollect(global))) { /* Collect arguments */
if (tokenp->nargs != global->nargs) { /* Should be an error? */ if (tokenp->nargs != global->nargs) { /* Should be an error? */
cwarn(global, WARN_WRONG_NUMBER_ARGUMENTS, tokenp->name); fpp_cwarn(global, WARN_WRONG_NUMBER_ARGUMENTS, tokenp->name);
} }
} else { /* Collect arguments */ } else { /* Collect arguments */
return(ret); /* We failed in argument colleting! */ return(ret); /* We failed in argument colleting! */
} }
case DEF_NOARGS: /* No parameters just stuffs */ case DEF_NOARGS: /* No parameters just stuffs */
ret=expstuff(global, tokenp->name, tokenp->repl); /* expand macro */ ret=fpp_expstuff(global, tokenp->name, tokenp->repl); /* expand macro */
} /* nargs switch */ } /* nargs switch */
return(ret); return(ret);
} }
INLINE FILE_LOCAL INLINE FILE_LOCAL
ReturnCode expcollect(struct Global *global) ReturnCode fpp_expcollect(struct Global *global)
{ {
/* /*
* Collect the actual parameters for this macro. * Collect the actual parameters for this macro.
@ -479,8 +479,8 @@ ReturnCode expcollect(struct Global *global)
for (;;) { for (;;) {
paren = 0; /* Collect next arg. */ paren = 0; /* Collect next arg. */
while ((c = skipws(global)) == '\n')/* Skip over whitespace */ while ((c = fpp_skipws(global)) == '\n')/* Skip over whitespace */
global->wrongline = TRUE; /* and newlines. */ global->wrongline = FPP_TRUE; /* and newlines. */
if (c == ')') { /* At end of all args? */ if (c == ')') { /* At end of all args? */
/* /*
* Note that there is a guard byte in parm[] * Note that there is a guard byte in parm[]
@ -490,22 +490,22 @@ ReturnCode expcollect(struct Global *global)
break; /* Exit collection loop */ break; /* Exit collection loop */
} }
else if (global->nargs >= LASTPARM) { else if (global->nargs >= LASTPARM) {
cfatal(global, FATAL_TOO_MANY_ARGUMENTS_EXPANSION); fpp_cfatal(global, FATAL_TOO_MANY_ARGUMENTS_EXPANSION);
return(FPP_TOO_MANY_ARGUMENTS); return(FPP_TOO_MANY_ARGUMENTS);
} }
global->parlist[global->nargs++] = global->parmp; /* At start of new arg */ global->parlist[global->nargs++] = global->parmp; /* At start of new arg */
for (;; c = cget(global)) { /* Collect arg's bytes */ for (;; c = fpp_cget(global)) { /* Collect arg's bytes */
if (c == EOF_CHAR) { if (c == EOF_CHAR) {
cerror(global, ERROR_EOF_IN_ARGUMENT); fpp_cerror(global, ERROR_EOF_IN_ARGUMENT);
return(FPP_EOF_IN_MACRO); /* Sorry. */ return(FPP_EOF_IN_MACRO); /* Sorry. */
} }
else if (c == '\\') { /* Quote next character */ else if (c == '\\') { /* Quote next character */
charput(global, c); /* Save the \ for later */ fpp_charput(global, c); /* Save the \ for later */
charput(global, cget(global)); /* Save the next char. */ fpp_charput(global, fpp_cget(global)); /* Save the next char. */
continue; /* And go get another */ continue; /* And go get another */
} }
else if (type[c] == QUO) { /* Start of string? */ else if (type[c] == QUO) { /* Start of string? */
ret=scanstring(global, c, (ReturnCode (*)(struct Global *, int))charput); /* Scan it off */ ret=fpp_scanstring(global, c, (ReturnCode (*)(struct Global *, int))fpp_charput); /* Scan it off */
if(ret) if(ret)
return(ret); return(ret);
continue; /* Go get next char */ continue; /* Go get next char */
@ -514,7 +514,7 @@ ReturnCode expcollect(struct Global *global)
paren++; /* To know about commas */ paren++; /* To know about commas */
else if (c == ')') { /* Other side too */ else if (c == ')') { /* Other side too */
if (paren == 0) { /* At the end? */ if (paren == 0) { /* At the end? */
unget(global); /* Look at it later */ fpp_unget(global); /* Look at it later */
break; /* Exit arg getter. */ break; /* Exit arg getter. */
} }
paren--; /* More to come. */ paren--; /* More to come. */
@ -522,10 +522,10 @@ ReturnCode expcollect(struct Global *global)
else if (c == ',' && paren == 0) /* Comma delimits args */ else if (c == ',' && paren == 0) /* Comma delimits args */
break; break;
else if (c == '\n') /* Newline inside arg? */ else if (c == '\n') /* Newline inside arg? */
global->wrongline = TRUE; /* We'll need a #line */ global->wrongline = FPP_TRUE; /* We'll need a #line */
charput(global, c); /* Store this one */ fpp_charput(global, c); /* Store this one */
} /* Collect an argument */ } /* Collect an argument */
charput(global, EOS); /* Terminate argument */ fpp_charput(global, EOS); /* Terminate argument */
} /* Collect all args. */ } /* Collect all args. */
return(FPP_OK); /* Normal return */ return(FPP_OK); /* Normal return */
} }
@ -534,7 +534,7 @@ ReturnCode expcollect(struct Global *global)
#if OK_CONCAT #if OK_CONCAT
INLINE FILE_LOCAL INLINE FILE_LOCAL
char *doquoting(char *to, char *from) char *fpp_doquoting(char *to, char *from)
{ {
*to++ = '"'; *to++ = '"';
while (*from) { while (*from) {
@ -549,7 +549,7 @@ char *doquoting(char *to, char *from)
#endif #endif
ReturnCode expstuff(struct Global *global, ReturnCode fpp_expstuff(struct Global *global,
char *MacroName, char *MacroName,
char *MacroReplace) char *MacroReplace)
{ {
@ -568,7 +568,7 @@ ReturnCode expstuff(struct Global *global,
char quoting; /* Quote macro argument */ char quoting; /* Quote macro argument */
#endif #endif
ret = getfile(global, NBUFF, MacroName, &file); ret = fpp_getfile(global, NBUFF, MacroName, &file);
if(ret) if(ret)
return(ret); return(ret);
inp = MacroReplace; /* -> macro replacement */ inp = MacroReplace; /* -> macro replacement */
@ -599,7 +599,7 @@ ReturnCode expstuff(struct Global *global,
} }
#endif #endif
if ((defp + size) >= defend) { if ((defp + size) >= defend) {
cfatal(global, FATAL_OUT_OF_SPACE_IN_ARGUMENT, MacroName); fpp_cfatal(global, FATAL_OUT_OF_SPACE_IN_ARGUMENT, MacroName);
return(FPP_OUT_OF_SPACE_IN_MACRO_EXPANSION); return(FPP_OUT_OF_SPACE_IN_MACRO_EXPANSION);
} }
/* /*
@ -611,7 +611,7 @@ ReturnCode expstuff(struct Global *global,
} }
#if OK_CONCAT #if OK_CONCAT
else if (quoting) else if (quoting)
defp = doquoting(defp, global->parlist[c]); defp = fpp_doquoting(defp, global->parlist[c]);
#endif #endif
else { else {
strcpy(defp, global->parlist[c]); strcpy(defp, global->parlist[c]);
@ -620,7 +620,7 @@ else {
} }
} }
else if (defp >= defend) { else if (defp >= defend) {
cfatal(global, FATAL_OUT_OF_SPACE_IN_ARGUMENT, MacroName); fpp_cfatal(global, FATAL_OUT_OF_SPACE_IN_ARGUMENT, MacroName);
return(FPP_OUT_OF_SPACE_IN_MACRO_EXPANSION); return(FPP_OUT_OF_SPACE_IN_MACRO_EXPANSION);
} else } else
*defp++ = c; *defp++ = c;

214
3rdparty/fcpp/cpp5.c поставляемый
Просмотреть файл

@ -24,12 +24,12 @@ SOFTWARE.
#include "cppdef.h" #include "cppdef.h"
#include "cpp.h" #include "cpp.h"
INLINE FILE_LOCAL ReturnCode evallex(struct Global *, int, int *); INLINE FILE_LOCAL ReturnCode fpp_evallex(struct Global *, int, int *);
INLINE FILE_LOCAL ReturnCode dosizeof(struct Global *, int *); INLINE FILE_LOCAL ReturnCode fpp_dosizeof(struct Global *, int *);
INLINE FILE_LOCAL int bittest(int); INLINE FILE_LOCAL int fpp_bittest(int);
INLINE FILE_LOCAL int evalnum(struct Global *, int); INLINE FILE_LOCAL int fpp_evalnum(struct Global *, int);
INLINE FILE_LOCAL int evalchar(struct Global *, int); INLINE FILE_LOCAL int fpp_evalchar(struct Global *, int);
INLINE FILE_LOCAL int *evaleval(struct Global *, int *, int, int); INLINE FILE_LOCAL int *fpp_evaleval(struct Global *, int *, int, int);
/* /*
* Evaluate an #if expression. * Evaluate an #if expression.
@ -92,7 +92,7 @@ static char opdope[OP_MAX] = {
typedef struct optab { typedef struct optab {
char op; /* Operator */ char op; /* Operator */
char prec; /* Its precedence */ char prec; /* Its precedence */
char skip; /* Short-circuit: TRUE to skip */ char skip; /* Short-circuit: FPP_TRUE to skip */
} OPTAB; } OPTAB;
#ifdef nomacargs #ifdef nomacargs
@ -216,18 +216,18 @@ SIZES size_table[] = {
#endif /* OK_SIZEOF */ #endif /* OK_SIZEOF */
ReturnCode eval(struct Global *global, int *eval) ReturnCode fpp_eval(struct Global *global, int *eval)
{ {
/* /*
* Evaluate an expression. Straight-forward operator precedence. * Evaluate an expression. Straight-forward operator precedence.
* This is called from control() on encountering an #if statement. * This is called from fpp_control() on encountering an #if statement.
* It calls the following routines: * It calls the following routines:
* evallex Lexical analyser -- returns the type and value of * fpp_evallex Lexical analyser -- returns the type and value of
* the next input token. * the next input token.
* evaleval Evaluate the current operator, given the values on * fpp_evaleval Evaluate the current operator, given the values on
* the value stack. Returns a pointer to the (new) * the value stack. Returns a pointer to the (new)
* value stack. * value stack.
* For compatiblity with older cpp's, this return returns 1 (TRUE) * For compatiblity with older cpp's, this return returns 1 (FPP_TRUE)
* if a syntax error is detected. * if a syntax error is detected.
*/ */
int op; /* Current operator */ int op; /* Current operator */
@ -240,7 +240,7 @@ ReturnCode eval(struct Global *global, int *eval)
int value[NEXP]; /* Value stack */ int value[NEXP]; /* Value stack */
OPTAB opstack[NEXP]; /* Operand stack */ OPTAB opstack[NEXP]; /* Operand stack */
ReturnCode ret; ReturnCode ret;
char again=TRUE; char again=FPP_TRUE;
valp = value; valp = value;
opp = opstack; opp = opstack;
@ -250,7 +250,7 @@ ReturnCode eval(struct Global *global, int *eval)
binop = 0; binop = 0;
while(again) { while(again) {
ret=evallex(global, opp->skip, &op); ret=fpp_evallex(global, opp->skip, &op);
if(ret) if(ret)
return(ret); return(ret);
if (op == OP_SUB && binop == 0) if (op == OP_SUB && binop == 0)
@ -263,27 +263,27 @@ ReturnCode eval(struct Global *global, int *eval)
} }
if (op == DIG) { /* Value? */ if (op == DIG) { /* Value? */
if (binop != 0) { if (binop != 0) {
cerror(global, ERROR_MISPLACED_CONSTANT); fpp_cerror(global, ERROR_MISPLACED_CONSTANT);
*eval=1; *eval=1;
return(FPP_OK); return(FPP_OK);
} else if (valp >= &value[NEXP-1]) { } else if (valp >= &value[NEXP-1]) {
cerror(global, ERROR_IF_OVERFLOW); fpp_cerror(global, ERROR_IF_OVERFLOW);
*eval=1; *eval=1;
return(FPP_OK); return(FPP_OK);
} else { } else {
*valp++ = global->evalue; *valp++ = global->evalue;
binop = 1; binop = 1;
} }
again=TRUE; again=FPP_TRUE;
continue; continue;
} else if (op > OP_END) { } else if (op > OP_END) {
cerror(global, ERROR_ILLEGAL_IF_LINE); fpp_cerror(global, ERROR_ILLEGAL_IF_LINE);
*eval=1; *eval=1;
return(FPP_OK); return(FPP_OK);
} }
prec = opdope[op]; prec = opdope[op];
if (binop != (prec & 1)) { if (binop != (prec & 1)) {
cerror(global, ERROR_OPERATOR, opname[op]); fpp_cerror(global, ERROR_OPERATOR, opname[op]);
*eval=1; *eval=1;
return(FPP_OK); return(FPP_OK);
} }
@ -300,7 +300,7 @@ ReturnCode eval(struct Global *global, int *eval)
*/ */
opp++; opp++;
if (opp >= &opstack[NEXP]) { if (opp >= &opstack[NEXP]) {
cerror(global, ERROR_EXPR_OVERFLOW, opname[op]); fpp_cerror(global, ERROR_EXPR_OVERFLOW, opname[op]);
*eval=1; *eval=1;
return(FPP_OK); return(FPP_OK);
} }
@ -323,7 +323,7 @@ ReturnCode eval(struct Global *global, int *eval)
else { /* Other ops leave */ else { /* Other ops leave */
opp->skip = op1; /* skipping unchanged. */ opp->skip = op1; /* skipping unchanged. */
} }
again=TRUE; again=FPP_TRUE;
continue; continue;
} }
/* /*
@ -338,11 +338,11 @@ ReturnCode eval(struct Global *global, int *eval)
return(FPP_OK); return(FPP_OK);
} }
/* Read another op. */ /* Read another op. */
again=TRUE; again=FPP_TRUE;
continue; continue;
case OP_LPA: /* ( on stack */ case OP_LPA: /* ( on stack */
if (op != OP_RPA) { /* Matches ) on input */ if (op != OP_RPA) { /* Matches ) on input */
cerror(global, ERROR_UNBALANCED_PARENS, opname[op]); fpp_cerror(global, ERROR_UNBALANCED_PARENS, opname[op]);
*eval=1; *eval=1;
return(FPP_OK); return(FPP_OK);
} }
@ -350,12 +350,12 @@ ReturnCode eval(struct Global *global, int *eval)
/* -- Fall through */ /* -- Fall through */
case OP_QUE: case OP_QUE:
/* Evaluate true expr. */ /* Evaluate true expr. */
again=TRUE; again=FPP_TRUE;
continue; continue;
case OP_COL: /* : on stack. */ case OP_COL: /* : on stack. */
opp--; /* Unstack : */ opp--; /* Unstack : */
if (opp->op != OP_QUE) { /* Matches ? on stack? */ if (opp->op != OP_QUE) { /* Matches ? on stack? */
cerror(global, ERROR_MISPLACED, opname[(unsigned)opp->op]); fpp_cerror(global, ERROR_MISPLACED, opname[(unsigned)opp->op]);
*eval=1; *eval=1;
return(FPP_OK); return(FPP_OK);
} }
@ -364,8 +364,8 @@ ReturnCode eval(struct Global *global, int *eval)
*/ */
default: /* Others: */ default: /* Others: */
opp--; /* Unstack the operator */ opp--; /* Unstack the operator */
valp = evaleval(global, valp, op1, skip); valp = fpp_evaleval(global, valp, op1, skip);
again=FALSE; again=FPP_FALSE;
} /* op1 switch end */ } /* op1 switch end */
} while (!again); /* Stack unwind loop */ } while (!again); /* Stack unwind loop */
} }
@ -373,16 +373,16 @@ ReturnCode eval(struct Global *global, int *eval)
} }
INLINE FILE_LOCAL INLINE FILE_LOCAL
ReturnCode evallex(struct Global *global, ReturnCode fpp_evallex(struct Global *global,
int skip, /* TRUE if short-circuit evaluation */ int skip, /* FPP_TRUE if short-circuit evaluation */
int *op) int *op)
{ {
/* /*
* Set *op to next eval operator or value. Called from eval(). It * Set *op to next fpp_eval operator or value. Called from fpp_eval(). It
* calls a special-purpose routines for 'char' strings and * calls a special-purpose routines for 'char' strings and
* numeric values: * numeric values:
* evalchar called to evaluate 'x' * fpp_evalchar called to evaluate 'x'
* evalnum called to evaluate numbers. * fpp_evalnum called to evaluate numbers.
*/ */
int c, c1, t; int c, c1, t;
@ -391,55 +391,55 @@ ReturnCode evallex(struct Global *global,
do { /* while(loop); */ do { /* while(loop); */
/* again: */ /* again: */
loop=FALSE; loop=FPP_FALSE;
do { /* Collect the token */ do { /* Collect the token */
c = skipws(global); c = fpp_skipws(global);
if((ret=macroid(global, &c))) if((ret=fpp_macroid(global, &c)))
return(ret); return(ret);
if (c == EOF_CHAR || c == '\n') { if (c == EOF_CHAR || c == '\n') {
unget(global); fpp_unget(global);
*op=OP_EOE; /* End of expression */ *op=OP_EOE; /* End of expression */
return(FPP_OK); return(FPP_OK);
} }
} while ((t = type[c]) == LET && catenate(global, &ret) && !ret); } while ((t = type[c]) == LET && fpp_catenate(global, 0, &ret) && !ret);
if(ret) if(ret)
/* If the loop was broken because of a fatal error! */ /* If the loop was broken because of a fatal error! */
return(ret); return(ret);
if (t == INV) { /* Total nonsense */ if (t == INV) { /* Total nonsense */
if (!skip) { if (!skip) {
if (isascii(c) && isprint(c)) if (isascii(c) && isprint(c))
cerror(global, ERROR_ILLEGAL_CHARACTER, c); fpp_cerror(global, ERROR_ILLEGAL_CHARACTER, c);
else else
cerror(global, ERROR_ILLEGAL_CHARACTER2, c); fpp_cerror(global, ERROR_ILLEGAL_CHARACTER2, c);
} }
return(FPP_ILLEGAL_CHARACTER); return(FPP_ILLEGAL_CHARACTER);
} else if (t == QUO) { /* ' or " */ } else if (t == QUO) { /* ' or " */
if (c == '\'') { /* Character constant */ if (c == '\'') { /* Character constant */
global->evalue = evalchar(global, skip); /* Somewhat messy */ global->evalue = fpp_evalchar(global, skip); /* Somewhat messy */
*op=DIG; /* Return a value */ *op=DIG; /* Return a value */
return(FPP_OK); return(FPP_OK);
} }
cerror(global, ERROR_STRING_IN_IF); fpp_cerror(global, ERROR_STRING_IN_IF);
return(FPP_CANT_USE_STRING_IN_IF); return(FPP_CANT_USE_STRING_IN_IF);
} else if (t == LET) { /* ID must be a macro */ } else if (t == LET) { /* ID must be a macro */
if (streq(global->tokenbuf, "defined")) { /* Or defined name */ if (streq(global->tokenbuf, "defined")) { /* Or defined name */
c1 = c = skipws(global); c1 = c = fpp_skipws(global);
if (c == '(') /* Allow defined(name) */ if (c == '(') /* Allow defined(name) */
c = skipws(global); c = fpp_skipws(global);
if (type[c] == LET) { if (type[c] == LET) {
global->evalue = (lookid(global, c) != NULL); global->evalue = (fpp_lookid(global, c) != NULL);
if (c1 != '(' /* Need to balance */ if (c1 != '(' /* Need to balance */
|| skipws(global) == ')') { /* Did we balance? */ || fpp_skipws(global) == ')') { /* Did we balance? */
*op=DIG; *op=DIG;
return(FPP_OK); /* Parsed ok */ return(FPP_OK); /* Parsed ok */
} }
} }
cerror(global, ERROR_DEFINED_SYNTAX); fpp_cerror(global, ERROR_DEFINED_SYNTAX);
return(FPP_BAD_IF_DEFINED_SYNTAX); return(FPP_BAD_IF_DEFINED_SYNTAX);
} }
#if OK_SIZEOF #if OK_SIZEOF
else if (streq(global->tokenbuf, "sizeof")) { /* New sizeof hackery */ else if (streq(global->tokenbuf, "sizeof")) { /* New sizeof hackery */
ret=dosizeof(global, op); /* Gets own routine */ ret=fpp_dosizeof(global, op); /* Gets own routine */
return(ret); return(ret);
} }
#endif #endif
@ -448,13 +448,13 @@ else if (streq(global->tokenbuf, "sizeof")) { /* New sizeof hackery */
return(FPP_OK); return(FPP_OK);
} }
else if (t == DIG) { /* Numbers are harder */ else if (t == DIG) { /* Numbers are harder */
global->evalue = evalnum(global, c); global->evalue = fpp_evalnum(global, c);
} }
else if (strchr("!=<>&|\\", c) != NULL) { else if (strchr("!=<>&|\\", c) != NULL) {
/* /*
* Process a possible multi-byte lexeme. * Process a possible multi-byte lexeme.
*/ */
c1 = cget(global); /* Peek at next char */ c1 = fpp_cget(global); /* Peek at next char */
switch (c) { switch (c) {
case '!': case '!':
if (c1 == '=') { if (c1 == '=') {
@ -465,8 +465,8 @@ else if (streq(global->tokenbuf, "sizeof")) { /* New sizeof hackery */
case '=': case '=':
if (c1 != '=') { /* Can't say a=b in #if */ if (c1 != '=') { /* Can't say a=b in #if */
unget(global); fpp_unget(global);
cerror(global, ERROR_ILLEGAL_ASSIGN); fpp_cerror(global, ERROR_ILLEGAL_ASSIGN);
return (FPP_IF_ERROR); return (FPP_IF_ERROR);
} }
*op=OP_EQ; *op=OP_EQ;
@ -493,14 +493,14 @@ else if (streq(global->tokenbuf, "sizeof")) { /* New sizeof hackery */
case '\\': case '\\':
if (c1 == '\n') { /* Multi-line if */ if (c1 == '\n') { /* Multi-line if */
loop=TRUE; loop=FPP_TRUE;
break; break;
} }
cerror(global, ERROR_ILLEGAL_BACKSLASH); fpp_cerror(global, ERROR_ILLEGAL_BACKSLASH);
return(FPP_IF_ERROR); return(FPP_IF_ERROR);
} }
if(!loop) if(!loop)
unget(global); fpp_unget(global);
} }
} while(loop); } while(loop);
*op=t; *op=t;
@ -510,7 +510,7 @@ else if (streq(global->tokenbuf, "sizeof")) { /* New sizeof hackery */
#if OK_SIZEOF #if OK_SIZEOF
INLINE FILE_LOCAL INLINE FILE_LOCAL
ReturnCode dosizeof(struct Global *global, int *result) ReturnCode fpp_dosizeof(struct Global *global, int *result)
{ {
/* /*
* Process the sizeof (basic type) operation in an #if string. * Process the sizeof (basic type) operation in an #if string.
@ -525,44 +525,44 @@ ReturnCode dosizeof(struct Global *global, int *result)
short typecode; short typecode;
ReturnCode ret; ReturnCode ret;
if ((c = skipws(global)) != '(') { if ((c = fpp_skipws(global)) != '(') {
unget(global); fpp_unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX); fpp_cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR); return(FPP_SIZEOF_ERROR);
} }
/* /*
* Scan off the tokens. * Scan off the tokens.
*/ */
typecode = 0; typecode = 0;
while ((c = skipws(global))) { while ((c = fpp_skipws(global))) {
if((ret=macroid(global, &c))) if((ret=fpp_macroid(global, &c)))
return(ret); return(ret);
/* (I) return on fail! */ /* (I) return on fail! */
if (c == EOF_CHAR || c == '\n') { if (c == EOF_CHAR || c == '\n') {
/* End of line is a bug */ /* End of line is a bug */
unget(global); fpp_unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX); fpp_cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR); return(FPP_SIZEOF_ERROR);
} else if (c == '(') { /* thing (*)() func ptr */ } else if (c == '(') { /* thing (*)() func ptr */
if (skipws(global) == '*' if (fpp_skipws(global) == '*'
&& skipws(global) == ')') { /* We found (*) */ && fpp_skipws(global) == ')') { /* We found (*) */
if (skipws(global) != '(') /* Let () be optional */ if (fpp_skipws(global) != '(') /* Let () be optional */
unget(global); fpp_unget(global);
else if (skipws(global) != ')') { else if (fpp_skipws(global) != ')') {
unget(global); fpp_unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX); fpp_cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR); return(FPP_SIZEOF_ERROR);
} }
typecode |= T_FPTR; /* Function pointer */ typecode |= T_FPTR; /* Function pointer */
} else { /* Junk is a bug */ } else { /* Junk is a bug */
unget(global); fpp_unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX); fpp_cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR); return(FPP_SIZEOF_ERROR);
} }
} }
else if (type[c] != LET) /* Exit if not a type */ else if (type[c] != LET) /* Exit if not a type */
break; break;
else if (!catenate(global, &ret) && !ret) { /* Maybe combine tokens */ else if (!fpp_catenate(global, 0, &ret) && !ret) { /* Maybe combine tokens */
/* /*
* Look for this unexpandable token in basic_types. * Look for this unexpandable token in basic_types.
* The code accepts "int long" as well as "long int" * The code accepts "int long" as well as "long int"
@ -574,7 +574,7 @@ ReturnCode dosizeof(struct Global *global, int *result)
break; break;
} }
if (tp->name == NULLST) { if (tp->name == NULLST) {
cerror(global, ERROR_SIZEOF_UNKNOWN, global->tokenbuf); fpp_cerror(global, ERROR_SIZEOF_UNKNOWN, global->tokenbuf);
return(FPP_SIZEOF_ERROR); return(FPP_SIZEOF_ERROR);
} }
typecode |= tp->type; /* Or in the type bit */ typecode |= tp->type; /* Or in the type bit */
@ -586,12 +586,12 @@ ReturnCode dosizeof(struct Global *global, int *result)
*/ */
if (c == '*') { if (c == '*') {
typecode |= T_PTR; typecode |= T_PTR;
c = skipws(global); c = fpp_skipws(global);
} }
if (c == ')') { /* Last syntax check */ if (c == ')') { /* Last syntax check */
for (testp = test_table; *testp != 0; testp++) { for (testp = test_table; *testp != 0; testp++) {
if (!bittest(typecode & *testp)) { if (!fpp_bittest(typecode & *testp)) {
cerror(global, ERROR_SIZEOF_ILLEGAL_TYPE); fpp_cerror(global, ERROR_SIZEOF_ILLEGAL_TYPE);
return(FPP_SIZEOF_ERROR); return(FPP_SIZEOF_ERROR);
} }
} }
@ -609,7 +609,7 @@ ReturnCode dosizeof(struct Global *global, int *result)
typecode &= ~T_INT; typecode &= ~T_INT;
} }
if ((typecode & ~T_PTR) == 0) { if ((typecode & ~T_PTR) == 0) {
cerror(global, ERROR_SIZEOF_NO_TYPE); fpp_cerror(global, ERROR_SIZEOF_NO_TYPE);
return(FPP_SIZEOF_ERROR); return(FPP_SIZEOF_ERROR);
} }
/* /*
@ -623,19 +623,19 @@ ReturnCode dosizeof(struct Global *global, int *result)
return(FPP_OK); return(FPP_OK);
} }
} /* We shouldn't fail */ } /* We shouldn't fail */
cerror(global, ERROR_SIZEOF_BUG, typecode); fpp_cerror(global, ERROR_SIZEOF_BUG, typecode);
return(FPP_SIZEOF_ERROR); return(FPP_SIZEOF_ERROR);
} }
unget(global); fpp_unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX); fpp_cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR); return(FPP_SIZEOF_ERROR);
} }
INLINE FILE_LOCAL INLINE FILE_LOCAL
int bittest(int value) int fpp_bittest(int value)
{ {
/* /*
* TRUE if value is zero or exactly one bit is set in value. * FPP_TRUE if value is zero or exactly one bit is set in value.
*/ */
#if (4096 & ~(-4096)) == 0 #if (4096 & ~(-4096)) == 0
@ -651,10 +651,10 @@ int bittest(int value)
#endif /* OK_SIZEOF */ #endif /* OK_SIZEOF */
INLINE FILE_LOCAL INLINE FILE_LOCAL
int evalnum(struct Global *global, int c) int fpp_evalnum(struct Global *global, int c)
{ {
/* /*
* Expand number for #if lexical analysis. Note: evalnum recognizes * Expand number for #if lexical analysis. Note: fpp_evalnum recognizes
* the unsigned suffix, but only returns a signed int value. * the unsigned suffix, but only returns a signed int value.
*/ */
@ -664,16 +664,16 @@ int evalnum(struct Global *global, int c)
if (c != '0') if (c != '0')
base = 10; base = 10;
else if ((c = cget(global)) == 'x' || c == 'X') { else if ((c = fpp_cget(global)) == 'x' || c == 'X') {
base = 16; base = 16;
c = cget(global); c = fpp_cget(global);
} }
else base = 8; else base = 8;
value = 0; value = 0;
for (;;) { for (;;) {
c1 = c; c1 = c;
if (isascii(c) && isupper(c1)) if (isascii(c) && isupper(c1))
c1 = tolower(c1); c1 = fpp_tolower(c1);
if (c1 >= 'a') if (c1 >= 'a')
c1 -= ('a' - 10); c1 -= ('a' - 10);
else c1 -= '0'; else c1 -= '0';
@ -681,17 +681,17 @@ int evalnum(struct Global *global, int c)
break; break;
value *= base; value *= base;
value += c1; value += c1;
c = cget(global); c = fpp_cget(global);
} }
if (c == 'u' || c == 'U') /* Unsigned nonsense */ if (c == 'u' || c == 'U') /* Unsigned nonsense */
c = cget(global); c = fpp_cget(global);
unget(global); fpp_unget(global);
return (value); return (value);
} }
INLINE FILE_LOCAL INLINE FILE_LOCAL
int evalchar(struct Global *global, int fpp_evalchar(struct Global *global,
int skip) /* TRUE if short-circuit evaluation */ int skip) /* FPP_TRUE if short-circuit evaluation */
/* /*
* Get a character constant * Get a character constant
*/ */
@ -700,9 +700,9 @@ int evalchar(struct Global *global,
int value; int value;
int count; int count;
global->instring = TRUE; global->instring = FPP_TRUE;
if ((c = cget(global)) == '\\') { if ((c = fpp_cget(global)) == '\\') {
switch ((c = cget(global))) { switch ((c = fpp_cget(global))) {
case 'a': /* New in Standard */ case 'a': /* New in Standard */
#if ('a' == '\a' || '\a' == ALERT) #if ('a' == '\a' || '\a' == ALERT)
value = ALERT; /* Use predefined value */ value = ALERT; /* Use predefined value */
@ -742,14 +742,14 @@ int evalchar(struct Global *global,
case 'x': /* '\xFF' */ case 'x': /* '\xFF' */
count = 3; count = 3;
value = 0; value = 0;
while ((((c = get(global)) >= '0' && c <= '9') while ((((c = fpp_get(global)) >= '0' && c <= '9')
|| (c >= 'a' && c <= 'f') || (c >= 'a' && c <= 'f')
|| (c >= 'A' && c <= 'F')) || (c >= 'A' && c <= 'F'))
&& (--count >= 0)) { && (--count >= 0)) {
value *= 16; value *= 16;
value += (c <= '9') ? (c - '0') : ((c & 0xF) + 9); value += (c <= '9') ? (c - '0') : ((c & 0xF) + 9);
} }
unget(global); fpp_unget(global);
break; break;
default: default:
@ -759,9 +759,9 @@ int evalchar(struct Global *global,
while (c >= '0' && c <= '7' && --count >= 0) { while (c >= '0' && c <= '7' && --count >= 0) {
value *= 8; value *= 8;
value += (c - '0'); value += (c - '0');
c = get(global); c = fpp_get(global);
} }
unget(global); fpp_unget(global);
} else } else
value = c; value = c;
break; break;
@ -776,9 +776,9 @@ int evalchar(struct Global *global,
#if BIG_ENDIAN #if BIG_ENDIAN
count = 0; count = 0;
#endif #endif
while ((c = get(global)) != '\'' && c != EOF_CHAR && c != '\n') { while ((c = fpp_get(global)) != '\'' && c != EOF_CHAR && c != '\n') {
if (!skip) if (!skip)
cwarn(global, WARN_MULTIBYTE_NOT_PORTABLE, c); fpp_cwarn(global, WARN_MULTIBYTE_NOT_PORTABLE, c);
#if BIG_ENDIAN #if BIG_ENDIAN
count += BITS_CHAR; count += BITS_CHAR;
value += (c << count); value += (c << count);
@ -787,15 +787,15 @@ int evalchar(struct Global *global,
value += c; value += c;
#endif #endif
} }
global->instring = FALSE; global->instring = FPP_FALSE;
return (value); return (value);
} }
INLINE FILE_LOCAL INLINE FILE_LOCAL
int *evaleval(struct Global *global, int *fpp_evaleval(struct Global *global,
int *valp, int *valp,
int op, int op,
int skip) /* TRUE if short-circuit evaluation */ int skip) /* FPP_TRUE if short-circuit evaluation */
{ {
/* /*
* Apply the argument operator to the data on the value stack. * Apply the argument operator to the data on the value stack.
@ -804,7 +804,7 @@ int *evaleval(struct Global *global,
* *
* OP_COL is a special case. * OP_COL is a special case.
* *
* evaleval() returns the new pointer to the top of the value stack. * fpp_evaleval() returns the new pointer to the top of the value stack.
*/ */
int v1, v2 = 0; int v1, v2 = 0;
@ -827,7 +827,7 @@ int *evaleval(struct Global *global,
case OP_MOD: case OP_MOD:
if (v2 == 0) { if (v2 == 0) {
if (!skip) { if (!skip) {
cwarn(global, WARN_DIVISION_BY_ZERO, fpp_cwarn(global, WARN_DIVISION_BY_ZERO,
(op == OP_DIV) ? "divide" : "mod"); (op == OP_DIV) ? "divide" : "mod");
} }
v1 = 0; v1 = 0;
@ -895,7 +895,7 @@ int *evaleval(struct Global *global,
v1 = !v1; v1 = !v1;
break; break;
default: default:
cerror(global, ERROR_IF_OPERAND, op); fpp_cerror(global, ERROR_IF_OPERAND, op);
v1 = 0; v1 = 0;
} }
*valp++ = v1; *valp++ = v1;

387
3rdparty/fcpp/cpp6.c поставляемый
Просмотреть файл

@ -24,52 +24,52 @@ SOFTWARE.
#include "cppdef.h" #include "cppdef.h"
#include "cpp.h" #include "cpp.h"
INLINE FILE_LOCAL void outadefine(struct Global *, DEFBUF *); INLINE FILE_LOCAL void fpp_outadefine(struct Global *, DEFBUF *);
INLINE FILE_LOCAL void domsg(struct Global *, ErrorCode, va_list); INLINE FILE_LOCAL void fpp_domsg(struct Global *, ErrorCode, va_list);
/* /*
* skipnl() skips over input text to the end of the line. * fpp_skipnl() skips over input text to the end of the line.
* skipws() skips over "whitespace" (spaces or tabs), but * fpp_skipws() skips over "whitespace" (spaces or tabs), but
* not skip over the end of the line. It skips over * not skip over the end of the line. It skips over
* TOK_SEP, however (though that shouldn't happen). * TOK_SEP, however (though that shouldn't happen).
* scanid() reads the next token (C identifier) into tokenbuf. * fpp_scanid() reads the next token (C identifier) into tokenbuf.
* The caller has already read the first character of * The caller has already read the first character of
* the identifier. Unlike macroid(), the token is * the identifier. Unlike fpp_macroid(), the token is
* never expanded. * never expanded.
* macroid() reads the next token (C identifier) into tokenbuf. * fpp_macroid() reads the next token (C identifier) into tokenbuf.
* If it is a #defined macro, it is expanded, and * If it is a #defined macro, it is expanded, and
* macroid() returns TRUE, otherwise, FALSE. * fpp_macroid() returns FPP_TRUE, otherwise, FPP_FALSE.
* catenate() Does the dirty work of token concatenation, TRUE if it did. * fpp_catenate() Does the dirty work of token concatenation, FPP_TRUE if it did.
* scanstring() Reads a string from the input stream, calling * fpp_scanstring() Reads a string from the input stream, calling
* a user-supplied function for each character. * a user-supplied function for each character.
* This function may be output() to write the * This function may be fpp_output() to write the
* string to the output file, or save() to save * string to the output file, or fpp_save() to fpp_save
* the string in the work buffer. * the string in the work buffer.
* scannumber() Reads a C numeric constant from the input stream, * fpp_scannumber() Reads a C numeric constant from the input stream,
* calling the user-supplied function for each * calling the user-supplied function for each
* character. (output() or save() as noted above.) * character. (fpp_output() or fpp_save() as noted above.)
* save() Save one character in the work[] buffer. * fpp_save() Save one character in the work[] buffer.
* savestring() Saves a string in malloc() memory. * fpp_savestring() Saves a string in malloc() memory.
* getfile() Initialize a new FILEINFO structure, called when * fpp_getfile() Initialize a new FILEINFO structure, called when
* #include opens a new file, or a macro is to be * #include opens a new file, or a macro is to be
* expanded. * expanded.
* Getmem() Get a specified number of bytes from malloc memory. * fpp_Getmem() Get a specified number of bytes from malloc memory.
* output() Write one character to stdout (calling Putchar) -- * fpp_output() Write one character to stdout (calling fpp_Putchar) --
* implemented as a function so its address may be * implemented as a function so its address may be
* passed to scanstring() and scannumber(). * passed to fpp_scanstring() and fpp_scannumber().
* lookid() Scans the next token (identifier) from the input * fpp_lookid() Scans the next token (identifier) from the input
* stream. Looks for it in the #defined symbol table. * stream. Looks for it in the #defined symbol table.
* Returns a pointer to the definition, if found, or NULL * Returns a pointer to the definition, if found, or NULL
* if not present. The identifier is stored in tokenbuf. * if not present. The identifier is stored in tokenbuf.
* defnedel() Define enter/delete subroutine. Updates the * fpp_defendel() Define enter/delete subroutine. Updates the
* symbol table. * symbol table.
* get() Read the next byte from the current input stream, * fpp_get() Read the next byte from the current input stream,
* handling end of (macro/file) input and embedded * handling end of (macro/file) input and embedded
* comments appropriately. Note that the global * comments appropriately. Note that the global
* instring is -- essentially -- a parameter to get(). * instring is -- essentially -- a parameter to fpp_get().
* cget() Like get(), but skip over TOK_SEP. * fpp_cget() Like fpp_get(), but skip over TOK_SEP.
* unget() Push last gotten character back on the input stream. * fpp_unget() Push last gotten character back on the input stream.
* cerror() This routine format an print messages to the user. * fpp_cerror() This routine format an print messages to the user.
*/ */
/* /*
@ -121,7 +121,7 @@ char type[256] = { /* Character type codes Hex */
000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */
}; };
void skipnl(struct Global *global) void fpp_skipnl(struct Global *global)
{ {
/* /*
* Skip to the end of the current input line. * Skip to the end of the current input line.
@ -129,12 +129,12 @@ void skipnl(struct Global *global)
int c; int c;
do { /* Skip to newline */ do { /* Skip to newline */
c = get(global); c = fpp_get(global);
} while (c != '\n' && c != EOF_CHAR); } while (c != '\n' && c != EOF_CHAR);
return; return;
} }
int skipws(struct Global *global) int fpp_skipws(struct Global *global)
{ {
/* /*
* Skip over whitespace * Skip over whitespace
@ -142,7 +142,7 @@ int skipws(struct Global *global)
int c; int c;
do { /* Skip whitespace */ do { /* Skip whitespace */
c = get(global); c = fpp_get(global);
#if COMMENT_INVISIBLE #if COMMENT_INVISIBLE
} while (type[c] == SPA || c == COM_SEP); } while (type[c] == SPA || c == COM_SEP);
#else #else
@ -151,19 +151,19 @@ int skipws(struct Global *global)
return(c); return(c);
} }
void scanid(struct Global *global, void fpp_scanid(struct Global *global,
int c) /* First char of id */ int c) /* First char of id */
{ {
/* /*
* Get the next token (an id) into the token buffer. * Get the next token (an id) into the token buffer.
* Note: this code is duplicated in lookid(). * Note: this code is duplicated in fpp_lookid().
* Change one, change both. * Change one, change both.
*/ */
int ct; int ct;
if (c == DEF_MAGIC) /* Eat the magic token */ if (c == DEF_MAGIC) /* Eat the magic token */
c = get(global); /* undefiner. */ c = fpp_get(global); /* undefiner. */
ct = 0; ct = 0;
do do
{ {
@ -171,14 +171,14 @@ void scanid(struct Global *global,
global->tokenbuf = realloc(global->tokenbuf, 1 + global->tokenbuf = realloc(global->tokenbuf, 1 +
(global->tokenbsize *= 2)); (global->tokenbsize *= 2));
global->tokenbuf[ct++] = c; global->tokenbuf[ct++] = c;
c = get(global); c = fpp_get(global);
} }
while (type[c] == LET || type[c] == DIG); while (type[c] == LET || type[c] == DIG);
unget(global); fpp_unget(global);
global->tokenbuf[ct] = EOS; global->tokenbuf[ct] = EOS;
} }
ReturnCode macroid(struct Global *global, int *c) ReturnCode fpp_macroid(struct Global *global, int *c)
{ {
/* /*
* If c is a letter, scan the id. if it's #defined, expand it and scan * If c is a letter, scan the id. if it's #defined, expand it and scan
@ -191,51 +191,53 @@ ReturnCode macroid(struct Global *global, int *c)
if (global->infile != NULL && global->infile->fp != NULL) if (global->infile != NULL && global->infile->fp != NULL)
global->recursion = 0; global->recursion = 0;
while (type[*c] == LET && (dp = lookid(global, *c)) != NULL) { while (type[*c] == LET && (dp = fpp_lookid(global, *c)) != NULL) {
if((ret=expand(global, dp))) if((ret=fpp_expand(global, dp)))
return(ret); return(ret);
*c = get(global); *c = fpp_get(global);
} }
return(FPP_OK); return(FPP_OK);
} }
int catenate(struct Global *global, ReturnCode *ret) int fpp_catenate(struct Global *global, int lhs_number, ReturnCode *ret)
{ {
/* /*
* A token was just read (via macroid). * A token was just read (via fpp_macroid).
* If the next character is TOK_SEP, concatenate the next token * If the next character is TOK_SEP, concatenate the next token
* return TRUE -- which should recall macroid after refreshing * return FPP_TRUE -- which should recall fpp_macroid after refreshing
* macroid's argument. If it is not TOK_SEP, unget() the character * fpp_macroid's argument. If it is not TOK_SEP, fpp_unget() the character
* and return FALSE. * and return FPP_FALSE.
*/ */
#if OK_CONCAT #if OK_CONCAT
int c; int c;
char *token1; char *token1 = "";
#endif #endif
#if OK_CONCAT #if OK_CONCAT
if (get(global) != TOK_SEP) { /* Token concatenation */ if (fpp_get(global) != TOK_SEP) { /* Token concatenation */
unget(global); fpp_unget(global);
return (FALSE); return (FPP_FALSE);
} }
else { else {
token1 = savestring(global, global->tokenbuf); /* Save first token */ if (lhs_number == 0) { /* The lhs number has already been emit */
c=get(global); token1 = fpp_savestring(global, global->tokenbuf); /* Save first token */
}
c= fpp_get(global);
if(global->rightconcat) { if(global->rightconcat) {
*ret=macroid(global, &c); /* Scan next token */ *ret=fpp_macroid(global, &c); /* Scan next token */
if(*ret) if(*ret)
return(FALSE); return(FPP_FALSE);
} /* BK - BUG? Parses token into global->tokenbuf but never uses it. } /* BK - BUG? Parses token into global->tokenbuf but never uses it.
else else
lookid(global, c); fpp_lookid(global, c);
*/ */
switch(type[c]) { /* What was it? */ switch(type[c]) { /* What was it? */
case LET: /* An identifier, ... */ case LET: /* An identifier, ... */
if ((int)strlen(token1) + (int)strlen(global->tokenbuf) >= NWORK) { if ((int)strlen(token1) + (int)strlen(global->tokenbuf) >= NWORK) {
cfatal(global, FATAL_WORK_AREA_OVERFLOW, token1); fpp_cfatal(global, FATAL_WORK_AREA_OVERFLOW, token1);
*ret=FPP_WORK_AREA_OVERFLOW; *ret=FPP_WORK_AREA_OVERFLOW;
return(FALSE); return(FPP_FALSE);
} }
sprintf(global->work, "%s%s", token1, global->tokenbuf); sprintf(global->work, "%s%s", token1, global->tokenbuf);
break; break;
@ -243,20 +245,20 @@ int catenate(struct Global *global, ReturnCode *ret)
case DOT: /* Or maybe a float */ case DOT: /* Or maybe a float */
strcpy(global->work, token1); strcpy(global->work, token1);
global->workp = global->work + strlen(global->work); global->workp = global->work + strlen(global->work);
*ret=scannumber(global, c, save); *ret=fpp_scannumber(global, c, fpp_save);
if(*ret) if(*ret)
return(FALSE); return(FPP_FALSE);
*ret=save(global, EOS); *ret=fpp_save(global, EOS);
if(*ret) if(*ret)
return(FALSE); return(FPP_FALSE);
break; break;
default: /* An error, ... */ default: /* An error, ... */
if (isprint(c)) if (isprint(c))
cerror(global, ERROR_STRANG_CHARACTER, c); fpp_cerror(global, ERROR_STRANG_CHARACTER, c);
else else
cerror(global, ERROR_STRANG_CHARACTER2, c); fpp_cerror(global, ERROR_STRANG_CHARACTER2, c);
strcpy(global->work, token1); strcpy(global->work, token1);
unget(global); fpp_unget(global);
break; break;
} }
/* /*
@ -265,18 +267,20 @@ int catenate(struct Global *global, ReturnCode *ret)
* new (concatenated) token after freeing token1. * new (concatenated) token after freeing token1.
* Finally, setup to read the new token. * Finally, setup to read the new token.
*/ */
free(token1); /* Free up memory */ if (lhs_number == 0) {
*ret=ungetstring(global, global->work); /* Unget the new thing, */ free(token1); /* Free up memory */
}
*ret=fpp_ungetstring(global, global->work); /* Unget the new thing, */
if(*ret) if(*ret)
return(FALSE); return(FPP_FALSE);
return(TRUE); return(FPP_TRUE);
} }
#else #else
return(FALSE); /* Not supported */ return(FPP_FALSE); /* Not supported */
#endif #endif
} }
ReturnCode scanstring(struct Global *global, ReturnCode fpp_scanstring(struct Global *global,
int delim, /* ' or " */ int delim, /* ' or " */
/* Output function: */ /* Output function: */
ReturnCode (*outfun)(struct Global *, int)) ReturnCode (*outfun)(struct Global *, int))
@ -284,40 +288,40 @@ ReturnCode scanstring(struct Global *global,
/* /*
* Scan off a string. Warning if terminated by newline or EOF. * Scan off a string. Warning if terminated by newline or EOF.
* outfun() outputs the character -- to a buffer if in a macro. * outfun() outputs the character -- to a buffer if in a macro.
* TRUE if ok, FALSE if error. * FPP_TRUE if ok, FPP_FALSE if error.
*/ */
int c; int c;
ReturnCode ret; ReturnCode ret;
global->instring = TRUE; /* Don't strip comments */ global->instring = FPP_TRUE; /* Don't strip comments */
ret=(*outfun)(global, delim); ret=(*outfun)(global, delim);
if(ret) if(ret)
return(ret); return(ret);
while ((c = get(global)) != delim while ((c = fpp_get(global)) != delim
&& c != '\n' && c != '\n'
&& c != EOF_CHAR) { && c != EOF_CHAR) {
ret=(*outfun)(global, c); ret=(*outfun)(global, c);
if(ret) if(ret)
return(ret); return(ret);
if (c == '\\') { if (c == '\\') {
ret=(*outfun)(global, get(global)); ret=(*outfun)(global, fpp_get(global));
if(ret) if(ret)
return(ret); return(ret);
} }
} }
global->instring = FALSE; global->instring = FPP_FALSE;
if (c == delim) { if (c == delim) {
ret=(*outfun)(global, c); ret=(*outfun)(global, c);
return(ret); return(ret);
} else { } else {
cerror(global, ERROR_UNTERMINATED_STRING); fpp_cerror(global, ERROR_UNTERMINATED_STRING);
unget(global); fpp_unget(global);
return(FPP_UNTERMINATED_STRING); return(FPP_UNTERMINATED_STRING);
} }
} }
ReturnCode scannumber(struct Global *global, ReturnCode fpp_scannumber(struct Global *global,
int c, /* First char of number */ int c, /* First char of number */
/* Output/store func: */ /* Output/store func: */
ReturnCode (*outfun)(struct Global *, int)) ReturnCode (*outfun)(struct Global *, int))
@ -331,20 +335,20 @@ ReturnCode scannumber(struct Global *global,
int expseen; /* 'e' seen in floater */ int expseen; /* 'e' seen in floater */
int signseen; /* '+' or '-' seen */ int signseen; /* '+' or '-' seen */
int octal89; /* For bad octal test */ int octal89; /* For bad octal test */
int dotflag; /* TRUE if '.' was seen */ int dotflag; /* FPP_TRUE if '.' was seen */
ReturnCode ret; ReturnCode ret;
char done=FALSE; char done=FPP_FALSE;
expseen = FALSE; /* No exponent seen yet */ expseen = FPP_FALSE; /* No exponent seen yet */
signseen = TRUE; /* No +/- allowed yet */ signseen = FPP_TRUE; /* No +/- allowed yet */
octal89 = FALSE; /* No bad octal yet */ octal89 = FPP_FALSE; /* No bad octal yet */
radix = 10; /* Assume decimal */ radix = 10; /* Assume decimal */
if ((dotflag = (c == '.')) != FALSE) {/* . something? */ if ((dotflag = (c == '.')) != FPP_FALSE) {/* . something? */
ret=(*outfun)(global, '.'); /* Always out the dot */ ret=(*outfun)(global, '.'); /* Always out the dot */
if(ret) if(ret)
return(ret); return(ret);
if (type[(c = get(global))] != DIG) { /* If not a float numb, */ if (type[(c = fpp_get(global))] != DIG) { /* If not a float numb, */
unget(global); /* Rescan strange char */ fpp_unget(global); /* Rescan strange char */
return(FPP_OK); /* All done for now */ return(FPP_OK); /* All done for now */
} }
} /* End of float test */ } /* End of float test */
@ -353,13 +357,13 @@ ReturnCode scannumber(struct Global *global,
if(ret) if(ret)
return(ret); return(ret);
radix = 8; /* Assume it's octal */ radix = 8; /* Assume it's octal */
c = get(global); /* Look for an 'x' */ c = fpp_get(global); /* Look for an 'x' */
if (c == 'x' || c == 'X') { /* Did we get one? */ if (c == 'x' || c == 'X') { /* Did we fpp_get one? */
radix = 16; /* Remember new radix */ radix = 16; /* Remember new radix */
ret=(*outfun)(global, c); /* Stuff the 'x' */ ret=(*outfun)(global, c); /* Stuff the 'x' */
if(ret) if(ret)
return(ret); return(ret);
c = get(global); /* Get next character */ c = fpp_get(global); /* Get next character */
} }
} }
while (!done) { /* Process curr. char. */ while (!done) { /* Process curr. char. */
@ -370,24 +374,24 @@ ReturnCode scannumber(struct Global *global,
if (radix != 16 && (c == 'e' || c == 'E')) { if (radix != 16 && (c == 'e' || c == 'E')) {
if (expseen) /* Already saw 'E'? */ if (expseen) /* Already saw 'E'? */
break; /* Exit loop, bad nbr. */ break; /* Exit loop, bad nbr. */
expseen = TRUE; /* Set exponent seen */ expseen = FPP_TRUE; /* Set exponent seen */
signseen = FALSE; /* We can read '+' now */ signseen = FPP_FALSE; /* We can read '+' now */
radix = 10; /* Decimal exponent */ radix = 10; /* Decimal exponent */
} }
else if (radix != 16 && c == '.') { else if (radix != 16 && c == '.') {
if (dotflag) /* Saw dot already? */ if (dotflag) /* Saw dot already? */
break; /* Exit loop, two dots */ break; /* Exit loop, two dots */
dotflag = TRUE; /* Remember the dot */ dotflag = FPP_TRUE; /* Remember the dot */
radix = 10; /* Decimal fraction */ radix = 10; /* Decimal fraction */
} }
else if (c == '+' || c == '-') { /* 1.0e+10 */ else if (c == '+' || c == '-') { /* 1.0e+10 */
if (signseen) /* Sign in wrong place? */ if (signseen) /* Sign in wrong place? */
break; /* Exit loop, not nbr. */ break; /* Exit loop, not nbr. */
/* signseen = TRUE; */ /* Remember we saw it */ /* signseen = FPP_TRUE; */ /* Remember we saw it */
} else { /* Check the digit */ } else { /* Check the digit */
switch (c) { switch (c) {
case '8': case '9': /* Sometimes wrong */ case '8': case '9': /* Sometimes wrong */
octal89 = TRUE; /* Do check later */ octal89 = FPP_TRUE; /* Do check later */
case '0': case '1': case '2': case '3': case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7': case '4': case '5': case '6': case '7':
break; /* Always ok */ break; /* Always ok */
@ -397,15 +401,15 @@ ReturnCode scannumber(struct Global *global,
if (radix == 16) /* Alpha's are ok only */ if (radix == 16) /* Alpha's are ok only */
break; /* if reading hex. */ break; /* if reading hex. */
default: /* At number end */ default: /* At number end */
done=TRUE; /* Break from for loop */ done=FPP_TRUE; /* Break from for loop */
continue; continue;
} /* End of switch */ } /* End of switch */
} /* End general case */ } /* End general case */
ret=(*outfun)(global, c); /* Accept the character */ ret=(*outfun)(global, c); /* Accept the character */
if(ret) if(ret)
return(ret); return(ret);
signseen = TRUE; /* Don't read sign now */ signseen = FPP_TRUE; /* Don't read sign now */
c = get(global); /* Read another char */ c = fpp_get(global); /* Read another char */
} /* End of scan loop */ } /* End of scan loop */
/* /*
* When we break out of the scan loop, c contains the first * When we break out of the scan loop, c contains the first
@ -421,7 +425,7 @@ ReturnCode scannumber(struct Global *global,
ret=(*outfun)(global, c); ret=(*outfun)(global, c);
if(ret) if(ret)
return(ret); return(ret);
c = get(global); /* Ungotten later */ c = fpp_get(global); /* Ungotten later */
} }
} else { /* Else it's an integer */ } else { /* Else it's an integer */
/* /*
@ -429,54 +433,54 @@ ReturnCode scannumber(struct Global *global,
* dotflag signals "saw 'L'", and * dotflag signals "saw 'L'", and
* expseen signals "saw 'U'". * expseen signals "saw 'U'".
*/ */
done=TRUE; done=FPP_TRUE;
while(done) { while(done) {
switch (c) { switch (c) {
case 'l': case 'l':
case 'L': case 'L':
if (dotflag) { if (dotflag) {
done=FALSE; done=FPP_FALSE;
continue; continue;
} }
dotflag = TRUE; dotflag = FPP_TRUE;
break; break;
case 'u': case 'u':
case 'U': case 'U':
if (expseen) { if (expseen) {
done=FALSE; done=FPP_FALSE;
continue; continue;
} }
expseen = TRUE; expseen = FPP_TRUE;
break; break;
default: default:
done=FALSE; done=FPP_FALSE;
continue; continue;
} }
ret=(*outfun)(global, c); /* Got 'L' or 'U'. */ ret=(*outfun)(global, c); /* Got 'L' or 'U'. */
if(ret) if(ret)
return(ret); return(ret);
c = get(global); /* Look at next, too. */ c = fpp_get(global); /* Look at next, too. */
} }
} }
unget(global); /* Not part of a number */ fpp_unget(global); /* Not part of a number */
if(!(global->webmode)) { if(!(global->webmode)) {
if (octal89 && radix == 8) if (octal89 && radix == 8)
cwarn(global, WARN_ILLEGAL_OCTAL); fpp_cwarn(global, WARN_ILLEGAL_OCTAL);
} }
return(FPP_OK); return(FPP_OK);
} }
ReturnCode save(struct Global *global, int c) ReturnCode fpp_save(struct Global *global, int c)
{ {
if (global->workp >= &global->work[NWORK]) { if (global->workp >= &global->work[NWORK]) {
cfatal(global, FATAL_WORK_BUFFER_OVERFLOW); fpp_cfatal(global, FATAL_WORK_BUFFER_OVERFLOW);
return(FPP_WORK_AREA_OVERFLOW); return(FPP_WORK_AREA_OVERFLOW);
} else } else
*global->workp++ = c; *global->workp++ = c;
return(FPP_OK); return(FPP_OK);
} }
char *savestring(struct Global *global, char *text) char *fpp_savestring(struct Global *global, char *text)
{ {
/* /*
* Store a string into free memory. * Store a string into free memory.
@ -488,7 +492,7 @@ char *savestring(struct Global *global, char *text)
return (result); return (result);
} }
ReturnCode getfile(struct Global *global, ReturnCode fpp_getfile(struct Global *global,
size_t bufsize, /* Line or define buffer size */ size_t bufsize, /* Line or define buffer size */
char *name, char *name,
FILEINFO **file) /* File or macro name string */ FILEINFO **file) /* File or macro name string */
@ -511,7 +515,7 @@ ReturnCode getfile(struct Global *global,
return(FPP_OUT_OF_MEMORY); return(FPP_OUT_OF_MEMORY);
(*file)->parent = global->infile; /* Chain files together */ (*file)->parent = global->infile; /* Chain files together */
(*file)->fp = NULL; /* No file yet */ (*file)->fp = NULL; /* No file yet */
(*file)->filename = savestring(global, name); /* Save file/macro name */ (*file)->filename = fpp_savestring(global, name); /* Save file/macro name */
(*file)->progname = NULL; /* No #line seen yet */ (*file)->progname = NULL; /* No #line seen yet */
(*file)->unrecur = 0; /* No macro fixup */ (*file)->unrecur = 0; /* No macro fixup */
(*file)->bptr = (*file)->buffer; /* Initialize line ptr */ (*file)->bptr = (*file)->buffer; /* Initialize line ptr */
@ -528,7 +532,7 @@ ReturnCode getfile(struct Global *global,
* C P P S y m b o l T a b l e s * C P P S y m b o l T a b l e s
*/ */
DEFBUF *lookid(struct Global *global, DEFBUF *fpp_lookid(struct Global *global,
int c) /* First character of token */ int c) /* First character of token */
{ {
/* /*
@ -544,16 +548,16 @@ DEFBUF *lookid(struct Global *global,
nhash = 0; nhash = 0;
if ((isrecurse = (c == DEF_MAGIC))) /* If recursive macro */ if ((isrecurse = (c == DEF_MAGIC))) /* If recursive macro */
c = get(global); /* hack, skip DEF_MAGIC */ c = fpp_get(global); /* hack, skip DEF_MAGIC */
ct = 0; ct = 0;
do { do {
if (ct == global->tokenbsize) if (ct == global->tokenbsize)
global->tokenbuf = realloc(global->tokenbuf, 1 + (global->tokenbsize *= 2)); global->tokenbuf = realloc(global->tokenbuf, 1 + (global->tokenbsize *= 2));
global->tokenbuf[ct++] = c; /* Store token byte */ global->tokenbuf[ct++] = c; /* Store token byte */
nhash += c; /* Update hash value */ nhash += c; /* Update hash value */
c = get(global); c = fpp_get(global);
} while (type[c] == LET || type[c] == DIG); } while (type[c] == LET || type[c] == DIG);
unget(global); /* Rescan terminator */ fpp_unget(global); /* Rescan terminator */
global->tokenbuf[ct] = EOS; /* Terminate token */ global->tokenbuf[ct] = EOS; /* Terminate token */
if (isrecurse) /* Recursive definition */ if (isrecurse) /* Recursive definition */
return(NULL); /* undefined just now */ return(NULL); /* undefined just now */
@ -568,15 +572,15 @@ DEFBUF *lookid(struct Global *global,
return((temp == 0) ? dp : NULL); return((temp == 0) ? dp : NULL);
} }
DEFBUF *defendel(struct Global *global, DEFBUF *fpp_defendel(struct Global *global,
char *name, char *name,
int delete) /* TRUE to delete a symbol */ int delete) /* FPP_TRUE to delete a symbol */
{ {
/* /*
* Enter this name in the lookup table (delete = FALSE) * Enter this name in the lookup table (delete = FPP_FALSE)
* or delete this name (delete = TRUE). * or delete this name (delete = FPP_TRUE).
* Returns a pointer to the define block (delete = FALSE) * Returns a pointer to the define block (delete = FPP_FALSE)
* Returns NULL if the symbol wasn't defined (delete = TRUE). * Returns NULL if the symbol wasn't defined (delete = FPP_TRUE).
*/ */
DEFBUF *dp; DEFBUF *dp;
@ -618,8 +622,7 @@ DEFBUF *defendel(struct Global *global,
return(dp); return(dp);
} }
void fpp_delalldefines(struct Global *global)
void delalldefines(struct Global *global)
{ {
/* /*
* Delete all the defines in the tables and free memory * Delete all the defines in the tables and free memory
@ -642,92 +645,92 @@ void delalldefines(struct Global *global)
} }
void outdefines(struct Global *global) void fpp_outdefines(struct Global *global)
{ {
DEFBUF *dp; DEFBUF *dp;
DEFBUF **syp; DEFBUF **syp;
delbuiltindefines(global); /* Delete built-in #defines */ fpp_delbuiltindefines(global); /* Delete built-in #defines */
for (syp = global->symtab; syp < &global->symtab[SBSIZE]; syp++) { for (syp = global->symtab; syp < &global->symtab[SBSIZE]; syp++) {
if ((dp = *syp) != (DEFBUF *) NULL) { if ((dp = *syp) != (DEFBUF *) NULL) {
do { do {
outadefine(global, dp); fpp_outadefine(global, dp);
} while ((dp = dp->link) != (DEFBUF *) NULL); } while ((dp = dp->link) != (DEFBUF *) NULL);
} }
} }
} }
INLINE FILE_LOCAL INLINE FILE_LOCAL
void outadefine(struct Global *global, DEFBUF *dp) void fpp_outadefine(struct Global *global, DEFBUF *dp)
{ {
char *cp; char *cp;
int c; int c;
/* printf("#define %s", dp->name); */ /* printf("#define %s", dp->name); */
Putstring(global, "#define "); fpp_Putstring(global, "#define ");
Putstring(global, dp->name); fpp_Putstring(global, dp->name);
if (dp->nargs > 0) { if (dp->nargs > 0) {
int i; int i;
Putchar(global, '('); fpp_Putchar(global, '(');
for (i = 1; i < dp->nargs; i++) { for (i = 1; i < dp->nargs; i++) {
/* printf("__%d,", i); */ /* printf("__%d,", i); */
Putstring(global, "__"); fpp_Putstring(global, "__");
Putint(global, i); fpp_Putint(global, i);
Putchar(global, ','); fpp_Putchar(global, ',');
} }
/* printf("__%d)", i); */ /* printf("__%d)", i); */
Putstring(global, "__"); fpp_Putstring(global, "__");
Putint(global, i); fpp_Putint(global, i);
Putchar(global, ')'); fpp_Putchar(global, ')');
} else if (dp->nargs == 0) { } else if (dp->nargs == 0) {
Putstring(global, "()"); fpp_Putstring(global, "()");
} }
if (dp->repl != NULL) { if (dp->repl != NULL) {
Putchar(global, '\t'); fpp_Putchar(global, '\t');
for (cp = dp->repl; (c = *cp++ & 0xFF) != EOS;) { for (cp = dp->repl; (c = *cp++ & 0xFF) != EOS;) {
if (c >= MAC_PARM && c < (MAC_PARM + PAR_MAC)) { if (c >= MAC_PARM && c < (MAC_PARM + PAR_MAC)) {
/* printf("__%d", c - MAC_PARM + 1); */ /* printf("__%d", c - MAC_PARM + 1); */
Putstring(global, "__"); fpp_Putstring(global, "__");
Putint(global, c - MAC_PARM + 1); fpp_Putint(global, c - MAC_PARM + 1);
} else if (isprint(c) || c == '\t' || c == '\n') } else if (isprint(c) || c == '\t' || c == '\n')
Putchar(global, c); fpp_Putchar(global, c);
else switch (c) { else switch (c) {
case QUOTE_PARM: case QUOTE_PARM:
Putchar(global, '#'); fpp_Putchar(global, '#');
break; break;
case DEF_MAGIC: /* Special anti-recursion */ case DEF_MAGIC: /* Special anti-recursion */
case MAC_PARM + PAR_MAC: /* Special "arg" marker */ case MAC_PARM + PAR_MAC: /* Special "arg" marker */
break; break;
case COM_SEP: case COM_SEP:
#if COMMENT_INVISIBLE #if COMMENT_INVISIBLE
Putstring(global, "/**/"); fpp_Putstring(global, "/**/");
#else #else
Putchar(global, ' '); fpp_Putchar(global, ' ');
#endif #endif
break; break;
case TOK_SEP: case TOK_SEP:
Putstring(global, "##"); fpp_Putstring(global, "##");
break; break;
default: default:
{ {
/* Octal output! */ /* Octal output! */
char buffer[32]; char buffer[32];
sprintf(buffer, "\\0%o", c); sprintf(buffer, "\\0%o", c);
Putstring(global, buffer); fpp_Putstring(global, buffer);
} }
} }
} }
} }
Putchar(global, '\n'); fpp_Putchar(global, '\n');
} }
/* /*
* G E T * G E T
*/ */
int get(struct Global *global) int fpp_get(struct Global *global)
{ {
/* /*
* Return the next character from a macro or the current file. * Return the next character from a macro or the current file.
@ -783,12 +786,12 @@ int get(struct Global *global)
if ((global->infile = file->parent) != NULL) { if ((global->infile = file->parent) != NULL) {
/* /*
* There is an "ungotten" newline in the current * There is an "ungotten" newline in the current
* infile buffer (set there by doinclude() in * infile buffer (set there by fpp_doinclude() in
* cpp1.c). Thus, we know that the mainline code * cpp1.c). Thus, we know that the mainline code
* is skipping over blank lines and will do a * is skipping over blank lines and will do a
* #line at its convenience. * #line at its convenience.
*/ */
global->wrongline = TRUE; /* Need a #line now */ global->wrongline = FPP_TRUE; /* Need a #line now */
} }
} }
} }
@ -825,13 +828,13 @@ int get(struct Global *global)
if (global->instring) /* Strings just return */ if (global->instring) /* Strings just return */
return (c); /* the character. */ return (c); /* the character. */
else if (c == '/') { /* Comment? */ else if (c == '/') { /* Comment? */
global->instring = TRUE; /* So get() won't loop */ global->instring = FPP_TRUE; /* So fpp_get() won't loop */
/* Check next byte for '*' and if(cplusplus) also '/' */ /* Check next byte for '*' and if(cplusplus) also '/' */
if ( (c = get(global)) != '*' ) if ( (c = fpp_get(global)) != '*' )
if(!global->cplusplus || (global->cplusplus && c!='/')) { if(!global->cplusplus || (global->cplusplus && c!='/')) {
global->instring = FALSE; /* Nope, no comment */ global->instring = FPP_FALSE; /* Nope, no comment */
unget(global); /* Push the char. back */ fpp_unget(global); /* Push the char. back */
return ('/'); /* Return the slash */ return ('/'); /* Return the slash */
} }
@ -839,49 +842,49 @@ int get(struct Global *global)
if (global->keepcomments) { /* If writing comments */ if (global->keepcomments) { /* If writing comments */
global->comment = TRUE; /* information that a comment has been output */ global->comment = FPP_TRUE; /* information that a comment has been output */
if(global->showspace) { if(global->showspace) {
/* Show all whitespaces! */ /* Show all whitespaces! */
global->spacebuf[global->chpos] = '\0'; global->spacebuf[global->chpos] = '\0';
Putstring(global, global->spacebuf); fpp_Putstring(global, global->spacebuf);
} }
if(c=='*') { if(c=='*') {
Putchar(global, '/'); /* Write out the */ fpp_Putchar(global, '/'); /* Write out the */
Putchar(global, '*'); /* initializer */ fpp_Putchar(global, '*'); /* initializer */
} else { } else {
/* C++ style comment */ /* C++ style comment */
Putchar(global, '/'); /* Write out the */ fpp_Putchar(global, '/'); /* Write out the */
Putchar(global, '/'); /* initializer */ fpp_Putchar(global, '/'); /* initializer */
} }
} }
if(global->cplusplus && c=='/') { /* Eat C++ comment! */ if(global->cplusplus && c=='/') { /* Eat C++ comment! */
do { do {
c=get(global); c=fpp_get(global);
if(global->keepcomments) if(global->keepcomments)
Putchar(global, c); fpp_Putchar(global, c);
} while(c!='\n' && c!=EOF_CHAR); /* eat all to EOL or EOF */ } while(c!='\n' && c!=EOF_CHAR); /* eat all to EOL or EOF */
global->instring = FALSE; /* End of comment */ global->instring = FPP_FALSE; /* End of comment */
return(c); /* Return the end char */ return(c); /* Return the end char */
} }
for (;;) { /* Eat a comment */ for (;;) { /* Eat a comment */
c = get(global); c = fpp_get(global);
test: test:
if (global->keepcomments && c != EOF_CHAR) if (global->keepcomments && c != EOF_CHAR)
Putchar(global, c); fpp_Putchar(global, c);
switch (c) { switch (c) {
case EOF_CHAR: case EOF_CHAR:
cerror(global, ERROR_EOF_IN_COMMENT); fpp_cerror(global, ERROR_EOF_IN_COMMENT);
return (EOF_CHAR); return (EOF_CHAR);
case '/': case '/':
if(global->nestcomments || global->warnnestcomments) { if(global->nestcomments || global->warnnestcomments) {
if((c = get(global)) != '*') if((c = fpp_get(global)) != '*')
goto test; goto test;
if(global->warnnestcomments) { if(global->warnnestcomments) {
cwarn(global, WARN_NESTED_COMMENT); fpp_cwarn(global, WARN_NESTED_COMMENT);
} }
if(global->nestcomments) if(global->nestcomments)
comments++; comments++;
@ -889,16 +892,16 @@ int get(struct Global *global)
break; break;
case '*': case '*':
if ((c = get(global)) != '/') /* If comment doesn't */ if ((c = fpp_get(global)) != '/') /* If comment doesn't */
goto test; /* end, look at next */ goto test; /* end, look at next */
if (global->keepcomments) { /* Put out the comment */ if (global->keepcomments) { /* Put out the comment */
Putchar(global, c); /* terminator, too */ fpp_Putchar(global, c); /* terminator, too */
} }
if(--comments) if(--comments)
/* nested comment, continue! */ /* nested comment, continue! */
break; break;
global->instring = FALSE; /* End of comment, */ global->instring = FPP_FALSE; /* End of comment, */
/* /*
* A comment is syntactically "whitespace" -- * A comment is syntactically "whitespace" --
* however, there are certain strange sequences * however, there are certain strange sequences
@ -928,18 +931,18 @@ int get(struct Global *global)
case '\n': /* we'll need a #line */ case '\n': /* we'll need a #line */
if (!global->keepcomments) if (!global->keepcomments)
global->wrongline = TRUE; /* later... */ global->wrongline = FPP_TRUE; /* later... */
default: /* Anything else is */ default: /* Anything else is */
break; /* Just a character */ break; /* Just a character */
} /* End switch */ } /* End switch */
} /* End comment loop */ } /* End comment loop */
} /* End if in comment */ } /* End if in comment */
else if (!global->inmacro && c == '\\') { /* If backslash, peek */ else if (!global->inmacro && c == '\\') { /* If backslash, peek */
if ((c = get(global)) == '\n') { /* for a <nl>. If so, */ if ((c = fpp_get(global)) == '\n') { /* for a <nl>. If so, */
global->wrongline = TRUE; global->wrongline = FPP_TRUE;
goto newline; goto newline;
} else { /* Backslash anything */ } else { /* Backslash anything */
unget(global); /* Get it later */ fpp_unget(global); /* Get it later */
return ('\\'); /* Return the backslash */ return ('\\'); /* Return the backslash */
} }
} else if (c == '\f' || c == VT) /* Form Feed, Vertical */ } else if (c == '\f' || c == VT) /* Form Feed, Vertical */
@ -947,20 +950,20 @@ int get(struct Global *global)
return (c); /* Just return the char */ return (c); /* Just return the char */
} }
void unget(struct Global *global) void fpp_unget(struct Global *global)
{ {
/* /*
* Backup the pointer to reread the last character. Fatal error * Backup the pointer to reread the last character. Fatal error
* (code bug) if we backup too far. unget() may be called, * (code bug) if we backup too far. fpp_unget() may be called,
* without problems, at end of file. Only one character may * without problems, at end of file. Only one character may
* be ungotten. If you need to unget more, call ungetstring(). * be ungotten. If you need to unget more, call fpp_ungetstring().
*/ */
FILEINFO *file; FILEINFO *file;
if ((file = global->infile) == NULL) if ((file = global->infile) == NULL)
return; /* Unget after EOF */ return; /* Unget after EOF */
if (--file->bptr < file->buffer) { if (--file->bptr < file->buffer) {
cfatal(global, FATAL_TOO_MUCH_PUSHBACK); fpp_cfatal(global, FATAL_TOO_MUCH_PUSHBACK);
/* This happens only if used the wrong way! */ /* This happens only if used the wrong way! */
return; return;
} }
@ -968,7 +971,7 @@ void unget(struct Global *global)
--global->line; /* Unget the line number, too */ --global->line; /* Unget the line number, too */
} }
ReturnCode ungetstring(struct Global *global, char *text) ReturnCode fpp_ungetstring(struct Global *global, char *text)
{ {
/* /*
* Push a string back on the input stream. This is done by treating * Push a string back on the input stream. This is done by treating
@ -978,13 +981,13 @@ ReturnCode ungetstring(struct Global *global, char *text)
FILEINFO *file; FILEINFO *file;
ReturnCode ret; ReturnCode ret;
ret = getfile(global, strlen(text) + 1, "", &file); ret = fpp_getfile(global, strlen(text) + 1, "", &file);
if(!ret) if(!ret)
strcpy(file->buffer, text); strcpy(file->buffer, text);
return(ret); return(ret);
} }
int cget(struct Global *global) int fpp_cget(struct Global *global)
{ {
/* /*
* Get one character, absorb "funny space" after comments or * Get one character, absorb "funny space" after comments or
@ -993,7 +996,7 @@ int cget(struct Global *global)
int c; int c;
do { do {
c = get(global); c = fpp_get(global);
#if COMMENT_INVISIBLE #if COMMENT_INVISIBLE
} while (c == TOK_SEP || c == COM_SEP); } while (c == TOK_SEP || c == COM_SEP);
#else #else
@ -1007,7 +1010,7 @@ int cget(struct Global *global)
*/ */
INLINE FILE_LOCAL INLINE FILE_LOCAL
void domsg(struct Global *global, void fpp_domsg(struct Global *global,
ErrorCode error, /* error message number */ ErrorCode error, /* error message number */
va_list arg) /* Something for the message */ va_list arg) /* Something for the message */
{ {
@ -1106,8 +1109,8 @@ void domsg(struct Global *global,
for (file = global->infile; file && !file->fp; file = file->parent) for (file = global->infile; file && !file->fp; file = file->parent)
; ;
tp = file ? file->filename : 0; tp = file ? file->filename : 0;
Error(global, "%s\"%s\", line %d: %s: ", fpp_Error(global, "%s\"%s\", line %d: %s: ",
MSG_PREFIX, tp, global->infile?global->line:(file?file->line:0), severity); MSG_PREFIX, tp, global->infile->fp?global->line:file->line, severity);
if(global->error) if(global->error)
global->error(global->userdata, ErrorMessage[error], arg); global->error(global->userdata, ErrorMessage[error], arg);
#if defined(UNIX) #if defined(UNIX)
@ -1117,15 +1120,15 @@ void domsg(struct Global *global,
else else
return; return;
#endif #endif
Error(global, "\n"); fpp_Error(global, "\n");
if (file) /*OIS*0.92*/ if (file) /*OIS*0.92*/
while ((file = file->parent) != NULL) { /* Print #includes, too */ while ((file = file->parent) != NULL) { /* Print #includes, too */
tp = file->parent ? "," : "."; tp = file->parent ? "," : ".";
if (file->fp == NULL) if (file->fp == NULL)
Error(global, " from macro %s%s\n", file->filename, tp); fpp_Error(global, " from macro %s%s\n", file->filename, tp);
else else
Error(global, " from file %s, line %d%s\n", fpp_Error(global, " from file %s, line %d%s\n",
(file->progname != NULL) ? file->progname : file->filename, (file->progname != NULL) ? file->progname : file->filename,
file->line, tp); file->line, tp);
} }
@ -1135,7 +1138,7 @@ void domsg(struct Global *global,
global->errors++; global->errors++;
} }
void cerror(struct Global *global, void fpp_cerror(struct Global *global,
ErrorCode message, ErrorCode message,
...) /* arguments */ ...) /* arguments */
{ {
@ -1144,10 +1147,10 @@ void cerror(struct Global *global,
*/ */
va_list arg; va_list arg;
va_start(arg, message); va_start(arg, message);
domsg(global, message, arg); fpp_domsg(global, message, arg);
} }
void Error(struct Global *global, char *format, ...) void fpp_Error(struct Global *global, char *format, ...)
{ {
/* /*
* Just get the arguments and send a decent string to the user error * Just get the arguments and send a decent string to the user error

124
3rdparty/fcpp/cppadd.h поставляемый
Просмотреть файл

@ -67,7 +67,7 @@ struct Global {
int errors; /* cpp error counter */ int errors; /* cpp error counter */
FILEINFO *infile; /* Current input file */ FILEINFO *infile; /* Current input file */
#if DEBUG #if DEBUG
int debug; /* TRUE if debugging now */ int debug; /* FPP_TRUE if debugging now */
#endif #endif
/* /*
* This counter is incremented when a macro expansion is initiated. * This counter is incremented when a macro expansion is initiated.
@ -83,7 +83,7 @@ struct Global {
int rec_recover; /* Unwind recursive macros */ int rec_recover; /* Unwind recursive macros */
/* /*
* instring is set TRUE when a string is scanned. It modifies the * instring is set FPP_TRUE when a string is scanned. It modifies the
* behavior of the "get next character" routine, causing all characters * behavior of the "get next character" routine, causing all characters
* to be passed to the caller (except <DEF_MAGIC>). Note especially that * to be passed to the caller (except <DEF_MAGIC>). Note especially that
* comments and \<newline> are not removed from the source. (This * comments and \<newline> are not removed from the source. (This
@ -95,17 +95,17 @@ struct Global {
* shouldn't delimit tokens, but we'll worry about that some other * shouldn't delimit tokens, but we'll worry about that some other
* time -- it is more important to prevent infinitly long output lines. * time -- it is more important to prevent infinitly long output lines.
* *
* instring and inmarcor are parameters to the get() routine which * instring and inmarcor are parameters to the fpp_get() routine which
* were made global for speed. * were made global for speed.
*/ */
int instring; /* TRUE if scanning string */ int instring; /* FPP_TRUE if scanning string */
int inmacro; /* TRUE if #defining a macro */ int inmacro; /* FPP_TRUE if #defining a macro */
/* /*
* work[] and workp are used to store one piece of text in a temporay * work[] and workp are used to store one piece of text in a temporay
* buffer. To initialize storage, set workp = work. To store one * buffer. To initialize storage, set workp = work. To store one
* character, call save(c); (This will fatally exit if there isn't * character, call fpp_save(c); (This will fatally exit if there isn't
* room.) To terminate the string, call save(EOS). Note that * room.) To terminate the string, call fpp_save(EOS). Note that
* the work buffer is used by several subroutines -- be sure your * the work buffer is used by several subroutines -- be sure your
* data won't be overwritten. The extra byte in the allocation is * data won't be overwritten. The extra byte in the allocation is
* needed for string formal replacement. * needed for string formal replacement.
@ -114,7 +114,7 @@ struct Global {
char *workp; /* Work buffer pointer */ char *workp; /* Work buffer pointer */
/* /*
* keepcomments is set TRUE by the -C option. If TRUE, comments * keepcomments is set FPP_TRUE by the -C option. If FPP_TRUE, comments
* are written directly to the output stream. This is needed if * are written directly to the output stream. This is needed if
* the output from cpp is to be passed to lint (which uses commands * the output from cpp is to be passed to lint (which uses commands
* embedded in comments). cflag contains the permanent state of the * embedded in comments). cflag contains the permanent state of the
@ -138,10 +138,10 @@ struct Global {
* ifstack[] holds information about nested #if's. It is always * ifstack[] holds information about nested #if's. It is always
* accessed via *ifptr. The information is as follows: * accessed via *ifptr. The information is as follows:
* WAS_COMPILING state of compiling flag at outer level. * WAS_COMPILING state of compiling flag at outer level.
* ELSE_SEEN set TRUE when #else seen to prevent 2nd #else. * ELSE_SEEN set FPP_TRUE when #else seen to prevent 2nd #else.
* TRUE_SEEN set TRUE when #if or #elif succeeds * FPP_TRUE_SEEN set FPP_TRUE when #if or #elif succeeds
* ifstack[0] holds the compiling flag. It is TRUE if compilation * ifstack[0] holds the compiling flag. It is FPP_TRUE if compilation
* is currently enabled. Note that this must be initialized TRUE. * is currently enabled. Note that this must be initialized FPP_TRUE.
*/ */
char ifstack[BLK_NEST]; /* #if information */ char ifstack[BLK_NEST]; /* #if information */
char *ifptr; /* -> current ifstack[] */ char *ifptr; /* -> current ifstack[] */
@ -158,7 +158,7 @@ struct Global {
*/ */
char *include[NINCLUDE]; char *include[NINCLUDE];
char includeshow[NINCLUDE]; /* show it or not! */ char includeshow[NINCLUDE]; /* show it or not! */
char included; unsigned included;
/* /*
* This is the table used to predefine target machine and operating * This is the table used to predefine target machine and operating
@ -176,7 +176,7 @@ struct Global {
/* /*
* This is the variable saying if Cpp should remove C++ style comments from * This is the variable saying if Cpp should remove C++ style comments from
* the output. Default is... TRUE, yes, pronto, do it!!! * the output. Default is... FPP_TRUE, yes, pronto, do it!!!
*/ */
char cplusplus; char cplusplus;
@ -197,7 +197,7 @@ struct Global {
DEFBUF *symtab[SBSIZE]; /* Symbol table queue headers */ DEFBUF *symtab[SBSIZE]; /* Symbol table queue headers */
int evalue; /* Current value from evallex() */ int evalue; /* Current value from fpp_evallex() */
void (*depends)(char *filename, void *); /* depends function */ void (*depends)(char *filename, void *); /* depends function */
@ -225,7 +225,7 @@ struct Global {
char showspace; /* display all whitespaces as they are */ char showspace; /* display all whitespaces as they are */
char comment; /* TRUE if a comment just has been written to output */ char comment; /* FPP_TRUE if a comment just has been written to output */
char *spacebuf; /* Buffer to store whitespaces in if -H */ char *spacebuf; /* Buffer to store whitespaces in if -H */
@ -242,7 +242,7 @@ struct Global {
char out; /* should we output anything now? */ char out; /* should we output anything now? */
char rightconcat; /* should the right part of a concatenation be avaluated char rightconcat; /* should the right part of a concatenation be avaluated
before the concat (TRUE) or after (FALSE) */ before the concat (FPP_TRUE) or after (FPP_FALSE) */
char *initialfunc; /* file to include first in all functions */ char *initialfunc; /* file to include first in all functions */
char *excludedinit[20]; /* functions (names) excluded from the initfunc */ char *excludedinit[20]; /* functions (names) excluded from the initfunc */
@ -251,6 +251,10 @@ struct Global {
char outputfunctions; /* output all discovered functions to stderr! */ char outputfunctions; /* output all discovered functions to stderr! */
char webmode; /* WWW process mode */ char webmode; /* WWW process mode */
char allowincludelocal;
FILE* (*openfile)(char *,char *, void *);
}; };
typedef enum { typedef enum {
@ -359,56 +363,56 @@ typedef enum {
} ReturnCode; } ReturnCode;
/* Nasty defines to make them appear as three different functions! */ /* Nasty defines to make them appear as three different functions! */
#define cwarn cerror #define fpp_cwarn fpp_cerror
#define cfatal cerror #define fpp_cfatal fpp_cerror
/********************************************************************** /**********************************************************************
* PROTOTYPES: * PROTOTYPES:
*********************************************************************/ *********************************************************************/
int PREFIX fppPreProcess(REG(a0) struct fppTag *); int PREFIX fppPreProcess(REG(a0) struct fppTag *);
void Freemem(void *); void fpp_Freemem(void *);
void Error(struct Global *, char *, ...); void fpp_Error(struct Global *, char *, ...);
void Putchar(struct Global *, int); void fpp_Putchar(struct Global *, int);
void Putstring(struct Global *, char *); void fpp_Putstring(struct Global *, char *);
void Putint(struct Global *, int); void fpp_Putint(struct Global *, int);
char *savestring(struct Global *, char *); char *fpp_savestring(struct Global *, char *);
ReturnCode addfile(struct Global *, FILE *, char *); ReturnCode fpp_addfile(struct Global *, FILE *, char *);
int catenate(struct Global *, ReturnCode *); int fpp_catenate(struct Global *, int lhs_number, ReturnCode *);
void cerror(struct Global *, ErrorCode, ...); void fpp_cerror(struct Global *, ErrorCode, ...);
ReturnCode control(struct Global *, int *); ReturnCode fpp_control(struct Global *, int *);
ReturnCode dodefine(struct Global *); ReturnCode fpp_dodefine(struct Global *);
int dooptions(struct Global *, struct fppTag *); int fpp_dooptions(struct Global *, struct fppTag *);
void doundef(struct Global *); void fpp_doundef(struct Global *);
void dumpparm(char *); void fpp_dumpparm(char *);
ReturnCode expand(struct Global *, DEFBUF *); ReturnCode fpp_expand(struct Global *, DEFBUF *);
int get(struct Global *); int fpp_get(struct Global *);
ReturnCode initdefines(struct Global *); ReturnCode fpp_initdefines(struct Global *);
void outdefines(struct Global *); void fpp_outdefines(struct Global *);
ReturnCode save(struct Global *, int); ReturnCode fpp_save(struct Global *, int);
void scanid(struct Global *, int); void fpp_scanid(struct Global *, int);
ReturnCode scannumber(struct Global *, int, ReturnCode(*)(struct Global *, int)); ReturnCode fpp_scannumber(struct Global *, int, ReturnCode(*)(struct Global *, int));
ReturnCode scanstring(struct Global *, int, ReturnCode(*)(struct Global *, int)); ReturnCode fpp_scanstring(struct Global *, int, ReturnCode(*)(struct Global *, int));
void unget(struct Global *); void fpp_unget(struct Global *);
ReturnCode ungetstring(struct Global *, char *); ReturnCode fpp_ungetstring(struct Global *, char *);
ReturnCode eval(struct Global *, int *); ReturnCode fpp_eval(struct Global *, int *);
#ifdef DEBUG_EVAL #ifdef DEBUG_EVAL
void dumpstack(OPTAB[NEXP], register OPTAB *, int [NEXP], register int *); void fpp_dumpstack(OPTAB[NEXP], register OPTAB *, int [NEXP], register int *);
#endif #endif
void skipnl(struct Global *); void fpp_skipnl(struct Global *);
int skipws(struct Global *); int fpp_skipws(struct Global *);
ReturnCode macroid(struct Global *, int *); ReturnCode fpp_macroid(struct Global *, int *);
ReturnCode getfile(struct Global *, size_t, char *, FILEINFO **); ReturnCode fpp_getfile(struct Global *, size_t, char *, FILEINFO **);
DEFBUF *lookid(struct Global *, int ); DEFBUF *fpp_lookid(struct Global *, int );
DEFBUF *defendel(struct Global *, char *, int); DEFBUF *fpp_defendel(struct Global *, char *, int);
#if DEBUG #if DEBUG
void dumpdef(char *); void fpp_dumpdef(char *);
void dumpadef(char *, register DEFBUF *); void fpp_dumpadef(char *, register DEFBUF *);
#endif #endif
ReturnCode openfile(struct Global *,char *); ReturnCode fpp_openfile(struct Global *,char *);
int cget(struct Global *); int fpp_cget(struct Global *);
void delbuiltindefines(struct Global *); void fpp_delbuiltindefines(struct Global *);
void delalldefines(struct Global *); void fpp_delalldefines(struct Global *);
char *Getmem(struct Global *, int); char *fpp_Getmem(struct Global *, int);
ReturnCode openinclude(struct Global *, char *, int); ReturnCode fpp_openinclude(struct Global *, char *, int);
ReturnCode expstuff(struct Global *, char *, char *); ReturnCode fpp_expstuff(struct Global *, char *, char *);

58
3rdparty/fcpp/cppdef.h поставляемый
Просмотреть файл

@ -35,9 +35,9 @@
/* Convert Emacs's conventions for BIG_ENDIAN to cpp's convention. */ /* Convert Emacs's conventions for BIG_ENDIAN to cpp's convention. */
#ifdef BIG_ENDIAN #ifdef BIG_ENDIAN
#undef BIG_ENDIAN #undef BIG_ENDIAN
#define BIG_ENDIAN TRUE #define BIG_ENDIAN FPP_TRUE
#else /* not BIG_ENDIAN */ #else /* not BIG_ENDIAN */
#define BIG_ENDIAN FALSE #define BIG_ENDIAN FPP_FALSE
#endif /* BIG_ENDIAN */ #endif /* BIG_ENDIAN */
/* Emacs uses the names index and rindex and defines them as str(r)chr if nec; /* Emacs uses the names index and rindex and defines them as str(r)chr if nec;
@ -73,12 +73,12 @@
*/ */
/* /*
* This redundant definition of TRUE and FALSE works around * This redundant definition of FPP_TRUE and FPP_FALSE works around
* a limitation of Decus C. * a limitation of Decus C.
*/ */
#ifndef TRUE #ifndef FPP_TRUE
#define TRUE 1 #define FPP_TRUE 1
#define FALSE 0 #define FPP_FALSE 0
#endif #endif
/* /*
@ -134,27 +134,27 @@
* to be marked "static" even though they are referenced * to be marked "static" even though they are referenced
* by "extern" statements elsewhere. * by "extern" statements elsewhere.
* *
* OK_DOLLAR Should be set TRUE if $ is a valid alphabetic character * OK_DOLLAR Should be set FPP_TRUE if $ is a valid alphabetic character
* in identifiers (default), or zero if $ is invalid. * in identifiers (default), or zero if $ is invalid.
* Default is TRUE. * Default is FPP_TRUE.
* *
* OK_CONCAT Should be set TRUE if # may be used to concatenate * OK_CONCAT Should be set FPP_TRUE if # may be used to concatenate
* tokens in macros (per the Ansi Draft Standard) or * tokens in macros (per the Ansi Draft Standard) or
* FALSE for old-style # processing (needed if cpp is * FPP_FALSE for old-style # processing (needed if cpp is
* to process assembler source code). * to process assembler source code).
*/ */
#define OK_CONCAT TRUE #define OK_CONCAT FPP_TRUE
/* /*
* OK_DATE Predefines the compilation date if set TRUE. * OK_DATE Predefines the compilation date if set FPP_TRUE.
* Not permitted by the Nov. 12, 1984 Draft Standard. * Not permitted by the Nov. 12, 1984 Draft Standard.
*/ */
#define OK_DATE TRUE #define OK_DATE FPP_TRUE
/* /*
* *
* OK_SIZEOF Permits sizeof in #if preprocessor expressions. * OK_SIZEOF Permits sizeof in #if preprocessor expressions.
* According to K&R V2 (page 232), this is not allowed. * According to K&R V2 (page 232), this is not allowed.
*/ */
#define OK_SIZEOF TRUE #define OK_SIZEOF FPP_TRUE
/* /*
* S_CHAR etc. Define the sizeof the basic TARGET machine word types. * S_CHAR etc. Define the sizeof the basic TARGET machine word types.
* By default, sizes are set to the values for the HOST * By default, sizes are set to the values for the HOST
@ -188,9 +188,9 @@
*/ */
#if OLD_PREPROCESSOR #if OLD_PREPROCESSOR
#define OK_DOLLAR FALSE #define OK_DOLLAR FPP_FALSE
#define OK_CONCAT FALSE #define OK_CONCAT FPP_FALSE
#define COMMENT_INVISIBLE TRUE #define COMMENT_INVISIBLE FPP_TRUE
#endif #endif
/* /*
@ -209,15 +209,15 @@
#endif #endif
/* /*
* BIG_ENDIAN is set TRUE on machines (such as the IBM 360 series) * BIG_ENDIAN is set FPP_TRUE on machines (such as the IBM 360 series)
* where 'ab' stores 'a' in the high-bits and 'b' in the low-bits. * where 'ab' stores 'a' in the high-bits and 'b' in the low-bits.
* It is set FALSE on machines (such as the PDP-11 and Vax-11) * It is set FPP_FALSE on machines (such as the PDP-11 and Vax-11)
* where 'ab' stores 'a' in the low-bits and 'b' in the high-bits. * where 'ab' stores 'a' in the low-bits and 'b' in the high-bits.
* (Or is it the other way around?) -- Warning: BIG_ENDIAN code is untested. * (Or is it the other way around?) -- Warning: BIG_ENDIAN code is untested.
* [I *seems* to be the other way around, according to the code /OIS] * [I *seems* to be the other way around, according to the code /OIS]
*/ */
#ifndef BIG_ENDIAN #ifndef BIG_ENDIAN
#define BIG_ENDIAN FALSE #define BIG_ENDIAN FPP_FALSE
#endif #endif
/* /*
@ -227,27 +227,27 @@
* expansions. This was removed from the Draft Ansi Standard. * expansions. This was removed from the Draft Ansi Standard.
*/ */
#ifndef COMMENT_INVISIBLE #ifndef COMMENT_INVISIBLE
#define COMMENT_INVISIBLE FALSE #define COMMENT_INVISIBLE FPP_FALSE
#endif #endif
/* /*
* OK_DOLLAR enables use of $ as a valid "letter" in identifiers. * OK_DOLLAR enables use of $ as a valid "letter" in identifiers.
* This is a permitted extension to the Ansi Standard and is required * This is a permitted extension to the Ansi Standard and is required
* for e.g., VMS, RSX-11M, etc. It should be set FALSE if cpp is * for e.g., VMS, RSX-11M, etc. It should be set FPP_FALSE if cpp is
* used to preprocess assembler source on Unix systems. OLD_PREPROCESSOR * used to preprocess assembler source on Unix systems. OLD_PREPROCESSOR
* sets OK_DOLLAR FALSE for that reason. * sets OK_DOLLAR FPP_FALSE for that reason.
*/ */
#ifndef OK_DOLLAR #ifndef OK_DOLLAR
#define OK_DOLLAR TRUE #define OK_DOLLAR FPP_TRUE
#endif #endif
/* /*
* OK_CONCAT enables (one possible implementation of) token concatenation. * OK_CONCAT enables (one possible implementation of) token concatenation.
* If cpp is used to preprocess Unix assembler source, this should be * If cpp is used to preprocess Unix assembler source, this should be
* set FALSE as the concatenation character, #, is used by the assembler. * set FPP_FALSE as the concatenation character, #, is used by the assembler.
*/ */
#ifndef OK_CONCAT #ifndef OK_CONCAT
#define OK_CONCAT TRUE #define OK_CONCAT FPP_TRUE
#endif #endif
/* /*
@ -256,7 +256,7 @@
* by the Draft Ansi Standard. * by the Draft Ansi Standard.
*/ */
#ifndef OK_DATE #ifndef OK_DATE
#define OK_DATE TRUE #define OK_DATE FPP_TRUE
#endif #endif
/* /*
@ -267,7 +267,7 @@
* This option was added in the PDC process, under no. *OIS*0.92*. * This option was added in the PDC process, under no. *OIS*0.92*.
*/ */
#ifndef OK_SIZEOF #ifndef OK_SIZEOF
#define OK_SIZEOF FALSE #define OK_SIZEOF FPP_FALSE
#endif #endif
/* /*
@ -275,7 +275,7 @@
*/ */
#ifndef DEBUG #ifndef DEBUG
#define DEBUG FALSE #define DEBUG FPP_FALSE
#endif #endif
/* /*

66
3rdparty/fcpp/fpp.h поставляемый
Просмотреть файл

@ -35,18 +35,21 @@
* *
*/ */
#ifdef __cplusplus
extern "C" {
#endif
struct fppTag { struct fppTag {
int tag; int tag;
void *data; void *data;
}; };
#ifndef TRUE #ifndef FPP_TRUE
#define TRUE 1 #define FPP_TRUE 1
#endif #endif
#ifndef FALSE #ifndef FPP_FALSE
#define FALSE 0 #define FPP_FALSE 0
#endif #endif
#define NFLAG_BUILTIN 1 #define NFLAG_BUILTIN 1
@ -56,26 +59,26 @@ struct fppTag {
#define FPPTAG_END 0 #define FPPTAG_END 0
/* To make the preprocessed output keep the comments: */ /* To make the preprocessed output keep the comments: */
#define FPPTAG_KEEPCOMMENTS 1 /* data is TRUE or FALSE */ #define FPPTAG_KEEPCOMMENTS 1 /* data is FPP_TRUE or FPP_FALSE */
/* To define symbols to the preprocessor: */ /* To define symbols to the preprocessor: */
#define FPPTAG_DEFINE 2 /* data is the string "symbol" or "symbol=<value>" */ #define FPPTAG_DEFINE 2 /* data is the string "symbol" or "symbol=<value>" */
/* To make the preprocessor ignore all non-fatal errors: */ /* To make the preprocessor ignore all non-fatal errors: */
#define FPPTAG_IGNORE_NONFATAL 3 /* data is TRUE or FALSE */ #define FPPTAG_IGNORE_NONFATAL 3 /* data is FPP_TRUE or FPP_FALSE */
/* To add an include directory to the include directory list: */ /* To add an include directory to the include directory list: */
#define FPPTAG_INCLUDE_DIR 4 /* data is directory name ending with a '/' (on #define FPPTAG_INCLUDE_DIR 4 /* data is directory name ending with a '/' (on
amiga a ':' is also valid) */ amiga a ':' is also valid) */
/* To define all machine specific built-in #defines, default is TRUE: */ /* To define all machine specific built-in #defines, default is FPP_TRUE: */
#define FPPTAG_BUILTINS 5 /* data is TRUE or FALSE */ #define FPPTAG_BUILTINS 5 /* data is FPP_TRUE or FPP_FALSE */
/* To define predefines like __LINE__, __DATE__, etc. default is TRUE: */ /* To define predefines like __LINE__, __DATE__, etc. default is FPP_TRUE: */
#define FPPTAG_PREDEFINES 6 /* data is TRUE or FALSE */ #define FPPTAG_PREDEFINES 6 /* data is FPP_TRUE or FPP_FALSE */
/* To make fpp leave C++ comments in the output: */ /* To make fpp leave C++ comments in the output: */
#define FPPTAG_IGNORE_CPLUSPLUS 7 /* data is TRUE or FALSE */ #define FPPTAG_IGNORE_CPLUSPLUS 7 /* data is FPP_TRUE or FPP_FALSE */
/* To define new sizes to #if sizeof: */ /* To define new sizes to #if sizeof: */
#define FPPTAG_SIZEOF_TABLE 8 /* data is sizeof table string */ #define FPPTAG_SIZEOF_TABLE 8 /* data is sizeof table string */
@ -84,7 +87,7 @@ struct fppTag {
#define FPPTAG_UNDEFINE 9 /* data is symbol name */ #define FPPTAG_UNDEFINE 9 /* data is symbol name */
/* Output all #defines: */ /* Output all #defines: */
#define FPPTAG_OUTPUT_DEFINES 10 /* data is TRUE or FALSE */ #define FPPTAG_OUTPUT_DEFINES 10 /* data is FPP_TRUE or FPP_FALSE */
/* Initial input file name: */ /* Initial input file name: */
#define FPPTAG_INPUT_NAME 11 /* data is string */ #define FPPTAG_INPUT_NAME 11 /* data is string */
@ -98,42 +101,42 @@ struct fppTag {
/* User data, sent in the last argument to the input function: */ /* User data, sent in the last argument to the input function: */
#define FPPTAG_USERDATA 14 /* data is user data */ #define FPPTAG_USERDATA 14 /* data is user data */
/* Whether to exclude #line instructions in the output, default is FALSE */ /* Whether to exclude #line instructions in the output, default is FPP_FALSE */
#define FPPTAG_LINE 15 /* data is TRUE or FALSE */ #define FPPTAG_LINE 15 /* data is FPP_TRUE or FPP_FALSE */
/* Error function. This is called when FPP finds any warning/error/fatal: */ /* Error function. This is called when FPP finds any warning/error/fatal: */
#define FPPTAG_ERROR 16 /* data is function pointer to a #define FPPTAG_ERROR 16 /* data is function pointer to a
"void (*)(void *, char *, va_list)" */ "void (*)(void *, char *, va_list)" */
/* Whether to warn for illegal cpp instructions */ /* Whether to warn for illegal cpp instructions */
#define FPPTAG_WARNILLEGALCPP 17 /* data is boolean, default is FALSE */ #define FPPTAG_WARNILLEGALCPP 17 /* data is boolean, default is FPP_FALSE */
/* Output the 'line' keyword on #line-lines? */ /* Output the 'line' keyword on #line-lines? */
#define FPPTAG_OUTPUTLINE 18 /* data is boolean, default is TRUE */ #define FPPTAG_OUTPUTLINE 18 /* data is boolean, default is FPP_TRUE */
/* Do not output the version information string */ /* Output the version information string */
#define FPPTAG_IGNOREVERSION 19 /* data is boolean, default is FALSE */ #define FPPTAG_SHOWVERSION 19 /* data is boolean, default is FPP_TRUE */
/* Output all included file names to stderr */ /* Output all included file names to stderr */
#define FPPTAG_OUTPUTINCLUDES 20 /* data is boolean, default is FALSE */ #define FPPTAG_OUTPUTINCLUDES 20 /* data is boolean, default is FPP_FALSE */
/* Display warning if there is any brace, bracket or parentheses unbalance */ /* Display warning if there is any brace, bracket or parentheses unbalance */
#define FPPTAG_OUTPUTBALANCE 21 /* data is boolean, default is FALSE */ #define FPPTAG_OUTPUTBALANCE 21 /* data is boolean, default is FPP_FALSE */
/* Display all whitespaces in the source */ /* Display all whitespaces in the source */
#define FPPTAG_OUTPUTSPACE 22 /* data is boolean, default is FALSE */ #define FPPTAG_OUTPUTSPACE 22 /* data is boolean, default is FPP_FALSE */
/* Allow nested comments */ /* Allow nested comments */
#define FPPTAG_NESTED_COMMENTS 23 /* data is boolean, default is FALSE */ #define FPPTAG_NESTED_COMMENTS 23 /* data is boolean, default is FPP_FALSE */
/* Enable warnings at nested comments */ /* Enable warnings at nested comments */
#define FPPTAG_WARN_NESTED_COMMENTS 24 /* data is boolean, default is FALSE */ #define FPPTAG_WARN_NESTED_COMMENTS 24 /* data is boolean, default is FPP_FALSE */
/* Enable warnings at missing includes */ /* Enable warnings at missing includes */
#define FPPTAG_WARNMISSINCLUDE 25 /* data is boolean, default is TRUE */ #define FPPTAG_WARNMISSINCLUDE 25 /* data is boolean, default is FPP_TRUE */
/* Output the main file */ /* Output the main file */
#define FPPTAG_OUTPUTMAIN 26 /* data is boolean, default is TRUE */ #define FPPTAG_OUTPUTMAIN 26 /* data is boolean, default is FPP_TRUE */
/* Include file */ /* Include file */
#define FPPTAG_INCLUDE_FILE 27 /* data is char pointer */ #define FPPTAG_INCLUDE_FILE 27 /* data is char pointer */
@ -142,7 +145,7 @@ struct fppTag {
#define FPPTAG_INCLUDE_MACRO_FILE 28 /* data is char pointer */ #define FPPTAG_INCLUDE_MACRO_FILE 28 /* data is char pointer */
/* Evaluate the right part of a concatenate before the concat */ /* Evaluate the right part of a concatenate before the concat */
#define FPPTAG_RIGHTCONCAT 29 /* data is boolean, default is FALSE */ #define FPPTAG_RIGHTCONCAT 29 /* data is boolean, default is FPP_FALSE */
/* Include the specified file at the beginning of each function */ /* Include the specified file at the beginning of each function */
#define FPPTAG_INITFUNC 30 /* data is char pointer or NULL */ #define FPPTAG_INITFUNC 30 /* data is char pointer or NULL */
@ -159,4 +162,15 @@ struct fppTag {
/* Depends function: */ /* Depends function: */
#define FPPTAG_DEPENDS 34 /* data is an depends funtion */ #define FPPTAG_DEPENDS 34 /* data is an depends funtion */
/* Allow include "X" (rather than <X>) to search local files, default is FPP_TRUE */
#define FPPTAG_ALLOW_INCLUDE_LOCAL 35
/* Fileopen function. If set, this is called when FPP tries to open a file: */
#define FPPTAG_FILEOPENFUNC 36 /* data is function pointer to a
"FILE* (*)(char * filename, char * mode, void * userdata)", default is NULL */
int fppPreProcess(struct fppTag *); int fppPreProcess(struct fppTag *);
#ifdef __cplusplus
} // extern "C"
#endif

42
3rdparty/fcpp/usecpp.c поставляемый
Просмотреть файл

@ -128,8 +128,8 @@ FILE_LOCAL char DoString(struct fppTag **, char *);
extern long __stack=8000; extern long __stack=8000;
#endif #endif
FILE_LOCAL char ignore=FALSE; /* if we should ignore strange flags! */ FILE_LOCAL char ignore=FPP_FALSE; /* if we should ignore strange flags! */
FILE_LOCAL char display=FALSE; /* display all options in use! */ FILE_LOCAL char display=FPP_FALSE; /* display all options in use! */
FILE_LOCAL char dontreadprefs; /* set if only the command line is valid */ FILE_LOCAL char dontreadprefs; /* set if only the command line is valid */
@ -369,37 +369,37 @@ int SetOptions(int argc, char **argv, struct fppTag **tagptr)
case 'H': /* display all whitespaces */ case 'H': /* display all whitespaces */
(*tagptr)->tag = FPPTAG_OUTPUTSPACE; (*tagptr)->tag = FPPTAG_OUTPUTSPACE;
(*tagptr)->data= (void *)TRUE; (*tagptr)->data= (void *)FPP_TRUE;
(*tagptr)++; (*tagptr)++;
break; break;
case 'b': /* display unbalance */ case 'b': /* display unbalance */
(*tagptr)->tag = FPPTAG_OUTPUTBALANCE; (*tagptr)->tag = FPPTAG_OUTPUTBALANCE;
(*tagptr)->data= (void *)TRUE; (*tagptr)->data= (void *)FPP_TRUE;
(*tagptr)++; (*tagptr)++;
break; break;
case 'f': /* output all defined functions! */ case 'f': /* output all defined functions! */
(*tagptr)->tag = FPPTAG_DISPLAYFUNCTIONS; (*tagptr)->tag = FPPTAG_DISPLAYFUNCTIONS;
(*tagptr)->data= (void *)TRUE; (*tagptr)->data= (void *)FPP_TRUE;
(*tagptr)++; (*tagptr)++;
break; break;
case 'F': /* output all included files! */ case 'F': /* output all included files! */
(*tagptr)->tag = FPPTAG_OUTPUTINCLUDES; (*tagptr)->tag = FPPTAG_OUTPUTINCLUDES;
(*tagptr)->data= (void *)TRUE; (*tagptr)->data= (void *)FPP_TRUE;
(*tagptr)++; (*tagptr)++;
break; break;
case 'V': /* do not output version */ case 'V': /* do not output version */
(*tagptr)->tag = FPPTAG_IGNOREVERSION; (*tagptr)->tag = FPPTAG_SHOWVERSION;
(*tagptr)->data= (void *)FALSE; (*tagptr)->data= (void *)FPP_FALSE;
(*tagptr)++; (*tagptr)++;
break; break;
case 'C': /* Keep comments */ case 'C': /* Keep comments */
(*tagptr)->tag = FPPTAG_KEEPCOMMENTS; (*tagptr)->tag = FPPTAG_KEEPCOMMENTS;
(*tagptr)->data= (void *)TRUE; (*tagptr)->data= (void *)FPP_TRUE;
(*tagptr)++; (*tagptr)++;
break; break;
@ -411,12 +411,12 @@ int SetOptions(int argc, char **argv, struct fppTag **tagptr)
case 'd': /* Display all options */ case 'd': /* Display all options */
fprintf(stderr, "FOUND -d flag!\n"); fprintf(stderr, "FOUND -d flag!\n");
display = TRUE; display = FPP_TRUE;
break; break;
case 'E': /* Ignore non-fatal errors */ case 'E': /* Ignore non-fatal errors */
(*tagptr)->tag=FPPTAG_IGNORE_NONFATAL; (*tagptr)->tag=FPPTAG_IGNORE_NONFATAL;
(*tagptr)->data=(void *)TRUE; (*tagptr)->data=(void *)FPP_TRUE;
(*tagptr)++; (*tagptr)++;
break; break;
@ -445,13 +445,13 @@ int SetOptions(int argc, char **argv, struct fppTag **tagptr)
/* Do not output the 'line' keyword */ /* Do not output the 'line' keyword */
(*tagptr)->tag=FPPTAG_OUTPUTLINE; (*tagptr)->tag=FPPTAG_OUTPUTLINE;
} }
(*tagptr)->data=(void *)FALSE; (*tagptr)->data=(void *)FPP_FALSE;
(*tagptr)++; (*tagptr)++;
break; break;
case 'M': /* Do not warn at missing includes */ case 'M': /* Do not warn at missing includes */
(*tagptr)->tag=FPPTAG_WARNMISSINCLUDE; (*tagptr)->tag=FPPTAG_WARNMISSINCLUDE;
(*tagptr)->data=(void *)FALSE; (*tagptr)->data=(void *)FPP_FALSE;
(*tagptr)++; (*tagptr)++;
break; break;
@ -466,31 +466,31 @@ int SetOptions(int argc, char **argv, struct fppTag **tagptr)
case 'N': /* No machine specific built-ins */ case 'N': /* No machine specific built-ins */
(*tagptr)->tag=FPPTAG_BUILTINS; (*tagptr)->tag=FPPTAG_BUILTINS;
(*tagptr)->data=(void *)FALSE; (*tagptr)->data=(void *)FPP_FALSE;
(*tagptr)++; (*tagptr)++;
break; break;
case 'B': /* No predefines like __LINE__, etc. */ case 'B': /* No predefines like __LINE__, etc. */
(*tagptr)->tag=FPPTAG_PREDEFINES; (*tagptr)->tag=FPPTAG_PREDEFINES;
(*tagptr)->data=(void *)FALSE; (*tagptr)->data=(void *)FPP_FALSE;
(*tagptr)++; (*tagptr)++;
break; break;
case 'P': /* No C++ comments */ case 'P': /* No C++ comments */
(*tagptr)->tag=FPPTAG_IGNORE_CPLUSPLUS; (*tagptr)->tag=FPPTAG_IGNORE_CPLUSPLUS;
(*tagptr)->data=(void *)TRUE; (*tagptr)->data=(void *)FPP_TRUE;
(*tagptr)++; (*tagptr)++;
break; break;
case 'p': /* warn about illegal # - instructions */ case 'p': /* warn about illegal # - instructions */
(*tagptr)->tag = FPPTAG_WARNILLEGALCPP; (*tagptr)->tag = FPPTAG_WARNILLEGALCPP;
(*tagptr)->data= (void *)TRUE; (*tagptr)->data= (void *)FPP_TRUE;
(*tagptr)++; (*tagptr)++;
break; break;
case 'R': case 'R':
(*tagptr)->tag = FPPTAG_RIGHTCONCAT; (*tagptr)->tag = FPPTAG_RIGHTCONCAT;
(*tagptr)->data= (void *)TRUE; (*tagptr)->data= (void *)FPP_TRUE;
(*tagptr)++; (*tagptr)++;
break; break;
@ -521,18 +521,18 @@ int SetOptions(int argc, char **argv, struct fppTag **tagptr)
case 'w': /* Output all #defines but not the case 'w': /* Output all #defines but not the
main file */ main file */
(*tagptr)->tag=FPPTAG_OUTPUTMAIN; (*tagptr)->tag=FPPTAG_OUTPUTMAIN;
(*tagptr)->data=(void *)FALSE; (*tagptr)->data=(void *)FPP_FALSE;
(*tagptr)++; (*tagptr)++;
case 'W': /* Output all #defines */ case 'W': /* Output all #defines */
if(!strncmp(ap, "WW", 2)) { if(!strncmp(ap, "WW", 2)) {
(*tagptr)->tag=FPPTAG_WEBMODE; (*tagptr)->tag=FPPTAG_WEBMODE;
(*tagptr)->data=(void *)TRUE; (*tagptr)->data=(void *)FPP_TRUE;
(*tagptr)++; (*tagptr)++;
} }
else { else {
(*tagptr)->tag=FPPTAG_OUTPUT_DEFINES; (*tagptr)->tag=FPPTAG_OUTPUT_DEFINES;
(*tagptr)->data=(void *)TRUE; (*tagptr)->data=(void *)FPP_TRUE;
(*tagptr)++; (*tagptr)++;
} }
break; break;

Просмотреть файл

@ -558,7 +558,7 @@ namespace bgfx
m_tagptr->data = (void*)fppError; m_tagptr->data = (void*)fppError;
m_tagptr++; m_tagptr++;
m_tagptr->tag = FPPTAG_IGNOREVERSION; m_tagptr->tag = FPPTAG_SHOWVERSION;
m_tagptr->data = (void*)0; m_tagptr->data = (void*)0;
m_tagptr++; m_tagptr++;