-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new interceptor for fparseln(3) from NetBSD
Summary: fparseln - returns the next logical line from a stream. Add a dedicated test for this API. Reviewers: vitalybuka, joerg Reviewed By: vitalybuka Subscribers: kubamracek, mgorny, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D55019 llvm-svn: 348654
- Loading branch information
1 parent
737be83
commit 592898b
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
compiler-rt/test/sanitizer_common/TestCases/NetBSD/fparseln.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} |