diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2021-08-03 07:33:33 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2021-08-08 08:08:04 +0200 |
commit | 4b802d64171203642c1c0b148ff8ace8fdaeb1f5 (patch) | |
tree | bafe6fa256f5b47babc7c9ce0b728995181c1f59 /examples | |
parent | 7f1e9249d05c779b821a2e8ec4d97f89782d09f5 (diff) | |
download | bison-4b802d64171203642c1c0b148ff8ace8fdaeb1f5.tar.gz |
bistromathic: beware of portability issues with readline
In some cases readline emits a trailing spaces after the last
suggestion, which results in errors such as:
```
-( - atan cos exp ln number sin sqrt$
+( - atan cos exp ln number sin sqrt $
```
Reported by Christopher Nielsen <mascguy@github.com>.
<https://trac.macports.org/ticket/59927#comment:48>
<https://trac.macports.org/attachment/ticket/59927/bison-3.7.6-test-10.13.test-suite.log>
* examples/test (run): Add support for -t.
* examples/c/bistromathic/bistromathic.test: Use it.
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/c/bistromathic/bistromathic.test | 11 | ||||
-rwxr-xr-x | examples/test | 19 |
2 files changed, 22 insertions, 8 deletions
diff --git a/examples/c/bistromathic/bistromathic.test b/examples/c/bistromathic/bistromathic.test index badccc0d..2db5dcfe 100755 --- a/examples/c/bistromathic/bistromathic.test +++ b/examples/c/bistromathic/bistromathic.test @@ -306,10 +306,17 @@ esac sed -e 's/\\t/ /g' >input <<EOF (1+\t\t EOF -run 0 '> (1+ +# Nuke the possible trailing white spaces in the effective output. +# This is to cope with some readlines that pad all the suggestions +# with white spaces (for alignment), including the last one on a line. +# +# See for instance <https://trac.macports.org/ticket/59927#comment:48> +# and its test-suite.log: +# <https://trac.macports.org/attachment/ticket/59927/bison-3.7.6-test-10.13.test-suite.log> +run -t 0 '> (1+ ( - atan cos exp ln number sin sqrt > (1+ -> '' +> err: 1.4: syntax error: expected - or ( or number or function or variable before end of file err: 1 | (1+ err: | ^' diff --git a/examples/test b/examples/test index f96e5b4d..a5370624 100755 --- a/examples/test +++ b/examples/test @@ -91,18 +91,21 @@ skip () } -# run [-noerr, -n] EXPECTED-EXIT-STATUS EXPECTED-OUTPUT [PARSER-OPTIONS] -# ---------------------------------------------------------------------- +# run [-n, -noerr, -t] EXPECTED-EXIT-STATUS EXPECTED-OUTPUT [PARSER-OPTIONS] +# -------------------------------------------------------------------------- +# -n: no final end-of-line in expected-output # -noerr: ignore stderr, otherwise merge it into effective output. -# -n: not final end-of-line in expected-output +# -t: nuke the possible trailing white spaces in the effective output. run () { - noerr=false echo=echo + noerr=false + rstrip=false while true; do case $1 in - (-noerr) noerr=true; shift;; (-n) echo=printf; shift;; + (-noerr) noerr=true; shift;; + (-t) rstrip=true; shift;; (*) break;; esac done @@ -129,7 +132,11 @@ run () # Combine effective output and error streams. { - cat out_eff + if $rstrip; then + sed -e 's/ *$//g' out_eff + else + cat out_eff + fi if ! $noerr; then sed -e 's/^/err: /g' \ -e 's/Reducing stack by rule .* (line .*):/Reducing stack by rule XX (line XXX):/g' \ |