[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gawk] mixed LF/CRLF scripts: incorrect line numbers

From: Jannick
Subject: [bug-gawk] mixed LF/CRLF scripts: incorrect line numbers
Date: Mon, 7 May 2018 17:15:02 +0200

Hi All,

I have come across something weird from the EOL hell on my Windows
box using Cygwin's gawk in -D mode (debug). Gawk did not show the correct
numbers which caused confusion in break statements.

Drilling things down I found out this is because the script file is of mixed
EOL type
(LF and CRLF).  The culprit lines are those with LF only (at least on my
Windows machine using the cygwin's LF gawk version). 

In the syntax error report gawk tells us the line numbers of the processed
it thinks they are OK and supposedly uses throughout the program (syntax
debug etc.). So I used the attached file with a small example. 

The sample file is CRLF with one single CR line causing the issue. Running
it produces

gawk: ./gawk-line.awk:2:        line2 .= 2 # shown with correct line
gawk: ./gawk-line.awk:2:              ^ syntax error
gawk: ./line4 .= 4 # shown with line 3!= 3 # not shown, here the comment-tag
syntactically meant as EOL does not help
gawk: ./gawk-line.awk:3:              ^ syntax error
gawk: ./gawk-line.awk:4:        line5 .= 5 # shown with line 4!
gawk: ./gawk-line.awk:4:              ^ syntax error

The problem starts in line 3. Before that gawk and I agreed so far.
- line 3 is ignored, the CR causes the overlay in the syntax error
of the next line, the comment tag does not stop gawk from parsing
beyond the CR, I think
- line 4 gawk thinks it is line 3, but we think it is line 4
... and so on.

I included the syntax error report in the attached file.

I think this is a bug, albeit it lives in the CR/CRLF realm where the best
would not be to point to a private compilation of gawk on my Windows
to avoid cygwin's executable and CR confusion. 

Please give me a shout if I you need any more information or I should run
any tests
here on my machine.

Best - and sorry for being a bit lengthy in this posting,

Attachment: gawk-line.awk
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]