Deleted Added
full compact
scan.l (256281) scan.l (281168)
1%{
1%{
2/* $NetBSD: scan.l,v 1.26 2002/01/31 22:30:21 tv Exp $ */
2/* $NetBSD: scan.l,v 1.37 2007/02/06 00:08:31 he Exp $ */
3
4/*
5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
6 * Copyright (c) 1994, 1995 Jochen Pohl
7 * All Rights Reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions

--- 19 unchanged lines hidden (view full) ---

30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#include <sys/cdefs.h>
37#if defined(__RCSID) && !defined(lint)
3
4/*
5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
6 * Copyright (c) 1994, 1995 Jochen Pohl
7 * All Rights Reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions

--- 19 unchanged lines hidden (view full) ---

30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#include <sys/cdefs.h>
37#if defined(__RCSID) && !defined(lint)
38__RCSID("$NetBSD: scan.l,v 1.26 2002/01/31 22:30:21 tv Exp $");
38__RCSID("$NetBSD: scan.l,v 1.37 2007/02/06 00:08:31 he Exp $");
39#endif
39#endif
40__FBSDID("$FreeBSD: stable/10/usr.bin/xlint/lint1/scan.l 250227 2013-05-03 23:51:32Z jkim $");
40__FBSDID("$FreeBSD: stable/10/usr.bin/xlint/lint1/scan.l 281168 2015-04-06 19:56:27Z pfg $");
41
42#include <stdlib.h>
43#include <string.h>
44#include <limits.h>
45#include <float.h>
46#include <ctype.h>
47#include <errno.h>
48#include <err.h>

--- 42 unchanged lines hidden (view full) ---

91D [0-9]
92NZD [1-9]
93OD [0-7]
94HD [0-9A-Fa-f]
95EX ([eE][+-]?[0-9]+)
96
97%%
98
41
42#include <stdlib.h>
43#include <string.h>
44#include <limits.h>
45#include <float.h>
46#include <ctype.h>
47#include <errno.h>
48#include <err.h>

--- 42 unchanged lines hidden (view full) ---

91D [0-9]
92NZD [1-9]
93OD [0-7]
94HD [0-9A-Fa-f]
95EX ([eE][+-]?[0-9]+)
96
97%%
98
99{L}({L}|{D})* return (name());
99{L}({L}|{D})* return (name());
1000{OD}*[lLuU]* return (icon(8));
101{NZD}{D}*[lLuU]* return (icon(10));
1020[xX]{HD}+[lLuU]* return (icon(16));
103{D}+\.{D}*{EX}?[fFlL]? |
104{D}+{EX}[fFlL]? |
1000{OD}*[lLuU]* return (icon(8));
101{NZD}{D}*[lLuU]* return (icon(10));
1020[xX]{HD}+[lLuU]* return (icon(16));
103{D}+\.{D}*{EX}?[fFlL]? |
104{D}+{EX}[fFlL]? |
1050[xX]{HD}+p{HD}+[fFlL]? |
105\.{D}+{EX}?[fFlL]? return (fcon());
106"=" return (operator(T_ASSIGN, ASSIGN));
107"*=" return (operator(T_OPASS, MULASS));
108"/=" return (operator(T_OPASS, DIVASS));
109"%=" return (operator(T_OPASS, MODASS));
110"+=" return (operator(T_OPASS, ADDASS));
111"-=" return (operator(T_OPASS, SUBASS));
112"<<=" return (operator(T_OPASS, SHLASS));

--- 73 unchanged lines hidden (view full) ---

186 * During initialisation they are written to the symbol table.
187 */
188static struct kwtab {
189 const char *kw_name; /* keyword */
190 int kw_token; /* token returned by yylex() */
191 scl_t kw_scl; /* storage class if kw_token T_SCLASS */
192 tspec_t kw_tspec; /* type spec. if kw_token T_TYPE or T_SOU */
193 tqual_t kw_tqual; /* type qual. fi kw_token T_QUAL */
106\.{D}+{EX}?[fFlL]? return (fcon());
107"=" return (operator(T_ASSIGN, ASSIGN));
108"*=" return (operator(T_OPASS, MULASS));
109"/=" return (operator(T_OPASS, DIVASS));
110"%=" return (operator(T_OPASS, MODASS));
111"+=" return (operator(T_OPASS, ADDASS));
112"-=" return (operator(T_OPASS, SUBASS));
113"<<=" return (operator(T_OPASS, SHLASS));

--- 73 unchanged lines hidden (view full) ---

187 * During initialisation they are written to the symbol table.
188 */
189static struct kwtab {
190 const char *kw_name; /* keyword */
191 int kw_token; /* token returned by yylex() */
192 scl_t kw_scl; /* storage class if kw_token T_SCLASS */
193 tspec_t kw_tspec; /* type spec. if kw_token T_TYPE or T_SOU */
194 tqual_t kw_tqual; /* type qual. fi kw_token T_QUAL */
194 u_int kw_stdc : 1; /* STDC keyword */
195 u_int kw_gcc : 1; /* GCC keyword */
195 u_int kw_c89; /* c89 keyword */
196 u_int kw_c99; /* c99 keyword */
197 u_int kw_gcc; /* GCC keyword */
196} kwtab[] = {
198} kwtab[] = {
197 { "asm", T_ASM, 0, 0, 0, 0, 1 },
198 { "__asm", T_ASM, 0, 0, 0, 0, 0 },
199 { "__asm__", T_ASM, 0, 0, 0, 0, 0 },
200 { "auto", T_SCLASS, AUTO, 0, 0, 0, 0 },
201 { "break", T_BREAK, 0, 0, 0, 0, 0 },
202 { "case", T_CASE, 0, 0, 0, 0, 0 },
203 { "char", T_TYPE, 0, CHAR, 0, 0, 0 },
204 { "const", T_QUAL, 0, 0, CONST, 1, 0 },
205 { "__const__", T_QUAL, 0, 0, CONST, 0, 0 },
206 { "__const", T_QUAL, 0, 0, CONST, 0, 0 },
207 { "continue", T_CONTINUE, 0, 0, 0, 0, 0 },
208 { "default", T_DEFAULT, 0, 0, 0, 0, 0 },
209 { "do", T_DO, 0, 0, 0, 0, 0 },
210 { "double", T_TYPE, 0, DOUBLE, 0, 0, 0 },
211 { "else", T_ELSE, 0, 0, 0, 0, 0 },
212 { "enum", T_ENUM, 0, 0, 0, 0, 0 },
213 { "extern", T_SCLASS, EXTERN, 0, 0, 0, 0 },
214 { "float", T_TYPE, 0, FLOAT, 0, 0, 0 },
215 { "for", T_FOR, 0, 0, 0, 0, 0 },
216 { "goto", T_GOTO, 0, 0, 0, 0, 0 },
217 { "if", T_IF, 0, 0, 0, 0, 0 },
218 { "inline", T_SCLASS, INLINE, 0, 0, 0, 1 },
219 { "__inline__", T_SCLASS, INLINE, 0, 0, 0, 0 },
220 { "__inline", T_SCLASS, INLINE, 0, 0, 0, 0 },
221 { "int", T_TYPE, 0, INT, 0, 0, 0 },
222 { "__symbolrename", T_SYMBOLRENAME, 0, 0, 0, 0, 0 },
223 { "long", T_TYPE, 0, LONG, 0, 0, 0 },
224 { "register", T_SCLASS, REG, 0, 0, 0, 0 },
225 { "return", T_RETURN, 0, 0, 0, 0, 0 },
226 { "short", T_TYPE, 0, SHORT, 0, 0, 0 },
227 { "signed", T_TYPE, 0, SIGNED, 0, 1, 0 },
228 { "__signed__", T_TYPE, 0, SIGNED, 0, 0, 0 },
229 { "__signed", T_TYPE, 0, SIGNED, 0, 0, 0 },
230 { "sizeof", T_SIZEOF, 0, 0, 0, 0, 0 },
231 { "static", T_SCLASS, STATIC, 0, 0, 0, 0 },
232 { "struct", T_SOU, 0, STRUCT, 0, 0, 0 },
233 { "switch", T_SWITCH, 0, 0, 0, 0, 0 },
234 { "typedef", T_SCLASS, TYPEDEF, 0, 0, 0, 0 },
235 { "union", T_SOU, 0, UNION, 0, 0, 0 },
236 { "unsigned", T_TYPE, 0, UNSIGN, 0, 0, 0 },
237 { "void", T_TYPE, 0, VOID, 0, 0, 0 },
238 { "volatile", T_QUAL, 0, 0, VOLATILE, 1, 0 },
239 { "__volatile__", T_QUAL, 0, 0, VOLATILE, 0, 0 },
240 { "__volatile", T_QUAL, 0, 0, VOLATILE, 0, 0 },
241 { "while", T_WHILE, 0, 0, 0, 0, 0 },
242 { NULL, 0, 0, 0, 0, 0, 0 }
199 { "asm", T_ASM, 0, 0, 0, 0, 0, 1 },
200 { "__asm", T_ASM, 0, 0, 0, 0, 0, 0 },
201 { "__asm__", T_ASM, 0, 0, 0, 0, 0, 0 },
202 { "auto", T_SCLASS, AUTO, 0, 0, 0, 0, 0 },
203 { "break", T_BREAK, 0, 0, 0, 0, 0, 0 },
204 { "case", T_CASE, 0, 0, 0, 0, 0, 0 },
205 { "char", T_TYPE, 0, CHAR, 0, 0, 0, 0 },
206 { "const", T_QUAL, 0, 0, CONST, 1, 0, 0 },
207 { "__const__", T_QUAL, 0, 0, CONST, 0, 0, 0 },
208 { "__const", T_QUAL, 0, 0, CONST, 0, 0, 0 },
209 { "continue", T_CONTINUE, 0, 0, 0, 0, 0, 0 },
210 { "default", T_DEFAULT, 0, 0, 0, 0, 0, 0 },
211 { "do", T_DO, 0, 0, 0, 0, 0, 0 },
212 { "double", T_TYPE, 0, DOUBLE, 0, 0, 0, 0 },
213 { "else", T_ELSE, 0, 0, 0, 0, 0, 0 },
214 { "enum", T_ENUM, 0, 0, 0, 0, 0, 0 },
215 { "extern", T_SCLASS, EXTERN, 0, 0, 0, 0, 0 },
216 { "float", T_TYPE, 0, FLOAT, 0, 0, 0, 0 },
217 { "for", T_FOR, 0, 0, 0, 0, 0, 0 },
218 { "goto", T_GOTO, 0, 0, 0, 0, 0, 0 },
219 { "if", T_IF, 0, 0, 0, 0, 0, 0 },
220 { "inline", T_SCLASS, INLINE, 0, 0, 0, 1, 0 },
221 { "__inline__", T_SCLASS, INLINE, 0, 0, 0, 0, 0 },
222 { "__inline", T_SCLASS, INLINE, 0, 0, 0, 0, 0 },
223 { "int", T_TYPE, 0, INT, 0, 0, 0, 0 },
224 { "__symbolrename", T_SYMBOLRENAME, 0, 0, 0, 0, 0, 0 },
225 { "long", T_TYPE, 0, LONG, 0, 0, 0, 0 },
226 { "register", T_SCLASS, REG, 0, 0, 0, 0, 0 },
227 { "return", T_RETURN, 0, 0, 0, 0, 0, 0 },
228 { "short", T_TYPE, 0, SHORT, 0, 0, 0, 0 },
229 { "signed", T_TYPE, 0, SIGNED, 0, 1, 0, 0 },
230 { "__signed__", T_TYPE, 0, SIGNED, 0, 0, 0, 0 },
231 { "__signed", T_TYPE, 0, SIGNED, 0, 0, 0, 0 },
232 { "sizeof", T_SIZEOF, 0, 0, 0, 0, 0, 0 },
233 { "static", T_SCLASS, STATIC, 0, 0, 0, 0, 0 },
234 { "struct", T_SOU, 0, STRUCT, 0, 0, 0, 0 },
235 { "switch", T_SWITCH, 0, 0, 0, 0, 0, 0 },
236 { "typedef", T_SCLASS, TYPEDEF, 0, 0, 0, 0, 0 },
237 { "union", T_SOU, 0, UNION, 0, 0, 0, 0 },
238 { "unsigned", T_TYPE, 0, UNSIGN, 0, 0, 0, 0 },
239 { "void", T_TYPE, 0, VOID, 0, 0, 0, 0 },
240 { "volatile", T_QUAL, 0, 0, VOLATILE, 1, 0, 0 },
241 { "__volatile__", T_QUAL, 0, 0, VOLATILE, 0, 0, 0 },
242 { "__volatile", T_QUAL, 0, 0, VOLATILE, 0, 0, 0 },
243 { "while", T_WHILE, 0, 0, 0, 0, 0, 0 },
244 { NULL, 0, 0, 0, 0, 0, 0, 0 }
243};
244
245/* Symbol table */
246static sym_t *symtab[HSHSIZ1];
247
248/* bit i of the entry with index i is set */
249uint64_t qbmasks[sizeof(uint64_t) * CHAR_BIT];
250

--- 18 unchanged lines hidden (view full) ---

269initscan(void)
270{
271 struct kwtab *kw;
272 sym_t *sym;
273 int h, i;
274 uint64_t uq;
275
276 for (kw = kwtab; kw->kw_name != NULL; kw++) {
245};
246
247/* Symbol table */
248static sym_t *symtab[HSHSIZ1];
249
250/* bit i of the entry with index i is set */
251uint64_t qbmasks[sizeof(uint64_t) * CHAR_BIT];
252

--- 18 unchanged lines hidden (view full) ---

271initscan(void)
272{
273 struct kwtab *kw;
274 sym_t *sym;
275 int h, i;
276 uint64_t uq;
277
278 for (kw = kwtab; kw->kw_name != NULL; kw++) {
277 if (kw->kw_stdc && tflag)
279 if ((kw->kw_c89 || kw->kw_c99) && tflag)
278 continue;
280 continue;
281 if (kw->kw_c99 && !(Sflag || gflag))
282 continue;
279 if (kw->kw_gcc && !gflag)
280 continue;
281 sym = getblk(sizeof (sym_t));
282 sym->s_name = kw->kw_name;
283 sym->s_keyw = 1;
284 sym->s_value.v_quad = kw->kw_token;
285 if (kw->kw_token == T_TYPE || kw->kw_token == T_SOU) {
286 sym->s_tspec = kw->kw_tspec;

--- 108 unchanged lines hidden (view full) ---

395 freesb(sb);
396 return (keyw(sym));
397 }
398
399 sb->sb_sym = sym;
400
401 if (sym != NULL) {
402 if (blklev < sym->s_blklev)
283 if (kw->kw_gcc && !gflag)
284 continue;
285 sym = getblk(sizeof (sym_t));
286 sym->s_name = kw->kw_name;
287 sym->s_keyw = 1;
288 sym->s_value.v_quad = kw->kw_token;
289 if (kw->kw_token == T_TYPE || kw->kw_token == T_SOU) {
290 sym->s_tspec = kw->kw_tspec;

--- 108 unchanged lines hidden (view full) ---

399 freesb(sb);
400 return (keyw(sym));
401 }
402
403 sb->sb_sym = sym;
404
405 if (sym != NULL) {
406 if (blklev < sym->s_blklev)
403 lerror("name() 1");
407 LERROR("name()");
404 sb->sb_name = sym->s_name;
405 sb->sb_len = strlen(sym->s_name);
406 tok = sym->s_scl == TYPEDEF ? T_TYPENAME : T_NAME;
407 } else {
408 s = getblk(yyleng + 1);
409 (void)memcpy(s, yytext, yyleng + 1);
410 sb->sb_name = s;
411 sb->sb_len = yyleng;

--- 91 unchanged lines hidden (view full) ---

503
504 errno = 0;
505 if (l_suffix < 2) {
506 ul = strtoul(cp, &eptr, base);
507 } else {
508 uq = strtouq(cp, &eptr, base);
509 }
510 if (eptr != cp + len)
408 sb->sb_name = sym->s_name;
409 sb->sb_len = strlen(sym->s_name);
410 tok = sym->s_scl == TYPEDEF ? T_TYPENAME : T_NAME;
411 } else {
412 s = getblk(yyleng + 1);
413 (void)memcpy(s, yytext, yyleng + 1);
414 sb->sb_name = s;
415 sb->sb_len = yyleng;

--- 91 unchanged lines hidden (view full) ---

507
508 errno = 0;
509 if (l_suffix < 2) {
510 ul = strtoul(cp, &eptr, base);
511 } else {
512 uq = strtouq(cp, &eptr, base);
513 }
514 if (eptr != cp + len)
511 lerror("icon() 1");
515 LERROR("icon()");
512 if (errno != 0)
513 /* integer constant out of range */
514 warning(252);
515
516 /*
517 * If the value is to big for the current type, we must choose
518 * another type.
519 */
520 ansiu = 0;
521 switch (typ) {
522 case INT:
523 if (ul <= INT_MAX) {
524 /* ok */
525 } else if (ul <= (unsigned)UINT_MAX && base != 10) {
526 typ = UINT;
516 if (errno != 0)
517 /* integer constant out of range */
518 warning(252);
519
520 /*
521 * If the value is to big for the current type, we must choose
522 * another type.
523 */
524 ansiu = 0;
525 switch (typ) {
526 case INT:
527 if (ul <= INT_MAX) {
528 /* ok */
529 } else if (ul <= (unsigned)UINT_MAX && base != 10) {
530 typ = UINT;
531#if INT_MAX != LONG_MAX
527 } else if (ul <= LONG_MAX) {
528 typ = LONG;
532 } else if (ul <= LONG_MAX) {
533 typ = LONG;
534#endif
529 } else {
530 typ = ULONG;
531 }
532 if (typ == UINT || typ == ULONG) {
533 if (tflag) {
534 typ = LONG;
535 } else if (!sflag) {
536 /*

--- 139 unchanged lines hidden (view full) ---

676
677 if (tflag && typ != DOUBLE) {
678 /* suffixes F and L are illegal in traditional C */
679 warning(98);
680 }
681
682 errno = 0;
683 d = strtod(cp, &eptr);
535 } else {
536 typ = ULONG;
537 }
538 if (typ == UINT || typ == ULONG) {
539 if (tflag) {
540 typ = LONG;
541 } else if (!sflag) {
542 /*

--- 139 unchanged lines hidden (view full) ---

682
683 if (tflag && typ != DOUBLE) {
684 /* suffixes F and L are illegal in traditional C */
685 warning(98);
686 }
687
688 errno = 0;
689 d = strtod(cp, &eptr);
684 if (eptr != cp + len)
685 lerror("fcon() 1");
690 if (eptr != cp + len) {
691 switch (*eptr) {
692 /*
693 * XXX: non-native non-current strtod() may not handle hex
694 * floats, ignore the rest if we find traces of hex float
695 * syntax...
696 */
697 case 'p':
698 case 'P':
699 case 'x':
700 case 'X':
701 d = 0;
702 errno = 0;
703 break;
704 default:
705 LERROR("fcon()");
706 }
707 }
686 if (errno != 0)
687 /* floating-point constant out of range */
688 warning(248);
689
690 if (typ == FLOAT) {
691 f = (float)d;
692 if (!finite(f)) {
693 /* floating-point constant out of range */

--- 441 unchanged lines hidden (view full) ---

1135/*
1136 * Handle // style comments
1137 */
1138static void
1139slashslashcomment(void)
1140{
1141 int c;
1142
708 if (errno != 0)
709 /* floating-point constant out of range */
710 warning(248);
711
712 if (typ == FLOAT) {
713 f = (float)d;
714 if (!finite(f)) {
715 /* floating-point constant out of range */

--- 441 unchanged lines hidden (view full) ---

1157/*
1158 * Handle // style comments
1159 */
1160static void
1161slashslashcomment(void)
1162{
1163 int c;
1164
1143 if (sflag < 2 && !gflag)
1165 if (!Sflag && !gflag)
1144 /* // comments only supported in C99 */
1145 (void)gnuism(312, tflag ? "traditional" : "ANSI");
1146
1147 while ((c = inpc()) != EOF && c != '\n')
1148 continue;
1149}
1150
1151/*

--- 142 unchanged lines hidden (view full) ---

1294 */
1295 if (symtyp == FMOS || symtyp == FLAB) {
1296 if (sym == NULL || sym->s_kind == FVFT)
1297 sym = search(sb);
1298 }
1299
1300 if (sym != NULL) {
1301 if (sym->s_kind != symtyp)
1166 /* // comments only supported in C99 */
1167 (void)gnuism(312, tflag ? "traditional" : "ANSI");
1168
1169 while ((c = inpc()) != EOF && c != '\n')
1170 continue;
1171}
1172
1173/*

--- 142 unchanged lines hidden (view full) ---

1316 */
1317 if (symtyp == FMOS || symtyp == FLAB) {
1318 if (sym == NULL || sym->s_kind == FVFT)
1319 sym = search(sb);
1320 }
1321
1322 if (sym != NULL) {
1323 if (sym->s_kind != symtyp)
1302 lerror("storesym() 1");
1324 LERROR("storesym()");
1303 symtyp = FVFT;
1304 freesb(sb);
1305 return (sym);
1306 }
1307
1308 /* create a new symbol table entry */
1309
1310 /* labels must always be allocated at level 1 (outhermost block) */
1311 if (symtyp == FLAB) {
1312 sym = getlblk(1, sizeof (sym_t));
1313 s = getlblk(1, sb->sb_len + 1);
1314 (void)memcpy(s, sb->sb_name, sb->sb_len + 1);
1315 sym->s_name = s;
1316 sym->s_blklev = 1;
1317 di = dcs;
1318 while (di->d_nxt != NULL && di->d_nxt->d_nxt != NULL)
1319 di = di->d_nxt;
1320 if (di->d_ctx != AUTO)
1325 symtyp = FVFT;
1326 freesb(sb);
1327 return (sym);
1328 }
1329
1330 /* create a new symbol table entry */
1331
1332 /* labels must always be allocated at level 1 (outhermost block) */
1333 if (symtyp == FLAB) {
1334 sym = getlblk(1, sizeof (sym_t));
1335 s = getlblk(1, sb->sb_len + 1);
1336 (void)memcpy(s, sb->sb_name, sb->sb_len + 1);
1337 sym->s_name = s;
1338 sym->s_blklev = 1;
1339 di = dcs;
1340 while (di->d_nxt != NULL && di->d_nxt->d_nxt != NULL)
1341 di = di->d_nxt;
1342 if (di->d_ctx != AUTO)
1321 lerror("storesym() 2");
1343 LERROR("storesym()");
1322 } else {
1323 sym = getblk(sizeof (sym_t));
1324 sym->s_name = sb->sb_name;
1325 sym->s_blklev = blklev;
1326 di = dcs;
1327 }
1328
1329 UNIQUE_CURR_POS(sym->s_dpos);

--- 9 unchanged lines hidden (view full) ---

1339 *di->d_ldlsym = sym;
1340 di->d_ldlsym = &sym->s_dlnxt;
1341
1342 freesb(sb);
1343 return (sym);
1344}
1345
1346/*
1344 } else {
1345 sym = getblk(sizeof (sym_t));
1346 sym->s_name = sb->sb_name;
1347 sym->s_blklev = blklev;
1348 di = dcs;
1349 }
1350
1351 UNIQUE_CURR_POS(sym->s_dpos);

--- 9 unchanged lines hidden (view full) ---

1361 *di->d_ldlsym = sym;
1362 di->d_ldlsym = &sym->s_dlnxt;
1363
1364 freesb(sb);
1365 return (sym);
1366}
1367
1368/*
1369 * Construct a temporary symbol. The symbol starts with a digit, so that
1370 * it is illegal.
1371 */
1372sym_t *
1373mktempsym(type_t *t)
1374{
1375 static int n = 0;
1376 int h;
1377 char *s = getlblk(blklev, 64);
1378 sym_t *sym = getblk(sizeof (sym_t));
1379
1380 (void)snprintf(s, 64, "%.8d_tmp", n++);
1381 h = hash(s);
1382
1383 sym->s_name = s;
1384 sym->s_type = t;
1385 sym->s_blklev = blklev;
1386 sym->s_scl = AUTO;
1387 sym->s_kind = FVFT;
1388 sym->s_used = 1;
1389 sym->s_set = 1;
1390
1391 if ((sym->s_link = symtab[h]) != NULL)
1392 symtab[h]->s_rlink = &sym->s_link;
1393 (symtab[h] = sym)->s_rlink = &symtab[h];
1394
1395 *dcs->d_ldlsym = sym;
1396 dcs->d_ldlsym = &sym->s_dlnxt;
1397
1398 return sym;
1399}
1400
1401/*
1347 * Remove a symbol forever from the symbol table. s_blklev
1348 * is set to -1 to avoid that the symbol will later be put
1349 * back to the symbol table.
1350 */
1351void
1352rmsym(sym_t *sym)
1353{
1354

--- 31 unchanged lines hidden (view full) ---

1386 int h;
1387
1388 h = hash(sym->s_name);
1389 if ((sym->s_link = symtab[h]) != NULL)
1390 symtab[h]->s_rlink = &sym->s_link;
1391 (symtab[h] = sym)->s_rlink = &symtab[h];
1392 sym->s_blklev = bl;
1393 if (sym->s_link != NULL && sym->s_blklev < sym->s_link->s_blklev)
1402 * Remove a symbol forever from the symbol table. s_blklev
1403 * is set to -1 to avoid that the symbol will later be put
1404 * back to the symbol table.
1405 */
1406void
1407rmsym(sym_t *sym)
1408{
1409

--- 31 unchanged lines hidden (view full) ---

1441 int h;
1442
1443 h = hash(sym->s_name);
1444 if ((sym->s_link = symtab[h]) != NULL)
1445 symtab[h]->s_rlink = &sym->s_link;
1446 (symtab[h] = sym)->s_rlink = &symtab[h];
1447 sym->s_blklev = bl;
1448 if (sym->s_link != NULL && sym->s_blklev < sym->s_link->s_blklev)
1394 lerror("inssym()");
1449 LERROR("inssym()");
1395}
1396
1397/*
1398 * Called at level 0 after syntax errors
1399 * Removes all symbols which are not declared at level 0 from the
1400 * symbol table. Also frees all memory which is not associated with
1401 * level 0.
1402 */

--- 24 unchanged lines hidden (view full) ---

1427pushdown(sym_t *sym)
1428{
1429 int h;
1430 sym_t *nsym;
1431
1432 h = hash(sym->s_name);
1433 nsym = getblk(sizeof (sym_t));
1434 if (sym->s_blklev > blklev)
1450}
1451
1452/*
1453 * Called at level 0 after syntax errors
1454 * Removes all symbols which are not declared at level 0 from the
1455 * symbol table. Also frees all memory which is not associated with
1456 * level 0.
1457 */

--- 24 unchanged lines hidden (view full) ---

1482pushdown(sym_t *sym)
1483{
1484 int h;
1485 sym_t *nsym;
1486
1487 h = hash(sym->s_name);
1488 nsym = getblk(sizeof (sym_t));
1489 if (sym->s_blklev > blklev)
1435 lerror("pushdown()");
1490 LERROR("pushdown()");
1436 nsym->s_name = sym->s_name;
1437 UNIQUE_CURR_POS(nsym->s_dpos);
1438 nsym->s_kind = sym->s_kind;
1439 nsym->s_blklev = blklev;
1440
1441 if ((nsym->s_link = symtab[h]) != NULL)
1442 symtab[h]->s_rlink = &nsym->s_link;
1443 (symtab[h] = nsym)->s_rlink = &symtab[h];

--- 20 unchanged lines hidden (view full) ---

1464 free(val);
1465 } else if (tok == T_STRING) {
1466 strg_t *strg = *(strg_t **)sp;
1467 if (strg->st_tspec == CHAR) {
1468 free(strg->st_cp);
1469 } else if (strg->st_tspec == WCHAR) {
1470 free(strg->st_wcp);
1471 } else {
1491 nsym->s_name = sym->s_name;
1492 UNIQUE_CURR_POS(nsym->s_dpos);
1493 nsym->s_kind = sym->s_kind;
1494 nsym->s_blklev = blklev;
1495
1496 if ((nsym->s_link = symtab[h]) != NULL)
1497 symtab[h]->s_rlink = &nsym->s_link;
1498 (symtab[h] = nsym)->s_rlink = &symtab[h];

--- 20 unchanged lines hidden (view full) ---

1519 free(val);
1520 } else if (tok == T_STRING) {
1521 strg_t *strg = *(strg_t **)sp;
1522 if (strg->st_tspec == CHAR) {
1523 free(strg->st_cp);
1524 } else if (strg->st_tspec == WCHAR) {
1525 free(strg->st_wcp);
1526 } else {
1472 lerror("fryylv() 1");
1527 LERROR("fryylv()");
1473 }
1474 free(strg);
1475 }
1476}
1528 }
1529 free(strg);
1530 }
1531}