2004-05-03 Artem B. Bityuckiy <abitytsky@softminecorp.com>
* libc/include/stdio.h (_ungetc_r): New prototype.
        * libc/stdio/ungetc.c (_ungetc_r): New reentrant function.
        (__submore): Add reentrant struct pointer argument.
        (ungetc): Change to call _ungetc_r.
			
			
This commit is contained in:
		| @@ -1,3 +1,10 @@ | |||||||
|  | 2004-05-03  Artem B. Bityuckiy  <abitytsky@softminecorp.com> | ||||||
|  |  | ||||||
|  | 	* libc/include/stdio.h (_ungetc_r): New prototype. | ||||||
|  | 	* libc/stdio/ungetc.c (_ungetc_r): New reentrant function. | ||||||
|  | 	(__submore): Add reentrant struct pointer argument. | ||||||
|  | 	(ungetc): Change to call _ungetc_r. | ||||||
|  |  | ||||||
| 2004-04-28  Artem B. Bityuckiy  <abitytsky@softminecorp.com> | 2004-04-28  Artem B. Bityuckiy  <abitytsky@softminecorp.com> | ||||||
|  |  | ||||||
| 	* libc/stdio/local.h (_fwalk_reent): Specify prototype of | 	* libc/stdio/local.h (_fwalk_reent): Specify prototype of | ||||||
|   | |||||||
| @@ -298,6 +298,7 @@ int	_EXFUN(_sscanf_r, (struct _reent *, const char *, const char *, ...)); | |||||||
| char *	_EXFUN(_tempnam_r, (struct _reent *, const char *, const char *)); | char *	_EXFUN(_tempnam_r, (struct _reent *, const char *, const char *)); | ||||||
| FILE *	_EXFUN(_tmpfile_r, (struct _reent *)); | FILE *	_EXFUN(_tmpfile_r, (struct _reent *)); | ||||||
| char *	_EXFUN(_tmpnam_r, (struct _reent *, char *)); | char *	_EXFUN(_tmpnam_r, (struct _reent *, char *)); | ||||||
|  | int	_EXFUN(_ungetc_r, (struct _reent *, int, FILE *)); | ||||||
| int	_EXFUN(_vasprintf_r, (struct _reent *, char **, const char *, __VALIST)); | int	_EXFUN(_vasprintf_r, (struct _reent *, char **, const char *, __VALIST)); | ||||||
| int	_EXFUN(_vfprintf_r, (struct _reent *, FILE *, const char *, __VALIST)); | int	_EXFUN(_vfprintf_r, (struct _reent *, FILE *, const char *, __VALIST)); | ||||||
| int	_EXFUN(_vprintf_r, (struct _reent *, const char *, __VALIST)); | int	_EXFUN(_vprintf_r, (struct _reent *, const char *, __VALIST)); | ||||||
|   | |||||||
| @@ -20,6 +20,7 @@ static char sccsid[] = "%W% (Berkeley) %G%"; | |||||||
| #endif /* LIBC_SCCS and not lint */ | #endif /* LIBC_SCCS and not lint */ | ||||||
|  |  | ||||||
| #include <_ansi.h> | #include <_ansi.h> | ||||||
|  | #include <reent.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| @@ -34,7 +35,8 @@ static char sccsid[] = "%W% (Berkeley) %G%"; | |||||||
|  |  | ||||||
| /*static*/ | /*static*/ | ||||||
| int | int | ||||||
| _DEFUN(__submore, (fp), | _DEFUN(__submore, (rptr, fp), | ||||||
|  |        struct _reent *rptr _AND | ||||||
|        register FILE *fp) |        register FILE *fp) | ||||||
| { | { | ||||||
|   register int i; |   register int i; | ||||||
| @@ -45,7 +47,7 @@ _DEFUN(__submore, (fp), | |||||||
|       /* |       /* | ||||||
|        * Get a new buffer (rather than expanding the old one). |        * Get a new buffer (rather than expanding the old one). | ||||||
|        */ |        */ | ||||||
|       if ((p = (unsigned char *) _malloc_r (_REENT, (size_t) BUFSIZ)) == NULL) |       if ((p = (unsigned char *) _malloc_r (rptr, (size_t) BUFSIZ)) == NULL) | ||||||
| 	return EOF; | 	return EOF; | ||||||
|       fp->_ub._base = p; |       fp->_ub._base = p; | ||||||
|       fp->_ub._size = BUFSIZ; |       fp->_ub._size = BUFSIZ; | ||||||
| @@ -56,7 +58,7 @@ _DEFUN(__submore, (fp), | |||||||
|       return 0; |       return 0; | ||||||
|     } |     } | ||||||
|   i = fp->_ub._size; |   i = fp->_ub._size; | ||||||
|   p = (unsigned char *) _realloc_r (_REENT, (_PTR) (fp->_ub._base), i << 1); |   p = (unsigned char *) _realloc_r (rptr, (_PTR) (fp->_ub._base), i << 1); | ||||||
|   if (p == NULL) |   if (p == NULL) | ||||||
|     return EOF; |     return EOF; | ||||||
|   _CAST_VOID memcpy ((_PTR) (p + i), (_PTR) p, (size_t) i); |   _CAST_VOID memcpy ((_PTR) (p + i), (_PTR) p, (size_t) i); | ||||||
| @@ -67,7 +69,8 @@ _DEFUN(__submore, (fp), | |||||||
| } | } | ||||||
|  |  | ||||||
| int | int | ||||||
| _DEFUN(ungetc, (c, fp), | _DEFUN(_ungetc_r, (rptr, c, fp), | ||||||
|  |        struct _reent *rptr _AND | ||||||
|        int c               _AND |        int c               _AND | ||||||
|        register FILE *fp) |        register FILE *fp) | ||||||
| { | { | ||||||
| @@ -118,7 +121,7 @@ _DEFUN(ungetc, (c, fp), | |||||||
|  |  | ||||||
|   if (HASUB (fp)) |   if (HASUB (fp)) | ||||||
|     { |     { | ||||||
|       if (fp->_r >= fp->_ub._size && __submore (fp)) |       if (fp->_r >= fp->_ub._size && __submore (rptr, fp)) | ||||||
|         { |         { | ||||||
|           _funlockfile (fp); |           _funlockfile (fp); | ||||||
|           return EOF; |           return EOF; | ||||||
| @@ -158,3 +161,14 @@ _DEFUN(ungetc, (c, fp), | |||||||
|   _funlockfile (fp); |   _funlockfile (fp); | ||||||
|   return c; |   return c; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #ifndef _REENT_ONLY | ||||||
|  | int | ||||||
|  | _DEFUN(ungetc, (c, fp), | ||||||
|  |        int c               _AND | ||||||
|  |        register FILE *fp) | ||||||
|  | { | ||||||
|  |   return _ungetc_r (_REENT, c, fp); | ||||||
|  | } | ||||||
|  | #endif /* !_REENT_ONLY */ | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user