Changeset 2594


Ignore:
Timestamp:
Mar 9, 2006, 7:38:07 PM (19 years ago)
Author:
bird
Message:

#62: Fixed incorrect EOF treatment in getdelim (and in getline since that's just a special case of getdelim).

Location:
branches/libc-0.6/src/emx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/ChangeLog.LIBC

    r2579 r2594  
    22
    33TODO: open replace on RAMFS fails with error 32!
     4
     52006-03-09: knut st. osmundsen <bird-gccos2-spam@anduin.net>
     6    - libc:
     7        o #62: Fixed incorrect EOF treatment in getdelim (and in getline since that's just a
     8          special case of getdelim).
    49
    5102006-03-07: knut st. osmundsen <bird-gccos2-spam@anduin.net>
  • branches/libc-0.6/src/emx/src/lib/io/getdelim.c

    r2254 r2594  
    4646 *
    4747 * @returns number of bytes read.
    48  * @returns -1 on failure, including EOF.
     48 * @returns -1 on failure - this includes EOF when nothing was retrieved.
    4949 * @param   ppszString      Where to buffer pointer is stored. *ppszString can of course be NULL.
    5050 * @param   pcchString      Size of the buffer pointed to by *ppszString.
     
    8181     */
    8282    STREAM_LOCK(pStream);
    83     ssize_t rc = -1;
     83    ssize_t rc = 0;
    8484    char *psz = *ppszString;
    8585    char *pszEnd = psz + *pcchString - 1;
     
    9090        int ch = _getc_inline(pStream);
    9191        if (ch == EOF)
     92        {
     93            if (psz == *ppszString)
     94                rc = -1;
    9295            break;
     96        }
    9397        if (psz == pszEnd)
    9498        {
     
    100104            char *pszNew = (char *)realloc(*ppszString, cch);
    101105            if (!pszNew)
     106            {
     107                rc = -1;
    102108                break;
     109            }
    103110
    104111            psz = pszNew + (psz - *ppszString);
     
    109116        *psz++ = (char)ch;
    110117        if (ch == chDelim)
    111         {
    112             rc = psz - *ppszString;
    113118            break;
    114         }
    115119    }
    116120    STREAM_UNLOCK(pStream);
     121
     122    if (!rc)
     123        rc = psz - *ppszString;
    117124
    118125    *psz = '\0';
Note: See TracChangeset for help on using the changeset viewer.