diff options
author | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2003-05-01 03:16:30 +0000 |
---|---|---|
committer | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2003-05-01 03:16:30 +0000 |
commit | d1cd5dbccdeb73f57e251b216f3e238960861ce6 (patch) | |
tree | 4bc0d25765671b41d8ce1a2686fd3530059b4a70 /file_io | |
parent | ecfdcc37ceb07a86da28f3500def444b7d8f8027 (diff) | |
download | libapr-d1cd5dbccdeb73f57e251b216f3e238960861ce6.tar.gz |
apr_file_gets(): Return APR_SUCCESS if any characters are
returned. Any I/O errors or EOF will be reported on the
next call. Callers that are coded to expect returned
data + APR_EOF when there is no final newline are affected
by this change.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64498 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r-- | file_io/os2/readwrite.c | 6 | ||||
-rw-r--r-- | file_io/unix/readwrite.c | 9 | ||||
-rw-r--r-- | file_io/win32/readwrite.c | 6 |
3 files changed, 20 insertions, 1 deletions
diff --git a/file_io/os2/readwrite.c b/file_io/os2/readwrite.c index 20c298742..6121ebc5a 100644 --- a/file_io/os2/readwrite.c +++ b/file_io/os2/readwrite.c @@ -349,6 +349,12 @@ APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) } } str[i] = 0; + if (i > 0) { + /* we stored chars; don't report EOF or any other errors; + * the app will find out about that on the next call + */ + return APR_SUCCESS; + } return rv; } diff --git a/file_io/unix/readwrite.c b/file_io/unix/readwrite.c index db412ec06..c7782a35b 100644 --- a/file_io/unix/readwrite.c +++ b/file_io/unix/readwrite.c @@ -330,6 +330,7 @@ APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) { apr_status_t rv = APR_SUCCESS; /* get rid of gcc warning */ apr_size_t nbytes; + const char *str_start = str; char *final = str + len - 1; if (len <= 1) { @@ -353,7 +354,13 @@ APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) /* We must store a terminating '\0' if we've stored any chars. We can * get away with storing it if we hit an error first. */ - *str = '\0'; + *str = '\0'; + if (str > str_start) { + /* we stored chars; don't report EOF or any other errors; + * the app will find out about that on the next call + */ + return APR_SUCCESS; + } return rv; } diff --git a/file_io/win32/readwrite.c b/file_io/win32/readwrite.c index c54878a52..6c023b484 100644 --- a/file_io/win32/readwrite.c +++ b/file_io/win32/readwrite.c @@ -458,6 +458,12 @@ APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile) } } str[i] = 0; + if (i > 0) { + /* we stored chars; don't report EOF or any other errors; + * the app will find out about that on the next call + */ + return APR_SUCCESS; + } return rv; } |