Raw
1 #ifndef WS_H
2 #define WS_H
3
4 struct index_state;
5 struct strbuf;
6
7 /*
8 * whitespace rules.
9 * used by both diff and apply
10 * last two octal-digits are tab width (we support only up to 63).
11 */
12 #define WS_BLANK_AT_EOL (1<<6)
13 #define WS_SPACE_BEFORE_TAB (1<<7)
14 #define WS_INDENT_WITH_NON_TAB (1<<8)
15 #define WS_CR_AT_EOL (1<<9)
16 #define WS_BLANK_AT_EOF (1<<10)
17 #define WS_TAB_IN_INDENT (1<<11)
18 #define WS_INCOMPLETE_LINE (1<<12)
19
20 #define WS_TRAILING_SPACE (WS_BLANK_AT_EOL|WS_BLANK_AT_EOF)
21 #define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB|8)
22 #define WS_TAB_WIDTH_MASK ((1<<6)-1)
23
24 /* All WS_* -- when extended, adapt constants defined after diff.c:diff_symbol */
25 #define WS_RULE_MASK ((1<<16)-1)
26
27 extern unsigned whitespace_rule_cfg;
28 unsigned whitespace_rule(struct index_state *, const char *);
29 unsigned parse_whitespace_rule(const char *);
30 unsigned ws_check(const char *line, int len, unsigned ws_rule);
31 void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws);
32 char *whitespace_error_string(unsigned ws);
33 void ws_fix_copy(struct strbuf *, const char *, int, unsigned, int *);
34 int ws_blank_line(const char *line, int len);
35 #define ws_tab_width(rule) ((rule) & WS_TAB_WIDTH_MASK)
36
37 #endif /* WS_H */