# HG changeset patch # User Claus Gittinger # Date 818013862 -3600 # Node ID 73165201a9da52e32ce954ff2aadfe1689d5c2a4 # Parent 3b1e83ecf6d5ac29b8bc16305cf83bbffaaf38fa nextChunk: %{ is only recognized if at begin-of-line diff -r 3b1e83ecf6d5 -r 73165201a9da ExtStream.st --- a/ExtStream.st Sun Dec 03 19:02:39 1995 +0100 +++ b/ExtStream.st Sun Dec 03 19:04:22 1995 +0100 @@ -12,10 +12,10 @@ ReadWriteStream subclass:#ExternalStream instanceVariableNames:'filePointer mode buffered binary useCRLF hitEOF didWrite - lastErrorNumber' + lastErrorNumber' classVariableNames:'Lobby LastErrorNumber ReadErrorSignal WriteErrorSignal - InvalidReadSignal InvalidWriteSignal InvalidModeSignal - OpenErrorSignal StreamNotOpenSignal' + InvalidReadSignal InvalidWriteSignal InvalidModeSignal + OpenErrorSignal StreamNotOpenSignal' poolDictionaries:'' category:'Streams-External' ! @@ -177,7 +177,7 @@ ! version - ^ '$Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.71 1995-12-03 16:25:38 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.72 1995-12-03 18:04:22 cg Exp $' ! ! !ExternalStream class methodsFor:'initialization'! @@ -2280,7 +2280,7 @@ nextChunk "return the next chunk, i.e. all characters up to the next - exclamation mark. Within the chunk, exclass have to be doubled - + exclamation mark. Within the chunk, exclamation marks have to be doubled - except within primitive code (this exception was added to make it easier to edit primitive code with external editors). This means, that other Smalltalks cannot always read chunks containing primitive code - but that @@ -2305,15 +2305,15 @@ REGISTER int c; int peekC; char *bufferPtr = (char *)0; - char fastBuffer[4096]; + char fastBuffer[7000]; REGISTER int index; int currSize, fastFlag; - int inComment, inString, inPrimitive = 0; + int atBeginOfLine = 1, inComment, inString, inPrimitive = 0; OBJ __MKSTRING_L(), __MKSTRING_ST_L(), __MKEMPTYSTRING(); _INST(lastErrorNumber) = nil; f = __FILEVal(_INST(filePointer)); - + __READING__(f) if (feof(f)) { @@ -2331,10 +2331,13 @@ } while ((c < 0) && (errno == EINTR)); __END_INTERRUPTABLE__ + atBeginOfLine = 0; switch (c) { + case '\n': + atBeginOfLine = 1; + /* fall into */ case ' ': case '\t': - case '\n': case '\r': case '\b': case '\014': @@ -2367,7 +2370,7 @@ * do we have to resize the buffer ? */ if ((index+2) >= currSize) { - OBJ newBuffer; + OBJ newBuffer; char *nbp; newBuffer = __MKEMPTYSTRING(currSize * 2 COMMA_CON); @@ -2399,7 +2402,7 @@ } while (c < 0 && (errno == EINTR)); __END_INTERRUPTABLE__ - if (c == '%') { + if (atBeginOfLine && (c == '%')) { __BEGIN_INTERRUPTABLE__ do { peekC = getc(f); @@ -2438,6 +2441,7 @@ break; } bufferPtr[index++] = c; + atBeginOfLine = (c == '\n'); } /* @@ -2447,7 +2451,7 @@ * fast (C) buffer or from real (ST) buffer. */ if (fastFlag) { - retVal = __MKSTRING_L(bufferPtr, index COMMA_CON); + retVal = __MKSTRING_L(bufferPtr, index COMMA_CON); } else { retVal = __MKSTRING_ST_L(buffer, index COMMA_CON); } diff -r 3b1e83ecf6d5 -r 73165201a9da ExternalStream.st --- a/ExternalStream.st Sun Dec 03 19:02:39 1995 +0100 +++ b/ExternalStream.st Sun Dec 03 19:04:22 1995 +0100 @@ -12,10 +12,10 @@ ReadWriteStream subclass:#ExternalStream instanceVariableNames:'filePointer mode buffered binary useCRLF hitEOF didWrite - lastErrorNumber' + lastErrorNumber' classVariableNames:'Lobby LastErrorNumber ReadErrorSignal WriteErrorSignal - InvalidReadSignal InvalidWriteSignal InvalidModeSignal - OpenErrorSignal StreamNotOpenSignal' + InvalidReadSignal InvalidWriteSignal InvalidModeSignal + OpenErrorSignal StreamNotOpenSignal' poolDictionaries:'' category:'Streams-External' ! @@ -177,7 +177,7 @@ ! version - ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.71 1995-12-03 16:25:38 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.72 1995-12-03 18:04:22 cg Exp $' ! ! !ExternalStream class methodsFor:'initialization'! @@ -2280,7 +2280,7 @@ nextChunk "return the next chunk, i.e. all characters up to the next - exclamation mark. Within the chunk, exclass have to be doubled - + exclamation mark. Within the chunk, exclamation marks have to be doubled - except within primitive code (this exception was added to make it easier to edit primitive code with external editors). This means, that other Smalltalks cannot always read chunks containing primitive code - but that @@ -2305,15 +2305,15 @@ REGISTER int c; int peekC; char *bufferPtr = (char *)0; - char fastBuffer[4096]; + char fastBuffer[7000]; REGISTER int index; int currSize, fastFlag; - int inComment, inString, inPrimitive = 0; + int atBeginOfLine = 1, inComment, inString, inPrimitive = 0; OBJ __MKSTRING_L(), __MKSTRING_ST_L(), __MKEMPTYSTRING(); _INST(lastErrorNumber) = nil; f = __FILEVal(_INST(filePointer)); - + __READING__(f) if (feof(f)) { @@ -2331,10 +2331,13 @@ } while ((c < 0) && (errno == EINTR)); __END_INTERRUPTABLE__ + atBeginOfLine = 0; switch (c) { + case '\n': + atBeginOfLine = 1; + /* fall into */ case ' ': case '\t': - case '\n': case '\r': case '\b': case '\014': @@ -2367,7 +2370,7 @@ * do we have to resize the buffer ? */ if ((index+2) >= currSize) { - OBJ newBuffer; + OBJ newBuffer; char *nbp; newBuffer = __MKEMPTYSTRING(currSize * 2 COMMA_CON); @@ -2399,7 +2402,7 @@ } while (c < 0 && (errno == EINTR)); __END_INTERRUPTABLE__ - if (c == '%') { + if (atBeginOfLine && (c == '%')) { __BEGIN_INTERRUPTABLE__ do { peekC = getc(f); @@ -2438,6 +2441,7 @@ break; } bufferPtr[index++] = c; + atBeginOfLine = (c == '\n'); } /* @@ -2447,7 +2451,7 @@ * fast (C) buffer or from real (ST) buffer. */ if (fastFlag) { - retVal = __MKSTRING_L(bufferPtr, index COMMA_CON); + retVal = __MKSTRING_L(bufferPtr, index COMMA_CON); } else { retVal = __MKSTRING_ST_L(buffer, index COMMA_CON); }