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

Function strbuf_add_tabexpand

pretty.c:2183–2221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2181}
2182
2183static void strbuf_add_tabexpand(struct strbuf *sb, struct grep_opt *opt,
2184 enum git_colorbool color, int tabwidth, const char *line,
2185 int linelen)
2186{
2187 const char *tab;
2188
2189 while ((tab = memchr(line, '\t', linelen)) != NULL) {
2190 int width = pp_utf8_width(line, tab);
2191
2192 /*
2193 * If it wasn't well-formed utf8, or it
2194 * had characters with badly defined
2195 * width (control characters etc), just
2196 * give up on trying to align things.
2197 */
2198 if (width < 0)
2199 break;
2200
2201 /* Output the data .. */
2202 append_line_with_color(sb, opt, line, tab - line, color,
2203 GREP_CONTEXT_BODY,
2204 GREP_HEADER_FIELD_MAX);
2205
2206 /* .. and the de-tabified tab */
2207 strbuf_addchars(sb, ' ', tabwidth - (width % tabwidth));
2208
2209 /* Skip over the printed part .. */
2210 linelen -= tab + 1 - line;
2211 line = tab + 1;
2212 }
2213
2214 /*
2215 * Print out everything after the last tab without
2216 * worrying about width - there's nothing more to
2217 * align.
2218 */
2219 append_line_with_color(sb, opt, line, linelen, color, GREP_CONTEXT_BODY,
2220 GREP_HEADER_FIELD_MAX);
2221}
2222
2223/*
2224 * pp_handle_indent() prints out the indentation, and

Callers 2

pp_handle_indentFunction · 0.85
pp_remainderFunction · 0.85

Calls 3

pp_utf8_widthFunction · 0.85
append_line_with_colorFunction · 0.85
strbuf_addcharsFunction · 0.85

Tested by

no test coverage detected