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}
|
{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 void usage(void);
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -240,6 +251,9 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SIGINFO
|
||||||
|
(void)signal(SIGINFO, siginfo);
|
||||||
|
#endif
|
||||||
if (special)
|
if (special)
|
||||||
c_special(fd1, file1, skip1, fd2, file2, skip2, limit);
|
c_special(fd1, file1, skip1, fd2, file2, skip2, limit);
|
||||||
else {
|
else {
|
||||||
|
@ -46,3 +46,7 @@ void diffmsg(const char *, const char *, off_t, off_t, int, int);
|
|||||||
void eofmsg(const char *);
|
void eofmsg(const char *);
|
||||||
|
|
||||||
extern bool bflag, lflag, sflag, xflag, zflag;
|
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);
|
p2 = m2 + (skip2 - off2);
|
||||||
|
|
||||||
for (byte = line = 1; length--; ++byte) {
|
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 ((ch = *p1) != *p2) {
|
||||||
if (xflag) {
|
if (xflag) {
|
||||||
dfound = 1;
|
dfound = 1;
|
||||||
|
@ -77,6 +77,13 @@ c_special(int fd1, const char *file1, off_t skip1,
|
|||||||
goto eof;
|
goto eof;
|
||||||
|
|
||||||
for (byte = line = 1; limit == 0 || byte <= limit; ++byte) {
|
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);
|
ch1 = getc(fp1);
|
||||||
ch2 = getc(fp2);
|
ch2 = getc(fp2);
|
||||||
if (ch1 == EOF || ch2 == EOF)
|
if (ch1 == EOF || ch2 == EOF)
|
||||||
|
Loading…
Reference in New Issue
Block a user