inline strcmp(s, "-") [actually macro-ize it for now - gcc is too stupid]
This commit is contained in:
parent
a597aaddfa
commit
9f739445cd
@ -23,7 +23,7 @@ int bunzip2_main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Set input filename and number */
|
/* Set input filename and number */
|
||||||
filename = argv[optind];
|
filename = argv[optind];
|
||||||
if ((filename) && (filename[0] != '-') && (filename[1] != '\0')) {
|
if (filename && NOT_LONE_DASH(filename)) {
|
||||||
/* Open input file */
|
/* Open input file */
|
||||||
src_fd = xopen(filename, O_RDONLY);
|
src_fd = xopen(filename, O_RDONLY);
|
||||||
} else {
|
} else {
|
||||||
|
@ -58,7 +58,7 @@ int gunzip_main(int argc, char **argv)
|
|||||||
|
|
||||||
optind++;
|
optind++;
|
||||||
|
|
||||||
if (old_path == NULL || strcmp(old_path, "-") == 0) {
|
if (old_path == NULL || LONE_DASH(old_path)) {
|
||||||
src_fd = STDIN_FILENO;
|
src_fd = STDIN_FILENO;
|
||||||
opt |= GUNZIP_OPT_STDOUT;
|
opt |= GUNZIP_OPT_STDOUT;
|
||||||
USE_DESKTOP(opt &= ~GUNZIP_OPT_VERBOSE;)
|
USE_DESKTOP(opt &= ~GUNZIP_OPT_VERBOSE;)
|
||||||
|
@ -1201,7 +1201,7 @@ int gzip_main(int argc, char **argv)
|
|||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
|
|
||||||
clear_bufs();
|
clear_bufs();
|
||||||
if (strcmp(argv[i], "-") == 0) {
|
if (LONE_DASH(argv[i])) {
|
||||||
time_stamp = 0;
|
time_stamp = 0;
|
||||||
inFileNum = STDIN_FILENO;
|
inFileNum = STDIN_FILENO;
|
||||||
outFileNum = STDOUT_FILENO;
|
outFileNum = STDOUT_FILENO;
|
||||||
|
@ -851,7 +851,7 @@ int tar_main(int argc, char **argv)
|
|||||||
flags = O_RDONLY;
|
flags = O_RDONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tar_filename[0] == '-' && !tar_filename[1]) {
|
if (LONE_DASH(tar_filename)) {
|
||||||
tar_handle->src_fd = fileno(tar_stream);
|
tar_handle->src_fd = fileno(tar_stream);
|
||||||
tar_handle->seek = seek_by_read;
|
tar_handle->seek = seek_by_read;
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,7 +25,7 @@ int uncompress_main(int argc, char **argv)
|
|||||||
int src_fd;
|
int src_fd;
|
||||||
int dst_fd;
|
int dst_fd;
|
||||||
|
|
||||||
if (strcmp(compressed_file, "-") == 0) {
|
if (LONE_DASH(compressed_file)) {
|
||||||
src_fd = STDIN_FILENO;
|
src_fd = STDIN_FILENO;
|
||||||
flags |= GUNZIP_TO_STDOUT;
|
flags |= GUNZIP_TO_STDOUT;
|
||||||
} else {
|
} else {
|
||||||
|
@ -26,7 +26,7 @@ int unlzma_main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Set input filename and number */
|
/* Set input filename and number */
|
||||||
filename = argv[optind];
|
filename = argv[optind];
|
||||||
if (filename && (filename[0] != '-') && (filename[1] != '\0')) {
|
if (filename && NOT_LONE_DASH(filename)) {
|
||||||
/* Open input file */
|
/* Open input file */
|
||||||
src_fd = xopen(filename, O_RDONLY);
|
src_fd = xopen(filename, O_RDONLY);
|
||||||
} else {
|
} else {
|
||||||
|
@ -187,11 +187,10 @@ int unzip_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Open input file */
|
/* Open input file */
|
||||||
if (strcmp("-", src_fn) == 0) {
|
if (LONE_DASH(src_fn)) {
|
||||||
src_fd = STDIN_FILENO;
|
src_fd = STDIN_FILENO;
|
||||||
/* Cannot use prompt mode since zip data is arriving on STDIN */
|
/* Cannot use prompt mode since zip data is arriving on STDIN */
|
||||||
overwrite = (overwrite == o_prompt) ? o_never : overwrite;
|
overwrite = (overwrite == o_prompt) ? o_never : overwrite;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
static const char *const extn[] = {"", ".zip", ".ZIP"};
|
static const char *const extn[] = {"", ".zip", ".ZIP"};
|
||||||
int orig_src_fn_len = strlen(src_fn);
|
int orig_src_fn_len = strlen(src_fn);
|
||||||
|
@ -168,6 +168,8 @@ int cut_main(int argc, char **argv)
|
|||||||
|
|
||||||
opt_complementary = "b--bcf:c--bcf:f--bcf";
|
opt_complementary = "b--bcf:c--bcf:f--bcf";
|
||||||
getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, <ok);
|
getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, <ok);
|
||||||
|
// argc -= optind;
|
||||||
|
argv += optind;
|
||||||
if (!(option_mask32 & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
|
if (!(option_mask32 & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
|
||||||
bb_error_msg_and_die("expected a list of bytes, characters, or fields");
|
bb_error_msg_and_die("expected a list of bytes, characters, or fields");
|
||||||
if (option_mask32 & BB_GETOPT_ERROR)
|
if (option_mask32 & BB_GETOPT_ERROR)
|
||||||
@ -262,22 +264,21 @@ int cut_main(int argc, char **argv)
|
|||||||
qsort(cut_lists, nlists, sizeof(struct cut_list), cmpfunc);
|
qsort(cut_lists, nlists, sizeof(struct cut_list), cmpfunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* argv[(optind)..(argc-1)] should be names of file to process. If no
|
/* argv[0..argc-1] should be names of file to process. If no
|
||||||
* files were specified or '-' was specified, take input from stdin.
|
* files were specified or '-' was specified, take input from stdin.
|
||||||
* Otherwise, we process all the files specified. */
|
* Otherwise, we process all the files specified. */
|
||||||
if (argv[optind] == NULL
|
if (argv[0] == NULL || LONE_DASH(argv[0])) {
|
||||||
|| (argv[optind][0] == '-' && argv[optind][1] == '\0')) {
|
|
||||||
cut_file(stdin);
|
cut_file(stdin);
|
||||||
} else {
|
} else {
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|
||||||
for (; optind < argc; optind++) {
|
do {
|
||||||
file = fopen_or_warn(argv[optind], "r");
|
file = fopen_or_warn(argv[0], "r");
|
||||||
if (file) {
|
if (file) {
|
||||||
cut_file(file);
|
cut_file(file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
}
|
} while (*++argv);
|
||||||
}
|
}
|
||||||
if (ENABLE_FEATURE_CLEAN_UP)
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
free(cut_lists);
|
free(cut_lists);
|
||||||
|
@ -904,19 +904,19 @@ static int diffreg(char *ofile1, char *ofile2, int flags)
|
|||||||
|
|
||||||
if (S_ISDIR(stb1.st_mode) != S_ISDIR(stb2.st_mode))
|
if (S_ISDIR(stb1.st_mode) != S_ISDIR(stb2.st_mode))
|
||||||
return (S_ISDIR(stb1.st_mode) ? D_MISMATCH1 : D_MISMATCH2);
|
return (S_ISDIR(stb1.st_mode) ? D_MISMATCH1 : D_MISMATCH2);
|
||||||
if (strcmp(file1, "-") == 0 && strcmp(file2, "-") == 0)
|
if (LONE_DASH(file1) && LONE_DASH(file2))
|
||||||
goto closem;
|
goto closem;
|
||||||
|
|
||||||
f1 = stdin;
|
f1 = stdin;
|
||||||
if (flags & D_EMPTY1)
|
if (flags & D_EMPTY1)
|
||||||
f1 = xfopen(bb_dev_null, "r");
|
f1 = xfopen(bb_dev_null, "r");
|
||||||
else if (file1[0] != '-' || file1[1]) /* not "-" */
|
else if (NOT_LONE_DASH(file1))
|
||||||
f1 = xfopen(file1, "r");
|
f1 = xfopen(file1, "r");
|
||||||
|
|
||||||
f2 = stdin;
|
f2 = stdin;
|
||||||
if (flags & D_EMPTY2)
|
if (flags & D_EMPTY2)
|
||||||
f2 = xfopen(bb_dev_null, "r");
|
f2 = xfopen(bb_dev_null, "r");
|
||||||
else if (file2[0] != '-' || file2[1]) /* not "-" */
|
else if (NOT_LONE_DASH(file2))
|
||||||
f2 = xfopen(file2, "r");
|
f2 = xfopen(file2, "r");
|
||||||
|
|
||||||
i = files_differ(f1, f2, flags);
|
i = files_differ(f1, f2, flags);
|
||||||
@ -1212,12 +1212,12 @@ int diff_main(int argc, char **argv)
|
|||||||
bb_error_msg("missing filename");
|
bb_error_msg("missing filename");
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
}
|
}
|
||||||
if (argv[0][0] == '-' && !argv[0][1]) { /* "-" */
|
if (LONE_DASH(argv[0])) {
|
||||||
fstat(STDIN_FILENO, &stb1);
|
fstat(STDIN_FILENO, &stb1);
|
||||||
gotstdin = 1;
|
gotstdin = 1;
|
||||||
} else
|
} else
|
||||||
xstat(argv[0], &stb1);
|
xstat(argv[0], &stb1);
|
||||||
if (argv[1][0] == '-' && !argv[1][1]) { /* "-" */
|
if (LONE_DASH(argv[1])) {
|
||||||
fstat(STDIN_FILENO, &stb2);
|
fstat(STDIN_FILENO, &stb2);
|
||||||
gotstdin = 1;
|
gotstdin = 1;
|
||||||
} else
|
} else
|
||||||
|
@ -58,7 +58,7 @@ int env_main(int argc, char** argv)
|
|||||||
opt = getopt32(argc, argv, "+iu:", &unset_env);
|
opt = getopt32(argc, argv, "+iu:", &unset_env);
|
||||||
|
|
||||||
argv += optind;
|
argv += optind;
|
||||||
if (*argv && (argv[0][0] == '-') && !argv[0][1]) {
|
if (*argv && LONE_DASH(argv[0])) {
|
||||||
opt |= 1;
|
opt |= 1;
|
||||||
++argv;
|
++argv;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo)
|
|||||||
void (*final)(void*, void*);
|
void (*final)(void*, void*);
|
||||||
|
|
||||||
src_fd = STDIN_FILENO;
|
src_fd = STDIN_FILENO;
|
||||||
if (filename[0] != '-' || filename[1]) { /* not "-" */
|
if (NOT_LONE_DASH(filename)) {
|
||||||
src_fd = open(filename, O_RDONLY);
|
src_fd = open(filename, O_RDONLY);
|
||||||
if (src_fd < 0) {
|
if (src_fd < 0) {
|
||||||
bb_perror_msg("%s", filename);
|
bb_perror_msg("%s", filename);
|
||||||
@ -120,7 +120,7 @@ int md5_sha1_sum_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pre_computed_stream = stdin;
|
pre_computed_stream = stdin;
|
||||||
if (file_ptr[0] != '-' || file_ptr[1]) { /* not "-" */
|
if (NOT_LONE_DASH(file_ptr)) {
|
||||||
pre_computed_stream = xfopen(file_ptr, "r");
|
pre_computed_stream = xfopen(file_ptr, "r");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ int sort_main(int argc, char **argv)
|
|||||||
/* Open input files and read data */
|
/* Open input files and read data */
|
||||||
for (i = argv[optind] ? optind : optind-1; argv[i]; i++) {
|
for (i = argv[optind] ? optind : optind-1; argv[i]; i++) {
|
||||||
fp = stdin;
|
fp = stdin;
|
||||||
if (i >= optind && (argv[i][0] != '-' || argv[i][1]))
|
if (i >= optind && NOT_LONE_DASH(argv[i]))
|
||||||
fp = xfopen(argv[i], "r");
|
fp = xfopen(argv[i], "r");
|
||||||
for (;;) {
|
for (;;) {
|
||||||
line = GET_LINE(fp);
|
line = GET_LINE(fp);
|
||||||
|
@ -18,9 +18,6 @@
|
|||||||
/* 1 if any of the files read were the standard input */
|
/* 1 if any of the files read were the standard input */
|
||||||
static int have_read_stdin;
|
static int have_read_stdin;
|
||||||
|
|
||||||
/* make a little more readable and avoid using strcmp for just 2 bytes */
|
|
||||||
#define IS_STDIN(s) (s[0] == '-' && s[1] == '\0')
|
|
||||||
|
|
||||||
/* Calculate and print the rotated checksum and the size in 1K blocks
|
/* Calculate and print the rotated checksum and the size in 1K blocks
|
||||||
of file FILE, or of the standard input if FILE is "-".
|
of file FILE, or of the standard input if FILE is "-".
|
||||||
If PRINT_NAME is >1, print FILE next to the checksum and size.
|
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)
|
|||||||
int ch; /* Each character read. */
|
int ch; /* Each character read. */
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (IS_STDIN(file)) {
|
if (LONE_DASH(file)) {
|
||||||
fp = stdin;
|
fp = stdin;
|
||||||
have_read_stdin++;
|
have_read_stdin++;
|
||||||
} else {
|
} else {
|
||||||
@ -84,7 +81,7 @@ static int sysv_sum_file(const char *file, int print_name)
|
|||||||
/* The sum of all the input bytes, modulo (UINT_MAX + 1). */
|
/* The sum of all the input bytes, modulo (UINT_MAX + 1). */
|
||||||
unsigned int s = 0;
|
unsigned int s = 0;
|
||||||
|
|
||||||
if (IS_STDIN(file)) {
|
if (LONE_DASH(file)) {
|
||||||
fd = 0;
|
fd = 0;
|
||||||
have_read_stdin = 1;
|
have_read_stdin = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -103,7 +100,7 @@ static int sysv_sum_file(const char *file, int print_name)
|
|||||||
release_and_ret:
|
release_and_ret:
|
||||||
bb_perror_msg(file);
|
bb_perror_msg(file);
|
||||||
RELEASE_CONFIG_BUFFER(buf);
|
RELEASE_CONFIG_BUFFER(buf);
|
||||||
if (!IS_STDIN(file))
|
if (NOT_LONE_DASH(file))
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -113,7 +110,7 @@ release_and_ret:
|
|||||||
s += buf[bytes_read];
|
s += buf[bytes_read];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_STDIN(file) && close(fd) == -1)
|
if (NOT_LONE_DASH(file) && close(fd) == -1)
|
||||||
goto release_and_ret;
|
goto release_and_ret;
|
||||||
else
|
else
|
||||||
RELEASE_CONFIG_BUFFER(buf);
|
RELEASE_CONFIG_BUFFER(buf);
|
||||||
|
@ -176,7 +176,7 @@ int tail_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if ((argv[i][0] == '-') && !argv[i][1]) {
|
if (LONE_DASH(argv[i])) {
|
||||||
DO_STDIN:
|
DO_STDIN:
|
||||||
fds[nfiles] = STDIN_FILENO;
|
fds[nfiles] = STDIN_FILENO;
|
||||||
} else if ((fds[nfiles] = open(argv[i], O_RDONLY)) < 0) {
|
} else if ((fds[nfiles] = open(argv[i], O_RDONLY)) < 0) {
|
||||||
|
@ -166,7 +166,7 @@ int uudecode_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
outname++;
|
outname++;
|
||||||
}
|
}
|
||||||
if (strcmp(outname, "-") == 0) {
|
if (LONE_DASH(outname)) {
|
||||||
dst_stream = stdout;
|
dst_stream = stdout;
|
||||||
} else {
|
} else {
|
||||||
dst_stream = xfopen(outname, "w");
|
dst_stream = xfopen(outname, "w");
|
||||||
|
@ -1249,8 +1249,8 @@ static void PRS(int argc, char *argv[])
|
|||||||
progress_fd = 0;
|
progress_fd = 0;
|
||||||
else
|
else
|
||||||
goto next_arg;
|
goto next_arg;
|
||||||
} else if ((i+1) < argc &&
|
} else if ((i+1) < argc
|
||||||
!strncmp(argv[i+1], "-", 1) == 0) {
|
&& argv[i+1][0] != '-') {
|
||||||
progress_fd = string_to_int(argv[i]);
|
progress_fd = string_to_int(argv[i]);
|
||||||
if (progress_fd < 0)
|
if (progress_fd < 0)
|
||||||
progress_fd = 0;
|
progress_fd = 0;
|
||||||
|
@ -1235,9 +1235,7 @@ int sed_main(int argc, char **argv)
|
|||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
int nonstdoutfd;
|
int nonstdoutfd;
|
||||||
|
|
||||||
if (argv[i][0] == '-' && !argv[i][1]
|
if (LONE_DASH(argv[i]) && !(opt & OPT_in_place)) {
|
||||||
&& !(opt & OPT_in_place)
|
|
||||||
) {
|
|
||||||
add_input_file(stdin);
|
add_input_file(stdin);
|
||||||
process_files();
|
process_files();
|
||||||
continue;
|
continue;
|
||||||
|
@ -255,6 +255,14 @@ extern char *xstrdup(const char *s);
|
|||||||
extern char *xstrndup(const char *s, int n);
|
extern char *xstrndup(const char *s, int n);
|
||||||
extern char *safe_strncpy(char *dst, const char *src, size_t size);
|
extern char *safe_strncpy(char *dst, const char *src, size_t size);
|
||||||
extern char *xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
|
extern char *xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
|
||||||
|
// gcc-4.1.1 still isn't good enough at optimizing it
|
||||||
|
// (+200 bytes compared to macro)
|
||||||
|
//static ATTRIBUTE_ALWAYS_INLINE
|
||||||
|
//int LONE_DASH(const char *s) { return s[0] == '-' && !s[1]; }
|
||||||
|
//static ATTRIBUTE_ALWAYS_INLINE
|
||||||
|
//int NOT_LONE_DASH(const char *s) { return s[0] != '-' || s[1]; }
|
||||||
|
#define LONE_DASH(s) ((s)[0] == '-' && !(s)[1])
|
||||||
|
#define NOT_LONE_DASH(s) ((s)[0] != '-' || (s)[1])
|
||||||
|
|
||||||
/* dmalloc will redefine these to it's own implementation. It is safe
|
/* dmalloc will redefine these to it's own implementation. It is safe
|
||||||
* to have the prototypes here unconditionally. */
|
* to have the prototypes here unconditionally. */
|
||||||
|
@ -22,7 +22,7 @@ FILE *fopen_or_warn_stdin(const char *filename)
|
|||||||
|
|
||||||
if (filename != bb_msg_standard_input
|
if (filename != bb_msg_standard_input
|
||||||
&& filename[0]
|
&& filename[0]
|
||||||
&& (filename[0] != '-' || filename[1])
|
&& NOT_LONE_DASH(filename)
|
||||||
) {
|
) {
|
||||||
fp = fopen_or_warn(filename, "r");
|
fp = fopen_or_warn(filename, "r");
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ static void open_tty(char *tty, struct termios *tp, int local)
|
|||||||
|
|
||||||
/* Set up new standard input, unless we are given an already opened port. */
|
/* Set up new standard input, unless we are given an already opened port. */
|
||||||
|
|
||||||
if (strcmp(tty, "-")) {
|
if (NOT_LONE_DASH(tty)) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
@ -14,25 +14,29 @@ int su_main(int argc, char **argv)
|
|||||||
char *opt_shell = 0;
|
char *opt_shell = 0;
|
||||||
char *opt_command = 0;
|
char *opt_command = 0;
|
||||||
char *opt_username = "root";
|
char *opt_username = "root";
|
||||||
char **opt_args = 0;
|
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
uid_t cur_uid = getuid();
|
uid_t cur_uid = getuid();
|
||||||
const char *tty;
|
const char *tty;
|
||||||
char *old_user;
|
char *old_user;
|
||||||
|
|
||||||
flags = getopt32(argc, argv, "mplc:s:", &opt_command, &opt_shell);
|
flags = getopt32(argc, argv, "mplc:s:", &opt_command, &opt_shell);
|
||||||
|
argc -= optind;
|
||||||
|
argv -= optind;
|
||||||
#define SU_OPT_mp (3)
|
#define SU_OPT_mp (3)
|
||||||
#define SU_OPT_l (4)
|
#define SU_OPT_l (4)
|
||||||
|
|
||||||
if (optind < argc && argv[optind][0] == '-' && argv[optind][1] == 0) {
|
if (argc && LONE_DASH(argv[0])) {
|
||||||
flags |= SU_OPT_l;
|
flags |= SU_OPT_l;
|
||||||
++optind;
|
argc--;
|
||||||
|
argv++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get user if specified */
|
/* get user if specified */
|
||||||
if (optind < argc) opt_username = argv [optind++];
|
if (argc) {
|
||||||
|
opt_username = argv[0];
|
||||||
if (optind < argc) opt_args = argv + optind;
|
// argc--;
|
||||||
|
argv++;
|
||||||
|
}
|
||||||
|
|
||||||
if (ENABLE_SU_SYSLOG) {
|
if (ENABLE_SU_SYSLOG) {
|
||||||
/* The utmp entry (via getlogin) is probably the best way to identify
|
/* The utmp entry (via getlogin) is probably the best way to identify
|
||||||
@ -84,7 +88,7 @@ int su_main(int argc, char **argv)
|
|||||||
USE_SELINUX(set_current_security_context(NULL);)
|
USE_SELINUX(set_current_security_context(NULL);)
|
||||||
|
|
||||||
/* Never returns */
|
/* Never returns */
|
||||||
run_shell(opt_shell, flags & SU_OPT_l, opt_command, (const char**)opt_args);
|
run_shell(opt_shell, flags & SU_OPT_l, opt_command, (const char**)argv);
|
||||||
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ int crontab_main(int ac, char **av)
|
|||||||
|
|
||||||
i = 1;
|
i = 1;
|
||||||
if (ac > 1) {
|
if (ac > 1) {
|
||||||
if (av[1][0] == '-' && av[1][1] == 0) {
|
if (LONE_DASH(av[1])) {
|
||||||
option = REPLACE;
|
option = REPLACE;
|
||||||
++i;
|
++i;
|
||||||
} else if (av[1][0] != '-') {
|
} else if (av[1][0] != '-') {
|
||||||
|
@ -132,7 +132,7 @@ int ftp_receive(ftp_host_info_t *server, FILE *control_stream,
|
|||||||
do_continue = 0;
|
do_continue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((local_path[0] == '-') && (local_path[1] == '\0')) {
|
if (LONE_DASH(local_path)) {
|
||||||
fd_local = STDOUT_FILENO;
|
fd_local = STDOUT_FILENO;
|
||||||
do_continue = 0;
|
do_continue = 0;
|
||||||
}
|
}
|
||||||
@ -212,9 +212,8 @@ int ftp_send(ftp_host_info_t *server, FILE *control_stream,
|
|||||||
fd_data = xconnect_ftpdata(server, buf);
|
fd_data = xconnect_ftpdata(server, buf);
|
||||||
|
|
||||||
/* get the local file */
|
/* get the local file */
|
||||||
if ((local_path[0] == '-') && (local_path[1] == '\0')) {
|
|
||||||
fd_local = STDIN_FILENO;
|
fd_local = STDIN_FILENO;
|
||||||
} else {
|
if (NOT_LONE_DASH(local_path)) {
|
||||||
fd_local = xopen(local_path, O_RDONLY);
|
fd_local = xopen(local_path, O_RDONLY);
|
||||||
fstat(fd_local, &sbuf);
|
fstat(fd_local, &sbuf);
|
||||||
|
|
||||||
|
@ -681,7 +681,7 @@ static int ipaddr_modify(int cmd, int argc, char **argv)
|
|||||||
if (strcmp(*argv, "+") == 0) {
|
if (strcmp(*argv, "+") == 0) {
|
||||||
brd_len = -1;
|
brd_len = -1;
|
||||||
}
|
}
|
||||||
else if (strcmp(*argv, "-") == 0) {
|
else if (LONE_DASH(*argv)) {
|
||||||
brd_len = -2;
|
brd_len = -2;
|
||||||
} else {
|
} else {
|
||||||
get_addr(&addr, *argv, req.ifa.ifa_family);
|
get_addr(&addr, *argv, req.ifa.ifa_family);
|
||||||
|
@ -530,7 +530,7 @@ int tftp_main(int argc, char **argv)
|
|||||||
if ((localfile == NULL && remotefile == NULL) || (argv[optind] == NULL))
|
if ((localfile == NULL && remotefile == NULL) || (argv[optind] == NULL))
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
|
|
||||||
if (localfile == NULL || strcmp(localfile, "-") == 0) {
|
if (localfile == NULL || LONE_DASH(localfile)) {
|
||||||
fd = (cmd == tftp_cmd_get) ? STDOUT_FILENO : STDIN_FILENO;
|
fd = (cmd == tftp_cmd_get) ? STDOUT_FILENO : STDIN_FILENO;
|
||||||
} else {
|
} else {
|
||||||
fd = open(localfile, flags, 0644); /* fail below */
|
fd = open(localfile, flags, 0644); /* fail below */
|
||||||
|
@ -217,7 +217,7 @@ int wget_main(int argc, char **argv)
|
|||||||
/*
|
/*
|
||||||
* Determine where to start transfer.
|
* Determine where to start transfer.
|
||||||
*/
|
*/
|
||||||
if (fname_out[0] == '-' && !fname_out[1]) {
|
if (LONE_DASH(fname_out)) {
|
||||||
output_fd = 1;
|
output_fd = 1;
|
||||||
opt &= ~WGET_OPT_CONTINUE;
|
opt &= ~WGET_OPT_CONTINUE;
|
||||||
}
|
}
|
||||||
|
14
shell/ash.c
14
shell/ash.c
@ -2315,7 +2315,7 @@ cdcmd(int argc, char **argv)
|
|||||||
dest = *argptr;
|
dest = *argptr;
|
||||||
if (!dest)
|
if (!dest)
|
||||||
dest = bltinlookup(homestr);
|
dest = bltinlookup(homestr);
|
||||||
else if (dest[0] == '-' && dest[1] == '\0') {
|
else if (LONE_DASH(dest)) {
|
||||||
dest = bltinlookup("OLDPWD");
|
dest = bltinlookup("OLDPWD");
|
||||||
flags |= CD_PRINT;
|
flags |= CD_PRINT;
|
||||||
}
|
}
|
||||||
@ -8889,7 +8889,7 @@ options(int cmdline)
|
|||||||
argptr++;
|
argptr++;
|
||||||
if ((c = *p++) == '-') {
|
if ((c = *p++) == '-') {
|
||||||
val = 1;
|
val = 1;
|
||||||
if (p[0] == '\0' || (p[0] == '-' && p[1] == '\0')) {
|
if (p[0] == '\0' || LONE_DASH(p)) {
|
||||||
if (!cmdline) {
|
if (!cmdline) {
|
||||||
/* "-" means turn off -x and -v */
|
/* "-" means turn off -x and -v */
|
||||||
if (p[0] == '\0')
|
if (p[0] == '\0')
|
||||||
@ -9114,7 +9114,7 @@ atend:
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
optnext++;
|
optnext++;
|
||||||
if (p[0] == '-' && p[1] == '\0') /* check for "--" */
|
if (LONE_DASH(p)) /* check for "--" */
|
||||||
goto atend;
|
goto atend;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9232,7 +9232,7 @@ nextopt(const char *optstring)
|
|||||||
if (p == NULL || *p != '-' || *++p == '\0')
|
if (p == NULL || *p != '-' || *++p == '\0')
|
||||||
return '\0';
|
return '\0';
|
||||||
argptr++;
|
argptr++;
|
||||||
if (p[0] == '-' && p[1] == '\0') /* check for "--" */
|
if (LONE_DASH(p)) /* check for "--" */
|
||||||
return '\0';
|
return '\0';
|
||||||
}
|
}
|
||||||
c = *p++;
|
c = *p++;
|
||||||
@ -9825,7 +9825,7 @@ void fixredir(union node *n, const char *text, int err)
|
|||||||
|
|
||||||
if (is_digit(text[0]) && text[1] == '\0')
|
if (is_digit(text[0]) && text[1] == '\0')
|
||||||
n->ndup.dupfd = digit_val(text[0]);
|
n->ndup.dupfd = digit_val(text[0]);
|
||||||
else if (text[0] == '-' && text[1] == '\0')
|
else if (LONE_DASH(text))
|
||||||
n->ndup.dupfd = -1;
|
n->ndup.dupfd = -1;
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -11650,7 +11650,7 @@ trapcmd(int argc, char **argv)
|
|||||||
sh_error("%s: bad trap", *ap);
|
sh_error("%s: bad trap", *ap);
|
||||||
INTOFF;
|
INTOFF;
|
||||||
if (action) {
|
if (action) {
|
||||||
if (action[0] == '-' && action[1] == '\0')
|
if (LONE_DASH(action))
|
||||||
action = NULL;
|
action = NULL;
|
||||||
else
|
else
|
||||||
action = savestr(action);
|
action = savestr(action);
|
||||||
@ -12257,7 +12257,7 @@ static void mklocal(char *name)
|
|||||||
|
|
||||||
INTOFF;
|
INTOFF;
|
||||||
lvp = ckmalloc(sizeof (struct localvar));
|
lvp = ckmalloc(sizeof (struct localvar));
|
||||||
if (name[0] == '-' && name[1] == '\0') {
|
if (LONE_DASH(name)) {
|
||||||
char *p;
|
char *p;
|
||||||
p = ckmalloc(sizeof(optlist));
|
p = ckmalloc(sizeof(optlist));
|
||||||
lvp->text = memcpy(p, optlist, sizeof(optlist));
|
lvp->text = memcpy(p, optlist, sizeof(optlist));
|
||||||
|
@ -1001,7 +1001,7 @@ static int newfile(char *s)
|
|||||||
|
|
||||||
DBGPRINTF7(("NEWFILE: opening %s\n", s));
|
DBGPRINTF7(("NEWFILE: opening %s\n", s));
|
||||||
|
|
||||||
if (strcmp(s, "-") != 0) {
|
if (NOT_LONE_DASH(s)) {
|
||||||
DBGPRINTF(("NEWFILE: s is %s\n", s));
|
DBGPRINTF(("NEWFILE: s is %s\n", s));
|
||||||
f = open(s, 0);
|
f = open(s, 0);
|
||||||
if (f < 0) {
|
if (f < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user