Subversion Repositories HelenOS

Rev

Rev 4377 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4377 Rev 4692
Line 45... Line 45...
45
 
45
 
46
int opterr = 1;     /* if error message should be printed */
46
int opterr = 1;     /* if error message should be printed */
47
int optind = 1;     /* index into parent argv vector */
47
int optind = 1;     /* index into parent argv vector */
48
int optopt = '?';       /* character checked for validity */
48
int optopt = '?';       /* character checked for validity */
49
int optreset;       /* reset getopt */
49
int optreset;       /* reset getopt */
50
char *optarg;       /* argument associated with option */
50
const char *optarg;     /* argument associated with option */
51
 
51
 
52
 
52
 
53
#define IGNORE_FIRST    (*options == '-' || *options == '+')
53
#define IGNORE_FIRST    (*options == '-' || *options == '+')
54
#define PRINT_ERROR ((opterr) && ((*options != ':') \
54
#define PRINT_ERROR ((opterr) && ((*options != ':') \
55
                      || (IGNORE_FIRST && options[1] != ':')))
55
                      || (IGNORE_FIRST && options[1] != ':')))
Line 160... Line 160...
160
getopt_internal(nargc, nargv, options)
160
getopt_internal(nargc, nargv, options)
161
    int nargc;
161
    int nargc;
162
    char **nargv;
162
    char **nargv;
163
    const char *options;
163
    const char *options;
164
{
164
{
165
    char *oli;              /* option letter list index */
165
    const char *oli;                /* option letter list index */
166
    int optchar;
166
    int optchar;
167
 
167
 
168
    assert(nargv != NULL);
168
    assert(nargv != NULL);
169
    assert(options != NULL);
169
    assert(options != NULL);
170
 
170
 
Line 273... Line 273...
273
        if (!*place)
273
        if (!*place)
274
            ++optind;
274
            ++optind;
275
    } else {                /* takes (optional) argument */
275
    } else {                /* takes (optional) argument */
276
        optarg = NULL;
276
        optarg = NULL;
277
        if (*place)         /* no white space */
277
        if (*place)         /* no white space */
278
            optarg = *place;
278
            optarg = place;
279
        /* XXX: disable test for :: if PC? (GNU doesn't) */
279
        /* XXX: disable test for :: if PC? (GNU doesn't) */
280
        else if (oli[1] != ':') {   /* arg not optional */
280
        else if (oli[1] != ':') {   /* arg not optional */
281
            if (++optind >= nargc) {    /* no arg */
281
            if (++optind >= nargc) {    /* no arg */
282
                place = EMSG;
282
                place = EMSG;
283
                if (PRINT_ERROR)
283
                if (PRINT_ERROR)
Line 351... Line 351...
351
    assert(long_options != NULL);
351
    assert(long_options != NULL);
352
    /* idx may be NULL */
352
    /* idx may be NULL */
353
 
353
 
354
    retval = getopt_internal(nargc, (char **)nargv, options);
354
    retval = getopt_internal(nargc, (char **)nargv, options);
355
    if (retval == -2) {
355
    if (retval == -2) {
356
        char *current_argv, *has_equal;
356
        char *current_argv;
-
 
357
        const char *has_equal;
357
        size_t current_argv_len;
358
        size_t current_argv_len;
358
        int i, ambiguous, match;
359
        int i, ambiguous, match;
359
 
360
 
360
        current_argv = (char *)place;
361
        current_argv = (char *)place;
361
        match = -1;
362
        match = -1;