@@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -73,15 +71,13 @@ #endif OF_DIRECT_MEMBERS @interface OFApplication () - (instancetype)of_init OF_METHOD_FAMILY(init); -- (void)of_setArgumentCount: (int *)argc - andArgumentValues: (char **[])argv; +- (void)of_setArgumentCount: (int *)argc andArgumentValues: (char **[])argv; #ifdef OF_WINDOWS -- (void)of_setArgumentCount: (int)argc - andWideArgumentValues: (wchar_t *[])argv; +- (void)of_setArgumentCount: (int)argc andWideArgumentValues: (wchar_t *[])argv; #endif - (void)of_run; @end static OFApplication *app = nil; @@ -116,16 +112,14 @@ app = [[OFApplication alloc] of_init]; #ifdef OF_WINDOWS if ([OFSystemInfo isWindowsNT]) { __wgetmainargs(&wargc, &wargv, &wenvp, _CRT_glob, &si); - [app of_setArgumentCount: wargc - andWideArgumentValues: wargv]; + [app of_setArgumentCount: wargc andWideArgumentValues: wargv]; } else #endif - [app of_setArgumentCount: argc - andArgumentValues: argv]; + [app of_setArgumentCount: argc andArgumentValues: argv]; app.delegate = delegate; [app of_run]; @@ -260,13 +254,11 @@ continue; } key = [tmp substringToIndex: pos]; value = [tmp substringFromIndex: pos + 1]; - - [_environment setObject: value - forKey: key]; + [_environment setObject: value forKey: key]; objc_autoreleasePoolPop(pool); } FreeEnvironmentStringsW(env0); @@ -304,13 +296,11 @@ continue; } key = [tmp substringToIndex: pos]; value = [tmp substringFromIndex: pos + 1]; - - [_environment setObject: value - forKey: key]; + [_environment setObject: value forKey: key]; objc_autoreleasePoolPop(pool); } FreeEnvironmentStringsA(env0); @@ -335,17 +325,15 @@ path = [@"ENV:" stringByAppendingString: name]; if ([fileManager directoryExistsAtPath: path]) continue; - file = [OFFile fileWithPath: path - mode: @"r"]; + file = [OFFile fileWithPath: path mode: @"r"]; value = [file readLineWithEncoding: encoding]; if (value != nil) - [_environment setObject: value - forKey: name]; + [_environment setObject: value forKey: name]; objc_autoreleasePoolPop(pool2); } /* Local variables override global variables */ @@ -374,13 +362,11 @@ encoding: encoding]; value = [OFString stringWithCString: (const char *)iter->lv_Value encoding: encoding length: length]; - - [_environment setObject: value - forKey: key]; + [_environment setObject: value forKey: key]; } objc_autoreleasePoolPop(pool); #elif !defined(OF_IOS) # ifndef OF_MACOS @@ -409,13 +395,11 @@ 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); } } #else @@ -431,40 +415,35 @@ if ((env = getenv("HOME")) != NULL) { OFString *home = [[[OFString alloc] initWithUTF8StringNoCopy: env freeWhenDone: false] autorelease]; - [_environment setObject: home - forKey: @"HOME"]; + [_environment setObject: home forKey: @"HOME"]; } if ((env = getenv("PATH")) != NULL) { OFString *path = [[[OFString alloc] initWithUTF8StringNoCopy: env freeWhenDone: false] autorelease]; - [_environment setObject: path - forKey: @"PATH"]; + [_environment setObject: path forKey: @"PATH"]; } if ((env = getenv("SHELL")) != NULL) { OFString *shell = [[[OFString alloc] initWithUTF8StringNoCopy: env freeWhenDone: false] autorelease]; - [_environment setObject: shell - forKey: @"SHELL"]; + [_environment setObject: shell forKey: @"SHELL"]; } if ((env = getenv("TMPDIR")) != NULL) { OFString *tmpdir = [[[OFString alloc] initWithUTF8StringNoCopy: env freeWhenDone: false] autorelease]; - [_environment setObject: tmpdir - forKey: @"TMPDIR"]; + [_environment setObject: tmpdir forKey: @"TMPDIR"]; } if ((env = getenv("USER")) != NULL) { OFString *user = [[[OFString alloc] initWithUTF8StringNoCopy: env freeWhenDone: false] autorelease]; - [_environment setObject: user - forKey: @"USER"]; + [_environment setObject: user forKey: @"USER"]; } objc_autoreleasePoolPop(pool); #endif @@ -483,12 +462,11 @@ [_environment release]; [super dealloc]; } -- (void)of_setArgumentCount: (int *)argc - andArgumentValues: (char ***)argv +- (void)of_setArgumentCount: (int *)argc andArgumentValues: (char ***)argv { void *pool = objc_autoreleasePoolPush(); OFMutableArray *arguments; of_string_encoding_t encoding; @@ -517,12 +495,11 @@ objc_autoreleasePoolPop(pool); } #ifdef OF_WINDOWS -- (void)of_setArgumentCount: (int)argc - andWideArgumentValues: (wchar_t **)argv +- (void)of_setArgumentCount: (int)argc andWideArgumentValues: (wchar_t **)argv { void *pool = objc_autoreleasePoolPush(); OFMutableArray *arguments; if (argc > 0) { @@ -539,12 +516,11 @@ objc_autoreleasePoolPop(pool); } #endif -- (void)getArgumentCount: (int **)argc - andArgumentValues: (char ****)argv +- (void)getArgumentCount: (int **)argc andArgumentValues: (char ****)argv { *argc = _argc; *argv = _argv; }