mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Reworked the __putc() and putc() macros to reference the 'c' input
parameter only once, and to be free of side-effects when tinkering with the buffer position. - isatty() had the __fd_lock() call in the wrong place, which could have led to cleanup problems later. - The close action in the stdio, socket and termios hook code now also zaps the fd pointer itself after cleaning up the file descriptor table entry. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15211 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -1,3 +1,15 @@
|
||||
- Reworked the __putc() and putc() macros to reference the 'c' input
|
||||
parameter only once, and to be free of side-effects when tinkering
|
||||
with the buffer position.
|
||||
|
||||
- isatty() had the __fd_lock() call in the wrong place, which could have
|
||||
led to cleanup problems later.
|
||||
|
||||
- The close action in the stdio, socket and termios hook code now
|
||||
also zaps the fd pointer itself after cleaning up the file descriptor
|
||||
table entry.
|
||||
|
||||
|
||||
c.lib 1.205 (21.8.2010)
|
||||
|
||||
- Added dlclose(), dlerror(), dlopen() and dlsym() functions, which are
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio.h,v 1.23 2010-10-19 09:35:16 obarthel Exp $
|
||||
* $Id: stdio.h,v 1.24 2010-10-20 13:12:59 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -285,11 +285,11 @@ extern char *tmpnam(char *buf);
|
||||
(((((FILE *)(f))->flags & (__FILE_IN_USE|__FILE_WRITABLE)) == (__FILE_IN_USE|__FILE_WRITABLE) && \
|
||||
(((FILE *)(f))->flags & __FILE_BUFFER_MASK) != _IONBF && \
|
||||
(((FILE *)(f))->num_write_bytes < ((FILE *)(f))->size)) ? \
|
||||
(((FILE *)(f))->buffer[((FILE *)(f))->num_write_bytes++] = (c), \
|
||||
(((FILE *)(f))->buffer[((FILE *)(f))->num_write_bytes] = (c), \
|
||||
(((((FILE *)(f))->flags & __FILE_BUFFER_MASK) == _IOLBF && \
|
||||
(c) == '\n') ? \
|
||||
__flush(f) : \
|
||||
(c))) : \
|
||||
((FILE *)(f))->buffer[((FILE *)(f))->num_write_bytes] == '\n') ? \
|
||||
((FILE *)(f))->num_write_bytes++, __flush(f) : \
|
||||
((FILE *)(f))->buffer[((FILE *)(f))->num_write_bytes++])) : \
|
||||
fputc((c),(f)))
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: socket_hook_entry.c,v 1.17 2006-11-16 10:41:15 obarthel Exp $
|
||||
* $Id: socket_hook_entry.c,v 1.18 2010-10-20 13:12:58 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -145,6 +145,8 @@ __socket_hook_entry(
|
||||
/* And that's the last for this file descriptor. */
|
||||
memset(fd,0,sizeof(*fd));
|
||||
|
||||
fd = NULL;
|
||||
|
||||
break;
|
||||
|
||||
case file_action_seek:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_fdhookentry.c,v 1.34 2006-11-16 14:39:23 obarthel Exp $
|
||||
* $Id: stdio_fdhookentry.c,v 1.35 2010-10-20 13:12:58 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -367,6 +367,7 @@ __fd_hook_entry(
|
||||
|
||||
/* And that's the last for this file descriptor. */
|
||||
memset(fd,0,sizeof(*fd));
|
||||
fd = NULL;
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_fwrite.c,v 1.11 2006-09-25 15:38:21 obarthel Exp $
|
||||
* $Id: stdio_fwrite.c,v 1.12 2010-10-20 13:12:58 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -134,7 +134,7 @@ fwrite(const void *ptr,size_t element_size,size_t count,FILE *stream)
|
||||
{
|
||||
c = (*data++);
|
||||
|
||||
if(__putc_line_buffered(c,(FILE *)file) < 0)
|
||||
if(__putc_line_buffered(c,(FILE *)file) == EOF)
|
||||
goto out;
|
||||
|
||||
total_bytes_written++;
|
||||
@ -146,7 +146,7 @@ fwrite(const void *ptr,size_t element_size,size_t count,FILE *stream)
|
||||
{
|
||||
c = (*data++);
|
||||
|
||||
if(__putc_fully_buffered(c,(FILE *)file) < 0)
|
||||
if(__putc_fully_buffered(c,(FILE *)file) == EOF)
|
||||
goto out;
|
||||
|
||||
total_bytes_written++;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_headers.h,v 1.32 2010-10-19 09:35:16 obarthel Exp $
|
||||
* $Id: stdio_headers.h,v 1.33 2010-10-20 13:12:59 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -276,12 +276,13 @@ struct iob
|
||||
((struct iob *)(f))->iob_Buffer[((struct iob *)(f))->iob_BufferPosition++] : \
|
||||
__fgetc((FILE *)(f)))
|
||||
|
||||
/* Caution: this putc() variant will evaluate the 'c' parameter more than once. */
|
||||
#define __putc(c,f,m) \
|
||||
(((((struct iob *)(f))->iob_BufferWriteBytes < ((struct iob *)(f))->iob_BufferSize)) ? \
|
||||
(((struct iob *)(f))->iob_Buffer[((struct iob *)(f))->iob_BufferWriteBytes++] = (c), \
|
||||
(((m) == IOBF_BUFFER_MODE_LINE && (c) == '\n') ? \
|
||||
__flush(f) : \
|
||||
(c))) : \
|
||||
((c) & 255))) : \
|
||||
__fputc((c),(f),(m)))
|
||||
|
||||
#define __putc_fully_buffered(c,f) \
|
||||
@ -289,12 +290,13 @@ struct iob
|
||||
(((struct iob *)(f))->iob_Buffer[((struct iob *)(f))->iob_BufferWriteBytes++] = (c)) : \
|
||||
__fputc((c),(f),IOBF_BUFFER_MODE_FULL))
|
||||
|
||||
/* Caution: this putc() variant will evaluate the 'c' parameter more than once. */
|
||||
#define __putc_line_buffered(c,f) \
|
||||
(((((struct iob *)(f))->iob_BufferWriteBytes < ((struct iob *)(f))->iob_BufferSize)) ? \
|
||||
(((struct iob *)(f))->iob_Buffer[((struct iob *)(f))->iob_BufferWriteBytes++] = (c), \
|
||||
(((c) == '\n') ? \
|
||||
__flush(f) : \
|
||||
((c)))) : \
|
||||
((c) & 255))) : \
|
||||
__fputc((c),(f),IOBF_BUFFER_MODE_LINE))
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: termios_console_fdhookentry.c,v 1.5 2006-11-16 14:39:23 obarthel Exp $
|
||||
* $Id: termios_console_fdhookentry.c,v 1.6 2010-10-20 13:12:59 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -474,6 +474,7 @@ __termios_console_hook(
|
||||
|
||||
/* And that's the last for this file descriptor. */
|
||||
memset(fd,0,sizeof(*fd));
|
||||
fd = NULL;
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: unistd_isatty.c,v 1.10 2008-04-16 07:46:05 obarthel Exp $
|
||||
* $Id: unistd_isatty.c,v 1.11 2010-10-20 13:12:59 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -67,14 +67,14 @@ isatty(int file_descriptor)
|
||||
goto out;
|
||||
}
|
||||
|
||||
__fd_lock(fd);
|
||||
|
||||
if(FLAG_IS_SET(fd->fd_Flags,FDF_IS_SOCKET))
|
||||
{
|
||||
__set_errno(ENOTTY);
|
||||
goto out;
|
||||
}
|
||||
|
||||
__fd_lock(fd);
|
||||
|
||||
result = 1;
|
||||
|
||||
if(FLAG_IS_CLEAR(fd->fd_Flags,FDF_IS_INTERACTIVE))
|
||||
|
||||
Reference in New Issue
Block a user