mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-12-26 11:30:03 +05:30
fixup: freadln.c: test: use return
instead of exit
This commit is contained in:
parent
2c6d56faa5
commit
889f39ac29
@ -139,13 +139,13 @@ int main(void) {
|
|||||||
FILE* f = fopen(TEST_FILE, "w");
|
FILE* f = fopen(TEST_FILE, "w");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
perror("fopen");
|
perror("fopen");
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
fprintf(f, "Hello, world!\nAnother line\n\n");
|
fprintf(f, "Hello, world!\nAnother line\n\n");
|
||||||
FILE* new_f = freopen(TEST_FILE, "r", f);
|
FILE* new_f = freopen(TEST_FILE, "r", f);
|
||||||
if (new_f == NULL) {
|
if (new_f == NULL) {
|
||||||
perror("freopen");
|
perror("freopen");
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
f = new_f;
|
f = new_f;
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ int main(void) {
|
|||||||
int result = freadln(f, &line, &line_length);
|
int result = freadln(f, &line, &line_length);
|
||||||
if (result == freadln_ERROR) {
|
if (result == freadln_ERROR) {
|
||||||
perror("freadln");
|
perror("freadln");
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
} else if (result == freadln_EOF || feof(f)) {
|
} else if (result == freadln_EOF || feof(f)) {
|
||||||
printf("File: EOF, breaking the loop (returned by function? %s, "
|
printf("File: EOF, breaking the loop (returned by function? %s, "
|
||||||
"feof? %s)\n", YN(result == freadln_EOF), YN(feof(f)));
|
"feof? %s)\n", YN(result == freadln_EOF), YN(feof(f)));
|
||||||
|
Loading…
Reference in New Issue
Block a user