Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (7 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/libbb/getopt32.c

    r2725 r3232  
    88 */
    99
    10 #include <getopt.h>
     10#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
     11# include <getopt.h>
     12#endif
    1113#include "libbb.h"
    1214
     
    8183
    8284        static const char applet_longopts[] ALIGN1 =
    83         //"name\0" has_arg val
    84         "verbose\0" No_argument "v"
    85         ;
     85                //"name\0" has_arg val
     86                "verbose\0" No_argument "v"
     87                ;
    8688        applet_long_options = applet_longopts;
    8789
     
    227229        opt_complementary = "b--cf:c--bf:f--bc".  If two of the
    228230        mutually exclusive options are found, getopt32 will call
    229     bb_show_usage() and die.
     231        bb_show_usage() and die.
    230232
    231233 "x--x" Variation of the above, it means that -x option should occur
     
    466468        for (on_off = complementary; on_off->opt_char; on_off++)
    467469            if (on_off->opt_char == *s)
    468                 break;
     470                goto found_opt;
     471        /* Without this, diagnostic of such bugs is not easy */
     472        bb_error_msg_and_die("NO OPT %c!", *s);
     473 found_opt:
    469474        if (c == ':' && s[2] == ':') {
    470475            on_off->param_type = PARAM_LIST;
     
    473478        if (c == '+' && (s[2] == ':' || s[2] == '\0')) {
    474479            on_off->param_type = PARAM_INT;
     480            s++;
    475481            continue;
    476482        }
     
    532538    /* In case getopt32 was already called:
    533539     * reset the libc getopt() function, which keeps internal state.
    534      * run_nofork_applet_prime() does this, but we might end up here
     540     * run_nofork_applet() does this, but we might end up here
    535541     * also via gunzip_main() -> gzip_main(). Play safe.
    536542     */
     
    542548#endif
    543549    /* optarg = NULL; opterr = 0; optopt = 0; - do we need this?? */
    544 
    545     pargv = NULL;
    546550
    547551    /* Note: just "getopt() <= 0" will not work well for
     
    575579        if (on_off->counter)
    576580            (*(on_off->counter))++;
    577         if (on_off->param_type == PARAM_LIST) {
    578             if (optarg)
     581        if (optarg) {
     582            if (on_off->param_type == PARAM_LIST) {
    579583                llist_add_to_end((llist_t **)(on_off->optarg), optarg);
    580         } else if (on_off->param_type == PARAM_INT) {
    581             if (optarg)
     584            } else if (on_off->param_type == PARAM_INT) {
    582585//TODO: xatoi_positive indirectly pulls in printf machinery
    583586                *(unsigned*)(on_off->optarg) = xatoi_positive(optarg);
    584         } else if (on_off->optarg) {
    585             if (optarg)
     587            } else if (on_off->optarg) {
    586588                *(char **)(on_off->optarg) = optarg;
    587         }
    588         if (pargv != NULL)
    589             break;
     589            }
     590        }
    590591    }
    591592
Note: See TracChangeset for help on using the changeset viewer.