Merge jv
authorMerge Script
Thu, 30 Apr 2015 07:07:24 +0200
branchjv
changeset 18308 0e48540e3b9f
parent 18304 424139e100b2 (current diff)
parent 18307 c1d97d109f88 (diff)
child 18310 b2a780f62c41
Merge
CharacterEncoder.st
Smalltalk.st
String.st
--- a/CharacterEncoder.st	Wed Apr 29 06:39:38 2015 +0200
+++ b/CharacterEncoder.st	Thu Apr 30 07:07:24 2015 +0200
@@ -289,7 +289,7 @@
         ].
 
         AccessLock critical:[
-            unicodeEncoderClasses := EncoderClassesByName at:#unicode.
+            unicodeEncoderClasses := self encoderClassesByName at:#unicode.
         ].
         unicodeEncoderClasses notNil ifTrue:[
             unicodeEncoderClasses keysAndValuesDo:[:eachEncodingAlias :eachEncoderClassOrName |
@@ -317,9 +317,9 @@
     ].
     enc isNil ifTrue:[
         AccessLock critical:[
-            unicodeEncoderClasses := EncoderClassesByName at:#unicode ifAbsent:nil.
+            unicodeEncoderClasses := self encoderClassesByName at:#unicode ifAbsent:nil.
             unicodeEncoderClasses isNil ifTrue:[
-                EncoderClassesByName at:#unicode put:(unicodeEncoderClasses := Dictionary new).
+                self encoderClassesByName at:#unicode put:(unicodeEncoderClasses := Dictionary new).
             ].
             clsName := unicodeEncoderClasses at:name ifAbsent:nil.
         ].
@@ -345,13 +345,13 @@
     "/ no direct encoder from unicode->name
     "/ search for unicode->any and: any->name
     AccessLock critical:[
-        unicodeEncoderClasses := EncoderClassesByName at:#unicode ifAbsent:nil.
+        unicodeEncoderClasses := self encoderClassesByName at:#unicode ifAbsent:nil.
     ].
     unicodeEncoderClasses keysAndValuesDo:[:eachEncodingAlias :eachEncoderClass |
         |dict2 enc1 enc2|
 
         AccessLock critical:[
-            dict2 := EncoderClassesByName at:eachEncodingAlias ifAbsent:nil.
+            dict2 := self encoderClassesByName at:eachEncodingAlias ifAbsent:nil.
         ].
         dict2 notNil ifTrue:[
             clsName := dict2 at:name ifAbsent:nil.
@@ -376,13 +376,13 @@
         ].
     ].
 
-    EncoderClassesByName keysAndValuesDo:[:encoding1 :dict1 |
+    self encoderClassesByName keysAndValuesDo:[:encoding1 :dict1 |
         dict1 keysAndValuesDo:[:encoding2 :clsName1|
             |clsName2 cls1 cls2 dict2 enc1 enc2|
 
             encoding2 = encodingNameSymbol ifTrue:[
                 AccessLock critical:[
-                    dict2 := EncoderClassesByName at:#unicode.
+                    dict2 := self encoderClassesByName at:#unicode.
                 ].
                 clsName2 := dict2 at:encoding1 ifAbsent:nil.
                 clsName2 notNil ifTrue:[
@@ -471,9 +471,9 @@
         ].
         encoder := encoders at:newEncodingArg ifAbsent:nil.
         encoder isNil ifTrue:[
-            encoderClasses := EncoderClassesByName at:oldEncoding ifAbsent:nil.
+            encoderClasses := self encoderClassesByName at:oldEncoding ifAbsent:nil.
             encoderClasses isNil ifTrue:[
-                EncoderClassesByName at:oldEncoding put:(encoderClasses := Dictionary new).
+                self encoderClassesByName at:oldEncoding put:(encoderClasses := Dictionary new).
             ].
             clsName := encoderClasses at:newEncoding ifAbsent:nil.
             clsName notNil ifTrue:[
@@ -549,17 +549,46 @@
 
 !CharacterEncoder class methodsFor:'class initialization'!
 
+encoderClassesByName
+    EncoderClassesByName isNil ifTrue:[
+        self initializeEncoderClassesByName
+    ].
+    ^ EncoderClassesByName    
+!
+
 initialize
-    |ud|
-
     AccessLock notNil ifTrue:[^ self].  "/ already initialized
 
     AccessLock := RecursionLock new name:'CharacterEncoder'.
     NullEncoderInstance := NullEncoder new.
 
     EncodersByName := Dictionary new.
+    CachedEncoders := Dictionary new.
+
+    self initializeEncoderClassesByName.
+
+    OperatingSystem isUNIXlike ifTrue:[
+        "/Initialize OS system encoder
+        OperatingSystem getCodesetEncoder.
+    ].
+
+    "
+     self initialize
+    "
+
+    "Modified: / 01-04-2011 / 14:30:06 / cg"
+    "Modified (format): / 23-01-2013 / 09:56:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+initializeEncoderClassesByName
+    "initialize the dictionary which maps commonly used names
+     to encoder classes. 
+     This is done, because some encodings come along
+     with different names"
+
+    |ud|
+
     EncoderClassesByName := Dictionary new.
-    CachedEncoders := Dictionary new.
 
     EncoderClassesByName at:#'unicode' put:(ud := Dictionary new).
     ud at:#'fontspecific' put:NullEncoder.    
@@ -717,11 +746,6 @@
         ].
     ].
 
-    OperatingSystem isUNIXlike ifTrue:[
-        "/Initialize OS system encoder
-        OperatingSystem getCodesetEncoder.
-    ].
-
     "
      self initialize
     "
@@ -1715,11 +1739,11 @@
 !CharacterEncoder class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoder.st,v 1.138 2015-03-26 16:21:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoder.st,v 1.139 2015-04-29 11:21:18 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoder.st,v 1.138 2015-03-26 16:21:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoder.st,v 1.139 2015-04-29 11:21:18 cg Exp $'
 ! !
 
 
--- a/Smalltalk.st	Wed Apr 29 06:39:38 2015 +0200
+++ b/Smalltalk.st	Thu Apr 30 07:07:24 2015 +0200
@@ -232,17 +232,17 @@
      right after startup, usually immediately followed by Smalltalk>>start.
 
      Notice:
-        this is NOT called when an image is restarted; in this
-        case the show starts in Smalltalk>>restart."
+	this is NOT called when an image is restarted; in this
+	case the show starts in Smalltalk>>restart."
 
     Compiler := ByteCodeCompiler.
     Compiler isNil ifTrue:[
-        "
-         ByteCodeCompiler is not in the system (i.e. has not been linked in)
-         this allows at least immediate evaluations for runtime systems without compiler
-         NOTICE: a parser is always needed, otherwise we cannot read resource files etc.
-        "
-        Compiler := Parser
+	"
+	 ByteCodeCompiler is not in the system (i.e. has not been linked in)
+	 this allows at least immediate evaluations for runtime systems without compiler
+	 NOTICE: a parser is always needed, otherwise we cannot read resource files etc.
+	"
+	Compiler := Parser
     ].
 
     "/
@@ -281,7 +281,7 @@
     "/ in case, someone needs the objectFileLoader early
     "/
     ObjectFileLoader notNil ifTrue:[
-        ObjectFileLoader initialize.
+	ObjectFileLoader initialize.
     ].
 
     "/
@@ -298,7 +298,7 @@
     "/ flush them here, so they are reread in any case.
     "/ required for some apps, for example to show the menu correctly (see launcher's help menu)
     ApplicationModel notNil ifTrue:[
-        ApplicationModel flushAllClassResources.
+	ApplicationModel flushAllClassResources.
     ].
 
     "/
@@ -603,8 +603,8 @@
      Here, a few specific initializations are done, then the actual initialization is
      done inside an error handler in basicInitializeSystem.
      Notice:
-        this is NOT called when an image is restarted;
-        in this case the show starts in Smalltalk>>restart."
+	this is NOT called when an image is restarted;
+	in this case the show starts in Smalltalk>>restart."
 
     |idx|
 
@@ -613,8 +613,8 @@
     Initializing := true.
     AbstractOperatingSystem initializeConcreteClass.
 
-    CommandLineArguments isNil ifTrue:[
-        CommandLineArguments := #('stx') asOrderedCollection.
+    CommandLineArguments isEmptyOrNil ifTrue:[
+	CommandLineArguments := #('stx') asOrderedCollection.
     ].
     CommandLine := CommandLineArguments copy.
     CommandLineArguments := CommandLineArguments asOrderedCollection.
@@ -626,42 +626,42 @@
     DebuggingStandAlone := false.
 
     StandAlone ifTrue:[
-        InfoPrinting := false.
-        ObjectMemory infoPrinting:false.
-        IgnoreAssertions := true.
-
-        idx := CommandLineArguments indexOf:'--debug'.
-        idx ~~ 0 ifTrue:[
-            DebuggingStandAlone := true.
-        ].
-        DebuggingStandAlone ifTrue:[
-            Inspector := MiniInspector.
-            Debugger := MiniDebugger.
-            IgnoreAssertions := false.
-        ].
+	InfoPrinting := false.
+	ObjectMemory infoPrinting:false.
+	IgnoreAssertions := true.
+
+	idx := CommandLineArguments indexOf:'--debug'.
+	idx ~~ 0 ifTrue:[
+	    DebuggingStandAlone := true.
+	].
+	DebuggingStandAlone ifTrue:[
+	    Inspector := MiniInspector.
+	    Debugger := MiniDebugger.
+	    IgnoreAssertions := false.
+	].
     ] ifFalse:[
-        "/
-        "/ define low-level debugging tools - graphical classes are not prepared yet
-        "/ to handle things.
-        "/ This will bring us into the MiniDebugger when an error occurs during startup.
-        "/
-        Inspector := MiniInspector.
-        Debugger := MiniDebugger.
-        IgnoreAssertions := false.
+	"/
+	"/ define low-level debugging tools - graphical classes are not prepared yet
+	"/ to handle things.
+	"/ This will bring us into the MiniDebugger when an error occurs during startup.
+	"/
+	Inspector := MiniInspector.
+	Debugger := MiniDebugger.
+	IgnoreAssertions := false.
     ].
 
     Error handle:[:ex |
-        StandAlone ifTrue:[
-            DebuggingStandAlone ifFalse:[
-                'Startup Error - use --debug command line argument for more info' errorPrintCR.
-                Smalltalk exit:1.
-            ].
-            'Startup Error' errorPrintCR.
-            thisContext fullPrintAll.
-        ].
-        ex reject.
+	StandAlone ifTrue:[
+	    DebuggingStandAlone ifFalse:[
+		'Startup Error - use --debug command line argument for more info' errorPrintCR.
+		Smalltalk exit:1.
+	    ].
+	    'Startup Error' errorPrintCR.
+	    thisContext fullPrintAll.
+	].
+	ex reject.
     ] do:[
-        self basicInitializeSystem
+	self basicInitializeSystem
     ].
 
     "Modified: / 12-10-2010 / 11:27:47 / cg"
@@ -8223,11 +8223,11 @@
 !Smalltalk class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1124 2015-04-27 14:16:56 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1125 2015-04-29 11:23:35 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1124 2015-04-27 14:16:56 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1125 2015-04-29 11:23:35 cg Exp $'
 !
 
 version_HG
@@ -8238,4 +8238,3 @@
 version_SVN
     ^ '$ Id: Smalltalk.st 10648 2011-06-23 15:55:10Z vranyj1  $'
 ! !
-
--- a/String.st	Wed Apr 29 06:39:38 2015 +0200
+++ b/String.st	Thu Apr 30 07:07:24 2015 +0200
@@ -922,14 +922,24 @@
      - reimplemented here for speed"
 
 %{  /* NOCONTEXT */
-#undef __UNROLL_LOOPS__
-#undef FAST_MEMCHR
-#define V2
+#ifdef __SCHTEAM__
+    if (start.isSmallInteger()
+     && aCharacter.isSTCharacter()) {
+	int idx1Based = start.intValue();   // st index is 1 based
+	int jIdx = self.asString().indexOf(aCharacter.charValue(), idx1Based-1);
+
+	return context._RETURN( jIdx+1 );    // st index is 1 based
+    }
+
+#else
+# undef __UNROLL_LOOPS__
+# undef FAST_MEMCHR
+# define V2
 
     REGISTER unsigned char *cp;
-#ifdef FAST_MEMCHR
+# ifdef FAST_MEMCHR
     REGISTER unsigned char *ncp;
-#endif
+# endif
     REGISTER INT index;
     REGISTER unsigned byteValue;
     int last;
@@ -950,13 +960,13 @@
 			last -= numInstBytes;
 		    }
 		    if (index <= last) {
-#ifdef FAST_MEMCHR
+# ifdef FAST_MEMCHR
 			ncp = (unsigned char *) memchr(cp+index-1, byteValue, last+1-index);
 			if (ncp) {
 			    RETURN ( __mkSmallInteger(ncp - cp + 1) );
 			}
-#else
-# ifdef __UNROLL_LOOPS__
+# else
+#  ifdef __UNROLL_LOOPS__
 			{
 			    int last3 = last-3;
 
@@ -967,15 +977,15 @@
 				if (cp[index-1+3] == byteValue) { RETURN ( __mkSmallInteger(index+3) ); }
 			    }
 			}
-# endif
-# ifdef V1
+#  endif
+#  ifdef V1
 			for (; index <= last; index++) {
 			    if (cp[index-1] == byteValue) {
 				RETURN ( __mkSmallInteger(index) );
 			    }
 			}
-# endif
-# ifdef V2
+#  endif
+#  ifdef V2
 			{
 			    // see bit twiddling hacks
 #                           define hasZeroByte(v) (((v) - 0x01010101UL) & ~(v) & 0x80808080UL)
@@ -1000,15 +1010,16 @@
 				index++;
 			    }
 			}
+#  endif
 # endif
-#endif
 		    }
 		}
 	    }
 	    RETURN ( __mkSmallInteger(0) );
 	}
     }
-#undef V2
+# undef V2
+#endif /* not SCHTEAM */
 %}.
     ^ super indexOf:aCharacter startingAt:start
 
@@ -4310,9 +4321,9 @@
 !String class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.336 2015-04-26 11:18:39 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.337 2015-04-29 11:22:57 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.336 2015-04-26 11:18:39 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.337 2015-04-29 11:22:57 cg Exp $'
 ! !