From: J. Bruce Fields Date: Sun, 16 Dec 2007 16:31:38 +0000 (-0500) Subject: whitespace: reorganize initial-indent check X-Git-Tag: v1.5.4-rc1~39 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1020999a981e0dadedc475c41e33e20fd7832019;p=git-core%2Fgit.git whitespace: reorganize initial-indent check Reorganize to emphasize the most complicated part of the code (the tab case). Signed-off-by: J. Bruce Fields Signed-off-by: Junio C Hamano --- diff --git a/ws.c b/ws.c index 5ebd1095a..716587498 100644 --- a/ws.c +++ b/ws.c @@ -146,16 +146,15 @@ unsigned check_and_emit_line(const char *line, int len, unsigned ws_rule, /* Check for space before tab in initial indent. */ for (i = 0; i < len; i++) { - if (line[i] == '\t') { - if ((ws_rule & WS_SPACE_BEFORE_TAB) && - (leading_space != -1)) - result |= WS_SPACE_BEFORE_TAB; - break; - } - else if (line[i] == ' ') + if (line[i] == ' ') { leading_space = i; - else + continue; + } + if (line[i] != '\t') break; + if ((ws_rule & WS_SPACE_BEFORE_TAB) && (leading_space != -1)) + result |= WS_SPACE_BEFORE_TAB; + break; } /* Check for indent using non-tab. */