| 3028 | append some debugging information. */ |
| 3029 | |
| 3030 | static void |
| 3031 | write_line (struct line const *line, FILE *fp, char const *output_file) |
| 3032 | { |
| 3033 | char *buf = line->text; |
| 3034 | size_t n_bytes = line->length; |
| 3035 | char *ebuf = buf + n_bytes; |
| 3036 | |
| 3037 | if (!output_file && debug) |
| 3038 | { |
| 3039 | /* Convert TAB to '>' and EOL to \n, and then output debugging info. */ |
| 3040 | char const *c = buf; |
| 3041 | |
| 3042 | while (c < ebuf) |
| 3043 | { |
| 3044 | char wc = *c++; |
| 3045 | if (wc == '\t') |
| 3046 | wc = '>'; |
| 3047 | else if (c == ebuf) |
| 3048 | wc = '\n'; |
| 3049 | if (fputc (wc, fp) == EOF) |
| 3050 | sort_die (_("write failed"), output_file); |
| 3051 | } |
| 3052 | |
| 3053 | debug_line (line); |
| 3054 | } |
| 3055 | else |
| 3056 | { |
| 3057 | ebuf[-1] = eolchar; |
| 3058 | if (fwrite (buf, 1, n_bytes, fp) != n_bytes) |
| 3059 | sort_die (_("write failed"), output_file); |
| 3060 | ebuf[-1] = '\0'; |
| 3061 | } |
| 3062 | } |
| 3063 | |
| 3064 | /* Check that the lines read from FILE_NAME come in order. Return |
| 3065 | true if they are in order. If CHECKONLY == 'c', also print a |
no test coverage detected