X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2bda0e173844e8e0f8acf4e8ad8b5c26e5c6fe5d..748a3af8e74ce74fe143650af0b2da2534c70d45:/src/common/doslex.c diff --git a/src/common/doslex.c b/src/common/doslex.c index 67e789afba..be7be146d1 100644 --- a/src/common/doslex.c +++ b/src/common/doslex.c @@ -21,7 +21,23 @@ #ifdef __cplusplus #include + +#ifdef __SALFORDC__ +#include +#include +#else #include +#endif + +#ifdef __VISAGECPP__ +#include +#endif + +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif /* use prototypes in function declarations */ #define YY_USE_PROTOS @@ -119,6 +135,7 @@ int read(); * done when it reached the ';' after the YY_FATAL_ERROR() call. */ +#if !defined(__VISAGECPP__) #define YY_FATAL_ERROR(msg) \ do \ { \ @@ -127,6 +144,18 @@ int read(); exit( 1 ); \ } \ while ( 0 ) +#else +/* suppress expression always false warning */ +int os2var = 0; +#define YY_FATAL_ERROR(msg) \ + do \ + { \ + (void) fputs( msg, stderr ); \ + (void) putc( '\n', stderr ); \ + exit( 1 ); \ + } \ + while ( os2var == 0 ) +#endif /* default yywrap function - always treat EOF as an EOF */ int yywrap(void) { return 1; } @@ -142,6 +171,7 @@ int yywrap(void) { return 1; } #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* special action meaning "start processing a new file" */ +#if !defined(__VISAGECPP__) #define YY_NEW_FILE \ do \ { \ @@ -149,11 +179,20 @@ int yywrap(void) { return 1; } yy_load_buffer_state(); \ } \ while ( 0 ) +#else +#define YY_NEW_FILE \ + do \ + { \ + yy_init_buffer( yy_current_buffer, yyin ); \ + yy_load_buffer_state(); \ + } \ + while ( os2var == 0 ) +#endif /* default declaration of generated scanner - a define so the user can * easily add parameters */ -#define YY_DECL int yylex YY_PROTO(( void )) +#define YY_DECL int yylex YY_PROTO(( void )) /* code executed at the end of each rule */ #define YY_BREAK break; @@ -192,7 +231,7 @@ extern char *malloc(); #endif #define Return(x) return x; -#if defined(VMS) && !defined(strdup) +#if defined(VMS) && ( __VMS_VER < 70000000 ) #define strdup(s) (strcpy((char *)malloc(strlen(s)+1), s)); #endif @@ -213,7 +252,9 @@ static int my_unput(char); if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ YY_FATAL_ERROR( "read() in flex scanner failed" ); #else -# undef unput +# ifndef unput +# undef unput +# endif # define unput(_c) my_unput(_c) #endif @@ -234,6 +275,7 @@ static int my_unput(char); #define EOB_ACT_LAST_MATCH 2 /* return all but the first 'n' matched characters back to the input stream */ +#if !defined(__VISAGECPP__) #define yyless(n) \ do \ { \ @@ -243,6 +285,17 @@ static int my_unput(char); YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) +#else +#define yyless(n) \ + do \ + { \ + /* undo effects of setting up yytext */ \ + *yy_cp = yy_hold_char; \ + yy_c_buf_p = yy_cp = yy_bp + n; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( os2var == 0 ) +#endif #undef unput #define unput(c) yyunput( c, yytext ) @@ -465,7 +518,13 @@ YY_DECL yy_init = 0; } +#if !defined(__VISAGECPP__) while ( 1 ) /* loops until end-of-file is reached */ +#else + os2var = 1; + if (os2var == 0) return 0; + while ( os2var == 1 ) /* loops until end-of-file is reached */ +#endif { yy_cp = yy_c_buf_p; @@ -520,7 +579,7 @@ do_action: /* this label is used only to access EOF actions */ case 1: # line 60 "lexer.l" -{yylval.s = strdup(yytext); Return(INTEGER);} +{yylval.s = strdup((const char*) yytext); Return(INTEGER);} YY_BREAK case 2: # line 62 "lexer.l" @@ -528,18 +587,18 @@ Return(EXP); YY_BREAK case 3: # line 64 "lexer.l" -{yylval.s = strdup(yytext); Return(WORD);} +{yylval.s = strdup((const char*) yytext); Return(WORD);} YY_BREAK case 4: # line 66 "lexer.l" -{int len = strlen(yytext); +{int len = strlen((const char*) yytext); yytext[len-1] = 0; - yylval.s = strdup(yytext+1); + yylval.s = strdup((const char*) (yytext+1)); Return(WORD);} YY_BREAK case 5: # line 71 "lexer.l" -{yylval.s = strdup(yytext); Return(STRING);} +{yylval.s = strdup((const char*) yytext); Return(STRING);} YY_BREAK case 6: # line 73 "lexer.l" @@ -717,6 +776,10 @@ case YY_STATE_EOF(INITIAL): "fatal flex scanner internal error--no action found" ); } } +#if defined(__VISAGECPP__) +/* VA complains about proc maybe not returning a value so return one */ +return 0; +#endif } @@ -724,9 +787,9 @@ case YY_STATE_EOF(INITIAL): * * synopsis * int yy_get_next_buffer(); - * + * * returns a code representing an action - * EOB_ACT_LAST_MATCH - + * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ @@ -1163,7 +1226,7 @@ static int my_unput(char c) #endif -/* Public */ +/* Public */ void LexFromFile(FILE *fd) { lex_read_from_string = 0; @@ -1180,7 +1243,7 @@ void LexFromString(char *buffer) { lex_read_from_string = 1; lex_buffer = buffer; - lex_buffer_length = strlen(buffer); + lex_buffer_length = strlen((const char*) buffer); lex_string_ptr = 0; /* Don't know why this is necessary, but otherwise * lex only works _once_!