From e1f4deb26fc81c33c64e338ba735197cefc610c6 Mon Sep 17 00:00:00 2001 From: Kris Katterjohn Date: Wed, 23 Nov 2022 14:11:28 -0500 Subject: [PATCH] Fix bug #3996: parse_string fails to parse string which contains semicolon ENSURE-TERMINATOR was not appending a terminator to the string to parse if it already contained a semicolon or dollar sign. This was problematic in cases such as this one: (%i1) parse_string ("\"semi ; string\""); Now we always append a terminator, since PARSE-STRING will only parse the first expression in a string. (%i1) parse_string ("\"semi ; string\""); (%o1) "semi ; string" No problems with the test suite or share test suite. --- ChangeLog | 1 + share/stringproc/eval_string.lisp | 11 ++++------- share/stringproc/rtest_stringproc.mac | 12 ++++++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e09dbd7f..82cc9c949 100644 --- a/ChangeLog +++ b/ChangeLog @@ -61,6 +61,7 @@ Bug fixes for numbered bugs: * \#3926: Various limits give UND where they should give IND * \#3972: gcl only: Autocompletion inverts command case * \#3985: integrate(sin(x*cos(x)), x), risch; causes unlimited recursion + * \#3996: parse_string fails to parse string which contains semicolon * \#3998: Lisp error when parser encounters eof in a comment * \#4008: translator and prederror * \#4018: defint(foo,,0,inf) lisp error when denom(foo) contains %i diff --git a/share/stringproc/eval_string.lisp b/share/stringproc/eval_string.lisp index 72e5bf4ca..884d44769 100644 --- a/share/stringproc/eval_string.lisp +++ b/share/stringproc/eval_string.lisp @@ -54,12 +54,9 @@ (let ((*mread-prompt* "")) (third (mread *parse-string-input-stream*)) )) -;; (ENSURE-TERMINATOR S) -- if the string S does not contain dollar sign `$' or semicolon `;' -;; then append a dollar sign to the end of S. +;; (ENSURE-TERMINATOR S) -- always concatenate a dollar sign `$' to the end of S. +;; Always concatenating a terminator is not a problem for PARSE-STRING since it only +;; parses the first expression in a string. (defun ensure-terminator (s) - (cond - ((or (search "$" s :test #'char-equal) (search ";" s :test #'char-equal)) - s) - (t - (concatenate 'string s "$")))) + (concatenate 'string s "$")) diff --git a/share/stringproc/rtest_stringproc.mac b/share/stringproc/rtest_stringproc.mac index 98d2e1af0..b918847c7 100644 --- a/share/stringproc/rtest_stringproc.mac +++ b/share/stringproc/rtest_stringproc.mac @@ -90,6 +90,18 @@ parse_string (".25b-1"); parse_string ("foo"); foo$ +parse_string ("foo;"); +foo$ + +parse_string ("foo$;$;"); +foo$ + +parse_string ("\"semicolon ; string\""); +"semicolon ; string"$ + +parse_string ("\"dollar $ string\""); +"dollar $ string"$ + parse_string ("[2]"); [2]; -- 2.11.4.GIT