=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/parse/cpp.c,v retrieving revision 1.1 retrieving revision 1.6 diff -u -p -r1.1 -r1.6 --- OpenXM_contrib2/asir2000/parse/cpp.c 1999/12/03 07:39:12 1.1 +++ OpenXM_contrib2/asir2000/parse/cpp.c 2015/08/08 14:19:42 1.6 @@ -1,8 +1,52 @@ -/* $OpenXM: OpenXM/src/asir99/parse/cpp.c,v 1.1.1.1 1999/11/10 08:12:34 noro Exp $ */ -#if defined(__MWERKS__) -#define THINK_C -#endif - +/* + * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED + * All rights reserved. + * + * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited, + * non-exclusive and royalty-free license to use, copy, modify and + * redistribute, solely for non-commercial and non-profit purposes, the + * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and + * conditions of this Agreement. For the avoidance of doubt, you acquire + * only a limited right to use the SOFTWARE hereunder, and FLL or any + * third party developer retains all rights, including but not limited to + * copyrights, in and to the SOFTWARE. + * + * (1) FLL does not grant you a license in any way for commercial + * purposes. You may use the SOFTWARE only for non-commercial and + * non-profit purposes only, such as academic, research and internal + * business use. + * (2) The SOFTWARE is protected by the Copyright Law of Japan and + * international copyright treaties. If you make copies of the SOFTWARE, + * with or without modification, as permitted hereunder, you shall affix + * to all such copies of the SOFTWARE the above copyright notice. + * (3) An explicit reference to this SOFTWARE and its copyright owner + * shall be made on your publication or presentation in any form of the + * results obtained by use of the SOFTWARE. + * (4) In the event that you modify the SOFTWARE, you shall notify FLL by + * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification + * for such modification or the source code of the modified part of the + * SOFTWARE. + * + * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL + * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND + * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES' + * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY + * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY. + * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT, + * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL + * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES + * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES + * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY + * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF + * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART + * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY + * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, + * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. + * + * $OpenXM: OpenXM_contrib2/asir2000/parse/cpp.c,v 1.5 2015/08/06 10:01:53 fujimoto Exp $ +*/ #include #include #include @@ -20,14 +64,7 @@ jmp_buf cpp_env; #include "unctrl.h" #endif -#if defined(THINK_C) -#include -int define(char *,int,unsigned char *,int); -void Bcopy(char *,char *,int); -#endif - - #include "cpp.h" char *init_accum(void) @@ -170,6 +207,9 @@ void do_at(void) { if (! in_false_if()) { err_head(); fprintf(stderr,"unknown control `%s'\n",w); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } } free(w); @@ -319,6 +359,9 @@ void read_formals(void) } } } +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } } @@ -364,6 +407,9 @@ void do_define(int sharp, int redef) if (! mac) { err_head(); fprintf(stderr,"missing/illegal macro name\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif flush_sharp_line(); return; } @@ -374,6 +420,9 @@ void do_define(int sharp, int redef) if (nargs > 128) { err_head(); fprintf(stderr,"too many macro formals, more than 128 ignored\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif nargs = 128; } } @@ -567,6 +616,9 @@ void do_dump(void) { fprintf(stderr,"\t\t%s\n",incldir[i]); } fprintf(stderr,"\t\t%s\n",cur_incldir); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } void dump_single(DEF *d) @@ -593,17 +645,26 @@ void dump_single(DEF *d) { putc(*cp,stderr); } } +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } void err_head(void) { fprintf(stderr,"\"%s\", line %d: ",curfile(),curline()); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } void Check_malloc(char *ptr) { if (ptr == 0) { fprintf(stderr,"out of memory!\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif abort(); } } @@ -626,6 +687,9 @@ void do_eval(void) for (i=strlen(temp)-1;i>=0;i--) { Push(temp[i]); } +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } } @@ -760,6 +824,9 @@ void read_actuals(DEF *d) actlens[i] = 0; } } +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } void expand_def(DEF *d) @@ -1053,6 +1120,9 @@ int get_quote_char(void) if (c == '\n') { err_head(); fprintf(stderr,"newline in character constant\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif return(-1); } if (c != '\\') @@ -1129,6 +1199,9 @@ NODE *read_expr_11(void) if (c != ')') { err_head(); fprintf(stderr,"expression syntax error -- missing ) supplied\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif Push(c); } #ifdef DEBUG_EXPR @@ -1176,6 +1249,9 @@ NODE *read_expr_11(void) { err_head(); fprintf(stderr,"warning: illegal %sdigit `%c'\n", (base==16)?"hex ":(base==8)?"octal ":"",c); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } v = (v * base) + values[d-digits]; c = Get(); @@ -1198,6 +1274,9 @@ NODE *read_expr_11(void) if (n > 4) { err_head(); fprintf(stderr,"warning: too many characters in character constant\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } return(newleaf(i)); } @@ -1209,6 +1288,9 @@ NODE *read_expr_11(void) if (complain) { err_head(); fprintf(stderr,"expression syntax error -- number expected\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } if (isbsymchar(c)) { Push(c); @@ -1791,6 +1873,9 @@ NODE *read_expr_(void) default: err_head(); fprintf(stderr,"expression syntax error -- bad operator `%c'\n",c); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif return(l); break; } @@ -1814,6 +1899,9 @@ NODE *read_expr_p(void) if (c != ')') { err_head(); fprintf(stderr,"junk after expression\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } return(rv); } @@ -1839,6 +1927,9 @@ int eval_expr(int Sharp, int Complain) { if (complain) { err_head(); fprintf(stderr,"expression syntax error -- junk after expression\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } while (Get() != d) ; } @@ -1944,6 +2035,9 @@ void do_if(int expr_sharp) if (c != '(') { err_head(); fprintf(stderr,"@if must have ()s\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif Push(c); iffalse(); #ifdef DEBUG_IF @@ -2140,6 +2234,9 @@ void do_else(int expr_sharp) #endif err_head(); fprintf(stderr,"if-less else\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } } else @@ -2195,6 +2292,9 @@ void do_elif(int expr_sharp) if (ifstack == 0) { err_head(); fprintf(stderr,"if-less elif converted to normal if\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif iffalse(); } if (n_skipped_ifs > 0) @@ -2219,6 +2319,9 @@ void do_elif(int expr_sharp) if (c != '(') { err_head(); fprintf(stderr,"@elif must have ()s\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif Push(c); ifstack->condstate = IFSTATE_STAYFALSE; #ifdef DEBUG_IF @@ -2301,6 +2404,9 @@ void do_endif(int expr_sharp) else { err_head(); fprintf(stderr,"if-less endif\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif #ifdef DEBUG_IF if (debugging) { outputc('>'); @@ -2433,6 +2539,9 @@ void do_include(int expr_sharp) err_head(); fprintf(stderr,"warning: unterminated %cinclude filename\n", sharp?'#':'@'); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } if (c == '"') { break; @@ -2453,6 +2562,9 @@ void do_include(int expr_sharp) err_head(); fprintf(stderr,"warning: unterminated %cinclude filename\n", sharp?'#':'@'); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } if (c == '>') { break; @@ -2468,16 +2580,12 @@ void do_include(int expr_sharp) { free(accum_result(acc)); err_head(); fprintf(stderr,"illegal %cinclude filename delimiter\n",sharp?'#':'@'); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } } -#if defined(THINK_C) -#if defined(DELIM) -#undef DELIM -#endif -#define DELIM ':' -#endif - #if defined(SYSV) #else #if defined(DELIM) @@ -2486,7 +2594,7 @@ void do_include(int expr_sharp) #define DELIM '/' #endif -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) #if defined(DELIM) #undef DELIM #endif @@ -2533,6 +2641,9 @@ void read_include_file(char *name, int dohere, int exp if (f == NULL) { err_head(); fprintf(stderr,"can't find include file %s\n",name); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif free(name); return; } @@ -2749,6 +2860,9 @@ void Push(char c) { if (cur_npushed > MAX_PUSHBACK) { fprintf(stderr,"too much pushback\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif cur_npushed = 0; } PUSH() = c; @@ -3127,6 +3241,9 @@ void mark_file_ending(void) } else if (m->nincs <= 0) { fprintf(stderr,"INTERNAL BUG: nincs<0 in mark_file_ending\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif abort(); } else @@ -3589,6 +3706,9 @@ void cpp_main(int ac, char **av) } } } +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } void do_pragma(void) @@ -3648,6 +3768,9 @@ void do_set(void) check_malloc(cp); define(mac,-1,(unsigned char *)cp,DEF_DEFINE); } +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif free(mac); } @@ -3711,6 +3834,9 @@ void do_sharp(void) flush_sharp_line(); } } +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif maybe_print('\n'); free(w); } @@ -3879,6 +4005,9 @@ void define(char *name, int nargs, unsigned char *repl { if ( (nargs != d->nargs) || strcmp((char *)repl,(char *)d->repl) ) { err_head(); fprintf(stderr,"%s redefined\n",n); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } free((char *)d->repl); free(d->name); @@ -4509,6 +4638,9 @@ void do_undef(int expr_sharp) if (! mac) { err_head(); fprintf(stderr,"missing/illegal macro name\n"); +#if defined(__MINGW32__) || defined(__MINGW64__) + fflush(stderr); +#endif } else { if (undef(mac))