summaryrefslogtreecommitdiff
path: root/test/sanitizer_common/TestCases/NetBSD/fparseln.cc
blob: 8a71d5fcdadcd046c51570d896b8dfaa77afd5d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  printf("fparseln\n");

  FILE *fp = fopen("/etc/fstab", "r");
  assert(fp);

  int flags = FPARSELN_UNESCALL;
  const char *delim = "\\\\#";
  size_t lineno = 0, len;
  char *line;
  while ((line = fparseln(fp, &len, &lineno, delim, flags))) {
    printf("lineno: %zu, length: %zu, line: %s\n", lineno, len, line);
    free(line);
  }

  // CHECK: fparseln

  return 0;
}