NonPositionableExternalStream.st
author Stefan Vogel <sv@exept.de>
Thu, 28 Oct 1999 01:58:45 +0200
changeset 4962 0023029d2522
parent 4559 7b454e1d1265
child 5407 d6729266a95b
permissions -rw-r--r--
allow Transcript current if Transcript is stdErr
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
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    23
#include <stdio.h>
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    24
#define _STDIO_H_INCLUDED_
3956
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3808
diff changeset
    25
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    26
%}
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    27
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
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    30
!NonPositionableExternalStream class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    31
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    32
copyright
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    33
"
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    34
 COPYRIGHT (c) 1989 by Claus Gittinger
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    35
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    36
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    37
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    38
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    39
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    40
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    41
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    42
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    43
"
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    44
!
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    45
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    46
documentation
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    47
"
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    48
    This class provides common protocol for all non-positionable,
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    49
    external streams. Concrete subclasses are terminal streams, pipe streams,
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    50
    PrinterStreams, Sockets etc.
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    51
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    52
    There are three special instances of this class, representing stdin,
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    53
    stdout and stderr of the smalltalk/X process (see Unix manuals, if you
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    54
    dont know what those are used for). These special streams are bound to
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    55
    to globals Stdin, Stdout and Stderr at early initialization time
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    56
    (see Smalltalk>>initializeStandardStreams).
159
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
    57
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
    58
    The name of this class is a historical leftover - it should be called
514c749165c3 *** empty log message ***
claus
parents: 93
diff changeset
    59
    'TTYStream' or similar.
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    60
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    61
    [author:]
3808
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
    62
	Claus Gittinger
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    63
"
216
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
    64
! !
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
    65
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    66
!NonPositionableExternalStream class methodsFor:'instance creation'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    67
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    68
forStderr
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    69
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    70
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    71
    "return a NonPositionableExternalStream object for writing to
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    72
     Unixes standard error output file descriptor"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    73
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    74
    StdErrorStream isNil ifTrue:[
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    75
	StdErrorStream := self basicNew initializeForStderr
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    76
    ].
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
    77
    ^ StdErrorStream
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
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    80
forStdin
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    81
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    82
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    83
    "return a NonPositionableExternalStream object for reading from
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    84
     Unixes standard input file descriptor"
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    85
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    86
    StdInStream isNil ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    87
	StdInStream := self basicNew initializeForStdin
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    88
    ].
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    89
    ^ StdInStream
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    90
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    91
a27a279701f8 Initial revision
claus
parents:
diff changeset
    92
forStdout
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    93
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    94
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    95
    "return a NonPositionableExternalStream object for writing to
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    96
     Unixes standard output file descriptor"
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
    97
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
    98
    StdOutStream isNil ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
    99
	StdOutStream := self basicNew initializeForStdout
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
   100
    ].
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
   101
    ^ StdOutStream
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   102
! !
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   103
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   104
!NonPositionableExternalStream methodsFor:'error handling'!
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
positionError
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   107
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   108
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   109
    "notify that this stream has no concept of a position"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   110
4559
7b454e1d1265 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4467
diff changeset
   111
    ^ PositionErrorSignal raiseRequestWith:self
7b454e1d1265 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4467
diff changeset
   112
7b454e1d1265 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4467
diff changeset
   113
    "
7b454e1d1265 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4467
diff changeset
   114
     Stderr positionError
7b454e1d1265 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4467
diff changeset
   115
    "
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   116
! !
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
!NonPositionableExternalStream methodsFor:'positioning'!
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   119
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   120
position
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   121
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   122
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   123
    "catch position - there is none here"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   124
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   125
    ^ self positionError
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   126
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   127
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   128
position:aPosition
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   129
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   130
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   131
    "catch position - there is none here"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   132
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   133
    ^ self positionError
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   134
!
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   135
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   136
skip:numberToSkip
4467
8ddf534d7d81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4392
diff changeset
   137
    "skip count bytes/characters, return the receiver"
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   138
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   139
    "dont know how to unread ..."
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   140
    numberToSkip < 0 ifTrue:[
4467
8ddf534d7d81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4392
diff changeset
   141
        PositionErrorSignal raiseRequest.
8ddf534d7d81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4392
diff changeset
   142
        ^ self 
88
81dacba7a63a *** empty log message ***
claus
parents: 44
diff changeset
   143
    ].
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   144
    numberToSkip timesRepeat:self next
4467
8ddf534d7d81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4392
diff changeset
   145
8ddf534d7d81 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4392
diff changeset
   146
    "Modified: / 30.7.1999 / 12:42:12 / cg"
3173
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   147
!
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   148
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   149
skipThroughAll:aCollection
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   150
    "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
   151
     return nil if not found, the receiver otherwise. 
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   152
     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
   153
     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
   154
     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
   155
     the redefinition from PositionableStream"
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   156
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   157
    |buffer l first idx|
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   158
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   159
    l := aCollection size.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   160
    first := aCollection at:1.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   161
    [self atEnd] whileFalse:[
3808
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   162
	buffer isNil ifTrue:[
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   163
	    buffer := self nextAvailable:l.
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   164
	].
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   165
	buffer = aCollection ifTrue:[
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   166
	    ^ self
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   167
	].
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   168
	idx := buffer indexOf:first startingAt:2.
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   169
	idx == 0 ifTrue:[
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   170
	    buffer := nil
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   171
	] ifFalse:[
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   172
	    buffer := (buffer copyFrom:idx) , (self nextAvailable:(idx - 1))
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   173
	]
3173
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   174
    ].
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   175
    ^ nil
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   176
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
     |s|
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   179
     s := ReadStream on:'12345678901234567890'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   180
     s skipThroughAll:'901'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   181
     s upToEnd                    
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   182
    "
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
     |s|
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   185
     s := ReadStream on:'12345678901234567890'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   186
     s skipThroughAll:'1234'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   187
     s upToEnd                    
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   188
    "
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
     |s|
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   191
     s := ReadStream on:'12345678901234567890'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   192
     s skipThroughAll:'999'.
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   193
     s atEnd                    
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   194
    "
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   195
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   196
    "Modified: / 11.1.1997 / 19:09:06 / cg"
664f2ffa7493 Redefine #skipThroughAll: to not use #position.
Stefan Vogel <sv@exept.de>
parents: 2965
diff changeset
   197
    "Created: / 15.1.1998 / 23:33:37 / stefan"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   198
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   199
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   200
!NonPositionableExternalStream methodsFor:'printing & storing'!
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   201
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   202
printOn:aStream
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   203
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   204
4392
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   205
    "append a user printed representation of the receiver to aStream.
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   206
     The format is suitable for a human - not meant to be read back."
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   207
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   208
    |myName|
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   209
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   210
    self == Stdin ifTrue:[
4392
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   211
        myName := 'Stdin'.
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   212
    ] ifFalse:[
4392
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   213
        self == Stdout ifTrue:[
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   214
            myName := 'Stdout'.
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   215
        ] ifFalse:[
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   216
            self == Stderr ifTrue:[
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   217
                myName := 'Stderr'.
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   218
            ]
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   219
        ]
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   220
    ].
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   221
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   222
    myName notNil ifTrue:[
4392
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   223
        aStream nextPutAll:myName.
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   224
        ^ self
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   225
    ].
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   226
    super printOn:aStream
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   227
!
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   228
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   229
storeOn:aStream
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   230
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   231
213
3b56a17534fd *** empty log message ***
claus
parents: 177
diff changeset
   232
    "append a printed representation of the receiver on aStream, from
3b56a17534fd *** empty log message ***
claus
parents: 177
diff changeset
   233
     which the receiver can be reconstructed."
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   234
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   235
    ((self == Stdin)
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   236
    or:[self == Stdout
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   237
    or:[self == Stderr]]) ifTrue:[
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   238
	^ self printOn:aStream
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   239
    ].
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   240
    super storeOn:aStream
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   241
! !
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   242
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   243
!NonPositionableExternalStream methodsFor:'private'!
360
claus
parents: 269
diff changeset
   244
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   245
initializeForStderr
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   246
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   247
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   248
    "setup for writing to stderr"
269
93162487a94b *** empty log message ***
claus
parents: 216
diff changeset
   249
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   250
    mode := #readwrite.
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   251
    buffered := false.
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   252
%{
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   253
    OBJ fp;
269
93162487a94b *** empty log message ***
claus
parents: 216
diff changeset
   254
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 850
diff changeset
   255
    __INST(filePointer) = fp = __MKOBJ(stderr); __STORE(self, fp);
3808
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   256
#ifdef WIN32
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   257
    __INST(eolMode) = @symbol(crlf);
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   258
#else
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   259
# ifdef xxx__VMS__  /* XXX: to be tested */
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   260
    __INST(eolMode) = @symbol(cr);
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   261
# endif
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   262
#endif
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   263
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   264
%}
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   265
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   266
a27a279701f8 Initial revision
claus
parents:
diff changeset
   267
initializeForStdin
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 reading stdin"
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   271
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   272
    mode := #readonly.
10
claus
parents: 5
diff changeset
   273
    buffered := true.
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(stdin); __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
initializeForStdout
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
    "setup for writing to stdout"
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   285
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   286
    mode := #readwrite.
10
claus
parents: 5
diff changeset
   287
    buffered := false.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   288
%{
477
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   289
    OBJ fp;
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   290
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 850
diff changeset
   291
    __INST(filePointer) = fp = __MKOBJ(stdout); __STORE(self, fp);
3808
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   292
#ifdef WIN32
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   293
    __INST(eolMode) = @symbol(crlf);
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   294
#else
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   295
# ifdef xxx__VMS__   /* XXX: to be tested */
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   296
    __INST(eolMode) = @symbol(cr);
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   297
# endif
5a7866138026 set eolMode of stderr & stdout to #crlf under win32
Claus Gittinger <cg@exept.de>
parents: 3173
diff changeset
   298
#endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   299
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
   300
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   301
a27a279701f8 Initial revision
claus
parents:
diff changeset
   302
reOpen
2965
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   303
    "{ Pragma: +optSpace }"
c5d6d02b0e8c lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   304
44
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   305
    "reopen the stream after an image restart.
b262907c93ea *** empty log message ***
claus
parents: 10
diff changeset
   306
     If I am one of the standard streams, reopen is easy"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   307
477
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   308
    (self == StdInStream) ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   309
	^ self initializeForStdin
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   310
    ].
477
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   311
    (self == StdOutStream) ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   312
	^ self initializeForStdout
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   313
    ].
477
8710aba7876b oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents: 475
diff changeset
   314
    (self == StdErrorStream) ifTrue:[
177
c9f8a4bc4b10 better printString & storeString
claus
parents: 159
diff changeset
   315
	^ self initializeForStderr
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   316
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   317
    ^ super reOpen
a27a279701f8 Initial revision
claus
parents:
diff changeset
   318
! !
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   319
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   320
!NonPositionableExternalStream methodsFor:'queries'!
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   321
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   322
isPositionable
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   323
    "return true, if the stream supports positioning (this one is not)"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   324
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   325
    ^ false
4962
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   326
!
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   327
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   328
current
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   329
    "for compatibility with Transcript - allow Transcript current,
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   330
     even if redirected to the standardError"
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   331
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   332
    self == Transcript ifTrue:[
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   333
	^ self
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   334
    ].
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   335
    ^ super current
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   336
! !
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   337
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   338
!NonPositionableExternalStream class methodsFor:'documentation'!
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   339
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   340
version
4962
0023029d2522 allow Transcript current if Transcript is stdErr
Stefan Vogel <sv@exept.de>
parents: 4559
diff changeset
   341
    ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.38 1999-10-27 23:58:45 stefan Exp $'
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   342
! !