mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
cmp: Print a summary on SIGINFO.
MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D38280
This commit is contained in:
parent
b9ef068943
commit
6673a5476d
|
@ -75,6 +75,17 @@ static const struct option long_opts[] =
|
|||
{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 @@ main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef SIGINFO
|
||||
(void)signal(SIGINFO, siginfo);
|
||||
#endif
|
||||
if (special)
|
||||
c_special(fd1, file1, skip1, fd2, file2, skip2, limit);
|
||||
else {
|
||||
|
|
|
@ -46,3 +46,7 @@ void diffmsg(const char *, const char *, off_t, off_t, int, int);
|
|||
void eofmsg(const char *);
|
||||
|
||||
extern bool bflag, lflag, sflag, xflag, zflag;
|
||||
|
||||
#ifdef SIGINFO
|
||||
extern volatile sig_atomic_t info;
|
||||
#endif
|
||||
|
|
|
@ -120,6 +120,13 @@ c_regular(int fd1, const char *file1, off_t skip1, off_t len1,
|
|||
p2 = m2 + (skip2 - off2);
|
||||
|
||||
for (byte = line = 1; length--; ++byte) {
|
||||
#ifdef SIGINFO
|
||||
if (info) {
|
||||
(void)fprintf(stderr, "%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;
|
||||
|
|
|
@ -77,6 +77,13 @@ c_special(int fd1, const char *file1, off_t skip1,
|
|||
goto eof;
|
||||
|
||||
for (byte = line = 1; limit == 0 || byte <= limit; ++byte) {
|
||||
#ifdef SIGINFO
|
||||
if (info) {
|
||||
(void)fprintf(stderr, "%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)
|
||||
|
|
Loading…
Reference in a new issue