summaryrefslogtreecommitdiff
path: root/misc/getopt/files/patch-getopt.c
diff options
context:
space:
mode:
authorSergey A. Osokin <osa@FreeBSD.org>2003-06-13 23:56:42 +0000
committerSergey A. Osokin <osa@FreeBSD.org>2003-06-13 23:56:42 +0000
commit445d53b2d18b1e791d6ddea09bfbc5d48e35e0f1 (patch)
tree54c421cdb09d22f7eefa19cfc647d2240bb69438 /misc/getopt/files/patch-getopt.c
parentNew port: graphical configuation utility for the newsreader slrn (diff)
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/patch-getopt.c')
-rw-r--r--misc/getopt/files/patch-getopt.c55
1 files changed, 55 insertions, 0 deletions
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);