|
|
bacbc8 |
From b652c8a14c3cda433cd8d3ebe8290ee7907e4815 Mon Sep 17 00:00:00 2001
|
|
|
bacbc8 |
From: Phil Sutter <phil@nwl.cc>
|
|
|
bacbc8 |
Date: Mon, 18 Jun 2018 10:23:22 +0200
|
|
|
bacbc8 |
Subject: [PATCH] scanner: Do not convert tabs into spaces
|
|
|
bacbc8 |
|
|
|
bacbc8 |
Commit 2f86dd5a43baf ("erec: Review erec_print()") changed erec_print()
|
|
|
bacbc8 |
function to expect tabs in input by replacing the whitespace character
|
|
|
bacbc8 |
in the marker line at the same offset with a tab character so that the
|
|
|
bacbc8 |
marker aligns with the offending part of input.
|
|
|
bacbc8 |
|
|
|
bacbc8 |
The need for that came from JSON input not having its tabs converted to
|
|
|
bacbc8 |
spaces, which erec_print() didn't expect.
|
|
|
bacbc8 |
|
|
|
bacbc8 |
Above change though has a shortcoming: When reading standard syntax
|
|
|
bacbc8 |
input from a file, Flex code converts tabs into spaces. Location
|
|
|
bacbc8 |
information is taken from this converted input, but when printing an
|
|
|
bacbc8 |
error message, the offending input line is read from the input file
|
|
|
bacbc8 |
directly (which still contains tabs).
|
|
|
bacbc8 |
|
|
|
bacbc8 |
The solution is to simply drop said tab conversion from scanner.l.
|
|
|
bacbc8 |
|
|
|
bacbc8 |
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
|
|
bacbc8 |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
bacbc8 |
(cherry picked from commit 7f8d28105c8caeae7af5bccbe4a6d79f1f73e205)
|
|
|
bacbc8 |
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
|
bacbc8 |
---
|
|
|
bacbc8 |
src/scanner.l | 16 +---------------
|
|
|
bacbc8 |
1 file changed, 1 insertion(+), 15 deletions(-)
|
|
|
bacbc8 |
|
|
|
bacbc8 |
diff --git a/src/scanner.l b/src/scanner.l
|
|
|
bacbc8 |
index 416bd27af1427..3551fbf80df6e 100644
|
|
|
bacbc8 |
--- a/src/scanner.l
|
|
|
bacbc8 |
+++ b/src/scanner.l
|
|
|
bacbc8 |
@@ -613,21 +613,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
|
|
|
bacbc8 |
return NEWLINE;
|
|
|
bacbc8 |
}
|
|
|
bacbc8 |
|
|
|
bacbc8 |
-{tab} {
|
|
|
bacbc8 |
- /*
|
|
|
bacbc8 |
- * Compensate difference between visible length
|
|
|
bacbc8 |
- * and real length.
|
|
|
bacbc8 |
- */
|
|
|
bacbc8 |
- struct parser_state *state = yyget_extra(yyscanner);
|
|
|
bacbc8 |
- unsigned int diff;
|
|
|
bacbc8 |
-
|
|
|
bacbc8 |
- diff = TABSIZE - strlen("\t");
|
|
|
bacbc8 |
- diff -= (state->indesc->column -
|
|
|
bacbc8 |
- strlen("\t") - 1) % TABSIZE;
|
|
|
bacbc8 |
-
|
|
|
bacbc8 |
- update_pos(state, yylloc, diff);
|
|
|
bacbc8 |
- }
|
|
|
bacbc8 |
-
|
|
|
bacbc8 |
+{tab}+
|
|
|
bacbc8 |
{space}+
|
|
|
bacbc8 |
{comment}
|
|
|
bacbc8 |
|
|
|
bacbc8 |
--
|
|
|
bacbc8 |
2.21.0
|
|
|
bacbc8 |
|