@matheusbsbs / matheus-bagliano / commits / 1020999a98
Fork 0

whitespace: reorganize initial-indent check

Reorganize to emphasize the most complicated part of the code (the tab case). 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 11:31 UTC 1020999a981e0dadedc475c41e33e20fd7832019
1 file changed +7 -8
ws.c
+7 -8
@@ -146,16 +146,15 @@ unsigned check_and_emit_line(const char *line, int len, unsigned ws_rule,
146
147 /* Check for space before tab in initial indent. */
148 for (i = 0; i < len; i++) {
149 - if (line[i] == '\t') {
150 - if ((ws_rule & WS_SPACE_BEFORE_TAB) &&
151 - (leading_space != -1))
152 - result |= WS_SPACE_BEFORE_TAB;
153 - break;
154 - }
155 - else if (line[i] == ' ')
149 + if (line[i] == ' ') {
150 leading_space = i;
157 - else
151 + continue;
152 + }
153 + if (line[i] != '\t')
154 break;
155 + if ((ws_rule & WS_SPACE_BEFORE_TAB) && (leading_space != -1))
156 + result |= WS_SPACE_BEFORE_TAB;
157 + break;
158 }
159
160 /* Check for indent using non-tab. */