From 2148e5c2a936b7bd6f7582b0a3b20e2d4b842502 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 22 Nov 2021 16:06:11 +0300 Subject: Release version 65.1.0+6 Fix 'unable to find numeric literal operator' MinGW GCC 11 error Fix outdated URL in comment in libicuuc/build/bootstrap.build Update .gitignore Add symlink attribute for symbolic links that refer to upstream subdirectories Redo libicuio patch to align with libicuuc patches --- libicuio/.gitignore | 5 + libicuio/README-DEV | 17 +- libicuio/build/bootstrap.build | 2 +- libicuio/build/export.build | 2 +- libicuio/libicuio/.gitattributes | 1 + libicuio/libicuio/buildfile | 4 +- libicuio/libicuio/io | 1 + libicuio/libicuio/io/locbund.cpp | 1 - libicuio/libicuio/io/locbund.h | 1 - libicuio/libicuio/io/sprintf.cpp | 1 - libicuio/libicuio/io/sscanf.cpp | 1 - libicuio/libicuio/io/ucln_io.cpp | 1 - libicuio/libicuio/io/ucln_io.h | 1 - libicuio/libicuio/io/ufile.cpp | 337 ----------------------------------- libicuio/libicuio/io/ufile.cpp.patch | 17 -- libicuio/libicuio/io/ufile.h | 1 - libicuio/libicuio/io/ufmt_cmn.cpp | 1 - libicuio/libicuio/io/ufmt_cmn.h | 1 - libicuio/libicuio/io/unicode | 1 - libicuio/libicuio/io/uprintf.cpp | 1 - libicuio/libicuio/io/uprintf.h | 1 - libicuio/libicuio/io/uprntf_p.cpp | 1 - libicuio/libicuio/io/uscanf.cpp | 1 - libicuio/libicuio/io/uscanf.h | 1 - libicuio/libicuio/io/uscanf_p.cpp | 1 - libicuio/libicuio/io/ustdio.cpp | 1 - libicuio/libicuio/io/ustream.cpp | 1 - libicuio/libicuio/ufile.cpp | 337 +++++++++++++++++++++++++++++++++++ libicuio/libicuio/ufile.cpp.patch | 15 ++ libicuio/manifest | 2 +- 30 files changed, 370 insertions(+), 388 deletions(-) create mode 100644 libicuio/libicuio/.gitattributes create mode 120000 libicuio/libicuio/io delete mode 120000 libicuio/libicuio/io/locbund.cpp delete mode 120000 libicuio/libicuio/io/locbund.h delete mode 120000 libicuio/libicuio/io/sprintf.cpp delete mode 120000 libicuio/libicuio/io/sscanf.cpp delete mode 120000 libicuio/libicuio/io/ucln_io.cpp delete mode 120000 libicuio/libicuio/io/ucln_io.h delete mode 100644 libicuio/libicuio/io/ufile.cpp delete mode 100644 libicuio/libicuio/io/ufile.cpp.patch delete mode 120000 libicuio/libicuio/io/ufile.h delete mode 120000 libicuio/libicuio/io/ufmt_cmn.cpp delete mode 120000 libicuio/libicuio/io/ufmt_cmn.h delete mode 120000 libicuio/libicuio/io/unicode delete mode 120000 libicuio/libicuio/io/uprintf.cpp delete mode 120000 libicuio/libicuio/io/uprintf.h delete mode 120000 libicuio/libicuio/io/uprntf_p.cpp delete mode 120000 libicuio/libicuio/io/uscanf.cpp delete mode 120000 libicuio/libicuio/io/uscanf.h delete mode 120000 libicuio/libicuio/io/uscanf_p.cpp delete mode 120000 libicuio/libicuio/io/ustdio.cpp delete mode 120000 libicuio/libicuio/io/ustream.cpp create mode 100644 libicuio/libicuio/ufile.cpp create mode 100644 libicuio/libicuio/ufile.cpp.patch (limited to 'libicuio') diff --git a/libicuio/.gitignore b/libicuio/.gitignore index 4c4fec7..3dcc22f 100644 --- a/libicuio/.gitignore +++ b/libicuio/.gitignore @@ -3,9 +3,14 @@ *.d *.t *.i +*.i.* *.ii +*.ii.* *.o *.obj +*.gcm +*.pcm +*.ifc *.so *.so.* *.dll diff --git a/libicuio/README-DEV b/libicuio/README-DEV index 733d50b..8cd01d9 100644 --- a/libicuio/README-DEV +++ b/libicuio/README-DEV @@ -2,18 +2,11 @@ This document describes how libicuio was packaged for build2. In particular, this understanding will be useful when upgrading to a new upstream version. See ../README-DEV for general notes on ICU packaging. -Symlink the required upstream files and directories into libicuio/io/ and -apply a patch that fixes the 'unable to find numeric literal operator' GCC 11 -error: +Symlink the required upstream directories into libicuio/: -$ mkdir libicuio/io -$ pushd libicuio/io -$ ln -s ../../../upstream/icu4c/source/io/{*.{h,cpp},unicode} ./ -$ rm ufile.cpp -$ cp ../../../upstream/icu4c/source/io/ufile.cpp ./ -$ git apply ufile.cpp.patch -$ popd +$ ln -s ../../upstream/icu4c/source/io libicuio -Note that the patch is produces by the following command: +Fix the 'unable to find numeric literal operator' GCC 11 error: -$ git diff >ufile.cpp.patch +$ cp libicuio/io/ufile.cpp libicuio +$ patch -p0 - -#include "ufile.h" -#include "unicode/uloc.h" -#include "unicode/ures.h" -#include "unicode/ucnv.h" -#include "unicode/ustring.h" -#include "cstring.h" -#include "cmemory.h" - -#if U_PLATFORM_USES_ONLY_WIN32_API && !defined(fileno) -/* Windows likes to rename Unix-like functions */ -#define fileno _fileno -#endif - -static UFILE* -finit_owner(FILE *f, - const char *locale, - const char *codepage, - UBool takeOwnership - ) -{ - UErrorCode status = U_ZERO_ERROR; - UFILE *result; - if(f == NULL) { - return 0; - } - result = (UFILE*) uprv_malloc(sizeof(UFILE)); - if(result == NULL) { - return 0; - } - - uprv_memset(result, 0, sizeof(UFILE)); - result->fFileno = fileno(f); - result->fFile = f; - - result->str.fBuffer = result->fUCBuffer; - result->str.fPos = result->fUCBuffer; - result->str.fLimit = result->fUCBuffer; - -#if !UCONFIG_NO_FORMATTING - /* if locale is 0, use the default */ - if(u_locbund_init(&result->str.fBundle, locale) == 0) { - /* DO NOT FCLOSE HERE! */ - uprv_free(result); - return 0; - } -#endif - - /* If the codepage is not "" use the ucnv_open default behavior */ - if(codepage == NULL || *codepage != '\0') { - result->fConverter = ucnv_open(codepage, &status); - } - /* else result->fConverter is already memset'd to NULL. */ - - if(U_SUCCESS(status)) { - result->fOwnFile = takeOwnership; - } - else { -#if !UCONFIG_NO_FORMATTING - u_locbund_close(&result->str.fBundle); -#endif - /* DO NOT fclose here!!!!!! */ - uprv_free(result); - result = NULL; - } - - return result; -} - -U_CAPI UFILE* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_finit(FILE *f, - const char *locale, - const char *codepage) -{ - return finit_owner(f, locale, codepage, FALSE); -} - -U_CAPI UFILE* U_EXPORT2 -u_fadopt(FILE *f, - const char *locale, - const char *codepage) -{ - return finit_owner(f, locale, codepage, TRUE); -} - -U_CAPI UFILE* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_fopen(const char *filename, - const char *perm, - const char *locale, - const char *codepage) -{ - UFILE *result; - FILE *systemFile = fopen(filename, perm); - if(systemFile == 0) { - return 0; - } - - result = finit_owner(systemFile, locale, codepage, TRUE); - - if (!result) { - /* Something bad happened. - Maybe the converter couldn't be opened. */ - fclose(systemFile); - } - - return result; /* not a file leak */ -} - -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); - - result = u_fopen(buffer, perm, locale, codepage); -#if U_PLATFORM_USES_ONLY_WIN32_API - /* Try Windows API _wfopen if the above fails. */ - if (!result) { - // TODO: test this code path, including wperm. - wchar_t wperm[40] = {}; - size_t retVal; - mbstowcs_s(&retVal, wperm, UPRV_LENGTHOF(wperm), perm, _TRUNCATE); - FILE *systemFile = _wfopen((const wchar_t *)filename, wperm); - if (systemFile) { - result = finit_owner(systemFile, locale, codepage, TRUE); - } - if (!result) { - /* Something bad happened. - Maybe the converter couldn't be opened. */ - fclose(systemFile); - } - } -#endif - return result; /* not a file leak */ -} - -U_CAPI UFILE* U_EXPORT2 -u_fstropen(UChar *stringBuf, - int32_t capacity, - const char *locale) -{ - UFILE *result; - - if (capacity < 0) { - return NULL; - } - - result = (UFILE*) uprv_malloc(sizeof(UFILE)); - /* Null pointer test */ - if (result == NULL) { - return NULL; /* Just get out. */ - } - uprv_memset(result, 0, sizeof(UFILE)); - result->str.fBuffer = stringBuf; - result->str.fPos = stringBuf; - result->str.fLimit = stringBuf+capacity; - -#if !UCONFIG_NO_FORMATTING - /* if locale is 0, use the default */ - if(u_locbund_init(&result->str.fBundle, locale) == 0) { - /* DO NOT FCLOSE HERE! */ - uprv_free(result); - return 0; - } -#endif - - 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); - ufile_flush_io(file); - if (file->fFile) { - fflush(file->fFile); - } - else if (file->str.fPos < file->str.fLimit) { - *(file->str.fPos++) = 0; - } - /* TODO: flush input */ -} - -U_CAPI void -u_frewind(UFILE *file) -{ - u_fflush(file); - ucnv_reset(file->fConverter); - if (file->fFile) { - rewind(file->fFile); - file->str.fLimit = file->fUCBuffer; - file->str.fPos = file->fUCBuffer; - } - else { - file->str.fPos = file->str.fBuffer; - } -} - -U_CAPI void U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_fclose(UFILE *file) -{ - if (file) { - u_fflush(file); - ufile_close_translit(file); - - if(file->fOwnFile) - fclose(file->fFile); - -#if !UCONFIG_NO_FORMATTING - u_locbund_close(&file->str.fBundle); -#endif - - ucnv_close(file->fConverter); - uprv_free(file); - } -} - -U_CAPI FILE* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_fgetfile( UFILE *f) -{ - return f->fFile; -} - -#if !UCONFIG_NO_FORMATTING - -U_CAPI const char* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_fgetlocale( UFILE *file) -{ - return file->str.fBundle.fLocale; -} - -U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_fsetlocale(UFILE *file, - const char *locale) -{ - u_locbund_close(&file->str.fBundle); - - return u_locbund_init(&file->str.fBundle, locale) == 0 ? -1 : 0; -} - -#endif - -U_CAPI const char* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_fgetcodepage(UFILE *file) -{ - UErrorCode status = U_ZERO_ERROR; - const char *codepage = NULL; - - if (file->fConverter) { - codepage = ucnv_getName(file->fConverter, &status); - if(U_FAILURE(status)) - return 0; - } - return codepage; -} - -U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_fsetcodepage( const char *codepage, - UFILE *file) -{ - UErrorCode status = U_ZERO_ERROR; - int32_t retVal = -1; - - /* We use the normal default codepage for this system, and not the one for the locale. */ - if ((file->str.fPos == file->str.fBuffer) && (file->str.fLimit == file->str.fBuffer)) { - ucnv_close(file->fConverter); - file->fConverter = ucnv_open(codepage, &status); - if(U_SUCCESS(status)) { - retVal = 0; - } - } - return retVal; -} - - -U_CAPI UConverter * U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ -u_fgetConverter(UFILE *file) -{ - return file->fConverter; -} -#if !UCONFIG_NO_FORMATTING -U_CAPI const UNumberFormat* U_EXPORT2 u_fgetNumberFormat(UFILE *file) -{ - return u_locbund_getNumberFormat(&file->str.fBundle, UNUM_DECIMAL); -} -#endif - -#endif diff --git a/libicuio/libicuio/io/ufile.cpp.patch b/libicuio/libicuio/io/ufile.cpp.patch deleted file mode 100644 index b0e8acd..0000000 --- a/libicuio/libicuio/io/ufile.cpp.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/libicuio/libicuio/io/ufile.cpp b/libicuio/libicuio/io/ufile.cpp -index 1d8c221..2c00d21 100644 ---- a/libicuio/libicuio/io/ufile.cpp -+++ b/libicuio/libicuio/io/ufile.cpp -@@ -21,12 +21,6 @@ - */ - - #include "unicode/platform.h" --#if defined(__GNUC__) && !defined(__clang__) && defined(__STRICT_ANSI__) --// g++, fileno isn't defined if __STRICT_ANSI__ is defined. --// clang fails to compile the header unless __STRICT_ANSI__ is defined. --// __GNUC__ is set by both gcc and clang. --#undef __STRICT_ANSI__ --#endif - - #include "locmap.h" - #include "unicode/ustdio.h" diff --git a/libicuio/libicuio/io/ufile.h b/libicuio/libicuio/io/ufile.h deleted file mode 120000 index 8b66131..0000000 --- a/libicuio/libicuio/io/ufile.h +++ /dev/null @@ -1 +0,0 @@ -../../../upstream/icu4c/source/io/ufile.h \ No newline at end of file diff --git a/libicuio/libicuio/io/ufmt_cmn.cpp b/libicuio/libicuio/io/ufmt_cmn.cpp deleted file mode 120000 index c45c1dc..0000000 --- a/libicuio/libicuio/io/ufmt_cmn.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../upstream/icu4c/source/io/ufmt_cmn.cpp \ No newline at end of file diff --git a/libicuio/libicuio/io/ufmt_cmn.h b/libicuio/libicuio/io/ufmt_cmn.h deleted file mode 120000 index 9f446f2..0000000 --- a/libicuio/libicuio/io/ufmt_cmn.h +++ /dev/null @@ -1 +0,0 @@ -../../../upstream/icu4c/source/io/ufmt_cmn.h \ No newline at end of file diff --git a/libicuio/libicuio/io/unicode b/libicuio/libicuio/io/unicode deleted file mode 120000 index affdbc2..0000000 --- a/libicuio/libicuio/io/unicode +++ /dev/null @@ -1 +0,0 @@ -../../../upstream/icu4c/source/io/unicode \ No newline at end of file diff --git a/libicuio/libicuio/io/uprintf.cpp b/libicuio/libicuio/io/uprintf.cpp deleted file mode 120000 index c733ad9..0000000 --- a/libicuio/libicuio/io/uprintf.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../upstream/icu4c/source/io/uprintf.cpp \ No newline at end of file diff --git a/libicuio/libicuio/io/uprintf.h b/libicuio/libicuio/io/uprintf.h deleted file mode 120000 index 89bf0ec..0000000 --- a/libicuio/libicuio/io/uprintf.h +++ /dev/null @@ -1 +0,0 @@ -../../../upstream/icu4c/source/io/uprintf.h \ No newline at end of file diff --git a/libicuio/libicuio/io/uprntf_p.cpp b/libicuio/libicuio/io/uprntf_p.cpp deleted file mode 120000 index 5269327..0000000 --- a/libicuio/libicuio/io/uprntf_p.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../upstream/icu4c/source/io/uprntf_p.cpp \ No newline at end of file diff --git a/libicuio/libicuio/io/uscanf.cpp b/libicuio/libicuio/io/uscanf.cpp deleted file mode 120000 index 42692fd..0000000 --- a/libicuio/libicuio/io/uscanf.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../upstream/icu4c/source/io/uscanf.cpp \ No newline at end of file diff --git a/libicuio/libicuio/io/uscanf.h b/libicuio/libicuio/io/uscanf.h deleted file mode 120000 index 660b9c5..0000000 --- a/libicuio/libicuio/io/uscanf.h +++ /dev/null @@ -1 +0,0 @@ -../../../upstream/icu4c/source/io/uscanf.h \ No newline at end of file diff --git a/libicuio/libicuio/io/uscanf_p.cpp b/libicuio/libicuio/io/uscanf_p.cpp deleted file mode 120000 index f0eb6f7..0000000 --- a/libicuio/libicuio/io/uscanf_p.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../upstream/icu4c/source/io/uscanf_p.cpp \ No newline at end of file diff --git a/libicuio/libicuio/io/ustdio.cpp b/libicuio/libicuio/io/ustdio.cpp deleted file mode 120000 index 8dc47e8..0000000 --- a/libicuio/libicuio/io/ustdio.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../upstream/icu4c/source/io/ustdio.cpp \ No newline at end of file diff --git a/libicuio/libicuio/io/ustream.cpp b/libicuio/libicuio/io/ustream.cpp deleted file mode 120000 index 91304b4..0000000 --- a/libicuio/libicuio/io/ustream.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../upstream/icu4c/source/io/ustream.cpp \ No newline at end of file diff --git a/libicuio/libicuio/ufile.cpp b/libicuio/libicuio/ufile.cpp new file mode 100644 index 0000000..2c00d21 --- /dev/null +++ b/libicuio/libicuio/ufile.cpp @@ -0,0 +1,337 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html +/* +****************************************************************************** +* +* Copyright (C) 1998-2015, International Business Machines +* Corporation and others. All Rights Reserved. +* +****************************************************************************** +* +* File ufile.cpp +* +* Modification History: +* +* Date Name Description +* 11/19/98 stephen Creation. +* 03/12/99 stephen Modified for new C API. +* 06/16/99 stephen Changed T_LocaleBundle to u_locbund +* 07/19/99 stephen Fixed to use ucnv's default codepage. +****************************************************************************** +*/ + +#include "unicode/platform.h" + +#include "locmap.h" +#include "unicode/ustdio.h" + +#if !UCONFIG_NO_CONVERSION + +#include + +#include "ufile.h" +#include "unicode/uloc.h" +#include "unicode/ures.h" +#include "unicode/ucnv.h" +#include "unicode/ustring.h" +#include "cstring.h" +#include "cmemory.h" + +#if U_PLATFORM_USES_ONLY_WIN32_API && !defined(fileno) +/* Windows likes to rename Unix-like functions */ +#define fileno _fileno +#endif + +static UFILE* +finit_owner(FILE *f, + const char *locale, + const char *codepage, + UBool takeOwnership + ) +{ + UErrorCode status = U_ZERO_ERROR; + UFILE *result; + if(f == NULL) { + return 0; + } + result = (UFILE*) uprv_malloc(sizeof(UFILE)); + if(result == NULL) { + return 0; + } + + uprv_memset(result, 0, sizeof(UFILE)); + result->fFileno = fileno(f); + result->fFile = f; + + result->str.fBuffer = result->fUCBuffer; + result->str.fPos = result->fUCBuffer; + result->str.fLimit = result->fUCBuffer; + +#if !UCONFIG_NO_FORMATTING + /* if locale is 0, use the default */ + if(u_locbund_init(&result->str.fBundle, locale) == 0) { + /* DO NOT FCLOSE HERE! */ + uprv_free(result); + return 0; + } +#endif + + /* If the codepage is not "" use the ucnv_open default behavior */ + if(codepage == NULL || *codepage != '\0') { + result->fConverter = ucnv_open(codepage, &status); + } + /* else result->fConverter is already memset'd to NULL. */ + + if(U_SUCCESS(status)) { + result->fOwnFile = takeOwnership; + } + else { +#if !UCONFIG_NO_FORMATTING + u_locbund_close(&result->str.fBundle); +#endif + /* DO NOT fclose here!!!!!! */ + uprv_free(result); + result = NULL; + } + + return result; +} + +U_CAPI UFILE* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ +u_finit(FILE *f, + const char *locale, + const char *codepage) +{ + return finit_owner(f, locale, codepage, FALSE); +} + +U_CAPI UFILE* U_EXPORT2 +u_fadopt(FILE *f, + const char *locale, + const char *codepage) +{ + return finit_owner(f, locale, codepage, TRUE); +} + +U_CAPI UFILE* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ +u_fopen(const char *filename, + const char *perm, + const char *locale, + const char *codepage) +{ + UFILE *result; + FILE *systemFile = fopen(filename, perm); + if(systemFile == 0) { + return 0; + } + + result = finit_owner(systemFile, locale, codepage, TRUE); + + if (!result) { + /* Something bad happened. + Maybe the converter couldn't be opened. */ + fclose(systemFile); + } + + return result; /* not a file leak */ +} + +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); + + result = u_fopen(buffer, perm, locale, codepage); +#if U_PLATFORM_USES_ONLY_WIN32_API + /* Try Windows API _wfopen if the above fails. */ + if (!result) { + // TODO: test this code path, including wperm. + wchar_t wperm[40] = {}; + size_t retVal; + mbstowcs_s(&retVal, wperm, UPRV_LENGTHOF(wperm), perm, _TRUNCATE); + FILE *systemFile = _wfopen((const wchar_t *)filename, wperm); + if (systemFile) { + result = finit_owner(systemFile, locale, codepage, TRUE); + } + if (!result) { + /* Something bad happened. + Maybe the converter couldn't be opened. */ + fclose(systemFile); + } + } +#endif + return result; /* not a file leak */ +} + +U_CAPI UFILE* U_EXPORT2 +u_fstropen(UChar *stringBuf, + int32_t capacity, + const char *locale) +{ + UFILE *result; + + if (capacity < 0) { + return NULL; + } + + result = (UFILE*) uprv_malloc(sizeof(UFILE)); + /* Null pointer test */ + if (result == NULL) { + return NULL; /* Just get out. */ + } + uprv_memset(result, 0, sizeof(UFILE)); + result->str.fBuffer = stringBuf; + result->str.fPos = stringBuf; + result->str.fLimit = stringBuf+capacity; + +#if !UCONFIG_NO_FORMATTING + /* if locale is 0, use the default */ + if(u_locbund_init(&result->str.fBundle, locale) == 0) { + /* DO NOT FCLOSE HERE! */ + uprv_free(result); + return 0; + } +#endif + + 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); + ufile_flush_io(file); + if (file->fFile) { + fflush(file->fFile); + } + else if (file->str.fPos < file->str.fLimit) { + *(file->str.fPos++) = 0; + } + /* TODO: flush input */ +} + +U_CAPI void +u_frewind(UFILE *file) +{ + u_fflush(file); + ucnv_reset(file->fConverter); + if (file->fFile) { + rewind(file->fFile); + file->str.fLimit = file->fUCBuffer; + file->str.fPos = file->fUCBuffer; + } + else { + file->str.fPos = file->str.fBuffer; + } +} + +U_CAPI void U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ +u_fclose(UFILE *file) +{ + if (file) { + u_fflush(file); + ufile_close_translit(file); + + if(file->fOwnFile) + fclose(file->fFile); + +#if !UCONFIG_NO_FORMATTING + u_locbund_close(&file->str.fBundle); +#endif + + ucnv_close(file->fConverter); + uprv_free(file); + } +} + +U_CAPI FILE* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ +u_fgetfile( UFILE *f) +{ + return f->fFile; +} + +#if !UCONFIG_NO_FORMATTING + +U_CAPI const char* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ +u_fgetlocale( UFILE *file) +{ + return file->str.fBundle.fLocale; +} + +U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ +u_fsetlocale(UFILE *file, + const char *locale) +{ + u_locbund_close(&file->str.fBundle); + + return u_locbund_init(&file->str.fBundle, locale) == 0 ? -1 : 0; +} + +#endif + +U_CAPI const char* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ +u_fgetcodepage(UFILE *file) +{ + UErrorCode status = U_ZERO_ERROR; + const char *codepage = NULL; + + if (file->fConverter) { + codepage = ucnv_getName(file->fConverter, &status); + if(U_FAILURE(status)) + return 0; + } + return codepage; +} + +U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ +u_fsetcodepage( const char *codepage, + UFILE *file) +{ + UErrorCode status = U_ZERO_ERROR; + int32_t retVal = -1; + + /* We use the normal default codepage for this system, and not the one for the locale. */ + if ((file->str.fPos == file->str.fBuffer) && (file->str.fLimit == file->str.fBuffer)) { + ucnv_close(file->fConverter); + file->fConverter = ucnv_open(codepage, &status); + if(U_SUCCESS(status)) { + retVal = 0; + } + } + return retVal; +} + + +U_CAPI UConverter * U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */ +u_fgetConverter(UFILE *file) +{ + return file->fConverter; +} +#if !UCONFIG_NO_FORMATTING +U_CAPI const UNumberFormat* U_EXPORT2 u_fgetNumberFormat(UFILE *file) +{ + return u_locbund_getNumberFormat(&file->str.fBundle, UNUM_DECIMAL); +} +#endif + +#endif diff --git a/libicuio/libicuio/ufile.cpp.patch b/libicuio/libicuio/ufile.cpp.patch new file mode 100644 index 0000000..9397298 --- /dev/null +++ b/libicuio/libicuio/ufile.cpp.patch @@ -0,0 +1,15 @@ +--- libicuio/io/ufile.cpp 2019-12-23 14:38:40.255889178 +0300 ++++ libicuio/ufile.cpp 2021-11-22 10:50:17.658962827 +0300 +@@ -21,12 +21,6 @@ + */ + + #include "unicode/platform.h" +-#if defined(__GNUC__) && !defined(__clang__) && defined(__STRICT_ANSI__) +-// g++, fileno isn't defined if __STRICT_ANSI__ is defined. +-// clang fails to compile the header unless __STRICT_ANSI__ is defined. +-// __GNUC__ is set by both gcc and clang. +-#undef __STRICT_ANSI__ +-#endif + + #include "locmap.h" + #include "unicode/ustdio.h" diff --git a/libicuio/manifest b/libicuio/manifest index 4c1c8e8..c0eac20 100644 --- a/libicuio/manifest +++ b/libicuio/manifest @@ -1,6 +1,6 @@ : 1 name: libicuio -version: 65.1.0+5 +version: 65.1.0+6 upstream-version: 65.1 project: icu summary: ICU input/output C/C++ library -- cgit v1.1