--- a/ExternalStream.st Tue Mar 05 21:02:56 1996 +0100
+++ b/ExternalStream.st Tue Mar 05 22:10:57 1996 +0100
@@ -542,8 +542,7 @@
f = __FILEVal(fp);
RETURN ( __MKSMALLINT(fileno(f)) );
}
-%}
-.
+%}.
^ self errorNotOpen
!
@@ -758,8 +757,7 @@
closeFile
"low level close - may be redefined in subclasses"
-%{ /* NOCONTEXT */
-
+%{
OBJ fp;
if ((fp = _INST(filePointer)) != nil) {
@@ -824,8 +822,6 @@
_buffered = (_INST(buffered) == true);
_isReadWrite = (_INST(mode) == @symbol(readwrite));
- __PROTECT__(self);
-
__BEGIN_INTERRUPTABLE__
buffer[0] = 0;
@@ -869,7 +865,6 @@
continue;
}
}
- __FETCHPROTECT__(self, 1);
_INST(lastErrorNumber) = __MKSMALLINT(errno);
}
len = 0;
@@ -905,8 +900,6 @@
#endif
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
-
if (rslt != NULL) {
/*
* that strlen can be avoided and replaced by (nextPtr - buffer)
@@ -946,7 +939,7 @@
nextPutLine:aString
"write the characters in aString and append a newline"
-%{ /* NOCONTEXT */
+%{
FILE *f;
int len, cnt, len1;
@@ -964,9 +957,6 @@
_buffered = (_INST(buffered) == true);
_useCRLF = (_INST(useCRLF) == true);
- __PROTECT__(self);
- __PROTECT__(aString);
-
__BEGIN_INTERRUPTABLE__
if (_buffered) {
@@ -975,7 +965,6 @@
} else {
do {
cnt = write(fileno(f), _stringVal(aString), len);
- __FETCHPROTECT__(aString, 1);
} while ((cnt < 0) && (errno == EINTR));
}
@@ -996,8 +985,6 @@
}
__END_INTERRUPTABLE__
- __UNPROTECT__(aString);
- __UNPROTECT__(self);
if (cnt > 0) {
pos = _INST(position);
@@ -1010,8 +997,6 @@
}
__END_INTERRUPTABLE__
- __UNPROTECT__(aString);
- __UNPROTECT__(self);
_INST(lastErrorNumber) = __MKSMALLINT(errno);
}
}
@@ -1261,7 +1246,7 @@
"to provide a simple ioctl facility - an ioctl is performed
on the underlying file; no arguments are passed."
-%{ /* NOCONTEXT */
+%{
#ifndef MSDOS_LIKE
FILE *f;
int ret, ioNum, ioArg;
@@ -1273,14 +1258,11 @@
ioNum = __intVal(ioctlNumber);
f = __FILEVal(fp);
- __PROTECT__(self);
-
__BEGIN_INTERRUPTABLE__
do {
ret = ioctl(fileno(f), ioNum);
} while ((ret < 0) && (errno == EINTR));
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (ret >= 0) {
RETURN ( __MKSMALLINT(ret) );
@@ -1308,7 +1290,7 @@
the data is passed. This allows performing most ioctls - however,
it might be tricky to setup the buffer."
-%{ /* NOCONTEXT */
+%{
#ifndef MSDOS_LIKE
FILE *f;
int ret, ioNum;
@@ -1321,7 +1303,6 @@
f = __FILEVal(fp);
ioNum = __intVal(ioctlNumber);
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
do {
if (__isSmallInteger(arg)) {
@@ -1331,7 +1312,6 @@
}
} while ((ret < 0) && (errno == EINTR));
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (ret >= 0) {
RETURN ( __MKSMALLINT(ret) );
@@ -1433,7 +1413,7 @@
This is allowed in both text and binary modes, always returning the
bytes binary value as an integer in 0..255."
-%{ /* NOCONTEXT */
+%{
FILE *f;
unsigned char byte;
@@ -1450,17 +1430,15 @@
__READING__(f)
}
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
do {
- if (_buffered) {
+ if (! _buffered) {
cnt = read(fileno(f), &byte, 1);
} else {
cnt = fread(&byte, 1, 1, f);
}
} while ((cnt < 0) && (errno == EINTR));
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (cnt == 1) {
if (_INST(position) != nil)
@@ -1567,7 +1545,7 @@
* because we are interruptable, refetch pointer
*/
cp = (char *)__InstPtr(anObject) + nInstBytes + offs;
- if (_buffered) {
+ if (! _buffered) {
ret = read(fileno(f), cp, cnt);
} else {
if (feof(f)) {
@@ -1675,7 +1653,7 @@
A nil is returned, if EOF is hit before all 4 bytes have been read.
Works in both binary and text modes."
-%{ /* NOCONTEXT */
+%{
OBJ fp;
_INST(lastErrorNumber) = nil;
@@ -1687,7 +1665,6 @@
f = __FILEVal(fp);
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
__READING__(f)
@@ -1708,7 +1685,6 @@
} while ((fourth < 0) && (errno == EINTR));
if (fourth != EOF) {
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (msbFlag == true) {
value = (first & 0xFF);
@@ -1733,7 +1709,6 @@
}
}
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (ferror(f) && (errno != 0)) {
_INST(lastErrorNumber) = __MKSMALLINT(errno);
@@ -1756,7 +1731,7 @@
A nil is returned if EOF is reached (also when EOF is hit after the first byte).
Works in both binary and text modes."
-%{ /* NOCONTEXT */
+%{
OBJ fp;
_INST(lastErrorNumber) = nil;
@@ -1768,7 +1743,6 @@
f = __FILEVal(fp);
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
__READING__(f)
@@ -1782,7 +1756,6 @@
} while ((second < 0) && (errno == EINTR));
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (second != EOF) {
if (_INST(position) != nil) {
@@ -1797,7 +1770,6 @@
}
}
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (ferror(f) && (errno != 0)) {
_INST(position) = nil;
@@ -1821,7 +1793,7 @@
A nil is returned, if endOfFile occurs before all 4 bytes have been read.
Works in both binary and text modes."
-%{ /* NOCONTEXT */
+%{
OBJ fp;
_INST(lastErrorNumber) = nil;
@@ -1832,7 +1804,7 @@
unsigned int value;
f = __FILEVal(fp);
- __PROTECT__(self);
+
__BEGIN_INTERRUPTABLE__
__READING__(f)
@@ -1853,7 +1825,6 @@
} while ((fourth < 0) && (errno == EINTR));
if (fourth != EOF) {
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (msbFlag == true) {
value = (first & 0xFF);
@@ -1878,7 +1849,6 @@
}
}
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (ferror(f) && (errno != 0)) {
_INST(lastErrorNumber) = __MKSMALLINT(errno);
@@ -1901,7 +1871,7 @@
A nil is returned if EOF is reached (also when EOF is hit after the first byte).
Works in both binary and text modes."
-%{ /* NOCONTEXT */
+%{
OBJ fp;
_INST(lastErrorNumber) = nil;
@@ -1912,7 +1882,7 @@
unsigned value;
f = __FILEVal(fp);
- __PROTECT__(self);
+
__BEGIN_INTERRUPTABLE__
__READING__(f)
@@ -1926,7 +1896,6 @@
} while ((second < 0) && (errno == EINTR));
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (second != EOF) {
if (_INST(position) != nil) {
@@ -1941,7 +1910,6 @@
}
}
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (ferror(f) && (errno != 0)) {
_INST(position) = nil;
@@ -1977,7 +1945,7 @@
"write a byte.
Works in both binary and text modes."
-%{ /* NOCONTEXT */
+%{
FILE *f;
char c;
@@ -1993,7 +1961,6 @@
f = __FILEVal(fp);
_buffered = (_INST(buffered) == true);
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
/*
*#ifdef OLD
@@ -2020,7 +1987,6 @@
} while ((cnt < 0) && (errno == EINTR));
}
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (cnt == 1) {
pos = _INST(position);
@@ -2060,7 +2026,7 @@
Warning: in general, you cannot use this method to pass data to other
architectures since it does not care for byte order or float representation."
-%{ /* NOCONTEXT */
+%{
FILE *f;
int cnt, offs, _buffered;
int objSize, nInstVars, nInstBytes;
@@ -2094,24 +2060,18 @@
_buffered = (_INST(buffered) == true);
- __PROTECT__(self);
- __PROTECT__(anObject);
- __BEGIN_INTERRUPTABLE__
-
if (_buffered) {
__WRITING__(f)
cnt = fwrite(cp, 1, cnt, f);
} else {
+ __BEGIN_INTERRUPTABLE__
do {
- __FETCHPROTECT__(anObject, 1);
cp = (char *)__InstPtr(anObject) + nInstBytes + offs;
cnt = write(fileno(f), cp, cnt);
} while ((cnt < 0) && (errno == EINTR));
+ __END_INTERRUPTABLE__
}
- __END_INTERRUPTABLE__
- __UNPROTECT__(anObject);
- __UNPROTECT__(self);
if (cnt >= 0) {
pos = _INST(position);
@@ -2150,7 +2110,7 @@
first.
Works in both binary and text modes."
-%{ /* NOCONTEXT */
+%{
int num;
char bytes[4];
@@ -2178,7 +2138,6 @@
f = __FILEVal(fp);
_buffered = (_INST(buffered) == true);
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
if (_buffered) {
@@ -2191,7 +2150,6 @@
}
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (cnt == 4) {
if (_INST(position) != nil) {
@@ -2225,7 +2183,7 @@
first.
Works in both binary and text modes."
-%{ /* NOCONTEXT */
+%{
int num;
char bytes[2];
@@ -2249,7 +2207,6 @@
f = __FILEVal(fp);
_buffered = (_INST(buffered) == true);
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
if (_buffered) {
@@ -2262,7 +2219,6 @@
}
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (cnt == 2) {
if (_INST(position) != nil) {
@@ -2374,7 +2330,7 @@
In binary mode, an integer is returned, otherwise a character.
If there are no more elements, nil is returned."
-%{ /* NOCONTEXT */
+%{
FILE *f;
int c, _buffered;
@@ -2388,7 +2344,6 @@
_buffered = (_INST(buffered) == false);
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
if (_buffered) {
@@ -2397,7 +2352,7 @@
do {
errno = 0;
- if (_buffered) {
+ if (! _buffered) {
if (read(fileno(f), &ch, 1) != 1)
c = EOF;
else
@@ -2409,7 +2364,6 @@
} while ((c < 0) && (errno == EINTR));
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (c != EOF) {
pos = _INST(position);
@@ -2466,7 +2420,7 @@
If there are no more elements, nil is returned.
Not allowed in unbuffered mode."
-%{ /* NOCONTEXT */
+%{
FILE *f;
REGISTER int c;
@@ -2481,7 +2435,6 @@
{
f = __FILEVal(fp);
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
__READING__(f)
@@ -2489,7 +2442,6 @@
c = getc(f);
} while ((c < 0) && (errno == EINTR));
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (c != EOF) {
ungetc(c, f);
@@ -2820,7 +2772,7 @@
the element after anObject.
Only single byte characters are currently supported."
-%{ /* NOCONTEXT */
+%{
FILE *f;
int peekValue, c;
@@ -2843,7 +2795,6 @@
_INST(position) = nil;
f = __FILEVal(fp);
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
__READING__(f)
@@ -2854,7 +2805,6 @@
if (c == EOF) {
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (ferror(f) && (errno != 0)) {
_INST(lastErrorNumber) = __MKSMALLINT(errno);
@@ -2865,7 +2815,6 @@
}
if (c == peekValue) {
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
RETURN (anObject);
}
}
@@ -2884,7 +2833,7 @@
The argument must be an integer if in binary, a character if in
text mode; only single byte characters are currently supported."
-%{ /* NOCONTEXT */
+%{
FILE *f;
int c;
@@ -2918,7 +2867,6 @@
__READING__(f)
errno = 0;
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
do {
if (feof(f)) {
@@ -2927,7 +2875,6 @@
c = getc(f);
} while ((c < 0) && (errno == EINTR));
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (feof(f)) {
_INST(hitEOF) = true;
@@ -3008,7 +2955,7 @@
or nil if endOfFile reached. Not allowed in binary mode.
- reimplemented for speed"
-%{ /* NOCONTEXT */
+%{
FILE *f;
REGISTER int c;
@@ -3027,12 +2974,10 @@
__READING__(f)
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
while (1) {
do {
if (feof(f)) {
- __UNPROTECT__(self);
__END_INTERRUPTABLE__
_INST(hitEOF) = true;
RETURN ( nil );
@@ -3050,7 +2995,6 @@
break;
default:
- __UNPROTECT__(self);
__END_INTERRUPTABLE__
if (c < 0) {
_INST(hitEOF) = true;
@@ -3080,7 +3024,7 @@
or nil if endOfFile reached. Not allowed in binary mode.
- reimplemented for speed"
-%{ /* NOCONTEXT */
+%{
FILE *f;
int c;
@@ -3093,12 +3037,10 @@
f = __FILEVal(fp);
__READING__(f)
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
while (1) {
if (feof(f)) {
- __UNPROTECT__(self);
__END_INTERRUPTABLE__
_INST(hitEOF) = true;
RETURN ( nil );
@@ -3115,7 +3057,6 @@
break;
default:
- __UNPROTECT__(self);
__END_INTERRUPTABLE__
if (c < 0) {
if (ferror(f) && (errno != 0)) {
@@ -3146,7 +3087,7 @@
The argument, aCharacter must be character, or integer when in binary mode.
Only single byte characters are currently supported."
-%{ /* NOCONTEXT */
+%{
FILE *f;
REGISTER int c, cSearch;
@@ -3170,12 +3111,10 @@
f = __FILEVal(fp);
__READING__(f)
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
while (1) {
#ifdef NOTNEEDED
if (feof(f)) {
- __UNPROTECT__(self);
__END_INTERRUPTABLE__
RETURN ( nil );
}
@@ -3185,12 +3124,10 @@
} while ((c < 0) && (errno == EINTR));
if (c == cSearch) {
- __UNPROTECT__(self);
__END_INTERRUPTABLE__
RETURN (self);
}
if (c < 0) {
- __UNPROTECT__(self);
__END_INTERRUPTABLE__
if (ferror(f) && (errno != 0)) {
_INST(lastErrorNumber) = __MKSMALLINT(errno);
@@ -3294,7 +3231,7 @@
atEnd
"return true, if position is at end"
-%{ /* NOCONTEXT */
+%{
FILE *f;
OBJ fp;
@@ -3316,13 +3253,11 @@
#else
__READING__(f)
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
do {
c = getc(f);
} while ((c < 0) && (errno == EINTR) && (clearerr(f), 1));
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (c != EOF) {
ungetc(c, f);
@@ -3509,7 +3444,7 @@
"append an end-of-line character (or CRLF if in crlf mode).
reimplemented for speed"
-%{ /* NOCONTEXT */
+%{
FILE *f;
int len, cnt, _buffered;
@@ -3530,7 +3465,6 @@
_buffered = (_INST(buffered) == true);
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
if (_buffered) {
@@ -3543,7 +3477,6 @@
}
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (cnt == len) {
if (_INST(position) != nil) {
@@ -3565,7 +3498,7 @@
"write the argument, aCharacter - return nil if failed, self if ok.
Only single-byte characters are currently supported"
-%{ /* NOCONTEXT */
+%{
FILE *f;
char c;
@@ -3582,7 +3515,6 @@
f = __FILEVal(fp);
_buffered = (_INST(buffered) == true);
- __PROTECT__(self);
__BEGIN_INTERRUPTABLE__
if (_buffered) {
@@ -3598,7 +3530,6 @@
}
__END_INTERRUPTABLE__
- __UNPROTECT__(self);
if (cnt == 1) {
pos = _INST(position);
@@ -3629,7 +3560,7 @@
Reimplemented for speed when writing strings or byteArrays.
For others, falls back to general method in superclass."
-%{ /* NOCONTEXT */
+%{
FILE *f;
unsigned char *cp;
@@ -3669,11 +3600,9 @@
f = __FILEVal(fp);
_buffered = (_INST(buffered) == false);
- __PROTECT__(self);
- __PROTECT__(aCollection);
__BEGIN_INTERRUPTABLE__
- if (_buffered) {
+ if (! _buffered) {
int cc, rest;
cnt = 0;
@@ -3686,7 +3615,6 @@
* I do not like this
*/
do {
- __FETCHPROTECT__(aCollection, 1);
cp = __ByteArrayInstPtr(aCollection)->ba_element + offs;
cc = write(fileno(f), cp, rest);
if (cc > 0) {
@@ -3706,7 +3634,6 @@
/*
* refetch pointer in case of an interrupt
*/
- __FETCHPROTECT__(aCollection, 1);
cp = __ByteArrayInstPtr(aCollection)->ba_element + offs;
cnt = write(fileno(f), cp, len);
} while ((cnt < 0) && (errno == EINTR));
@@ -3718,8 +3645,6 @@
}
__END_INTERRUPTABLE__
- __UNPROTECT__(aCollection);
- __UNPROTECT__(self);
if (cnt == len) {
pos = _INST(position);
@@ -3744,7 +3669,7 @@
Reimplemented for speed when writing strings or byteArrays.
For others, falls back to general method in superclass."
-%{ /* NOCONTEXT */
+%{
FILE *f;
unsigned char *cp;
@@ -3796,9 +3721,6 @@
_buffered = (_INST(buffered) == true);
- __PROTECT__(self);
- __PROTECT__(aCollection);
-
__BEGIN_INTERRUPTABLE__
if (_buffered) {
@@ -3806,15 +3728,12 @@
cnt = fwrite(cp+index1-1, 1, len, f);
} else {
do {
- __FETCHPROTECT__(aCollection, 1);
cp = __ByteArrayInstPtr(aCollection)->ba_element + offs;
cnt = write(fileno(f), cp+offs, len);
} while ((cnt < 0) && (errno == EINTR));
}
__END_INTERRUPTABLE__
- __PROTECT__(aCollection);
- __PROTECT__(self);
if (cnt == len) {
if (_INST(position) != nil) {
@@ -3834,7 +3753,7 @@
synchronizeOutput
"write all buffered data - ignored if unbuffered"
-%{ /* NOCONTEXT */
+%{
OBJ fp;
_INST(lastErrorNumber) = nil;
@@ -3853,6 +3772,6 @@
!ExternalStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.90 1996-03-05 20:02:56 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.91 1996-03-05 21:10:57 cg Exp $'
! !
ExternalStream initialize!