diff options
author | Karl Berry <karl@freefriends.org> | 2021-02-13 17:46:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-02-13 17:46:14 +0000 |
commit | e10da232612cffe84bd4104d6e49a4b3eb5408f1 (patch) | |
tree | 2557cc3a01b6cfadfa75efc0e213062ec648990c /Build/source/libs/icu/icu-src/source/io | |
parent | 29a53021f09a33510bfc86395b70476368e85b7f (diff) |
icu-68.2
git-svn-id: svn://tug.org/texlive/trunk@57727 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/icu/icu-src/source/io')
9 files changed, 138 insertions, 92 deletions
diff --git a/Build/source/libs/icu/icu-src/source/io/Makefile.in b/Build/source/libs/icu/icu-src/source/io/Makefile.in index 45dbe870fb3..9bf9359eadd 100644 --- a/Build/source/libs/icu/icu-src/source/io/Makefile.in +++ b/Build/source/libs/icu/icu-src/source/io/Makefile.in @@ -60,9 +60,8 @@ DEFS += -DU_IO_IMPLEMENTATION LDFLAGS += $(LDFLAGSICUIO) LIBS = $(LIBICUUC) $(LIBICUI18N) $(DEFAULT_LIBS) -OBJECTS = locbund.o ufile.o ufmt_cmn.o uprintf.o uprntf_p.o \ -uscanf.o uscanf_p.o ustdio.o sprintf.o sscanf.o \ -ustream.o ucln_io.o +SOURCES = $(shell cat $(srcdir)/sources.txt) +OBJECTS = $(SOURCES:.cpp=.o) ## Header files to install HEADERS = $(srcdir)/unicode/*.h @@ -101,6 +100,11 @@ ifneq ($(ENABLE_STATIC),) $(INSTALL-L) $(TARGET) $(DESTDIR)$(libdir) endif ifneq ($(ENABLE_SHARED),) +# For MinGW, do we want the DLL to go in the bin location? +ifeq ($(MINGW_MOVEDLLSTOBINDIR),YES) + $(MKINSTALLDIRS) $(DESTDIR)$(bindir) + $(INSTALL-L) $(FINAL_SO_TARGET) $(DESTDIR)$(bindir) +else $(INSTALL-L) $(FINAL_SO_TARGET) $(DESTDIR)$(libdir) ifneq ($(FINAL_SO_TARGET),$(SO_TARGET)) cd $(DESTDIR)$(libdir) && $(RM) $(notdir $(SO_TARGET)) && ln -s $(notdir $(FINAL_SO_TARGET)) $(notdir $(SO_TARGET)) @@ -108,6 +112,7 @@ ifneq ($(FINAL_SO_TARGET),$(MIDDLE_SO_TARGET)) cd $(DESTDIR)$(libdir) && $(RM) $(notdir $(MIDDLE_SO_TARGET)) && ln -s $(notdir $(FINAL_SO_TARGET)) $(notdir $(MIDDLE_SO_TARGET)) endif endif +endif ifneq ($(IMPORT_LIB_EXT),) $(INSTALL-L) $(FINAL_IMPORT_LIB) $(DESTDIR)$(libdir) ifneq ($(IMPORT_LIB),$(FINAL_IMPORT_LIB)) diff --git a/Build/source/libs/icu/icu-src/source/io/io.vcxproj b/Build/source/libs/icu/icu-src/source/io/io.vcxproj index 3fca55fb0fd..c324236abee 100644 --- a/Build/source/libs/icu/icu-src/source/io/io.vcxproj +++ b/Build/source/libs/icu/icu-src/source/io/io.vcxproj @@ -16,22 +16,6 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> - </ImportGroup> <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> @@ -76,7 +60,7 @@ </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> - <OutputFile>..\..\$(IcuBinOutputDir)\icuio65d.dll</OutputFile> + <OutputFile>..\..\$(IcuBinOutputDir)\icuio68d.dll</OutputFile> <ProgramDatabaseFile>..\..\$(IcuLibOutputDir)\icuiod.pdb</ProgramDatabaseFile> <ImportLibrary>..\..\$(IcuLibOutputDir)\icuiod.lib</ImportLibrary> <AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies> @@ -89,7 +73,7 @@ <FunctionLevelLinking>true</FunctionLevelLinking> </ClCompile> <Link> - <OutputFile>..\..\$(IcuBinOutputDir)\icuio65.dll</OutputFile> + <OutputFile>..\..\$(IcuBinOutputDir)\icuio68.dll</OutputFile> <ProgramDatabaseFile>..\..\$(IcuLibOutputDir)\icuio.pdb</ProgramDatabaseFile> <ImportLibrary>..\..\$(IcuLibOutputDir)\icuio.lib</ImportLibrary> <AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies> diff --git a/Build/source/libs/icu/icu-src/source/io/sources.txt b/Build/source/libs/icu/icu-src/source/io/sources.txt new file mode 100644 index 00000000000..733104399f3 --- /dev/null +++ b/Build/source/libs/icu/icu-src/source/io/sources.txt @@ -0,0 +1,12 @@ +locbund.cpp +sprintf.cpp +sscanf.cpp +ucln_io.cpp +ufile.cpp +ufmt_cmn.cpp +uprintf.cpp +uprntf_p.cpp +uscanf.cpp +uscanf_p.cpp +ustdio.cpp +ustream.cpp diff --git a/Build/source/libs/icu/icu-src/source/io/ucln_io.cpp b/Build/source/libs/icu/icu-src/source/io/ucln_io.cpp index 5cd367cfadb..c1307b5d97f 100644 --- a/Build/source/libs/icu/icu-src/source/io/ucln_io.cpp +++ b/Build/source/libs/icu/icu-src/source/io/ucln_io.cpp @@ -23,7 +23,7 @@ #include "uassert.h" #ifndef U_IO_IMPLEMENTATION -#error U_IO_IMPLEMENTATION not set - must be set for all ICU source files in io/ - see http://userguide.icu-project.org/howtouseicu +#error U_IO_IMPLEMENTATION not set - must be set for all ICU source files in io/ - see https://unicode-org.github.io/icu/userguide/howtouseicu #endif @@ -69,4 +69,3 @@ void ucln_io_registerCleanup(ECleanupIOType type, ucln_registerAutomaticCleanup(); #endif } - diff --git a/Build/source/libs/icu/icu-src/source/io/ufile.cpp b/Build/source/libs/icu/icu-src/source/io/ufile.cpp index 1d8c221cdcb..607601935cf 100644 --- a/Build/source/libs/icu/icu-src/source/io/ufile.cpp +++ b/Build/source/libs/icu/icu-src/source/io/ufile.cpp @@ -40,6 +40,7 @@ #include "unicode/ures.h" #include "unicode/ucnv.h" #include "unicode/ustring.h" +#include "unicode/unistr.h" #include "cstring.h" #include "cmemory.h" @@ -142,18 +143,42 @@ u_fopen(const char *filename, return result; /* not a file leak */ } +// FILENAME_BUF_MAX represents the largest size that we are willing to use for a +// stack-allocated buffer to contain a file name or path. If PATH_MAX (POSIX) or MAX_PATH +// (Windows) are defined and are smaller than this we will use their defined value; +// otherwise, we will use FILENAME_BUF_MAX for the stack-allocated buffer, and dynamically +// allocate a buffer for any file name or path that is that length or longer. +#define FILENAME_BUF_MAX 296 +#if defined PATH_MAX && PATH_MAX < FILENAME_BUF_MAX +#define FILENAME_BUF_CAPACITY PATH_MAX +#elif defined MAX_PATH && MAX_PATH < FILENAME_BUF_MAX +#define FILENAME_BUF_CAPACITY MAX_PATH +#else +#define FILENAME_BUF_CAPACITY FILENAME_BUF_MAX +#endif + U_CAPI UFILE* U_EXPORT2 u_fopen_u(const UChar *filename, const char *perm, const char *locale, const char *codepage) { - UFILE *result; - char buffer[256]; - - u_austrcpy(buffer, filename); + UFILE *result; + char buffer[FILENAME_BUF_CAPACITY]; + char *filenameBuffer = buffer; + + icu::UnicodeString filenameString(true, filename, -1); // readonly aliasing, does not allocate memory + // extract with conversion to platform default codepage, return full length (not including 0 termination) + int32_t filenameLength = filenameString.extract(0, filenameString.length(), filenameBuffer, FILENAME_BUF_CAPACITY); + if (filenameLength >= FILENAME_BUF_CAPACITY) { // could not fit (with zero termination) in buffer + filenameBuffer = static_cast<char *>(uprv_malloc(++filenameLength)); // add one for zero termination + if (!filenameBuffer) { + return nullptr; + } + filenameString.extract(0, filenameString.length(), filenameBuffer, filenameLength); + } - result = u_fopen(buffer, perm, locale, codepage); + result = u_fopen(filenameBuffer, perm, locale, codepage); #if U_PLATFORM_USES_ONLY_WIN32_API /* Try Windows API _wfopen if the above fails. */ if (!result) { @@ -161,20 +186,25 @@ u_fopen_u(const UChar *filename, wchar_t wperm[40] = {}; size_t retVal; mbstowcs_s(&retVal, wperm, UPRV_LENGTHOF(wperm), perm, _TRUNCATE); - FILE *systemFile = _wfopen((const wchar_t *)filename, wperm); + FILE *systemFile = _wfopen(reinterpret_cast<const wchar_t *>(filename), wperm); // may return NULL for long filename if (systemFile) { result = finit_owner(systemFile, locale, codepage, TRUE); } - if (!result) { + if (!result && systemFile) { /* Something bad happened. - Maybe the converter couldn't be opened. */ + Maybe the converter couldn't be opened. + Bu do not fclose(systemFile) if systemFile is NULL. */ fclose(systemFile); } } #endif + if (filenameBuffer != buffer) { + uprv_free(filenameBuffer); + } return result; /* not a file leak */ } + U_CAPI UFILE* U_EXPORT2 u_fstropen(UChar *stringBuf, int32_t capacity, diff --git a/Build/source/libs/icu/icu-src/source/io/ufile.h b/Build/source/libs/icu/icu-src/source/io/ufile.h index e85208fcd35..88fa40911e4 100644 --- a/Build/source/libs/icu/icu-src/source/io/ufile.h +++ b/Build/source/libs/icu/icu-src/source/io/ufile.h @@ -74,7 +74,7 @@ struct UFILE { UChar fUCBuffer[UFILE_UCHARBUFFER_SIZE];/* buffer used for toUnicode */ - UBool fOwnFile; /* TRUE if fFile should be closed */ + UBool fOwnFile; /* true if fFile should be closed */ int32_t fFileno; /* File number. Useful to determine if it's stdin. */ }; @@ -100,7 +100,7 @@ ufile_fill_uchar_buffer(UFILE *f); * Get one code unit and detect whether the end of file has been reached. * @param f The UFILE containing the characters. * @param ch The read in character - * @return TRUE if the character is valid, or FALSE when EOF has been detected + * @return true if the character is valid, or false when EOF has been detected */ U_CFUNC UBool U_EXPORT2 ufile_getch(UFILE *f, UChar *ch); @@ -109,7 +109,7 @@ ufile_getch(UFILE *f, UChar *ch); * Get one character and detect whether the end of file has been reached. * @param f The UFILE containing the characters. * @param ch The read in character - * @return TRUE if the character is valid, or FALSE when EOF has been detected + * @return true if the character is valid, or false when EOF has been detected */ U_CFUNC UBool U_EXPORT2 ufile_getch32(UFILE *f, UChar32 *ch); diff --git a/Build/source/libs/icu/icu-src/source/io/ufmt_cmn.h b/Build/source/libs/icu/icu-src/source/io/ufmt_cmn.h index 33b56a0175c..d040fdce5a9 100644 --- a/Build/source/libs/icu/icu-src/source/io/ufmt_cmn.h +++ b/Build/source/libs/icu/icu-src/source/io/ufmt_cmn.h @@ -82,7 +82,7 @@ ufmt_digitvalue(UChar c); * Determine if a UChar is a digit for a specified radix. * @param c The UChar to check. * @param radix The desired radix. - * @return TRUE if <TT>c</TT> is a digit in <TT>radix</TT>, FALSE otherwise. + * @return true if <TT>c</TT> is a digit in <TT>radix</TT>, false otherwise. */ UBool ufmt_isdigit(UChar c, @@ -95,7 +95,7 @@ ufmt_isdigit(UChar c, * the number of UChars written to <TT>buffer</TT>. * @param value The value to be converted * @param radix The desired radix - * @param uselower TRUE means lower case will be used, FALSE means upper case + * @param uselower true means lower case will be used, false means upper case * @param minDigits The minimum number of digits for for the formatted number, * which will be padded with zeroes. -1 means do not pad. */ diff --git a/Build/source/libs/icu/icu-src/source/io/unicode/ustdio.h b/Build/source/libs/icu/icu-src/source/io/unicode/ustdio.h index 342c2b46045..50a8815e3a7 100644 --- a/Build/source/libs/icu/icu-src/source/io/unicode/ustdio.h +++ b/Build/source/libs/icu/icu-src/source/io/unicode/ustdio.h @@ -30,9 +30,12 @@ #include "unicode/utypes.h" #include "unicode/ucnv.h" #include "unicode/utrans.h" -#include "unicode/localpointer.h" #include "unicode/unum.h" +#if U_SHOW_CPLUSPLUS_API +#include "unicode/localpointer.h" +#endif // U_SHOW_CPLUSPLUS_API + #if !UCONFIG_NO_CONVERSION /* @@ -228,7 +231,7 @@ typedef enum { * That is, data written to a UFILE will be formatted using the conventions * specified by that UFILE's Locale; this data will be in the character set * specified by that UFILE's codepage. - * @param filename The name of the file to open. + * @param filename The name of the file to open. Must be 0-terminated. * @param perm The read/write permission for the UFILE; one of "r", "w", "rw" * @param locale The locale whose conventions will be used to format * and parse output. If this parameter is NULL, the default locale will @@ -239,7 +242,7 @@ typedef enum { * @return A new UFILE, or NULL if an error occurred. * @stable ICU 3.0 */ -U_STABLE UFILE* U_EXPORT2 +U_CAPI UFILE* U_EXPORT2 u_fopen(const char *filename, const char *perm, const char *locale, @@ -251,7 +254,7 @@ u_fopen(const char *filename, * That is, data written to a UFILE will be formatted using the conventions * specified by that UFILE's Locale; this data will be in the character set * specified by that UFILE's codepage. - * @param filename The name of the file to open. + * @param filename The name of the file to open. Must be 0-terminated. * @param perm The read/write permission for the UFILE; one of "r", "w", "rw" * @param locale The locale whose conventions will be used to format * and parse output. If this parameter is NULL, the default locale will @@ -262,7 +265,7 @@ u_fopen(const char *filename, * @return A new UFILE, or NULL if an error occurred. * @stable ICU 54 */ -U_STABLE UFILE* U_EXPORT2 +U_CAPI UFILE* U_EXPORT2 u_fopen_u(const UChar *filename, const char *perm, const char *locale, @@ -284,7 +287,7 @@ u_fopen_u(const UChar *filename, * @return A new UFILE, or NULL if an error occurred. * @stable ICU 3.0 */ -U_STABLE UFILE* U_EXPORT2 +U_CAPI UFILE* U_EXPORT2 u_finit(FILE *f, const char *locale, const char *codepage); @@ -305,7 +308,7 @@ u_finit(FILE *f, * the ownership of the FILE* stream remains with the caller. * @stable ICU 4.4 */ -U_STABLE UFILE* U_EXPORT2 +U_CAPI UFILE* U_EXPORT2 u_fadopt(FILE *f, const char *locale, const char *codepage); @@ -324,7 +327,7 @@ u_fadopt(FILE *f, * @return A new UFILE, or NULL if an error occurred. * @stable ICU 3.0 */ -U_STABLE UFILE* U_EXPORT2 +U_CAPI UFILE* U_EXPORT2 u_fstropen(UChar *stringBuf, int32_t capacity, const char *locale); @@ -335,7 +338,7 @@ u_fstropen(UChar *stringBuf, * @stable ICU 3.0 * @see u_fflush */ -U_STABLE void U_EXPORT2 +U_CAPI void U_EXPORT2 u_fclose(UFILE *file); #if U_SHOW_CPLUSPLUS_API @@ -360,12 +363,12 @@ U_NAMESPACE_END /** * 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 + * @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. * @stable ICU 3.0 */ -U_STABLE UBool U_EXPORT2 +U_CAPI UBool U_EXPORT2 u_feof(UFILE *f); /** @@ -378,7 +381,7 @@ u_feof(UFILE *f); * @param file The UFILE to flush. * @stable ICU 3.0 */ -U_STABLE void U_EXPORT2 +U_CAPI void U_EXPORT2 u_fflush(UFILE *file); /** @@ -386,7 +389,7 @@ u_fflush(UFILE *file); * @param file The UFILE to rewind. * @stable ICU 3.0 */ -U_STABLE void +U_CAPI void u_frewind(UFILE *file); /** @@ -395,7 +398,7 @@ u_frewind(UFILE *file); * @return A FILE*, owned by the UFILE. (The FILE <EM>must not</EM> be modified or closed) * @stable ICU 3.0 */ -U_STABLE FILE* U_EXPORT2 +U_CAPI FILE* U_EXPORT2 u_fgetfile(UFILE *f); #if !UCONFIG_NO_FORMATTING @@ -408,7 +411,7 @@ u_fgetfile(UFILE *f); * @return The locale whose conventions are used to format and parse output. * @stable ICU 3.0 */ -U_STABLE const char* U_EXPORT2 +U_CAPI const char* U_EXPORT2 u_fgetlocale(UFILE *file); /** @@ -419,7 +422,7 @@ u_fgetlocale(UFILE *file); * @return NULL if successful, otherwise a negative number. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_fsetlocale(UFILE *file, const char *locale); @@ -434,7 +437,7 @@ u_fsetlocale(UFILE *file, * or NULL if an error occurred. * @stable ICU 3.0 */ -U_STABLE const char* U_EXPORT2 +U_CAPI const char* U_EXPORT2 u_fgetcodepage(UFILE *file); /** @@ -452,7 +455,7 @@ u_fgetcodepage(UFILE *file); * @see u_frewind * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_fsetcodepage(const char *codepage, UFILE *file); @@ -463,7 +466,7 @@ u_fsetcodepage(const char *codepage, * @return alias to the converter (The converter <EM>must not</EM> be modified or closed) * @stable ICU 3.0 */ -U_STABLE UConverter* U_EXPORT2 u_fgetConverter(UFILE *f); +U_CAPI UConverter* U_EXPORT2 u_fgetConverter(UFILE *f); #if !UCONFIG_NO_FORMATTING /** @@ -472,7 +475,7 @@ U_STABLE UConverter* U_EXPORT2 u_fgetConverter(UFILE *f); * @return alias to the number formatter (The formatter <EM>must not</EM> be modified or closed) * @stable ICU 51 */ - U_STABLE const UNumberFormat* U_EXPORT2 u_fgetNumberFormat(UFILE *f); + U_CAPI const UNumberFormat* U_EXPORT2 u_fgetNumberFormat(UFILE *f); /* Output functions */ @@ -483,7 +486,7 @@ U_STABLE UConverter* U_EXPORT2 u_fgetConverter(UFILE *f); * @return The number of Unicode characters written to <TT>stdout</TT> * @stable ICU 49 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_printf(const char *patternSpecification, ... ); @@ -495,7 +498,7 @@ u_printf(const char *patternSpecification, * @return The number of Unicode characters written to <TT>f</TT>. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_fprintf(UFILE *f, const char *patternSpecification, ... ); @@ -512,7 +515,7 @@ u_fprintf(UFILE *f, * @see u_fprintf * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_vfprintf(UFILE *f, const char *patternSpecification, va_list ap); @@ -524,7 +527,7 @@ u_vfprintf(UFILE *f, * @return The number of Unicode characters written to <TT>stdout</TT> * @stable ICU 49 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_printf_u(const UChar *patternSpecification, ... ); @@ -533,7 +536,7 @@ u_printf_u(const UChar *patternSpecification, * @return UFILE that writes to <TT>stdout</TT> * @stable ICU 49 */ -U_STABLE UFILE * U_EXPORT2 +U_CAPI UFILE * U_EXPORT2 u_get_stdout(void); /** @@ -544,7 +547,7 @@ u_get_stdout(void); * @return The number of Unicode characters written to <TT>f</TT>. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_fprintf_u(UFILE *f, const UChar *patternSpecification, ... ); @@ -561,7 +564,7 @@ u_fprintf_u(UFILE *f, * @see u_fprintf_u * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_vfprintf_u(UFILE *f, const UChar *patternSpecification, va_list ap); @@ -576,7 +579,7 @@ u_vfprintf_u(UFILE *f, * @see u_file_write * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_fputs(const UChar *s, UFILE *f); @@ -587,7 +590,7 @@ u_fputs(const UChar *s, * @return The character written if successful, EOF otherwise. * @stable ICU 3.0 */ -U_STABLE UChar32 U_EXPORT2 +U_CAPI UChar32 U_EXPORT2 u_fputc(UChar32 uc, UFILE *f); @@ -602,7 +605,7 @@ u_fputc(UChar32 uc, * @see u_fputs * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_file_write(const UChar *ustring, int32_t count, UFILE *f); @@ -620,7 +623,7 @@ u_file_write(const UChar *ustring, * if an error occurred. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_fscanf(UFILE *f, const char *patternSpecification, ... ); @@ -638,7 +641,7 @@ u_fscanf(UFILE *f, * @see u_fscanf * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_vfscanf(UFILE *f, const char *patternSpecification, va_list ap); @@ -652,7 +655,7 @@ u_vfscanf(UFILE *f, * if an error occurred. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_fscanf_u(UFILE *f, const UChar *patternSpecification, ... ); @@ -670,7 +673,7 @@ u_fscanf_u(UFILE *f, * @see u_fscanf_u * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_vfscanf_u(UFILE *f, const UChar *patternSpecification, va_list ap); @@ -688,7 +691,7 @@ u_vfscanf_u(UFILE *f, * @return A pointer to <TT>s</TT>, or NULL if no characters were available. * @stable ICU 3.0 */ -U_STABLE UChar* U_EXPORT2 +U_CAPI UChar* U_EXPORT2 u_fgets(UChar *s, int32_t n, UFILE *f); @@ -702,7 +705,7 @@ u_fgets(UChar *s, * @return The UChar value read, or U+FFFF if no character was available. * @stable ICU 3.0 */ -U_STABLE UChar U_EXPORT2 +U_CAPI UChar U_EXPORT2 u_fgetc(UFILE *f); /** @@ -715,7 +718,7 @@ u_fgetc(UFILE *f); * @see u_unescape() * @stable ICU 3.0 */ -U_STABLE UChar32 U_EXPORT2 +U_CAPI UChar32 U_EXPORT2 u_fgetcx(UFILE *f); /** @@ -729,7 +732,7 @@ u_fgetcx(UFILE *f); * @return The UChar32 value put back if successful, U_EOF otherwise. * @stable ICU 3.0 */ -U_STABLE UChar32 U_EXPORT2 +U_CAPI UChar32 U_EXPORT2 u_fungetc(UChar32 c, UFILE *f); @@ -743,7 +746,7 @@ u_fungetc(UChar32 c, * @return The number of Unicode characters read. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_file_read(UChar *chars, int32_t count, UFILE *f); @@ -767,7 +770,7 @@ u_file_read(UChar *chars, * on the result of this function. * @stable ICU 3.0 */ -U_STABLE UTransliterator* U_EXPORT2 +U_CAPI UTransliterator* U_EXPORT2 u_fsettransliterator(UFILE *file, UFileDirection direction, UTransliterator *adopt, UErrorCode *status); @@ -788,7 +791,7 @@ u_fsettransliterator(UFILE *file, UFileDirection direction, * does not include the terminating null character. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_sprintf(UChar *buffer, const char *patternSpecification, ... ); @@ -810,7 +813,7 @@ u_sprintf(UChar *buffer, * the terminating null character. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_snprintf(UChar *buffer, int32_t count, const char *patternSpecification, @@ -829,7 +832,7 @@ u_snprintf(UChar *buffer, * @see u_sprintf * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_vsprintf(UChar *buffer, const char *patternSpecification, va_list ap); @@ -854,7 +857,7 @@ u_vsprintf(UChar *buffer, * @see u_sprintf * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_vsnprintf(UChar *buffer, int32_t count, const char *patternSpecification, @@ -869,7 +872,7 @@ u_vsnprintf(UChar *buffer, * @return The number of Unicode characters written to <TT>buffer</TT>. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_sprintf_u(UChar *buffer, const UChar *patternSpecification, ... ); @@ -890,7 +893,7 @@ u_sprintf_u(UChar *buffer, * <TT>buffer</TT> had count been sufficiently large. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_snprintf_u(UChar *buffer, int32_t count, const UChar *patternSpecification, @@ -909,7 +912,7 @@ u_snprintf_u(UChar *buffer, * @see u_sprintf_u * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_vsprintf_u(UChar *buffer, const UChar *patternSpecification, va_list ap); @@ -934,7 +937,7 @@ u_vsprintf_u(UChar *buffer, * @see u_sprintf_u * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_vsnprintf_u(UChar *buffer, int32_t count, const UChar *patternSpecification, @@ -952,7 +955,7 @@ u_vsnprintf_u(UChar *buffer, * if an error occurred. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_sscanf(const UChar *buffer, const char *patternSpecification, ... ); @@ -971,7 +974,7 @@ u_sscanf(const UChar *buffer, * @see u_sscanf * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_vsscanf(const UChar *buffer, const char *patternSpecification, va_list ap); @@ -986,7 +989,7 @@ u_vsscanf(const UChar *buffer, * if an error occurred. * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_sscanf_u(const UChar *buffer, const UChar *patternSpecification, ... ); @@ -1005,7 +1008,7 @@ u_sscanf_u(const UChar *buffer, * @see u_sscanf_u * @stable ICU 3.0 */ -U_STABLE int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 u_vsscanf_u(const UChar *buffer, const UChar *patternSpecification, va_list ap); diff --git a/Build/source/libs/icu/icu-src/source/io/uscanf_p.cpp b/Build/source/libs/icu/icu-src/source/io/uscanf_p.cpp index 6dc1c09dee7..5bf3e5b7a84 100644 --- a/Build/source/libs/icu/icu-src/source/io/uscanf_p.cpp +++ b/Build/source/libs/icu/icu-src/source/io/uscanf_p.cpp @@ -695,9 +695,10 @@ u_scanf_integer_handler(UFILE *input, int32_t len; void *num = (void*) (args[0].ptrValue); - UNumberFormat *format; + UNumberFormat *format, *localFormat; int32_t parsePos = 0; int32_t skipped; + int32_t parseIntOnly = 0; UErrorCode status = U_ZERO_ERROR; int64_t result; @@ -722,11 +723,20 @@ u_scanf_integer_handler(UFILE *input, if(format == 0) return 0; + /* for integer types, do not attempt to parse fractions */ + localFormat = unum_clone(format, &status); + if(U_FAILURE(status)) + return 0; + + if(info->fSpec == 'd' || info->fSpec == 'i' || info->fSpec == 'u') + parseIntOnly = 1; + unum_setAttribute(localFormat, UNUM_PARSE_INT_ONLY, parseIntOnly); + /* Skip the positive prefix. ICU normally can't handle this due to strict parsing. */ - skipped += u_scanf_skip_leading_positive_sign(input, format, &status); + skipped += u_scanf_skip_leading_positive_sign(input, localFormat, &status); /* parse the number */ - result = unum_parseInt64(format, input->str.fPos, len, &parsePos, &status); + result = unum_parseInt64(localFormat, input->str.fPos, len, &parsePos, &status); /* mask off any necessary bits */ if (!info->fSkipArg) { @@ -741,6 +751,9 @@ u_scanf_integer_handler(UFILE *input, /* update the input's position to reflect consumed data */ input->str.fPos += parsePos; + /* cleanup cloned formatter */ + unum_close(localFormat); + /* we converted 1 arg */ *argConverted = !info->fSkipArg; return parsePos + skipped; |