diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-12-16 12:22:52 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-12-16 12:27:02 +0200 |
commit | 74d73e0936d8ff28167e1f5045e3661ab9384a38 (patch) | |
tree | 8fbd707298c690fdaade7ff9cd6b7acfc84434cf | |
parent | 27ac5a32a7ca4cddacce307c586830fbb877b4ce (diff) | |
parent | 9e978b089268e6bfc4b8fcdf9ef721f6fa92c11f (diff) | |
download | grecs-74d73e0936d8ff28167e1f5045e3661ab9384a38.tar.gz grecs-74d73e0936d8ff28167e1f5045e3661ab9384a38.tar.bz2 |
Merge branch 'master' into clparse
* build-aux/getopt.m4: Use separate namespace for internal symbols
* src/format.c (grecs_format_node_path)
(grecs_format_node_path): don't coredump on NULL values.
* src/grecs-lex.l: Improve error reporting.
-rw-r--r-- | build-aux/getopt.m4 | 110 | ||||
-rw-r--r-- | src/format.c | 14 | ||||
-rw-r--r-- | src/grecs-lex.l | 6 | ||||
-rw-r--r-- | src/grecs.hin | 1 | ||||
-rw-r--r-- | src/preproc.c | 3 |
5 files changed, 75 insertions, 59 deletions
diff --git a/build-aux/getopt.m4 b/build-aux/getopt.m4 index c7357d1..97a2cd5 100644 --- a/build-aux/getopt.m4 +++ b/build-aux/getopt.m4 | |||
@@ -88,87 +88,88 @@ define([<_getopt_set_options>], | |||
88 | [<_getopt_set_option([<$1>]) | 88 | [<_getopt_set_option([<$1>]) |
89 | _getopt_set_options(shift($@))>])>]) | 89 | _getopt_set_options(shift($@))>])>]) |
90 | 90 | ||
91 | dnl format_authors(name[,name...]) | 91 | dnl __getopt_format_authors(name[,name...]) |
92 | dnl ------------------------------ | 92 | dnl ------------------------------ |
93 | define([<format_authors>],dnl | 93 | define([<__getopt_format_authors>],dnl |
94 | [<ifelse([<$1>],,NULL,[<"$1", | 94 | [<ifelse([<$1>],,NULL,[<"$1", |
95 | format_authors(shift($@))>])>]) | 95 | __getopt_format_authors(shift($@))>])>]) |
96 | 96 | ||
97 | dnl upcase(ARGS...) | 97 | dnl __getopt_upcase(ARGS...) |
98 | dnl Concatenate and convert ARGS to upper case. | 98 | dnl Concatenate and convert ARGS to upper case. |
99 | dnl | 99 | dnl |
100 | define([<upcase>], [<translit([<$*>], [<a-z>], [<A-Z>])>]) | 100 | define([<__getopt_upcase>], [<translit([<$*>], [<a-z>], [<A-Z>])>]) |
101 | 101 | ||
102 | dnl concat(ARGS...) | 102 | dnl __getopt_concat(ARGS...) |
103 | dnl Concatenate arguments, inserting ", " between each pair of them. | 103 | dnl Concatenate arguments, inserting ", " between each pair of them. |
104 | dnl | 104 | dnl |
105 | define([<concat>],[<ifelse([<$#>],1,[<$1>],[<$1, concat(shift($@))>])>]) | 105 | define([<__getopt_concat>],[<ifelse([<$#>],1,[<$1>],[<$1, __getopt_concat(shift($@))>])>]) |
106 | 106 | ||
107 | dnl flushleft(ARGS...) | 107 | dnl __getopt_flushleft(ARGS...) |
108 | dnl Concatenate ARGS and remove any leading whitespace | 108 | dnl Concatenate ARGS and remove any leading whitespace |
109 | dnl | 109 | dnl |
110 | define([<flushleft>], | 110 | define([<__getopt_flushleft>], |
111 | [<patsubst([<concat($*)>], [<^[ ]+>])>]) | 111 | [<patsubst([<__getopt_concat($*)>], [<^[ ]+>])>]) |
112 | 112 | ||
113 | dnl chop(ARGS...) | 113 | dnl __getopt_chop(ARGS...) |
114 | dnl Concatenate ARGS and remove any trailing whitespace | 114 | dnl Concatenate ARGS and remove any trailing whitespace |
115 | dnl | 115 | dnl |
116 | define([<chop>], | 116 | define([<__getopt_chop>], |
117 | [<patsubst([<$*>], [<[ ]+$>])>]) | 117 | [<patsubst([<$*>], [<[ ]+$>])>]) |
118 | 118 | ||
119 | dnl escape(ARGS...) | 119 | dnl __getopt_escape(ARGS...) |
120 | dnl Concatenate ARGS and escape any occurrences of double-quotes with | 120 | dnl Concatenate ARGS and escape any occurrences of double-quotes with |
121 | dnl backslashes. | 121 | dnl backslashes. |
122 | dnl | 122 | dnl |
123 | define([<escape>], | 123 | define([<__getopt_escape>], |
124 | [<patsubst([<concat($*)>],[<[\"]>],[<\\\&>])>]) | 124 | [<patsubst([<__getopt_concat($*)>],[<[\"]>],[<\\\&>])>]) |
125 | 125 | ||
126 | dnl prep(ARG) | 126 | dnl __getopt_prep(ARG) |
127 | dnl Prepare ARG for including in C strings: replace newlines and any | 127 | dnl Prepare ARG for including in C strings: replace newlines and any |
128 | dnl preceding and following whitespace by a single space character, remove | 128 | dnl preceding and following whitespace by a single space character, remove |
129 | dnl leading whitespace, and escape double-quotes. | 129 | dnl leading whitespace, and escape double-quotes. |
130 | dnl | 130 | dnl |
131 | define([<prep>], | 131 | define([<__getopt_prep>], |
132 | [<escape(flushleft(patsubst([<$1>],[<[ ]* | 132 | [<__getopt_escape(__getopt_flushleft(patsubst([<$1>],[<[ ]* |
133 | +[ ]*>],[< >])))>]) | 133 | +[ ]*>],[< >])))>]) |
134 | 134 | ||
135 | dnl SHORT_OPTS | 135 | dnl __GETOPT_SHORT_OPTS |
136 | dnl Accumulator for the 3rd argument of getopt_long | 136 | dnl Accumulator for the 3rd argument of getopt_long |
137 | dnl | 137 | dnl |
138 | define([<SHORT_OPTS>],[<_getopt_if_option_set([<nopermute>],+)>]) | 138 | define([<__GETOPT_SHORT_OPTS>],[<_getopt_if_option_set([<nopermute>],+)>]) |
139 | 139 | ||
140 | dnl GROUP(STRING) | 140 | dnl GROUP(STRING) |
141 | dnl Begin a named group of options | 141 | dnl Begin a named group of options |
142 | dnl | 142 | dnl |
143 | define([<GROUP>],[<dnl | 143 | define([<GROUP>],[<dnl |
144 | divert(3) | 144 | divert(3) |
145 | { NULL, NULL, 0, N_("prep([<$1>])") }, | 145 | { NULL, NULL, 0, N_("__getopt_prep([<$1>])") }, |
146 | divert(-1)>]) | 146 | divert(-1)>]) |
147 | 147 | ||
148 | # quote(args) - convert args to single-quoted string | 148 | # __getopt_quote(args) - convert args to single-quoted string |
149 | define([<quote>], [<ifelse([<$#>], [<0>], [<>], [<[<$*>]>])>]) | 149 | define([<__getopt_quote>], [<ifelse([<$#>], [<0>], [<>], [<[<$*>]>])>]) |
150 | define([<dquote>], [<[<$@>]>]) | 150 | define([<__getopt_dquote>], [<[<$@>]>]) |
151 | 151 | ||
152 | define([<__GATHER_OPTIONS>],[< | 152 | define([<__GATHER_OPTIONS>],[< |
153 | define([<KEY>],ifelse([<$2>],,[<OPTION_>]upcase(patsubst($1,-,_)),'$2')) | 153 | pushdef([<__GETOPT_KEY>],ifelse([<$2>],,[<OPTION_>]__getopt_upcase(patsubst($1,-,_)),'$2')) |
154 | ifelse([<$2>],,[< | 154 | ifelse([<$2>],,[< |
155 | divert(1) | 155 | divert(1) |
156 | KEY, | 156 | __GETOPT_KEY, |
157 | divert(-1) | 157 | divert(-1) |
158 | >]) | 158 | >]) |
159 | define([<SELECTOR>],ifdef([<SELECTOR>],SELECTOR) case KEY:) | 159 | define([<__GETOPT_SELECTOR>],ifdef([<__GETOPT_SELECTOR>],__GETOPT_SELECTOR) case __GETOPT_KEY:) |
160 | ifelse([<$1>],,,[< | 160 | ifelse([<$1>],,,[< |
161 | divert(2) | 161 | divert(2) |
162 | { "$1", ARGTYPE, 0, KEY }, | 162 | { "$1", __GETOPT_ARGTYPE, 0, __GETOPT_KEY }, |
163 | divert(-1)>]) | 163 | divert(-1)>]) |
164 | dnl | 164 | dnl |
165 | define([<SHORT_OPTS>],dquote(SHORT_OPTS[<>]dnl | 165 | define([<__GETOPT_SHORT_OPTS>],__getopt_dquote(__GETOPT_SHORT_OPTS[<>]dnl |
166 | ifelse([<$2>],,,[<$2>]ifelse(ARGTYPE,[<no_argument>],,ARGTYPE,[<required_argument>],:,ARGTYPE,[<optional_argument>],::)))) | 166 | ifelse([<$2>],,,[<$2>]ifelse(__GETOPT_ARGTYPE,[<no_argument>],,__GETOPT_ARGTYPE,[<required_argument>],:,__GETOPT_ARGTYPE,[<optional_argument>],::)))) |
167 | dnl | 167 | dnl |
168 | ifelse([<$1>],,,dnl | 168 | ifelse([<$1>],,,dnl |
169 | [<define([<LONG_TAG>],ifelse(LONG_TAG,,[<--$1>],[<LONG_TAG; --$1>]))>]) | 169 | [<define([<__GETOPT_LONG_TAG>],ifelse(__GETOPT_LONG_TAG,,[<--$1>],[<__GETOPT_LONG_TAG; --$1>]))>]) |
170 | ifelse([<$2>],,,dnl | 170 | ifelse([<$2>],,,dnl |
171 | [<define([<SHORT_TAG>],ifelse(SHORT_TAG,,[<-$2>],[<SHORT_TAG; -$2>]))>]) | 171 | [<define([<__GETOPT_SHORT_TAG>],ifelse(__GETOPT_SHORT_TAG,,[<-$2>],[<__GETOPT_SHORT_TAG; -$2>]))>]) |
172 | popdef([<__GETOPT_KEY>]) | ||
172 | >]) | 173 | >]) |
173 | 174 | ||
174 | dnl OPTION(long-opt, short-opt, [arg], [descr]) | 175 | dnl OPTION(long-opt, short-opt, [arg], [descr]) |
@@ -189,12 +190,13 @@ dnl If descr is not given the option will not appear in the --help and | |||
189 | dnl --usage outputs. | 190 | dnl --usage outputs. |
190 | dnl | 191 | dnl |
191 | define([<OPTION>],[< | 192 | define([<OPTION>],[< |
192 | pushdef([<LONG_TAG>]) | 193 | pushdef([<__GETOPT_LONG_TAG>]) |
193 | pushdef([<SHORT_TAG>]) | 194 | pushdef([<__GETOPT_SHORT_TAG>]) |
194 | pushdef([<ARGNAME>],[<$3>]) | 195 | pushdef([<__GETOPT_SELECTOR>]) |
195 | pushdef([<HIDDEN>],ifelse([<$4>],,1,0)) | 196 | pushdef([<__GETOPT_ARGNAME>],[<$3>]) |
196 | pushdef([<DOCSTRING>],[<prep([<$4>])>]) | 197 | pushdef([<__GETOPT_HIDDEN>],ifelse([<$4>],,1,0)) |
197 | pushdef([<ARGTYPE>],[<ifelse([<$3>],,[<no_argument>],dnl | 198 | pushdef([<__GETOPT_DOCSTRING>],[<__getopt_prep([<$4>])>]) |
199 | pushdef([<__GETOPT_ARGTYPE>],[<ifelse([<$3>],,[<no_argument>],dnl | ||
198 | patsubst([<$3>],[<\[.*\]>]),,[<optional_argument>],dnl | 200 | patsubst([<$3>],[<\[.*\]>]),,[<optional_argument>],dnl |
199 | [<required_argument>])>]) | 201 | [<required_argument>])>]) |
200 | __GATHER_OPTIONS($@) | 202 | __GATHER_OPTIONS($@) |
@@ -216,28 +218,28 @@ dnl Start an action associated with the declared option. Must follow OPTION | |||
216 | dnl statement, with optional ALIAS statements in between. | 218 | dnl statement, with optional ALIAS statements in between. |
217 | dnl | 219 | dnl |
218 | define([<BEGIN>],[< | 220 | define([<BEGIN>],[< |
219 | ifelse(HIDDEN,1,,[< | 221 | ifelse(__GETOPT_HIDDEN,1,,[< |
220 | divert(3) | 222 | divert(3) |
221 | { | 223 | { |
222 | #ifdef HAVE_GETOPT_LONG | 224 | #ifdef HAVE_GETOPT_LONG |
223 | "translit(dnl | 225 | "translit(dnl |
224 | ifelse(SHORT_TAG,,LONG_TAG,[<SHORT_TAG[<>]ifelse(LONG_TAG,,,; LONG_TAG)>]), | 226 | ifelse(__GETOPT_SHORT_TAG,,__GETOPT_LONG_TAG,[<__GETOPT_SHORT_TAG[<>]ifelse(__GETOPT_LONG_TAG,,,; __GETOPT_LONG_TAG)>]), |
225 | [<;>],[<,>])", | 227 | [<;>],[<,>])", |
226 | #else | 228 | #else |
227 | "translit(SHORT_TAG, [<;>],[<,>])", | 229 | "translit(__GETOPT_SHORT_TAG, [<;>],[<,>])", |
228 | #endif | 230 | #endif |
229 | ifelse(ARGNAME,,[<NULL, 0>], | 231 | ifelse(__GETOPT_ARGNAME,,[<NULL, 0>], |
230 | [<ifelse(ARGTYPE,[<optional_argument>], | 232 | [<ifelse(__GETOPT_ARGTYPE,[<optional_argument>], |
231 | [<N_(>]"[<patsubst(ARGNAME,[<\[\(.*\)\]>],[<\1>])>][<"), 1>],[<N_("ARGNAME"), 0>])>]), N_("DOCSTRING") }, | 233 | [<N_(>]"[<patsubst(__GETOPT_ARGNAME,[<\[\(.*\)\]>],[<\1>])>][<"), 1>],[<N_("__GETOPT_ARGNAME"), 0>])>]), N_("__GETOPT_DOCSTRING") }, |
232 | divert(-1)>]) | 234 | divert(-1)>]) |
233 | popdef([<ARGTYPE>]) | 235 | popdef([<__GETOPT_ARGTYPE>]) |
234 | popdef([<ARGNAME>]) | 236 | popdef([<__GETOPT_ARGNAME>]) |
235 | popdef([<DOCSTRING>]) | 237 | popdef([<__GETOPT_DOCSTRING>]) |
236 | popdef([<HIDDEN>]) | 238 | popdef([<__GETOPT_HIDDEN>]) |
237 | divert(4)dnl | 239 | divert(4)dnl |
238 | popdef([<LONG_TAG>])dnl | 240 | popdef([<__GETOPT_LONG_TAG>])dnl |
239 | popdef([<SHORT_TAG>])dnl | 241 | popdef([<__GETOPT_SHORT_TAG>])dnl |
240 | SELECTOR | 242 | __GETOPT_SELECTOR |
241 | { | 243 | { |
242 | >]) | 244 | >]) |
243 | 245 | ||
@@ -248,7 +250,7 @@ define([<END>],[< | |||
248 | break; | 250 | break; |
249 | } | 251 | } |
250 | divert(-1) | 252 | divert(-1) |
251 | undefine([<SELECTOR>])>]) | 253 | popdef([<__GETOPT_SELECTOR>])>]) |
252 | 254 | ||
253 | dnl OPTNODE(name, value) | 255 | dnl OPTNODE(name, value) |
254 | define([<OPTNODE>],[<do { | 256 | define([<OPTNODE>],[<do { |
@@ -275,10 +277,10 @@ define([<GETOPT>],[< | |||
275 | 277 | ||