NPExtStr.st
author Claus Gittinger <cg@exept.de>
Thu, 07 May 1998 20:02:53 +0200
changeset 3422 09c13ab58bb2
parent 3173 664f2ffa7493
child 3808 5a7866138026
permissions -rw-r--r--
i386 can do unaligned accesses
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
1344
32a51164b237 No longer a subclass of UnboundedExternalStream, now subclass of ExternalStream.
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
    13
ExternalStream subclass:#NonPositionableExternalStream
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    14
	instanceVariableNames:''
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    15
	classVariableNames:'StdInStream StdOutStream StdErrorStream'
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    16
	poolDictionaries:''
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    17
	category:'Streams-External'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    20
!NonPositionableExternalStream primitiveDefinitions!
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    21
%{
2896
be30640b9012 VMS stuff
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
    22
#ifdef __openVMS__
be30640b9012 VMS stuff
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
    23
# undef __new
be30640b9012 VMS stuff
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
    24
#endif
be30640b9012 VMS stuff
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
    25
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    26
#include <stdio.h>
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    27
#define _STDIO_H_INCLUDED_
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    28
%}
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    29
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    30
! !
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    31
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    32
!NonPositionableExternalStream class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    33
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    34
copyright
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    35
"
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    36
 COPYRIGHT (c) 1989 by Claus Gittinger
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    37
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    38
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    39
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    40
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    41
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    42
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    43
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    44
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    45
"
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    46
!
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    47
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    48
documentation
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    49
"
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    50
    This class provides common protocol for all non-positionable,
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    51
    external streams. Concrete subclasses are terminal streams, pipe streams,
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    52
    PrinterStreams, Sockets etc.
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    53
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    54
    There are three special instances of this class, representing stdin,
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    55
    stdout and stderr of the smalltalk/X process (see Unix manuals, if you
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    56
    dont know what those are used for). These special streams are bound to
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    57
    to globals Stdin, Stdout and Stderr at early initialization time
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    58
    (see Smalltalk>>initializeStandardStreams).
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
    59
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
    60
    The name of this class is a historical leftover - it should be called
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
    61
    'TTYStream' or similar.
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    62
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    63
    [author:]
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    64
        Claus Gittinger
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    65
"
216
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
    66
! !
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
    67
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    68
!NonPositionableExternalStream class methodsFor:'instance creation'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    69
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    70
forStderr
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    71
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    72
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    73
    "return a NonPositionableExternalStream object for writing to
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    74
     Unixes standard error output file descriptor"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    75
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    76
    StdErrorStream isNil ifTrue:[
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    77
	StdErrorStream := self basicNew initializeForStderr
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    78
    ].
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    79
    ^ StdErrorStream
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    80
!
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    81
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    82
forStdin
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    83
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    84
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    85
    "return a NonPositionableExternalStream object for reading from
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    86
     Unixes standard input file descriptor"
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    87
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    88
    StdInStream isNil ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    89
	StdInStream := self basicNew initializeForStdin
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    90
    ].
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    91
    ^ StdInStream
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    92
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    93
a27a279701f8 Initial revision
claus
parents:
diff changeset
    94
forStdout
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    95
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    96
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    97
    "return a NonPositionableExternalStream object for writing to
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    98
     Unixes standard output file descriptor"
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    99
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
   100
    StdOutStream isNil ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   101
	StdOutStream := self basicNew initializeForStdout
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
   102
    ].
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
   103
    ^ StdOutStream
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   104
! !
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   105
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   106
!NonPositionableExternalStream methodsFor:'error handling'!
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   107
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   108
positionError
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   109
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   110
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   111
    "notify that this stream has no concept of a position"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   112
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   113
    ^ PositionErrorSignal raiseRequestWith:self in:thisContext sender
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   114
! !
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   115
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   116
!NonPositionableExternalStream methodsFor:'positioning'!
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   117
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   118
position
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   119
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   120
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   121
    "catch position - there is none here"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   122
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   123
    ^ self positionError
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   124
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   125
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   126
position:aPosition
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   127
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   128
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   129
    "catch position - there is none here"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   130
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   131
    ^ self positionError
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   132
!
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   133
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   134
skip:numberToSkip
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   135
    "skip count objects, return the receiver"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   136
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   137
    "dont know how to unread ..."
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   138
    numberToSkip < 0 ifTrue:[
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   139
	^ self error:'stream is not positionable'
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
   140
    ].
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   141
    numberToSkip timesRepeat:self next
3173
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   142
!
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   143
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   144
skipThroughAll:aCollection
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   145
    "skip for and through the sequence given by the argument, aCollection;
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   146
     return nil if not found, the receiver otherwise. 
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   147
     On a successful match, the next read will return elements after aCollection;
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   148
     if no match was found, the receiver will be positioned at the end.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   149
     Redefined to be the same as Stream>>#skipThroughAll, to undo
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   150
     the redefinition from PositionableStream"
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   151
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   152
    |buffer l first idx|
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   153
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   154
    l := aCollection size.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   155
    first := aCollection at:1.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   156
    [self atEnd] whileFalse:[
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   157
        buffer isNil ifTrue:[
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   158
            buffer := self nextAvailable:l.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   159
        ].
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   160
        buffer = aCollection ifTrue:[
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   161
            ^ self
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   162
        ].
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   163
        idx := buffer indexOf:first startingAt:2.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   164
        idx == 0 ifTrue:[
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   165
            buffer := nil
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   166
        ] ifFalse:[
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   167
            buffer := (buffer copyFrom:idx) , (self nextAvailable:(idx - 1))
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   168
        ]
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   169
    ].
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   170
    ^ nil
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   171
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   172
    "
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   173
     |s|
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   174
     s := ReadStream on:'12345678901234567890'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   175
     s skipThroughAll:'901'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   176
     s upToEnd                    
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   177
    "
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   178
    "
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   179
     |s|
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   180
     s := ReadStream on:'12345678901234567890'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   181
     s skipThroughAll:'1234'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   182
     s upToEnd                    
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   183
    "
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   184
    "
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   185
     |s|
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   186
     s := ReadStream on:'12345678901234567890'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   187
     s skipThroughAll:'999'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   188
     s atEnd                    
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   189
    "
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   190
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   191
    "Modified: / 11.1.1997 / 19:09:06 / cg"
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   192
    "Created: / 15.1.1998 / 23:33:37 / stefan"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   193
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   194
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   195
!NonPositionableExternalStream methodsFor:'printing & storing'!
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   196
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   197
printOn:aStream
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   198
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   199
213
3b56a17534fd *** empty log message ***
claus
parents: 177
diff changeset
   200
    "append a printed representation of the receiver on aStream"
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   201
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   202
    |myName|
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   203
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   204
    self == Stdin ifTrue:[
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   205
	myName := 'Stdin'.
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   206
    ] ifFalse:[
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   207
        self == Stdout ifTrue:[
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   208
	    myName := 'Stdout'.
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   209
        ] ifFalse:[
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   210
            self == Stderr ifTrue:[
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   211
	        myName := 'Stderr'.
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   212
	    ]
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   213
	]
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   214
    ].
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   215
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   216
    myName notNil ifTrue:[
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   217
	aStream nextPutAll:myName.
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   218
	^ self
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   219
    ].
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   220
    super printOn:aStream
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   221
!
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   222
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   223
storeOn:aStream
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   224
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   225
213
3b56a17534fd *** empty log message ***
claus
parents: 177
diff changeset
   226
    "append a printed representation of the receiver on aStream, from
3b56a17534fd *** empty log message ***
claus
parents: 177
diff changeset
   227
     which the receiver can be reconstructed."
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   228
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   229
    ((self == Stdin)
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   230
    or:[self == Stdout
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   231
    or:[self == Stderr]]) ifTrue:[
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   232
	^ self printOn:aStream
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   233
    ].
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   234
    super storeOn:aStream
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   235
! !
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   236
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   237
!NonPositionableExternalStream methodsFor:'private'!
360
claus
parents: 269
diff changeset
   238
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   239
initializeForStderr
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   240
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   241
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   242
    "setup for writing to stderr"
269
93162487a94b *** empty log message ***
claus
parents: 216
diff changeset
   243
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   244
    mode := #readwrite.
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   245
    buffered := false.
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   246
%{
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   247
    OBJ fp;
269
93162487a94b *** empty log message ***
claus
parents: 216
diff changeset
   248
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 850
diff changeset
   249
    __INST(filePointer) = fp = __MKOBJ(stderr); __STORE(self, fp);
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   250
%}
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   251
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   252
a27a279701f8 Initial revision
claus
parents:
diff changeset
   253
initializeForStdin
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   254
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   255
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   256
    "setup for reading stdin"
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   257
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   258
    mode := #readonly.
10
claus
parents: 5
diff changeset
   259
    buffered := true.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   260
%{
477
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   261
    OBJ fp;
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   262
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 850
diff changeset
   263
    __INST(filePointer) = fp = __MKOBJ(stdin); __STORE(self, fp);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   264
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
   265
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   266
a27a279701f8 Initial revision
claus
parents:
diff changeset
   267
initializeForStdout
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   268
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   269
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   270
    "setup for writing to stdout"
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   271
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   272
    mode := #readwrite.
10
claus
parents: 5
diff changeset
   273
    buffered := false.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   274
%{
477
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   275
    OBJ fp;
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   276
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 850
diff changeset
   277
    __INST(filePointer) = fp = __MKOBJ(stdout); __STORE(self, fp);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   278
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
   279
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   280
a27a279701f8 Initial revision
claus
parents:
diff changeset
   281
reOpen
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   282
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   283
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   284
    "reopen the stream after an image restart.
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   285
     If I am one of the standard streams, reopen is easy"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   286
477
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   287
    (self == StdInStream) ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   288
	^ self initializeForStdin
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   289
    ].
477
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   290
    (self == StdOutStream) ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   291
	^ self initializeForStdout
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   292
    ].
477
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   293
    (self == StdErrorStream) ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   294
	^ self initializeForStderr
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   295
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   296
    ^ super reOpen
a27a279701f8 Initial revision
claus
parents:
diff changeset
   297
! !
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   298
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   299
!NonPositionableExternalStream methodsFor:'queries'!
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   300
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   301
isPositionable
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   302
    "return true, if the stream supports positioning (this one is not)"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   303
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   304
    ^ false
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   305
! !
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   306
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   307
!NonPositionableExternalStream class methodsFor:'documentation'!
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   308
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   309
version
3173
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   310
    ^ '$Header: /cvs/stx/stx/libbasic/Attic/NPExtStr.st,v 1.31 1998-01-15 23:30:40 stefan Exp $'
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   311
! !