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

Function output

src/tac.c:152–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150 If START is null, just flush the buffer. */
151
152static void
153output (char const *start, char const *past_end)
154{
155 static char buffer[WRITESIZE];
156 static size_t bytes_in_buffer = 0;
157 size_t bytes_to_add = past_end - start;
158 size_t bytes_available = WRITESIZE - bytes_in_buffer;
159
160 if (!start)
161 {
162 if (full_write (STDOUT_FILENO, buffer, bytes_in_buffer)
163 != bytes_in_buffer)
164 write_error ();
165 bytes_in_buffer = 0;
166 return;
167 }
168
169 /* Write out as many full buffers as possible. */
170 while (bytes_to_add >= bytes_available)
171 {
172 memcpy (buffer + bytes_in_buffer, start, bytes_available);
173 bytes_to_add -= bytes_available;
174 start += bytes_available;
175 if (full_write (STDOUT_FILENO, buffer, WRITESIZE) != WRITESIZE)
176 write_error ();
177 bytes_in_buffer = 0;
178 bytes_available = WRITESIZE;
179 }
180
181 memcpy (buffer + bytes_in_buffer, start, bytes_to_add);
182 bytes_in_buffer += bytes_to_add;
183}
184
185/* Print in reverse the file open on descriptor FD for reading FILE.
186 The file is already positioned at FILE_POS, which should be near its end.

Callers 2

tac_seekableFunction · 0.85
mainFunction · 0.85

Calls 1

write_errorFunction · 0.85

Tested by

no test coverage detected