changeset 7:ceda140f42fb

Remove the embedded getopt implementation.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 08 Sep 2014 17:23:31 +0200
parents da588a3fb3cc
children a7e3a45d3002
files Makefile getopt.c
diffstat 2 files changed, 1 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- 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 $@ $^
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 <string.h>
-#include <unistd.h>
-
-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);
-}
-