diff --git a/src/gapstate.h b/src/gapstate.h index 240f041736..16db84bf39 100644 --- a/src/gapstate.h +++ b/src/gapstate.h @@ -63,7 +63,6 @@ typedef struct GAPState { /* From scanner.c */ Obj ValueObj; Char Value[MAX_VALUE_LEN]; - UInt ValueLen; UInt NrError; UInt NrErrLine; UInt Symbol; diff --git a/src/read.c b/src/read.c index f1d2b23616..45afb5c9eb 100644 --- a/src/read.c +++ b/src/read.c @@ -2569,10 +2569,8 @@ void ReadTryNext ( void ReadHelp(TypSymbolSet follow) { - Obj topic; - - C_NEW_STRING(topic, STATE(ValueLen), (void *)STATE(Value)); - TRY_READ { IntrHelp(topic); }; + TRY_READ { IntrHelp(STATE(ValueObj)); } + STATE(ValueObj) = 0; } /**************************************************************************** diff --git a/src/scanner.c b/src/scanner.c index 9dbc4ea143..669ed6ae65 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -887,20 +887,30 @@ static void GetChar(void) static void GetHelp(void) { - Int i = 0; + Obj string = 0; + Char buf[1024]; + UInt i; - /* Skip the first ? */ + // Skip the leading '?' Char c = GET_NEXT_CHAR(); - while (i < SAFE_VALUE_SIZE-1 && - c != '\n' && - c != '\r' && - c != '\377') { - STATE(Value)[i] = c; - i++; + + for (i = 0; c != '\n' && c != '\r' && c != '\377'; i++) { + // if 'buf' is full, copy it into 'string' and then reset it + if (i >= sizeof(buf)) { + string = AppendBufToString(string, buf, i); + i = 0; + } + buf[i] = c; c = GET_NEXT_CHAR(); } - STATE(Value)[i] = '\0'; - STATE(ValueLen) = i; + string = AppendBufToString(string, buf, i); + + // ensure that the string has a terminator + const UInt len = GET_LEN_STRING(string); + CSTR_STRING(string)[len] = '\0'; + + STATE(ValueObj) = string; + STATE(Symbol) = S_HELP; } /**************************************************************************** @@ -996,7 +1006,7 @@ static void NextSymbol(void) case '^': STATE(Symbol) = S_POW; GET_NEXT_CHAR(); break; case '~': STATE(Symbol) = S_TILDE; GET_NEXT_CHAR(); break; - case '?': STATE(Symbol) = S_HELP; GetHelp(); break; + case '?': GetHelp(); break; case '"': GetMaybeTripStr(); break; case '\'': GetChar(); break; case '\\': GetIdent(0); break; diff --git a/src/scanner.h b/src/scanner.h index 3d2c7939fe..0996b8fc96 100644 --- a/src/scanner.h +++ b/src/scanner.h @@ -231,7 +231,6 @@ typedef UInt TypSymbolSet; ** it hard for the scanner to carry on correctly. */ /* TL: extern Char Value [1030]; */ -/* TL: extern UInt ValueLen; */ #define SAFE_VALUE_SIZE 1024