diff options
author | Matt Kraai <kraai@debian.org> | 2001-02-01 16:49:30 +0000 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2001-02-01 16:49:30 +0000 |
commit | 05e782ddd3dc58245c889529bb8aeeaddf24bf71 (patch) | |
tree | 8fbb91ca75358923724889a558c954cffdf10136 | |
parent | bd018b1babf0521b8e740abb6473133c1c4c35d2 (diff) | |
download | busybox-w32-05e782ddd3dc58245c889529bb8aeeaddf24bf71.tar.gz busybox-w32-05e782ddd3dc58245c889529bb8aeeaddf24bf71.tar.bz2 busybox-w32-05e782ddd3dc58245c889529bb8aeeaddf24bf71.zip |
Fix wget error message and add (and use) chomp library function.
-rw-r--r-- | archival/tar.c | 3 | ||||
-rw-r--r-- | busybox.h | 1 | ||||
-rw-r--r-- | editors/sed.c | 3 | ||||
-rw-r--r-- | findutils/grep.c | 3 | ||||
-rw-r--r-- | findutils/xargs.c | 3 | ||||
-rw-r--r-- | grep.c | 3 | ||||
-rw-r--r-- | hostname.c | 5 | ||||
-rw-r--r-- | include/busybox.h | 1 | ||||
-rw-r--r-- | networking/hostname.c | 5 | ||||
-rw-r--r-- | networking/wget.c | 3 | ||||
-rw-r--r-- | sed.c | 3 | ||||
-rw-r--r-- | tar.c | 3 | ||||
-rw-r--r-- | utility.c | 13 | ||||
-rw-r--r-- | wget.c | 3 | ||||
-rw-r--r-- | xargs.c | 3 |
15 files changed, 31 insertions, 24 deletions
diff --git a/archival/tar.c b/archival/tar.c index 60744e8db..fb0fcc614 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -274,8 +274,7 @@ extern int tar_main(int argc, char **argv) | |||
274 | while (fgets(file, sizeof(file), fileList) != NULL) { | 274 | while (fgets(file, sizeof(file), fileList) != NULL) { |
275 | excludeList = xrealloc(excludeList, | 275 | excludeList = xrealloc(excludeList, |
276 | sizeof(char *) * (excludeListSize+2)); | 276 | sizeof(char *) * (excludeListSize+2)); |
277 | if (file[strlen(file)-1] == '\n') | 277 | chomp(file); |
278 | file[strlen(file)-1] = '\0'; | ||
279 | excludeList[excludeListSize] = xstrdup(file); | 278 | excludeList[excludeListSize] = xstrdup(file); |
280 | /* Tack a NULL onto the end of the list */ | 279 | /* Tack a NULL onto the end of the list */ |
281 | excludeList[++excludeListSize] = NULL; | 280 | excludeList[++excludeListSize] = NULL; |
@@ -152,6 +152,7 @@ extern char process_escape_sequence(char **ptr); | |||
152 | extern char *get_last_path_component(char *path); | 152 | extern char *get_last_path_component(char *path); |
153 | extern FILE *wfopen(const char *path, const char *mode); | 153 | extern FILE *wfopen(const char *path, const char *mode); |
154 | extern FILE *xfopen(const char *path, const char *mode); | 154 | extern FILE *xfopen(const char *path, const char *mode); |
155 | extern void chomp(char *s); | ||
155 | 156 | ||
156 | #ifndef DMALLOC | 157 | #ifndef DMALLOC |
157 | extern void *xmalloc (size_t size); | 158 | extern void *xmalloc (size_t size); |
diff --git a/editors/sed.c b/editors/sed.c index e0351c3b8..0ce9f45e0 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -436,8 +436,7 @@ static void load_cmd_file(char *filename) | |||
436 | } | 436 | } |
437 | /* eat trailing newline (if any) --if I don't do this, edit commands | 437 | /* eat trailing newline (if any) --if I don't do this, edit commands |
438 | * (aic) will print an extra newline */ | 438 | * (aic) will print an extra newline */ |
439 | if (line[strlen(line)-1] == '\n') | 439 | chomp(line); |
440 | line[strlen(line)-1] = 0; | ||
441 | add_cmd_str(line); | 440 | add_cmd_str(line); |
442 | free(line); | 441 | free(line); |
443 | } | 442 | } |
diff --git a/findutils/grep.c b/findutils/grep.c index 320655bf4..fec8d0913 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -69,8 +69,7 @@ static void grep_file(FILE *file) | |||
69 | int nmatches = 0; | 69 | int nmatches = 0; |
70 | 70 | ||
71 | while ((line = get_line_from_file(file)) != NULL) { | 71 | while ((line = get_line_from_file(file)) != NULL) { |
72 | if (line[strlen(line)-1] == '\n') | 72 | chomp(line); |
73 | line[strlen(line)-1] = '\0'; | ||
74 | linenum++; | 73 | linenum++; |
75 | ret = regexec(®ex, line, 0, NULL, 0); | 74 | ret = regexec(®ex, line, 0, NULL, 0); |
76 | if (ret == 0 && !invert_search) { /* match */ | 75 | if (ret == 0 && !invert_search) { /* match */ |
diff --git a/findutils/xargs.c b/findutils/xargs.c index 89bcfc156..f05efd917 100644 --- a/findutils/xargs.c +++ b/findutils/xargs.c | |||
@@ -68,8 +68,7 @@ int xargs_main(int argc, char **argv) | |||
68 | char *execstr = NULL; | 68 | char *execstr = NULL; |
69 | 69 | ||
70 | /* eat the newline off the filename. */ | 70 | /* eat the newline off the filename. */ |
71 | if (file_to_act_on[strlen(file_to_act_on)-1] == '\n') | 71 | chomp(file_to_act_on); |
72 | file_to_act_on[strlen(file_to_act_on)-1] = '\0'; | ||
73 | 72 | ||
74 | /* eat blank lines */ | 73 | /* eat blank lines */ |
75 | if (strlen(file_to_act_on) == 0) | 74 | if (strlen(file_to_act_on) == 0) |
@@ -69,8 +69,7 @@ static void grep_file(FILE *file) | |||
69 | int nmatches = 0; | 69 | int nmatches = 0; |
70 | 70 | ||
71 | while ((line = get_line_from_file(file)) != NULL) { | 71 | while ((line = get_line_from_file(file)) != NULL) { |
72 | if (line[strlen(line)-1] == '\n') | 72 | chomp(line); |
73 | line[strlen(line)-1] = '\0'; | ||
74 | linenum++; | 73 | linenum++; |
75 | ret = regexec(®ex, line, 0, NULL, 0); | 74 | ret = regexec(®ex, line, 0, NULL, 0); |
76 | if (ret == 0 && !invert_search) { /* match */ | 75 | if (ret == 0 && !invert_search) { /* match */ |
diff --git a/hostname.c b/hostname.c index 3dba64154..ce17ba91c 100644 --- a/hostname.c +++ b/hostname.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * $Id: hostname.c,v 1.22 2001/01/31 19:00:20 kraai Exp $ | 3 | * $Id: hostname.c,v 1.23 2001/02/01 16:49:29 kraai Exp $ |
4 | * Mini hostname implementation for busybox | 4 | * Mini hostname implementation for busybox |
5 | * | 5 | * |
6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> | 6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> |
@@ -49,8 +49,7 @@ void do_sethostname(char *s, int isfile) | |||
49 | f = xfopen(s, "r"); | 49 | f = xfopen(s, "r"); |
50 | fgets(buf, 255, f); | 50 | fgets(buf, 255, f); |
51 | fclose(f); | 51 | fclose(f); |
52 | if (buf[strlen(buf) - 1] == '\n') | 52 | chomp(buf); |
53 | buf[strlen(buf) - 1] = 0; | ||
54 | if (sethostname(buf, strlen(buf)) < 0) | 53 | if (sethostname(buf, strlen(buf)) < 0) |
55 | perror_msg_and_die("sethostname"); | 54 | perror_msg_and_die("sethostname"); |
56 | } | 55 | } |
diff --git a/include/busybox.h b/include/busybox.h index 5f9425a5b..e332ed412 100644 --- a/include/busybox.h +++ b/include/busybox.h | |||
@@ -152,6 +152,7 @@ extern char process_escape_sequence(char **ptr); | |||
152 | extern char *get_last_path_component(char *path); | 152 | extern char *get_last_path_component(char *path); |
153 | extern FILE *wfopen(const char *path, const char *mode); | 153 | extern FILE *wfopen(const char *path, const char *mode); |
154 | extern FILE *xfopen(const char *path, const char *mode); | 154 | extern FILE *xfopen(const char *path, const char *mode); |
155 | extern void chomp(char *s); | ||
155 | 156 | ||
156 | #ifndef DMALLOC | 157 | #ifndef DMALLOC |
157 | extern void *xmalloc (size_t size); | 158 | extern void *xmalloc (size_t size); |
diff --git a/networking/hostname.c b/networking/hostname.c index 3dba64154..ce17ba91c 100644 --- a/networking/hostname.c +++ b/networking/hostname.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * $Id: hostname.c,v 1.22 2001/01/31 19:00:20 kraai Exp $ | 3 | * $Id: hostname.c,v 1.23 2001/02/01 16:49:29 kraai Exp $ |
4 | * Mini hostname implementation for busybox | 4 | * Mini hostname implementation for busybox |
5 | * | 5 | * |
6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> | 6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> |
@@ -49,8 +49,7 @@ void do_sethostname(char *s, int isfile) | |||
49 | f = xfopen(s, "r"); | 49 | f = xfopen(s, "r"); |
50 | fgets(buf, 255, f); | 50 | fgets(buf, 255, f); |
51 | fclose(f); | 51 | fclose(f); |
52 | if (buf[strlen(buf) - 1] == '\n') | 52 | chomp(buf); |
53 | buf[strlen(buf) - 1] = 0; | ||
54 | if (sethostname(buf, strlen(buf)) < 0) | 53 | if (sethostname(buf, strlen(buf)) < 0) |
55 | perror_msg_and_die("sethostname"); | 54 | perror_msg_and_die("sethostname"); |
56 | } | 55 | } |
diff --git a/networking/wget.c b/networking/wget.c index 70f8d1b89..c134427e4 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -216,6 +216,7 @@ int wget_main(int argc, char **argv) | |||
216 | /*FALLTHRU*/ | 216 | /*FALLTHRU*/ |
217 | default: | 217 | default: |
218 | close_and_delete_outfile(output, fname_out, do_continue); | 218 | close_and_delete_outfile(output, fname_out, do_continue); |
219 | chomp(buf); | ||
219 | error_msg_and_die("server returned error %d: %s", atoi(s), buf); | 220 | error_msg_and_die("server returned error %d: %s", atoi(s), buf); |
220 | } | 221 | } |
221 | 222 | ||
@@ -532,7 +533,7 @@ progressmeter(int flag) | |||
532 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 533 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
533 | * SUCH DAMAGE. | 534 | * SUCH DAMAGE. |
534 | * | 535 | * |
535 | * $Id: wget.c,v 1.25 2001/01/31 19:00:21 kraai Exp $ | 536 | * $Id: wget.c,v 1.26 2001/02/01 16:49:30 kraai Exp $ |
536 | */ | 537 | */ |
537 | 538 | ||
538 | 539 | ||
@@ -436,8 +436,7 @@ static void load_cmd_file(char *filename) | |||
436 | } | 436 | } |
437 | /* eat trailing newline (if any) --if I don't do this, edit commands | 437 | /* eat trailing newline (if any) --if I don't do this, edit commands |
438 | * (aic) will print an extra newline */ | 438 | * (aic) will print an extra newline */ |
439 | if (line[strlen(line)-1] == '\n') | 439 | chomp(line); |
440 | line[strlen(line)-1] = 0; | ||
441 | add_cmd_str(line); | 440 | add_cmd_str(line); |
442 | free(line); | 441 | free(line); |
443 | } | 442 | } |
@@ -274,8 +274,7 @@ extern int tar_main(int argc, char **argv) | |||
274 | while (fgets(file, sizeof(file), fileList) != NULL) { | 274 | while (fgets(file, sizeof(file), fileList) != NULL) { |
275 | excludeList = xrealloc(excludeList, | 275 | excludeList = xrealloc(excludeList, |
276 | sizeof(char *) * (excludeListSize+2)); | 276 | sizeof(char *) * (excludeListSize+2)); |
277 | if (file[strlen(file)-1] == '\n') | 277 | chomp(file); |
278 | file[strlen(file)-1] = '\0'; | ||
279 | excludeList[excludeListSize] = xstrdup(file); | 278 | excludeList[excludeListSize] = xstrdup(file); |
280 | /* Tack a NULL onto the end of the list */ | 279 | /* Tack a NULL onto the end of the list */ |
281 | excludeList[++excludeListSize] = NULL; | 280 | excludeList[++excludeListSize] = NULL; |
@@ -1760,6 +1760,19 @@ char *format(unsigned long val, unsigned long hr) | |||
1760 | } | 1760 | } |
1761 | #endif | 1761 | #endif |
1762 | 1762 | ||
1763 | #if defined(BB_GREP) || defined(BB_HOSTNAME) || defined(BB_SED) || defined(BB_TAR) || defined(BB_WGET) || defined(BB_XARGS) | ||
1764 | void chomp(char *s) | ||
1765 | { | ||
1766 | size_t len = strlen(s); | ||
1767 | |||
1768 | if (len == 0) | ||
1769 | return; | ||
1770 | |||
1771 | if (s[len-1] == '\n') | ||
1772 | s[len-1] = '\0'; | ||
1773 | } | ||
1774 | #endif | ||
1775 | |||
1763 | /* END CODE */ | 1776 | /* END CODE */ |
1764 | /* | 1777 | /* |
1765 | Local Variables: | 1778 | Local Variables: |
@@ -216,6 +216,7 @@ int wget_main(int argc, char **argv) | |||
216 | /*FALLTHRU*/ | 216 | /*FALLTHRU*/ |
217 | default: | 217 | default: |
218 | close_and_delete_outfile(output, fname_out, do_continue); | 218 | close_and_delete_outfile(output, fname_out, do_continue); |
219 | chomp(buf); | ||
219 | error_msg_and_die("server returned error %d: %s", atoi(s), buf); | 220 | error_msg_and_die("server returned error %d: %s", atoi(s), buf); |
220 | } | 221 | } |
221 | 222 | ||
@@ -532,7 +533,7 @@ progressmeter(int flag) | |||
532 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 533 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
533 | * SUCH DAMAGE. | 534 | * SUCH DAMAGE. |
534 | * | 535 | * |
535 | * $Id: wget.c,v 1.25 2001/01/31 19:00:21 kraai Exp $ | 536 | * $Id: wget.c,v 1.26 2001/02/01 16:49:30 kraai Exp $ |
536 | */ | 537 | */ |
537 | 538 | ||
538 | 539 | ||
@@ -68,8 +68,7 @@ int xargs_main(int argc, char **argv) | |||
68 | char *execstr = NULL; | 68 | char *execstr = NULL; |
69 | 69 | ||
70 | /* eat the newline off the filename. */ | 70 | /* eat the newline off the filename. */ |
71 | if (file_to_act_on[strlen(file_to_act_on)-1] == '\n') | 71 | chomp(file_to_act_on); |
72 | file_to_act_on[strlen(file_to_act_on)-1] = '\0'; | ||
73 | 72 | ||
74 | /* eat blank lines */ | 73 | /* eat blank lines */ |
75 | if (strlen(file_to_act_on) == 0) | 74 | if (strlen(file_to_act_on) == 0) |