ObjFW  Check-in [8fe08864f8]

Overview
Comment:Fix incomplete of_char16_t migration.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8fe08864f8879666d2ff95d7eb5de1dd7b315e78e400fa2e08ecdc8df94f0eb4
User & Date: js on 2013-04-09 22:09:15
Other Links: manifest | tags
Context
2013-04-10
16:48
OFXMLParser: Require version in prolog. check-in: 1efd40d895 user: js tags: trunk
2013-04-09
22:09
Fix incomplete of_char16_t migration. check-in: 8fe08864f8 user: js tags: trunk
21:37
Simplify -[OFDictionary all{Keys,Objects}]. check-in: bff98a6244 user: js tags: trunk
Changes

Modified src/OFApplication.m from [1d72ff5c7e] to [87c9d886dc].

148
149
150
151
152
153
154
155

156
157
158
159
160
161
162
148
149
150
151
152
153
154

155
156
157
158
159
160
161
162







-
+








	@try {
		void *pool;
		OFMutableDictionary *environment;
#if defined(__MACH__) && !defined(OF_IOS)
		char **env = *_NSGetEnviron();
#elif defined(__WIN32)
		uint16_t *env;
		of_char16_t *env;
#elif !defined(OF_IOS)
		char **env = environ;
#else
		char *env;
#endif

		environment = [[OFMutableDictionary alloc] init];

Modified src/OFProcess.h from [6ab46f1eca] to [cb05d48dd9].

20
21
22
23
24
25
26

27
28
29
30
31
32
33
34
35
36
37
38
39
20
21
22
23
24
25
26
27
28
29
30
31
32

33
34
35
36
37
38
39







+





-







#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
#endif

#include <sys/types.h>

#import "OFStream.h"
#import "OFString.h"

#ifdef _WIN32
# include <windows.h>
#endif

@class OFString;
@class OFArray;
@class OFDictionary;

/*!
 * @brief A class for stream-like communication with a newly created process.
 */
@interface OFProcess: OFStream
163
164
165
166
167
168
169
170

171
172
173
174
175
176
177
178
179
180
181
163
164
165
166
167
168
169

170
171
172
173
174
175
176
177
178
179
180
181







-
+











      programName: (OFString*)programName
	arguments: (OFArray*)arguments
      environment: (OFDictionary*)environment;

#ifndef _WIN32
- (char**)OF_environmentForDictionary: (OFDictionary*)dictionary;
#else
- (uint16_t*)OF_environmentForDictionary: (OFDictionary*)dictionary;
- (of_char16_t*)OF_environmentForDictionary: (OFDictionary*)dictionary;
#endif

/*!
 * @brief Closes the write direction of the process.
 *
 * This method needs to be called for some programs before data can be read,
 * since some programs don't start processing before the write direction is
 * closed.
 */
- (void)closeForWriting;
@end

Modified src/OFProcess.m from [c2449bdcce] to [4f94efa779].

172
173
174
175
176
177
178
179

180
181
182
183
184
185
186
172
173
174
175
176
177
178

179
180
181
182
183
184
185
186







-
+







		SECURITY_ATTRIBUTES sa;
		PROCESS_INFORMATION pi;
		STARTUPINFOW si;
		void *pool;
		OFMutableString *argumentsString;
		OFEnumerator *enumerator;
		OFString *argument;
		uint16_t *argumentsCopy;
		of_char16_t *argumentsCopy;
		size_t length;

		sa.nLength = sizeof(sa);
		sa.bInheritHandle = TRUE;
		sa.lpSecurityDescriptor = NULL;

		if (!CreatePipe(&_readPipe[0], &_readPipe[1], &sa, 0))
242
243
244
245
246
247
248
249

250
251
252
253
254
255
256
242
243
244
245
246
247
248

249
250
251
252
253
254
255
256







-
+







			[argumentsString appendString: tmp];

			if (containsSpaces)
				[argumentsString appendString: @"\""];
		}

		length = [argumentsString UTF16StringLength];
		argumentsCopy = [self allocMemoryWithSize: sizeof(uint16_t)
		argumentsCopy = [self allocMemoryWithSize: sizeof(of_char16_t)
						    count: length + 1];
		memcpy(argumentsCopy, [argumentsString UTF16String],
		    ([argumentsString UTF16StringLength] + 1) * 2);
		@try {
			if (!CreateProcessW([program UTF16String],
			    argumentsCopy, NULL, NULL, TRUE,
			    CREATE_UNICODE_ENVIRONMENT,
326
327
328
329
330
331
332
333

334
335
336
337
338
339


340
341
342
343
344
345
346
326
327
328
329
330
331
332

333
334
335
336
337


338
339
340
341
342
343
344
345
346







-
+




-
-
+
+







	}

	envp[i] = NULL;

	return envp;
}
#else
- (uint16_t*)OF_environmentForDictionary: (OFDictionary*)environment
- (of_char16_t*)OF_environmentForDictionary: (OFDictionary*)environment
{
	OFDataArray *env = [OFDataArray dataArrayWithItemSize: 2];
	OFEnumerator *keyEnumerator, *objectEnumerator;
	OFString *key, *object;
	const uint16_t equal = '=';
	const uint16_t zero = 0;
	const of_char16_t equal = '=';
	const of_char16_t zero = 0;

	keyEnumerator = [environment keyEnumerator];
	objectEnumerator = [environment objectEnumerator];

	while ((key = [keyEnumerator nextObject]) != nil &&
	    (object = [objectEnumerator nextObject]) != nil) {
		[env addItems: [key UTF16String]

Modified src/OFString+JSONValue.m from [b110ce39ff] to [a402664fc6].

107
108
109
110
111
112
113
114

115
116
117

118
119
120
121
122
123
124
107
108
109
110
111
112
113

114
115
116

117
118
119
120
121
122
123
124







-
+


-
+







		old = *pointer;

		skipWhitespaces(pointer, stop, line);
		skipComment(pointer, stop, line);
	}
}

static inline uint16_t
static inline of_char16_t
parseUnicodeEscape(const char *pointer, const char *stop)
{
	uint16_t ret = 0;
	of_char16_t ret = 0;
	char i;

	if (pointer + 5 >= stop)
		return 0xFFFF;

	if (pointer[0] != '\\' || pointer[1] != 'u')
		return 0xFFFF;
190
191
192
193
194
195
196
197

198
199
200
201
202
203
204
190
191
192
193
194
195
196

197
198
199
200
201
202
203
204







-
+







				break;
			case 't':
				buffer[i++] = '\t';
				(*pointer)++;
				break;
			/* Parse unicode escape sequence */
			case 'u':;
				uint16_t c1, c2;
				of_char16_t c1, c2;
				of_unichar_t c;
				size_t l;

				c1 = parseUnicodeEscape(*pointer - 1, stop);
				if (c1 == 0xFFFF) {
					free(buffer);
					return nil;
309
310
311
312
313
314
315
316

317
318
319
320
321
322
323
309
310
311
312
313
314
315

316
317
318
319
320
321
322
323







-
+







		    (**pointer >= 'A' && **pointer <= 'Z') ||
		    (**pointer >= '0' && **pointer <= '9') ||
		    **pointer == '_' || **pointer == '$' ||
		    (**pointer & 0x80)) {
			buffer[i++] = **pointer;
			(*pointer)++;
		} else if (**pointer == '\\') {
			uint16_t c1, c2;
			of_char16_t c1, c2;
			of_unichar_t c;
			size_t l;

			if (++(*pointer) >= stop || **pointer != 'u') {
				free(buffer);
				return nil;
			}