Hi! I have tried to install Hugs on a Apple Powerbook G3, running debian. It does not work. First I get: gcc -c -g -O2 input.c input.c: In function `nextLine': input.c:516: warning: comparison is always false due to limited range of data type Then I changed the type of lineBuffer in input.c from *char to *int. The compile error disapperead, instead I got 2 warnings: gcc -c -g -O2 input.c input.c: In function `nextLine': input.c:546: warning: passing arg 2 of `linecmp' from incompatible pointer type input.c:558: warning: passing arg 2 of `linecmp' from incompatible pointer type So I added the two necessary casts. Now compilation went fine, but when I try to start a program, the following happens: Reading file "/usr/local/share/hugs/lib/exts/IORef.lhs": ERROR "/usr/local/share/hugs/lib/exts/IORef.lhs":40 - Empty script - perhaps you forgot the `>'s? There seems to be a problem with if (linecmp(BEGINCODE, (char*)lineBuffer)) { input.c, line 545 and else if (linecmp(ENDCODE, (char*)lineBuffer)) { input.c, line 557 Bye, Stefan -- Stefan Heimann | http://www.stefanheimann.net Brandensteinstr. 5 | http://www.cantaloop.org D-79110 Freiburg | http://cvsshell.sourceforge.net
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; }
participants (2)
-
Alastair Reid -
Stefan Heimann