Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Update.
2002-07-24 Ulrich Drepper <drepper@redhat.com> * locale/hashval.h: Make more self-containedby defining LONG_BITS. * locale/programs/simple-hash.c: Remove LONG_BITS definition. * locale/programs/locarchive.c (add_locale_to_archive): Correct test to detect duplicate locales. * libio/fileops.c (_IO_new_file_seekoff): Fail if relative position would be before beginning of file. (_IO_file_seekoff_mmap): Likewise. * libio/Makefile (tests): Add bug-fseek. * libio/bug-fseek.c: New file. * intl/explodename.c: Remove support for CEN-style locale variables. It was never used and shouldn't be since it's not portable. * intl/finddomain.c: Likewise. * intl/l10nflist.c: Likewise. * intl/loadinfo.h: Likewise. * locale/findlocale.c: Likewise.
- Loading branch information
Ulrich Drepper
committed
Jul 24, 2002
1 parent
e155c80
commit 405550b
Showing
7 changed files
with
135 additions
and
8 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,94 @@ | ||
#include <errno.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
|
||
static char *fname; | ||
|
||
|
||
static void do_prepare (void); | ||
#define PREPARE(argc, argv) do_prepare () | ||
static int do_test (void); | ||
#define TEST_FUNCTION do_test () | ||
#include <test-skeleton.c> | ||
|
||
|
||
static void | ||
do_prepare (void) | ||
{ | ||
static const char pattern[] = "12345678901234567890"; | ||
int fd = create_temp_file ("bug-fseek.", &fname); | ||
if (fd == -1) | ||
{ | ||
printf ("cannot create temporary file: %m\n"); | ||
exit (1); | ||
} | ||
|
||
if (write (fd, pattern, sizeof (pattern)) != sizeof (pattern)) | ||
{ | ||
perror ("short write"); | ||
abort (); | ||
} | ||
close (fd); | ||
} | ||
|
||
|
||
|
||
static int | ||
do_test (void) | ||
{ | ||
FILE *f; | ||
int result = 0; | ||
char buf[10]; | ||
|
||
|
||
if ((f = fopen (fname, "r")) == (FILE *) NULL) | ||
{ | ||
perror ("fopen(\"r\")"); | ||
} | ||
|
||
fread (buf, 3, 1, f); | ||
errno = 0; | ||
if (fseek (f, -10, SEEK_CUR) == 0) | ||
{ | ||
printf ("fseek() for r to before start of file worked!\n"); | ||
result = 1; | ||
} | ||
else if (errno != EINVAL) | ||
{ | ||
printf ("\ | ||
fseek() for r to before start of file did not set errno to EINVAL. \ | ||
Got %d instead\n", | ||
errno); | ||
result = 1; | ||
} | ||
|
||
fclose (f); | ||
|
||
|
||
if ((f = fopen (fname, "r+")) == (FILE *) NULL) | ||
{ | ||
perror ("fopen(\"r+\")"); | ||
} | ||
|
||
fread (buf, 3, 1, f); | ||
errno = 0; | ||
if (fseek (f, -10, SEEK_CUR) == 0) | ||
{ | ||
printf ("fseek() for r+ to before start of file worked!\n"); | ||
result = 1; | ||
} | ||
else if (errno != EINVAL) | ||
{ | ||
printf ("\ | ||
fseek() for r+ to before start of file did not set errno to EINVAL. \ | ||
Got %d instead\n", | ||
errno); | ||
result = 1; | ||
} | ||
|
||
fclose (f); | ||
|
||
return result; | ||
} |
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
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