Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions deps/icu-small/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -540,3 +540,29 @@ publicity pertaining to distribution of the software without specific,
written prior permission. M.I.T. makes no representations about the
suitability of this software for any purpose. It is provided "as is"
without express or implied warranty.

----------------------------------------------------------------------

File: sorttable.js (only for ICU4J)

The MIT Licence, for code from kryogenix.org

Code downloaded from the Browser Experiments section of kryogenix.org is
licenced under the so-called MIT licence. The licence is below.

Copyright (c) 1997-date Stuart Langridge

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 2 additions & 2 deletions deps/icu-small/README-FULL-ICU.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ICU sources - auto generated by shrink-icu-src.py

This directory contains the ICU subset used by --with-intl=full-icu
It is a strict subset of ICU 77 source files with the following exception(s):
* deps/icu-small/source/data/in/icudt77l.dat.bz2 : compressed data file
It is a strict subset of ICU 78 source files with the following exception(s):
* deps/icu-small/source/data/in/icudt78l.dat.bz2 : compressed data file


To rebuild this directory, see ../../tools/icu/README.md
Expand Down
1 change: 1 addition & 0 deletions deps/icu-small/source/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ cc_library(
"umutex.cpp",
"sharedobject.cpp",
"utrace.cpp",
"fixedstring.cpp",
],
deps = [
":headers",
Expand Down
47 changes: 18 additions & 29 deletions deps/icu-small/source/common/brkiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,9 @@ BreakIterator::buildInstance(const Locale& loc, const char *type, UErrorCode &st

// If there is a result, set the valid locale and actual locale, and the kind
if (U_SUCCESS(status) && result != nullptr) {
U_LOCALE_BASED(locBased, *(BreakIterator*)result);

locBased.setLocaleIDs(ures_getLocaleByType(b, ULOC_VALID_LOCALE, &status),
actual.data(), status);
LocaleBased::setLocaleID(loc.getName(), result->requestLocale, status);
result->actualLocale = Locale(actual.data());
result->validLocale = Locale(ures_getLocaleByType(b, ULOC_VALID_LOCALE, &status));
result->requestLocale = loc;
}

ures_close(b);
Expand Down Expand Up @@ -204,33 +202,28 @@ BreakIterator::getAvailableLocales(int32_t& count)
//-------------------------------------------

BreakIterator::BreakIterator()
: actualLocale(Locale::getRoot()), validLocale(Locale::getRoot()), requestLocale(Locale::getRoot())
{
}

BreakIterator::BreakIterator(const BreakIterator &other) : UObject(other) {
UErrorCode status = U_ZERO_ERROR;
U_LOCALE_BASED(locBased, *this);
locBased.setLocaleIDs(other.validLocale, other.actualLocale, status);
LocaleBased::setLocaleID(other.requestLocale, requestLocale, status);
U_ASSERT(U_SUCCESS(status));
BreakIterator::BreakIterator(const BreakIterator &other)
: UObject(other),
actualLocale(other.actualLocale),
validLocale(other.validLocale),
requestLocale(other.requestLocale) {
}

BreakIterator &BreakIterator::operator =(const BreakIterator &other) {
if (this != &other) {
UErrorCode status = U_ZERO_ERROR;
U_LOCALE_BASED(locBased, *this);
locBased.setLocaleIDs(other.validLocale, other.actualLocale, status);
LocaleBased::setLocaleID(other.requestLocale, requestLocale, status);
U_ASSERT(U_SUCCESS(status));
actualLocale = other.actualLocale;
validLocale = other.validLocale;
requestLocale = other.requestLocale;
}
return *this;
}

BreakIterator::~BreakIterator()
{
delete validLocale;
delete actualLocale;
delete requestLocale;
}

// ------------------------------------------
Expand Down Expand Up @@ -398,8 +391,8 @@ BreakIterator::createInstance(const Locale& loc, int32_t kind, UErrorCode& statu
// THIS LONG is a sign of bad code -- so the action item is to
// revisit this in ICU 3.0 and clean it up/fix it/remove it.
if (U_SUCCESS(status) && (result != nullptr) && *actualLoc.getName() != 0) {
U_LOCALE_BASED(locBased, *result);
locBased.setLocaleIDs(actualLoc.getName(), actualLoc.getName(), status);
result->actualLocale = actualLoc;
result->validLocale = actualLoc;
}
return result;
}
Expand Down Expand Up @@ -506,8 +499,7 @@ BreakIterator::getLocale(ULocDataLocaleType type, UErrorCode& status) const {
return Locale::getRoot();
}
if (type == ULOC_REQUESTED_LOCALE) {
return requestLocale == nullptr ?
Locale::getRoot() : Locale(requestLocale->data());
return requestLocale;
}
return LocaleBased::getLocale(validLocale, actualLocale, type, status);
}
Expand All @@ -518,7 +510,7 @@ BreakIterator::getLocaleID(ULocDataLocaleType type, UErrorCode& status) const {
return nullptr;
}
if (type == ULOC_REQUESTED_LOCALE) {
return requestLocale == nullptr ? "" : requestLocale->data();
return requestLocale.getName();
}
return LocaleBased::getLocaleID(validLocale, actualLocale, type, status);
}
Expand Down Expand Up @@ -546,11 +538,8 @@ int32_t BreakIterator::getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UE
return 1;
}

BreakIterator::BreakIterator (const Locale& valid, const Locale& actual) {
UErrorCode status = U_ZERO_ERROR;
U_LOCALE_BASED(locBased, (*this));
locBased.setLocaleIDs(valid.getName(), actual.getName(), status);
U_ASSERT(U_SUCCESS(status));
BreakIterator::BreakIterator(const Locale& valid, const Locale& actual)
: actualLocale(actual), validLocale(valid), requestLocale(Locale::getRoot()) {
}

U_NAMESPACE_END
Expand Down
86 changes: 41 additions & 45 deletions deps/icu-small/source/common/charstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@

U_NAMESPACE_BEGIN

// Windows needs us to DLL-export the MaybeStackArray template specialization,
// but MacOS X cannot handle it. Same as in digitlst.h.
#if !U_PLATFORM_IS_DARWIN_BASED
template class U_COMMON_API MaybeStackArray<char, 40>;
#endif

/**
* ICU-internal char * string class.
* This class does not assume or enforce any particular character encoding.
Expand All @@ -38,56 +32,56 @@ template class U_COMMON_API MaybeStackArray<char, 40>;
* For example:
* cs.data()[5]='a'; // no need for setCharAt(5, 'a')
*/
class U_COMMON_API CharString : public UMemory {
class U_COMMON_API_CLASS CharString : public UMemory {
public:
CharString() : len(0) { buffer[0]=0; }
CharString(StringPiece s, UErrorCode &errorCode) : len(0) {
U_COMMON_API CharString() : len(0) { buffer[0]=0; }
U_COMMON_API CharString(StringPiece s, UErrorCode &errorCode) : len(0) {
buffer[0]=0;
append(s, errorCode);
}
CharString(const CharString &s, UErrorCode &errorCode) : len(0) {
U_COMMON_API CharString(const CharString &s, UErrorCode &errorCode) : len(0) {
buffer[0]=0;
append(s, errorCode);
}
CharString(const char *s, int32_t sLength, UErrorCode &errorCode) : len(0) {
U_COMMON_API CharString(const char *s, int32_t sLength, UErrorCode &errorCode) : len(0) {
buffer[0]=0;
append(s, sLength, errorCode);
}
~CharString() {}
U_COMMON_API ~CharString() {}

/**
* Move constructor; might leave src in an undefined state.
* This string will have the same contents and state that the source string had.
*/
CharString(CharString &&src) noexcept;
U_COMMON_API CharString(CharString &&src) noexcept;
/**
* Move assignment operator; might leave src in an undefined state.
* This string will have the same contents and state that the source string had.
* The behavior is undefined if *this and src are the same object.
*/
CharString &operator=(CharString &&src) noexcept;
U_COMMON_API CharString &operator=(CharString &&src) noexcept;

/**
* Replaces this string's contents with the other string's contents.
* CharString does not support the standard copy constructor nor
* the assignment operator, to make copies explicit and to
* use a UErrorCode where memory allocations might be needed.
*/
CharString &copyFrom(const CharString &other, UErrorCode &errorCode);
CharString &copyFrom(StringPiece s, UErrorCode &errorCode);
U_COMMON_API CharString &copyFrom(const CharString &other, UErrorCode &errorCode);
U_COMMON_API CharString &copyFrom(StringPiece s, UErrorCode &errorCode);

UBool isEmpty() const { return len==0; }
int32_t length() const { return len; }
char operator[](int32_t index) const { return buffer[index]; }
StringPiece toStringPiece() const { return StringPiece(buffer.getAlias(), len); }
U_COMMON_API UBool isEmpty() const { return len==0; }
U_COMMON_API int32_t length() const { return len; }
U_COMMON_API char operator[](int32_t index) const { return buffer[index]; }
U_COMMON_API StringPiece toStringPiece() const { return StringPiece(buffer.getAlias(), len); }

const char *data() const { return buffer.getAlias(); }
char *data() { return buffer.getAlias(); }
U_COMMON_API const char *data() const { return buffer.getAlias(); }
U_COMMON_API char *data() { return buffer.getAlias(); }
/**
* Allocates length()+1 chars and copies the NUL-terminated data().
* The caller must uprv_free() the result.
*/
char *cloneData(UErrorCode &errorCode) const;
U_COMMON_API char *cloneData(UErrorCode &errorCode) const;
/**
* Copies the contents of the string into dest.
* Checks if there is enough space in dest, extracts the entire string if possible,
Expand All @@ -103,40 +97,40 @@ class U_COMMON_API CharString : public UMemory {
* @param errorCode ICU error code.
* @return length()
*/
int32_t extract(char *dest, int32_t capacity, UErrorCode &errorCode) const;
U_COMMON_API int32_t extract(char *dest, int32_t capacity, UErrorCode &errorCode) const;

bool operator==(const CharString& other) const {
U_COMMON_API bool operator==(const CharString& other) const {
return len == other.length() && (len == 0 || uprv_memcmp(data(), other.data(), len) == 0);
}
bool operator!=(const CharString& other) const {
U_COMMON_API bool operator!=(const CharString& other) const {
return !operator==(other);
}

bool operator==(StringPiece other) const {
U_COMMON_API bool operator==(StringPiece other) const {
return len == other.length() && (len == 0 || uprv_memcmp(data(), other.data(), len) == 0);
}
bool operator!=(StringPiece other) const {
U_COMMON_API bool operator!=(StringPiece other) const {
return !operator==(other);
}

/** @return last index of c, or -1 if c is not in this string */
int32_t lastIndexOf(char c) const;
U_COMMON_API int32_t lastIndexOf(char c) const;

bool contains(StringPiece s) const;
U_COMMON_API bool contains(StringPiece s) const;

CharString &clear() { len=0; buffer[0]=0; return *this; }
CharString &truncate(int32_t newLength);
U_COMMON_API CharString &clear() { len=0; buffer[0]=0; return *this; }
U_COMMON_API CharString &truncate(int32_t newLength);

CharString &append(char c, UErrorCode &errorCode);
CharString &append(StringPiece s, UErrorCode &errorCode) {
U_COMMON_API CharString &append(char c, UErrorCode &errorCode);
U_COMMON_API CharString &append(StringPiece s, UErrorCode &errorCode) {
return append(s.data(), s.length(), errorCode);
}
CharString &append(const CharString &s, UErrorCode &errorCode) {
U_COMMON_API CharString &append(const CharString &s, UErrorCode &errorCode) {
return append(s.data(), s.length(), errorCode);
}
CharString &append(const char *s, int32_t sLength, UErrorCode &status);
U_COMMON_API CharString &append(const char *s, int32_t sLength, UErrorCode &status);

CharString &appendNumber(int64_t number, UErrorCode &status);
U_COMMON_API CharString &appendNumber(int64_t number, UErrorCode &status);

/**
* Returns a writable buffer for appending and writes the buffer's capacity to
Expand All @@ -158,26 +152,28 @@ class U_COMMON_API CharString : public UMemory {
* @param errorCode in/out error code
* @return a buffer with resultCapacity>=min_capacity
*/
char *getAppendBuffer(int32_t minCapacity,
int32_t desiredCapacityHint,
int32_t &resultCapacity,
UErrorCode &errorCode);
U_COMMON_API char *getAppendBuffer(int32_t minCapacity,
int32_t desiredCapacityHint,
int32_t &resultCapacity,
UErrorCode &errorCode);

CharString &appendInvariantChars(const UnicodeString &s, UErrorCode &errorCode);
CharString &appendInvariantChars(const char16_t* uchars, int32_t ucharsLen, UErrorCode& errorCode);
U_COMMON_API CharString &appendInvariantChars(const UnicodeString &s, UErrorCode &errorCode);
U_COMMON_API CharString &appendInvariantChars(const char16_t* uchars,
int32_t ucharsLen,
UErrorCode& errorCode);

/**
* Appends a filename/path part, e.g., a directory name.
* First appends a U_FILE_SEP_CHAR or U_FILE_ALT_SEP_CHAR if necessary.
* Does nothing if s is empty.
*/
CharString &appendPathPart(StringPiece s, UErrorCode &errorCode);
U_COMMON_API CharString &appendPathPart(StringPiece s, UErrorCode &errorCode);

/**
* Appends a U_FILE_SEP_CHAR or U_FILE_ALT_SEP_CHAR if this string is not empty
* and does not already end with a U_FILE_SEP_CHAR or U_FILE_ALT_SEP_CHAR.
*/
CharString &ensureEndsWithFileSeparator(UErrorCode &errorCode);
U_COMMON_API CharString &ensureEndsWithFileSeparator(UErrorCode &errorCode);

private:
MaybeStackArray<char, 40> buffer;
Expand Down
4 changes: 0 additions & 4 deletions deps/icu-small/source/common/cmemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,7 @@ class MaybeStackArray {
// No heap allocation. Use only on the stack.
static void* U_EXPORT2 operator new(size_t) noexcept = delete;
static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
#if U_HAVE_PLACEMENT_NEW
static void* U_EXPORT2 operator new(size_t, void*) noexcept = delete;
#endif

/**
* Default constructor initializes with internal T[stackCapacity] buffer.
Expand Down Expand Up @@ -570,9 +568,7 @@ class MaybeStackHeaderAndArray {
// No heap allocation. Use only on the stack.
static void* U_EXPORT2 operator new(size_t) noexcept = delete;
static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
#if U_HAVE_PLACEMENT_NEW
static void* U_EXPORT2 operator new(size_t, void*) noexcept = delete;
#endif

/**
* Default constructor initializes with internal H+T[stackCapacity] buffer.
Expand Down
8 changes: 4 additions & 4 deletions deps/icu-small/source/common/cstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@

U_NAMESPACE_BEGIN

class U_COMMON_API CStr : public UMemory {
class U_COMMON_API_CLASS CStr : public UMemory {
public:
CStr(const UnicodeString &in);
~CStr();
const char * operator ()() const;
U_COMMON_API CStr(const UnicodeString &in);
U_COMMON_API ~CStr();
U_COMMON_API const char * operator ()() const;

private:
CharString s;
Expand Down
29 changes: 29 additions & 0 deletions deps/icu-small/source/common/fixedstring.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// © 2025 and later: Unicode, Inc. and others.
// License & terms of use: https://www.unicode.org/copyright.html

#include "fixedstring.h"

#include "unicode/unistr.h"
#include "unicode/utypes.h"

U_NAMESPACE_BEGIN

U_EXPORT void copyInvariantChars(const UnicodeString& src, FixedString& dst, UErrorCode& status) {
if (U_FAILURE(status)) {
return;
}

if (src.isEmpty()) {
dst.clear();
return;
}

int32_t length = src.length();
if (!dst.reserve(length + 1)) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
src.extract(0, length, dst.getAlias(), length + 1, US_INV);
}

U_NAMESPACE_END
Loading