diff options
| author | Kyle Evans <kevans@FreeBSD.org> | 2018-06-20 03:31:19 +0000 |
|---|---|---|
| committer | Kyle Evans <kevans@FreeBSD.org> | 2018-06-20 03:31:19 +0000 |
| commit | 7137597e15bdd19c4aa33a0848595bec51b7a1da (patch) | |
| tree | 26c1a689c9babbbf1ce5914c9c4f2aafe5521261 /usr.bin/sort | |
| parent | 36180cd53d0e4d6bd4c5fb27c2f9ba80dbefa62c (diff) | |
Notes
Diffstat (limited to 'usr.bin/sort')
| -rw-r--r-- | usr.bin/sort/file.c | 4 | ||||
| -rw-r--r-- | usr.bin/sort/file.h | 4 | ||||
| -rw-r--r-- | usr.bin/sort/sort.c | 6 |
3 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/sort/file.c b/usr.bin/sort/file.c index 59752012eda2..58a97826916e 100644 --- a/usr.bin/sort/file.c +++ b/usr.bin/sort/file.c @@ -227,7 +227,7 @@ file_list_init(struct file_list *fl, bool tmp) * Add a file name to the list */ void -file_list_add(struct file_list *fl, char *fn, bool allocate) +file_list_add(struct file_list *fl, const char *fn, bool allocate) { if (fl && fn) { @@ -1115,7 +1115,7 @@ file_headers_merge(size_t fnum, struct file_header **fh, FILE *f_out) * stdout. */ static void -merge_files_array(size_t argc, char **argv, const char *fn_out) +merge_files_array(size_t argc, const char **argv, const char *fn_out) { if (argv && fn_out) { diff --git a/usr.bin/sort/file.h b/usr.bin/sort/file.h index f3a7d3abc022..724928a7c050 100644 --- a/usr.bin/sort/file.h +++ b/usr.bin/sort/file.h @@ -66,7 +66,7 @@ struct file_reader; */ struct file_list { - char **fns; + const char * *fns; size_t count; size_t sz; bool tmp; @@ -108,7 +108,7 @@ char *new_tmp_file_name(void); void tmp_file_atexit(const char *tmp_file); void file_list_init(struct file_list *fl, bool tmp); -void file_list_add(struct file_list *fl, char *fn, bool allocate); +void file_list_add(struct file_list *fl, const char *fn, bool allocate); void file_list_populate(struct file_list *fl, int argc, char **argv, bool allocate); void file_list_clean(struct file_list *fl); diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c index 5edc5af6703e..bbe8af4607bd 100644 --- a/usr.bin/sort/sort.c +++ b/usr.bin/sort/sort.c @@ -1299,7 +1299,11 @@ main(int argc, char **argv) struct file_list fl; file_list_init(&fl, false); - file_list_populate(&fl, argc, argv, true); + /* No file arguments remaining means "read from stdin." */ + if (argc == 0) + file_list_add(&fl, "-", true); + else + file_list_populate(&fl, argc, argv, true); merge_files(&fl, outfile); file_list_clean(&fl); } |
