-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* stdio-common/vfscanf.c (_IO_vfscanf): Add additional test for EOF in loop to look for conversion specifier to avoid testing of wrong errno value. * stdio-common/Makefile (tests): Add bug18, bug18a, bug19, bug19a. * stdio-common/bug18.c: New file. * stdio-common/bug18a.c: New file. * stdio-common/bug19.c: New file. * stdio-common/bug19a.c: New file.
- Loading branch information
Jakub Jelinek
committed
Jul 8, 2007
1 parent
027dc27
commit 41dfb5c
Showing
7 changed files
with
141 additions
and
4 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
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,48 @@ | ||
#include <assert.h> | ||
#include <errno.h> | ||
#include <stdio.h> | ||
|
||
#ifndef CHAR | ||
# define CHAR char | ||
# define L(str) str | ||
# define SSCANF sscanf | ||
#endif | ||
|
||
|
||
static int | ||
do_test (void) | ||
{ | ||
printf("setting errno to EINTR\n"); | ||
errno = EINTR; | ||
|
||
printf("checking sscanf\n"); | ||
|
||
CHAR str[] = L("7-11"); | ||
int i, j, n; | ||
|
||
i = j = n = 0; | ||
SSCANF (str, L(" %i - %i %n"), &i, &j, &n); | ||
printf ("found %i-%i (length=%i)\n", i, j, n); | ||
|
||
int result = 0; | ||
if (i != 7) | ||
{ | ||
printf ("i is %d, expected 7\n", i); | ||
result = 1; | ||
} | ||
if (j != 11) | ||
{ | ||
printf ("j is %d, expected 11\n", j); | ||
result = 1; | ||
} | ||
if (n != 4) | ||
{ | ||
printf ("n is %d, expected 4\n", j); | ||
result = 1; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
#define TEST_FUNCTION do_test () | ||
#include "../test-skeleton.c" |
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,6 @@ | ||
#include <wchar.h> | ||
#define CHAR wchar_t | ||
#define L(str) L##str | ||
#define SSCANF swscanf | ||
|
||
#include "bug18.c" |
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,58 @@ | ||
#include <assert.h> | ||
#include <errno.h> | ||
#include <stdio.h> | ||
|
||
#ifndef CHAR | ||
# define CHAR char | ||
# define L(str) str | ||
# define FPUTS fputs | ||
# define FSCANF fscanf | ||
#endif | ||
|
||
|
||
static int | ||
do_test (void) | ||
{ | ||
FILE *fp = tmpfile (); | ||
if (fp == NULL) | ||
{ | ||
puts ("cannot open file"); | ||
return 1; | ||
} | ||
|
||
FPUTS (L("7-11"), fp); | ||
rewind (fp); | ||
|
||
printf("setting errno to EINTR\n"); | ||
errno = EINTR; | ||
|
||
printf("checking sscanf\n"); | ||
|
||
int i, j, n; | ||
|
||
i = j = n = 0; | ||
FSCANF (fp, L(" %i - %i %n"), &i, &j, &n); | ||
printf ("found %i-%i (length=%i)\n", i, j, n); | ||
|
||
int result = 0; | ||
if (i != 7) | ||
{ | ||
printf ("i is %d, expected 7\n", i); | ||
result = 1; | ||
} | ||
if (j != 11) | ||
{ | ||
printf ("j is %d, expected 11\n", j); | ||
result = 1; | ||
} | ||
if (n != 4) | ||
{ | ||
printf ("n is %d, expected 4\n", j); | ||
result = 1; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
#define TEST_FUNCTION do_test () | ||
#include "../test-skeleton.c" |
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,7 @@ | ||
#include <wchar.h> | ||
#define CHAR wchar_t | ||
#define L(str) L##str | ||
#define FPUTS fputws | ||
#define FSCANF fwscanf | ||
|
||
#include "bug19.c" |
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