aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-10-26 23:25:17 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-10-26 23:25:17 +0000
commit467f463615e7329b267abea02da9ed9cedd2382b (patch)
treef4f2aa58fa669aed6e2c50bb7aa648a79ec1873d /libbb
parent6dc3a21627db11fa0f374afe29a6bbf4f89c8b64 (diff)
downloadbusybox-w32-467f463615e7329b267abea02da9ed9cedd2382b.tar.gz
busybox-w32-467f463615e7329b267abea02da9ed9cedd2382b.tar.bz2
busybox-w32-467f463615e7329b267abea02da9ed9cedd2382b.zip
rename functions to more understandable names
git-svn-id: svn://busybox.net/trunk/busybox@16447 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r--libbb/Kbuild2
-rw-r--r--libbb/fclose_nonstdin.c2
-rw-r--r--libbb/fgets_str.c10
-rw-r--r--libbb/wfopen.c8
-rw-r--r--libbb/wfopen_input.c13
-rw-r--r--libbb/xfuncs.c1
6 files changed, 15 insertions, 21 deletions
diff --git a/libbb/Kbuild b/libbb/Kbuild
index 0dd8c2be4..87c09bdfd 100644
--- a/libbb/Kbuild
+++ b/libbb/Kbuild
@@ -9,7 +9,7 @@ lib-y:= \
9 compare_string_array.o concat_path_file.o copy_file.o copyfd.o \ 9 compare_string_array.o concat_path_file.o copy_file.o copyfd.o \
10 crc32.o create_icmp_socket.o create_icmp6_socket.o \ 10 crc32.o create_icmp_socket.o create_icmp6_socket.o \
11 device_open.o dump.o error_msg.o error_msg_and_die.o \ 11 device_open.o dump.o error_msg.o error_msg_and_die.o \
12 find_pid_by_name.o find_root_device.o fgets_str.o \ 12 find_pid_by_name.o find_root_device.o xmalloc_fgets_str.o \
13 full_write.o get_last_path_component.o get_line_from_file.o \ 13 full_write.o get_last_path_component.o get_line_from_file.o \
14 herror_msg.o herror_msg_and_die.o \ 14 herror_msg.o herror_msg_and_die.o \
15 human_readable.o inet_common.o inode_hash.o isdirectory.o \ 15 human_readable.o inet_common.o inode_hash.o isdirectory.o \
diff --git a/libbb/fclose_nonstdin.c b/libbb/fclose_nonstdin.c
index be986d1b1..951ab30d6 100644
--- a/libbb/fclose_nonstdin.c
+++ b/libbb/fclose_nonstdin.c
@@ -15,7 +15,7 @@
15#include <stdio.h> 15#include <stdio.h>
16#include <libbb.h> 16#include <libbb.h>
17 17
18int bb_fclose_nonstdin(FILE *f) 18int fclose_if_not_stdin(FILE *f)
19{ 19{
20 if (f != stdin) { 20 if (f != stdin) {
21 return fclose(f); 21 return fclose(f);
diff --git a/libbb/fgets_str.c b/libbb/fgets_str.c
index 41370d176..1bc6c3b1c 100644
--- a/libbb/fgets_str.c
+++ b/libbb/fgets_str.c
@@ -8,17 +8,12 @@
8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
9 */ 9 */
10 10
11
12#include <stdio.h>
13#include <stdlib.h>
14#include <string.h>
15
16#include "libbb.h" 11#include "libbb.h"
17 12
18/* Read up to (and including) TERMINATING_STRING from FILE and return it. 13/* Read up to (and including) TERMINATING_STRING from FILE and return it.
19 * Return NULL on EOF. */ 14 * Return NULL on EOF. */
20 15
21char *fgets_str(FILE *file, const char *terminating_string) 16char *xmalloc_fgets_str(FILE *file, const char *terminating_string)
22{ 17{
23 char *linebuf = NULL; 18 char *linebuf = NULL;
24 const int term_length = strlen(terminating_string); 19 const int term_length = strlen(terminating_string);
@@ -36,7 +31,8 @@ char *fgets_str(FILE *file, const char *terminating_string)
36 31
37 /* grow the line buffer as necessary */ 32 /* grow the line buffer as necessary */
38 while (idx > linebufsz - 2) { 33 while (idx > linebufsz - 2) {
39 linebuf = xrealloc(linebuf, linebufsz += 1000); 34 linebufsz += 200;
35 linebuf = xrealloc(linebuf, linebufsz);
40 } 36 }
41 37
42 linebuf[idx] = ch; 38 linebuf[idx] = ch;
diff --git a/libbb/wfopen.c b/libbb/wfopen.c
index 9d663281e..26e6a13e2 100644
--- a/libbb/wfopen.c
+++ b/libbb/wfopen.c
@@ -7,14 +7,12 @@
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 tarball for details.
8 */ 8 */
9 9
10#include <stdio.h>
11#include <errno.h>
12#include "libbb.h" 10#include "libbb.h"
13 11
14FILE *bb_wfopen(const char *path, const char *mode) 12FILE *fopen_or_warn(const char *path, const char *mode)
15{ 13{
16 FILE *fp; 14 FILE *fp = fopen(path, mode);
17 if ((fp = fopen(path, mode)) == NULL) { 15 if (!fp) {
18 bb_perror_msg("%s", path); 16 bb_perror_msg("%s", path);
19 errno = 0; 17 errno = 0;
20 } 18 }
diff --git a/libbb/wfopen_input.c b/libbb/wfopen_input.c
index d764f1d06..3da855fe6 100644
--- a/libbb/wfopen_input.c
+++ b/libbb/wfopen_input.c
@@ -14,18 +14,17 @@
14 * Note: We also consider "" to main stdin (for 'cmp' at least). 14 * Note: We also consider "" to main stdin (for 'cmp' at least).
15 */ 15 */
16 16
17#include <stdio.h> 17#include "libbb.h"
18#include <sys/stat.h>
19#include <libbb.h>
20 18
21FILE *bb_wfopen_input(const char *filename) 19FILE *fopen_or_warn_stdin(const char *filename)
22{ 20{
23 FILE *fp = stdin; 21 FILE *fp = stdin;
24 22
25 if ((filename != bb_msg_standard_input) 23 if (filename != bb_msg_standard_input
26 && filename[0] && ((filename[0] != '-') || filename[1]) 24 && filename[0]
25 && (filename[0] != '-' || filename[1])
27 ) { 26 ) {
28 fp = bb_wfopen(filename, "r"); 27 fp = fopen_or_warn(filename, "r");
29 } 28 }
30 29
31 return fp; 30 return fp;
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index c5e18c312..1144a67c6 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -341,6 +341,7 @@ char *xasprintf(const char *format, ...)
341// close that file. 341// close that file.
342void xprint_and_close_file(FILE *file) 342void xprint_and_close_file(FILE *file)
343{ 343{
344 fflush(stdout);
344 // copyfd outputs error messages for us. 345 // copyfd outputs error messages for us.
345 if (bb_copyfd_eof(fileno(file), 1) == -1) 346 if (bb_copyfd_eof(fileno(file), 1) == -1)
346 exit(xfunc_error_retval); 347 exit(xfunc_error_retval);