Overview
Comment: | Win32: Correctly handle Unicode in environment. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
1fb00cc3b46257f300711ffcc505fbf6 |
User & Date: | js on 2013-01-07 23:42:59 |
Other Links: | manifest | tags |
Context
2013-01-08
| ||
03:13 | OFProcess: Correctly handle Unicode env on Win32. check-in: 52f2c17f55 user: js tags: trunk | |
2013-01-07
| ||
23:42 | Win32: Correctly handle Unicode in environment. check-in: 1fb00cc3b4 user: js tags: trunk | |
22:07 | OFString: Zero-terminate UTF-16 strings. check-in: 9d3cd5e5fe user: js tags: trunk | |
Changes
Modified src/OFApplication.m from [35ca9806a3] to [30420d2d38].
︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #import "OFThread.h" #import "OFRunLoop.h" #import "autorelease.h" #if defined(__MACH__) && !defined(OF_IOS) # include <crt_externs.h> #elif !defined(OF_IOS) extern char **environ; #endif static OFApplication *app = nil; static void | > > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #import "OFThread.h" #import "OFRunLoop.h" #import "autorelease.h" #if defined(__MACH__) && !defined(OF_IOS) # include <crt_externs.h> #elif defined(_WIN32) # include <windows.h> #elif !defined(OF_IOS) extern char **environ; #endif static OFApplication *app = nil; static void |
︙ | ︙ | |||
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | { self = [super init]; @try { void *pool; #if defined(__MACH__) && !defined(OF_IOS) char **env = *_NSGetEnviron(); #elif !defined(OF_IOS) char **env = environ; #else char *env; #endif environment = [[OFMutableDictionary alloc] init]; atexit(atexit_handler); | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < > | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | { self = [super init]; @try { void *pool; #if defined(__MACH__) && !defined(OF_IOS) char **env = *_NSGetEnviron(); #elif defined(__WIN32) uint16_t *env; #elif !defined(OF_IOS) char **env = environ; #else char *env; #endif environment = [[OFMutableDictionary alloc] init]; atexit(atexit_handler); #if defined(_WIN32) env = GetEnvironmentStringsW(); while (*env != 0) { OFString *tmp, *key, *value; size_t length, pos; pool = objc_autoreleasePoolPush(); length = of_string_utf16_length(env); tmp = [OFString stringWithUTF16String: env length: length]; env += length + 1; /* * cmd.exe seems to add some special variables which * start with a "=", even though variable names are not * allowed to contain a "=". */ if ([tmp hasPrefix: @"="]) { objc_autoreleasePoolPop(pool); continue; } pos = [tmp rangeOfString: @"="].location; if (pos == OF_NOT_FOUND) { fprintf(stderr, "Warning: Invalid environment " "variable: %s\n", [tmp UTF8String]); continue; } key = [tmp substringWithRange: of_range(0, pos)]; value = [tmp substringWithRange: of_range(pos + 1, [tmp length] - pos - 1)]; [environment setObject: value forKey: key]; objc_autoreleasePoolPop(pool); } FreeEnvironmentStringsW(env); #elif !defined(OF_IOS) for (; *env != NULL; env++) { OFString *key, *value; char *sep; pool = objc_autoreleasePoolPush(); if ((sep = strchr(*env, '=')) == NULL) { fprintf(stderr, "Warning: Invalid environment " "variable: %s\n", *env); continue; } key = [OFString stringWithCString: *env encoding: OF_STRING_ENCODING_NATIVE length: sep - *env]; value = [OFString stringWithCString: sep + 1 encoding: OF_STRING_ENCODING_NATIVE]; [environment setObject: value forKey: key]; objc_autoreleasePoolPop(pool); } #else /* |
︙ | ︙ |