]> git.pld-linux.org Git - packages/flex.git/blame - flex-m4-quotes.diff
- x32 rebuild
[packages/flex.git] / flex-m4-quotes.diff
CommitLineData
f2f8cfff 1diff -urN -X ./diff-exclude flex-2.5.31/flex.skl flex/flex.skl
648d211f 2--- flex-2.5.31/flex.skl 2003-04-01 04:51:38.000000000 +0300
f2f8cfff
JB
3+++ flex/flex.skl 2004-01-02 12:22:33.000000000 +0200
4@@ -27,6 +27,13 @@
648d211f
JB
5 %# Macros for runtime processing stage.
6 m4_changecom
7 m4_changequote
8+
f2f8cfff 9+%# Support for m4 quote escaping
648d211f
JB
10+m4_changequote({, })
11+m4_define( {m4_userquote_start}, {m4_changequote(<, >)[[m4_changequote([[, ]])})
12+m4_define( {m4_userquote_end}, {m4_changequote(<, >)]]m4_changequote([[, ]])})
f2f8cfff
JB
13+
14+%# Setup quoting
648d211f
JB
15 m4_changequote([[, ]])
16
17 %#
f2f8cfff
JB
18diff -urN -X ./diff-exclude flex-2.5.31/flexdef.h flex/flexdef.h
19--- flex-2.5.31/flexdef.h 2003-04-01 04:51:38.000000000 +0300
20+++ flex/flexdef.h 2004-01-02 12:14:49.000000000 +0200
21@@ -373,6 +373,7 @@
22 * yymore_really_used - whether to treat yymore() as really used, regardless
23 * of what we think based on references to it in the user's actions.
24 * reject_really_used - same for REJECT
25+ * keep_m4 - dont quote m4 quotes "[[", "]]" - so user can use m4
26 */
27
28 extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn,
29@@ -387,7 +388,7 @@
30 extern int yymore_used, reject, real_reject, continued_action, in_rule;
31
32 extern int yymore_really_used, reject_really_used;
33-
34+extern int keep_m4;
35
36 /* Variables used in the flex input routines:
37 * datapos - characters on current output line
38diff -urN -X ./diff-exclude flex-2.5.31/main.c flex/main.c
39--- flex-2.5.31/main.c 2003-04-01 04:51:38.000000000 +0300
40+++ flex/main.c 2004-01-02 12:13:07.000000000 +0200
41@@ -106,6 +106,7 @@
42 bool *rule_has_nl, *ccl_has_nl;
43 int nlch = '\n';
44 bool ansi_func_defs, ansi_func_protos;
45+int keep_m4;
46
47 bool tablesext, tablesverify, gentables;
48 char *tablesfilename=0,*tablesname=0;
49@@ -999,6 +1000,10 @@
50 case OPT_DONOTHING:
51 break;
52
53+ case OPT_KEEP_M4:
54+ keep_m4 = true;
55+ break;
56+
57 case OPT_COMPRESSION:
58 if (!sawcmpflag) {
59 useecs = false;
60diff -urN -X ./diff-exclude flex-2.5.31/options.c flex/options.c
61--- flex-2.5.31/options.c 2003-03-25 18:39:08.000000000 +0200
62+++ flex/options.c 2004-01-02 12:16:07.000000000 +0200
63@@ -42,6 +42,10 @@
64 /* The command-line options, passed to scanopt_init() */
65 optspec_t flexopts[] = {
66
67+ {"-4", OPT_KEEP_M4, 0}
68+ ,
69+ {"--keep-m4", OPT_KEEP_M4, 0}
70+ , /* dont try to quote m4 */
71 {"-7", OPT_7BIT, 0}
72 ,
73 {"--7bit", OPT_7BIT, 0}
74diff -urN -X ./diff-exclude flex-2.5.31/options.h flex/options.h
75--- flex-2.5.31/options.h 2003-03-25 18:39:08.000000000 +0200
76+++ flex/options.h 2004-01-02 12:15:30.000000000 +0200
77@@ -61,6 +61,7 @@
78 OPT_HEADER_FILE,
79 OPT_HELP,
80 OPT_INTERACTIVE,
81+ OPT_KEEP_M4,
82 OPT_LEX_COMPAT,
83 OPT_POSIX_COMPAT,
84 OPT_MAIN,
85diff -urN -X ./diff-exclude flex-2.5.31/scan.l flex/scan.l
648d211f 86--- flex-2.5.31/scan.l 2003-04-01 04:51:38.000000000 +0300
f2f8cfff
JB
87+++ flex/scan.l 2004-01-02 12:00:21.000000000 +0200
88@@ -88,6 +88,29 @@
89 if ( getenv("POSIXLY_CORRECT") ) \
90 posix_compat = true;
91
92+/* Macros need to be clearly separated from surrounding text
93+ and this file needs to go through (unpatched) flex untouched. */
94+static char *userquote_start = "[" "[]" "]m4_" "userquote_start()";
95+static char *userquote_end = "[" "[]" "]m4_" "userquote_end()";
96+
97+#define QUOTE4_START \
98+ do { \
99+ if (keep_m4) { \
100+ ACTION_ECHO; \
101+ } else { \
102+ add_action(userquote_start); \
103+ } \
104+ } while (0)
105+
106+#define QUOTE4_END \
107+ do { \
108+ if (keep_m4) { \
109+ ACTION_ECHO; \
110+ } else { \
111+ add_action(userquote_end); \
112+ } \
113+ } while (0)
114+
115 %}
116
117 %option caseless nodefault stack noyy_top_state
118@@ -95,7 +118,7 @@
119
120 %x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
121 %x FIRSTCCL CCL ACTION RECOVER COMMENT ACTION_STRING PERCENT_BRACE_ACTION
122-%x OPTION LINEDIR CODEBLOCK_MATCH_BRACE
123+%x OPTION LINEDIR CODEBLOCK_MATCH_BRACE PROLOGLINE
124
125 WS [[:blank:]]+
126 OPTWS [[:blank:]]*
127@@ -194,8 +217,11 @@
648d211f
JB
128 <COMMENT>{
129 "*/" ACTION_ECHO; yy_pop_state();
130 "*" ACTION_ECHO;
131- [^*\n]+ ACTION_ECHO;
132- [^*\n]*{NL} ++linenum; ACTION_ECHO;
133+ [\[\]] ACTION_ECHO;
134+ [^*\[\]\n]+ ACTION_ECHO;
135+ [^*\[\]\n]*{NL} ++linenum; ACTION_ECHO;
f2f8cfff
JB
136+ \[\[ QUOTE4_START;
137+ \]\] QUOTE4_END;
648d211f
JB
138 }
139
140 <LINEDIR>{
f2f8cfff
JB
141@@ -213,7 +239,11 @@
142 <CODEBLOCK>{
143 ^"%}".*{NL} ++linenum; BEGIN(INITIAL);
144
145- {NAME}|{NOT_NAME}|. ACTION_ECHO;
146+ \[\[ QUOTE4_START;
147+ \]\] QUOTE4_END;
148+
149+ [^\n\]\[]+ ACTION_ECHO;
150+ [\]\[] ACTION_ECHO;
151
152 {NL} {
153 ++linenum;
154@@ -242,10 +272,25 @@
155 buf_strnappend(&top_buf, yytext, yyleng);
156 }
157
158- [^{}\r\n]+ {
159+ [^{}\[\]\r\n]+ {
160 buf_strnappend(&top_buf, yytext, yyleng);
161 }
162
163+ [\]\[] buf_strnappend(&top_buf, yytext, yyleng);
164+
165+ \[\[ {
166+ if (keep_m4)
167+ buf_strnappend(&top_buf, yytext, yyleng);
168+ else
169+ buf_strappend(&top_buf, userquote_start);
170+ }
171+ \]\] {
172+ if (keep_m4)
173+ buf_strnappend(&top_buf, yytext, yyleng);
174+ else
175+ buf_strappend(&top_buf, userquote_end);
176+ }
177+
178 <<EOF>> {
179 linenum = brace_start_line;
180 synerr(_("Unmatched '{'"));
181@@ -424,33 +469,48 @@
182
183
184 <SECT2PROLOG>{
185- ^"%{".* ++bracelevel; yyless( 2 ); /* eat only %{ */
186- ^"%}".* --bracelevel; yyless( 2 ); /* eat only %} */
187-
188- ^{WS}.* ACTION_ECHO; /* indented code in prolog */
189+ ^"%{".* ++bracelevel; yyless( 2 ); /* eat only %{ */
190+ ^"%}".* --bracelevel; yyless( 2 ); /* eat only %} */
191
192+ ^{WS}.* { /* indented code in prolog */
193+ yyless(0);
194+ BEGIN(PROLOGLINE);
195+ }
196 ^{NOT_WS}.* { /* non-indented code */
197+ yyless( 0 ); /* put it all back */
198 if ( bracelevel <= 0 )
199 { /* not in %{ ... %} */
200- yyless( 0 ); /* put it all back */
201 yy_set_bol( 1 );
202 mark_prolog();
203 BEGIN(SECT2);
204 }
205 else
206- ACTION_ECHO;
207+ BEGIN(PROLOGLINE);
208 }
209
210- .* ACTION_ECHO;
211- {NL} ++linenum; ACTION_ECHO;
212+ .* yyless(0); BEGIN(PROLOGLINE);
213
214- <<EOF>> {
215- mark_prolog();
216- sectnum = 0;
217- yyterminate(); /* to stop the parser */
218+ {NL} ++linenum; ACTION_ECHO;
219+}
220+
221+<PROLOGLINE>{
222+ [^\]\[\n\r]* ACTION_ECHO;
223+ \[\[ QUOTE4_START;
224+ \]\] QUOTE4_END;
225+ [\]\[] ACTION_ECHO;
226+ {NL} {
227+ ++linenum;
228+ ACTION_ECHO;
229+ BEGIN(SECT2PROLOG);
230 }
231 }
232
233+<PROLOGLINE,SECT2PROLOG><<EOF>> {
234+ mark_prolog();
235+ sectnum = 0;
236+ yyterminate();
237+ }
238+
239 <SECT2>{
240 ^{OPTWS}{NL} ++linenum; /* allow blank lines in section 2 */
241
242@@ -768,10 +828,15 @@
243 <ACTION>{
244 "{" ACTION_ECHO; ++bracelevel;
245 "}" ACTION_ECHO; --bracelevel;
246- [^[:alpha:]_{}"'/\n]+ ACTION_ECHO;
247+ [^[:alpha:]_{}\[\]"'/\n]+ ACTION_ECHO;
248 {NAME} ACTION_ECHO;
249 "'"([^'\\\n]|\\.)*"'" ACTION_ECHO; /* character constant */
250 \" ACTION_ECHO; BEGIN(ACTION_STRING);
251+
252+ \[\[ QUOTE4_START;
253+ \]\] QUOTE4_END;
254+ [\]\[] ACTION_ECHO;
255+
256 {NL} {
257 ++linenum;
258 ACTION_ECHO;
259@@ -788,7 +853,10 @@
260 }
261
262 <ACTION_STRING>{
263- [^"\\\n]+ ACTION_ECHO;
264+ [^"\]\[\\\n]+ ACTION_ECHO;
265+ \[\[ QUOTE4_START;
266+ \]\] QUOTE4_END;
267+ [\]\[] ACTION_ECHO;
268 \\. ACTION_ECHO;
269 {NL} ++linenum; ACTION_ECHO; BEGIN(ACTION);
270 \" ACTION_ECHO; BEGIN(ACTION);
271@@ -812,7 +880,21 @@
272
273
274 <SECT3>{
275- .*(\n?) ECHO;
276+ [^\]\[\n\r]*({NL})? ECHO;
277+
278+ \[\[ if (keep_m4) {
279+ ECHO;
280+ } else {
281+ fputs(userquote_start, yyout);
282+ }
283+ \]\] if (keep_m4) {
284+ ECHO;
285+ } else {
286+ fputs(userquote_end, yyout);
287+ }
288+
289+ [\]\[] ECHO;
290+
291 <<EOF>> sectnum = 0; yyterminate();
292 }
293
294diff -urN -X ./diff-exclude flex-2.5.31/tests/Makefile.am flex/tests/Makefile.am
295--- flex-2.5.31/tests/Makefile.am 2003-03-27 20:02:59.000000000 +0200
296+++ flex/tests/Makefile.am 2004-01-02 11:48:17.000000000 +0200
297@@ -40,6 +40,7 @@
298 test-c++-basic \
299 test-posixly-correct \
300 test-posix \
301+ test-m4-quotes \
302 test-mem-r \
303 test-mem-nr \
304 test-debug-nr \
305@@ -81,6 +82,7 @@
306 test-c++-basic \
307 test-posixly-correct \
308 test-posix \
309+ test-m4-quotes \
310 test-mem-r \
311 test-mem-nr \
312 test-debug-nr \
313diff -urN -X ./diff-exclude flex-2.5.31/tests/test-m4-quotes/Makefile.am flex/tests/test-m4-quotes/Makefile.am
314--- flex-2.5.31/tests/test-m4-quotes/Makefile.am 1970-01-01 03:00:00.000000000 +0300
315+++ flex/tests/test-m4-quotes/Makefile.am 2004-01-02 11:49:06.000000000 +0200
316@@ -0,0 +1,44 @@
317+# This file is part of flex.
318+
319+# Redistribution and use in source and binary forms, with or without
320+# modification, are permitted provided that the following conditions
321+# are met:
322+
323+# 1. Redistributions of source code must retain the above copyright
324+# notice, this list of conditions and the following disclaimer.
325+# 2. Redistributions in binary form must reproduce the above copyright
326+# notice, this list of conditions and the following disclaimer in the
327+# documentation and/or other materials provided with the distribution.
328+
329+# Neither the name of the University nor the names of its contributors
330+# may be used to endorse or promote products derived from this software
331+# without specific prior written permission.
332+
333+# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
334+# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
335+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
336+# PURPOSE.
337+
338+FLEX = $(top_builddir)/flex
339+
340+builddir = @builddir@
341+
342+EXTRA_DIST = scanner.l test.input
343+CLEANFILES = scanner.c scanner.h TEMPLATE OUTPUT $(OBJS)
344+OBJS = scanner.o
345+
346+AM_CPPFLAGS = -I$(srcdir) -I$(builddir) -I$(top_srcdir) -I$(top_builddir)
347+
348+testname = TEMPLATE
349+
350+scanner.c: $(srcdir)/scanner.l
351+ $(FLEX) $(LFLAGS) $<
352+
353+$(testname)$(EXEEXT): $(OBJS)
354+ $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LOADLIBES)
355+
356+test: $(testname)$(EXEEXT)
357+ ./$(testname)$(EXEEXT) < $(srcdir)/test.input
358+
359+.c.o:
360+ $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) $(CFLAGS) $<
361diff -urN -X ./diff-exclude flex-2.5.31/tests/test-m4-quotes/scanner.l flex/tests/test-m4-quotes/scanner.l
362--- flex-2.5.31/tests/test-m4-quotes/scanner.l 1970-01-01 03:00:00.000000000 +0300
363+++ flex/tests/test-m4-quotes/scanner.l 2004-01-02 11:49:33.000000000 +0200
364@@ -0,0 +1,93 @@
365+/*
366+ * This file is part of flex.
367+ *
368+ * Redistribution and use in source and binary forms, with or without
369+ * modification, are permitted provided that the following conditions
370+ * are met:
371+ *
372+ * 1. Redistributions of source code must retain the above copyright
373+ * notice, this list of conditions and the following disclaimer.
374+ * 2. Redistributions in binary form must reproduce the above copyright
375+ * notice, this list of conditions and the following disclaimer in the
376+ * documentation and/or other materials provided with the distribution.
377+ *
378+ * Neither the name of the University nor the names of its contributors
379+ * may be used to endorse or promote products derived from this software
380+ * without specific prior written permission.
381+ *
382+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
383+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
384+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
385+ * PURPOSE.
386+ */
387+
388+/* [[ grep qtest scanner.c ]] */
389+
390+%{
391+
392+#include <stdio.h>
393+#include <stdlib.h>
394+#include "config.h"
395+
396+/* qtest: ]] */
397+
398+static int a[10];
399+static int b[10];
400+static char *p = "]]"; /* qtest */
401+
402+#define fx1(x) a[b[0]] /* qtest */
403+
404+static void xerror(char *msg);
405+
406+%}
407+
408+%option 8bit outfile="scanner.c" prefix="test"
409+%option nounput nomain noyywrap
410+%option warn
411+
412+/* qtest: ]] [[ ]] */
413+
414+%%
415+
416+%{
417+ /* qtest [[ ]] */
418+ if (a[a[0]]) ; /* qtest */
419+ p = "[["; /* qtest */
420+%}
421+ if (a[a[0]]) ; /* qtest */
422+ p = "[["; /* qtest */
423+
424+[^a-e]* { }
425+a if (a[a[0]]) ; /* qtest */
426+b {
427+ if (a[a[0]]) ; /* qtest */
428+ p = "[["; /* qtest */
429+ }
430+c /* qtest: ]] [[ ]] */
431+ /* qtest: ]] [[ ]] */
432+d if (strlen(p) != 2) xerror("qtest [[ ]]\n");
433+e if (strcmp(p, "[[")) xerror("qtest\n");
434+
435+
436+%%
437+
438+/* qtest: ]] [[ ]] */
439+
440+int main(void);
441+
442+static void xerror(char *msg)
443+{
444+ fprintf(stderr, "error: %s\n", msg);
445+ exit(1);
446+}
447+
448+int
449+main ()
450+{
451+ yyin = stdin;
452+ yyout = stdout;
453+ yylex();
454+ if (a[a[0]]) ; /* qtest */
455+ printf("TEST RETURNING OK.\n");
456+ return 0;
457+}
458diff -urN -X ./diff-exclude flex-2.5.31/tests/test-m4-quotes/test.input flex/tests/test-m4-quotes/test.input
459--- flex-2.5.31/tests/test-m4-quotes/test.input 1970-01-01 03:00:00.000000000 +0300
460+++ flex/tests/test-m4-quotes/test.input 2004-01-02 11:49:49.000000000 +0200
461@@ -0,0 +1,7 @@
462+a
463+b
464+c
465+d
466+e
467+f
468+g
469diff -urN -X ./diff-exclude flex-2.5.31/tests/test-reject/Makefile.am flex/tests/test-reject/Makefile.am
470--- flex-2.5.31/tests/test-reject/Makefile.am 2002-10-11 18:26:43.000000000 +0300
471+++ flex/tests/test-reject/Makefile.am 2003-12-28 04:56:02.000000000 +0200
472@@ -20,7 +20,7 @@
473 # PURPOSE.
474
475
476-FLEX = $(top_builddir)/flex
477+FLEX = $(top_builddir)/flex -4
478
479 EXTRA_DIST = scanner.l test.input
480 CLEANFILES = scanner.c test-reject-* OUTPUT $(OBJS)
481diff -urN -X ./diff-exclude flex-2.5.31/tests/test-table-opts/Makefile.am flex/tests/test-table-opts/Makefile.am
482--- flex-2.5.31/tests/test-table-opts/Makefile.am 2002-10-11 18:26:43.000000000 +0300
483+++ flex/tests/test-table-opts/Makefile.am 2003-12-28 04:54:00.000000000 +0200
484@@ -29,7 +29,7 @@
485 # ------------------------------------------------
486
487
488-FLEX = $(top_builddir)/flex
489+FLEX = $(top_builddir)/flex -4
490
491 testname := test-table-opts
492 allopts := -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem
a90575d0
JB
493--- flex-2.5.31/configure.in.orig 2004-07-19 21:19:47.640163000 +0000
494+++ flex-2.5.31/configure.in 2004-07-19 21:37:45.584485799 +0000
495@@ -101,6 +101,7 @@
496 tests/test-include-by-buffer/Makefile
497 tests/test-include-by-push/Makefile
498 tests/test-include-by-reentrant/Makefile
499+tests/test-m4-quotes/Makefile
500 tests/test-multiple-scanners-nr/Makefile
501 tests/test-multiple-scanners-r/Makefile
502 tests/test-noansi-nr/Makefile
This page took 0.208844 seconds and 4 git commands to generate.