summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-02-24 22:08:45 +0200
committerArnold D. Robbins <arnold@skeeve.com>2015-02-24 22:08:45 +0200
commitefefbfe40342975cc0ddbd69a9b0f2635d905d3c (patch)
treed90f5fc95e6702dadf4cfad6b6f8ec5d592331f3
parent764317bf85e5e63651486933b880a4627529d967 (diff)
downloadgawk-efefbfe40342975cc0ddbd69a9b0f2635d905d3c.tar.gz
Fix line continuation with CR-LF.
-rw-r--r--ChangeLog2
-rw-r--r--awkgram.c7
-rw-r--r--awkgram.y7
-rw-r--r--test/ChangeLog5
-rw-r--r--test/Makefile.am4
-rw-r--r--test/Makefile.in9
-rw-r--r--test/Maketests5
-rw-r--r--test/crlf.awk11
-rw-r--r--test/crlf.ok3
9 files changed, 49 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index ac0e13bf..610cc4fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
2015-02-24 Arnold D. Robbins <arnold@skeeve.com>
* POSIX.STD: Update copyright year.
+ * awkgram.y (yylex): Allow \r after \\ line continuation everywhere.
+ Thanks to Scott Rush <scott.rush@honeywell.com> for the report.
2015-02-13 Arnold D. Robbins <arnold@skeeve.com>
diff --git a/awkgram.c b/awkgram.c
index b3283eb2..5376d010 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -5400,7 +5400,10 @@ yylex(void)
pushback();
yyerror(_("unterminated regexp ends with `\\' at end of file"));
goto end_regexp; /* kludge */
- } else if (c == '\n') {
+ }
+ if (c == '\r') /* allow MS-DOS files. bleah */
+ c = nextc(true);
+ if (c == '\n') {
sourceline++;
continue;
} else {
@@ -5731,6 +5734,8 @@ retry:
if ((gawk_mb_cur_max == 1 || nextc_is_1stbyte) &&
c == '\\') {
c = nextc(true);
+ if (c == '\r') /* allow MS-DOS files. bleah */
+ c = nextc(true);
if (c == '\n') {
sourceline++;
continue;
diff --git a/awkgram.y b/awkgram.y
index 0df72b42..2307c362 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -3061,7 +3061,10 @@ yylex(void)
pushback();
yyerror(_("unterminated regexp ends with `\\' at end of file"));
goto end_regexp; /* kludge */
- } else if (c == '\n') {
+ }
+ if (c == '\r') /* allow MS-DOS files. bleah */
+ c = nextc(true);
+ if (c == '\n') {
sourceline++;
continue;
} else {
@@ -3392,6 +3395,8 @@ retry:
if ((gawk_mb_cur_max == 1 || nextc_is_1stbyte) &&
c == '\\') {
c = nextc(true);
+ if (c == '\r') /* allow MS-DOS files. bleah */
+ c = nextc(true);
if (c == '\n') {
sourceline++;
continue;
diff --git a/test/ChangeLog b/test/ChangeLog
index 0d6934e9..84e416b3 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-24 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (crlf): New test.
+ * crlf.awk, crlf.ok: New files.
+
2015-02-10 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (profile0): New test.
diff --git a/test/Makefile.am b/test/Makefile.am
index 419265f9..499c004a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -169,6 +169,8 @@ EXTRA_DIST = \
concat4.ok \
convfmt.awk \
convfmt.ok \
+ crlf.awk \
+ crlf.ok \
datanonl.awk \
datanonl.in \
datanonl.ok \
@@ -1030,7 +1032,7 @@ UNIX_TESTS = \
GAWK_EXT_TESTS = \
aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \
backw badargs beginfile1 beginfile2 binmode1 charasbytes \
- colonwarn clos1way dbugeval delsub devfd devfd1 devfd2 dumpvars exit \
+ colonwarn clos1way crlf dbugeval delsub devfd devfd1 devfd2 dumpvars exit \
fieldwdth fpat1 fpat2 fpat3 fpatnull fsfwfs funlen \
functab1 functab2 functab3 fwtest fwtest2 fwtest3 \
genpot gensub gensub2 getlndir gnuops2 gnuops3 gnureops \
diff --git a/test/Makefile.in b/test/Makefile.in
index 598285ed..cc1ab711 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -426,6 +426,8 @@ EXTRA_DIST = \
concat4.ok \
convfmt.awk \
convfmt.ok \
+ crlf.awk \
+ crlf.ok \
datanonl.awk \
datanonl.in \
datanonl.ok \
@@ -1286,7 +1288,7 @@ UNIX_TESTS = \
GAWK_EXT_TESTS = \
aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \
backw badargs beginfile1 beginfile2 binmode1 charasbytes \
- colonwarn clos1way dbugeval delsub devfd devfd1 devfd2 dumpvars exit \
+ colonwarn clos1way crlf dbugeval delsub devfd devfd1 devfd2 dumpvars exit \
fieldwdth fpat1 fpat2 fpat3 fpatnull fsfwfs funlen \
functab1 functab2 functab3 fwtest fwtest2 fwtest3 \
genpot gensub gensub2 getlndir gnuops2 gnuops3 gnureops \
@@ -3429,6 +3431,11 @@ backw:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+crlf:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
delsub:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index f3639b0f..adf95cc5 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -962,6 +962,11 @@ backw:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+crlf:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
delsub:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/crlf.awk b/test/crlf.awk
new file mode 100644
index 00000000..79be9eb6
--- /dev/null
+++ b/test/crlf.awk
@@ -0,0 +1,11 @@
+BEGIN {
+ print \
+ "hi there"
+ print "hello \
+world"
+ if ("foo" ~ /fo\
+o/)
+ print "matches"
+ else
+ print "does not match!"
+}
diff --git a/test/crlf.ok b/test/crlf.ok
new file mode 100644
index 00000000..0ba071b5
--- /dev/null
+++ b/test/crlf.ok
@@ -0,0 +1,3 @@
+hi there
+hello world
+matches