From 95c021fb7c302096763fbef954293802a8b7b29e Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Fri, 16 Apr 2004 05:47:01 +0000 Subject: [PATCH] ICU-3499 Add u_feof() X-SVN-Rev: 14992 --- icu4c/source/extra/ustdio/ufile.c | 20 +++++++++++++++++--- icu4c/source/extra/ustdio/unicode/ustdio.h | 16 ++++++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/icu4c/source/extra/ustdio/ufile.c b/icu4c/source/extra/ustdio/ufile.c index 8454d9a1828..7c3c9a61c51 100644 --- a/icu4c/source/extra/ustdio/ufile.c +++ b/icu4c/source/extra/ustdio/ufile.c @@ -114,12 +114,26 @@ u_fopen(const char *filename, return result; } +U_CAPI UBool U_EXPORT2 +u_feof(UFILE *f) +{ + UBool endOfBuffer; + if (f == NULL) { + return TRUE; + } + endOfBuffer = (UBool)(f->str.fPos >= f->str.fLimit); + if (f->fFile != NULL) { + return endOfBuffer && feof(f->fFile); + } + return endOfBuffer; +} + U_CAPI void U_EXPORT2 u_fflush(UFILE *file) { - ufile_flush_translit(file); - fflush(file->fFile); - /* TODO: flush input */ + ufile_flush_translit(file); + fflush(file->fFile); + /* TODO: flush input */ } U_CAPI void diff --git a/icu4c/source/extra/ustdio/unicode/ustdio.h b/icu4c/source/extra/ustdio/unicode/ustdio.h index 142d91118aa..21f719ac340 100644 --- a/icu4c/source/extra/ustdio/unicode/ustdio.h +++ b/icu4c/source/extra/ustdio/unicode/ustdio.h @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 1998-2003, International Business Machines +* Copyright (C) 1998-2004, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -41,7 +41,8 @@ * Make sure that #, blank and precision in the printf format specification works. * Make sure that * in the scanf format specification works. - * Each UFILE takes up at least 2KB. This should be really reduced. + * Each UFILE takes up at least 2KB. + Look into adding setvbuf() for configurable buffers. * This library does buffering. The OS should do this for us already. Check on this, and remove it from this library, if this is the case. Double buffering wastes a lot of time and space. @@ -167,6 +168,17 @@ u_finit(FILE *f, U_CAPI void U_EXPORT2 u_fclose(UFILE *file); +/** + * Tests if the UFILE is at the end of the file stream. + * @param f The UFILE from which to read. + * @return Returns TRUE after the first read operation that attempts to + * read past the end of the file. It returns FALSE if the current position is + * not end of file. + * @draft +*/ +U_CAPI UBool U_EXPORT2 +u_feof(UFILE *f); + /** * Flush output of a UFILE. Implies a flush of * converter/transliterator state. (That is, a logical break is