aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-16 23:49:13 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-16 23:49:13 +0000
commit9f739445cd3deddd0343c3a8d5a981ede26bef30 (patch)
tree6dc013e44d2281eb1e6f61c4bca1ae7546001f79
parenta597aaddfa76d589d3e1a37b1f1c3401c2decffd (diff)
downloadbusybox-w32-9f739445cd3deddd0343c3a8d5a981ede26bef30.tar.gz
busybox-w32-9f739445cd3deddd0343c3a8d5a981ede26bef30.tar.bz2
busybox-w32-9f739445cd3deddd0343c3a8d5a981ede26bef30.zip
inline strcmp(s, "-") [actually macro-ize it for now - gcc is too stupid]
-rw-r--r--archival/bunzip2.c2
-rw-r--r--archival/gunzip.c2
-rw-r--r--archival/gzip.c2
-rw-r--r--archival/tar.c2
-rw-r--r--archival/uncompress.c2
-rw-r--r--archival/unlzma.c2
-rw-r--r--archival/unzip.c3
-rw-r--r--coreutils/cut.c13
-rw-r--r--coreutils/diff.c10
-rw-r--r--coreutils/env.c2
-rw-r--r--coreutils/md5_sha1_sum.c4
-rw-r--r--coreutils/sort.c2
-rw-r--r--coreutils/sum.c11
-rw-r--r--coreutils/tail.c4
-rw-r--r--coreutils/uudecode.c2
-rw-r--r--e2fsprogs/fsck.c4
-rw-r--r--editors/sed.c4
-rw-r--r--include/libbb.h8
-rw-r--r--libbb/wfopen_input.c2
-rw-r--r--loginutils/getty.c2
-rw-r--r--loginutils/su.c18
-rw-r--r--miscutils/crontab.c2
-rw-r--r--networking/ftpgetput.c7
-rw-r--r--networking/libiproute/ipaddress.c2
-rw-r--r--networking/tftp.c2
-rw-r--r--networking/wget.c2
-rw-r--r--shell/ash.c14
-rw-r--r--shell/msh.c2
28 files changed, 69 insertions, 63 deletions
diff --git a/archival/bunzip2.c b/archival/bunzip2.c
index 757001fe4..a6cd17611 100644
--- a/archival/bunzip2.c
+++ b/archival/bunzip2.c
@@ -23,7 +23,7 @@ int bunzip2_main(int argc, char **argv)
23 23
24 /* Set input filename and number */ 24 /* Set input filename and number */
25 filename = argv[optind]; 25 filename = argv[optind];
26 if ((filename) && (filename[0] != '-') && (filename[1] != '\0')) { 26 if (filename && NOT_LONE_DASH(filename)) {
27 /* Open input file */ 27 /* Open input file */
28 src_fd = xopen(filename, O_RDONLY); 28 src_fd = xopen(filename, O_RDONLY);
29 } else { 29 } else {
diff --git a/archival/gunzip.c b/archival/gunzip.c
index e24401c71..c5deec3ce 100644
--- a/archival/gunzip.c
+++ b/archival/gunzip.c
@@ -58,7 +58,7 @@ int gunzip_main(int argc, char **argv)
58 58
59 optind++; 59 optind++;
60 60
61 if (old_path == NULL || strcmp(old_path, "-") == 0) { 61 if (old_path == NULL || LONE_DASH(old_path)) {
62 src_fd = STDIN_FILENO; 62 src_fd = STDIN_FILENO;
63 opt |= GUNZIP_OPT_STDOUT; 63 opt |= GUNZIP_OPT_STDOUT;
64 USE_DESKTOP(opt &= ~GUNZIP_OPT_VERBOSE;) 64 USE_DESKTOP(opt &= ~GUNZIP_OPT_VERBOSE;)
diff --git a/archival/gzip.c b/archival/gzip.c
index c9b67538e..7124e9bd4 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -1201,7 +1201,7 @@ int gzip_main(int argc, char **argv)
1201 char *path = NULL; 1201 char *path = NULL;
1202 1202
1203 clear_bufs(); 1203 clear_bufs();
1204 if (strcmp(argv[i], "-") == 0) { 1204 if (LONE_DASH(argv[i])) {
1205 time_stamp = 0; 1205 time_stamp = 0;
1206 inFileNum = STDIN_FILENO; 1206 inFileNum = STDIN_FILENO;
1207 outFileNum = STDOUT_FILENO; 1207 outFileNum = STDOUT_FILENO;
diff --git a/archival/tar.c b/archival/tar.c
index 79c3595ac..ba7cb0f8c 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -851,7 +851,7 @@ int tar_main(int argc, char **argv)
851 flags = O_RDONLY; 851 flags = O_RDONLY;
852 } 852 }
853 853
854 if (tar_filename[0] == '-' && !tar_filename[1]) { 854 if (LONE_DASH(tar_filename)) {
855 tar_handle->src_fd = fileno(tar_stream); 855 tar_handle->src_fd = fileno(tar_stream);
856 tar_handle->seek = seek_by_read; 856 tar_handle->seek = seek_by_read;
857 } else { 857 } else {
diff --git a/archival/uncompress.c b/archival/uncompress.c
index 3c78961d5..461179016 100644
--- a/archival/uncompress.c
+++ b/archival/uncompress.c
@@ -25,7 +25,7 @@ int uncompress_main(int argc, char **argv)
25 int src_fd; 25 int src_fd;
26 int dst_fd; 26 int dst_fd;
27 27
28 if (strcmp(compressed_file, "-") == 0) { 28 if (LONE_DASH(compressed_file)) {
29 src_fd = STDIN_FILENO; 29 src_fd = STDIN_FILENO;
30 flags |= GUNZIP_TO_STDOUT; 30 flags |= GUNZIP_TO_STDOUT;
31 } else { 31 } else {
diff --git a/archival/unlzma.c b/archival/unlzma.c
index 46fbefdc0..20c4ff2a7 100644
--- a/archival/unlzma.c
+++ b/archival/unlzma.c
@@ -26,7 +26,7 @@ int unlzma_main(int argc, char **argv)
26 26
27 /* Set input filename and number */ 27 /* Set input filename and number */
28 filename = argv[optind]; 28 filename = argv[optind];
29 if (filename && (filename[0] != '-') && (filename[1] != '\0')) { 29 if (filename && NOT_LONE_DASH(filename)) {
30 /* Open input file */ 30 /* Open input file */
31 src_fd = xopen(filename, O_RDONLY); 31 src_fd = xopen(filename, O_RDONLY);
32 } else { 32 } else {
diff --git a/archival/unzip.c b/archival/unzip.c
index 8b1c281c4..f553eefa2 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -187,11 +187,10 @@ int unzip_main(int argc, char **argv)
187 } 187 }
188 188
189 /* Open input file */ 189 /* Open input file */
190 if (strcmp("-", src_fn) == 0) { 190 if (LONE_DASH(src_fn)) {
191 src_fd = STDIN_FILENO; 191 src_fd = STDIN_FILENO;
192 /* Cannot use prompt mode since zip data is arriving on STDIN */ 192 /* Cannot use prompt mode since zip data is arriving on STDIN */
193 overwrite = (overwrite == o_prompt) ? o_never : overwrite; 193 overwrite = (overwrite == o_prompt) ? o_never : overwrite;
194
195 } else { 194 } else {
196 static const char *const extn[] = {"", ".zip", ".ZIP"}; 195 static const char *const extn[] = {"", ".zip", ".ZIP"};
197 int orig_src_fn_len = strlen(src_fn); 196 int orig_src_fn_len = strlen(src_fn);
diff --git a/coreutils/cut.c b/coreutils/cut.c
index a538e3d20..a72b2c29a 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -168,6 +168,8 @@ int cut_main(int argc, char **argv)
168 168
169 opt_complementary = "b--bcf:c--bcf:f--bcf"; 169 opt_complementary = "b--bcf:c--bcf:f--bcf";
170 getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, &ltok); 170 getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, &ltok);
171// argc -= optind;
172 argv += optind;
171 if (!(option_mask32 & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS))) 173 if (!(option_mask32 & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
172 bb_error_msg_and_die("expected a list of bytes, characters, or fields"); 174 bb_error_msg_and_die("expected a list of bytes, characters, or fields");
173 if (option_mask32 & BB_GETOPT_ERROR) 175 if (option_mask32 & BB_GETOPT_ERROR)
@@ -262,22 +264,21 @@ int cut_main(int argc, char **argv)
262 qsort(cut_lists, nlists, sizeof(struct cut_list), cmpfunc); 264 qsort(cut_lists, nlists, sizeof(struct cut_list), cmpfunc);
263 } 265 }
264 266
265 /* argv[(optind)..(argc-1)] should be names of file to process. If no 267 /* argv[0..argc-1] should be names of file to process. If no
266 * files were specified or '-' was specified, take input from stdin. 268 * files were specified or '-' was specified, take input from stdin.
267 * Otherwise, we process all the files specified. */ 269 * Otherwise, we process all the files specified. */
268 if (argv[optind] == NULL 270 if (argv[0] == NULL || LONE_DASH(argv[0])) {
269 || (argv[optind][0] == '-' && argv[optind][1] == '\0')) {
270 cut_file(stdin); 271 cut_file(stdin);
271 } else { 272 } else {
272 FILE *file; 273 FILE *file;
273 274
274 for (; optind < argc; optind++) { 275 do {
275 file = fopen_or_warn(argv[optind], "r"); 276 file = fopen_or_warn(argv[0], "r");
276 if (file) { 277 if (file) {
277 cut_file(file); 278 cut_file(file);
278 fclose(file); 279 fclose(file);
279 } 280 }
280 } 281 } while (*++argv);
281 } 282 }
282 if (ENABLE_FEATURE_CLEAN_UP) 283 if (ENABLE_FEATURE_CLEAN_UP)
283 free(cut_lists); 284 free(cut_lists);
diff --git a/coreutils/diff.c b/coreutils/diff.c
index 0df9989b7..887679a0a 100644
--- a/coreutils/diff.c
+++ b/coreutils/diff.c
@@ -904,19 +904,19 @@ static int diffreg(char *ofile1, char *ofile2, int flags)
904 904
905 if (S_ISDIR(stb1.st_mode) != S_ISDIR(stb2.st_mode)) 905 if (S_ISDIR(stb1.st_mode) != S_ISDIR(stb2.st_mode))
906 return (S_ISDIR(stb1.st_mode) ? D_MISMATCH1 : D_MISMATCH2); 906 return (S_ISDIR(stb1.st_mode) ? D_MISMATCH1 : D_MISMATCH2);
907 if (strcmp(file1, "-") == 0 && strcmp(file2, "-") == 0) 907 if (LONE_DASH(file1) && LONE_DASH(file2))
908 goto closem; 908 goto closem;
909 909
910 f1 = stdin; 910 f1 = stdin;
911 if (flags & D_EMPTY1) 911 if (flags & D_EMPTY1)
912 f1 = xfopen(bb_dev_null, "r"); 912 f1 = xfopen(bb_dev_null, "r");
913 else if (file1[0] != '-' || file1[1]) /* not "-" */ 913 else if (NOT_LONE_DASH(file1))
914 f1 = xfopen(file1, "r"); 914 f1 = xfopen(file1, "r");
915 915
916 f2 = stdin; 916 f2 = stdin;
917 if (flags & D_EMPTY2) 917 if (flags & D_EMPTY2)
918 f2 = xfopen(bb_dev_null, "r"); 918 f2 = xfopen(bb_dev_null, "r");
919 else if (file2[0] != '-' || file2[1]) /* not "-" */ 919 else if (NOT_LONE_DASH(file2))
920 f2 = xfopen(file2, "r"); 920 f2 = xfopen(file2, "r");
921 921
922 i = files_differ(f1, f2, flags); 922 i = files_differ(f1, f2, flags);
@@ -1212,12 +1212,12 @@ int diff_main(int argc, char **argv)
1212 bb_error_msg("missing filename"); 1212 bb_error_msg("missing filename");
1213 bb_show_usage(); 1213 bb_show_usage();
1214 } 1214 }
1215 if (argv[0][0] == '-' && !argv[0][1]) { /* "-" */ 1215 if (LONE_DASH(argv[0])) {
1216 fstat(STDIN_FILENO, &stb1); 1216 fstat(STDIN_FILENO, &stb1);
1217 gotstdin = 1; 1217 gotstdin = 1;
1218 } else 1218 } else
1219 xstat(argv[0], &stb1); 1219 xstat(argv[0], &stb1);
1220 if (argv[1][0] == '-' && !argv[1][1]) { /* "-" */ 1220 if (LONE_DASH(argv[1])) {
1221 fstat(STDIN_FILENO, &stb2); 1221 fstat(STDIN_FILENO, &stb2);
1222 gotstdin = 1; 1222 gotstdin = 1;
1223 } else 1223 } else
diff --git a/coreutils/env.c b/coreutils/env.c
index 2ce99b0ad..e4cad271b 100644
--- a/coreutils/env.c
+++ b/coreutils/env.c
@@ -58,7 +58,7 @@ int env_main(int argc, char** argv)
58 opt = getopt32(argc, argv, "+iu:", &unset_env); 58 opt = getopt32(argc, argv, "+iu:", &unset_env);
59 59
60 argv += optind; 60 argv += optind;
61 if (*argv && (argv[0][0] == '-') && !argv[0][1]) { 61 if (*argv && LONE_DASH(argv[0])) {
62 opt |= 1; 62 opt |= 1;
63 ++argv; 63 ++argv;
64 } 64 }
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c
index e8d3a1509..6fe1b0286 100644
--- a/coreutils/md5_sha1_sum.c
+++ b/coreutils/md5_sha1_sum.c
@@ -39,7 +39,7 @@ static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo)
39 void (*final)(void*, void*); 39 void (*final)(void*, void*);
40 40
41 src_fd = STDIN_FILENO; 41 src_fd = STDIN_FILENO;
42 if (filename[0] != '-' || filename[1]) { /* not "-" */ 42 if (NOT_LONE_DASH(filename)) {
43 src_fd = open(filename, O_RDONLY); 43 src_fd = open(filename, O_RDONLY);
44 if (src_fd < 0) { 44 if (src_fd < 0) {
45 bb_perror_msg("%s", filename); 45 bb_perror_msg("%s", filename);
@@ -120,7 +120,7 @@ int md5_sha1_sum_main(int argc, char **argv)
120 } 120 }
121 121
122 pre_computed_stream = stdin; 122 pre_computed_stream = stdin;
123 if (file_ptr[0] != '-' || file_ptr[1]) { /* not "-" */ 123 if (NOT_LONE_DASH(file_ptr)) {
124 pre_computed_stream = xfopen(file_ptr, "r"); 124 pre_computed_stream = xfopen(file_ptr, "r");
125 } 125 }
126 126
diff --git a/coreutils/sort.c b/coreutils/sort.c
index c23bf9c60..c37810f1a 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -310,7 +310,7 @@ int sort_main(int argc, char **argv)
310 /* Open input files and read data */ 310 /* Open input files and read data */
311 for (i = argv[optind] ? optind : optind-1; argv[i]; i++) { 311 for (i = argv[optind] ? optind : optind-1; argv[i]; i++) {
312 fp = stdin; 312 fp = stdin;
313 if (i >= optind && (argv[i][0] != '-' || argv[i][1])) 313 if (i >= optind && NOT_LONE_DASH(argv[i]))
314 fp = xfopen(argv[i], "r"); 314 fp = xfopen(argv[i], "r");
315 for (;;) { 315 for (;;) {
316 line = GET_LINE(fp); 316 line = GET_LINE(fp);
diff --git a/coreutils/sum.c b/coreutils/sum.c
index 93f4e22eb..68a857816 100644
--- a/coreutils/sum.c
+++ b/coreutils/sum.c
@@ -18,9 +18,6 @@
18/* 1 if any of the files read were the standard input */ 18/* 1 if any of the files read were the standard input */
19static int have_read_stdin; 19static int have_read_stdin;
20 20
21/* make a little more readable and avoid using strcmp for just 2 bytes */
22#define IS_STDIN(s) (s[0] == '-' && s[1] == '\0')
23
24/* Calculate and print the rotated checksum and the size in 1K blocks 21/* Calculate and print the rotated checksum and the size in 1K blocks
25 of file FILE, or of the standard input if FILE is "-". 22 of file FILE, or of the standard input if FILE is "-".
26 If PRINT_NAME is >1, print FILE next to the checksum and size. 23 If PRINT_NAME is >1, print FILE next to the checksum and size.
@@ -34,7 +31,7 @@ static int bsd_sum_file(const char *file, int print_name)
34 int ch; /* Each character read. */ 31 int ch; /* Each character read. */
35 int ret = 0; 32 int ret = 0;
36 33
37 if (IS_STDIN(file)) { 34 if (LONE_DASH(file)) {
38 fp = stdin; 35 fp = stdin;
39 have_read_stdin++; 36 have_read_stdin++;
40 } else { 37 } else {
@@ -84,7 +81,7 @@ static int sysv_sum_file(const char *file, int print_name)
84 /* The sum of all the input bytes, modulo (UINT_MAX + 1). */ 81 /* The sum of all the input bytes, modulo (UINT_MAX + 1). */
85 unsigned int s = 0; 82 unsigned int s = 0;
86 83
87 if (IS_STDIN(file)) { 84 if (LONE_DASH(file)) {
88 fd = 0; 85 fd = 0;
89 have_read_stdin = 1; 86 have_read_stdin = 1;
90 } else { 87 } else {
@@ -103,7 +100,7 @@ static int sysv_sum_file(const char *file, int print_name)
103release_and_ret: 100release_and_ret:
104 bb_perror_msg(file); 101 bb_perror_msg(file);
105 RELEASE_CONFIG_BUFFER(buf); 102 RELEASE_CONFIG_BUFFER(buf);
106 if (!IS_STDIN(file)) 103 if (NOT_LONE_DASH(file))
107 close(fd); 104 close(fd);
108 return 0; 105 return 0;
109 } 106 }
@@ -113,7 +110,7 @@ release_and_ret:
113 s += buf[bytes_read]; 110 s += buf[bytes_read];
114 } 111 }
115 112
116 if (!IS_STDIN(file) && close(fd) == -1) 113 if (NOT_LONE_DASH(file) && close(fd) == -1)
117 goto release_and_ret; 114 goto release_and_ret;
118 else 115 else
119 RELEASE_CONFIG_BUFFER(buf); 116 RELEASE_CONFIG_BUFFER(buf);
diff --git a/coreutils/tail.c b/coreutils/tail.c
index ed5ea1467..4c3c3b901 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -176,8 +176,8 @@ int tail_main(int argc, char **argv)
176 } 176 }
177 177
178 do { 178 do {
179 if ((argv[i][0] == '-') && !argv[i][1]) { 179 if (LONE_DASH(argv[i])) {
180 DO_STDIN: 180 DO_STDIN:
181 fds[nfiles] = STDIN_FILENO; 181 fds[nfiles] = STDIN_FILENO;
182 } else if ((fds[nfiles] = open(argv[i], O_RDONLY)) < 0) { 182 } else if ((fds[nfiles] = open(argv[i], O_RDONLY)) < 0) {
183 bb_perror_msg("%s", argv[i]); 183 bb_perror_msg("%s", argv[i]);
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c
index 8b7de74ff..06512119e 100644
--- a/coreutils/uudecode.c
+++ b/coreutils/uudecode.c
@@ -166,7 +166,7 @@ int uudecode_main(int argc, char **argv)
166 } 166 }
167 outname++; 167 outname++;
168 } 168 }
169 if (strcmp(outname, "-") == 0) { 169 if (LONE_DASH(outname)) {
170 dst_stream = stdout; 170 dst_stream = stdout;
171 } else { 171 } else {
172 dst_stream = xfopen(outname, "w"); 172 dst_stream = xfopen(outname, "w");
diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c
index f0c1316a9..3b01c1021 100644
--- a/e2fsprogs/fsck.c
+++ b/e2fsprogs/fsck.c
@@ -1249,8 +1249,8 @@ static void PRS(int argc, char *argv[])
1249 progress_fd = 0; 1249 progress_fd = 0;
1250 else 1250 else
1251 goto next_arg; 1251 goto next_arg;
1252 } else if ((i+1) < argc && 1252 } else if ((i+1) < argc
1253 !strncmp(argv[i+1], "-", 1) == 0) { 1253 && argv[i+1][0] != '-') {
1254 progress_fd = string_to_int(argv[i]); 1254 progress_fd = string_to_int(argv[i]);
1255 if (progress_fd < 0) 1255 if (progress_fd < 0)
1256 progress_fd = 0; 1256 progress_fd = 0;
diff --git a/editors/sed.c b/editors/sed.c
index ac3d8d463..8d372abe4 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -1235,9 +1235,7 @@ int sed_main(int argc, char **argv)
1235 struct stat statbuf; 1235 struct stat statbuf;
1236 int nonstdoutfd; 1236 int nonstdoutfd;
1237 1237
1238 if (argv[i][0] == '-' && !argv[i][1] 1238 if (LONE_DASH(argv[i]) && !(opt & OPT_in_place)) {
1239 && !(opt & OPT_in_place)
1240 ) {
1241 add_input_file(stdin); 1239 add_input_file(stdin);
1242 process_files(); 1240 process_files();
1243 continue; 1241 continue;
diff --git a/include/libbb.h b/include/libbb.h
index 1d91a0a72..fcd0dfa31 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -255,6 +255,14 @@ extern char *xstrdup(const char *s);
255extern char *xstrndup(const char *s, int n); 255extern char *xstrndup(const char *s, int n);
256extern char *safe_strncpy(char *dst, const char *src, size_t size); 256extern char *safe_strncpy(char *dst, const char *src, size_t size);
257extern char *xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2))); 257extern char *xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
258// gcc-4.1.1 still isn't good enough at optimizing it
259// (+200 bytes compared to macro)
260//static ATTRIBUTE_ALWAYS_INLINE
261//int LONE_DASH(const char *s) { return s[0] == '-' && !s[1]; }
262//static ATTRIBUTE_ALWAYS_INLINE
263//int NOT_LONE_DASH(const char *s) { return s[0] != '-' || s[1]; }
264#define LONE_DASH(s) ((s)[0] == '-' && !(s)[1])
265#define NOT_LONE_DASH(s) ((s)[0] != '-' || (s)[1])
258 266
259/* dmalloc will redefine these to it's own implementation. It is safe 267/* dmalloc will redefine these to it's own implementation. It is safe
260 * to have the prototypes here unconditionally. */ 268 * to have the prototypes here unconditionally. */
diff --git a/libbb/wfopen_input.c b/libbb/wfopen_input.c
index 3da855fe6..7a11dacd7 100644
--- a/libbb/wfopen_input.c
+++ b/libbb/wfopen_input.c
@@ -22,7 +22,7 @@ FILE *fopen_or_warn_stdin(const char *filename)
22 22
23 if (filename != bb_msg_standard_input 23 if (filename != bb_msg_standard_input
24 && filename[0] 24 && filename[0]
25 && (filename[0] != '-' || filename[1]) 25 && NOT_LONE_DASH(filename)
26 ) { 26 ) {
27 fp = fopen_or_warn(filename, "r"); 27 fp = fopen_or_warn(filename, "r");
28 } 28 }
diff --git a/loginutils/getty.c b/loginutils/getty.c
index a85e52306..5ceaefcac 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -239,7 +239,7 @@ static void open_tty(char *tty, struct termios *tp, int local)
239 239
240 /* Set up new standard input, unless we are given an already opened port. */ 240 /* Set up new standard input, unless we are given an already opened port. */
241 241
242 if (strcmp(tty, "-")) { 242 if (NOT_LONE_DASH(tty)) {
243 struct stat st; 243 struct stat st;
244 int fd; 244 int fd;
245 245
diff --git a/loginutils/su.c b/loginutils/su.c
index a23ee932b..046457b6f 100644
--- a/loginutils/su.c
+++ b/loginutils/su.c
@@ -14,25 +14,29 @@ int su_main(int argc, char **argv)
14 char *opt_shell = 0; 14 char *opt_shell = 0;
15 char *opt_command = 0; 15 char *opt_command = 0;
16 char *opt_username = "root"; 16 char *opt_username = "root";
17 char **opt_args = 0;
18 struct passwd *pw; 17 struct passwd *pw;
19 uid_t cur_uid = getuid(); 18 uid_t cur_uid = getuid();
20 const char *tty; 19 const char *tty;
21 char *old_user; 20 char *old_user;
22 21
23 flags = getopt32(argc, argv, "mplc:s:", &opt_command, &opt_shell); 22 flags = getopt32(argc, argv, "mplc:s:", &opt_command, &opt_shell);
23 argc -= optind;
24 argv -= optind;
24#define SU_OPT_mp (3) 25#define SU_OPT_mp (3)
25#define SU_OPT_l (4) 26#define SU_OPT_l (4)
26 27
27 if (optind < argc && argv[optind][0] == '-' && argv[optind][1] == 0) { 28 if (argc && LONE_DASH(argv[0])) {
28 flags |= SU_OPT_l; 29 flags |= SU_OPT_l;
29 ++optind; 30 argc--;
31 argv++;
30 } 32 }
31 33
32 /* get user if specified */ 34 /* get user if specified */
33 if (optind < argc) opt_username = argv [optind++]; 35 if (argc) {
34 36 opt_username = argv[0];
35 if (optind < argc) opt_args = argv + optind; 37// argc--;
38 argv++;
39 }
36 40
37 if (ENABLE_SU_SYSLOG) { 41 if (ENABLE_SU_SYSLOG) {
38 /* The utmp entry (via getlogin) is probably the best way to identify 42 /* The utmp entry (via getlogin) is probably the best way to identify
@@ -84,7 +88,7 @@ int su_main(int argc, char **argv)
84 USE_SELINUX(set_current_security_context(NULL);) 88 USE_SELINUX(set_current_security_context(NULL);)
85 89
86 /* Never returns */ 90 /* Never returns */
87 run_shell(opt_shell, flags & SU_OPT_l, opt_command, (const char**)opt_args); 91 run_shell(opt_shell, flags & SU_OPT_l, opt_command, (const char**)argv);
88 92
89 return EXIT_FAILURE; 93 return EXIT_FAILURE;
90} 94}
diff --git a/miscutils/crontab.c b/miscutils/crontab.c
index 39d3aae41..d442272f0 100644
--- a/miscutils/crontab.c
+++ b/miscutils/crontab.c
@@ -51,7 +51,7 @@ int crontab_main(int ac, char **av)
51 51
52 i = 1; 52 i = 1;
53 if (ac > 1) { 53 if (ac > 1) {
54 if (av[1][0] == '-' && av[1][1] == 0) { 54 if (LONE_DASH(av[1])) {
55 option = REPLACE; 55 option = REPLACE;
56 ++i; 56 ++i;
57 } else if (av[1][0] != '-') { 57 } else if (av[1][0] != '-') {
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index 223d2435c..dff894468 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -132,7 +132,7 @@ int ftp_receive(ftp_host_info_t *server, FILE *control_stream,
132 do_continue = 0; 132 do_continue = 0;
133 } 133 }
134 134
135 if ((local_path[0] == '-') && (local_path[1] == '\0')) { 135 if (LONE_DASH(local_path)) {
136 fd_local = STDOUT_FILENO; 136 fd_local = STDOUT_FILENO;
137 do_continue = 0; 137 do_continue = 0;
138 } 138 }
@@ -212,9 +212,8 @@ int ftp_send(ftp_host_info_t *server, FILE *control_stream,
212 fd_data = xconnect_ftpdata(server, buf); 212 fd_data = xconnect_ftpdata(server, buf);
213 213
214 /* get the local file */ 214 /* get the local file */
215 if ((local_path[0] == '-') && (local_path[1] == '\0')) { 215 fd_local = STDIN_FILENO;
216 fd_local = STDIN_FILENO; 216 if (NOT_LONE_DASH(local_path)) {
217 } else {
218 fd_local = xopen(local_path, O_RDONLY); 217 fd_local = xopen(local_path, O_RDONLY);
219 fstat(fd_local, &sbuf); 218 fstat(fd_local, &sbuf);
220 219
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index 2a267fef6..9fb08e6ba 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -681,7 +681,7 @@ static int ipaddr_modify(int cmd, int argc, char **argv)
681 if (strcmp(*argv, "+") == 0) { 681 if (strcmp(*argv, "+") == 0) {
682 brd_len = -1; 682 brd_len = -1;
683 } 683 }
684 else if (strcmp(*argv, "-") == 0) { 684 else if (LONE_DASH(*argv)) {
685 brd_len = -2; 685 brd_len = -2;
686 } else { 686 } else {
687 get_addr(&addr, *argv, req.ifa.ifa_family); 687 get_addr(&addr, *argv, req.ifa.ifa_family);
diff --git a/networking/tftp.c b/networking/tftp.c
index 64d376fa7..a62c5d8cc 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -530,7 +530,7 @@ int tftp_main(int argc, char **argv)
530 if ((localfile == NULL && remotefile == NULL) || (argv[optind] == NULL)) 530 if ((localfile == NULL && remotefile == NULL) || (argv[optind] == NULL))
531 bb_show_usage(); 531 bb_show_usage();
532 532
533 if (localfile == NULL || strcmp(localfile, "-") == 0) { 533 if (localfile == NULL || LONE_DASH(localfile)) {
534 fd = (cmd == tftp_cmd_get) ? STDOUT_FILENO : STDIN_FILENO; 534 fd = (cmd == tftp_cmd_get) ? STDOUT_FILENO : STDIN_FILENO;
535 } else { 535 } else {
536 fd = open(localfile, flags, 0644); /* fail below */ 536 fd = open(localfile, flags, 0644); /* fail below */
diff --git a/networking/wget.c b/networking/wget.c
index 19bf8f887..fbdbf62f6 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -217,7 +217,7 @@ int wget_main(int argc, char **argv)
217 /* 217 /*
218 * Determine where to start transfer. 218 * Determine where to start transfer.
219 */ 219 */
220 if (fname_out[0] == '-' && !fname_out[1]) { 220 if (LONE_DASH(fname_out)) {
221 output_fd = 1; 221 output_fd = 1;
222 opt &= ~WGET_OPT_CONTINUE; 222 opt &= ~WGET_OPT_CONTINUE;
223 } 223 }
diff --git a/shell/ash.c b/shell/ash.c
index 3a9998fc0..8ba4cb8a0 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -2315,7 +2315,7 @@ cdcmd(int argc, char **argv)
2315 dest = *argptr; 2315 dest = *argptr;
2316 if (!dest) 2316 if (!dest)
2317 dest = bltinlookup(homestr); 2317 dest = bltinlookup(homestr);
2318 else if (dest[0] == '-' && dest[1] == '\0') { 2318 else if (LONE_DASH(dest)) {
2319 dest = bltinlookup("OLDPWD"); 2319 dest = bltinlookup("OLDPWD");
2320 flags |= CD_PRINT; 2320 flags |= CD_PRINT;
2321 } 2321 }
@@ -8889,7 +8889,7 @@ options(int cmdline)
8889 argptr++; 8889 argptr++;
8890 if ((c = *p++) == '-') { 8890 if ((c = *p++) == '-') {
8891 val = 1; 8891 val = 1;
8892 if (p[0] == '\0' || (p[0] == '-' && p[1] == '\0')) { 8892 if (p[0] == '\0' || LONE_DASH(p)) {
8893 if (!cmdline) { 8893 if (!cmdline) {
8894 /* "-" means turn off -x and -v */ 8894 /* "-" means turn off -x and -v */
8895 if (p[0] == '\0') 8895 if (p[0] == '\0')
@@ -9114,7 +9114,7 @@ atend:
9114 goto out; 9114 goto out;
9115 } 9115 }
9116 optnext++; 9116 optnext++;
9117 if (p[0] == '-' && p[1] == '\0') /* check for "--" */ 9117 if (LONE_DASH(p)) /* check for "--" */
9118 goto atend; 9118 goto atend;
9119 } 9119 }
9120 9120
@@ -9232,7 +9232,7 @@ nextopt(const char *optstring)
9232 if (p == NULL || *p != '-' || *++p == '\0') 9232 if (p == NULL || *p != '-' || *++p == '\0')
9233 return '\0'; 9233 return '\0';
9234 argptr++; 9234 argptr++;
9235 if (p[0] == '-' && p[1] == '\0') /* check for "--" */ 9235 if (LONE_DASH(p)) /* check for "--" */
9236 return '\0'; 9236 return '\0';
9237 } 9237 }
9238 c = *p++; 9238 c = *p++;
@@ -9825,7 +9825,7 @@ void fixredir(union node *n, const char *text, int err)
9825 9825
9826 if (is_digit(text[0]) && text[1] == '\0') 9826 if (is_digit(text[0]) && text[1] == '\0')
9827 n->ndup.dupfd = digit_val(text[0]); 9827 n->ndup.dupfd = digit_val(text[0]);
9828 else if (text[0] == '-' && text[1] == '\0') 9828 else if (LONE_DASH(text))
9829 n->ndup.dupfd = -1; 9829 n->ndup.dupfd = -1;
9830 else { 9830 else {
9831 9831
@@ -11650,7 +11650,7 @@ trapcmd(int argc, char **argv)
11650 sh_error("%s: bad trap", *ap); 11650 sh_error("%s: bad trap", *ap);
11651 INTOFF; 11651 INTOFF;
11652 if (action) { 11652 if (action) {
11653 if (action[0] == '-' && action[1] == '\0') 11653 if (LONE_DASH(action))
11654 action = NULL; 11654 action = NULL;
11655 else 11655 else
11656 action = savestr(action); 11656 action = savestr(action);
@@ -12257,7 +12257,7 @@ static void mklocal(char *name)
12257 12257
12258 INTOFF; 12258 INTOFF;
12259 lvp = ckmalloc(sizeof (struct localvar)); 12259 lvp = ckmalloc(sizeof (struct localvar));
12260 if (name[0] == '-' && name[1] == '\0') { 12260 if (LONE_DASH(name)) {
12261 char *p; 12261 char *p;
12262 p = ckmalloc(sizeof(optlist)); 12262 p = ckmalloc(sizeof(optlist));
12263 lvp->text = memcpy(p, optlist, sizeof(optlist)); 12263 lvp->text = memcpy(p, optlist, sizeof(optlist));
diff --git a/shell/msh.c b/shell/msh.c
index 492d3cf43..45ca3df81 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -1001,7 +1001,7 @@ static int newfile(char *s)
1001 1001
1002 DBGPRINTF7(("NEWFILE: opening %s\n", s)); 1002 DBGPRINTF7(("NEWFILE: opening %s\n", s));
1003 1003
1004 if (strcmp(s, "-") != 0) { 1004 if (NOT_LONE_DASH(s)) {
1005 DBGPRINTF(("NEWFILE: s is %s\n", s)); 1005 DBGPRINTF(("NEWFILE: s is %s\n", s));
1006 f = open(s, 0); 1006 f = open(s, 0);
1007 if (f < 0) { 1007 if (f < 0) {