MCPcopy Create free account
hub / github.com/coreutils/coreutils / write_line

Function write_line

src/sort.c:3030–3062  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3028 append some debugging information. */
3029
3030static void
3031write_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

Callers 3

checkFunction · 0.85
mergefpsFunction · 0.85
write_uniqueFunction · 0.85

Calls 2

sort_dieFunction · 0.85
debug_lineFunction · 0.85

Tested by

no test coverage detected