---
Makefile | 1 +
strings.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
create mode 100644 strings.c
diff --git a/Makefile b/Makefile
index 33c78a0..6bc091a 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -70,6 +70,7 @@ SRC = \
sort.c \
split.c \
sponge.c \
+ strings.c \
sync.c \
tail.c \
tar.c \
diff --git a/strings.c b/strings.c
new file mode 100644
index 0000000..7386963
--- /dev/null
+++ b/strings.c
_AT_@ -0,0 +1,56 @@
+/* See LICENSE file for copyright and license details. */
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "util.h"
+
+static void dostrings(FILE *fp, const char *fname);
+
+static void
+usage(void)
+{
+ eprintf("usage: %s file\n", argv0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ FILE *fp;
+
+ ARGBEGIN {
+ default:
+ usage();
+ } ARGEND;
+
+ if (argc > 0) {
+ if (!(fp = fopen(argv[0], "r")))
+ eprintf("open %s:", argv[0]);
+ dostrings(fp, argv[0]);
+ fclose(fp);
+ } else {
+ dostrings(stdin, "<stdin>");
+ }
+
+ return 0;
+}
+
+static void
+dostrings(FILE *fp, const char *fname)
+{
+ unsigned char buf[BUFSIZ];
+ int c, i = 0;
+ off_t offset = 0;
+
+ do {
+ offset++;
+ if (isprint(c = getc(fp)))
+ buf[i++] = c;
+ if ((!isprint(c) && i >= 6) || i == sizeof(buf) - 1) {
+ buf[i] = '\0';
+ printf("%8ld: %s\n", (long)offset - i - 1, buf);
+ i = 0;
+ }
+ } while (c != EOF);
+ if (ferror(fp))
+ eprintf("%s read error:", fname);
+}
--
1.8.2.3
--sm4nu43k4a2Rpi4c
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="0006-Add-stat-1.patch"
Content-Transfer-Encoding: 8bit
Received on Mon Sep 17 2001 - 00:00:00 CEST
This archive was generated by hypermail 2.3.0 : Thu Aug 15 2013 - 14:12:02 CEST