Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/coreutils/tee.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/tee.c

    r1765 r2725  
    55 * Copyright (C) 2003  Manuel Novoa III  <mjn3@codepoet.org>
    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
     
    1212
    1313#include "libbb.h"
    14 #include <signal.h>
    1514
    16 int tee_main(int argc, char **argv);
     15int tee_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    1716int tee_main(int argc, char **argv)
    1817{
     
    2322    char **np;
    2423    char retval;
     24//TODO: make unconditional
    2525#if ENABLE_FEATURE_TEE_USE_BLOCK_IO
    2626    ssize_t c;
     
    3636
    3737    if (retval & 1) {
    38         signal(SIGINT, SIG_IGN); /* TODO - switch to sigaction. */
     38        signal(SIGINT, SIG_IGN); /* TODO - switch to sigaction. (why?) */
    3939    }
    4040    retval = EXIT_SUCCESS;
    4141    /* gnu tee ignores SIGPIPE in case one of the output files is a pipe
    4242     * that doesn't consume all its input.  Good idea... */
    43     signal(SIGPIPE, SIG_IGN);   /* TODO - switch to sigaction. */
     43    signal(SIGPIPE, SIG_IGN);
    4444
    45     /* Allocate an array of FILE *'s, with one extra for a sentinal. */
     45    /* Allocate an array of FILE *'s, with one extra for a sentinel. */
    4646    fp = files = xzalloc(sizeof(FILE *) * (argc + 2));
    4747    np = names = argv - 1;
     
    5050    goto GOT_NEW_FILE;
    5151    do {
    52         *fp = fopen_or_warn(*argv, mode);
    53         if (*fp == NULL) {
    54             retval = EXIT_FAILURE;
    55             continue;
     52        *fp = stdout;
     53        if (NOT_LONE_DASH(*argv)) {
     54            *fp = fopen_or_warn(*argv, mode);
     55            if (*fp == NULL) {
     56                retval = EXIT_FAILURE;
     57                argv++;
     58                continue;
     59            }
    5660        }
    5761        *np = *argv++;
    5862 GOT_NEW_FILE:
    59         setbuf(*fp++, NULL);    /* tee must not buffer output. */
     63        setbuf(*fp, NULL);  /* tee must not buffer output. */
     64        fp++;
    6065        np++;
    6166    } while (*argv);
     
    6368
    6469#if ENABLE_FEATURE_TEE_USE_BLOCK_IO
    65     while ((c = safe_read(STDIN_FILENO, buf, BUFSIZ)) > 0) {
     70    while ((c = safe_read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
    6671        fp = files;
    6772        do
    68             fwrite(buf, 1, c, *fp++);
    69         while (*fp);
     73            fwrite(buf, 1, c, *fp);
     74        while (*++fp);
    7075    }
    7176    if (c < 0) {        /* Make sure read errors are signaled. */
     
    7782        fp = files;
    7883        do
    79             putc(c, *fp++);
    80         while (*fp);
     84            putc(c, *fp);
     85        while (*++fp);
    8186    }
    8287#endif
Note: See TracChangeset for help on using the changeset viewer.