PositionableStream.st
changeset 517 c8fae50c2cc5
parent 432 5815c61da8a2
child 530 07d0bce293c9
equal deleted inserted replaced
516:17a170eb1112 517:c8fae50c2cc5
    19 
    19 
    20 PositionableStream comment:'
    20 PositionableStream comment:'
    21 COPYRIGHT (c) 1989 by Claus Gittinger
    21 COPYRIGHT (c) 1989 by Claus Gittinger
    22 	      All Rights Reserved
    22 	      All Rights Reserved
    23 
    23 
    24 $Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.31 1995-09-13 18:52:44 claus Exp $
    24 $Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.32 1995-11-10 15:11:38 cg Exp $
    25 '!
    25 '!
    26 
    26 
    27 !PositionableStream class methodsFor:'documentation'!
    27 !PositionableStream class methodsFor:'documentation'!
    28 
    28 
    29 copyright
    29 copyright
    40 "
    40 "
    41 !
    41 !
    42 
    42 
    43 version
    43 version
    44 "
    44 "
    45 $Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.31 1995-09-13 18:52:44 claus Exp $
    45 $Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.32 1995-11-10 15:11:38 cg Exp $
    46 "
    46 "
    47 !
    47 !
    48 
    48 
    49 documentation
    49 documentation
    50 "
    50 "
   333      This modification of the chunk format was done to have primitive
   333      This modification of the chunk format was done to have primitive
   334      code more readable. (since it must be edited using the fileBrowser).
   334      code more readable. (since it must be edited using the fileBrowser).
   335      Its no incompatibility, since inline primitives are an ST/X special
   335      Its no incompatibility, since inline primitives are an ST/X special
   336      anyway."
   336      anyway."
   337 
   337 
   338     |sep gotPercent inPrimitive character
   338     |sep stopChars inPrimitive character
   339      index    "{ Class:SmallInteger }"
   339      index    "{ Class:SmallInteger }"
   340      endIndex "{ Class:SmallInteger }"
   340      endIndex "{ Class:SmallInteger }"
   341      stop     "{ Class:SmallInteger }"
   341      stop     "{ Class:SmallInteger }"
   342      next     "{ Class:SmallInteger }"|
   342      next     "{ Class:SmallInteger }"|
   343 
   343 
   344     sep := ChunkSeparator.
   344     sep := ChunkSeparator.
       
   345     stopChars := '{}' copyWith:sep.
       
   346 
   345     inPrimitive := false.
   347     inPrimitive := false.
   346     gotPercent := false.
       
   347     index := 1.
   348     index := 1.
   348     endIndex := aString size.
   349     endIndex := aString size.
   349     stop := endIndex + 1.
   350     stop := endIndex + 1.
   350 
   351 
   351     [index <= endIndex] whileTrue:[
   352     [index <= endIndex] whileTrue:[
   352 	"
   353 	"
   353 	 find position of next interresting character; 
   354 	 find position of next interresting character; 
   354 	 output stuff up to that one in one piece
   355 	 output stuff up to that one in one piece
   355 	"
   356 	"
   356 	next := aString indexOf:$% startingAt:index ifAbsent:stop.
   357 	next := aString indexOfAny:stopChars startingAt:index ifAbsent:stop.
   357 	next := next min:
       
   358 		(aString indexOf:${ startingAt:index ifAbsent:stop).
       
   359 	next := next min:
       
   360 		(aString indexOf:$} startingAt:index ifAbsent:stop).
       
   361 	next := next min:
       
   362 		(aString indexOf:sep startingAt:index ifAbsent:stop).
       
   363 
   358 
   364 	((index == 1) and:[next == stop]) ifTrue:[
   359 	((index == 1) and:[next == stop]) ifTrue:[
   365 	    self nextPutAll:aString
   360 	    self nextPutAll:aString
   366 	] ifFalse:[
   361 	] ifFalse:[
   367 	    self nextPutAll:aString startingAt:index to:(next - 1)
   362 	    self nextPutAll:aString startingAt:index to:(next - 1)
   369 
   364 
   370 	index := next.
   365 	index := next.
   371 	(index <= endIndex) ifTrue:[
   366 	(index <= endIndex) ifTrue:[
   372 	    character := aString at:index.
   367 	    character := aString at:index.
   373 
   368 
   374 	    (character == $% ) ifTrue:[
   369 	    (character == ${ ) ifTrue:[
   375 		gotPercent := true
   370 		"/ starts a primitive
       
   371 		((index > 1) and:[(aString at:index-1) == $%]) ifTrue:[
       
   372 		    inPrimitive := true
       
   373 		]
   376 	    ] ifFalse:[
   374 	    ] ifFalse:[
   377 		(character == ${ ) ifTrue:[
   375 		"/ ends a primitive
   378 		    gotPercent ifTrue:[
   376 		(character == $} ) ifTrue:[
   379 			inPrimitive := true
   377 		    ((index > 1) and:[(aString at:index-1) == $%]) ifTrue:[
       
   378 			inPrimitive := false
   380 		    ]
   379 		    ]
   381 		] ifFalse:[
   380 		] ifFalse:[
   382 		    (character == $} ) ifTrue:[
   381 		    "/
   383 			gotPercent ifTrue:[
   382 		    "/ exclas have to be doubled - except if within a primitive
   384 			    inPrimitive := false
   383 		    "/
   385 			]
   384 		    inPrimitive ifFalse:[
   386 		    ] ifFalse:[
   385 			(character == sep) ifTrue:[
   387 			inPrimitive ifFalse:[
   386 			    self nextPut:sep
   388 			    (character == sep) ifTrue:[
       
   389 				self nextPut:sep
       
   390 			    ]
       
   391 			]
   387 			]
   392 		    ]
   388 		    ]
   393 		].
   389 		]
   394 		gotPercent := false
       
   395 	    ].
   390 	    ].
   396 
   391 
   397 	    self nextPut:character.
   392 	    self nextPut:character.
   398 	    index := index + 1
   393 	    index := index + 1
   399 	]
   394 	]
   400     ].
   395     ].
   401     self nextPut:sep
   396     self nextPut:sep
       
   397 
       
   398     "Modified: 10.11.1995 / 16:04:49 / cg"
   402 ! !
   399 ! !
   403 
   400 
   404 !PositionableStream methodsFor:'fileIn'!
   401 !PositionableStream methodsFor:'fileIn'!
   405 
   402 
   406 fileIn
   403 fileIn