From: Jay Freeman (saurik) Date: Wed, 29 Jan 2014 17:24:38 +0000 (-0800) Subject: Generalize and centralize cpr flag conflict check. X-Git-Tag: v0.9.502~30 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/9674674739f8ab3c2b81879f36fdb7fcf294cb5e?ds=inline Generalize and centralize cpr flag conflict check. --- diff --git a/Console.cpp b/Console.cpp index f904f08..f93e090 100644 --- a/Console.cpp +++ b/Console.cpp @@ -616,6 +616,7 @@ int Main(int argc, char const * const argv[], char const * const envp[]) { bool tty(isatty(STDIN_FILENO)); bool compile(false); + bool target(false); CYOptions options; append_history$ = (int (*)(int, const char *)) (dlsym(RTLD_DEFAULT, "append_history")); @@ -664,9 +665,22 @@ int Main(int argc, char const * const argv[], char const * const envp[]) { } switch (opt) { + target: + if (!target) + target = true; + else { + fprintf(stderr, "only one of -[c" +#ifdef CY_ATTACH + "p" +#endif + "r] may be used at a time\n"); + return 1; + } + break; + case 'c': compile = true; - break; + goto target; case 'g': if (false); @@ -738,7 +752,7 @@ int Main(int argc, char const * const argv[], char const * const envp[]) { return 1; } } - } break; + } goto target; #endif case 'r': { @@ -760,7 +774,7 @@ int Main(int argc, char const * const argv[], char const * const envp[]) { host = arg; *colon = '\0'; port = colon + 1; - } break; + } goto target; case 's': strict_ = true; @@ -776,11 +790,6 @@ int Main(int argc, char const * const argv[], char const * const envp[]) { fprintf(stderr, "-p cannot set argv\n"); return 1; } - - if (pid != _not(pid_t) && compile) { - fprintf(stderr, "-p conflicts with -c\n"); - return 1; - } #endif if (ind == argc)