| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: print.c,v 1.9 2021/01/05 07:37:41 rillig Exp $ */ | | 1 | /* $NetBSD: print.c,v 1.10 2021/01/05 23:20:53 rillig Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2003 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2003 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Christos Zoulas. | | 8 | * by Christos Zoulas. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -25,99 +25,33 @@ | | | @@ -25,99 +25,33 @@ |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #if HAVE_NBTOOL_CONFIG_H | | 32 | #if HAVE_NBTOOL_CONFIG_H |
33 | #include "nbtool_config.h" | | 33 | #include "nbtool_config.h" |
34 | #endif | | 34 | #endif |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | #ifndef lint | | 37 | #ifndef lint |
38 | __RCSID("$NetBSD: print.c,v 1.9 2021/01/05 07:37:41 rillig Exp $"); | | 38 | __RCSID("$NetBSD: print.c,v 1.10 2021/01/05 23:20:53 rillig Exp $"); |
39 | #endif | | 39 | #endif |
40 | | | 40 | |
41 | #include <stdio.h> | | 41 | #include <stdio.h> |
42 | | | 42 | |
43 | #include "lint1.h" | | 43 | #include "lint1.h" |
44 | | | 44 | |
45 | static const char *str_op_t[] = | | | |
46 | { | | | |
47 | "*noop*", | | | |
48 | "->", | | | |
49 | ".", | | | |
50 | "!", | | | |
51 | "~", | | | |
52 | "++", | | | |
53 | "--", | | | |
54 | "++<", | | | |
55 | "--<", | | | |
56 | "++>", | | | |
57 | "-->", | | | |
58 | "+", | | | |
59 | "-", | | | |
60 | "*", | | | |
61 | "&", | | | |
62 | "*", | | | |
63 | "/", | | | |
64 | "%", | | | |
65 | "+", | | | |
66 | "-", | | | |
67 | "<<", | | | |
68 | ">>", | | | |
69 | "<", | | | |
70 | "<=", | | | |
71 | ">", | | | |
72 | ">=", | | | |
73 | "==", | | | |
74 | "!=", | | | |
75 | "&", | | | |
76 | "^", | | | |
77 | "|", | | | |
78 | "&&", | | | |
79 | "||", | | | |
80 | "?", | | | |
81 | ":", | | | |
82 | "=", | | | |
83 | "*=", | | | |
84 | "/=", | | | |
85 | "%=", | | | |
86 | "+=", | | | |
87 | "-=", | | | |
88 | "<<=", | | | |
89 | ">>=", | | | |
90 | "&=", | | | |
91 | "^=", | | | |
92 | "|=", | | | |
93 | "*name*", | | | |
94 | "*constant*", | | | |
95 | "*string*", | | | |
96 | "*field select*", | | | |
97 | "*call*", | | | |
98 | ",", | | | |
99 | "*(cast)*", | | | |
100 | "*icall*", | | | |
101 | "*load*", | | | |
102 | "*push*", | | | |
103 | "return", | | | |
104 | "real", | | | |
105 | "imag", | | | |
106 | "*init*", | | | |
107 | "*case*", | | | |
108 | "*farg*", | | | |
109 | }; | | | |
110 | | | | |
111 | char * | | 45 | char * |
112 | print_tnode(char *buf, size_t bufsiz, const tnode_t *tn) | | 46 | print_tnode(char *buf, size_t bufsiz, const tnode_t *tn) |
113 | { | | 47 | { |
114 | strg_t *st; | | 48 | strg_t *st; |
115 | val_t *v; | | 49 | val_t *v; |
116 | sym_t *s; | | 50 | sym_t *s; |
117 | switch (tn->tn_op) { | | 51 | switch (tn->tn_op) { |
118 | case NAME: | | 52 | case NAME: |
119 | s = tn->tn_sym; | | 53 | s = tn->tn_sym; |
120 | (void)snprintf(buf, bufsiz, "%s", s->s_name); | | 54 | (void)snprintf(buf, bufsiz, "%s", s->s_name); |
121 | break; | | 55 | break; |
122 | case CON: | | 56 | case CON: |
123 | v = tn->tn_val; | | 57 | v = tn->tn_val; |
| @@ -138,18 +72,18 @@ print_tnode(char *buf, size_t bufsiz, co | | | @@ -138,18 +72,18 @@ print_tnode(char *buf, size_t bufsiz, co |
138 | st = tn->tn_string; | | 72 | st = tn->tn_string; |
139 | switch (st->st_tspec) { | | 73 | switch (st->st_tspec) { |
140 | case CHAR: | | 74 | case CHAR: |
141 | case SCHAR: | | 75 | case SCHAR: |
142 | case UCHAR: | | 76 | case UCHAR: |
143 | (void)snprintf(buf, bufsiz, "\"%s\"", st->st_cp); | | 77 | (void)snprintf(buf, bufsiz, "\"%s\"", st->st_cp); |
144 | break; | | 78 | break; |
145 | default: | | 79 | default: |
146 | (void)snprintf(buf, bufsiz, "\"*wide string*\""); | | 80 | (void)snprintf(buf, bufsiz, "\"*wide string*\""); |
147 | break; | | 81 | break; |
148 | } | | 82 | } |
149 | break; | | 83 | break; |
150 | default: | | 84 | default: |
151 | (void)snprintf(buf, bufsiz, "%s", str_op_t[tn->tn_op]); | | 85 | (void)snprintf(buf, bufsiz, "%s", getopname(tn->tn_op)); |
152 | break; | | 86 | break; |
153 | } | | 87 | } |
154 | return buf; | | 88 | return buf; |
155 | } | | 89 | } |