summaryrefslogtreecommitdiffstats
path: root/usr.bin/strings
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/strings')
-rw-r--r--usr.bin/strings/strings.18
-rw-r--r--usr.bin/strings/strings.1aout8
-rw-r--r--usr.bin/strings/strings.c32
3 files changed, 25 insertions, 23 deletions
diff --git a/usr.bin/strings/strings.1 b/usr.bin/strings/strings.1
index ceeae10..b22becd 100644
--- a/usr.bin/strings/strings.1
+++ b/usr.bin/strings/strings.1
@@ -38,10 +38,10 @@
.Nm strings
.Nd find printable strings in a file
.Sh SYNOPSIS
-.Nm strings
+.Nm
.Op Fl afo
.Op Fl n Ar number
-.Op Ar file ...
+.Op Ar
.Sh DESCRIPTION
.Nm Strings
displays the sequences of printable characters in each of the specified
@@ -53,12 +53,12 @@ The options are as follows:
.Bl -tag -width Ds
.It Fl a
By default,
-.Nm strings
+.Nm
only searches the text and data segments of object files.
The
.Fl a
option causes
-.Nm strings
+.Nm
to search the entire object file.
.It Fl f
Each string is preceded by the name of the file
diff --git a/usr.bin/strings/strings.1aout b/usr.bin/strings/strings.1aout
index ceeae10..b22becd 100644
--- a/usr.bin/strings/strings.1aout
+++ b/usr.bin/strings/strings.1aout
@@ -38,10 +38,10 @@
.Nm strings
.Nd find printable strings in a file
.Sh SYNOPSIS
-.Nm strings
+.Nm
.Op Fl afo
.Op Fl n Ar number
-.Op Ar file ...
+.Op Ar
.Sh DESCRIPTION
.Nm Strings
displays the sequences of printable characters in each of the specified
@@ -53,12 +53,12 @@ The options are as follows:
.Bl -tag -width Ds
.It Fl a
By default,
-.Nm strings
+.Nm
only searches the text and data segments of object files.
The
.Fl a
option causes
-.Nm strings
+.Nm
to search the entire object file.
.It Fl f
Each string is preceded by the name of the file
diff --git a/usr.bin/strings/strings.c b/usr.bin/strings/strings.c
index 2ddeced..663d73d 100644
--- a/usr.bin/strings/strings.c
+++ b/usr.bin/strings/strings.c
@@ -32,20 +32,24 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1980, 1987, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)strings.c 8.2 (Berkeley) 1/28/94";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <sys/types.h>
#include <a.out.h>
#include <ctype.h>
-#include <errno.h>
+#include <err.h>
#include <fcntl.h>
#include <locale.h>
#include <stdio.h>
@@ -55,8 +59,8 @@ static char sccsid[] = "@(#)strings.c 8.2 (Berkeley) 1/28/94";
#define DEF_LEN 4 /* default minimum string length */
#define ISSTR(ch) (isalnum(ch) || ispunct(ch) || \
- isspace(ch) && (!iscntrl(ch) || ch == '\t') || \
- isascii(ch) && isprint(ch))
+ (isspace(ch) && (!iscntrl(ch) || ch == '\t')) || \
+ (isascii(ch) && isprint(ch)))
typedef struct exec EXEC; /* struct exec cast */
@@ -66,8 +70,10 @@ static int hcnt, /* head count */
read_len; /* length to read */
static u_char hbfr[sizeof(EXEC)]; /* buffer for struct exec */
-static void usage();
+int getch __P((void));
+static void usage __P((void));
+int
main(argc, argv)
int argc;
char **argv;
@@ -128,23 +134,18 @@ main(argc, argv)
if (minlen == -1)
minlen = DEF_LEN;
- else if (minlen < 1) {
- (void)fprintf(stderr, "strings: length less than 1\n");
- exit (1);
- }
+ else if (minlen < 1)
+ errx(1, "length less than 1");
- if (!(bfr = malloc((u_int)minlen))) {
- (void)fprintf(stderr, "strings: %s\n", strerror(errno));
- exit(1);
- }
+ if (!(bfr = malloc((u_int)minlen)))
+ errx(1, "malloc");
bfr[minlen] = '\0';
file = "stdin";
do {
if (*argv) {
file = *argv++;
if (!freopen(file, "r", stdin)) {
- (void)fprintf(stderr,
- "strings: %s: %s\n", file, strerror(errno));
+ warn("%s", file);
exitcode = 1;
goto nextfile;
}
@@ -199,6 +200,7 @@ nextfile: ;
* getch --
* get next character from wherever
*/
+int
getch()
{
++foff;
OpenPOWER on IntegriCloud