- puts(reset);
-}
-
-static void emit_line_with_ws(int nparents,
- const char *set, const char *reset, const char *ws,
- const char *line, int len, unsigned ws_rule)
-{
- int col0 = nparents;
- int last_tab_in_indent = -1;
- int last_space_in_indent = -1;
- int i;
- int tail = len;
- int need_highlight_leading_space = 0;
- /*
- * The line is a newly added line. Does it have funny leading
- * whitespaces? In indent, SP should never precede a TAB. In
- * addition, under "indent with non tab" rule, there should not
- * be more than 8 consecutive spaces.
- */
- for (i = col0; i < len; i++) {
- if (line[i] == '\t') {
- last_tab_in_indent = i;
- if ((ws_rule & WS_SPACE_BEFORE_TAB) &&
- 0 <= last_space_in_indent)
- need_highlight_leading_space = 1;
- }
- else if (line[i] == ' ')
- last_space_in_indent = i;
- else
- break;
- }
- if ((ws_rule & WS_INDENT_WITH_NON_TAB) &&
- 0 <= last_space_in_indent &&
- last_tab_in_indent < 0 &&
- 8 <= (i - col0)) {
- last_tab_in_indent = i;
- need_highlight_leading_space = 1;
- }
- fputs(set, stdout);
- fwrite(line, col0, 1, stdout);