cmp: use C99 bool for flags
MFC after: 1 week Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28072
This commit is contained in:
parent
d00431a7bd
commit
1f7661742d
@ -60,7 +60,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
|
||||||
int lflag, sflag, xflag, zflag;
|
bool lflag, sflag, xflag, zflag;
|
||||||
|
|
||||||
static const struct option long_opts[] =
|
static const struct option long_opts[] =
|
||||||
{
|
{
|
||||||
@ -77,7 +77,8 @@ main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
struct stat sb1, sb2;
|
struct stat sb1, sb2;
|
||||||
off_t skip1, skip2;
|
off_t skip1, skip2;
|
||||||
int ch, fd1, fd2, oflag, special;
|
int ch, fd1, fd2, oflag;
|
||||||
|
bool special;
|
||||||
const char *file1, *file2;
|
const char *file1, *file2;
|
||||||
|
|
||||||
oflag = O_RDONLY;
|
oflag = O_RDONLY;
|
||||||
@ -87,18 +88,18 @@ main(int argc, char *argv[])
|
|||||||
oflag |= O_NOFOLLOW;
|
oflag |= O_NOFOLLOW;
|
||||||
break;
|
break;
|
||||||
case 'l': /* print all differences */
|
case 'l': /* print all differences */
|
||||||
lflag = 1;
|
lflag = true;
|
||||||
break;
|
break;
|
||||||
case 's': /* silent run */
|
case 's': /* silent run */
|
||||||
sflag = 1;
|
sflag = true;
|
||||||
zflag = 1;
|
zflag = true;
|
||||||
break;
|
break;
|
||||||
case 'x': /* hex output */
|
case 'x': /* hex output */
|
||||||
lflag = 1;
|
lflag = true;
|
||||||
xflag = 1;
|
xflag = true;
|
||||||
break;
|
break;
|
||||||
case 'z': /* compare size first */
|
case 'z': /* compare size first */
|
||||||
zflag = 1;
|
zflag = true;
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
default:
|
default:
|
||||||
@ -120,9 +121,9 @@ main(int argc, char *argv[])
|
|||||||
err(ERR_EXIT, "unable to limit rights on stderr");
|
err(ERR_EXIT, "unable to limit rights on stderr");
|
||||||
|
|
||||||
/* Backward compatibility -- handle "-" meaning stdin. */
|
/* Backward compatibility -- handle "-" meaning stdin. */
|
||||||
special = 0;
|
special = false;
|
||||||
if (strcmp(file1 = argv[0], "-") == 0) {
|
if (strcmp(file1 = argv[0], "-") == 0) {
|
||||||
special = 1;
|
special = true;
|
||||||
fd1 = STDIN_FILENO;
|
fd1 = STDIN_FILENO;
|
||||||
file1 = "stdin";
|
file1 = "stdin";
|
||||||
} else if ((fd1 = open(file1, oflag, 0)) < 0 && errno != EMLINK) {
|
} else if ((fd1 = open(file1, oflag, 0)) < 0 && errno != EMLINK) {
|
||||||
@ -135,7 +136,7 @@ main(int argc, char *argv[])
|
|||||||
if (special)
|
if (special)
|
||||||
errx(ERR_EXIT,
|
errx(ERR_EXIT,
|
||||||
"standard input may only be specified once");
|
"standard input may only be specified once");
|
||||||
special = 1;
|
special = true;
|
||||||
fd2 = STDIN_FILENO;
|
fd2 = STDIN_FILENO;
|
||||||
file2 = "stdin";
|
file2 = "stdin";
|
||||||
} else if ((fd2 = open(file2, oflag, 0)) < 0 && errno != EMLINK) {
|
} else if ((fd2 = open(file2, oflag, 0)) < 0 && errno != EMLINK) {
|
||||||
@ -174,7 +175,7 @@ main(int argc, char *argv[])
|
|||||||
exit(ERR_EXIT);
|
exit(ERR_EXIT);
|
||||||
}
|
}
|
||||||
if (!S_ISREG(sb1.st_mode))
|
if (!S_ISREG(sb1.st_mode))
|
||||||
special = 1;
|
special = true;
|
||||||
else {
|
else {
|
||||||
if (fstat(fd2, &sb2)) {
|
if (fstat(fd2, &sb2)) {
|
||||||
if (!sflag)
|
if (!sflag)
|
||||||
@ -183,7 +184,7 @@ main(int argc, char *argv[])
|
|||||||
exit(ERR_EXIT);
|
exit(ERR_EXIT);
|
||||||
}
|
}
|
||||||
if (!S_ISREG(sb2.st_mode))
|
if (!S_ISREG(sb2.st_mode))
|
||||||
special = 1;
|
special = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,4 +44,4 @@ void c_special(int, const char *, off_t, int, const char *, off_t);
|
|||||||
void diffmsg(const char *, const char *, off_t, off_t);
|
void diffmsg(const char *, const char *, off_t, off_t);
|
||||||
void eofmsg(const char *);
|
void eofmsg(const char *);
|
||||||
|
|
||||||
extern int lflag, sflag, xflag, zflag;
|
extern bool lflag, sflag, xflag, zflag;
|
||||||
|
@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user