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

Function skip_read

src/pr.c:2152–2211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2150 printed relative to 1st line of input file (start_line_num). */
2151
2152static void
2153skip_read (COLUMN *p, int column_number)
2154{
2155 int c;
2156 FILE *f = p->fp;
2157 int i;
2158 bool single_ff = false;
2159 COLUMN *q;
2160
2161 /* Read 1st character in a line or any character succeeding a FF */
2162 if ((c = getc (f)) == '\f' && p->full_page_printed)
2163 /* A FF-coincidence with a previous full_page_printed.
2164 To avoid an additional empty page, eliminate the FF */
2165 if ((c = getc (f)) == '\n')
2166 c = getc (f);
2167
2168 p->full_page_printed = false;
2169
2170 /* 1st character a FF means a single FF without any printable
2171 characters. Don't count it as a line with -n option. */
2172 if (c == '\f')
2173 single_ff = true;
2174
2175 /* Preparing for a FF-coincidence: Maybe we finish that page
2176 without a FF found */
2177 if (last_line)
2178 p->full_page_printed = true;
2179
2180 while (c != '\n')
2181 {
2182 if (c == '\f')
2183 {
2184 /* No FF-coincidence possible,
2185 no catching up of a FF-coincidence with next page */
2186 if (last_line)
2187 {
2188 if (!parallel_files)
2189 for (q = column_vector, i = columns; i; ++q, --i)
2190 q->full_page_printed = false;
2191 else
2192 p->full_page_printed = false;
2193 }
2194
2195 if ((c = getc (f)) != '\n')
2196 ungetc (c, f);
2197 hold_file (p);
2198 break;
2199 }
2200 else if (c == EOF)
2201 {
2202 close_file (p);
2203 break;
2204 }
2205 c = getc (f);
2206 }
2207
2208 if (skip_count)
2209 if ((!parallel_files || column_number == 1) && !single_ff)

Callers 1

skip_to_pageFunction · 0.85

Calls 2

hold_fileFunction · 0.85
close_fileFunction · 0.85

Tested by

no test coverage detected