Read a line of up to bufsiz-1 characters into buf. Strips * the (required) trailing newline and all carriage returns. * Returns 1 for success; 0 for I/O error or truncation. */
| 2400 | * the (required) trailing newline and all carriage returns. |
| 2401 | * Returns 1 for success; 0 for I/O error or truncation. */ |
| 2402 | int read_line_old(int fd, char *buf, size_t bufsiz, int eof_ok) |
| 2403 | { |
| 2404 | assert(fd != iobuf.in_fd); |
| 2405 | bufsiz--; /* leave room for the null */ |
| 2406 | while (bufsiz > 0) { |
| 2407 | if (safe_read(fd, buf, 1) == 0) { |
| 2408 | if (eof_ok) |
| 2409 | break; |
| 2410 | return 0; |
| 2411 | } |
| 2412 | if (*buf == '\0') |
| 2413 | return 0; |
| 2414 | if (*buf == '\n') |
| 2415 | break; |
| 2416 | if (*buf != '\r') { |
| 2417 | buf++; |
| 2418 | bufsiz--; |
| 2419 | } |
| 2420 | } |
| 2421 | *buf = '\0'; |
| 2422 | return bufsiz > 0; |
| 2423 | } |
| 2424 | |
| 2425 | void io_printf(int fd, const char *format, ...) |
| 2426 | { |
no test coverage detected