diff options
-rw-r--r-- | archival/dpkg.c | 2 | ||||
-rw-r--r-- | archival/tar.c | 2 | ||||
-rw-r--r-- | coreutils/cut.c | 2 | ||||
-rw-r--r-- | coreutils/md5_sha1_sum.c | 2 | ||||
-rw-r--r-- | coreutils/sort.c | 4 | ||||
-rw-r--r-- | coreutils/uniq.c | 2 | ||||
-rw-r--r-- | coreutils/uudecode.c | 4 | ||||
-rw-r--r-- | editors/patch.c | 14 | ||||
-rw-r--r-- | editors/sed.c | 4 | ||||
-rw-r--r-- | findutils/grep.c | 4 | ||||
-rw-r--r-- | include/libbb.h | 5 | ||||
-rw-r--r-- | libbb/get_line_from_file.c | 4 | ||||
-rw-r--r-- | miscutils/dc.c | 2 | ||||
-rw-r--r-- | miscutils/makedevs.c | 2 | ||||
-rw-r--r-- | networking/dnsd.c | 2 | ||||
-rw-r--r-- | networking/ifupdown.c | 2 | ||||
-rw-r--r-- | networking/nameif.c | 2 | ||||
-rw-r--r-- | shell/cmdedit.c | 2 | ||||
-rw-r--r-- | util-linux/hexdump.c | 2 | ||||
-rw-r--r-- | util-linux/mount.c | 2 |
20 files changed, 33 insertions, 32 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c index 825a8c1d2..4d0f3fbf3 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c | |||
@@ -1206,7 +1206,7 @@ static char **create_list(const char *filename) | |||
1206 | return NULL; | 1206 | return NULL; |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | while ((line = bb_get_chomped_line_from_file(list_stream)) != NULL) { | 1209 | while ((line = xmalloc_getline(list_stream)) != NULL) { |
1210 | file_list = xrealloc(file_list, sizeof(char *) * (count + 2)); | 1210 | file_list = xrealloc(file_list, sizeof(char *) * (count + 2)); |
1211 | file_list[count] = line; | 1211 | file_list[count] = line; |
1212 | count++; | 1212 | count++; |
diff --git a/archival/tar.c b/archival/tar.c index 5ebb3dff4..5935ccaa3 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -523,7 +523,7 @@ static llist_t *append_file_list_to_list(llist_t *list) | |||
523 | tmp = cur; | 523 | tmp = cur; |
524 | cur = cur->link; | 524 | cur = cur->link; |
525 | free(tmp); | 525 | free(tmp); |
526 | while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL) { | 526 | while ((line = xmalloc_getline(src_stream)) != NULL) { |
527 | char *filename_ptr = last_char_is(line, '/'); | 527 | char *filename_ptr = last_char_is(line, '/'); |
528 | if (filename_ptr > line) | 528 | if (filename_ptr > line) |
529 | *filename_ptr = '\0'; | 529 | *filename_ptr = '\0'; |
diff --git a/coreutils/cut.c b/coreutils/cut.c index 94e12e609..5dc35434f 100644 --- a/coreutils/cut.c +++ b/coreutils/cut.c | |||
@@ -50,7 +50,7 @@ static void cut_file(FILE * file) | |||
50 | unsigned int linenum = 0; /* keep these zero-based to be consistent */ | 50 | unsigned int linenum = 0; /* keep these zero-based to be consistent */ |
51 | 51 | ||
52 | /* go through every line in the file */ | 52 | /* go through every line in the file */ |
53 | while ((line = bb_get_chomped_line_from_file(file)) != NULL) { | 53 | while ((line = xmalloc_getline(file)) != NULL) { |
54 | 54 | ||
55 | /* set up a list so we can keep track of what's been printed */ | 55 | /* set up a list so we can keep track of what's been printed */ |
56 | char * printed = xzalloc(strlen(line) * sizeof(char)); | 56 | char * printed = xzalloc(strlen(line) * sizeof(char)); |
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c index a99e45864..ca23d8ac4 100644 --- a/coreutils/md5_sha1_sum.c +++ b/coreutils/md5_sha1_sum.c | |||
@@ -126,7 +126,7 @@ int md5_sha1_sum_main(int argc, char **argv) | |||
126 | pre_computed_stream = xfopen(file_ptr, "r"); | 126 | pre_computed_stream = xfopen(file_ptr, "r"); |
127 | } | 127 | } |
128 | 128 | ||
129 | while ((line = bb_get_chomped_line_from_file(pre_computed_stream)) != NULL) { | 129 | while ((line = xmalloc_getline(pre_computed_stream)) != NULL) { |
130 | char *filename_ptr; | 130 | char *filename_ptr; |
131 | 131 | ||
132 | count_total++; | 132 | count_total++; |
diff --git a/coreutils/sort.c b/coreutils/sort.c index e789292b9..c23c14226 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c | |||
@@ -124,9 +124,9 @@ static struct sort_key *add_key(void) | |||
124 | } | 124 | } |
125 | 125 | ||
126 | #define GET_LINE(fp) (global_flags&FLAG_z) ? bb_get_chunk_from_file(fp,NULL) \ | 126 | #define GET_LINE(fp) (global_flags&FLAG_z) ? bb_get_chunk_from_file(fp,NULL) \ |
127 | : bb_get_chomped_line_from_file(fp) | 127 | : xmalloc_getline(fp) |
128 | #else | 128 | #else |
129 | #define GET_LINE(fp) bb_get_chomped_line_from_file(fp) | 129 | #define GET_LINE(fp) xmalloc_getline(fp) |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | /* Iterate through keys list and perform comparisons */ | 132 | /* Iterate through keys list and perform comparisons */ |
diff --git a/coreutils/uniq.c b/coreutils/uniq.c index 1b201af24..a7b7a8e07 100644 --- a/coreutils/uniq.c +++ b/coreutils/uniq.c | |||
@@ -69,7 +69,7 @@ int uniq_main(int argc, char **argv) | |||
69 | dups = 0; | 69 | dups = 0; |
70 | 70 | ||
71 | /* gnu uniq ignores newlines */ | 71 | /* gnu uniq ignores newlines */ |
72 | while ((s1 = bb_get_chomped_line_from_file(in)) != NULL) { | 72 | while ((s1 = xmalloc_getline(in)) != NULL) { |
73 | e1 = s1; | 73 | e1 = s1; |
74 | for (i=skip_fields ; i ; i--) { | 74 | for (i=skip_fields ; i ; i--) { |
75 | e1 = skip_whitespace(e1); | 75 | e1 = skip_whitespace(e1); |
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index 921d29af0..c8152a808 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c | |||
@@ -18,7 +18,7 @@ static int read_stduu(FILE *src_stream, FILE *dst_stream) | |||
18 | { | 18 | { |
19 | char *line; | 19 | char *line; |
20 | 20 | ||
21 | while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL) { | 21 | while ((line = xmalloc_getline(src_stream)) != NULL) { |
22 | int length; | 22 | int length; |
23 | char *line_ptr = line; | 23 | char *line_ptr = line; |
24 | 24 | ||
@@ -140,7 +140,7 @@ int uudecode_main(int argc, char **argv) | |||
140 | } | 140 | } |
141 | 141 | ||
142 | /* Search for the start of the encoding */ | 142 | /* Search for the start of the encoding */ |
143 | while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL) { | 143 | while ((line = xmalloc_getline(src_stream)) != NULL) { |
144 | int (*decode_fn_ptr)(FILE * src, FILE * dst); | 144 | int (*decode_fn_ptr)(FILE * src, FILE * dst); |
145 | char *line_ptr; | 145 | char *line_ptr; |
146 | FILE *dst_stream; | 146 | FILE *dst_stream; |
diff --git a/editors/patch.c b/editors/patch.c index 9336b275a..545e70b50 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
@@ -32,7 +32,7 @@ static unsigned int copy_lines(FILE *src_stream, FILE *dest_stream, const unsign | |||
32 | 32 | ||
33 | while (src_stream && (i < lines_count)) { | 33 | while (src_stream && (i < lines_count)) { |
34 | char *line; | 34 | char *line; |
35 | line = bb_get_line_from_file(src_stream); | 35 | line = xmalloc_fgets(src_stream); |
36 | if (line == NULL) { | 36 | if (line == NULL) { |
37 | break; | 37 | break; |
38 | } | 38 | } |
@@ -96,7 +96,7 @@ int patch_main(int argc, char **argv) | |||
96 | ret = 0; | 96 | ret = 0; |
97 | } | 97 | } |
98 | 98 | ||
99 | patch_line = bb_get_line_from_file(patch_file); | 99 | patch_line = xmalloc_fgets(patch_file); |
100 | while (patch_line) { | 100 | while (patch_line) { |
101 | FILE *src_stream; | 101 | FILE *src_stream; |
102 | FILE *dst_stream; | 102 | FILE *dst_stream; |
@@ -115,14 +115,14 @@ int patch_main(int argc, char **argv) | |||
115 | */ | 115 | */ |
116 | while (patch_line && strncmp(patch_line, "--- ", 4) != 0) { | 116 | while (patch_line && strncmp(patch_line, "--- ", 4) != 0) { |
117 | free(patch_line); | 117 | free(patch_line); |
118 | patch_line = bb_get_line_from_file(patch_file); | 118 | patch_line = xmalloc_fgets(patch_file); |
119 | } | 119 | } |
120 | 120 | ||
121 | /* Extract the filename used before the patch was generated */ | 121 | /* Extract the filename used before the patch was generated */ |
122 | original_filename = extract_filename(patch_line, patch_level); | 122 | original_filename = extract_filename(patch_line, patch_level); |
123 | free(patch_line); | 123 | free(patch_line); |
124 | 124 | ||
125 | patch_line = bb_get_line_from_file(patch_file); | 125 | patch_line = xmalloc_fgets(patch_file); |
126 | if (strncmp(patch_line, "+++ ", 4) != 0) { | 126 | if (strncmp(patch_line, "+++ ", 4) != 0) { |
127 | ret = 2; | 127 | ret = 2; |
128 | bb_error_msg("Invalid patch"); | 128 | bb_error_msg("Invalid patch"); |
@@ -166,7 +166,7 @@ int patch_main(int argc, char **argv) | |||
166 | printf("patching file %s\n", new_filename); | 166 | printf("patching file %s\n", new_filename); |
167 | 167 | ||
168 | /* Handle each hunk */ | 168 | /* Handle each hunk */ |
169 | patch_line = bb_get_line_from_file(patch_file); | 169 | patch_line = xmalloc_fgets(patch_file); |
170 | while (patch_line) { | 170 | while (patch_line) { |
171 | unsigned int count; | 171 | unsigned int count; |
172 | unsigned int src_beg_line; | 172 | unsigned int src_beg_line; |
@@ -197,11 +197,11 @@ int patch_main(int argc, char **argv) | |||
197 | } | 197 | } |
198 | hunk_offset_start = src_cur_line; | 198 | hunk_offset_start = src_cur_line; |
199 | 199 | ||
200 | while ((patch_line = bb_get_line_from_file(patch_file)) != NULL) { | 200 | while ((patch_line = xmalloc_fgets(patch_file)) != NULL) { |
201 | if ((*patch_line == '-') || (*patch_line == ' ')) { | 201 | if ((*patch_line == '-') || (*patch_line == ' ')) { |
202 | char *src_line = NULL; | 202 | char *src_line = NULL; |
203 | if (src_stream) { | 203 | if (src_stream) { |
204 | src_line = bb_get_line_from_file(src_stream); | 204 | src_line = xmalloc_fgets(src_stream); |
205 | if (!src_line) { | 205 | if (!src_line) { |
206 | hunk_error++; | 206 | hunk_error++; |
207 | break; | 207 | break; |
diff --git a/editors/sed.c b/editors/sed.c index 7dba8b456..30f35ce22 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -904,7 +904,7 @@ restart: | |||
904 | if (rfile) { | 904 | if (rfile) { |
905 | char *line; | 905 | char *line; |
906 | 906 | ||
907 | while ((line = bb_get_chomped_line_from_file(rfile)) | 907 | while ((line = xmalloc_getline(rfile)) |
908 | != NULL) | 908 | != NULL) |
909 | append(line); | 909 | append(line); |
910 | xprint_and_close_file(rfile); | 910 | xprint_and_close_file(rfile); |
@@ -1099,7 +1099,7 @@ static void add_files_link(llist_t *opt_f) | |||
1099 | if (!opt_f) return; | 1099 | if (!opt_f) return; |
1100 | add_files_link(opt_f->link); | 1100 | add_files_link(opt_f->link); |
1101 | cmdfile = xfopen(opt_f->data, "r"); | 1101 | cmdfile = xfopen(opt_f->data, "r"); |
1102 | while ((line = bb_get_chomped_line_from_file(cmdfile)) != NULL) { | 1102 | while ((line = xmalloc_getline(cmdfile)) != NULL) { |
1103 | add_cmd(line); | 1103 | add_cmd(line); |
1104 | free(line); | 1104 | free(line); |
1105 | } | 1105 | } |
diff --git a/findutils/grep.c b/findutils/grep.c index ce975e771..c0c495bd1 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -123,7 +123,7 @@ static int grep_file(FILE *file) | |||
123 | int idx = 0; /* used for iteration through the circular buffer */ | 123 | int idx = 0; /* used for iteration through the circular buffer */ |
124 | #endif /* ENABLE_FEATURE_GREP_CONTEXT */ | 124 | #endif /* ENABLE_FEATURE_GREP_CONTEXT */ |
125 | 125 | ||
126 | while ((line = bb_get_chomped_line_from_file(file)) != NULL) { | 126 | while ((line = xmalloc_getline(file)) != NULL) { |
127 | llist_t *pattern_ptr = pattern_head; | 127 | llist_t *pattern_ptr = pattern_head; |
128 | grep_list_data_t * gl; | 128 | grep_list_data_t * gl; |
129 | 129 | ||
@@ -280,7 +280,7 @@ static void load_regexes_from_file(llist_t *fopt) | |||
280 | fopt = cur->link; | 280 | fopt = cur->link; |
281 | free(cur); | 281 | free(cur); |
282 | f = xfopen(ffile, "r"); | 282 | f = xfopen(ffile, "r"); |
283 | while ((line = bb_get_chomped_line_from_file(f)) != NULL) { | 283 | while ((line = xmalloc_getline(f)) != NULL) { |
284 | llist_add_to(&pattern_head, | 284 | llist_add_to(&pattern_head, |
285 | new_grep_list_data(line, PATTERN_MEM_A)); | 285 | new_grep_list_data(line, PATTERN_MEM_A)); |
286 | } | 286 | } |
diff --git a/include/libbb.h b/include/libbb.h index ac48411c0..767a3378b 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -230,8 +230,9 @@ extern void erase_mtab(const char * name); | |||
230 | extern long *find_pid_by_name( const char* pidName); | 230 | extern long *find_pid_by_name( const char* pidName); |
231 | extern long *pidlist_reverse(long *pidList); | 231 | extern long *pidlist_reverse(long *pidList); |
232 | extern char *find_block_device(char *path); | 232 | extern char *find_block_device(char *path); |
233 | extern char *bb_get_line_from_file(FILE *file); | 233 | extern char *xmalloc_fgets(FILE *file); |
234 | extern char *bb_get_chomped_line_from_file(FILE *file); | 234 | /* Chops off '\n' from the end, unlike fgets: */ |
235 | extern char *xmalloc_getline(FILE *file); | ||
235 | extern char *bb_get_chunk_from_file(FILE *file, int *end); | 236 | extern char *bb_get_chunk_from_file(FILE *file, int *end); |
236 | extern off_t bb_copyfd_size(int fd1, int fd2, off_t size); | 237 | extern off_t bb_copyfd_size(int fd1, int fd2, off_t size); |
237 | extern off_t bb_copyfd_eof(int fd1, int fd2); | 238 | extern off_t bb_copyfd_eof(int fd1, int fd2); |
diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c index 722a904b5..969d808cf 100644 --- a/libbb/get_line_from_file.c +++ b/libbb/get_line_from_file.c | |||
@@ -48,7 +48,7 @@ char *bb_get_chunk_from_file(FILE * file, int *end) | |||
48 | } | 48 | } |
49 | 49 | ||
50 | /* Get line, including trailing \n if any */ | 50 | /* Get line, including trailing \n if any */ |
51 | char *bb_get_line_from_file(FILE * file) | 51 | char *xmalloc_fgets(FILE * file) |
52 | { | 52 | { |
53 | int i; | 53 | int i; |
54 | 54 | ||
@@ -56,7 +56,7 @@ char *bb_get_line_from_file(FILE * file) | |||
56 | } | 56 | } |
57 | 57 | ||
58 | /* Get line. Remove trailing \n */ | 58 | /* Get line. Remove trailing \n */ |
59 | char *bb_get_chomped_line_from_file(FILE * file) | 59 | char *xmalloc_getline(FILE * file) |
60 | { | 60 | { |
61 | int i; | 61 | int i; |
62 | char *c = bb_get_chunk_from_file(file, &i); | 62 | char *c = bb_get_chunk_from_file(file, &i); |
diff --git a/miscutils/dc.c b/miscutils/dc.c index 8e7a2494c..fd5390143 100644 --- a/miscutils/dc.c +++ b/miscutils/dc.c | |||
@@ -208,7 +208,7 @@ int dc_main(int argc, char **argv) | |||
208 | char *line = NULL; | 208 | char *line = NULL; |
209 | char *cursor = NULL; | 209 | char *cursor = NULL; |
210 | char *token = NULL; | 210 | char *token = NULL; |
211 | while ((line = bb_get_chomped_line_from_file(stdin))) { | 211 | while ((line = xmalloc_getline(stdin))) { |
212 | cursor = line; | 212 | cursor = line; |
213 | len = number_of_tokens(line); | 213 | len = number_of_tokens(line); |
214 | for (i = 0; i < len; i++) { | 214 | for (i = 0; i < len; i++) { |
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c index e27634add..e4658010c 100644 --- a/miscutils/makedevs.c +++ b/miscutils/makedevs.c | |||
@@ -95,7 +95,7 @@ int makedevs_main(int argc, char **argv) | |||
95 | printf("table=<stdin>\n"); | 95 | printf("table=<stdin>\n"); |
96 | } | 96 | } |
97 | 97 | ||
98 | while ((line = bb_get_chomped_line_from_file(table))) { | 98 | while ((line = xmalloc_getline(table))) { |
99 | char type; | 99 | char type; |
100 | unsigned int mode = 0755; | 100 | unsigned int mode = 0755; |
101 | unsigned int major = 0; | 101 | unsigned int major = 0; |
diff --git a/networking/dnsd.c b/networking/dnsd.c index 35f6c1096..6f9dc5d67 100644 --- a/networking/dnsd.c +++ b/networking/dnsd.c | |||
@@ -138,7 +138,7 @@ static int getfileentry(FILE * fp, struct dns_entry *s) | |||
138 | char *r, *name; | 138 | char *r, *name; |
139 | 139 | ||
140 | restart: | 140 | restart: |
141 | r = bb_get_line_from_file(fp); | 141 | r = xmalloc_fgets(fp); |
142 | if (!r) | 142 | if (!r) |
143 | return -1; | 143 | return -1; |
144 | while (*r == ' ' || *r == '\t') { | 144 | while (*r == ' ' || *r == '\t') { |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index c1dc1d35d..00eb576f4 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -649,7 +649,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |||
649 | 649 | ||
650 | f = xfopen(filename, "r"); | 650 | f = xfopen(filename, "r"); |
651 | 651 | ||
652 | while ((buf = bb_get_chomped_line_from_file(f)) != NULL) { | 652 | while ((buf = xmalloc_getline(f)) != NULL) { |
653 | char *buf_ptr = buf; | 653 | char *buf_ptr = buf; |
654 | 654 | ||
655 | firstword = next_word(&buf_ptr); | 655 | firstword = next_word(&buf_ptr); |
diff --git a/networking/nameif.c b/networking/nameif.c index f60a97e8b..385e7fb71 100644 --- a/networking/nameif.c +++ b/networking/nameif.c | |||
@@ -91,7 +91,7 @@ int nameif_main(int argc, char **argv) | |||
91 | } else { | 91 | } else { |
92 | ifh = xfopen(fname, "r"); | 92 | ifh = xfopen(fname, "r"); |
93 | 93 | ||
94 | while ((line = bb_get_line_from_file(ifh)) != NULL) { | 94 | while ((line = xmalloc_fgets(ifh)) != NULL) { |
95 | char *line_ptr; | 95 | char *line_ptr; |
96 | size_t name_length; | 96 | size_t name_length; |
97 | 97 | ||
diff --git a/shell/cmdedit.c b/shell/cmdedit.c index 7b4d46511..3f44ea013 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c | |||
@@ -1205,7 +1205,7 @@ void load_history ( const char *fromfile ) | |||
1205 | if (( fp = fopen ( fromfile, "r" ))) { | 1205 | if (( fp = fopen ( fromfile, "r" ))) { |
1206 | 1206 | ||
1207 | for ( hi = 0; hi < MAX_HISTORY; ) { | 1207 | for ( hi = 0; hi < MAX_HISTORY; ) { |
1208 | char * hl = bb_get_chomped_line_from_file(fp); | 1208 | char * hl = xmalloc_getline(fp); |
1209 | int l; | 1209 | int l; |
1210 | 1210 | ||
1211 | if(!hl) | 1211 | if(!hl) |
diff --git a/util-linux/hexdump.c b/util-linux/hexdump.c index 03b222dd0..5cb245feb 100644 --- a/util-linux/hexdump.c +++ b/util-linux/hexdump.c | |||
@@ -21,7 +21,7 @@ static void bb_dump_addfile(char *name) | |||
21 | 21 | ||
22 | fp = xfopen(name, "r"); | 22 | fp = xfopen(name, "r"); |
23 | 23 | ||
24 | while ((buf = bb_get_chomped_line_from_file(fp)) != NULL) { | 24 | while ((buf = xmalloc_getline(fp)) != NULL) { |
25 | p = skip_whitespace(buf); | 25 | p = skip_whitespace(buf); |
26 | 26 | ||
27 | if (*p && (*p != '#')) { | 27 | if (*p && (*p != '#')) { |
diff --git a/util-linux/mount.c b/util-linux/mount.c index 5448f1f21..9793b825a 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -186,7 +186,7 @@ static llist_t *get_block_backed_filesystems(void) | |||
186 | f = fopen(filesystems[i], "r"); | 186 | f = fopen(filesystems[i], "r"); |
187 | if (!f) continue; | 187 | if (!f) continue; |
188 | 188 | ||
189 | while ((buf = bb_get_chomped_line_from_file(f)) != 0) { | 189 | while ((buf = xmalloc_getline(f)) != 0) { |
190 | if (!strncmp(buf, "nodev", 5) && isspace(buf[5])) | 190 | if (!strncmp(buf, "nodev", 5) && isspace(buf[5])) |
191 | continue; | 191 | continue; |
192 | fs = buf; | 192 | fs = buf; |