- just whitespace

This commit is contained in:
Bernhard Reutner-Fischer 2006-05-29 12:12:45 +00:00
parent d2c306e862
commit bbc225e13d

View File

@ -68,6 +68,7 @@
/* Command line options */
static unsigned long cmd_flags;
#define FLAG_a (1<<0)
#define FLAG_b (1<<1)
#define FLAG_d (1<<2)
@ -142,6 +143,7 @@ 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) {
case D_ONLY:
print_only(path1, strlen(path1), entry);
@ -202,8 +204,7 @@ static int readhash(FILE *f)
break;
}
sum = sum * 127 + t;
}
else
} else
for (i = 0; (t = getc(f)) != '\n'; i++) {
if (t == EOF) {
if (i == 0)
@ -305,13 +306,10 @@ static void prune(void)
int i, j;
for (pref = 0; pref < len[0] && pref < len[1] &&
file[0][pref + 1].value == file[1][pref + 1].value;
pref++)
;
file[0][pref + 1].value == file[1][pref + 1].value; pref++);
for (suff = 0; suff < len[0] - pref && suff < len[1] - pref &&
file[0][len[0] - suff].value == file[1][len[1] - suff].value;
suff++)
;
suff++);
for (j = 0; j < 2; j++) {
sfile[j] = file[j] + pref;
slen[j] = len[j] - pref - suff;
@ -347,9 +345,12 @@ static void equiv(struct line *a, int n, struct line *b, int m, int *c)
c[j] = -1;
}
static int isqrt(int n) {
static int isqrt(int n)
{
int y, x = 1;
if (n == 0) return(0);
if (n == 0)
return (0);
do {
y = x;
@ -406,8 +407,10 @@ static int stone(int *a, int n, int *b, int *c)
int i, k, y, j, l;
int oldc, tc, oldl;
unsigned int numtries;
#if ENABLE_FEATURE_DIFF_MINIMAL
const unsigned int bound = (cmd_flags & FLAG_d) ? UINT_MAX : MAX(256, isqrt(n));
const unsigned int bound =
(cmd_flags & FLAG_d) ? UINT_MAX : MAX(256, isqrt(n));
#else
const unsigned int bound = MAX(256, isqrt(n));
#endif
@ -451,8 +454,7 @@ static void unravel(int p)
int i;
for (i = 0; i <= len[0]; i++)
J[i] = i <= pref ? i :
i > len[0] - suff ? i + len[1] - len[0] : 0;
J[i] = i <= pref ? i : i > len[0] - suff ? i + len[1] - len[0] : 0;
for (q = clist + p; q->y != 0; q = clist + q->pred)
J[q->x + pref] = q->y + pref;
}
@ -506,7 +508,8 @@ static void check(FILE *f1, FILE *f2)
ixnew[j] = ctnew += skipline(f2);
j++;
}
if ((cmd_flags & FLAG_b) || (cmd_flags & FLAG_w) || (cmd_flags & FLAG_i)) {
if ((cmd_flags & FLAG_b) || (cmd_flags & FLAG_w)
|| (cmd_flags & FLAG_i)) {
while (1) {
c = getc(f1);
d = getc(f2);
@ -515,8 +518,7 @@ static void check(FILE *f1, FILE *f2)
* in one file if bflag || wflag.
*/
if (((cmd_flags & FLAG_b) || (cmd_flags & FLAG_w)) &&
((c == EOF && d == '\n') ||
(c == '\n' && d == EOF))) {
((c == EOF && d == '\n') || (c == '\n' && d == EOF))) {
break;
}
ctold++;
@ -596,8 +598,7 @@ static void sort(struct line *a, int n)
if (aim < ai)
break; /* wraparound */
if (aim->value > ai[0].value ||
(aim->value == ai[0].value &&
aim->serial > ai[0].serial))
(aim->value == ai[0].value && aim->serial > ai[0].serial))
break;
w.value = ai[0].value;
ai[0].value = aim->value;
@ -757,17 +758,13 @@ static void dump_unified_vec(FILE *f1, FILE *f2)
static void print_header(const char *file1, const char *file2)
{
if (label[0] != NULL)
printf("%s %s\n", "---",
label[0]);
printf("%s %s\n", "---", label[0]);
else
printf("%s %s\t%s", "---",
file1, ctime(&stb1.st_mtime));
printf("%s %s\t%s", "---", file1, ctime(&stb1.st_mtime));
if (label[1] != NULL)
printf("%s %s\n", "+++",
label[1]);
printf("%s %s\n", "+++", label[1]);
else
printf("%s %s\t%s", "+++",
file2, ctime(&stb2.st_mtime));
printf("%s %s\t%s", "+++", file2, ctime(&stb2.st_mtime));
}
@ -779,21 +776,26 @@ static void print_header(const char *file1, const char *file2)
* lines appended (beginning at b). If c is greater than d then there are
* lines missing from the to file.
*/
static void change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d)
static void change(char *file1, FILE * f1, char *file2, FILE * f2, int a,
int b, int c, int d)
{
static size_t max_context = 64;
if (a > b && c > d) return;
if (cmd_flags & FLAG_q) return;
if (a > b && c > d)
return;
if (cmd_flags & FLAG_q)
return;
/*
* Allocate change records as needed.
*/
if (context_vec_ptr == context_vec_end - 1) {
ptrdiff_t offset = context_vec_ptr - context_vec_start;
max_context <<= 1;
context_vec_start = xrealloc(context_vec_start,
max_context * sizeof(struct context_vec));
max_context *
sizeof(struct context_vec));
context_vec_end = context_vec_start + max_context;
context_vec_ptr = context_vec_start + offset;
}
@ -1014,7 +1016,8 @@ closem:
}
#if ENABLE_FEATURE_DIFF_DIR
static void do_diff (char *dir1, char *path1, char *dir2, char *path2) {
static void do_diff(char *dir1, char *path1, char *dir2, char *path2)
{
int flags = D_HEADER;
int val;
@ -1054,27 +1057,31 @@ static void do_diff (char *dir1, char *path1, char *dir2, char *path2) {
#endif
#if ENABLE_FEATURE_DIFF_DIR
static int dir_strcmp(const void *p1, const void *p2) {
static int dir_strcmp(const void *p1, const void *p2)
{
return strcmp(*(char *const *) p1, *(char *const *) p2);
}
/* This function adds a filename to dl, the directory listing. */
static int add_to_dirlist(const char *filename,
struct stat ATTRIBUTE_UNUSED *sb, void *userdata) {
struct stat ATTRIBUTE_UNUSED * sb, void *userdata)
{
dl_count++;
dl = xrealloc(dl, dl_count * sizeof(char *));
dl[dl_count - 1] = bb_xstrdup(filename);
if (cmd_flags & FLAG_r) {
int *pp = (int *) userdata;
int path_len = *pp + 1;
dl[dl_count - 1] = &(dl[dl_count - 1])[path_len];
}
return TRUE;
}
/* This returns a sorted directory listing. */
static char **get_dir(char *path) {
static char **get_dir(char *path)
{
int i;
char **retval;
@ -1094,7 +1101,8 @@ static char **get_dir(char *path) {
/* Now fill dl with a listing. */
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);
else {
DIR *dp;
struct dirent *ep;
@ -1119,7 +1127,8 @@ static char **get_dir(char *path) {
return retval;
}
static void diffdir (char *p1, char *p2) {
static void diffdir(char *p1, char *p2)
{
char **dirlist1, **dirlist2;
char *dp1, *dp2;
@ -1164,15 +1173,13 @@ static void diffdir (char *p1, char *p2) {
do_diff(p1, dp1, p2, dp2);
dirlist1++;
dirlist2++;
}
else if (pos < 0) {
} else if (pos < 0) {
if (cmd_flags & FLAG_N)
do_diff(p1, dp1, p2, NULL);
else
print_only(p1, strlen(p1) + 1, dp1);
dirlist1++;
}
else {
} else {
if (cmd_flags & FLAG_N)
do_diff(p1, NULL, p2, dp2);
else
@ -1185,14 +1192,18 @@ static void diffdir (char *p1, char *p2) {
int diff_main(int argc, char **argv) {
int diff_main(int argc, char **argv)
{
char *ep;
int gotstdin = 0;
char *U_opt;
llist_t *L_arg = NULL;
bb_opt_complementally = "L::";
cmd_flags = bb_getopt_ulflags(argc, argv, "abdiL:NqrsS:tTU:wu", &L_arg, &start, &U_opt);
cmd_flags =
bb_getopt_ulflags(argc, argv, "abdiL:NqrsS:tTU:wu", &L_arg, &start,
&U_opt);
if (cmd_flags & FLAG_L) {
while (L_arg) {
@ -1209,6 +1220,7 @@ int diff_main(int argc, char **argv) {
/* If both label[0] and label[1] were set, they need to be swapped. */
if (label[0] && label[1]) {
char *tmp;
tmp = label[1];
label[1] = label[0];
label[0] = tmp;
@ -1252,8 +1264,7 @@ int diff_main(int argc, char **argv) {
#else
bb_error_msg_and_die("Directory comparison not supported");
#endif
}
else {
} else {
if (S_ISDIR(stb1.st_mode)) {
argv[0] = concat_path_file(argv[0], argv[1]);
xstat(argv[0], &stb1);
@ -1266,4 +1277,3 @@ int diff_main(int argc, char **argv) {
}
exit(status);
}