diff options
author | Thomas Fitzsimmons <fitzsim@redhat.com> | 2002-08-29 23:53:06 +0000 |
---|---|---|
committer | Thomas Fitzsimmons <fitzsim@redhat.com> | 2002-08-29 23:53:06 +0000 |
commit | cd45f029c215eec23cce1916b9778383b01ff521 (patch) | |
tree | d3baa6e2700b9bc4a4bf5fcb3c866853f7277598 /newlib/libc/sys/linux/getoptlong.c | |
parent | 3c6891852a6cc252d10cb452f0445b588765a3ba (diff) | |
download | cygnal-cd45f029c215eec23cce1916b9778383b01ff521.tar.gz cygnal-cd45f029c215eec23cce1916b9778383b01ff521.tar.bz2 cygnal-cd45f029c215eec23cce1916b9778383b01ff521.zip |
* libc/sys/linux/argp: New directory.
* libc/sys/linux/getopt.c: New file.
* libc/sys/linux/getopt1.c: New file.
* libc/sys/linux/getoptlong.c: Remove file.
* libc/sys/linux/include/argp.h: New file.
* libc/sys/linux/Makefile.am: Define argp_dir and ARGP_LIB,
based on ELIX level.
(SUBDIRS): Add argp_dir.
(SUBLIBS): Add ARGP_LIB.
(ELIX_2_OBJS): Add getopt.$(oext), getopt1.$(oext), remove
getopt_long.$(oext).
* libc/sys/linux/configure.in (AC_OUTPUT): Add argp/Makefile.
Diffstat (limited to 'newlib/libc/sys/linux/getoptlong.c')
-rw-r--r-- | newlib/libc/sys/linux/getoptlong.c | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/newlib/libc/sys/linux/getoptlong.c b/newlib/libc/sys/linux/getoptlong.c deleted file mode 100644 index 089f4cdee..000000000 --- a/newlib/libc/sys/linux/getoptlong.c +++ /dev/null @@ -1,64 +0,0 @@ -#include <unistd.h> -#include <string.h> -#include <getopt.h> - -/* Written 2000 by Werner Almesberger */ - -static const char *__resume; - - -int getopt_long(int argc,char *const argv[],const char *optstring, - const struct option *longopts,int *longindex) -{ - char *here; - - optarg = NULL; - if (!__resume) { - if (argc == optind || *argv[optind] != '-') return -1; - if (argv[optind][1] == '-') { - const struct option *opt; - - optarg = strchr(argv[optind],'='); - if (optarg) optarg++; - for (opt = longopts; opt->name && - (optarg || strcmp(opt->name,argv[optind]+2)) && - (!optarg || strlen(opt->name) != optarg-argv[optind]-3 || - strncmp(opt->name,argv[optind]+2,optarg-argv[optind]-3)); - opt++); - optind++; - if (!opt->name) return '?'; - if ((opt->has_arg == no_argument && optarg) || - (opt->has_arg == required_argument && !optarg)) return ':'; - if (longindex) *longindex = opt-longopts; - if (!opt->flag) return opt->val; - *opt->flag = opt->val; - return 0; - } - else { - __resume = argv[optind]+1; - } - } - here = strchr(optstring,*__resume); - if (!here) { - optind++; - __resume = NULL; - return '?'; - } - if (here[1] != ':') { - if (!*++__resume) __resume = NULL; - } - else { - if (__resume[1]) optarg = (char *) __resume+1; - else { - optarg = (char *) argv[++optind]; - if (optind == argc || *argv[optind] == '-') { - optind++; - __resume = NULL; - return ':'; - } - } - __resume = NULL; - } - if (!__resume) optind++; - return *here; -} |