diff options
author | osa <osa@FreeBSD.org> | 2003-06-14 07:56:42 +0800 |
---|---|---|
committer | osa <osa@FreeBSD.org> | 2003-06-14 07:56:42 +0800 |
commit | 40f8fa4bae84c7afa5a5f4cac14409cbb717597e (patch) | |
tree | 7292e1c340ed64530477c310059f4dabed82ae6e /misc/getopt/files | |
parent | 9b8d7a6eeb38b77df4d34a1a7d5ed65fca8e38fc (diff) | |
download | freebsd-ports-gnome-40f8fa4bae84c7afa5a5f4cac14409cbb717597e.tar.gz freebsd-ports-gnome-40f8fa4bae84c7afa5a5f4cac14409cbb717597e.tar.zst freebsd-ports-gnome-40f8fa4bae84c7afa5a5f4cac14409cbb717597e.zip |
A getopt(1) replacement that supports GNU-style long options
Submitted by: Sergei Kolobov <sergei@kolobov.com>
PR: 53174
Approved by: fjoe (implicit)
Diffstat (limited to 'misc/getopt/files')
-rw-r--r-- | misc/getopt/files/patch-Makefile | 38 | ||||
-rw-r--r-- | misc/getopt/files/patch-getopt.c | 55 |
2 files changed, 93 insertions, 0 deletions
diff --git a/misc/getopt/files/patch-Makefile b/misc/getopt/files/patch-Makefile new file mode 100644 index 000000000000..fadb1f525005 --- /dev/null +++ b/misc/getopt/files/patch-Makefile @@ -0,0 +1,38 @@ +--- Makefile.orig Thu Jan 23 23:52:29 2003 ++++ Makefile Thu Jun 5 16:17:44 2003 +@@ -1,7 +1,7 @@ + .SUFFIXES: + + DESTDIR= +-prefix=/usr/local ++prefix=$(PREFIX) + bindir=$(prefix)/bin + mandir=$(prefix)/man + man1dir=$(mandir)/man1 +@@ -29,7 +29,7 @@ + LANGUAGES = cs de es fr it ja nl pt_BR + MOFILES:=$(patsubst %,po/%.mo,$(LANGUAGES)) + +-CPPFLAGS=-DLIBCGETOPT=$(LIBCGETOPT) -DWITH_GETTEXT=$(WITH_GETTEXT) -DLOCALEDIR=\"$(localedir)\" -DNOT_UTIL_LINUX ++CPPFLAGS+=-DLIBCGETOPT=$(LIBCGETOPT) -DWITH_GETTEXT=$(WITH_GETTEXT) -DLOCALEDIR=\"$(localedir)\" -DNOT_UTIL_LINUX + ifeq ($(LIBCGETOPT),0) + CPPFLAGS+=-I./gnu + endif +@@ -39,8 +39,6 @@ + -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \ + -Wnested-externs -Winline + OPTIMIZE=-O3 -fno-strength-reduce +-CFLAGS=$(WARNINGS) $(OPTIMIZE) +-LDFLAGS= + + sources=getopt.c + ifeq ($(LIBCGETOPT),0) +@@ -71,7 +69,7 @@ + getopt-test.bash getopt-test.tcsh \ + $(DESTDIR)$(getoptdir) + +-ifeq ($(WITH_GETTEXT),1) ++ifeq ($(WITHOUT_GETTEXT),0) + all_po: $(MOFILES) + install_po: all_po + $(INSTALL) -m 755 -d $(DESTDIR)$(localedir) diff --git a/misc/getopt/files/patch-getopt.c b/misc/getopt/files/patch-getopt.c new file mode 100644 index 000000000000..70cf42ffe042 --- /dev/null +++ b/misc/getopt/files/patch-getopt.c @@ -0,0 +1,55 @@ +--- getopt.c.orig Thu Jun 5 16:00:34 2003 ++++ getopt.c Thu Jun 5 16:02:34 2003 +@@ -66,7 +66,6 @@ + int quiet_errors=0; /* 0 is not quiet. */ + int quiet_output=0; /* 0 is not quiet. */ + int quote=1; /* 1 is do quote. */ +-int alternative=0; /* 0 is getopt_long, 1 is getopt_long_only */ + + /* Function prototypes */ + void *our_malloc(size_t size); +@@ -188,9 +187,7 @@ + opterr=0; + optind=0; /* Reset getopt(3) */ + +- while ((opt = (alternative? +- getopt_long_only(argc,argv,optstr,longopts,&longindex): +- getopt_long(argc,argv,optstr,longopts,&longindex))) ++ while ((opt = getopt_long(argc,argv,optstr,longopts,&longindex)) + != EOF) + if (opt == '?' || opt == ':' ) + exit_code = 1; +@@ -325,7 +322,6 @@ + fputs(_(" getopt [options] [--] optstring parameters\n"),stderr); + fputs(_(" getopt [options] -o|--options optstring [options] [--]\n"),stderr); + fputs(_(" parameters\n"),stderr); +- fputs(_(" -a, --alternative Allow long options starting with single -\n"),stderr); + fputs(_(" -h, --help This small usage guide\n"),stderr); + fputs(_(" -l, --longoptions=longopts Long options to be recognized\n"),stderr); + fputs(_(" -n, --name=progname The name under which errors are reported\n"),stderr); +@@ -355,14 +351,13 @@ + {"test",no_argument,NULL,'T'}, + {"unquoted",no_argument,NULL,'u'}, + {"help",no_argument,NULL,'h'}, +- {"alternative",no_argument,NULL,'a'}, + {"name",required_argument,NULL,'n'}, + {"version",no_argument,NULL,'V'}, + {NULL,0,NULL,0} + }; + + /* Stop scanning as soon as a non-option argument is found! */ +-static const char *shortopts="+ao:l:n:qQs:TuhV"; ++static const char *shortopts="+o:l:n:qQs:TuhV"; + + int main(int argc, char *argv[]) + { +@@ -405,9 +400,6 @@ + + while ((opt=getopt_long(argc,argv,shortopts,longopts,NULL)) != EOF) + switch (opt) { +- case 'a': +- alternative=1; +- break; + case 'h': + print_help(); + exit(0); |