esclex.c (7aec1d6e) | esclex.c (8a40a695) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the |
5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. | 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. |
8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. --- 44 unchanged lines hidden (view full) --- 60 61/* some misc stats we keep on the lexer & parser */ 62static struct stats *Tokcount; 63static struct stats *Lexelapse; 64struct stats *Filecount; 65struct filestats { 66 struct filestats *next; 67 struct stats *stats; | 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. --- 44 unchanged lines hidden (view full) --- 59 60/* some misc stats we keep on the lexer & parser */ 61static struct stats *Tokcount; 62static struct stats *Lexelapse; 63struct stats *Filecount; 64struct filestats { 65 struct filestats *next; 66 struct stats *stats; |
67 struct stats *idstats; |
|
68} *Fstats; 69 70static int Errcount; 71 72/* input file state */ 73static char **Files; 74static const char *Fileopened; 75static FILE *Fp; --- 215 unchanged lines hidden (view full) --- 291 char *eptr = &Tok[MAXTOK]; 292 const char *cptr; 293 int startline; 294 int val; 295 static int bol = 1; /* true if we're at beginning of line */ 296 297 for (;;) { 298 while (Fp == NULL) { | 68} *Fstats; 69 70static int Errcount; 71 72/* input file state */ 73static char **Files; 74static const char *Fileopened; 75static FILE *Fp; --- 215 unchanged lines hidden (view full) --- 291 char *eptr = &Tok[MAXTOK]; 292 const char *cptr; 293 int startline; 294 int val; 295 static int bol = 1; /* true if we're at beginning of line */ 296 297 for (;;) { 298 while (Fp == NULL) { |
299 char ibuf[80]; 300 |
|
299 if (*Files == NULL) 300 return (record(EOF, NULL)); 301 Fileopened = stable(*Files++); 302#ifdef ESC 303 sprintf(Tok, "%s %s %s %s", 304 Cpp, Cppstdargs, Cppargs, Fileopened); 305 if ((Fp = popen(Tok, "r")) == NULL) 306 out(O_DIE|O_SYS, "%s", Tok); 307#else | 301 if (*Files == NULL) 302 return (record(EOF, NULL)); 303 Fileopened = stable(*Files++); 304#ifdef ESC 305 sprintf(Tok, "%s %s %s %s", 306 Cpp, Cppstdargs, Cppargs, Fileopened); 307 if ((Fp = popen(Tok, "r")) == NULL) 308 out(O_DIE|O_SYS, "%s", Tok); 309#else |
308 Fp = eftread_fopen(Fileopened); | 310 Fp = eftread_fopen(Fileopened, ibuf, sizeof (ibuf)); |
309#endif /* ESC */ 310 Line = 1; 311 bol = 1; 312 313 /* add name to stats for visibility */ 314 if (Fp != NULL) { 315 static int fnum; 316 char nbuf[100]; 317 struct filestats *nfs = MALLOC(sizeof (*nfs)); | 311#endif /* ESC */ 312 Line = 1; 313 bol = 1; 314 315 /* add name to stats for visibility */ 316 if (Fp != NULL) { 317 static int fnum; 318 char nbuf[100]; 319 struct filestats *nfs = MALLOC(sizeof (*nfs)); |
318 (void) sprintf(nbuf, "lex.file%d", fnum++); | 320 321 (void) sprintf(nbuf, "lex.file%d", fnum); |
319 nfs->stats = stats_new_string(nbuf, "", 0); 320 stats_string_set(nfs->stats, Fileopened); | 322 nfs->stats = stats_new_string(nbuf, "", 0); 323 stats_string_set(nfs->stats, Fileopened); |
324 325 if (ibuf[0] != '\0') { 326 (void) sprintf(nbuf, "lex.file%d-ident", 327 fnum); 328 nfs->idstats = 329 stats_new_string(nbuf, "", 0); 330 stats_string_set(nfs->idstats, ibuf); 331 } else { 332 nfs->idstats = NULL; 333 } 334 |
|
321 nfs->next = Fstats; 322 Fstats = nfs; | 335 nfs->next = Fstats; 336 Fstats = nfs; |
337 fnum++; |
|
323 } 324 } 325 326 switch (c = getc(Fp)) { 327 case '#': 328 /* enforce that we're at beginning of line */ 329 if (!bol) 330 return (record(c, NULL)); --- 610 unchanged lines hidden (view full) --- 941 * Free up memory consumed by the lexer 942 */ 943 stats_delete(Tokcount); 944 stats_delete(Filecount); 945 stats_delete(Lexelapse); 946 while (nfstats != NULL) { 947 Fstats = nfstats->next; 948 stats_delete(nfstats->stats); | 338 } 339 } 340 341 switch (c = getc(Fp)) { 342 case '#': 343 /* enforce that we're at beginning of line */ 344 if (!bol) 345 return (record(c, NULL)); --- 610 unchanged lines hidden (view full) --- 956 * Free up memory consumed by the lexer 957 */ 958 stats_delete(Tokcount); 959 stats_delete(Filecount); 960 stats_delete(Lexelapse); 961 while (nfstats != NULL) { 962 Fstats = nfstats->next; 963 stats_delete(nfstats->stats); |
964 if (nfstats->idstats != NULL) 965 stats_delete(nfstats->idstats); |
|
949 FREE(nfstats); 950 nfstats = Fstats; 951 } 952 lut_free(Timesuffixlut, NULL, NULL); 953 lut_free(Rwordslut, NULL, NULL); 954 lut_free(Ident, NULL, NULL); 955 lut_free(Dicts, NULL, NULL); 956} | 966 FREE(nfstats); 967 nfstats = Fstats; 968 } 969 lut_free(Timesuffixlut, NULL, NULL); 970 lut_free(Rwordslut, NULL, NULL); 971 lut_free(Ident, NULL, NULL); 972 lut_free(Dicts, NULL, NULL); 973} |