summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2019-02-10 15:06:46 +0100
committerAkim Demaille <akim.demaille@gmail.com>2019-02-10 16:41:50 +0100
commit30f61b0549536b37bcd6495f01774a912643e343 (patch)
tree74ad01ca1d1a53052ac82b0fa4e717f3a0df1456 /examples
parentad7d8af6d1f8d755f6a885cb10692ac85a045c99 (diff)
downloadbison-30f61b0549536b37bcd6495f01774a912643e343.tar.gz
examples: fix annoying off-by-one errors
* examples/extexi: Since we issue #lines only at the beginning of @example, leave empty line when removing content (such as @comment lines), otherwise the lines that follow have incorrect source line location. This leaves ugly empty lines, but they are removed when you tidy the output for the end user: sequences of \n are mapped to at most two sucessive \n.
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/extexi6
-rw-r--r--examples/local.mk8
2 files changed, 7 insertions, 7 deletions
diff --git a/examples/extexi b/examples/extexi
index d50b477b..3b7d907d 100755
--- a/examples/extexi
+++ b/examples/extexi
@@ -60,7 +60,11 @@ sub normalize($)
{
local ($_) = @_;
- s/^\@(c |comment|dots|end (ignore|group)|ignore|group).*\n//mg;
+ # If we just remove this lines, then the compiler's tracking of
+ # #lines is broken. Leave lines that that accepted by all our tools
+ # (including flex, hence the leading space), and that will be easy
+ # to remove (see the Make examples-unline recipe).
+ s{^\@(c |comment|dots|end (ignore|group)|ignore|group).*}{ /**/}mg;
s/\@value\{VERSION\}/$ENV{VERSION}/g;
s/^\@(error|result)\{\}//mg;
s/\@([{}@])/$1/g;
diff --git a/examples/local.mk b/examples/local.mk
index a35c082f..1cd60457 100644
--- a/examples/local.mk
+++ b/examples/local.mk
@@ -59,12 +59,8 @@ EXTRA_DIST += %D%/extracted.stamp
dist-hook: examples-unline
.PHONY: examples-unline
examples-unline:
- for e in $(extracted); \
- do \
- e=$(distdir)/$$e; \
- sed -e '/#line/d' $$e >$$e.tmp; \
- mv -f $$e.tmp $$e; \
- done
+ cd $(distdir) && \
+ perl -pi -0777 -e 's/#line.*\n//g;s{^ /\*\*/\n}{}mg' $(extracted)
## ---------- ##