use timegm instead of mktime
authorClaus Gittinger <cg@exept.de>
Sat, 25 Jan 2014 01:30:52 +0100
changeset 15906 8bbbcd3b5765
parent 15905 1975e5cce9c9
child 15907 b6a05f7d463f
use timegm instead of mktime for now: only for OSX; must check for other OSs too.
UnixOperatingSystem.st
--- a/UnixOperatingSystem.st	Thu Jan 23 17:11:54 2014 +0100
+++ b/UnixOperatingSystem.st	Sat Jan 25 01:30:52 2014 +0100
@@ -221,19 +221,20 @@
 
 # ifdef __osx__
 #  include <time.h>
+#  define HAS_TIMEGM
 
 struct tm {
-        int     tm_sec;         /* seconds after the minute [0-60] */
-        int     tm_min;         /* minutes after the hour [0-59] */
-        int     tm_hour;        /* hours since midnight [0-23] */
-        int     tm_mday;        /* day of the month [1-31] */
-        int     tm_mon;         /* months since January [0-11] */
-        int     tm_year;        /* years since 1900 */
-        int     tm_wday;        /* days since Sunday [0-6] */
-        int     tm_yday;        /* days since January 1 [0-365] */
-        int     tm_isdst;       /* Daylight Savings Time flag */
-        long    tm_gmtoff;      /* offset from CUT in seconds */
-        char    *tm_zone;       /* timezone abbreviation */
+	int     tm_sec;         /* seconds after the minute [0-60] */
+	int     tm_min;         /* minutes after the hour [0-59] */
+	int     tm_hour;        /* hours since midnight [0-23] */
+	int     tm_mday;        /* day of the month [1-31] */
+	int     tm_mon;         /* months since January [0-11] */
+	int     tm_year;        /* years since 1900 */
+	int     tm_wday;        /* days since Sunday [0-6] */
+	int     tm_yday;        /* days since January 1 [0-365] */
+	int     tm_isdst;       /* Daylight Savings Time flag */
+	long    tm_gmtoff;      /* offset from CUT in seconds */
+	char    *tm_zone;       /* timezone abbreviation */
 };
 
 #  include <crt_externs.h>
@@ -1016,9 +1017,9 @@
     "initialize the codeset, we are running under.
      The codeset is determined from the environment.
      The LC_CTYPE locale is set from the environment as a side effect."
-    
+
     |codeset|
-    
+
 %{
 #include <langinfo.h>
     char *__codeset;
@@ -1026,16 +1027,16 @@
     setlocale(LC_CTYPE, "");
     __codeset = nl_langinfo(CODESET);
     if (strlen(__codeset) > 0) {
-        codeset = __MKSTRING(__codeset);
+	codeset = __MKSTRING(__codeset);
     }
 %}.
     codeset notNil ifTrue:[
-        codeset := codeset asLowercase.
-        codeset = 'utf-8' ifTrue:[
-            codeset := #utf8.
-        ] ifFalse:[
-            codeset := codeset asSymbol.
-        ].
+	codeset := codeset asLowercase.
+	codeset = 'utf-8' ifTrue:[
+	    codeset := #utf8.
+	] ifFalse:[
+	    codeset := codeset asSymbol.
+	].
     ].
     Codeset := codeset.
     ^ codeset.
@@ -1049,7 +1050,7 @@
     "catch image restart and flush some cached data"
 
     something == #earlyRestart ifTrue:[
-        self initializeCachedData
+	self initializeCachedData
     ]
 
     "Created: / 15.6.1996 / 15:22:37 / cg"
@@ -4056,26 +4057,26 @@
 
     if (__isSmallInteger(aFileDescriptor)) {
 # ifdef TRACE_STAT_CALLS
-        printf("fstat on '%d' for accessMode\n", __smallIntegerVal(aFileDescriptor));
-# endif
-        __BEGIN_INTERRUPTABLE__
-        do {
-            ret = fstat(__smallIntegerVal(aFileDescriptor), &buf);
-        } while ((ret < 0) && (errno == EINTR));
-        __END_INTERRUPTABLE__
-
-        if (ret < 0) {
-            @global(LastErrorNumber) = __mkSmallInteger(errno);
-            RETURN ( nil );
-        }
-        RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
+	printf("fstat on '%d' for accessMode\n", __smallIntegerVal(aFileDescriptor));
+# endif
+	__BEGIN_INTERRUPTABLE__
+	do {
+	    ret = fstat(__smallIntegerVal(aFileDescriptor), &buf);
+	} while ((ret < 0) && (errno == EINTR));
+	__END_INTERRUPTABLE__
+
+	if (ret < 0) {
+	    @global(LastErrorNumber) = __mkSmallInteger(errno);
+	    RETURN ( nil );
+	}
+	RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
     }
 %}.
    ^ self primitiveFailed
 
    "
     '/' asFilename readingFileDo:[:s|
-        (OperatingSystem accessModeOfFd:s fileDescriptor) printStringRadix:8
+	(OperatingSystem accessModeOfFd:s fileDescriptor) printStringRadix:8
     ].
    "
 !
@@ -4119,16 +4120,16 @@
     int ret;
 
     if (__isSmallInteger(aFileDescriptor) && __isSmallInteger(modeBits)) {
-        __BEGIN_INTERRUPTABLE__
-        do {
-            ret = fchmod(__smallIntegerVal(aFileDescriptor), __intVal(modeBits));
-        } while (ret < 0 && errno == EINTR);
-        __END_INTERRUPTABLE__
-        if (ret < 0) {
-            @global(LastErrorNumber) = __mkSmallInteger(errno);
-            RETURN ( false );
-        }
-        RETURN ( true );
+	__BEGIN_INTERRUPTABLE__
+	do {
+	    ret = fchmod(__smallIntegerVal(aFileDescriptor), __intVal(modeBits));
+	} while (ret < 0 && errno == EINTR);
+	__END_INTERRUPTABLE__
+	if (ret < 0) {
+	    @global(LastErrorNumber) = __mkSmallInteger(errno);
+	    RETURN ( false );
+	}
+	RETURN ( true );
     }
 %}.
     ^ self primitiveFailed
@@ -7037,16 +7038,16 @@
 !
 
 getNetworkAddressInfo
-    "return a Dictionary of network interface information. 
-        key -> name of interface
-        value -> a Set of network address 
-                information for the interface - a dictionaries containing the 
-                information about the configuration of each interface in the system. 
-                The dictionary keys are:
-                    #address
-                    #netmask
-                    #flags
-                    #destAddress"
+    "return a Dictionary of network interface information.
+	key -> name of interface
+	value -> a Set of network address
+		information for the interface - a dictionaries containing the
+		information about the configuration of each interface in the system.
+		The dictionary keys are:
+		    #address
+		    #netmask
+		    #flags
+		    #destAddress"
 
     |returnArray addressArray nameArray noOfIf retDictionary error retIndex|
 
@@ -7066,8 +7067,8 @@
     OBJ t;
 
     if (getifaddrs(&ifap) < 0) {
-        error = __MKSTRING("getifaddrs() failed");
-        goto out;
+	error = __MKSTRING("getifaddrs() failed");
+	goto out;
     }
 
     for (ifaLoop = ifap; ifaLoop != 0; ifaLoop = ifaLoop->ifa_next) n_ifa++;
@@ -7075,49 +7076,49 @@
     returnArray = __ARRAY_NEW_INT(n_ifa*5);
 
     if (returnArray == nil) {
-        /* Creating a string wouldn't work here */
-        error = @symbol(allocationFailure);
-        goto bad;
+	/* Creating a string wouldn't work here */
+	error = @symbol(allocationFailure);
+	goto bad;
     }
 
     for (ifaLoop = ifap; ifaLoop != 0; ifaLoop = ifaLoop->ifa_next) {
-        int family, len;
-
-        if (ifaLoop->ifa_addr == 0)
-               continue;
-        family = ifaLoop->ifa_addr->sa_family;
-        switch (family) {
-        case AF_INET:
-            len = sizeof(struct sockaddr_in);
-            break;
-        case AF_INET6:
-            len = sizeof(struct sockaddr_in6);
-            break;
+	int family, len;
+
+	if (ifaLoop->ifa_addr == 0)
+	       continue;
+	family = ifaLoop->ifa_addr->sa_family;
+	switch (family) {
+	case AF_INET:
+	    len = sizeof(struct sockaddr_in);
+	    break;
+	case AF_INET6:
+	    len = sizeof(struct sockaddr_in6);
+	    break;
 #if 0
-        case AF_PACKET:
-            len = sizeof(sockaddr_ll);
-            break;
-#endif
-        default:
-            /* skip */
-            continue;
-        };
-        t = __MKSTRING(ifaLoop->ifa_name);
-        __arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
-        t = __MKUINT(ifaLoop->ifa_flags);
-        __arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
-        t = __MKBYTEARRAY((char *)ifaLoop->ifa_addr, len);
-        __arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
-        if (ifaLoop->ifa_netmask != 0) {
-            t = __MKBYTEARRAY((char *)ifaLoop->ifa_netmask, len);
-            __arrayVal(returnArray)[retI] = t; __STORE(returnArray, t);
-        }
-        retI++;
-        if (ifaLoop->ifa_dstaddr != 0) {
-            t = __MKBYTEARRAY((char *)ifaLoop->ifa_dstaddr, len);
-            __arrayVal(returnArray)[retI] = t; __STORE(returnArray, t);
-        }
-        retI++;
+	case AF_PACKET:
+	    len = sizeof(sockaddr_ll);
+	    break;
+#endif
+	default:
+	    /* skip */
+	    continue;
+	};
+	t = __MKSTRING(ifaLoop->ifa_name);
+	__arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
+	t = __MKUINT(ifaLoop->ifa_flags);
+	__arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
+	t = __MKBYTEARRAY((char *)ifaLoop->ifa_addr, len);
+	__arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
+	if (ifaLoop->ifa_netmask != 0) {
+	    t = __MKBYTEARRAY((char *)ifaLoop->ifa_netmask, len);
+	    __arrayVal(returnArray)[retI] = t; __STORE(returnArray, t);
+	}
+	retI++;
+	if (ifaLoop->ifa_dstaddr != 0) {
+	    t = __MKBYTEARRAY((char *)ifaLoop->ifa_dstaddr, len);
+	    __arrayVal(returnArray)[retI] = t; __STORE(returnArray, t);
+	}
+	retI++;
     }
 
     noOfIf = __mkSmallInteger(n_ifa);
@@ -7142,7 +7143,7 @@
 
     afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
     if (afinet_socket < 0) {
-        goto bad;
+	goto bad;
     }
 
     /*
@@ -7153,9 +7154,9 @@
     ifc.ifc_buf = (caddr_t) buf;
 
     if (ioctl (afinet_socket, SIOCGIFCONF, (caddr_t) &ifc) < 0) {
-        close(afinet_socket);
-        error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
-        goto bad;
+	close(afinet_socket);
+	error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
+	goto bad;
     }
 
     n_ifs = ifc.ifc_len / sizeof (struct ifreq);
@@ -7164,9 +7165,9 @@
     addressArray = __ARRAY_NEW_INT(n_ifs);
 
     if (nameArray == nil || addressArray == nil) {
-        /* Creating a string wouldn/t work here */
-        error = @symbol(allocationFailure);
-        goto bad;
+	/* Creating a string wouldn/t work here */
+	error = @symbol(allocationFailure);
+	goto bad;
     }
 
     /*
@@ -7176,27 +7177,27 @@
     countOfIf = 0;
 
     for (i=0, ifr = ifc.ifc_req; i < n_ifs; i++, ifr++) {
-        /*
-        ** Get address for this interface
-        */
-        memset (&ifreq, 0, sizeof(ifreq));
-        memcpy (ifreq.ifr_name, ifr->ifr_name, sizeof(ifr->ifr_name));
-        if (ioctl (afinet_socket, SIOCGIFADDR, &ifreq) >= 0) {
-            t = __MKBYTEARRAY((char *)&ifreq.ifr_addr, sizeof(ifreq.ifr_addr));
-            __arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
-            t = __MKSTRING(&ifreq.ifr_name);
-            __arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
-            countOfIf++;
-        } else {
-            fprintf(stderr, "SIOCGIFADDR failed: %s\n", errno);
-        }
-        error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
+	/*
+	** Get address for this interface
+	*/
+	memset (&ifreq, 0, sizeof(ifreq));
+	memcpy (ifreq.ifr_name, ifr->ifr_name, sizeof(ifr->ifr_name));
+	if (ioctl (afinet_socket, SIOCGIFADDR, &ifreq) >= 0) {
+	    t = __MKBYTEARRAY((char *)&ifreq.ifr_addr, sizeof(ifreq.ifr_addr));
+	    __arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
+	    t = __MKSTRING(&ifreq.ifr_name);
+	    __arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
+	    countOfIf++;
+	} else {
+	    fprintf(stderr, "SIOCGIFADDR failed: %s\n", errno);
+	}
+	error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
     }
 
     noOfIf = __mkSmallInteger(countOfIf);
 bad:
     if (afinet_socket >= 0)
-        close(afinet_socket);
+	close(afinet_socket);
 #else
     error = @symbol(notSupported);
 #endif /* defined(SIOCGIFADDR) */
@@ -7205,35 +7206,35 @@
 
     retDictionary := Dictionary new:noOfIf.
     error notNil ifTrue:[
-        self primitiveFailed:error.
-        "return empty dictionary if proceeding from error"
-        ^  retDictionary.
+	self primitiveFailed:error.
+	"return empty dictionary if proceeding from error"
+	^  retDictionary.
     ].
 
     retIndex := 1.
 
     1 to:noOfIf do:[:cnt|
-        |name addressBytes set dict|
-
-        name := returnArray at:retIndex.
-        addressBytes := returnArray at:retIndex+2.
-
-        addressBytes notNil ifTrue:[
-            set := retDictionary at:name ifAbsentPut:[Set new].
-            dict := Dictionary new:5.
-            dict at:#flags put:(returnArray at:retIndex+1).
-            dict at:#address put:(SocketAddress fromBytes:addressBytes).
-            addressBytes := returnArray at:retIndex+3.
-            addressBytes notNil ifTrue:[
-                dict at:#netMask put:(SocketAddress fromBytes:addressBytes).
-            ].
-            addressBytes := returnArray at:retIndex+4.
-            addressBytes notNil ifTrue:[
-                dict at:#destAddress put:(SocketAddress fromBytes:addressBytes).
-            ].
-            set add:dict.
-        ].
-        retIndex := retIndex + 5.
+	|name addressBytes set dict|
+
+	name := returnArray at:retIndex.
+	addressBytes := returnArray at:retIndex+2.
+
+	addressBytes notNil ifTrue:[
+	    set := retDictionary at:name ifAbsentPut:[Set new].
+	    dict := Dictionary new:5.
+	    dict at:#flags put:(returnArray at:retIndex+1).
+	    dict at:#address put:(SocketAddress fromBytes:addressBytes).
+	    addressBytes := returnArray at:retIndex+3.
+	    addressBytes notNil ifTrue:[
+		dict at:#netMask put:(SocketAddress fromBytes:addressBytes).
+	    ].
+	    addressBytes := returnArray at:retIndex+4.
+	    addressBytes notNil ifTrue:[
+		dict at:#destAddress put:(SocketAddress fromBytes:addressBytes).
+	    ].
+	    set add:dict.
+	].
+	retIndex := retIndex + 5.
     ].
 
     ^ retDictionary
@@ -8559,57 +8560,57 @@
     "
 !
 
-setLocale:categorySymbol to:localeStringOrNil 
+setLocale:categorySymbol to:localeStringOrNil
     "set (and get) the locale for categorySymbol (e.g. #LC_ALL, #LC_CTYPE,....).
      If localeStringOrNil is nil, nothing is set.
      If localeStringOrNil is empty, the locale for categorySymbol ist set from the environment.
      If localeStringOrNil is 'C', the locale for categorySymbol ist set to the default.
      If localeStringOrNil is to a locale name, the locale for categorySymbol ist set.
      The current locale setting is returned."
-    
+
     |locale error|
-    
+
 %{
     int __category;
     char *__locale, *ret;
 
     if (categorySymbol == @symbol(LC_ALL)) {
-        __category = LC_ALL;
+	__category = LC_ALL;
     } else if (categorySymbol == @symbol(LC_COLLATE)) {
-        __category = LC_COLLATE;
+	__category = LC_COLLATE;
     } else if (categorySymbol == @symbol(LC_CTYPE)) {
-        __category = LC_CTYPE;
+	__category = LC_CTYPE;
     } else if (categorySymbol == @symbol(LC_MESSAGES)) {
-        __category = LC_MESSAGES;
+	__category = LC_MESSAGES;
     } else if (categorySymbol == @symbol(LC_MONETARY)) {
-        __category = LC_MONETARY;
+	__category = LC_MONETARY;
     } else if (categorySymbol == @symbol(LC_NUMERIC)) {
-        __category = LC_NUMERIC;
+	__category = LC_NUMERIC;
     } else if (categorySymbol == @symbol(LC_TIME)) {
-        __category = LC_TIME;
+	__category = LC_TIME;
     } else {
-        error = @symbol(argument1);
-        goto out;
+	error = @symbol(argument1);
+	goto out;
     }
 
     if (localeStringOrNil == nil) {
-        __locale = 0;
+	__locale = 0;
     } else if (__isStringLike(localeStringOrNil)){
-        __locale = __stringVal(localeStringOrNil);
+	__locale = __stringVal(localeStringOrNil);
     } else {
-        error = @symbol(argument1);
-        goto out;
+	error = @symbol(argument1);
+	goto out;
     }
 
     ret = setlocale(__category, __locale);
     if (ret) {
-        locale = __MKSTRING(ret);
+	locale = __MKSTRING(ret);
     }
 
 out:;
 %}.
     locale notNil ifTrue:[
-        ^ locale.
+	^ locale.
     ].
     ^ self primitiveFailed:error.
 
@@ -8999,12 +9000,20 @@
 	tm.tm_mon = __intVal(m) - 1;
 	tm.tm_mday = __intVal(d);
 	tm.tm_isdst = -1;
-
-	t = mktime(&tm);                        /* mktime() interprets tm as localtime */
+#ifdef HAS_TIMEGM
+	if (utcBoolean == true) {               /* convert to utc time */
+	    t = timegm(&tm);                    /* timegm() interprets tm as utc time */
+	} else
+#endif
+	{
+	    t = mktime(&tm);                    /* mktime() interprets tm as localtime */
+	}
 	if ((INT)t != -1) {
+#ifndef HAS_TIMEGM
 	    if (utcBoolean == true) {           /* convert to utc time */
 		t = (INT)t - TIMEZONE(&tm);     /* TIMZONE = seconds westward from 0 */
 	    }
+#endif
 	    osSeconds = __MKINT((INT)t);        /* be careful, t can be negative at the start of the epoch ! */
 	}
     }
@@ -9395,7 +9404,7 @@
 getDesktopDirectory
     "{ Pragma: +optSpace }"
     "return the name of the user's desktop directory."
-    
+
     |home desktop|
 
     home := self getHomeDirectory.
@@ -9632,7 +9641,7 @@
     and:[self getUserID ~~ 0 ]
 
     "
-     self isRunningWithElevatedRootOrAdminRights 
+     self isRunningWithElevatedRootOrAdminRights
     "
 !
 
@@ -11909,88 +11918,88 @@
     type := OperatingSystem socketTypeCodeOf:typeArg.
     proto := self protocolCodeOf:protoArg.
     serviceNameArg notNil ifTrue:[
-        serviceName := serviceNameArg printString.      "convert integer port numbers"
+	serviceName := serviceNameArg printString.      "convert integer port numbers"
     ].
 
     hostName isNil ifTrue:[
-        encodedHostName := nil.
+	encodedHostName := nil.
     ] ifFalse:[
-        encodedHostName := hostName utf8Encoded.
+	encodedHostName := hostName utf8Encoded.
     ].
     (encodedHostName ~~ hostName and:[OperatingSystem getCodeset ~~ #utf8]) ifTrue:[
-        "hostName is not plain ASCII - so this is an IDN domain name. Have to ensure, that the locale is UTF-8.
-         Block interrupt to not affect othe ST/X processes while the locale is changed."
-        |interruptsBlocked oldLocale|
-
-        interruptsBlocked := OperatingSystem blockInterrupts.
-        oldLocale := OperatingSystem setLocale:#'LC_CTYPE' to:nil.
-        OperatingSystem setLocale:#'LC_CTYPE' to:'en_US.UTF-8'.
-        result := self primGetAddressInfo:encodedHostName serviceName:serviceName domainCode:domain socketTypeCode:type protocolCode:proto flags:flags.
-        OperatingSystem setLocale:#'LC_CTYPE' to:oldLocale.
-        interruptsBlocked ifFalse:[
-            OperatingSystem unblockInterrupts.
-        ].
+	"hostName is not plain ASCII - so this is an IDN domain name. Have to ensure, that the locale is UTF-8.
+	 Block interrupt to not affect othe ST/X processes while the locale is changed."
+	|interruptsBlocked oldLocale|
+
+	interruptsBlocked := OperatingSystem blockInterrupts.
+	oldLocale := OperatingSystem setLocale:#'LC_CTYPE' to:nil.
+	OperatingSystem setLocale:#'LC_CTYPE' to:'en_US.UTF-8'.
+	result := self primGetAddressInfo:encodedHostName serviceName:serviceName domainCode:domain socketTypeCode:type protocolCode:proto flags:flags.
+	OperatingSystem setLocale:#'LC_CTYPE' to:oldLocale.
+	interruptsBlocked ifFalse:[
+	    OperatingSystem unblockInterrupts.
+	].
     ] ifFalse:[
-        result := self primGetAddressInfo:encodedHostName serviceName:serviceName domainCode:domain socketTypeCode:type protocolCode:proto flags:flags.
+	result := self primGetAddressInfo:encodedHostName serviceName:serviceName domainCode:domain socketTypeCode:type protocolCode:proto flags:flags.
     ].
     result isArray ifFalse:[
-        |request|
-        request := SocketAddressInfo new
-            domain:domainArg;
-            type:typeArg;
-            protocol:protoArg;
-            canonicalName:hostName;
-            serviceName:serviceName.
-        ^ (HostNameLookupError new
-                parameter:result;
-                messageText:' - ', (result printString);
-                request:request) raiseRequest.
+	|request|
+	request := SocketAddressInfo new
+	    domain:domainArg;
+	    type:typeArg;
+	    protocol:protoArg;
+	    canonicalName:hostName;
+	    serviceName:serviceName.
+	^ (HostNameLookupError new
+		parameter:result;
+		messageText:' - ', (result printString);
+		request:request) raiseRequest.
     ].
     1 to:result size do:[:i |
-        |entry dom info|
-
-        entry := result at:i.
-
-        info := SocketAddressInfo new.
-        info
-            flags:(entry at:1);
-            domain:(dom := OperatingSystem domainSymbolOf:(entry at:2));
-            type:(OperatingSystem socketTypeSymbolOf:(entry at:3));
-            protocol:(self protocolSymbolOf:(entry at:4));
-            socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5));
-            canonicalName:(entry at:6).
-
-        result at:i put:info.
+	|entry dom info|
+
+	entry := result at:i.
+
+	info := SocketAddressInfo new.
+	info
+	    flags:(entry at:1);
+	    domain:(dom := OperatingSystem domainSymbolOf:(entry at:2));
+	    type:(OperatingSystem socketTypeSymbolOf:(entry at:3));
+	    protocol:(self protocolSymbolOf:(entry at:4));
+	    socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5));
+	    canonicalName:(entry at:6).
+
+	result at:i put:info.
     ].
     ^ result
 
     "
      self getAddressInfo:'localhost' serviceName:nil
-            domain:nil type:nil protocol:nil flags:nil
+	    domain:nil type:nil protocol:nil flags:nil
      self getAddressInfo:'localhost' serviceName:nil
-            domain:#inet type:#stream protocol:nil flags:nil
+	    domain:#inet type:#stream protocol:nil flags:nil
      self getAddressInfo:'localhost' serviceName:nil
-            domain:#inet type:#stream protocol:#tcp flags:nil
+	    domain:#inet type:#stream protocol:#tcp flags:nil
      self getAddressInfo:'blurb.exept.de' serviceName:nil
-            domain:#inet type:nil protocol:nil flags:nil
+	    domain:#inet type:nil protocol:nil flags:nil
      self getAddressInfo:'1.2.3.4' serviceName:'bla'
-            domain:#inet type:nil protocol:nil flags:nil
+	    domain:#inet type:nil protocol:nil flags:nil
      self getAddressInfo:'localhost' serviceName:'echo'
-            domain:#inet type:nil protocol:nil flags:nil
+	    domain:#inet type:nil protocol:nil flags:nil
      self getAddressInfo:nil serviceName:'echo'
-            domain:#inet type:nil protocol:nil flags:nil
+	    domain:#inet type:nil protocol:nil flags:nil
      self getAddressInfo:nil serviceName:nil
-            domain:#inet type:nil protocol:nil flags:nil
+	    domain:#inet type:nil protocol:nil flags:nil
      self getAddressInfo:'www.google.de' serviceName:nil
-            domain:nil type:nil protocol:nil flags:nil
+	    domain:nil type:nil protocol:nil flags:nil
      self getAddressInfo:'www.exept.de' serviceName:nil
-            domain:nil type:nil protocol:nil flags:nil
+	    domain:nil type:nil protocol:nil flags:nil
      self getAddressInfo:'www.exept.de' serviceName:nil
-            domain:#'AF_INET' type:nil protocol:nil flags:nil
+	    domain:#'AF_INET' type:nil protocol:nil flags:nil
      self getAddressInfo:'www.exept.de' serviceName:nil
-            domain:#'AF_INET6' type:nil protocol:nil flags:nil
+	    domain:#'AF_INET6' type:nil protocol:nil flags:nil
      self getAddressInfo:'www.baden-württemberg.de' serviceName:nil
-            domain:#'AF_INET' type:#stream protocol:nil flags:nil
+	    domain:#'AF_INET' type:#stream protocol:nil flags:nil
     "
 !
 
@@ -12242,24 +12251,24 @@
     int ret, cnt = 0;
 
     if (hostName == nil) {
-        __hostName = 0;
+	__hostName = 0;
     } else if (__isStringLike(hostName)) {
-        __hostName = __stringVal(hostName);
+	__hostName = __stringVal(hostName);
     } else {
-        error = @symbol(badArgument1);
-        goto out;
+	error = @symbol(badArgument1);
+	goto out;
     }
     if (serviceName == nil) {
-        __serviceName = 0;
+	__serviceName = 0;
     } else if (__isStringLike(serviceName)) {
-        __serviceName = __stringVal(serviceName);
+	__serviceName = __stringVal(serviceName);
     } else {
-        error = @symbol(badArgument2);
-        goto out;
+	error = @symbol(badArgument2);
+	goto out;
     }
     if (__hostName == 0 && __serviceName == 0) {
-        error = @symbol(badArgument);
-        goto out;
+	error = @symbol(badArgument);
+	goto out;
     }
 
 {
@@ -12274,116 +12283,116 @@
     hints.ai_flags = AI_IDN | AI_CANONIDN;      // map non-ascii domain names to IDN format
 #endif
     if (__isSmallInteger(domain))
-        hints.ai_family = __intVal(domain);
+	hints.ai_family = __intVal(domain);
     if (__isSmallInteger(type))
-        hints.ai_socktype = __intVal(type);
+	hints.ai_socktype = __intVal(type);
     if (__isSmallInteger(proto))
-        hints.ai_protocol = __intVal(proto);
+	hints.ai_protocol = __intVal(proto);
     if (__isSmallInteger(flags))
-        hints.ai_flags |= __intVal(flags);
+	hints.ai_flags |= __intVal(flags);
 
     do {
-        /* reload */
-        if (__hostName) {
-            __hostName = __stringVal(hostName);
-        }
-        if (__serviceName) {
-            __serviceName = __stringVal(serviceName);
-        }
+	/* reload */
+	if (__hostName) {
+	    __hostName = __stringVal(hostName);
+	}
+	if (__serviceName) {
+	    __serviceName = __stringVal(serviceName);
+	}
 
 //        __BEGIN_INTERRUPTABLE__
-        ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
+	ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
 //        __END_INTERRUPTABLE__
     } while (ret == EAI_SYSTEM && errno == EINTR);
     if (ret != 0) {
-        switch (ret) {
-        case EAI_FAMILY:
-            error = @symbol(badProtocol);
-            break;
-        case EAI_SOCKTYPE:
-            error = @symbol(badSocketType);
-            break;
-        case EAI_BADFLAGS:
-            error = @symbol(badFlags);
-            break;
-        case EAI_NONAME:
-            error = @symbol(unknownHost);
-            break;
-        case EAI_SERVICE:
-            error = @symbol(unknownService);
-            break;
+	switch (ret) {
+	case EAI_FAMILY:
+	    error = @symbol(badProtocol);
+	    break;
+	case EAI_SOCKTYPE:
+	    error = @symbol(badSocketType);
+	    break;
+	case EAI_BADFLAGS:
+	    error = @symbol(badFlags);
+	    break;
+	case EAI_NONAME:
+	    error = @symbol(unknownHost);
+	    break;
+	case EAI_SERVICE:
+	    error = @symbol(unknownService);
+	    break;
 #ifdef EAI_ADDRFAMILY
-        case EAI_ADDRFAMILY :
-            error = @symbol(unknownHostForProtocol);
-            break;
+	case EAI_ADDRFAMILY :
+	    error = @symbol(unknownHostForProtocol);
+	    break;
 #endif
 #ifdef EAI_NODATA
-        case EAI_NODATA:
-            error = @symbol(noAddress);
-            break;
-#endif
-        case EAI_MEMORY:
-            error = @symbol(allocationFailure);
-            break;
-        case EAI_FAIL:
-            error = @symbol(permanentFailure);
-            break;
-        case EAI_AGAIN:
-            error = @symbol(tryAgain);
-            break;
-        case EAI_SYSTEM:
-            error = @symbol(systemError);
-            break;
-        default:
-            error = @symbol(unknownError);
-        }
-        errorString = __MKSTRING(gai_strerror(ret));
-        goto err;
+	case EAI_NODATA:
+	    error = @symbol(noAddress);
+	    break;
+#endif
+	case EAI_MEMORY:
+	    error = @symbol(allocationFailure);
+	    break;
+	case EAI_FAIL:
+	    error = @symbol(permanentFailure);
+	    break;
+	case EAI_AGAIN:
+	    error = @symbol(tryAgain);
+	    break;
+	case EAI_SYSTEM:
+	    error = @symbol(systemError);
+	    break;
+	default:
+	    error = @symbol(unknownError);
+	}
+	errorString = __MKSTRING(gai_strerror(ret));
+	goto err;
     }
     for (cnt=0, infop=info; infop; infop=infop->ai_next)
-        cnt++;
+	cnt++;
 
     result = __ARRAY_NEW_INT(cnt);
     if (result == nil) {
-        error = @symbol(allocationFailure);
-        goto err;
+	error = @symbol(allocationFailure);
+	goto err;
     }
     for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
-        OBJ o, resp;
-
-        resp = __ARRAY_NEW_INT(6);
-        if (resp == nil) {
-            error = @symbol(allocationFailure);
-            goto err;
-        }
-
-        __ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp);
-
-        __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(infop->ai_flags);
-        __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(infop->ai_family);
-        __ArrayInstPtr(resp)->a_element[2] = __mkSmallInteger(infop->ai_socktype);
-        __ArrayInstPtr(resp)->a_element[3] = __mkSmallInteger(infop->ai_protocol);
-
-        __PROTECT__(resp);
-        o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
-        __UNPROTECT__(resp);
-        if (o == nil) {
-            error = @symbol(allocationFailure);
-            goto err;
-        }
-        memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
+	OBJ o, resp;
+
+	resp = __ARRAY_NEW_INT(6);
+	if (resp == nil) {
+	    error = @symbol(allocationFailure);
+	    goto err;
+	}
+
+	__ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp);
+
+	__ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(infop->ai_flags);
+	__ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(infop->ai_family);
+	__ArrayInstPtr(resp)->a_element[2] = __mkSmallInteger(infop->ai_socktype);
+	__ArrayInstPtr(resp)->a_element[3] = __mkSmallInteger(infop->ai_protocol);
+
+	__PROTECT__(resp);
+	o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
+	__UNPROTECT__(resp);
+	if (o == nil) {
+	    error = @symbol(allocationFailure);
+	    goto err;
+	}
+	memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
        __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
 
-        if (infop->ai_canonname) {
-            __PROTECT__(resp);
-            o = __MKSTRING(infop->ai_canonname);
-            __UNPROTECT__(resp);
-            if (o == nil) {
-                error = @symbol(allocationFailure);
-                goto err;
-            }
-            __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
-        }
+	if (infop->ai_canonname) {
+	    __PROTECT__(resp);
+	    o = __MKSTRING(infop->ai_canonname);
+	    __UNPROTECT__(resp);
+	    if (o == nil) {
+		error = @symbol(allocationFailure);
+		goto err;
+	    }
+	    __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
+	}
     }
 
 err:
@@ -12400,136 +12409,136 @@
     int i;
 
     if (__serviceName) {
-        struct servent *sp;
-        char *__proto = 0;
-
-        if (__isStringLike(protoArg))
-            __proto = __stringVal(protoArg);
-
-        sp = getservbyname(__serviceName, __proto);
-        if (sp == NULL) {
-            errorString = @symbol(unknownService);
-            error = __mkSmallInteger(-3);
-            goto err;
-        }
-        port = sp->s_port;
+	struct servent *sp;
+	char *__proto = 0;
+
+	if (__isStringLike(protoArg))
+	    __proto = __stringVal(protoArg);
+
+	sp = getservbyname(__serviceName, __proto);
+	if (sp == NULL) {
+	    errorString = @symbol(unknownService);
+	    error = __mkSmallInteger(-3);
+	    goto err;
+	}
+	port = sp->s_port;
     }
 
     if (__hostName) {
 #  ifdef USE_H_ERRNO
-        do {
-            if (hostName == nil) {
-                __hostName = 0;
-            } else if (__isStringLike(hostName)) {
-                __hostName = __stringVal(hostName);
-            }
-            /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
-             * uses a static data area
-             */
-            __BEGIN_INTERRUPTABLE__
-            hp = gethostbyname(__hostName);
-            __END_INTERRUPTABLE__
-        } while ((hp == NULL)
-                  && (
-                        (h_errno == TRY_AGAIN)
-                      || errno == EINTR
+	do {
+	    if (hostName == nil) {
+		__hostName = 0;
+	    } else if (__isStringLike(hostName)) {
+		__hostName = __stringVal(hostName);
+	    }
+	    /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
+	     * uses a static data area
+	     */
+	    __BEGIN_INTERRUPTABLE__
+	    hp = gethostbyname(__hostName);
+	    __END_INTERRUPTABLE__
+	} while ((hp == NULL)
+		  && (
+			(h_errno == TRY_AGAIN)
+		      || errno == EINTR
 #   ifdef IRIX5_3
-                      || (errno == ECONNREFUSED)
+		      || (errno == ECONNREFUSED)
 #   endif
-                     )
-        );
-        if (hp == 0) {
-            switch (h_errno) {
-            case HOST_NOT_FOUND:
-                errorString = @symbol(unknownHost);
-                break;
-            case NO_ADDRESS:
-                errorString = @symbol(noAddress);
-                break;
-            case NO_RECOVERY:
-                errorString = @symbol(permanentFailure);
-                break;
-            case TRY_AGAIN:
-                errorString = @symbol(tryAgain);
-                break;
-            default:
-                errorString = @symbol(unknownError);
-                break;
-            }
-            error = __mkSmallInteger(h_errno);
-            goto err;
-        }
+		     )
+	);
+	if (hp == 0) {
+	    switch (h_errno) {
+	    case HOST_NOT_FOUND:
+		errorString = @symbol(unknownHost);
+		break;
+	    case NO_ADDRESS:
+		errorString = @symbol(noAddress);
+		break;
+	    case NO_RECOVERY:
+		errorString = @symbol(permanentFailure);
+		break;
+	    case TRY_AGAIN:
+		errorString = @symbol(tryAgain);
+		break;
+	    default:
+		errorString = @symbol(unknownError);
+		break;
+	    }
+	    error = __mkSmallInteger(h_errno);
+	    goto err;
+	}
 #  else /* !USE_H_ERRNO */
-        hp = gethostbyname(__hostName);
-        if (hp == 0) {
-            errorString = @symbol(unknownHost);
-            error = __mkSmallInteger(-1);
-            goto err;
-        }
+	hp = gethostbyname(__hostName);
+	if (hp == 0) {
+	    errorString = @symbol(unknownHost);
+	    error = __mkSmallInteger(-1);
+	    goto err;
+	}
 #  endif /* !USE_H_ERRNO*/
 
-        if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
-            errorString = @symbol(unknownHost);
-            error = __mkSmallInteger(-2);
-            goto err;
-        }
-
-        for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
-            cnt++;
-        addrpp = hp->h_addr_list;
+	if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
+	    errorString = @symbol(unknownHost);
+	    error = __mkSmallInteger(-2);
+	    goto err;
+	}
+
+	for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
+	    cnt++;
+	addrpp = hp->h_addr_list;
     } else {
-        cnt = 1;
+	cnt = 1;
     }
 
     result = __ARRAY_NEW_INT(cnt);
     if (result == nil) {
-        error = @symbol(allocationFailure);
-        goto err;
+	error = @symbol(allocationFailure);
+	goto err;
     }
 
     for (i = 0; i < cnt; i++) {
-        OBJ o, resp;
-        struct sockaddr_in *sa;
-
-        resp = __ARRAY_NEW_INT(6);
-        if (resp == nil) {
-            error = @symbol(allocationFailure);
-            goto err;
-        }
-
-        __ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp);
-        __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
-        __ArrayInstPtr(resp)->a_element[2] = type; __STORE(result, type);
-        __ArrayInstPtr(resp)->a_element[3] = proto; __STORE(result, proto);
-        __PROTECT__(resp);
-        o = __BYTEARRAY_NEW_INT(sizeof(*sa));
-        __UNPROTECT__(resp);
-        if (o == nil) {
-            error = @symbol(allocationFailure);
-            goto err;
-        }
-        __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
-        sa = (struct sockaddr_in *)__byteArrayVal(o);
-        sa->sin_port = port;
-
-        if (__hostName) {
-            sa->sin_family = hp->h_addrtype;
-            memcpy(&sa->sin_addr, *addrpp, hp->h_length);
-            __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
-            if (hp->h_name) {
-                __PROTECT__(resp);
-                o = __MKSTRING(hp->h_name);
-                __UNPROTECT__(resp);
-                if (o == nil) {
-                    error = @symbol(allocationFailure);
-                    goto err;
-                }
-                __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
-            }
-            addrpp++;
-        } else{
-            __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain);
-        }
+	OBJ o, resp;
+	struct sockaddr_in *sa;
+
+	resp = __ARRAY_NEW_INT(6);
+	if (resp == nil) {
+	    error = @symbol(allocationFailure);
+	    goto err;
+	}
+
+	__ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp);
+	__ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
+	__ArrayInstPtr(resp)->a_element[2] = type; __STORE(result, type);
+	__ArrayInstPtr(resp)->a_element[3] = proto; __STORE(result, proto);
+	__PROTECT__(resp);
+	o = __BYTEARRAY_NEW_INT(sizeof(*sa));
+	__UNPROTECT__(resp);
+	if (o == nil) {
+	    error = @symbol(allocationFailure);
+	    goto err;
+	}
+	__ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
+	sa = (struct sockaddr_in *)__byteArrayVal(o);
+	sa->sin_port = port;
+
+	if (__hostName) {
+	    sa->sin_family = hp->h_addrtype;
+	    memcpy(&sa->sin_addr, *addrpp, hp->h_length);
+	    __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
+	    if (hp->h_name) {
+		__PROTECT__(resp);
+		o = __MKSTRING(hp->h_name);
+		__UNPROTECT__(resp);
+		if (o == nil) {
+		    error = @symbol(allocationFailure);
+		    goto err;
+		}
+		__ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
+	    }
+	    addrpp++;
+	} else{
+	    __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain);
+	}
     }
 
 err:;
@@ -12541,10 +12550,10 @@
 out:;
 %}.
     error notNil ifTrue:[
-        errorString notNil ifTrue:[
-            ^ errorString.
-        ].
-        ^ error.
+	errorString notNil ifTrue:[
+	    ^ errorString.
+	].
+	^ error.
     ].
     ^ result.
 ! !
@@ -13390,11 +13399,11 @@
 !UnixOperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.338 2013-12-17 16:46:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.339 2014-01-25 00:30:52 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.338 2013-12-17 16:46:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.339 2014-01-25 00:30:52 cg Exp $'
 ! !