diff options
-rw-r--r-- | miscutils/strings.c | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/miscutils/strings.c b/miscutils/strings.c index df7ff093b..bd07f5d3e 100644 --- a/miscutils/strings.c +++ b/miscutils/strings.c | |||
@@ -5,19 +5,7 @@ | |||
5 | * Copyright (c) 1980, 1987 | 5 | * Copyright (c) 1980, 1987 |
6 | * The Regents of the University of California. All rights reserved. | 6 | * The Regents of the University of California. All rights reserved. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | * | 9 | * |
22 | * Original copyright notice is retained at the end of this file. | 10 | * Original copyright notice is retained at the end of this file. |
23 | * | 11 | * |
@@ -31,8 +19,6 @@ | |||
31 | #include <ctype.h> | 19 | #include <ctype.h> |
32 | #include "busybox.h" | 20 | #include "busybox.h" |
33 | 21 | ||
34 | #define ISSTR(ch) (isprint(ch) || ch == '\t') | ||
35 | |||
36 | #define WHOLE_FILE 1 | 22 | #define WHOLE_FILE 1 |
37 | #define PRINT_NAME 2 | 23 | #define PRINT_NAME 2 |
38 | #define PRINT_OFFSET 4 | 24 | #define PRINT_OFFSET 4 |
@@ -48,7 +34,7 @@ int strings_main(int argc, char **argv) | |||
48 | const char *fmt = "%s: "; | 34 | const char *fmt = "%s: "; |
49 | char *n_arg = "4"; | 35 | char *n_arg = "4"; |
50 | 36 | ||
51 | opt = bb_getopt_ulflags (argc, argv, "afon:", &n_arg); | 37 | opt = bb_getopt_ulflags(argc, argv, "afon:", &n_arg); |
52 | /* -a is our default behaviour */ | 38 | /* -a is our default behaviour */ |
53 | 39 | ||
54 | argc -= optind; | 40 | argc -= optind; |
@@ -58,7 +44,7 @@ int strings_main(int argc, char **argv) | |||
58 | string = xcalloc(n + 1, 1); | 44 | string = xcalloc(n + 1, 1); |
59 | n--; | 45 | n--; |
60 | 46 | ||
61 | if ( argc == 0) { | 47 | if (argc == 0) { |
62 | fmt = "{%s}: "; | 48 | fmt = "{%s}: "; |
63 | *argv = (char *)bb_msg_standard_input; | 49 | *argv = (char *)bb_msg_standard_input; |
64 | goto PIPE; | 50 | goto PIPE; |
@@ -70,9 +56,9 @@ PIPE: | |||
70 | count = 0; | 56 | count = 0; |
71 | do { | 57 | do { |
72 | c = fgetc(file); | 58 | c = fgetc(file); |
73 | if (ISSTR(c)) { | 59 | if (isprint(c) || c == '\t') { |
74 | if (i <= n) { | 60 | if (i <= n) { |
75 | string[i]=c; | 61 | string[i] = c; |
76 | } else { | 62 | } else { |
77 | putchar(c); | 63 | putchar(c); |
78 | } | 64 | } |
@@ -81,7 +67,7 @@ PIPE: | |||
81 | printf(fmt, *argv); | 67 | printf(fmt, *argv); |
82 | } | 68 | } |
83 | if (opt & PRINT_OFFSET) { | 69 | if (opt & PRINT_OFFSET) { |
84 | printf("%7lo ", count - n ); | 70 | printf("%7lo ", count - n); |
85 | } | 71 | } |
86 | printf("%s", string); | 72 | printf("%s", string); |
87 | } | 73 | } |
@@ -96,11 +82,12 @@ PIPE: | |||
96 | } while (c != EOF); | 82 | } while (c != EOF); |
97 | bb_fclose_nonstdin(file); | 83 | bb_fclose_nonstdin(file); |
98 | } else { | 84 | } else { |
99 | status=EXIT_FAILURE; | 85 | status = EXIT_FAILURE; |
100 | } | 86 | } |
101 | } while ( --argc > 0 ); | 87 | } while (--argc > 0); |
102 | 88 | ||
103 | if (ENABLE_FEATURE_CLEAN_UP) free(string); | 89 | if (ENABLE_FEATURE_CLEAN_UP) |
90 | free(string); | ||
104 | 91 | ||
105 | bb_fflush_stdout_and_exit(status); | 92 | bb_fflush_stdout_and_exit(status); |
106 | } | 93 | } |