aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2015-12-16 12:22:52 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2015-12-16 12:27:02 +0200
commit74d73e0936d8ff28167e1f5045e3661ab9384a38 (patch)
tree8fbd707298c690fdaade7ff9cd6b7acfc84434cf
parent27ac5a32a7ca4cddacce307c586830fbb877b4ce (diff)
parent9e978b089268e6bfc4b8fcdf9ef721f6fa92c11f (diff)
downloadgrecs-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.m4110
-rw-r--r--src/format.c14
-rw-r--r--src/grecs-lex.l6
-rw-r--r--src/grecs.hin1
-rw-r--r--src/preproc.c3
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
@@ -85,93 +85,94 @@ dnl ---------------------------------------
85dnl Set options given as arguments. 85dnl Set options given as arguments.
86define([<_getopt_set_options>], 86define([<_getopt_set_options>],
87 [<ifelse([<$1>],,, 87 [<ifelse([<$1>],,,
88 [<_getopt_set_option([<$1>]) 88 [<_getopt_set_option([<$1>])
89 _getopt_set_options(shift($@))>])>]) 89 _getopt_set_options(shift($@))>])>])
90 90
91dnl format_authors(name[,name...]) 91dnl __getopt_format_authors(name[,name...])
92dnl ------------------------------ 92dnl ------------------------------
93define([<format_authors>],dnl 93define([<__getopt_format_authors>],dnl
94 [<ifelse([<$1>],,NULL,[<"$1", 94 [<ifelse([<$1>],,NULL,[<"$1",
95format_authors(shift($@))>])>]) 95__getopt_format_authors(shift($@))>])>])
96 96
97dnl upcase(ARGS...) 97dnl __getopt_upcase(ARGS...)
98dnl Concatenate and convert ARGS to upper case. 98dnl Concatenate and convert ARGS to upper case.
99dnl 99dnl
100define([<upcase>], [<translit([<$*>], [<a-z>], [<A-Z>])>]) 100define([<__getopt_upcase>], [<translit([<$*>], [<a-z>], [<A-Z>])>])
101 101
102dnl concat(ARGS...) 102dnl __getopt_concat(ARGS...)
103dnl Concatenate arguments, inserting ", " between each pair of them. 103dnl Concatenate arguments, inserting ", " between each pair of them.
104dnl 104dnl
105define([<concat>],[<ifelse([<$#>],1,[<$1>],[<$1, concat(shift($@))>])>]) 105define([<__getopt_concat>],[<ifelse([<$#>],1,[<$1>],[<$1, __getopt_concat(shift($@))>])>])
106 106
107dnl flushleft(ARGS...) 107dnl __getopt_flushleft(ARGS...)
108dnl Concatenate ARGS and remove any leading whitespace 108dnl Concatenate ARGS and remove any leading whitespace
109dnl 109dnl
110define([<flushleft>], 110define([<__getopt_flushleft>],
111 [<patsubst([<concat($*)>], [<^[ ]+>])>]) 111 [<patsubst([<__getopt_concat($*)>], [<^[ ]+>])>])
112 112
113dnl chop(ARGS...) 113dnl __getopt_chop(ARGS...)
114dnl Concatenate ARGS and remove any trailing whitespace 114dnl Concatenate ARGS and remove any trailing whitespace
115dnl 115dnl
116define([<chop>], 116define([<__getopt_chop>],
117 [<patsubst([<$*>], [<[ ]+$>])>]) 117 [<patsubst([<$*>], [<[ ]+$>])>])
118 118
119dnl escape(ARGS...) 119dnl __getopt_escape(ARGS...)
120dnl Concatenate ARGS and escape any occurrences of double-quotes with 120dnl Concatenate ARGS and escape any occurrences of double-quotes with
121dnl backslashes. 121dnl backslashes.
122dnl 122dnl
123define([<escape>], 123define([<__getopt_escape>],
124[<patsubst([<concat($*)>],[<[\"]>],[<\\\&>])>]) 124[<patsubst([<__getopt_concat($*)>],[<[\"]>],[<\\\&>])>])
125 125
126dnl prep(ARG) 126dnl __getopt_prep(ARG)
127dnl Prepare ARG for including in C strings: replace newlines and any 127dnl Prepare ARG for including in C strings: replace newlines and any
128dnl preceding and following whitespace by a single space character, remove 128dnl preceding and following whitespace by a single space character, remove
129dnl leading whitespace, and escape double-quotes. 129dnl leading whitespace, and escape double-quotes.
130dnl 130dnl
131define([<prep>], 131define([<__getopt_prep>],
132 [<escape(flushleft(patsubst([<$1>],[<[ ]* 132 [<__getopt_escape(__getopt_flushleft(patsubst([<$1>],[<[ ]*
133+[ ]*>],[< >])))>]) 133+[ ]*>],[< >])))>])
134 134
135dnl SHORT_OPTS 135dnl __GETOPT_SHORT_OPTS
136dnl Accumulator for the 3rd argument of getopt_long 136dnl Accumulator for the 3rd argument of getopt_long
137dnl 137dnl
138define([<SHORT_OPTS>],[<_getopt_if_option_set([<nopermute>],+)>]) 138define([<__GETOPT_SHORT_OPTS>],[<_getopt_if_option_set([<nopermute>],+)>])
139 139
140dnl GROUP(STRING) 140dnl GROUP(STRING)
141dnl Begin a named group of options 141dnl Begin a named group of options
142dnl 142dnl
143define([<GROUP>],[<dnl 143define([<GROUP>],[<dnl
144divert(3) 144divert(3)
145 { NULL, NULL, 0, N_("prep([<$1>])") }, 145 { NULL, NULL, 0, N_("__getopt_prep([<$1>])") },
146divert(-1)>]) 146divert(-1)>])
147 147
148# quote(args) - convert args to single-quoted string 148# __getopt_quote(args) - convert args to single-quoted string
149define([<quote>], [<ifelse([<$#>], [<0>], [<>], [<[<$*>]>])>]) 149define([<__getopt_quote>], [<ifelse([<$#>], [<0>], [<>], [<[<$*>]>])>])
150define([<dquote>], [<[<$@>]>]) 150define([<__getopt_dquote>], [<[<$@>]>])
151 151
152define([<__GATHER_OPTIONS>],[< 152define([<__GATHER_OPTIONS>],[<
153define([<KEY>],ifelse([<$2>],,[<OPTION_>]upcase(patsubst($1,-,_)),'$2')) 153pushdef([<__GETOPT_KEY>],ifelse([<$2>],,[<OPTION_>]__getopt_upcase(patsubst($1,-,_)),'$2'))
154ifelse([<$2>],,[< 154ifelse([<$2>],,[<
155divert(1) 155divert(1)
156 KEY, 156 __GETOPT_KEY,
157divert(-1) 157divert(-1)
158>]) 158>])
159define([<SELECTOR>],ifdef([<SELECTOR>],SELECTOR) case KEY:) 159define([<__GETOPT_SELECTOR>],ifdef([<__GETOPT_SELECTOR>],__GETOPT_SELECTOR) case __GETOPT_KEY:)
160ifelse([<$1>],,,[< 160ifelse([<$1>],,,[<
161divert(2) 161divert(2)
162 { "$1", ARGTYPE, 0, KEY }, 162 { "$1", __GETOPT_ARGTYPE, 0, __GETOPT_KEY },
163divert(-1)>]) 163divert(-1)>])
164dnl 164dnl
165define([<SHORT_OPTS>],dquote(SHORT_OPTS[<>]dnl 165define([<__GETOPT_SHORT_OPTS>],__getopt_dquote(__GETOPT_SHORT_OPTS[<>]dnl
166ifelse([<$2>],,,[<$2>]ifelse(ARGTYPE,[<no_argument>],,ARGTYPE,[<required_argument>],:,ARGTYPE,[<optional_argument>],::)))) 166ifelse([<$2>],,,[<$2>]ifelse(__GETOPT_ARGTYPE,[<no_argument>],,__GETOPT_ARGTYPE,[<required_argument>],:,__GETOPT_ARGTYPE,[<optional_argument>],::))))
167dnl 167dnl
168ifelse([<$1>],,,dnl 168ifelse([<$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>]))>])
170ifelse([<$2>],,,dnl 170ifelse([<$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>]))>])
172popdef([<__GETOPT_KEY>])
172>]) 173>])
173 174
174dnl OPTION(long-opt, short-opt, [arg], [descr]) 175dnl OPTION(long-opt, short-opt, [arg], [descr])
175dnl Introduce a command line option. Arguments: 176dnl Introduce a command line option. Arguments:
176dnl long-opt Long option. 177dnl long-opt Long option.
177dnl short-opt Short option (a single char) 178dnl short-opt Short option (a single char)
@@ -186,18 +187,19 @@ dnl enclosed in square brackets, the option takes an optional argument.
186dnl Otherwise, the argument is required. 187dnl Otherwise, the argument is required.
187dnl 188dnl
188dnl If descr is not given the option will not appear in the --help and 189dnl If descr is not given the option will not appear in the --help and
189dnl --usage outputs. 190dnl --usage outputs.
190dnl 191dnl
191define([<OPTION>],[< 192define([<OPTION>],[<
192pushdef([<LONG_TAG>]) 193pushdef([<__GETOPT_LONG_TAG>])
193pushdef([<SHORT_TAG>]) 194pushdef([<__GETOPT_SHORT_TAG>])
194pushdef([<ARGNAME>],[<$3>]) 195pushdef([<__GETOPT_SELECTOR>])
195pushdef([<HIDDEN>],ifelse([<$4>],,1,0)) 196pushdef([<__GETOPT_ARGNAME>],[<$3>])
196pushdef([<DOCSTRING>],[<prep([<$4>])>]) 197pushdef([<__GETOPT_HIDDEN>],ifelse([<$4>],,1,0))
197pushdef([<ARGTYPE>],[<ifelse([<$3>],,[<no_argument>],dnl 198pushdef([<__GETOPT_DOCSTRING>],[<__getopt_prep([<$4>])>])
199pushdef([<__GETOPT_ARGTYPE>],[<ifelse([<$3>],,[<no_argument>],dnl
198patsubst([<$3>],[<\[.*\]>]),,[<optional_argument>],dnl 200patsubst([<$3>],[<\[.*\]>]),,[<optional_argument>],dnl
199[<required_argument>])>]) 201[<required_argument>])>])
200__GATHER_OPTIONS($@) 202__GATHER_OPTIONS($@)
201>]) 203>])
202 204
203dnl ALIAS(long-opt, short-opt) 205dnl ALIAS(long-opt, short-opt)
@@ -213,45 +215,45 @@ __GATHER_OPTIONS($1,$2)
213 215
214dnl BEGIN 216dnl BEGIN
215dnl Start an action associated with the declared option. Must follow OPTION 217dnl Start an action associated with the declared option. Must follow OPTION
216dnl statement, with optional ALIAS statements in between. 218dnl statement, with optional ALIAS statements in between.
217dnl 219dnl
218define([<BEGIN>],[< 220define([<BEGIN>],[<
219ifelse(HIDDEN,1,,[< 221ifelse(__GETOPT_HIDDEN,1,,[<
220divert(3) 222divert(3)
221 { 223 {
222#ifdef HAVE_GETOPT_LONG 224#ifdef HAVE_GETOPT_LONG
223 "translit(dnl 225 "translit(dnl
224ifelse(SHORT_TAG,,LONG_TAG,[<SHORT_TAG[<>]ifelse(LONG_TAG,,,; LONG_TAG)>]), 226ifelse(__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") },
232divert(-1)>]) 234divert(-1)>])
233popdef([<ARGTYPE>]) 235popdef([<__GETOPT_ARGTYPE>])
234popdef([<ARGNAME>]) 236popdef([<__GETOPT_ARGNAME>])
235popdef([<DOCSTRING>]) 237popdef([<__GETOPT_DOCSTRING>])
236popdef([<HIDDEN>])