- shrink it a little bit and make it buildable with gcc-2.95
text data bss dec hex filename 7332 4 92 7428 1d04 diff.o-gcc-4.2-HEAD.orig 7185 4 92 7281 1c71 diff.o-gcc-4.2-HEAD.new 7336 4 92 7432 1d08 diff.o-gcc-4.1-HEAD.orig 7148 4 92 7244 1c4c diff.o-gcc-4.1-HEAD.new 7485 4 92 7581 1d9d diff.o-gcc-4.0.orig 7318 4 92 7414 1cf6 diff.o-gcc-4.0.new 7511 4 92 7607 1db7 diff.o-gcc-3.4.orig 7252 4 92 7348 1cb4 diff.o-gcc-3.4.new 8214 4 92 8310 2076 diff.o-gcc-3.3.orig 7882 4 92 7978 1f2a diff.o-gcc-3.3.new - - - - - diff.o-gcc-2.95.orig 8238 8 88 8334 208e diff.o-gcc-2.95.new
This commit is contained in:
parent
cc4003f778
commit
5fb0fecc1f
@ -154,47 +154,48 @@ static void print_only(const char *path, size_t dirlen, const char *entry)
|
|||||||
|
|
||||||
static void print_status(int val, char *path1, char *path2, char *entry)
|
static void print_status(int val, char *path1, char *path2, char *entry)
|
||||||
{
|
{
|
||||||
|
const char * const _entry = entry ? entry : "";
|
||||||
|
char *_path1 = entry ? concat_path_file(path1, _entry) : path1;
|
||||||
|
char *_path2 = entry ? concat_path_file(path2, _entry) : path2;
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case D_ONLY:
|
case D_ONLY:
|
||||||
print_only(path1, strlen(path1), entry);
|
print_only(path1, strlen(path1), entry);
|
||||||
break;
|
break;
|
||||||
case D_COMMON:
|
case D_COMMON:
|
||||||
printf("Common subdirectories: %s%s and %s%s\n",
|
printf("Common subdirectories: %s and %s\n", _path1, _path2);
|
||||||
path1, entry ? entry : "", path2, entry ? entry : "");
|
|
||||||
break;
|
break;
|
||||||
case D_BINARY:
|
case D_BINARY:
|
||||||
printf("Binary files %s%s and %s%s differ\n",
|
printf("Binary files %s and %s differ\n", _path1, _path2);
|
||||||
path1, entry ? entry : "", path2, entry ? entry : "");
|
|
||||||
break;
|
break;
|
||||||
case D_DIFFER:
|
case D_DIFFER:
|
||||||
if (cmd_flags & FLAG_q)
|
if (cmd_flags & FLAG_q)
|
||||||
printf("Files %s%s and %s%s differ\n",
|
printf("Files %s and %s differ\n", _path1, _path2);
|
||||||
path1, entry ? entry : "",
|
|
||||||
path2, entry ? entry : "");
|
|
||||||
break;
|
break;
|
||||||
case D_SAME:
|
case D_SAME:
|
||||||
if (cmd_flags & FLAG_s)
|
if (cmd_flags & FLAG_s)
|
||||||
printf("Files %s%s and %s%s are identical\n",
|
printf("Files %s and %s are identical\n", _path1, _path2);
|
||||||
path1, entry ? entry : "",
|
|
||||||
path2, entry ? entry : "");
|
|
||||||
break;
|
break;
|
||||||
case D_MISMATCH1:
|
case D_MISMATCH1:
|
||||||
printf("File %s%s is a directory while file %s%s is a regular file\n",
|
printf("File %s is a directory while file %s is a regular file\n",
|
||||||
path1, entry ? entry : "", path2, entry ? entry : "");
|
_path1, _path2);
|
||||||
break;
|
break;
|
||||||
case D_MISMATCH2:
|
case D_MISMATCH2:
|
||||||
printf("File %s%s is a regular file while file %s%s is a directory\n",
|
printf("File %s is a regular file while file %s is a directory\n",
|
||||||
path1, entry ? entry : "", path2, entry ? entry : "");
|
_path1, _path2);
|
||||||
break;
|
break;
|
||||||
case D_SKIPPED1:
|
case D_SKIPPED1:
|
||||||
printf("File %s%s is not a regular file or directory and was skipped\n",
|
printf("File %s is not a regular file or directory and was skipped\n",
|
||||||
path1, entry ? entry : "");
|
_path1);
|
||||||
break;
|
break;
|
||||||
case D_SKIPPED2:
|
case D_SKIPPED2:
|
||||||
printf("File %s%s is not a regular file or directory and was skipped\n",
|
printf("File %s is not a regular file or directory and was skipped\n",
|
||||||
path2, entry ? entry : "");
|
_path2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (entry) {
|
||||||
|
free(_path1);
|
||||||
|
free(_path2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -293,8 +294,8 @@ static int files_differ(FILE *f1, FILE *f2, int flags)
|
|||||||
static void prepare(int i, FILE *fd, off_t filesize)
|
static void prepare(int i, FILE *fd, off_t filesize)
|
||||||
{
|
{
|
||||||
struct line *p;
|
struct line *p;
|
||||||
int j, h;
|
int h;
|
||||||
size_t sz;
|
size_t j, sz;
|
||||||
|
|
||||||
rewind(fd);
|
rewind(fd);
|
||||||
|
|
||||||
@ -671,13 +672,15 @@ static int fetch(long *f, int a, int b, FILE *lb, int ch)
|
|||||||
|
|
||||||
static int asciifile(FILE *f)
|
static int asciifile(FILE *f)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((cmd_flags & FLAG_a) || f == NULL)
|
|
||||||
return (1);
|
|
||||||
#ifdef CONFIG_FEATURE_DIFF_BINARY
|
#ifdef CONFIG_FEATURE_DIFF_BINARY
|
||||||
unsigned char buf[BUFSIZ];
|
unsigned char buf[BUFSIZ];
|
||||||
int i, cnt;
|
int i, cnt;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ((cmd_flags & FLAG_a) || f == NULL)
|
||||||
|
return (1);
|
||||||
|
|
||||||
|
#ifdef CONFIG_FEATURE_DIFF_BINARY
|
||||||
rewind(f);
|
rewind(f);
|
||||||
cnt = fread(buf, 1, sizeof(buf), f);
|
cnt = fread(buf, 1, sizeof(buf), f);
|
||||||
for (i = 0; i < cnt; i++)
|
for (i = 0; i < cnt; i++)
|
||||||
@ -730,7 +733,7 @@ static void dump_unified_vec(FILE *f1, FILE *f2)
|
|||||||
ch = 'c';
|
ch = 'c';
|
||||||
else
|
else
|
||||||
ch = (a <= b) ? 'd' : 'a';
|
ch = (a <= b) ? 'd' : 'a';
|
||||||
|
#if 0
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'c':
|
case 'c':
|
||||||
fetch(ixold, lowa, a - 1, f1, ' ');
|
fetch(ixold, lowa, a - 1, f1, ' ');
|
||||||
@ -746,6 +749,16 @@ static void dump_unified_vec(FILE *f1, FILE *f2)
|
|||||||
fetch(ixnew, c, d, f2, '+');
|
fetch(ixnew, c, d, f2, '+');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (ch == 'c' || ch == 'd') {
|
||||||
|
fetch(ixold, lowa, a - 1, f1, ' ');
|
||||||
|
fetch(ixold, a, b, f1, '-');
|
||||||
|
}
|
||||||
|
if (ch == 'a')
|
||||||
|
fetch(ixnew, lowc, c - 1, f2, ' ');
|
||||||
|
if (ch == 'c' || ch == 'a')
|
||||||
|
fetch(ixnew, c, d, f2, '+');
|
||||||
|
#endif
|
||||||
lowa = b + 1;
|
lowa = b + 1;
|
||||||
lowc = d + 1;
|
lowc = d + 1;
|
||||||
}
|
}
|
||||||
@ -948,12 +961,9 @@ static int diffreg(char *ofile1, char *ofile2, int flags)
|
|||||||
f2 = bb_xfopen(file2, "r");
|
f2 = bb_xfopen(file2, "r");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (files_differ(f1, f2, flags)) {
|
if ((i=files_differ(f1, f2, flags)) == 0)
|
||||||
case 0:
|
|
||||||
goto closem;
|
goto closem;
|
||||||
case 1:
|
else if (i != 1) {/* 1 == ok */
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* error */
|
/* error */
|
||||||
status |= 2;
|
status |= 2;
|
||||||
goto closem;
|
goto closem;
|
||||||
@ -1078,10 +1088,7 @@ static int add_to_dirlist (const char *filename,
|
|||||||
static char **get_dir(char *path) {
|
static char **get_dir(char *path) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
char **retval;
|
||||||
/* Reset dl_count - there's no need to free dl as bb_xrealloc does
|
|
||||||
* the job nicely. */
|
|
||||||
dl_count = 0;
|
|
||||||
|
|
||||||
/* If -r has been set, then the recursive_action function will be
|
/* If -r has been set, then the recursive_action function will be
|
||||||
* used. Unfortunately, this outputs the root directory along with
|
* used. Unfortunately, this outputs the root directory along with
|
||||||
@ -1092,6 +1099,10 @@ static char **get_dir(char *path) {
|
|||||||
int path_len = strlen(path);
|
int path_len = strlen(path);
|
||||||
void *userdata = &path_len;
|
void *userdata = &path_len;
|
||||||
|
|
||||||
|
/* Reset dl_count - there's no need to free dl as bb_xrealloc does
|
||||||
|
* the job nicely. */
|
||||||
|
dl_count = 0;
|
||||||
|
|
||||||
/* Now fill dl with a listing. */
|
/* Now fill dl with a listing. */
|
||||||
if (cmd_flags & FLAG_r)
|
if (cmd_flags & FLAG_r)
|
||||||
recursive_action(path, TRUE, TRUE, FALSE, add_to_dirlist, NULL, userdata);
|
recursive_action(path, TRUE, TRUE, FALSE, add_to_dirlist, NULL, userdata);
|
||||||
@ -1112,7 +1123,7 @@ static char **get_dir(char *path) {
|
|||||||
qsort(dl, dl_count, sizeof(char *), dir_strcmp);
|
qsort(dl, dl_count, sizeof(char *), dir_strcmp);
|
||||||
|
|
||||||
/* Copy dl so that we can return it. */
|
/* Copy dl so that we can return it. */
|
||||||
char **retval = xmalloc(dl_count * sizeof(char *));
|
retval = xmalloc(dl_count * sizeof(char *));
|
||||||
for (i = 0; i < dl_count; i++)
|
for (i = 0; i < dl_count; i++)
|
||||||
retval[i] = bb_xstrdup(dl[i]);
|
retval[i] = bb_xstrdup(dl[i]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user