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/util-linux/readprofile.c

    r1765 r2725  
    55 *  Copyright (C) 1994,1996 Alessandro Rubini (rubini@ipvvis.unipv.it)
    66 *
    7  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
     7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    88 */
    99
    1010/*
    11  * 1999-02-22 Arkadiusz Mikiewicz <misiek@pld.ORG.PL>
     11 * 1999-02-22 Arkadiusz Mickiewicz <misiek@pld.ORG.PL>
    1212 * - added Native Language Support
    1313 * 1999-09-01 Stephane Eranian <eranian@cello.hpl.hp.com>
     
    4242static const char defaultpro[] ALIGN1 = "/proc/profile";
    4343
    44 int readprofile_main(int argc, char **argv);
    45 int readprofile_main(int argc, char **argv)
     44int readprofile_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     45int readprofile_main(int argc UNUSED_PARAM, char **argv)
    4646{
    4747    FILE *map;
    48     const char *mapFile, *proFile, *mult = 0;
     48    const char *mapFile, *proFile;
    4949    unsigned long indx = 1;
    5050    size_t len;
     
    5656    char mapline[S_LEN];
    5757    char mode[8];
    58     int optAll = 0, optInfo = 0, optReset = 0;
    59     int optVerbose = 0, optNative = 0;
    60     int optBins = 0, optSub = 0;
    6158    int maplineno = 1;
    6259    int header_printed;
     60    int multiplier = 0;
     61    unsigned opt;
     62    enum {
     63        OPT_M = (1 << 0),
     64        OPT_m = (1 << 1),
     65        OPT_p = (1 << 2),
     66        OPT_n = (1 << 3),
     67        OPT_a = (1 << 4),
     68        OPT_b = (1 << 5),
     69        OPT_s = (1 << 6),
     70        OPT_i = (1 << 7),
     71        OPT_r = (1 << 8),
     72        OPT_v = (1 << 9),
     73    };
     74#define optMult    (opt & OPT_M)
     75#define optNative  (opt & OPT_n)
     76#define optAll     (opt & OPT_a)
     77#define optBins    (opt & OPT_b)
     78#define optSub     (opt & OPT_s)
     79#define optInfo    (opt & OPT_i)
     80#define optReset   (opt & OPT_r)
     81#define optVerbose (opt & OPT_v)
    6382
    6483#define next (current^1)
     
    6786    mapFile = defaultmap;
    6887
    69     opt_complementary = "nn:aa:bb:ss:ii:rr:vv";
    70     getopt32(argv, "M:m:p:nabsirv",
    71             &mult, &mapFile, &proFile,
    72             &optNative, &optAll, &optBins, &optSub,
    73             &optInfo, &optReset, &optVerbose);
    74 
    75     if (optReset || mult) {
    76         int multiplier, fd, to_write;
     88    opt_complementary = "M+"; /* -M N */
     89    opt = getopt32(argv, "M:m:p:nabsirv", &multiplier, &mapFile, &proFile);
     90
     91    if (opt & (OPT_M|OPT_r)) { /* mult or reset, or both */
     92        int fd, to_write;
    7793
    7894        /*
     
    8096         * not sizeof(int), the multiplier is not changed
    8197         */
    82         if (mult) {
    83             multiplier = xatoi_u(mult);
    84             to_write = sizeof(int);
    85         } else {
    86             multiplier = 0;
    87             to_write = 1;   /* sth different from sizeof(int) */
    88         }
     98        to_write = sizeof(int);
     99        if (!optMult)
     100            to_write = 1;  /* sth different from sizeof(int) */
    89101
    90102        fd = xopen(defaultpro, O_WRONLY);
    91 
    92         if (full_write(fd, &multiplier, to_write) != to_write)
    93             bb_perror_msg_and_die("error writing %s", defaultpro);
    94 
     103        xwrite(fd, &multiplier, to_write);
    95104        close(fd);
    96105        return EXIT_SUCCESS;
     
    101110     */
    102111    len = MAXINT(ssize_t);
    103     buf = xmalloc_open_read_close(proFile, &len);
     112    buf = xmalloc_xopen_read_close(proFile, &len);
    104113    if (!optNative) {
    105         int entries = len/sizeof(*buf);
     114        int entries = len / sizeof(*buf);
    106115        int big = 0, small = 0, i;
    107116        unsigned *p;
     
    136145    total = 0;
    137146
    138     map = xfopen(mapFile, "r");
     147    map = xfopen_for_read(mapFile);
    139148
    140149    while (fgets(mapline, S_LEN, map)) {
     
    168177           Absolute symbols */
    169178        if ((*mode == 'A' || *mode == '?') && total == 0) continue;
    170         if (*mode != 'T' && *mode != 't' &&
    171             *mode != 'W' && *mode != 'w')
    172             break;  /* only text is profiled */
     179        if (*mode != 'T' && *mode != 't'
     180         && *mode != 'W' && *mode != 'w'
     181        ) {
     182            break;  /* only text is profiled */
     183        }
    173184
    174185        if (indx >= len / sizeof(*buf))
     
    191202            if (optVerbose || this > 0)
    192203                printf("  total\t\t\t\t%u\n", this);
    193         } else if ((this || optAll) &&
    194                (fn_len = next_add-fn_add) != 0) {
     204        } else if ((this || optAll)
     205                && (fn_len = next_add-fn_add) != 0
     206        ) {
    195207            if (optVerbose)
    196208                printf("%016llx %-40s %6i %8.4f\n", fn_add,
Note: See TracChangeset for help on using the changeset viewer.