From 4b3c197fc0912a22b07affd7caef344ce301840a Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 16 Aug 2001 20:04:19 +0000 Subject: 2001-08-16 Mike Siers * libc/termios.c: Fix a bug in the termios implementation in the following scenario: The General Terminal Interface document that me states that if VMIN = 0 and VTIME = 0, then read() should return the minimum of two values: a) number of bytes available b) number of bytes requested (I assume from the read call) The current implementation of the fillBufferQueue() in termios.c is always return 1 character with these setting values. I know the termios buffer has more than one character available and my read() call is requesting 1024 bytes. --- c/src/exec/libcsupport/src/termios.c | 19 +++++++++++-------- c/src/lib/ChangeLog | 15 +++++++++++++++ c/src/lib/libc/termios.c | 19 +++++++++++-------- 3 files changed, 37 insertions(+), 16 deletions(-) (limited to 'c') diff --git a/c/src/exec/libcsupport/src/termios.c b/c/src/exec/libcsupport/src/termios.c index cf0c4984eb..0a23d5bc32 100644 --- a/c/src/exec/libcsupport/src/termios.c +++ b/c/src/exec/libcsupport/src/termios.c @@ -982,8 +982,9 @@ fillBufferQueue (struct rtems_termios_tty *tty) { rtems_interval timeout = tty->rawInBufSemaphoreFirstTimeout; rtems_status_code sc; + int wait = (int)1; - for (;;) { + while ( wait ) { /* * Process characters read from raw queue */ @@ -1020,12 +1021,12 @@ fillBufferQueue (struct rtems_termios_tty *tty) /* continue processing new character */ if (tty->termios.c_lflag & ICANON) { if (siproc (c, tty)) - return RTEMS_SUCCESSFUL; + wait = 0; } else { siproc (c, tty); if (tty->ccount >= tty->termios.c_cc[VMIN]) - return RTEMS_SUCCESSFUL; + wait = 0; } timeout = tty->rawInBufSemaphoreTimeout; } @@ -1033,11 +1034,13 @@ fillBufferQueue (struct rtems_termios_tty *tty) /* * Wait for characters */ - sc = rtems_semaphore_obtain (tty->rawInBuf.Semaphore, - tty->rawInBufSemaphoreOptions, - timeout); - if (sc != RTEMS_SUCCESSFUL) - break; + if ( wait ) { + sc = rtems_semaphore_obtain (tty->rawInBuf.Semaphore, + tty->rawInBufSemaphoreOptions, + timeout); + if (sc != RTEMS_SUCCESSFUL) + break; + } } return RTEMS_SUCCESSFUL; } diff --git a/c/src/lib/ChangeLog b/c/src/lib/ChangeLog index a4d4064130..4581a619bd 100644 --- a/c/src/lib/ChangeLog +++ b/c/src/lib/ChangeLog @@ -1,3 +1,18 @@ +2001-08-16 Mike Siers + + * libc/termios.c: Fix a bug in the termios implementation in + the following scenario: + The General Terminal Interface document that me states that + if VMIN = 0 and VTIME = 0, then read() should return the minimum + of two values: + a) number of bytes available + b) number of bytes requested (I assume from the read call) + + The current implementation of the fillBufferQueue() in termios.c is + always return 1 character with these setting values. I know the + termios buffer has more than one character available and my read() + call is requesting 1024 bytes. + 2001-08-09 Fernando-Ruiz Casas * libc/getgrent.c, libc/getpwent.c: the 'ls' and more related command diff --git a/c/src/lib/libc/termios.c b/c/src/lib/libc/termios.c index cf0c4984eb..0a23d5bc32 100644 --- a/c/src/lib/libc/termios.c +++ b/c/src/lib/libc/termios.c @@ -982,8 +982,9 @@ fillBufferQueue (struct rtems_termios_tty *tty) { rtems_interval timeout = tty->rawInBufSemaphoreFirstTimeout; rtems_status_code sc; + int wait = (int)1; - for (;;) { + while ( wait ) { /* * Process characters read from raw queue */ @@ -1020,12 +1021,12 @@ fillBufferQueue (struct rtems_termios_tty *tty) /* continue processing new character */ if (tty->termios.c_lflag & ICANON) { if (siproc (c, tty)) - return RTEMS_SUCCESSFUL; + wait = 0; } else { siproc (c, tty); if (tty->ccount >= tty->termios.c_cc[VMIN]) - return RTEMS_SUCCESSFUL; + wait = 0; } timeout = tty->rawInBufSemaphoreTimeout; } @@ -1033,11 +1034,13 @@ fillBufferQueue (struct rtems_termios_tty *tty) /* * Wait for characters */ - sc = rtems_semaphore_obtain (tty->rawInBuf.Semaphore, - tty->rawInBufSemaphoreOptions, - timeout); - if (sc != RTEMS_SUCCESSFUL) - break; + if ( wait ) { + sc = rtems_semaphore_obtain (tty->rawInBuf.Semaphore, + tty->rawInBufSemaphoreOptions, + timeout); + if (sc != RTEMS_SUCCESSFUL) + break; + } } return RTEMS_SUCCESSFUL; } -- cgit v1.2.3