rename functions to more understandable names
This commit is contained in:
@ -9,7 +9,7 @@ lib-y:= \
|
||||
compare_string_array.o concat_path_file.o copy_file.o copyfd.o \
|
||||
crc32.o create_icmp_socket.o create_icmp6_socket.o \
|
||||
device_open.o dump.o error_msg.o error_msg_and_die.o \
|
||||
find_pid_by_name.o find_root_device.o fgets_str.o \
|
||||
find_pid_by_name.o find_root_device.o xmalloc_fgets_str.o \
|
||||
full_write.o get_last_path_component.o get_line_from_file.o \
|
||||
herror_msg.o herror_msg_and_die.o \
|
||||
human_readable.o inet_common.o inode_hash.o isdirectory.o \
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <stdio.h>
|
||||
#include <libbb.h>
|
||||
|
||||
int bb_fclose_nonstdin(FILE *f)
|
||||
int fclose_if_not_stdin(FILE *f)
|
||||
{
|
||||
if (f != stdin) {
|
||||
return fclose(f);
|
||||
|
@ -8,17 +8,12 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
/* Read up to (and including) TERMINATING_STRING from FILE and return it.
|
||||
* Return NULL on EOF. */
|
||||
|
||||
char *fgets_str(FILE *file, const char *terminating_string)
|
||||
char *xmalloc_fgets_str(FILE *file, const char *terminating_string)
|
||||
{
|
||||
char *linebuf = NULL;
|
||||
const int term_length = strlen(terminating_string);
|
||||
@ -36,7 +31,8 @@ char *fgets_str(FILE *file, const char *terminating_string)
|
||||
|
||||
/* grow the line buffer as necessary */
|
||||
while (idx > linebufsz - 2) {
|
||||
linebuf = xrealloc(linebuf, linebufsz += 1000);
|
||||
linebufsz += 200;
|
||||
linebuf = xrealloc(linebuf, linebufsz);
|
||||
}
|
||||
|
||||
linebuf[idx] = ch;
|
||||
|
@ -7,14 +7,12 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "libbb.h"
|
||||
|
||||
FILE *bb_wfopen(const char *path, const char *mode)
|
||||
FILE *fopen_or_warn(const char *path, const char *mode)
|
||||
{
|
||||
FILE *fp;
|
||||
if ((fp = fopen(path, mode)) == NULL) {
|
||||
FILE *fp = fopen(path, mode);
|
||||
if (!fp) {
|
||||
bb_perror_msg("%s", path);
|
||||
errno = 0;
|
||||
}
|
||||
|
@ -14,18 +14,17 @@
|
||||
* Note: We also consider "" to main stdin (for 'cmp' at least).
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <libbb.h>
|
||||
#include "libbb.h"
|
||||
|
||||
FILE *bb_wfopen_input(const char *filename)
|
||||
FILE *fopen_or_warn_stdin(const char *filename)
|
||||
{
|
||||
FILE *fp = stdin;
|
||||
|
||||
if ((filename != bb_msg_standard_input)
|
||||
&& filename[0] && ((filename[0] != '-') || filename[1])
|
||||
if (filename != bb_msg_standard_input
|
||||
&& filename[0]
|
||||
&& (filename[0] != '-' || filename[1])
|
||||
) {
|
||||
fp = bb_wfopen(filename, "r");
|
||||
fp = fopen_or_warn(filename, "r");
|
||||
}
|
||||
|
||||
return fp;
|
||||
|
@ -341,6 +341,7 @@ char *xasprintf(const char *format, ...)
|
||||
// close that file.
|
||||
void xprint_and_close_file(FILE *file)
|
||||
{
|
||||
fflush(stdout);
|
||||
// copyfd outputs error messages for us.
|
||||
if (bb_copyfd_eof(fileno(file), 1) == -1)
|
||||
exit(xfunc_error_retval);
|
||||
|
Reference in New Issue
Block a user