| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: lex.c,v 1.52 2021/07/08 02:59:22 rillig Exp $ */ | | 1 | /* $NetBSD: lex.c,v 1.53 2021/07/08 03:10:39 rillig Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | | 4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. |
5 | * Copyright (c) 1994, 1995 Jochen Pohl | | 5 | * Copyright (c) 1994, 1995 Jochen Pohl |
6 | * All Rights Reserved. | | 6 | * All Rights Reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -28,27 +28,27 @@ | | | @@ -28,27 +28,27 @@ |
28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #if HAVE_NBTOOL_CONFIG_H | | 35 | #if HAVE_NBTOOL_CONFIG_H |
36 | #include "nbtool_config.h" | | 36 | #include "nbtool_config.h" |
37 | #endif | | 37 | #endif |
38 | | | 38 | |
39 | #include <sys/cdefs.h> | | 39 | #include <sys/cdefs.h> |
40 | #if defined(__RCSID) && !defined(lint) | | 40 | #if defined(__RCSID) && !defined(lint) |
41 | __RCSID("$NetBSD: lex.c,v 1.52 2021/07/08 02:59:22 rillig Exp $"); | | 41 | __RCSID("$NetBSD: lex.c,v 1.53 2021/07/08 03:10:39 rillig Exp $"); |
42 | #endif | | 42 | #endif |
43 | | | 43 | |
44 | #include <ctype.h> | | 44 | #include <ctype.h> |
45 | #include <errno.h> | | 45 | #include <errno.h> |
46 | #include <float.h> | | 46 | #include <float.h> |
47 | #include <limits.h> | | 47 | #include <limits.h> |
48 | #include <math.h> | | 48 | #include <math.h> |
49 | #include <stdlib.h> | | 49 | #include <stdlib.h> |
50 | #include <string.h> | | 50 | #include <string.h> |
51 | | | 51 | |
52 | #include "lint1.h" | | 52 | #include "lint1.h" |
53 | #include "cgram.h" | | 53 | #include "cgram.h" |
54 | | | 54 | |
| @@ -1371,31 +1371,30 @@ lex_wide_string(void) | | | @@ -1371,31 +1371,30 @@ lex_wide_string(void) |
1371 | strg->st_len = wlen; | | 1371 | strg->st_len = wlen; |
1372 | strg->st_wcp = ws; | | 1372 | strg->st_wcp = ws; |
1373 | | | 1373 | |
1374 | yylval.y_string = strg; | | 1374 | yylval.y_string = strg; |
1375 | return T_STRING; | | 1375 | return T_STRING; |
1376 | } | | 1376 | } |
1377 | | | 1377 | |
1378 | /* | | 1378 | /* |
1379 | * As noted above the scanner does not create new symbol table entries | | 1379 | * As noted above the scanner does not create new symbol table entries |
1380 | * for symbols it cannot find in the symbol table. This is to avoid | | 1380 | * for symbols it cannot find in the symbol table. This is to avoid |
1381 | * putting undeclared symbols into the symbol table if a syntax error | | 1381 | * putting undeclared symbols into the symbol table if a syntax error |
1382 | * occurs. | | 1382 | * occurs. |
1383 | * | | 1383 | * |
1384 | * getsym() is called as soon as it is probably ok to put the symbol to | | 1384 | * getsym() is called as soon as it is probably ok to put the symbol to the |
1385 | * the symbol table. This does not mean that it is not possible that | | 1385 | * symbol table. It is still possible that symbols are put in the symbol |
1386 | * symbols are put to the symbol table which are not completely | | 1386 | * table that are not completely declared due to syntax errors. To avoid too |
1387 | * declared due to syntax errors. To avoid too many problems in this | | 1387 | * many problems in this case, symbols get type int in getsym(). |
1388 | * case, symbols get type int in getsym(). | | | |
1389 | * | | 1388 | * |
1390 | * XXX calls to getsym() should be delayed until decl1*() is called. | | 1389 | * XXX calls to getsym() should be delayed until decl1*() is called. |
1391 | */ | | 1390 | */ |
1392 | sym_t * | | 1391 | sym_t * |
1393 | getsym(sbuf_t *sb) | | 1392 | getsym(sbuf_t *sb) |
1394 | { | | 1393 | { |
1395 | dinfo_t *di; | | 1394 | dinfo_t *di; |
1396 | char *s; | | 1395 | char *s; |
1397 | sym_t *sym; | | 1396 | sym_t *sym; |
1398 | | | 1397 | |
1399 | sym = sb->sb_sym; | | 1398 | sym = sb->sb_sym; |
1400 | | | 1399 | |
1401 | /* | | 1400 | /* |
| @@ -1446,28 +1445,28 @@ getsym(sbuf_t *sb) | | | @@ -1446,28 +1445,28 @@ getsym(sbuf_t *sb) |
1446 | if ((sym->s_link = symtab[sb->sb_hash]) != NULL) | | 1445 | if ((sym->s_link = symtab[sb->sb_hash]) != NULL) |
1447 | symtab[sb->sb_hash]->s_rlink = &sym->s_link; | | 1446 | symtab[sb->sb_hash]->s_rlink = &sym->s_link; |
1448 | sym->s_rlink = &symtab[sb->sb_hash]; | | 1447 | sym->s_rlink = &symtab[sb->sb_hash]; |
1449 | symtab[sb->sb_hash] = sym; | | 1448 | symtab[sb->sb_hash] = sym; |
1450 | | | 1449 | |
1451 | *di->d_ldlsym = sym; | | 1450 | *di->d_ldlsym = sym; |
1452 | di->d_ldlsym = &sym->s_dlnxt; | | 1451 | di->d_ldlsym = &sym->s_dlnxt; |
1453 | | | 1452 | |
1454 | freesb(sb); | | 1453 | freesb(sb); |
1455 | return sym; | | 1454 | return sym; |
1456 | } | | 1455 | } |
1457 | | | 1456 | |
1458 | /* | | 1457 | /* |
1459 | * Construct a temporary symbol. The symbol starts with a digit, so that | | 1458 | * Construct a temporary symbol. The symbol name starts with a digit, making |
1460 | * it is illegal. | | 1459 | * the name illegal. |
1461 | */ | | 1460 | */ |
1462 | sym_t * | | 1461 | sym_t * |
1463 | mktempsym(type_t *t) | | 1462 | mktempsym(type_t *t) |
1464 | { | | 1463 | { |
1465 | static int n = 0; | | 1464 | static int n = 0; |
1466 | int h; | | 1465 | int h; |
1467 | char *s = getlblk(block_level, 64); | | 1466 | char *s = getlblk(block_level, 64); |
1468 | sym_t *sym = getblk(sizeof(*sym)); | | 1467 | sym_t *sym = getblk(sizeof(*sym)); |
1469 | scl_t scl; | | 1468 | scl_t scl; |
1470 | | | 1469 | |
1471 | (void)snprintf(s, 64, "%.8d_tmp", n++); | | 1470 | (void)snprintf(s, 64, "%.8d_tmp", n++); |
1472 | h = hash(s); | | 1471 | h = hash(s); |
1473 | | | 1472 | |