[hackers] [sbase] Allow strings(1) to operate on more than one file || sin

From: <git_AT_suckless.org>
Date: Thu, 10 Oct 2013 17:07:01 +0200

commit 12ad81fa245ee1c9e37a7527741a08bd3ba7df5a
Author: sin <sin_AT_2f30.org>
Date: Thu Oct 10 16:04:15 2013 +0100

    Allow strings(1) to operate on more than one file

diff --git a/strings.1 b/strings.1
index 11e2293..3d8cdff 100644
--- a/strings.1
+++ b/strings.1
_AT_@ -3,7 +3,7 @@
 strings \- print the strings of printable characters in files
 .SH SYNOPSIS
 .B strings
-.IR [file...]
+.IR file...
 .SH DESCRIPTION
 .B strings
 prints the printable character sequences that are at least 6 characters
diff --git a/strings.c b/strings.c
index ff2ca18..c407b56 100644
--- a/strings.c
+++ b/strings.c
_AT_@ -9,7 +9,7 @@ static void dostrings(FILE *fp, const char *fname);
 static void
 usage(void)
 {
- eprintf("usage: %s file
", argv0);
+ eprintf("usage: %s file...
", argv0);
 }
 
 int
_AT_@ -22,13 +22,15 @@ main(int argc, char *argv[])
                 usage();
         } ARGEND;
 
- if (argc > 0) {
- if (!(fp = fopen(argv[0], "r")))
- eprintf("open %s:", argv[0]);
- dostrings(fp, argv[0]);
- fclose(fp);
- } else {
+ if (argc == 0) {
                 dostrings(stdin, "<stdin>");
+ } else {
+ for (; argc > 0; argc--, argv++) {
+ if (!(fp = fopen(argv[0], "r")))
+ eprintf("open %s:", argv[0]);
+ dostrings(fp, argv[0]);
+ fclose(fp);
+ }
         }
 
         return EXIT_SUCCESS;
Received on Thu Oct 10 2013 - 17:07:01 CEST

This archive was generated by hypermail 2.3.0 : Thu Oct 10 2013 - 17:12:13 CEST