Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (16 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/coreutils/fold.c

    r821 r1765  
     1/* vi: set sw=4 ts=4: */
    12/* fold -- wrap each input line to fit in specified width.
    23
     
    1011*/
    1112
    12 #include <ctype.h>
    13 #include <errno.h>
    14 #include <stdio.h>
    15 #include <stdlib.h>
    16 #include <string.h>
    17 #include <sys/types.h>
    18 #include <unistd.h>
    19 #include "busybox.h"
     13#include "libbb.h"
    2014
    2115static unsigned long flags;
     
    4539}
    4640
     41int fold_main(int argc, char **argv);
    4742int fold_main(int argc, char **argv)
    4843{
     44    char *line_out = NULL;
     45    int allocated_out = 0;
    4946    char *w_opt;
    5047    int width = 80;
     
    5249    int errs = 0;
    5350
    54     if(!ENABLE_DEBUG_YANK_SUSv2) {
     51    if (ENABLE_INCLUDE_SUSv2) {
    5552        /* Turn any numeric options into -w options.  */
    5653        for (i = 1; i < argc; i++) {
     
    6158                    break;
    6259                if (isdigit(*a)) {
    63                     argv[i] = bb_xasprintf("-w%s", a);
     60                    argv[i] = xasprintf("-w%s", a);
    6461                }
    6562            }
     
    6764    }
    6865
    69     flags = bb_getopt_ulflags(argc, argv, "bsw:", &w_opt);
     66    flags = getopt32(argv, "bsw:", &w_opt);
    7067    if (flags & FLAG_WIDTH)
    71         width = bb_xgetlarg(w_opt, 10, 1, 10000);
     68        width = xatoul_range(w_opt, 1, 10000);
    7269
    7370    argv += optind;
    7471    if (!*argv) {
    75         *--argv = "-";
     72        *--argv = (char*)"-";
    7673    }
    7774
    7875    do {
    79         FILE *istream = bb_wfopen_input(*argv);
     76        FILE *istream = fopen_or_warn_stdin(*argv);
    8077        int c;
    8178        int column = 0;     /* Screen column where next char will go. */
    8279        int offset_out = 0; /* Index in `line_out' for next char. */
    83         static char *line_out = NULL;
    84         static int allocated_out = 0;
    8580
    8681        if (istream == NULL) {
     
    10196                continue;
    10297            }
    103 
    104 rescan:
     98 rescan:
    10599            column = adjust_column(column, c);
    106100
     
    151145        }
    152146
    153         if (ferror(istream) || bb_fclose_nonstdin(istream)) {
     147        if (ferror(istream) || fclose_if_not_stdin(istream)) {
    154148            bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */
    155149            errs |= EXIT_FAILURE;
     
    157151    } while (*++argv);
    158152
    159     bb_fflush_stdout_and_exit(errs);
     153    fflush_stdout_and_exit(errs);
    160154}
    161 /* vi: set sw=4 ts=4: */
Note: See TracChangeset for help on using the changeset viewer.