diff options
author | Roland McGrath <roland@gnu.org> | 2005-02-16 12:31:10 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2005-02-16 12:31:10 +0000 |
commit | 833861be818bb5d45ab0c47370b84068dfb2fedf (patch) | |
tree | 2f1754a415c378f6b067f9158cc42df24d4641d2 /libio | |
parent | c397a0064061e28a00eea873669e59f3983db791 (diff) |
import later fedora-branch tweaks
Diffstat (limited to 'libio')
-rw-r--r-- | libio/fmemopen.c | 25 | ||||
-rw-r--r-- | libio/iofopncook.c | 23 | ||||
-rw-r--r-- | libio/stdio.h | 45 |
3 files changed, 32 insertions, 61 deletions
diff --git a/libio/fmemopen.c b/libio/fmemopen.c index 7c8769a130..ab6ffdd678 100644 --- a/libio/fmemopen.c +++ b/libio/fmemopen.c @@ -1,5 +1,5 @@ /* Fmemopen implementation. - Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 2000, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Hanno Mueller, kontakt@hanno.de, 2000. @@ -27,6 +27,8 @@ * but couldn't find it in libio. The following snippet of code is an * attempt to implement what glibc's documentation describes. * + * No, it isn't really tested yet. :-) + * * * * I already see some potential problems: @@ -71,7 +73,6 @@ #include <libio.h> #include <stdio.h> #include <stdlib.h> -#include <stdint.h> #include <string.h> #include <sys/types.h> #include "libioP.h" @@ -165,7 +166,7 @@ fmemopen_seek (void *cookie, _IO_off64_t *p, int w) break; case SEEK_END: - np = c->maxpos - *p; + np = c->size - *p; break; default: @@ -175,9 +176,9 @@ fmemopen_seek (void *cookie, _IO_off64_t *p, int w) if (np < 0 || (size_t) np > c->size) return -1; - *p = c->pos = np; + c->pos = np; - return 0; + return np; } @@ -202,13 +203,6 @@ fmemopen (void *buf, size_t len, const char *mode) cookie_io_functions_t iof; fmemopen_cookie_t *c; - if (len == 0) - { - einval: - __set_errno (EINVAL); - return NULL; - } - c = (fmemopen_cookie_t *) malloc (sizeof (fmemopen_cookie_t)); if (c == NULL) return NULL; @@ -226,12 +220,7 @@ fmemopen (void *buf, size_t len, const char *mode) c->buffer[0] = '\0'; } else - { - if ((uintptr_t) len > -(uintptr_t) buf) - goto einval; - - c->buffer = buf; - } + c->buffer = buf; c->size = len; diff --git a/libio/iofopncook.c b/libio/iofopncook.c index 9c5503d1f2..321eb67b8d 100644 --- a/libio/iofopncook.c +++ b/libio/iofopncook.c @@ -1,5 +1,4 @@ -/* Copyright (C) 1993,95,97,99,2000,2002,2004, 2005 - Free Software Foundation, Inc. +/* Copyright (C) 1993,95,97,99,2000,2002,2004 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -37,8 +36,6 @@ static _IO_ssize_t _IO_cookie_read (register _IO_FILE* fp, void* buf, static _IO_ssize_t _IO_cookie_write (register _IO_FILE* fp, const void* buf, _IO_ssize_t size); static _IO_off64_t _IO_cookie_seek (_IO_FILE *fp, _IO_off64_t offset, int dir); -static _IO_off64_t _IO_cookie_seekoff (_IO_FILE *fp, _IO_off64_t offset, - int dir, int mode); static int _IO_cookie_close (_IO_FILE* fp); static _IO_ssize_t @@ -97,20 +94,6 @@ _IO_cookie_close (fp) } -static _IO_off64_t -_IO_cookie_seekoff (fp, offset, dir, mode) - _IO_FILE *fp; - _IO_off64_t offset; - int dir; - int mode; -{ - /* We must force the fileops code to always use seek to determine - the position. */ - fp->_offset = _IO_pos_BAD; - return INTUSE(_IO_file_seekoff) (fp, offset, dir, mode); -} - - static const struct _IO_jump_t _IO_cookie_jumps = { JUMP_INIT_DUMMY, JUMP_INIT(finish, INTUSE(_IO_file_finish)), @@ -120,7 +103,7 @@ static const struct _IO_jump_t _IO_cookie_jumps = { JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)), JUMP_INIT(xsputn, INTUSE(_IO_file_xsputn)), JUMP_INIT(xsgetn, INTUSE(_IO_default_xsgetn)), - JUMP_INIT(seekoff, _IO_cookie_seekoff), + JUMP_INIT(seekoff, INTUSE(_IO_file_seekoff)), JUMP_INIT(seekpos, _IO_default_seekpos), JUMP_INIT(setbuf, INTUSE(_IO_file_setbuf)), JUMP_INIT(sync, INTUSE(_IO_file_sync)), @@ -240,7 +223,7 @@ static const struct _IO_jump_t _IO_old_cookie_jumps = { JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)), JUMP_INIT(xsputn, INTUSE(_IO_file_xsputn)), JUMP_INIT(xsgetn, INTUSE(_IO_default_xsgetn)), - JUMP_INIT(seekoff, _IO_cookie_seekoff), + JUMP_INIT(seekoff, INTUSE(_IO_file_seekoff)), JUMP_INIT(seekpos, _IO_default_seekpos), JUMP_INIT(setbuf, INTUSE(_IO_file_setbuf)), JUMP_INIT(sync, INTUSE(_IO_file_sync)), diff --git a/libio/stdio.h b/libio/stdio.h index ac42b3e2ac..941a2afc74 100644 --- a/libio/stdio.h +++ b/libio/stdio.h @@ -1,5 +1,5 @@ /* Define ISO C stdio on top of C++ iostreams. - Copyright (C) 1991,1994-2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1991,1994-2002,2003,2004 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -393,15 +393,15 @@ __BEGIN_NAMESPACE_STD This function is a possible cancellation point and therefore not marked with __THROW. */ extern int fscanf (FILE *__restrict __stream, - __const char *__restrict __format, ...) __wur; + __const char *__restrict __format, ...); /* Read formatted input from stdin. This function is a possible cancellation point and therefore not marked with __THROW. */ -extern int scanf (__const char *__restrict __format, ...) __wur; +extern int scanf (__const char *__restrict __format, ...); /* Read formatted input from S. */ extern int sscanf (__const char *__restrict __s, - __const char *__restrict __format, ...) __THROW __wur; + __const char *__restrict __format, ...) __THROW; __END_NAMESPACE_STD #ifdef __USE_ISOC99 @@ -412,19 +412,19 @@ __BEGIN_NAMESPACE_C99 marked with __THROW. */ extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format, _G_va_list __arg) - __attribute__ ((__format__ (__scanf__, 2, 0))) __wur; + __attribute__ ((__format__ (__scanf__, 2, 0))); /* Read formatted input from stdin into argument list ARG. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int vscanf (__const char *__restrict __format, _G_va_list __arg) - __attribute__ ((__format__ (__scanf__, 1, 0))) __wur; + __attribute__ ((__format__ (__scanf__, 1, 0))); /* Read formatted input from S into argument list ARG. */ extern int vsscanf (__const char *__restrict __s, __const char *__restrict __format, _G_va_list __arg) - __THROW __attribute__ ((__format__ (__scanf__, 2, 0))) __wur; + __THROW __attribute__ ((__format__ (__scanf__, 2, 0))); __END_NAMESPACE_C99 #endif /* Use ISO C9x. */ @@ -525,15 +525,14 @@ __BEGIN_NAMESPACE_STD This function is a possible cancellation point and therefore not marked with __THROW. */ -extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream) - __wur; +extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream); /* Get a newline-terminated string from stdin, removing the newline. DO NOT USE THIS FUNCTION!! There is no limit on how much it will read. This function is a possible cancellation point and therefore not marked with __THROW. */ -extern char *gets (char *__s) __wur; +extern char *gets (char *__s); __END_NAMESPACE_STD #ifdef __USE_GNU @@ -544,7 +543,7 @@ __END_NAMESPACE_STD or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern char *fgets_unlocked (char *__restrict __s, int __n, - FILE *__restrict __stream) __wur; + FILE *__restrict __stream); #endif @@ -561,10 +560,10 @@ extern char *fgets_unlocked (char *__restrict __s, int __n, therefore not marked with __THROW. */ extern _IO_ssize_t __getdelim (char **__restrict __lineptr, size_t *__restrict __n, int __delimiter, - FILE *__restrict __stream) __wur; + FILE *__restrict __stream); extern _IO_ssize_t getdelim (char **__restrict __lineptr, size_t *__restrict __n, int __delimiter, - FILE *__restrict __stream) __wur; + FILE *__restrict __stream); /* Like `getdelim', but reads up to a newline. @@ -574,7 +573,7 @@ extern _IO_ssize_t getdelim (char **__restrict __lineptr, therefore not marked with __THROW. */ extern _IO_ssize_t getline (char **__restrict __lineptr, size_t *__restrict __n, - FILE *__restrict __stream) __wur; + FILE *__restrict __stream); #endif @@ -596,7 +595,7 @@ extern int puts (__const char *__s); This function is a possible cancellation points and therefore not marked with __THROW. */ -extern int ungetc (int __c, FILE *__stream) __wur; +extern int ungetc (int __c, FILE *__stream); /* Read chunks of generic data from STREAM. @@ -604,13 +603,13 @@ extern int ungetc (int __c, FILE *__stream) __wur; This function is a possible cancellation points and therefore not marked with __THROW. */ extern size_t fread (void *__restrict __ptr, size_t __size, - size_t __n, FILE *__restrict __stream) __wur; + size_t __n, FILE *__restrict __stream); /* Write chunks of generic data to STREAM. This function is a possible cancellation points and therefore not marked with __THROW. */ extern size_t fwrite (__const void *__restrict __ptr, size_t __size, - size_t __n, FILE *__restrict __s) __wur; + size_t __n, FILE *__restrict __s); __END_NAMESPACE_STD #ifdef __USE_GNU @@ -632,9 +631,9 @@ extern int fputs_unlocked (__const char *__restrict __s, or due to the implementation they are cancellation points and therefore not marked with __THROW. */ extern size_t fread_unlocked (void *__restrict __ptr, size_t __size, - size_t __n, FILE *__restrict __stream) __wur; + size_t __n, FILE *__restrict __stream); extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size, - size_t __n, FILE *__restrict __stream) __wur; + size_t __n, FILE *__restrict __stream); #endif @@ -648,7 +647,7 @@ extern int fseek (FILE *__stream, long int __off, int __whence); This function is a possible cancellation point and therefore not marked with __THROW. */ -extern long int ftell (FILE *__stream) __wur; +extern long int ftell (FILE *__stream); /* Rewind to the beginning of STREAM. This function is a possible cancellation point and therefore not @@ -672,7 +671,7 @@ extern int fseeko (FILE *__stream, __off_t __off, int __whence); This function is a possible cancellation point and therefore not marked with __THROW. */ -extern __off_t ftello (FILE *__stream) __wur; +extern __off_t ftello (FILE *__stream); # else # ifdef __REDIRECT extern int __REDIRECT (fseeko, @@ -713,7 +712,7 @@ __END_NAMESPACE_STD #ifdef __USE_LARGEFILE64 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence); -extern __off64_t ftello64 (FILE *__stream) __wur; +extern __off64_t ftello64 (FILE *__stream); extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos); extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos); #endif @@ -811,7 +810,7 @@ extern void flockfile (FILE *__stream) __THROW; /* Try to acquire ownership of STREAM but do not block if it is not possible. */ -extern int ftrylockfile (FILE *__stream) __THROW __wur; +extern int ftrylockfile (FILE *__stream) __THROW; /* Relinquish the ownership granted for STREAM. */ extern void funlockfile (FILE *__stream) __THROW; |