diff options
Diffstat (limited to 'ws.c')
-rw-r--r-- | ws.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -3,8 +3,12 @@ * * Copyright (c) 2007 Junio C Hamano */ -#include "cache.h" +#include "git-compat-util.h" #include "attr.h" +#include "strbuf.h" +#include "ws.h" + +unsigned whitespace_rule_cfg = WS_DEFAULT_RULE; static struct whitespace_rule { const char *rule_name; @@ -29,6 +33,7 @@ unsigned parse_whitespace_rule(const char *string) int i; size_t len; const char *ep; + const char *arg; int negated = 0; string = string + strspn(string, ", \t\n\r"); @@ -52,15 +57,15 @@ unsigned parse_whitespace_rule(const char *string) rule |= whitespace_rule_names[i].rule_bits; break; } - if (strncmp(string, "tabwidth=", 9) == 0) { - unsigned tabwidth = atoi(string + 9); + if (skip_prefix(string, "tabwidth=", &arg)) { + unsigned tabwidth = atoi(arg); if (0 < tabwidth && tabwidth < 0100) { rule &= ~WS_TAB_WIDTH_MASK; rule |= tabwidth; } else warning("tabwidth %.*s out of range", - (int)(len - 9), string + 9); + (int)(ep - arg), arg); } string = ep; } @@ -78,7 +83,7 @@ unsigned whitespace_rule(struct index_state *istate, const char *pathname) if (!attr_whitespace_rule) attr_whitespace_rule = attr_check_initl("whitespace", NULL); - git_check_attr(istate, pathname, attr_whitespace_rule); + git_check_attr(istate, NULL, pathname, attr_whitespace_rule); value = attr_whitespace_rule->items[0].value; if (ATTR_TRUE(value)) { /* true (whitespace) */ @@ -252,7 +257,7 @@ unsigned ws_check(const char *line, int len, unsigned ws_rule) return ws_check_emit_1(line, len, ws_rule, NULL, NULL, NULL, NULL); } -int ws_blank_line(const char *line, int len, unsigned ws_rule) +int ws_blank_line(const char *line, int len) { /* * We _might_ want to treat CR differently from other |