| 928 | #define INDENT_BLANKLINE INT_MIN |
| 929 | |
| 930 | static void fill_es_indent_data(struct emitted_diff_symbol *es) |
| 931 | { |
| 932 | unsigned int off = 0, i; |
| 933 | int width = 0, tab_width = es->flags & WS_TAB_WIDTH_MASK; |
| 934 | const char *s = es->line; |
| 935 | const int len = es->len; |
| 936 | |
| 937 | /* skip any \v \f \r at start of indentation */ |
| 938 | while (s[off] == '\f' || s[off] == '\v' || |
| 939 | (off < len - 1 && s[off] == '\r')) |
| 940 | off++; |
| 941 | |
| 942 | /* calculate the visual width of indentation */ |
| 943 | while(1) { |
| 944 | if (s[off] == ' ') { |
| 945 | width++; |
| 946 | off++; |
| 947 | } else if (s[off] == '\t') { |
| 948 | width += tab_width - (width % tab_width); |
| 949 | while (s[++off] == '\t') |
| 950 | width += tab_width; |
| 951 | } else { |
| 952 | break; |
| 953 | } |
| 954 | } |
| 955 | |
| 956 | /* check if this line is blank */ |
| 957 | for (i = off; i < len; i++) |
| 958 | if (!isspace(s[i])) |
| 959 | break; |
| 960 | |
| 961 | if (i == len) { |
| 962 | es->indent_width = INDENT_BLANKLINE; |
| 963 | es->indent_off = len; |
| 964 | } else { |
| 965 | es->indent_off = off; |
| 966 | es->indent_width = width; |
| 967 | } |
| 968 | } |
| 969 | |
| 970 | static int compute_ws_delta(const struct emitted_diff_symbol *a, |
| 971 | const struct emitted_diff_symbol *b) |
no outgoing calls
no test coverage detected