PositionableStream.st
changeset 517 c8fae50c2cc5
parent 432 5815c61da8a2
child 530 07d0bce293c9
--- a/PositionableStream.st	Thu Nov 09 15:15:06 1995 +0100
+++ b/PositionableStream.st	Fri Nov 10 16:11:38 1995 +0100
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.31 1995-09-13 18:52:44 claus Exp $
+$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.32 1995-11-10 15:11:38 cg Exp $
 '!
 
 !PositionableStream class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.31 1995-09-13 18:52:44 claus Exp $
+$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.32 1995-11-10 15:11:38 cg Exp $
 "
 !
 
@@ -335,15 +335,16 @@
      Its no incompatibility, since inline primitives are an ST/X special
      anyway."
 
-    |sep gotPercent inPrimitive character
+    |sep stopChars inPrimitive character
      index    "{ Class:SmallInteger }"
      endIndex "{ Class:SmallInteger }"
      stop     "{ Class:SmallInteger }"
      next     "{ Class:SmallInteger }"|
 
     sep := ChunkSeparator.
+    stopChars := '{}' copyWith:sep.
+
     inPrimitive := false.
-    gotPercent := false.
     index := 1.
     endIndex := aString size.
     stop := endIndex + 1.
@@ -353,13 +354,7 @@
 	 find position of next interresting character; 
 	 output stuff up to that one in one piece
 	"
-	next := aString indexOf:$% startingAt:index ifAbsent:stop.
-	next := next min:
-		(aString indexOf:${ startingAt:index ifAbsent:stop).
-	next := next min:
-		(aString indexOf:$} startingAt:index ifAbsent:stop).
-	next := next min:
-		(aString indexOf:sep startingAt:index ifAbsent:stop).
+	next := aString indexOfAny:stopChars startingAt:index ifAbsent:stop.
 
 	((index == 1) and:[next == stop]) ifTrue:[
 	    self nextPutAll:aString
@@ -371,27 +366,27 @@
 	(index <= endIndex) ifTrue:[
 	    character := aString at:index.
 
-	    (character == $% ) ifTrue:[
-		gotPercent := true
+	    (character == ${ ) ifTrue:[
+		"/ starts a primitive
+		((index > 1) and:[(aString at:index-1) == $%]) ifTrue:[
+		    inPrimitive := true
+		]
 	    ] ifFalse:[
-		(character == ${ ) ifTrue:[
-		    gotPercent ifTrue:[
-			inPrimitive := true
+		"/ ends a primitive
+		(character == $} ) ifTrue:[
+		    ((index > 1) and:[(aString at:index-1) == $%]) ifTrue:[
+			inPrimitive := false
 		    ]
 		] ifFalse:[
-		    (character == $} ) ifTrue:[
-			gotPercent ifTrue:[
-			    inPrimitive := false
-			]
-		    ] ifFalse:[
-			inPrimitive ifFalse:[
-			    (character == sep) ifTrue:[
-				self nextPut:sep
-			    ]
+		    "/
+		    "/ exclas have to be doubled - except if within a primitive
+		    "/
+		    inPrimitive ifFalse:[
+			(character == sep) ifTrue:[
+			    self nextPut:sep
 			]
 		    ]
-		].
-		gotPercent := false
+		]
 	    ].
 
 	    self nextPut:character.
@@ -399,6 +394,8 @@
 	]
     ].
     self nextPut:sep
+
+    "Modified: 10.11.1995 / 16:04:49 / cg"
 ! !
 
 !PositionableStream methodsFor:'fileIn'!