From 8e88e462ee0fe27163ab6c90764425cb4307a5d3 Mon Sep 17 00:00:00 2001 From: Ricky Zhang Date: Sun, 28 Jun 2020 18:42:14 -0400 Subject: [PATCH] Fix code review issues. Signed-off-by: Ricky Zhang --- BasiliskII/src/MacOSX/Info.plist | 2 +- BasiliskII/src/MacOSX/extfs_macosx.cpp | 3 +- BasiliskII/src/MacOSX/runtool.c | 136 ------------------------- BasiliskII/src/MacOSX/utils_macosx.mm | 1 - BasiliskII/src/SDL/video_sdl.cpp | 2 +- BasiliskII/src/SDL/video_sdl2.cpp | 2 +- BasiliskII/src/Unix/main_unix.cpp | 18 ++-- BasiliskII/src/user_strings.cpp | 3 +- 8 files changed, 15 insertions(+), 152 deletions(-) delete mode 100644 BasiliskII/src/MacOSX/runtool.c diff --git a/BasiliskII/src/MacOSX/Info.plist b/BasiliskII/src/MacOSX/Info.plist index da3aae24..b879fccd 100644 --- a/BasiliskII/src/MacOSX/Info.plist +++ b/BasiliskII/src/MacOSX/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable BasiliskII CFBundleGetInfoString - Basilisk II version 1.0, Copyright © 1997-2017 Christian Bauer et al. SDL2 port + Basilisk II version 1.0, Copyright © 1997-2020 Christian Bauer et al. SDL2 port CFBundleIconFile BasiliskII.icns CFBundleIdentifier diff --git a/BasiliskII/src/MacOSX/extfs_macosx.cpp b/BasiliskII/src/MacOSX/extfs_macosx.cpp index dea61b00..34f57058 100644 --- a/BasiliskII/src/MacOSX/extfs_macosx.cpp +++ b/BasiliskII/src/MacOSX/extfs_macosx.cpp @@ -252,7 +252,8 @@ static int open_rsrc(const char *path, int flag) make_rsrc_path(path, rsrc_path); int fd = open(rsrc_path, flag); - if (fd < 0 && flag == O_WRONLY) fd = open(rsrc_path, O_WRONLY | O_CREAT); // for APFS + if (fd < 0 && flag == O_WRONLY) + fd = open(rsrc_path, O_WRONLY | O_CREAT); // for APFS return fd; } diff --git a/BasiliskII/src/MacOSX/runtool.c b/BasiliskII/src/MacOSX/runtool.c deleted file mode 100644 index 77c38a43..00000000 --- a/BasiliskII/src/MacOSX/runtool.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * runtool.m - Run an external program as root for networking - * Copyright (C) 2010, Daniel Sumorok - * - * Basilisk II (C) 1997-2008 Christian Bauer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include - -FILE * run_tool(const char *if_name, const char *tool_name); - -FILE * run_tool(const char *if_name, const char *tool_name) -{ - OSStatus auth_status; - FILE *fp = NULL; - char *args[] = {NULL, NULL, NULL}; - int ret; - char path_buffer[256]; - AuthorizationFlags auth_flags; - AuthorizationRef auth_ref; - AuthorizationItem auth_items[1]; - AuthorizationRights auth_rights; - CFBundleRef bundle_ref; - CFURLRef url_ref; - CFStringRef path_str; - CFStringRef tool_name_str; - char c; - - bundle_ref = CFBundleGetMainBundle(); - if(bundle_ref == NULL) { - return NULL; - } - - tool_name_str = CFStringCreateWithCString(NULL, tool_name, - kCFStringEncodingUTF8); - - url_ref = CFBundleCopyResourceURL(bundle_ref, tool_name_str, - NULL, NULL); - CFRelease(tool_name_str); - - if(url_ref == NULL) { - return NULL; - } - - path_str = CFURLCopyFileSystemPath(url_ref, kCFURLPOSIXPathStyle); - CFRelease(url_ref); - - if(path_str == NULL) { - return NULL; - } - - if(!CFStringGetCString(path_str, path_buffer, sizeof(path_buffer), - kCFStringEncodingUTF8)) { - CFRelease(path_str); - return NULL; - } - CFRelease(path_str); - - args[0] = (char *)tool_name; - args[1] = (char *)if_name; - - auth_flags = kAuthorizationFlagExtendRights | - kAuthorizationFlagInteractionAllowed | - kAuthorizationFlagPreAuthorize; - - auth_items[0].name = "system.privilege.admin"; - auth_items[0].valueLength = 0; - auth_items[0].value = NULL; - auth_items[0].flags = 0; - - auth_rights.count = sizeof (auth_items) / sizeof (auth_items[0]); - auth_rights.items = auth_items; - - auth_status = AuthorizationCreate(&auth_rights, - kAuthorizationEmptyEnvironment, - auth_flags, - &auth_ref); - - if (auth_status != errAuthorizationSuccess) { - fprintf(stderr, "%s: AuthorizationCreate() failed.\n", - __func__); - return NULL; - } - - auth_status = AuthorizationExecuteWithPrivileges(auth_ref, - path_buffer, - kAuthorizationFlagDefaults, - args + 1, - &fp); - - if (auth_status != errAuthorizationSuccess) { - fprintf(stderr, "%s: AuthorizationExecWithPrivileges() failed.\n", - __func__); - return NULL; - } - - if(fread(&c, 1, 1, fp) != 1) { - fclose(fp); - return NULL; - } - - return fp; -} diff --git a/BasiliskII/src/MacOSX/utils_macosx.mm b/BasiliskII/src/MacOSX/utils_macosx.mm index c68d2115..6fcb8290 100644 --- a/BasiliskII/src/MacOSX/utils_macosx.mm +++ b/BasiliskII/src/MacOSX/utils_macosx.mm @@ -36,7 +36,6 @@ void NSAutoReleasePool_wrap(void (*fn)(void)) } #if SDL_VERSION_ATLEAST(2,0,0) - void disable_SDL2_macosx_menu_bar_keyboard_shortcuts() { for (NSMenuItem * menu_item in [NSApp mainMenu].itemArray) { if (menu_item.hasSubmenu) { diff --git a/BasiliskII/src/SDL/video_sdl.cpp b/BasiliskII/src/SDL/video_sdl.cpp index 037d3fab..cbf034d8 100644 --- a/BasiliskII/src/SDL/video_sdl.cpp +++ b/BasiliskII/src/SDL/video_sdl.cpp @@ -2279,4 +2279,4 @@ void video_set_dirty_area(int x, int y, int w, int h) // XXX handle dirty bounding boxes for non-VOSF modes } #endif -#endif //end of ifdef ENABLE_SDL1 +#endif //ifdef ENABLE_SDL1 diff --git a/BasiliskII/src/SDL/video_sdl2.cpp b/BasiliskII/src/SDL/video_sdl2.cpp index 6e497550..ce83ed9d 100644 --- a/BasiliskII/src/SDL/video_sdl2.cpp +++ b/BasiliskII/src/SDL/video_sdl2.cpp @@ -2720,4 +2720,4 @@ void video_set_dirty_area(int x, int y, int w, int h) } #endif -#endif // ends: ifdef ENABLE_SDL2 +#endif //ifdef ENABLE_SDL2 diff --git a/BasiliskII/src/Unix/main_unix.cpp b/BasiliskII/src/Unix/main_unix.cpp index 03ef32a2..af6f6609 100644 --- a/BasiliskII/src/Unix/main_unix.cpp +++ b/BasiliskII/src/Unix/main_unix.cpp @@ -456,17 +456,17 @@ int main(int argc, char **argv) argv[i] = NULL; } -#if defined(__APPLE__) && defined(__MACH__) +#if __MACOSX__ // Mac OS X likes to pass in various options of its own, when launching an app. // Attempt to ignore these. - if (argv[i]) { - const char * mac_psn_prefix = "-psn_"; - if (strcmp(argv[i], "-NSDocumentRevisionsDebugMode") == 0) { - argv[i] = NULL; - } else if (strncmp(mac_psn_prefix, argv[i], strlen(mac_psn_prefix)) == 0) { - argv[i] = NULL; - } - } + if (argv[i]) { + const char * mac_psn_prefix = "-psn_"; + if (strcmp(argv[i], "-NSDocumentRevisionsDebugMode") == 0) { + argv[i] = NULL; + } else if (strncmp(mac_psn_prefix, argv[i], strlen(mac_psn_prefix)) == 0) { + argv[i] = NULL; + } + } #endif } diff --git a/BasiliskII/src/user_strings.cpp b/BasiliskII/src/user_strings.cpp index a9de2b6c..f6b59ed4 100644 --- a/BasiliskII/src/user_strings.cpp +++ b/BasiliskII/src/user_strings.cpp @@ -241,7 +241,6 @@ user_string_def common_strings[] = { {STR_CPU_68040_LAB, "68040"}, {STR_ROM_FILE_CTRL, "ROM File"}, {STR_IDLEWAIT_CTRL, "Don't Use CPU When Idle"}, - {STR_JIT_PANE_TITLE, "JIT Compiler"}, {STR_JIT_CTRL, "Enable JIT Compiler"}, {STR_JIT_FPU_CTRL, "Compile FPU Instructions"}, @@ -258,7 +257,7 @@ user_string_def common_strings[] = { {STR_WINDOW_TITLE_GRABBED, "Basilisk II (mouse grabbed, press Ctrl-F5 to release)"}, {STR_WINDOW_TITLE_GRABBED0, "Basilisk II (mouse grabbed, press "}, {STR_WINDOW_TITLE_GRABBED1, "Ctrl-"}, -#ifdef __APPLE__ +#ifdef __MACOSX__ {STR_WINDOW_TITLE_GRABBED2, "Opt-"}, {STR_WINDOW_TITLE_GRABBED3, "Cmd-"}, #else