Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/coreutils/od.c


Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/coreutils/od.c

    r1765 r2725  
    55 *
    66 * Copyright (c) 1990
    7  *  The Regents of the University of California.  All rights reserved.
    8  *
    9  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
     7 * The Regents of the University of California.  All rights reserved.
     8 *
     9 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    1010 *
    1111 * Original copyright notice is retained at the end of this file.
     
    1818#include "od_bloaty.c"
    1919#else
    20 #include <getopt.h>
    2120
    2221#include "dump.h"
    2322
    24 #define isdecdigit(c) isdigit(c)
    25 #define ishexdigit(c) (isxdigit)(c)
    26 
    2723static void
    28 odoffset(int argc, char ***argvp)
     24odoffset(dumper_t *dumper, int argc, char ***argvp)
    2925{
    3026    char *num, *p;
     
    5349    if ((*p != '+')
    5450        && (argc < 2
    55             || (!isdecdigit(p[0])
    56                 && ((p[0] != 'x') || !ishexdigit(p[1])))))
     51            || (!isdigit(p[0])
     52                && ((p[0] != 'x') || !isxdigit(p[1])))))
    5753        return;
    5854
    5955    base = 0;
    6056    /*
    61      * bb_dump_skip over leading '+', 'x[0-9a-fA-f]' or '0x', and
     57     * skip over leading '+', 'x[0-9a-fA-f]' or '0x', and
    6258     * set base.
    6359     */
    6460    if (p[0] == '+')
    6561        ++p;
    66     if (p[0] == 'x' && ishexdigit(p[1])) {
     62    if (p[0] == 'x' && isxdigit(p[1])) {
    6763        ++p;
    6864        base = 16;
     
    7268    }
    7369
    74     /* bb_dump_skip over the number */
     70    /* skip over the number */
    7571    if (base == 16)
    76         for (num = p; ishexdigit(*p); ++p);
     72        for (num = p; isxdigit(*p); ++p)
     73            continue;
    7774    else
    78         for (num = p; isdecdigit(*p); ++p);
     75        for (num = p; isdigit(*p); ++p)
     76            continue;
    7977
    8078    /* check for no number */
     
    8987    }
    9088
    91     bb_dump_skip = strtol(num, &end, base ? base : 8);
     89    dumper->dump_skip = strtol(num, &end, base ? base : 8);
    9290
    9391    /* if end isn't the same as p, we got a non-octal digit */
    9492    if (end != p)
    95         bb_dump_skip = 0;
     93        dumper->dump_skip = 0;
    9694    else {
    9795        if (*p) {
    9896            if (*p == 'b') {
    99                 bb_dump_skip *= 512;
     97                dumper->dump_skip *= 512;
    10098                ++p;
    10199            } else if (*p == 'B') {
    102                 bb_dump_skip *= 1024;
     100                dumper->dump_skip *= 1024;
    103101                ++p;
    104102            }
    105103        }
    106104        if (*p)
    107             bb_dump_skip = 0;
     105            dumper->dump_skip = 0;
    108106        else {
    109107            ++*argvp;
     
    113111             * but it's easy.
    114112             */
    115 #define TYPE_OFFSET 7
     113#define TYPE_OFFSET 7
    116114            {
    117115                char x_or_d;
     
    122120                if (base == 10) {
    123121                    x_or_d = 'd';
    124                 DO_X_OR_D:
    125                     bb_dump_fshead->nextfu->fmt[TYPE_OFFSET]
    126                         = bb_dump_fshead->nextfs->nextfu->fmt[TYPE_OFFSET]
     122 DO_X_OR_D:
     123                    dumper->fshead->nextfu->fmt[TYPE_OFFSET]
     124                        = dumper->fshead->nextfs->nextfu->fmt[TYPE_OFFSET]
    127125                        = x_or_d;
    128126                }
     
    133131
    134132static const char *const add_strings[] = {
    135     "16/1 \"%3_u \" \"\\n\"",               /* a */
    136     "8/2 \" %06o \" \"\\n\"",               /* B, o */
    137     "16/1 \"%03o \" \"\\n\"",               /* b */
    138     "16/1 \"%3_c \" \"\\n\"",               /* c */
    139     "8/2 \"  %05u \" \"\\n\"",              /* d */
    140     "4/4 \"     %010u \" \"\\n\"",          /* D */
    141     "2/8 \"          %21.14e \" \"\\n\"",   /* e (undocumented in od), F */
    142     "4/4 \" %14.7e \" \"\\n\"",             /* f */
    143     "4/4 \"       %08x \" \"\\n\"",         /* H, X */
    144     "8/2 \"   %04x \" \"\\n\"",             /* h, x */
    145     "4/4 \"    %11d \" \"\\n\"",            /* I, L, l */
    146     "8/2 \" %6d \" \"\\n\"",                /* i */
    147     "4/4 \"    %011o \" \"\\n\"",           /* O */
     133    "16/1 \"%3_u \" \"\\n\"",              /* a */
     134    "8/2 \" %06o \" \"\\n\"",              /* B, o */
     135    "16/1 \"%03o \" \"\\n\"",              /* b */
     136    "16/1 \"%3_c \" \"\\n\"",              /* c */
     137    "8/2 \"  %05u \" \"\\n\"",             /* d */
     138    "4/4 \"     %010u \" \"\\n\"",         /* D */
     139    "2/8 \"          %21.14e \" \"\\n\"",  /* e (undocumented in od), F */
     140    "4/4 \" %14.7e \" \"\\n\"",            /* f */
     141    "4/4 \"       %08x \" \"\\n\"",        /* H, X */
     142    "8/2 \"   %04x \" \"\\n\"",            /* h, x */
     143    "4/4 \"    %11d \" \"\\n\"",           /* I, L, l */
     144    "8/2 \" %6d \" \"\\n\"",               /* i */
     145    "4/4 \"    %011o \" \"\\n\"",          /* O */
    148146};
    149147
     
    157155};
    158156
    159 int od_main(int argc, char **argv);
     157int od_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    160158int od_main(int argc, char **argv)
    161159{
     
    163161    int first = 1;
    164162    char *p;
    165     bb_dump_vflag = FIRST;
    166     bb_dump_length = -1;
     163    dumper_t *dumper = alloc_dumper();
    167164
    168165    while ((ch = getopt(argc, argv, od_opts)) > 0) {
    169166        if (ch == 'v') {
    170             bb_dump_vflag = ALL;
     167            dumper->dump_vflag = ALL;
    171168        } else if (((p = strchr(od_opts, ch)) != NULL) && (*p != '\0')) {
    172169            if (first) {
    173170                first = 0;
    174                 bb_dump_add("\"%07.7_Ao\n\"");
    175                 bb_dump_add("\"%07.7_ao  \"");
     171                bb_dump_add(dumper, "\"%07.7_Ao\n\"");
     172                bb_dump_add(dumper, "\"%07.7_ao  \"");
    176173            } else {
    177                 bb_dump_add("\"         \"");
     174                bb_dump_add(dumper, "\"         \"");
    178175            }
    179             bb_dump_add(add_strings[(int)od_o2si[(p-od_opts)]]);
    180         } else {    /* P, p, s, w, or other unhandled */
     176            bb_dump_add(dumper, add_strings[(int)od_o2si[(p - od_opts)]]);
     177        } else {  /* P, p, s, w, or other unhandled */
    181178            bb_show_usage();
    182179        }
    183180    }
    184     if (!bb_dump_fshead) {
    185         bb_dump_add("\"%07.7_Ao\n\"");
    186         bb_dump_add("\"%07.7_ao  \" 8/2 \"%06o \" \"\\n\"");
     181    if (!dumper->fshead) {
     182        bb_dump_add(dumper, "\"%07.7_Ao\n\"");
     183        bb_dump_add(dumper, "\"%07.7_ao  \" 8/2 \"%06o \" \"\\n\"");
    187184    }
    188185
     
    190187    argv += optind;
    191188
    192     odoffset(argc, &argv);
    193 
    194     return bb_dump_dump(argv);
     189    odoffset(dumper, argc, &argv);
     190
     191    return bb_dump_dump(dumper, argv);
    195192}
    196193#endif /* ENABLE_DESKTOP */
Note: See TracChangeset for help on using the changeset viewer.