1 | // RUN: %clangxx -O0 -g %s -o %t -lutil && %run %t 2>&1 | FileCheck %s |
2 | |
3 | #include <assert.h> |
4 | #include <stdio.h> |
5 | #include <stdlib.h> |
6 | #include <libutil.h> |
7 | |
8 | int main(void) { |
9 | printf(format: "fparseln\n" ); |
10 | |
11 | FILE *fp = fopen(filename: "/etc/fstab" , modes: "r" ); |
12 | assert(fp); |
13 | |
14 | int flags = FPARSELN_UNESCALL; |
15 | const char *delim = "\\\\#" ; |
16 | size_t lineno = 0, len; |
17 | char *line; |
18 | while ((line = fparseln(fp, &len, &lineno, delim, flags))) { |
19 | printf(format: "lineno: %zu, length: %zu, line: %s\n" , lineno, len, line); |
20 | free(ptr: line); |
21 | } |
22 | |
23 | // CHECK: fparseln |
24 | |
25 | return 0; |
26 | } |
27 | |