diff options
author | Rene Engelhard <rene@openoffice.org> | 2010-06-14 22:57:51 +0200 |
---|---|---|
committer | Rene Engelhard <rene@openoffice.org> | 2010-06-14 22:57:51 +0200 |
commit | e592b814914be90e465aa5a440c3a8865f8bc4c4 (patch) | |
tree | 5560faf719614c0ae7535bd0cdb7cfb1242ab909 /soltools/cpp | |
parent | systemlibc: add missing "test" to fix build (diff) | |
download | core-e592b814914be90e465aa5a440c3a8865f8bc4c4.tar.gz core-e592b814914be90e465aa5a440c3a8865f8bc4c4.zip |
systemlibc: reintroduce stgetopt() for -isysroot on Mac. sigh.
Diffstat (limited to 'soltools/cpp')
-rw-r--r-- | soltools/cpp/_getopt.c | 71 | ||||
-rw-r--r-- | soltools/cpp/_unix.c | 4 | ||||
-rw-r--r-- | soltools/cpp/makefile.mk | 5 |
3 files changed, 80 insertions, 0 deletions
diff --git a/soltools/cpp/_getopt.c b/soltools/cpp/_getopt.c new file mode 100644 index 000000000000..589638936efb --- /dev/null +++ b/soltools/cpp/_getopt.c @@ -0,0 +1,71 @@ +#include <stdio.h> +#include <string.h> + +#define EPR fprintf(stderr, +#define ERR(str, chr) if(opterr) { EPR "%s%c\n", str, chr); } + +int opterr = 1; +int optind = 1; +int optopt; +char *optarg; + +int + stgetopt(int argc, char *const argv[], const char *opts) +{ + static int sp = 1; + register int c; + register char *cp; + + if (sp == 1) + { + if (optind >= argc || + argv[optind][0] != '-' || argv[optind][1] == '\0') + return -1; + else if (strcmp(argv[optind], "--") == 0) + { + optind++; + return -1; + } + else if (strcmp(argv[optind], "-isysroot") == 0) + { + // skip Mac OS X SDK selection flags + optind++; optind++; + } + } + optopt = c = argv[optind][sp]; + if (c == ':' || (cp = strchr(opts, c)) == 0) + { + ERR(": illegal option -- ", c); + if (argv[optind][++sp] == '\0') + { + optind++; + sp = 1; + } + return '?'; + } + if (*++cp == ':') + { + if (argv[optind][sp + 1] != '\0') + optarg = &argv[optind++][sp + 1]; + else + if (++optind >= argc) + { + ERR(": option requires an argument -- ", c); + sp = 1; + return '?'; + } + else + optarg = argv[optind++]; + sp = 1; + } + else + { + if (argv[optind][++sp] == '\0') + { + sp = 1; + optind++; + } + optarg = 0; + } + return c; +} diff --git a/soltools/cpp/_unix.c b/soltools/cpp/_unix.c index 1b58c00b6edb..48a6ff0e189e 100644 --- a/soltools/cpp/_unix.c +++ b/soltools/cpp/_unix.c @@ -34,7 +34,11 @@ void Tokenrow tr; setup_kwtab(); +#if defined MACOSX + while ((c = stgetopt(argc, argv, "NOPV:I:D:U:F:A:X:u:l:+")) != -1) +#else while ((c = getopt(argc, argv, "NOPV:I:D:U:F:A:X:u:l:+")) != -1) +#endif switch (c) { case 'N': diff --git a/soltools/cpp/makefile.mk b/soltools/cpp/makefile.mk index 5143e01e1d1f..bb3c1b5547f7 100644 --- a/soltools/cpp/makefile.mk +++ b/soltools/cpp/makefile.mk @@ -53,6 +53,11 @@ OBJFILES= \ $(OBJ)$/_tokens.obj \ $(OBJ)$/_unix.obj +# nonstandard cpp options, needs the custom stgetopt defined here :/ +.IF "$(OS)" == "MACOSX" +OBJFILES += $(OBJ)$/_getopt.obj +.ENDIF + APP1TARGET = $(TARGET) .IF "$(GUI)" != "OS2" APP1STACK = 1000000 |