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/cksum.c

    r821 r1765  
    44 *
    55 * Copyright (C) 2006 by Rob Sullivan, with ideas from code by Walter Harms
    6  * 
     6 *
    77 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */
    88
    9 #include <stdio.h>
    10 #include <unistd.h>
    11 #include <fcntl.h>
    12 #include "busybox.h"
     9#include "libbb.h"
    1310
    14 int cksum_main(int argc, char **argv) {
    15    
    16     uint32_t *crc32_table = bb_crc32_filltable(1);
     11int cksum_main(int argc, char **argv);
     12int cksum_main(int argc, char **argv)
     13{
     14    uint32_t *crc32_table = crc32_filltable(NULL, 1);
    1715
    1816    FILE *fp;
     
    2119    int bytes_read;
    2220    char *cp;
    23     RESERVE_CONFIG_BUFFER(buf, BUFSIZ);
     21
    2422    int inp_stdin = (argc == optind) ? 1 : 0;
    25    
     23
    2624    do {
    27         fp = bb_wfopen_input((inp_stdin) ? bb_msg_standard_input : *++argv);
    28            
     25        fp = fopen_or_warn_stdin((inp_stdin) ? bb_msg_standard_input : *++argv);
     26
    2927        crc = 0;
    3028        length = 0;
    31        
    32         while ((bytes_read = fread(buf, 1, BUFSIZ, fp)) > 0) {
    33             cp = buf;
     29
     30#define read_buf bb_common_bufsiz1
     31        while ((bytes_read = fread(read_buf, 1, BUFSIZ, fp)) > 0) {
     32            cp = read_buf;
    3433            length += bytes_read;
    3534            while (bytes_read--)
    3635                crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ (*cp++)) & 0xffL];
    3736        }
    38        
     37
    3938        filesize = length;
    40        
     39
    4140        for (; length; length >>= 8)
    4241            crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ length) & 0xffL];
     
    4443
    4544        if (inp_stdin) {
    46             printf("%"PRIu32" %li\n", crc, filesize);
     45            printf("%" PRIu32 " %li\n", crc, filesize);
    4746            break;
    4847        }
    49        
    50         printf("%"PRIu32" %li %s\n", crc, filesize, *argv);
     48
     49        printf("%" PRIu32 " %li %s\n", crc, filesize, *argv);
    5150        fclose(fp);
    52     } while (*(argv+1));
    53    
    54     return EXIT_SUCCESS;
     51    } while (*(argv + 1));
     52
     53    fflush_stdout_and_exit(EXIT_SUCCESS);
    5554}
Note: See TracChangeset for help on using the changeset viewer.