--- a/ExternalStream.st Wed Oct 26 23:35:39 2016 +0100
+++ b/ExternalStream.st Fri Nov 18 20:48:04 2016 +0000
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1988 by Claus Gittinger
All Rights Reserved
@@ -2596,129 +2594,133 @@
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(socketHandle))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(writeonly))
- && (__INST(binary) != true)
- ) {
- f = __FILEVal(fp);
- buffer[0] = '\0';
-
- _buffered = (__INST(buffered) == true);
- if (_buffered) {
- __READING__(f);
- }
-
- rslt = nextPtr = buffer;
- limit = buffer + sizeof(buffer) - 2;
-
- for (;;) {
- __READBYTE__(ret, f, nextPtr, _buffered, __INST(handleType));
- if (ret <= 0) {
- if (nextPtr == buffer)
- rslt = NULL;
- if (ret == 0) {
- __INST(hitEOF) = true;
- break;
- } else {
- error = __mkSmallInteger(__threadErrno);
- goto err;
- }
- }
-
- if (*nextPtr == '\n') {
- cutOff = 1;
- *nextPtr = '\0';
- break;
- }
- if (*nextPtr == '\r') {
- char peekChar;
-
- /*
- * peek ahead for a newLine ...
- */
- __READBYTE__(ret, f, &peekChar, _buffered, __INST(handleType));
- if (ret <= 0) {
- cutOff = 1;
- *nextPtr = '\0';
- if (ret == 0) {
- __INST(hitEOF) = true;
- break;
- }
- error = __mkSmallInteger(__threadErrno);
- goto err;
- }
-
- if (peekChar == '\n') {
- cutOff = 2;
- *nextPtr = '\0';
- break;
- }
-
- __UNGETC__(peekChar, f, _buffered);
-
- cutOff = 1;
- *nextPtr = '\0';
- break;
- }
-
- nextPtr++;
- if (nextPtr >= limit) {
- *nextPtr = '\0';
- lineTooLong = 1;
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "ExtStream [warning]: line truncated in nextLine\n");
- }
- break;
- }
- }
-
- if (rslt != NULL) {
- len = nextPtr-buffer;
-
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + len + cutOff;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e. do not know */
- }
- /* remove any EOL character */
- if (len != 0) {
- if (buffer[len-1] == '\n') {
- buffer[--len] = '\0';
- }
- if ((len != 0) && (buffer[len-1] == '\r')) {
- buffer[--len] = '\0';
- }
- }
- line = __MKSTRING_L(buffer, len);
- if (! lineTooLong) {
- RETURN ( line );
- }
- }
- }
+ if (((fp = __INST(handle)) != nil)
+ && (__INST(mode) != @symbol(writeonly))
+ && (__INST(binary) != true)
+ ) {
+ f = __FILEVal(fp);
+ buffer[0] = '\0';
+
+ _buffered = (__INST(buffered) == true);
+ if (_buffered) {
+ __READING__(f);
+ }
+
+ rslt = nextPtr = buffer;
+ limit = buffer + sizeof(buffer) - 2;
+
+ for (;;) {
+ __READBYTE__(ret, f, nextPtr, _buffered, __INST(handleType));
+ if (ret <= 0) {
+ if (nextPtr == buffer)
+ rslt = NULL;
+ if (ret == 0) {
+ __INST(hitEOF) = true;
+ break;
+ } else {
+ error = __mkSmallInteger(__threadErrno);
+ goto err;
+ }
+ }
+
+ if (*nextPtr == '\n') {
+ cutOff = 1;
+ *nextPtr = '\0';
+ break;
+ }
+ if (*nextPtr == '\r') {
+ char peekChar;
+
+ /*
+ * peek ahead for a newLine ...
+ */
+ __READBYTE__(ret, f, &peekChar, _buffered, __INST(handleType));
+ if (ret <= 0) {
+ cutOff = 1;
+ *nextPtr = '\0';
+ if (ret == 0) {
+ __INST(hitEOF) = true;
+ break;
+ }
+ error = __mkSmallInteger(__threadErrno);
+ goto err;
+ }
+
+ if (peekChar == '\n') {
+ cutOff = 2;
+ *nextPtr = '\0';
+ break;
+ }
+
+ __UNGETC__(peekChar, f, _buffered);
+
+ cutOff = 1;
+ *nextPtr = '\0';
+ break;
+ }
+
+ nextPtr++;
+ if (nextPtr >= limit) {
+ *nextPtr = '\0';
+ lineTooLong = 1;
+ // signalled below anyway; so no need to print on stderr
+#if 0
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "ExtStream [warning]: line truncated in nextLine\n");
+ }
+#endif
+ break;
+ }
+ }
+
+ if (rslt != NULL) {
+ len = nextPtr-buffer;
+
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + len + cutOff;
+ OBJ t;
+
+ t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e. do not know */
+ }
+ /* remove any EOL character */
+ if (len != 0) {
+ if (buffer[len-1] == '\n') {
+ buffer[--len] = '\0';
+ }
+ if ((len != 0) && (buffer[len-1] == '\r')) {
+ buffer[--len] = '\0';
+ }
+ }
+ line = __MKSTRING_L(buffer, len);
+ if (! lineTooLong) {
+ RETURN ( line );
+ }
+ }
+ }
}
err: ;
%}.
line notNil ifTrue:[
- "/ the line as read is longer than 32k characters (boy - what a line)
- "/ The exception could be handled by reading more and returning the
- "/ concatenation in your exception handler (the receiver and the partial
- "/ line are passed as parameter)
-
- LineTooLongErrorSignal isHandled ifTrue:[
- ^ LineTooLongErrorSignal
- raiseRequestWith:(Array with:self with:line)
- errorString:('line too long read error')
- ].
- ^ line , self nextLine
+ "/ the line as read is longer than 32k characters (boy - what a line)
+ "/ The exception could be handled by reading more and returning the
+ "/ concatenation in your exception handler (the receiver and the partial
+ "/ line are passed as parameter)
+
+ LineTooLongErrorSignal isHandled ifTrue:[
+ ^ LineTooLongErrorSignal
+ raiseRequestWith:(Array with:self with:line)
+ errorString:('line too long read error')
+ ].
+ 'ExternalStream [warning]: line truncated in nextLine' infoPrintCR.
+ ^ line , self nextLine
].
(hitEOF == true) ifTrue:[^ self pastEndRead].
error notNil ifTrue:[
- lastErrorNumber := error.
- ^ self readError:error
+ lastErrorNumber := error.
+ ^ self readError:error
].
handle isNil ifTrue:[^ self errorNotOpen].
(mode == #writeonly) ifTrue:[^ self errorWriteOnly].
@@ -4634,7 +4636,7 @@
"
(FileStream newTemporary
nextPutUtf16:$B;
- nextPutUtf16:$Ä;
+ nextPutUtf16:$;
nextPutUtf16:(Character codePoint:16r10CCCC);
reset;
binary;
@@ -5933,57 +5935,57 @@
|| (__INST(handleType) == @symbol(socketHandle))
|| (__INST(handleType) == @symbol(socketFilePointer))
|| (__INST(handleType) == @symbol(pipeFilePointer))) {
- OBJ fp;
-
- __INST(lastErrorNumber) = nil;
- if (((fp = __INST(handle)) != nil)
- && (__INST(mode) != @symbol(readonly))
- && (__INST(binary) != true)
- ) {
- FILEPOINTER f = __FILEVal(fp);
- int _buffered = (__INST(buffered) == true);
- int len, cnt;
- char *cp;
-
- if (_buffered) {
- __WRITING__(f)
- }
- {
- OBJ mode = __INST(eolMode);
-
- if (mode == @symbol(cr)) {
- cp = "\r"; len = 1;
- } else if (mode == @symbol(crlf)) {
- cp = "\r\n"; len = 2;
- } else if (mode == @symbol(eot)) {
- cp = "\004"; len = 1;
- } else if (mode == @symbol(etx)) {
- cp = "\003"; len = 1;
- } else {
- cp = "\n"; len = 1;
- }
- }
+ OBJ fp;
+
+ __INST(lastErrorNumber) = nil;
+ if (((fp = __INST(handle)) != nil)
+ && (__INST(mode) != @symbol(readonly))
+ && (__INST(binary) != true)
+ ) {
+ FILEPOINTER f = __FILEVal(fp);
+ int _buffered = (__INST(buffered) == true);
+ int len, cnt;
+ char *cp;
+
+ if (_buffered) {
+ __WRITING__(f)
+ }
+ {
+ OBJ mode = __INST(eolMode);
+
+ if (mode == @symbol(cr)) {
+ cp = "\r"; len = 1;
+ } else if (mode == @symbol(crlf)) {
+ cp = "\r\n"; len = 2;
+ } else if (mode == @symbol(eot)) {
+ cp = "\004"; len = 1;
+ } else if (mode == @symbol(etx)) {
+ cp = "\003"; len = 1;
+ } else {
+ cp = "\n"; len = 1;
+ }
+ }
#if defined(WIN32) && !defined(__MINGW__)
- if ((f == __win32_stdout()) || (f == __win32_stderr())) {
- cnt = __win32_fwrite(cp, 1, len, f);
- } else
+ if ((f == __win32_stdout()) || (f == __win32_stderr())) {
+ cnt = __win32_fwrite(cp, 1, len, f);
+ } else
#endif
- {
- __WRITEBYTES__(cnt, f, cp, len, _buffered, __INST(handleType));
- }
- if (cnt == len) {
- if (__isSmallInteger(__INST(position))) {
- INT np = __intVal(__INST(position)) + len;
- OBJ t;
-
- t = __MKINT(np); __INST(position) = t; __STORE(self, t);
- } else {
- __INST(position) = nil; /* i.e: dont know */
- }
- RETURN ( self );
- }
- __INST(lastErrorNumber) = __mkSmallInteger(__threadErrno);
- }
+ {
+ __WRITEBYTES__(cnt, f, cp, len, _buffered, __INST(handleType));
+ }
+ if (cnt == len) {
+ if (__isSmallInteger(__INST(position))) {
+ INT np = __intVal(__INST(position)) + len;
+ OBJ t;
+
+ t = __MKINT(np); __INST(position) = t; __STORE(self, t);
+ } else {
+ __INST(position) = nil; /* i.e: don't know */
+ }
+ RETURN ( self );
+ }
+ __INST(lastErrorNumber) = __mkSmallInteger(__threadErrno);
+ }
}
%}.
lastErrorNumber notNil ifTrue:[self writeError. ^ self].
@@ -5992,11 +5994,11 @@
(binary==true) ifTrue:[self errorBinary. ^ self].
(eolMode == #cr) ifTrue:[
- self nextPut:(Character return).
- ^ self
+ self nextPut:(Character return).
+ ^ self
].
(eolMode == #crlf) ifTrue:[
- self nextPut:(Character return).
+ self nextPut:(Character return).
].
self nextPut:(Character nl).
^ self
@@ -6569,7 +6571,7 @@
].
"
- 'Bönnigheim' asUnicode16String errorPrintCR
+ 'Bnnigheim' asUnicode16String errorPrintCR
"
!