squirrel icon indicating copy to clipboard operation
squirrel copied to clipboard

sq : input line too long, interactive console line = (1) column = (1) : error expression expected

Open ryandesign opened this issue 1 year ago • 1 comments

I've compiled and installed squirrel 3.2 on macOS. When I run sq I get a prompt:

% sq
Squirrel 3.2 stable Copyright (C) 2003-2022 Alberto Demichelis (64 bits)

sq>

Satisfied that the program was working, I wanted to exit. Many interactive programs let me exit by pressing Control-D but when I tried this at the sq> prompt I received a neverending stream of this message:

sq : input line too long
interactive console line = (1) column = (1) : error expression expected
sq>
sq : input line too long
interactive console line = (1) column = (1) : error expression expected
sq>
sq : input line too long
interactive console line = (1) column = (1) : error expression expected
sq>

The message comes from this code:

https://github.com/albertodemichelis/squirrel/blob/c02bf2dfd599a0b99b814d486512a3ee934667f1/sq/sq.c#L268-L271

ryandesign avatar Jul 31 '24 01:07 ryandesign

Not surprisingly, I see the same issue on Ubuntu 22.04.5.

The following patch seems to correct the problem:

diff --git sq/sq.c sq/sq.c
index ee5eabb..ae7a664 100644
--- sq/sq.c
+++ sq/sq.c
@@ -248,7 +248,12 @@ void Interactive(HSQUIRRELVM v)
             int c;
             if(done)return;
             c = getchar();
-            if (c == _SC('\n')) {
+            if (c == EOF) {
+                done = true;
+                scprintf(_SC("\n"));
+                break;
+            }
+            else if (c == _SC('\n')) {
                 if (i>0 && buffer[i-1] == _SC('\\'))
                 {
                     buffer[i-1] = _SC('\n');

Keith-S-Thompson avatar Dec 17 '24 02:12 Keith-S-Thompson