# HG changeset patch # User Emmanuel Gil Peyrot # Date 1410189811 -7200 # Node ID ceda140f42fb300b2fb72cf709c2c510210f41b0 # Parent da588a3fb3ccc26f8468fbd604d749e331a7239a Remove the embedded getopt implementation. diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -21,5 +21,5 @@ clean: pmdwin: pmd_play.o libpmdwin.so $(CC) -L. -lpmdwin -o $@ pmd_play.o -libpmdwin.so: pmdwin.o table.o getopt.o lfg.o $(AUDIO_DRV) fmgen.o +libpmdwin.so: pmdwin.o table.o lfg.o $(AUDIO_DRV) fmgen.o $(CC) -shared -o $@ $^ diff --git a/getopt.c b/getopt.c deleted file mode 100644 --- a/getopt.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * getopt - get option letter from argv - * - * This is a version of the public domain getopt() implementation by - * Henry Spencer, changed for 4.3BSD compatibility (in addition to System V). - * It allows rescanning of an option list by setting optind to 0 before - * calling, which is why we use it even if the system has its own (in fact, - * this one has a unique name so as not to conflict with the system's). - * Thanks to Dennis Ferguson for the appropriate modifications. - * - * This file is in the Public Domain. - */ - -#include -#include - -char *optarg; /* Global argument pointer. */ -int optind = 0; /* Global argv index. */ -int opterr = 1; /* for compatibility, should error be printed? */ -int optopt; /* for compatibility, option character checked */ - -static char *scan = NULL; /* Private scan pointer. */ - -/* - * Print message about a bad option. - */ -static int badopt(const char *msg, int ch) -{ - if (opterr) { - write(2, msg, strlen(msg)); - write(2, &ch, 1); - write(2, "\n", 1); - } - return ('?'); -} - -int getopt(int argc, char *const argv[], const char *optstring) -{ - register char c; - register const char *place; - optarg = NULL; - - if (optind == 0) { - scan = NULL; - optind++; - } - - if (scan == NULL || *scan == '\0') { - if (optind >= argc - || argv[optind][0] != '-' - || argv[optind][1] == '\0') { - return (-1); - } - if (argv[optind][1] == '-' - && argv[optind][2] == '\0') { - optind++; - return (-1); - } - scan = argv[optind++]+1; - } - - c = *scan++; - optopt = c & 0377; - for (place = optstring; place != NULL && *place != '\0'; ++place) - if (*place == c) - break; - - if (place == NULL || *place == '\0' || c == ':' || c == '?') { - return (badopt("getopt: unknown option -", c)); - } - - place++; - if (*place == ':') { - if (*scan != '\0') { - optarg = scan; - scan = NULL; - } else if (optind >= argc) { - return (badopt("getopt: option requires argument -", c)); - } else { - optarg = argv[optind++]; - } - } - return (c & 0377); -} -