diff options
author | charnier <charnier@FreeBSD.org> | 1997-08-11 07:31:28 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-08-11 07:31:28 +0000 |
commit | 59770b8246c383da01838df128a563d5e574c764 (patch) | |
tree | abc4ec82dd94c0322ce249d1a3454e408766e874 | |
parent | 55429790ab7bed1e7a1d3556ce06ec3010f64dd9 (diff) | |
download | FreeBSD-src-59770b8246c383da01838df128a563d5e574c764.zip FreeBSD-src-59770b8246c383da01838df128a563d5e574c764.tar.gz |
Use err(3).
-rw-r--r-- | usr.bin/strings/strings.1 | 8 | ||||
-rw-r--r-- | usr.bin/strings/strings.1aout | 8 | ||||
-rw-r--r-- | usr.bin/strings/strings.c | 32 |
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; |