24 |
#include "libbb.h" |
#include "libbb.h" |
25 |
|
|
26 |
static const char fmt_eof[] ALIGN1 = "cmp: EOF on %s\n"; |
static const char fmt_eof[] ALIGN1 = "cmp: EOF on %s\n"; |
27 |
static const char fmt_differ[] ALIGN1 = "%s %s differ: char %"OFF_FMT"d, line %d\n"; |
static const char fmt_differ[] ALIGN1 = "%s %s differ: char %"OFF_FMT"u, line %u\n"; |
28 |
// This fmt_l_opt uses gnu-isms. SUSv3 would be "%.0s%.0s%"OFF_FMT"d %o %o\n" |
// This fmt_l_opt uses gnu-isms. SUSv3 would be "%.0s%.0s%"OFF_FMT"u %o %o\n" |
29 |
static const char fmt_l_opt[] ALIGN1 = "%.0s%.0s%"OFF_FMT"d %3o %3o\n"; |
static const char fmt_l_opt[] ALIGN1 = "%.0s%.0s%"OFF_FMT"u %3o %3o\n"; |
30 |
|
|
31 |
static const char opt_chars[] ALIGN1 = "sl"; |
static const char opt_chars[] ALIGN1 = "sl"; |
32 |
#define CMP_OPT_s (1<<0) |
#define CMP_OPT_s (1<<0) |
37 |
{ |
{ |
38 |
FILE *fp1, *fp2, *outfile = stdout; |
FILE *fp1, *fp2, *outfile = stdout; |
39 |
const char *filename1, *filename2 = "-"; |
const char *filename1, *filename2 = "-"; |
40 |
USE_DESKTOP(off_t skip1 = 0, skip2 = 0;) |
IF_DESKTOP(off_t skip1 = 0, skip2 = 0;) |
41 |
off_t char_pos = 0; |
off_t char_pos = 0; |
42 |
int line_pos = 1; /* Hopefully won't overflow... */ |
int line_pos = 1; /* Hopefully won't overflow... */ |
43 |
const char *fmt; |
const char *fmt; |
48 |
xfunc_error_retval = 2; /* 1 is returned if files are different. */ |
xfunc_error_retval = 2; /* 1 is returned if files are different. */ |
49 |
|
|
50 |
opt_complementary = "-1" |
opt_complementary = "-1" |
51 |
USE_DESKTOP(":?4") |
IF_DESKTOP(":?4") |
52 |
SKIP_DESKTOP(":?2") |
IF_NOT_DESKTOP(":?2") |
53 |
":l--s:s--l"; |
":l--s:s--l"; |
54 |
opt = getopt32(argv, opt_chars); |
opt = getopt32(argv, opt_chars); |
55 |
argv += optind; |
argv += optind; |
108 |
outfile = stderr; |
outfile = stderr; |
109 |
/* There may have been output to stdout (option -l), so |
/* There may have been output to stdout (option -l), so |
110 |
* make sure we fflush before writing to stderr. */ |
* make sure we fflush before writing to stderr. */ |
111 |
xfflush_stdout(); |
fflush_all(); |
112 |
} |
} |
113 |
if (!(opt & CMP_OPT_s)) { |
if (!(opt & CMP_OPT_s)) { |
114 |
if (opt & CMP_OPT_l) { |
if (opt & CMP_OPT_l) { |