ObjFW  Diff

Differences From Artifact [65cd40e6d2]:

To Artifact [91fefa5006]:

  • File src/OFApplication.m — part of check-in [c5e7dd679b] at 2013-09-17 16:12:37 on branch trunk — Work around Android bugs.

    Includes:
    * Check environ against NULL before using it, since Android sets it to
    NULL.
    * Cast st_size of struct stat to off_t. Android uses long long for
    st_size as its off_t is only 32 bit, but st_size should be off_t
    according to POSIX.
    * Android's strtod() does not accept 0x, as specified by C99. Thus,
    the test is disabled if __ANDROID__ is defined. (user: js, size: 9892) [annotate] [blame] [check-ins using]


220
221
222
223
224
225
226

227
228
229





230
231

232
233
234
235
236
237





238
239
240
241
242
243
244
245







246
247
248


249
250


251
252
253
254
255
256
257
220
221
222
223
224
225
226
227



228
229
230
231
232
233

234
235





236
237
238
239
240
241







242
243
244
245
246
247
248
249


250
251
252

253
254
255
256
257
258
259
260
261







+
-
-
-
+
+
+
+
+

-
+

-
-
-
-
-
+
+
+
+
+

-
-
-
-
-
-
-
+
+
+
+
+
+
+

-
-
+
+

-
+
+







					forKey: key];

			objc_autoreleasePoolPop(pool);
		}

		FreeEnvironmentStringsW(env);
#elif !defined(OF_IOS)
		if (env != NULL) {
		for (; *env != NULL; env++) {
			OFString *key, *value;
			char *sep;
			for (; *env != NULL; env++) {
				OFString *key, *value;
				char *sep;
				const of_string_encoding_t encoding =
				    OF_STRING_ENCODING_NATIVE;

			pool = objc_autoreleasePoolPush();
				pool = objc_autoreleasePoolPush();

			if ((sep = strchr(*env, '=')) == NULL) {
				fprintf(stderr, "Warning: Invalid environment "
				    "variable: %s\n", *env);
				continue;
			}
				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];
				key = [OFString
				    stringWithCString: *env
					     encoding: encoding
					       length: sep - *env];
				value = [OFString
				    stringWithCString: sep + 1
					     encoding: encoding];

			[environment setObject: value
					forKey: key];
				[environment setObject: value
						forKey: key];

			objc_autoreleasePoolPop(pool);
				objc_autoreleasePoolPop(pool);
			}
		}
#else
		/*
		 * iOS does not provide environ and Apple does not allow using
		 * _NSGetEnviron on iOS. Therefore, we just get a few common
		 * variables from the environment which applications might
		 * expect.