diff options
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/getopt32.c | 68 | ||||
-rw-r--r-- | libbb/mtab_file.c | 4 | ||||
-rw-r--r-- | libbb/procps.c | 64 | ||||
-rw-r--r-- | libbb/safe_strtol.c | 42 |
4 files changed, 88 insertions, 90 deletions
diff --git a/libbb/getopt32.c b/libbb/getopt32.c index f442933a3..dddf8121a 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c @@ -147,6 +147,40 @@ const char *opt_complementary Special characters: + "-" A dash as the first char in a opt_complementary group forces + all arguments to be treated as options, even if they have + no leading dashes. Next char in this case can't be a digit (0-9), + use ':' or end of line. For example: + + opt_complementary = "-:w-x:x-w"; + getopt32(argc, argv, "wx"); + + Allows any arguments to be given without a dash (./program w x) + as well as with a dash (./program -x). + + "--" A double dash at the beginning of opt_complementary means the + argv[1] string should always be treated as options, even if it isn't + prefixed with a "-". This is useful for special syntax in applets + such as "ar" and "tar": + tar xvf foo.tar + + "-N" A dash as the first char in a opt_complementary group followed + by a single digit (0-9) means that at least N non-option + arguments must be present on the command line + + "=N" An equal sign as the first char in a opt_complementary group followed + by a single digit (0-9) means that exactly N non-option + arguments must be present on the command line + + "?N" A "?" as the first char in a opt_complementary group followed + by a single digit (0-9) means that at most N arguments must be present + on the command line. + + "V-" An option with dash before colon or end-of-line results in + bb_show_usage being called if this option is encountered. + This is typically used to implement "print verbose usage message + and exit" option. + "-" A dash between two options causes the second of the two to be unset (and ignored) if it is given on the command line. @@ -173,30 +207,6 @@ Special characters: if (opt & 4) printf("Detected odd -x usage\n"); - "-" A dash as the first char in a opt_complementary group forces - all arguments to be treated as options, even if they have - no leading dashes. Next char in this case can't be a digit (0-9), - use ':' or end of line. For example: - - opt_complementary = "-:w-x:x-w"; - getopt32(argc, argv, "wx"); - - Allows any arguments to be given without a dash (./program w x) - as well as with a dash (./program -x). - - "-N" A dash as the first char in a opt_complementary group followed - by a single digit (0-9) means that at least N non-option - arguments must be present on the command line - - "=N" An equal sign as the first char in a opt_complementary group followed - by a single digit (0-9) means that exactly N non-option - arguments must be present on the command line - - "V-" An option with dash before colon or end-of-line results in - bb_show_usage being called if this option is encountered. - This is typically used to implement "print verbose usage message - and exit" option. - "--" A double dash between two options, or between an option and a group of options, means that they are mutually exclusive. Unlike the "-" case above, an error will be forced if the options @@ -221,10 +231,6 @@ Special characters: if BB_GETOPT_ERROR is detected, don't return, call bb_show_usage and exit instead. Next char after '?' can't be a digit. - "?N" A "?" as the first char in a opt_complementary group followed - by a single digit (0-9) means that at most N arguments must be present - on the command line. - "::" A double colon after a char in opt_complementary means that the option can occur multiple times. Each occurrence will be saved as a llist_t element instead of char*. @@ -245,12 +251,6 @@ Special characters: root:x:0:0:root:/root:/bin/bash user:x:500:500::/home/user:/bin/bash - "--" A double dash at the beginning of opt_complementary means the - argv[1] string should always be treated as options, even if it isn't - prefixed with a "-". This is useful for special syntax in applets - such as "ar" and "tar": - tar xvf foo.tar - "?" An "?" between an option and a group of options means that at least one of them is required to occur if the first option occurs in preceding command line arguments. diff --git a/libbb/mtab_file.c b/libbb/mtab_file.c index 3181d6d58..67367e3d7 100644 --- a/libbb/mtab_file.c +++ b/libbb/mtab_file.c @@ -13,5 +13,5 @@ /* Busybox mount uses either /proc/mounts or /etc/mtab to * get the list of currently mounted filesystems */ -const char bb_path_mtab_file[] = USE_FEATURE_MTAB_SUPPORT("/etc/mtab") - SKIP_FEATURE_MTAB_SUPPORT("/proc/mounts"); +const char bb_path_mtab_file[] = +USE_FEATURE_MTAB_SUPPORT("/etc/mtab")SKIP_FEATURE_MTAB_SUPPORT("/proc/mounts"); diff --git a/libbb/procps.c b/libbb/procps.c index 2581d03b2..ee4f5e53f 100644 --- a/libbb/procps.c +++ b/libbb/procps.c @@ -216,39 +216,39 @@ procps_status_t* procps_scan(procps_status_t* sp, int flags) } /* from kernel: // pid comm S ppid pgid sid tty_nr tty_pgrp flg - sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \ + sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \ %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \ %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu %llu\n", - task->pid, - tcomm, - state, - ppid, - pgid, - sid, - tty_nr, - tty_pgrp, - task->flags, - min_flt, - - cmin_flt, - maj_flt, - cmaj_flt, - cputime_to_clock_t(utime), - cputime_to_clock_t(stime), - cputime_to_clock_t(cutime), - cputime_to_clock_t(cstime), - priority, - nice, - num_threads, - // 0, - start_time, - vsize, - mm ? get_mm_rss(mm) : 0, - rsslim, - mm ? mm->start_code : 0, - mm ? mm->end_code : 0, - mm ? mm->start_stack : 0, - esp, - eip, + task->pid, + tcomm, + state, + ppid, + pgid, + sid, + tty_nr, + tty_pgrp, + task->flags, + min_flt, + + cmin_flt, + maj_flt, + cmaj_flt, + cputime_to_clock_t(utime), + cputime_to_clock_t(stime), + cputime_to_clock_t(cutime), + cputime_to_clock_t(cstime), + priority, + nice, + num_threads, + // 0, + start_time, + vsize, + mm ? get_mm_rss(mm) : 0, + rsslim, + mm ? mm->start_code : 0, + mm ? mm->end_code : 0, + mm ? mm->start_stack : 0, + esp, + eip, the rest is some obsolete cruft */ diff --git a/libbb/safe_strtol.c b/libbb/safe_strtol.c index a7f012fbc..d3bb29cdd 100644 --- a/libbb/safe_strtol.c +++ b/libbb/safe_strtol.c @@ -102,40 +102,38 @@ int safe_strtol(const char *arg, long* value) # define strong_alias(name, aliasname) _strong_alias (name, aliasname) # define _strong_alias(name, aliasname) \ - __asm__(".global " __C_SYMBOL_PREFIX__ #aliasname "\n" \ - ".set " __C_SYMBOL_PREFIX__ #aliasname "," __C_SYMBOL_PREFIX__ #name); + __asm__(".global " __C_SYMBOL_PREFIX__ #aliasname "\n" \ + ".set " __C_SYMBOL_PREFIX__ #aliasname "," __C_SYMBOL_PREFIX__ #name); #endif #endif int safe_strtoi(const char *arg, int* value) { - if (sizeof(long) == sizeof(int)) { + int error; + long lvalue; + if (sizeof(long) == sizeof(int)) return safe_strtol(arg, (long*)value); - } else { - int error; - long lvalue = *value; - error = safe_strtol(arg, &lvalue); - if (lvalue < INT_MIN || lvalue > INT_MAX) - return 1; - *value = (int) lvalue; - return error; - } + lvalue = *value; + error = safe_strtol(arg, &lvalue); + if (lvalue < INT_MIN || lvalue > INT_MAX) + return 1; + *value = (int) lvalue; + return error; } int safe_strtou(const char *arg, unsigned* value) { - if (sizeof(unsigned long) == sizeof(unsigned)) { + int error; + unsigned long lvalue; + if (sizeof(unsigned long) == sizeof(unsigned)) return safe_strtoul(arg, (unsigned long*)value); - } else { - int error; - unsigned long lvalue = *value; - error = safe_strtoul(arg, &lvalue); - if (lvalue > UINT_MAX) - return 1; - *value = (unsigned) lvalue; - return error; - } + lvalue = *value; + error = safe_strtoul(arg, &lvalue); + if (lvalue > UINT_MAX) + return 1; + *value = (unsigned) lvalue; + return error; } int BUG_safe_strtou32_unimplemented(void); |