Page MenuHomeFreeBSD

D38280.id116053.diff
No OneTemporary

D38280.id116053.diff

diff --git a/usr.bin/cmp/cmp.c b/usr.bin/cmp/cmp.c
--- a/usr.bin/cmp/cmp.c
+++ b/usr.bin/cmp/cmp.c
@@ -75,6 +75,17 @@
{NULL, no_argument, NULL, 0}
};
+#ifdef SIGINFO
+volatile sig_atomic_t info;
+
+static void
+siginfo(int signo)
+{
+
+ info = signo;
+}
+#endif
+
static void usage(void);
static bool
@@ -240,6 +251,9 @@
}
}
+#ifdef SIGINFO
+ signal(SIGINFO, siginfo);
+#endif
if (special)
c_special(fd1, file1, skip1, fd2, file2, skip2, limit);
else {
@@ -252,6 +266,9 @@
c_regular(fd1, file1, skip1, sb1.st_size,
fd2, file2, skip2, sb2.st_size, limit);
}
+#ifdef SIGINFO
+ signal(SIGINFO, SIG_DFL);
+#endif
exit(0);
}
diff --git a/usr.bin/cmp/extern.h b/usr.bin/cmp/extern.h
--- a/usr.bin/cmp/extern.h
+++ b/usr.bin/cmp/extern.h
@@ -46,3 +46,7 @@
void eofmsg(const char *);
extern bool bflag, lflag, sflag, xflag, zflag;
+
+#ifdef SIGINFO
+extern volatile sig_atomic_t info;
+#endif
diff --git a/usr.bin/cmp/regular.c b/usr.bin/cmp/regular.c
--- a/usr.bin/cmp/regular.c
+++ b/usr.bin/cmp/regular.c
@@ -120,6 +120,13 @@
p2 = m2 + (skip2 - off2);
for (byte = line = 1; length--; ++byte) {
+#ifdef SIGINFO
+ if (info) {
+ (void)printf("%s %s char %zu line %zu\n",
+ file1, file2, (size_t)byte, (size_t)line);
+ info = 0;
+ }
+#endif
if ((ch = *p1) != *p2) {
if (xflag) {
dfound = 1;
diff --git a/usr.bin/cmp/special.c b/usr.bin/cmp/special.c
--- a/usr.bin/cmp/special.c
+++ b/usr.bin/cmp/special.c
@@ -77,6 +77,13 @@
goto eof;
for (byte = line = 1; limit == 0 || byte <= limit; ++byte) {
+#ifdef SIGINFO
+ if (info) {
+ (void)printf("%s %s char %zu line %zu\n",
+ file1, file2, (size_t)byte, (size_t)line);
+ info = 0;
+ }
+#endif
ch1 = getc(fp1);
ch2 = getc(fp2);
if (ch1 == EOF || ch2 == EOF)

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 30, 1:06 AM (9 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32424064
Default Alt Text
D38280.id116053.diff (1 KB)

Event Timeline