MCPcopy Create free account
hub / github.com/git/git / parse_whitespace_rule

Function parse_whitespace_rule

ws.c:32–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30};
31
32unsigned parse_whitespace_rule(const char *string)
33{
34 unsigned rule = WS_DEFAULT_RULE;
35
36 while (string) {
37 int i;
38 size_t len;
39 const char *ep;
40 const char *arg;
41 int negated = 0;
42
43 string = string + strspn(string, ", \t\n\r");
44 ep = strchrnul(string, ',');
45 len = ep - string;
46
47 if (*string == '-') {
48 negated = 1;
49 string++;
50 len--;
51 }
52 if (!len)
53 break;
54 for (i = 0; i < ARRAY_SIZE(whitespace_rule_names); i++) {
55 if (strncmp(whitespace_rule_names[i].rule_name,
56 string, len))
57 continue;
58 if (negated)
59 rule &= ~whitespace_rule_names[i].rule_bits;
60 else
61 rule |= whitespace_rule_names[i].rule_bits;
62 break;
63 }
64 if (skip_prefix(string, "tabwidth=", &arg)) {
65 unsigned tabwidth = atoi(arg);
66 if (0 < tabwidth && tabwidth < 0100) {
67 rule &= ~WS_TAB_WIDTH_MASK;
68 rule |= tabwidth;
69 }
70 else
71 warning("tabwidth %.*s out of range",
72 (int)(ep - arg), arg);
73 }
74 string = ep;
75 }
76
77 if (rule & WS_TAB_IN_INDENT && rule & WS_INDENT_WITH_NON_TAB)
78 die("cannot enforce both tab-in-indent and indent-with-non-tab");
79 return rule;
80}
81
82unsigned whitespace_rule(struct index_state *istate, const char *pathname)
83{

Callers 2

whitespace_ruleFunction · 0.85
git_default_core_configFunction · 0.85

Calls 2

warningFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected