comparison mc-parse.c @ 25:b7a94557bf92

*** empty log message ***
author kono
date Wed, 05 Feb 2003 02:34:28 +0900
parents e605560e6146
children c6994794f084
comparison
equal deleted inserted replaced
24:1df0bf7eb5da 25:b7a94557bf92
192 */ 192 */
193 closing(); 193 closing();
194 exit(0); 194 exit(0);
195 } 195 }
196 } 196 }
197 fprintf(stderr,"%5d:%s.\n",lineno, 197 fprintf(stderr,"%s:%d:%s\n",filep->name0,lineno,
198 (n==FILERR) ? "Can't open specified file" : 198 (n==FILERR) ? "Can't open specified file" :
199 (n==DCERR) ? "Declaration syntax" : 199 (n==DCERR) ? "Declaration syntax" :
200 (n==STERR) ? "Statement syntax" : 200 (n==STERR) ? "Statement syntax" :
201 (n==EXERR) ? "Expression syntax" : 201 (n==EXERR) ? "Expression syntax" :
202 (n==CNERR) ? "Constant required" : 202 (n==CNERR) ? "Constant required" :
300 } 300 }
301 301
302 void 302 void
303 newfile(void) 303 newfile(void)
304 { 304 {
305 char *s;
305 lineno=0; 306 lineno=0;
306 /* fprintf(stderr,"%s:\n",av[ac2]); */ 307 /* fprintf(stderr,"%s:\n",av[ac2]); */
307 opening(av[ac2]); 308 opening(av[ac2]);
308 if ( (filep->fcb = fopen(av[ac2++],"r")) == NULL ) error(FILERR); 309 if ( (filep->fcb = fopen(av[ac2++],"r")) == NULL ) error(FILERR);
310 s = av[ac2-1];
311 filep->name0 = cheapp;
312 while((*cheapp++ = *s++));
309 } 313 }
310 314
311 void 315 void
312 reserve(char *s, int d) 316 reserve(char *s, int d)
313 { 317 {
2479 2483
2480 FILE * 2484 FILE *
2481 getfname(void) 2485 getfname(void)
2482 { 2486 {
2483 int i; 2487 int i;
2484 char name[LBUFSIZE]; 2488 char *s,name[LBUFSIZE];
2485 FILE *fp; 2489 FILE *fp;
2486 2490
2487 getch(); 2491 getch();
2488 if(skipspc()!='"') error(INCERR); 2492 if(skipspc()!='"') error(INCERR);
2489 for(i=0;(getch()!='"' && ch!='\n');) { 2493 for(i=0;(getch()!='"' && ch!='\n');) {
2490 if(i<LBUFSIZE-1) name[i++]=ch; 2494 if(i<LBUFSIZE-1) name[i++]=ch;
2491 } 2495 }
2492 if(ch=='\n') error(INCERR); 2496 if(ch=='\n') error(INCERR);
2493 name[i]=0; 2497 name[i]=0;
2494 fp = fopen(name,"r") ; 2498 fp = fopen(name,"r") ;
2499 s = name;
2500 (filep+1)->name0 = cheapp;
2501 while((*cheapp++ = *s++));
2495 return ( (filep+1)->fcb = fp ); 2502 return ( (filep+1)->fcb = fp );
2496 } 2503 }
2497 2504
2498 static int macro_if_depth ; 2505 static int macro_if_depth ;
2499 static int macro_if_current ; 2506 static int macro_if_current ;
2508 do { 2515 do {
2509 lineno++; 2516 lineno++;
2510 glineno++; 2517 glineno++;
2511 chptr=linebuf; 2518 chptr=linebuf;
2512 i=0; 2519 i=0;
2513 #if 1
2514 while ((*chptr++ = c = getc(filep->fcb)) != '\n') { 2520 while ((*chptr++ = c = getc(filep->fcb)) != '\n') {
2515 #else
2516 while ((c=getc(filep->fcb)),(*chptr++=c)!='\n') {
2517 #endif
2518 /* we cannot handle unsaved register in library call
2519 so make it easy for the compiler
2520 \ line continuation?
2521 */
2522 if (++i > LBUFSIZE-2) error(LNERR); 2521 if (++i > LBUFSIZE-2) error(LNERR);
2523 if (c==EOF) { 2522 if (c==EOF) {
2524 error(EOFERR); 2523 error(EOFERR);
2525 --chptr; 2524 --chptr;
2526 } 2525 }