Fix wget error message and add (and use) chomp library function.
This commit is contained in:
parent
bd018b1bab
commit
05e782ddd3
@ -274,8 +274,7 @@ extern int tar_main(int argc, char **argv)
|
||||
while (fgets(file, sizeof(file), fileList) != NULL) {
|
||||
excludeList = xrealloc(excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
if (file[strlen(file)-1] == '\n')
|
||||
file[strlen(file)-1] = '\0';
|
||||
chomp(file);
|
||||
excludeList[excludeListSize] = xstrdup(file);
|
||||
/* Tack a NULL onto the end of the list */
|
||||
excludeList[++excludeListSize] = NULL;
|
||||
|
@ -152,6 +152,7 @@ extern char process_escape_sequence(char **ptr);
|
||||
extern char *get_last_path_component(char *path);
|
||||
extern FILE *wfopen(const char *path, const char *mode);
|
||||
extern FILE *xfopen(const char *path, const char *mode);
|
||||
extern void chomp(char *s);
|
||||
|
||||
#ifndef DMALLOC
|
||||
extern void *xmalloc (size_t size);
|
||||
|
@ -436,8 +436,7 @@ static void load_cmd_file(char *filename)
|
||||
}
|
||||
/* eat trailing newline (if any) --if I don't do this, edit commands
|
||||
* (aic) will print an extra newline */
|
||||
if (line[strlen(line)-1] == '\n')
|
||||
line[strlen(line)-1] = 0;
|
||||
chomp(line);
|
||||
add_cmd_str(line);
|
||||
free(line);
|
||||
}
|
||||
|
@ -69,8 +69,7 @@ static void grep_file(FILE *file)
|
||||
int nmatches = 0;
|
||||
|
||||
while ((line = get_line_from_file(file)) != NULL) {
|
||||
if (line[strlen(line)-1] == '\n')
|
||||
line[strlen(line)-1] = '\0';
|
||||
chomp(line);
|
||||
linenum++;
|
||||
ret = regexec(®ex, line, 0, NULL, 0);
|
||||
if (ret == 0 && !invert_search) { /* match */
|
||||
|
@ -68,8 +68,7 @@ int xargs_main(int argc, char **argv)
|
||||
char *execstr = NULL;
|
||||
|
||||
/* eat the newline off the filename. */
|
||||
if (file_to_act_on[strlen(file_to_act_on)-1] == '\n')
|
||||
file_to_act_on[strlen(file_to_act_on)-1] = '\0';
|
||||
chomp(file_to_act_on);
|
||||
|
||||
/* eat blank lines */
|
||||
if (strlen(file_to_act_on) == 0)
|
||||
|
3
grep.c
3
grep.c
@ -69,8 +69,7 @@ static void grep_file(FILE *file)
|
||||
int nmatches = 0;
|
||||
|
||||
while ((line = get_line_from_file(file)) != NULL) {
|
||||
if (line[strlen(line)-1] == '\n')
|
||||
line[strlen(line)-1] = '\0';
|
||||
chomp(line);
|
||||
linenum++;
|
||||
ret = regexec(®ex, line, 0, NULL, 0);
|
||||
if (ret == 0 && !invert_search) { /* match */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* $Id: hostname.c,v 1.22 2001/01/31 19:00:20 kraai Exp $
|
||||
* $Id: hostname.c,v 1.23 2001/02/01 16:49:29 kraai Exp $
|
||||
* Mini hostname implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
|
||||
@ -49,8 +49,7 @@ void do_sethostname(char *s, int isfile)
|
||||
f = xfopen(s, "r");
|
||||
fgets(buf, 255, f);
|
||||
fclose(f);
|
||||
if (buf[strlen(buf) - 1] == '\n')
|
||||
buf[strlen(buf) - 1] = 0;
|
||||
chomp(buf);
|
||||
if (sethostname(buf, strlen(buf)) < 0)
|
||||
perror_msg_and_die("sethostname");
|
||||
}
|
||||
|
@ -152,6 +152,7 @@ extern char process_escape_sequence(char **ptr);
|
||||
extern char *get_last_path_component(char *path);
|
||||
extern FILE *wfopen(const char *path, const char *mode);
|
||||
extern FILE *xfopen(const char *path, const char *mode);
|
||||
extern void chomp(char *s);
|
||||
|
||||
#ifndef DMALLOC
|
||||
extern void *xmalloc (size_t size);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* $Id: hostname.c,v 1.22 2001/01/31 19:00:20 kraai Exp $
|
||||
* $Id: hostname.c,v 1.23 2001/02/01 16:49:29 kraai Exp $
|
||||
* Mini hostname implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
|
||||
@ -49,8 +49,7 @@ void do_sethostname(char *s, int isfile)
|
||||
f = xfopen(s, "r");
|
||||
fgets(buf, 255, f);
|
||||
fclose(f);
|
||||
if (buf[strlen(buf) - 1] == '\n')
|
||||
buf[strlen(buf) - 1] = 0;
|
||||
chomp(buf);
|
||||
if (sethostname(buf, strlen(buf)) < 0)
|
||||
perror_msg_and_die("sethostname");
|
||||
}
|
||||
|
@ -216,6 +216,7 @@ int wget_main(int argc, char **argv)
|
||||
/*FALLTHRU*/
|
||||
default:
|
||||
close_and_delete_outfile(output, fname_out, do_continue);
|
||||
chomp(buf);
|
||||
error_msg_and_die("server returned error %d: %s", atoi(s), buf);
|
||||
}
|
||||
|
||||
@ -532,7 +533,7 @@ progressmeter(int flag)
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: wget.c,v 1.25 2001/01/31 19:00:21 kraai Exp $
|
||||
* $Id: wget.c,v 1.26 2001/02/01 16:49:30 kraai Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
3
sed.c
3
sed.c
@ -436,8 +436,7 @@ static void load_cmd_file(char *filename)
|
||||
}
|
||||
/* eat trailing newline (if any) --if I don't do this, edit commands
|
||||
* (aic) will print an extra newline */
|
||||
if (line[strlen(line)-1] == '\n')
|
||||
line[strlen(line)-1] = 0;
|
||||
chomp(line);
|
||||
add_cmd_str(line);
|
||||
free(line);
|
||||
}
|
||||
|
3
tar.c
3
tar.c
@ -274,8 +274,7 @@ extern int tar_main(int argc, char **argv)
|
||||
while (fgets(file, sizeof(file), fileList) != NULL) {
|
||||
excludeList = xrealloc(excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
if (file[strlen(file)-1] == '\n')
|
||||
file[strlen(file)-1] = '\0';
|
||||
chomp(file);
|
||||
excludeList[excludeListSize] = xstrdup(file);
|
||||
/* Tack a NULL onto the end of the list */
|
||||
excludeList[++excludeListSize] = NULL;
|
||||
|
13
utility.c
13
utility.c
@ -1760,6 +1760,19 @@ char *format(unsigned long val, unsigned long hr)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BB_GREP) || defined(BB_HOSTNAME) || defined(BB_SED) || defined(BB_TAR) || defined(BB_WGET) || defined(BB_XARGS)
|
||||
void chomp(char *s)
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
|
||||
if (len == 0)
|
||||
return;
|
||||
|
||||
if (s[len-1] == '\n')
|
||||
s[len-1] = '\0';
|
||||
}
|
||||
#endif
|
||||
|
||||
/* END CODE */
|
||||
/*
|
||||
Local Variables:
|
||||
|
3
wget.c
3
wget.c
@ -216,6 +216,7 @@ int wget_main(int argc, char **argv)
|
||||
/*FALLTHRU*/
|
||||
default:
|
||||
close_and_delete_outfile(output, fname_out, do_continue);
|
||||
chomp(buf);
|
||||
error_msg_and_die("server returned error %d: %s", atoi(s), buf);
|
||||
}
|
||||
|
||||
@ -532,7 +533,7 @@ progressmeter(int flag)
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: wget.c,v 1.25 2001/01/31 19:00:21 kraai Exp $
|
||||
* $Id: wget.c,v 1.26 2001/02/01 16:49:30 kraai Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
3
xargs.c
3
xargs.c
@ -68,8 +68,7 @@ int xargs_main(int argc, char **argv)
|
||||
char *execstr = NULL;
|
||||
|
||||
/* eat the newline off the filename. */
|
||||
if (file_to_act_on[strlen(file_to_act_on)-1] == '\n')
|
||||
file_to_act_on[strlen(file_to_act_on)-1] = '\0';
|
||||
chomp(file_to_act_on);
|
||||
|
||||
/* eat blank lines */
|
||||
if (strlen(file_to_act_on) == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user