diff options
author | B. Watson <urchlay@slackware.uk> | 2024-12-23 04:32:58 -0500 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-12-23 04:32:58 -0500 |
commit | aea3a3ec017ea0032a7debb04092c6e423e16fcb (patch) | |
tree | 617a4d2ea15153027b97691f669aaa932c5a377a | |
parent | 404892de8d87dc68fc0882844d69911fb04f6df5 (diff) | |
download | uxd-aea3a3ec017ea0032a7debb04092c6e423e16fcb.tar.gz |
remove opterr, reformat getopt.c
-rw-r--r-- | getopt.c | 44 |
1 files changed, 21 insertions, 23 deletions
@@ -1,27 +1,27 @@ /* 20070425 bkw: - Public Domain implementation of getopt(), - downloaded from http://www.zdomain.com/a56/src/getopt.c - Following anonymous comment was in the original version: + Public Domain implementation of getopt(), + downloaded from http://www.zdomain.com/a56/src/getopt.c + Following anonymous comment was in the original version: */ /* - I got this off net.sources from Henry Spencer. - It is a public domain getopt(3) like in System V. - I have made the following modifications: + I got this off net.sources from Henry Spencer. + It is a public domain getopt(3) like in System V. + I have made the following modifications: - index(s,c) was added because too many people could - not compile getopt without it. + index(s,c) was added because too many people could + not compile getopt without it. - A test main program was added, ifdeffed by GETOPT. - This main program is a public domain implementation - of the getopt(1) program like in System V. The getopt - program can be used to standardize shell option handling. - e.g. cc -DGETOPT getopt.c -o getopt + A test main program was added, ifdeffed by GETOPT. + This main program is a public domain implementation + of the getopt(1) program like in System V. The getopt + program can be used to standardize shell option handling. + e.g. cc -DGETOPT getopt.c -o getopt */ /* 20070425 bkw: - Altered slightly for cassio (use fatal() for error messages, - get rid of main(), add return type to getopt()...) + Altered slightly for cassio (use fatal() for error messages, + get rid of main(), add return type to getopt()...) */ /* 20241214 bkw: modified slightly for use with uxd. */ @@ -30,10 +30,10 @@ extern char *self; #include <stdio.h> -#define ARGCH (int)':' +#define ARGCH (int)':' #define BADCH (int)'?' #define EMSG "" -#define ENDARGS "--" +#define ENDARGS "--" /* this is included because index is not on some UNIX systems */ static char *index (char *s, int c) { @@ -46,15 +46,13 @@ static char *index (char *s, int c) { /* * get option letter from argument vector */ -int opterr = 1, /* useless, never set or used */ - my_optind = 1, /* index into parent argv vector */ - my_optopt; /* character checked for validity */ -char *my_optarg; /* argument associated with option */ +int my_optind = 1, /* index into parent argv vector */ + my_optopt; /* character checked for validity */ +char *my_optarg; /* argument associated with option */ -#define tell(s) fprintf(stderr, "%s: %s", self, s); \ +#define tell(s) fprintf(stderr, "%s: %s", self, s); \ fputc(my_optopt,stderr);fputs(" (use -h for help)\n",stderr);return(BADCH); - int my_getopt(int nargc, char **nargv, char *ostr) { static char *place = EMSG; /* option letter processing */ char *oli; /* option letter list index */ |