Ticket #36397: patch-token.c.diff
File patch-token.c.diff, 3.4 KB (added by stevecheckoway (Stephen Checkoway), 12 years ago) |
---|
-
token.c
old new 7 7 8 8 #include <math.h> 9 9 #include <stdio.h> 10 #include <string.h> 10 11 11 12 #ifdef LCC 12 13 #include <stdlib.h> … … typedef struct iostack { 35 36 static char INPUT[1000]; 36 37 static int getnew = 1; 37 38 static char oldchar = '\0'; 38 static oldcharvalid = 0;39 static int oldcharvalid = 0; 39 40 static char pipe = 0; 40 41 static int eof = 0; 41 42 static int init = 0; … … static FILE *IOSTREAM; 46 47 static char FILENAME[300]; 47 48 static int line = 1; 48 49 50 static int getsystemstring(void); 51 49 52 #ifdef VMS 50 53 /* On VMS, there are no popen() and pclose(), so we provide dummies here. */ 51 FILE *popen(command, type) 52 char *command, *type; 54 FILE *popen(const char *command, const char *type) 53 55 { 54 56 return(NULL); 55 57 } 56 int pclose(stream) 57 FILE *stream; 58 int pclose(FILE *stream) 58 59 { 59 60 return(-1); 60 61 } 61 62 #endif /*VMS*/ 62 63 63 set_input_file(s) 64 char *s; 64 void set_input_file(const char *s) 65 65 { 66 FILE *f;67 66 Iostack n; 68 67 69 68 if (init == 0) { … … char *s; 93 92 } 94 93 } 95 94 96 error_header()95 void error_header() 97 96 { 98 97 fprintf(stderr, "%s,%d: ", FILENAME, line); 99 98 } 100 99 101 int gettokenchar()100 static int gettokenchar() 102 101 { 103 102 if (oldcharvalid == 0) oldchar = getc(IOSTREAM); 104 103 oldcharvalid = 0; … … int gettokenchar() 106 105 return oldchar; 107 106 } 108 107 109 ungettokenchar()108 static void ungettokenchar() 110 109 { 111 110 oldcharvalid = 1; 112 111 if (oldchar == '\n') line--; 113 112 } 114 113 115 int gettoken(s) 116 char *s; 114 static int gettoken(char *s) 117 115 { 118 116 int i; 119 117 char c; … … char *s; 131 129 return i; 132 130 } 133 131 134 get_comment()132 static void get_comment() 135 133 { 136 134 if (eof) return; 137 135 while (1) { … … static int iostackempty() 148 146 return (first(stack) == nil(stack)); 149 147 } 150 148 151 static push_iostack(p) 152 int p; 149 static void push_iostack(int p) 153 150 { 154 151 Iostack n; 155 152 … … int p; 177 174 strcpy(FILENAME, INPUT); 178 175 } 179 176 180 static pop_iostack()177 static void pop_iostack() 181 178 { 182 179 Iostack n; 183 180 … … static pop_iostack() 195 192 if (n->stream == NULL) { 196 193 n->stream = fopen(n->filename, "r"); 197 194 if (n->stream == NULL) { 198 fprintf(stderr, "Error: cannot open file \"%s\"\n", n-> stream);195 fprintf(stderr, "Error: cannot open file \"%s\"\n", n->filename); 199 196 exit(1); 200 197 } 201 198 } … … static pop_iostack() 210 207 free_node(n, stack); 211 208 } 212 209 213 static nexttoken()210 static void nexttoken() 214 211 { 215 212 if (eof) return; 216 213 if (getnew) { … … static nexttoken() 258 255 return; 259 256 } 260 257 261 int getstring(s) 262 char *s; 258 int getstring(char *s) 263 259 { 264 260 nexttoken(); 265 261 if (eof) return 0; … … char *s; 267 263 return 1; 268 264 } 269 265 270 int getint(i) 271 int *i; 266 int getint(int *i) 272 267 { 273 268 int j; 274 269 … … int *i; 282 277 return 1; 283 278 } 284 279 285 int getfloat(f) 286 float *f; 280 int getfloat(float *f) 287 281 { 288 282 int j; 289 283 … … float *f; 304 298 } else return 1; 305 299 } 306 300 307 static char *new_printable_text(s) 308 char *s; 301 static char *new_printable_text(const char *s) 309 302 { 310 303 char *new_s; 311 304 int to_pad, i, j; … … char *s; 334 327 char *getmultiline() 335 328 { 336 329 char c; 337 int i, j,done, len, started;330 int i, done, len, started; 338 331 char *out_str; 339 332 340 333 if (getnew == 0) return CNULL; … … char *getmultiline() 374 367 375 368 char *getlabel() 376 369 { 377 char c;378 370 char *txt, *new; 379 int i;380 371 381 372 txt = getmultiline(); 382 373 if (txt == CNULL) return CNULL; … … int getsystemstring() 415 406 return 1; 416 407 } 417 408 418 rejecttoken()409 void rejecttoken() 419 410 { 420 411 getnew = 0; 421 412 }