@matheusbsbs / matheus-bagliano / commits / 95f9b92700
Fork 0

builtin-apply: minor cleanup of whitespace detection

Use 0 instead of -1 for the case where not tabs or spaces are found; it will make some later math slightly simpler. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

J. Bruce Fields committed Dec 16, 2007 at 12:58 UTC 95f9b92700585eb9afa6978c350dc07ec5769ec6
1 file changed +4 -4
builtin-apply.c
+4 -4
@@ -1550,8 +1550,8 @@ static int apply_line(char *output, const char *patch, int plen,
1550 int i;
1551 int add_nl_to_tail = 0;
1552 int fixed = 0;
1553 - int last_tab_in_indent = -1;
1554 - int last_space_in_indent = -1;
1553 + int last_tab_in_indent = 0;
1554 + int last_space_in_indent = 0;
1555 int need_fix_leading_space = 0;
1556 char *buf;
1557
@@ -1582,12 +1582,12 @@ static int apply_line(char *output, const char *patch, int plen,
1582 if (ch == '\t') {
1583 last_tab_in_indent = i;
1584 if ((ws_rule & WS_SPACE_BEFORE_TAB) &&
1585 - 0 <= last_space_in_indent)
1585 + 0 < last_space_in_indent)
1586 need_fix_leading_space = 1;
1587 } else if (ch == ' ') {
1588 last_space_in_indent = i;
1589 if ((ws_rule & WS_INDENT_WITH_NON_TAB) &&
1590 - last_tab_in_indent < 0 &&
1590 + last_tab_in_indent <= 0 &&
1591 8 <= i)
1592 need_fix_leading_space = 1;
1593 }