# HG changeset patch # User Stefan Vogel # Date 1355477392 -3600 # Node ID 32a92bd392dd7ba7fe89e456bb172853833b90f1 # Parent 058231c234cbb2dfc31870d827046c9b42f84f6c class: UnixOperatingSystem changed:6 methods codeset stuff diff -r 058231c234cb -r 32a92bd392dd UnixOperatingSystem.st --- a/UnixOperatingSystem.st Thu Dec 13 19:40:08 2012 +0100 +++ b/UnixOperatingSystem.st Fri Dec 14 10:29:52 2012 +0100 @@ -15,7 +15,8 @@ instanceVariableNames:'' classVariableNames:'HostName DomainName SlowFork ForkFailed CurrentDirectory LastTimeInfo LastTimeInfoSeconds LastTimeInfoMilliseconds - LastTimeInfoIsLocal CachedMountPoints CacheMountPointsTimeStamp CodeSet' + LastTimeInfoIsLocal CachedMountPoints CacheMountPointsTimeStamp + Codeset' poolDictionaries:'' category:'OS-Unix' ! @@ -985,6 +986,7 @@ ForkFailed := false. SlowFork := false. CurrentDirectory := nil. + Codeset := self getCodeset. "Modified: / 11.12.1998 / 16:35:39 / cg" ! @@ -993,16 +995,17 @@ "catch image restart and flush some cached data" something == #earlyRestart ifTrue:[ - " - flush cached data/info - " - HostName := nil. - DomainName := nil. - LastErrorNumber := nil. - PipeFailed := false. - SlowFork := false. - ForkFailed := false. - CurrentDirectory := nil. + " + flush cached data/info + " + HostName := nil. + DomainName := nil. + LastErrorNumber := nil. + PipeFailed := false. + SlowFork := false. + ForkFailed := false. + CurrentDirectory := nil. + Codeset := self getCodeset. ] "Created: / 15.6.1996 / 15:22:37 / cg" @@ -2854,20 +2857,20 @@ |envArray argArray fdArray dirName cnt aCommandPath| - environmentDictionary size ~~ 0 ifTrue:[ + environmentDictionary notEmptyOrNil ifTrue:[ envArray := Array new:environmentDictionary size. cnt := 1. environmentDictionary keysAndValuesDo:[:key :val | val isNil ifTrue:[ - envArray at:cnt put:(key, '=') + envArray at:cnt put:((self encodePath:key), '=') ] ifFalse:[ - envArray at:cnt put:(key, '=', val) + envArray at:cnt put:((self encodePath:key), '=', (self encodePath:val)) ]. cnt := cnt + 1. ]. ]. argColl notNil ifTrue:[ - argArray := argColl asArray + argArray := argColl asArray collect:[:eachArg| self encodePath:eachArg]. ]. fdColl notNil ifTrue:[ fdArray := fdColl asArray @@ -4329,8 +4332,7 @@ |path| - path := self primGetCurrentDirectory. - path := self decodePath:path. + path := self decodePath:self primGetCurrentDirectory. CurrentDirectory := path. ^ path. @@ -6413,27 +6415,34 @@ "Modified: / 5.6.1998 / 18:38:52 / cg" ! -getCodeSet +getCodeset "get the codeset, we are running under" - |codeSet| + |codeset| %{ #include { char *__codeset; + setlocale(LC_ALL, ""); __codeset = nl_langinfo(CODESET); if (strlen(__codeset) > 0) { - codeSet = __MKSTRING(__codeset); + codeset = __MKSTRING(__codeset); } } %}. - CodeSet := codeSet. - ^ codeSet. - - " - OperatingSystem getCodeSet + codeset := codeset asLowercase. + codeset = 'utf-8' ifTrue:[ + codeset := #utf8. + ] ifFalse:[ + codeset := codeset asSymbol. + ]. + Codeset := codeset. + ^ codeset. + + " + OperatingSystem getCodeset " ! @@ -8469,7 +8478,7 @@ so the pathName has been UTF-8 decoded." "linux strings are in UTF8 (in contemporary linux versions)" - encodedPathName notNil ifTrue:[ + (encodedPathName notNil and:[Codeset == #utf8]) ifTrue:[ [ ^ encodedPathName utf8Decoded. ] on:InvalidEncodingError do:[:ex| @@ -8535,7 +8544,10 @@ E.g. linux system calls accept sigle byte strings only, so the pathName has been UTF-8 encoded, before using it in a system call." - ^ pathName utf8Encoded + (pathName notNil and:[Codeset == #utf8]) ifTrue:[ + ^ pathName utf8Encoded. + ]. + ^ pathName ! ! !UnixOperatingSystem class methodsFor:'private'! @@ -13401,11 +13413,11 @@ !UnixOperatingSystem class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.296 2012-12-13 16:25:33 stefan Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.297 2012-12-14 09:29:52 stefan Exp $' ! version_CVS - ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.296 2012-12-13 16:25:33 stefan Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.297 2012-12-14 09:29:52 stefan Exp $' ! ! UnixOperatingSystem initialize!