equal
deleted
inserted
replaced
22 |
22 |
23 ExternalStream comment:' |
23 ExternalStream comment:' |
24 COPYRIGHT (c) 1988 by Claus Gittinger |
24 COPYRIGHT (c) 1988 by Claus Gittinger |
25 All Rights Reserved |
25 All Rights Reserved |
26 |
26 |
27 $Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.60 1995-11-02 15:15:43 cg Exp $ |
27 $Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.61 1995-11-02 20:10:35 cg Exp $ |
28 '! |
28 '! |
29 |
29 |
30 !ExternalStream primitiveDefinitions! |
30 !ExternalStream primitiveDefinitions! |
31 |
31 |
32 %{ |
32 %{ |
149 " |
149 " |
150 ! |
150 ! |
151 |
151 |
152 version |
152 version |
153 " |
153 " |
154 $Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.60 1995-11-02 15:15:43 cg Exp $ |
154 $Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.61 1995-11-02 20:10:35 cg Exp $ |
155 " |
155 " |
156 ! |
156 ! |
157 |
157 |
158 documentation |
158 documentation |
159 " |
159 " |
432 OBJ fp; |
432 OBJ fp; |
433 |
433 |
434 if ((fp = _INST(filePointer)) != nil) { |
434 if ((fp = _INST(filePointer)) != nil) { |
435 _INST(filePointer) = nil; |
435 _INST(filePointer) = nil; |
436 __BEGIN_INTERRUPTABLE__ |
436 __BEGIN_INTERRUPTABLE__ |
437 fclose(MKFD(fp)); |
437 fclose(__FILEVal(fp)); |
438 __END_INTERRUPTABLE__ |
438 __END_INTERRUPTABLE__ |
439 } |
439 } |
440 %} |
440 %} |
441 ! ! |
441 ! ! |
442 |
442 |
661 |
661 |
662 FILE *f; |
662 FILE *f; |
663 OBJ fp; |
663 OBJ fp; |
664 |
664 |
665 if ((fp = _INST(filePointer)) != nil) { |
665 if ((fp = _INST(filePointer)) != nil) { |
666 f = MKFD(fp); |
666 f = __FILEVal(fp); |
667 RETURN ( __MKSMALLINT(fileno(f)) ); |
667 RETURN ( __MKSMALLINT(fileno(f)) ); |
668 } |
668 } |
669 %} |
669 %} |
670 . |
670 . |
671 ^ self errorNotOpen |
671 ^ self errorNotOpen |
856 |
856 |
857 _INST(lastErrorNumber) = nil; |
857 _INST(lastErrorNumber) = nil; |
858 if ((fp = _INST(filePointer)) != nil) { |
858 if ((fp = _INST(filePointer)) != nil) { |
859 if (__isSmallInteger(ioctlNumber)) { |
859 if (__isSmallInteger(ioctlNumber)) { |
860 ioNum = __intVal(ioctlNumber); |
860 ioNum = __intVal(ioctlNumber); |
861 f = MKFD(fp); |
861 f = __FILEVal(fp); |
862 |
862 |
863 __BEGIN_INTERRUPTABLE__ |
863 __BEGIN_INTERRUPTABLE__ |
864 do { |
864 do { |
865 ret = ioctl(fileno(f), ioNum); |
865 ret = ioctl(fileno(f), ioNum); |
866 } while ((ret < 0) && (errno == EINTR)); |
866 } while ((ret < 0) && (errno == EINTR)); |
897 |
897 |
898 _INST(lastErrorNumber) = nil; |
898 _INST(lastErrorNumber) = nil; |
899 if ((fp = _INST(filePointer)) != nil) { |
899 if ((fp = _INST(filePointer)) != nil) { |
900 if (__isSmallInteger(ioctlNumber) |
900 if (__isSmallInteger(ioctlNumber) |
901 && (__isSmallInteger(arg) || __isBytes(arg))) { |
901 && (__isSmallInteger(arg) || __isBytes(arg))) { |
902 f = MKFD(fp); |
902 f = __FILEVal(fp); |
903 ioNum = __intVal(ioctlNumber); |
903 ioNum = __intVal(ioctlNumber); |
904 |
904 |
905 __BEGIN_INTERRUPTABLE__ |
905 __BEGIN_INTERRUPTABLE__ |
906 do { |
906 do { |
907 if (__isSmallInteger(arg)) { |
907 if (__isSmallInteger(arg)) { |
943 OBJ fp; |
943 OBJ fp; |
944 |
944 |
945 _INST(lastErrorNumber) = nil; |
945 _INST(lastErrorNumber) = nil; |
946 if (((fp = _INST(filePointer)) != nil) |
946 if (((fp = _INST(filePointer)) != nil) |
947 && (_INST(mode) != @symbol(writeonly))) { |
947 && (_INST(mode) != @symbol(writeonly))) { |
948 f = MKFD(fp); |
948 f = __FILEVal(fp); |
949 |
949 |
950 __BEGIN_INTERRUPTABLE__ |
950 __BEGIN_INTERRUPTABLE__ |
951 do { |
951 do { |
952 if (_INST(buffered) == false) { |
952 if (_INST(buffered) == false) { |
953 cnt = read(fileno(f), &byte, 1); |
953 cnt = read(fileno(f), &byte, 1); |
1040 |
1040 |
1041 _INST(lastErrorNumber) = nil; |
1041 _INST(lastErrorNumber) = nil; |
1042 if (((fp = _INST(filePointer)) != nil) |
1042 if (((fp = _INST(filePointer)) != nil) |
1043 && (_INST(mode) != @symbol(writeonly))) { |
1043 && (_INST(mode) != @symbol(writeonly))) { |
1044 if (__bothSmallInteger(count, start)) { |
1044 if (__bothSmallInteger(count, start)) { |
1045 f = MKFD(fp); |
1045 f = __FILEVal(fp); |
1046 |
1046 |
1047 oClass = __Class(anObject); |
1047 oClass = __Class(anObject); |
1048 switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) { |
1048 switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) { |
1049 case BYTEARRAY: |
1049 case BYTEARRAY: |
1050 case WORDARRAY: |
1050 case WORDARRAY: |
1122 && (_INST(mode) != @symbol(writeonly))) { |
1122 && (_INST(mode) != @symbol(writeonly))) { |
1123 FILE *f; |
1123 FILE *f; |
1124 int first, second, err; |
1124 int first, second, err; |
1125 short value; |
1125 short value; |
1126 |
1126 |
1127 f = MKFD(fp); |
1127 f = __FILEVal(fp); |
1128 __BEGIN_INTERRUPTABLE__ |
1128 __BEGIN_INTERRUPTABLE__ |
1129 __READING__(f) |
1129 __READING__(f) |
1130 |
1130 |
1131 do { |
1131 do { |
1132 first = getc(f); |
1132 first = getc(f); |
1181 && (_INST(mode) != @symbol(writeonly))) { |
1181 && (_INST(mode) != @symbol(writeonly))) { |
1182 FILE *f; |
1182 FILE *f; |
1183 int first, second; |
1183 int first, second; |
1184 unsigned value; |
1184 unsigned value; |
1185 |
1185 |
1186 f = MKFD(fp); |
1186 f = __FILEVal(fp); |
1187 __BEGIN_INTERRUPTABLE__ |
1187 __BEGIN_INTERRUPTABLE__ |
1188 __READING__(f) |
1188 __READING__(f) |
1189 |
1189 |
1190 do { |
1190 do { |
1191 first = getc(f); |
1191 first = getc(f); |
1241 && (_INST(mode) != @symbol(writeonly))) { |
1241 && (_INST(mode) != @symbol(writeonly))) { |
1242 FILE *f; |
1242 FILE *f; |
1243 int first, second, third, fourth; |
1243 int first, second, third, fourth; |
1244 int value; |
1244 int value; |
1245 |
1245 |
1246 f = MKFD(fp); |
1246 f = __FILEVal(fp); |
1247 __BEGIN_INTERRUPTABLE__ |
1247 __BEGIN_INTERRUPTABLE__ |
1248 __READING__(f) |
1248 __READING__(f) |
1249 |
1249 |
1250 do { |
1250 do { |
1251 first = getc(f); |
1251 first = getc(f); |
1319 && (_INST(mode) != @symbol(writeonly))) { |
1319 && (_INST(mode) != @symbol(writeonly))) { |
1320 FILE *f; |
1320 FILE *f; |
1321 int first, second, third, fourth; |
1321 int first, second, third, fourth; |
1322 unsigned int value; |
1322 unsigned int value; |
1323 |
1323 |
1324 f = MKFD(fp); |
1324 f = __FILEVal(fp); |
1325 __BEGIN_INTERRUPTABLE__ |
1325 __BEGIN_INTERRUPTABLE__ |
1326 __READING__(f) |
1326 __READING__(f) |
1327 |
1327 |
1328 do { |
1328 do { |
1329 first = getc(f); |
1329 first = getc(f); |
1419 _INST(lastErrorNumber) = nil; |
1419 _INST(lastErrorNumber) = nil; |
1420 if (((fp = _INST(filePointer)) != nil) |
1420 if (((fp = _INST(filePointer)) != nil) |
1421 && (_INST(mode) != @symbol(readonly))) { |
1421 && (_INST(mode) != @symbol(readonly))) { |
1422 if (__isSmallInteger(aByteValue)) { |
1422 if (__isSmallInteger(aByteValue)) { |
1423 c = __intVal(aByteValue); |
1423 c = __intVal(aByteValue); |
1424 f = MKFD(fp); |
1424 f = __FILEVal(fp); |
1425 __BEGIN_INTERRUPTABLE__ |
1425 __BEGIN_INTERRUPTABLE__ |
1426 /* |
1426 /* |
1427 *#ifdef OLD |
1427 *#ifdef OLD |
1428 * if (_INST(buffered) == false) { |
1428 * if (_INST(buffered) == false) { |
1429 * cnt = write(fileno(f), &c, 1); |
1429 * cnt = write(fileno(f), &c, 1); |
1516 default: |
1516 default: |
1517 goto bad; |
1517 goto bad; |
1518 } |
1518 } |
1519 cnt = __intVal(count); |
1519 cnt = __intVal(count); |
1520 offs = __intVal(start) - 1; |
1520 offs = __intVal(start) - 1; |
1521 f = MKFD(fp); |
1521 f = __FILEVal(fp); |
1522 |
1522 |
1523 nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars); |
1523 nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars); |
1524 nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
1524 nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars); |
1525 objSize = __Size(anObject) - nInstBytes; |
1525 objSize = __Size(anObject) - nInstBytes; |
1526 if ( (offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs)) ) { |
1526 if ( (offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs)) ) { |
1590 } else { |
1590 } else { |
1591 bytes[1] = (num >> 8) & 0xFF; |
1591 bytes[1] = (num >> 8) & 0xFF; |
1592 bytes[0] = num & 0xFF; |
1592 bytes[0] = num & 0xFF; |
1593 } |
1593 } |
1594 |
1594 |
1595 f = MKFD(fp); |
1595 f = __FILEVal(fp); |
1596 __BEGIN_INTERRUPTABLE__ |
1596 __BEGIN_INTERRUPTABLE__ |
1597 #ifdef OLD |
1597 #ifdef OLD |
1598 if (_INST(buffered) == false) { |
1598 if (_INST(buffered) == false) { |
1599 cnt = write(fileno(f), bytes, 2); |
1599 cnt = write(fileno(f), bytes, 2); |
1600 } else |
1600 } else |
1654 bytes[2] = (num >> 16) & 0xFF; |
1654 bytes[2] = (num >> 16) & 0xFF; |
1655 bytes[1] = (num >> 8) & 0xFF; |
1655 bytes[1] = (num >> 8) & 0xFF; |
1656 bytes[0] = num & 0xFF; |
1656 bytes[0] = num & 0xFF; |
1657 } |
1657 } |
1658 |
1658 |
1659 f = MKFD(fp); |
1659 f = __FILEVal(fp); |
1660 __BEGIN_INTERRUPTABLE__ |
1660 __BEGIN_INTERRUPTABLE__ |
1661 #ifdef OLD |
1661 #ifdef OLD |
1662 if (_INST(buffered) == false) { |
1662 if (_INST(buffered) == false) { |
1663 cnt = write(fileno(f), bytes, 4); |
1663 cnt = write(fileno(f), bytes, 4); |
1664 } else |
1664 } else |
1719 && (_INST(mode) != @symbol(writeonly))) { |
1719 && (_INST(mode) != @symbol(writeonly))) { |
1720 #ifdef OLD |
1720 #ifdef OLD |
1721 if (_INST(buffered) == true) |
1721 if (_INST(buffered) == true) |
1722 #endif |
1722 #endif |
1723 { |
1723 { |
1724 f = MKFD(fp); |
1724 f = __FILEVal(fp); |
1725 |
1725 |
1726 __BEGIN_INTERRUPTABLE__ |
1726 __BEGIN_INTERRUPTABLE__ |
1727 __READING__(f) |
1727 __READING__(f) |
1728 |
1728 |
1729 do { |
1729 do { |
1766 unsigned char ch; |
1766 unsigned char ch; |
1767 |
1767 |
1768 _INST(lastErrorNumber) = nil; |
1768 _INST(lastErrorNumber) = nil; |
1769 if (((fp = _INST(filePointer)) != nil) |
1769 if (((fp = _INST(filePointer)) != nil) |
1770 && (_INST(mode) != @symbol(writeonly))) { |
1770 && (_INST(mode) != @symbol(writeonly))) { |
1771 f = MKFD(fp); |
1771 f = __FILEVal(fp); |
1772 __BEGIN_INTERRUPTABLE__ |
1772 __BEGIN_INTERRUPTABLE__ |
1773 __READING__(f) |
1773 __READING__(f) |
1774 |
1774 |
1775 do { |
1775 do { |
1776 #ifdef OLD |
1776 #ifdef OLD |
1852 _INST(lastErrorNumber) = nil; |
1852 _INST(lastErrorNumber) = nil; |
1853 if ((fp = _INST(filePointer)) != nil) { |
1853 if ((fp = _INST(filePointer)) != nil) { |
1854 if (_INST(mode) != @symbol(readonly)) { |
1854 if (_INST(mode) != @symbol(readonly)) { |
1855 if (_INST(buffered) == true) { |
1855 if (_INST(buffered) == true) { |
1856 __BEGIN_INTERRUPTABLE__ |
1856 __BEGIN_INTERRUPTABLE__ |
1857 fflush( MKFD(fp) ); |
1857 fflush( __FILEVal(fp) ); |
1858 __END_INTERRUPTABLE__ |
1858 __END_INTERRUPTABLE__ |
1859 } |
1859 } |
1860 } |
1860 } |
1861 } |
1861 } |
1862 %} |
1862 %} |
1863 ! |
1863 ! |
1864 |
1864 |
1865 nextPut:aCharacter |
1865 nextPut:aCharacter |
1866 "write the argument, aCharacter - return nil if failed, self if ok" |
1866 "write the argument, aCharacter - return nil if failed, self if ok. |
|
1867 Only single-byte characters are currently supported" |
1867 |
1868 |
1868 %{ /* NOCONTEXT */ |
1869 %{ /* NOCONTEXT */ |
1869 |
1870 |
1870 FILE *f; |
1871 FILE *f; |
1871 char c; |
1872 char c; |
1875 _INST(lastErrorNumber) = nil; |
1876 _INST(lastErrorNumber) = nil; |
1876 if (((fp = _INST(filePointer)) != nil) |
1877 if (((fp = _INST(filePointer)) != nil) |
1877 && (_INST(mode) != @symbol(readonly))) { |
1878 && (_INST(mode) != @symbol(readonly))) { |
1878 if (_INST(binary) != true) { |
1879 if (_INST(binary) != true) { |
1879 if (__isCharacter(aCharacter)) { |
1880 if (__isCharacter(aCharacter)) { |
1880 c = __intVal(__CharacterInstPtr(aCharacter)->c_asciivalue); |
1881 c = __intVal(__characterVal(aCharacter)) & 0xFF; |
1881 doWrite: |
1882 doWrite: |
1882 f = MKFD(fp); |
1883 f = __FILEVal(fp); |
1883 |
1884 |
1884 __BEGIN_INTERRUPTABLE__ |
1885 __BEGIN_INTERRUPTABLE__ |
1885 |
1886 |
1886 __WRITING__(f) |
1887 __WRITING__(f) |
1887 |
1888 |
1955 } |
1956 } |
1956 } |
1957 } |
1957 } |
1958 } |
1958 } |
1959 } |
1959 if (cp != NULL) { |
1960 if (cp != NULL) { |
1960 f = MKFD(fp); |
1961 f = __FILEVal(fp); |
1961 |
1962 |
1962 __BEGIN_INTERRUPTABLE__ |
1963 __BEGIN_INTERRUPTABLE__ |
1963 #ifdef NONONO |
1964 #ifdef NONONO |
1964 |
1965 |
1965 #ifdef OLD |
1966 #ifdef OLD |
2076 len -= __OBJS2BYTES__(nInst); |
2077 len -= __OBJS2BYTES__(nInst); |
2077 } |
2078 } |
2078 } |
2079 } |
2079 } |
2080 } |
2080 if (cp != NULL) { |
2081 if (cp != NULL) { |
2081 f = MKFD(fp); |
2082 f = __FILEVal(fp); |
2082 index1 = __intVal(start); |
2083 index1 = __intVal(start); |
2083 index2 = __intVal(stop); |
2084 index2 = __intVal(stop); |
2084 if ((index1 < 1) || (index2 > len) || (index2 < index1)) { |
2085 if ((index1 < 1) || (index2 > len) || (index2 < index1)) { |
2085 RETURN ( self ); |
2086 RETURN ( self ); |
2086 } |
2087 } |
2139 |
2140 |
2140 _INST(lastErrorNumber) = nil; |
2141 _INST(lastErrorNumber) = nil; |
2141 if (((fp = _INST(filePointer)) != nil) |
2142 if (((fp = _INST(filePointer)) != nil) |
2142 && (_INST(mode) != @symbol(readonly))) { |
2143 && (_INST(mode) != @symbol(readonly))) { |
2143 if (_INST(binary) != true) { |
2144 if (_INST(binary) != true) { |
2144 f = MKFD(fp); |
2145 f = __FILEVal(fp); |
2145 |
2146 |
2146 __BEGIN_INTERRUPTABLE__ |
2147 __BEGIN_INTERRUPTABLE__ |
2147 |
2148 |
2148 __WRITING__(f) |
2149 __WRITING__(f) |
2149 |
2150 |
2193 |
2194 |
2194 _INST(lastErrorNumber) = nil; |
2195 _INST(lastErrorNumber) = nil; |
2195 if (((fp = _INST(filePointer)) != nil) |
2196 if (((fp = _INST(filePointer)) != nil) |
2196 && (_INST(mode) != @symbol(writeonly))) { |
2197 && (_INST(mode) != @symbol(writeonly))) { |
2197 if (_INST(binary) != true) { |
2198 if (_INST(binary) != true) { |
2198 f = MKFD(fp); |
2199 f = __FILEVal(fp); |
2199 __BEGIN_INTERRUPTABLE__ |
2200 __BEGIN_INTERRUPTABLE__ |
2200 buffer[0] = 0; |
2201 buffer[0] = 0; |
2201 |
2202 |
2202 _buffered = (_INST(buffered) == true); |
2203 _buffered = (_INST(buffered) == true); |
2203 if (_buffered) { |
2204 if (_buffered) { |
2327 _INST(lastErrorNumber) = nil; |
2328 _INST(lastErrorNumber) = nil; |
2328 if (((fp = _INST(filePointer)) != nil) |
2329 if (((fp = _INST(filePointer)) != nil) |
2329 && (_INST(mode) != @symbol(readonly))) { |
2330 && (_INST(mode) != @symbol(readonly))) { |
2330 if (_INST(binary) != true) { |
2331 if (_INST(binary) != true) { |
2331 if (__isString(aString)) { |
2332 if (__isString(aString)) { |
2332 f = MKFD(fp); |
2333 f = __FILEVal(fp); |
2333 s = (char *) _stringVal(aString); |
2334 s = (char *) _stringVal(aString); |
2334 len = _stringSize(aString); |
2335 len = _stringSize(aString); |
2335 |
2336 |
2336 __BEGIN_INTERRUPTABLE__ |
2337 __BEGIN_INTERRUPTABLE__ |
2337 /* |
2338 /* |
2425 if ((aStringOrNil == nil) || __isString(aStringOrNil)) { |
2426 if ((aStringOrNil == nil) || __isString(aStringOrNil)) { |
2426 if (aStringOrNil != nil) { |
2427 if (aStringOrNil != nil) { |
2427 matchString = (char *) _stringVal(aStringOrNil); |
2428 matchString = (char *) _stringVal(aStringOrNil); |
2428 matchLen = _stringSize(aStringOrNil); |
2429 matchLen = _stringSize(aStringOrNil); |
2429 } |
2430 } |
2430 dst = MKFD(_INST(filePointer)); |
2431 dst = __FILEVal(_INST(filePointer)); |
2431 src = MKFD(srcFilePointer); |
2432 src = __FILEVal(srcFilePointer); |
2432 __BEGIN_INTERRUPTABLE__ |
2433 __BEGIN_INTERRUPTABLE__ |
2433 errno = 0; |
2434 errno = 0; |
2434 |
2435 |
2435 __WRITING__(dst) |
2436 __WRITING__(dst) |
2436 |
2437 |
2502 _INST(lastErrorNumber) = nil; |
2503 _INST(lastErrorNumber) = nil; |
2503 if (__isString(aString)) { |
2504 if (__isString(aString)) { |
2504 matchString = (char *) _stringVal(aString); |
2505 matchString = (char *) _stringVal(aString); |
2505 l = _stringSize(aString); |
2506 l = _stringSize(aString); |
2506 |
2507 |
2507 f = MKFD(_INST(filePointer)); |
2508 f = __FILEVal(_INST(filePointer)); |
2508 __READING__(f) |
2509 __READING__(f) |
2509 |
2510 |
2510 for (;;) { |
2511 for (;;) { |
2511 lastpos = ftell(f); |
2512 lastpos = ftell(f); |
2512 if (firstpos == -1) firstpos = lastpos; |
2513 if (firstpos == -1) firstpos = lastpos; |
2589 if (_INST(hitEOF) == _true) { |
2590 if (_INST(hitEOF) == _true) { |
2590 RETURN (_true); |
2591 RETURN (_true); |
2591 } |
2592 } |
2592 _INST(lastErrorNumber) = nil; |
2593 _INST(lastErrorNumber) = nil; |
2593 if ((fp = _INST(filePointer)) != nil) { |
2594 if ((fp = _INST(filePointer)) != nil) { |
2594 f = MKFD(fp); |
2595 f = __FILEVal(fp); |
2595 #ifdef OLD |
2596 #ifdef OLD |
2596 RETURN ( feof(f) ? _true : false ); |
2597 RETURN ( feof(f) ? _true : false ); |
2597 #else |
2598 #else |
2598 __READING__(f) |
2599 __READING__(f) |
2599 |
2600 |
2779 !ExternalStream methodsFor:'reimplemented for speed'! |
2780 !ExternalStream methodsFor:'reimplemented for speed'! |
2780 |
2781 |
2781 peekFor:anObject |
2782 peekFor:anObject |
2782 "return true and move past next element, if next == something. |
2783 "return true and move past next element, if next == something. |
2783 Otherwise, stay and return false. False is also returned |
2784 Otherwise, stay and return false. False is also returned |
2784 when EOF is encountered." |
2785 when EOF is encountered. |
|
2786 The argument must be an integer if in binary, a character if in |
|
2787 text mode; only single byte characters are currently supported." |
2785 |
2788 |
2786 %{ /* NOCONTEXT */ |
2789 %{ /* NOCONTEXT */ |
2787 |
2790 |
2788 FILE *f; |
2791 FILE *f; |
2789 int c; |
2792 int c; |
2805 } else { |
2808 } else { |
2806 goto bad; |
2809 goto bad; |
2807 } |
2810 } |
2808 } |
2811 } |
2809 |
2812 |
2810 f = MKFD(fp); |
2813 f = __FILEVal(fp); |
2811 |
2814 |
2812 if (feof(f)) { |
2815 if (feof(f)) { |
2813 _INST(hitEOF) = true; |
2816 _INST(hitEOF) = true; |
2814 RETURN (false); |
2817 RETURN (false); |
2815 } |
2818 } |
2860 ! |
2863 ! |
2861 |
2864 |
2862 nextMatchFor:anObject |
2865 nextMatchFor:anObject |
2863 "skip all objects up-to and including anObject, return anObject on success, |
2866 "skip all objects up-to and including anObject, return anObject on success, |
2864 nil if end-of-file is reached before. The next read operation will return |
2867 nil if end-of-file is reached before. The next read operation will return |
2865 the element after anObject." |
2868 the element after anObject. |
|
2869 Only single byte characters are currently supported." |
2866 |
2870 |
2867 %{ /* NOCONTEXT */ |
2871 %{ /* NOCONTEXT */ |
2868 |
2872 |
2869 FILE *f; |
2873 FILE *f; |
2870 int peekValue, c; |
2874 int peekValue, c; |
2883 } |
2887 } |
2884 } |
2888 } |
2885 |
2889 |
2886 if (peekValue >= 0) { |
2890 if (peekValue >= 0) { |
2887 _INST(position) = nil; |
2891 _INST(position) = nil; |
2888 f = MKFD(fp); |
2892 f = __FILEVal(fp); |
2889 __BEGIN_INTERRUPTABLE__ |
2893 __BEGIN_INTERRUPTABLE__ |
2890 __READING__(f) |
2894 __READING__(f) |
2891 |
2895 |
2892 for (;;) { |
2896 for (;;) { |
2893 do { |
2897 do { |
2929 |
2933 |
2930 _INST(lastErrorNumber) = nil; |
2934 _INST(lastErrorNumber) = nil; |
2931 if (((fp = _INST(filePointer)) != nil) |
2935 if (((fp = _INST(filePointer)) != nil) |
2932 && (_INST(mode) != @symbol(writeonly))) { |
2936 && (_INST(mode) != @symbol(writeonly))) { |
2933 if (_INST(binary) != true) { |
2937 if (_INST(binary) != true) { |
2934 f = MKFD(fp); |
2938 f = __FILEVal(fp); |
2935 |
2939 |
2936 __READING__(f) |
2940 __READING__(f) |
2937 |
2941 |
2938 __BEGIN_INTERRUPTABLE__ |
2942 __BEGIN_INTERRUPTABLE__ |
2939 if (fgets(buffer, sizeof(buffer)-1, f) != NULL) { |
2943 if (fgets(buffer, sizeof(buffer)-1, f) != NULL) { |
3027 |
3031 |
3028 skipThrough:aCharacter |
3032 skipThrough:aCharacter |
3029 "skip all characters up-to and including aCharacter. Return the receiver if |
3033 "skip all characters up-to and including aCharacter. Return the receiver if |
3030 skip was successfull, otherwise (i.e. if not found) return nil. |
3034 skip was successfull, otherwise (i.e. if not found) return nil. |
3031 The next read operation will return the character after aCharacter. |
3035 The next read operation will return the character after aCharacter. |
3032 The argument, aCharacter must be character, or integer wehn in binary mode." |
3036 The argument, aCharacter must be character, or integer when in binary mode. |
|
3037 Only single byte characters are currently supported." |
3033 |
3038 |
3034 %{ /* NOCONTEXT */ |
3039 %{ /* NOCONTEXT */ |
3035 |
3040 |
3036 FILE *f; |
3041 FILE *f; |
3037 REGISTER int c, cSearch; |
3042 REGISTER int c, cSearch; |
3050 cSearch = __intVal(_characterVal(aCharacter)); |
3055 cSearch = __intVal(_characterVal(aCharacter)); |
3051 } |
3056 } |
3052 /* Q: should we just say: "not found" ? */ |
3057 /* Q: should we just say: "not found" ? */ |
3053 if ((cSearch < 0) || (cSearch > 255)) goto badArgument; |
3058 if ((cSearch < 0) || (cSearch > 255)) goto badArgument; |
3054 |
3059 |
3055 f = MKFD(fp); |
3060 f = __FILEVal(fp); |
3056 __READING__(f) |
3061 __READING__(f) |
3057 |
3062 |
3058 __BEGIN_INTERRUPTABLE__ |
3063 __BEGIN_INTERRUPTABLE__ |
3059 while (1) { |
3064 while (1) { |
3060 #ifdef NOTNEEDED |
3065 #ifdef NOTNEEDED |
3115 |
3120 |
3116 _INST(lastErrorNumber) = nil; |
3121 _INST(lastErrorNumber) = nil; |
3117 if (((fp = _INST(filePointer)) != nil) |
3122 if (((fp = _INST(filePointer)) != nil) |
3118 && (_INST(mode) != @symbol(writeonly))) { |
3123 && (_INST(mode) != @symbol(writeonly))) { |
3119 if (_INST(binary) != true) { |
3124 if (_INST(binary) != true) { |
3120 f = MKFD(fp); |
3125 f = __FILEVal(fp); |
3121 |
3126 |
3122 if (feof(f)) { |
3127 if (feof(f)) { |
3123 _INST(hitEOF) = true; |
3128 _INST(hitEOF) = true; |
3124 RETURN ( nil ); |
3129 RETURN ( nil ); |
3125 } |
3130 } |
3184 |
3189 |
3185 _INST(lastErrorNumber) = nil; |
3190 _INST(lastErrorNumber) = nil; |
3186 if (((fp = _INST(filePointer)) != nil) |
3191 if (((fp = _INST(filePointer)) != nil) |
3187 && (_INST(mode) != @symbol(writeonly))) { |
3192 && (_INST(mode) != @symbol(writeonly))) { |
3188 if (_INST(binary) != true) { |
3193 if (_INST(binary) != true) { |
3189 f = MKFD(fp); |
3194 f = __FILEVal(fp); |
3190 __READING__(f) |
3195 __READING__(f) |
3191 |
3196 |
3192 __BEGIN_INTERRUPTABLE__ |
3197 __BEGIN_INTERRUPTABLE__ |
3193 while (1) { |
3198 while (1) { |
3194 |
3199 |
3247 int cnt = 0; |
3252 int cnt = 0; |
3248 OBJ fp; |
3253 OBJ fp; |
3249 |
3254 |
3250 if (((fp = _INST(filePointer)) != nil) |
3255 if (((fp = _INST(filePointer)) != nil) |
3251 && (_INST(mode) != @symbol(writeonly))) { |
3256 && (_INST(mode) != @symbol(writeonly))) { |
3252 f = MKFD(fp); |
3257 f = __FILEVal(fp); |
3253 __BEGIN_INTERRUPTABLE__ |
3258 __BEGIN_INTERRUPTABLE__ |
3254 __READING__(f) |
3259 __READING__(f) |
3255 |
3260 |
3256 /* |
3261 /* |
3257 * skip whiteSpace first ... |
3262 * skip whiteSpace first ... |
3367 free(buffer); |
3372 free(buffer); |
3368 buffer = (char *)0; |
3373 buffer = (char *)0; |
3369 } |
3374 } |
3370 |
3375 |
3371 _INST(lastErrorNumber) = nil; |
3376 _INST(lastErrorNumber) = nil; |
3372 f = MKFD(_INST(filePointer)); |
3377 f = __FILEVal(_INST(filePointer)); |
3373 |
3378 |
3374 __READING__(f) |
3379 __READING__(f) |
3375 |
3380 |
3376 if (feof(f)) { |
3381 if (feof(f)) { |
3377 _INST(hitEOF) = true; |
3382 _INST(hitEOF) = true; |