Skip to content

Commit 446d12c

Browse files
committed
xdiff: reassign xpparm_t.flags bits
We have packed the bits too tightly in such a way that it is not easy to add a new type of whitespace ignoring option, a new type of LCS algorithm, or a new type of post-cleanup heuristics. Reorder bits a bit to give room for these three classes of options to grow. Also make use of XDF_WHITESPACE_FLAGS macro where we check any of these bits are on, instead of using DIFF_XDL_TST() macro on individual possibilities. That way, the "is any of the bits on?" code does not have to change when we add more ways to ignore whitespaces. While at it, add a comment in front of the bit definitions to clarify in which structure these defined bits may appear. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 42e6fde commit 446d12c

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

diff.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3434,9 +3434,7 @@ void diff_setup_done(struct diff_options *options)
34343434
* inside contents.
34353435
*/
34363436

3437-
if (DIFF_XDL_TST(options, IGNORE_WHITESPACE) ||
3438-
DIFF_XDL_TST(options, IGNORE_WHITESPACE_CHANGE) ||
3439-
DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL))
3437+
if ((options->xdl_opts & XDF_WHITESPACE_FLAGS))
34403438
DIFF_OPT_SET(options, DIFF_FROM_CONTENTS);
34413439
else
34423440
DIFF_OPT_CLR(options, DIFF_FROM_CONTENTS);

xdiff/xdiff.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,26 @@
2727
extern "C" {
2828
#endif /* #ifdef __cplusplus */
2929

30+
/* xpparm_t.flags */
31+
#define XDF_NEED_MINIMAL (1 << 0)
3032

31-
#define XDF_NEED_MINIMAL (1 << 1)
32-
#define XDF_IGNORE_WHITESPACE (1 << 2)
33-
#define XDF_IGNORE_WHITESPACE_CHANGE (1 << 3)
34-
#define XDF_IGNORE_WHITESPACE_AT_EOL (1 << 4)
35-
#define XDF_WHITESPACE_FLAGS (XDF_IGNORE_WHITESPACE | XDF_IGNORE_WHITESPACE_CHANGE | XDF_IGNORE_WHITESPACE_AT_EOL)
33+
#define XDF_IGNORE_WHITESPACE (1 << 1)
34+
#define XDF_IGNORE_WHITESPACE_CHANGE (1 << 2)
35+
#define XDF_IGNORE_WHITESPACE_AT_EOL (1 << 3)
36+
#define XDF_WHITESPACE_FLAGS (XDF_IGNORE_WHITESPACE | \
37+
XDF_IGNORE_WHITESPACE_CHANGE | \
38+
XDF_IGNORE_WHITESPACE_AT_EOL)
3639

37-
#define XDF_PATIENCE_DIFF (1 << 5)
38-
#define XDF_HISTOGRAM_DIFF (1 << 6)
40+
#define XDF_IGNORE_BLANK_LINES (1 << 7)
41+
42+
#define XDF_PATIENCE_DIFF (1 << 14)
43+
#define XDF_HISTOGRAM_DIFF (1 << 15)
3944
#define XDF_DIFF_ALGORITHM_MASK (XDF_PATIENCE_DIFF | XDF_HISTOGRAM_DIFF)
4045
#define XDF_DIFF_ALG(x) ((x) & XDF_DIFF_ALGORITHM_MASK)
4146

42-
#define XDF_IGNORE_BLANK_LINES (1 << 7)
43-
44-
#define XDF_INDENT_HEURISTIC (1 << 8)
47+
#define XDF_INDENT_HEURISTIC (1 << 23)
4548

49+
/* xdemitconf_t.flags */
4650
#define XDL_EMIT_FUNCNAMES (1 << 0)
4751
#define XDL_EMIT_FUNCCONTEXT (1 << 2)
4852

0 commit comments

Comments
 (0)