diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-21 01:23:19 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-21 01:23:19 +0200 |
commit | d8dd25a2a70ed0bc7d3f708683aa7ce733dc29cf (patch) | |
tree | a6b124faf622b7d78e60392030a61e312cd40b0c /editors/diff.c | |
parent | 3e0205031425b8c161d7e8936e603f5ece9aa937 (diff) | |
download | busybox-w32-d8dd25a2a70ed0bc7d3f708683aa7ce733dc29cf.tar.gz busybox-w32-d8dd25a2a70ed0bc7d3f708683aa7ce733dc29cf.tar.bz2 busybox-w32-d8dd25a2a70ed0bc7d3f708683aa7ce733dc29cf.zip |
diff: debug macros; one trivial size optimization
function old new delta
diffreg 1781 1815 +34
isqrt 64 - -64
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 34/-64) Total: -30 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors/diff.c')
-rw-r--r-- | editors/diff.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/editors/diff.c b/editors/diff.c index 42aba9ae0..e977f4d14 100644 --- a/editors/diff.c +++ b/editors/diff.c | |||
@@ -14,6 +14,9 @@ | |||
14 | 14 | ||
15 | #include "libbb.h" | 15 | #include "libbb.h" |
16 | 16 | ||
17 | #define dbg_error_msg(...) ((void)0) | ||
18 | //#define dbg_error_msg(...) bb_error_msg(__VA_ARGS__) | ||
19 | |||
17 | // #define FSIZE_MAX 32768 | 20 | // #define FSIZE_MAX 32768 |
18 | 21 | ||
19 | /* NOINLINEs added to prevent gcc from merging too much into diffreg() | 22 | /* NOINLINEs added to prevent gcc from merging too much into diffreg() |
@@ -474,12 +477,13 @@ static int stone(int *a, int n, int *b, int *c) | |||
474 | { | 477 | { |
475 | int i, k, y, j, l; | 478 | int i, k, y, j, l; |
476 | int oldc, tc, oldl; | 479 | int oldc, tc, oldl; |
477 | unsigned int numtries; | 480 | unsigned numtries; |
481 | int isq = isqrt(n); | ||
478 | #if ENABLE_FEATURE_DIFF_MINIMAL | 482 | #if ENABLE_FEATURE_DIFF_MINIMAL |
479 | const unsigned int bound = | 483 | const unsigned bound = |
480 | (option_mask32 & FLAG_d) ? UINT_MAX : MAX(256, isqrt(n)); | 484 | (option_mask32 & FLAG_d) ? UINT_MAX : MAX(256, isq); |
481 | #else | 485 | #else |
482 | const unsigned int bound = MAX(256, isqrt(n)); | 486 | const unsigned bound = MAX(256, isq); |
483 | #endif | 487 | #endif |
484 | 488 | ||
485 | k = 0; | 489 | k = 0; |
@@ -769,6 +773,8 @@ static void dump_unified_vec(FILE *f1, FILE *f2) | |||
769 | if (context_idx < 0) | 773 | if (context_idx < 0) |
770 | return; | 774 | return; |
771 | 775 | ||
776 | dbg_error_msg("dumping %d context_vecs", context_idx+1); | ||
777 | |||
772 | b = d = 0; /* gcc */ | 778 | b = d = 0; /* gcc */ |
773 | lowa = MAX(1, cvp->a - opt_U_context); | 779 | lowa = MAX(1, cvp->a - opt_U_context); |
774 | upb = MIN(nlen[0], context_vector[context_idx].b + opt_U_context); | 780 | upb = MIN(nlen[0], context_vector[context_idx].b + opt_U_context); |
@@ -860,6 +866,10 @@ static void change(const char *file1, FILE *f1, const char *file2, FILE *f2, | |||
860 | int a, int b, int c, int d) | 866 | int a, int b, int c, int d) |
861 | { | 867 | { |
862 | if ((a > b && c > d) || (option_mask32 & FLAG_q)) { | 868 | if ((a > b && c > d) || (option_mask32 & FLAG_q)) { |
869 | //compat BUG: "diff -ub F1 F2" will output nothing, but will exit 1 | ||
870 | //if F1 and F2 differ only in whitespace. "standard" diff exits 0. | ||
871 | //This is the place where this erroneous exitcode is set: | ||
872 | dbg_error_msg("%d: abcd:%d,%d,%d,%d, anychange=1", __LINE__, a,b,c,d); | ||
863 | anychange = 1; | 873 | anychange = 1; |
864 | return; | 874 | return; |
865 | } | 875 | } |
@@ -885,6 +895,7 @@ static void change(const char *file1, FILE *f1, const char *file2, FILE *f2, | |||
885 | context_vector[context_idx].b = b; | 895 | context_vector[context_idx].b = b; |
886 | context_vector[context_idx].c = c; | 896 | context_vector[context_idx].c = c; |
887 | context_vector[context_idx].d = d; | 897 | context_vector[context_idx].d = d; |
898 | dbg_error_msg("new context_vec[%d]:%d,%d,%d,%d", context_idx, a,b,c,d); | ||
888 | anychange = 1; | 899 | anychange = 1; |
889 | } | 900 | } |
890 | 901 | ||
@@ -1074,6 +1085,7 @@ static unsigned diffreg(const char *file1, const char *file2, int flags) | |||
1074 | closem: | 1085 | closem: |
1075 | if (anychange) { | 1086 | if (anychange) { |
1076 | exit_status |= 1; | 1087 | exit_status |= 1; |
1088 | dbg_error_msg("exit_status|=1 = %d", exit_status); | ||
1077 | if (rval == D_SAME) | 1089 | if (rval == D_SAME) |
1078 | rval = D_DIFFER; | 1090 | rval = D_DIFFER; |
1079 | } | 1091 | } |