| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: lex.c,v 1.22 2021/04/02 12:16:50 rillig Exp $ */ | | 1 | /* $NetBSD: lex.c,v 1.23 2021/04/02 22:05:43 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,51 +28,51 @@ | | | @@ -28,51 +28,51 @@ |
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.22 2021/04/02 12:16:50 rillig Exp $"); | | 41 | __RCSID("$NetBSD: lex.c,v 1.23 2021/04/02 22:05:43 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 | |
55 | #define CHAR_MASK ((int)(~(~0U << CHAR_SIZE))) | | 55 | #define CHAR_MASK ((int)(~(~0U << CHAR_SIZE))) |
56 | | | 56 | |
57 | | | 57 | |
58 | /* Current position (it's also updated when an included file is parsed) */ | | 58 | /* Current position (it's also updated when an included file is parsed) */ |
59 | pos_t curr_pos = { 1, "", 0 }; | | 59 | pos_t curr_pos = { "", 1, 0 }; |
60 | | | 60 | |
61 | /* | | 61 | /* |
62 | * Current position in C source (not updated when an included file is | | 62 | * Current position in C source (not updated when an included file is |
63 | * parsed). | | 63 | * parsed). |
64 | */ | | 64 | */ |
65 | pos_t csrc_pos = { 1, "", 0 }; | | 65 | pos_t csrc_pos = { "", 1, 0 }; |
66 | | | 66 | |
67 | /* Are we parsing a gcc attribute? */ | | 67 | /* Are we parsing a gcc attribute? */ |
68 | bool attron; | | 68 | bool attron; |
69 | | | 69 | |
70 | bool in_system_header = false; | | 70 | bool in_system_header = false; |
71 | | | 71 | |
72 | static sbuf_t *allocsb(void); | | 72 | static sbuf_t *allocsb(void); |
73 | static void freesb(sbuf_t *); | | 73 | static void freesb(sbuf_t *); |
74 | static int inpc(void); | | 74 | static int inpc(void); |
75 | static int hash(const char *); | | 75 | static int hash(const char *); |
76 | static sym_t * search(sbuf_t *); | | 76 | static sym_t * search(sbuf_t *); |
77 | static int keyw(sym_t *); | | 77 | static int keyw(sym_t *); |
78 | static int get_escaped_char(int); | | 78 | static int get_escaped_char(int); |