Renaming...
return NULL;
}
- while ((line = bb_get_chomped_line_from_file(list_stream)) != NULL) {
+ while ((line = xmalloc_getline(list_stream)) != NULL) {
file_list = xrealloc(file_list, sizeof(char *) * (count + 2));
file_list[count] = line;
count++;
tmp = cur;
cur = cur->link;
free(tmp);
- while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL) {
+ while ((line = xmalloc_getline(src_stream)) != NULL) {
char *filename_ptr = last_char_is(line, '/');
if (filename_ptr > line)
*filename_ptr = '\0';
unsigned int linenum = 0; /* keep these zero-based to be consistent */
/* go through every line in the file */
- while ((line = bb_get_chomped_line_from_file(file)) != NULL) {
+ while ((line = xmalloc_getline(file)) != NULL) {
/* set up a list so we can keep track of what's been printed */
char * printed = xzalloc(strlen(line) * sizeof(char));
pre_computed_stream = xfopen(file_ptr, "r");
}
- while ((line = bb_get_chomped_line_from_file(pre_computed_stream)) != NULL) {
+ while ((line = xmalloc_getline(pre_computed_stream)) != NULL) {
char *filename_ptr;
count_total++;
}
#define GET_LINE(fp) (global_flags&FLAG_z) ? bb_get_chunk_from_file(fp,NULL) \
- : bb_get_chomped_line_from_file(fp)
+ : xmalloc_getline(fp)
#else
-#define GET_LINE(fp) bb_get_chomped_line_from_file(fp)
+#define GET_LINE(fp) xmalloc_getline(fp)
#endif
/* Iterate through keys list and perform comparisons */
dups = 0;
/* gnu uniq ignores newlines */
- while ((s1 = bb_get_chomped_line_from_file(in)) != NULL) {
+ while ((s1 = xmalloc_getline(in)) != NULL) {
e1 = s1;
for (i=skip_fields ; i ; i--) {
e1 = skip_whitespace(e1);
{
char *line;
- while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL) {
+ while ((line = xmalloc_getline(src_stream)) != NULL) {
int length;
char *line_ptr = line;
}
/* Search for the start of the encoding */
- while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL) {
+ while ((line = xmalloc_getline(src_stream)) != NULL) {
int (*decode_fn_ptr)(FILE * src, FILE * dst);
char *line_ptr;
FILE *dst_stream;
while (src_stream && (i < lines_count)) {
char *line;
- line = bb_get_line_from_file(src_stream);
+ line = xmalloc_fgets(src_stream);
if (line == NULL) {
break;
}
ret = 0;
}
- patch_line = bb_get_line_from_file(patch_file);
+ patch_line = xmalloc_fgets(patch_file);
while (patch_line) {
FILE *src_stream;
FILE *dst_stream;
*/
while (patch_line && strncmp(patch_line, "--- ", 4) != 0) {
free(patch_line);
- patch_line = bb_get_line_from_file(patch_file);
+ patch_line = xmalloc_fgets(patch_file);
}
/* Extract the filename used before the patch was generated */
original_filename = extract_filename(patch_line, patch_level);
free(patch_line);
- patch_line = bb_get_line_from_file(patch_file);
+ patch_line = xmalloc_fgets(patch_file);
if (strncmp(patch_line, "+++ ", 4) != 0) {
ret = 2;
bb_error_msg("Invalid patch");
printf("patching file %s\n", new_filename);
/* Handle each hunk */
- patch_line = bb_get_line_from_file(patch_file);
+ patch_line = xmalloc_fgets(patch_file);
while (patch_line) {
unsigned int count;
unsigned int src_beg_line;
}
hunk_offset_start = src_cur_line;
- while ((patch_line = bb_get_line_from_file(patch_file)) != NULL) {
+ while ((patch_line = xmalloc_fgets(patch_file)) != NULL) {
if ((*patch_line == '-') || (*patch_line == ' ')) {
char *src_line = NULL;
if (src_stream) {
- src_line = bb_get_line_from_file(src_stream);
+ src_line = xmalloc_fgets(src_stream);
if (!src_line) {
hunk_error++;
break;
if (rfile) {
char *line;
- while ((line = bb_get_chomped_line_from_file(rfile))
+ while ((line = xmalloc_getline(rfile))
!= NULL)
append(line);
xprint_and_close_file(rfile);
if (!opt_f) return;
add_files_link(opt_f->link);
cmdfile = xfopen(opt_f->data, "r");
- while ((line = bb_get_chomped_line_from_file(cmdfile)) != NULL) {
+ while ((line = xmalloc_getline(cmdfile)) != NULL) {
add_cmd(line);
free(line);
}
int idx = 0; /* used for iteration through the circular buffer */
#endif /* ENABLE_FEATURE_GREP_CONTEXT */
- while ((line = bb_get_chomped_line_from_file(file)) != NULL) {
+ while ((line = xmalloc_getline(file)) != NULL) {
llist_t *pattern_ptr = pattern_head;
grep_list_data_t * gl;
fopt = cur->link;
free(cur);
f = xfopen(ffile, "r");
- while ((line = bb_get_chomped_line_from_file(f)) != NULL) {
+ while ((line = xmalloc_getline(f)) != NULL) {
llist_add_to(&pattern_head,
new_grep_list_data(line, PATTERN_MEM_A));
}
extern long *find_pid_by_name( const char* pidName);
extern long *pidlist_reverse(long *pidList);
extern char *find_block_device(char *path);
-extern char *bb_get_line_from_file(FILE *file);
-extern char *bb_get_chomped_line_from_file(FILE *file);
+extern char *xmalloc_fgets(FILE *file);
+/* Chops off '\n' from the end, unlike fgets: */
+extern char *xmalloc_getline(FILE *file);
extern char *bb_get_chunk_from_file(FILE *file, int *end);
extern off_t bb_copyfd_size(int fd1, int fd2, off_t size);
extern off_t bb_copyfd_eof(int fd1, int fd2);
}
/* Get line, including trailing \n if any */
-char *bb_get_line_from_file(FILE * file)
+char *xmalloc_fgets(FILE * file)
{
int i;
}
/* Get line. Remove trailing \n */
-char *bb_get_chomped_line_from_file(FILE * file)
+char *xmalloc_getline(FILE * file)
{
int i;
char *c = bb_get_chunk_from_file(file, &i);
char *line = NULL;
char *cursor = NULL;
char *token = NULL;
- while ((line = bb_get_chomped_line_from_file(stdin))) {
+ while ((line = xmalloc_getline(stdin))) {
cursor = line;
len = number_of_tokens(line);
for (i = 0; i < len; i++) {
printf("table=<stdin>\n");
}
- while ((line = bb_get_chomped_line_from_file(table))) {
+ while ((line = xmalloc_getline(table))) {
char type;
unsigned int mode = 0755;
unsigned int major = 0;
char *r, *name;
restart:
- r = bb_get_line_from_file(fp);
+ r = xmalloc_fgets(fp);
if (!r)
return -1;
while (*r == ' ' || *r == '\t') {
f = xfopen(filename, "r");
- while ((buf = bb_get_chomped_line_from_file(f)) != NULL) {
+ while ((buf = xmalloc_getline(f)) != NULL) {
char *buf_ptr = buf;
firstword = next_word(&buf_ptr);
} else {
ifh = xfopen(fname, "r");
- while ((line = bb_get_line_from_file(ifh)) != NULL) {
+ while ((line = xmalloc_fgets(ifh)) != NULL) {
char *line_ptr;
size_t name_length;
if (( fp = fopen ( fromfile, "r" ))) {
for ( hi = 0; hi < MAX_HISTORY; ) {
- char * hl = bb_get_chomped_line_from_file(fp);
+ char * hl = xmalloc_getline(fp);
int l;
if(!hl)
fp = xfopen(name, "r");
- while ((buf = bb_get_chomped_line_from_file(fp)) != NULL) {
+ while ((buf = xmalloc_getline(fp)) != NULL) {
p = skip_whitespace(buf);
if (*p && (*p != '#')) {
f = fopen(filesystems[i], "r");
if (!f) continue;
- while ((buf = bb_get_chomped_line_from_file(f)) != 0) {
+ while ((buf = xmalloc_getline(f)) != 0) {
if (!strncmp(buf, "nodev", 5) && isspace(buf[5]))
continue;
fs = buf;