Commit graph

6317 commits

Author SHA1 Message Date
Shane F. Carr
5e35ffc87e
ICU-22745 Merge ICU 75 maintenance branch to main (#2972) 2024-04-18 15:04:33 -07:00
Mihai Nita
aebd5ba54b ICU-22533 Change API version annotation from 75.0 to 75 2024-04-15 11:17:15 -07:00
Elango Cheran
a1bce0c096 ICU-22261 Refactor error handling for internal MF2 array-allocating functions 2024-04-12 09:22:15 -07:00
Fredrik Roubert
75eab42060 ICU-22261 Improved identification of the MSVC compiler and library.
It's not uncommon for code for Windows to use the _MSC_VER preprocessor
macro to identify that it's being compiled for Windows so it's also not
uncommon for compilers other than the real MSVC compiler to also set
this to be able to compile such code.

It's also not possible to use _MSC_VER to determine whether the C++
standard library implementation used is the Microsoft STL.

Clang will however refuse to instantiate a template with a forward
declared type, so the code that currently does this needs to be moved to
after the type has been properly defined, which in turn makes MSVC warn
that those templates aren't instantiated, so those warnings need to be
disabled, but then the disabling of warning C4661 doesn't work any
longer (for some unknown reason) but this can be resolved by properly
deleting the non-existent operators instead of disabling the warning.
2024-04-11 15:35:23 -07:00
Frank Tang
29b1141f79 ICU-22730 Fix Japanese extended year int32 overflow 2024-04-10 22:17:01 -07:00
Tim Chevalier
9e1c66daf7 ICU-22261 Refactor MF2 attributes and options parsing code
Previously, there were separate overrides for the options and
attributes parsing methods in the parser that were used in different
context. (Options can appear in Operator and Markup, while attributes
can appear in Expression and Markup.)

This is a refactoring that eliminates this duplicated code.
To enable it, a builder is added for the internal OptionMap type.

Separately, this patch also explicitly deletes copy constructors
and copy assignment operators for all Builder classes; a bug in an
earlier version of this patch caused me to notice this hadn't been
done. Also explicitly deletes move constructors/assignment operators
with the exception of OptionMap::Builder (OptionMap is non-public,
so that shouldn't cause confusion).
2024-04-09 08:15:54 -07:00
Tim Chevalier
4f0c2ca71c ICU-22261 Remove MF2 formatter caching optimization
The implementation was keeping a cache of FormatterFactory
    objects so that subsequent calls to the same formatter re-use the
    same object.
    The problem is that this is unsafe, because
    `MFFunctionRegistry::getFormatter()` returns a non-const `FormatterFactory*`;
    so if the caller deleted the resulting pointer, the formatter cache
    would contain a dangling pointer.
    
    This optimization was added because of an ICU4J test that checked for
    the presence of the optimization. However, for separate reasons
    (making `adoptFormatter()` actually adopt its argument), this test
    was already removed.
    
    The caching could be re-added later if that optimization is needed,
    but for now, remove it (also, no tests were checking for its presence).
2024-04-05 13:14:34 -07:00
Tim Chevalier
070a1f420b ICU-22261 Add missing API tags for MessageFormat 2 methods/constants 2024-03-28 15:46:32 -07:00
Frank Tang
d83d26cc5d ICU-9972 Fix Chinese/Dangi Calendar getActualMaximum(UCAL_DAY_OF_YEAR)
Also fix ICU-12620 which is mark duplicate of ICU-9972 just now.
and fix ICU-22258.

Separate the new year and winter solstice cache since the calculated
value for these two calendar are mostly but not always the same due
to slightly different observation timeZone.

Remove the epochYear and zoneAstroCalc from the member data
and instead return them from a getStting() method with the two caches
since all four of them are constant per subclass of ChineseCalendar
and do not need to be different per object.

The known issues in the TestLimit is caused by both Calendar get/put the
value from the same cache while the calculated result depends on the
timeZone zoneAstroCalc.
2024-03-28 11:02:21 -07:00
Tim Chevalier
aff1bbaa14 ICU-22261 Add UCONFIG_NO_MF2 flag that can be used to disable MessageFormat 2 functionality 2024-03-28 08:48:35 -07:00
Tim Chevalier
f7d641d5ad ICU-22261 Add tech preview implementation for MessageFormat 2.0 to icu4c 2024-03-27 17:04:07 -04:00
Shane F. Carr
8a1df5a7f4 ICU-22692 Change SimpleNumber truncateAt to setMaximumIntegerDigits
Also promotes the remaining draft SimpleNumber functions to stable.

See #2892
2024-03-26 16:13:46 -07:00
Rich Gillam
13bf3c8313 ICU-22611 Fixed the RBNF MultiplierSubstitution to only perform floor() on the value being formatted when the
substitution is using a DecimalFormat and its owning rule also has a modulus substitution.  Took out a redundant
call to floor().  Added a hack to allow the caller to change the rounding behavior with setRoundingMode().
Added appropriate unit tests. Added additional documentation of the behavior to the API docs.
2024-03-22 11:18:27 -07:00
Fredrik Roubert
2a6bc212d4 ICU-22691 Delete abandoned sample code. 2024-03-21 23:19:54 +01:00
Frank Tang
37bdffb240 ICU-22679 Fix broken header test
See #2918
2024-03-21 15:12:10 -07:00
Frank Tang
fbc1f33e7e ICU-22679 Clean up Calendar code.
1. Remove redudant implementation of default system ceuntry by using
   macro
2. Fold long if / else block if one block return.
2024-03-21 09:50:10 -07:00
Fredrik Roubert
91721504ef ICU-22621 Clang-Tidy: modernize-return-braced-init-list
https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/modernize/return-braced-init-list.html
2024-03-21 13:50:45 +01:00
Frank Tang
0b77215040 ICU-22698 Clean up CalendarAstronomer 2024-03-20 13:36:17 -07:00
Markus Scherer
cce162bf4d ICU-11396 new properties Identifier_Status & Identifier_Type
See #2879
2024-03-20 13:20:14 -07:00
Frank Tang
7a3dfe877d ICU-22679 Remove getType and string comparsion
Change the logic of handling year in era 0 counting backwards
to depend on a boolean virtual function instead of adding
string comparsion code in the base class to have specific knowledge of
behavior of subclass.
2024-03-19 17:44:37 -07:00
Frank Tang
6b67715a94 ICU-22633 Fix hang on large negative day in hebrew calendar
Check error status and return error early in the loop
2024-03-19 16:32:06 -07:00
Fredrik Roubert
ade671e252 ICU-22621 Clang-Tidy: readability-static-definition-in-anonymous-namespace
https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/readability/static-definition-in-anonymous-namespace.html
2024-03-19 15:55:56 +01:00
Fredrik Roubert
6ad78a08c7 ICU-22621 Clang-Tidy: readability-redundant-control-flow
https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/readability/redundant-control-flow.html
2024-03-19 15:55:56 +01:00
Fredrik Roubert
e017edc97d ICU-22621 Clang-Tidy: readability-qualified-auto
https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/readability/qualified-auto.html
2024-03-19 15:55:56 +01:00
Frank Tang
606623cf30 ICU-22679 Refactor ChineseCalendar
See #2898
2024-03-18 18:51:27 -07:00
Fredrik Roubert
ce052f52c2 ICU-22621 Clang-Tidy: readability-delete-null-pointer
https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/readability/delete-null-pointer.html
2024-03-18 17:14:23 +01:00
Fredrik Roubert
2295478716 ICU-22621 Clang-Tidy: readability-const-return-type
https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/readability/const-return-type.html
2024-03-18 17:14:23 +01:00
Younies Mahmoud
4405c543ad ICU-22686 Fix Unit preferences calculation in Cpp 2024-03-18 13:23:58 +01:00
Frank Tang
a1c5294ae7 ICU-22679 Remove duplicate code inside Islamic calendar 2024-03-15 16:25:52 -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
Frank Tang
de9910659d ICU-22661 Limit the size of variants in Locale
See #2821
2024-03-14 16:23:51 -07:00
Rich Gillam
c771fc444f ICU-22523 Cut down the large tables in the APIs docs for SimpleDateFormat and included a link to the full table
in the LDML spec.
2024-03-14 14:32:29 -07:00
Frank Tang
9a912bb51b ICU-22633 Add more Calendar overflow tests
Test set+set, set+add, set+roll, add+add, roll+roll
Fix more int32_t overflow problems.

Optimize both Java and C++ Hebrew Calendar month/year advancement by first consider
every 235 months is 19 years before iteration.
2024-03-13 15:48:25 -07:00
Fredrik Roubert
1a4fc9b009 ICU-22621 Clang-Tidy: modernize-concat-nested-namespaces
https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/modernize/concat-nested-namespaces.html
2024-03-13 16:31:47 +01:00
Rich Gillam
1cedbbd90d ICU-22534 Fixed a couple issues from the API-promotions PR that Frank found in code review. 2024-03-12 16:47:57 -07:00
Frank Tang
d43d216feb ICU-22633 Test and fix int32_t overflow for Calendar set
Add test to set with INT32_MAX and INT32_MIN then call getTime()
and fix all the undefined errors.
2024-03-12 16:46:53 -07:00
Peter Edberg
ceee4f0b46 ICU-22655 Implement "special" conversion for speed-beaufort, part 2 icu4c 2024-03-09 19:52:42 -08:00
Frank Tang
784056dfdb ICU-22633 Fix overflow in Chinese calendar
Fix issue found by https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=67256
2024-03-07 16:03:00 -08: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
Frank Tang
e0a711c0a4 ICU-22633 Fix Hebrew overflow issue 2024-03-06 14:52:19 -08: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
Rich Gillam
c610d7f986 ICU-22534 Promote (almost) all @draft ICU 73 APIs to @stable ICU 73 2024-03-04 18:05:29 -08:00
Frank Tang
73744ea41f ICU-22633 Fix overflow cause by large AM PM value
Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66771
2024-03-04 13:48:24 -08:00
Shane F. Carr
71b9b88200 ICU-22319 Fix number range semanticallyEquivalent
See #2385
2024-03-04 08:23:00 -08: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
David Carlier
35353f2d7f ICU-22671 format_date should use c++ nullptr instead of 0 for udat_open/DateFormat::create
- [x] Required: Issue filed: https://unicode-org.atlassian.net/browse/ICU-22671
- [x] Required: The PR title must be prefixed with a JIRA Issue number. <!-- For example: "ICU-1234 Fix xyz" -->
- [x] Required: The PR description must include the link to the Jira Issue, for example by completing the URL in the first checklist item
- [x] Required: Each commit message must be prefixed with a JIRA Issue number. <!-- For example: "ICU-1234 Fix xyz" -->
- [ ] Issue accepted (done by Technical Committee after discussion)
- [ ] Tests included, if applicable
- [ ] API docs and/or User Guide docs changed or added, if applicable
2024-02-29 20:02:20 +01:00
Frank Tang
0563859d8c ICU-22679 Optimize calendar code for edge cases
See #2853
2024-02-28 17:08:24 -08:00
Craig
d271d3f269 ICU-21952 fix draft version of withoutLocale to ICU 75 2024-02-27 17:03:46 -08:00
Frank Tang
ec800e7407 ICU-22633 Return error if era is out of range 2024-02-27 10:56:28 -08:00
Frank Tang
b24b251bca ICU-22633 Fix more int overflow issues in calendar 2024-02-13 17:24:18 -08:00