[BACK]Return to cpp.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / parse

Diff for /OpenXM_contrib2/asir2000/parse/cpp.c between version 1.1.1.1 and 1.6

version 1.1.1.1, 1999/12/03 07:39:12 version 1.6, 2015/08/08 14:19:42
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/asir99/parse/cpp.c,v 1.1.1.1 1999/11/10 08:12:34 noro Exp $ */  /*
 #if defined(__MWERKS__)   * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
 #define THINK_C   * All rights reserved.
 #endif   *
    * 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 <stdio.h>  #include <stdio.h>
 #include <ctype.h>  #include <ctype.h>
 #include <setjmp.h>  #include <setjmp.h>
Line 20  jmp_buf cpp_env;
Line 64  jmp_buf cpp_env;
 #include "unctrl.h"  #include "unctrl.h"
 #endif  #endif
   
 #if defined(THINK_C)  
 #include <string.h>  
   
 int define(char *,int,unsigned char *,int);  
 void Bcopy(char *,char *,int);  
 #endif  
   
   
 #include "cpp.h"  #include "cpp.h"
   
 char *init_accum(void)  char *init_accum(void)
Line 170  void do_at(void)
Line 207  void do_at(void)
   { if (! in_false_if())    { if (! in_false_if())
      { err_head();       { err_head();
        fprintf(stderr,"unknown control `%s'\n",w);         fprintf(stderr,"unknown control `%s'\n",w);
   #if defined(__MINGW32__) || defined(__MINGW64__)
          fflush(stderr);
   #endif
      }       }
   }    }
  free(w);   free(w);
Line 319  void read_formals(void)
Line 359  void read_formals(void)
            }             }
         }          }
      }       }
   #if defined(__MINGW32__) || defined(__MINGW64__)
       fflush(stderr);
   #endif
   }    }
 }  }
   
Line 364  void do_define(int sharp, int redef)
Line 407  void do_define(int sharp, int redef)
  if (! mac)   if (! mac)
   { err_head();    { err_head();
     fprintf(stderr,"missing/illegal macro name\n");      fprintf(stderr,"missing/illegal macro name\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
       fflush(stderr);
   #endif
     flush_sharp_line();      flush_sharp_line();
     return;      return;
   }    }
Line 374  void do_define(int sharp, int redef)
Line 420  void do_define(int sharp, int redef)
     if (nargs > 128)      if (nargs > 128)
      { err_head();       { err_head();
        fprintf(stderr,"too many macro formals, more than 128 ignored\n");         fprintf(stderr,"too many macro formals, more than 128 ignored\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
          fflush(stderr);
   #endif
        nargs = 128;         nargs = 128;
      }       }
   }    }
Line 567  void do_dump(void)
Line 616  void do_dump(void)
   { fprintf(stderr,"\t\t%s\n",incldir[i]);    { fprintf(stderr,"\t\t%s\n",incldir[i]);
   }    }
  fprintf(stderr,"\t\t%s\n",cur_incldir);   fprintf(stderr,"\t\t%s\n",cur_incldir);
   #if defined(__MINGW32__) || defined(__MINGW64__)
    fflush(stderr);
   #endif
 }  }
   
 void dump_single(DEF *d)  void dump_single(DEF *d)
Line 593  void dump_single(DEF *d)
Line 645  void dump_single(DEF *d)
      { putc(*cp,stderr);       { putc(*cp,stderr);
      }       }
   }    }
   #if defined(__MINGW32__) || defined(__MINGW64__)
    fflush(stderr);
   #endif
 }  }
   
 void err_head(void)  void err_head(void)
 {  {
  fprintf(stderr,"\"%s\", line %d: ",curfile(),curline());   fprintf(stderr,"\"%s\", line %d: ",curfile(),curline());
   #if defined(__MINGW32__) || defined(__MINGW64__)
    fflush(stderr);
   #endif
 }  }
   
 void Check_malloc(char *ptr)  void Check_malloc(char *ptr)
 {  {
  if (ptr == 0)   if (ptr == 0)
   { fprintf(stderr,"out of memory!\n");    { fprintf(stderr,"out of memory!\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
       fflush(stderr);
   #endif
     abort();      abort();
   }    }
 }  }
Line 626  void do_eval(void)
Line 687  void do_eval(void)
     for (i=strlen(temp)-1;i>=0;i--)      for (i=strlen(temp)-1;i>=0;i--)
      { Push(temp[i]);       { Push(temp[i]);
      }       }
   #if defined(__MINGW32__) || defined(__MINGW64__)
       fflush(stderr);
   #endif
   }    }
 }  }
   
Line 760  void read_actuals(DEF *d)
Line 824  void read_actuals(DEF *d)
        actlens[i] = 0;         actlens[i] = 0;
      }       }
   }    }
   #if defined(__MINGW32__) || defined(__MINGW64__)
    fflush(stderr);
   #endif
 }  }
   
 void expand_def(DEF *d)  void expand_def(DEF *d)
Line 1053  int get_quote_char(void)
Line 1120  int get_quote_char(void)
  if (c == '\n')   if (c == '\n')
   { err_head();    { err_head();
     fprintf(stderr,"newline in character constant\n");      fprintf(stderr,"newline in character constant\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
                         fflush(stderr);
   #endif
     return(-1);      return(-1);
   }    }
  if (c != '\\')   if (c != '\\')
Line 1129  NODE *read_expr_11(void)
Line 1199  NODE *read_expr_11(void)
        if (c != ')')         if (c != ')')
         { err_head();          { err_head();
           fprintf(stderr,"expression syntax error -- missing ) supplied\n");            fprintf(stderr,"expression syntax error -- missing ) supplied\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
             fflush(stderr);
   #endif
           Push(c);            Push(c);
         }          }
 #ifdef DEBUG_EXPR  #ifdef DEBUG_EXPR
Line 1176  NODE *read_expr_11(void)
Line 1249  NODE *read_expr_11(void)
            { err_head();             { err_head();
              fprintf(stderr,"warning: illegal %sdigit `%c'\n",               fprintf(stderr,"warning: illegal %sdigit `%c'\n",
                         (base==16)?"hex ":(base==8)?"octal ":"",c);                          (base==16)?"hex ":(base==8)?"octal ":"",c);
   #if defined(__MINGW32__) || defined(__MINGW64__)
                fflush(stderr);
   #endif
            }             }
           v = (v * base) + values[d-digits];            v = (v * base) + values[d-digits];
           c = Get();            c = Get();
Line 1198  NODE *read_expr_11(void)
Line 1274  NODE *read_expr_11(void)
        if (n > 4)         if (n > 4)
         { err_head();          { err_head();
           fprintf(stderr,"warning: too many characters in character constant\n");            fprintf(stderr,"warning: too many characters in character constant\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
             fflush(stderr);
   #endif
         }          }
        return(newleaf(i));         return(newleaf(i));
      }       }
Line 1209  NODE *read_expr_11(void)
Line 1288  NODE *read_expr_11(void)
        if (complain)         if (complain)
         { err_head();          { err_head();
           fprintf(stderr,"expression syntax error -- number expected\n");            fprintf(stderr,"expression syntax error -- number expected\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
             fflush(stderr);
   #endif
         }          }
        if (isbsymchar(c))         if (isbsymchar(c))
         { Push(c);          { Push(c);
Line 1791  NODE *read_expr_(void)
Line 1873  NODE *read_expr_(void)
        default:         default:
           err_head();            err_head();
           fprintf(stderr,"expression syntax error -- bad operator `%c'\n",c);            fprintf(stderr,"expression syntax error -- bad operator `%c'\n",c);
   #if defined(__MINGW32__) || defined(__MINGW64__)
             fflush(stderr);
   #endif
           return(l);            return(l);
           break;            break;
      }       }
Line 1814  NODE *read_expr_p(void)
Line 1899  NODE *read_expr_p(void)
  if (c != ')')   if (c != ')')
   { err_head();    { err_head();
     fprintf(stderr,"junk after expression\n");      fprintf(stderr,"junk after expression\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
       fflush(stderr);
   #endif
   }    }
  return(rv);   return(rv);
 }  }
Line 1839  int eval_expr(int Sharp, int Complain)
Line 1927  int eval_expr(int Sharp, int Complain)
   { if (complain)    { if (complain)
      { err_head();       { err_head();
        fprintf(stderr,"expression syntax error -- junk after expression\n");         fprintf(stderr,"expression syntax error -- junk after expression\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
          fflush(stderr);
   #endif
      }       }
     while (Get() != d) ;      while (Get() != d) ;
   }    }
Line 1944  void do_if(int expr_sharp)
Line 2035  void do_if(int expr_sharp)
     if (c != '(')      if (c != '(')
      { err_head();       { err_head();
        fprintf(stderr,"@if must have ()s\n");         fprintf(stderr,"@if must have ()s\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
          fflush(stderr);
   #endif
        Push(c);         Push(c);
        iffalse();         iffalse();
 #ifdef DEBUG_IF  #ifdef DEBUG_IF
Line 2140  void do_else(int expr_sharp)
Line 2234  void do_else(int expr_sharp)
 #endif  #endif
        err_head();         err_head();
        fprintf(stderr,"if-less else\n");         fprintf(stderr,"if-less else\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
          fflush(stderr);
   #endif
      }       }
   }    }
  else   else
Line 2195  void do_elif(int expr_sharp)
Line 2292  void do_elif(int expr_sharp)
  if (ifstack == 0)   if (ifstack == 0)
   { err_head();    { err_head();
     fprintf(stderr,"if-less elif converted to normal if\n");      fprintf(stderr,"if-less elif converted to normal if\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
       fflush(stderr);
   #endif
     iffalse();      iffalse();
   }    }
  if (n_skipped_ifs > 0)   if (n_skipped_ifs > 0)
Line 2219  void do_elif(int expr_sharp)
Line 2319  void do_elif(int expr_sharp)
     if (c != '(')      if (c != '(')
      { err_head();       { err_head();
        fprintf(stderr,"@elif must have ()s\n");         fprintf(stderr,"@elif must have ()s\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
          fflush(stderr);
   #endif
        Push(c);         Push(c);
        ifstack->condstate = IFSTATE_STAYFALSE;         ifstack->condstate = IFSTATE_STAYFALSE;
 #ifdef DEBUG_IF  #ifdef DEBUG_IF
Line 2301  void do_endif(int expr_sharp)
Line 2404  void do_endif(int expr_sharp)
  else   else
   { err_head();    { err_head();
     fprintf(stderr,"if-less endif\n");      fprintf(stderr,"if-less endif\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
       fflush(stderr);
   #endif
 #ifdef DEBUG_IF  #ifdef DEBUG_IF
     if (debugging)      if (debugging)
      { outputc('>');       { outputc('>');
Line 2433  void do_include(int expr_sharp)
Line 2539  void do_include(int expr_sharp)
           err_head();            err_head();
           fprintf(stderr,"warning: unterminated %cinclude filename\n",            fprintf(stderr,"warning: unterminated %cinclude filename\n",
                                                         sharp?'#':'@');                                                          sharp?'#':'@');
   #if defined(__MINGW32__) || defined(__MINGW64__)
             fflush(stderr);
   #endif
         }          }
        if (c == '"')         if (c == '"')
         { break;          { break;
Line 2453  void do_include(int expr_sharp)
Line 2562  void do_include(int expr_sharp)
           err_head();            err_head();
           fprintf(stderr,"warning: unterminated %cinclude filename\n",            fprintf(stderr,"warning: unterminated %cinclude filename\n",
                                                         sharp?'#':'@');                                                          sharp?'#':'@');
   #if defined(__MINGW32__) || defined(__MINGW64__)
             fflush(stderr);
   #endif
         }          }
        if (c == '>')         if (c == '>')
         { break;          { break;
Line 2468  void do_include(int expr_sharp)
Line 2580  void do_include(int expr_sharp)
   { free(accum_result(acc));    { free(accum_result(acc));
     err_head();      err_head();
     fprintf(stderr,"illegal %cinclude filename delimiter\n",sharp?'#':'@');      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)  #if  defined(SYSV)
 #else  #else
 #if defined(DELIM)  #if defined(DELIM)
Line 2486  void do_include(int expr_sharp)
Line 2594  void do_include(int expr_sharp)
 #define DELIM '/'  #define DELIM '/'
 #endif  #endif
   
 #if defined(VISUAL)  #if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__)
 #if defined(DELIM)  #if defined(DELIM)
 #undef DELIM  #undef DELIM
 #endif  #endif
Line 2533  void read_include_file(char *name, int dohere, int exp
Line 2641  void read_include_file(char *name, int dohere, int exp
  if (f == NULL)   if (f == NULL)
   { err_head();    { err_head();
     fprintf(stderr,"can't find include file %s\n",name);      fprintf(stderr,"can't find include file %s\n",name);
   #if defined(__MINGW32__) || defined(__MINGW64__)
       fflush(stderr);
   #endif
     free(name);      free(name);
     return;      return;
   }    }
Line 2749  void Push(char c)
Line 2860  void Push(char c)
 {  {
  if (cur_npushed > MAX_PUSHBACK)   if (cur_npushed > MAX_PUSHBACK)
   { fprintf(stderr,"too much pushback\n");    { fprintf(stderr,"too much pushback\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
       fflush(stderr);
   #endif
     cur_npushed = 0;      cur_npushed = 0;
   }    }
  PUSH() = c;   PUSH() = c;
Line 3127  void mark_file_ending(void)
Line 3241  void mark_file_ending(void)
      }       }
     else if (m->nincs <= 0)      else if (m->nincs <= 0)
      { fprintf(stderr,"INTERNAL BUG: nincs<0 in mark_file_ending\n");       { fprintf(stderr,"INTERNAL BUG: nincs<0 in mark_file_ending\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
          fflush(stderr);
   #endif
        abort();         abort();
      }       }
     else      else
Line 3589  void cpp_main(int ac, char **av)
Line 3706  void cpp_main(int ac, char **av)
         }          }
      }       }
   }    }
   #if defined(__MINGW32__) || defined(__MINGW64__)
    fflush(stderr);
   #endif
 }  }
   
 void do_pragma(void)  void do_pragma(void)
Line 3648  void do_set(void)
Line 3768  void do_set(void)
     check_malloc(cp);      check_malloc(cp);
     define(mac,-1,(unsigned char *)cp,DEF_DEFINE);      define(mac,-1,(unsigned char *)cp,DEF_DEFINE);
   }    }
   #if defined(__MINGW32__) || defined(__MINGW64__)
    fflush(stderr);
   #endif
  free(mac);   free(mac);
 }  }
   
Line 3711  void do_sharp(void)
Line 3834  void do_sharp(void)
        flush_sharp_line();         flush_sharp_line();
      }       }
   }    }
   #if defined(__MINGW32__) || defined(__MINGW64__)
    fflush(stderr);
   #endif
  maybe_print('\n');   maybe_print('\n');
  free(w);   free(w);
 }  }
Line 3879  void define(char *name, int nargs, unsigned char *repl
Line 4005  void define(char *name, int nargs, unsigned char *repl
   { if ( (nargs != d->nargs) || strcmp((char *)repl,(char *)d->repl) )    { if ( (nargs != d->nargs) || strcmp((char *)repl,(char *)d->repl) )
      { err_head();       { err_head();
        fprintf(stderr,"%s redefined\n",n);         fprintf(stderr,"%s redefined\n",n);
   #if defined(__MINGW32__) || defined(__MINGW64__)
          fflush(stderr);
   #endif
      }       }
     free((char *)d->repl);      free((char *)d->repl);
     free(d->name);      free(d->name);
Line 4509  void do_undef(int expr_sharp)
Line 4638  void do_undef(int expr_sharp)
     if (! mac)      if (! mac)
      { err_head();       { err_head();
        fprintf(stderr,"missing/illegal macro name\n");         fprintf(stderr,"missing/illegal macro name\n");
   #if defined(__MINGW32__) || defined(__MINGW64__)
          fflush(stderr);
   #endif
      }       }
     else      else
      { if (undef(mac))       { if (undef(mac))

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.6

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>