Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/coreutils/split.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/coreutils/split.c
r1765 r2725 2 2 /* 3 3 * split - split a file into pieces 4 * Copyright (c) 2007 Bernhard Fischer4 * Copyright (c) 2007 Bernhard Reutner-Fischer 5 5 * 6 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.6 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 7 */ 8 8 /* BB_AUDIT: SUSv3 compliant … … 21 21 { "g", 1024*1024*1024 }, 22 22 #endif 23 { }23 { "", 0 } 24 24 }; 25 25 … … 56 56 #define SPLIT_OPT_a (1<<2) 57 57 58 int split_main(int argc, char **argv) ;59 int split_main(int argc , char **argv)58 int split_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 59 int split_main(int argc UNUSED_PARAM, char **argv) 60 60 { 61 61 unsigned suffix_len = 2; … … 69 69 char *src; 70 70 71 opt_complementary = "?2 ";72 opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &s fx);71 opt_complementary = "?2:a+"; /* max 2 args; -a N */ 72 opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len); 73 73 74 74 if (opt & SPLIT_OPT_l) 75 cnt = xatoul(count_p); 76 if (opt & SPLIT_OPT_b) 77 cnt = xatoul_sfx(count_p, split_suffices); 78 if (opt & SPLIT_OPT_a) 79 suffix_len = xatou(sfx); 75 cnt = XATOOFF(count_p); 76 if (opt & SPLIT_OPT_b) // FIXME: also needs XATOOFF 77 cnt = xatoull_sfx(count_p, split_suffices); 80 78 sfx = "x"; 81 79 82 80 argv += optind; 83 81 if (argv[0]) { 82 int fd; 84 83 if (argv[1]) 85 84 sfx = argv[1]; 86 xmove_fd(xopen(argv[0], O_RDONLY), 0); 85 fd = xopen_stdin(argv[0]); 86 xmove_fd(fd, STDIN_FILENO); 87 87 } else { 88 88 argv[0] = (char *) bb_msg_standard_input; … … 101 101 102 102 while (1) { 103 bytes_read = safe_read( 0, read_buffer, READ_BUFFER_SIZE);103 bytes_read = safe_read(STDIN_FILENO, read_buffer, READ_BUFFER_SIZE); 104 104 if (!bytes_read) 105 105 break; 106 106 if (bytes_read < 0) 107 bb_ perror_msg_and_die("%s",argv[0]);107 bb_simple_perror_msg_and_die(argv[0]); 108 108 src = read_buffer; 109 109 do { … … 133 133 } 134 134 135 xwrite( 1, src, to_write);135 xwrite(STDOUT_FILENO, src, to_write); 136 136 bytes_read -= to_write; 137 137 src += to_write; 138 138 } while (bytes_read); 139 139 } 140 return 0;140 return EXIT_SUCCESS; 141 141 }
Note:
See TracChangeset
for help on using the changeset viewer.