OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [sys/] [linux/] [getoptlong.c] - Diff between revs 1010 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 1010 Rev 1765
#include <unistd.h>
#include <unistd.h>
#include <string.h>
#include <string.h>
#include <getopt.h>
#include <getopt.h>
 
 
/* Written 2000 by Werner Almesberger */
/* Written 2000 by Werner Almesberger */
 
 
static const char *__resume;
static const char *__resume;
 
 
 
 
int getopt_long(int argc,char *const argv[],const char *optstring,
int getopt_long(int argc,char *const argv[],const char *optstring,
  const struct option *longopts,int *longindex)
  const struct option *longopts,int *longindex)
{
{
    char *here;
    char *here;
 
 
    optarg = NULL;
    optarg = NULL;
    if (!__resume) {
    if (!__resume) {
        if (argc == optind || *argv[optind] != '-') return -1;
        if (argc == optind || *argv[optind] != '-') return -1;
        if (argv[optind][1] == '-') {
        if (argv[optind][1] == '-') {
            const struct option *opt;
            const struct option *opt;
 
 
            optarg = strchr(argv[optind],'=');
            optarg = strchr(argv[optind],'=');
            if (optarg) optarg++;
            if (optarg) optarg++;
            for (opt = longopts; opt->name &&
            for (opt = longopts; opt->name &&
              (optarg || strcmp(opt->name,argv[optind]+2)) &&
              (optarg || strcmp(opt->name,argv[optind]+2)) &&
              (!optarg || strlen(opt->name) != optarg-argv[optind]-3 ||
              (!optarg || strlen(opt->name) != optarg-argv[optind]-3 ||
              strncmp(opt->name,argv[optind]+2,optarg-argv[optind]-3));
              strncmp(opt->name,argv[optind]+2,optarg-argv[optind]-3));
              opt++);
              opt++);
            optind++;
            optind++;
            if (!opt->name) return '?';
            if (!opt->name) return '?';
            if ((opt->has_arg == no_argument && optarg) ||
            if ((opt->has_arg == no_argument && optarg) ||
              (opt->has_arg == required_argument && !optarg)) return ':';
              (opt->has_arg == required_argument && !optarg)) return ':';
            if (longindex) *longindex = opt-longopts;
            if (longindex) *longindex = opt-longopts;
            if (!opt->flag) return opt->val;
            if (!opt->flag) return opt->val;
            *opt->flag = opt->val;
            *opt->flag = opt->val;
            return 0;
            return 0;
        }
        }
        else {
        else {
            __resume = argv[optind]+1;
            __resume = argv[optind]+1;
        }
        }
    }
    }
    here = strchr(optstring,*__resume);
    here = strchr(optstring,*__resume);
    if (!here) {
    if (!here) {
        optind++;
        optind++;
        __resume = NULL;
        __resume = NULL;
        return '?';
        return '?';
    }
    }
    if (here[1] != ':') {
    if (here[1] != ':') {
        if (!*++__resume) __resume = NULL;
        if (!*++__resume) __resume = NULL;
    }
    }
    else {
    else {
        if (__resume[1]) optarg = (char *) __resume+1;
        if (__resume[1]) optarg = (char *) __resume+1;
        else {
        else {
            optarg = (char *) argv[++optind];
            optarg = (char *) argv[++optind];
            if (optind == argc || *argv[optind] == '-') {
            if (optind == argc || *argv[optind] == '-') {
                optind++;
                optind++;
                __resume = NULL;
                __resume = NULL;
                return ':';
                return ':';
            }
            }
        }
        }
        __resume = NULL;
        __resume = NULL;
    }
    }
    if (!__resume) optind++;
    if (!__resume) optind++;
    return *here;
    return *here;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.