deps: update icu to 75.1 · nodejs/node@5b52a48 · GitHub
Skip to content

Commit 5b52a48

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update icu to 75.1
PR-URL: #52573 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent a93f5d4 commit 5b52a48

408 files changed

Lines changed: 25369 additions & 12777 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

deps/icu-small/LICENSE

Lines changed: 3 additions & 1 deletion

deps/icu-small/README-FULL-ICU.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ICU sources - auto generated by shrink-icu-src.py
22

33
This directory contains the ICU subset used by --with-intl=full-icu
4-
It is a strict subset of ICU 74 source files with the following exception(s):
5-
* deps/icu-small/source/data/in/icudt74l.dat.bz2 : compressed data file
4+
It is a strict subset of ICU 75 source files with the following exception(s):
5+
* deps/icu-small/source/data/in/icudt75l.dat.bz2 : compressed data file
66

77

88
To rebuild this directory, see ../../tools/icu/README.md

deps/icu-small/source/common/brkeng.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,11 @@ UnhandledEngine::handleCharacter(UChar32 c) {
114114
*/
115115

116116
ICULanguageBreakFactory::ICULanguageBreakFactory(UErrorCode &/*status*/) {
117-
fEngines = 0;
117+
fEngines = nullptr;
118118
}
119119

120120
ICULanguageBreakFactory::~ICULanguageBreakFactory() {
121-
if (fEngines != 0) {
122-
delete fEngines;
123-
}
121+
delete fEngines;
124122
}
125123

126124
void ICULanguageBreakFactory::ensureEngines(UErrorCode& status) {

deps/icu-small/source/common/brkiter.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,17 +438,14 @@ BreakIterator::makeInstance(const Locale& loc, int32_t kind, UErrorCode& status)
438438
UTRACE_ENTRY(UTRACE_UBRK_CREATE_LINE);
439439
uprv_strcpy(lb_lw, "line");
440440
UErrorCode kvStatus = U_ZERO_ERROR;
441-
CharString value;
442-
CharStringByteSink valueSink(&value);
443-
loc.getKeywordValue("lb", valueSink, kvStatus);
441+
auto value = loc.getKeywordValue<CharString>("lb", kvStatus);
444442
if (U_SUCCESS(kvStatus) && (value == "strict" || value == "normal" || value == "loose")) {
445443
uprv_strcat(lb_lw, "_");
446444
uprv_strcat(lb_lw, value.data());
447445
}
448446
// lw=phrase is only supported in Japanese and Korean
449447
if (uprv_strcmp(loc.getLanguage(), "ja") == 0 || uprv_strcmp(loc.getLanguage(), "ko") == 0) {
450-
value.clear();
451-
loc.getKeywordValue("lw", valueSink, kvStatus);
448+
value = loc.getKeywordValue<CharString>("lw", kvStatus);
452449
if (U_SUCCESS(kvStatus) && value == "phrase") {
453450
uprv_strcat(lb_lw, "_");
454451
uprv_strcat(lb_lw, value.data());
@@ -500,7 +497,7 @@ BreakIterator::makeInstance(const Locale& loc, int32_t kind, UErrorCode& status)
500497
Locale
501498
BreakIterator::getLocale(ULocDataLocaleType type, UErrorCode& status) const {
502499
if (type == ULOC_REQUESTED_LOCALE) {
503-
return Locale(requestLocale);
500+
return {requestLocale};
504501
}
505502
U_LOCALE_BASED(locBased, *this);
506503
return locBased.getLocale(type, status);

deps/icu-small/source/common/bytesinkutil.h

Lines changed: 90 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,52 @@
77
#ifndef BYTESINKUTIL_H
88
#define BYTESINKUTIL_H
99

10+
#include <type_traits>
11+
1012
#include "unicode/utypes.h"
1113
#include "unicode/bytestream.h"
1214
#include "unicode/edits.h"
15+
#include "charstr.h"
1316
#include "cmemory.h"
1417
#include "uassert.h"
18+
#include "ustr_imp.h"
1519

1620
U_NAMESPACE_BEGIN
1721

1822
class ByteSink;
19-
class CharString;
2023
class Edits;
2124

25+
class U_COMMON_API CharStringByteSink : public ByteSink {
26+
public:
27+
CharStringByteSink(CharString* dest);
28+
~CharStringByteSink() override;
29+
30+
CharStringByteSink() = delete;
31+
CharStringByteSink(const CharStringByteSink&) = delete;
32+
CharStringByteSink& operator=(const CharStringByteSink&) = delete;
33+
34+
void Append(const char* bytes, int32_t n) override;
35+
36+
char* GetAppendBuffer(int32_t min_capacity,
37+
int32_t desired_capacity_hint,
38+
char* scratch,
39+
int32_t scratch_capacity,
40+
int32_t* result_capacity) override;
41+
42+
private:
43+
CharString& dest_;
44+
};
45+
46+
// CharString doesn't provide the public API that StringByteSink requires a
47+
// string class to have so this template specialization replaces the default
48+
// implementation of StringByteSink<CharString> with CharStringByteSink.
49+
template<>
50+
class StringByteSink<CharString> : public CharStringByteSink {
51+
public:
52+
StringByteSink(CharString* dest) : CharStringByteSink(dest) { }
53+
StringByteSink(CharString* dest, int32_t /*initialAppendCapacity*/) : CharStringByteSink(dest) { }
54+
};
55+
2256
class U_COMMON_API ByteSinkUtil {
2357
public:
2458
ByteSinkUtil() = delete; // all static
@@ -57,30 +91,64 @@ class U_COMMON_API ByteSinkUtil {
5791
ByteSink &sink, uint32_t options, Edits *edits,
5892
UErrorCode &errorCode);
5993

60-
private:
61-
static void appendNonEmptyUnchanged(const uint8_t *s, int32_t length,
62-
ByteSink &sink, uint32_t options, Edits *edits);
63-
};
64-
65-
class U_COMMON_API CharStringByteSink : public ByteSink {
66-
public:
67-
CharStringByteSink(CharString* dest);
68-
~CharStringByteSink() override;
69-
70-
CharStringByteSink() = delete;
71-
CharStringByteSink(const CharStringByteSink&) = delete;
72-
CharStringByteSink& operator=(const CharStringByteSink&) = delete;
73-
74-
void Append(const char* bytes, int32_t n) override;
94+
/**
95+
* Calls a lambda that writes to a ByteSink with a CheckedArrayByteSink
96+
* and then returns through u_terminateChars(), in order to implement
97+
* the classic ICU4C C API writing to a fix sized buffer on top of a
98+
* contemporary C++ API.
99+
*
100+
* @param buffer receiving buffer
101+
* @param capacity capacity of receiving buffer
102+
* @param lambda that gets called with the sink as an argument
103+
* @param status set to U_BUFFER_OVERFLOW_ERROR on overflow
104+
* @return number of bytes written, or needed (in case of overflow)
105+
* @internal
106+
*/
107+
template <typename F,
108+
typename = std::enable_if_t<
109+
std::is_invocable_r_v<void, F, ByteSink&, UErrorCode&>>>
110+
static int32_t viaByteSinkToTerminatedChars(char* buffer, int32_t capacity,
111+
F&& lambda,
112+
UErrorCode& status) {
113+
if (U_FAILURE(status)) { return 0; }
114+
CheckedArrayByteSink sink(buffer, capacity);
115+
lambda(sink, status);
116+
if (U_FAILURE(status)) { return 0; }
117+
118+
int32_t reslen = sink.NumberOfBytesAppended();
119+
120+
if (sink.Overflowed()) {
121+
status = U_BUFFER_OVERFLOW_ERROR;
122+
return reslen;
123+
}
124+
125+
return u_terminateChars(buffer, capacity, reslen, &status);
126+
}
75127

76-
char* GetAppendBuffer(int32_t min_capacity,
77-
int32_t desired_capacity_hint,
78-
char* scratch,
79-
int32_t scratch_capacity,
80-
int32_t* result_capacity) override;
128+
/**
129+
* Calls a lambda that writes to a ByteSink with a CharStringByteSink and
130+
* then returns a CharString, in order to implement a contemporary C++ API
131+
* on top of a C/C++ compatibility ByteSink API.
132+
*
133+
* @param lambda that gets called with the sink as an argument
134+
* @param status to check and report
135+
* @return the resulting string, or an empty string (in case of error)
136+
* @internal
137+
*/
138+
template <typename F,
139+
typename = std::enable_if_t<
140+
std::is_invocable_r_v<void, F, ByteSink&, UErrorCode&>>>
141+
static CharString viaByteSinkToCharString(F&& lambda, UErrorCode& status) {
142+
if (U_FAILURE(status)) { return {}; }
143+
CharString result;
144+
CharStringByteSink sink(&result);
145+
lambda(sink, status);
146+
return result;
147+
}
81148

82149
private:
83-
CharString& dest_;
150+
static void appendNonEmptyUnchanged(const uint8_t *s, int32_t length,
151+
ByteSink &sink, uint32_t options, Edits *edits);
84152
};
85153

86154
U_NAMESPACE_END

deps/icu-small/source/common/caniter.cpp

Lines changed: 29 additions & 21 deletions

0 commit comments

Comments
 (0)