Commit graph

231 commits

Author SHA1 Message Date
Fredrik Roubert
7da5e90a3d ICU-22901 Update Locale::init() to use StringPiece. 2025-02-14 20:52:40 +01:00
Fredrik Roubert
7ffbe77e12 ICU-22696 Update ulocimp_setKeywordValue() to use std::string_view. 2024-08-13 14:03:18 +02:00
Fredrik Roubert
8a6d59ec80 ICU-22696 Update ulocimp_to*{Key,Type}() to use std::string_view. 2024-08-07 14:14:23 +02:00
Fredrik Roubert
dd65ee3f0b ICU-22696 Update ulocimp_getKeywordValue() to use std::string_view. 2024-07-31 15:39:15 +02:00
Fredrik Roubert
5d7cbdbc02 ICU-22696 Delete unused code.
These optional output parameters weren't used when these function were
originally added so they were most likely included just in case someone
would want to use them in the future, but that was 10 years ago now and
they still haven't been used yet, so it's unlikely that they'll be used
in the foreseeable future and call sites as well as the implementation
can instead be simplified by removing them.
2024-07-29 22:03:10 +02:00
Fredrik Roubert
0178a07a26 ICU-22793 Clang-Tidy: google-readability-casting
https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/google/readability-casting.html
2024-07-04 22:32:12 +02:00
Frank Tang
42d0bab7c3 ICU-22800 Avoid inconsistent state inside Locale
There are some memory leak in Locale which is hard to figure out why.
Use different variable to track memory allocation to avoid inconsistent
state while malloc fail
2024-06-21 11:49:11 -07:00
David Yeung
6e9e120520 ICU-22796 Bugfix: Memory access after uprv_free(). 2024-06-17 13:09:27 -07:00
Fredrik Roubert
5401c12018 ICU-22621 Clang-Tidy: modernize-use-nullptr
https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/modernize/use-nullptr.html
2024-03-15 14:31:54 +01:00
Fredrik Roubert
3a88e99a27 ICU-22520 Add a StringByteSink<CharString> template specialization.
This makes it possible to call public functions that take a string class
as a template parameter and return an object of that class (implemented
through the StringByteSink helper class) also with the CharString class,
even though this class doesn't actually provide the public API required
by StringByteSink.

This makes it possible to use such more modern APIs also internally.
2024-03-07 17:35:48 +01:00
Fredrik Roubert
53568e8dfc ICU-22520 Refactor CharString & CharStringByteSink into helper.
The repeated sequence of allocating a CharString and CharStringByteSink,
before calling some function that writes into this, can be moved into a
single shared helper function which then is used to give all ulocimp.h
functions that write to ByteSink an overload that instead returns a
CharString, to make call sites look like perfectly normal C++ code.
2024-03-05 23:44:50 +01:00
Fredrik Roubert
929cd9bb4f ICU-22520 Standardize return on error for all locale functions.
· No function should do anything if an error has already occurred.
· On error, a value of 0, nullptr, {}, etc., should be returned.
· Values shouldn't have overloaded meanings (eg. index or found).
· Values that are never used should not be returned at all.
2024-02-29 20:42:03 +01:00
Fredrik Roubert
939f08f274 ICU-22520 Use C++ function signatures for internal C++ functions.
Some of this code was originally written as C code and some of this code
was originally written as C++ code but made to resemble the then already
existing code that had once been C code. Changing it all to normal C++
now will make it easier and safer to work with going forward.

· Use unnamed namespace instead of static.
· Use reference instead of non-nullable pointer.
· Use bool instead of UBool.
· Use constexpr for static data.
· Use U_EXPORT instead of U_CAPI or U_CFUNC.
· Use the default calling convention instead of U_EXPORT2.
2024-02-12 21:44:06 +01:00
Fredrik Roubert
03a870a23c ICU-22520 Replace uprv_malloc() / uprv_free() with icu::CharString. 2023-12-28 10:27:35 +09:00
Frank Tang
35645abdcb ICU-22494 Avoid adding empty or duplicate variants during locale canoncalization.
It change the failure case (see the bug) from 35s to 0.126s on a very
fast developement machine.
2023-09-11 15:25:37 -07:00
Frank Tang
667ee72b7c ICU-22457 count() of getUnicodeKeywords is incorrect
The count() is incorrect if the Locale contains extension which is not -u-
for example -x-, -t-.

Currently, this PR only contains tests to show the problem.

ICU-22457 Fix the enum_count
2023-08-21 14:44:10 -07:00
Frank Tang
ffc449de62 ICU-20777 Merge the likelySubtags implemention
Change testdata/likelySubtags.txt to consider FAIL line

ICU-20777 Fix Java Tests

ICU-20777 Fix all issues

ICU-20777 Incase timeout

ICU-20777

ICU-20777 Skip Data Driven test
2023-08-18 09:35:54 -07:00
Frank Tang
ca1435c3ea ICU-22453 Fix non null terminated buffer issue.
See #2543
2023-08-09 15:36:04 -07:00
Markus Scherer
b6dcc95d3c ICU-21833 remove redundant void parameter lists
See #2351
2023-03-02 09:31:57 -08:00
Markus Scherer
2864379937 ICU-21833 replace U_NOEXCEPT with C++11 standard noexcept 2023-03-01 15:24:34 -08:00
Fredrik Roubert
2e0d30cfcf ICU-21833 Replace NULL with nullptr in all C++ code. 2023-02-03 20:20:38 +01:00
Fredrik Roubert
030fa1a479 ICU-21148 Consistently use standard lowercase true/false everywhere.
This is the normal standard way in C, C++ as well as Java and there's no
longer any reason for ICU to be different. The various internal macros
providing custom boolean constants can all be deleted and code as well
as documentation can be updated to use lowercase true/false everywhere.
2022-09-07 20:56:33 +02:00
Andy Heninger
85705f04e0 ICU-21960 C++20 Warnings from ATOMIC_VAR_INIT
Remove the ICU macros ATOMIC_INT32_T_INITIALIZER and U_INITONCE_INITIALIZER,
which made use of C++ ATOMIC_VAR_INIT, which has been removed from C++20.

With modern C++ features being available, these macros no longer served
any real need.
2022-05-17 15:45:06 -07:00
Frank Tang
fca6b342c0 ICU-21994 Fix heap-buffer-overflow 2022-04-20 12:03:35 -07:00
Andy Heninger
c48f218600 ICU-21763 UVector cleanup in Locale & Region Code
Revise uses of UVector in Locale and Region related code to better handle
memory allocation failures.  This is one of an ongoing series of commits to
address similar problems with UVector usage throughout ICU.

The changes involve switching uses of UVector::addElementX() to the new
adoptElement() or addElement() functions, as appropriate, and using
LocalPointers for tracking memory ownership.

In Region::loadRegionData(), improved the overall error detection and recovery.
2021-11-11 16:06:36 -08:00
Peter Varga
1986dcd0d8 ICU-21734 Add missing overrides 2021-09-07 17:42:14 -07:00
Fredrik Roubert
633438f8da ICU-20973 Change all equality operator return types from UBool to bool. 2021-08-17 00:35:00 +02:00
Andy Heninger
c26aebe802 ICU-21662 Rename UVector::addElement().
This is the first step towards improving the error handling and out-of-memory
behavior of UVector::addElement(). A followup PR will add back a new addElement()
with corrected error handling, then additional followups will switch call sites
from the original (renamed) function to the new addElement().

This commit includes no logic or behavior changes; it only renames the existing functions.
2021-07-28 15:36:50 -07:00
luz paz
73eca0a9c9 ICU-21580 Fix typos in icu4c/
Found via `codespell -q 3 -L ans,anumber,atleast,ba,bre,hace,nd,nin,ois,rsource,som,sur,tht -S icu4c/source/data/zone,icu4c/source/data/lang`
ICU-21580 Fix source (related) typos
ICU-21580 Revert extraneous auto-encoding
ICU-21580 Re-add previous reverted fix without auto-encoding
2021-07-19 13:22:38 -05:00
Jeff Genovy
1d560c37e5 ICU-21664 Fix set but unused warning in locid.cpp 2021-07-12 12:11:34 -07:00
Frank Tang
b13be666cd ICU-21597 Fix Null-deref W in canonicalizeLocale 2021-04-28 15:37:08 -07:00
Frank Tang
2dc5bea906 ICU-21587 Fix memory bug w/ baseName
Edge cases not fixed in assign and move assign operator
while the locale is long and call setKeywordValue with incorrect
keyword/values.
2021-04-13 16:33:06 -07:00
Frank Tang
45b893c1f9 ICU-21539 Fix getUnicodeKeywords to skip non keys
See #1683
2021-04-08 22:02:15 -07:00
Shane Carr
bc22e421bf ICU-21578 Merging maint/maint-69 into main (conflict: icudata.jar) 2021-04-07 15:15:05 -07:00
Frank Tang
b926f52688 ICU-21550 Add zzzz to subdivision if len==2
See #1662
2021-04-07 13:47:42 -05:00
Jeff Genovy
c5406692bb ICU-21546 Fix warnings from running the samples with MSVC. 2021-04-05 13:59:43 -07:00
Frank Tang
bdb4c7025a ICU-21526 Change return of UElementComparator to int32_t
See #1621
2021-03-31 12:02:08 -07:00
Frank Tang
15d3f9f65d ICU-21550 Add zzzz to subdivision if len==2
See #1662
2021-03-29 19:04:53 -07:00
Frank Tang
cec7de7a39 ICU-21537 Fix invalid free by long locale name
Do not free baseName if it is pointing to fullNameBuffer.

Better Fix
2021-03-17 10:34:27 -07:00
Craig Cornelius
bc7e2e230c ICU-21480 Scrub TODOs for completed issues 21292 and 21236
See #1652
2021-03-16 11:17:14 -07:00
Frank Tang
75874eb0eb ICU-21521 Fix cast of uprv_strcmp
See #1618
2021-03-05 14:19:51 -08:00
Peter Edberg
7159e334ff ICU-21480 integrate CLDR release 39 alpha1 to ICU trunk 2021-02-16 21:44:12 -08:00
Peter Edberg
3333fd557c ICU-21480 integrate CLDR release 39 alpha0 to ICU trunk 2021-02-10 11:58:26 -08:00
Frank Tang
c3ed0c5371 ICU-21430 propagate error code 2020-12-07 23:03:23 -08:00
Frank Tang
5f8df0d288 ICU-21406 canonicalize -T- extension
See #1491
2020-12-07 21:21:41 -08:00
Frank Tang
63cd3a7d40 ICU-21419 Fix memory leak in AliasReplacer 2020-12-02 10:44:45 -08:00
Frank Tang
1aa229daff ICU-21402 replace sd and rg by subdivisionAlias
See #1475
2020-11-24 17:22:12 -08:00
Frank Tang
9663195189 ICU-21385 Fix assertion when setKeywordValue w/ long value.
See #1461
2020-11-12 10:00:28 -08:00
Frank Tang
916932648d ICU-21373 Remove wrong cast to avoid CFI 2020-11-09 15:13:59 -08:00
Frank Tang
9ab5487eb8 ICU-21344 Fix wrong passing of script in Locale.
Also add same unit test in Java which have no problem.
2020-10-21 16:46:01 -07:00