Hi Stefan,

It looks like this has been fixed in the CVS repository - you might
grab a copy from there.  

What was done was to use an int buffer for the character just read
from input.  Your fix of using an int[] buffer for the entire line
would lead to changes throughout Hugs as we tracked down and fixed up
every place that touches a String.

--
Alastair

ps Here's how the CVS repository solves the problem


/* Returns line length (including \n) or 0 upon EOF. */
static Int local nextLine()
{
    int ch;

    for (lineLength = 0; lineLength < LINEBUFFER_SIZE-1; lineLength++) {
        lineBuffer[lineLength] = (ch = fgetc(inputStream));
        if (ch == EOF)
            break;
#if MULTI_LINEFEED
        if ((char)ch == '\r') {
            ch = fgetc(inputStream);
            /* ToDo: verify that this behaves correctly re EOF */
            if ((char)ch != '\n') 
                ungetc(ch, inputStream);
            lineBuffer[lineLength] = '\n';
            lineLength++;
            break;
        } else 
#endif
        if ((char)ch == '\n') {
            lineLength++;
            break;
        }
    }
    lineBuffer[lineLength] = '\0';

    /* printf("Read: \"%s\"", lineBuffer); */
    if (lineLength <= 0) { /* EOF / IO error, who knows.. */
        return lineLength;
    }
    else if (lineLength >= 2 && lineBuffer[0] == '#' && lineBuffer[1] == '!') {
        lineBuffer[0]='\n'; /* pretend it's a blank line */
        lineBuffer[1]='\0';
        lineLength=1;
    } else if (thisLiterate) {
        if (linecmp(BEGINCODE, lineBuffer)) {
            if (!inCodeBlock) {             /* Entered a code block        */
                inCodeBlock = TRUE;
                lineBuffer[0]='\n'; /* pretend it's a blank line */
                lineBuffer[1]='\0';
                lineLength=1;
            }
            else {
                ERRMSG(row) "\\begin{code} encountered inside code block"
                EEND;
            }
        }
        else if (linecmp(ENDCODE, lineBuffer)) {
            if (inCodeBlock) {              /* Finished code block         */
                inCodeBlock = FALSE;
                lineBuffer[0]='\n'; /* pretend it's a blank line */
                lineBuffer[1]='\0';
                lineLength=1;
            }
            else {
                ERRMSG(row) "\\end{code} encountered outside code block"
                EEND;
            }
        }
    }
    /* printf("Read: \"%s\"", lineBuffer); */
    return lineLength;
}
_______________________________________________
Hugs-Bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/hugs-bugs

Reply via email to