summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2020-11-20 12:57:06 +0100
committerNode.js GitHub Bot <github-bot@iojs.org>2020-11-22 20:58:08 +0000
commitf3821cd8d797bb9f3857f379968206226aa3ac46 (patch)
treea957e0e80777aec4f625910fffec7e4fe4908ef4 /deps
parent62a56264f618239479088d59e532828d46adccf0 (diff)
downloadios-node-v8-f3821cd8d797bb9f3857f379968206226aa3ac46.tar.gz
ios-node-v8-f3821cd8d797bb9f3857f379968206226aa3ac46.tar.bz2
ios-node-v8-f3821cd8d797bb9f3857f379968206226aa3ac46.zip
deps: update ICU to 68.1
Refs: https://github.com/unicode-org/icu/releases/tag/release-68-1 PR-URL: https://github.com/nodejs/node/pull/36187 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Diffstat (limited to 'deps')
-rw-r--r--deps/icu-small/LICENSE6
-rw-r--r--deps/icu-small/README-FULL-ICU.txt4
-rw-r--r--deps/icu-small/source/.clang-format11
-rw-r--r--deps/icu-small/source/common/bmpset.h2
-rw-r--r--deps/icu-small/source/common/brkeng.h4
-rw-r--r--deps/icu-small/source/common/bytesinkutil.h4
-rw-r--r--deps/icu-small/source/common/charstr.cpp28
-rw-r--r--deps/icu-small/source/common/charstr.h26
-rw-r--r--deps/icu-small/source/common/charstrmap.h55
-rw-r--r--deps/icu-small/source/common/cmemory.h89
-rw-r--r--deps/icu-small/source/common/dictbe.h2
-rw-r--r--deps/icu-small/source/common/icuplug.cpp12
-rw-r--r--deps/icu-small/source/common/icuplugimp.h12
-rw-r--r--deps/icu-small/source/common/localematcher.cpp84
-rw-r--r--deps/icu-small/source/common/localeprioritylist.cpp2
-rw-r--r--deps/icu-small/source/common/localeprioritylist.h2
-rw-r--r--deps/icu-small/source/common/locdispnames.cpp55
-rw-r--r--deps/icu-small/source/common/locdistance.cpp2
-rw-r--r--deps/icu-small/source/common/locdistance.h10
-rw-r--r--deps/icu-small/source/common/locid.cpp1417
-rw-r--r--deps/icu-small/source/common/loclikely.cpp112
-rw-r--r--deps/icu-small/source/common/loclikelysubtags.cpp68
-rw-r--r--deps/icu-small/source/common/loclikelysubtags.h40
-rw-r--r--deps/icu-small/source/common/locmap.cpp12
-rw-r--r--deps/icu-small/source/common/lsr.cpp2
-rw-r--r--deps/icu-small/source/common/lsr.h2
-rw-r--r--deps/icu-small/source/common/messageimpl.h2
-rw-r--r--deps/icu-small/source/common/norm2allmodes.h34
-rw-r--r--deps/icu-small/source/common/normalizer2impl.h10
-rw-r--r--deps/icu-small/source/common/patternprops.h8
-rw-r--r--deps/icu-small/source/common/pluralmap.h8
-rw-r--r--deps/icu-small/source/common/punycode.cpp87
-rw-r--r--deps/icu-small/source/common/punycode.h10
-rw-r--r--deps/icu-small/source/common/putil.cpp74
-rw-r--r--deps/icu-small/source/common/putilimp.h78
-rw-r--r--deps/icu-small/source/common/rbbi.cpp207
-rw-r--r--deps/icu-small/source/common/rbbi_cache.cpp10
-rw-r--r--deps/icu-small/source/common/rbbi_cache.h6
-rwxr-xr-xdeps/icu-small/source/common/rbbicst.pl2
-rw-r--r--deps/icu-small/source/common/rbbidata.cpp101
-rw-r--r--deps/icu-small/source/common/rbbidata.h99
-rw-r--r--deps/icu-small/source/common/rbbinode.h2
-rw-r--r--deps/icu-small/source/common/rbbirb.cpp36
-rw-r--r--deps/icu-small/source/common/rbbiscan.cpp4
-rw-r--r--deps/icu-small/source/common/rbbiscan.h2
-rw-r--r--deps/icu-small/source/common/rbbisetb.cpp218
-rw-r--r--deps/icu-small/source/common/rbbisetb.h48
-rw-r--r--deps/icu-small/source/common/rbbitblb.cpp114
-rw-r--r--deps/icu-small/source/common/rbbitblb.h20
-rw-r--r--deps/icu-small/source/common/resource.h12
-rw-r--r--deps/icu-small/source/common/ruleiter.h2
-rw-r--r--deps/icu-small/source/common/serv.h38
-rw-r--r--deps/icu-small/source/common/servnotf.h2
-rw-r--r--deps/icu-small/source/common/sharedobject.h4
-rw-r--r--deps/icu-small/source/common/simpleformatter.cpp2
-rw-r--r--deps/icu-small/source/common/uassert.h2
-rw-r--r--deps/icu-small/source/common/ubidi_props.cpp2
-rw-r--r--deps/icu-small/source/common/ubidiimp.h20
-rw-r--r--deps/icu-small/source/common/ubiditransform.cpp6
-rw-r--r--deps/icu-small/source/common/ucase.cpp36
-rw-r--r--deps/icu-small/source/common/ucase.h5
-rw-r--r--deps/icu-small/source/common/ucase_props_data.h268
-rw-r--r--deps/icu-small/source/common/ucasemap_imp.h8
-rw-r--r--deps/icu-small/source/common/ucln_cmn.h2
-rw-r--r--deps/icu-small/source/common/ucln_imp.h6
-rw-r--r--deps/icu-small/source/common/ucnv_bld.cpp2
-rw-r--r--deps/icu-small/source/common/ucnv_bld.h14
-rw-r--r--deps/icu-small/source/common/ucnv_cnv.h6
-rw-r--r--deps/icu-small/source/common/ucnv_u8.cpp4
-rw-r--r--deps/icu-small/source/common/ucnvmbcs.h2
-rw-r--r--deps/icu-small/source/common/ucol_swp.h2
-rw-r--r--deps/icu-small/source/common/ucurr.cpp27
-rw-r--r--deps/icu-small/source/common/uelement.h2
-rw-r--r--deps/icu-small/source/common/uinvchar.cpp4
-rw-r--r--deps/icu-small/source/common/uinvchar.h18
-rw-r--r--deps/icu-small/source/common/uloc.cpp307
-rw-r--r--deps/icu-small/source/common/uloc_tag.cpp137
-rw-r--r--deps/icu-small/source/common/ulocimp.h77
-rw-r--r--deps/icu-small/source/common/umutex.h4
-rw-r--r--deps/icu-small/source/common/unicode/appendable.h20
-rw-r--r--deps/icu-small/source/common/unicode/brkiter.h4
-rw-r--r--deps/icu-small/source/common/unicode/bytestream.h4
-rw-r--r--deps/icu-small/source/common/unicode/bytestrie.h16
-rw-r--r--deps/icu-small/source/common/unicode/bytestriebuilder.h9
-rw-r--r--deps/icu-small/source/common/unicode/caniter.h4
-rw-r--r--deps/icu-small/source/common/unicode/chariter.h12
-rw-r--r--deps/icu-small/source/common/unicode/docmain.h10
-rw-r--r--deps/icu-small/source/common/unicode/dtintrv.h4
-rw-r--r--deps/icu-small/source/common/unicode/edits.h34
-rw-r--r--deps/icu-small/source/common/unicode/filteredbrk.h8
-rw-r--r--deps/icu-small/source/common/unicode/icudataver.h2
-rw-r--r--deps/icu-small/source/common/unicode/icuplug.h34
-rw-r--r--deps/icu-small/source/common/unicode/idna.h22
-rw-r--r--deps/icu-small/source/common/unicode/localebuilder.h19
-rw-r--r--deps/icu-small/source/common/unicode/localematcher.h167
-rw-r--r--deps/icu-small/source/common/unicode/localpointer.h4
-rw-r--r--deps/icu-small/source/common/unicode/locid.h58
-rw-r--r--deps/icu-small/source/common/unicode/messagepattern.h24
-rw-r--r--deps/icu-small/source/common/unicode/normalizer2.h32
-rw-r--r--deps/icu-small/source/common/unicode/normlzr.h18
-rw-r--r--deps/icu-small/source/common/unicode/parsepos.h8
-rw-r--r--deps/icu-small/source/common/unicode/putil.h12
-rw-r--r--deps/icu-small/source/common/unicode/rbbi.h38
-rw-r--r--deps/icu-small/source/common/unicode/resbund.h2
-rw-r--r--deps/icu-small/source/common/unicode/simpleformatter.h4
-rw-r--r--deps/icu-small/source/common/unicode/strenum.h4
-rw-r--r--deps/icu-small/source/common/unicode/stringpiece.h10
-rw-r--r--deps/icu-small/source/common/unicode/stringtriebuilder.h4
-rw-r--r--deps/icu-small/source/common/unicode/ubidi.h107
-rw-r--r--deps/icu-small/source/common/unicode/ubiditransform.h13
-rw-r--r--deps/icu-small/source/common/unicode/ubrk.h47
-rw-r--r--deps/icu-small/source/common/unicode/ucasemap.h31
-rw-r--r--deps/icu-small/source/common/unicode/ucat.h6
-rw-r--r--deps/icu-small/source/common/unicode/uchar.h184
-rw-r--r--deps/icu-small/source/common/unicode/ucharstrie.h18
-rw-r--r--deps/icu-small/source/common/unicode/ucharstriebuilder.h9
-rw-r--r--deps/icu-small/source/common/unicode/uchriter.h8
-rw-r--r--deps/icu-small/source/common/unicode/uclean.h6
-rw-r--r--deps/icu-small/source/common/unicode/ucnv.h165
-rw-r--r--deps/icu-small/source/common/unicode/ucnv_cb.h10
-rw-r--r--deps/icu-small/source/common/unicode/ucnv_err.h20
-rw-r--r--deps/icu-small/source/common/unicode/ucnvsel.h15
-rw-r--r--deps/icu-small/source/common/unicode/ucptrie.h12
-rw-r--r--deps/icu-small/source/common/unicode/ucurr.h62
-rw-r--r--deps/icu-small/source/common/unicode/udata.h29
-rw-r--r--deps/icu-small/source/common/unicode/udisplaycontext.h3
-rw-r--r--deps/icu-small/source/common/unicode/uenum.h21
-rw-r--r--deps/icu-small/source/common/unicode/uidna.h30
-rw-r--r--deps/icu-small/source/common/unicode/uiter.h20
-rw-r--r--deps/icu-small/source/common/unicode/uldnames.h33
-rw-r--r--deps/icu-small/source/common/unicode/uloc.h240
-rw-r--r--deps/icu-small/source/common/unicode/umachine.h66
-rw-r--r--deps/icu-small/source/common/unicode/umutablecptrie.h5
-rw-r--r--deps/icu-small/source/common/unicode/unimatch.h10
-rw-r--r--deps/icu-small/source/common/unicode/uniset.h12
-rw-r--r--deps/icu-small/source/common/unicode/unistr.h94
-rw-r--r--deps/icu-small/source/common/unicode/unorm.h14
-rw-r--r--deps/icu-small/source/common/unicode/unorm2.h57
-rw-r--r--deps/icu-small/source/common/unicode/urename.h20
-rw-r--r--deps/icu-small/source/common/unicode/ures.h91
-rw-r--r--deps/icu-small/source/common/unicode/uscript.h36
-rw-r--r--deps/icu-small/source/common/unicode/uset.h149
-rw-r--r--deps/icu-small/source/common/unicode/usetiter.h6
-rw-r--r--deps/icu-small/source/common/unicode/ushape.h2
-rw-r--r--deps/icu-small/source/common/unicode/usprep.h11
-rw-r--r--deps/icu-small/source/common/unicode/ustring.h134
-rw-r--r--deps/icu-small/source/common/unicode/utext.h94
-rw-r--r--deps/icu-small/source/common/unicode/utf.h20
-rw-r--r--deps/icu-small/source/common/unicode/utf16.h21
-rw-r--r--deps/icu-small/source/common/unicode/utf8.h31
-rw-r--r--deps/icu-small/source/common/unicode/utf_old.h4
-rw-r--r--deps/icu-small/source/common/unicode/utrace.h28
-rw-r--r--deps/icu-small/source/common/unicode/utypes.h14
-rw-r--r--deps/icu-small/source/common/unicode/uvernum.h12
-rw-r--r--deps/icu-small/source/common/unicode/uversion.h8
-rw-r--r--deps/icu-small/source/common/unifiedcache.cpp14
-rw-r--r--deps/icu-small/source/common/unifiedcache.h30
-rw-r--r--deps/icu-small/source/common/uniquecharstr.h98
-rw-r--r--deps/icu-small/source/common/unisetspan.h4
-rw-r--r--deps/icu-small/source/common/unormimp.h2
-rw-r--r--deps/icu-small/source/common/uresbund.cpp18
-rw-r--r--deps/icu-small/source/common/uresdata.cpp2
-rw-r--r--deps/icu-small/source/common/uresdata.h22
-rw-r--r--deps/icu-small/source/common/uresimp.h4
-rw-r--r--deps/icu-small/source/common/ustr_imp.h20
-rw-r--r--deps/icu-small/source/common/ustring.cpp12
-rw-r--r--deps/icu-small/source/common/util.h6
-rw-r--r--deps/icu-small/source/common/utrie.h12
-rw-r--r--deps/icu-small/source/common/utrie2.h14
-rw-r--r--deps/icu-small/source/common/utrie_swap.cpp18
-rw-r--r--deps/icu-small/source/common/uts46.cpp18
-rw-r--r--deps/icu-small/source/common/utypes.cpp3
-rw-r--r--deps/icu-small/source/common/uvector.h2
-rw-r--r--deps/icu-small/source/common/uvectr32.h4
-rw-r--r--deps/icu-small/source/common/uvectr64.h4
-rw-r--r--deps/icu-small/source/common/wintz.cpp143
-rw-r--r--deps/icu-small/source/common/wintz.h2
-rw-r--r--deps/icu-small/source/data/in/icudt68l.dat.bz2 (renamed from deps/icu-small/source/data/in/icudt67l.dat.bz2)bin10042879 -> 10124683 bytes
-rw-r--r--deps/icu-small/source/i18n/buddhcal.h2
-rw-r--r--deps/icu-small/source/i18n/calendar.cpp4
-rw-r--r--deps/icu-small/source/i18n/cecal.cpp2
-rw-r--r--deps/icu-small/source/i18n/cecal.h2
-rw-r--r--deps/icu-small/source/i18n/chnsecal.cpp4
-rw-r--r--deps/icu-small/source/i18n/chnsecal.h2
-rw-r--r--deps/icu-small/source/i18n/collation.h2
-rw-r--r--deps/icu-small/source/i18n/collationbuilder.h2
-rw-r--r--deps/icu-small/source/i18n/collationdatabuilder.h8
-rw-r--r--deps/icu-small/source/i18n/collationfcd.h6
-rw-r--r--deps/icu-small/source/i18n/collationiterator.h8
-rw-r--r--deps/icu-small/source/i18n/collationkeys.h8
-rw-r--r--deps/icu-small/source/i18n/collationtailoring.h2
-rw-r--r--deps/icu-small/source/i18n/collationweights.h2
-rw-r--r--deps/icu-small/source/i18n/cpdtrans.h2
-rw-r--r--deps/icu-small/source/i18n/csrecog.h4
-rw-r--r--deps/icu-small/source/i18n/dayperiodrules.h2
-rw-r--r--deps/icu-small/source/i18n/decContext.h32
-rw-r--r--deps/icu-small/source/i18n/decNumber.h122
-rw-r--r--deps/icu-small/source/i18n/dtitv_impl.h2
-rw-r--r--deps/icu-small/source/i18n/dtitvfmt.cpp220
-rw-r--r--deps/icu-small/source/i18n/dtitvinf.cpp28
-rw-r--r--deps/icu-small/source/i18n/dtptngen.cpp22
-rw-r--r--deps/icu-small/source/i18n/dtptngen_impl.h2
-rw-r--r--deps/icu-small/source/i18n/fmtable.cpp26
-rw-r--r--deps/icu-small/source/i18n/fmtable_cnv.cpp2
-rw-r--r--deps/icu-small/source/i18n/format.cpp2
-rw-r--r--deps/icu-small/source/i18n/formatted_string_builder.h3
-rw-r--r--deps/icu-small/source/i18n/formattedval_impl.h24
-rw-r--r--deps/icu-small/source/i18n/formattedval_sbimpl.cpp75
-rw-r--r--deps/icu-small/source/i18n/formattedvalue.cpp4
-rw-r--r--deps/icu-small/source/i18n/fphdlimp.h4
-rw-r--r--deps/icu-small/source/i18n/gregocal.cpp2
-rw-r--r--deps/icu-small/source/i18n/gregoimp.h4
-rw-r--r--deps/icu-small/source/i18n/hebrwcal.cpp9
-rw-r--r--deps/icu-small/source/i18n/hebrwcal.h2
-rw-r--r--deps/icu-small/source/i18n/indiancal.cpp57
-rw-r--r--deps/icu-small/source/i18n/indiancal.h4
-rw-r--r--deps/icu-small/source/i18n/islamcal.cpp16
-rw-r--r--deps/icu-small/source/i18n/islamcal.h2
-rw-r--r--deps/icu-small/source/i18n/japancal.h2
-rw-r--r--deps/icu-small/source/i18n/listformatter.cpp359
-rw-r--r--deps/icu-small/source/i18n/measfmt.cpp2
-rw-r--r--deps/icu-small/source/i18n/measunit.cpp483
-rw-r--r--deps/icu-small/source/i18n/measunit_extra.cpp342
-rw-r--r--deps/icu-small/source/i18n/measunit_impl.h48
-rw-r--r--deps/icu-small/source/i18n/measure.cpp10
-rw-r--r--deps/icu-small/source/i18n/nfrs.cpp28
-rw-r--r--deps/icu-small/source/i18n/nfrs.h6
-rw-r--r--deps/icu-small/source/i18n/nfrule.cpp26
-rw-r--r--deps/icu-small/source/i18n/nfrule.h2
-rw-r--r--deps/icu-small/source/i18n/nfsubs.cpp4
-rw-r--r--deps/icu-small/source/i18n/nounit.cpp42
-rw-r--r--deps/icu-small/source/i18n/number_asformat.h1
-rw-r--r--deps/icu-small/source/i18n/number_capi.cpp18
-rw-r--r--deps/icu-small/source/i18n/number_compact.cpp5
-rw-r--r--deps/icu-small/source/i18n/number_currencysymbols.cpp10
-rw-r--r--deps/icu-small/source/i18n/number_currencysymbols.h4
-rw-r--r--deps/icu-small/source/i18n/number_decimalquantity.cpp24
-rw-r--r--deps/icu-small/source/i18n/number_decimalquantity.h12
-rw-r--r--deps/icu-small/source/i18n/number_decnum.h8
-rw-r--r--deps/icu-small/source/i18n/number_fluent.cpp213
-rw-r--r--deps/icu-small/source/i18n/number_formatimpl.cpp123
-rw-r--r--deps/icu-small/source/i18n/number_formatimpl.h22
-rw-r--r--deps/icu-small/source/i18n/number_grouping.cpp14
-rw-r--r--deps/icu-small/source/i18n/number_integerwidth.cpp3
-rw-r--r--deps/icu-small/source/i18n/number_longnames.cpp337
-rw-r--r--deps/icu-small/source/i18n/number_longnames.h194
-rw-r--r--deps/icu-small/source/i18n/number_mapper.cpp6
-rw-r--r--deps/icu-small/source/i18n/number_mapper.h14
-rw-r--r--deps/icu-small/source/i18n/number_microprops.h97
-rw-r--r--deps/icu-small/source/i18n/number_modifiers.cpp16
-rw-r--r--deps/icu-small/source/i18n/number_output.cpp43
-rw-r--r--deps/icu-small/source/i18n/number_patternmodifier.cpp18
-rw-r--r--deps/icu-small/source/i18n/number_rounding.cpp55
-rw-r--r--deps/icu-small/source/i18n/number_roundingutils.h18
-rw-r--r--deps/icu-small/source/i18n/number_skeletons.cpp178
-rw-r--r--deps/icu-small/source/i18n/number_skeletons.h45
-rw-r--r--deps/icu-small/source/i18n/number_symbolswrapper.cpp131
-rw-r--r--deps/icu-small/source/i18n/number_types.h18
-rw-r--r--deps/icu-small/source/i18n/number_usageprefs.cpp208
-rw-r--r--deps/icu-small/source/i18n/number_usageprefs.h125
-rw-r--r--deps/icu-small/source/i18n/number_utils.cpp5
-rw-r--r--deps/icu-small/source/i18n/number_utils.h4
-rw-r--r--deps/icu-small/source/i18n/number_utypes.h9
-rw-r--r--deps/icu-small/source/i18n/numparse_affixes.cpp11
-rw-r--r--deps/icu-small/source/i18n/numparse_affixes.h5
-rw-r--r--deps/icu-small/source/i18n/numparse_types.h7
-rw-r--r--deps/icu-small/source/i18n/numrange_capi.cpp193
-rw-r--r--deps/icu-small/source/i18n/numrange_fluent.cpp25
-rw-r--r--deps/icu-small/source/i18n/numrange_impl.cpp86
-rw-r--r--deps/icu-small/source/i18n/numrange_impl.h36
-rw-r--r--deps/icu-small/source/i18n/olsontz.cpp90
-rw-r--r--deps/icu-small/source/i18n/olsontz.h6
-rw-r--r--deps/icu-small/source/i18n/persncal.cpp2
-rw-r--r--deps/icu-small/source/i18n/persncal.h2
-rw-r--r--deps/icu-small/source/i18n/pluralranges.cpp144
-rw-r--r--deps/icu-small/source/i18n/pluralranges.h67
-rw-r--r--deps/icu-small/source/i18n/plurfmt.cpp12
-rw-r--r--deps/icu-small/source/i18n/plurrule.cpp232
-rw-r--r--deps/icu-small/source/i18n/plurrule_impl.h27
-rw-r--r--deps/icu-small/source/i18n/quant.h6
-rw-r--r--deps/icu-small/source/i18n/quantityformatter.h8
-rw-r--r--deps/icu-small/source/i18n/rbt.h2
-rw-r--r--deps/icu-small/source/i18n/rbt_pars.cpp2
-rw-r--r--deps/icu-small/source/i18n/rbt_pars.h2
-rw-r--r--deps/icu-small/source/i18n/rbt_rule.h8
-rw-r--r--deps/icu-small/source/i18n/rbt_set.h12
-rw-r--r--deps/icu-small/source/i18n/regexcmp.h2
-rw-r--r--deps/icu-small/source/i18n/regextxt.h2
-rw-r--r--deps/icu-small/source/i18n/region.cpp2
-rw-r--r--deps/icu-small/source/i18n/reldatefmt.cpp4
-rw-r--r--deps/icu-small/source/i18n/rematch.cpp2
-rw-r--r--deps/icu-small/source/i18n/rulebasedcollator.cpp5
-rw-r--r--deps/icu-small/source/i18n/smpdtfmt.cpp131
-rw-r--r--deps/icu-small/source/i18n/strmatch.h12
-rw-r--r--deps/icu-small/source/i18n/taiwncal.h2
-rw-r--r--deps/icu-small/source/i18n/timezone.cpp18
-rw-r--r--deps/icu-small/source/i18n/transreg.h8
-rw-r--r--deps/icu-small/source/i18n/tridpars.h2
-rw-r--r--deps/icu-small/source/i18n/tznames_impl.h6
-rw-r--r--deps/icu-small/source/i18n/ucal.cpp2
-rw-r--r--deps/icu-small/source/i18n/ucol_imp.h4
-rw-r--r--deps/icu-small/source/i18n/ucol_sit.cpp5
-rw-r--r--deps/icu-small/source/i18n/ucsdet.cpp2
-rw-r--r--deps/icu-small/source/i18n/udat.cpp23
-rw-r--r--deps/icu-small/source/i18n/udateintervalformat.cpp25
-rw-r--r--deps/icu-small/source/i18n/uitercollationiterator.h4
-rw-r--r--deps/icu-small/source/i18n/ulocdata.cpp2
-rw-r--r--deps/icu-small/source/i18n/unicode/alphaindex.h6
-rw-r--r--deps/icu-small/source/i18n/unicode/basictz.h4
-rw-r--r--deps/icu-small/source/i18n/unicode/calendar.h26
-rw-r--r--deps/icu-small/source/i18n/unicode/choicfmt.h16
-rw-r--r--deps/icu-small/source/i18n/unicode/coleitr.h2
-rw-r--r--deps/icu-small/source/i18n/unicode/coll.h20
-rw-r--r--deps/icu-small/source/i18n/unicode/curramt.h2
-rw-r--r--deps/icu-small/source/i18n/unicode/dcfmtsym.h10
-rw-r--r--deps/icu-small/source/i18n/unicode/decimfmt.h43
-rw-r--r--deps/icu-small/source/i18n/unicode/dtfmtsym.h7
-rw-r--r--deps/icu-small/source/i18n/unicode/dtitvfmt.h59
-rw-r--r--deps/icu-small/source/i18n/unicode/dtitvinf.h4
-rw-r--r--deps/icu-small/source/i18n/unicode/dtptngen.h11
-rw-r--r--deps/icu-small/source/i18n/unicode/fieldpos.h4
-rw-r--r--deps/icu-small/source/i18n/unicode/fmtable.h8
-rw-r--r--deps/icu-small/source/i18n/unicode/formattedvalue.h12
-rw-r--r--deps/icu-small/source/i18n/unicode/fpositer.h2
-rw-r--r--deps/icu-small/source/i18n/unicode/gregocal.h4
-rw-r--r--deps/icu-small/source/i18n/unicode/measfmt.h2
-rw-r--r--deps/icu-small/source/i18n/unicode/measunit.h376
-rw-r--r--deps/icu-small/source/i18n/unicode/measure.h2
-rw-r--r--deps/icu-small/source/i18n/unicode/msgfmt.h4
-rw-r--r--deps/icu-small/source/i18n/unicode/nounit.h89
-rw-r--r--deps/icu-small/source/i18n/unicode/numberformatter.h220
-rw-r--r--deps/icu-small/source/i18n/unicode/numberrangeformatter.h199
-rw-r--r--deps/icu-small/source/i18n/unicode/numfmt.h18
-rw-r--r--deps/icu-small/source/i18n/unicode/numsys.h8
-rw-r--r--deps/icu-small/source/i18n/unicode/plurfmt.h2
-rw-r--r--deps/icu-small/source/i18n/unicode/plurrule.h68
-rw-r--r--deps/icu-small/source/i18n/unicode/rbnf.h14
-rw-r--r--deps/icu-small/source/i18n/unicode/rbtz.h4
-rw-r--r--deps/icu-small/source/i18n/unicode/regex.h38
-rw-r--r--deps/icu-small/source/i18n/unicode/reldatefmt.h6
-rw-r--r--deps/icu-small/source/i18n/unicode/search.h6
-rw-r--r--deps/icu-small/source/i18n/unicode/simpletz.h4
-rw-r--r--deps/icu-small/source/i18n/unicode/smpdtfmt.h26
-rw-r--r--deps/icu-small/source/i18n/unicode/sortkey.h4
-rw-r--r--deps/icu-small/source/i18n/unicode/stsearch.h2
-rw-r--r--deps/icu-small/source/i18n/unicode/tblcoll.h12
-rw-r--r--deps/icu-small/source/i18n/unicode/timezone.h25
-rw-r--r--deps/icu-small/source/i18n/unicode/tmutamt.h2
-rw-r--r--deps/icu-small/source/i18n/unicode/translit.h16
-rw-r--r--deps/icu-small/source/i18n/unicode/tzfmt.h8
-rw-r--r--deps/icu-small/source/i18n/unicode/tznames.h8
-rw-r--r--deps/icu-small/source/i18n/unicode/ucal.h127
-rw-r--r--deps/icu-small/source/i18n/unicode/ucol.h127
-rw-r--r--deps/icu-small/source/i18n/unicode/ucoleitr.h50
-rw-r--r--deps/icu-small/source/i18n/unicode/ucsdet.h39
-rw-r--r--deps/icu-small/source/i18n/unicode/udat.h46
-rw-r--r--deps/icu-small/source/i18n/unicode/udateintervalformat.h44
-rw-r--r--deps/icu-small/source/i18n/unicode/udatpg.h51
-rw-r--r--deps/icu-small/source/i18n/unicode/ufieldpositer.h8
-rw-r--r--deps/icu-small/source/i18n/unicode/uformattable.h28
-rw-r--r--deps/icu-small/source/i18n/unicode/uformattedvalue.h36
-rw-r--r--deps/icu-small/source/i18n/unicode/ugender.h6
-rw-r--r--deps/icu-small/source/i18n/unicode/ulistformatter.h7
-rw-r--r--deps/icu-small/source/i18n/unicode/ulocdata.h25
-rw-r--r--deps/icu-small/source/i18n/unicode/umsg.h45
-rw-r--r--deps/icu-small/source/i18n/unicode/unirepl.h2
-rw-r--r--deps/icu-small/source/i18n/unicode/unum.h99
-rw-r--r--deps/icu-small/source/i18n/unicode/unumberformatter.h88
-rw-r--r--deps/icu-small/source/i18n/unicode/unumberrangeformatter.h477
-rw-r--r--deps/icu-small/source/i18n/unicode/unumsys.h21
-rw-r--r--deps/icu-small/source/i18n/unicode/upluralrules.h36
-rw-r--r--deps/icu-small/source/i18n/unicode/uregex.h175
-rw-r--r--deps/icu-small/source/i18n/unicode/uregion.h26
-rw-r--r--deps/icu-small/source/i18n/unicode/ureldatefmt.h25
-rw-r--r--deps/icu-small/source/i18n/unicode/usearch.h234
-rw-r--r--deps/icu-small/source/i18n/unicode/uspoof.h89
-rw-r--r--deps/icu-small/source/i18n/unicode/utmscale.h6
-rw-r--r--deps/icu-small/source/i18n/unicode/utrans.h43
-rw-r--r--deps/icu-small/source/i18n/unicode/vtzone.h8
-rw-r--r--deps/icu-small/source/i18n/units_complexconverter.cpp253
-rw-r--r--deps/icu-small/source/i18n/units_complexconverter.h93
-rw-r--r--deps/icu-small/source/i18n/units_converter.cpp546
-rw-r--r--deps/icu-small/source/i18n/units_converter.h173
-rw-r--r--deps/icu-small/source/i18n/units_data.cpp428
-rw-r--r--deps/icu-small/source/i18n/units_data.h229
-rw-r--r--deps/icu-small/source/i18n/units_router.cpp132
-rw-r--r--deps/icu-small/source/i18n/units_router.h162
-rw-r--r--deps/icu-small/source/i18n/unum.cpp4
-rw-r--r--deps/icu-small/source/i18n/upluralrules.cpp20
-rw-r--r--deps/icu-small/source/i18n/uspoof_impl.h2
-rw-r--r--deps/icu-small/source/i18n/usrchimp.h8
-rw-r--r--deps/icu-small/source/i18n/utf16collationiterator.h4
-rw-r--r--deps/icu-small/source/i18n/utf8collationiterator.h6
-rw-r--r--deps/icu-small/source/i18n/vzone.h10
-rw-r--r--deps/icu-small/source/i18n/zonemeta.h2
-rw-r--r--deps/icu-small/source/python/icutools/databuilder/filtration_schema.json43
-rw-r--r--deps/icu-small/source/python/icutools/databuilder/test/sample_data/brkitr/LOCALE_DEPS.json2
-rw-r--r--deps/icu-small/source/python/icutools/databuilder/test/sample_data/locales/LOCALE_DEPS.json2
-rw-r--r--deps/icu-small/source/python/icutools/databuilder/test/sample_data/rbnf/LOCALE_DEPS.json2
-rw-r--r--deps/icu-small/source/tools/genrb/errmsg.c1
-rw-r--r--deps/icu-small/source/tools/genrb/read.c1
-rw-r--r--deps/icu-small/source/tools/genrb/reslist.cpp1
-rw-r--r--deps/icu-small/source/tools/genrb/reslist.h2
-rw-r--r--deps/icu-small/source/tools/genrb/rle.c7
-rw-r--r--deps/icu-small/source/tools/icupkg/icupkg.cpp11
-rw-r--r--deps/icu-small/source/tools/pkgdata/pkgtypes.c5
-rw-r--r--deps/icu-small/source/tools/toolutil/dbgutil.cpp2
-rw-r--r--deps/icu-small/source/tools/toolutil/filetools.h2
-rw-r--r--deps/icu-small/source/tools/toolutil/package.h8
-rw-r--r--deps/icu-small/source/tools/toolutil/pkg_genc.cpp4
-rw-r--r--deps/icu-small/source/tools/toolutil/pkg_genc.h10
-rw-r--r--deps/icu-small/source/tools/toolutil/pkgitems.cpp2
-rw-r--r--deps/icu-small/source/tools/toolutil/toolutil.cpp15
-rw-r--r--deps/icu-small/source/tools/toolutil/toolutil.h6
-rw-r--r--deps/icu-small/source/tools/toolutil/udbgutil.cpp54
-rw-r--r--deps/icu-small/source/tools/toolutil/udbgutil.h8
-rw-r--r--deps/icu-small/source/tools/toolutil/unewdata.cpp16
417 files changed, 12534 insertions, 5750 deletions
diff --git a/deps/icu-small/LICENSE b/deps/icu-small/LICENSE
index e7f98ed183..5d664a083b 100644
--- a/deps/icu-small/LICENSE
+++ b/deps/icu-small/LICENSE
@@ -284,9 +284,9 @@ property of their respective owners.
# Copyright (c) 2013 International Business Machines Corporation
# and others. All Rights Reserved.
#
- # Project: http://code.google.com/p/lao-dictionary/
- # Dictionary: http://lao-dictionary.googlecode.com/git/Lao-Dictionary.txt
- # License: http://lao-dictionary.googlecode.com/git/Lao-Dictionary-LICENSE.txt
+ # Project: https://github.com/veer66/lao-dictionary
+ # Dictionary: https://github.com/veer66/lao-dictionary/blob/master/Lao-Dictionary.txt
+ # License: https://github.com/veer66/lao-dictionary/blob/master/Lao-Dictionary-LICENSE.txt
# (copied below)
#
# This file is derived from the above dictionary, with slight
diff --git a/deps/icu-small/README-FULL-ICU.txt b/deps/icu-small/README-FULL-ICU.txt
index bad8b0346d..df63187d3a 100644
--- a/deps/icu-small/README-FULL-ICU.txt
+++ b/deps/icu-small/README-FULL-ICU.txt
@@ -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 67 source files with the following exception(s):
-* deps/icu-small/source/data/in/icudt67l.dat.bz2 : compressed data file
+It is a strict subset of ICU 68 source files with the following exception(s):
+* deps/icu-small/source/data/in/icudt68l.dat.bz2 : compressed data file
To rebuild this directory, see ../../tools/icu/README.md
diff --git a/deps/icu-small/source/.clang-format b/deps/icu-small/source/.clang-format
new file mode 100644
index 0000000000..06bd4885a1
--- /dev/null
+++ b/deps/icu-small/source/.clang-format
@@ -0,0 +1,11 @@
+# © 2020 and later: Unicode, Inc. and others.
+# License & terms of use: http://www.unicode.org/copyright.html
+
+---
+Language: Cpp
+BasedOnStyle: LLVM
+IndentWidth: 4
+ColumnLimit: 105
+AllowShortBlocksOnASingleLine: false
+AllowShortIfStatementsOnASingleLine: true
+...
diff --git a/deps/icu-small/source/common/bmpset.h b/deps/icu-small/source/common/bmpset.h
index 018aeb7f95..e1982ac669 100644
--- a/deps/icu-small/source/common/bmpset.h
+++ b/deps/icu-small/source/common/bmpset.h
@@ -101,7 +101,7 @@ private:
*/
UBool latin1Contains[0x100];
- /* TRUE if contains(U+FFFD). */
+ /* true if contains(U+FFFD). */
UBool containsFFFD;
/*
diff --git a/deps/icu-small/source/common/brkeng.h b/deps/icu-small/source/common/brkeng.h
index e40fce13f6..155433b89a 100644
--- a/deps/icu-small/source/common/brkeng.h
+++ b/deps/icu-small/source/common/brkeng.h
@@ -54,7 +54,7 @@ class LanguageBreakEngine : public UMemory {
* a particular kind of break.</p>
*
* @param c A character which begins a run that the engine might handle
- * @return TRUE if this engine handles the particular character and break
+ * @return true if this engine handles the particular character and break
* type.
*/
virtual UBool handles(UChar32 c) const = 0;
@@ -171,7 +171,7 @@ class UnhandledEngine : public LanguageBreakEngine {
* a particular kind of break.</p>
*
* @param c A character which begins a run that the engine might handle
- * @return TRUE if this engine handles the particular character and break
+ * @return true if this engine handles the particular character and break
* type.
*/
virtual UBool handles(UChar32 c) const;
diff --git a/deps/icu-small/source/common/bytesinkutil.h b/deps/icu-small/source/common/bytesinkutil.h
index 6808fbe677..ab2516432d 100644
--- a/deps/icu-small/source/common/bytesinkutil.h
+++ b/deps/icu-small/source/common/bytesinkutil.h
@@ -45,9 +45,9 @@ public:
static UBool appendUnchanged(const uint8_t *s, int32_t length,
ByteSink &sink, uint32_t options, Edits *edits,
UErrorCode &errorCode) {
- if (U_FAILURE(errorCode)) { return FALSE; }
+ if (U_FAILURE(errorCode)) { return false; }
if (length > 0) { appendNonEmptyUnchanged(s, length, sink, options, edits); }
- return TRUE;
+ return true;
}
static UBool appendUnchanged(const uint8_t *s, const uint8_t *limit,
diff --git a/deps/icu-small/source/common/charstr.cpp b/deps/icu-small/source/common/charstr.cpp
index dda29dac63..318a185b3f 100644
--- a/deps/icu-small/source/common/charstr.cpp
+++ b/deps/icu-small/source/common/charstr.cpp
@@ -20,6 +20,7 @@
#include "cmemory.h"
#include "cstring.h"
#include "uinvchar.h"
+#include "ustr_imp.h"
U_NAMESPACE_BEGIN
@@ -46,6 +47,19 @@ char *CharString::cloneData(UErrorCode &errorCode) const {
return p;
}
+int32_t CharString::extract(char *dest, int32_t capacity, UErrorCode &errorCode) const {
+ if (U_FAILURE(errorCode)) { return len; }
+ if (capacity < 0 || (capacity > 0 && dest == nullptr)) {
+ errorCode = U_ILLEGAL_ARGUMENT_ERROR;
+ return len;
+ }
+ const char *src = buffer.getAlias();
+ if (0 < len && len <= capacity && src != dest) {
+ uprv_memcpy(dest, src, len);
+ }
+ return u_terminateChars(dest, capacity, len, &errorCode);
+}
+
CharString &CharString::copyFrom(const CharString &s, UErrorCode &errorCode) {
if(U_SUCCESS(errorCode) && this!=&s && ensureCapacity(s.len+1, 0, errorCode)) {
len=s.len;
@@ -197,7 +211,7 @@ CharString &CharString::appendPathPart(StringPiece s, UErrorCode &errorCode) {
}
char c;
if(len>0 && (c=buffer[len-1])!=U_FILE_SEP_CHAR && c!=U_FILE_ALT_SEP_CHAR) {
- append(U_FILE_SEP_CHAR, errorCode);
+ append(getDirSepChar(), errorCode);
}
append(s, errorCode);
return *this;
@@ -207,9 +221,19 @@ CharString &CharString::ensureEndsWithFileSeparator(UErrorCode &errorCode) {
char c;
if(U_SUCCESS(errorCode) && len>0 &&
(c=buffer[len-1])!=U_FILE_SEP_CHAR && c!=U_FILE_ALT_SEP_CHAR) {
- append(U_FILE_SEP_CHAR, errorCode);
+ append(getDirSepChar(), errorCode);
}
return *this;
}
+char CharString::getDirSepChar() const {
+ char dirSepChar = U_FILE_SEP_CHAR;
+#if (U_FILE_SEP_CHAR != U_FILE_ALT_SEP_CHAR)
+ // We may need to return a different directory separator when building for Cygwin or MSYS2.
+ if(len>0 && !uprv_strchr(data(), U_FILE_SEP_CHAR) && uprv_strchr(data(), U_FILE_ALT_SEP_CHAR))
+ dirSepChar = U_FILE_ALT_SEP_CHAR;
+#endif
+ return dirSepChar;
+}
+
U_NAMESPACE_END
diff --git a/deps/icu-small/source/common/charstr.h b/deps/icu-small/source/common/charstr.h
index 23b950ed6e..6619faac61 100644
--- a/deps/icu-small/source/common/charstr.h
+++ b/deps/icu-small/source/common/charstr.h
@@ -87,6 +87,22 @@ public:
* The caller must uprv_free() the result.
*/
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,
+ * and NUL-terminates dest if possible.
+ *
+ * If the string fits into dest but cannot be NUL-terminated (length()==capacity),
+ * then the error code is set to U_STRING_NOT_TERMINATED_WARNING.
+ * If the string itself does not fit into dest (length()>capacity),
+ * then the error code is set to U_BUFFER_OVERFLOW_ERROR.
+ *
+ * @param dest Destination string buffer.
+ * @param capacity Size of the dest buffer (number of chars).
+ * @param errorCode ICU error code.
+ * @return length()
+ */
+ int32_t extract(char *dest, int32_t capacity, UErrorCode &errorCode) const;
bool operator==(StringPiece other) const {
return len == other.length() && (len == 0 || uprv_memcmp(data(), other.data(), len) == 0);
@@ -141,13 +157,13 @@ public:
/**
* Appends a filename/path part, e.g., a directory name.
- * First appends a U_FILE_SEP_CHAR if necessary.
+ * 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);
/**
- * Appends a U_FILE_SEP_CHAR if this string is not empty
+ * 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);
@@ -160,6 +176,12 @@ private:
CharString(const CharString &other); // forbid copying of this class
CharString &operator=(const CharString &other); // forbid copying of this class
+
+ /**
+ * Returns U_FILE_ALT_SEP_CHAR if found in string, and U_FILE_SEP_CHAR is not found.
+ * Otherwise returns U_FILE_SEP_CHAR.
+ */
+ char getDirSepChar() const;
};
U_NAMESPACE_END
diff --git a/deps/icu-small/source/common/charstrmap.h b/deps/icu-small/source/common/charstrmap.h
new file mode 100644
index 0000000000..3320a46208
--- /dev/null
+++ b/deps/icu-small/source/common/charstrmap.h
@@ -0,0 +1,55 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+// charstrmap.h
+// created: 2020sep01 Frank Yung-Fong Tang
+
+#ifndef __CHARSTRMAP_H__
+#define __CHARSTRMAP_H__
+
+#include <utility>
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+#include "uhash.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * Map of const char * keys & values.
+ * Stores pointers as is: Does not own/copy/adopt/release strings.
+ */
+class CharStringMap final : public UMemory {
+public:
+ /** Constructs an unusable non-map. */
+ CharStringMap() : map(nullptr) {}
+ CharStringMap(int32_t size, UErrorCode &errorCode) {
+ map = uhash_openSize(uhash_hashChars, uhash_compareChars, uhash_compareChars,
+ size, &errorCode);
+ }
+ CharStringMap(CharStringMap &&other) U_NOEXCEPT : map(other.map) {
+ other.map = nullptr;
+ }
+ CharStringMap(const CharStringMap &other) = delete;
+ ~CharStringMap() {
+ uhash_close(map);
+ }
+
+ CharStringMap &operator=(CharStringMap &&other) U_NOEXCEPT {
+ map = other.map;
+ other.map = nullptr;
+ return *this;
+ }
+ CharStringMap &operator=(const CharStringMap &other) = delete;
+
+ const char *get(const char *key) const { return static_cast<const char *>(uhash_get(map, key)); }
+ void put(const char *key, const char *value, UErrorCode &errorCode) {
+ uhash_put(map, const_cast<char *>(key), const_cast<char *>(value), &errorCode);
+ }
+
+private:
+ UHashtable *map;
+};
+
+U_NAMESPACE_END
+
+#endif // __CHARSTRMAP_H__
diff --git a/deps/icu-small/source/common/cmemory.h b/deps/icu-small/source/common/cmemory.h
index 38f9917963..b5e0c2b7a1 100644
--- a/deps/icu-small/source/common/cmemory.h
+++ b/deps/icu-small/source/common/cmemory.h
@@ -292,14 +292,21 @@ public:
/**
* Default constructor initializes with internal T[stackCapacity] buffer.
*/
- MaybeStackArray() : ptr(stackArray), capacity(stackCapacity), needToRelease(FALSE) {}
+ MaybeStackArray() : ptr(stackArray), capacity(stackCapacity), needToRelease(false) {}
/**
* Automatically allocates the heap array if the argument is larger than the stack capacity.
* Intended for use when an approximate capacity is known at compile time but the true
* capacity is not known until runtime.
*/
- MaybeStackArray(int32_t newCapacity) : MaybeStackArray() {
- if (capacity < newCapacity) { resize(newCapacity); }
+ MaybeStackArray(int32_t newCapacity, UErrorCode status) : MaybeStackArray() {
+ if (U_FAILURE(status)) {
+ return;
+ }
+ if (capacity < newCapacity) {
+ if (resize(newCapacity) == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ }
+ }
}
/**
* Destructor deletes the array (if owned).
@@ -355,7 +362,7 @@ public:
releaseArray();
ptr=otherArray;
capacity=otherCapacity;
- needToRelease=FALSE;
+ needToRelease=false;
}
}
/**
@@ -380,6 +387,20 @@ public:
* caller becomes responsible for deleting the array
*/
inline T *orphanOrClone(int32_t length, int32_t &resultCapacity);
+
+protected:
+ // Resizes the array to the size of src, then copies the contents of src.
+ void copyFrom(const MaybeStackArray &src, UErrorCode &status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
+ if (this->resize(src.capacity, 0) == NULL) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ uprv_memcpy(this->ptr, src.ptr, (size_t)capacity * sizeof(T));
+ }
+
private:
T *ptr;
int32_t capacity;
@@ -393,14 +414,14 @@ private:
void resetToStackArray() {
ptr=stackArray;
capacity=stackCapacity;
- needToRelease=FALSE;
+ needToRelease=false;
}
/* No comparison operators with other MaybeStackArray's. */
- bool operator==(const MaybeStackArray & /*other*/) {return FALSE;}
- bool operator!=(const MaybeStackArray & /*other*/) {return TRUE;}
+ bool operator==(const MaybeStackArray & /*other*/) = delete;
+ bool operator!=(const MaybeStackArray & /*other*/) = delete;
/* No ownership transfer: No copy constructor, no assignment operator. */
- MaybeStackArray(const MaybeStackArray & /*other*/) {}
- void operator=(const MaybeStackArray & /*other*/) {}
+ MaybeStackArray(const MaybeStackArray & /*other*/) = delete;
+ void operator=(const MaybeStackArray & /*other*/) = delete;
};
template<typename T, int32_t stackCapacity>
@@ -435,7 +456,7 @@ template<typename T, int32_t stackCapacity>
inline T *MaybeStackArray<T, stackCapacity>::resize(int32_t newCapacity, int32_t length) {
if(newCapacity>0) {
#if U_DEBUG && defined(UPRV_MALLOC_COUNT)
- ::fprintf(::stderr,"MaybeStacArray (resize) alloc %d * %lu\n", newCapacity,sizeof(T));
+ ::fprintf(::stderr, "MaybeStackArray (resize) alloc %d * %lu\n", newCapacity, sizeof(T));
#endif
T *p=(T *)uprv_malloc(newCapacity*sizeof(T));
if(p!=NULL) {
@@ -451,7 +472,7 @@ inline T *MaybeStackArray<T, stackCapacity>::resize(int32_t newCapacity, int32_t
releaseArray();
ptr=p;
capacity=newCapacity;
- needToRelease=TRUE;
+ needToRelease=true;
}
return p;
} else {
@@ -507,7 +528,7 @@ public:
/**
* Default constructor initializes with internal H+T[stackCapacity] buffer.
*/
- MaybeStackHeaderAndArray() : ptr(&stackHeader), capacity(stackCapacity), needToRelease(FALSE) {}
+ MaybeStackHeaderAndArray() : ptr(&stackHeader), capacity(stackCapacity), needToRelease(false) {}
/**
* Destructor deletes the memory (if owned).
*/
@@ -556,7 +577,7 @@ public:
releaseMemory();
ptr=otherMemory;
capacity=otherCapacity;
- needToRelease=FALSE;
+ needToRelease=false;
}
}
/**
@@ -595,8 +616,8 @@ private:
}
}
/* No comparison operators with other MaybeStackHeaderAndArray's. */
- bool operator==(const MaybeStackHeaderAndArray & /*other*/) {return FALSE;}
- bool operator!=(const MaybeStackHeaderAndArray & /*other*/) {return TRUE;}
+ bool operator==(const MaybeStackHeaderAndArray & /*other*/) {return false;}
+ bool operator!=(const MaybeStackHeaderAndArray & /*other*/) {return true;}
/* No ownership transfer: No copy constructor, no assignment operator. */
MaybeStackHeaderAndArray(const MaybeStackHeaderAndArray & /*other*/) {}
void operator=(const MaybeStackHeaderAndArray & /*other*/) {}
@@ -625,7 +646,7 @@ inline H *MaybeStackHeaderAndArray<H, T, stackCapacity>::resize(int32_t newCapac
releaseMemory();
ptr=p;
capacity=newCapacity;
- needToRelease=TRUE;
+ needToRelease=true;
}
return p;
} else {
@@ -657,7 +678,7 @@ inline H *MaybeStackHeaderAndArray<H, T, stackCapacity>::orphanOrClone(int32_t l
resultCapacity=length;
ptr=&stackHeader;
capacity=stackCapacity;
- needToRelease=FALSE;
+ needToRelease=false;
return p;
}
@@ -728,6 +749,18 @@ public:
return fPool[fCount++] = new T(std::forward<Args>(args)...);
}
+ template <typename... Args>
+ T* createAndCheckErrorCode(UErrorCode &status, Args &&... args) {
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
+ T *pointer = this->create(args...);
+ if (U_SUCCESS(status) && pointer == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ }
+ return pointer;
+ }
+
/**
* @return Number of elements that have been allocated.
*/
@@ -771,6 +804,11 @@ public:
return this->create(args...);
}
+ template <typename... Args>
+ T *emplaceBackAndCheckErrorCode(UErrorCode &status, Args &&... args) {
+ return this->createAndCheckErrorCode(status, args...);
+ }
+
int32_t length() const {
return this->fCount;
}
@@ -779,6 +817,10 @@ public:
return this->fPool.getAlias();
}
+ const T *const *getAlias() const {
+ return this->fPool.getAlias();
+ }
+
/**
* Array item access (read-only).
* No index bounds check.
@@ -798,19 +840,6 @@ public:
T* operator[](ptrdiff_t i) {
return this->fPool[i];
}
-
- /**
- * Append all the items from another MaybeStackVector to this one.
- */
- void appendAll(const MaybeStackVector& other, UErrorCode& status) {
- for (int32_t i = 0; i < other.fCount; i++) {
- T* item = emplaceBack(*other[i]);
- if (!item) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return;
- }
- }
- }
};
diff --git a/deps/icu-small/source/common/dictbe.h b/deps/icu-small/source/common/dictbe.h
index 99d176cc2e..246c1dc693 100644
--- a/deps/icu-small/source/common/dictbe.h
+++ b/deps/icu-small/source/common/dictbe.h
@@ -59,7 +59,7 @@ class DictionaryBreakEngine : public LanguageBreakEngine {
* a particular kind of break.</p>
*
* @param c A character which begins a run that the engine might handle
- * @return TRUE if this engine handles the particular character and break
+ * @return true if this engine handles the particular character and break
* type.
*/
virtual UBool handles(UChar32 c) const;
diff --git a/deps/icu-small/source/common/icuplug.cpp b/deps/icu-small/source/common/icuplug.cpp
index c3c8231b77..944df5465d 100644
--- a/deps/icu-small/source/common/icuplug.cpp
+++ b/deps/icu-small/source/common/icuplug.cpp
@@ -145,7 +145,7 @@ static int32_t searchForLibrary(void *lib) {
return -1;
}
-U_INTERNAL char * U_EXPORT2
+U_CAPI char * U_EXPORT2
uplug_findLibrary(void *lib, UErrorCode *status) {
int32_t libEnt;
char *ret = NULL;
@@ -161,7 +161,7 @@ uplug_findLibrary(void *lib, UErrorCode *status) {
return ret;
}
-U_INTERNAL void * U_EXPORT2
+U_CAPI void * U_EXPORT2
uplug_openLibrary(const char *libName, UErrorCode *status) {
int32_t libEntry = -1;
void *lib = NULL;
@@ -209,7 +209,7 @@ uplug_openLibrary(const char *libName, UErrorCode *status) {
return lib;
}
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uplug_closeLibrary(void *lib, UErrorCode *status) {
int32_t i;
@@ -507,7 +507,7 @@ uplug_getConfiguration(UPlugData *data) {
return data->config;
}
-U_INTERNAL UPlugData* U_EXPORT2
+U_CAPI UPlugData* U_EXPORT2
uplug_getPlugInternal(int32_t n) {
if(n <0 || n >= pluginCount) {
return NULL;
@@ -707,7 +707,7 @@ static void uplug_loadWaitingPlugs(UErrorCode *status) {
static char plugin_file[2048] = "";
#endif
-U_INTERNAL const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uplug_getPluginFile() {
#if U_ENABLE_DYLOAD && !UCONFIG_NO_FILE_IO
return plugin_file;
@@ -782,7 +782,7 @@ uplug_init(UErrorCode *status) {
/* plugin_file is not used for processing - it is only used
so that uplug_getPluginFile() works (i.e. icuinfo)
*/
- uprv_strncpy(plugin_file, pluginFile.data(), sizeof(plugin_file));
+ pluginFile.extract(plugin_file, sizeof(plugin_file), *status);
#if UPLUG_TRACE
DBG((stderr, "pluginfile= %s len %d/%d\n", plugin_file, (int)strlen(plugin_file), (int)sizeof(plugin_file)));
diff --git a/deps/icu-small/source/common/icuplugimp.h b/deps/icu-small/source/common/icuplugimp.h
index 282c639b40..712fdb236f 100644
--- a/deps/icu-small/source/common/icuplugimp.h
+++ b/deps/icu-small/source/common/icuplugimp.h
@@ -36,7 +36,7 @@
* @return the library pointer, or NULL
* @internal internal use only
*/
-U_INTERNAL void * U_EXPORT2
+U_CAPI void * U_EXPORT2
uplug_openLibrary(const char *libName, UErrorCode *status);
/**
@@ -45,7 +45,7 @@ uplug_openLibrary(const char *libName, UErrorCode *status);
* @param status error code
* @internal internal use only
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uplug_closeLibrary(void *lib, UErrorCode *status);
/**
@@ -55,7 +55,7 @@ uplug_closeLibrary(void *lib, UErrorCode *status);
* @return the library name, or NULL if not found.
* @internal internal use only
*/
-U_INTERNAL char * U_EXPORT2
+U_CAPI char * U_EXPORT2
uplug_findLibrary(void *lib, UErrorCode *status);
/** @} */
@@ -69,21 +69,21 @@ uplug_findLibrary(void *lib, UErrorCode *status);
* @param status error result
* @internal - Internal use only.
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uplug_init(UErrorCode *status);
/**
* Get raw plug N
* @internal - Internal use only
*/
-U_INTERNAL UPlugData* U_EXPORT2
+U_CAPI UPlugData* U_EXPORT2
uplug_getPlugInternal(int32_t n);
/**
* Get the name of the plugin file.
* @internal - Internal use only.
*/
-U_INTERNAL const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uplug_getPluginFile(void);
/** @} */
diff --git a/deps/icu-small/source/common/localematcher.cpp b/deps/icu-small/source/common/localematcher.cpp
index 85db8c8bf3..5795cbf87e 100644
--- a/deps/icu-small/source/common/localematcher.cpp
+++ b/deps/icu-small/source/common/localematcher.cpp
@@ -1,12 +1,9 @@
// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
// localematcher.cpp
// created: 2019may08 Markus W. Scherer
-#ifndef __LOCMATCHER_H__
-#define __LOCMATCHER_H__
-
#include "unicode/utypes.h"
#include "unicode/localebuilder.h"
#include "unicode/localematcher.h"
@@ -131,6 +128,7 @@ LocaleMatcher::Builder::Builder(LocaleMatcher::Builder &&src) U_NOEXCEPT :
thresholdDistance_(src.thresholdDistance_),
demotion_(src.demotion_),
defaultLocale_(src.defaultLocale_),
+ withDefault_(src.withDefault_),
favor_(src.favor_),
direction_(src.direction_) {
src.supportedLocales_ = nullptr;
@@ -140,6 +138,8 @@ LocaleMatcher::Builder::Builder(LocaleMatcher::Builder &&src) U_NOEXCEPT :
LocaleMatcher::Builder::~Builder() {
delete supportedLocales_;
delete defaultLocale_;
+ delete maxDistanceDesired_;
+ delete maxDistanceSupported_;
}
LocaleMatcher::Builder &LocaleMatcher::Builder::operator=(LocaleMatcher::Builder &&src) U_NOEXCEPT {
@@ -150,6 +150,7 @@ LocaleMatcher::Builder &LocaleMatcher::Builder::operator=(LocaleMatcher::Builder
thresholdDistance_ = src.thresholdDistance_;
demotion_ = src.demotion_;
defaultLocale_ = src.defaultLocale_;
+ withDefault_ = src.withDefault_,
favor_ = src.favor_;
direction_ = src.direction_;
@@ -229,6 +230,14 @@ LocaleMatcher::Builder &LocaleMatcher::Builder::addSupportedLocale(const Locale
return *this;
}
+LocaleMatcher::Builder &LocaleMatcher::Builder::setNoDefaultLocale() {
+ if (U_FAILURE(errorCode_)) { return *this; }
+ delete defaultLocale_;
+ defaultLocale_ = nullptr;
+ withDefault_ = false;
+ return *this;
+}
+
LocaleMatcher::Builder &LocaleMatcher::Builder::setDefaultLocale(const Locale *defaultLocale) {
if (U_FAILURE(errorCode_)) { return *this; }
Locale *clone = nullptr;
@@ -241,6 +250,7 @@ LocaleMatcher::Builder &LocaleMatcher::Builder::setDefaultLocale(const Locale *d
}
delete defaultLocale_;
defaultLocale_ = clone;
+ withDefault_ = true;
return *this;
}
@@ -256,6 +266,24 @@ LocaleMatcher::Builder &LocaleMatcher::Builder::setDemotionPerDesiredLocale(ULoc
return *this;
}
+LocaleMatcher::Builder &LocaleMatcher::Builder::setMaxDistance(const Locale &desired,
+ const Locale &supported) {
+ if (U_FAILURE(errorCode_)) { return *this; }
+ Locale *desiredClone = desired.clone();
+ Locale *supportedClone = supported.clone();
+ if (desiredClone == nullptr || supportedClone == nullptr) {
+ delete desiredClone; // in case only one could not be allocated
+ delete supportedClone;
+ errorCode_ = U_MEMORY_ALLOCATION_ERROR;
+ return *this;
+ }
+ delete maxDistanceDesired_;
+ delete maxDistanceSupported_;
+ maxDistanceDesired_ = desiredClone;
+ maxDistanceSupported_ = supportedClone;
+ return *this;
+}
+
#if 0
/**
* <i>Internal only!</i>
@@ -340,9 +368,6 @@ LocaleMatcher::LocaleMatcher(const Builder &builder, UErrorCode &errorCode) :
supportedLSRs(nullptr), supportedIndexes(nullptr), supportedLSRsLength(0),
ownedDefaultLocale(nullptr), defaultLocale(nullptr) {
if (U_FAILURE(errorCode)) { return; }
- if (thresholdDistance < 0) {
- thresholdDistance = localeDistance.getDefaultScriptDistance();
- }
const Locale *def = builder.defaultLocale_;
LSR builderDefaultLSR;
const LSR *defLSR = nullptr;
@@ -408,22 +433,20 @@ LocaleMatcher::LocaleMatcher(const Builder &builder, UErrorCode &errorCode) :
int32_t suppLength = 0;
// Determine insertion order.
// Add locales immediately that are equivalent to the default.
- MaybeStackArray<int8_t, 100> order(supportedLocalesLength);
- if (order.getAlias() == nullptr) {
- errorCode = U_MEMORY_ALLOCATION_ERROR;
- return;
- }
+ MaybeStackArray<int8_t, 100> order(supportedLocalesLength, errorCode);
+ if (U_FAILURE(errorCode)) { return; }
int32_t numParadigms = 0;
for (int32_t i = 0; i < supportedLocalesLength; ++i) {
const Locale &locale = *supportedLocales[i];
const LSR &lsr = lsrs[i];
- if (defLSR == nullptr) {
+ if (defLSR == nullptr && builder.withDefault_) {
+ // Implicit default locale = first supported locale, if not turned off.
U_ASSERT(i == 0);
def = &locale;
defLSR = &lsr;
order[i] = 1;
suppLength = putIfAbsent(lsr, 0, suppLength, errorCode);
- } else if (lsr.isEquivalentTo(*defLSR)) {
+ } else if (defLSR != nullptr && lsr.isEquivalentTo(*defLSR)) {
order[i] = 1;
suppLength = putIfAbsent(lsr, i, suppLength, errorCode);
} else if (localeDistance.isParadigmLSR(lsr)) {
@@ -458,6 +481,25 @@ LocaleMatcher::LocaleMatcher(const Builder &builder, UErrorCode &errorCode) :
if (builder.demotion_ == ULOCMATCH_DEMOTION_REGION) {
demotionPerDesiredLocale = localeDistance.getDefaultDemotionPerDesiredLocale();
}
+
+ if (thresholdDistance >= 0) {
+ // already copied
+ } else if (builder.maxDistanceDesired_ != nullptr) {
+ LSR suppLSR = getMaximalLsrOrUnd(likelySubtags, *builder.maxDistanceSupported_, errorCode);
+ const LSR *pSuppLSR = &suppLSR;
+ int32_t indexAndDistance = localeDistance.getBestIndexAndDistance(
+ getMaximalLsrOrUnd(likelySubtags, *builder.maxDistanceDesired_, errorCode),
+ &pSuppLSR, 1,
+ LocaleDistance::shiftDistance(100), favorSubtag, direction);
+ if (U_SUCCESS(errorCode)) {
+ // +1 for an exclusive threshold from an inclusive max.
+ thresholdDistance = LocaleDistance::getDistanceFloor(indexAndDistance) + 1;
+ } else {
+ thresholdDistance = 0;
+ }
+ } else {
+ thresholdDistance = localeDistance.getDefaultScriptDistance();
+ }
}
LocaleMatcher::LocaleMatcher(LocaleMatcher &&src) U_NOEXCEPT :
@@ -683,6 +725,18 @@ int32_t LocaleMatcher::getBestSuppIndex(LSR desiredLSR, LocaleLsrIterator *remai
return supportedIndexes[bestSupportedLsrIndex];
}
+UBool LocaleMatcher::isMatch(const Locale &desired, const Locale &supported,
+ UErrorCode &errorCode) const {
+ LSR suppLSR = getMaximalLsrOrUnd(likelySubtags, supported, errorCode);
+ if (U_FAILURE(errorCode)) { return 0; }
+ const LSR *pSuppLSR = &suppLSR;
+ int32_t indexAndDistance = localeDistance.getBestIndexAndDistance(
+ getMaximalLsrOrUnd(likelySubtags, desired, errorCode),
+ &pSuppLSR, 1,
+ LocaleDistance::shiftDistance(thresholdDistance), favorSubtag, direction);
+ return indexAndDistance >= 0;
+}
+
double LocaleMatcher::internalMatch(const Locale &desired, const Locale &supported, UErrorCode &errorCode) const {
// Returns the inverse of the distance: That is, 1-distance(desired, supported).
LSR suppLSR = getMaximalLsrOrUnd(likelySubtags, supported, errorCode);
@@ -790,5 +844,3 @@ uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,
return acceptLanguage(*availableLocales, desiredLocales,
result, resultAvailable, outResult, *status);
}
-
-#endif // __LOCMATCHER_H__
diff --git a/deps/icu-small/source/common/localeprioritylist.cpp b/deps/icu-small/source/common/localeprioritylist.cpp
index cee408269c..8916b121be 100644
--- a/deps/icu-small/source/common/localeprioritylist.cpp
+++ b/deps/icu-small/source/common/localeprioritylist.cpp
@@ -1,5 +1,5 @@
// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
// localeprioritylist.cpp
// created: 2019jul11 Markus W. Scherer
diff --git a/deps/icu-small/source/common/localeprioritylist.h b/deps/icu-small/source/common/localeprioritylist.h
index 80ca38a7b5..41e9d3ea08 100644
--- a/deps/icu-small/source/common/localeprioritylist.h
+++ b/deps/icu-small/source/common/localeprioritylist.h
@@ -1,5 +1,5 @@
// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
// localeprioritylist.h
// created: 2019jul11 Markus W. Scherer
diff --git a/deps/icu-small/source/common/locdispnames.cpp b/deps/icu-small/source/common/locdispnames.cpp
index 7216a3a308..a60dd0c9c1 100644
--- a/deps/icu-small/source/common/locdispnames.cpp
+++ b/deps/icu-small/source/common/locdispnames.cpp
@@ -26,6 +26,8 @@
#include "unicode/uloc.h"
#include "unicode/ures.h"
#include "unicode/ustring.h"
+#include "bytesinkutil.h"
+#include "charstr.h"
#include "cmemory.h"
#include "cstring.h"
#include "putilimp.h"
@@ -406,20 +408,26 @@ uloc_getDisplayScript(const char* locale,
UChar *dest, int32_t destCapacity,
UErrorCode *pErrorCode)
{
- UErrorCode err = U_ZERO_ERROR;
- int32_t res = _getDisplayNameForComponent(locale, displayLocale, dest, destCapacity,
+ UErrorCode err = U_ZERO_ERROR;
+ int32_t res = _getDisplayNameForComponent(locale, displayLocale, dest, destCapacity,
uloc_getScript, _kScriptsStandAlone, &err);
- if ( err == U_USING_DEFAULT_WARNING ) {
+ if (destCapacity == 0 && err == U_BUFFER_OVERFLOW_ERROR) {
+ // For preflight, return the max of the value and the fallback.
+ int32_t fallback_res = _getDisplayNameForComponent(locale, displayLocale, dest, destCapacity,
+ uloc_getScript, _kScripts, pErrorCode);
+ return (fallback_res > res) ? fallback_res : res;
+ }
+ if ( err == U_USING_DEFAULT_WARNING ) {
return _getDisplayNameForComponent(locale, displayLocale, dest, destCapacity,
- uloc_getScript, _kScripts, pErrorCode);
- } else {
- *pErrorCode = err;
- return res;
- }
+ uloc_getScript, _kScripts, pErrorCode);
+ } else {
+ *pErrorCode = err;
+ return res;
+ }
}
-U_INTERNAL int32_t U_EXPORT2
+static int32_t
uloc_getDisplayScriptInContext(const char* locale,
const char* displayLocale,
UChar *dest, int32_t destCapacity,
@@ -727,7 +735,7 @@ uloc_getDisplayName(const char *locale,
int32_t padLen;
patPos+=subLen;
padLen=(subi==0 ? sub1Pos : patLen)-patPos;
- if(length+padLen < destCapacity) {
+ if(length+padLen <= destCapacity) {
p=dest+length;
for(int32_t i=0;i<padLen;++i) {
*p++=pattern[patPos++];
@@ -805,10 +813,6 @@ uloc_getDisplayKeywordValue( const char* locale,
UErrorCode* status){
- char keywordValue[ULOC_FULLNAME_CAPACITY*4];
- int32_t capacity = ULOC_FULLNAME_CAPACITY*4;
- int32_t keywordValueLen =0;
-
/* argument checking */
if(status==NULL || U_FAILURE(*status)) {
return 0;
@@ -820,10 +824,11 @@ uloc_getDisplayKeywordValue( const char* locale,
}
/* get the keyword value */
- keywordValue[0]=0;
- keywordValueLen = uloc_getKeywordValue(locale, keyword, keywordValue, capacity, status);
- if (*status == U_STRING_NOT_TERMINATED_WARNING)
- *status = U_BUFFER_OVERFLOW_ERROR;
+ CharString keywordValue;
+ {
+ CharStringByteSink sink(&keywordValue);
+ ulocimp_getKeywordValue(locale, keyword, sink, status);
+ }
/*
* if the keyword is equal to currency .. then to get the display name
@@ -839,7 +844,7 @@ uloc_getDisplayKeywordValue( const char* locale,
icu::LocalUResourceBundlePointer currencies(
ures_getByKey(bundle.getAlias(), _kCurrencies, NULL, status));
icu::LocalUResourceBundlePointer currency(
- ures_getByKeyWithFallback(currencies.getAlias(), keywordValue, NULL, status));
+ ures_getByKeyWithFallback(currencies.getAlias(), keywordValue.data(), NULL, status));
dispName = ures_getStringByIndex(currency.getAlias(), UCURRENCY_DISPLAY_NAME_INDEX, &dispNameLen, status);
@@ -863,12 +868,12 @@ uloc_getDisplayKeywordValue( const char* locale,
}
}else{
/* we have not found the display name for the value .. just copy over */
- if(keywordValueLen <= destCapacity){
- u_charsToUChars(keywordValue, dest, keywordValueLen);
- return u_terminateUChars(dest, destCapacity, keywordValueLen, status);
+ if(keywordValue.length() <= destCapacity){
+ u_charsToUChars(keywordValue.data(), dest, keywordValue.length());
+ return u_terminateUChars(dest, destCapacity, keywordValue.length(), status);
}else{
*status = U_BUFFER_OVERFLOW_ERROR;
- return keywordValueLen;
+ return keywordValue.length();
}
}
@@ -877,8 +882,8 @@ uloc_getDisplayKeywordValue( const char* locale,
return _getStringOrCopyKey(U_ICUDATA_LANG, displayLocale,
_kTypes, keyword,
- keywordValue,
- keywordValue,
+ keywordValue.data(),
+ keywordValue.data(),
dest, destCapacity,
status);
}
diff --git a/deps/icu-small/source/common/locdistance.cpp b/deps/icu-small/source/common/locdistance.cpp
index 18e4d91bce..ff8892791b 100644
--- a/deps/icu-small/source/common/locdistance.cpp
+++ b/deps/icu-small/source/common/locdistance.cpp
@@ -1,5 +1,5 @@
// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
// locdistance.cpp
// created: 2019may08 Markus W. Scherer
diff --git a/deps/icu-small/source/common/locdistance.h b/deps/icu-small/source/common/locdistance.h
index ad84151383..51b777e627 100644
--- a/deps/icu-small/source/common/locdistance.h
+++ b/deps/icu-small/source/common/locdistance.h
@@ -1,5 +1,5 @@
// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
// locdistance.h
// created: 2019may08 Markus W. Scherer
@@ -39,6 +39,10 @@ public:
return shiftedDistance / (1 << DISTANCE_SHIFT);
}
+ static int32_t getDistanceFloor(int32_t indexAndDistance) {
+ return (indexAndDistance & DISTANCE_MASK) >> DISTANCE_SHIFT;
+ }
+
static int32_t getIndex(int32_t indexAndDistance) {
// assert indexAndDistance >= 0;
return indexAndDistance >> INDEX_SHIFT;
@@ -79,10 +83,6 @@ private:
// tic constexpr int32_t MAX_INDEX = 0x1fffff; // avoids sign bit
static constexpr int32_t INDEX_NEG_1 = 0xfffffc00;
- static int32_t getDistanceFloor(int32_t indexAndDistance) {
- return (indexAndDistance & DISTANCE_MASK) >> DISTANCE_SHIFT;
- }
-
LocaleDistance(const LocaleDistanceData &data, const XLikelySubtags &likely);
LocaleDistance(const LocaleDistance &other) = delete;
LocaleDistance &operator=(const LocaleDistance &other) = delete;
diff --git a/deps/icu-small/source/common/locid.cpp b/deps/icu-small/source/common/locid.cpp
index 753a452120..2804e36bf6 100644
--- a/deps/icu-small/source/common/locid.cpp
+++ b/deps/icu-small/source/common/locid.cpp
@@ -42,6 +42,7 @@
#include "bytesinkutil.h"
#include "charstr.h"
+#include "charstrmap.h"
#include "cmemory.h"
#include "cstring.h"
#include "mutex.h"
@@ -51,7 +52,9 @@
#include "uhash.h"
#include "ulocimp.h"
#include "umutex.h"
+#include "uniquecharstr.h"
#include "ustr_imp.h"
+#include "uvector.h"
U_CDECL_BEGIN
static UBool U_CALLCONV locale_cleanup(void);
@@ -102,12 +105,6 @@ typedef enum ELocalePos {
eMAX_LOCALES
} ELocalePos;
-U_CFUNC int32_t locale_getKeywords(const char *localeID,
- char prev,
- char *keywords, int32_t keywordCapacity,
- UBool valuesToo,
- UErrorCode *status);
-
U_CDECL_BEGIN
//
// Deleter function for Locales owned by the default Locale hash table/
@@ -252,6 +249,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(Locale)
// '_'
// In the platform codepage.
#define SEP_CHAR '_'
+#define NULL_CHAR '\0'
Locale::~Locale()
{
@@ -506,38 +504,1127 @@ Locale::operator==( const Locale& other) const
return (uprv_strcmp(other.fullName, fullName) == 0);
}
-#define ISASCIIALPHA(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z'))
-
namespace {
-CharString& AppendLSCVE(CharString& out, const char* language, const char* script,
- const char* country, const char* variants, const char* extension,
- UErrorCode& status) {
+UInitOnce gKnownCanonicalizedInitOnce = U_INITONCE_INITIALIZER;
+UHashtable *gKnownCanonicalized = nullptr;
+
+static const char* const KNOWN_CANONICALIZED[] = {
+ "c",
+ // Commonly used locales known are already canonicalized
+ "af", "af_ZA", "am", "am_ET", "ar", "ar_001", "as", "as_IN", "az", "az_AZ",
+ "be", "be_BY", "bg", "bg_BG", "bn", "bn_IN", "bs", "bs_BA", "ca", "ca_ES",
+ "cs", "cs_CZ", "cy", "cy_GB", "da", "da_DK", "de", "de_DE", "el", "el_GR",
+ "en", "en_GB", "en_US", "es", "es_419", "es_ES", "et", "et_EE", "eu",
+ "eu_ES", "fa", "fa_IR", "fi", "fi_FI", "fil", "fil_PH", "fr", "fr_FR",
+ "ga", "ga_IE", "gl", "gl_ES", "gu", "gu_IN", "he", "he_IL", "hi", "hi_IN",
+ "hr", "hr_HR", "hu", "hu_HU", "hy", "hy_AM", "id", "id_ID", "is", "is_IS",
+ "it", "it_IT", "ja", "ja_JP", "jv", "jv_ID", "ka", "ka_GE", "kk", "kk_KZ",
+ "km", "km_KH", "kn", "kn_IN", "ko", "ko_KR", "ky", "ky_KG", "lo", "lo_LA",
+ "lt", "lt_LT", "lv", "lv_LV", "mk", "mk_MK", "ml", "ml_IN", "mn", "mn_MN",
+ "mr", "mr_IN", "ms", "ms_MY", "my", "my_MM", "nb", "nb_NO", "ne", "ne_NP",
+ "nl", "nl_NL", "or", "or_IN", "pa", "pa_IN", "pl", "pl_PL", "ps", "ps_AF",
+ "pt", "pt_BR", "pt_PT", "ro", "ro_RO", "ru", "ru_RU", "sd", "sd_IN", "si",
+ "si_LK", "sk", "sk_SK", "sl", "sl_SI", "so", "so_SO", "sq", "sq_AL", "sr",
+ "sr_Cyrl_RS", "sr_Latn", "sr_RS", "sv", "sv_SE", "sw", "sw_TZ", "ta",
+ "ta_IN", "te", "te_IN", "th", "th_TH", "tk", "tk_TM", "tr", "tr_TR", "uk",
+ "uk_UA", "ur", "ur_PK", "uz", "uz_UZ", "vi", "vi_VN", "yue", "yue_Hant",
+ "yue_Hant_HK", "yue_HK", "zh", "zh_CN", "zh_Hans", "zh_Hans_CN", "zh_Hant",
+ "zh_Hant_TW", "zh_TW", "zu", "zu_ZA"
+};
+
+static UBool U_CALLCONV cleanupKnownCanonicalized() {
+ gKnownCanonicalizedInitOnce.reset();
+ if (gKnownCanonicalized) { uhash_close(gKnownCanonicalized); }
+ return TRUE;
+}
+
+static void U_CALLCONV loadKnownCanonicalized(UErrorCode &status) {
+ ucln_common_registerCleanup(UCLN_COMMON_LOCALE_KNOWN_CANONICALIZED,
+ cleanupKnownCanonicalized);
+ LocalUHashtablePointer newKnownCanonicalizedMap(
+ uhash_open(uhash_hashChars, uhash_compareChars, nullptr, &status));
+ for (int32_t i = 0;
+ U_SUCCESS(status) && i < UPRV_LENGTHOF(KNOWN_CANONICALIZED);
+ i++) {
+ uhash_puti(newKnownCanonicalizedMap.getAlias(),
+ (void*)KNOWN_CANONICALIZED[i],
+ 1, &status);
+ }
+ if (U_FAILURE(status)) {
+ return;
+ }
+
+ gKnownCanonicalized = newKnownCanonicalizedMap.orphan();
+}
+
+class AliasData;
+
+/**
+ * A Builder class to build the alias data.
+ */
+class AliasDataBuilder {
+public:
+ AliasDataBuilder() {
+ }
+
+ // Build the AliasData from resource.
+ AliasData* build(UErrorCode &status);
+
+private:
+ void readAlias(UResourceBundle* alias,
+ UniqueCharStrings* strings,
+ LocalMemory<const char*>& types,
+ LocalMemory<int32_t>& replacementIndexes,
+ int32_t &length,
+ void (*checkType)(const char* type),
+ void (*checkReplacement)(const UnicodeString& replacement),
+ UErrorCode &status);
+
+ // Read the languageAlias data from alias to
+ // strings+types+replacementIndexes
+ // The number of record will be stored into length.
+ // Allocate length items for types, to store the type field.
+ // Allocate length items for replacementIndexes,
+ // to store the index in the strings for the replacement script.
+ void readLanguageAlias(UResourceBundle* alias,
+ UniqueCharStrings* strings,
+ LocalMemory<const char*>& types,
+ LocalMemory<int32_t>& replacementIndexes,
+ int32_t &length,
+ UErrorCode &status);
+
+ // Read the scriptAlias data from alias to
+ // strings+types+replacementIndexes
+ // Allocate length items for types, to store the type field.
+ // Allocate length items for replacementIndexes,
+ // to store the index in the strings for the replacement script.
+ void readScriptAlias(UResourceBundle* alias,
+ UniqueCharStrings* strings,
+ LocalMemory<const char*>& types,
+ LocalMemory<int32_t>& replacementIndexes,
+ int32_t &length, UErrorCode &status);
+
+ // Read the territoryAlias data from alias to
+ // strings+types+replacementIndexes
+ // Allocate length items for types, to store the type field.
+ // Allocate length items for replacementIndexes,
+ // to store the index in the strings for the replacement script.
+ void readTerritoryAlias(UResourceBundle* alias,
+ UniqueCharStrings* strings,
+ LocalMemory<const char*>& types,
+ LocalMemory<int32_t>& replacementIndexes,
+ int32_t &length, UErrorCode &status);
+
+ // Read the variantAlias data from alias to
+ // strings+types+replacementIndexes
+ // Allocate length items for types, to store the type field.
+ // Allocate length items for replacementIndexes,
+ // to store the index in the strings for the replacement variant.
+ void readVariantAlias(UResourceBundle* alias,
+ UniqueCharStrings* strings,
+ LocalMemory<const char*>& types,
+ LocalMemory<int32_t>& replacementIndexes,
+ int32_t &length, UErrorCode &status);
+};
+
+/**
+ * A class to hold the Alias Data.
+ */
+class AliasData : public UMemory {
+public:
+ static const AliasData* singleton(UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ // Do not get into loadData if the status already has error.
+ return nullptr;
+ }
+ umtx_initOnce(AliasData::gInitOnce, &AliasData::loadData, status);
+ return gSingleton;
+ }
+
+ const CharStringMap& languageMap() const { return language; }
+ const CharStringMap& scriptMap() const { return script; }
+ const CharStringMap& territoryMap() const { return territory; }
+ const CharStringMap& variantMap() const { return variant; }
+
+ static void U_CALLCONV loadData(UErrorCode &status);
+ static UBool U_CALLCONV cleanup();
+
+ static UInitOnce gInitOnce;
+
+private:
+ AliasData(CharStringMap languageMap,
+ CharStringMap scriptMap,
+ CharStringMap territoryMap,
+ CharStringMap variantMap,
+ CharString* strings)
+ : language(std::move(languageMap)),
+ script(std::move(scriptMap)),
+ territory(std::move(territoryMap)),
+ variant(std::move(variantMap)),
+ strings(strings) {
+ }
+
+ ~AliasData() {
+ delete strings;
+ }
+
+ static const AliasData* gSingleton;
+
+ CharStringMap language;
+ CharStringMap script;
+ CharStringMap territory;
+ CharStringMap variant;
+ CharString* strings;
+
+ friend class AliasDataBuilder;
+};
+
+
+const AliasData* AliasData::gSingleton = nullptr;
+UInitOnce AliasData::gInitOnce = U_INITONCE_INITIALIZER;
+
+UBool U_CALLCONV
+AliasData::cleanup()
+{
+ gInitOnce.reset();
+ delete gSingleton;
+ return TRUE;
+}
+
+void
+AliasDataBuilder::readAlias(
+ UResourceBundle* alias,
+ UniqueCharStrings* strings,
+ LocalMemory<const char*>& types,
+ LocalMemory<int32_t>& replacementIndexes,
+ int32_t &length,
+ void (*checkType)(const char* type),
+ void (*checkReplacement)(const UnicodeString& replacement),
+ UErrorCode &status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
+ length = ures_getSize(alias);
+ const char** rawTypes = types.allocateInsteadAndCopy(length);
+ if (rawTypes == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ int32_t* rawIndexes = replacementIndexes.allocateInsteadAndCopy(length);
+ if (rawIndexes == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ int i = 0;
+ while (ures_hasNext(alias)) {
+ LocalUResourceBundlePointer res(
+ ures_getNextResource(alias, nullptr, &status));
+ const char* aliasFrom = ures_getKey(res.getAlias());
+ UnicodeString aliasTo =
+ ures_getUnicodeStringByKey(res.getAlias(), "replacement", &status);
+
+ checkType(aliasFrom);
+ checkReplacement(aliasTo);
+
+ rawTypes[i] = aliasFrom;
+ rawIndexes[i] = strings->add(aliasTo, status);
+ i++;
+ }
+}
+
+/**
+ * Read the languageAlias data from alias to strings+types+replacementIndexes.
+ * Allocate length items for types, to store the type field. Allocate length
+ * items for replacementIndexes, to store the index in the strings for the
+ * replacement language.
+ */
+void
+AliasDataBuilder::readLanguageAlias(
+ UResourceBundle* alias,
+ UniqueCharStrings* strings,
+ LocalMemory<const char*>& types,
+ LocalMemory<int32_t>& replacementIndexes,
+ int32_t &length,
+ UErrorCode &status)
+{
+ return readAlias(
+ alias, strings, types, replacementIndexes, length,
+#if U_DEBUG
+ [](const char* type) {
+ // Assert the aliasFrom only contains the following possibilties
+ // language_REGION_variant
+ // language_REGION
+ // language_variant
+ // language
+ // und_variant
+ Locale test(type);
+ // Assert no script in aliasFrom
+ U_ASSERT(test.getScript()[0] == '\0');
+ // Assert when language is und, no REGION in aliasFrom.
+ U_ASSERT(test.getLanguage()[0] != '\0' || test.getCountry()[0] == '\0');
+ },
+#else
+ [](const char*) {},
+#endif
+ [](const UnicodeString&) {}, status);
+}
+
+/**
+ * Read the scriptAlias data from alias to strings+types+replacementIndexes.
+ * Allocate length items for types, to store the type field. Allocate length
+ * items for replacementIndexes, to store the index in the strings for the
+ * replacement script.
+ */
+void
+AliasDataBuilder::readScriptAlias(
+ UResourceBundle* alias,
+ UniqueCharStrings* strings,
+ LocalMemory<const char*>& types,
+ LocalMemory<int32_t>& replacementIndexes,
+ int32_t &length,
+ UErrorCode &status)
+{
+ return readAlias(
+ alias, strings, types, replacementIndexes, length,
+#if U_DEBUG
+ [](const char* type) {
+ U_ASSERT(uprv_strlen(type) == 4);
+ },
+ [](const UnicodeString& replacement) {
+ U_ASSERT(replacement.length() == 4);
+ },
+#else
+ [](const char*) {},
+ [](const UnicodeString&) { },
+#endif
+ status);
+}
+
+/**
+ * Read the territoryAlias data from alias to strings+types+replacementIndexes.
+ * Allocate length items for types, to store the type field. Allocate length
+ * items for replacementIndexes, to store the index in the strings for the
+ * replacement regions.
+ */
+void
+AliasDataBuilder::readTerritoryAlias(
+ UResourceBundle* alias,
+ UniqueCharStrings* strings,
+ LocalMemory<const char*>& types,
+ LocalMemory<int32_t>& replacementIndexes,
+ int32_t &length,
+ UErrorCode &status)
+{
+ return readAlias(
+ alias, strings, types, replacementIndexes, length,
+#if U_DEBUG
+ [](const char* type) {
+ U_ASSERT(uprv_strlen(type) == 2 || uprv_strlen(type) == 3);
+ },
+#else
+ [](const char*) {},
+#endif
+ [](const UnicodeString&) { },
+ status);
+}
+
+/**
+ * Read the variantAlias data from alias to strings+types+replacementIndexes.
+ * Allocate length items for types, to store the type field. Allocate length
+ * items for replacementIndexes, to store the index in the strings for the
+ * replacement variant.
+ */
+void
+AliasDataBuilder::readVariantAlias(
+ UResourceBundle* alias,
+ UniqueCharStrings* strings,
+ LocalMemory<const char*>& types,
+ LocalMemory<int32_t>& replacementIndexes,
+ int32_t &length,
+ UErrorCode &status)
+{
+ return readAlias(
+ alias, strings, types, replacementIndexes, length,
+#if U_DEBUG
+ [](const char* type) {
+ U_ASSERT(uprv_strlen(type) >= 4 && uprv_strlen(type) <= 8);
+ U_ASSERT(uprv_strlen(type) != 4 ||
+ (type[0] >= '0' && type[0] <= '9'));
+ },
+ [](const UnicodeString& replacement) {
+ U_ASSERT(replacement.length() >= 4 && replacement.length() <= 8);
+ U_ASSERT(replacement.length() != 4 ||
+ (replacement.charAt(0) >= u'0' &&
+ replacement.charAt(0) <= u'9'));
+ },
+#else
+ [](const char*) {},
+ [](const UnicodeString&) { },
+#endif
+ status);
+}
+
+/**
+ * Initializes the alias data from the ICU resource bundles. The alias data
+ * contains alias of language, country, script and variants.
+ *
+ * If the alias data has already loaded, then this method simply returns without
+ * doing anything meaningful.
+ */
+void U_CALLCONV
+AliasData::loadData(UErrorCode &status)
+{
+#ifdef LOCALE_CANONICALIZATION_DEBUG
+ UDate start = uprv_getRawUTCtime();
+#endif // LOCALE_CANONICALIZATION_DEBUG
+ ucln_common_registerCleanup(UCLN_COMMON_LOCALE_ALIAS, cleanup);
+ AliasDataBuilder builder;
+ gSingleton = builder.build(status);
+#ifdef LOCALE_CANONICALIZATION_DEBUG
+ UDate end = uprv_getRawUTCtime();
+ printf("AliasData::loadData took total %f ms\n", end - start);
+#endif // LOCALE_CANONICALIZATION_DEBUG
+}
+
+/**
+ * Build the alias data from resources.
+ */
+AliasData*
+AliasDataBuilder::build(UErrorCode &status) {
+ LocalUResourceBundlePointer metadata(
+ ures_openDirect(nullptr, "metadata", &status));
+ LocalUResourceBundlePointer metadataAlias(
+ ures_getByKey(metadata.getAlias(), "alias", nullptr, &status));
+ LocalUResourceBundlePointer languageAlias(
+ ures_getByKey(metadataAlias.getAlias(), "language", nullptr, &status));
+ LocalUResourceBundlePointer scriptAlias(
+ ures_getByKey(metadataAlias.getAlias(), "script", nullptr, &status));
+ LocalUResourceBundlePointer territoryAlias(
+ ures_getByKey(metadataAlias.getAlias(), "territory", nullptr, &status));
+ LocalUResourceBundlePointer variantAlias(
+ ures_getByKey(metadataAlias.getAlias(), "variant", nullptr, &status));
+
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
+ int32_t languagesLength = 0, scriptLength = 0, territoryLength = 0,
+ variantLength = 0;
+
+ // Read the languageAlias into languageTypes, languageReplacementIndexes
+ // and strings
+ UniqueCharStrings strings(status);
+ LocalMemory<const char*> languageTypes;
+ LocalMemory<int32_t> languageReplacementIndexes;
+ readLanguageAlias(languageAlias.getAlias(),
+ &strings,
+ languageTypes,
+ languageReplacementIndexes,
+ languagesLength,
+ status);
+
+ // Read the scriptAlias into scriptTypes, scriptReplacementIndexes
+ // and strings
+ LocalMemory<const char*> scriptTypes;
+ LocalMemory<int32_t> scriptReplacementIndexes;
+ readScriptAlias(scriptAlias.getAlias(),
+ &strings,
+ scriptTypes,
+ scriptReplacementIndexes,
+ scriptLength,
+ status);
+
+ // Read the territoryAlias into territoryTypes, territoryReplacementIndexes
+ // and strings
+ LocalMemory<const char*> territoryTypes;
+ LocalMemory<int32_t> territoryReplacementIndexes;
+ readTerritoryAlias(territoryAlias.getAlias(),
+ &strings,
+ territoryTypes,
+ territoryReplacementIndexes,
+ territoryLength, status);
+
+ // Read the variantAlias into variantTypes, variantReplacementIndexes
+ // and strings
+ LocalMemory<const char*> variantTypes;
+ LocalMemory<int32_t> variantReplacementIndexes;
+ readVariantAlias(variantAlias.getAlias(),
+ &strings,
+ variantTypes,
+ variantReplacementIndexes,
+ variantLength, status);
+
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
+
+ // We can only use strings after freeze it.
+ strings.freeze();
+
+ // Build the languageMap from languageTypes & languageReplacementIndexes
+ CharStringMap languageMap(490, status);
+ for (int32_t i = 0; U_SUCCESS(status) && i < languagesLength; i++) {
+ languageMap.put(languageTypes[i],
+ strings.get(languageReplacementIndexes[i]),
+ status);
+ }
+
+ // Build the scriptMap from scriptTypes & scriptReplacementIndexes
+ CharStringMap scriptMap(1, status);
+ for (int32_t i = 0; U_SUCCESS(status) && i < scriptLength; i++) {
+ scriptMap.put(scriptTypes[i],
+ strings.get(scriptReplacementIndexes[i]),
+ status);
+ }
+
+ // Build the territoryMap from territoryTypes & territoryReplacementIndexes
+ CharStringMap territoryMap(650, status);
+ for (int32_t i = 0; U_SUCCESS(status) && i < territoryLength; i++) {
+ territoryMap.put(territoryTypes[i],
+ strings.get(territoryReplacementIndexes[i]),
+ status);
+ }
+
+ // Build the variantMap from variantTypes & variantReplacementIndexes.
+ CharStringMap variantMap(2, status);
+ for (int32_t i = 0; U_SUCCESS(status) && i < variantLength; i++) {
+ variantMap.put(variantTypes[i],
+ strings.get(variantReplacementIndexes[i]),
+ status);
+ }
+
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
+
+ // copy hashtables
+ auto *data = new AliasData(
+ std::move(languageMap),
+ std::move(scriptMap),
+ std::move(territoryMap),
+ std::move(variantMap),
+ strings.orphanCharStrings());
+
+ if (data == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ }
+ return data;
+}
+
+/**
+ * A class that find the replacement values of locale fields by using AliasData.
+ */
+class AliasReplacer {
+public:
+ AliasReplacer(UErrorCode status) :
+ language(nullptr), script(nullptr), region(nullptr),
+ extensions(nullptr), variants(status),
+ data(nullptr) {
+ }
+ ~AliasReplacer() {
+ }
+
+ // Check the fields inside locale, if need to replace fields,
+ // place the the replaced locale ID in out and return true.
+ // Otherwise return false for no replacement or error.
+ bool replace(
+ const Locale& locale, CharString& out, UErrorCode status);
+
+private:
+ const char* language;
+ const char* script;
+ const char* region;
+ const char* extensions;
+ UVector variants;
+
+ const AliasData* data;
+
+ inline bool notEmpty(const char* str) {
+ return str && str[0] != NULL_CHAR;
+ }
+
+ /**
+ * If replacement is neither null nor empty and input is either null or empty,
+ * return replacement.
+ * If replacement is neither null nor empty but input is not empty, return input.
+ * If replacement is either null or empty and type is either null or empty,
+ * return input.
+ * Otherwise return null.
+ * replacement input type return
+ * AAA nullptr * AAA
+ * AAA BBB * BBB
+ * nullptr || "" CCC nullptr CCC
+ * nullptr || "" * DDD nullptr
+ */
+ inline const char* deleteOrReplace(
+ const char* input, const char* type, const char* replacement) {
+ return notEmpty(replacement) ?
+ ((input == nullptr) ? replacement : input) :
+ ((type == nullptr) ? input : nullptr);
+ }
+
+ inline bool same(const char* a, const char* b) {
+ if (a == nullptr && b == nullptr) {
+ return true;
+ }
+ if ((a == nullptr && b != nullptr) ||
+ (a != nullptr && b == nullptr)) {
+ return false;
+ }
+ return uprv_strcmp(a, b) == 0;
+ }
+
+ // Gather fields and generate locale ID into out.
+ CharString& outputToString(CharString& out, UErrorCode status);
+
+ // Generate the lookup key.
+ CharString& generateKey(const char* language, const char* region,
+ const char* variant, CharString& out,
+ UErrorCode status);
+
+ void parseLanguageReplacement(const char* replacement,
+ const char*& replaceLanguage,
+ const char*& replaceScript,
+ const char*& replaceRegion,
+ const char*& replaceVariant,
+ const char*& replaceExtensions,
+ UVector& toBeFreed,
+ UErrorCode& status);
+
+ // Replace by using languageAlias.
+ bool replaceLanguage(bool checkLanguage, bool checkRegion,
+ bool checkVariants, UVector& toBeFreed,
+ UErrorCode& status);
+
+ // Replace by using territoryAlias.
+ bool replaceTerritory(UVector& toBeFreed, UErrorCode& status);
+
+ // Replace by using scriptAlias.
+ bool replaceScript(UErrorCode& status);
+
+ // Replace by using variantAlias.
+ bool replaceVariant(UErrorCode& status);
+};
+
+CharString&
+AliasReplacer::generateKey(
+ const char* language, const char* region, const char* variant,
+ CharString& out, UErrorCode status)
+{
out.append(language, status);
- if (script && script[0] != '\0') {
- out.append('_', status);
- out.append(script, status);
- }
- if (country && country[0] != '\0') {
- out.append('_', status);
- out.append(country, status);
- }
- if (variants && variants[0] != '\0') {
- if ((script == nullptr || script[0] == '\0') &&
- (country == nullptr || country[0] == '\0')) {
- out.append('_', status);
+ if (notEmpty(region)) {
+ out.append(SEP_CHAR, status)
+ .append(region, status);
+ }
+ if (notEmpty(variant)) {
+ out.append(SEP_CHAR, status)
+ .append(variant, status);
+ }
+ return out;
+}
+
+void
+AliasReplacer::parseLanguageReplacement(
+ const char* replacement,
+ const char*& replacedLanguage,
+ const char*& replacedScript,
+ const char*& replacedRegion,
+ const char*& replacedVariant,
+ const char*& replacedExtensions,
+ UVector& toBeFreed,
+ UErrorCode& status)
+{
+ if (U_FAILURE(status)) {
+ return;
+ }
+ replacedScript = replacedRegion = replacedVariant
+ = replacedExtensions = nullptr;
+ if (uprv_strchr(replacement, '_') == nullptr) {
+ replacedLanguage = replacement;
+ // reach the end, just return it.
+ return;
+ }
+ // We have multiple field so we have to allocate and parse
+ CharString* str = new CharString(
+ replacement, (int32_t)uprv_strlen(replacement), status);
+ if (U_FAILURE(status)) {
+ return;
+ }
+ if (str == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ toBeFreed.addElement(str, status);
+ char* data = str->data();
+ replacedLanguage = (const char*) data;
+ char* endOfField = uprv_strchr(data, '_');
+ *endOfField = '\0'; // null terminiate it.
+ endOfField++;
+ const char* start = endOfField;
+ endOfField = (char*) uprv_strchr(start, '_');
+ size_t len = 0;
+ if (endOfField == nullptr) {
+ len = uprv_strlen(start);
+ } else {
+ len = endOfField - start;
+ *endOfField = '\0'; // null terminiate it.
+ }
+ if (len == 4 && uprv_isASCIILetter(*start)) {
+ // Got a script
+ replacedScript = start;
+ if (endOfField == nullptr) {
+ return;
+ }
+ start = endOfField++;
+ endOfField = (char*)uprv_strchr(start, '_');
+ if (endOfField == nullptr) {
+ len = uprv_strlen(start);
+ } else {
+ len = endOfField - start;
+ *endOfField = '\0'; // null terminiate it.
+ }
+ }
+ if (len >= 2 && len <= 3) {
+ // Got a region
+ replacedRegion = start;
+ if (endOfField == nullptr) {
+ return;
+ }
+ start = endOfField++;
+ endOfField = (char*)uprv_strchr(start, '_');
+ if (endOfField == nullptr) {
+ len = uprv_strlen(start);
+ } else {
+ len = endOfField - start;
+ *endOfField = '\0'; // null terminiate it.
+ }
+ }
+ if (len >= 4) {
+ // Got a variant
+ replacedVariant = start;
+ if (endOfField == nullptr) {
+ return;
}
- out.append('_', status);
- out.append(variants, status);
+ start = endOfField++;
+ }
+ replacedExtensions = start;
+}
+
+bool
+AliasReplacer::replaceLanguage(
+ bool checkLanguage, bool checkRegion,
+ bool checkVariants, UVector& toBeFreed, UErrorCode& status)
+{
+ if (U_FAILURE(status)) {
+ return false;
+ }
+ if ( (checkRegion && region == nullptr) ||
+ (checkVariants && variants.size() == 0)) {
+ // Nothing to search.
+ return false;
+ }
+ int32_t variant_size = checkVariants ? variants.size() : 1;
+ // Since we may have more than one variant, we need to loop through them.
+ const char* searchLanguage = checkLanguage ? language : "und";
+ const char* searchRegion = checkRegion ? region : nullptr;
+ const char* searchVariant = nullptr;
+ for (int32_t variant_index = 0;
+ variant_index < variant_size;
+ variant_index++) {
+ if (checkVariants) {
+ U_ASSERT(variant_index < variant_size);
+ searchVariant = (const char*)(variants.elementAt(variant_index));
+ }
+
+ if (searchVariant != nullptr && uprv_strlen(searchVariant) < 4) {
+ // Do not consider ill-formed variant subtag.
+ searchVariant = nullptr;
+ }
+ CharString typeKey;
+ generateKey(searchLanguage, searchRegion, searchVariant, typeKey,
+ status);
+ if (U_FAILURE(status)) {
+ return false;
+ }
+ const char *replacement = data->languageMap().get(typeKey.data());
+ if (replacement == nullptr) {
+ // Found no replacement data.
+ continue;
+ }
+
+ const char* replacedLanguage = nullptr;
+ const char* replacedScript = nullptr;
+ const char* replacedRegion = nullptr;
+ const char* replacedVariant = nullptr;
+ const char* replacedExtensions = nullptr;
+ parseLanguageReplacement(replacement,
+ replacedLanguage,
+ replacedScript,
+ replacedRegion,
+ replacedVariant,
+ replacedExtensions,
+ toBeFreed,
+ status);
+ replacedLanguage =
+ (replacedLanguage != nullptr && uprv_strcmp(replacedLanguage, "und") == 0) ?
+ language : replacedLanguage;
+ replacedScript = deleteOrReplace(script, nullptr, replacedScript);
+ replacedRegion = deleteOrReplace(region, searchRegion, replacedRegion);
+ replacedVariant = deleteOrReplace(
+ searchVariant, searchVariant, replacedVariant);
+
+ if ( same(language, replacedLanguage) &&
+ same(script, replacedScript) &&
+ same(region, replacedRegion) &&
+ same(searchVariant, replacedVariant) &&
+ replacedExtensions == nullptr) {
+ // Replacement produce no changes.
+ continue;
+ }
+
+ language = replacedLanguage;
+ region = replacedRegion;
+ script = replacedScript;
+ if (searchVariant != nullptr) {
+ if (notEmpty(replacedVariant)) {
+ variants.setElementAt((void*)replacedVariant, variant_index);
+ } else {
+ variants.removeElementAt(variant_index);
+ }
+ }
+ if (replacedExtensions != nullptr) {
+ // TODO(ICU-21292)
+ // DO NOTHING
+ // UTS35 does not specifiy what should we do if we have extensions in the
+ // replacement. Currently we know only the following 4 "BCP47 LegacyRules" have
+ // extensions in them languageAlias:
+ // i_default => en_x_i_default
+ // i_enochian => und_x_i_enochian
+ // i_mingo => see_x_i_mingo
+ // zh_min => nan_x_zh_min
+ // But all of them are already changed by code inside ultag_parse() before
+ // hitting this code.
+ }
+
+ // Something changed by language alias data.
+ return true;
+ }
+ // Nothing changed by language alias data.
+ return false;
+}
+
+bool
+AliasReplacer::replaceTerritory(UVector& toBeFreed, UErrorCode& status)
+{
+ if (U_FAILURE(status)) {
+ return false;
+ }
+ if (region == nullptr) {
+ // No region to search.
+ return false;
+ }
+ const char *replacement = data->territoryMap().get(region);
+ if (replacement == nullptr) {
+ // Found no replacement data for this region.
+ return false;
+ }
+ const char* replacedRegion = replacement;
+ const char* firstSpace = uprv_strchr(replacement, ' ');
+ if (firstSpace != nullptr) {
+ // If there are are more than one region in the replacement.
+ // We need to check which one match based on the language.
+ // Cannot use nullptr for language because that will construct
+ // the default locale, in that case, use "und" to get the correct
+ // locale.
+ Locale l(language == nullptr ? "und" : language, nullptr, script);
+ l.addLikelySubtags(status);
+ const char* likelyRegion = l.getCountry();
+ CharString* item = nullptr;
+ if (likelyRegion != nullptr && uprv_strlen(likelyRegion) > 0) {
+ size_t len = uprv_strlen(likelyRegion);
+ const char* foundInReplacement = uprv_strstr(replacement,
+ likelyRegion);
+ if (foundInReplacement != nullptr) {
+ // Assuming the case there are no three letter region code in
+ // the replacement of territoryAlias
+ U_ASSERT(foundInReplacement == replacement ||
+ *(foundInReplacement-1) == ' ');
+ U_ASSERT(foundInReplacement[len] == ' ' ||
+ foundInReplacement[len] == '\0');
+ item = new CharString(foundInReplacement, (int32_t)len, status);
+ }
+ }
+ if (item == nullptr) {
+ item = new CharString(replacement,
+ (int32_t)(firstSpace - replacement), status);
+ }
+ if (U_FAILURE(status)) { return false; }
+ if (item == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return false;
+ }
+ replacedRegion = item->data();
+ toBeFreed.addElement(item, status);
+ }
+ U_ASSERT(!same(region, replacedRegion));
+ region = replacedRegion;
+ // The region is changed by data in territory alias.
+ return true;
+}
+
+bool
+AliasReplacer::replaceScript(UErrorCode& status)
+{
+ if (U_FAILURE(status)) {
+ return false;
+ }
+ if (script == nullptr) {
+ // No script to search.
+ return false;
}
- if (extension && extension[0] != '\0') {
- out.append(extension, status);
+ const char *replacement = data->scriptMap().get(script);
+ if (replacement == nullptr) {
+ // Found no replacement data for this script.
+ return false;
+ }
+ U_ASSERT(!same(script, replacement));
+ script = replacement;
+ // The script is changed by data in script alias.
+ return true;
+}
+
+bool
+AliasReplacer::replaceVariant(UErrorCode& status)
+{
+ if (U_FAILURE(status)) {
+ return false;
+ }
+ // Since we may have more than one variant, we need to loop through them.
+ for (int32_t i = 0; i < variants.size(); i++) {
+ const char *variant = (const char*)(variants.elementAt(i));
+ const char *replacement = data->variantMap().get(variant);
+ if (replacement == nullptr) {
+ // Found no replacement data for this variant.
+ continue;
+ }
+ U_ASSERT((uprv_strlen(replacement) >= 5 &&
+ uprv_strlen(replacement) <= 8) ||
+ (uprv_strlen(replacement) == 4 &&
+ replacement[0] >= '0' &&
+ replacement[0] <= '9'));
+ if (!same(variant, replacement)) {
+ variants.setElementAt((void*)replacement, i);
+ // Special hack to handle hepburn-heploc => alalc97
+ if (uprv_strcmp(variant, "heploc") == 0) {
+ for (int32_t j = 0; j < variants.size(); j++) {
+ if (uprv_strcmp((const char*)(variants.elementAt(j)),
+ "hepburn") == 0) {
+ variants.removeElementAt(j);
+ }
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
+CharString&
+AliasReplacer::outputToString(
+ CharString& out, UErrorCode status)
+{
+ out.append(language, status);
+ if (notEmpty(script)) {
+ out.append(SEP_CHAR, status)
+ .append(script, status);
+ }
+ if (notEmpty(region)) {
+ out.append(SEP_CHAR, status)
+ .append(region, status);
+ }
+ if (variants.size() > 0) {
+ if (!notEmpty(script) && !notEmpty(region)) {
+ out.append(SEP_CHAR, status);
+ }
+ variants.sort([](UElement e1, UElement e2) -> int8_t {
+ return uprv_strcmp(
+ (const char*)e1.pointer, (const char*)e2.pointer);
+ }, status);
+ int32_t variantsStart = out.length();
+ for (int32_t i = 0; i < variants.size(); i++) {
+ out.append(SEP_CHAR, status)
+ .append((const char*)((UVector*)variants.elementAt(i)),
+ status);
+ }
+ T_CString_toUpperCase(out.data() + variantsStart);
+ }
+ if (notEmpty(extensions)) {
+ CharString tmp("und_", status);
+ tmp.append(extensions, status);
+ Locale tmpLocale(tmp.data());
+ // only support x extension inside CLDR for now.
+ U_ASSERT(extensions[0] == 'x');
+ out.append(tmpLocale.getName() + 1, status);
}
return out;
}
+bool
+AliasReplacer::replace(const Locale& locale, CharString& out, UErrorCode status)
+{
+ data = AliasData::singleton(status);
+ if (U_FAILURE(status)) {
+ return false;
+ }
+ U_ASSERT(data != nullptr);
+ out.clear();
+ language = locale.getLanguage();
+ if (!notEmpty(language)) {
+ language = nullptr;
+ }
+ script = locale.getScript();
+ if (!notEmpty(script)) {
+ script = nullptr;
+ }
+ region = locale.getCountry();
+ if (!notEmpty(region)) {
+ region = nullptr;
+ }
+ const char* variantsStr = locale.getVariant();
+ const char* extensionsStr = locale_getKeywordsStart(locale.getName());
+ CharString variantsBuff(variantsStr, -1, status);
+ if (!variantsBuff.isEmpty()) {
+ if (U_FAILURE(status)) { return false; }
+ char* start = variantsBuff.data();
+ T_CString_toLowerCase(start);
+ char* end;
+ while ((end = uprv_strchr(start, SEP_CHAR)) != nullptr &&
+ U_SUCCESS(status)) {
+ *end = NULL_CHAR; // null terminate inside variantsBuff
+ variants.addElement(start, status);
+ start = end + 1;
+ }
+ variants.addElement(start, status);
+ }
+ if (U_FAILURE(status)) { return false; }
+
+ // Sort the variants
+ variants.sort([](UElement e1, UElement e2) -> int8_t {
+ return uprv_strcmp(
+ (const char*)e1.pointer, (const char*)e2.pointer);
+ }, status);
+
+ // A changed count to assert when loop too many times.
+ int changed = 0;
+ // A UVector to to hold CharString allocated by the replace* method
+ // and freed when out of scope from his function.
+ UVector stringsToBeFreed([](void *obj){ delete ((CharString*) obj); },
+ nullptr, 10, status);
+ while (U_SUCCESS(status)) {
+ // Something wrong with the data cause looping here more than 10 times
+ // already.
+ U_ASSERT(changed < 5);
+ // From observation of key in data/misc/metadata.txt
+ // we know currently we only need to search in the following combination
+ // of fields for type in languageAlias:
+ // * lang_region_variant
+ // * lang_region
+ // * lang_variant
+ // * lang
+ // * und_variant
+ // This assumption is ensured by the U_ASSERT in readLanguageAlias
+ //
+ // lang REGION variant
+ if ( replaceLanguage(true, true, true, stringsToBeFreed, status) ||
+ replaceLanguage(true, true, false, stringsToBeFreed, status) ||
+ replaceLanguage(true, false, true, stringsToBeFreed, status) ||
+ replaceLanguage(true, false, false, stringsToBeFreed, status) ||
+ replaceLanguage(false,false, true, stringsToBeFreed, status) ||
+ replaceTerritory(stringsToBeFreed, status) ||
+ replaceScript(status) ||
+ replaceVariant(status)) {
+ // Some values in data is changed, try to match from the beginning
+ // again.
+ changed++;
+ continue;
+ }
+ // Nothing changed. Break out.
+ break;
+ } // while(1)
+
+ if (U_FAILURE(status)) { return false; }
+ // Nothing changed and we know the order of the vaiants are not change
+ // because we have no variant or only one.
+ if (changed == 0 && variants.size() <= 1) {
+ return false;
+ }
+ outputToString(out, status);
+ if (extensionsStr != nullptr) {
+ out.append(extensionsStr, status);
+ }
+ if (U_FAILURE(status)) {
+ return false;
+ }
+ // If the tag is not changed, return.
+ if (uprv_strcmp(out.data(), locale.getName()) == 0) {
+ U_ASSERT(changed == 0);
+ U_ASSERT(variants.size() > 1);
+ out.clear();
+ return false;
+ }
+ return true;
+}
+
+// Return true if the locale is changed during canonicalization.
+// The replaced value then will be put into out.
+bool
+canonicalizeLocale(const Locale& locale, CharString& out, UErrorCode& status)
+{
+ AliasReplacer replacer(status);
+ return replacer.replace(locale, out, status);
+}
+
+// Function to optimize for known cases without so we can skip the loading
+// of resources in the startup time until we really need it.
+bool
+isKnownCanonicalizedLocale(const char* locale, UErrorCode& status)
+{
+ if ( uprv_strcmp(locale, "c") == 0 ||
+ uprv_strcmp(locale, "en") == 0 ||
+ uprv_strcmp(locale, "en_US") == 0) {
+ return true;
+ }
+
+ // common well-known Canonicalized.
+ umtx_initOnce(gKnownCanonicalizedInitOnce,
+ &loadKnownCanonicalized, status);
+ if (U_FAILURE(status)) {
+ return false;
+ }
+ U_ASSERT(gKnownCanonicalized != nullptr);
+ return uhash_geti(gKnownCanonicalized, locale) != 0;
+}
+
} // namespace
+// Function for testing.
+U_CAPI const char* const*
+ulocimp_getKnownCanonicalizedLocaleForTest(int32_t* length)
+{
+ *length = UPRV_LENGTHOF(KNOWN_CANONICALIZED);
+ return KNOWN_CANONICALIZED;
+}
+
+// Function for testing.
+U_CAPI bool
+ulocimp_isCanonicalizedLocaleForTest(const char* localeName)
+{
+ Locale l(localeName);
+ UErrorCode status = U_ZERO_ERROR;
+ CharString temp;
+ return !canonicalizeLocale(l, temp, status) && U_SUCCESS(status);
+}
+
/*This function initializes a Locale from a C locale ID*/
Locale& Locale::init(const char* localeID, UBool canonicalize)
{
@@ -632,9 +1719,9 @@ Locale& Locale::init(const char* localeID, UBool canonicalize)
uprv_memcpy(language, fullName, fieldLen[0]);
language[fieldLen[0]] = 0;
}
- if (fieldLen[1] == 4 && ISASCIIALPHA(field[1][0]) &&
- ISASCIIALPHA(field[1][1]) && ISASCIIALPHA(field[1][2]) &&
- ISASCIIALPHA(field[1][3])) {
+ if (fieldLen[1] == 4 && uprv_isASCIILetter(field[1][0]) &&
+ uprv_isASCIILetter(field[1][1]) && uprv_isASCIILetter(field[1][2]) &&
+ uprv_isASCIILetter(field[1][3])) {
/* We have at least a script */
uprv_memcpy(script, field[1], fieldLen[1]);
script[fieldLen[1]] = 0;
@@ -662,192 +1749,18 @@ Locale& Locale::init(const char* localeID, UBool canonicalize)
}
if (canonicalize) {
- UErrorCode status = U_ZERO_ERROR;
- // TODO: Try to use ResourceDataValue and ures_getValueWithFallback() etc.
- LocalUResourceBundlePointer metadata(ures_openDirect(NULL, "metadata", &status));
- LocalUResourceBundlePointer metadataAlias(ures_getByKey(metadata.getAlias(), "alias", NULL, &status));
- // Look up the metadata:alias:language:$key:replacement entries
- // key could be one of the following:
- // language
- // language_Script_REGION
- // language_REGION
- // language_variant
- do {
- // The resource structure looks like
- // metadata {
- // alias {
- // language {
- // art_lojban {
- // replacement{"jbo"}
- // }
- // ...
- // ks_Arab_IN {
- // replacement{"ks_IN"}
- // }
- // ...
- // no {
- // replacement{"nb"}
- // }
- // ....
- // zh_CN {
- // replacement{"zh_Hans_CN"}
- // }
- // }
- // ...
- // }
- // }
- LocalUResourceBundlePointer languageAlias(ures_getByKey(metadataAlias.getAlias(), "language", NULL, &status));
- if (U_FAILURE(status))
+ if (!isKnownCanonicalizedLocale(fullName, err)) {
+ CharString replaced;
+ // Not sure it is already canonicalized
+ if (canonicalizeLocale(*this, replaced, err)) {
+ U_ASSERT(U_SUCCESS(err));
+ // If need replacement, call init again.
+ init(replaced.data(), false);
+ }
+ if (U_FAILURE(err)) {
break;
- CharString temp;
- // Handle cases of key pattern "language _ variant"
- // ex: Map "art_lojban" to "jbo"
- const char* variants = getVariant();
- if (variants != nullptr && variants[0] != '\0') {
- const char* begin = variants;
- const char* end = begin;
- // We may have multiple variants, need to look at each of
- // them.
- do {
- status = U_ZERO_ERROR;
- end = uprv_strchr(begin, '_');
- int32_t len = (end == nullptr) ? int32_t(uprv_strlen(begin)) : int32_t(end - begin);
- temp.clear().append(getLanguage(), status).append("_", status).append(begin, len, status);
- LocalUResourceBundlePointer languageVariantAlias(
- ures_getByKey(languageAlias.getAlias(),
- temp.data(),
- NULL, &status));
- temp.clear().appendInvariantChars(
- UnicodeString(ures_getStringByKey(languageVariantAlias.getAlias(), "replacement", nullptr, &status)), status);
- if (U_SUCCESS(status)) {
- CharString newVar;
- if (begin != variants) {
- newVar.append(variants, static_cast<int32_t>(begin - variants - 1), status);
- }
- if (end != nullptr) {
- if (begin != variants) {
- newVar.append("_", status);
- }
- newVar.append(end + 1, status);
- }
- Locale l(temp.data());
- init(AppendLSCVE(temp.clear(),
- l.getLanguage(),
- (getScript() != nullptr && getScript()[0] != '\0') ? getScript() : l.getScript(),
- (getCountry() != nullptr && getCountry()[0] != '\0') ? getCountry() : l.getCountry(),
- newVar.data(),
- uprv_strchr(fullName, '@'), status).data(), false);
- break;
- }
- begin = end + 1;
- } while (end != nullptr);
- } // End of handle language _ variant
- // Handle cases of key pattern "language _ Script _ REGION"
- // ex: Map "ks_Arab_IN" to "ks_IN"
- if (getScript() != nullptr && getScript()[0] != '\0' &&
- getCountry() != nullptr && getCountry()[0] != '\0') {
- status = U_ZERO_ERROR;
- LocalUResourceBundlePointer replacedAlias(
- ures_getByKey(languageAlias.getAlias(),
- AppendLSCVE(temp.clear(), getLanguage(), getScript(), getCountry(),
- nullptr, nullptr, status).data(), NULL, &status));
- temp.clear().appendInvariantChars(
- UnicodeString(ures_getStringByKey(replacedAlias.getAlias(), "replacement", nullptr, &status)), status);
- if (U_SUCCESS(status)) {
- Locale l(temp.data());
- init(AppendLSCVE(temp.clear(),
- l.getLanguage(),
- l.getScript(),
- l.getCountry(),
- getVariant(),
- uprv_strchr(fullName, '@'), status).data(), false);
- }
- } // End of handle language _ Script _ REGION
- // Handle cases of key pattern "language _ REGION"
- // ex: Map "zh_CN" to "zh_Hans_CN"
- if (getCountry() != nullptr && getCountry()[0] != '\0') {
- status = U_ZERO_ERROR;
- LocalUResourceBundlePointer replacedAlias(
- ures_getByKey(languageAlias.getAlias(),
- AppendLSCVE(temp.clear(), getLanguage(), nullptr, getCountry(),
- nullptr, nullptr, status).data(), NULL, &status));
- temp.clear().appendInvariantChars(
- UnicodeString(ures_getStringByKey(replacedAlias.getAlias(), "replacement", nullptr, &status)), status);
- if (U_SUCCESS(status)) {
- Locale l(temp.data());
- init(AppendLSCVE(temp.clear(),
- l.getLanguage(),
- (getScript() != nullptr && getScript()[0] != '\0') ? getScript() : l.getScript(),
- l.getCountry(),
- getVariant(),
- uprv_strchr(fullName, '@'), status).data(), false);
- }
- } // End of handle "language _ REGION"
- // Handle cases of key pattern "language"
- // ex: Map "no" to "nb"
- {
- status = U_ZERO_ERROR;
- LocalUResourceBundlePointer replaceLanguageAlias(ures_getByKey(languageAlias.getAlias(), getLanguage(), NULL, &status));
- temp.clear().appendInvariantChars(
- UnicodeString(ures_getStringByKey(replaceLanguageAlias.getAlias(), "replacement", nullptr, &status)), status);
- if (U_SUCCESS(status)) {
- Locale l(temp.data());
- init(AppendLSCVE(temp.clear(),
- l.getLanguage(),
- (getScript() != nullptr && getScript()[0] != '\0') ? getScript() : l.getScript(),
- (getCountry() != nullptr && getCountry()[0] != '\0') ? getCountry() : l.getCountry(),
- getVariant(),
- uprv_strchr(fullName, '@'), status).data(), false);
- }
- } // End of handle "language"
-
- // Look up the metadata:alias:territory:$key:replacement entries
- // key is region code.
- if (getCountry() != nullptr) {
- status = U_ZERO_ERROR;
- // The resource structure looks like
- // metadata {
- // alias {
- // ...
- // territory: {
- // 172 {
- // replacement{"RU AM AZ BY GE KG KZ MD TJ TM UA UZ"}
- // }
- // ...
- // 554 {
- // replacement{"NZ"}
- // }
- // }
- // }
- // }
- LocalUResourceBundlePointer territoryAlias(ures_getByKey(metadataAlias.getAlias(), "territory", NULL, &status));
- LocalUResourceBundlePointer countryAlias(ures_getByKey(territoryAlias.getAlias(), getCountry(), NULL, &status));
- UnicodeString replacements(
- ures_getStringByKey(countryAlias.getAlias(), "replacement", nullptr, &status));
- if (U_SUCCESS(status)) {
- CharString replacedCountry;
- int32_t delPos = replacements.indexOf(' ');
- if (delPos == -1) {
- replacedCountry.appendInvariantChars(replacements, status);
- } else {
- Locale l(AppendLSCVE(temp.clear(), getLanguage(), nullptr, getScript(),
- nullptr, nullptr, status).data());
- l.addLikelySubtags(status);
- if (replacements.indexOf(UnicodeString(l.getCountry())) != -1) {
- replacedCountry.append(l.getCountry(), status);
- } else {
- replacedCountry.appendInvariantChars(replacements.getBuffer(), delPos, status);
- }
- }
- init(AppendLSCVE(temp.clear(),
- getLanguage(),
- getScript(),
- replacedCountry.data(),
- getVariant(),
- uprv_strchr(fullName, '@'), status).data(), false);
- }
- } // End of handle REGION
- } while (0);
+ }
+ }
} // if (canonicalize) {
// successful end of init()
@@ -1024,13 +1937,14 @@ Locale::forLanguageTag(StringPiece tag, UErrorCode& status)
return result;
}
- // If a BCP-47 language tag is passed as the language parameter to the
+ // If a BCP 47 language tag is passed as the language parameter to the
// normal Locale constructor, it will actually fall back to invoking
// uloc_forLanguageTag() to parse it if it somehow is able to detect that
- // the string actually is BCP-47. This works well for things like strings
- // using BCP-47 extensions, but it does not at all work for things like
- // BCP-47 grandfathered tags (eg. "en-GB-oed") which are possible to also
- // interpret as ICU locale IDs and because of that won't trigger the BCP-47
+ // the string actually is BCP 47. This works well for things like strings
+ // using BCP 47 extensions, but it does not at all work for things like
+ // legacy language tags (marked as “Type: grandfathered” in BCP 47,
+ // e.g., "en-GB-oed") which are possible to also
+ // interpret as ICU locale IDs and because of that won't trigger the BCP 47
// parsing. Therefore the code here explicitly calls uloc_forLanguageTag()
// and then Locale::init(), instead of just calling the normal constructor.
@@ -1414,8 +2328,6 @@ UnicodeKeywordEnumeration::~UnicodeKeywordEnumeration() = default;
StringEnumeration *
Locale::createKeywords(UErrorCode &status) const
{
- char keywords[256];
- int32_t keywordCapacity = sizeof keywords;
StringEnumeration *result = NULL;
if (U_FAILURE(status)) {
@@ -1426,9 +2338,11 @@ Locale::createKeywords(UErrorCode &status) const
const char* assignment = uprv_strchr(fullName, '=');
if(variantStart) {
if(assignment > variantStart) {
- int32_t keyLen = locale_getKeywords(variantStart+1, '@', keywords, keywordCapacity, FALSE, &status);
- if(U_SUCCESS(status) && keyLen) {
- result = new KeywordEnumeration(keywords, keyLen, 0, status);
+ CharString keywords;
+ CharStringByteSink sink(&keywords);
+ ulocimp_getKeywords(variantStart+1, '@', sink, FALSE, &status);
+ if (U_SUCCESS(status) && !keywords.isEmpty()) {
+ result = new KeywordEnumeration(keywords.data(), keywords.length(), 0, status);
if (!result) {
status = U_MEMORY_ALLOCATION_ERROR;
}
@@ -1443,8 +2357,6 @@ Locale::createKeywords(UErrorCode &status) const
StringEnumeration *
Locale::createUnicodeKeywords(UErrorCode &status) const
{
- char keywords[256];
- int32_t keywordCapacity = sizeof keywords;
StringEnumeration *result = NULL;
if (U_FAILURE(status)) {
@@ -1455,9 +2367,11 @@ Locale::createUnicodeKeywords(UErrorCode &status) const
const char* assignment = uprv_strchr(fullName, '=');
if(variantStart) {
if(assignment > variantStart) {
- int32_t keyLen = locale_getKeywords(variantStart+1, '@', keywords, keywordCapacity, FALSE, &status);
- if(U_SUCCESS(status) && keyLen) {
- result = new UnicodeKeywordEnumeration(keywords, keyLen, 0, status);
+ CharString keywords;
+ CharStringByteSink sink(&keywords);
+ ulocimp_getKeywords(variantStart+1, '@', sink, FALSE, &status);
+ if (U_SUCCESS(status) && !keywords.isEmpty()) {
+ result = new UnicodeKeywordEnumeration(keywords.data(), keywords.length(), 0, status);
if (!result) {
status = U_MEMORY_ALLOCATION_ERROR;
}
@@ -1492,48 +2406,7 @@ Locale::getKeywordValue(StringPiece keywordName, ByteSink& sink, UErrorCode& sta
return;
}
- LocalMemory<char> scratch;
- int32_t scratch_capacity = 16; // Arbitrarily chosen default size.
-
- char* buffer;
- int32_t result_capacity, reslen;
-
- for (;;) {
- if (scratch.allocateInsteadAndReset(scratch_capacity) == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return;
- }
-
- buffer = sink.GetAppendBuffer(
- /*min_capacity=*/scratch_capacity,
- /*desired_capacity_hint=*/scratch_capacity,
- scratch.getAlias(),
- scratch_capacity,
- &result_capacity);
-
- reslen = uloc_getKeywordValue(
- fullName,
- keywordName_nul.data(),
- buffer,
- result_capacity,
- &status);
-
- if (status != U_BUFFER_OVERFLOW_ERROR) {
- break;
- }
-
- scratch_capacity = reslen;
- status = U_ZERO_ERROR;
- }
-
- if (U_FAILURE(status)) {
- return;
- }
-
- sink.Append(buffer, reslen);
- if (status == U_STRING_NOT_TERMINATED_WARNING) {
- status = U_ZERO_ERROR; // Terminators not used.
- }
+ ulocimp_getKeywordValue(fullName, keywordName_nul.data(), sink, &status);
}
void
diff --git a/deps/icu-small/source/common/loclikely.cpp b/deps/icu-small/source/common/loclikely.cpp
index 3b71708e54..6a34bb42ce 100644
--- a/deps/icu-small/source/common/loclikely.cpp
+++ b/deps/icu-small/source/common/loclikely.cpp
@@ -464,8 +464,7 @@ parseTagString(
goto error;
}
- subtagLength = ulocimp_getLanguage(position, lang, *langLength, &position);
- u_terminateChars(lang, *langLength, subtagLength, err);
+ subtagLength = ulocimp_getLanguage(position, &position, *err).extract(lang, *langLength, *err);
/*
* Note that we explicit consider U_STRING_NOT_TERMINATED_WARNING
@@ -486,8 +485,7 @@ parseTagString(
++position;
}
- subtagLength = ulocimp_getScript(position, script, *scriptLength, &position);
- u_terminateChars(script, *scriptLength, subtagLength, err);
+ subtagLength = ulocimp_getScript(position, &position, *err).extract(script, *scriptLength, *err);
if(U_FAILURE(*err)) {
goto error;
@@ -511,8 +509,7 @@ parseTagString(
}
}
- subtagLength = ulocimp_getCountry(position, region, *regionLength, &position);
- u_terminateChars(region, *regionLength, subtagLength, err);
+ subtagLength = ulocimp_getCountry(position, &position, *err).extract(region, *regionLength, *err);
if(U_FAILURE(*err)) {
goto error;
@@ -826,7 +823,7 @@ error:
} \
} UPRV_BLOCK_MACRO_END
-static void
+static UBool
_uloc_addLikelySubtags(const char* localeID,
icu::ByteSink& sink,
UErrorCode* err) {
@@ -897,15 +894,22 @@ _uloc_addLikelySubtags(const char* localeID,
sink.Append(localeID, localIDLength);
}
- return;
+ return success;
error:
if (!U_FAILURE(*err)) {
*err = U_ILLEGAL_ARGUMENT_ERROR;
}
+ return FALSE;
}
+// Add likely subtags to the sink
+// return true if the value in the sink is produced by a match during the lookup
+// return false if the value in the sink is the same as input because there are
+// no match after the lookup.
+static UBool _ulocimp_addLikelySubtags(const char*, icu::ByteSink&, UErrorCode*);
+
static void
_uloc_minimizeSubtags(const char* localeID,
icu::ByteSink& sink,
@@ -921,6 +925,7 @@ _uloc_minimizeSubtags(const char* localeID,
const char* trailing = "";
int32_t trailingLength = 0;
int32_t trailingIndex = 0;
+ UBool successGetMax = FALSE;
if(U_FAILURE(*err)) {
goto error;
@@ -961,7 +966,7 @@ _uloc_minimizeSubtags(const char* localeID,
{
icu::CharString base;
{
- icu::CharStringByteSink sink(&base);
+ icu::CharStringByteSink baseSink(&base);
createTagString(
lang,
langLength,
@@ -971,7 +976,7 @@ _uloc_minimizeSubtags(const char* localeID,
regionLength,
NULL,
0,
- sink,
+ baseSink,
err);
}
@@ -980,8 +985,8 @@ _uloc_minimizeSubtags(const char* localeID,
* from AddLikelySubtags.
**/
{
- icu::CharStringByteSink sink(&maximizedTagBuffer);
- ulocimp_addLikelySubtags(base.data(), sink, err);
+ icu::CharStringByteSink maxSink(&maximizedTagBuffer);
+ successGetMax = _ulocimp_addLikelySubtags(base.data(), maxSink, err);
}
}
@@ -989,13 +994,40 @@ _uloc_minimizeSubtags(const char* localeID,
goto error;
}
+ if (!successGetMax) {
+ /**
+ * If we got here, return the locale ID parameter unchanged.
+ **/
+ const int32_t localeIDLength = (int32_t)uprv_strlen(localeID);
+ sink.Append(localeID, localeIDLength);
+ return;
+ }
+
+ // In the following, the lang, script, region are referring to those in
+ // the maximizedTagBuffer, not the one in the localeID.
+ langLength = sizeof(lang);
+ scriptLength = sizeof(script);
+ regionLength = sizeof(region);
+ parseTagString(
+ maximizedTagBuffer.data(),
+ lang,
+ &langLength,
+ script,
+ &scriptLength,
+ region,
+ &regionLength,
+ err);
+ if(U_FAILURE(*err)) {
+ goto error;
+ }
+
/**
* Start first with just the language.
**/
{
icu::CharString tagBuffer;
{
- icu::CharStringByteSink sink(&tagBuffer);
+ icu::CharStringByteSink tagSink(&tagBuffer);
createLikelySubtagsString(
lang,
langLength,
@@ -1005,14 +1037,15 @@ _uloc_minimizeSubtags(const char* localeID,
0,
NULL,
0,
- sink,
+ tagSink,
err);
}
if(U_FAILURE(*err)) {
goto error;
}
- else if (!tagBuffer.isEmpty() && uprv_strnicmp(
+ else if (!tagBuffer.isEmpty() &&
+ uprv_strnicmp(
maximizedTagBuffer.data(),
tagBuffer.data(),
tagBuffer.length()) == 0) {
@@ -1039,7 +1072,7 @@ _uloc_minimizeSubtags(const char* localeID,
icu::CharString tagBuffer;
{
- icu::CharStringByteSink sink(&tagBuffer);
+ icu::CharStringByteSink tagSink(&tagBuffer);
createLikelySubtagsString(
lang,
langLength,
@@ -1049,14 +1082,15 @@ _uloc_minimizeSubtags(const char* localeID,
regionLength,
NULL,
0,
- sink,
+ tagSink,
err);
}
if(U_FAILURE(*err)) {
goto error;
}
- else if (uprv_strnicmp(
+ else if (!tagBuffer.isEmpty() &&
+ uprv_strnicmp(
maximizedTagBuffer.data(),
tagBuffer.data(),
tagBuffer.length()) == 0) {
@@ -1081,10 +1115,10 @@ _uloc_minimizeSubtags(const char* localeID,
* since trying with all three subtags would only yield the
* maximal version that we already have.
**/
- if (scriptLength > 0 && regionLength > 0) {
+ if (scriptLength > 0) {
icu::CharString tagBuffer;
{
- icu::CharStringByteSink sink(&tagBuffer);
+ icu::CharStringByteSink tagSink(&tagBuffer);
createLikelySubtagsString(
lang,
langLength,
@@ -1094,14 +1128,15 @@ _uloc_minimizeSubtags(const char* localeID,
0,
NULL,
0,
- sink,
+ tagSink,
err);
}
if(U_FAILURE(*err)) {
goto error;
}
- else if (uprv_strnicmp(
+ else if (!tagBuffer.isEmpty() &&
+ uprv_strnicmp(
maximizedTagBuffer.data(),
tagBuffer.data(),
tagBuffer.length()) == 0) {
@@ -1123,10 +1158,19 @@ _uloc_minimizeSubtags(const char* localeID,
{
/**
- * If we got here, return the locale ID parameter.
+ * If we got here, return the max + trail.
**/
- const int32_t localeIDLength = (int32_t)uprv_strlen(localeID);
- sink.Append(localeID, localeIDLength);
+ createTagString(
+ lang,
+ langLength,
+ script,
+ scriptLength,
+ region,
+ regionLength,
+ trailing,
+ trailingLength,
+ sink,
+ err);
return;
}
@@ -1193,15 +1237,23 @@ uloc_addLikelySubtags(const char* localeID,
return reslen;
}
-U_CAPI void U_EXPORT2
-ulocimp_addLikelySubtags(const char* localeID,
- icu::ByteSink& sink,
- UErrorCode* status) {
+static UBool
+_ulocimp_addLikelySubtags(const char* localeID,
+ icu::ByteSink& sink,
+ UErrorCode* status) {
char localeBuffer[ULOC_FULLNAME_CAPACITY];
if (do_canonicalize(localeID, localeBuffer, sizeof localeBuffer, status)) {
- _uloc_addLikelySubtags(localeBuffer, sink, status);
+ return _uloc_addLikelySubtags(localeBuffer, sink, status);
}
+ return FALSE;
+}
+
+U_CAPI void U_EXPORT2
+ulocimp_addLikelySubtags(const char* localeID,
+ icu::ByteSink& sink,
+ UErrorCode* status) {
+ _ulocimp_addLikelySubtags(localeID, sink, status);
}
U_CAPI int32_t U_EXPORT2
diff --git a/deps/icu-small/source/common/loclikelysubtags.cpp b/deps/icu-small/source/common/loclikelysubtags.cpp
index 1fbf1a1463..a031bfa587 100644
--- a/deps/icu-small/source/common/loclikelysubtags.cpp
+++ b/deps/icu-small/source/common/loclikelysubtags.cpp
@@ -1,5 +1,5 @@
// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
// loclikelysubtags.cpp
// created: 2019may08 Markus W. Scherer
@@ -20,6 +20,7 @@
#include "uhash.h"
#include "uinvchar.h"
#include "umutex.h"
+#include "uniquecharstr.h"
#include "uresdata.h"
#include "uresimp.h"
@@ -31,71 +32,6 @@ constexpr char PSEUDO_ACCENTS_PREFIX = '\''; // -XA, -PSACCENT
constexpr char PSEUDO_BIDI_PREFIX = '+'; // -XB, -PSBIDI
constexpr char PSEUDO_CRACKED_PREFIX = ','; // -XC, -PSCRACK
-/**
- * Stores NUL-terminated strings with duplicate elimination.
- * Checks for unique UTF-16 string pointers and converts to invariant characters.
- */
-class UniqueCharStrings {
-public:
- UniqueCharStrings(UErrorCode &errorCode) : strings(nullptr) {
- uhash_init(&map, uhash_hashUChars, uhash_compareUChars, uhash_compareLong, &errorCode);
- if (U_FAILURE(errorCode)) { return; }
- strings = new CharString();
- if (strings == nullptr) {
- errorCode = U_MEMORY_ALLOCATION_ERROR;
- }
- }
- ~UniqueCharStrings() {
- uhash_close(&map);
- delete strings;
- }
-
- /** Returns/orphans the CharString that contains all strings. */
- CharString *orphanCharStrings() {
- CharString *result = strings;
- strings = nullptr;
- return result;
- }
-
- /** Adds a string and returns a unique number for it. */
- int32_t add(const UnicodeString &s, UErrorCode &errorCode) {
- if (U_FAILURE(errorCode)) { return 0; }
- if (isFrozen) {
- errorCode = U_NO_WRITE_PERMISSION;
- return 0;
- }
- // The string points into the resource bundle.
- const char16_t *p = s.getBuffer();
- int32_t oldIndex = uhash_geti(&map, p);
- if (oldIndex != 0) { // found duplicate
- return oldIndex;
- }
- // Explicit NUL terminator for the previous string.
- // The strings object is also terminated with one implicit NUL.
- strings->append(0, errorCode);
- int32_t newIndex = strings->length();
- strings->appendInvariantChars(s, errorCode);
- uhash_puti(&map, const_cast<char16_t *>(p), newIndex, &errorCode);
- return newIndex;
- }
-
- void freeze() { isFrozen = true; }
-
- /**
- * Returns a string pointer for its unique number, if this object is frozen.
- * Otherwise nullptr.
- */
- const char *get(int32_t i) const {
- U_ASSERT(isFrozen);
- return isFrozen && i > 0 ? strings->data() + i : nullptr;
- }
-
-private:
- UHashtable map;
- CharString *strings;
- bool isFrozen = false;
-};
-
} // namespace
LocaleDistanceData::LocaleDistanceData(LocaleDistanceData &&data) :
diff --git a/deps/icu-small/source/common/loclikelysubtags.h b/deps/icu-small/source/common/loclikelysubtags.h
index 90ddfffaca..14a01a5eac 100644
--- a/deps/icu-small/source/common/loclikelysubtags.h
+++ b/deps/icu-small/source/common/loclikelysubtags.h
@@ -1,5 +1,5 @@
// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
// loclikelysubtags.h
// created: 2019may08 Markus W. Scherer
@@ -13,49 +13,13 @@
#include "unicode/locid.h"
#include "unicode/uobject.h"
#include "unicode/ures.h"
+#include "charstrmap.h"
#include "lsr.h"
-#include "uhash.h"
U_NAMESPACE_BEGIN
struct XLikelySubtagsData;
-/**
- * Map of const char * keys & values.
- * Stores pointers as is: Does not own/copy/adopt/release strings.
- */
-class CharStringMap final : public UMemory {
-public:
- /** Constructs an unusable non-map. */
- CharStringMap() : map(nullptr) {}
- CharStringMap(int32_t size, UErrorCode &errorCode) {
- map = uhash_openSize(uhash_hashChars, uhash_compareChars, uhash_compareChars,
- size, &errorCode);
- }
- CharStringMap(CharStringMap &&other) U_NOEXCEPT : map(other.map) {
- other.map = nullptr;
- }
- CharStringMap(const CharStringMap &other) = delete;
- ~CharStringMap() {
- uhash_close(map);
- }
-
- CharStringMap &operator=(CharStringMap &&other) U_NOEXCEPT {
- map = other.map;
- other.map = nullptr;
- return *this;
- }
- CharStringMap &operator=(const CharStringMap &other) = delete;
-
- const char *get(const char *key) const { return static_cast<const char *>(uhash_get(map, key)); }
- void put(const char *key, const char *value, UErrorCode &errorCode) {
- uhash_put(map, const_cast<char *>(key), const_cast<char *>(value), &errorCode);
- }
-
-private:
- UHashtable *map;
-};
-
struct LocaleDistanceData {
LocaleDistanceData() = default;
LocaleDistanceData(LocaleDistanceData &&data);
diff --git a/deps/icu-small/source/common/locmap.cpp b/deps/icu-small/source/common/locmap.cpp
index 46986399b2..515205222a 100644
--- a/deps/icu-small/source/common/locmap.cpp
+++ b/deps/icu-small/source/common/locmap.cpp
@@ -28,8 +28,11 @@
*/
#include "locmap.h"
+#include "bytesinkutil.h"
+#include "charstr.h"
#include "cstring.h"
#include "cmemory.h"
+#include "ulocimp.h"
#include "unicode/uloc.h"
#if U_PLATFORM_HAS_WIN32_API && UCONFIG_USE_WINDOWS_LCID_MAPPING_API
@@ -1167,15 +1170,18 @@ uprv_convertToLCIDPlatform(const char* localeID, UErrorCode* status)
// conversion functionality when available.
#if U_PLATFORM_HAS_WIN32_API && UCONFIG_USE_WINDOWS_LCID_MAPPING_API
int32_t len;
- char collVal[ULOC_KEYWORDS_CAPACITY] = {};
char baseName[ULOC_FULLNAME_CAPACITY] = {};
const char * mylocaleID = localeID;
// Check any for keywords.
if (uprv_strchr(localeID, '@'))
{
- len = uloc_getKeywordValue(localeID, "collation", collVal, UPRV_LENGTHOF(collVal) - 1, status);
- if (U_SUCCESS(*status) && len > 0)
+ icu::CharString collVal;
+ {
+ icu::CharStringByteSink sink(&collVal);
+ ulocimp_getKeywordValue(localeID, "collation", sink, status);
+ }
+ if (U_SUCCESS(*status) && !collVal.isEmpty())
{
// If it contains the keyword collation, return 0 so that the LCID lookup table will be used.
return 0;
diff --git a/deps/icu-small/source/common/lsr.cpp b/deps/icu-small/source/common/lsr.cpp
index d4308ad027..b81808f2c4 100644
--- a/deps/icu-small/source/common/lsr.cpp
+++ b/deps/icu-small/source/common/lsr.cpp
@@ -1,5 +1,5 @@
// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
// lsr.cpp
// created: 2019may08 Markus W. Scherer
diff --git a/deps/icu-small/source/common/lsr.h b/deps/icu-small/source/common/lsr.h
index d535e5b037..a33f855245 100644
--- a/deps/icu-small/source/common/lsr.h
+++ b/deps/icu-small/source/common/lsr.h
@@ -1,5 +1,5 @@
// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
// lsr.h
// created: 2019may08 Markus W. Scherer
diff --git a/deps/icu-small/source/common/messageimpl.h b/deps/icu-small/source/common/messageimpl.h
index dc7a6edd6c..a56479066b 100644
--- a/deps/icu-small/source/common/messageimpl.h
+++ b/deps/icu-small/source/common/messageimpl.h
@@ -33,7 +33,7 @@ U_NAMESPACE_BEGIN
class U_COMMON_API MessageImpl {
public:
/**
- * @return TRUE if getApostropheMode()==UMSGPAT_APOS_DOUBLE_REQUIRED
+ * @return true if getApostropheMode()==UMSGPAT_APOS_DOUBLE_REQUIRED
*/
static UBool jdkAposMode(const MessagePattern &msgPattern) {
return msgPattern.getApostropheMode()==UMSGPAT_APOS_DOUBLE_REQUIRED;
diff --git a/deps/icu-small/source/common/norm2allmodes.h b/deps/icu-small/source/common/norm2allmodes.h
index 682ece28f1..e8bd52c6ae 100644
--- a/deps/icu-small/source/common/norm2allmodes.h
+++ b/deps/icu-small/source/common/norm2allmodes.h
@@ -65,13 +65,13 @@ public:
normalizeSecondAndAppend(UnicodeString &first,
const UnicodeString &second,
UErrorCode &errorCode) const {
- return normalizeSecondAndAppend(first, second, TRUE, errorCode);
+ return normalizeSecondAndAppend(first, second, true, errorCode);
}
virtual UnicodeString &
append(UnicodeString &first,
const UnicodeString &second,
UErrorCode &errorCode) const {
- return normalizeSecondAndAppend(first, second, FALSE, errorCode);
+ return normalizeSecondAndAppend(first, second, false, errorCode);
}
UnicodeString &
normalizeSecondAndAppend(UnicodeString &first,
@@ -112,14 +112,14 @@ public:
int32_t length;
const UChar *d=impl.getDecomposition(c, buffer, length);
if(d==NULL) {
- return FALSE;
+ return false;
}
if(d==buffer) {
decomposition.setTo(buffer, length); // copy the string (Jamos from Hangul syllable c)
} else {
- decomposition.setTo(FALSE, d, length); // read-only alias
+ decomposition.setTo(false, d, length); // read-only alias
}
- return TRUE;
+ return true;
}
virtual UBool
getRawDecomposition(UChar32 c, UnicodeString &decomposition) const {
@@ -127,14 +127,14 @@ public:
int32_t length;
const UChar *d=impl.getRawDecomposition(c, buffer, length);
if(d==NULL) {
- return FALSE;
+ return false;
}
if(d==buffer) {
decomposition.setTo(buffer, length); // copy the string (algorithmic decomposition)
} else {
- decomposition.setTo(FALSE, d, length); // read-only alias
+ decomposition.setTo(false, d, length); // read-only alias
}
- return TRUE;
+ return true;
}
virtual UChar32
composePair(UChar32 a, UChar32 b) const {
@@ -150,12 +150,12 @@ public:
virtual UBool
isNormalized(const UnicodeString &s, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) {
- return FALSE;
+ return false;
}
const UChar *sArray=s.getBuffer();
if(sArray==NULL) {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
- return FALSE;
+ return false;
}
const UChar *sLimit=sArray+s.length();
return sLimit==spanQuickCheckYes(sArray, sLimit, errorCode);
@@ -227,7 +227,7 @@ private:
virtual void
normalize(const UChar *src, const UChar *limit,
ReorderingBuffer &buffer, UErrorCode &errorCode) const U_OVERRIDE {
- impl.compose(src, limit, onlyContiguous, TRUE, buffer, errorCode);
+ impl.compose(src, limit, onlyContiguous, true, buffer, errorCode);
}
using Normalizer2WithImpl::normalize; // Avoid warning about hiding base class function.
@@ -256,24 +256,24 @@ private:
virtual UBool
isNormalized(const UnicodeString &s, UErrorCode &errorCode) const U_OVERRIDE {
if(U_FAILURE(errorCode)) {
- return FALSE;
+ return false;
}
const UChar *sArray=s.getBuffer();
if(sArray==NULL) {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
- return FALSE;
+ return false;
}
UnicodeString temp;
ReorderingBuffer buffer(impl, temp);
if(!buffer.init(5, errorCode)) { // small destCapacity for substring normalization
- return FALSE;
+ return false;
}
- return impl.compose(sArray, sArray+s.length(), onlyContiguous, FALSE, buffer, errorCode);
+ return impl.compose(sArray, sArray+s.length(), onlyContiguous, false, buffer, errorCode);
}
virtual UBool
isNormalizedUTF8(StringPiece sp, UErrorCode &errorCode) const U_OVERRIDE {
if(U_FAILURE(errorCode)) {
- return FALSE;
+ return false;
}
const uint8_t *s = reinterpret_cast<const uint8_t *>(sp.data());
return impl.composeUTF8(0, onlyContiguous, s, s + sp.length(), nullptr, nullptr, errorCode);
@@ -343,7 +343,7 @@ private:
struct Norm2AllModes : public UMemory {
Norm2AllModes(Normalizer2Impl *i)
- : impl(i), comp(*i, FALSE), decomp(*i), fcd(*i), fcc(*i, TRUE) {}
+ : impl(i), comp(*i, false), decomp(*i), fcd(*i), fcc(*i, true) {}
~Norm2AllModes();
static Norm2AllModes *createInstance(Normalizer2Impl *impl, UErrorCode &errorCode);
diff --git a/deps/icu-small/source/common/normalizer2impl.h b/deps/icu-small/source/common/normalizer2impl.h
index cf3015ea88..4218a30a34 100644
--- a/deps/icu-small/source/common/normalizer2impl.h
+++ b/deps/icu-small/source/common/normalizer2impl.h
@@ -171,7 +171,7 @@ public:
UErrorCode &errorCode);
UBool appendBMP(UChar c, uint8_t cc, UErrorCode &errorCode) {
if(remainingCapacity==0 && !resize(1, errorCode)) {
- return FALSE;
+ return false;
}
if(lastCC<=cc || cc==0) {
*limit++=c;
@@ -183,7 +183,7 @@ public:
insert(c, cc);
}
--remainingCapacity;
- return TRUE;
+ return true;
}
UBool appendZeroCC(UChar32 c, UErrorCode &errorCode);
UBool appendZeroCC(const UChar *s, const UChar *sLimit, UErrorCode &errorCode);
@@ -359,7 +359,7 @@ public:
return getFCD16FromNormData(c);
}
- /** Returns TRUE if the single-or-lead code unit c might have non-zero FCD data. */
+ /** Returns true if the single-or-lead code unit c might have non-zero FCD data. */
UBool singleLeadMightHaveNonZeroFCD16(UChar32 lead) const {
// 0<=lead<=0xffff
uint8_t bits=smallFCD[lead>>8];
@@ -397,8 +397,8 @@ public:
MIN_YES_YES_WITH_CC=0xfe02,
JAMO_VT=0xfe00,
MIN_NORMAL_MAYBE_YES=0xfc00,
- JAMO_L=2, // offset=1 hasCompBoundaryAfter=FALSE
- INERT=1, // offset=0 hasCompBoundaryAfter=TRUE
+ JAMO_L=2, // offset=1 hasCompBoundaryAfter=false
+ INERT=1, // offset=0 hasCompBoundaryAfter=true
// norm16 bit 0 is comp-boundary-after.
HAS_COMP_BOUNDARY_AFTER=1,
diff --git a/deps/icu-small/source/common/patternprops.h b/deps/icu-small/source/common/patternprops.h
index b57cdeb6e5..95898d580c 100644
--- a/deps/icu-small/source/common/patternprops.h
+++ b/deps/icu-small/source/common/patternprops.h
@@ -44,17 +44,17 @@ U_NAMESPACE_BEGIN
class U_COMMON_API PatternProps {
public:
/**
- * @return TRUE if c is a Pattern_Syntax code point.
+ * @return true if c is a Pattern_Syntax code point.
*/
static UBool isSyntax(UChar32 c);
/**
- * @return TRUE if c is a Pattern_Syntax or Pattern_White_Space code point.
+ * @return true if c is a Pattern_Syntax or Pattern_White_Space code point.
*/
static UBool isSyntaxOrWhiteSpace(UChar32 c);
/**
- * @return TRUE if c is a Pattern_White_Space character.
+ * @return true if c is a Pattern_White_Space character.
*/
static UBool isWhiteSpace(UChar32 c);
@@ -78,7 +78,7 @@ public:
/**
* Tests whether the string contains a "pattern identifier", that is,
* whether it contains only non-Pattern_White_Space, non-Pattern_Syntax characters.
- * @return TRUE if there are no Pattern_White_Space or Pattern_Syntax characters in s.
+ * @return true if there are no Pattern_White_Space or Pattern_Syntax characters in s.
*/
static UBool isIdentifier(const UChar *s, int32_t length);
diff --git a/deps/icu-small/source/common/pluralmap.h b/deps/icu-small/source/common/pluralmap.h
index db644093a1..d898ac4671 100644
--- a/deps/icu-small/source/common/pluralmap.h
+++ b/deps/icu-small/source/common/pluralmap.h
@@ -234,7 +234,7 @@ public:
}
/**
- * Returns TRUE if this object equals rhs.
+ * Returns true if this object equals rhs.
*/
UBool equals(
const PluralMap<T> &rhs,
@@ -244,13 +244,13 @@ public:
continue;
}
if (fVariants[i] == NULL || rhs.fVariants[i] == NULL) {
- return FALSE;
+ return false;
}
if (!eqFunc(*fVariants[i], *rhs.fVariants[i])) {
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
private:
diff --git a/deps/icu-small/source/common/punycode.cpp b/deps/icu-small/source/common/punycode.cpp
index 4f0b9ea9cd..94d32a66d7 100644
--- a/deps/icu-small/source/common/punycode.cpp
+++ b/deps/icu-small/source/common/punycode.cpp
@@ -107,36 +107,26 @@ digitToBasic(int32_t digit, UBool uppercase) {
}
/**
- * basicToDigit[] contains the numeric value of a basic code
- * point (for use in representing integers) in the range 0 to
- * BASE-1, or -1 if b is does not represent a value.
+ * @return the numeric value of a basic code point (for use in representing integers)
+ * in the range 0 to BASE-1, or a negative value if cp is invalid.
*/
-static const int8_t
-basicToDigit[256]={
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1,
-
- -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-
- -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
-};
+static int32_t decodeDigit(int32_t cp) {
+ if(cp<=u'Z') {
+ if(cp<=u'9') {
+ if(cp<u'0') {
+ return -1;
+ } else {
+ return cp-u'0'+26; // 0..9 -> 26..35
+ }
+ } else {
+ return cp-u'A'; // A-Z -> 0..25
+ }
+ } else if(cp<=u'z') {
+ return cp-'a'; // a..z -> 0..25
+ } else {
+ return -1;
+ }
+}
static inline char
asciiCaseMap(char b, UBool uppercase) {
@@ -178,15 +168,23 @@ adaptBias(int32_t delta, int32_t length, UBool firstTime) {
return count+(((BASE-TMIN+1)*delta)/(delta+SKEW));
}
-#define MAX_CP_COUNT 200
+namespace {
-U_CFUNC int32_t
+// ICU-13727: Limit input length for n^2 algorithm
+// where well-formed strings are at most 59 characters long.
+constexpr int32_t ENCODE_MAX_CODE_UNITS=1000;
+constexpr int32_t DECODE_MAX_CHARS=2000;
+
+} // namespace
+
+// encode
+U_CAPI int32_t
u_strToPunycode(const UChar *src, int32_t srcLength,
UChar *dest, int32_t destCapacity,
const UBool *caseFlags,
UErrorCode *pErrorCode) {
- int32_t cpBuffer[MAX_CP_COUNT];
+ int32_t cpBuffer[ENCODE_MAX_CODE_UNITS];
int32_t n, delta, handledCPCount, basicLength, destLength, bias, j, m, q, k, t, srcCPCount;
UChar c, c2;
@@ -199,6 +197,10 @@ u_strToPunycode(const UChar *src, int32_t srcLength,
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
+ if (srcLength>ENCODE_MAX_CODE_UNITS) {
+ *pErrorCode=U_INPUT_TOO_LONG_ERROR;
+ return 0;
+ }
/*
* Handle the basic code points and
@@ -211,9 +213,8 @@ u_strToPunycode(const UChar *src, int32_t srcLength,
if((c=src[j])==0) {
break;
}
- if(srcCPCount==MAX_CP_COUNT) {
- /* too many input code points */
- *pErrorCode=U_INDEX_OUTOFBOUNDS_ERROR;
+ if(j>=ENCODE_MAX_CODE_UNITS) {
+ *pErrorCode=U_INPUT_TOO_LONG_ERROR;
return 0;
}
if(IS_BASIC(c)) {
@@ -243,11 +244,6 @@ u_strToPunycode(const UChar *src, int32_t srcLength,
} else {
/* length-specified input */
for(j=0; j<srcLength; ++j) {
- if(srcCPCount==MAX_CP_COUNT) {
- /* too many input code points */
- *pErrorCode=U_INDEX_OUTOFBOUNDS_ERROR;
- return 0;
- }
c=src[j];
if(IS_BASIC(c)) {
cpBuffer[srcCPCount++]=0;
@@ -312,7 +308,7 @@ u_strToPunycode(const UChar *src, int32_t srcLength,
* Increase delta enough to advance the decoder's
* <n,i> state to <m,0>, but guard against overflow:
*/
- if(m-n>(0x7fffffff-MAX_CP_COUNT-delta)/(handledCPCount+1)) {
+ if(m-n>(0x7fffffff-handledCPCount-delta)/(handledCPCount+1)) {
*pErrorCode=U_INTERNAL_PROGRAM_ERROR;
return 0;
}
@@ -373,7 +369,8 @@ u_strToPunycode(const UChar *src, int32_t srcLength,
return u_terminateUChars(dest, destCapacity, destLength, pErrorCode);
}
-U_CFUNC int32_t
+// decode
+U_CAPI int32_t
u_strFromPunycode(const UChar *src, int32_t srcLength,
UChar *dest, int32_t destCapacity,
UBool *caseFlags,
@@ -395,6 +392,10 @@ u_strFromPunycode(const UChar *src, int32_t srcLength,
if(srcLength==-1) {
srcLength=u_strlen(src);
}
+ if (srcLength>DECODE_MAX_CHARS) {
+ *pErrorCode=U_INPUT_TOO_LONG_ERROR;
+ return 0;
+ }
/*
* Handle the basic code points:
@@ -455,7 +456,7 @@ u_strFromPunycode(const UChar *src, int32_t srcLength,
return 0;
}
- digit=basicToDigit[(uint8_t)src[in++]];
+ digit=decodeDigit(src[in++]);
if(digit<0) {
*pErrorCode=U_INVALID_CHAR_FOUND;
return 0;
diff --git a/deps/icu-small/source/common/punycode.h b/deps/icu-small/source/common/punycode.h
index 5d8a243175..9e28f770c4 100644
--- a/deps/icu-small/source/common/punycode.h
+++ b/deps/icu-small/source/common/punycode.h
@@ -50,7 +50,7 @@ http://www.nicemice.net/amc/
* @param caseFlags Vector of boolean values, one per input UChar,
* indicating that the corresponding character is to be
* marked for the decoder optionally
- * uppercasing (TRUE) or lowercasing (FALSE)
+ * uppercasing (true) or lowercasing (false)
* the character.
* ASCII characters are output directly in the case as marked.
* Flags corresponding to trail surrogates are ignored.
@@ -65,7 +65,7 @@ http://www.nicemice.net/amc/
*
* @see u_strFromPunycode
*/
-U_CFUNC int32_t
+U_CAPI int32_t
u_strToPunycode(const UChar *src, int32_t srcLength,
UChar *dest, int32_t destCapacity,
const UBool *caseFlags,
@@ -83,10 +83,10 @@ u_strToPunycode(const UChar *src, int32_t srcLength,
* and of caseFlags in numbers of UBools.
* @param caseFlags Output array for case flags as
* defined by the Punycode string.
- * The caller should uppercase (TRUE) or lowercase (FASLE)
+ * The caller should uppercase (true) or lowercase (FASLE)
* the corresponding character in dest.
* For supplementary characters, only the lead surrogate
- * is marked, and FALSE is stored for the trail surrogate.
+ * is marked, and false is stored for the trail surrogate.
* This is redundant and not necessary for ASCII characters
* because they are already in the case indicated.
* Can be NULL if the case flags are not needed.
@@ -100,7 +100,7 @@ u_strToPunycode(const UChar *src, int32_t srcLength,
*
* @see u_strToPunycode
*/
-U_CFUNC int32_t
+U_CAPI int32_t
u_strFromPunycode(const UChar *src, int32_t srcLength,
UChar *dest, int32_t destCapacity,
UBool *caseFlags,
diff --git a/deps/icu-small/source/common/putil.cpp b/deps/icu-small/source/common/putil.cpp
index 51c2473c98..3ed6a05d22 100644
--- a/deps/icu-small/source/common/putil.cpp
+++ b/deps/icu-small/source/common/putil.cpp
@@ -81,7 +81,7 @@
#include <float.h>
#ifndef U_COMMON_IMPLEMENTATION
-#error U_COMMON_IMPLEMENTATION not set - must be set for all ICU source files in common/ - see http://userguide.icu-project.org/howtouseicu
+#error U_COMMON_IMPLEMENTATION not set - must be set for all ICU source files in common/ - see https://unicode-org.github.io/icu/userguide/howtouseicu
#endif
@@ -118,11 +118,15 @@
# ifndef _XPG4_2
# define _XPG4_2
# endif
+# elif U_PLATFORM == U_PF_ANDROID
+# include <sys/system_properties.h>
+# include <dlfcn.h>
# endif
#elif U_PLATFORM == U_PF_QNX
# include <sys/neutrino.h>
#endif
+
/*
* Only include langinfo.h if we have a way to get the codeset. If we later
* depend on more feature, we can test on U_HAVE_NL_LANGINFO.
@@ -1043,9 +1047,53 @@ static char* searchForTZFile(const char* path, DefaultTZInfo* tzInfo) {
}
#endif
+#if U_PLATFORM == U_PF_ANDROID
+typedef int(system_property_read_callback)(const prop_info* info,
+ void (*callback)(void* cookie,
+ const char* name,
+ const char* value,
+ uint32_t serial),
+ void* cookie);
+typedef int(system_property_get)(const char*, char*);
+
+static char gAndroidTimeZone[PROP_VALUE_MAX] = { '\0' };
+
+static void u_property_read(void* cookie, const char* name, const char* value,
+ uint32_t serial) {
+ uprv_strcpy((char* )cookie, value);
+}
+#endif
+
U_CAPI void U_EXPORT2
-uprv_tzname_clear_cache()
+uprv_tzname_clear_cache(void)
{
+#if U_PLATFORM == U_PF_ANDROID
+ /* Android's timezone is stored in system property. */
+ gAndroidTimeZone[0] = '\0';
+ void* libc = dlopen("libc.so", RTLD_NOLOAD);
+ if (libc) {
+ /* Android API 26+ has new API to get system property and old API
+ * (__system_property_get) is deprecated */
+ system_property_read_callback* property_read_callback =
+ (system_property_read_callback*)dlsym(
+ libc, "__system_property_read_callback");
+ if (property_read_callback) {
+ const prop_info* info =
+ __system_property_find("persist.sys.timezone");
+ if (info) {
+ property_read_callback(info, &u_property_read, gAndroidTimeZone);
+ }
+ } else {
+ system_property_get* property_get =
+ (system_property_get*)dlsym(libc, "__system_property_get");
+ if (property_get) {
+ property_get("persist.sys.timezone", gAndroidTimeZone);
+ }
+ }
+ dlclose(libc);
+ }
+#endif
+
#if defined(CHECK_LOCALTIME_LINK) && !defined(DEBUG_SKIP_LOCALTIME_LINK)
gTimeZoneBufferPtr = NULL;
#endif
@@ -1084,7 +1132,11 @@ uprv_tzname(int n)
/* This code can be temporarily disabled to test tzname resolution later on. */
#ifndef DEBUG_TZNAME
+#if U_PLATFORM == U_PF_ANDROID
+ tzid = gAndroidTimeZone;
+#else
tzid = getenv("TZ");
+#endif
if (tzid != NULL && isValidOlsonID(tzid)
#if U_PLATFORM == U_PF_SOLARIS
/* When TZ equals localtime on Solaris, check the /etc/localtime file. */
@@ -2299,7 +2351,7 @@ u_getVersion(UVersionInfo versionArray) {
#include <dlfcn.h>
#endif /* HAVE_DLFCN_H */
-U_INTERNAL void * U_EXPORT2
+U_CAPI void * U_EXPORT2
uprv_dl_open(const char *libName, UErrorCode *status) {
void *ret = NULL;
if(U_FAILURE(*status)) return ret;
@@ -2313,13 +2365,13 @@ uprv_dl_open(const char *libName, UErrorCode *status) {
return ret;
}
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uprv_dl_close(void *lib, UErrorCode *status) {
if(U_FAILURE(*status)) return;
dlclose(lib);
}
-U_INTERNAL UVoidFunction* U_EXPORT2
+U_CAPI UVoidFunction* U_EXPORT2
uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
union {
UVoidFunction *fp;
@@ -2342,7 +2394,7 @@ uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
/* Windows API implementation. */
// Note: UWP does not expose/allow these APIs, so the UWP version gets the null implementation. */
-U_INTERNAL void * U_EXPORT2
+U_CAPI void * U_EXPORT2
uprv_dl_open(const char *libName, UErrorCode *status) {
HMODULE lib = NULL;
@@ -2357,7 +2409,7 @@ uprv_dl_open(const char *libName, UErrorCode *status) {
return (void*)lib;
}
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uprv_dl_close(void *lib, UErrorCode *status) {
HMODULE handle = (HMODULE)lib;
if(U_FAILURE(*status)) return;
@@ -2367,7 +2419,7 @@ uprv_dl_close(void *lib, UErrorCode *status) {
return;
}
-U_INTERNAL UVoidFunction* U_EXPORT2
+U_CAPI UVoidFunction* U_EXPORT2
uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
HMODULE handle = (HMODULE)lib;
UVoidFunction* addr = NULL;
@@ -2392,7 +2444,7 @@ uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
/* No dynamic loading, null (nonexistent) implementation. */
-U_INTERNAL void * U_EXPORT2
+U_CAPI void * U_EXPORT2
uprv_dl_open(const char *libName, UErrorCode *status) {
(void)libName;
if(U_FAILURE(*status)) return NULL;
@@ -2400,7 +2452,7 @@ uprv_dl_open(const char *libName, UErrorCode *status) {
return NULL;
}
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uprv_dl_close(void *lib, UErrorCode *status) {
(void)lib;
if(U_FAILURE(*status)) return;
@@ -2408,7 +2460,7 @@ uprv_dl_close(void *lib, UErrorCode *status) {
return;
}
-U_INTERNAL UVoidFunction* U_EXPORT2
+U_CAPI UVoidFunction* U_EXPORT2
uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
(void)lib;
(void)sym;
diff --git a/deps/icu-small/source/common/putilimp.h b/deps/icu-small/source/common/putilimp.h
index 2e9fbcc483..a325c6c359 100644
--- a/deps/icu-small/source/common/putilimp.h
+++ b/deps/icu-small/source/common/putilimp.h
@@ -210,93 +210,93 @@ typedef size_t uintptr_t;
* Floating point utility to determine if a double is Not a Number (NaN).
* @internal
*/
-U_INTERNAL UBool U_EXPORT2 uprv_isNaN(double d);
+U_CAPI UBool U_EXPORT2 uprv_isNaN(double d);
/**
* Floating point utility to determine if a double has an infinite value.
* @internal
*/
-U_INTERNAL UBool U_EXPORT2 uprv_isInfinite(double d);
+U_CAPI UBool U_EXPORT2 uprv_isInfinite(double d);
/**
* Floating point utility to determine if a double has a positive infinite value.
* @internal
*/
-U_INTERNAL UBool U_EXPORT2 uprv_isPositiveInfinity(double d);
+U_CAPI UBool U_EXPORT2 uprv_isPositiveInfinity(double d);
/**
* Floating point utility to determine if a double has a negative infinite value.
* @internal
*/
-U_INTERNAL UBool U_EXPORT2 uprv_isNegativeInfinity(double d);
+U_CAPI UBool U_EXPORT2 uprv_isNegativeInfinity(double d);
/**
* Floating point utility that returns a Not a Number (NaN) value.
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_getNaN(void);
+U_CAPI double U_EXPORT2 uprv_getNaN(void);
/**
* Floating point utility that returns an infinite value.
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_getInfinity(void);
+U_CAPI double U_EXPORT2 uprv_getInfinity(void);
/**
* Floating point utility to truncate a double.
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_trunc(double d);
+U_CAPI double U_EXPORT2 uprv_trunc(double d);
/**
* Floating point utility to calculate the floor of a double.
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_floor(double d);
+U_CAPI double U_EXPORT2 uprv_floor(double d);
/**
* Floating point utility to calculate the ceiling of a double.
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_ceil(double d);
+U_CAPI double U_EXPORT2 uprv_ceil(double d);
/**
* Floating point utility to calculate the absolute value of a double.
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_fabs(double d);
+U_CAPI double U_EXPORT2 uprv_fabs(double d);
/**
* Floating point utility to calculate the fractional and integer parts of a double.
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_modf(double d, double* pinteger);
+U_CAPI double U_EXPORT2 uprv_modf(double d, double* pinteger);
/**
* Floating point utility to calculate the remainder of a double divided by another double.
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_fmod(double d, double y);
+U_CAPI double U_EXPORT2 uprv_fmod(double d, double y);
/**
* Floating point utility to calculate d to the power of exponent (d^exponent).
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_pow(double d, double exponent);
+U_CAPI double U_EXPORT2 uprv_pow(double d, double exponent);
/**
* Floating point utility to calculate 10 to the power of exponent (10^exponent).
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_pow10(int32_t exponent);
+U_CAPI double U_EXPORT2 uprv_pow10(int32_t exponent);
/**
* Floating point utility to calculate the maximum value of two doubles.
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_fmax(double d, double y);
+U_CAPI double U_EXPORT2 uprv_fmax(double d, double y);
/**
* Floating point utility to calculate the minimum value of two doubles.
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_fmin(double d, double y);
+U_CAPI double U_EXPORT2 uprv_fmin(double d, double y);
/**
* Private utility to calculate the maximum value of two integers.
* @internal
*/
-U_INTERNAL int32_t U_EXPORT2 uprv_max(int32_t d, int32_t y);
+U_CAPI int32_t U_EXPORT2 uprv_max(int32_t d, int32_t y);
/**
* Private utility to calculate the minimum value of two integers.
* @internal
*/
-U_INTERNAL int32_t U_EXPORT2 uprv_min(int32_t d, int32_t y);
+U_CAPI int32_t U_EXPORT2 uprv_min(int32_t d, int32_t y);
#if U_IS_BIG_ENDIAN
# define uprv_isNegative(number) (*((signed char *)&(number))<0)
@@ -309,13 +309,13 @@ U_INTERNAL int32_t U_EXPORT2 uprv_min(int32_t d, int32_t y);
* type of arbitrary bit length.
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_maxMantissa(void);
+U_CAPI double U_EXPORT2 uprv_maxMantissa(void);
/**
* Floating point utility to calculate the logarithm of a double.
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_log(double d);
+U_CAPI double U_EXPORT2 uprv_log(double d);
/**
* Does common notion of rounding e.g. uprv_floor(x + 0.5);
@@ -323,7 +323,7 @@ U_INTERNAL double U_EXPORT2 uprv_log(double d);
* @return the rounded double
* @internal
*/
-U_INTERNAL double U_EXPORT2 uprv_round(double x);
+U_CAPI double U_EXPORT2 uprv_round(double x);
/**
* Adds the signed integers a and b, storing the result in res.
@@ -336,7 +336,7 @@ U_INTERNAL double U_EXPORT2 uprv_round(double x);
* @return true if overflow occurred; false if no overflow occurred.
* @internal
*/
-U_INTERNAL UBool U_EXPORT2 uprv_add32_overflow(int32_t a, int32_t b, int32_t* res);
+U_CAPI UBool U_EXPORT2 uprv_add32_overflow(int32_t a, int32_t b, int32_t* res);
/**
* Multiplies the signed integers a and b, storing the result in res.
@@ -349,7 +349,7 @@ U_INTERNAL UBool U_EXPORT2 uprv_add32_overflow(int32_t a, int32_t b, int32_t* re
* @return true if overflow occurred; false if no overflow occurred.
* @internal
*/
-U_INTERNAL UBool U_EXPORT2 uprv_mul32_overflow(int32_t a, int32_t b, int32_t* res);
+U_CAPI UBool U_EXPORT2 uprv_mul32_overflow(int32_t a, int32_t b, int32_t* res);
#if 0
/**
@@ -359,7 +359,7 @@ U_INTERNAL UBool U_EXPORT2 uprv_mul32_overflow(int32_t a, int32_t b, int32_t* re
* @return the number of digits after the decimal point in a double number x.
* @internal
*/
-/*U_INTERNAL int32_t U_EXPORT2 uprv_digitsAfterDecimal(double x);*/
+/*U_CAPI int32_t U_EXPORT2 uprv_digitsAfterDecimal(double x);*/
#endif
#if !U_CHARSET_IS_UTF8
@@ -371,7 +371,7 @@ U_INTERNAL UBool U_EXPORT2 uprv_mul32_overflow(int32_t a, int32_t b, int32_t* re
* @return the default codepage for this platform
* @internal
*/
-U_INTERNAL const char* U_EXPORT2 uprv_getDefaultCodepage(void);
+U_CAPI const char* U_EXPORT2 uprv_getDefaultCodepage(void);
#endif
/**
@@ -383,7 +383,7 @@ U_INTERNAL const char* U_EXPORT2 uprv_getDefaultCodepage(void);
* @return the default locale ID string
* @internal
*/
-U_INTERNAL const char* U_EXPORT2 uprv_getDefaultLocaleID(void);
+U_CAPI const char* U_EXPORT2 uprv_getDefaultLocaleID(void);
/**
* Time zone utilities
@@ -417,7 +417,7 @@ U_INTERNAL const char* U_EXPORT2 uprv_getDefaultLocaleID(void);
* Date/Time application.
* @internal
*/
-U_INTERNAL void U_EXPORT2 uprv_tzset(void);
+U_CAPI void U_EXPORT2 uprv_tzset(void);
/**
* Difference in seconds between coordinated universal
@@ -425,7 +425,7 @@ U_INTERNAL void U_EXPORT2 uprv_tzset(void);
* @return the difference in seconds between coordinated universal time and local time.
* @internal
*/
-U_INTERNAL int32_t U_EXPORT2 uprv_timezone(void);
+U_CAPI int32_t U_EXPORT2 uprv_timezone(void);
/**
* tzname(0) Three-letter time-zone name derived from TZ environment
@@ -435,13 +435,13 @@ U_INTERNAL int32_t U_EXPORT2 uprv_timezone(void);
* tzname(1) is an empty string.
* @internal
*/
-U_INTERNAL const char* U_EXPORT2 uprv_tzname(int n);
+U_CAPI const char* U_EXPORT2 uprv_tzname(int n);
/**
* Reset the global tzname cache.
* @internal
*/
-U_INTERNAL void uprv_tzname_clear_cache();
+U_CAPI void uprv_tzname_clear_cache(void);
/**
* Get UTC (GMT) time measured in milliseconds since 0:00 on 1/1/1970.
@@ -449,7 +449,7 @@ U_INTERNAL void uprv_tzname_clear_cache();
* @return the UTC time measured in milliseconds
* @internal
*/
-U_INTERNAL UDate U_EXPORT2 uprv_getUTCtime(void);
+U_CAPI UDate U_EXPORT2 uprv_getUTCtime(void);
/**
* Get UTC (GMT) time measured in milliseconds since 0:00 on 1/1/1970.
@@ -458,15 +458,15 @@ U_INTERNAL UDate U_EXPORT2 uprv_getUTCtime(void);
* @return the UTC time measured in milliseconds
* @internal
*/
-U_INTERNAL UDate U_EXPORT2 uprv_getRawUTCtime(void);
+U_CAPI UDate U_EXPORT2 uprv_getRawUTCtime(void);
/**
* Determine whether a pathname is absolute or not, as defined by the platform.
* @param path Pathname to test
- * @return TRUE if the path is absolute
+ * @return true if the path is absolute
* @internal (ICU 3.0)
*/
-U_INTERNAL UBool U_EXPORT2 uprv_pathIsAbsolute(const char *path);
+U_CAPI UBool U_EXPORT2 uprv_pathIsAbsolute(const char *path);
/**
* Use U_MAX_PTR instead of this function.
@@ -474,7 +474,7 @@ U_INTERNAL UBool U_EXPORT2 uprv_pathIsAbsolute(const char *path);
* @return the largest possible pointer greater than the base
* @internal (ICU 3.8)
*/
-U_INTERNAL void * U_EXPORT2 uprv_maximumPtr(void *base);
+U_CAPI void * U_EXPORT2 uprv_maximumPtr(void *base);
/**
* Maximum value of a (void*) - use to indicate the limit of an 'infinite' buffer.
@@ -572,26 +572,26 @@ typedef void (UVoidFunction)(void);
* Load a library
* @internal (ICU 4.4)
*/
-U_INTERNAL void * U_EXPORT2 uprv_dl_open(const char *libName, UErrorCode *status);
+U_CAPI void * U_EXPORT2 uprv_dl_open(const char *libName, UErrorCode *status);
/**
* Close a library
* @internal (ICU 4.4)
*/
-U_INTERNAL void U_EXPORT2 uprv_dl_close( void *lib, UErrorCode *status);
+U_CAPI void U_EXPORT2 uprv_dl_close( void *lib, UErrorCode *status);
/**
* Extract a symbol from a library (function)
* @internal (ICU 4.8)
*/
-U_INTERNAL UVoidFunction* U_EXPORT2 uprv_dlsym_func( void *lib, const char *symbolName, UErrorCode *status);
+U_CAPI UVoidFunction* U_EXPORT2 uprv_dlsym_func( void *lib, const char *symbolName, UErrorCode *status);
/**
* Extract a symbol from a library (function)
* Not implemented, no clients.
* @internal
*/
-/* U_INTERNAL void * U_EXPORT2 uprv_dlsym_data( void *lib, const char *symbolName, UErrorCode *status); */
+/* U_CAPI void * U_EXPORT2 uprv_dlsym_data( void *lib, const char *symbolName, UErrorCode *status); */
#endif
diff --git a/deps/icu-small/source/common/rbbi.cpp b/deps/icu-small/source/common/rbbi.cpp
index 43ba58ba9e..9b7e70c3cf 100644
--- a/deps/icu-small/source/common/rbbi.cpp
+++ b/deps/icu-small/source/common/rbbi.cpp
@@ -68,10 +68,18 @@ RuleBasedBreakIterator::RuleBasedBreakIterator(RBBIDataHeader* data, UErrorCode
init(status);
fData = new RBBIDataWrapper(data, status); // status checked in constructor
if (U_FAILURE(status)) {return;}
- if(fData == 0) {
+ if(fData == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
+ if (fData->fForwardTable->fLookAheadResultsSize > 0) {
+ fLookAheadMatches = static_cast<int32_t *>(
+ uprv_malloc(fData->fForwardTable->fLookAheadResultsSize * sizeof(int32_t)));
+ if (fLookAheadMatches == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ }
}
//
@@ -98,10 +106,18 @@ RuleBasedBreakIterator::RuleBasedBreakIterator(const uint8_t *compiledRules,
}
fData = new RBBIDataWrapper(data, RBBIDataWrapper::kDontAdopt, status);
if (U_FAILURE(status)) {return;}
- if(fData == 0) {
+ if(fData == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
+ if (fData->fForwardTable->fLookAheadResultsSize > 0) {
+ fLookAheadMatches = static_cast<int32_t *>(
+ uprv_malloc(fData->fForwardTable->fLookAheadResultsSize * sizeof(int32_t)));
+ if (fLookAheadMatches == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ }
}
@@ -117,10 +133,18 @@ RuleBasedBreakIterator::RuleBasedBreakIterator(UDataMemory* udm, UErrorCode &sta
init(status);
fData = new RBBIDataWrapper(udm, status); // status checked in constructor
if (U_FAILURE(status)) {return;}
- if(fData == 0) {
+ if(fData == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
+ if (fData->fForwardTable->fLookAheadResultsSize > 0) {
+ fLookAheadMatches = static_cast<int32_t *>(
+ uprv_malloc(fData->fForwardTable->fLookAheadResultsSize * sizeof(int32_t)));
+ if (fLookAheadMatches == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ }
}
@@ -188,30 +212,34 @@ RuleBasedBreakIterator::~RuleBasedBreakIterator() {
// fCharIter was adopted from the outside.
delete fCharIter;
}
- fCharIter = NULL;
+ fCharIter = nullptr;
utext_close(&fText);
- if (fData != NULL) {
+ if (fData != nullptr) {
fData->removeReference();
- fData = NULL;
+ fData = nullptr;
}
delete fBreakCache;
- fBreakCache = NULL;
+ fBreakCache = nullptr;
delete fDictionaryCache;
- fDictionaryCache = NULL;
+ fDictionaryCache = nullptr;
delete fLanguageBreakEngines;
- fLanguageBreakEngines = NULL;
+ fLanguageBreakEngines = nullptr;
delete fUnhandledBreakEngine;
- fUnhandledBreakEngine = NULL;
+ fUnhandledBreakEngine = nullptr;
+
+ uprv_free(fLookAheadMatches);
+ fLookAheadMatches = nullptr;
}
/**
* Assignment operator. Sets this iterator to have the same behavior,
* and iterate over the same text, as the one passed in.
+ * TODO: needs better handling of memory allocation errors.
*/
RuleBasedBreakIterator&
RuleBasedBreakIterator::operator=(const RuleBasedBreakIterator& that) {
@@ -252,6 +280,14 @@ RuleBasedBreakIterator::operator=(const RuleBasedBreakIterator& that) {
fData = that.fData->addReference();
}
+ uprv_free(fLookAheadMatches);
+ fLookAheadMatches = nullptr;
+ if (fData && fData->fForwardTable->fLookAheadResultsSize > 0) {
+ fLookAheadMatches = static_cast<int32_t *>(
+ uprv_malloc(fData->fForwardTable->fLookAheadResultsSize * sizeof(int32_t)));
+ }
+
+
fPosition = that.fPosition;
fRuleStatusIndex = that.fRuleStatusIndex;
fDone = that.fDone;
@@ -275,16 +311,17 @@ RuleBasedBreakIterator::operator=(const RuleBasedBreakIterator& that) {
//
//-----------------------------------------------------------------------------
void RuleBasedBreakIterator::init(UErrorCode &status) {
- fCharIter = NULL;
- fData = NULL;
+ fCharIter = nullptr;
+ fData = nullptr;
fPosition = 0;
fRuleStatusIndex = 0;
fDone = false;
fDictionaryCharCount = 0;
- fLanguageBreakEngines = NULL;
- fUnhandledBreakEngine = NULL;
- fBreakCache = NULL;
- fDictionaryCache = NULL;
+ fLanguageBreakEngines = nullptr;
+ fUnhandledBreakEngine = nullptr;
+ fBreakCache = nullptr;
+ fDictionaryCache = nullptr;
+ fLookAheadMatches = nullptr;
// Note: IBM xlC is unable to assign or initialize member fText from UTEXT_INITIALIZER.
// fText = UTEXT_INITIALIZER;
@@ -700,50 +737,53 @@ enum RBBIRunMode {
};
-// Map from look-ahead break states (corresponds to rules) to boundary positions.
-// Allows multiple lookahead break rules to be in flight at the same time.
+// Wrapper functions to select the appropriate handleNext() or handleSafePrevious()
+// instantiation, based on whether an 8 or 16 bit table is required.
//
-// This is a temporary approach for ICU 57. A better fix is to make the look-ahead numbers
-// in the state table be sequential, then we can just index an array. And the
-// table could also tell us in advance how big that array needs to be.
-//
-// Before ICU 57 there was just a single simple variable for a look-ahead match that
-// was in progress. Two rules at once did not work.
-
-static const int32_t kMaxLookaheads = 8;
-struct LookAheadResults {
- int32_t fUsedSlotLimit;
- int32_t fPositions[8];
- int16_t fKeys[8];
+// These Trie access functions will be inlined within the handleNext()/Previous() instantions.
+static inline uint16_t TrieFunc8(const UCPTrie *trie, UChar32 c) {
+ return UCPTRIE_FAST_GET(trie, UCPTRIE_8, c);
+}
- LookAheadResults() : fUsedSlotLimit(0), fPositions(), fKeys() {}
+static inline uint16_t TrieFunc16(const UCPTrie *trie, UChar32 c) {
+ return UCPTRIE_FAST_GET(trie, UCPTRIE_16, c);
+}
- int32_t getPosition(int16_t key) {
- for (int32_t i=0; i<fUsedSlotLimit; ++i) {
- if (fKeys[i] == key) {
- return fPositions[i];
- }
+int32_t RuleBasedBreakIterator::handleNext() {
+ const RBBIStateTable *statetable = fData->fForwardTable;
+ bool use8BitsTrie = ucptrie_getValueWidth(fData->fTrie) == UCPTRIE_VALUE_BITS_8;
+ if (statetable->fFlags & RBBI_8BITS_ROWS) {
+ if (use8BitsTrie) {
+ return handleNext<RBBIStateTableRow8, TrieFunc8>();
+ } else {
+ return handleNext<RBBIStateTableRow8, TrieFunc16>();
+ }
+ } else {
+ if (use8BitsTrie) {
+ return handleNext<RBBIStateTableRow16, TrieFunc8>();
+ } else {
+ return handleNext<RBBIStateTableRow16, TrieFunc16>();
}
- UPRV_UNREACHABLE;
}
+}
- void setPosition(int16_t key, int32_t position) {
- int32_t i;
- for (i=0; i<fUsedSlotLimit; ++i) {
- if (fKeys[i] == key) {
- fPositions[i] = position;
- return;
- }
+int32_t RuleBasedBreakIterator::handleSafePrevious(int32_t fromPosition) {
+ const RBBIStateTable *statetable = fData->fReverseTable;
+ bool use8BitsTrie = ucptrie_getValueWidth(fData->fTrie) == UCPTRIE_VALUE_BITS_8;
+ if (statetable->fFlags & RBBI_8BITS_ROWS) {
+ if (use8BitsTrie) {
+ return handleSafePrevious<RBBIStateTableRow8, TrieFunc8>(fromPosition);
+ } else {
+ return handleSafePrevious<RBBIStateTableRow8, TrieFunc16>(fromPosition);
}
- if (i >= kMaxLookaheads) {
- UPRV_UNREACHABLE;
+ } else {
+ if (use8BitsTrie) {
+ return handleSafePrevious<RBBIStateTableRow16, TrieFunc8>(fromPosition);
+ } else {
+ return handleSafePrevious<RBBIStateTableRow16, TrieFunc16>(fromPosition);
}
- fKeys[i] = key;
- fPositions[i] = position;
- U_ASSERT(fUsedSlotLimit == i);
- fUsedSlotLimit = i + 1;
}
-};
+}
//-----------------------------------------------------------------------------------
@@ -752,19 +792,20 @@ struct LookAheadResults {
// Run the state machine to find a boundary
//
//-----------------------------------------------------------------------------------
+template <typename RowType, RuleBasedBreakIterator::PTrieFunc trieFunc>
int32_t RuleBasedBreakIterator::handleNext() {
int32_t state;
uint16_t category = 0;
RBBIRunMode mode;
- RBBIStateTableRow *row;
+ RowType *row;
UChar32 c;
- LookAheadResults lookAheadMatches;
int32_t result = 0;
int32_t initialPosition = 0;
const RBBIStateTable *statetable = fData->fForwardTable;
const char *tableData = statetable->fTableData;
uint32_t tableRowLen = statetable->fRowLen;
+ uint32_t dictStart = statetable->fDictCategoriesStart;
#ifdef RBBI_DEBUG
if (gTrace) {
RBBIDebugPuts("Handle Next pos char state category");
@@ -789,7 +830,7 @@ int32_t RuleBasedBreakIterator::handleNext() {
// Set the initial state for the state machine
state = START_STATE;
- row = (RBBIStateTableRow *)
+ row = (RowType *)
//(statetable->fTableData + (statetable->fRowLen * state));
(tableData + tableRowLen * state);
@@ -825,21 +866,8 @@ int32_t RuleBasedBreakIterator::handleNext() {
if (mode == RBBI_RUN) {
// look up the current character's character category, which tells us
// which column in the state table to look at.
- // Note: the 16 in UTRIE_GET16 refers to the size of the data being returned,
- // not the size of the character going in, which is a UChar32.
- //
- category = UTRIE2_GET16(fData->fTrie, c);
-
- // Check the dictionary bit in the character's category.
- // Counter is only used by dictionary based iteration.
- // Chars that need to be handled by a dictionary have a flag bit set
- // in their category values.
- //
- if ((category & 0x4000) != 0) {
- fDictionaryCharCount++;
- // And off the dictionary flag bit.
- category &= ~0x4000;
- }
+ category = trieFunc(fData->fTrie, c);
+ fDictionaryCharCount += (category >= dictStart);
}
#ifdef RBBI_DEBUG
@@ -860,25 +888,24 @@ int32_t RuleBasedBreakIterator::handleNext() {
// fNextState is a variable-length array.
U_ASSERT(category<fData->fHeader->fCatCount);
state = row->fNextState[category]; /*Not accessing beyond memory*/
- row = (RBBIStateTableRow *)
+ row = (RowType *)
// (statetable->fTableData + (statetable->fRowLen * state));
(tableData + tableRowLen * state);
- if (row->fAccepting == -1) {
+ uint16_t accepting = row->fAccepting;
+ if (accepting == ACCEPTING_UNCONDITIONAL) {
// Match found, common case.
if (mode != RBBI_START) {
result = (int32_t)UTEXT_GETNATIVEINDEX(&fText);
}
- fRuleStatusIndex = row->fTagIdx; // Remember the break status (tag) values.
- }
-
- int16_t completedRule = row->fAccepting;
- if (completedRule > 0) {
+ fRuleStatusIndex = row->fTagsIdx; // Remember the break status (tag) values.
+ } else if (accepting > ACCEPTING_UNCONDITIONAL) {
// Lookahead match is completed.
- int32_t lookaheadResult = lookAheadMatches.getPosition(completedRule);
+ U_ASSERT(accepting < fData->fForwardTable->fLookAheadResultsSize);
+ int32_t lookaheadResult = fLookAheadMatches[accepting];
if (lookaheadResult >= 0) {
- fRuleStatusIndex = row->fTagIdx;
+ fRuleStatusIndex = row->fTagsIdx;
fPosition = lookaheadResult;
return lookaheadResult;
}
@@ -890,10 +917,12 @@ int32_t RuleBasedBreakIterator::handleNext() {
// This would enable hard-break rules with no following context.
// But there are line break test failures when trying this. Investigate.
// Issue ICU-20837
- int16_t rule = row->fLookAhead;
- if (rule != 0) {
+ uint16_t rule = row->fLookAhead;
+ U_ASSERT(rule == 0 || rule > ACCEPTING_UNCONDITIONAL);
+ U_ASSERT(rule == 0 || rule < fData->fForwardTable->fLookAheadResultsSize);
+ if (rule > ACCEPTING_UNCONDITIONAL) {
int32_t pos = (int32_t)UTEXT_GETNATIVEINDEX(&fText);
- lookAheadMatches.setPosition(rule, pos);
+ fLookAheadMatches[rule] = pos;
}
if (state == STOP_STATE) {
@@ -948,10 +977,12 @@ int32_t RuleBasedBreakIterator::handleNext() {
// because the safe table does not require as many options.
//
//-----------------------------------------------------------------------------------
+template <typename RowType, RuleBasedBreakIterator::PTrieFunc trieFunc>
int32_t RuleBasedBreakIterator::handleSafePrevious(int32_t fromPosition) {
+
int32_t state;
uint16_t category = 0;
- RBBIStateTableRow *row;
+ RowType *row;
UChar32 c;
int32_t result = 0;
@@ -971,7 +1002,7 @@ int32_t RuleBasedBreakIterator::handleSafePrevious(int32_t fromPosition) {
// Set the initial state for the state machine
c = UTEXT_PREVIOUS32(&fText);
state = START_STATE;
- row = (RBBIStateTableRow *)
+ row = (RowType *)
(stateTable->fTableData + (stateTable->fRowLen * state));
// loop until we reach the start of the text or transition to state 0
@@ -980,12 +1011,9 @@ int32_t RuleBasedBreakIterator::handleSafePrevious(int32_t fromPosition) {
// look up the current character's character category, which tells us
// which column in the state table to look at.
- // Note: the 16 in UTRIE_GET16 refers to the size of the data being returned,
- // not the size of the character going in, which is a UChar32.
//
- // And off the dictionary flag bit. For reverse iteration it is not used.
- category = UTRIE2_GET16(fData->fTrie, c);
- category &= ~0x4000;
+ // Off the dictionary flag bit. For reverse iteration it is not used.
+ category = trieFunc(fData->fTrie, c);
#ifdef RBBI_DEBUG
if (gTrace) {
@@ -1004,7 +1032,7 @@ int32_t RuleBasedBreakIterator::handleSafePrevious(int32_t fromPosition) {
// fNextState is a variable-length array.
U_ASSERT(category<fData->fHeader->fCatCount);
state = row->fNextState[category]; /*Not accessing beyond memory*/
- row = (RBBIStateTableRow *)
+ row = (RowType *)
(stateTable->fTableData + (stateTable->fRowLen * state));
if (state == STOP_STATE) {
@@ -1024,6 +1052,7 @@ int32_t RuleBasedBreakIterator::handleSafePrevious(int32_t fromPosition) {
return result;
}
+
//-------------------------------------------------------------------------------
//
// getRuleStatus() Return the break rule tag associated with the current
diff --git a/deps/icu-small/source/common/rbbi_cache.cpp b/deps/icu-small/source/common/rbbi_cache.cpp
index 4f9e83360a..63ff3001c7 100644
--- a/deps/icu-small/source/common/rbbi_cache.cpp
+++ b/deps/icu-small/source/common/rbbi_cache.cpp
@@ -142,13 +142,15 @@ void RuleBasedBreakIterator::DictionaryCache::populateDictionary(int32_t startPo
utext_setNativeIndex(text, rangeStart);
UChar32 c = utext_current32(text);
- category = UTRIE2_GET16(fBI->fData->fTrie, c);
+ category = ucptrie_get(fBI->fData->fTrie, c);
+ uint32_t dictStart = fBI->fData->fForwardTable->fDictCategoriesStart;
while(U_SUCCESS(status)) {
- while((current = (int32_t)UTEXT_GETNATIVEINDEX(text)) < rangeEnd && (category & 0x4000) == 0) {
+ while((current = (int32_t)UTEXT_GETNATIVEINDEX(text)) < rangeEnd
+ && (category < dictStart)) {
utext_next32(text); // TODO: cleaner loop structure.
c = utext_current32(text);
- category = UTRIE2_GET16(fBI->fData->fTrie, c);
+ category = ucptrie_get(fBI->fData->fTrie, c);
}
if (current >= rangeEnd) {
break;
@@ -166,7 +168,7 @@ void RuleBasedBreakIterator::DictionaryCache::populateDictionary(int32_t startPo
// Reload the loop variables for the next go-round
c = utext_current32(text);
- category = UTRIE2_GET16(fBI->fData->fTrie, c);
+ category = ucptrie_get(fBI->fData->fTrie, c);
}
// If we found breaks, ensure that the first and last entries are
diff --git a/deps/icu-small/source/common/rbbi_cache.h b/deps/icu-small/source/common/rbbi_cache.h
index 864ff811aa..8c1fa86e7d 100644
--- a/deps/icu-small/source/common/rbbi_cache.h
+++ b/deps/icu-small/source/common/rbbi_cache.h
@@ -126,13 +126,13 @@ class RuleBasedBreakIterator::BreakCache: public UMemory {
* Additional boundaries, either preceding or following, may be added
* to the cache as a side effect.
*
- * Return FALSE if the operation failed.
+ * Return false if the operation failed.
*/
UBool populateNear(int32_t position, UErrorCode &status);
/**
* Add boundary(s) to the cache following the current last boundary.
- * Return FALSE if at the end of the text, and no more boundaries can be added.
+ * Return false if at the end of the text, and no more boundaries can be added.
* Leave iteration position at the first newly added boundary, or unchanged if no boundary was added.
*/
UBool populateFollowing();
@@ -170,7 +170,7 @@ class RuleBasedBreakIterator::BreakCache: public UMemory {
* Fails if the requested position is outside of the range of boundaries currently held by the cache.
* The startPosition must be on a code point boundary.
*
- * Return TRUE if successful, FALSE if the specified position is after
+ * Return true if successful, false if the specified position is after
* the last cached boundary or before the first.
*/
UBool seek(int32_t startPosition);
diff --git a/deps/icu-small/source/common/rbbicst.pl b/deps/icu-small/source/common/rbbicst.pl
index 839b9501dd..29f575d7d0 100755
--- a/deps/icu-small/source/common/rbbicst.pl
+++ b/deps/icu-small/source/common/rbbicst.pl
@@ -1,6 +1,6 @@
#**************************************************************************
# Copyright (C) 2016 and later: Unicode, Inc. and others.
-# License & terms of use: http://www.unicode.org/copyright.html#License
+# License & terms of use: http://www.unicode.org/copyright.html
#**************************************************************************
#**************************************************************************
# Copyright (C) 2002-2016 International Business Machines Corporation
diff --git a/deps/icu-small/source/common/rbbidata.cpp b/deps/icu-small/source/common/rbbidata.cpp
index fdcb564961..f78d9d0668 100644
--- a/deps/icu-small/source/common/rbbidata.cpp
+++ b/deps/icu-small/source/common/rbbidata.cpp
@@ -11,10 +11,10 @@
#if !UCONFIG_NO_BREAK_ITERATION
+#include "unicode/ucptrie.h"
#include "unicode/utypes.h"
#include "rbbidata.h"
#include "rbbirb.h"
-#include "utrie2.h"
#include "udatamem.h"
#include "cmemory.h"
#include "cstring.h"
@@ -110,17 +110,24 @@ void RBBIDataWrapper::init(const RBBIDataHeader *data, UErrorCode &status) {
fReverseTable = (RBBIStateTable *)((char *)data + fHeader->fRTable);
}
- fTrie = utrie2_openFromSerialized(UTRIE2_16_VALUE_BITS,
- (uint8_t *)data + fHeader->fTrie,
- fHeader->fTrieLen,
- NULL, // *actual length
- &status);
+ fTrie = ucptrie_openFromBinary(UCPTRIE_TYPE_FAST,
+ UCPTRIE_VALUE_BITS_ANY,
+ (uint8_t *)data + fHeader->fTrie,
+ fHeader->fTrieLen,
+ nullptr, // *actual length
+ &status);
if (U_FAILURE(status)) {
return;
}
- fRuleSource = (UChar *)((char *)data + fHeader->fRuleSource);
- fRuleString.setTo(TRUE, fRuleSource, -1);
+ UCPTrieValueWidth width = ucptrie_getValueWidth(fTrie);
+ if (!(width == UCPTRIE_VALUE_BITS_8 || width == UCPTRIE_VALUE_BITS_16)) {
+ status = U_INVALID_FORMAT_ERROR;
+ return;
+ }
+
+ fRuleSource = ((char *)data + fHeader->fRuleSource);
+ fRuleString = UnicodeString::fromUTF8(StringPiece(fRuleSource, fHeader->fRuleSourceLen));
U_ASSERT(data->fRuleSourceLen > 0);
fRuleStatusTable = (int32_t *)((char *)data + fHeader->fStatusTable);
@@ -142,8 +149,8 @@ void RBBIDataWrapper::init(const RBBIDataHeader *data, UErrorCode &status) {
//-----------------------------------------------------------------------------
RBBIDataWrapper::~RBBIDataWrapper() {
U_ASSERT(fRefCount == 0);
- utrie2_close(fTrie);
- fTrie = NULL;
+ ucptrie_close(fTrie);
+ fTrie = nullptr;
if (fUDataMem) {
udata_close(fUDataMem);
} else if (!fDontFreeData) {
@@ -223,9 +230,16 @@ void RBBIDataWrapper::printTable(const char *heading, const RBBIStateTable *tab
uint32_t c;
uint32_t s;
- RBBIDebugPrintf(" %s\n", heading);
+ RBBIDebugPrintf("%s\n", heading);
- RBBIDebugPrintf("State | Acc LA TagIx");
+ RBBIDebugPrintf(" fDictCategoriesStart: %d\n", table->fDictCategoriesStart);
+ RBBIDebugPrintf(" fLookAheadResultsSize: %d\n", table->fLookAheadResultsSize);
+ RBBIDebugPrintf(" Flags: %4x RBBI_LOOKAHEAD_HARD_BREAK=%s RBBI_BOF_REQUIRED=%s RBBI_8BITS_ROWS=%s\n",
+ table->fFlags,
+ table->fFlags & RBBI_LOOKAHEAD_HARD_BREAK ? "T" : "F",
+ table->fFlags & RBBI_BOF_REQUIRED ? "T" : "F",
+ table->fFlags & RBBI_8BITS_ROWS ? "T" : "F");
+ RBBIDebugPrintf("\nState | Acc LA TagIx");
for (c=0; c<fHeader->fCatCount; c++) {RBBIDebugPrintf("%3d ", c);}
RBBIDebugPrintf("\n------|---------------"); for (c=0;c<fHeader->fCatCount; c++) {
RBBIDebugPrintf("----");
@@ -236,12 +250,20 @@ void RBBIDataWrapper::printTable(const char *heading, const RBBIStateTable *tab
RBBIDebugPrintf(" N U L L T A B L E\n\n");
return;
}
+ UBool use8Bits = table->fFlags & RBBI_8BITS_ROWS;
for (s=0; s<table->fNumStates; s++) {
RBBIStateTableRow *row = (RBBIStateTableRow *)
(table->fTableData + (table->fRowLen * s));
- RBBIDebugPrintf("%4d | %3d %3d %3d ", s, row->fAccepting, row->fLookAhead, row->fTagIdx);
- for (c=0; c<fHeader->fCatCount; c++) {
- RBBIDebugPrintf("%3d ", row->fNextState[c]);
+ if (use8Bits) {
+ RBBIDebugPrintf("%4d | %3d %3d %3d ", s, row->r8.fAccepting, row->r8.fLookAhead, row->r8.fTagsIdx);
+ for (c=0; c<fHeader->fCatCount; c++) {
+ RBBIDebugPrintf("%3d ", row->r8.fNextState[c]);
+ }
+ } else {
+ RBBIDebugPrintf("%4d | %3d %3d %3d ", s, row->r16.fAccepting, row->r16.fLookAhead, row->r16.fTagsIdx);
+ for (c=0; c<fHeader->fCatCount; c++) {
+ RBBIDebugPrintf("%3d ", row->r16.fNextState[c]);
+ }
}
RBBIDebugPrintf("\n");
}
@@ -382,10 +404,23 @@ ubrk_swap(const UDataSwapper *ds, const void *inData, int32_t length, void *outD
tableLength = ds->readUInt32(rbbiDH->fFTableLen);
if (tableLength > 0) {
+ RBBIStateTable *rbbiST = (RBBIStateTable *)(inBytes+tableStartOffset);
+ UBool use8Bits = ds->readUInt32(rbbiST->fFlags) & RBBI_8BITS_ROWS;
+
ds->swapArray32(ds, inBytes+tableStartOffset, topSize,
outBytes+tableStartOffset, status);
- ds->swapArray16(ds, inBytes+tableStartOffset+topSize, tableLength-topSize,
- outBytes+tableStartOffset+topSize, status);
+
+ // Swap the state table if the table is in 16 bits.
+ if (use8Bits) {
+ if (outBytes != inBytes) {
+ uprv_memmove(outBytes+tableStartOffset+topSize,
+ inBytes+tableStartOffset+topSize,
+ tableLength-topSize);
+ }
+ } else {
+ ds->swapArray16(ds, inBytes+tableStartOffset+topSize, tableLength-topSize,
+ outBytes+tableStartOffset+topSize, status);
+ }
}
// Reverse state table. Same layout as forward table, above.
@@ -393,19 +428,35 @@ ubrk_swap(const UDataSwapper *ds, const void *inData, int32_t length, void *outD
tableLength = ds->readUInt32(rbbiDH->fRTableLen);
if (tableLength > 0) {
+ RBBIStateTable *rbbiST = (RBBIStateTable *)(inBytes+tableStartOffset);
+ UBool use8Bits = ds->readUInt32(rbbiST->fFlags) & RBBI_8BITS_ROWS;
+
ds->swapArray32(ds, inBytes+tableStartOffset, topSize,
outBytes+tableStartOffset, status);
- ds->swapArray16(ds, inBytes+tableStartOffset+topSize, tableLength-topSize,
- outBytes+tableStartOffset+topSize, status);
+
+ // Swap the state table if the table is in 16 bits.
+ if (use8Bits) {
+ if (outBytes != inBytes) {
+ uprv_memmove(outBytes+tableStartOffset+topSize,
+ inBytes+tableStartOffset+topSize,
+ tableLength-topSize);
+ }
+ } else {
+ ds->swapArray16(ds, inBytes+tableStartOffset+topSize, tableLength-topSize,
+ outBytes+tableStartOffset+topSize, status);
+ }
}
// Trie table for character categories
- utrie2_swap(ds, inBytes+ds->readUInt32(rbbiDH->fTrie), ds->readUInt32(rbbiDH->fTrieLen),
- outBytes+ds->readUInt32(rbbiDH->fTrie), status);
-
- // Source Rules Text. It's UChar data
- ds->swapArray16(ds, inBytes+ds->readUInt32(rbbiDH->fRuleSource), ds->readUInt32(rbbiDH->fRuleSourceLen),
- outBytes+ds->readUInt32(rbbiDH->fRuleSource), status);
+ ucptrie_swap(ds, inBytes+ds->readUInt32(rbbiDH->fTrie), ds->readUInt32(rbbiDH->fTrieLen),
+ outBytes+ds->readUInt32(rbbiDH->fTrie), status);
+
+ // Source Rules Text. It's UTF8 data
+ if (outBytes != inBytes) {
+ uprv_memmove(outBytes+ds->readUInt32(rbbiDH->fRuleSource),
+ inBytes+ds->readUInt32(rbbiDH->fRuleSource),
+ ds->readUInt32(rbbiDH->fRuleSourceLen));
+ }
// Table of rule status values. It's all int_32 values
ds->swapArray32(ds, inBytes+ds->readUInt32(rbbiDH->fStatusTable), ds->readUInt32(rbbiDH->fStatusTableLen),
diff --git a/deps/icu-small/source/common/rbbidata.h b/deps/icu-small/source/common/rbbidata.h
index 96e4649533..5d725deba4 100644
--- a/deps/icu-small/source/common/rbbidata.h
+++ b/deps/icu-small/source/common/rbbidata.h
@@ -49,16 +49,17 @@ ubrk_swap(const UDataSwapper *ds,
#ifdef __cplusplus
+#include "unicode/ucptrie.h"
#include "unicode/uobject.h"
#include "unicode/unistr.h"
#include "unicode/uversion.h"
#include "umutex.h"
-#include "utrie2.h"
+
U_NAMESPACE_BEGIN
// The current RBBI data format version.
-static const uint8_t RBBI_DATA_FORMAT_VERSION[] = {5, 0, 0, 0};
+static const uint8_t RBBI_DATA_FORMAT_VERSION[] = {6, 0, 0, 0};
/*
* The following structs map exactly onto the raw data from ICU common data file.
@@ -94,49 +95,61 @@ struct RBBIDataHeader {
-struct RBBIStateTableRow {
- int16_t fAccepting; /* Non-zero if this row is for an accepting state. */
- /* Value 0: not an accepting state. */
- /* -1: Unconditional Accepting state. */
- /* positive: Look-ahead match has completed. */
- /* Actual boundary position happened earlier */
- /* Value here == fLookAhead in earlier */
- /* state, at actual boundary pos. */
- int16_t fLookAhead; /* Non-zero if this row is for a state that */
- /* corresponds to a '/' in the rule source. */
- /* Value is the same as the fAccepting */
- /* value for the rule (which will appear */
- /* in a different state. */
- int16_t fTagIdx; /* Non-zero if this row covers a {tagged} position */
- /* from a rule. Value is the index in the */
- /* StatusTable of the set of matching */
- /* tags (rule status values) */
- int16_t fReserved;
- uint16_t fNextState[1]; /* Next State, indexed by char category. */
- /* Variable-length array declared with length 1 */
- /* to disable bounds checkers. */
- /* Array Size is actually fData->fHeader->fCatCount*/
- /* CAUTION: see RBBITableBuilder::getTableSize() */
- /* before changing anything here. */
+template <typename T>
+struct RBBIStateTableRowT {
+ T fAccepting; // Non-zero if this row is for an accepting state.
+ // Value 0: not an accepting state.
+ // 1: (ACCEPTING_UNCONDITIONAL) Unconditional Accepting state.
+ // >1: Look-ahead match has completed.
+ // Actual boundary position happened earlier.
+ // Value here == fLookAhead in earlier
+ // state, at actual boundary pos.
+ T fLookAhead; // Non-zero if this row is for a state that
+ // corresponds to a '/' in the rule source.
+ // Value is the same as the fAccepting
+ // value for the rule (which will appear
+ // in a different state.
+ T fTagsIdx; // Non-zero if this row covers a {tagged} position
+ // from a rule. Value is the index in the
+ // StatusTable of the set of matching
+ // tags (rule status values)
+ T fNextState[1]; // Next State, indexed by char category.
+ // Variable-length array declared with length 1
+ // to disable bounds checkers.
+ // Array Size is actually fData->fHeader->fCatCount
+ // CAUTION: see RBBITableBuilder::getTableSize()
+ // before changing anything here.
};
+typedef RBBIStateTableRowT<uint8_t> RBBIStateTableRow8;
+typedef RBBIStateTableRowT<uint16_t> RBBIStateTableRow16;
+
+constexpr uint16_t ACCEPTING_UNCONDITIONAL = 1; // Value constant for RBBIStateTableRow::fAccepting
+
+union RBBIStateTableRow {
+ RBBIStateTableRow16 r16;
+ RBBIStateTableRow8 r8;
+};
struct RBBIStateTable {
- uint32_t fNumStates; /* Number of states. */
- uint32_t fRowLen; /* Length of a state table row, in bytes. */
- uint32_t fFlags; /* Option Flags for this state table */
- uint32_t fReserved; /* reserved */
- char fTableData[1]; /* First RBBIStateTableRow begins here. */
- /* Variable-length array declared with length 1 */
- /* to disable bounds checkers. */
- /* (making it char[] simplifies ugly address */
- /* arithmetic for indexing variable length rows.) */
+ uint32_t fNumStates; // Number of states.
+ uint32_t fRowLen; // Length of a state table row, in bytes.
+ uint32_t fDictCategoriesStart; // Char category number of the first dictionary
+ // char class, or the the largest category number + 1
+ // if there are no dictionary categories.
+ uint32_t fLookAheadResultsSize; // Size of run-time array required for holding
+ // look-ahead results. Indexed by row.fLookAhead.
+ uint32_t fFlags; // Option Flags for this state table.
+ char fTableData[1]; // First RBBIStateTableRow begins here.
+ // Variable-length array declared with length 1
+ // to disable bounds checkers.
+ // (making it char[] simplifies ugly address
+ // arithmetic for indexing variable length rows.)
};
-typedef enum {
- RBBI_LOOKAHEAD_HARD_BREAK = 1,
- RBBI_BOF_REQUIRED = 2
-} RBBIStateTableFlags;
+constexpr uint32_t RBBI_LOOKAHEAD_HARD_BREAK = 1;
+constexpr uint32_t RBBI_BOF_REQUIRED = 2;
+constexpr uint32_t RBBI_8BITS_ROWS = 4;
/* */
@@ -170,13 +183,13 @@ public:
const RBBIDataHeader *fHeader;
const RBBIStateTable *fForwardTable;
const RBBIStateTable *fReverseTable;
- const UChar *fRuleSource;
+ const char *fRuleSource;
const int32_t *fRuleStatusTable;
/* number of int32_t values in the rule status table. Used to sanity check indexing */
int32_t fStatusMaxIdx;
- UTrie2 *fTrie;
+ UCPTrie *fTrie;
private:
u_atomic_int32_t fRefCount;
@@ -184,8 +197,8 @@ private:
UnicodeString fRuleString;
UBool fDontFreeData;
- RBBIDataWrapper(const RBBIDataWrapper &other); /* forbid copying of this class */
- RBBIDataWrapper &operator=(const RBBIDataWrapper &other); /* forbid copying of this class */
+ RBBIDataWrapper(const RBBIDataWrapper &other) = delete; /* forbid copying of this class */
+ RBBIDataWrapper &operator=(const RBBIDataWrapper &other) = delete; /* forbid copying of this class */
};
diff --git a/deps/icu-small/source/common/rbbinode.h b/deps/icu-small/source/common/rbbinode.h
index e33662167f..ef4e4ccac7 100644
--- a/deps/icu-small/source/common/rbbinode.h
+++ b/deps/icu-small/source/common/rbbinode.h
@@ -79,7 +79,7 @@ class RBBINode : public UMemory {
// corresponds to columns in the final
// state transition table.
- UBool fLookAheadEnd; // For endMark nodes, set TRUE if
+ UBool fLookAheadEnd; // For endMark nodes, set true if
// marking the end of a look-ahead rule.
UBool fRuleRoot; // True if this node is the root of a rule.
diff --git a/deps/icu-small/source/common/rbbirb.cpp b/deps/icu-small/source/common/rbbirb.cpp
index 4df9653264..09c8d3de7e 100644
--- a/deps/icu-small/source/common/rbbirb.cpp
+++ b/deps/icu-small/source/common/rbbirb.cpp
@@ -22,6 +22,7 @@
#include "unicode/uniset.h"
#include "unicode/uchar.h"
#include "unicode/uchriter.h"
+#include "unicode/ustring.h"
#include "unicode/parsepos.h"
#include "unicode/parseerr.h"
@@ -154,7 +155,14 @@ RBBIDataHeader *RBBIRuleBuilder::flattenData() {
int32_t reverseTableSize = align8(fForwardTable->getSafeTableSize());
int32_t trieSize = align8(fSetBuilder->getTrieSize());
int32_t statusTableSize = align8(fRuleStatusVals->size() * sizeof(int32_t));
- int32_t rulesSize = align8((fStrippedRules.length()+1) * sizeof(UChar));
+
+ int32_t rulesLengthInUTF8 = 0;
+ u_strToUTF8WithSub(0, 0, &rulesLengthInUTF8,
+ fStrippedRules.getBuffer(), fStrippedRules.length(),
+ 0xfffd, nullptr, fStatus);
+ *fStatus = U_ZERO_ERROR;
+
+ int32_t rulesSize = align8((rulesLengthInUTF8+1));
int32_t totalSize = headerSize
+ forwardTableSize
@@ -197,11 +205,11 @@ RBBIDataHeader *RBBIRuleBuilder::flattenData() {
data->fRTableLen = reverseTableSize;
data->fTrie = data->fRTable + data->fRTableLen;
- data->fTrieLen = fSetBuilder->getTrieSize();
- data->fStatusTable = data->fTrie + trieSize;
+ data->fTrieLen = trieSize;
+ data->fStatusTable = data->fTrie + data->fTrieLen;
data->fStatusTableLen= statusTableSize;
data->fRuleSource = data->fStatusTable + statusTableSize;
- data->fRuleSourceLen = fStrippedRules.length() * sizeof(UChar);
+ data->fRuleSourceLen = rulesLengthInUTF8;
uprv_memset(data->fReserved, 0, sizeof(data->fReserved));
@@ -214,7 +222,12 @@ RBBIDataHeader *RBBIRuleBuilder::flattenData() {
ruleStatusTable[i] = fRuleStatusVals->elementAti(i);
}
- fStrippedRules.extract((UChar *)((uint8_t *)data+data->fRuleSource), rulesSize/2+1, *fStatus);
+ u_strToUTF8WithSub((char *)data+data->fRuleSource, rulesSize, &rulesLengthInUTF8,
+ fStrippedRules.getBuffer(), fStrippedRules.length(),
+ 0xfffd, nullptr, fStatus);
+ if (U_FAILURE(*fStatus)) {
+ return NULL;
+ }
return data;
}
@@ -274,9 +287,7 @@ RBBIDataHeader *RBBIRuleBuilder::build(UErrorCode &status) {
//
// UnicodeSet processing.
- // Munge the Unicode Sets to create a set of character categories.
- // Generate the mapping tables (TRIE) from input code points to
- // the character categories.
+ // Munge the Unicode Sets to create an initial set of character categories.
//
fSetBuilder->buildRanges();
@@ -290,6 +301,12 @@ RBBIDataHeader *RBBIRuleBuilder::build(UErrorCode &status) {
}
fForwardTable->buildForwardTable();
+
+ // State table and character category optimization.
+ // Merge equivalent rows and columns.
+ // Note that this process alters the initial set of character categories,
+ // causing the representation of UnicodeSets in the parse tree to become invalid.
+
optimizeTables();
fForwardTable->buildSafeReverseTable(status);
@@ -302,6 +319,9 @@ RBBIDataHeader *RBBIRuleBuilder::build(UErrorCode &status) {
}
#endif
+ // Generate the mapping tables (TRIE) from input code points to
+ // the character categories.
+ //
fSetBuilder->buildTrie();
//
diff --git a/deps/icu-small/source/common/rbbiscan.cpp b/deps/icu-small/source/common/rbbiscan.cpp
index da8246ba6f..947a07304f 100644
--- a/deps/icu-small/source/common/rbbiscan.cpp
+++ b/deps/icu-small/source/common/rbbiscan.cpp
@@ -829,16 +829,14 @@ static const UChar chRParen = 0x29;
UnicodeString RBBIRuleScanner::stripRules(const UnicodeString &rules) {
UnicodeString strippedRules;
int32_t rulesLength = rules.length();
- bool skippingSpaces = false;
for (int32_t idx=0; idx<rulesLength; idx = rules.moveIndex32(idx, 1)) {
UChar32 cp = rules.char32At(idx);
bool whiteSpace = u_hasBinaryProperty(cp, UCHAR_PATTERN_WHITE_SPACE);
- if (skippingSpaces && whiteSpace) {
+ if (whiteSpace) {
continue;
}
strippedRules.append(cp);
- skippingSpaces = whiteSpace;
}
return strippedRules;
}
diff --git a/deps/icu-small/source/common/rbbiscan.h b/deps/icu-small/source/common/rbbiscan.h
index 559617e78b..f3f2621402 100644
--- a/deps/icu-small/source/common/rbbiscan.h
+++ b/deps/icu-small/source/common/rbbiscan.h
@@ -54,7 +54,7 @@ public:
struct RBBIRuleChar {
UChar32 fChar;
UBool fEscaped;
- RBBIRuleChar() : fChar(0), fEscaped(FALSE) {}
+ RBBIRuleChar() : fChar(0), fEscaped(false) {}
};
RBBIRuleScanner(RBBIRuleBuilder *rb);
diff --git a/deps/icu-small/source/common/rbbisetb.cpp b/deps/icu-small/source/common/rbbisetb.cpp
index e6b98cf3e2..2904a3280e 100644
--- a/deps/icu-small/source/common/rbbisetb.cpp
+++ b/deps/icu-small/source/common/rbbisetb.cpp
@@ -19,7 +19,7 @@
// by the RBBI rules.
// - compute a set of non-overlapping character ranges
// with all characters within a range belonging to the same
-// set of input uniocde sets.
+// set of input unicode sets.
// - Derive a set of non-overlapping UnicodeSet (like things)
// that will correspond to columns in the state table for
// the RBBI execution engine. All characters within one
@@ -35,7 +35,6 @@
#if !UCONFIG_NO_BREAK_ITERATION
#include "unicode/uniset.h"
-#include "utrie2.h"
#include "uvector.h"
#include "uassert.h"
#include "cmemory.h"
@@ -46,6 +45,7 @@
U_NAMESPACE_BEGIN
+const int32_t kMaxCharCategoriesFor8BitsTrie = 255;
//------------------------------------------------------------------------
//
// Constructor
@@ -55,11 +55,12 @@ RBBISetBuilder::RBBISetBuilder(RBBIRuleBuilder *rb)
{
fRB = rb;
fStatus = rb->fStatus;
- fRangeList = 0;
- fTrie = 0;
+ fRangeList = nullptr;
+ fMutableTrie = nullptr;
+ fTrie = nullptr;
fTrieSize = 0;
fGroupCount = 0;
- fSawBOF = FALSE;
+ fSawBOF = false;
}
@@ -79,7 +80,8 @@ RBBISetBuilder::~RBBISetBuilder()
delete r;
}
- utrie2_close(fTrie);
+ ucptrie_close(fTrie);
+ umutablecptrie_close(fMutableTrie);
}
@@ -194,24 +196,47 @@ void RBBISetBuilder::buildRanges() {
//
// Numbering: # 0 (state table column 0) is unused.
// # 1 is reserved - table column 1 is for end-of-input
- // # 2 is reserved - table column 2 is for beginning-in-input
+ // # 2 is reserved - table column 2 is for beginning-of-input
// # 3 is the first range list.
//
RangeDescriptor *rlSearchRange;
- for (rlRange = fRangeList; rlRange!=0; rlRange=rlRange->fNext) {
+ int32_t dictGroupCount = 0;
+
+ for (rlRange = fRangeList; rlRange!=nullptr; rlRange=rlRange->fNext) {
for (rlSearchRange=fRangeList; rlSearchRange != rlRange; rlSearchRange=rlSearchRange->fNext) {
if (rlRange->fIncludesSets->equals(*rlSearchRange->fIncludesSets)) {
rlRange->fNum = rlSearchRange->fNum;
+ rlRange->fIncludesDict = rlSearchRange->fIncludesDict;
break;
}
}
if (rlRange->fNum == 0) {
- fGroupCount ++;
- rlRange->fNum = fGroupCount+2;
- rlRange->setDictionaryFlag();
- addValToSets(rlRange->fIncludesSets, fGroupCount+2);
+ rlRange->fFirstInGroup = true;
+ if (rlRange->isDictionaryRange()) {
+ rlRange->fNum = ++dictGroupCount;
+ rlRange->fIncludesDict = true;
+ } else {
+ fGroupCount++;
+ rlRange->fNum = fGroupCount+2;
+ addValToSets(rlRange->fIncludesSets, rlRange->fNum);
+ }
+ }
+ }
+
+ // Move the character category numbers for any dictionary ranges up, so that they
+ // immediately follow the non-dictionary ranges.
+
+ fDictCategoriesStart = fGroupCount + 3;
+ for (rlRange = fRangeList; rlRange!=nullptr; rlRange=rlRange->fNext) {
+ if (rlRange->fIncludesDict) {
+ rlRange->fNum += fDictCategoriesStart - 1;
+ if (rlRange->fFirstInGroup) {
+ addValToSets(rlRange->fIncludesSets, rlRange->fNum);
+ }
}
}
+ fGroupCount += dictGroupCount;
+
// Handle input sets that contain the special string {eof}.
// Column 1 of the state table is reserved for EOF on input.
@@ -220,13 +245,11 @@ void RBBISetBuilder::buildRanges() {
// references to {bof}.)
// Add this column value (1 or 2) to the equivalent expression
// subtree for each UnicodeSet that contains the string {eof}
- // Because {bof} and {eof} are not a characters in the normal sense,
- // they doesn't affect the computation of ranges or TRIE.
- static const UChar eofUString[] = {0x65, 0x6f, 0x66, 0};
- static const UChar bofUString[] = {0x62, 0x6f, 0x66, 0};
+ // Because {bof} and {eof} are not characters in the normal sense,
+ // they don't affect the computation of the ranges or TRIE.
- UnicodeString eofString(eofUString);
- UnicodeString bofString(bofUString);
+ UnicodeString eofString(u"eof");
+ UnicodeString bofString(u"bof");
for (ni=0; ; ni++) { // Loop over each of the UnicodeSets encountered in the input rules
usetNode = (RBBINode *)this->fRB->fUSetNodes->elementAt(ni);
if (usetNode==NULL) {
@@ -253,19 +276,17 @@ void RBBISetBuilder::buildRanges() {
// range group number.
//
void RBBISetBuilder::buildTrie() {
- RangeDescriptor *rlRange;
-
- fTrie = utrie2_open(0, // Initial value for all code points.
+ fMutableTrie = umutablecptrie_open(
+ 0, // Initial value for all code points.
0, // Error value for out-of-range input.
fStatus);
- for (rlRange = fRangeList; rlRange!=0 && U_SUCCESS(*fStatus); rlRange=rlRange->fNext) {
- utrie2_setRange32(fTrie,
- rlRange->fStartChar, // Range start
- rlRange->fEndChar, // Range end (inclusive)
- rlRange->fNum, // value for range
- TRUE, // Overwrite previously written values
- fStatus);
+ for (RangeDescriptor *range = fRangeList; range!=nullptr && U_SUCCESS(*fStatus); range=range->fNext) {
+ umutablecptrie_setRange(fMutableTrie,
+ range->fStartChar, // Range start
+ range->fEndChar, // Range end (inclusive)
+ range->fNum, // value for range
+ fStatus);
}
}
@@ -273,16 +294,21 @@ void RBBISetBuilder::buildTrie() {
void RBBISetBuilder::mergeCategories(IntPair categories) {
U_ASSERT(categories.first >= 1);
U_ASSERT(categories.second > categories.first);
+ U_ASSERT((categories.first < fDictCategoriesStart && categories.second < fDictCategoriesStart) ||
+ (categories.first >= fDictCategoriesStart && categories.second >= fDictCategoriesStart));
+
for (RangeDescriptor *rd = fRangeList; rd != nullptr; rd = rd->fNext) {
- int32_t rangeNum = rd->fNum & ~DICT_BIT;
- int32_t rangeDict = rd->fNum & DICT_BIT;
+ int32_t rangeNum = rd->fNum;
if (rangeNum == categories.second) {
- rd->fNum = categories.first | rangeDict;
+ rd->fNum = categories.first;
} else if (rangeNum > categories.second) {
rd->fNum--;
}
}
--fGroupCount;
+ if (categories.second <= fDictCategoriesStart) {
+ --fDictCategoriesStart;
+ }
}
@@ -295,15 +321,18 @@ int32_t RBBISetBuilder::getTrieSize() {
if (U_FAILURE(*fStatus)) {
return 0;
}
- utrie2_freeze(fTrie, UTRIE2_16_VALUE_BITS, fStatus);
- fTrieSize = utrie2_serialize(fTrie,
- NULL, // Buffer
- 0, // Capacity
- fStatus);
- if (*fStatus == U_BUFFER_OVERFLOW_ERROR) {
- *fStatus = U_ZERO_ERROR;
+ if (fTrie == nullptr) {
+ bool use8Bits = getNumCharCategories() <= kMaxCharCategoriesFor8BitsTrie;
+ fTrie = umutablecptrie_buildImmutable(
+ fMutableTrie,
+ UCPTRIE_TYPE_FAST,
+ use8Bits ? UCPTRIE_VALUE_BITS_8 : UCPTRIE_VALUE_BITS_16,
+ fStatus);
+ fTrieSize = ucptrie_toBinary(fTrie, nullptr, 0, fStatus);
+ if (*fStatus == U_BUFFER_OVERFLOW_ERROR) {
+ *fStatus = U_ZERO_ERROR;
+ }
}
- // RBBIDebugPrintf("Trie table size is %d\n", trieSize);
return fTrieSize;
}
@@ -316,9 +345,9 @@ int32_t RBBISetBuilder::getTrieSize() {
//
//-----------------------------------------------------------------------------------
void RBBISetBuilder::serializeTrie(uint8_t *where) {
- utrie2_serialize(fTrie,
- where, // Buffer
- fTrieSize, // Capacity
+ ucptrie_toBinary(fTrie,
+ where, // Buffer
+ fTrieSize, // Capacity
fStatus);
}
@@ -386,6 +415,16 @@ int32_t RBBISetBuilder::getNumCharCategories() const {
//------------------------------------------------------------------------
//
+// getDictCategoriesStart
+//
+//------------------------------------------------------------------------
+int32_t RBBISetBuilder::getDictCategoriesStart() const {
+ return fDictCategoriesStart;
+}
+
+
+//------------------------------------------------------------------------
+//
// sawBOF
//
//------------------------------------------------------------------------
@@ -403,7 +442,7 @@ UBool RBBISetBuilder::sawBOF() const {
UChar32 RBBISetBuilder::getFirstChar(int32_t category) const {
RangeDescriptor *rlRange;
UChar32 retVal = (UChar32)-1;
- for (rlRange = fRangeList; rlRange!=0; rlRange=rlRange->fNext) {
+ for (rlRange = fRangeList; rlRange!=nullptr; rlRange=rlRange->fNext) {
if (rlRange->fNum == category) {
retVal = rlRange->fStartChar;
break;
@@ -413,7 +452,6 @@ UChar32 RBBISetBuilder::getFirstChar(int32_t category) const {
}
-
//------------------------------------------------------------------------
//
// printRanges A debugging function.
@@ -426,16 +464,16 @@ void RBBISetBuilder::printRanges() {
int i;
RBBIDebugPrintf("\n\n Nonoverlapping Ranges ...\n");
- for (rlRange = fRangeList; rlRange!=0; rlRange=rlRange->fNext) {
- RBBIDebugPrintf("%2i %4x-%4x ", rlRange->fNum, rlRange->fStartChar, rlRange->fEndChar);
+ for (rlRange = fRangeList; rlRange!=nullptr; rlRange=rlRange->fNext) {
+ RBBIDebugPrintf("%4x-%4x ", rlRange->fStartChar, rlRange->fEndChar);
for (i=0; i<rlRange->fIncludesSets->size(); i++) {
RBBINode *usetNode = (RBBINode *)rlRange->fIncludesSets->elementAt(i);
- UnicodeString setName = UNICODE_STRING("anon", 4);
+ UnicodeString setName {u"anon"};
RBBINode *setRef = usetNode->fParent;
- if (setRef != NULL) {
+ if (setRef != nullptr) {
RBBINode *varRef = setRef->fParent;
- if (varRef != NULL && varRef->fType == RBBINode::varRef) {
+ if (varRef != nullptr && varRef->fType == RBBINode::varRef) {
setName = varRef->fText;
}
}
@@ -455,19 +493,15 @@ void RBBISetBuilder::printRanges() {
//------------------------------------------------------------------------
#ifdef RBBI_DEBUG
void RBBISetBuilder::printRangeGroups() {
- RangeDescriptor *rlRange;
- RangeDescriptor *tRange;
int i;
- int lastPrintedGroupNum = 0;
RBBIDebugPrintf("\nRanges grouped by Unicode Set Membership...\n");
- for (rlRange = fRangeList; rlRange!=0; rlRange=rlRange->fNext) {
- int groupNum = rlRange->fNum & 0xbfff;
- if (groupNum > lastPrintedGroupNum) {
- lastPrintedGroupNum = groupNum;
+ for (RangeDescriptor *rlRange = fRangeList; rlRange!=nullptr; rlRange=rlRange->fNext) {
+ if (rlRange->fFirstInGroup) {
+ int groupNum = rlRange->fNum;
RBBIDebugPrintf("%2i ", groupNum);
- if (rlRange->fNum & DICT_BIT) { RBBIDebugPrintf(" <DICT> ");}
+ if (groupNum >= fDictCategoriesStart) { RBBIDebugPrintf(" <DICT> ");}
for (i=0; i<rlRange->fIncludesSets->size(); i++) {
RBBINode *usetNode = (RBBINode *)rlRange->fIncludesSets->elementAt(i);
@@ -483,7 +517,7 @@ void RBBISetBuilder::printRangeGroups() {
}
i = 0;
- for (tRange = rlRange; tRange != 0; tRange = tRange->fNext) {
+ for (RangeDescriptor *tRange = rlRange; tRange != nullptr; tRange = tRange->fNext) {
if (tRange->fNum == rlRange->fNum) {
if (i++ % 5 == 0) {
RBBIDebugPrintf("\n ");
@@ -550,28 +584,22 @@ void RBBISetBuilder::printSets() {
//
//-------------------------------------------------------------------------------------
-RangeDescriptor::RangeDescriptor(const RangeDescriptor &other, UErrorCode &status) {
- int i;
-
- this->fStartChar = other.fStartChar;
- this->fEndChar = other.fEndChar;
- this->fNum = other.fNum;
- this->fNext = NULL;
- UErrorCode oldstatus = status;
- this->fIncludesSets = new UVector(status);
- if (U_FAILURE(oldstatus)) {
- status = oldstatus;
- }
+RangeDescriptor::RangeDescriptor(const RangeDescriptor &other, UErrorCode &status) :
+ fStartChar(other.fStartChar), fEndChar {other.fEndChar}, fNum {other.fNum},
+ fIncludesDict{other.fIncludesDict}, fFirstInGroup{other.fFirstInGroup} {
+
if (U_FAILURE(status)) {
return;
}
- /* test for NULL */
- if (this->fIncludesSets == 0) {
+ fIncludesSets = new UVector(status);
+ if (this->fIncludesSets == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
+ }
+ if (U_FAILURE(status)) {
return;
}
- for (i=0; i<other.fIncludesSets->size(); i++) {
+ for (int32_t i=0; i<other.fIncludesSets->size(); i++) {
this->fIncludesSets->addElement(other.fIncludesSets->elementAt(i), status);
}
}
@@ -583,24 +611,13 @@ RangeDescriptor::RangeDescriptor(const RangeDescriptor &other, UErrorCode &statu
//
//-------------------------------------------------------------------------------------
RangeDescriptor::RangeDescriptor(UErrorCode &status) {
- this->fStartChar = 0;
- this->fEndChar = 0;
- this->fNum = 0;
- this->fNext = NULL;
- UErrorCode oldstatus = status;
- this->fIncludesSets = new UVector(status);
- if (U_FAILURE(oldstatus)) {
- status = oldstatus;
- }
if (U_FAILURE(status)) {
return;
}
- /* test for NULL */
- if(this->fIncludesSets == 0) {
+ fIncludesSets = new UVector(status);
+ if (fIncludesSets == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return;
}
-
}
@@ -611,7 +628,7 @@ RangeDescriptor::RangeDescriptor(UErrorCode &status) {
//-------------------------------------------------------------------------------------
RangeDescriptor::~RangeDescriptor() {
delete fIncludesSets;
- fIncludesSets = NULL;
+ fIncludesSets = nullptr;
}
//-------------------------------------------------------------------------------------
@@ -622,7 +639,7 @@ RangeDescriptor::~RangeDescriptor() {
void RangeDescriptor::split(UChar32 where, UErrorCode &status) {
U_ASSERT(where>fStartChar && where<=fEndChar);
RangeDescriptor *nr = new RangeDescriptor(*this, status);
- if(nr == 0) {
+ if(nr == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -641,27 +658,22 @@ void RangeDescriptor::split(UChar32 where, UErrorCode &status) {
//-------------------------------------------------------------------------------------
//
-// RangeDescriptor::setDictionaryFlag
+// RangeDescriptor::isDictionaryRange
//
-// Character Category Numbers that include characters from
-// the original Unicode Set named "dictionary" have bit 14
-// set to 1. The RBBI runtime engine uses this to trigger
-// use of the word dictionary.
+// Test whether this range includes characters from
+// the original Unicode Set named "dictionary".
//
-// This function looks through the Unicode Sets that it
-// (the range) includes, and sets the bit in fNum when
-// "dictionary" is among them.
+// This function looks through the Unicode Sets that
+// the range includes, checking for one named "dictionary"
//
// TODO: a faster way would be to find the set node for
// "dictionary" just once, rather than looking it
// up by name every time.
//
//-------------------------------------------------------------------------------------
-void RangeDescriptor::setDictionaryFlag() {
- int i;
-
+bool RangeDescriptor::isDictionaryRange() {
static const char16_t *dictionary = u"dictionary";
- for (i=0; i<fIncludesSets->size(); i++) {
+ for (int32_t i=0; i<fIncludesSets->size(); i++) {
RBBINode *usetNode = (RBBINode *)fIncludesSets->elementAt(i);
RBBINode *setRef = usetNode->fParent;
if (setRef != nullptr) {
@@ -669,16 +681,14 @@ void RangeDescriptor::setDictionaryFlag() {
if (varRef && varRef->fType == RBBINode::varRef) {
const UnicodeString *setName = &varRef->fText;
if (setName->compare(dictionary, -1) == 0) {
- fNum |= RBBISetBuilder::DICT_BIT;
- break;
+ return true;
}
}
}
}
+ return false;
}
-
-
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
diff --git a/deps/icu-small/source/common/rbbisetb.h b/deps/icu-small/source/common/rbbisetb.h
index ed6a76b121..6409a4ea57 100644
--- a/deps/icu-small/source/common/rbbisetb.h
+++ b/deps/icu-small/source/common/rbbisetb.h
@@ -16,9 +16,10 @@
#if !UCONFIG_NO_BREAK_ITERATION
+#include "unicode/ucptrie.h"
+#include "unicode/umutablecptrie.h"
#include "unicode/uobject.h"
#include "rbbirb.h"
-#include "utrie2.h"
#include "uvector.h"
U_NAMESPACE_BEGIN
@@ -40,25 +41,26 @@ U_NAMESPACE_BEGIN
//
class RangeDescriptor : public UMemory {
public:
- UChar32 fStartChar; // Start of range, unicode 32 bit value.
- UChar32 fEndChar; // End of range, unicode 32 bit value.
- int32_t fNum; // runtime-mapped input value for this range.
- UVector *fIncludesSets; // vector of the the original
- // Unicode sets that include this range.
- // (Contains ptrs to uset nodes)
- RangeDescriptor *fNext; // Next RangeDescriptor in the linked list.
+ UChar32 fStartChar {}; // Start of range, unicode 32 bit value.
+ UChar32 fEndChar {}; // End of range, unicode 32 bit value.
+ int32_t fNum {0}; // runtime-mapped input value for this range.
+ bool fIncludesDict {false}; // True if the range includes $dictionary.
+ bool fFirstInGroup {false}; // True if first range in a group with the same fNum.
+ UVector *fIncludesSets {nullptr}; // vector of the the original
+ // Unicode sets that include this range.
+ // (Contains ptrs to uset nodes)
+ RangeDescriptor *fNext {nullptr}; // Next RangeDescriptor in the linked list.
RangeDescriptor(UErrorCode &status);
RangeDescriptor(const RangeDescriptor &other, UErrorCode &status);
~RangeDescriptor();
void split(UChar32 where, UErrorCode &status); // Spit this range in two at "where", with
// where appearing in the second (higher) part.
- void setDictionaryFlag(); // Check whether this range appears as part of
+ bool isDictionaryRange(); // Check whether this range appears as part of
// the Unicode set named "dictionary"
-private:
- RangeDescriptor(const RangeDescriptor &other); // forbid copying of this class
- RangeDescriptor &operator=(const RangeDescriptor &other); // forbid copying of this class
+ RangeDescriptor(const RangeDescriptor &other) = delete; // forbid default copying of this class
+ RangeDescriptor &operator=(const RangeDescriptor &other) = delete; // forbid assigning of this class
};
@@ -89,6 +91,8 @@ public:
int32_t getNumCharCategories() const; // CharCategories are the same as input symbol set to the
// runtime state machine, which are the same as
// columns in the DFA state table
+ int32_t getDictCategoriesStart() const; // First char category that includes $dictionary, or
+ // last category + 1 if there are no dictionary categories.
int32_t getTrieSize() /*const*/; // Size in bytes of the serialized Trie.
void serializeTrie(uint8_t *where); // write out the serialized Trie.
UChar32 getFirstChar(int32_t val) const;
@@ -101,8 +105,6 @@ public:
*/
void mergeCategories(IntPair categories);
- static constexpr int32_t DICT_BIT = 0x4000;
-
#ifdef RBBI_DEBUG
void printSets();
void printRanges();
@@ -114,24 +116,22 @@ public:
#endif
private:
- void numberSets();
-
RBBIRuleBuilder *fRB; // The RBBI Rule Compiler that owns us.
UErrorCode *fStatus;
RangeDescriptor *fRangeList; // Head of the linked list of RangeDescriptors
- UTrie2 *fTrie; // The mapping TRIE that is the end result of processing
- uint32_t fTrieSize; // the Unicode Sets.
+ UMutableCPTrie *fMutableTrie; // The mapping TRIE that is the end result of processing
+ UCPTrie *fTrie; // the Unicode Sets.
+ uint32_t fTrieSize;
- // Groups correspond to character categories -
- // groups of ranges that are in the same original UnicodeSets.
- // fGroupCount is the index of the last used group.
- // fGroupCount+1 is also the number of columns in the RBBI state table being compiled.
- // State table column 0 is not used. Column 1 is for end-of-input.
- // column 2 is for group 0. Funny counting.
+ // Number of range groups, which are groups of ranges that are in the same original UnicodeSets.
int32_t fGroupCount;
+ // The number of the first dictionary char category.
+ // If there are no Dictionary categories, set to the last category + 1.
+ int32_t fDictCategoriesStart;
+
UBool fSawBOF;
RBBISetBuilder(const RBBISetBuilder &other); // forbid copying of this class
diff --git a/deps/icu-small/source/common/rbbitblb.cpp b/deps/icu-small/source/common/rbbitblb.cpp
index 3b1edc6a15..65b597c4a9 100644
--- a/deps/icu-small/source/common/rbbitblb.cpp
+++ b/deps/icu-small/source/common/rbbitblb.cpp
@@ -28,6 +28,8 @@
U_NAMESPACE_BEGIN
+const int32_t kMaxStateFor8BitsTable = 255;
+
RBBITableBuilder::RBBITableBuilder(RBBIRuleBuilder *rb, RBBINode **rootNode, UErrorCode &status) :
fRB(rb),
fTree(*rootNode),
@@ -712,7 +714,6 @@ void RBBITableBuilder::mapLookAheadRules() {
return;
}
fLookAheadRuleMap->setSize(fRB->fScanner->numRules() + 1);
- int32_t laSlotsInUse = 0;
for (int32_t n=0; n<fDStates->size(); n++) {
RBBIStateDescriptor *sd = (RBBIStateDescriptor *)fDStates->elementAt(n);
@@ -749,7 +750,7 @@ void RBBITableBuilder::mapLookAheadRules() {
}
if (laSlotForState == 0) {
- laSlotForState = ++laSlotsInUse;
+ laSlotForState = ++fLASlotsInUse;
}
// For each look ahead node covered by this state,
@@ -805,23 +806,23 @@ void RBBITableBuilder::flagAcceptingStates() {
if (sd->fPositions->indexOf(endMarker) >= 0) {
// Any non-zero value for fAccepting means this is an accepting node.
// The value is what will be returned to the user as the break status.
- // If no other value was specified, force it to -1.
+ // If no other value was specified, force it to ACCEPTING_UNCONDITIONAL (1).
if (sd->fAccepting==0) {
// State hasn't been marked as accepting yet. Do it now.
sd->fAccepting = fLookAheadRuleMap->elementAti(endMarker->fVal);
if (sd->fAccepting == 0) {
- sd->fAccepting = -1;
+ sd->fAccepting = ACCEPTING_UNCONDITIONAL;
}
}
- if (sd->fAccepting==-1 && endMarker->fVal != 0) {
+ if (sd->fAccepting==ACCEPTING_UNCONDITIONAL && endMarker->fVal != 0) {
// Both lookahead and non-lookahead accepting for this state.
// Favor the look-ahead, because a look-ahead match needs to
// immediately stop the run-time engine. First match, not longest.
sd->fAccepting = fLookAheadRuleMap->elementAti(endMarker->fVal);
}
// implicit else:
- // if sd->fAccepting already had a value other than 0 or -1, leave it be.
+ // if sd->fAccepting already had a value other than 0 or 1, leave it be.
}
}
}
@@ -855,7 +856,7 @@ void RBBITableBuilder::flagLookAheadStates() {
int32_t positionsIdx = sd->fPositions->indexOf(lookAheadNode);
if (positionsIdx >= 0) {
U_ASSERT(lookAheadNode == sd->fPositions->elementAt(positionsIdx));
- int32_t lookaheadSlot = fLookAheadRuleMap->elementAti(lookAheadNode->fVal);
+ uint32_t lookaheadSlot = fLookAheadRuleMap->elementAti(lookAheadNode->fVal);
U_ASSERT(sd->fLookAhead == 0 || sd->fLookAhead == lookaheadSlot);
// if (sd->fLookAhead != 0 && sd->fLookAhead != lookaheadSlot) {
// printf("%s:%d Bingo. sd->fLookAhead:%d lookaheadSlot:%d\n",
@@ -1148,7 +1149,13 @@ bool RBBITableBuilder::findDuplCharClassFrom(IntPair *categories) {
int32_t numCols = fRB->fSetBuilder->getNumCharCategories();
for (; categories->first < numCols-1; categories->first++) {
- for (categories->second=categories->first+1; categories->second < numCols; categories->second++) {
+ // Note: dictionary & non-dictionary columns cannot be merged.
+ // The limitSecond value prevents considering mixed pairs.
+ // Dictionary categories are >= DictCategoriesStart.
+ // Non dict categories are < DictCategoriesStart.
+ int limitSecond = categories->first < fRB->fSetBuilder->getDictCategoriesStart() ?
+ fRB->fSetBuilder->getDictCategoriesStart() : numCols;
+ for (categories->second=categories->first+1; categories->second < limitSecond; categories->second++) {
// Initialized to different values to prevent returning true if numStates = 0 (implies no duplicates).
uint16_t table_base = 0;
uint16_t table_dupl = 1;
@@ -1335,11 +1342,18 @@ int32_t RBBITableBuilder::getTableSize() const {
numRows = fDStates->size();
numCols = fRB->fSetBuilder->getNumCharCategories();
- rowSize = offsetof(RBBIStateTableRow, fNextState) + sizeof(uint16_t)*numCols;
+ if (use8BitsForTable()) {
+ rowSize = offsetof(RBBIStateTableRow8, fNextState) + sizeof(int8_t)*numCols;
+ } else {
+ rowSize = offsetof(RBBIStateTableRow16, fNextState) + sizeof(int16_t)*numCols;
+ }
size += numRows * rowSize;
return size;
}
+bool RBBITableBuilder::use8BitsForTable() const {
+ return fDStates->size() <= kMaxStateFor8BitsTable;
+}
//-----------------------------------------------------------------------------
//
@@ -1364,27 +1378,47 @@ void RBBITableBuilder::exportTable(void *where) {
return;
}
- table->fRowLen = offsetof(RBBIStateTableRow, fNextState) + sizeof(uint16_t) * catCount;
table->fNumStates = fDStates->size();
+ table->fDictCategoriesStart = fRB->fSetBuilder->getDictCategoriesStart();
+ table->fLookAheadResultsSize = fLASlotsInUse == ACCEPTING_UNCONDITIONAL ? 0 : fLASlotsInUse + 1;
table->fFlags = 0;
+ if (use8BitsForTable()) {
+ table->fRowLen = offsetof(RBBIStateTableRow8, fNextState) + sizeof(uint8_t) * catCount;
+ table->fFlags |= RBBI_8BITS_ROWS;
+ } else {
+ table->fRowLen = offsetof(RBBIStateTableRow16, fNextState) + sizeof(int16_t) * catCount;
+ }
if (fRB->fLookAheadHardBreak) {
table->fFlags |= RBBI_LOOKAHEAD_HARD_BREAK;
}
if (fRB->fSetBuilder->sawBOF()) {
table->fFlags |= RBBI_BOF_REQUIRED;
}
- table->fReserved = 0;
for (state=0; state<table->fNumStates; state++) {
RBBIStateDescriptor *sd = (RBBIStateDescriptor *)fDStates->elementAt(state);
RBBIStateTableRow *row = (RBBIStateTableRow *)(table->fTableData + state*table->fRowLen);
- U_ASSERT (-32768 < sd->fAccepting && sd->fAccepting <= 32767);
- U_ASSERT (-32768 < sd->fLookAhead && sd->fLookAhead <= 32767);
- row->fAccepting = (int16_t)sd->fAccepting;
- row->fLookAhead = (int16_t)sd->fLookAhead;
- row->fTagIdx = (int16_t)sd->fTagsIdx;
- for (col=0; col<catCount; col++) {
- row->fNextState[col] = (uint16_t)sd->fDtran->elementAti(col);
+ if (use8BitsForTable()) {
+ U_ASSERT (sd->fAccepting <= 255);
+ U_ASSERT (sd->fLookAhead <= 255);
+ U_ASSERT (0 <= sd->fTagsIdx && sd->fTagsIdx <= 255);
+ row->r8.fAccepting = sd->fAccepting;
+ row->r8.fLookAhead = sd->fLookAhead;
+ row->r8.fTagsIdx = sd->fTagsIdx;
+ for (col=0; col<catCount; col++) {
+ U_ASSERT (sd->fDtran->elementAti(col) <= kMaxStateFor8BitsTable);
+ row->r8.fNextState[col] = sd->fDtran->elementAti(col);
+ }
+ } else {
+ U_ASSERT (sd->fAccepting <= 0xffff);
+ U_ASSERT (sd->fLookAhead <= 0xffff);
+ U_ASSERT (0 <= sd->fTagsIdx && sd->fTagsIdx <= 0xffff);
+ row->r16.fAccepting = sd->fAccepting;
+ row->r16.fLookAhead = sd->fLookAhead;
+ row->r16.fTagsIdx = sd->fTagsIdx;
+ for (col=0; col<catCount; col++) {
+ row->r16.fNextState[col] = sd->fDtran->elementAti(col);
+ }
}
}
}
@@ -1520,11 +1554,18 @@ int32_t RBBITableBuilder::getSafeTableSize() const {
numRows = fSafeTable->size();
numCols = fRB->fSetBuilder->getNumCharCategories();
- rowSize = offsetof(RBBIStateTableRow, fNextState) + sizeof(uint16_t)*numCols;
+ if (use8BitsForSafeTable()) {
+ rowSize = offsetof(RBBIStateTableRow8, fNextState) + sizeof(int8_t)*numCols;
+ } else {
+ rowSize = offsetof(RBBIStateTableRow16, fNextState) + sizeof(int16_t)*numCols;
+ }
size += numRows * rowSize;
return size;
}
+bool RBBITableBuilder::use8BitsForSafeTable() const {
+ return fSafeTable->size() <= kMaxStateFor8BitsTable;
+}
//-----------------------------------------------------------------------------
//
@@ -1549,20 +1590,33 @@ void RBBITableBuilder::exportSafeTable(void *where) {
return;
}
- table->fRowLen = offsetof(RBBIStateTableRow, fNextState) + sizeof(uint16_t) * catCount;
table->fNumStates = fSafeTable->size();
table->fFlags = 0;
- table->fReserved = 0;
+ if (use8BitsForSafeTable()) {
+ table->fRowLen = offsetof(RBBIStateTableRow8, fNextState) + sizeof(uint8_t) * catCount;
+ table->fFlags |= RBBI_8BITS_ROWS;
+ } else {
+ table->fRowLen = offsetof(RBBIStateTableRow16, fNextState) + sizeof(int16_t) * catCount;
+ }
for (state=0; state<table->fNumStates; state++) {
UnicodeString *rowString = (UnicodeString *)fSafeTable->elementAt(state);
RBBIStateTableRow *row = (RBBIStateTableRow *)(table->fTableData + state*table->fRowLen);
- row->fAccepting = 0;
- row->fLookAhead = 0;
- row->fTagIdx = 0;
- row->fReserved = 0;
- for (col=0; col<catCount; col++) {
- row->fNextState[col] = rowString->charAt(col);
+ if (use8BitsForSafeTable()) {
+ row->r8.fAccepting = 0;
+ row->r8.fLookAhead = 0;
+ row->r8.fTagsIdx = 0;
+ for (col=0; col<catCount; col++) {
+ U_ASSERT(rowString->charAt(col) <= kMaxStateFor8BitsTable);
+ row->r8.fNextState[col] = static_cast<uint8_t>(rowString->charAt(col));
+ }
+ } else {
+ row->r16.fAccepting = 0;
+ row->r16.fLookAhead = 0;
+ row->r16.fTagsIdx = 0;
+ for (col=0; col<catCount; col++) {
+ row->r16.fNextState[col] = rowString->charAt(col);
+ }
}
}
}
@@ -1600,12 +1654,12 @@ void RBBITableBuilder::printStates() {
RBBIDebugPrintf("state | i n p u t s y m b o l s \n");
RBBIDebugPrintf(" | Acc LA Tag");
for (c=0; c<fRB->fSetBuilder->getNumCharCategories(); c++) {
- RBBIDebugPrintf(" %2d", c);
+ RBBIDebugPrintf(" %3d", c);
}
RBBIDebugPrintf("\n");
RBBIDebugPrintf(" |---------------");
for (c=0; c<fRB->fSetBuilder->getNumCharCategories(); c++) {
- RBBIDebugPrintf("---");
+ RBBIDebugPrintf("----");
}
RBBIDebugPrintf("\n");
@@ -1614,7 +1668,7 @@ void RBBITableBuilder::printStates() {
RBBIDebugPrintf(" %3d | " , n);
RBBIDebugPrintf("%3d %3d %5d ", sd->fAccepting, sd->fLookAhead, sd->fTagsIdx);
for (c=0; c<fRB->fSetBuilder->getNumCharCategories(); c++) {
- RBBIDebugPrintf(" %2d", sd->fDtran->elementAti(c));
+ RBBIDebugPrintf(" %3d", sd->fDtran->elementAti(c));
}
RBBIDebugPrintf("\n");
}
diff --git a/deps/icu-small/source/common/rbbitblb.h b/deps/icu-small/source/common/rbbitblb.h
index c2b574fe1b..fe3db8d7bf 100644
--- a/deps/icu-small/source/common/rbbitblb.h
+++ b/deps/icu-small/source/common/rbbitblb.h
@@ -20,6 +20,7 @@
#include "unicode/uobject.h"
#include "unicode/rbbi.h"
+#include "rbbidata.h"
#include "rbbirb.h"
#include "rbbinode.h"
@@ -53,6 +54,9 @@ public:
*/
void exportTable(void *where);
+ /** Use 8 bits to encode the forward table */
+ bool use8BitsForTable() const;
+
/**
* Find duplicate (redundant) character classes. Begin looking with categories.first.
* Duplicate, if found are returned in the categories parameter.
@@ -85,6 +89,8 @@ public:
*/
void exportSafeTable(void *where);
+ /** Use 8 bits to encode the safe reverse table */
+ bool use8BitsForSafeTable() const;
private:
void calcNullable(RBBINode *n);
@@ -179,9 +185,15 @@ private:
/** Map from rule number (fVal in look ahead nodes) to sequential lookahead index. */
UVector32 *fLookAheadRuleMap = nullptr;
+ /* Counter used when assigning lookahead rule numbers.
+ * Contains the last look-ahead number already in use.
+ * The first look-ahead number is 2; Number 1 (ACCEPTING_UNCONDITIONAL) is reserved
+ * for non-lookahead accepting states. See the declarations of RBBIStateTableRowT. */
+ int32_t fLASlotsInUse = ACCEPTING_UNCONDITIONAL;
+
- RBBITableBuilder(const RBBITableBuilder &other); // forbid copying of this class
- RBBITableBuilder &operator=(const RBBITableBuilder &other); // forbid copying of this class
+ RBBITableBuilder(const RBBITableBuilder &other) = delete; // forbid copying of this class
+ RBBITableBuilder &operator=(const RBBITableBuilder &other) = delete; // forbid copying of this class
};
//
@@ -190,8 +202,8 @@ private:
class RBBIStateDescriptor : public UMemory {
public:
UBool fMarked;
- int32_t fAccepting;
- int32_t fLookAhead;
+ uint32_t fAccepting;
+ uint32_t fLookAhead;
UVector *fTagVals;
int32_t fTagsIdx;
UVector *fPositions; // Set of parse tree positions associated
diff --git a/deps/icu-small/source/common/resource.h b/deps/icu-small/source/common/resource.h
index 5199b85888..3795694412 100644
--- a/deps/icu-small/source/common/resource.h
+++ b/deps/icu-small/source/common/resource.h
@@ -60,7 +60,7 @@ public:
/**
* @param i Array item index.
* @param value Output-only, receives the value of the i'th item.
- * @return TRUE if i is non-negative and less than getSize().
+ * @return true if i is non-negative and less than getSize().
*/
UBool getValue(int32_t i, ResourceValue &value) const;
@@ -97,14 +97,14 @@ public:
* @param i Table item index.
* @param key Output-only, receives the key of the i'th item.
* @param value Output-only, receives the value of the i'th item.
- * @return TRUE if i is non-negative and less than getSize().
+ * @return true if i is non-negative and less than getSize().
*/
UBool getKeyAndValue(int32_t i, const char *&key, ResourceValue &value) const;
/**
* @param key Key string to find in the table.
* @param value Output-only, receives the value of the item with that key.
- * @return TRUE if the table contains the key.
+ * @return true if the table contains the key.
*/
UBool findValue(const char *key, ResourceValue &value) const;
@@ -141,7 +141,7 @@ public:
inline UnicodeString getUnicodeString(UErrorCode &errorCode) const {
int32_t len = 0;
const UChar *r = getString(len, errorCode);
- return UnicodeString(TRUE, r, len);
+ return UnicodeString(true, r, len);
}
/**
@@ -152,7 +152,7 @@ public:
inline UnicodeString getAliasUnicodeString(UErrorCode &errorCode) const {
int32_t len = 0;
const UChar *r = getAliasString(len, errorCode);
- return UnicodeString(TRUE, r, len);
+ return UnicodeString(true, r, len);
}
/**
@@ -199,7 +199,7 @@ public:
* CLDR no-fallback data values of (three empty-set symbols)=={2205, 2205, 2205}
* when enumerating tables with fallback from the specific resource bundle to root.
*
- * @return TRUE if this is a no-inheritance marker string
+ * @return true if this is a no-inheritance marker string
*/
virtual UBool isNoInheritanceMarker() const = 0;
diff --git a/deps/icu-small/source/common/ruleiter.h b/deps/icu-small/source/common/ruleiter.h
index b6edc657af..f397f8bccd 100644
--- a/deps/icu-small/source/common/ruleiter.h
+++ b/deps/icu-small/source/common/ruleiter.h
@@ -114,7 +114,7 @@ public:
* character.
* @param options one or more of the following options, bitwise-OR-ed
* together: PARSE_VARIABLES, PARSE_ESCAPES, SKIP_WHITESPACE.
- * @param isEscaped output parameter set to TRUE if the character
+ * @param isEscaped output parameter set to true if the character
* was escaped
* @param ec input-output error code. An error will only be set by
* this routing if options includes PARSE_VARIABLES and an unknown
diff --git a/deps/icu-small/source/common/serv.h b/deps/icu-small/source/common/serv.h
index 70695839a8..6a3d1915af 100644
--- a/deps/icu-small/source/common/serv.h
+++ b/deps/icu-small/source/common/serv.h
@@ -138,16 +138,16 @@ class U_COMMON_API ICUServiceKey : public UObject {
* must eventually return false. This implementation has no fallbacks
* and always returns false.</p>
*
- * @return TRUE if the ICUServiceKey changed to a valid fallback value.
+ * @return true if the ICUServiceKey changed to a valid fallback value.
*/
virtual UBool fallback();
/**
- * <p>Return TRUE if a key created from id matches, or would eventually
+ * <p>Return true if a key created from id matches, or would eventually
* fallback to match, the canonical ID of this ICUServiceKey.</p>
*
* @param id the id to test.
- * @return TRUE if this ICUServiceKey's canonical ID is a fallback of id.
+ * @return true if this ICUServiceKey's canonical ID is a fallback of id.
*/
virtual UBool isFallbackOf(const UnicodeString& id) const;
@@ -291,15 +291,15 @@ class U_COMMON_API SimpleFactory : public ICUServiceFactory {
public:
/**
* <p>Construct a SimpleFactory that maps a single ID to a single
- * service instance. If visible is TRUE, the ID will be visible.
+ * service instance. If visible is true, the ID will be visible.
* The instance must not be NULL. The SimpleFactory will adopt
* the instance, which must not be changed subsequent to this call.</p>
*
* @param instanceToAdopt the service instance to adopt.
* @param id the ID to assign to this service instance.
- * @param visible if TRUE, the ID will be visible.
+ * @param visible if true, the ID will be visible.
*/
- SimpleFactory(UObject* instanceToAdopt, const UnicodeString& id, UBool visible = TRUE);
+ SimpleFactory(UObject* instanceToAdopt, const UnicodeString& id, UBool visible = true);
/**
* <p>Destructor.</p>
@@ -318,7 +318,7 @@ class U_COMMON_API SimpleFactory : public ICUServiceFactory {
virtual UObject* create(const ICUServiceKey& key, const ICUService* service, UErrorCode& status) const;
/**
- * <p>This implementation adds a mapping from ID -> this to result if visible is TRUE,
+ * <p>This implementation adds a mapping from ID -> this to result if visible is true,
* otherwise it removes ID from result.</p>
*
* @param result the mapping table to update.
@@ -327,7 +327,7 @@ class U_COMMON_API SimpleFactory : public ICUServiceFactory {
virtual void updateVisibleIDs(Hashtable& result, UErrorCode& status) const;
/**
- * <p>This implementation returns the factory ID if it equals id and visible is TRUE,
+ * <p>This implementation returns the factory ID if it equals id and visible is true,
* otherwise it returns the empty string. (This implementation provides
* no localized id information.)</p>
*
@@ -427,8 +427,8 @@ public:
UErrorCode& status);
/**
- * <p>Return TRUE if either string of the pair is bogus.</p>
- * @return TRUE if either string of the pair is bogus.
+ * <p>Return true if either string of the pair is bogus.</p>
+ * @return true if either string of the pair is bogus.
*/
UBool isBogus() const;
@@ -761,7 +761,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
/**
* <p>A convenience override of registerInstance(UObject*, const UnicodeString&, UBool)
- * that defaults visible to TRUE.</p>
+ * that defaults visible to true.</p>
*
* @param objToAdopt the object to register and adopt.
* @param id the ID to assign to this object.
@@ -774,7 +774,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
/**
* <p>Register a service instance with the provided ID. The ID will be
* canonicalized. The canonicalized ID will be returned by
- * getVisibleIDs if visible is TRUE. The service instance will be adopted and
+ * getVisibleIDs if visible is true. The service instance will be adopted and
* must not be modified subsequent to this call.</p>
*
* <p>This issues a serviceChanged notification to registered listeners.</p>
@@ -784,7 +784,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
*
* @param objToAdopt the object to register and adopt.
* @param id the ID to assign to this object.
- * @param visible TRUE if getVisibleIDs is to return this ID.
+ * @param visible true if getVisibleIDs is to return this ID.
* @param status the error code status.
* @return a registry key that can be passed to unregister() to unregister
* (and discard) this instance.
@@ -820,7 +820,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
*
* @param rkey the registry key.
* @param status the error code status.
- * @return TRUE if the call successfully unregistered the factory.
+ * @return true if the call successfully unregistered the factory.
*/
virtual UBool unregister(URegistryKey rkey, UErrorCode& status);
@@ -833,9 +833,9 @@ class U_COMMON_API ICUService : public ICUNotifier {
virtual void reset(void);
/**
- * <p>Return TRUE if the service is in its default state.</p>
+ * <p>Return true if the service is in its default state.</p>
*
- * <p>The default implementation returns TRUE if there are no
+ * <p>The default implementation returns true if there are no
* factories registered.</p>
*/
virtual UBool isDefault(void) const;
@@ -877,7 +877,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
*
* @param instanceToAdopt the service instance to adopt.
* @param id the ID to assign to this service instance.
- * @param visible if TRUE, the ID will be visible.
+ * @param visible if true, the ID will be visible.
* @param status the error code status.
* @return an instance of ICUServiceFactory that maps this instance to the provided ID.
*/
@@ -885,7 +885,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
/**
* <p>Reinitialize the factory list to its default state. After this call, isDefault()
- * must return TRUE.</p>
+ * must return true.</p>
*
* <p>This issues a serviceChanged notification to registered listeners.</p>
*
@@ -928,7 +928,7 @@ class U_COMMON_API ICUService : public ICUNotifier {
* different listeners.</p>
*
* @param l the listener to test.
- * @return TRUE if the service accepts the listener.
+ * @return true if the service accepts the listener.
*/
virtual UBool acceptsListener(const EventListener& l) const;
diff --git a/deps/icu-small/source/common/servnotf.h b/deps/icu-small/source/common/servnotf.h
index cf92fc169e..7918a67247 100644
--- a/deps/icu-small/source/common/servnotf.h
+++ b/deps/icu-small/source/common/servnotf.h
@@ -105,7 +105,7 @@ public:
protected:
/**
- * Subclasses implement this to return TRUE if the listener is
+ * Subclasses implement this to return true if the listener is
* of the appropriate type.
*/
virtual UBool acceptsListener(const EventListener& l) const = 0;
diff --git a/deps/icu-small/source/common/sharedobject.h b/deps/icu-small/source/common/sharedobject.h
index 878594c7ff..0565de6608 100644
--- a/deps/icu-small/source/common/sharedobject.h
+++ b/deps/icu-small/source/common/sharedobject.h
@@ -90,13 +90,13 @@ public:
int32_t getRefCount() const;
/**
- * If noHardReferences() == TRUE then this object has no hard references.
+ * If noHardReferences() == true then this object has no hard references.
* Must be called only from within the internals of UnifiedCache.
*/
inline UBool noHardReferences() const { return getRefCount() == 0; }
/**
- * If hasHardReferences() == TRUE then this object has hard references.
+ * If hasHardReferences() == true then this object has hard references.
* Must be called only from within the internals of UnifiedCache.
*/
inline UBool hasHardReferences() const { return getRefCount() != 0; }
diff --git a/deps/icu-small/source/common/simpleformatter.cpp b/deps/icu-small/source/common/simpleformatter.cpp
index 76d8f54efd..f7f7aead61 100644
--- a/deps/icu-small/source/common/simpleformatter.cpp
+++ b/deps/icu-small/source/common/simpleformatter.cpp
@@ -263,6 +263,8 @@ UnicodeString SimpleFormatter::getTextWithNoArguments(
sb.append(compiledPattern + i, n);
i += n;
} else if (n < offsetsLength) {
+ // TODO(ICU-20406): This does not distinguish between "{0}{1}" and "{1}{0}".
+ // Consider removing this function and replacing it with an iterator interface.
offsets[n] = sb.length();
}
}
diff --git a/deps/icu-small/source/common/uassert.h b/deps/icu-small/source/common/uassert.h
index 15cd55c873..afd31eeffd 100644
--- a/deps/icu-small/source/common/uassert.h
+++ b/deps/icu-small/source/common/uassert.h
@@ -32,7 +32,7 @@
# include <assert.h>
# define U_ASSERT(exp) assert(exp)
#elif U_CPLUSPLUS_VERSION
-# define U_ASSERT(exp) void()
+# define U_ASSERT(exp) (void)0
#else
# define U_ASSERT(exp)
#endif
diff --git a/deps/icu-small/source/common/ubidi_props.cpp b/deps/icu-small/source/common/ubidi_props.cpp
index 4141c21938..afcc4aaf4f 100644
--- a/deps/icu-small/source/common/ubidi_props.cpp
+++ b/deps/icu-small/source/common/ubidi_props.cpp
@@ -248,7 +248,7 @@ u_charMirror(UChar32 c) {
return ubidi_getMirror(c);
}
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
u_getBidiPairedBracket(UChar32 c) {
return ubidi_getPairedBracket(c);
}
diff --git a/deps/icu-small/source/common/ubidiimp.h b/deps/icu-small/source/common/ubidiimp.h
index 9746b2bc10..e48fc6f941 100644
--- a/deps/icu-small/source/common/ubidiimp.h
+++ b/deps/icu-small/source/common/ubidiimp.h
@@ -26,6 +26,14 @@
/* miscellaneous definitions ---------------------------------------------- */
+// ICU-20853=ICU-20935 Solaris #defines CS and ES in sys/regset.h
+#ifdef CS
+# undef CS
+#endif
+#ifdef ES
+# undef ES
+#endif
+
typedef uint8_t DirProp;
typedef uint32_t Flags;
@@ -451,26 +459,26 @@ ubidi_getMemory(BidiMemoryForAllocation *pMemory, int32_t *pSize, UBool mayAlloc
/* additional macros used by ubidi_open() - always allow allocation */
#define getInitialDirPropsMemory(pBiDi, length) \
ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->dirPropsMemory, &(pBiDi)->dirPropsSize, \
- TRUE, (length))
+ true, (length))
#define getInitialLevelsMemory(pBiDi, length) \
ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->levelsMemory, &(pBiDi)->levelsSize, \
- TRUE, (length))
+ true, (length))
#define getInitialOpeningsMemory(pBiDi, length) \
ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->openingsMemory, &(pBiDi)->openingsSize, \
- TRUE, (length)*sizeof(Opening))
+ true, (length)*sizeof(Opening))
#define getInitialParasMemory(pBiDi, length) \
ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->parasMemory, &(pBiDi)->parasSize, \
- TRUE, (length)*sizeof(Para))
+ true, (length)*sizeof(Para))
#define getInitialRunsMemory(pBiDi, length) \
ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->runsMemory, &(pBiDi)->runsSize, \
- TRUE, (length)*sizeof(Run))
+ true, (length)*sizeof(Run))
#define getInitialIsolatesMemory(pBiDi, length) \
ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->isolatesMemory, &(pBiDi)->isolatesSize, \
- TRUE, (length)*sizeof(Isolate))
+ true, (length)*sizeof(Isolate))
#endif
diff --git a/deps/icu-small/source/common/ubiditransform.cpp b/deps/icu-small/source/common/ubiditransform.cpp
index bb3ce8cb93..ab3dcbe14c 100644
--- a/deps/icu-small/source/common/ubiditransform.cpp
+++ b/deps/icu-small/source/common/ubiditransform.cpp
@@ -89,7 +89,7 @@ struct UBiDiTransform {
uint32_t letters; /* letter option for ArabicShaping */
};
-U_DRAFT UBiDiTransform* U_EXPORT2
+U_CAPI UBiDiTransform* U_EXPORT2
ubiditransform_open(UErrorCode *pErrorCode)
{
UBiDiTransform *pBiDiTransform = NULL;
@@ -102,7 +102,7 @@ ubiditransform_open(UErrorCode *pErrorCode)
return pBiDiTransform;
}
-U_DRAFT void U_EXPORT2
+U_CAPI void U_EXPORT2
ubiditransform_close(UBiDiTransform *pBiDiTransform)
{
if (pBiDiTransform != NULL) {
@@ -434,7 +434,7 @@ findMatchingScheme(UBiDiLevel inLevel, UBiDiLevel outLevel,
return NULL;
}
-U_DRAFT uint32_t U_EXPORT2
+U_CAPI uint32_t U_EXPORT2
ubiditransform_transform(UBiDiTransform *pBiDiTransform,
const UChar *src, int32_t srcLength,
UChar *dest, int32_t destSize,
diff --git a/deps/icu-small/source/common/ucase.cpp b/deps/icu-small/source/common/ucase.cpp
index 57a4032790..c2180629fb 100644
--- a/deps/icu-small/source/common/ucase.cpp
+++ b/deps/icu-small/source/common/ucase.cpp
@@ -707,6 +707,7 @@ ucase_isCaseSensitive(UChar32 c) {
#define is_r(c) ((c)=='r' || (c)=='R')
#define is_t(c) ((c)=='t' || (c)=='T')
#define is_u(c) ((c)=='u' || (c)=='U')
+#define is_y(c) ((c)=='y' || (c)=='Y')
#define is_z(c) ((c)=='z' || (c)=='Z')
/* separator? */
@@ -804,6 +805,18 @@ ucase_getCaseLocale(const char *locale) {
return UCASE_LOC_DUTCH;
}
}
+ } else if(c=='h') {
+ /* hy or hye? *not* hyw */
+ c=*locale++;
+ if(is_y(c)) {
+ c=*locale++;
+ if(is_e(c)) {
+ c=*locale;
+ }
+ if(is_sep(c)) {
+ return UCASE_LOC_ARMENIAN;
+ }
+ }
}
} else {
// uppercase c
@@ -868,6 +881,18 @@ ucase_getCaseLocale(const char *locale) {
return UCASE_LOC_DUTCH;
}
}
+ } else if(c=='H') {
+ /* hy or hye? *not* hyw */
+ c=*locale++;
+ if(is_y(c)) {
+ c=*locale++;
+ if(is_e(c)) {
+ c=*locale;
+ }
+ if(is_sep(c)) {
+ return UCASE_LOC_ARMENIAN;
+ }
+ }
}
}
return UCASE_LOC_ROOT;
@@ -1229,6 +1254,17 @@ toUpperOrTitle(UChar32 c,
*/
*pString=nullptr;
return 0; /* remove the dot (continue without output) */
+ } else if(c==0x0587) {
+ // See ICU-13416:
+ // և ligature ech-yiwn
+ // uppercases to ԵՒ=ech+yiwn by default and in Western Armenian,
+ // but to ԵՎ=ech+vew in Eastern Armenian.
+ if(loc==UCASE_LOC_ARMENIAN) {
+ *pString=upperNotTitle ? u"ԵՎ" : u"Եվ";
+ } else {
+ *pString=upperNotTitle ? u"ԵՒ" : u"Եւ";
+ }
+ return 2;
} else {
/* no known conditional special case mapping, use a normal mapping */
}
diff --git a/deps/icu-small/source/common/ucase.h b/deps/icu-small/source/common/ucase.h
index b0a453b87e..a018f82b81 100644
--- a/deps/icu-small/source/common/ucase.h
+++ b/deps/icu-small/source/common/ucase.h
@@ -56,7 +56,8 @@ enum {
UCASE_LOC_TURKISH,
UCASE_LOC_LITHUANIAN,
UCASE_LOC_GREEK,
- UCASE_LOC_DUTCH
+ UCASE_LOC_DUTCH,
+ UCASE_LOC_ARMENIAN
};
/**
@@ -117,7 +118,7 @@ ucase_addCaseClosure(UChar32 c, const USetAdder *sa);
* the string itself is added as well as part of its code points' closure.
* It must be length>=0.
*
- * @return TRUE if the string was found
+ * @return true if the string was found
*/
U_CFUNC UBool U_EXPORT2
ucase_addStringCaseClosure(const UChar *s, int32_t length, const USetAdder *sa);
diff --git a/deps/icu-small/source/common/ucase_props_data.h b/deps/icu-small/source/common/ucase_props_data.h
index 7c97230957..aead6d58d1 100644
--- a/deps/icu-small/source/common/ucase_props_data.h
+++ b/deps/icu-small/source/common/ucase_props_data.h
@@ -13,7 +13,7 @@
static const UVersionInfo ucase_props_dataVersion={0xd,0,0,0};
-static const int32_t ucase_props_indexes[UCASE_IX_TOP]={0x10,0x70ca,0x6098,0x687,0x172,0,0,0,0,0,0,0,0,0,0,3};
+static const int32_t ucase_props_indexes[UCASE_IX_TOP]={0x10,0x70c2,0x6098,0x683,0x172,0,0,0,0,0,0,0,0,0,0,3};
static const uint16_t ucase_props_trieIndex[12356]={
0x336,0x33e,0x346,0x34e,0x35c,0x364,0x36c,0x374,0x37c,0x384,0x38b,0x393,0x39b,0x3a3,0x3ab,0x3b3,
@@ -411,18 +411,18 @@ static const uint16_t ucase_props_trieIndex[12356]={
0,0,0,0,0,4,4,4,4,0,0,0,0,0,0,0,
0,0,0,0,0,0,4,0,0,4,4,0,0,0,0,0,
0,0x64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,4,0,0,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,
-0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,
-0x179a,0x179a,0x179a,0x179a,0x179a,0x179a,0,0x179a,0,0,0,0,0,0x179a,0,0,
-0x17b9,0x17e9,0x1819,0x1849,0x1879,0x18a9,0x18d9,0x1909,0x1939,0x1969,0x1999,0x19c9,0x19f9,0x1a29,0x1a59,0x1a89,
-0x1ab9,0x1ae9,0x1b19,0x1b49,0x1b79,0x1ba9,0x1bd9,0x1c09,0x1c39,0x1c69,0x1c99,0x1cc9,0x1cf9,0x1d29,0x1d59,0x1d89,
-0x1db9,0x1de9,0x1e19,0x1e49,0x1e79,0x1ea9,0x1ed9,0x1f09,0x1f39,0x1f69,0x1f99,0,4,0x1fc9,0x1ff9,0x2029,
+0,4,0,0,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,
+0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,
+0x175a,0x175a,0x175a,0x175a,0x175a,0x175a,0,0x175a,0,0,0,0,0,0x175a,0,0,
+0x1779,0x17a9,0x17d9,0x1809,0x1839,0x1869,0x1899,0x18c9,0x18f9,0x1929,0x1959,0x1989,0x19b9,0x19e9,0x1a19,0x1a49,
+0x1a79,0x1aa9,0x1ad9,0x1b09,0x1b39,0x1b69,0x1b99,0x1bc9,0x1bf9,0x1c29,0x1c59,0x1c89,0x1cb9,0x1ce9,0x1d19,0x1d49,
+0x1d79,0x1da9,0x1dd9,0x1e09,0x1e39,0x1e69,0x1e99,0x1ec9,0x1ef9,0x1f29,0x1f59,0,4,0x1f89,0x1fb9,0x1fe9,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0x44,0x44,0x44,
-0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,
-0x207a,0x207a,0x207a,0x207a,0x207a,0x207a,0,0,0x2099,0x20c9,0x20f9,0x2129,0x2159,0x2189,0,0,
-0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,
-0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,0x205a,
+0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,
+0x203a,0x203a,0x203a,0x203a,0x203a,0x203a,0,0,0x2059,0x2089,0x20b9,0x20e9,0x2119,0x2149,0,0,
+0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,
+0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,0x201a,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,4,4,0x64,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,4,
@@ -458,9 +458,9 @@ static const uint16_t ucase_props_trieIndex[12356]={
0,0,0,0,4,4,4,4,4,4,4,4,0,0,4,0x64,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,4,4,4,4,4,4,0,0,
-0x21b9,0x21e9,0x2219,0x2249,0x2279,0x22c9,0x2319,0x2349,0x2379,0,0,0,0,0,0,0,
-0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,
-0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0x23aa,0,0,0x23aa,0x23aa,0x23aa,
+0x2179,0x21a9,0x21d9,0x2209,0x2239,0x2289,0x22d9,0x2309,0x2339,0,0,0,0,0,0,0,
+0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,
+0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0x236a,0,0,0x236a,0x236a,0x236a,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0x44,0x44,0x44,0,0x64,0x64,0x64,0x64,0x64,0x64,0x44,0x44,0x64,0x64,0x64,0x64,
0x44,0,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0,0,0,0,0x64,0,0,
@@ -470,10 +470,10 @@ static const uint16_t ucase_props_trieIndex[12356]={
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
5,5,0x25,5,5,5,5,5,5,5,5,1,1,1,1,1,
-1,1,1,1,1,1,1,1,5,0x23c9,1,1,1,0x23e9,1,1,
+1,1,1,1,1,1,1,1,5,0x2389,1,1,1,0x23a9,1,1,
5,5,5,5,0x25,5,5,5,0x25,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,0x2409,1,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,0x23c9,1,
1,1,1,1,1,1,0x21,1,1,1,1,5,5,5,5,5,
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
0x44,0x44,0x44,0x44,0x44,0x44,0x64,0x64,0x64,0x64,0,0x44,0x64,0x64,0x44,0x64,
@@ -481,27 +481,27 @@ static const uint16_t ucase_props_trieIndex[12356]={
0x64,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xffb1,0x92,0xff91,
0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,
-0x242a,0x2469,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,
+0x23ea,0x2429,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,
0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,
-0x92,0xff91,0x24a9,0x2529,0x25a9,0x2629,0x26a9,0x2729,1,1,0x275a,1,0x92,0xff91,0x92,0xff91,
+0x92,0xff91,0x2469,0x24e9,0x2569,0x25e9,0x2669,0x26e9,1,1,0x271a,1,0x92,0xff91,0x92,0xff91,
0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xffb1,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,
0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x411,0x411,0x411,0x411,
0x411,0x411,0x411,0x411,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0x411,0x411,0x411,0x411,
0x411,0x411,0,0,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0,0,0x411,0x411,0x411,0x411,
0x411,0x411,0x411,0x411,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0x411,0x411,0x411,0x411,
0x411,0x411,0x411,0x411,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0x411,0x411,0x411,0x411,
-0x411,0x411,0,0,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0,0,0x27a9,0x411,0x2829,0x411,
-0x28d9,0x411,0x2989,0x411,0,0xfc12,0,0xfc12,0,0xfc12,0,0xfc12,0x411,0x411,0x411,0x411,
+0x411,0x411,0,0,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0,0,0x2769,0x411,0x27e9,0x411,
+0x2899,0x411,0x2949,0x411,0,0xfc12,0,0xfc12,0,0xfc12,0,0xfc12,0x411,0x411,0x411,0x411,
0x411,0x411,0x411,0x411,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0xfc12,0x2511,0x2511,0x2b11,0x2b11,
-0x2b11,0x2b11,0x3211,0x3211,0x4011,0x4011,0x3811,0x3811,0x3f11,0x3f11,0,0,0x2a39,0x2aa9,0x2b19,0x2b89,
-0x2bf9,0x2c69,0x2cd9,0x2d49,0x2dbb,0x2e2b,0x2e9b,0x2f0b,0x2f7b,0x2feb,0x305b,0x30cb,0x3139,0x31a9,0x3219,0x3289,
-0x32f9,0x3369,0x33d9,0x3449,0x34bb,0x352b,0x359b,0x360b,0x367b,0x36eb,0x375b,0x37cb,0x3839,0x38a9,0x3919,0x3989,
-0x39f9,0x3a69,0x3ad9,0x3b49,0x3bbb,0x3c2b,0x3c9b,0x3d0b,0x3d7b,0x3deb,0x3e5b,0x3ecb,0x411,0x411,0x3f39,0x3fb9,
-0x4029,0,0x40a9,0x4129,0xfc12,0xfc12,0xdb12,0xdb12,0x41db,4,0x4249,4,4,4,0x4299,0x4319,
-0x4389,0,0x4409,0x4489,0xd512,0xd512,0xd512,0xd512,0x453b,4,4,4,0x411,0x411,0x45a9,0x4659,
-0,0,0x4729,0x47a9,0xfc12,0xfc12,0xce12,0xce12,0,4,4,4,0x411,0x411,0x4859,0x4909,
-0x49d9,0x391,0x4a59,0x4ad9,0xfc12,0xfc12,0xc812,0xc812,0xfc92,4,4,4,0,0,0x4b89,0x4c09,
-0x4c79,0,0x4cf9,0x4d79,0xc012,0xc012,0xc112,0xc112,0x4e2b,4,4,0,0,0,0,0,
+0x2b11,0x2b11,0x3211,0x3211,0x4011,0x4011,0x3811,0x3811,0x3f11,0x3f11,0,0,0x29f9,0x2a69,0x2ad9,0x2b49,
+0x2bb9,0x2c29,0x2c99,0x2d09,0x2d7b,0x2deb,0x2e5b,0x2ecb,0x2f3b,0x2fab,0x301b,0x308b,0x30f9,0x3169,0x31d9,0x3249,
+0x32b9,0x3329,0x3399,0x3409,0x347b,0x34eb,0x355b,0x35cb,0x363b,0x36ab,0x371b,0x378b,0x37f9,0x3869,0x38d9,0x3949,
+0x39b9,0x3a29,0x3a99,0x3b09,0x3b7b,0x3beb,0x3c5b,0x3ccb,0x3d3b,0x3dab,0x3e1b,0x3e8b,0x411,0x411,0x3ef9,0x3f79,
+0x3fe9,0,0x4069,0x40e9,0xfc12,0xfc12,0xdb12,0xdb12,0x419b,4,0x4209,4,4,4,0x4259,0x42d9,
+0x4349,0,0x43c9,0x4449,0xd512,0xd512,0xd512,0xd512,0x44fb,4,4,4,0x411,0x411,0x4569,0x4619,
+0,0,0x46e9,0x4769,0xfc12,0xfc12,0xce12,0xce12,0,4,4,4,0x411,0x411,0x4819,0x48c9,
+0x4999,0x391,0x4a19,0x4a99,0xfc12,0xfc12,0xc812,0xc812,0xfc92,4,4,4,0,0,0x4b49,0x4bc9,
+0x4c39,0,0x4cb9,0x4d39,0xc012,0xc012,0xc112,0xc112,0x4deb,4,4,0,0,0,0,0,
0,0,0,0,0,0,0,4,4,4,4,4,0,0,0,0,
0,0,0,0,4,4,0,0,0,0,0,0,4,0,0,4,
0,0,4,4,4,4,4,0,0,0,0,0,0,0,0,0,
@@ -515,8 +515,8 @@ static const uint16_t ucase_props_trieIndex[12356]={
0x64,0x44,0x64,0x64,0x64,0x64,0x64,0x64,0x44,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,
0,0,1,2,2,2,1,1,2,2,2,1,0,2,0,0,
-0,2,2,2,2,2,0,0,0,0,0,0,2,0,0x4e9a,0,
-2,0,0x4eda,0x4f1a,2,2,0,1,2,2,0xe12,2,1,0,0,0,
+0,2,2,2,2,2,0,0,0,0,0,0,2,0,0x4e5a,0,
+2,0,0x4e9a,0x4eda,2,2,0,1,2,2,0xe12,2,1,0,0,0,
0,1,0,0,1,1,2,2,0,0,0,0,0,2,1,1,
0x21,0x21,0,0,0,0,0xf211,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0x812,0x812,0x812,0x812,0x812,0x812,0x812,0x812,
@@ -531,14 +531,14 @@ static const uint16_t ucase_props_trieIndex[12356]={
0x1812,0x1812,0x1812,0x1812,0x1812,0x1812,0x1812,0x1812,0x1812,0x1812,0x1812,0x1812,0x1812,0x1812,0x1812,0x1812,
0x1812,0x1812,0x1812,0x1812,0x1812,0x1812,0x1812,0,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,
0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,
-0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0,0x92,0xff91,0x4f5a,0x4f7a,0x4f9a,0x4fb9,0x4fd9,0x92,
-0xff91,0x92,0xff91,0x92,0xff91,0x4ffa,0x501a,0x503a,0x505a,1,0x92,0xff91,1,0x92,0xff91,1,
-1,1,1,1,0x25,5,0x507a,0x507a,0x92,0xff91,0x92,0xff91,1,0,0,0,
+0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0xe811,0,0x92,0xff91,0x4f1a,0x4f3a,0x4f5a,0x4f79,0x4f99,0x92,
+0xff91,0x92,0xff91,0x92,0xff91,0x4fba,0x4fda,0x4ffa,0x501a,1,0x92,0xff91,1,0x92,0xff91,1,
+1,1,1,1,0x25,5,0x503a,0x503a,0x92,0xff91,0x92,0xff91,1,0,0,0,
0,0,0,0x92,0xff91,0x92,0xff91,0x44,0x44,0x44,0x92,0xff91,0,0,0,0,
-0,0,0,0,0,0,0,0,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,
-0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,
-0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0x5099,0,0x5099,0,0,0,0,
-0,0x5099,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,
+0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,
+0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0x5059,0,0x5059,0,0,0,0,
+0,0x5059,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0x64,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
@@ -552,7 +552,7 @@ static const uint16_t ucase_props_trieIndex[12356]={
0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0x92,0xff91,0x92,0xff91,
-0x92,0xff91,0x92,0xff91,0x92,0xff91,0x50ba,0x50f9,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,
+0x92,0xff91,0x92,0xff91,0x92,0xff91,0x507a,0x50b9,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,
0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0,0x44,
4,4,4,0,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0,4,
0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,
@@ -564,11 +564,11 @@ static const uint16_t ucase_props_trieIndex[12356]={
4,4,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,
1,1,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,
0x92,0xff91,0x92,0xff91,5,1,1,1,1,1,1,1,1,0x92,0xff91,0x92,
-0xff91,0x513a,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,4,4,4,0x92,
-0xff91,0x515a,1,0,0x92,0xff91,0x92,0xff91,0x1811,1,0x92,0xff91,0x92,0xff91,0x92,0xff91,
-0x92,0xff91,0x92,0xff91,0x92,0xff91,0x517a,0x519a,0x51ba,0x51da,0x517a,1,0x51fa,0x521a,0x523a,0x525a,
+0xff91,0x50fa,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,4,4,4,0x92,
+0xff91,0x511a,1,0,0x92,0xff91,0x92,0xff91,0x1811,1,0x92,0xff91,0x92,0xff91,0x92,0xff91,
+0x92,0xff91,0x92,0xff91,0x92,0xff91,0x513a,0x515a,0x517a,0x519a,0x513a,1,0x51ba,0x51da,0x51fa,0x521a,
0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0x92,0xff91,0,0,0x92,0xff91,
-0xe812,0x527a,0x529a,0x92,0xff91,0x92,0xff91,0,0,0,0,0,0,0,0,0,
+0xe812,0x523a,0x525a,0x92,0xff91,0x92,0xff91,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0x92,0xff91,0,
5,5,1,0,0,0,0,0,0,0,4,0,0,0,0x64,0,
0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -597,17 +597,17 @@ static const uint16_t ucase_props_trieIndex[12356]={
0,0,0,0,4,4,0,0,0,0,0,4,4,0,0x64,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,0x52b9,1,1,1,1,1,1,1,4,5,5,5,5,
+1,1,1,0x5279,1,1,1,1,1,1,1,4,5,5,5,5,
1,1,1,1,1,1,1,1,1,4,4,4,0,0,0,0,
-0x52d9,0x5309,0x5339,0x5369,0x5399,0x53c9,0x53f9,0x5429,0x5459,0x5489,0x54b9,0x54e9,0x5519,0x5549,0x5579,0x55a9,
-0x5bd9,0x5c09,0x5c39,0x5c69,0x5c99,0x5cc9,0x5cf9,0x5d29,0x5d59,0x5d89,0x5db9,0x5de9,0x5e19,0x5e49,0x5e79,0x5ea9,
-0x5ed9,0x5f09,0x5f39,0x5f69,0x5f99,0x5fc9,0x5ff9,0x6029,0x6059,0x6089,0x60b9,0x60e9,0x6119,0x6149,0x6179,0x61a9,
-0x55d9,0x5609,0x5639,0x5669,0x5699,0x56c9,0x56f9,0x5729,0x5759,0x5789,0x57b9,0x57e9,0x5819,0x5849,0x5879,0x58a9,
-0x58d9,0x5909,0x5939,0x5969,0x5999,0x59c9,0x59f9,0x5a29,0x5a59,0x5a89,0x5ab9,0x5ae9,0x5b19,0x5b49,0x5b79,0x5ba9,
+0x5299,0x52c9,0x52f9,0x5329,0x5359,0x5389,0x53b9,0x53e9,0x5419,0x5449,0x5479,0x54a9,0x54d9,0x5509,0x5539,0x5569,
+0x5b99,0x5bc9,0x5bf9,0x5c29,0x5c59,0x5c89,0x5cb9,0x5ce9,0x5d19,0x5d49,0x5d79,0x5da9,0x5dd9,0x5e09,0x5e39,0x5e69,
+0x5e99,0x5ec9,0x5ef9,0x5f29,0x5f59,0x5f89,0x5fb9,0x5fe9,0x6019,0x6049,0x6079,0x60a9,0x60d9,0x6109,0x6139,0x6169,
+0x5599,0x55c9,0x55f9,0x5629,0x5659,0x5689,0x56b9,0x56e9,0x5719,0x5749,0x5779,0x57a9,0x57d9,0x5809,0x5839,0x5869,
+0x5899,0x58c9,0x58f9,0x5929,0x5959,0x5989,0x59b9,0x59e9,0x5a19,0x5a49,0x5a79,0x5aa9,0x5ad9,0x5b09,0x5b39,0x5b69,
0,0,0,0,0,4,0,0,4,0,0,0,0,0x64,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0x61d9,0x6259,0x62d9,0x6359,0x6409,0x64b9,0x6559,0,0,0,0,0,0,0,0,0,
-0,0,0,0x65f9,0x6679,0x66f9,0x6779,0x67f9,0,0,0,0,0,0,0x64,0,
+0x6199,0x6219,0x6299,0x6319,0x63c9,0x6479,0x6519,0,0,0,0,0,0,0,0,0,
+0,0,0,0x65b9,0x6639,0x66b9,0x6739,0x67b9,0,0,0,0,0,0,0x64,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
4,4,4,4,0,0,0,4,0,0,0,0,0,0,0,0,
@@ -791,7 +791,7 @@ static const uint16_t ucase_props_trieIndex[12356]={
0,0,0,0
};
-static const uint16_t ucase_props_exceptions[1671]={
+static const uint16_t ucase_props_exceptions[1667]={
0xc850,0x20,2,0x130,0x131,0x4810,0x20,0x841,0x6b,1,0x212a,0x841,0x73,1,0x17f,0x5c50,
0x20,2,0x130,0x131,0x844,0x4b,1,0x212a,0x844,0x53,1,0x17f,0x806,0x3bc,0x39c,0x841,
0xe5,1,0x212b,0x8c0,1,0x2220,0x73,0x73,0x53,0x53,0x53,0x73,0x1e9e,0x844,0xc5,1,
@@ -815,88 +815,88 @@ static const uint16_t ucase_props_exceptions[1671]={
0x43e,1,0x1c82,0x841,0x441,1,0x1c83,0x841,0x442,2,0x1c84,0x1c85,0x841,0x44a,1,0x1c86,
0x844,0x412,1,0x1c80,0x844,0x414,1,0x1c81,0x844,0x41e,1,0x1c82,0x844,0x421,1,0x1c83,
0x844,0x422,2,0x1c84,0x1c85,0x844,0x42a,1,0x1c86,0x841,0x463,1,0x1c87,0x844,0x462,1,
-0x1c87,0x880,0x2220,0x565,0x582,0x535,0x552,0x535,0x582,0x810,0x1c60,0x80c,0x1c90,0x10d0,0x80c,0x1c91,
-0x10d1,0x80c,0x1c92,0x10d2,0x80c,0x1c93,0x10d3,0x80c,0x1c94,0x10d4,0x80c,0x1c95,0x10d5,0x80c,0x1c96,0x10d6,
-0x80c,0x1c97,0x10d7,0x80c,0x1c98,0x10d8,0x80c,0x1c99,0x10d9,0x80c,0x1c9a,0x10da,0x80c,0x1c9b,0x10db,0x80c,
-0x1c9c,0x10dc,0x80c,0x1c9d,0x10dd,0x80c,0x1c9e,0x10de,0x80c,0x1c9f,0x10df,0x80c,0x1ca0,0x10e0,0x80c,0x1ca1,
-0x10e1,0x80c,0x1ca2,0x10e2,0x80c,0x1ca3,0x10e3,0x80c,0x1ca4,0x10e4,0x80c,0x1ca5,0x10e5,0x80c,0x1ca6,0x10e6,
-0x80c,0x1ca7,0x10e7,0x80c,0x1ca8,0x10e8,0x80c,0x1ca9,0x10e9,0x80c,0x1caa,0x10ea,0x80c,0x1cab,0x10eb,0x80c,
-0x1cac,0x10ec,0x80c,0x1cad,0x10ed,0x80c,0x1cae,0x10ee,0x80c,0x1caf,0x10ef,0x80c,0x1cb0,0x10f0,0x80c,0x1cb1,
-0x10f1,0x80c,0x1cb2,0x10f2,0x80c,0x1cb3,0x10f3,0x80c,0x1cb4,0x10f4,0x80c,0x1cb5,0x10f5,0x80c,0x1cb6,0x10f6,
-0x80c,0x1cb7,0x10f7,0x80c,0x1cb8,0x10f8,0x80c,0x1cb9,0x10f9,0x80c,0x1cba,0x10fa,0x80c,0x1cbd,0x10fd,0x80c,
-0x1cbe,0x10fe,0x80c,0x1cbf,0x10ff,0xa10,0x97d0,0xa10,8,0x806,0x13f0,0x13f0,0x806,0x13f1,0x13f1,0x806,
-0x13f2,0x13f2,0x806,0x13f3,0x13f3,0x806,0x13f4,0x13f4,0x806,0x13f5,0x13f5,0x806,0x432,0x412,0x806,0x434,
-0x414,0x806,0x43e,0x41e,0x806,0x441,0x421,0x846,0x442,0x422,1,0x1c85,0x846,0x442,0x422,1,
-0x1c84,0x806,0x44a,0x42a,0x806,0x463,0x462,0x806,0xa64b,0xa64a,0xc10,0xbc0,0x810,0x8a04,0x810,0xee6,
-0x810,0x8a38,0x841,0x1e61,1,0x1e9b,0x844,0x1e60,1,0x1e9b,0x880,0x2220,0x68,0x331,0x48,0x331,
-0x48,0x331,0x880,0x2220,0x74,0x308,0x54,0x308,0x54,0x308,0x880,0x2220,0x77,0x30a,0x57,0x30a,
-0x57,0x30a,0x880,0x2220,0x79,0x30a,0x59,0x30a,0x59,0x30a,0x880,0x2220,0x61,0x2be,0x41,0x2be,
-0x41,0x2be,0x806,0x1e61,0x1e60,0xc90,0x1dbf,0x20,0x73,0x73,0x880,0x2220,0x3c5,0x313,0x3a5,0x313,
-0x3a5,0x313,0x880,0x3330,0x3c5,0x313,0x300,0x3a5,0x313,0x300,0x3a5,0x313,0x300,0x880,0x3330,0x3c5,
-0x313,0x301,0x3a5,0x313,0x301,0x3a5,0x313,0x301,0x880,0x3330,0x3c5,0x313,0x342,0x3a5,0x313,0x342,
-0x3a5,0x313,0x342,0x890,8,0x220,0x1f00,0x3b9,0x1f08,0x399,0x890,8,0x220,0x1f01,0x3b9,0x1f09,
-0x399,0x890,8,0x220,0x1f02,0x3b9,0x1f0a,0x399,0x890,8,0x220,0x1f03,0x3b9,0x1f0b,0x399,0x890,
-8,0x220,0x1f04,0x3b9,0x1f0c,0x399,0x890,8,0x220,0x1f05,0x3b9,0x1f0d,0x399,0x890,8,0x220,
-0x1f06,0x3b9,0x1f0e,0x399,0x890,8,0x220,0x1f07,0x3b9,0x1f0f,0x399,0xc90,8,0x220,0x1f00,0x3b9,
-0x1f08,0x399,0xc90,8,0x220,0x1f01,0x3b9,0x1f09,0x399,0xc90,8,0x220,0x1f02,0x3b9,0x1f0a,0x399,
-0xc90,8,0x220,0x1f03,0x3b9,0x1f0b,0x399,0xc90,8,0x220,0x1f04,0x3b9,0x1f0c,0x399,0xc90,8,
-0x220,0x1f05,0x3b9,0x1f0d,0x399,0xc90,8,0x220,0x1f06,0x3b9,0x1f0e,0x399,0xc90,8,0x220,0x1f07,
-0x3b9,0x1f0f,0x399,0x890,8,0x220,0x1f20,0x3b9,0x1f28,0x399,0x890,8,0x220,0x1f21,0x3b9,0x1f29,
-0x399,0x890,8,0x220,0x1f22,0x3b9,0x1f2a,0x399,0x890,8,0x220,0x1f23,0x3b9,0x1f2b,0x399,0x890,
-8,0x220,0x1f24,0x3b9,0x1f2c,0x399,0x890,8,0x220,0x1f25,0x3b9,0x1f2d,0x399,0x890,8,0x220,
-0x1f26,0x3b9,0x1f2e,0x399,0x890,8,0x220,0x1f27,0x3b9,0x1f2f,0x399,0xc90,8,0x220,0x1f20,0x3b9,
-0x1f28,0x399,0xc90,8,0x220,0x1f21,0x3b9,0x1f29,0x399,0xc90,8,0x220,0x1f22,0x3b9,0x1f2a,0x399,
-0xc90,8,0x220,0x1f23,0x3b9,0x1f2b,0x399,0xc90,8,0x220,0x1f24,0x3b9,0x1f2c,0x399,0xc90,8,
-0x220,0x1f25,0x3b9,0x1f2d,0x399,0xc90,8,0x220,0x1f26,0x3b9,0x1f2e,0x399,0xc90,8,0x220,0x1f27,
-0x3b9,0x1f2f,0x399,0x890,8,0x220,0x1f60,0x3b9,0x1f68,0x399,0x890,8,0x220,0x1f61,0x3b9,0x1f69,
-0x399,0x890,8,0x220,0x1f62,0x3b9,0x1f6a,0x399,0x890,8,0x220,0x1f63,0x3b9,0x1f6b,0x399,0x890,
-8,0x220,0x1f64,0x3b9,0x1f6c,0x399,0x890,8,0x220,0x1f65,0x3b9,0x1f6d,0x399,0x890,8,0x220,
-0x1f66,0x3b9,0x1f6e,0x399,0x890,8,0x220,0x1f67,0x3b9,0x1f6f,0x399,0xc90,8,0x220,0x1f60,0x3b9,
-0x1f68,0x399,0xc90,8,0x220,0x1f61,0x3b9,0x1f69,0x399,0xc90,8,0x220,0x1f62,0x3b9,0x1f6a,0x399,
-0xc90,8,0x220,0x1f63,0x3b9,0x1f6b,0x399,0xc90,8,0x220,0x1f64,0x3b9,0x1f6c,0x399,0xc90,8,
-0x220,0x1f65,0x3b9,0x1f6d,0x399,0xc90,8,0x220,0x1f66,0x3b9,0x1f6e,0x399,0xc90,8,0x220,0x1f67,
-0x3b9,0x1f6f,0x399,0x880,0x2220,0x1f70,0x3b9,0x1fba,0x399,0x1fba,0x345,0x890,9,0x220,0x3b1,0x3b9,
-0x391,0x399,0x880,0x2220,0x3ac,0x3b9,0x386,0x399,0x386,0x345,0x880,0x2220,0x3b1,0x342,0x391,0x342,
-0x391,0x342,0x880,0x3330,0x3b1,0x342,0x3b9,0x391,0x342,0x399,0x391,0x342,0x345,0xc90,9,0x220,
-0x3b1,0x3b9,0x391,0x399,0x846,0x3b9,0x399,1,0x345,0x880,0x2220,0x1f74,0x3b9,0x1fca,0x399,0x1fca,
-0x345,0x890,9,0x220,0x3b7,0x3b9,0x397,0x399,0x880,0x2220,0x3ae,0x3b9,0x389,0x399,0x389,0x345,
-0x880,0x2220,0x3b7,0x342,0x397,0x342,0x397,0x342,0x880,0x3330,0x3b7,0x342,0x3b9,0x397,0x342,0x399,
-0x397,0x342,0x345,0xc90,9,0x220,0x3b7,0x3b9,0x397,0x399,0x880,0x3330,0x3b9,0x308,0x300,0x399,
-0x308,0x300,0x399,0x308,0x300,0x8c0,1,0x3330,0x3b9,0x308,0x301,0x399,0x308,0x301,0x399,0x308,
-0x301,0x390,0x880,0x2220,0x3b9,0x342,0x399,0x342,0x399,0x342,0x880,0x3330,0x3b9,0x308,0x342,0x399,
-0x308,0x342,0x399,0x308,0x342,0x880,0x3330,0x3c5,0x308,0x300,0x3a5,0x308,0x300,0x3a5,0x308,0x300,
-0x8c0,1,0x3330,0x3c5,0x308,0x301,0x3a5,0x308,0x301,0x3a5,0x308,0x301,0x3b0,0x880,0x2220,0x3c1,
-0x313,0x3a1,0x313,0x3a1,0x313,0x880,0x2220,0x3c5,0x342,0x3a5,0x342,0x3a5,0x342,0x880,0x3330,0x3c5,
-0x308,0x342,0x3a5,0x308,0x342,0x3a5,0x308,0x342,0x880,0x2220,0x1f7c,0x3b9,0x1ffa,0x399,0x1ffa,0x345,
-0x890,9,0x220,0x3c9,0x3b9,0x3a9,0x399,0x880,0x2220,0x3ce,0x3b9,0x38f,0x399,0x38f,0x345,0x880,
-0x2220,0x3c9,0x342,0x3a9,0x342,0x3a9,0x342,0x880,0x3330,0x3c9,0x342,0x3b9,0x3a9,0x342,0x399,0x3a9,
-0x342,0x345,0xc90,9,0x220,0x3c9,0x3b9,0x3a9,0x399,0xc50,0x1d5d,1,0x3a9,0xc50,0x20bf,1,
-0x4b,0xc50,0x2046,1,0xc5,0xc10,0x29f7,0xc10,0xee6,0xc10,0x29e7,0xc10,0x2a2b,0xc10,0x2a28,0xc10,
-0x2a1c,0xc10,0x29fd,0xc10,0x2a1f,0xc10,0x2a1e,0xc10,0x2a3f,0xc10,0x1c60,0x841,0xa64b,1,0x1c88,0x844,
-0xa64a,1,0x1c88,0xc10,0x8a04,0xc10,0xa528,0xc10,0xa544,0xc10,0xa54f,0xc10,0xa54b,0xc10,0xa541,0xc10,
-0xa512,0xc10,0xa52a,0xc10,0xa515,0x810,0x3a0,0xc10,0xa543,0xc10,0x8a38,0xc10,0x3a0,0x806,0x13a0,0x13a0,
-0x806,0x13a1,0x13a1,0x806,0x13a2,0x13a2,0x806,0x13a3,0x13a3,0x806,0x13a4,0x13a4,0x806,0x13a5,0x13a5,0x806,
-0x13a6,0x13a6,0x806,0x13a7,0x13a7,0x806,0x13a8,0x13a8,0x806,0x13a9,0x13a9,0x806,0x13aa,0x13aa,0x806,0x13ab,
-0x13ab,0x806,0x13ac,0x13ac,0x806,0x13ad,0x13ad,0x806,0x13ae,0x13ae,0x806,0x13af,0x13af,0x806,0x13b0,0x13b0,
-0x806,0x13b1,0x13b1,0x806,0x13b2,0x13b2,0x806,0x13b3,0x13b3,0x806,0x13b4,0x13b4,0x806,0x13b5,0x13b5,0x806,
-0x13b6,0x13b6,0x806,0x13b7,0x13b7,0x806,0x13b8,0x13b8,0x806,0x13b9,0x13b9,0x806,0x13ba,0x13ba,0x806,0x13bb,
-0x13bb,0x806,0x13bc,0x13bc,0x806,0x13bd,0x13bd,0x806,0x13be,0x13be,0x806,0x13bf,0x13bf,0x806,0x13c0,0x13c0,
-0x806,0x13c1,0x13c1,0x806,0x13c2,0x13c2,0x806,0x13c3,0x13c3,0x806,0x13c4,0x13c4,0x806,0x13c5,0x13c5,0x806,
-0x13c6,0x13c6,0x806,0x13c7,0x13c7,0x806,0x13c8,0x13c8,0x806,0x13c9,0x13c9,0x806,0x13ca,0x13ca,0x806,0x13cb,
-0x13cb,0x806,0x13cc,0x13cc,0x806,0x13cd,0x13cd,0x806,0x13ce,0x13ce,0x806,0x13cf,0x13cf,0x806,0x13d0,0x13d0,
-0x806,0x13d1,0x13d1,0x806,0x13d2,0x13d2,0x806,0x13d3,0x13d3,0x806,0x13d4,0x13d4,0x806,0x13d5,0x13d5,0x806,
-0x13d6,0x13d6,0x806,0x13d7,0x13d7,0x806,0x13d8,0x13d8,0x806,0x13d9,0x13d9,0x806,0x13da,0x13da,0x806,0x13db,
-0x13db,0x806,0x13dc,0x13dc,0x806,0x13dd,0x13dd,0x806,0x13de,0x13de,0x806,0x13df,0x13df,0x806,0x13e0,0x13e0,
-0x806,0x13e1,0x13e1,0x806,0x13e2,0x13e2,0x806,0x13e3,0x13e3,0x806,0x13e4,0x13e4,0x806,0x13e5,0x13e5,0x806,
-0x13e6,0x13e6,0x806,0x13e7,0x13e7,0x806,0x13e8,0x13e8,0x806,0x13e9,0x13e9,0x806,0x13ea,0x13ea,0x806,0x13eb,
-0x13eb,0x806,0x13ec,0x13ec,0x806,0x13ed,0x13ed,0x806,0x13ee,0x13ee,0x806,0x13ef,0x13ef,0x880,0x2220,0x66,
-0x66,0x46,0x46,0x46,0x66,0x880,0x2220,0x66,0x69,0x46,0x49,0x46,0x69,0x880,0x2220,0x66,
-0x6c,0x46,0x4c,0x46,0x6c,0x880,0x3330,0x66,0x66,0x69,0x46,0x46,0x49,0x46,0x66,0x69,
-0x880,0x3330,0x66,0x66,0x6c,0x46,0x46,0x4c,0x46,0x66,0x6c,0x8c0,1,0x2220,0x73,0x74,
-0x53,0x54,0x53,0x74,0xfb06,0x8c0,1,0x2220,0x73,0x74,0x53,0x54,0x53,0x74,0xfb05,0x880,
-0x2220,0x574,0x576,0x544,0x546,0x544,0x576,0x880,0x2220,0x574,0x565,0x544,0x535,0x544,0x565,0x880,
-0x2220,0x574,0x56b,0x544,0x53b,0x544,0x56b,0x880,0x2220,0x57e,0x576,0x54e,0x546,0x54e,0x576,0x880,
-0x2220,0x574,0x56d,0x544,0x53d,0x544,0x56d
+0x1c87,0x4880,0x20,0x565,0x582,0x810,0x1c60,0x80c,0x1c90,0x10d0,0x80c,0x1c91,0x10d1,0x80c,0x1c92,0x10d2,
+0x80c,0x1c93,0x10d3,0x80c,0x1c94,0x10d4,0x80c,0x1c95,0x10d5,0x80c,0x1c96,0x10d6,0x80c,0x1c97,0x10d7,0x80c,
+0x1c98,0x10d8,0x80c,0x1c99,0x10d9,0x80c,0x1c9a,0x10da,0x80c,0x1c9b,0x10db,0x80c,0x1c9c,0x10dc,0x80c,0x1c9d,
+0x10dd,0x80c,0x1c9e,0x10de,0x80c,0x1c9f,0x10df,0x80c,0x1ca0,0x10e0,0x80c,0x1ca1,0x10e1,0x80c,0x1ca2,0x10e2,
+0x80c,0x1ca3,0x10e3,0x80c,0x1ca4,0x10e4,0x80c,0x1ca5,0x10e5,0x80c,0x1ca6,0x10e6,0x80c,0x1ca7,0x10e7,0x80c,
+0x1ca8,0x10e8,0x80c,0x1ca9,0x10e9,0x80c,0x1caa,0x10ea,0x80c,0x1cab,0x10eb,0x80c,0x1cac,0x10ec,0x80c,0x1cad,
+0x10ed,0x80c,0x1cae,0x10ee,0x80c,0x1caf,0x10ef,0x80c,0x1cb0,0x10f0,0x80c,0x1cb1,0x10f1,0x80c,0x1cb2,0x10f2,
+0x80c,0x1cb3,0x10f3,0x80c,0x1cb4,0x10f4,0x80c,0x1cb5,0x10f5,0x80c,0x1cb6,0x10f6,0x80c,0x1cb7,0x10f7,0x80c,
+0x1cb8,0x10f8,0x80c,0x1cb9,0x10f9,0x80c,0x1cba,0x10fa,0x80c,0x1cbd,0x10fd,0x80c,0x1cbe,0x10fe,0x80c,0x1cbf,
+0x10ff,0xa10,0x97d0,0xa10,8,0x806,0x13f0,0x13f0,0x806,0x13f1,0x13f1,0x806,0x13f2,0x13f2,0x806,0x13f3,
+0x13f3,0x806,0x13f4,0x13f4,0x806,0x13f5,0x13f5,0x806,0x432,0x412,0x806,0x434,0x414,0x806,0x43e,0x41e,
+0x806,0x441,0x421,0x846,0x442,0x422,1,0x1c85,0x846,0x442,0x422,1,0x1c84,0x806,0x44a,0x42a,
+0x806,0x463,0x462,0x806,0xa64b,0xa64a,0xc10,0xbc0,0x810,0x8a04,0x810,0xee6,0x810,0x8a38,0x841,0x1e61,
+1,0x1e9b,0x844,0x1e60,1,0x1e9b,0x880,0x2220,0x68,0x331,0x48,0x331,0x48,0x331,0x880,0x2220,
+0x74,0x308,0x54,0x308,0x54,0x308,0x880,0x2220,0x77,0x30a,0x57,0x30a,0x57,0x30a,0x880,0x2220,
+0x79,0x30a,0x59,0x30a,0x59,0x30a,0x880,0x2220,0x61,0x2be,0x41,0x2be,0x41,0x2be,0x806,0x1e61,
+0x1e60,0xc90,0x1dbf,0x20,0x73,0x73,0x880,0x2220,0x3c5,0x313,0x3a5,0x313,0x3a5,0x313,0x880,0x3330,
+0x3c5,0x313,0x300,0x3a5,0x313,0x300,0x3a5,0x313,0x300,0x880,0x3330,0x3c5,0x313,0x301,0x3a5,0x313,
+0x301,0x3a5,0x313,0x301,0x880,0x3330,0x3c5,0x313,0x342,0x3a5,0x313,0x342,0x3a5,0x313,0x342,0x890,
+8,0x220,0x1f00,0x3b9,0x1f08,0x399,0x890,8,0x220,0x1f01,0x3b9,0x1f09,0x399,0x890,8,0x220,
+0x1f02,0x3b9,0x1f0a,0x399,0x890,8,0x220,0x1f03,0x3b9,0x1f0b,0x399,0x890,8,0x220,0x1f04,0x3b9,
+0x1f0c,0x399,0x890,8,0x220,0x1f05,0x3b9,0x1f0d,0x399,0x890,8,0x220,0x1f06,0x3b9,0x1f0e,0x399,
+0x890,8,0x220,0x1f07,0x3b9,0x1f0f,0x399,0xc90,8,0x220,0x1f00,0x3b9,0x1f08,0x399,0xc90,8,
+0x220,0x1f01,0x3b9,0x1f09,0x399,0xc90,8,0x220,0x1f02,0x3b9,0x1f0a,0x399,0xc90,8,0x220,0x1f03,
+0x3b9,0x1f0b,0x399,0xc90,8,0x220,0x1f04,0x3b9,0x1f0c,0x399,0xc90,8,0x220,0x1f05,0x3b9,0x1f0d,
+0x399,0xc90,8,0x220,0x1f06,0x3b9,0x1f0e,0x399,0xc90,8,0x220,0x1f07,0x3b9,0x1f0f,0x399,0x890,
+8,0x220,0x1f20,0x3b9,0x1f28,0x399,0x890,8,0x220,0x1f21,0x3b9,0x1f29,0x399,0x890,8,0x220,
+0x1f22,0x3b9,0x1f2a,0x399,0x890,8,0x220,0x1f23,0x3b9,0x1f2b,0x399,0x890,8,0x220,0x1f24,0x3b9,
+0x1f2c,0x399,0x890,8,0x220,0x1f25,0x3b9,0x1f2d,0x399,0x890,8,0x220,0x1f26,0x3b9,0x1f2e,0x399,
+0x890,8,0x220,0x1f27,0x3b9,0x1f2f,0x399,0xc90,8,0x220,0x1f20,0x3b9,0x1f28,0x399,0xc90,8,
+0x220,0x1f21,0x3b9,0x1f29,0x399,0xc90,8,0x220,0x1f22,0x3b9,0x1f2a,0x399,0xc90,8,0x220,0x1f23,
+0x3b9,0x1f2b,0x399,0xc90,8,0x220,0x1f24,0x3b9,0x1f2c,0x399,0xc90,8,0x220,0x1f25,0x3b9,0x1f2d,
+0x399,0xc90,8,0x220,0x1f26,0x3b9,0x1f2e,0x399,0xc90,8,0x220,0x1f27,0x3b9,0x1f2f,0x399,0x890,
+8,0x220,0x1f60,0x3b9,0x1f68,0x399,0x890,8,0x220,0x1f61,0x3b9,0x1f69,0x399,0x890,8,0x220,
+0x1f62,0x3b9,0x1f6a,0x399,0x890,8,0x220,0x1f63,0x3b9,0x1f6b,0x399,0x890,8,0x220,0x1f64,0x3b9,
+0x1f6c,0x399,0x890,8,0x220,0x1f65,0x3b9,0x1f6d,0x399,0x890,8,0x220,0x1f66,0x3b9,0x1f6e,0x399,
+0x890,8,0x220,0x1f67,0x3b9,0x1f6f,0x399,0xc90,8,0x220,0x1f60,0x3b9,0x1f68,0x399,0xc90,8,
+0x220,0x1f61,0x3b9,0x1f69,0x399,0xc90,8,0x220,0x1f62,0x3b9,0x1f6a,0x399,0xc90,8,0x220,0x1f63,
+0x3b9,0x1f6b,0x399,0xc90,8,0x220,0x1f64,0x3b9,0x1f6c,0x399,0xc90,8,0x220,0x1f65,0x3b9,0x1f6d,
+0x399,0xc90,8,0x220,0x1f66,0x3b9,0x1f6e,0x399,0xc90,8,0x220,0x1f67,0x3b9,0x1f6f,0x399,0x880,
+0x2220,0x1f70,0x3b9,0x1fba,0x399,0x1fba,0x345,0x890,9,0x220,0x3b1,0x3b9,0x391,0x399,0x880,0x2220,
+0x3ac,0x3b9,0x386,0x399,0x386,0x345,0x880,0x2220,0x3b1,0x342,0x391,0x342,0x391,0x342,0x880,0x3330,
+0x3b1,0x342,0x3b9,0x391,0x342,0x399,0x391,0x342,0x345,0xc90,9,0x220,0x3b1,0x3b9,0x391,0x399,
+0x846,0x3b9,0x399,1,0x345,0x880,0x2220,0x1f74,0x3b9,0x1fca,0x399,0x1fca,0x345,0x890,9,0x220,
+0x3b7,0x3b9,0x397,0x399,0x880,0x2220,0x3ae,0x3b9,0x389,0x399,0x389,0x345,0x880,0x2220,0x3b7,0x342,
+0x397,0x342,0x397,0x342,0x880,0x3330,0x3b7,0x342,0x3b9,0x397,0x342,0x399,0x397,0x342,0x345,0xc90,
+9,0x220,0x3b7,0x3b9,0x397,0x399,0x880,0x3330,0x3b9,0x308,0x300,0x399,0x308,0x300,0x399,0x308,
+0x300,0x8c0,1,0x3330,0x3b9,0x308,0x301,0x399,0x308,0x301,0x399,0x308,0x301,0x390,0x880,0x2220,
+0x3b9,0x342,0x399,0x342,0x399,0x342,0x880,0x3330,0x3b9,0x308,0x342,0x399,0x308,0x342,0x399,0x308,
+0x342,0x880,0x3330,0x3c5,0x308,0x300,0x3a5,0x308,0x300,0x3a5,0x308,0x300,0x8c0,1,0x3330,0x3c5,
+0x308,0x301,0x3a5,0x308,0x301,0x3a5,0x308,0x301,0x3b0,0x880,0x2220,0x3c1,0x313,0x3a1,0x313,0x3a1,
+0x313,0x880,0x2220,0x3c5,0x342,0x3a5,0x342,0x3a5,0x342,0x880,0x3330,0x3c5,0x308,0x342,0x3a5,0x308,
+0x342,0x3a5,0x308,0x342,0x880,0x2220,0x1f7c,0x3b9,0x1ffa,0x399,0x1ffa,0x345,0x890,9,0x220,0x3c9,
+0x3b9,0x3a9,0x399,0x880,0x2220,0x3ce,0x3b9,0x38f,0x399,0x38f,0x345,0x880,0x2220,0x3c9,0x342,0x3a9,
+0x342,0x3a9,0x342,0x880,0x3330,0x3c9,0x342,0x3b9,0x3a9,0x342,0x399,0x3a9,0x342,0x345,0xc90,9,
+0x220,0x3c9,0x3b9,0x3a9,0x399,0xc50,0x1d5d,1,0x3a9,0xc50,0x20bf,1,0x4b,0xc50,0x2046,1,
+0xc5,0xc10,0x29f7,0xc10,0xee6,0xc10,0x29e7,0xc10,0x2a2b,0xc10,0x2a28,0xc10,0x2a1c,0xc10,0x29fd,0xc10,
+0x2a1f,0xc10,0x2a1e,0xc10,0x2a3f,0xc10,0x1c60,0x841,0xa64b,1,0x1c88,0x844,0xa64a,1,0x1c88,0xc10,
+0x8a04,0xc10,0xa528,0xc10,0xa544,0xc10,0xa54f,0xc10,0xa54b,0xc10,0xa541,0xc10,0xa512,0xc10,0xa52a,0xc10,
+0xa515,0x810,0x3a0,0xc10,0xa543,0xc10,0x8a38,0xc10,0x3a0,0x806,0x13a0,0x13a0,0x806,0x13a1,0x13a1,0x806,
+0x13a2,0x13a2,0x806,0x13a3,0x13a3,0x806,0x13a4,0x13a4,0x806,0x13a5,0x13a5,0x806,0x13a6,0x13a6,0x806,0x13a7,
+0x13a7,0x806,0x13a8,0x13a8,0x806,0x13a9,0x13a9,0x806,0x13aa,0x13aa,0x806,0x13ab,0x13ab,0x806,0x13ac,0x13ac,
+0x806,0x13ad,0x13ad,0x806,0x13ae,0x13ae,0x806,0x13af,0x13af,0x806,0x13b0,0x13b0,0x806,0x13b1,0x13b1,0x806,
+0x13b2,0x13b2,0x806,0x13b3,0x13b3,0x806,0x13b4,0x13b4,0x806,0x13b5,0x13b5,0x806,0x13b6,0x13b6,0x806,0x13b7,
+0x13b7,0x806,0x13b8,0x13b8,0x806,0x13b9,0x13b9,0x806,0x13ba,0x13ba,0x806,0x13bb,0x13bb,0x806,0x13bc,0x13bc,
+0x806,0x13bd,0x13bd,0x806,0x13be,0x13be,0x806,0x13bf,0x13bf,0x806,0x13c0,0x13c0,0x806,0x13c1,0x13c1,0x806,
+0x13c2,0x13c2,0x806,0x13c3,0x13c3,0x806,0x13c4,0x13c4,0x806,0x13c5,0x13c5,0x806,0x13c6,0x13c6,0x806,0x13c7,
+0x13c7,0x806,0x13c8,0x13c8,0x806,0x13c9,0x13c9,0x806,0x13ca,0x13ca,0x806,0x13cb,0x13cb,0x806,0x13cc,0x13cc,
+0x806,0x13cd,0x13cd,0x806,0x13ce,0x13ce,0x806,0x13cf,0x13cf,0x806,0x13d0,0x13d0,0x806,0x13d1,0x13d1,0x806,
+0x13d2,0x13d2,0x806,0x13d3,0x13d3,0x806,0x13d4,0x13d4,0x806,0x13d5,0x13d5,0x806,0x13d6,0x13d6,0x806,0x13d7,
+0x13d7,0x806,0x13d8,0x13d8,0x806,0x13d9,0x13d9,0x806,0x13da,0x13da,0x806,0x13db,0x13db,0x806,0x13dc,0x13dc,
+0x806,0x13dd,0x13dd,0x806,0x13de,0x13de,0x806,0x13df,0x13df,0x806,0x13e0,0x13e0,0x806,0x13e1,0x13e1,0x806,
+0x13e2,0x13e2,0x806,0x13e3,0x13e3,0x806,0x13e4,0x13e4,0x806,0x13e5,0x13e5,0x806,0x13e6,0x13e6,0x806,0x13e7,
+0x13e7,0x806,0x13e8,0x13e8,0x806,0x13e9,0x13e9,0x806,0x13ea,0x13ea,0x806,0x13eb,0x13eb,0x806,0x13ec,0x13ec,
+0x806,0x13ed,0x13ed,0x806,0x13ee,0x13ee,0x806,0x13ef,0x13ef,0x880,0x2220,0x66,0x66,0x46,0x46,0x46,
+0x66,0x880,0x2220,0x66,0x69,0x46,0x49,0x46,0x69,0x880,0x2220,0x66,0x6c,0x46,0x4c,0x46,
+0x6c,0x880,0x3330,0x66,0x66,0x69,0x46,0x46,0x49,0x46,0x66,0x69,0x880,0x3330,0x66,0x66,
+0x6c,0x46,0x46,0x4c,0x46,0x66,0x6c,0x8c0,1,0x2220,0x73,0x74,0x53,0x54,0x53,0x74,
+0xfb06,0x8c0,1,0x2220,0x73,0x74,0x53,0x54,0x53,0x74,0xfb05,0x880,0x2220,0x574,0x576,0x544,
+0x546,0x544,0x576,0x880,0x2220,0x574,0x565,0x544,0x535,0x544,0x565,0x880,0x2220,0x574,0x56b,0x544,
+0x53b,0x544,0x56b,0x880,0x2220,0x57e,0x576,0x54e,0x546,0x54e,0x576,0x880,0x2220,0x574,0x56d,0x544,
+0x53d,0x544,0x56d
};
static const uint16_t ucase_props_unfold[370]={
diff --git a/deps/icu-small/source/common/ucasemap_imp.h b/deps/icu-small/source/common/ucasemap_imp.h
index 7788fd9371..e17a0ae5a3 100644
--- a/deps/icu-small/source/common/ucasemap_imp.h
+++ b/deps/icu-small/source/common/ucasemap_imp.h
@@ -68,15 +68,15 @@ class BreakIterator; // unicode/brkiter.h
class ByteSink;
class Locale; // unicode/locid.h
-/** Returns TRUE if the options are valid. Otherwise FALSE, and sets an error. */
+/** Returns true if the options are valid. Otherwise false, and sets an error. */
inline UBool ustrcase_checkTitleAdjustmentOptions(uint32_t options, UErrorCode &errorCode) {
- if (U_FAILURE(errorCode)) { return FALSE; }
+ if (U_FAILURE(errorCode)) { return false; }
if ((options & U_TITLECASE_ADJUSTMENT_MASK) == U_TITLECASE_ADJUSTMENT_MASK) {
// Both options together.
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
inline UBool ustrcase_isLNS(UChar32 c) {
diff --git a/deps/icu-small/source/common/ucln_cmn.h b/deps/icu-small/source/common/ucln_cmn.h
index b837fb9462..44b73e94da 100644
--- a/deps/icu-small/source/common/ucln_cmn.h
+++ b/deps/icu-small/source/common/ucln_cmn.h
@@ -38,6 +38,8 @@ typedef enum ECleanupCommonType {
UCLN_COMMON_SERVICE,
UCLN_COMMON_LOCALE_KEY_TYPE,
UCLN_COMMON_LOCALE,
+ UCLN_COMMON_LOCALE_ALIAS,
+ UCLN_COMMON_LOCALE_KNOWN_CANONICALIZED,
UCLN_COMMON_LOCALE_AVAILABLE,
UCLN_COMMON_LIKELY_SUBTAGS,
UCLN_COMMON_LOCALE_DISTANCE,
diff --git a/deps/icu-small/source/common/ucln_imp.h b/deps/icu-small/source/common/ucln_imp.h
index 2e98566979..b08c6e8368 100644
--- a/deps/icu-small/source/common/ucln_imp.h
+++ b/deps/icu-small/source/common/ucln_imp.h
@@ -78,7 +78,7 @@
* Use the ANSI C 'atexit' function. Note that this mechanism does not
* guarantee the order of cleanup relative to other users of ICU!
*/
-static UBool gAutoCleanRegistered = FALSE;
+static UBool gAutoCleanRegistered = false;
static void ucln_atexit_handler()
{
@@ -88,7 +88,7 @@ static void ucln_atexit_handler()
static void ucln_registerAutomaticCleanup()
{
if(!gAutoCleanRegistered) {
- gAutoCleanRegistered = TRUE;
+ gAutoCleanRegistered = true;
atexit(&ucln_atexit_handler);
}
}
@@ -135,7 +135,7 @@ U_CAPI void U_EXPORT2 UCLN_FINI ()
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
- BOOL status = TRUE;
+ BOOL status = true;
switch(fdwReason) {
case DLL_PROCESS_ATTACH:
diff --git a/deps/icu-small/source/common/ucnv_bld.cpp b/deps/icu-small/source/common/ucnv_bld.cpp
index 1c2363ea89..0e198892f1 100644
--- a/deps/icu-small/source/common/ucnv_bld.cpp
+++ b/deps/icu-small/source/common/ucnv_bld.cpp
@@ -262,7 +262,7 @@ static UBool U_CALLCONV ucnv_cleanup(void) {
}
U_CAPI void U_EXPORT2
-ucnv_enableCleanup() {
+ucnv_enableCleanup(void) {
ucln_common_registerCleanup(UCLN_COMMON_UCNV, ucnv_cleanup);
}
diff --git a/deps/icu-small/source/common/ucnv_bld.h b/deps/icu-small/source/common/ucnv_bld.h
index caa263f56d..43e6c09ac0 100644
--- a/deps/icu-small/source/common/ucnv_bld.h
+++ b/deps/icu-small/source/common/ucnv_bld.h
@@ -101,8 +101,8 @@ struct UConverterSharedData {
const UConverterStaticData *staticData; /* pointer to the static (non changing) data. */
- UBool sharedDataCached; /* TRUE: shared data is in cache, don't destroy on ucnv_close() if 0 ref. FALSE: shared data isn't in the cache, do attempt to clean it up if the ref is 0 */
- /** If FALSE, then referenceCounter is not used. Must not change after initialization. */
+ UBool sharedDataCached; /* true: shared data is in cache, don't destroy on ucnv_close() if 0 ref. false: shared data isn't in the cache, do attempt to clean it up if the ref is 0 */
+ /** If false, then referenceCounter is not used. Must not change after initialization. */
UBool isReferenceCounted;
const UConverterImpl *impl; /* vtable-style struct of mostly function pointers */
@@ -128,7 +128,7 @@ struct UConverterSharedData {
#define UCNV_IMMUTABLE_SHARED_DATA_INITIALIZER(pStaticData, pImpl) \
{ \
sizeof(UConverterSharedData), ~((uint32_t)0), \
- NULL, pStaticData, FALSE, FALSE, pImpl, \
+ NULL, pStaticData, false, false, pImpl, \
0, UCNV_MBCS_TABLE_INITIALIZER \
}
@@ -181,9 +181,9 @@ struct UConverter {
uint32_t options; /* options flags from UConverterOpen, may contain additional bits */
- UBool sharedDataIsCached; /* TRUE: shared data is in cache, don't destroy on ucnv_close() if 0 ref. FALSE: shared data isn't in the cache, do attempt to clean it up if the ref is 0 */
- UBool isCopyLocal; /* TRUE if UConverter is not owned and not released in ucnv_close() (stack-allocated, safeClone(), etc.) */
- UBool isExtraLocal; /* TRUE if extraInfo is not owned and not released in ucnv_close() (stack-allocated, safeClone(), etc.) */
+ UBool sharedDataIsCached; /* true: shared data is in cache, don't destroy on ucnv_close() if 0 ref. false: shared data isn't in the cache, do attempt to clean it up if the ref is 0 */
+ UBool isCopyLocal; /* true if UConverter is not owned and not released in ucnv_close() (stack-allocated, safeClone(), etc.) */
+ UBool isExtraLocal; /* true if extraInfo is not owned and not released in ucnv_close() (stack-allocated, safeClone(), etc.) */
UBool useFallback;
int8_t toULength; /* number of bytes in toUBytes */
@@ -289,7 +289,7 @@ ucnv_swap(const UDataSwapper *ds,
UErrorCode *pErrorCode);
U_CAPI void U_EXPORT2
-ucnv_enableCleanup();
+ucnv_enableCleanup(void);
#endif
diff --git a/deps/icu-small/source/common/ucnv_cnv.h b/deps/icu-small/source/common/ucnv_cnv.h
index a996e29597..345a1998e4 100644
--- a/deps/icu-small/source/common/ucnv_cnv.h
+++ b/deps/icu-small/source/common/ucnv_cnv.h
@@ -59,7 +59,7 @@ typedef struct {
} UConverterLoadArgs;
#define UCNV_LOAD_ARGS_INITIALIZER \
- { (int32_t)sizeof(UConverterLoadArgs), 0, FALSE, FALSE, 0, 0, NULL, NULL, NULL }
+ { (int32_t)sizeof(UConverterLoadArgs), 0, false, false, 0, 0, NULL, NULL, NULL }
typedef void (*UConverterLoad) (UConverterSharedData *sharedData,
UConverterLoadArgs *pArgs,
@@ -267,8 +267,8 @@ extern const UConverterSharedData
U_CDECL_END
/** Always use fallbacks from codepage to Unicode */
-#define TO_U_USE_FALLBACK(useFallback) TRUE
-#define UCNV_TO_U_USE_FALLBACK(cnv) TRUE
+#define TO_U_USE_FALLBACK(useFallback) true
+#define UCNV_TO_U_USE_FALLBACK(cnv) true
/** Use fallbacks from Unicode to codepage when cnv->useFallback or for private-use code points */
#define IS_PRIVATE_USE(c) ((uint32_t)((c)-0xe000)<0x1900 || (uint32_t)((c)-0xf0000)<0x20000)
diff --git a/deps/icu-small/source/common/ucnv_u8.cpp b/deps/icu-small/source/common/ucnv_u8.cpp
index 878d67304c..9cf4a81ab2 100644
--- a/deps/icu-small/source/common/ucnv_u8.cpp
+++ b/deps/icu-small/source/common/ucnv_u8.cpp
@@ -707,9 +707,9 @@ ucnv_UTF8FromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
// Do not go back into the bytes that will be read for finishing a partial
// sequence from the previous buffer.
- int32_t length=count-toULimit;
+ int32_t length=count-toULength;
U8_TRUNCATE_IF_INCOMPLETE(source, 0, length);
- count=toULimit+length;
+ count=toULength+length;
}
if(c!=0) {
diff --git a/deps/icu-small/source/common/ucnvmbcs.h b/deps/icu-small/source/common/ucnvmbcs.h
index a750b92e49..ddc55b20fe 100644
--- a/deps/icu-small/source/common/ucnvmbcs.h
+++ b/deps/icu-small/source/common/ucnvmbcs.h
@@ -420,7 +420,7 @@ typedef struct UConverterMBCSTable {
NULL, \
0, \
0, 0, \
- FALSE, \
+ false, \
0, \
\
/* roundtrips */ \
diff --git a/deps/icu-small/source/common/ucol_swp.h b/deps/icu-small/source/common/ucol_swp.h
index fd8be9aa54..0c2990a85e 100644
--- a/deps/icu-small/source/common/ucol_swp.h
+++ b/deps/icu-small/source/common/ucol_swp.h
@@ -31,7 +31,7 @@
* Does the data look like a collation binary?
* @internal
*/
-U_INTERNAL UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucol_looksLikeCollationBinary(const UDataSwapper *ds,
const void *inData, int32_t length);
diff --git a/deps/icu-small/source/common/ucurr.cpp b/deps/icu-small/source/common/ucurr.cpp
index 391b08083b..8d213dfcfc 100644
--- a/deps/icu-small/source/common/ucurr.cpp
+++ b/deps/icu-small/source/common/ucurr.cpp
@@ -91,6 +91,8 @@ static const char VAR_DELIM = '_';
// Tag for localized display names (symbols) of currencies
static const char CURRENCIES[] = "Currencies";
static const char CURRENCIES_NARROW[] = "Currencies%narrow";
+static const char CURRENCIES_FORMAL[] = "Currencies%formal";
+static const char CURRENCIES_VARIANT[] = "Currencies%variant";
static const char CURRENCYPLURALS[] = "CurrencyPlurals";
// ISO codes mapping table
@@ -649,7 +651,7 @@ ucurr_getName(const UChar* currency,
}
int32_t choice = (int32_t) nameStyle;
- if (choice < 0 || choice > 2) {
+ if (choice < 0 || choice > 4) {
*ec = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -684,9 +686,22 @@ ucurr_getName(const UChar* currency,
ec2 = U_ZERO_ERROR;
LocalUResourceBundlePointer rb(ures_open(U_ICUDATA_CURR, loc, &ec2));
- if (nameStyle == UCURR_NARROW_SYMBOL_NAME) {
+ if (nameStyle == UCURR_NARROW_SYMBOL_NAME || nameStyle == UCURR_FORMAL_SYMBOL_NAME || nameStyle == UCURR_VARIANT_SYMBOL_NAME) {
CharString key;
- key.append(CURRENCIES_NARROW, ec2);
+ switch (nameStyle) {
+ case UCURR_NARROW_SYMBOL_NAME:
+ key.append(CURRENCIES_NARROW, ec2);
+ break;
+ case UCURR_FORMAL_SYMBOL_NAME:
+ key.append(CURRENCIES_FORMAL, ec2);
+ break;
+ case UCURR_VARIANT_SYMBOL_NAME:
+ key.append(CURRENCIES_VARIANT, ec2);
+ break;
+ default:
+ *ec = U_UNSUPPORTED_ERROR;
+ return 0;
+ }
key.append("/", ec2);
key.append(buf, ec2);
s = ures_getStringByKeyWithFallback(rb.getAlias(), key.data(), len, &ec2);
@@ -1610,7 +1625,7 @@ ucurr_getDefaultFractionDigits(const UChar* currency, UErrorCode* ec) {
return ucurr_getDefaultFractionDigitsForUsage(currency,UCURR_USAGE_STANDARD,ec);
}
-U_DRAFT int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucurr_getDefaultFractionDigitsForUsage(const UChar* currency, const UCurrencyUsage usage, UErrorCode* ec) {
int32_t fracDigits = 0;
if (U_SUCCESS(*ec)) {
@@ -1633,7 +1648,7 @@ ucurr_getRoundingIncrement(const UChar* currency, UErrorCode* ec) {
return ucurr_getRoundingIncrementForUsage(currency, UCURR_USAGE_STANDARD, ec);
}
-U_DRAFT double U_EXPORT2
+U_CAPI double U_EXPORT2
ucurr_getRoundingIncrementForUsage(const UChar* currency, const UCurrencyUsage usage, UErrorCode* ec) {
double result = 0.0;
@@ -2259,7 +2274,6 @@ ucurr_countCurrencies(const char* locale,
// local variables
UErrorCode localStatus = U_ZERO_ERROR;
char id[ULOC_FULLNAME_CAPACITY];
- uloc_getKeywordValue(locale, "currency", id, ULOC_FULLNAME_CAPACITY, &localStatus);
// get country or country_variant in `id'
idForLocale(locale, id, sizeof(id), ec);
@@ -2375,7 +2389,6 @@ ucurr_forLocaleAndDate(const char* locale,
// local variables
UErrorCode localStatus = U_ZERO_ERROR;
char id[ULOC_FULLNAME_CAPACITY];
- resLen = uloc_getKeywordValue(locale, "currency", id, ULOC_FULLNAME_CAPACITY, &localStatus);
// get country or country_variant in `id'
idForLocale(locale, id, sizeof(id), ec);
diff --git a/deps/icu-small/source/common/uelement.h b/deps/icu-small/source/common/uelement.h
index 9d45f09fb8..e4d16afe4e 100644
--- a/deps/icu-small/source/common/uelement.h
+++ b/deps/icu-small/source/common/uelement.h
@@ -46,7 +46,7 @@ typedef union UElement UElement;
* An element-equality (boolean) comparison function.
* @param e1 An element (object or integer)
* @param e2 An element (object or integer)
- * @return TRUE if the two elements are equal.
+ * @return true if the two elements are equal.
*/
typedef UBool U_CALLCONV UElementsAreEqual(const UElement e1, const UElement e2);
diff --git a/deps/icu-small/source/common/uinvchar.cpp b/deps/icu-small/source/common/uinvchar.cpp
index ac9716066f..7fce257baf 100644
--- a/deps/icu-small/source/common/uinvchar.cpp
+++ b/deps/icu-small/source/common/uinvchar.cpp
@@ -579,7 +579,7 @@ uprv_ebcdicToLowercaseAscii(char c) {
return (char)lowercaseAsciiFromEbcdic[(uint8_t)c];
}
-U_INTERNAL uint8_t* U_EXPORT2
+U_CAPI uint8_t* U_EXPORT2
uprv_aestrncpy(uint8_t *dst, const uint8_t *src, int32_t n)
{
uint8_t *orig_dst = dst;
@@ -600,7 +600,7 @@ uprv_aestrncpy(uint8_t *dst, const uint8_t *src, int32_t n)
return orig_dst;
}
-U_INTERNAL uint8_t* U_EXPORT2
+U_CAPI uint8_t* U_EXPORT2
uprv_eastrncpy(uint8_t *dst, const uint8_t *src, int32_t n)
{
uint8_t *orig_dst = dst;
diff --git a/deps/icu-small/source/common/uinvchar.h b/deps/icu-small/source/common/uinvchar.h
index a43cfcd982..9b7a9bd114 100644
--- a/deps/icu-small/source/common/uinvchar.h
+++ b/deps/icu-small/source/common/uinvchar.h
@@ -33,11 +33,11 @@
*
* @param s Input string pointer.
* @param length Length of the string, can be -1 if NUL-terminated.
- * @return TRUE if s contains only invariant characters.
+ * @return true if s contains only invariant characters.
*
* @internal (ICU 2.8)
*/
-U_INTERNAL UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uprv_isInvariantString(const char *s, int32_t length);
/**
@@ -46,11 +46,11 @@ uprv_isInvariantString(const char *s, int32_t length);
*
* @param s Input string pointer.
* @param length Length of the string, can be -1 if NUL-terminated.
- * @return TRUE if s contains only invariant characters.
+ * @return true if s contains only invariant characters.
*
* @internal (ICU 2.8)
*/
-U_INTERNAL UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uprv_isInvariantUString(const UChar *s, int32_t length);
/**
@@ -141,7 +141,7 @@ uprv_isEbcdicAtSign(char c);
* Compare two EBCDIC invariant-character strings in ASCII order.
* @internal
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uprv_compareInvEbcdicAsAscii(const char *s1, const char *s2);
/**
@@ -161,7 +161,7 @@ uprv_compareInvEbcdicAsAscii(const char *s1, const char *s2);
* Converts an EBCDIC invariant character to ASCII.
* @internal
*/
-U_INTERNAL char U_EXPORT2
+U_CAPI char U_EXPORT2
uprv_ebcdicToAscii(char c);
/**
@@ -181,7 +181,7 @@ uprv_ebcdicToAscii(char c);
* Converts an EBCDIC invariant character to lowercase ASCII.
* @internal
*/
-U_INTERNAL char U_EXPORT2
+U_CAPI char U_EXPORT2
uprv_ebcdicToLowercaseAscii(char c);
/**
@@ -202,7 +202,7 @@ uprv_ebcdicToLowercaseAscii(char c);
* @internal
* @see uprv_strncpy
*/
-U_INTERNAL uint8_t* U_EXPORT2
+U_CAPI uint8_t* U_EXPORT2
uprv_aestrncpy(uint8_t *dst, const uint8_t *src, int32_t n);
@@ -211,7 +211,7 @@ uprv_aestrncpy(uint8_t *dst, const uint8_t *src, int32_t n);
* @internal
* @see uprv_strncpy
*/
-U_INTERNAL uint8_t* U_EXPORT2
+U_CAPI uint8_t* U_EXPORT2
uprv_eastrncpy(uint8_t *dst, const uint8_t *src, int32_t n);
diff --git a/deps/icu-small/source/common/uloc.cpp b/deps/icu-small/source/common/uloc.cpp
index 0e235d7958..522f33dbe2 100644
--- a/deps/icu-small/source/common/uloc.cpp
+++ b/deps/icu-small/source/common/uloc.cpp
@@ -50,9 +50,6 @@
#include "uassert.h"
#include "charstr.h"
-#include <algorithm>
-#include <stdio.h> /* for sprintf */
-
U_NAMESPACE_USE
/* ### Declarations **************************************************/
@@ -60,12 +57,6 @@ U_NAMESPACE_USE
/* Locale stuff from locid.cpp */
U_CFUNC void locale_set_default(const char *id);
U_CFUNC const char *locale_get_default(void);
-U_CFUNC int32_t
-locale_getKeywords(const char *localeID,
- char prev,
- char *keywords, int32_t keywordCapacity,
- UBool valuesToo,
- UErrorCode *status);
/* ### Data tables **************************************************/
@@ -601,12 +592,12 @@ compareKeywordStructs(const void * /*context*/, const void *left, const void *ri
return uprv_strcmp(leftString, rightString);
}
-static void
-_getKeywords(const char *localeID,
- char prev,
- ByteSink& sink,
- UBool valuesToo,
- UErrorCode *status)
+U_CFUNC void
+ulocimp_getKeywords(const char *localeID,
+ char prev,
+ ByteSink& sink,
+ UBool valuesToo,
+ UErrorCode *status)
{
KeywordStruct keywordList[ULOC_MAX_NO_KEYWORDS];
@@ -722,18 +713,18 @@ _getKeywords(const char *localeID,
}
}
-U_CFUNC int32_t
-locale_getKeywords(const char *localeID,
- char prev,
- char *keywords, int32_t keywordCapacity,
- UBool valuesToo,
- UErrorCode *status) {
+U_CAPI int32_t U_EXPORT2
+uloc_getKeywordValue(const char* localeID,
+ const char* keywordName,
+ char* buffer, int32_t bufferCapacity,
+ UErrorCode* status)
+{
if (U_FAILURE(*status)) {
return 0;
}
- CheckedArrayByteSink sink(keywords, keywordCapacity);
- _getKeywords(localeID, prev, sink, valuesToo, status);
+ CheckedArrayByteSink sink(buffer, bufferCapacity);
+ ulocimp_getKeywordValue(localeID, keywordName, sink, status);
int32_t reslen = sink.NumberOfBytesAppended();
@@ -744,26 +735,22 @@ locale_getKeywords(const char *localeID,
if (sink.Overflowed()) {
*status = U_BUFFER_OVERFLOW_ERROR;
} else {
- u_terminateChars(keywords, keywordCapacity, reslen, status);
+ u_terminateChars(buffer, bufferCapacity, reslen, status);
}
return reslen;
}
-U_CAPI int32_t U_EXPORT2
-uloc_getKeywordValue(const char* localeID,
- const char* keywordName,
- char* buffer, int32_t bufferCapacity,
- UErrorCode* status)
+U_CAPI void U_EXPORT2
+ulocimp_getKeywordValue(const char* localeID,
+ const char* keywordName,
+ icu::ByteSink& sink,
+ UErrorCode* status)
{
- if (buffer != nullptr) {
- buffer[0] = '\0';
- }
const char* startSearchHere = NULL;
const char* nextSeparator = NULL;
char keywordNameBuffer[ULOC_KEYWORD_BUFFER_LEN];
char localeKeywordNameBuffer[ULOC_KEYWORD_BUFFER_LEN];
- int32_t result = 0;
if(status && U_SUCCESS(*status) && localeID) {
char tempBuffer[ULOC_FULLNAME_CAPACITY];
@@ -771,12 +758,12 @@ uloc_getKeywordValue(const char* localeID,
if (keywordName == NULL || keywordName[0] == 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return 0;
+ return;
}
locale_canonKeywordName(keywordNameBuffer, keywordName, status);
if(U_FAILURE(*status)) {
- return 0;
+ return;
}
if (_hasBCP47Extension(localeID)) {
@@ -788,7 +775,7 @@ uloc_getKeywordValue(const char* localeID,
startSearchHere = locale_getKeywordsStart(tmpLocaleID);
if(startSearchHere == NULL) {
/* no keywords, return at once */
- return 0;
+ return;
}
/* find the first keyword */
@@ -800,7 +787,7 @@ uloc_getKeywordValue(const char* localeID,
nextSeparator = uprv_strchr(startSearchHere, '=');
if(!nextSeparator) {
*status = U_ILLEGAL_ARGUMENT_ERROR; /* key must have =value */
- return 0;
+ return;
}
/* strip leading & trailing spaces (TC decided to tolerate these) */
while(*startSearchHere == ' ') {
@@ -814,20 +801,20 @@ uloc_getKeywordValue(const char* localeID,
/* copy & normalize keyName from locale */
if (startSearchHere == keyValueTail) {
*status = U_ILLEGAL_ARGUMENT_ERROR; /* empty keyword name in passed-in locale */
- return 0;
+ return;
}
keyValueLen = 0;
while (startSearchHere < keyValueTail) {
if (!UPRV_ISALPHANUM(*startSearchHere)) {
*status = U_ILLEGAL_ARGUMENT_ERROR; /* malformed keyword name */
- return 0;
+ return;
}
if (keyValueLen < ULOC_KEYWORD_BUFFER_LEN - 1) {
localeKeywordNameBuffer[keyValueLen++] = uprv_tolower(*startSearchHere++);
} else {
/* keyword name too long for internal buffer */
*status = U_INTERNAL_PROGRAM_ERROR;
- return 0;
+ return;
}
}
localeKeywordNameBuffer[keyValueLen] = 0; /* terminate */
@@ -848,28 +835,20 @@ uloc_getKeywordValue(const char* localeID,
/* Now copy the value, but check well-formedness */
if (nextSeparator == keyValueTail) {
*status = U_ILLEGAL_ARGUMENT_ERROR; /* empty key value name in passed-in locale */
- return 0;
+ return;
}
- keyValueLen = 0;
while (nextSeparator < keyValueTail) {
if (!UPRV_ISALPHANUM(*nextSeparator) && !UPRV_OK_VALUE_PUNCTUATION(*nextSeparator)) {
*status = U_ILLEGAL_ARGUMENT_ERROR; /* malformed key value */
- return 0;
- }
- if (keyValueLen < bufferCapacity) {
- /* Should we lowercase value to return here? Tests expect as-is. */
- buffer[keyValueLen++] = *nextSeparator++;
- } else { /* keep advancing so we return correct length in case of overflow */
- keyValueLen++;
- nextSeparator++;
+ return;
}
+ /* Should we lowercase value to return here? Tests expect as-is. */
+ sink.Append(nextSeparator++, 1);
}
- result = u_terminateChars(buffer, bufferCapacity, keyValueLen, status);
- return result;
+ return;
}
}
}
- return 0;
}
U_CAPI int32_t U_EXPORT2
@@ -892,7 +871,6 @@ uloc_setKeywordValue(const char* keywordName,
char* startSearchHere = NULL;
char* keywordStart = NULL;
CharString updatedKeysAndValues;
- int32_t updatedKeysAndValuesLen;
UBool handledInputKeyAndValue = FALSE;
char keyValuePrefix = '@';
@@ -1072,18 +1050,10 @@ uloc_setKeywordValue(const char* keywordName,
return bufLen;
}
- updatedKeysAndValuesLen = updatedKeysAndValues.length();
- /* needLen = length of the part before '@' + length of updated key-value part including '@' */
- needLen = (int32_t)(startSearchHere - buffer) + updatedKeysAndValuesLen;
- if(needLen >= bufferCapacity) {
- *status = U_BUFFER_OVERFLOW_ERROR;
- return needLen; /* no change */
- }
- if (updatedKeysAndValuesLen > 0) {
- uprv_strncpy(startSearchHere, updatedKeysAndValues.data(), updatedKeysAndValuesLen);
- }
- buffer[needLen]=0;
- return needLen;
+ // needLen = length of the part before '@'
+ needLen = (int32_t)(startSearchHere - buffer);
+ return needLen + updatedKeysAndValues.extract(
+ startSearchHere, bufferCapacity - needLen, *status);
}
/* ### ID parsing implementation **************************************************/
@@ -1148,7 +1118,7 @@ uloc_getCurrentLanguageID(const char* oldID){
*
* TODO try to use this in Locale
*/
-static CharString
+CharString U_EXPORT2
ulocimp_getLanguage(const char *localeID,
const char **pEnd,
UErrorCode &status) {
@@ -1193,21 +1163,7 @@ ulocimp_getLanguage(const char *localeID,
return result;
}
-U_CFUNC int32_t
-ulocimp_getLanguage(const char *localeID,
- char *language, int32_t languageCapacity,
- const char **pEnd) {
- ErrorCode status;
- CharString result = ulocimp_getLanguage(localeID, pEnd, status);
- if (status.isFailure()) {
- return 0;
- }
- int32_t reslen = result.length();
- uprv_memcpy(language, result.data(), std::min(reslen, languageCapacity));
- return reslen;
-}
-
-static CharString
+CharString U_EXPORT2
ulocimp_getScript(const char *localeID,
const char **pEnd,
UErrorCode &status) {
@@ -1241,21 +1197,7 @@ ulocimp_getScript(const char *localeID,
return result;
}
-U_CFUNC int32_t
-ulocimp_getScript(const char *localeID,
- char *script, int32_t scriptCapacity,
- const char **pEnd) {
- ErrorCode status;
- CharString result = ulocimp_getScript(localeID, pEnd, status);
- if (status.isFailure()) {
- return 0;
- }
- int32_t reslen = result.length();
- uprv_memcpy(script, result.data(), std::min(reslen, scriptCapacity));
- return reslen;
-}
-
-static CharString
+CharString U_EXPORT2
ulocimp_getCountry(const char *localeID,
const char **pEnd,
UErrorCode &status) {
@@ -1290,29 +1232,15 @@ ulocimp_getCountry(const char *localeID,
return result;
}
-U_CFUNC int32_t
-ulocimp_getCountry(const char *localeID,
- char *country, int32_t countryCapacity,
- const char **pEnd) {
- ErrorCode status;
- CharString result = ulocimp_getCountry(localeID, pEnd, status);
- if (status.isFailure()) {
- return 0;
- }
- int32_t reslen = result.length();
- uprv_memcpy(country, result.data(), std::min(reslen, countryCapacity));
- return reslen;
-}
-
/**
* @param needSeparator if true, then add leading '_' if any variants
* are added to 'variant'
*/
static void
-_getVariantEx(const char *localeID,
- char prev,
- ByteSink& sink,
- UBool needSeparator) {
+_getVariant(const char *localeID,
+ char prev,
+ ByteSink& sink,
+ UBool needSeparator) {
UBool hasVariant = FALSE;
/* get one or more variant tags and separate them with '_' */
@@ -1353,23 +1281,6 @@ _getVariantEx(const char *localeID,
}
}
-static int32_t
-_getVariantEx(const char *localeID,
- char prev,
- char *variant, int32_t variantCapacity,
- UBool needSeparator) {
- CheckedArrayByteSink sink(variant, variantCapacity);
- _getVariantEx(localeID, prev, sink, needSeparator);
- return sink.NumberOfBytesAppended();
-}
-
-static int32_t
-_getVariant(const char *localeID,
- char prev,
- char *variant, int32_t variantCapacity) {
- return _getVariantEx(localeID, prev, variant, variantCapacity, FALSE);
-}
-
/* Keyword enumeration */
typedef struct UKeywordsContext {
@@ -1466,9 +1377,6 @@ U_CAPI UEnumeration* U_EXPORT2
uloc_openKeywords(const char* localeID,
UErrorCode* status)
{
- int32_t i=0;
- char keywords[256];
- int32_t keywordsCapacity = 256;
char tempBuffer[ULOC_FULLNAME_CAPACITY];
const char* tmpLocaleID;
@@ -1486,34 +1394,42 @@ uloc_openKeywords(const char* localeID,
}
/* Skip the language */
- ulocimp_getLanguage(tmpLocaleID, NULL, 0, &tmpLocaleID);
+ ulocimp_getLanguage(tmpLocaleID, &tmpLocaleID, *status);
+ if (U_FAILURE(*status)) {
+ return 0;
+ }
+
if(_isIDSeparator(*tmpLocaleID)) {
const char *scriptID;
/* Skip the script if available */
- ulocimp_getScript(tmpLocaleID+1, NULL, 0, &scriptID);
+ ulocimp_getScript(tmpLocaleID+1, &scriptID, *status);
+ if (U_FAILURE(*status)) {
+ return 0;
+ }
if(scriptID != tmpLocaleID+1) {
/* Found optional script */
tmpLocaleID = scriptID;
}
/* Skip the Country */
if (_isIDSeparator(*tmpLocaleID)) {
- ulocimp_getCountry(tmpLocaleID+1, NULL, 0, &tmpLocaleID);
- if(_isIDSeparator(*tmpLocaleID)) {
- _getVariant(tmpLocaleID+1, *tmpLocaleID, NULL, 0);
+ ulocimp_getCountry(tmpLocaleID+1, &tmpLocaleID, *status);
+ if (U_FAILURE(*status)) {
+ return 0;
}
}
}
/* keywords are located after '@' */
if((tmpLocaleID = locale_getKeywordsStart(tmpLocaleID)) != NULL) {
- i=locale_getKeywords(tmpLocaleID+1, '@', keywords, keywordsCapacity, FALSE, status);
- }
-
- if(i) {
- return uloc_openKeywordList(keywords, i, status);
- } else {
- return NULL;
+ CharString keywords;
+ CharStringByteSink sink(&keywords);
+ ulocimp_getKeywords(tmpLocaleID+1, '@', sink, FALSE, status);
+ if (U_FAILURE(*status)) {
+ return NULL;
+ }
+ return uloc_openKeywordList(keywords.data(), keywords.length(), status);
}
+ return NULL;
}
@@ -1605,7 +1521,7 @@ _canonicalize(const char* localeID,
variantSize = -tag.length();
{
CharStringByteSink s(&tag);
- _getVariantEx(tmpLocaleID+1, *tmpLocaleID, s, FALSE);
+ _getVariant(tmpLocaleID+1, *tmpLocaleID, s, FALSE);
}
variantSize += tag.length();
if (variantSize > 0) {
@@ -1667,7 +1583,7 @@ _canonicalize(const char* localeID,
int32_t posixVariantSize = -tag.length();
{
CharStringByteSink s(&tag);
- _getVariantEx(tmpLocaleID+1, '@', s, (UBool)(variantSize > 0));
+ _getVariant(tmpLocaleID+1, '@', s, (UBool)(variantSize > 0));
}
posixVariantSize += tag.length();
if (posixVariantSize > 0) {
@@ -1696,7 +1612,7 @@ _canonicalize(const char* localeID,
(!separatorIndicator || separatorIndicator > keywordAssign)) {
sink.Append("@", 1);
++fieldCount;
- _getKeywords(tmpLocaleID+1, '@', sink, TRUE, err);
+ ulocimp_getKeywords(tmpLocaleID+1, '@', sink, TRUE, err);
}
}
}
@@ -1745,7 +1661,6 @@ uloc_getLanguage(const char* localeID,
UErrorCode* err)
{
/* uloc_getLanguage will return a 2 character iso-639 code if one exists. *CWB*/
- int32_t i=0;
if (err==NULL || U_FAILURE(*err)) {
return 0;
@@ -1755,8 +1670,7 @@ uloc_getLanguage(const char* localeID,
localeID=uloc_getDefault();
}
- i=ulocimp_getLanguage(localeID, language, languageCapacity, NULL);
- return u_terminateChars(language, languageCapacity, i, err);
+ return ulocimp_getLanguage(localeID, NULL, *err).extract(language, languageCapacity, *err);
}
U_CAPI int32_t U_EXPORT2
@@ -1765,8 +1679,6 @@ uloc_getScript(const char* localeID,
int32_t scriptCapacity,
UErrorCode* err)
{
- int32_t i=0;
-
if(err==NULL || U_FAILURE(*err)) {
return 0;
}
@@ -1776,11 +1688,15 @@ uloc_getScript(const char* localeID,
}
/* skip the language */
- ulocimp_getLanguage(localeID, NULL, 0, &localeID);
+ ulocimp_getLanguage(localeID, &localeID, *err);
+ if (U_FAILURE(*err)) {
+ return 0;
+ }
+
if(_isIDSeparator(*localeID)) {
- i=ulocimp_getScript(localeID+1, script, scriptCapacity, NULL);
+ return ulocimp_getScript(localeID+1, NULL, *err).extract(script, scriptCapacity, *err);
}
- return u_terminateChars(script, scriptCapacity, i, err);
+ return u_terminateChars(script, scriptCapacity, 0, err);
}
U_CAPI int32_t U_EXPORT2
@@ -1789,8 +1705,6 @@ uloc_getCountry(const char* localeID,
int32_t countryCapacity,
UErrorCode* err)
{
- int32_t i=0;
-
if(err==NULL || U_FAILURE(*err)) {
return 0;
}
@@ -1800,20 +1714,27 @@ uloc_getCountry(const char* localeID,
}
/* Skip the language */
- ulocimp_getLanguage(localeID, NULL, 0, &localeID);
+ ulocimp_getLanguage(localeID, &localeID, *err);
+ if (U_FAILURE(*err)) {
+ return 0;
+ }
+
if(_isIDSeparator(*localeID)) {
const char *scriptID;
/* Skip the script if available */
- ulocimp_getScript(localeID+1, NULL, 0, &scriptID);
+ ulocimp_getScript(localeID+1, &scriptID, *err);
+ if (U_FAILURE(*err)) {
+ return 0;
+ }
if(scriptID != localeID+1) {
/* Found optional script */
localeID = scriptID;
}
if(_isIDSeparator(*localeID)) {
- i=ulocimp_getCountry(localeID+1, country, countryCapacity, NULL);
+ return ulocimp_getCountry(localeID+1, NULL, *err).extract(country, countryCapacity, *err);
}
}
- return u_terminateChars(country, countryCapacity, i, err);
+ return u_terminateChars(country, countryCapacity, 0, err);
}
U_CAPI int32_t U_EXPORT2
@@ -1840,11 +1761,18 @@ uloc_getVariant(const char* localeID,
}
/* Skip the language */
- ulocimp_getLanguage(tmpLocaleID, NULL, 0, &tmpLocaleID);
+ ulocimp_getLanguage(tmpLocaleID, &tmpLocaleID, *err);
+ if (U_FAILURE(*err)) {
+ return 0;
+ }
+
if(_isIDSeparator(*tmpLocaleID)) {
const char *scriptID;
/* Skip the script if available */
- ulocimp_getScript(tmpLocaleID+1, NULL, 0, &scriptID);
+ ulocimp_getScript(tmpLocaleID+1, &scriptID, *err);
+ if (U_FAILURE(*err)) {
+ return 0;
+ }
if(scriptID != tmpLocaleID+1) {
/* Found optional script */
tmpLocaleID = scriptID;
@@ -1852,7 +1780,10 @@ uloc_getVariant(const char* localeID,
/* Skip the Country */
if (_isIDSeparator(*tmpLocaleID)) {
const char *cntryID;
- ulocimp_getCountry(tmpLocaleID+1, NULL, 0, &cntryID);
+ ulocimp_getCountry(tmpLocaleID+1, &cntryID, *err);
+ if (U_FAILURE(*err)) {
+ return 0;
+ }
if (cntryID != tmpLocaleID+1) {
/* Found optional country */
tmpLocaleID = cntryID;
@@ -1862,18 +1793,24 @@ uloc_getVariant(const char* localeID,
if (tmpLocaleID != cntryID && _isIDSeparator(tmpLocaleID[1])) {
tmpLocaleID++;
}
- i=_getVariant(tmpLocaleID+1, *tmpLocaleID, variant, variantCapacity);
+
+ CheckedArrayByteSink sink(variant, variantCapacity);
+ _getVariant(tmpLocaleID+1, *tmpLocaleID, sink, FALSE);
+
+ i = sink.NumberOfBytesAppended();
+
+ if (U_FAILURE(*err)) {
+ return i;
+ }
+
+ if (sink.Overflowed()) {
+ *err = U_BUFFER_OVERFLOW_ERROR;
+ return i;
+ }
}
}
}
- /* removed by weiv. We don't want to handle POSIX variants anymore. Use canonicalization function */
- /* if we do not have a variant tag yet then try a POSIX variant after '@' */
-/*
- if(!haveVariant && (localeID=uprv_strrchr(localeID, '@'))!=NULL) {
- i=_getVariant(localeID+1, '@', variant, variantCapacity);
- }
-*/
return u_terminateChars(variant, variantCapacity, i, err);
}
@@ -1905,7 +1842,7 @@ uloc_getName(const char* localeID,
return reslen;
}
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_getName(const char* localeID,
ByteSink& sink,
UErrorCode* err)
@@ -1941,7 +1878,7 @@ uloc_getBaseName(const char* localeID,
return reslen;
}
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_getBaseName(const char* localeID,
ByteSink& sink,
UErrorCode* err)
@@ -1977,7 +1914,7 @@ uloc_canonicalize(const char* localeID,
return reslen;
}
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_canonicalize(const char* localeID,
ByteSink& sink,
UErrorCode* err)
@@ -2058,22 +1995,22 @@ uloc_getLCID(const char* localeID)
// uprv_convertToLCID does not support keywords other than collation.
// Remove all keywords except collation.
int32_t len;
- char collVal[ULOC_KEYWORDS_CAPACITY];
char tmpLocaleID[ULOC_FULLNAME_CAPACITY];
- len = uloc_getKeywordValue(localeID, "collation", collVal,
- UPRV_LENGTHOF(collVal) - 1, &status);
-
- if (U_SUCCESS(status) && len > 0) {
- collVal[len] = 0;
+ CharString collVal;
+ {
+ CharStringByteSink sink(&collVal);
+ ulocimp_getKeywordValue(localeID, "collation", sink, &status);
+ }
+ if (U_SUCCESS(status) && !collVal.isEmpty()) {
len = uloc_getBaseName(localeID, tmpLocaleID,
UPRV_LENGTHOF(tmpLocaleID) - 1, &status);
if (U_SUCCESS(status) && len > 0) {
tmpLocaleID[len] = 0;
- len = uloc_setKeywordValue("collation", collVal, tmpLocaleID,
+ len = uloc_setKeywordValue("collation", collVal.data(), tmpLocaleID,
UPRV_LENGTHOF(tmpLocaleID) - len - 1, &status);
if (U_SUCCESS(status) && len > 0) {
diff --git a/deps/icu-small/source/common/uloc_tag.cpp b/deps/icu-small/source/common/uloc_tag.cpp
index 3bdeddbe06..d2d9387531 100644
--- a/deps/icu-small/source/common/uloc_tag.cpp
+++ b/deps/icu-small/source/common/uloc_tag.cpp
@@ -15,6 +15,7 @@
#include "unicode/uenum.h"
#include "unicode/uloc.h"
#include "ustr_imp.h"
+#include "bytesinkutil.h"
#include "charstr.h"
#include "cmemory.h"
#include "cstring.h"
@@ -53,7 +54,7 @@ typedef struct ULanguageTag {
VariantListEntry *variants;
ExtensionListEntry *extensions;
const char *privateuse;
- const char *grandfathered;
+ const char *legacy;
} ULanguageTag;
#define MINLEN 2
@@ -85,8 +86,9 @@ static const char LOCALE_TYPE_YES[] = "yes";
Updated on 2018-09-12 from
https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry .
- This table has 2 parts. The parts for Grandfathered tags is generated by the
- following scripts from the IANA language tag registry.
+ This table has 2 parts. The part for
+ legacy language tags (marked as “Type: grandfathered” in BCP 47)
+ is generated by the following scripts from the IANA language tag registry.
curl https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry |\
egrep -A 7 'Type: grandfathered' | \
@@ -100,8 +102,8 @@ static const char LOCALE_TYPE_YES[] = "yes";
values. They may have to be removed for the strict BCP 47 compliance.
*/
-static const char* const GRANDFATHERED[] = {
-/* grandfathered preferred */
+static const char* const LEGACY[] = {
+/* legacy preferred */
"art-lojban", "jbo",
"en-gb-oed", "en-gb-oxendict",
"i-ami", "ami",
@@ -124,7 +126,7 @@ static const char* const GRANDFATHERED[] = {
"zh-min-nan", "nan",
"zh-xiang", "hsn",
- // Grandfathered tags with no preferred value in the IANA
+ // Legacy tags with no preferred value in the IANA
// registry. Kept for now for the backward compatibility
// because ICU has mapped them this way.
"cel-gaulish", "xtg-x-cel-gaulish",
@@ -346,7 +348,7 @@ ultag_getPrivateUse(const ULanguageTag* langtag);
#if 0
static const char*
-ultag_getGrandfathered(const ULanguageTag* langtag);
+ultag_getLegacy(const ULanguageTag* langtag);
#endif
U_NAMESPACE_BEGIN
@@ -986,7 +988,7 @@ _initializeULanguageTag(ULanguageTag* langtag) {
langtag->variants = NULL;
langtag->extensions = NULL;
- langtag->grandfathered = EMPTY;
+ langtag->legacy = EMPTY;
langtag->privateuse = EMPTY;
}
@@ -1268,35 +1270,17 @@ _appendKeywordsToLanguageTag(const char* localeID, icu::ByteSink& sink, UBool st
UBool isBcpUExt;
while (TRUE) {
- icu::CharString buf;
key = uenum_next(keywordEnum.getAlias(), NULL, status);
if (key == NULL) {
break;
}
- char* buffer;
- int32_t resultCapacity = ULOC_KEYWORD_AND_VALUES_CAPACITY;
-
- for (;;) {
- buffer = buf.getAppendBuffer(
- /*minCapacity=*/resultCapacity,
- /*desiredCapacityHint=*/resultCapacity,
- resultCapacity,
- tmpStatus);
-
- if (U_FAILURE(tmpStatus)) {
- break;
- }
- len = uloc_getKeywordValue(
- localeID, key, buffer, resultCapacity, &tmpStatus);
-
- if (tmpStatus != U_BUFFER_OVERFLOW_ERROR) {
- break;
- }
-
- resultCapacity = len;
- tmpStatus = U_ZERO_ERROR;
+ icu::CharString buf;
+ {
+ icu::CharStringByteSink sink(&buf);
+ ulocimp_getKeywordValue(localeID, key, sink, &tmpStatus);
}
+ len = buf.length();
if (U_FAILURE(tmpStatus)) {
if (tmpStatus == U_MEMORY_ALLOCATION_ERROR) {
@@ -1312,11 +1296,6 @@ _appendKeywordsToLanguageTag(const char* localeID, icu::ByteSink& sink, UBool st
continue;
}
- buf.append(buffer, len, tmpStatus);
- if (tmpStatus == U_STRING_NOT_TERMINATED_WARNING) {
- tmpStatus = U_ZERO_ERROR; // Terminators provided by CharString.
- }
-
keylen = (int32_t)uprv_strlen(key);
isBcpUExt = (keylen > 1);
@@ -1395,32 +1374,18 @@ _appendKeywordsToLanguageTag(const char* localeID, icu::ByteSink& sink, UBool st
no known mapping. This implementation normalizes the
value to lower case
*/
- icu::CharString* extBuf = extBufPool.create();
+ icu::CharString* extBuf = extBufPool.create(buf, tmpStatus);
+
if (extBuf == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
break;
}
- int32_t bcpValueLen = static_cast<int32_t>(uprv_strlen(bcpValue));
- int32_t resultCapacity;
- char* pExtBuf = extBuf->getAppendBuffer(
- /*minCapacity=*/bcpValueLen,
- /*desiredCapacityHint=*/bcpValueLen,
- resultCapacity,
- tmpStatus);
- if (U_FAILURE(tmpStatus)) {
- *status = tmpStatus;
- break;
- }
-
- uprv_strcpy(pExtBuf, bcpValue);
- T_CString_toLowerCase(pExtBuf);
-
- extBuf->append(pExtBuf, bcpValueLen, tmpStatus);
if (U_FAILURE(tmpStatus)) {
*status = tmpStatus;
break;
}
+ T_CString_toLowerCase(extBuf->data());
bcpValue = extBuf->data();
}
} else {
@@ -2023,11 +1988,12 @@ _appendPrivateuseToLanguageTag(const char* localeID, icu::ByteSink& sink, UBool
#define PRIV 0x0080
/**
- * Ticket #12705 - Visual Studio 2015 Update 3 contains a new code optimizer which has problems optimizing
- * this function. (See https://blogs.msdn.microsoft.com/vcblog/2016/05/04/new-code-optimizer/ )
- * As a workaround, we will turn off optimization just for this function on VS2015 Update 3 and above.
+ * Ticket #12705 - The optimizer in Visual Studio 2015 Update 3 has problems optimizing this function.
+ * As a work-around, optimization is disabled for this function on VS2015 and VS2017.
+ * This work-around should be removed once the following versions of Visual Studio are no
+ * longer supported: All versions of VS2015/VS2017, and versions of VS2019 below 16.4.
*/
-#if (defined(_MSC_VER) && (_MSC_VER >= 1900) && defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190024210))
+#if defined(_MSC_VER) && (_MSC_VER >= 1900) && (_MSC_VER < 1924)
#pragma optimize( "", off )
#endif
@@ -2042,7 +2008,7 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta
char *pExtValueSubtag, *pExtValueSubtagEnd;
int32_t i;
UBool privateuseVar = FALSE;
- int32_t grandfatheredLen = 0;
+ int32_t legacyLen = 0;
if (parsedLen != NULL) {
*parsedLen = 0;
@@ -2082,25 +2048,25 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta
}
size_t parsedLenDelta = 0;
- // Grandfathered tag will be consider together. Grandfathered tag with intervening
+ // Legacy tag will be consider together. Legacy tag with intervening
// script and region such as art-DE-lojban or art-Latn-lojban won't be
// matched.
- /* check if the tag is grandfathered */
- for (i = 0; i < UPRV_LENGTHOF(GRANDFATHERED); i += 2) {
- int32_t checkGrandfatheredLen = static_cast<int32_t>(uprv_strlen(GRANDFATHERED[i]));
- if (tagLen < checkGrandfatheredLen) {
+ /* check if the tag is legacy */
+ for (i = 0; i < UPRV_LENGTHOF(LEGACY); i += 2) {
+ int32_t checkLegacyLen = static_cast<int32_t>(uprv_strlen(LEGACY[i]));
+ if (tagLen < checkLegacyLen) {
continue;
}
- if (tagLen > checkGrandfatheredLen && tagBuf[checkGrandfatheredLen] != '-') {
+ if (tagLen > checkLegacyLen && tagBuf[checkLegacyLen] != '-') {
// make sure next char is '-'.
continue;
}
- if (uprv_strnicmp(GRANDFATHERED[i], tagBuf, checkGrandfatheredLen) == 0) {
+ if (uprv_strnicmp(LEGACY[i], tagBuf, checkLegacyLen) == 0) {
int32_t newTagLength;
- grandfatheredLen = checkGrandfatheredLen; /* back up for output parsedLen */
- int32_t replacementLen = static_cast<int32_t>(uprv_strlen(GRANDFATHERED[i+1]));
- newTagLength = replacementLen + tagLen - checkGrandfatheredLen;
+ legacyLen = checkLegacyLen; /* back up for output parsedLen */
+ int32_t replacementLen = static_cast<int32_t>(uprv_strlen(LEGACY[i+1]));
+ newTagLength = replacementLen + tagLen - checkLegacyLen;
if (tagLen < newTagLength) {
uprv_free(tagBuf);
tagBuf = (char*)uprv_malloc(newTagLength + 1);
@@ -2111,16 +2077,16 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta
t->buf = tagBuf;
tagLen = newTagLength;
}
- parsedLenDelta = checkGrandfatheredLen - replacementLen;
- uprv_strcpy(t->buf, GRANDFATHERED[i + 1]);
- if (checkGrandfatheredLen != tagLen) {
- uprv_strcpy(t->buf + replacementLen, tag + checkGrandfatheredLen);
+ parsedLenDelta = checkLegacyLen - replacementLen;
+ uprv_strcpy(t->buf, LEGACY[i + 1]);
+ if (checkLegacyLen != tagLen) {
+ uprv_strcpy(t->buf + replacementLen, tag + checkLegacyLen);
}
break;
}
}
- if (grandfatheredLen == 0) {
+ if (legacyLen == 0) {
for (i = 0; i < UPRV_LENGTHOF(REDUNDANT); i += 2) {
const char* redundantTag = REDUNDANT[i];
size_t redundantTagLen = uprv_strlen(redundantTag);
@@ -2440,10 +2406,8 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta
return t.orphan();
}
-/**
-* Ticket #12705 - Turn optimization back on.
-*/
-#if (defined(_MSC_VER) && (_MSC_VER >= 1900) && defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190024210))
+// Ticket #12705 - Turn optimization back on.
+#if defined(_MSC_VER) && (_MSC_VER >= 1900) && (_MSC_VER < 1924)
#pragma optimize( "", on )
#endif
@@ -2608,8 +2572,8 @@ ultag_getPrivateUse(const ULanguageTag* langtag) {
#if 0
static const char*
-ultag_getGrandfathered(const ULanguageTag* langtag) {
- return langtag->grandfathered;
+ultag_getLegacy(const ULanguageTag* langtag) {
+ return langtag->legacy;
}
#endif
@@ -2720,14 +2684,17 @@ ulocimp_toLanguageTag(const char* localeID,
key = uenum_next(kwdEnum.getAlias(), &len, &tmpStatus);
if (len == 1 && *key == PRIVATEUSE) {
- char buf[ULOC_KEYWORD_AND_VALUES_CAPACITY];
- buf[0] = PRIVATEUSE;
- buf[1] = SEP;
- len = uloc_getKeywordValue(localeID, key, &buf[2], sizeof(buf) - 2, &tmpStatus);
+ icu::CharString buf;
+ {
+ icu::CharStringByteSink sink(&buf);
+ ulocimp_getKeywordValue(localeID, key, sink, &tmpStatus);
+ }
if (U_SUCCESS(tmpStatus)) {
- if (ultag_isPrivateuseValueSubtags(&buf[2], len)) {
+ if (ultag_isPrivateuseValueSubtags(buf.data(), buf.length())) {
/* return private use only tag */
- sink.Append(buf, len + 2);
+ static const char PREFIX[] = { PRIVATEUSE, SEP };
+ sink.Append(PREFIX, sizeof(PREFIX));
+ sink.Append(buf.data(), buf.length());
done = TRUE;
} else if (strict) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
diff --git a/deps/icu-small/source/common/ulocimp.h b/deps/icu-small/source/common/ulocimp.h
index 98b95dddfe..a686759f32 100644
--- a/deps/icu-small/source/common/ulocimp.h
+++ b/deps/icu-small/source/common/ulocimp.h
@@ -13,6 +13,8 @@
#include "unicode/bytestream.h"
#include "unicode/uloc.h"
+#include "charstr.h"
+
/**
* Create an iterator over the specified keywords list
* @param keywordList double-null terminated list. Will be copied.
@@ -38,7 +40,7 @@ uloc_getTableStringWithFallback(
int32_t *pLength,
UErrorCode *pErrorCode);
-/*returns TRUE if a is an ID separator FALSE otherwise*/
+/*returns true if a is an ID separator false otherwise*/
#define _isIDSeparator(a) (a == '_' || a == '-')
U_CFUNC const char*
@@ -47,42 +49,55 @@ uloc_getCurrentCountryID(const char* oldID);
U_CFUNC const char*
uloc_getCurrentLanguageID(const char* oldID);
-U_CFUNC int32_t
+U_CFUNC void
+ulocimp_getKeywords(const char *localeID,
+ char prev,
+ icu::ByteSink& sink,
+ UBool valuesToo,
+ UErrorCode *status);
+
+icu::CharString U_EXPORT2
ulocimp_getLanguage(const char *localeID,
- char *language, int32_t languageCapacity,
- const char **pEnd);
+ const char **pEnd,
+ UErrorCode &status);
-U_CFUNC int32_t
+icu::CharString U_EXPORT2
ulocimp_getScript(const char *localeID,
- char *script, int32_t scriptCapacity,
- const char **pEnd);
+ const char **pEnd,
+ UErrorCode &status);
-U_CFUNC int32_t
+icu::CharString U_EXPORT2
ulocimp_getCountry(const char *localeID,
- char *country, int32_t countryCapacity,
- const char **pEnd);
+ const char **pEnd,
+ UErrorCode &status);
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_getName(const char* localeID,
icu::ByteSink& sink,
UErrorCode* err);
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_getBaseName(const char* localeID,
icu::ByteSink& sink,
UErrorCode* err);
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_canonicalize(const char* localeID,
icu::ByteSink& sink,
UErrorCode* err);
+U_CAPI void U_EXPORT2
+ulocimp_getKeywordValue(const char* localeID,
+ const char* keywordName,
+ icu::ByteSink& sink,
+ UErrorCode* status);
+
/**
* Writes a well-formed language tag for this locale ID.
*
- * **Note**: When `strict` is FALSE, any locale fields which do not satisfy the
+ * **Note**: When `strict` is false, any locale fields which do not satisfy the
* BCP47 syntax requirement will be omitted from the result. When `strict` is
- * TRUE, this function sets U_ILLEGAL_ARGUMENT_ERROR to the `err` if any locale
+ * true, this function sets U_ILLEGAL_ARGUMENT_ERROR to the `err` if any locale
* fields do not satisfy the BCP47 syntax requirement.
*
* @param localeID the input locale ID
@@ -96,7 +111,7 @@ ulocimp_canonicalize(const char* localeID,
*
* @internal ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_toLanguageTag(const char* localeID,
icu::ByteSink& sink,
UBool strict,
@@ -107,13 +122,17 @@ ulocimp_toLanguageTag(const char* localeID,
* If the specified language tag contains any ill-formed subtags,
* the first such subtag and all following subtags are ignored.
* <p>
- * This implements the 'Language-Tag' production of BCP47, and so
- * supports grandfathered (regular and irregular) as well as private
- * use language tags. Private use tags are represented as 'x-whatever',
- * and grandfathered tags are converted to their canonical replacements
- * where they exist. Note that a few grandfathered tags have no modern
- * replacement, these will be converted using the fallback described in
+ * This implements the 'Language-Tag' production of BCP 47, and so
+ * supports legacy language tags (marked as “Type: grandfathered” in BCP 47)
+ * (regular and irregular) as well as private use language tags.
+ *
+ * Private use tags are represented as 'x-whatever',
+ * and legacy tags are converted to their canonical replacements where they exist.
+ *
+ * Note that a few legacy tags have no modern replacement;
+ * these will be converted using the fallback described in
* the first paragraph, so some information might be lost.
+ *
* @param langtag the input BCP47 language tag.
* @param tagLen the length of langtag, or -1 to call uprv_strlen().
* @param sink the output sink receiving a locale ID for the
@@ -135,7 +154,7 @@ ulocimp_forLanguageTag(const char* langtag,
* Get the region to use for supplemental data lookup. Uses
* (1) any region specified by locale tag "rg"; if none then
* (2) any unicode_region_tag in the locale ID; if none then
- * (3) if inferRegion is TRUE, the region suggested by
+ * (3) if inferRegion is true, the region suggested by
* getLikelySubtags on the localeID.
* If no region is found, returns length 0.
*
@@ -143,7 +162,7 @@ ulocimp_forLanguageTag(const char* langtag,
* The complete locale ID (with keywords) from which
* to get the region to use for supplemental data.
* @param inferRegion
- * If TRUE, will try to infer region from localeID if
+ * If true, will try to infer region from localeID if
* no other region is found.
* @param region
* Buffer in which to put the region ID found; should
@@ -189,7 +208,7 @@ ulocimp_getRegionForSupplementalData(const char *localeID, UBool inferRegion,
* or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
* @internal ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_addLikelySubtags(const char* localeID,
icu::ByteSink& sink,
UErrorCode* err);
@@ -223,7 +242,7 @@ ulocimp_addLikelySubtags(const char* localeID,
* or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
* @internal ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocimp_minimizeSubtags(const char* localeID,
icu::ByteSink& sink,
UErrorCode* err);
@@ -279,4 +298,10 @@ ulocimp_toBcpType(const char* key, const char* type, UBool* isKnownKey, UBool* i
U_CFUNC const char*
ulocimp_toLegacyType(const char* key, const char* type, UBool* isKnownKey, UBool* isSpecialType);
+/* Function for testing purpose */
+U_CAPI const char* const* ulocimp_getKnownCanonicalizedLocaleForTest(int32_t* length);
+
+// Return true if the value is already canonicalized.
+U_CAPI bool ulocimp_isCanonicalizedLocaleForTest(const char* localeName);
+
#endif
diff --git a/deps/icu-small/source/common/umutex.h b/deps/icu-small/source/common/umutex.h
index 7588bcc5d9..57955353d0 100644
--- a/deps/icu-small/source/common/umutex.h
+++ b/deps/icu-small/source/common/umutex.h
@@ -262,13 +262,13 @@ private:
* the global ICU mutex. Recursive locks are an error
* and may cause a deadlock on some platforms.
*/
-U_INTERNAL void U_EXPORT2 umtx_lock(UMutex* mutex);
+U_CAPI void U_EXPORT2 umtx_lock(UMutex* mutex);
/* Unlock a mutex.
* @param mutex The given mutex to be unlocked. Pass NULL to specify
* the global ICU mutex.
*/
-U_INTERNAL void U_EXPORT2 umtx_unlock (UMutex* mutex);
+U_CAPI void U_EXPORT2 umtx_unlock (UMutex* mutex);
U_NAMESPACE_END
diff --git a/deps/icu-small/source/common/unicode/appendable.h b/deps/icu-small/source/common/unicode/appendable.h
index 4beacaf658..fc99254de1 100644
--- a/deps/icu-small/source/common/unicode/appendable.h
+++ b/deps/icu-small/source/common/unicode/appendable.h
@@ -45,7 +45,7 @@ class UnicodeString;
*
* The methods do not take UErrorCode parameters.
* If an error occurs (e.g., out-of-memory),
- * in addition to returning FALSE from failing operations,
+ * in addition to returning false from failing operations,
* the implementation must prevent unexpected behavior (e.g., crashes)
* from further calls and should make the error condition available separately
* (e.g., store a UErrorCode, make/keep a UnicodeString bogus).
@@ -62,7 +62,7 @@ public:
/**
* Appends a 16-bit code unit.
* @param c code unit
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool appendCodeUnit(char16_t c) = 0;
@@ -71,7 +71,7 @@ public:
* Appends a code point.
* The default implementation calls appendCodeUnit(char16_t) once or twice.
* @param c code point 0..0x10ffff
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool appendCodePoint(UChar32 c);
@@ -81,7 +81,7 @@ public:
* The default implementation calls appendCodeUnit(char16_t) for each code unit.
* @param s string, must not be NULL if length!=0
* @param length string length, or -1 if NUL-terminated
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool appendString(const char16_t *s, int32_t length);
@@ -90,9 +90,9 @@ public:
* Tells the object that the caller is going to append roughly
* appendCapacity char16_ts. A subclass might use this to pre-allocate
* a larger buffer if necessary.
- * The default implementation does nothing. (It always returns TRUE.)
+ * The default implementation does nothing. (It always returns true.)
* @param appendCapacity estimated number of char16_ts that will be appended
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool reserveAppendCapacity(int32_t appendCapacity);
@@ -171,7 +171,7 @@ public:
/**
* Appends a 16-bit code unit to the string.
* @param c code unit
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool appendCodeUnit(char16_t c);
@@ -179,7 +179,7 @@ public:
/**
* Appends a code point to the string.
* @param c code point 0..0x10ffff
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool appendCodePoint(UChar32 c);
@@ -188,7 +188,7 @@ public:
* Appends a string to the UnicodeString.
* @param s string, must not be NULL if length!=0
* @param length string length, or -1 if NUL-terminated
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool appendString(const char16_t *s, int32_t length);
@@ -197,7 +197,7 @@ public:
* Tells the UnicodeString that the caller is going to append roughly
* appendCapacity char16_ts.
* @param appendCapacity estimated number of char16_ts that will be appended
- * @return TRUE if the operation succeeded
+ * @return true if the operation succeeded
* @stable ICU 4.8
*/
virtual UBool reserveAppendCapacity(int32_t appendCapacity);
diff --git a/deps/icu-small/source/common/unicode/brkiter.h b/deps/icu-small/source/common/unicode/brkiter.h
index b944497345..9bba5fcccc 100644
--- a/deps/icu-small/source/common/unicode/brkiter.h
+++ b/deps/icu-small/source/common/unicode/brkiter.h
@@ -564,7 +564,7 @@ public:
* BreakIterator::createXXXInstance to avoid undefined behavior.
* @param key the registry key returned by a previous call to registerInstance
* @param status the in/out status code, no special meanings are assigned
- * @return TRUE if the iterator for the key was successfully unregistered
+ * @return true if the iterator for the key was successfully unregistered
* @stable ICU 2.4
*/
static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
@@ -655,7 +655,7 @@ private:
inline UBool BreakIterator::isBufferClone()
{
- return FALSE;
+ return false;
}
#endif /* U_HIDE_DEPRECATED_API */
diff --git a/deps/icu-small/source/common/unicode/bytestream.h b/deps/icu-small/source/common/unicode/bytestream.h
index 33505a3429..73d498397c 100644
--- a/deps/icu-small/source/common/unicode/bytestream.h
+++ b/deps/icu-small/source/common/unicode/bytestream.h
@@ -197,7 +197,7 @@ public:
* Returns the sink to its original state, without modifying the buffer.
* Useful for reusing both the buffer and the sink for multiple streams.
* Resets the state to NumberOfBytesWritten()=NumberOfBytesAppended()=0
- * and Overflowed()=FALSE.
+ * and Overflowed()=false.
* @return *this
* @stable ICU 4.6
*/
@@ -236,7 +236,7 @@ public:
/**
* Returns true if any bytes were discarded, i.e., if there was an
* attempt to write more than 'capacity' bytes.
- * @return TRUE if more than 'capacity' bytes were Append()ed
+ * @return true if more than 'capacity' bytes were Append()ed
* @stable ICU 4.2
*/
UBool Overflowed() const { return overflowed_; }
diff --git a/deps/icu-small/source/common/unicode/bytestrie.h b/deps/icu-small/source/common/unicode/bytestrie.h
index 51405f64a1..85f802df42 100644
--- a/deps/icu-small/source/common/unicode/bytestrie.h
+++ b/deps/icu-small/source/common/unicode/bytestrie.h
@@ -97,14 +97,13 @@ public:
return *this;
}
-#ifndef U_HIDE_DRAFT_API
/**
* Returns the state of this trie as a 64-bit integer.
* The state value is never 0.
*
* @return opaque state value
* @see resetToState64
- * @draft ICU 65
+ * @stable ICU 65
*/
uint64_t getState64() const {
return (static_cast<uint64_t>(remainingMatchLength_ + 2) << kState64RemainingShift) |
@@ -123,14 +122,13 @@ public:
* @see getState64
* @see resetToState
* @see reset
- * @draft ICU 65
+ * @stable ICU 65
*/
BytesTrie &resetToState64(uint64_t state) {
remainingMatchLength_ = static_cast<int32_t>(state >> kState64RemainingShift) - 2;
pos_ = bytes_ + (state & kState64PosMask);
return *this;
}
-#endif /* U_HIDE_DRAFT_API */
/**
* BytesTrie state object, for saving a trie's current state
@@ -253,16 +251,16 @@ public:
/**
* Determines whether all byte sequences reachable from the current state
* map to the same value.
- * @param uniqueValue Receives the unique value, if this function returns TRUE.
+ * @param uniqueValue Receives the unique value, if this function returns true.
* (output-only)
- * @return TRUE if all byte sequences reachable from the current state
+ * @return true if all byte sequences reachable from the current state
* map to the same value.
* @stable ICU 4.8
*/
inline UBool hasUniqueValue(int32_t &uniqueValue) const {
const uint8_t *pos=pos_;
// Skip the rest of a pending linear-match node.
- return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, FALSE, uniqueValue);
+ return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, false, uniqueValue);
}
/**
@@ -321,7 +319,7 @@ public:
Iterator &reset();
/**
- * @return TRUE if there are more elements.
+ * @return true if there are more elements.
* @stable ICU 4.8
*/
UBool hasNext() const;
@@ -337,7 +335,7 @@ public:
* pass the U_SUCCESS() test, or else the function returns
* immediately. Check for U_FAILURE() on output or use with
* function chaining. (See User Guide for details.)
- * @return TRUE if there is another element.
+ * @return true if there is another element.
* @stable ICU 4.8
*/
UBool next(UErrorCode &errorCode);
diff --git a/deps/icu-small/source/common/unicode/bytestriebuilder.h b/deps/icu-small/source/common/unicode/bytestriebuilder.h
index e58f18755e..eafe5a28c3 100644
--- a/deps/icu-small/source/common/unicode/bytestriebuilder.h
+++ b/deps/icu-small/source/common/unicode/bytestriebuilder.h
@@ -101,9 +101,10 @@ public:
* Multiple calls to buildStringPiece() return StringPieces referring to the
* builder's same byte array, without rebuilding.
* If buildStringPiece() is called after build(), the trie will be
- * re-serialized into a new array.
- * If build() is called after buildStringPiece(), the trie object will become
- * the owner of the previously returned array.
+ * re-serialized into a new array (because build() passes on ownership).
+ * If build() is called after buildStringPiece(), the trie object returned
+ * by build() will become the owner of the underlying string for the
+ * previously returned StringPiece.
* After clear() has been called, a new array will be used as well.
* @param buildOption Build option, see UStringTrieBuildOption.
* @param errorCode Standard ICU error code. Its input value must
@@ -139,7 +140,7 @@ private:
virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t byteIndex, int32_t count) const;
virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t byteIndex, char16_t byte) const;
- virtual UBool matchNodesCanHaveValues() const { return FALSE; }
+ virtual UBool matchNodesCanHaveValues() const { return false; }
virtual int32_t getMaxBranchLinearSubNodeLength() const { return BytesTrie::kMaxBranchLinearSubNodeLength; }
virtual int32_t getMinLinearMatch() const { return BytesTrie::kMinLinearMatch; }
diff --git a/deps/icu-small/source/common/unicode/caniter.h b/deps/icu-small/source/common/unicode/caniter.h
index 87c946c2b4..8ba4cc7daa 100644
--- a/deps/icu-small/source/common/unicode/caniter.h
+++ b/deps/icu-small/source/common/unicode/caniter.h
@@ -25,11 +25,11 @@
*/
/** Should permutation skip characters with combining class zero
- * Should be either TRUE or FALSE. This is a compile time option
+ * Should be either true or false. This is a compile time option
* @stable ICU 2.4
*/
#ifndef CANITER_SKIP_ZEROES
-#define CANITER_SKIP_ZEROES TRUE
+#define CANITER_SKIP_ZEROES true
#endif
U_NAMESPACE_BEGIN
diff --git a/deps/icu-small/source/common/unicode/chariter.h b/deps/icu-small/source/common/unicode/chariter.h
index 7e4f446bb0..f7ecd8e003 100644
--- a/deps/icu-small/source/common/unicode/chariter.h
+++ b/deps/icu-small/source/common/unicode/chariter.h
@@ -65,7 +65,7 @@ U_NAMESPACE_BEGIN
* check for the end of the iteration. When there are no more
* characters in the text object:
* <ul>
- * <li>The hasNext() function returns FALSE.</li>
+ * <li>The hasNext() function returns false.</li>
* <li>nextPostInc() and next32PostInc() return DONE
* when one attempts to read beyond the end of the text object.</li>
* </ul>
@@ -165,11 +165,11 @@ public:
virtual UChar32 next32PostInc(void) = 0;
/**
- * Returns FALSE if there are no more code units or code points
+ * Returns false if there are no more code units or code points
* at or after the current position in the iteration range.
* This is used with nextPostInc() or next32PostInc() in forward
* iteration.
- * @returns FALSE if there are no more code units or code points
+ * @returns false if there are no more code units or code points
* at or after the current position in the iteration range.
* @stable ICU 2.0
*/
@@ -535,12 +535,12 @@ public:
virtual UChar32 previous32(void) = 0;
/**
- * Returns FALSE if there are no more code units or code points
+ * Returns false if there are no more code units or code points
* before the current position in the iteration range.
* This is used with previous() or previous32() in backward
* iteration.
- * @return FALSE if there are no more code units or code points
- * before the current position in the iteration range, return TRUE otherwise.
+ * @return false if there are no more code units or code points
+ * before the current position in the iteration range, return true otherwise.
* @stable ICU 2.0
*/
virtual UBool hasPrevious() = 0;
diff --git a/deps/icu-small/source/common/unicode/docmain.h b/deps/icu-small/source/common/unicode/docmain.h
index 2b38692997..f09d7e1dc2 100644
--- a/deps/icu-small/source/common/unicode/docmain.h
+++ b/deps/icu-small/source/common/unicode/docmain.h
@@ -53,10 +53,10 @@
*
* <h2>Architecture (User's Guide)</h2>
* <ul>
- * <li><a href="http://userguide.icu-project.org/">Introduction</a></li>
- * <li><a href="http://userguide.icu-project.org/i18n">Internationalization</a></li>
- * <li><a href="http://userguide.icu-project.org/design">Locale Model, Multithreading, Error Handling, etc.</a></li>
- * <li><a href="http://userguide.icu-project.org/conversion">Conversion</a></li>
+ * <li><a href="https://unicode-org.github.io/icu/userguide/">Introduction</a></li>
+ * <li><a href="https://unicode-org.github.io/icu/userguide/i18n">Internationalization</a></li>
+ * <li><a href="https://unicode-org.github.io/icu/userguide/design">Locale Model, Multithreading, Error Handling, etc.</a></li>
+ * <li><a href="https://unicode-org.github.io/icu/userguide/conversion">Conversion</a></li>
* </ul>
*
* <hr>
@@ -149,7 +149,7 @@
* </tr>
* <tr>
* <td>Number Range Formatting<br />(includes currency and unit ranges)</td>
- * <td>(no C API)</td>
+ * <td>unumberrangeformatter.h</td>
* <td>icu::number::NumberRangeFormatter</td>
* </tr>
* <tr>
diff --git a/deps/icu-small/source/common/unicode/dtintrv.h b/deps/icu-small/source/common/unicode/dtintrv.h
index 325faa3ccb..7932ea660f 100644
--- a/deps/icu-small/source/common/unicode/dtintrv.h
+++ b/deps/icu-small/source/common/unicode/dtintrv.h
@@ -106,14 +106,14 @@ public:
/**
* Equality operator.
- * @return TRUE if the two DateIntervals are the same
+ * @return true if the two DateIntervals are the same
* @stable ICU 4.0
*/
virtual UBool operator==(const DateInterval& other) const;
/**
* Non-equality operator
- * @return TRUE if the two DateIntervals are not the same
+ * @return true if the two DateIntervals are not the same
* @stable ICU 4.0
*/
inline UBool operator!=(const DateInterval& other) const;
diff --git a/deps/icu-small/source/common/unicode/edits.h b/deps/icu-small/source/common/unicode/edits.h
index c3ceaccb3b..bfa07fa676 100644
--- a/deps/icu-small/source/common/unicode/edits.h
+++ b/deps/icu-small/source/common/unicode/edits.h
@@ -159,7 +159,7 @@ public:
* @param outErrorCode Set to an error code if it does not contain one already
* and an error occurred while recording edits.
* Otherwise unchanged.
- * @return TRUE if U_FAILURE(outErrorCode)
+ * @return true if U_FAILURE(outErrorCode)
* @stable ICU 59
*/
UBool copyErrorTo(UErrorCode &outErrorCode) const;
@@ -171,7 +171,7 @@ public:
*/
int32_t lengthDelta() const { return delta; }
/**
- * @return TRUE if there are any change edits
+ * @return true if there are any change edits
* @stable ICU 59
*/
UBool hasChanges() const { return numChanges != 0; }
@@ -207,8 +207,8 @@ public:
*/
Iterator() :
array(nullptr), index(0), length(0),
- remaining(0), onlyChanges_(FALSE), coarse(FALSE),
- dir(0), changed(FALSE), oldLength_(0), newLength_(0),
+ remaining(0), onlyChanges_(false), coarse(false),
+ dir(0), changed(false), oldLength_(0), newLength_(0),
srcIndex(0), replIndex(0), destIndex(0) {}
/**
* Copy constructor.
@@ -226,7 +226,7 @@ public:
* @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test,
* or else the function returns immediately. Check for U_FAILURE()
* on output or use with function chaining. (See User Guide for details.)
- * @return TRUE if there is another edit
+ * @return true if there is another edit
* @stable ICU 59
*/
UBool next(UErrorCode &errorCode) { return next(onlyChanges_, errorCode); }
@@ -247,11 +247,11 @@ public:
* @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test,
* or else the function returns immediately. Check for U_FAILURE()
* on output or use with function chaining. (See User Guide for details.)
- * @return TRUE if the edit for the source index was found
+ * @return true if the edit for the source index was found
* @stable ICU 59
*/
UBool findSourceIndex(int32_t i, UErrorCode &errorCode) {
- return findIndex(i, TRUE, errorCode) == 0;
+ return findIndex(i, true, errorCode) == 0;
}
/**
@@ -270,11 +270,11 @@ public:
* @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test,
* or else the function returns immediately. Check for U_FAILURE()
* on output or use with function chaining. (See User Guide for details.)
- * @return TRUE if the edit for the destination index was found
+ * @return true if the edit for the destination index was found
* @stable ICU 60
*/
UBool findDestinationIndex(int32_t i, UErrorCode &errorCode) {
- return findIndex(i, FALSE, errorCode) == 0;
+ return findIndex(i, false, errorCode) == 0;
}
/**
@@ -328,8 +328,8 @@ public:
/**
* Returns whether the edit currently represented by the iterator is a change edit.
*
- * @return TRUE if this edit replaces oldLength() units with newLength() different ones.
- * FALSE if oldLength units remain unchanged.
+ * @return true if this edit replaces oldLength() units with newLength() different ones.
+ * false if oldLength units remain unchanged.
* @stable ICU 59
*/
UBool hasChange() const { return changed; }
@@ -347,8 +347,8 @@ public:
* {@link #destinationIndex}, or in the replacement string, which starts at
* {@link #replacementIndex}.
*
- * @return the number of units in the modified string, if hasChange() is TRUE.
- * Same as oldLength if hasChange() is FALSE.
+ * @return the number of units in the modified string, if hasChange() is true.
+ * Same as oldLength if hasChange() is false.
* @stable ICU 59
*/
int32_t newLength() const { return newLength_; }
@@ -436,7 +436,7 @@ public:
* @stable ICU 59
*/
Iterator getCoarseChangesIterator() const {
- return Iterator(array, length, TRUE, TRUE);
+ return Iterator(array, length, true, true);
}
/**
@@ -448,7 +448,7 @@ public:
* @stable ICU 59
*/
Iterator getCoarseIterator() const {
- return Iterator(array, length, FALSE, TRUE);
+ return Iterator(array, length, false, true);
}
/**
@@ -460,7 +460,7 @@ public:
* @stable ICU 59
*/
Iterator getFineChangesIterator() const {
- return Iterator(array, length, TRUE, FALSE);
+ return Iterator(array, length, true, false);
}
/**
@@ -471,7 +471,7 @@ public:
* @stable ICU 59
*/
Iterator getFineIterator() const {
- return Iterator(array, length, FALSE, FALSE);
+ return Iterator(array, length, false, false);
}
/**
diff --git a/deps/icu-small/source/common/unicode/filteredbrk.h b/deps/icu-small/source/common/unicode/filteredbrk.h
index 4293676325..8b07e39ae1 100644
--- a/deps/icu-small/source/common/unicode/filteredbrk.h
+++ b/deps/icu-small/source/common/unicode/filteredbrk.h
@@ -85,8 +85,8 @@ class U_COMMON_API FilteredBreakIteratorBuilder : public UObject {
* by the iterator.
* @param string the string to suppress, such as "Mr."
* @param status error code
- * @return returns TRUE if the string was not present and now added,
- * FALSE if the call was a no-op because the string was already being suppressed.
+ * @return returns true if the string was not present and now added,
+ * false if the call was a no-op because the string was already being suppressed.
* @stable ICU 56
*/
virtual UBool suppressBreakAfter(const UnicodeString& string, UErrorCode& status) = 0;
@@ -98,8 +98,8 @@ class U_COMMON_API FilteredBreakIteratorBuilder : public UObject {
* locale data which may be suppressing certain strings.
* @param string the exception to remove
* @param status error code
- * @return returns TRUE if the string was present and now removed,
- * FALSE if the call was a no-op because the string was not being suppressed.
+ * @return returns true if the string was present and now removed,
+ * false if the call was a no-op because the string was not being suppressed.
* @stable ICU 56
*/
virtual UBool unsuppressBreakAfter(const UnicodeString& string, UErrorCode& status) = 0;
diff --git a/deps/icu-small/source/common/unicode/icudataver.h b/deps/icu-small/source/common/unicode/icudataver.h
index d5c728da88..a82cb3d89d 100644
--- a/deps/icu-small/source/common/unicode/icudataver.h
+++ b/deps/icu-small/source/common/unicode/icudataver.h
@@ -38,6 +38,6 @@
*
* @stable ICU 49
*/
-U_STABLE void U_EXPORT2 u_getDataVersion(UVersionInfo dataVersionFillin, UErrorCode *status);
+U_CAPI void U_EXPORT2 u_getDataVersion(UVersionInfo dataVersionFillin, UErrorCode *status);
#endif
diff --git a/deps/icu-small/source/common/unicode/icuplug.h b/deps/icu-small/source/common/unicode/icuplug.h
index 827cbe94b6..2bd51ff8df 100644
--- a/deps/icu-small/source/common/unicode/icuplug.h
+++ b/deps/icu-small/source/common/unicode/icuplug.h
@@ -208,7 +208,7 @@ typedef UPlugTokenReturn (U_EXPORT2 UPlugEntrypoint) (
* @param dontUnload set true if this plugin can't be unloaded
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uplug_setPlugNoUnload(UPlugData *plug, UBool dontUnload);
/**
@@ -217,7 +217,7 @@ uplug_setPlugNoUnload(UPlugData *plug, UBool dontUnload);
* @param level the level of this plugin
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uplug_setPlugLevel(UPlugData *plug, UPlugLevel level);
/**
@@ -226,7 +226,7 @@ uplug_setPlugLevel(UPlugData *plug, UPlugLevel level);
* @return the level of this plugin
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL UPlugLevel U_EXPORT2
+U_CAPI UPlugLevel U_EXPORT2
uplug_getPlugLevel(UPlugData *plug);
/**
@@ -236,7 +236,7 @@ uplug_getPlugLevel(UPlugData *plug);
* @return the lowest level of plug which can currently load
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL UPlugLevel U_EXPORT2
+U_CAPI UPlugLevel U_EXPORT2
uplug_getCurrentLevel(void);
@@ -245,7 +245,7 @@ uplug_getCurrentLevel(void);
* @return The error code of this plugin's load attempt.
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL UErrorCode U_EXPORT2
+U_CAPI UErrorCode U_EXPORT2
uplug_getPlugLoadStatus(UPlugData *plug);
/**
@@ -254,7 +254,7 @@ uplug_getPlugLoadStatus(UPlugData *plug);
* @param name the name of this plugin. The first UPLUG_NAME_MAX characters willi be copied into a new buffer.
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uplug_setPlugName(UPlugData *plug, const char *name);
/**
@@ -263,7 +263,7 @@ uplug_setPlugName(UPlugData *plug, const char *name);
* @return the name of this plugin
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
uplug_getPlugName(UPlugData *plug);
/**
@@ -272,7 +272,7 @@ uplug_getPlugName(UPlugData *plug);
* @return the symbol name, or NULL
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
uplug_getSymbolName(UPlugData *plug);
/**
@@ -282,7 +282,7 @@ uplug_getSymbolName(UPlugData *plug);
* @return the library name, or NULL
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
uplug_getLibraryName(UPlugData *plug, UErrorCode *status);
/**
@@ -292,7 +292,7 @@ uplug_getLibraryName(UPlugData *plug, UErrorCode *status);
* @return the library, or NULL
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL void * U_EXPORT2
+U_CAPI void * U_EXPORT2
uplug_getLibrary(UPlugData *plug);
/**
@@ -301,7 +301,7 @@ uplug_getLibrary(UPlugData *plug);
* @return the context, or NULL if not set
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL void * U_EXPORT2
+U_CAPI void * U_EXPORT2
uplug_getContext(UPlugData *plug);
/**
@@ -310,7 +310,7 @@ uplug_getContext(UPlugData *plug);
* @param context new context to set
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uplug_setContext(UPlugData *plug, void *context);
@@ -321,7 +321,7 @@ uplug_setContext(UPlugData *plug, void *context);
* @return configuration string, or else null.
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
uplug_getConfiguration(UPlugData *plug);
/**
@@ -339,7 +339,7 @@ uplug_getConfiguration(UPlugData *plug);
* @return the next oldest plugin, or NULL if no more.
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL UPlugData* U_EXPORT2
+U_CAPI UPlugData* U_EXPORT2
uplug_nextPlug(UPlugData *prior);
/**
@@ -354,7 +354,7 @@ uplug_nextPlug(UPlugData *prior);
* @return the new UPlugData associated with this plugin, or NULL if error.
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL UPlugData* U_EXPORT2
+U_CAPI UPlugData* U_EXPORT2
uplug_loadPlugFromEntrypoint(UPlugEntrypoint *entrypoint, const char *config, UErrorCode *status);
@@ -368,7 +368,7 @@ uplug_loadPlugFromEntrypoint(UPlugEntrypoint *entrypoint, const char *config, UE
* @return the new UPlugData associated with this plugin, or NULL if error.
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL UPlugData* U_EXPORT2
+U_CAPI UPlugData* U_EXPORT2
uplug_loadPlugFromLibrary(const char *libName, const char *sym, const char *config, UErrorCode *status);
/**
@@ -378,7 +378,7 @@ uplug_loadPlugFromLibrary(const char *libName, const char *sym, const char *conf
* @param status error result
* @internal ICU 4.4 Technology Preview
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
uplug_removePlug(UPlugData *plug, UErrorCode *status);
#endif /* U_HIDE_INTERNAL_API */
diff --git a/deps/icu-small/source/common/unicode/idna.h b/deps/icu-small/source/common/unicode/idna.h
index 6dfcfe48db..1305dc6048 100644
--- a/deps/icu-small/source/common/unicode/idna.h
+++ b/deps/icu-small/source/common/unicode/idna.h
@@ -95,7 +95,7 @@ public:
/**
* Converts a single domain name label into its ASCII form for DNS lookup.
- * If any processing step fails, then info.hasErrors() will be TRUE and
+ * If any processing step fails, then info.hasErrors() will be true and
* the result might not be an ASCII string.
* The label might be modified according to the types of errors.
* Labels with severe errors will be left in (or turned into) their Unicode form.
@@ -119,7 +119,7 @@ public:
/**
* Converts a single domain name label into its Unicode form for human-readable display.
- * If any processing step fails, then info.hasErrors() will be TRUE.
+ * If any processing step fails, then info.hasErrors() will be true.
* The label might be modified according to the types of errors.
*
* The UErrorCode indicates an error only in exceptional cases,
@@ -141,7 +141,7 @@ public:
/**
* Converts a whole domain name into its ASCII form for DNS lookup.
- * If any processing step fails, then info.hasErrors() will be TRUE and
+ * If any processing step fails, then info.hasErrors() will be true and
* the result might not be an ASCII string.
* The domain name might be modified according to the types of errors.
* Labels with severe errors will be left in (or turned into) their Unicode form.
@@ -165,7 +165,7 @@ public:
/**
* Converts a whole domain name into its Unicode form for human-readable display.
- * If any processing step fails, then info.hasErrors() will be TRUE.
+ * If any processing step fails, then info.hasErrors() will be true.
* The domain name might be modified according to the types of errors.
*
* The UErrorCode indicates an error only in exceptional cases,
@@ -273,10 +273,10 @@ public:
* Constructor for stack allocation.
* @stable ICU 4.6
*/
- IDNAInfo() : errors(0), labelErrors(0), isTransDiff(FALSE), isBiDi(FALSE), isOkBiDi(TRUE) {}
+ IDNAInfo() : errors(0), labelErrors(0), isTransDiff(false), isBiDi(false), isOkBiDi(true) {}
/**
* Were there IDNA processing errors?
- * @return TRUE if there were processing errors
+ * @return true if there were processing errors
* @stable ICU 4.6
*/
UBool hasErrors() const { return errors!=0; }
@@ -288,7 +288,7 @@ public:
*/
uint32_t getErrors() const { return errors; }
/**
- * Returns TRUE if transitional and nontransitional processing produce different results.
+ * Returns true if transitional and nontransitional processing produce different results.
* This is the case when the input label or domain name contains
* one or more deviation characters outside a Punycode label (see UTS #46).
* <ul>
@@ -297,7 +297,7 @@ public:
* <li>With transitional processing, such characters are
* mapped (sharp s/sigma) or removed (joiner/nonjoiner).
* </ul>
- * @return TRUE if transitional and nontransitional processing produce different results
+ * @return true if transitional and nontransitional processing produce different results
* @stable ICU 4.6
*/
UBool isTransitionalDifferent() const { return isTransDiff; }
@@ -310,9 +310,9 @@ private:
void reset() {
errors=labelErrors=0;
- isTransDiff=FALSE;
- isBiDi=FALSE;
- isOkBiDi=TRUE;
+ isTransDiff=false;
+ isBiDi=false;
+ isOkBiDi=true;
}
uint32_t errors, labelErrors;
diff --git a/deps/icu-small/source/common/unicode/localebuilder.h b/deps/icu-small/source/common/unicode/localebuilder.h
index c5836fe270..27a894de10 100644
--- a/deps/icu-small/source/common/unicode/localebuilder.h
+++ b/deps/icu-small/source/common/unicode/localebuilder.h
@@ -1,5 +1,5 @@
// © 2018 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
#ifndef __LOCALEBUILDER_H__
#define __LOCALEBUILDER_H__
@@ -92,11 +92,12 @@ public:
/**
* Resets the LocaleBuilder to match the provided
* [Unicode Locale Identifier](http://www.unicode.org/reports/tr35/tr35.html#unicode_locale_id) .
- * Discards the existing state. the empty string cause the builder to be
- * reset, like {@link #clear}. Grandfathered tags are converted to their
- * canonical form before being processed. Otherwise, the <code>language
- * tag</code> must be well-formed, or else the build() method will later
- * report an U_ILLEGAL_ARGUMENT_ERROR.
+ * Discards the existing state.
+ * The empty string causes the builder to be reset, like {@link #clear}.
+ * Legacy language tags (marked as “Type: grandfathered” in BCP 47)
+ * are converted to their canonical form before being processed.
+ * Otherwise, the <code>language tag</code> must be well-formed,
+ * or else the build() method will later report an U_ILLEGAL_ARGUMENT_ERROR.
*
* <p>This method clears the internal UErrorCode.
*
@@ -278,18 +279,16 @@ public:
*/
Locale build(UErrorCode& status);
-#ifndef U_HIDE_DRAFT_API
/**
* Sets the UErrorCode if an error occurred while recording sets.
* Preserves older error codes in the outErrorCode.
* @param outErrorCode Set to an error code that occurred while setting subtags.
* Unchanged if there is no such error or if outErrorCode
* already contained an error.
- * @return TRUE if U_FAILURE(outErrorCode)
- * @draft ICU 65
+ * @return true if U_FAILURE(outErrorCode)
+ * @stable ICU 65
*/
UBool copyErrorTo(UErrorCode &outErrorCode) const;
-#endif /* U_HIDE_DRAFT_API */
private:
friend class LocaleMatcher::Result;
diff --git a/deps/icu-small/source/common/unicode/localematcher.h b/deps/icu-small/source/common/unicode/localematcher.h
index 2e1a7a349f..63a68b0b7f 100644
--- a/deps/icu-small/source/common/unicode/localematcher.h
+++ b/deps/icu-small/source/common/unicode/localematcher.h
@@ -1,5 +1,5 @@
// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
// localematcher.h
// created: 2019may08 Markus W. Scherer
@@ -20,26 +20,24 @@
* \brief C++ API: Locale matcher: User's desired locales vs. application's supported locales.
*/
-#ifndef U_FORCE_HIDE_DRAFT_API
-
/**
* Builder option for whether the language subtag or the script subtag is most important.
*
- * @see Builder#setFavorSubtag(ULocMatchFavorSubtag)
- * @draft ICU 65
+ * @see LocaleMatcher::Builder#setFavorSubtag(ULocMatchFavorSubtag)
+ * @stable ICU 65
*/
enum ULocMatchFavorSubtag {
/**
* Language differences are most important, then script differences, then region differences.
* (This is the default behavior.)
*
- * @draft ICU 65
+ * @stable ICU 65
*/
ULOCMATCH_FAVOR_LANGUAGE,
/**
* Makes script differences matter relatively more than language differences.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
ULOCMATCH_FAVOR_SCRIPT
};
@@ -51,14 +49,14 @@ typedef enum ULocMatchFavorSubtag ULocMatchFavorSubtag;
* Builder option for whether all desired locales are treated equally or
* earlier ones are preferred.
*
- * @see Builder#setDemotionPerDesiredLocale(ULocMatchDemotion)
- * @draft ICU 65
+ * @see LocaleMatcher::Builder#setDemotionPerDesiredLocale(ULocMatchDemotion)
+ * @stable ICU 65
*/
enum ULocMatchDemotion {
/**
* All desired locales are treated equally.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
ULOCMATCH_DEMOTION_NONE,
/**
@@ -85,7 +83,7 @@ enum ULocMatchDemotion {
* this is possible in future versions of the data.)
* </ul>
*
- * @draft ICU 65
+ * @stable ICU 65
*/
ULOCMATCH_DEMOTION_REGION
};
@@ -93,6 +91,8 @@ enum ULocMatchDemotion {
typedef enum ULocMatchDemotion ULocMatchDemotion;
#endif
+#ifndef U_FORCE_HIDE_DRAFT_API
+
/**
* Builder option for whether to include or ignore one-way (fallback) match data.
* The LocaleMatcher uses CLDR languageMatch data which includes fallback (oneway=true) entries.
@@ -107,7 +107,7 @@ typedef enum ULocMatchDemotion ULocMatchDemotion;
* if there is a decent match for the original UI language, we want to use it,
* but not if it is merely a fallback.
*
- * @see Builder#setDirection(ULocMatchDirection)
+ * @see LocaleMatcher::Builder#setDirection(ULocMatchDirection)
* @draft ICU 67
*/
enum ULocMatchDirection {
@@ -129,6 +129,8 @@ enum ULocMatchDirection {
typedef enum ULocMatchDirection ULocMatchDirection;
#endif
+#endif // U_FORCE_HIDE_DRAFT_API
+
struct UHashtable;
U_NAMESPACE_BEGIN
@@ -181,7 +183,7 @@ class XLikelySubtags;
*
* <p>This class is not intended for public subclassing.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
class U_COMMON_API LocaleMatcher : public UMemory {
public:
@@ -189,7 +191,7 @@ public:
* Data for the best-matching pair of a desired and a supported locale.
* Movable but not copyable.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
class U_COMMON_API Result : public UMemory {
public:
@@ -198,14 +200,14 @@ public:
* This object will have the same contents that the source object had.
*
* @param src Result to move contents from.
- * @draft ICU 65
+ * @stable ICU 65
*/
Result(Result &&src) U_NOEXCEPT;
/**
* Destructor.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
~Result();
@@ -214,28 +216,27 @@ public:
* This object will have the same contents that the source object had.
*
* @param src Result to move contents from.
- * @draft ICU 65
+ * @stable ICU 65
*/
Result &operator=(Result &&src) U_NOEXCEPT;
-#ifndef U_HIDE_DRAFT_API
/**
* Returns the best-matching desired locale.
* nullptr if the list of desired locales is empty or if none matched well enough.
*
* @return the best-matching desired locale, or nullptr.
- * @draft ICU 65
+ * @stable ICU 65
*/
inline const Locale *getDesiredLocale() const { return desiredLocale; }
/**
* Returns the best-matching supported locale.
* If none matched well enough, this is the default locale.
- * The default locale is nullptr if the list of supported locales is empty and
- * no explicit default locale is set.
+ * The default locale is nullptr if Builder::setNoDefaultLocale() was called,
+ * or if the list of supported locales is empty and no explicit default locale is set.
*
* @return the best-matching supported locale, or nullptr.
- * @draft ICU 65
+ * @stable ICU 65
*/
inline const Locale *getSupportedLocale() const { return supportedLocale; }
@@ -244,7 +245,7 @@ public:
* -1 if the list of desired locales is empty or if none matched well enough.
*
* @return the index of the best-matching desired locale, or -1.
- * @draft ICU 65
+ * @stable ICU 65
*/
inline int32_t getDesiredIndex() const { return desiredIndex; }
@@ -256,7 +257,7 @@ public:
* -1 if the list of supported locales is empty or if none matched well enough.
*
* @return the index of the best-matching supported locale, or -1.
- * @draft ICU 65
+ * @stable ICU 65
*/
inline int32_t getSupportedIndex() const { return supportedIndex; }
@@ -270,10 +271,9 @@ public:
* <p>Example: desired=ar-SA-u-nu-latn, supported=ar-EG, resolved locale=ar-SA-u-nu-latn
*
* @return a locale combining the best-matching desired and supported locales.
- * @draft ICU 65
+ * @stable ICU 65
*/
Locale makeResolvedLocale(UErrorCode &errorCode) const;
-#endif // U_HIDE_DRAFT_API
private:
Result(const Locale *desired, const Locale *supported,
@@ -298,8 +298,7 @@ public:
* LocaleMatcher builder.
* Movable but not copyable.
*
- * @see LocaleMatcher#builder()
- * @draft ICU 65
+ * @stable ICU 65
*/
class U_COMMON_API Builder : public UMemory {
public:
@@ -307,7 +306,7 @@ public:
* Constructs a builder used in chaining parameters for building a LocaleMatcher.
*
* @return a new Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder() {}
@@ -316,14 +315,14 @@ public:
* This builder will have the same contents that the source builder had.
*
* @param src Builder to move contents from.
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder(Builder &&src) U_NOEXCEPT;
/**
* Destructor.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
~Builder();
@@ -332,11 +331,10 @@ public:
* This builder will have the same contents that the source builder had.
*
* @param src Builder to move contents from.
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder &operator=(Builder &&src) U_NOEXCEPT;
-#ifndef U_HIDE_DRAFT_API
/**
* Parses an Accept-Language string
* (<a href="https://tools.ietf.org/html/rfc2616#section-14.4">RFC 2616 Section 14.4</a>),
@@ -346,7 +344,7 @@ public:
*
* @param locales the Accept-Language string of locales to set
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder &setSupportedLocalesFromListString(StringPiece locales);
@@ -357,7 +355,7 @@ public:
*
* @param locales the list of locale
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder &setSupportedLocales(Locale::Iterator &locales);
@@ -372,7 +370,7 @@ public:
* @param begin Start of range.
* @param end Exclusive end of range.
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
template<typename Iter>
Builder &setSupportedLocales(Iter begin, Iter end) {
@@ -397,7 +395,7 @@ public:
* @param end Exclusive end of range.
* @param converter Converter from *begin to const Locale & or compatible.
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
template<typename Iter, typename Conv>
Builder &setSupportedLocalesViaConverter(Iter begin, Iter end, Conv converter) {
@@ -415,17 +413,31 @@ public:
*
* @param locale another locale
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder &addSupportedLocale(const Locale &locale);
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Sets no default locale.
+ * There will be no explicit or implicit default locale.
+ * If there is no good match, then the matcher will return nullptr for the
+ * best supported locale.
+ *
+ * @draft ICU 68
+ */
+ Builder &setNoDefaultLocale();
+#endif // U_HIDE_DRAFT_API
+
/**
* Sets the default locale; if nullptr, or if it is not set explicitly,
* then the first supported locale is used as the default locale.
+ * There is no default locale at all (nullptr will be returned instead)
+ * if setNoDefaultLocale() is called.
*
* @param defaultLocale the default locale (will be copied)
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder &setDefaultLocale(const Locale *defaultLocale);
@@ -437,7 +449,7 @@ public:
*
* @param subtag the subtag to favor
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder &setFavorSubtag(ULocMatchFavorSubtag subtag);
@@ -447,10 +459,11 @@ public:
*
* @param demotion the demotion per desired locale to set.
* @return this Builder object
- * @draft ICU 65
+ * @stable ICU 65
*/
Builder &setDemotionPerDesiredLocale(ULocMatchDemotion demotion);
+#ifndef U_HIDE_DRAFT_API
/**
* Option for whether to include or ignore one-way (fallback) match data.
* By default, they are included.
@@ -465,6 +478,32 @@ public:
}
return *this;
}
+#endif // U_HIDE_DRAFT_API
+
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Sets the maximum distance for an acceptable match.
+ * The matcher will return a match for a pair of locales only if
+ * they match at least as well as the pair given here.
+ *
+ * For example, setMaxDistance(en-US, en-GB) limits matches to ones where the
+ * (desired, support) locales have a distance no greater than a region subtag difference.
+ * This is much stricter than the CLDR default.
+ *
+ * The details of locale matching are subject to changes in
+ * CLDR data and in the algorithm.
+ * Specifying a maximum distance in relative terms via a sample pair of locales
+ * insulates from changes that affect all distance metrics similarly,
+ * but some changes will necessarily affect relative distances between
+ * different pairs of locales.
+ *
+ * @param desired the desired locale for distance comparison.
+ * @param supported the supported locale for distance comparison.
+ * @return this Builder object
+ * @draft ICU 68
+ */
+ Builder &setMaxDistance(const Locale &desired, const Locale &supported);
+#endif // U_HIDE_DRAFT_API
/**
* Sets the UErrorCode if an error occurred while setting parameters.
@@ -473,8 +512,8 @@ public:
* @param outErrorCode Set to an error code if it does not contain one already
* and an error occurred while setting parameters.
* Otherwise unchanged.
- * @return TRUE if U_FAILURE(outErrorCode)
- * @draft ICU 65
+ * @return true if U_FAILURE(outErrorCode)
+ * @stable ICU 65
*/
UBool copyErrorTo(UErrorCode &outErrorCode) const;
@@ -485,11 +524,10 @@ public:
* @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test,
* or else the function returns immediately. Check for U_FAILURE()
* on output or use with function chaining. (See User Guide for details.)
- * @return new LocaleMatcher.
- * @draft ICU 65
+ * @return LocaleMatcher
+ * @stable ICU 65
*/
LocaleMatcher build(UErrorCode &errorCode) const;
-#endif // U_HIDE_DRAFT_API
private:
friend class LocaleMatcher;
@@ -505,8 +543,11 @@ public:
int32_t thresholdDistance_ = -1;
ULocMatchDemotion demotion_ = ULOCMATCH_DEMOTION_REGION;
Locale *defaultLocale_ = nullptr;
+ bool withDefault_ = true;
ULocMatchFavorSubtag favor_ = ULOCMATCH_FAVOR_LANGUAGE;
ULocMatchDirection direction_ = ULOCMATCH_DIRECTION_WITH_ONE_WAY;
+ Locale *maxDistanceDesired_ = nullptr;
+ Locale *maxDistanceSupported_ = nullptr;
};
// FYI No public LocaleMatcher constructors in C++; use the Builder.
@@ -515,13 +556,13 @@ public:
* Move copy constructor; might modify the source.
* This matcher will have the same settings that the source matcher had.
* @param src source matcher
- * @draft ICU 65
+ * @stable ICU 65
*/
LocaleMatcher(LocaleMatcher &&src) U_NOEXCEPT;
/**
* Destructor.
- * @draft ICU 65
+ * @stable ICU 65
*/
~LocaleMatcher();
@@ -531,11 +572,10 @@ public:
* The behavior is undefined if *this and src are the same object.
* @param src source matcher
* @return *this
- * @draft ICU 65
+ * @stable ICU 65
*/
LocaleMatcher &operator=(LocaleMatcher &&src) U_NOEXCEPT;
-#ifndef U_HIDE_DRAFT_API
/**
* Returns the supported locale which best matches the desired locale.
*
@@ -544,7 +584,7 @@ public:
* or else the function returns immediately. Check for U_FAILURE()
* on output or use with function chaining. (See User Guide for details.)
* @return the best-matching supported locale.
- * @draft ICU 65
+ * @stable ICU 65
*/
const Locale *getBestMatch(const Locale &desiredLocale, UErrorCode &errorCode) const;
@@ -556,7 +596,7 @@ public:
* or else the function returns immediately. Check for U_FAILURE()
* on output or use with function chaining. (See User Guide for details.)
* @return the best-matching supported locale.
- * @draft ICU 65
+ * @stable ICU 65
*/
const Locale *getBestMatch(Locale::Iterator &desiredLocales, UErrorCode &errorCode) const;
@@ -572,7 +612,7 @@ public:
* or else the function returns immediately. Check for U_FAILURE()
* on output or use with function chaining. (See User Guide for details.)
* @return the best-matching supported locale.
- * @draft ICU 65
+ * @stable ICU 65
*/
const Locale *getBestMatchForListString(StringPiece desiredLocaleList, UErrorCode &errorCode) const;
@@ -586,7 +626,7 @@ public:
* or else the function returns immediately. Check for U_FAILURE()
* on output or use with function chaining. (See User Guide for details.)
* @return the best-matching pair of the desired and a supported locale.
- * @draft ICU 65
+ * @stable ICU 65
*/
Result getBestMatchResult(const Locale &desiredLocale, UErrorCode &errorCode) const;
@@ -600,9 +640,25 @@ public:
* or else the function returns immediately. Check for U_FAILURE()
* on output or use with function chaining. (See User Guide for details.)
* @return the best-matching pair of a desired and a supported locale.
- * @draft ICU 65
+ * @stable ICU 65
*/
Result getBestMatchResult(Locale::Iterator &desiredLocales, UErrorCode &errorCode) const;
+
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Returns true if the pair of locales matches acceptably.
+ * This is influenced by Builder options such as setDirection(), setFavorSubtag(),
+ * and setMaxDistance().
+ *
+ * @param desired The desired locale.
+ * @param supported The supported locale.
+ * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test,
+ * or else the function returns immediately. Check for U_FAILURE()
+ * on output or use with function chaining. (See User Guide for details.)
+ * @return true if the pair of locales matches acceptably.
+ * @draft ICU 68
+ */
+ UBool isMatch(const Locale &desired, const Locale &supported, UErrorCode &errorCode) const;
#endif // U_HIDE_DRAFT_API
#ifndef U_HIDE_INTERNAL_API
@@ -660,6 +716,5 @@ private:
U_NAMESPACE_END
-#endif // U_FORCE_HIDE_DRAFT_API
#endif // U_SHOW_CPLUSPLUS_API
#endif // __LOCALEMATCHER_H__
diff --git a/deps/icu-small/source/common/unicode/localpointer.h b/deps/icu-small/source/common/unicode/localpointer.h
index 61c3020918..2a65f2d382 100644
--- a/deps/icu-small/source/common/unicode/localpointer.h
+++ b/deps/icu-small/source/common/unicode/localpointer.h
@@ -88,13 +88,13 @@ public:
~LocalPointerBase() { /* delete ptr; */ }
/**
* NULL check.
- * @return TRUE if ==NULL
+ * @return true if ==NULL
* @stable ICU 4.4
*/
UBool isNull() const { return ptr==NULL; }
/**
* NULL check.
- * @return TRUE if !=NULL
+ * @return true if !=NULL
* @stable ICU 4.4
*/
UBool isValid() const { return ptr!=NULL; }
diff --git a/deps/icu-small/source/common/unicode/locid.h b/deps/icu-small/source/common/unicode/locid.h
index ee8697b0a5..877c8014b0 100644
--- a/deps/icu-small/source/common/unicode/locid.h
+++ b/deps/icu-small/source/common/unicode/locid.h
@@ -253,7 +253,7 @@ public:
/**
* Construct a locale from language, country, variant.
* If an error occurs, then the constructed object will be "bogus"
- * (isBogus() will return TRUE).
+ * (isBogus() will return true).
*
* @param language Lowercase two-letter or three-letter ISO-639 code.
* This parameter can instead be an ICU style C locale (e.g. "en_US"),
@@ -393,13 +393,17 @@ public:
* If the specified language tag contains any ill-formed subtags,
* the first such subtag and all following subtags are ignored.
* <p>
- * This implements the 'Language-Tag' production of BCP47, and so
- * supports grandfathered (regular and irregular) as well as private
- * use language tags. Private use tags are represented as 'x-whatever',
- * and grandfathered tags are converted to their canonical replacements
- * where they exist. Note that a few grandfathered tags have no modern
- * replacement, these will be converted using the fallback described in
+ * This implements the 'Language-Tag' production of BCP 47, and so
+ * supports legacy language tags (marked as “Type: grandfathered” in BCP 47)
+ * (regular and irregular) as well as private use language tags.
+ *
+ * Private use tags are represented as 'x-whatever',
+ * and legacy tags are converted to their canonical replacements where they exist.
+ *
+ * Note that a few legacy tags have no modern replacement;
+ * these will be converted using the fallback described in
* the first paragraph, so some information might be lost.
+ *
* @param tag the input BCP47 language tag.
* @param status error information if creating the Locale failed.
* @return the Locale for the specified BCP47 language tag.
@@ -795,14 +799,14 @@ public:
/**
* Returns whether this locale's script is written right-to-left.
* If there is no script subtag, then the likely script is used, see uloc_addLikelySubtags().
- * If no likely script is known, then FALSE is returned.
+ * If no likely script is known, then false is returned.
*
* A script is right-to-left according to the CLDR script metadata
* which corresponds to whether the script's letters have Bidi_Class=R or AL.
*
- * Returns TRUE for "ar" and "en-Hebr", FALSE for "zh" and "fa-Cyrl".
+ * Returns true for "ar" and "en-Hebr", false for "zh" and "fa-Cyrl".
*
- * @return TRUE if the locale's script is written right-to-left
+ * @return true if the locale's script is written right-to-left
* @stable ICU 54
*/
UBool isRightToLeft() const;
@@ -956,7 +960,7 @@ public:
/**
* Gets the bogus state. Locale object can be bogus if it doesn't exist
- * @return FALSE if it is a real locale, TRUE if it is a bogus locale
+ * @return false if it is a real locale, true if it is a bogus locale
* @stable ICU 2.1
*/
inline UBool isBogus(void) const;
@@ -1005,32 +1009,31 @@ public:
*/
virtual UClassID getDynamicClassID() const;
-#ifndef U_HIDE_DRAFT_API
/**
* A Locale iterator interface similar to a Java Iterator<Locale>.
- * @draft ICU 65
+ * @stable ICU 65
*/
class U_COMMON_API Iterator /* not : public UObject because this is an interface/mixin class */ {
public:
- /** @draft ICU 65 */
+ /** @stable ICU 65 */
virtual ~Iterator();
/**
- * @return TRUE if next() can be called again.
- * @draft ICU 65
+ * @return true if next() can be called again.
+ * @stable ICU 65
*/
virtual UBool hasNext() const = 0;
/**
* @return the next locale.
- * @draft ICU 65
+ * @stable ICU 65
*/
virtual const Locale &next() = 0;
};
/**
* A generic Locale iterator implementation over Locale input iterators.
- * @draft ICU 65
+ * @stable ICU 65
*/
template<typename Iter>
class RangeIterator : public Iterator, public UMemory {
@@ -1042,19 +1045,19 @@ public:
*
* @param begin Start of range.
* @param end Exclusive end of range.
- * @draft ICU 65
+ * @stable ICU 65
*/
RangeIterator(Iter begin, Iter end) : it_(begin), end_(end) {}
/**
- * @return TRUE if next() can be called again.
- * @draft ICU 65
+ * @return true if next() can be called again.
+ * @stable ICU 65
*/
UBool hasNext() const override { return it_ != end_; }
/**
* @return the next locale.
- * @draft ICU 65
+ * @stable ICU 65
*/
const Locale &next() override { return *it_++; }
@@ -1066,7 +1069,7 @@ public:
/**
* A generic Locale iterator implementation over Locale input iterators.
* Calls the converter to convert each *begin to a const Locale &.
- * @draft ICU 65
+ * @stable ICU 65
*/
template<typename Iter, typename Conv>
class ConvertingIterator : public Iterator, public UMemory {
@@ -1079,20 +1082,20 @@ public:
* @param begin Start of range.
* @param end Exclusive end of range.
* @param converter Converter from *begin to const Locale & or compatible.
- * @draft ICU 65
+ * @stable ICU 65
*/
ConvertingIterator(Iter begin, Iter end, Conv converter) :
it_(begin), end_(end), converter_(converter) {}
/**
- * @return TRUE if next() can be called again.
- * @draft ICU 65
+ * @return true if next() can be called again.
+ * @stable ICU 65
*/
UBool hasNext() const override { return it_ != end_; }
/**
* @return the next locale.
- * @draft ICU 65
+ * @stable ICU 65
*/
const Locale &next() override { return converter_(*it_++); }
@@ -1101,7 +1104,6 @@ public:
const Iter end_;
Conv converter_;
};
-#endif // U_HIDE_DRAFT_API
protected: /* only protected for testing purposes. DO NOT USE. */
#ifndef U_HIDE_INTERNAL_API
diff --git a/deps/icu-small/source/common/unicode/messagepattern.h b/deps/icu-small/source/common/unicode/messagepattern.h
index 04f00a8757..98e7b70b1f 100644
--- a/deps/icu-small/source/common/unicode/messagepattern.h
+++ b/deps/icu-small/source/common/unicode/messagepattern.h
@@ -265,7 +265,7 @@ typedef enum UMessagePatternArgType UMessagePatternArgType;
/**
* \def UMSGPAT_ARG_TYPE_HAS_PLURAL_STYLE
- * Returns TRUE if the argument type has a plural style part sequence and semantics,
+ * Returns true if the argument type has a plural style part sequence and semantics,
* for example UMSGPAT_ARG_TYPE_PLURAL and UMSGPAT_ARG_TYPE_SELECTORDINAL.
* @stable ICU 50
*/
@@ -523,14 +523,14 @@ public:
/**
* @param other another object to compare with.
- * @return TRUE if this object is equivalent to the other one.
+ * @return true if this object is equivalent to the other one.
* @stable ICU 4.8
*/
UBool operator==(const MessagePattern &other) const;
/**
* @param other another object to compare with.
- * @return FALSE if this object is equivalent to the other one.
+ * @return false if this object is equivalent to the other one.
* @stable ICU 4.8
*/
inline UBool operator!=(const MessagePattern &other) const {
@@ -564,7 +564,7 @@ public:
/**
* Does the parsed pattern have named arguments like {first_name}?
- * @return TRUE if the parsed pattern has at least one named argument.
+ * @return true if the parsed pattern has at least one named argument.
* @stable ICU 4.8
*/
UBool hasNamedArguments() const {
@@ -573,7 +573,7 @@ public:
/**
* Does the parsed pattern have numbered arguments like {2}?
- * @return TRUE if the parsed pattern has at least one numbered argument.
+ * @return true if the parsed pattern has at least one numbered argument.
* @stable ICU 4.8
*/
UBool hasNumberedArguments() const {
@@ -664,7 +664,7 @@ public:
* Compares the part's substring with the input string s.
* @param part a part of this MessagePattern.
* @param s a string.
- * @return TRUE if getSubstring(part).equals(s).
+ * @return true if getSubstring(part).equals(s).
* @stable ICU 4.8
*/
UBool partSubstringMatches(const Part &part, const UnicodeString &s) const {
@@ -785,7 +785,7 @@ public:
* Indicates whether the Part type has a numeric value.
* If so, then that numeric value can be retrieved via MessagePattern.getNumericValue().
* @param type The Part type to be tested.
- * @return TRUE if the Part type has a numeric value.
+ * @return true if the Part type has a numeric value.
* @stable ICU 4.8
*/
static UBool hasNumericValue(UMessagePatternPartType type) {
@@ -794,14 +794,14 @@ public:
/**
* @param other another object to compare with.
- * @return TRUE if this object is equivalent to the other one.
+ * @return true if this object is equivalent to the other one.
* @stable ICU 4.8
*/
UBool operator==(const Part &other) const;
/**
* @param other another object to compare with.
- * @return FALSE if this object is equivalent to the other one.
+ * @return false if this object is equivalent to the other one.
* @stable ICU 4.8
*/
inline UBool operator!=(const Part &other) const {
@@ -869,7 +869,7 @@ private:
* Parses a number from the specified message substring.
* @param start start index into the message string
* @param limit limit index into the message string, must be start<limit
- * @param allowInfinity TRUE if U+221E is allowed (for ChoiceFormat)
+ * @param allowInfinity true if U+221E is allowed (for ChoiceFormat)
* @param parseError
* @param errorCode
*/
@@ -900,13 +900,13 @@ private:
UBool isOrdinal(int32_t index);
/**
- * @return TRUE if we are inside a MessageFormat (sub-)pattern,
+ * @return true if we are inside a MessageFormat (sub-)pattern,
* as opposed to inside a top-level choice/plural/select pattern.
*/
UBool inMessageFormatPattern(int32_t nestingLevel);
/**
- * @return TRUE if we are in a MessageFormat sub-pattern
+ * @return true if we are in a MessageFormat sub-pattern
* of a top-level ChoiceFormat pattern.
*/
UBool inTopLevelChoiceMessage(int32_t nestingLevel, UMessagePatternArgType parentType);
diff --git a/deps/icu-small/source/common/unicode/normalizer2.h b/deps/icu-small/source/common/unicode/normalizer2.h
index 4aeb3bb3d8..5eb1d95caf 100644
--- a/deps/icu-small/source/common/unicode/normalizer2.h
+++ b/deps/icu-small/source/common/unicode/normalizer2.h
@@ -290,13 +290,13 @@ public:
* Gets the decomposition mapping of c.
* Roughly equivalent to normalizing the String form of c
* on a UNORM2_DECOMPOSE Normalizer2 instance, but much faster, and except that this function
- * returns FALSE and does not write a string
+ * returns false and does not write a string
* if c does not have a decomposition mapping in this instance's data.
* This function is independent of the mode of the Normalizer2.
* @param c code point
* @param decomposition String object which will be set to c's
* decomposition mapping, if there is one.
- * @return TRUE if c has a decomposition, otherwise FALSE
+ * @return true if c has a decomposition, otherwise false
* @stable ICU 4.6
*/
virtual UBool
@@ -319,11 +319,11 @@ public:
* in this case, the result contains either one or two code points (=1..4 char16_ts).
*
* This function is independent of the mode of the Normalizer2.
- * The default implementation returns FALSE.
+ * The default implementation returns false.
* @param c code point
* @param decomposition String object which will be set to c's
* raw decomposition mapping, if there is one.
- * @return TRUE if c has a decomposition, otherwise FALSE
+ * @return true if c has a decomposition, otherwise false
* @stable ICU 49
*/
virtual UBool
@@ -369,7 +369,7 @@ public:
* pass the U_SUCCESS() test, or else the function returns
* immediately. Check for U_FAILURE() on output or use with
* function chaining. (See User Guide for details.)
- * @return TRUE if s is normalized
+ * @return true if s is normalized
* @stable ICU 4.4
*/
virtual UBool
@@ -392,7 +392,7 @@ public:
* pass the U_SUCCESS() test, or else the function returns
* immediately. Check for U_FAILURE() on output or use with
* function chaining. (See User Guide for details.)
- * @return TRUE if s is normalized
+ * @return true if s is normalized
* @stable ICU 60
*/
virtual UBool
@@ -452,7 +452,7 @@ public:
* character independently.
* This is used for iterative normalization. See the class documentation for details.
* @param c character to test
- * @return TRUE if c has a normalization boundary before it
+ * @return true if c has a normalization boundary before it
* @stable ICU 4.4
*/
virtual UBool hasBoundaryBefore(UChar32 c) const = 0;
@@ -468,7 +468,7 @@ public:
* This is used for iterative normalization. See the class documentation for details.
* Note that this operation may be significantly slower than hasBoundaryBefore().
* @param c character to test
- * @return TRUE if c has a normalization boundary after it
+ * @return true if c has a normalization boundary after it
* @stable ICU 4.4
*/
virtual UBool hasBoundaryAfter(UChar32 c) const = 0;
@@ -483,7 +483,7 @@ public:
* This is used for iterative normalization. See the class documentation for details.
* Note that this operation may be significantly slower than hasBoundaryBefore().
* @param c character to test
- * @return TRUE if c is normalization-inert
+ * @return true if c is normalization-inert
* @stable ICU 4.4
*/
virtual UBool isInert(UChar32 c) const = 0;
@@ -612,7 +612,7 @@ public:
* @param c code point
* @param decomposition String object which will be set to c's
* decomposition mapping, if there is one.
- * @return TRUE if c has a decomposition, otherwise FALSE
+ * @return true if c has a decomposition, otherwise false
* @stable ICU 4.6
*/
virtual UBool
@@ -626,7 +626,7 @@ public:
* @param c code point
* @param decomposition String object which will be set to c's
* raw decomposition mapping, if there is one.
- * @return TRUE if c has a decomposition, otherwise FALSE
+ * @return true if c has a decomposition, otherwise false
* @stable ICU 49
*/
virtual UBool
@@ -664,7 +664,7 @@ public:
* pass the U_SUCCESS() test, or else the function returns
* immediately. Check for U_FAILURE() on output or use with
* function chaining. (See User Guide for details.)
- * @return TRUE if s is normalized
+ * @return true if s is normalized
* @stable ICU 4.4
*/
virtual UBool
@@ -687,7 +687,7 @@ public:
* pass the U_SUCCESS() test, or else the function returns
* immediately. Check for U_FAILURE() on output or use with
* function chaining. (See User Guide for details.)
- * @return TRUE if s is normalized
+ * @return true if s is normalized
* @stable ICU 60
*/
virtual UBool
@@ -724,7 +724,7 @@ public:
* regardless of context.
* For details see the Normalizer2 base class documentation.
* @param c character to test
- * @return TRUE if c has a normalization boundary before it
+ * @return true if c has a normalization boundary before it
* @stable ICU 4.4
*/
virtual UBool hasBoundaryBefore(UChar32 c) const U_OVERRIDE;
@@ -734,7 +734,7 @@ public:
* regardless of context.
* For details see the Normalizer2 base class documentation.
* @param c character to test
- * @return TRUE if c has a normalization boundary after it
+ * @return true if c has a normalization boundary after it
* @stable ICU 4.4
*/
virtual UBool hasBoundaryAfter(UChar32 c) const U_OVERRIDE;
@@ -743,7 +743,7 @@ public:
* Tests if the character is normalization-inert.
* For details see the Normalizer2 base class documentation.
* @param c character to test
- * @return TRUE if c is normalization-inert
+ * @return true if c is normalization-inert
* @stable ICU 4.4
*/
virtual UBool isInert(UChar32 c) const U_OVERRIDE;
diff --git a/deps/icu-small/source/common/unicode/normlzr.h b/deps/icu-small/source/common/unicode/normlzr.h
index 00dd820474..83dc7cea01 100644
--- a/deps/icu-small/source/common/unicode/normlzr.h
+++ b/deps/icu-small/source/common/unicode/normlzr.h
@@ -234,7 +234,7 @@ public:
*
* @param source the string to be composed.
* @param compat Perform compatibility decomposition before composition.
- * If this argument is <code>FALSE</code>, only canonical
+ * If this argument is <code>false</code>, only canonical
* decomposition will be performed.
* @param options the optional features to be enabled (0 for no options)
* @param result The composed string (on output).
@@ -256,7 +256,7 @@ public:
*
* @param source the string to be decomposed.
* @param compat Perform compatibility decomposition.
- * If this argument is <code>FALSE</code>, only canonical
+ * If this argument is <code>false</code>, only canonical
* decomposition will be performed.
* @param options the optional features to be enabled (0 for no options)
* @param result The decomposed string (on output).
@@ -315,7 +315,7 @@ public:
* never a "maybe".
* For NFD, NFKD, and FCD, both functions work exactly the same.
* For NFC and NFKC where quickCheck may return "maybe", this function will
- * perform further tests to arrive at a TRUE/FALSE result.
+ * perform further tests to arrive at a true/false result.
*
* @param src String that is to be tested if it is in a normalization format.
* @param mode Which normalization form to test for.
@@ -577,7 +577,7 @@ public:
int32_t endIndex(void) const;
/**
- * Returns TRUE when both iterators refer to the same character in the same
+ * Returns true when both iterators refer to the same character in the same
* input text.
*
* @param that a Normalizer object to compare this one to
@@ -587,7 +587,7 @@ public:
UBool operator==(const Normalizer& that) const;
/**
- * Returns FALSE when both iterators refer to the same character in the same
+ * Returns false when both iterators refer to the same character in the same
* input text.
*
* @param that a Normalizer object to compare this one to
@@ -655,8 +655,8 @@ public:
* It is possible to specify multiple options that are all turned on or off.
*
* @param option the option(s) whose value is/are to be set.
- * @param value the new setting for the option. Use <code>TRUE</code> to
- * turn the option(s) on and <code>FALSE</code> to turn it/them off.
+ * @param value the new setting for the option. Use <code>true</code> to
+ * turn the option(s) on and <code>false</code> to turn it/them off.
*
* @see #getOption
* @deprecated ICU 56 Use Normalizer2 instead.
@@ -666,11 +666,11 @@ public:
/**
* Determine whether an option is turned on or off.
- * If multiple options are specified, then the result is TRUE if any
+ * If multiple options are specified, then the result is true if any
* of them are set.
* <p>
* @param option the option(s) that are to be checked
- * @return TRUE if any of the option(s) are set
+ * @return true if any of the option(s) are set
* @see #setOption
* @deprecated ICU 56 Use Normalizer2 instead.
*/
diff --git a/deps/icu-small/source/common/unicode/parsepos.h b/deps/icu-small/source/common/unicode/parsepos.h
index ae5754b8d7..d6129fd4f1 100644
--- a/deps/icu-small/source/common/unicode/parsepos.h
+++ b/deps/icu-small/source/common/unicode/parsepos.h
@@ -97,14 +97,14 @@ public:
/**
* Equality operator.
- * @return TRUE if the two parse positions are equal, FALSE otherwise.
+ * @return true if the two parse positions are equal, false otherwise.
* @stable ICU 2.0
*/
inline UBool operator==(const ParsePosition& that) const;
/**
* Equality operator.
- * @return TRUE if the two parse positions are not equal, FALSE otherwise.
+ * @return true if the two parse positions are not equal, false otherwise.
* @stable ICU 2.0
*/
inline UBool operator!=(const ParsePosition& that) const;
@@ -196,9 +196,9 @@ inline UBool
ParsePosition::operator==(const ParsePosition& copy) const
{
if(index != copy.index || errorIndex != copy.errorIndex)
- return FALSE;
+ return false;
else
- return TRUE;
+ return true;
}
inline UBool
diff --git a/deps/icu-small/source/common/unicode/putil.h b/deps/icu-small/source/common/unicode/putil.h
index 14bb99ccc5..f8c510dacc 100644
--- a/deps/icu-small/source/common/unicode/putil.h
+++ b/deps/icu-small/source/common/unicode/putil.h
@@ -66,7 +66,7 @@
*
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2 u_getDataDirectory(void);
+U_CAPI const char* U_EXPORT2 u_getDataDirectory(void);
/**
@@ -88,7 +88,7 @@ U_STABLE const char* U_EXPORT2 u_getDataDirectory(void);
* @see u_init
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory);
+U_CAPI void U_EXPORT2 u_setDataDirectory(const char *directory);
#ifndef U_HIDE_INTERNAL_API
/**
@@ -99,7 +99,7 @@ U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory);
* @return the time zone data override directory.
* @internal
*/
-U_INTERNAL const char * U_EXPORT2 u_getTimeZoneFilesDirectory(UErrorCode *status);
+U_CAPI const char * U_EXPORT2 u_getTimeZoneFilesDirectory(UErrorCode *status);
/**
* Set the time zone files override directory.
@@ -109,7 +109,7 @@ U_INTERNAL const char * U_EXPORT2 u_getTimeZoneFilesDirectory(UErrorCode *status
* will access the time zone data.
* @internal
*/
-U_INTERNAL void U_EXPORT2 u_setTimeZoneFilesDirectory(const char *path, UErrorCode *status);
+U_CAPI void U_EXPORT2 u_setTimeZoneFilesDirectory(const char *path, UErrorCode *status);
#endif /* U_HIDE_INTERNAL_API */
@@ -155,7 +155,7 @@ U_INTERNAL void U_EXPORT2 u_setTimeZoneFilesDirectory(const char *path, UErrorCo
* @see U_CHARSET_FAMILY
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_charsToUChars(const char *cs, UChar *us, int32_t length);
/**
@@ -177,7 +177,7 @@ u_charsToUChars(const char *cs, UChar *us, int32_t length);
* @see U_CHARSET_FAMILY
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_UCharsToChars(const UChar *us, char *cs, int32_t length);
#endif
diff --git a/deps/icu-small/source/common/unicode/rbbi.h b/deps/icu-small/source/common/unicode/rbbi.h
index 7825f603a5..65117f616c 100644
--- a/deps/icu-small/source/common/unicode/rbbi.h
+++ b/deps/icu-small/source/common/unicode/rbbi.h
@@ -32,6 +32,8 @@
#include "unicode/parseerr.h"
#include "unicode/schriter.h"
+struct UCPTrie;
+
U_NAMESPACE_BEGIN
/** @internal */
@@ -140,6 +142,11 @@ private:
*/
UBool fDone;
+ /**
+ * Array of look-ahead tentative results.
+ */
+ int32_t *fLookAheadMatches;
+
//=======================================================================
// constructors
//=======================================================================
@@ -246,20 +253,20 @@ public:
RuleBasedBreakIterator& operator=(const RuleBasedBreakIterator& that);
/**
- * Equality operator. Returns TRUE if both BreakIterators are of the
+ * Equality operator. Returns true if both BreakIterators are of the
* same class, have the same behavior, and iterate over the same text.
* @param that The BreakIterator to be compared for equality
- * @return TRUE if both BreakIterators are of the
+ * @return true if both BreakIterators are of the
* same class, have the same behavior, and iterate over the same text.
* @stable ICU 2.0
*/
virtual UBool operator==(const BreakIterator& that) const;
/**
- * Not-equal operator. If operator== returns TRUE, this returns FALSE,
+ * Not-equal operator. If operator== returns true, this returns false,
* and vice versa.
* @param that The BreakIterator to be compared for inequality
- * @return TRUE if both BreakIterators are not same.
+ * @return true if both BreakIterators are not same.
* @stable ICU 2.0
*/
inline UBool operator!=(const BreakIterator& that) const;
@@ -659,6 +666,28 @@ private:
*/
int32_t handleNext();
+ /*
+ * Templatized version of handleNext() and handleSafePrevious().
+ *
+ * There will be exactly four instantiations, two each for 8 and 16 bit tables,
+ * two each for 8 and 16 bit trie.
+ * Having separate instantiations for the table types keeps conditional tests of
+ * the table type out of the inner loops, at the expense of replicated code.
+ *
+ * The template parameter for the Trie access function is a value, not a type.
+ * Doing it this way, the compiler will inline the Trie function in the
+ * expanded functions. (Both the 8 and 16 bit access functions have the same type
+ * signature)
+ */
+
+ typedef uint16_t (*PTrieFunc)(const UCPTrie *, UChar32);
+
+ template<typename RowType, PTrieFunc trieFunc>
+ int32_t handleSafePrevious(int32_t fromPosition);
+
+ template<typename RowType, PTrieFunc trieFunc>
+ int32_t handleNext();
+
/**
* This function returns the appropriate LanguageBreakEngine for a
@@ -681,7 +710,6 @@ private:
* @internal
*/
void dumpTables();
-
#endif /* U_HIDE_INTERNAL_API */
};
diff --git a/deps/icu-small/source/common/unicode/resbund.h b/deps/icu-small/source/common/unicode/resbund.h
index 708a3423d2..63ffa506e7 100644
--- a/deps/icu-small/source/common/unicode/resbund.h
+++ b/deps/icu-small/source/common/unicode/resbund.h
@@ -286,7 +286,7 @@ public:
/**
* Checks whether the resource has another element to iterate over.
*
- * @return TRUE if there are more elements, FALSE if there is no more elements
+ * @return true if there are more elements, false if there is no more elements
* @stable ICU 2.0
*/
UBool
diff --git a/deps/icu-small/source/common/unicode/simpleformatter.h b/deps/icu-small/source/common/unicode/simpleformatter.h
index 9414bca308..6d9c04ace2 100644
--- a/deps/icu-small/source/common/unicode/simpleformatter.h
+++ b/deps/icu-small/source/common/unicode/simpleformatter.h
@@ -125,7 +125,7 @@ public:
* @param errorCode ICU error code in/out parameter.
* Must fulfill U_SUCCESS before the function call.
* Set to U_ILLEGAL_ARGUMENT_ERROR for bad argument syntax.
- * @return TRUE if U_SUCCESS(errorCode).
+ * @return true if U_SUCCESS(errorCode).
* @stable ICU 57
*/
UBool applyPattern(const UnicodeString &pattern, UErrorCode &errorCode) {
@@ -144,7 +144,7 @@ public:
* Must fulfill U_SUCCESS before the function call.
* Set to U_ILLEGAL_ARGUMENT_ERROR for bad argument syntax and
* too few or too many arguments.
- * @return TRUE if U_SUCCESS(errorCode).
+ * @return true if U_SUCCESS(errorCode).
* @stable ICU 57
*/
UBool applyPatternMinMaxArguments(const UnicodeString &pattern,
diff --git a/deps/icu-small/source/common/unicode/strenum.h b/deps/icu-small/source/common/unicode/strenum.h
index e813cd84b3..5d1600156e 100644
--- a/deps/icu-small/source/common/unicode/strenum.h
+++ b/deps/icu-small/source/common/unicode/strenum.h
@@ -196,7 +196,7 @@ public:
* Compares this enumeration to other to check if both are equal
*
* @param that The other string enumeration to compare this object to
- * @return TRUE if the enumerations are equal. FALSE if not.
+ * @return true if the enumerations are equal. false if not.
* @stable ICU 3.6
*/
virtual UBool operator==(const StringEnumeration& that)const;
@@ -204,7 +204,7 @@ public:
* Compares this enumeration to other to check if both are not equal
*
* @param that The other string enumeration to compare this object to
- * @return TRUE if the enumerations are equal. FALSE if not.
+ * @return true if the enumerations are equal. false if not.
* @stable ICU 3.6
*/
virtual UBool operator!=(const StringEnumeration& that)const;
diff --git a/deps/icu-small/source/common/unicode/stringpiece.h b/deps/icu-small/source/common/unicode/stringpiece.h
index 19fbe2e22e..58053cfd5c 100644
--- a/deps/icu-small/source/common/unicode/stringpiece.h
+++ b/deps/icu-small/source/common/unicode/stringpiece.h
@@ -111,7 +111,6 @@ class U_COMMON_API StringPiece : public UMemory {
#endif
#endif // U_HIDE_DRAFT_API
-#ifndef U_HIDE_DRAFT_API
/**
* Constructs from some other implementation of a string piece class, from any
* C++ record type that has these two methods:
@@ -132,7 +131,7 @@ class U_COMMON_API StringPiece : public UMemory {
* as from std::u8string_view.
*
* @param str the other string piece
- * @draft ICU 65
+ * @stable ICU 65
*/
template <typename T,
typename = typename std::enable_if<
@@ -145,7 +144,6 @@ class U_COMMON_API StringPiece : public UMemory {
StringPiece(T str)
: ptr_(reinterpret_cast<const char*>(str.data())),
length_(static_cast<int32_t>(str.size())) {}
-#endif // U_HIDE_DRAFT_API
/**
* Constructs from a const char * pointer and a specified length.
@@ -209,7 +207,7 @@ class U_COMMON_API StringPiece : public UMemory {
int32_t length() const { return length_; }
/**
* Returns whether the string is empty.
- * @return TRUE if the string is empty
+ * @return true if the string is empty
* @stable ICU 4.2
*/
UBool empty() const { return length_ == 0; }
@@ -331,7 +329,7 @@ class U_COMMON_API StringPiece : public UMemory {
* Global operator == for StringPiece
* @param x The first StringPiece to compare.
* @param y The second StringPiece to compare.
- * @return TRUE if the string data is equal
+ * @return true if the string data is equal
* @stable ICU 4.8
*/
U_EXPORT UBool U_EXPORT2
@@ -341,7 +339,7 @@ operator==(const StringPiece& x, const StringPiece& y);
* Global operator != for StringPiece
* @param x The first StringPiece to compare.
* @param y The second StringPiece to compare.
- * @return TRUE if the string data is not equal
+ * @return true if the string data is not equal
* @stable ICU 4.8
*/
inline UBool operator!=(const StringPiece& x, const StringPiece& y) {
diff --git a/deps/icu-small/source/common/unicode/stringtriebuilder.h b/deps/icu-small/source/common/unicode/stringtriebuilder.h
index 2860cbf551..efd2d49206 100644
--- a/deps/icu-small/source/common/unicode/stringtriebuilder.h
+++ b/deps/icu-small/source/common/unicode/stringtriebuilder.h
@@ -279,10 +279,10 @@ protected:
*/
class ValueNode : public Node {
public:
- ValueNode(int32_t initialHash) : Node(initialHash), hasValue(FALSE), value(0) {}
+ ValueNode(int32_t initialHash) : Node(initialHash), hasValue(false), value(0) {}
virtual UBool operator==(const Node &other) const;
void setValue(int32_t v) {
- hasValue=TRUE;
+ hasValue=true;
value=v;
hash=hash*37u+v;
}
diff --git a/deps/icu-small/source/common/unicode/ubidi.h b/deps/icu-small/source/common/unicode/ubidi.h
index f4875c8801..63d0e45cb7 100644
--- a/deps/icu-small/source/common/unicode/ubidi.h
+++ b/deps/icu-small/source/common/unicode/ubidi.h
@@ -21,7 +21,10 @@
#include "unicode/utypes.h"
#include "unicode/uchar.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
*\file
@@ -496,7 +499,7 @@ typedef struct UBiDi UBiDi;
* @return An empty <code>UBiDi</code> object.
* @stable ICU 2.0
*/
-U_STABLE UBiDi * U_EXPORT2
+U_CAPI UBiDi * U_EXPORT2
ubidi_open(void);
/**
@@ -533,7 +536,7 @@ ubidi_open(void);
* @return An empty <code>UBiDi</code> object with preallocated memory.
* @stable ICU 2.0
*/
-U_STABLE UBiDi * U_EXPORT2
+U_CAPI UBiDi * U_EXPORT2
ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode);
/**
@@ -556,7 +559,7 @@ ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode);
* @see ubidi_setLine
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_close(UBiDi *pBiDi);
#if U_SHOW_CPLUSPLUS_API
@@ -594,7 +597,7 @@ U_NAMESPACE_END
* this "inverse Bidi" and that the current implementation provides only an
* approximation of "inverse Bidi".</p>
*
- * <p>With <code>isInverse</code> set to <code>TRUE</code>,
+ * <p>With <code>isInverse</code> set to <code>true</code>,
* this function changes the behavior of some of the subsequent functions
* in a way that they can be used for the inverse Bidi algorithm.
* Specifically, runs of text with numeric characters will be treated in a
@@ -607,12 +610,12 @@ U_NAMESPACE_END
* the runs of the logically ordered output.</p>
*
* <p>Calling this function with argument <code>isInverse</code> set to
- * <code>TRUE</code> is equivalent to calling
+ * <code>true</code> is equivalent to calling
* <code>ubidi_setReorderingMode</code> with argument
* <code>reorderingMode</code>
* set to <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>.<br>
* Calling this function with argument <code>isInverse</code> set to
- * <code>FALSE</code> is equivalent to calling
+ * <code>false</code> is equivalent to calling
* <code>ubidi_setReorderingMode</code> with argument
* <code>reorderingMode</code>
* set to <code>#UBIDI_REORDER_DEFAULT</code>.
@@ -626,18 +629,18 @@ U_NAMESPACE_END
* @see ubidi_setReorderingMode
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_setInverse(UBiDi *pBiDi, UBool isInverse);
/**
* Is this Bidi object set to perform the inverse Bidi algorithm?
* <p>Note: calling this function after setting the reordering mode with
- * <code>ubidi_setReorderingMode</code> will return <code>TRUE</code> if the
+ * <code>ubidi_setReorderingMode</code> will return <code>true</code> if the
* reordering mode was set to <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>,
- * <code>FALSE</code> for all other values.</p>
+ * <code>false</code> for all other values.</p>
*
* @param pBiDi is a <code>UBiDi</code> object.
- * @return TRUE if the Bidi object is set to perform the inverse Bidi algorithm
+ * @return true if the Bidi object is set to perform the inverse Bidi algorithm
* by handling numbers as L.
*
* @see ubidi_setInverse
@@ -645,7 +648,7 @@ ubidi_setInverse(UBiDi *pBiDi, UBool isInverse);
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ubidi_isInverse(UBiDi *pBiDi);
/**
@@ -668,7 +671,7 @@ ubidi_isInverse(UBiDi *pBiDi);
* @see ubidi_setPara
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR);
/**
@@ -676,13 +679,13 @@ ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR);
* successive paragraphs progress from left to right?
*
* @param pBiDi is a <code>UBiDi</code> object.
- * @return TRUE if the Bidi object is set to allocate level 0 to block
+ * @return true if the Bidi object is set to allocate level 0 to block
* separators.
*
* @see ubidi_orderParagraphsLTR
* @stable ICU 3.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ubidi_isOrderParagraphsLTR(UBiDi *pBiDi);
/**
@@ -714,7 +717,7 @@ typedef enum UBiDiReorderingMode {
* @stable ICU 3.6 */
UBIDI_REORDER_RUNS_ONLY,
/** Visual to Logical algorithm which handles numbers like L
- * (same algorithm as selected by <code>ubidi_setInverse(TRUE)</code>.
+ * (same algorithm as selected by <code>ubidi_setInverse(true)</code>.
* @see ubidi_setInverse
* @stable ICU 3.6 */
UBIDI_REORDER_INVERSE_NUMBERS_AS_L,
@@ -833,7 +836,7 @@ typedef enum UBiDiReorderingMode {
* reordered sequence (the option <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code> can
* be used with function <code>ubidi_writeReordered</code> to this end. This
* mode is equivalent to calling <code>ubidi_setInverse()</code> with
- * argument <code>isInverse</code> set to <code>TRUE</code>.</li>
+ * argument <code>isInverse</code> set to <code>true</code>.</li>
*
* <li>When the reordering mode is set to
* <code>#UBIDI_REORDER_INVERSE_LIKE_DIRECT</code>, the "direct" Logical to Visual
@@ -886,7 +889,7 @@ typedef enum UBiDiReorderingMode {
* @see ubidi_writeReordered
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_setReorderingMode(UBiDi *pBiDi, UBiDiReorderingMode reorderingMode);
/**
@@ -897,7 +900,7 @@ ubidi_setReorderingMode(UBiDi *pBiDi, UBiDiReorderingMode reorderingMode);
* @see ubidi_setReorderingMode
* @stable ICU 3.6
*/
-U_STABLE UBiDiReorderingMode U_EXPORT2
+U_CAPI UBiDiReorderingMode U_EXPORT2
ubidi_getReorderingMode(UBiDi *pBiDi);
/**
@@ -935,7 +938,7 @@ typedef enum UBiDiReorderingOption {
*
* <p>If this option is set in conjunction with reordering mode
* <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code> or with calling
- * <code>ubidi_setInverse(TRUE)</code>, it implies
+ * <code>ubidi_setInverse(true)</code>, it implies
* option <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code>
* in calls to function <code>ubidi_writeReordered()</code>.</p>
*
@@ -1016,7 +1019,7 @@ typedef enum UBiDiReorderingOption {
*
* <p>When the <code>UBIDI_OPTION_STREAMING</code> option is used,
* it is recommended to call <code>ubidi_orderParagraphsLTR()</code> with
- * argument <code>orderParagraphsLTR</code> set to <code>TRUE</code> before
+ * argument <code>orderParagraphsLTR</code> set to <code>true</code> before
* calling <code>ubidi_setPara</code> so that later paragraphs may be
* concatenated to previous paragraphs on the right.</p>
*
@@ -1042,7 +1045,7 @@ typedef enum UBiDiReorderingOption {
* @see ubidi_getReorderingOptions
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions);
/**
@@ -1053,7 +1056,7 @@ ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions);
* @see ubidi_setReorderingOptions
* @stable ICU 3.6
*/
-U_STABLE uint32_t U_EXPORT2
+U_CAPI uint32_t U_EXPORT2
ubidi_getReorderingOptions(UBiDi *pBiDi);
/**
@@ -1140,7 +1143,7 @@ ubidi_getReorderingOptions(UBiDi *pBiDi);
* @see ubidi_setPara
* @stable ICU 4.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_setContext(UBiDi *pBiDi,
const UChar *prologue, int32_t proLength,
const UChar *epilogue, int32_t epiLength,
@@ -1228,7 +1231,7 @@ ubidi_setContext(UBiDi *pBiDi,
* @param pErrorCode must be a valid pointer to an error code value.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels,
UErrorCode *pErrorCode);
@@ -1279,7 +1282,7 @@ ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
* @see ubidi_getProcessedLength
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_setLine(const UBiDi *pParaBiDi,
int32_t start, int32_t limit,
UBiDi *pLineBiDi,
@@ -1300,7 +1303,7 @@ ubidi_setLine(const UBiDi *pParaBiDi,
* @see UBiDiDirection
* @stable ICU 2.0
*/
-U_STABLE UBiDiDirection U_EXPORT2
+U_CAPI UBiDiDirection U_EXPORT2
ubidi_getDirection(const UBiDi *pBiDi);
/**
@@ -1330,7 +1333,7 @@ ubidi_getDirection(const UBiDi *pBiDi);
* @see UBiDiDirection
* @stable ICU 4.6
*/
-U_STABLE UBiDiDirection U_EXPORT2
+U_CAPI UBiDiDirection U_EXPORT2
ubidi_getBaseDirection(const UChar *text, int32_t length );
/**
@@ -1344,7 +1347,7 @@ ubidi_getBaseDirection(const UChar *text, int32_t length );
* @see ubidi_setLine
* @stable ICU 2.0
*/
-U_STABLE const UChar * U_EXPORT2
+U_CAPI const UChar * U_EXPORT2
ubidi_getText(const UBiDi *pBiDi);
/**
@@ -1355,7 +1358,7 @@ ubidi_getText(const UBiDi *pBiDi);
* @return The length of the text that the UBiDi object was created for.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_getLength(const UBiDi *pBiDi);
/**
@@ -1373,7 +1376,7 @@ ubidi_getLength(const UBiDi *pBiDi);
* @see ubidi_getParagraphByIndex
* @stable ICU 2.0
*/
-U_STABLE UBiDiLevel U_EXPORT2
+U_CAPI UBiDiLevel U_EXPORT2
ubidi_getParaLevel(const UBiDi *pBiDi);
/**
@@ -1384,7 +1387,7 @@ ubidi_getParaLevel(const UBiDi *pBiDi);
* @return The number of paragraphs.
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_countParagraphs(UBiDi *pBiDi);
/**
@@ -1421,7 +1424,7 @@ ubidi_countParagraphs(UBiDi *pBiDi);
* @see ubidi_getProcessedLength
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,
int32_t *pParaLimit, UBiDiLevel *pParaLevel,
UErrorCode *pErrorCode);
@@ -1453,7 +1456,7 @@ ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,
*
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,
int32_t *pParaStart, int32_t *pParaLimit,
UBiDiLevel *pParaLevel, UErrorCode *pErrorCode);
@@ -1473,7 +1476,7 @@ ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,
* @see ubidi_getProcessedLength
* @stable ICU 2.0
*/
-U_STABLE UBiDiLevel U_EXPORT2
+U_CAPI UBiDiLevel U_EXPORT2
ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex);
/**
@@ -1494,7 +1497,7 @@ ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex);
* @see ubidi_getProcessedLength
* @stable ICU 2.0
*/
-U_STABLE const UBiDiLevel * U_EXPORT2
+U_CAPI const UBiDiLevel * U_EXPORT2
ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode);
/**
@@ -1521,7 +1524,7 @@ ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode);
* @see ubidi_getProcessedLength
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,
int32_t *pLogicalLimit, UBiDiLevel *pLevel);
@@ -1540,7 +1543,7 @@ ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,
* @return The number of runs.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
/**
@@ -1599,7 +1602,7 @@ ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
* to avoid these issues.
* @stable ICU 2.0
*/
-U_STABLE UBiDiDirection U_EXPORT2
+U_CAPI UBiDiDirection U_EXPORT2
ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
int32_t *pLogicalStart, int32_t *pLength);
@@ -1640,7 +1643,7 @@ ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
* @see ubidi_getProcessedLength
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode);
/**
@@ -1675,7 +1678,7 @@ ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode)
* @see ubidi_getResultLength
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode);
/**
@@ -1718,7 +1721,7 @@ ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode)
* @see ubidi_getResultLength
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
/**
@@ -1754,7 +1757,7 @@ ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
* @see ubidi_getResultLength
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
/**
@@ -1777,7 +1780,7 @@ ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
* The index map will result in <code>indexMap[logicalIndex]==visualIndex</code>.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
/**
@@ -1800,7 +1803,7 @@ ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap
* The index map will result in <code>indexMap[visualIndex]==logicalIndex</code>.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
/**
@@ -1835,7 +1838,7 @@ ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap)
* @see UBIDI_MAP_NOWHERE
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length);
/** option flags for ubidi_writeReordered() */
@@ -1940,7 +1943,7 @@ ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length);
* @see UBIDI_OPTION_STREAMING
* @stable ICU 3.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_getProcessedLength(const UBiDi *pBiDi);
/**
@@ -1970,7 +1973,7 @@ ubidi_getProcessedLength(const UBiDi *pBiDi);
* @see UBIDI_OPTION_REMOVE_CONTROLS
* @stable ICU 3.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_getResultLength(const UBiDi *pBiDi);
U_CDECL_BEGIN
@@ -2028,7 +2031,7 @@ U_CDECL_END
* @see UBiDiClassCallback
* @stable ICU 3.6
*/
-U_STABLE UCharDirection U_EXPORT2
+U_CAPI UCharDirection U_EXPORT2
ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c);
/**
@@ -2058,7 +2061,7 @@ ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c);
* @see ubidi_getClassCallback
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_setClassCallback(UBiDi *pBiDi, UBiDiClassCallback *newFn,
const void *newContext, UBiDiClassCallback **oldFn,
const void **oldContext, UErrorCode *pErrorCode);
@@ -2075,7 +2078,7 @@ ubidi_setClassCallback(UBiDi *pBiDi, UBiDiClassCallback *newFn,
* @see ubidi_setClassCallback
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context);
/**
@@ -2143,7 +2146,7 @@ ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **conte
* @see ubidi_getProcessedLength
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_writeReordered(UBiDi *pBiDi,
UChar *dest, int32_t destSize,
uint16_t options,
@@ -2195,7 +2198,7 @@ ubidi_writeReordered(UBiDi *pBiDi,
* @return The length of the output string.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubidi_writeReverse(const UChar *src, int32_t srcLength,
UChar *dest, int32_t destSize,
uint16_t options,
diff --git a/deps/icu-small/source/common/unicode/ubiditransform.h b/deps/icu-small/source/common/unicode/ubiditransform.h
index 5c08ed5df0..2dd7564010 100644
--- a/deps/icu-small/source/common/unicode/ubiditransform.h
+++ b/deps/icu-small/source/common/unicode/ubiditransform.h
@@ -21,7 +21,10 @@
#include "unicode/utypes.h"
#include "unicode/ubidi.h"
#include "unicode/uchar.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
@@ -147,10 +150,10 @@ typedef struct UBiDiTransform UBiDiTransform;
* calling <code>ubidi_setPara</code> with
* <code>paraLevel == UBIDI_DEFAULT_RTL</code>,</li>
* <li><Visual LTR, Logical LTR>: this is equivalent to
- * calling <code>ubidi_setInverse(UBiDi*, TRUE)</code> and then
+ * calling <code>ubidi_setInverse(UBiDi*, true)</code> and then
* <code>ubidi_setPara</code> with <code>paraLevel == UBIDI_LTR</code>,</li>
* <li><Visual LTR, Logical RTL>: this is equivalent to
- * calling <code>ubidi_setInverse(UBiDi*, TRUE)</code> and then
+ * calling <code>ubidi_setInverse(UBiDi*, true)</code> and then
* <code>ubidi_setPara</code> with <code>paraLevel == UBIDI_RTL</code>.</li>
* </ul>
* All combinations that involve the Visual RTL scheme are unsupported by
@@ -245,7 +248,7 @@ typedef struct UBiDiTransform UBiDiTransform;
* @see u_shapeArabic
* @stable ICU 58
*/
-U_STABLE uint32_t U_EXPORT2
+U_CAPI uint32_t U_EXPORT2
ubiditransform_transform(UBiDiTransform *pBiDiTransform,
const UChar *src, int32_t srcLength,
UChar *dest, int32_t destSize,
@@ -291,14 +294,14 @@ ubiditransform_transform(UBiDiTransform *pBiDiTransform,
* @return An empty <code>UBiDiTransform</code> object.
* @stable ICU 58
*/
-U_STABLE UBiDiTransform* U_EXPORT2
+U_CAPI UBiDiTransform* U_EXPORT2
ubiditransform_open(UErrorCode *pErrorCode);
/**
* Deallocates the given <code>UBiDiTransform</code> object.
* @stable ICU 58
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubiditransform_close(UBiDiTransform *pBidiTransform);
#if U_SHOW_CPLUSPLUS_API
diff --git a/deps/icu-small/source/common/unicode/ubrk.h b/deps/icu-small/source/common/unicode/ubrk.h
index 73c1553b24..37189a8598 100644
--- a/deps/icu-small/source/common/unicode/ubrk.h
+++ b/deps/icu-small/source/common/unicode/ubrk.h
@@ -13,7 +13,10 @@
#include "unicode/utypes.h"
#include "unicode/uloc.h"
#include "unicode/utext.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* A text-break iterator.
@@ -238,7 +241,7 @@ typedef enum USentenceBreakTag {
* @see ubrk_openRules
* @stable ICU 2.0
*/
-U_STABLE UBreakIterator* U_EXPORT2
+U_CAPI UBreakIterator* U_EXPORT2
ubrk_open(UBreakIteratorType type,
const char *locale,
const UChar *text,
@@ -260,7 +263,7 @@ ubrk_open(UBreakIteratorType type,
* @see ubrk_open
* @stable ICU 2.2
*/
-U_STABLE UBreakIterator* U_EXPORT2
+U_CAPI UBreakIterator* U_EXPORT2
ubrk_openRules(const UChar *rules,
int32_t rulesLength,
const UChar *text,
@@ -288,7 +291,7 @@ ubrk_openRules(const UChar *rules,
* @see ubrk_getBinaryRules
* @stable ICU 59
*/
-U_STABLE UBreakIterator* U_EXPORT2
+U_CAPI UBreakIterator* U_EXPORT2
ubrk_openBinaryRules(const uint8_t *binaryRules, int32_t rulesLength,
const UChar * text, int32_t textLength,
UErrorCode * status);
@@ -311,7 +314,7 @@ ubrk_openBinaryRules(const uint8_t *binaryRules, int32_t rulesLength,
* @return pointer to the new clone
* @stable ICU 2.0
*/
-U_STABLE UBreakIterator * U_EXPORT2
+U_CAPI UBreakIterator * U_EXPORT2
ubrk_safeClone(
const UBreakIterator *bi,
void *stackBuffer,
@@ -334,7 +337,7 @@ ubrk_safeClone(
* @param bi The break iterator to close.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubrk_close(UBreakIterator *bi);
#if U_SHOW_CPLUSPLUS_API
@@ -368,7 +371,7 @@ U_NAMESPACE_END
* @param status The error code
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubrk_setText(UBreakIterator* bi,
const UChar* text,
int32_t textLength,
@@ -392,7 +395,7 @@ ubrk_setText(UBreakIterator* bi,
* @param status The error code
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubrk_setUText(UBreakIterator* bi,
UText* text,
UErrorCode* status);
@@ -407,7 +410,7 @@ ubrk_setUText(UBreakIterator* bi,
* \ref ubrk_first, or \ref ubrk_last.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_current(const UBreakIterator *bi);
/**
@@ -419,7 +422,7 @@ ubrk_current(const UBreakIterator *bi);
* @see ubrk_previous
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_next(UBreakIterator *bi);
/**
@@ -431,7 +434,7 @@ ubrk_next(UBreakIterator *bi);
* @see ubrk_next
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_previous(UBreakIterator *bi);
/**
@@ -441,7 +444,7 @@ ubrk_previous(UBreakIterator *bi);
* @see ubrk_last
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_first(UBreakIterator *bi);
/**
@@ -453,7 +456,7 @@ ubrk_first(UBreakIterator *bi);
* @see ubrk_first
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_last(UBreakIterator *bi);
/**
@@ -465,7 +468,7 @@ ubrk_last(UBreakIterator *bi);
* @see ubrk_following
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_preceding(UBreakIterator *bi,
int32_t offset);
@@ -478,7 +481,7 @@ ubrk_preceding(UBreakIterator *bi,
* @see ubrk_preceding
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_following(UBreakIterator *bi,
int32_t offset);
@@ -491,7 +494,7 @@ ubrk_following(UBreakIterator *bi,
* @see ubrk_countAvailable
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ubrk_getAvailable(int32_t index);
/**
@@ -502,7 +505,7 @@ ubrk_getAvailable(int32_t index);
* @see ubrk_getAvailable
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_countAvailable(void);
@@ -515,7 +518,7 @@ ubrk_countAvailable(void);
* @return True if "offset" is a boundary position.
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ubrk_isBoundary(UBreakIterator *bi, int32_t offset);
/**
@@ -527,7 +530,7 @@ ubrk_isBoundary(UBreakIterator *bi, int32_t offset);
* For word break iterators, the possible values are defined in enum UWordBreak.
* @stable ICU 2.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_getRuleStatus(UBreakIterator *bi);
/**
@@ -547,7 +550,7 @@ ubrk_getRuleStatus(UBreakIterator *bi);
* the most recent boundary returned by the break iterator.
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_getRuleStatusVec(UBreakIterator *bi, int32_t *fillInVec, int32_t capacity, UErrorCode *status);
/**
@@ -559,7 +562,7 @@ ubrk_getRuleStatusVec(UBreakIterator *bi, int32_t *fillInVec, int32_t capacity,
* @return locale string
* @stable ICU 2.8
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ubrk_getLocaleByType(const UBreakIterator *bi, ULocDataLocaleType type, UErrorCode* status);
/**
@@ -587,7 +590,7 @@ ubrk_getLocaleByType(const UBreakIterator *bi, ULocDataLocaleType type, UErrorCo
*
* @stable ICU 49
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ubrk_refreshUText(UBreakIterator *bi,
UText *text,
UErrorCode *status);
@@ -618,7 +621,7 @@ ubrk_refreshUText(UBreakIterator *bi,
* @see ubrk_openBinaryRules
* @stable ICU 59
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ubrk_getBinaryRules(UBreakIterator *bi,
uint8_t * binaryRules, int32_t rulesCapacity,
UErrorCode * status);
diff --git a/deps/icu-small/source/common/unicode/ucasemap.h b/deps/icu-small/source/common/unicode/ucasemap.h
index 6b253e3d63..d1c1b483ab 100644
--- a/deps/icu-small/source/common/unicode/ucasemap.h
+++ b/deps/icu-small/source/common/unicode/ucasemap.h
@@ -22,10 +22,13 @@
#define __UCASEMAP_H__
#include "unicode/utypes.h"
-#include "unicode/localpointer.h"
#include "unicode/stringoptions.h"
#include "unicode/ustring.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* \file
* \brief C API: Unicode case mapping functions using a UCaseMap service object.
@@ -69,7 +72,7 @@ typedef struct UCaseMap UCaseMap; /**< C typedef for struct UCaseMap. @stable IC
* @see U_TITLECASE_NO_BREAK_ADJUSTMENT
* @stable ICU 3.4
*/
-U_STABLE UCaseMap * U_EXPORT2
+U_CAPI UCaseMap * U_EXPORT2
ucasemap_open(const char *locale, uint32_t options, UErrorCode *pErrorCode);
/**
@@ -77,7 +80,7 @@ ucasemap_open(const char *locale, uint32_t options, UErrorCode *pErrorCode);
* @param csm Object to be closed.
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucasemap_close(UCaseMap *csm);
#if U_SHOW_CPLUSPLUS_API
@@ -105,7 +108,7 @@ U_NAMESPACE_END
* @return locale ID
* @stable ICU 3.4
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucasemap_getLocale(const UCaseMap *csm);
/**
@@ -114,7 +117,7 @@ ucasemap_getLocale(const UCaseMap *csm);
* @return options bit set
* @stable ICU 3.4
*/
-U_STABLE uint32_t U_EXPORT2
+U_CAPI uint32_t U_EXPORT2
ucasemap_getOptions(const UCaseMap *csm);
/**
@@ -128,7 +131,7 @@ ucasemap_getOptions(const UCaseMap *csm);
* @see ucasemap_open
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucasemap_setLocale(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode);
/**
@@ -142,7 +145,7 @@ ucasemap_setLocale(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode);
* @see ucasemap_open
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucasemap_setOptions(UCaseMap *csm, uint32_t options, UErrorCode *pErrorCode);
#if !UCONFIG_NO_BREAK_ITERATION
@@ -154,7 +157,7 @@ ucasemap_setOptions(UCaseMap *csm, uint32_t options, UErrorCode *pErrorCode);
* @return titlecasing break iterator
* @stable ICU 3.8
*/
-U_STABLE const UBreakIterator * U_EXPORT2
+U_CAPI const UBreakIterator * U_EXPORT2
ucasemap_getBreakIterator(const UCaseMap *csm);
/**
@@ -177,7 +180,7 @@ ucasemap_getBreakIterator(const UCaseMap *csm);
* @see ucasemap_utf8ToTitle
* @stable ICU 3.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucasemap_setBreakIterator(UCaseMap *csm, UBreakIterator *iterToAdopt, UErrorCode *pErrorCode);
/**
@@ -226,7 +229,7 @@ ucasemap_setBreakIterator(UCaseMap *csm, UBreakIterator *iterToAdopt, UErrorCode
* @see u_strToTitle
* @stable ICU 3.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucasemap_toTitle(UCaseMap *csm,
UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
@@ -257,7 +260,7 @@ ucasemap_toTitle(UCaseMap *csm,
* @see u_strToLower
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucasemap_utf8ToLower(const UCaseMap *csm,
char *dest, int32_t destCapacity,
const char *src, int32_t srcLength,
@@ -286,7 +289,7 @@ ucasemap_utf8ToLower(const UCaseMap *csm,
* @see u_strToUpper
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucasemap_utf8ToUpper(const UCaseMap *csm,
char *dest, int32_t destCapacity,
const char *src, int32_t srcLength,
@@ -338,7 +341,7 @@ ucasemap_utf8ToUpper(const UCaseMap *csm,
* @see U_TITLECASE_NO_BREAK_ADJUSTMENT
* @stable ICU 3.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucasemap_utf8ToTitle(UCaseMap *csm,
char *dest, int32_t destCapacity,
const char *src, int32_t srcLength,
@@ -376,7 +379,7 @@ ucasemap_utf8ToTitle(UCaseMap *csm,
* @see U_FOLD_CASE_EXCLUDE_SPECIAL_I
* @stable ICU 3.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucasemap_utf8FoldCase(const UCaseMap *csm,
char *dest, int32_t destCapacity,
const char *src, int32_t srcLength,
diff --git a/deps/icu-small/source/common/unicode/ucat.h b/deps/icu-small/source/common/unicode/ucat.h
index f9c18b47d6..a177639a76 100644
--- a/deps/icu-small/source/common/unicode/ucat.h
+++ b/deps/icu-small/source/common/unicode/ucat.h
@@ -103,7 +103,7 @@ typedef UResourceBundle* u_nl_catd;
*
* @stable ICU 2.6
*/
-U_STABLE u_nl_catd U_EXPORT2
+U_CAPI u_nl_catd U_EXPORT2
u_catopen(const char* name, const char* locale, UErrorCode* ec);
/**
@@ -114,7 +114,7 @@ u_catopen(const char* name, const char* locale, UErrorCode* ec);
*
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_catclose(u_nl_catd catd);
/**
@@ -149,7 +149,7 @@ u_catclose(u_nl_catd catd);
*
* @stable ICU 2.6
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
u_catgets(u_nl_catd catd, int32_t set_num, int32_t msg_num,
const UChar* s,
int32_t* len, UErrorCode* ec);
diff --git a/deps/icu-small/source/common/unicode/uchar.h b/deps/icu-small/source/common/unicode/uchar.h
index 3b55b2326d..1e0f82e706 100644
--- a/deps/icu-small/source/common/unicode/uchar.h
+++ b/deps/icu-small/source/common/unicode/uchar.h
@@ -80,7 +80,7 @@ U_CDECL_BEGIN
* and the ICU User Guide chapter on Properties (http://icu-project.org/userguide/properties.html).
*
* Many properties are accessible via generic functions that take a UProperty selector.
- * - u_hasBinaryProperty() returns a binary value (TRUE/FALSE) per property and code point.
+ * - u_hasBinaryProperty() returns a binary value (true/false) per property and code point.
* - u_getIntPropertyValue() returns an integer value per property and code point.
* For each supported enumerated or catalog property, there is
* an enum type for all of the property's values, and
@@ -2586,8 +2586,8 @@ typedef enum UVerticalOrientation {
* @param c Code point to test.
* @param which UProperty selector constant, identifies which binary property to check.
* Must be UCHAR_BINARY_START<=which<UCHAR_BINARY_LIMIT.
- * @return TRUE or FALSE according to the binary Unicode property value for c.
- * Also FALSE if 'which' is out of bounds or if the Unicode version
+ * @return true or false according to the binary Unicode property value for c.
+ * Also false if 'which' is out of bounds or if the Unicode version
* does not have data for the property at all, or not for this code point.
*
* @see UProperty
@@ -2596,7 +2596,7 @@ typedef enum UVerticalOrientation {
* @see u_getUnicodeVersion
* @stable ICU 2.1
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_hasBinaryProperty(UChar32 c, UProperty which);
/**
@@ -2629,7 +2629,7 @@ u_getBinaryPropertySet(UProperty property, UErrorCode *pErrorCode);
* @see u_hasBinaryProperty
* @stable ICU 2.1
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isUAlphabetic(UChar32 c);
/**
@@ -2644,7 +2644,7 @@ u_isUAlphabetic(UChar32 c);
* @see u_hasBinaryProperty
* @stable ICU 2.1
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isULowercase(UChar32 c);
/**
@@ -2659,7 +2659,7 @@ u_isULowercase(UChar32 c);
* @see u_hasBinaryProperty
* @stable ICU 2.1
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isUUppercase(UChar32 c);
/**
@@ -2680,7 +2680,7 @@ u_isUUppercase(UChar32 c);
* @see u_hasBinaryProperty
* @stable ICU 2.1
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isUWhiteSpace(UChar32 c);
/**
@@ -2708,7 +2708,7 @@ u_isUWhiteSpace(UChar32 c);
* for enumerated properties, corresponds to the numeric value of the enumerated
* constant of the respective property value enumeration type
* (cast to enum type if necessary).
- * Returns 0 or 1 (for FALSE/TRUE) for binary Unicode properties.
+ * Returns 0 or 1 (for false/true) for binary Unicode properties.
* Returns a bit-mask for mask properties.
* Returns 0 if 'which' is out of bounds or if the Unicode version
* does not have data for the property at all, or not for this code point.
@@ -2721,7 +2721,7 @@ u_isUWhiteSpace(UChar32 c);
* @see u_getUnicodeVersion
* @stable ICU 2.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_getIntPropertyValue(UChar32 c, UProperty which);
/**
@@ -2742,7 +2742,7 @@ u_getIntPropertyValue(UChar32 c, UProperty which);
* @see u_getIntPropertyValue
* @stable ICU 2.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_getIntPropertyMinValue(UProperty which);
/**
@@ -2754,7 +2754,7 @@ u_getIntPropertyMinValue(UProperty which);
*
* - UCHAR_BIDI_CLASS: 0/18 (U_LEFT_TO_RIGHT/U_BOUNDARY_NEUTRAL)
* - UCHAR_SCRIPT: 0/45 (USCRIPT_COMMON/USCRIPT_TAGBANWA)
- * - UCHAR_IDEOGRAPHIC: 0/1 (FALSE/TRUE)
+ * - UCHAR_IDEOGRAPHIC: 0/1 (false/true)
*
* For undefined UProperty constant values, min/max values will be 0/-1.
*
@@ -2771,7 +2771,7 @@ u_getIntPropertyMinValue(UProperty which);
* @see u_getIntPropertyValue
* @stable ICU 2.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_getIntPropertyMaxValue(UProperty which);
/**
@@ -2814,7 +2814,7 @@ u_getIntPropertyMap(UProperty property, UErrorCode *pErrorCode);
* @see U_NO_NUMERIC_VALUE
* @stable ICU 2.2
*/
-U_STABLE double U_EXPORT2
+U_CAPI double U_EXPORT2
u_getNumericValue(UChar32 c);
/**
@@ -2842,14 +2842,14 @@ u_getNumericValue(UChar32 c);
* documentation at the top of this header file.
*
* @param c the code point to be tested
- * @return TRUE if the code point is an Ll lowercase letter
+ * @return true if the code point is an Ll lowercase letter
*
* @see UCHAR_LOWERCASE
* @see u_isupper
* @see u_istitle
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_islower(UChar32 c);
/**
@@ -2868,7 +2868,7 @@ u_islower(UChar32 c);
* documentation at the top of this header file.
*
* @param c the code point to be tested
- * @return TRUE if the code point is an Lu uppercase letter
+ * @return true if the code point is an Lu uppercase letter
*
* @see UCHAR_UPPERCASE
* @see u_islower
@@ -2876,7 +2876,7 @@ u_islower(UChar32 c);
* @see u_tolower
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isupper(UChar32 c);
/**
@@ -2886,14 +2886,14 @@ u_isupper(UChar32 c);
* Same as java.lang.Character.isTitleCase().
*
* @param c the code point to be tested
- * @return TRUE if the code point is an Lt titlecase letter
+ * @return true if the code point is an Lt titlecase letter
*
* @see u_isupper
* @see u_islower
* @see u_totitle
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_istitle(UChar32 c);
/**
@@ -2910,11 +2910,11 @@ u_istitle(UChar32 c);
* documentation at the top of this header file.
*
* @param c the code point to be tested
- * @return TRUE if the code point is a digit character according to Character.isDigit()
+ * @return true if the code point is a digit character according to Character.isDigit()
*
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isdigit(UChar32 c);
/**
@@ -2929,13 +2929,13 @@ u_isdigit(UChar32 c);
* documentation at the top of this header file.
*
* @param c the code point to be tested
- * @return TRUE if the code point is a letter character
+ * @return true if the code point is a letter character
*
* @see u_isdigit
* @see u_isalnum
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isalpha(UChar32 c);
/**
@@ -2952,11 +2952,11 @@ u_isalpha(UChar32 c);
* documentation at the top of this header file.
*
* @param c the code point to be tested
- * @return TRUE if the code point is an alphanumeric character according to Character.isLetterOrDigit()
+ * @return true if the code point is an alphanumeric character according to Character.isLetterOrDigit()
*
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isalnum(UChar32 c);
/**
@@ -2975,11 +2975,11 @@ u_isalnum(UChar32 c);
* documentation at the top of this header file.
*
* @param c the code point to be tested
- * @return TRUE if the code point is a hexadecimal digit
+ * @return true if the code point is a hexadecimal digit
*
* @stable ICU 2.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isxdigit(UChar32 c);
/**
@@ -2991,17 +2991,17 @@ u_isxdigit(UChar32 c);
* documentation at the top of this header file.
*
* @param c the code point to be tested
- * @return TRUE if the code point is a punctuation character
+ * @return true if the code point is a punctuation character
*
* @stable ICU 2.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_ispunct(UChar32 c);
/**
* Determines whether the specified code point is a "graphic" character
* (printable, excluding spaces).
- * TRUE for all characters except those with general categories
+ * true for all characters except those with general categories
* "Cc" (control codes), "Cf" (format controls), "Cs" (surrogates),
* "Cn" (unassigned), and "Z" (separators).
*
@@ -3010,11 +3010,11 @@ u_ispunct(UChar32 c);
* documentation at the top of this header file.
*
* @param c the code point to be tested
- * @return TRUE if the code point is a "graphic" character
+ * @return true if the code point is a "graphic" character
*
* @stable ICU 2.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isgraph(UChar32 c);
/**
@@ -3022,13 +3022,13 @@ u_isgraph(UChar32 c);
* a character that visibly separates words on a line.
* The following are equivalent definitions:
*
- * TRUE for Unicode White_Space characters except for "vertical space controls"
+ * true for Unicode White_Space characters except for "vertical space controls"
* where "vertical space controls" are the following characters:
* U+000A (LF) U+000B (VT) U+000C (FF) U+000D (CR) U+0085 (NEL) U+2028 (LS) U+2029 (PS)
*
* same as
*
- * TRUE for U+0009 (TAB) and characters with general category "Zs" (space separators).
+ * true for U+0009 (TAB) and characters with general category "Zs" (space separators).
*
* Note: There are several ICU whitespace functions; please see the uchar.h
* file documentation for a detailed comparison.
@@ -3038,11 +3038,11 @@ u_isgraph(UChar32 c);
* documentation at the top of this header file.
*
* @param c the code point to be tested
- * @return TRUE if the code point is a "blank"
+ * @return true if the code point is a "blank"
*
* @stable ICU 2.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isblank(UChar32 c);
/**
@@ -3057,7 +3057,7 @@ u_isblank(UChar32 c);
* Same as java.lang.Character.isDefined().
*
* @param c the code point to be tested
- * @return TRUE if the code point is assigned a character
+ * @return true if the code point is assigned a character
*
* @see u_isdigit
* @see u_isalpha
@@ -3067,7 +3067,7 @@ u_isblank(UChar32 c);
* @see u_istitle
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isdefined(UChar32 c);
/**
@@ -3088,7 +3088,7 @@ u_isdefined(UChar32 c);
* @see u_isUWhiteSpace
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isspace(UChar32 c);
/**
@@ -3102,14 +3102,14 @@ u_isspace(UChar32 c);
* file documentation for a detailed comparison.
*
* @param c the code point to be tested
- * @return TRUE if the code point is a space character according to Character.isSpaceChar()
+ * @return true if the code point is a space character according to Character.isSpaceChar()
*
* @see u_isspace
* @see u_isWhitespace
* @see u_isUWhiteSpace
* @stable ICU 2.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isJavaSpaceChar(UChar32 c);
/**
@@ -3142,14 +3142,14 @@ u_isJavaSpaceChar(UChar32 c);
* file documentation for a detailed comparison.
*
* @param c the code point to be tested
- * @return TRUE if the code point is a whitespace character according to Java/ICU
+ * @return true if the code point is a whitespace character according to Java/ICU
*
* @see u_isspace
* @see u_isJavaSpaceChar
* @see u_isUWhiteSpace
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isWhitespace(UChar32 c);
/**
@@ -3167,13 +3167,13 @@ u_isWhitespace(UChar32 c);
* documentation at the top of this header file.
*
* @param c the code point to be tested
- * @return TRUE if the code point is a control character
+ * @return true if the code point is a control character
*
* @see UCHAR_DEFAULT_IGNORABLE_CODE_POINT
* @see u_isprint
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_iscntrl(UChar32 c);
/**
@@ -3183,12 +3183,12 @@ u_iscntrl(UChar32 c);
* Same as java.lang.Character.isISOControl().
*
* @param c the code point to be tested
- * @return TRUE if the code point is an ISO control code
+ * @return true if the code point is an ISO control code
*
* @see u_iscntrl
* @stable ICU 2.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isISOControl(UChar32 c);
/**
@@ -3200,13 +3200,13 @@ u_isISOControl(UChar32 c);
* documentation at the top of this header file.
*
* @param c the code point to be tested
- * @return TRUE if the code point is a printable character
+ * @return true if the code point is a printable character
*
* @see UCHAR_DEFAULT_IGNORABLE_CODE_POINT
* @see u_iscntrl
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isprint(UChar32 c);
/**
@@ -3220,13 +3220,13 @@ u_isprint(UChar32 c);
* Letter (L), Number (N), Punctuation (P), Symbol (S), or Space Separator (Zs).
*
* @param c the code point to be tested
- * @return TRUE if the code point is a base character according to this function
+ * @return true if the code point is a base character according to this function
*
* @see u_isalpha
* @see u_isdigit
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isbase(UChar32 c);
/**
@@ -3245,7 +3245,7 @@ u_isbase(UChar32 c);
* @see UCharDirection
* @stable ICU 2.0
*/
-U_STABLE UCharDirection U_EXPORT2
+U_CAPI UCharDirection U_EXPORT2
u_charDirection(UChar32 c);
/**
@@ -3258,12 +3258,12 @@ u_charDirection(UChar32 c);
* Same as UCHAR_BIDI_MIRRORED
*
* @param c the code point to be tested
- * @return TRUE if the character has the Bidi_Mirrored property
+ * @return true if the character has the Bidi_Mirrored property
*
* @see UCHAR_BIDI_MIRRORED
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isMirrored(UChar32 c);
/**
@@ -3285,7 +3285,7 @@ u_isMirrored(UChar32 c);
* @see u_isMirrored
* @stable ICU 2.0
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
u_charMirror(UChar32 c);
/**
@@ -3304,7 +3304,7 @@ u_charMirror(UChar32 c);
* @see u_charMirror
* @stable ICU 52
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
u_getBidiPairedBracket(UChar32 c);
/**
@@ -3318,7 +3318,7 @@ u_getBidiPairedBracket(UChar32 c);
* @see UCharCategory
* @stable ICU 2.0
*/
-U_STABLE int8_t U_EXPORT2
+U_CAPI int8_t U_EXPORT2
u_charType(UChar32 c);
/**
@@ -3341,13 +3341,13 @@ u_charType(UChar32 c);
* of code points c (where start<=c<limit)
* with the same Unicode general category ("character type").
*
- * The callback function can stop the enumeration by returning FALSE.
+ * The callback function can stop the enumeration by returning false.
*
* @param context an opaque pointer, as passed into utrie_enum()
* @param start the first code point in a contiguous range with value
* @param limit one past the last code point in a contiguous range with value
* @param type the general category for all code points in [start..limit[
- * @return FALSE to stop the enumeration
+ * @return false to stop the enumeration
*
* @stable ICU 2.1
* @see UCharCategory
@@ -3375,7 +3375,7 @@ UCharEnumTypeRange(const void *context, UChar32 start, UChar32 limit, UCharCateg
* @see UCharCategory
* @see UCharEnumTypeRange
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_enumCharTypes(UCharEnumTypeRange *enumRange, const void *context);
#if !UCONFIG_NO_NORMALIZATION
@@ -3387,7 +3387,7 @@ u_enumCharTypes(UCharEnumTypeRange *enumRange, const void *context);
* @return the combining class of the character
* @stable ICU 2.0
*/
-U_STABLE uint8_t U_EXPORT2
+U_CAPI uint8_t U_EXPORT2
u_getCombiningClass(UChar32 c);
#endif
@@ -3415,7 +3415,7 @@ u_getCombiningClass(UChar32 c);
* @see u_getNumericValue
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_charDigitValue(UChar32 c);
/**
@@ -3427,7 +3427,7 @@ u_charDigitValue(UChar32 c);
* @see UBlockCode
* @stable ICU 2.0
*/
-U_STABLE UBlockCode U_EXPORT2
+U_CAPI UBlockCode U_EXPORT2
ublock_getCode(UChar32 c);
/**
@@ -3462,7 +3462,7 @@ ublock_getCode(UChar32 c);
* @see u_enumCharNames
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_charName(UChar32 code, UCharNameChoice nameChoice,
char *buffer, int32_t bufferLength,
UErrorCode *pErrorCode);
@@ -3512,7 +3512,7 @@ u_getISOComment(UChar32 c,
* @see u_enumCharNames
* @stable ICU 1.7
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
u_charFromName(UCharNameChoice nameChoice,
const char *name,
UErrorCode *pErrorCode);
@@ -3521,14 +3521,14 @@ u_charFromName(UCharNameChoice nameChoice,
* Type of a callback function for u_enumCharNames() that gets called
* for each Unicode character with the code point value and
* the character name.
- * If such a function returns FALSE, then the enumeration is stopped.
+ * If such a function returns false, then the enumeration is stopped.
*
* @param context The context pointer that was passed to u_enumCharNames().
* @param code The Unicode code point for the character with this name.
* @param nameChoice Selector for which kind of names is enumerated.
* @param name The character's name, zero-terminated.
* @param length The length of the name.
- * @return TRUE if the enumeration should continue, FALSE to stop it.
+ * @return true if the enumeration should continue, false to stop it.
*
* @see UCharNameChoice
* @see u_enumCharNames
@@ -3561,7 +3561,7 @@ typedef UBool U_CALLCONV UEnumCharNamesFn(void *context,
* @see u_charFromName
* @stable ICU 1.7
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_enumCharNames(UChar32 start, UChar32 limit,
UEnumCharNamesFn *fn,
void *context,
@@ -3599,7 +3599,7 @@ u_enumCharNames(UChar32 start, UChar32 limit,
* @see UPropertyNameChoice
* @stable ICU 2.4
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
u_getPropertyName(UProperty property,
UPropertyNameChoice nameChoice);
@@ -3622,7 +3622,7 @@ u_getPropertyName(UProperty property,
* @see UProperty
* @stable ICU 2.4
*/
-U_STABLE UProperty U_EXPORT2
+U_CAPI UProperty U_EXPORT2
u_getPropertyEnum(const char* alias);
/**
@@ -3672,7 +3672,7 @@ u_getPropertyEnum(const char* alias);
* @see UPropertyNameChoice
* @stable ICU 2.4
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
u_getPropertyValueName(UProperty property,
int32_t value,
UPropertyNameChoice nameChoice);
@@ -3708,7 +3708,7 @@ u_getPropertyValueName(UProperty property,
* @see UProperty
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_getPropertyValueEnum(UProperty property,
const char* alias);
@@ -3722,14 +3722,14 @@ u_getPropertyValueEnum(UProperty property,
* Same as UCHAR_ID_START
*
* @param c the code point to be tested
- * @return TRUE if the code point may start an identifier
+ * @return true if the code point may start an identifier
*
* @see UCHAR_ID_START
* @see u_isalpha
* @see u_isIDPart
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isIDStart(UChar32 c);
/**
@@ -3746,14 +3746,14 @@ u_isIDStart(UChar32 c);
* u_isIDIgnorable(c).
*
* @param c the code point to be tested
- * @return TRUE if the code point may occur in an identifier according to Java
+ * @return true if the code point may occur in an identifier according to Java
*
* @see UCHAR_ID_CONTINUE
* @see u_isIDStart
* @see u_isIDIgnorable
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isIDPart(UChar32 c);
/**
@@ -3769,14 +3769,14 @@ u_isIDPart(UChar32 c);
* Note that Unicode just recommends to ignore Cf (format controls).
*
* @param c the code point to be tested
- * @return TRUE if the code point is ignorable in identifiers according to Java
+ * @return true if the code point is ignorable in identifiers according to Java
*
* @see UCHAR_DEFAULT_IGNORABLE_CODE_POINT
* @see u_isIDStart
* @see u_isIDPart
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isIDIgnorable(UChar32 c);
/**
@@ -3788,14 +3788,14 @@ u_isIDIgnorable(UChar32 c);
* Same as java.lang.Character.isJavaIdentifierStart().
*
* @param c the code point to be tested
- * @return TRUE if the code point may start a Java identifier
+ * @return true if the code point may start a Java identifier
*
* @see u_isJavaIDPart
* @see u_isalpha
* @see u_isIDStart
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isJavaIDStart(UChar32 c);
/**
@@ -3807,7 +3807,7 @@ u_isJavaIDStart(UChar32 c);
* Same as java.lang.Character.isJavaIdentifierPart().
*
* @param c the code point to be tested
- * @return TRUE if the code point may occur in a Java identifier
+ * @return true if the code point may occur in a Java identifier
*
* @see u_isIDIgnorable
* @see u_isJavaIDStart
@@ -3816,7 +3816,7 @@ u_isJavaIDStart(UChar32 c);
* @see u_isIDPart
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_isJavaIDPart(UChar32 c);
/**
@@ -3841,7 +3841,7 @@ u_isJavaIDPart(UChar32 c);
* otherwise the code point itself.
* @stable ICU 2.0
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
u_tolower(UChar32 c);
/**
@@ -3866,7 +3866,7 @@ u_tolower(UChar32 c);
* otherwise the code point itself.
* @stable ICU 2.0
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
u_toupper(UChar32 c);
/**
@@ -3891,7 +3891,7 @@ u_toupper(UChar32 c);
* otherwise the code point itself.
* @stable ICU 2.0
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
u_totitle(UChar32 c);
/**
@@ -3916,7 +3916,7 @@ u_totitle(UChar32 c);
* otherwise the code point itself.
* @stable ICU 2.0
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
u_foldCase(UChar32 c, uint32_t options);
/**
@@ -3957,7 +3957,7 @@ u_foldCase(UChar32 c, uint32_t options);
* @see u_isdigit
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_digit(UChar32 ch, int8_t radix);
/**
@@ -3988,7 +3988,7 @@ u_digit(UChar32 ch, int8_t radix);
* @see u_isdigit
* @stable ICU 2.0
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
u_forDigit(int32_t digit, int8_t radix);
/**
@@ -4005,7 +4005,7 @@ u_forDigit(int32_t digit, int8_t radix);
*
* @stable ICU 2.1
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_charAge(UChar32 c, UVersionInfo versionArray);
/**
@@ -4019,7 +4019,7 @@ u_charAge(UChar32 c, UVersionInfo versionArray);
* the Unicode version number
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_getUnicodeVersion(UVersionInfo versionArray);
#if !UCONFIG_NO_NORMALIZATION
@@ -4044,7 +4044,7 @@ u_getUnicodeVersion(UVersionInfo versionArray);
*
* @stable ICU 2.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_getFC_NFKC_Closure(UChar32 c, UChar *dest, int32_t destCapacity, UErrorCode *pErrorCode);
#endif
diff --git a/deps/icu-small/source/common/unicode/ucharstrie.h b/deps/icu-small/source/common/unicode/ucharstrie.h
index d5729d944e..b6f9e3e075 100644
--- a/deps/icu-small/source/common/unicode/ucharstrie.h
+++ b/deps/icu-small/source/common/unicode/ucharstrie.h
@@ -97,14 +97,13 @@ public:
return *this;
}
-#ifndef U_HIDE_DRAFT_API
/**
* Returns the state of this trie as a 64-bit integer.
* The state value is never 0.
*
* @return opaque state value
* @see resetToState64
- * @draft ICU 65
+ * @stable ICU 65
*/
uint64_t getState64() const {
return (static_cast<uint64_t>(remainingMatchLength_ + 2) << kState64RemainingShift) |
@@ -123,14 +122,13 @@ public:
* @see getState64
* @see resetToState
* @see reset
- * @draft ICU 65
+ * @stable ICU 65
*/
UCharsTrie &resetToState64(uint64_t state) {
remainingMatchLength_ = static_cast<int32_t>(state >> kState64RemainingShift) - 2;
pos_ = uchars_ + (state & kState64PosMask);
return *this;
}
-#endif /* U_HIDE_DRAFT_API */
/**
* UCharsTrie state object, for saving a trie's current state
@@ -268,16 +266,16 @@ public:
/**
* Determines whether all strings reachable from the current state
* map to the same value.
- * @param uniqueValue Receives the unique value, if this function returns TRUE.
+ * @param uniqueValue Receives the unique value, if this function returns true.
* (output-only)
- * @return TRUE if all strings reachable from the current state
+ * @return true if all strings reachable from the current state
* map to the same value.
* @stable ICU 4.8
*/
inline UBool hasUniqueValue(int32_t &uniqueValue) const {
const char16_t *pos=pos_;
// Skip the rest of a pending linear-match node.
- return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, FALSE, uniqueValue);
+ return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, false, uniqueValue);
}
/**
@@ -335,7 +333,7 @@ public:
Iterator &reset();
/**
- * @return TRUE if there are more elements.
+ * @return true if there are more elements.
* @stable ICU 4.8
*/
UBool hasNext() const;
@@ -351,7 +349,7 @@ public:
* pass the U_SUCCESS() test, or else the function returns
* immediately. Check for U_FAILURE() on output or use with
* function chaining. (See User Guide for details.)
- * @return TRUE if there is another element.
+ * @return true if there is another element.
* @stable ICU 4.8
*/
UBool next(UErrorCode &errorCode);
@@ -371,7 +369,7 @@ public:
UBool truncateAndStop() {
pos_=NULL;
value_=-1; // no real value for str
- return TRUE;
+ return true;
}
const char16_t *branchNext(const char16_t *pos, int32_t length, UErrorCode &errorCode);
diff --git a/deps/icu-small/source/common/unicode/ucharstriebuilder.h b/deps/icu-small/source/common/unicode/ucharstriebuilder.h
index 540dcc047f..15657702f9 100644
--- a/deps/icu-small/source/common/unicode/ucharstriebuilder.h
+++ b/deps/icu-small/source/common/unicode/ucharstriebuilder.h
@@ -101,9 +101,10 @@ public:
* Multiple calls to buildUnicodeString() set the UnicodeStrings to the
* builder's same char16_t array, without rebuilding.
* If buildUnicodeString() is called after build(), the trie will be
- * re-serialized into a new array.
- * If build() is called after buildUnicodeString(), the trie object will become
- * the owner of the previously returned array.
+ * re-serialized into a new array (because build() passes on ownership).
+ * If build() is called after buildUnicodeString(), the trie object returned
+ * by build() will become the owner of the underlying data for the
+ * previously returned UnicodeString.
* After clear() has been called, a new array will be used as well.
* @param buildOption Build option, see UStringTrieBuildOption.
* @param result A UnicodeString which will be set to the char16_t-serialized
@@ -147,7 +148,7 @@ private:
virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const;
virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, char16_t unit) const;
- virtual UBool matchNodesCanHaveValues() const { return TRUE; }
+ virtual UBool matchNodesCanHaveValues() const { return true; }
virtual int32_t getMaxBranchLinearSubNodeLength() const { return UCharsTrie::kMaxBranchLinearSubNodeLength; }
virtual int32_t getMinLinearMatch() const { return UCharsTrie::kMinLinearMatch; }
diff --git a/deps/icu-small/source/common/unicode/uchriter.h b/deps/icu-small/source/common/unicode/uchriter.h
index bee842cc25..84309b2416 100644
--- a/deps/icu-small/source/common/unicode/uchriter.h
+++ b/deps/icu-small/source/common/unicode/uchriter.h
@@ -274,11 +274,11 @@ public:
virtual UChar32 next32PostInc(void);
/**
- * Returns FALSE if there are no more code units or code points
+ * Returns false if there are no more code units or code points
* at or after the current position in the iteration range.
* This is used with nextPostInc() or next32PostInc() in forward
* iteration.
- * @return FALSE if there are no more code units or code points
+ * @return false if there are no more code units or code points
* at or after the current position in the iteration range.
* @stable ICU 2.0
*/
@@ -303,11 +303,11 @@ public:
virtual UChar32 previous32(void);
/**
- * Returns FALSE if there are no more code units or code points
+ * Returns false if there are no more code units or code points
* before the current position in the iteration range.
* This is used with previous() or previous32() in backward
* iteration.
- * @return FALSE if there are no more code units or code points
+ * @return false if there are no more code units or code points
* before the current position in the iteration range.
* @stable ICU 2.0
*/
diff --git a/deps/icu-small/source/common/unicode/uclean.h b/deps/icu-small/source/common/unicode/uclean.h
index ab0cd6da6b..f03593964a 100644
--- a/deps/icu-small/source/common/unicode/uclean.h
+++ b/deps/icu-small/source/common/unicode/uclean.h
@@ -49,7 +49,7 @@
*
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_init(UErrorCode *status);
#ifndef U_HIDE_SYSTEM_API
@@ -98,7 +98,7 @@ u_init(UErrorCode *status);
* @stable ICU 2.0
* @system
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_cleanup(void);
U_CDECL_BEGIN
@@ -148,7 +148,7 @@ typedef void U_CALLCONV UMemFreeFn (const void *context, void *mem);
* @stable ICU 2.8
* @system
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_setMemoryFunctions(const void *context, UMemAllocFn * U_CALLCONV_FPTR a, UMemReallocFn * U_CALLCONV_FPTR r, UMemFreeFn * U_CALLCONV_FPTR f,
UErrorCode *status);
diff --git a/deps/icu-small/source/common/unicode/ucnv.h b/deps/icu-small/source/common/unicode/ucnv.h
index ec7c5f350b..58f271cfb5 100644
--- a/deps/icu-small/source/common/unicode/ucnv.h
+++ b/deps/icu-small/source/common/unicode/ucnv.h
@@ -51,7 +51,10 @@
#include "unicode/ucnv_err.h"
#include "unicode/uenum.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
#if !defined(USET_DEFINED) && !defined(U_IN_DOXYGEN)
@@ -308,7 +311,7 @@ U_CDECL_END
* lexically follows name2.
* @stable ICU 2.0
*/
-U_STABLE int U_EXPORT2
+U_CAPI int U_EXPORT2
ucnv_compareNames(const char *name1, const char *name2);
@@ -362,7 +365,7 @@ ucnv_compareNames(const char *name1, const char *name2);
* @see ucnv_compareNames
* @stable ICU 2.0
*/
-U_STABLE UConverter* U_EXPORT2
+U_CAPI UConverter* U_EXPORT2
ucnv_open(const char *converterName, UErrorCode *err);
@@ -392,7 +395,7 @@ ucnv_open(const char *converterName, UErrorCode *err);
* @see ucnv_compareNames
* @stable ICU 2.0
*/
-U_STABLE UConverter* U_EXPORT2
+U_CAPI UConverter* U_EXPORT2
ucnv_openU(const UChar *name,
UErrorCode *err);
@@ -460,7 +463,7 @@ ucnv_openU(const UChar *name,
* @see UConverterPlatform
* @stable ICU 2.0
*/
-U_STABLE UConverter* U_EXPORT2
+U_CAPI UConverter* U_EXPORT2
ucnv_openCCSID(int32_t codepage,
UConverterPlatform platform,
UErrorCode * err);
@@ -476,7 +479,7 @@ ucnv_openCCSID(int32_t codepage,
* <p>The name will NOT be looked up in the alias mechanism, nor will the converter be
* stored in the converter cache or the alias table. The only way to open further converters
* is call this function multiple times, or use the ucnv_safeClone() function to clone a
- * 'master' converter.</p>
+ * 'primary' converter.</p>
*
* <p>A future version of ICU may add alias table lookups and/or caching
* to this function.</p>
@@ -495,7 +498,7 @@ ucnv_openCCSID(int32_t codepage,
* @see ucnv_close
* @stable ICU 2.2
*/
-U_STABLE UConverter* U_EXPORT2
+U_CAPI UConverter* U_EXPORT2
ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err);
/**
@@ -537,7 +540,7 @@ ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode
* @return pointer to the new clone
* @stable ICU 2.0
*/
-U_STABLE UConverter * U_EXPORT2
+U_CAPI UConverter * U_EXPORT2
ucnv_safeClone(const UConverter *cnv,
void *stackBuffer,
int32_t *pBufferSize,
@@ -566,7 +569,7 @@ ucnv_safeClone(const UConverter *cnv,
* @see ucnv_openCCSID
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_close(UConverter * converter);
#if U_SHOW_CPLUSPLUS_API
@@ -605,7 +608,7 @@ U_NAMESPACE_END
* @see ucnv_setSubstChars
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getSubstChars(const UConverter *converter,
char *subChars,
int8_t *len,
@@ -630,7 +633,7 @@ ucnv_getSubstChars(const UConverter *converter,
* @see ucnv_getSubstChars
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_setSubstChars(UConverter *converter,
const char *subChars,
int8_t len,
@@ -663,7 +666,7 @@ ucnv_setSubstChars(UConverter *converter,
* @see ucnv_getSubstChars
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_setSubstString(UConverter *cnv,
const UChar *s,
int32_t length,
@@ -682,7 +685,7 @@ ucnv_setSubstString(UConverter *cnv,
* <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getInvalidChars(const UConverter *converter,
char *errBytes,
int8_t *len,
@@ -701,7 +704,7 @@ ucnv_getInvalidChars(const UConverter *converter,
* <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getInvalidUChars(const UConverter *converter,
UChar *errUChars,
int8_t *len,
@@ -714,7 +717,7 @@ ucnv_getInvalidUChars(const UConverter *converter,
* @param converter the Unicode converter
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_reset(UConverter *converter);
/**
@@ -725,7 +728,7 @@ ucnv_reset(UConverter *converter);
* @param converter the Unicode converter
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_resetToUnicode(UConverter *converter);
/**
@@ -736,7 +739,7 @@ ucnv_resetToUnicode(UConverter *converter);
* @param converter the Unicode converter
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_resetFromUnicode(UConverter *converter);
/**
@@ -789,7 +792,7 @@ ucnv_resetFromUnicode(UConverter *converter);
* @see ucnv_getMinCharSize
* @stable ICU 2.0
*/
-U_STABLE int8_t U_EXPORT2
+U_CAPI int8_t U_EXPORT2
ucnv_getMaxCharSize(const UConverter *converter);
/**
@@ -822,7 +825,7 @@ ucnv_getMaxCharSize(const UConverter *converter);
* @see ucnv_getMaxCharSize
* @stable ICU 2.0
*/
-U_STABLE int8_t U_EXPORT2
+U_CAPI int8_t U_EXPORT2
ucnv_getMinCharSize(const UConverter *converter);
/**
@@ -839,7 +842,7 @@ ucnv_getMinCharSize(const UConverter *converter);
* @see ucnv_getName
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_getDisplayName(const UConverter *converter,
const char *displayLocale,
UChar *displayName,
@@ -856,7 +859,7 @@ ucnv_getDisplayName(const UConverter *converter,
* @see ucnv_getDisplayName
* @stable ICU 2.0
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucnv_getName(const UConverter *converter, UErrorCode *err);
/**
@@ -882,7 +885,7 @@ ucnv_getName(const UConverter *converter, UErrorCode *err);
* @see ucnv_getPlatform
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_getCCSID(const UConverter *converter,
UErrorCode *err);
@@ -896,7 +899,7 @@ ucnv_getCCSID(const UConverter *converter,
* @return The codepage platform
* @stable ICU 2.0
*/
-U_STABLE UConverterPlatform U_EXPORT2
+U_CAPI UConverterPlatform U_EXPORT2
ucnv_getPlatform(const UConverter *converter,
UErrorCode *err);
@@ -908,14 +911,14 @@ ucnv_getPlatform(const UConverter *converter,
* @return the type of the converter
* @stable ICU 2.0
*/
-U_STABLE UConverterType U_EXPORT2
+U_CAPI UConverterType U_EXPORT2
ucnv_getType(const UConverter * converter);
/**
* Gets the "starter" (lead) bytes for converters of type MBCS.
* Will fill in an <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> if converter passed in
* is not MBCS. Fills in an array of type UBool, with the value of the byte
- * as offset to the array. For example, if (starters[0x20] == TRUE) at return,
+ * as offset to the array. For example, if (starters[0x20] == true) at return,
* it means that the byte 0x20 is a starter byte in this converter.
* Context pointers are always owned by the caller.
*
@@ -926,7 +929,7 @@ ucnv_getType(const UConverter * converter);
* @see ucnv_getType
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getStarters(const UConverter* converter,
UBool starters[256],
UErrorCode* err);
@@ -997,7 +1000,7 @@ typedef enum UConverterUnicodeSet {
* @see uset_close
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getUnicodeSet(const UConverter *cnv,
USet *setFillIn,
UConverterUnicodeSet whichSet,
@@ -1014,7 +1017,7 @@ ucnv_getUnicodeSet(const UConverter *cnv,
* @see ucnv_setToUCallBack
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getToUCallBack (const UConverter * converter,
UConverterToUCallback *action,
const void **context);
@@ -1030,7 +1033,7 @@ ucnv_getToUCallBack (const UConverter * converter,
* @see ucnv_setFromUCallBack
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getFromUCallBack (const UConverter * converter,
UConverterFromUCallback *action,
const void **context);
@@ -1050,7 +1053,7 @@ ucnv_getFromUCallBack (const UConverter * converter,
* @see ucnv_getToUCallBack
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_setToUCallBack (UConverter * converter,
UConverterToUCallback newAction,
const void* newContext,
@@ -1073,7 +1076,7 @@ ucnv_setToUCallBack (UConverter * converter,
* @see ucnv_getFromUCallBack
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_setFromUCallBack (UConverter * converter,
UConverterFromUCallback newAction,
const void *newContext,
@@ -1100,7 +1103,7 @@ ucnv_setFromUCallBack (UConverter * converter,
* consumed. At that point, the caller should reset the source and
* sourceLimit pointers to point to the next chunk.
*
- * At the end of the stream (flush==TRUE), the input is completely consumed
+ * At the end of the stream (flush==true), the input is completely consumed
* when *source==sourceLimit and no error code is set.
* The converter object is then automatically reset by this function.
* (This means that a converter need not be reset explicitly between data
@@ -1125,9 +1128,9 @@ ucnv_setFromUCallBack (UConverter * converter,
* e.g: <TT>offsets[3]</TT> is equal to 6, it means that the <TT>target[3]</TT> was a result of transcoding <TT>source[6]</TT>
* For output data carried across calls, and other data without a specific source character
* (such as from escape sequences or callbacks) -1 will be placed for offsets.
- * @param flush set to <TT>TRUE</TT> if the current source buffer is the last available
- * chunk of the source, <TT>FALSE</TT> otherwise. Note that if a failing status is returned,
- * this function may have to be called multiple times with flush set to <TT>TRUE</TT> until
+ * @param flush set to <TT>true</TT> if the current source buffer is the last available
+ * chunk of the source, <TT>false</TT> otherwise. Note that if a failing status is returned,
+ * this function may have to be called multiple times with flush set to <TT>true</TT> until
* the source buffer is consumed.
* @param err the error status. <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> will be set if the
* converter is <TT>NULL</TT>.
@@ -1139,7 +1142,7 @@ ucnv_setFromUCallBack (UConverter * converter,
* @see ucnv_setToUCallBack
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_fromUnicode (UConverter * converter,
char **target,
const char *targetLimit,
@@ -1169,7 +1172,7 @@ ucnv_fromUnicode (UConverter * converter,
* consumed. At that point, the caller should reset the source and
* sourceLimit pointers to point to the next chunk.
*
- * At the end of the stream (flush==TRUE), the input is completely consumed
+ * At the end of the stream (flush==true), the input is completely consumed
* when *source==sourceLimit and no error code is set
* The converter object is then automatically reset by this function.
* (This means that a converter need not be reset explicitly between data
@@ -1193,9 +1196,9 @@ ucnv_fromUnicode (UConverter * converter,
* e.g: <TT>offsets[3]</TT> is equal to 6, it means that the <TT>target[3]</TT> was a result of transcoding <TT>source[6]</TT>
* For output data carried across calls, and other data without a specific source character
* (such as from escape sequences or callbacks) -1 will be placed for offsets.
- * @param flush set to <TT>TRUE</TT> if the current source buffer is the last available
- * chunk of the source, <TT>FALSE</TT> otherwise. Note that if a failing status is returned,
- * this function may have to be called multiple times with flush set to <TT>TRUE</TT> until
+ * @param flush set to <TT>true</TT> if the current source buffer is the last available
+ * chunk of the source, <TT>false</TT> otherwise. Note that if a failing status is returned,
+ * this function may have to be called multiple times with flush set to <TT>true</TT> until
* the source buffer is consumed.
* @param err the error status. <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> will be set if the
* converter is <TT>NULL</TT>.
@@ -1208,7 +1211,7 @@ ucnv_fromUnicode (UConverter * converter,
* @see ucnv_getNextUChar
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_toUnicode(UConverter *converter,
UChar **target,
const UChar *targetLimit,
@@ -1245,7 +1248,7 @@ ucnv_toUnicode(UConverter *converter,
* @see UCNV_GET_MAX_BYTES_FOR_STRING
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_fromUChars(UConverter *cnv,
char *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
@@ -1277,7 +1280,7 @@ ucnv_fromUChars(UConverter *cnv,
* @see ucnv_convert
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_toUChars(UConverter *cnv,
UChar *dest, int32_t destCapacity,
const char *src, int32_t srcLength,
@@ -1295,7 +1298,7 @@ ucnv_toUChars(UConverter *cnv,
* - Convenient.
*
* Limitations compared to ucnv_toUnicode():
- * - Always assumes flush=TRUE.
+ * - Always assumes flush=true.
* This makes ucnv_getNextUChar() unsuitable for "streaming" conversion,
* that is, for where the input is supplied in multiple buffers,
* because ucnv_getNextUChar() will assume the end of the input at the end
@@ -1306,7 +1309,7 @@ ucnv_toUChars(UConverter *cnv,
* ucnv_getNextUChar() uses the current state of the converter
* (unlike ucnv_toUChars() which always resets first).
* However, if ucnv_getNextUChar() is called after ucnv_toUnicode()
- * stopped in the middle of a character sequence (with flush=FALSE),
+ * stopped in the middle of a character sequence (with flush=false),
* then ucnv_getNextUChar() will always use the slower ucnv_toUnicode()
* internally until the next character boundary.
* (This is new in ICU 2.6. In earlier releases, ucnv_getNextUChar() had to
@@ -1353,7 +1356,7 @@ ucnv_toUChars(UConverter *cnv,
* @see ucnv_convert
* @stable ICU 2.0
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
ucnv_getNextUChar(UConverter * converter,
const char **source,
const char * sourceLimit,
@@ -1385,7 +1388,7 @@ ucnv_getNextUChar(UConverter * converter,
*
* ucnv_convertEx() also provides further convenience:
* - an option to reset the converters at the beginning
- * (if reset==TRUE, see parameters;
+ * (if reset==true, see parameters;
* also sets *pivotTarget=*pivotSource=pivotStart)
* - allow NUL-terminated input
* (only a single NUL byte, will not work for charsets with multi-byte NULs)
@@ -1442,7 +1445,7 @@ ucnv_getNextUChar(UConverter * converter,
* &target, u8+capacity,
* &s, s+length,
* NULL, NULL, NULL, NULL,
- * TRUE, TRUE,
+ * true, true,
* pErrorCode);
*
* myReleaseCachedUTF8Converter(utf8Cnv);
@@ -1474,7 +1477,7 @@ ucnv_getNextUChar(UConverter * converter,
* It must be pivotStart<=*pivotSource<=*pivotTarget<=pivotLimit
* and pivotStart<pivotLimit (unless pivotStart==NULL).
* @param pivotLimit Pointer to the first unit after the pivot buffer.
- * @param reset If TRUE, then ucnv_resetToUnicode(sourceCnv) and
+ * @param reset If true, then ucnv_resetToUnicode(sourceCnv) and
* ucnv_resetFromUnicode(targetCnv) are called, and the
* pivot pointers are reset (*pivotTarget=*pivotSource=pivotStart).
* @param flush If true, indicates the end of the input.
@@ -1497,7 +1500,7 @@ ucnv_getNextUChar(UConverter * converter,
* @see ucnv_toUChars
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv,
char **target, const char *targetLimit,
const char **source, const char *sourceLimit,
@@ -1561,7 +1564,7 @@ ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv,
* @see ucnv_getNextUChar
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_convert(const char *toConverterName,
const char *fromConverterName,
char *target,
@@ -1615,7 +1618,7 @@ ucnv_convert(const char *toConverterName,
* @see ucnv_toUChars
* @stable ICU 2.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_toAlgorithmic(UConverterType algorithmicType,
UConverter *cnv,
char *target, int32_t targetCapacity,
@@ -1667,7 +1670,7 @@ ucnv_toAlgorithmic(UConverterType algorithmicType,
* @see ucnv_toUChars
* @stable ICU 2.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_fromAlgorithmic(UConverter *cnv,
UConverterType algorithmicType,
char *target, int32_t targetCapacity,
@@ -1681,7 +1684,7 @@ ucnv_fromAlgorithmic(UConverter *cnv,
* @see ucnv_close
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_flushCache(void);
/**
@@ -1691,7 +1694,7 @@ ucnv_flushCache(void);
* @see ucnv_getAvailableName
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_countAvailable(void);
/**
@@ -1704,7 +1707,7 @@ ucnv_countAvailable(void);
* @see ucnv_countAvailable
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ucnv_getAvailableName(int32_t n);
/**
@@ -1719,7 +1722,7 @@ ucnv_getAvailableName(int32_t n);
* @see uenum_next
* @stable ICU 2.4
*/
-U_STABLE UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
ucnv_openAllNames(UErrorCode *pErrorCode);
/**
@@ -1732,7 +1735,7 @@ ucnv_openAllNames(UErrorCode *pErrorCode);
* @return number of names on alias list for given alias
* @stable ICU 2.0
*/
-U_STABLE uint16_t U_EXPORT2
+U_CAPI uint16_t U_EXPORT2
ucnv_countAliases(const char *alias, UErrorCode *pErrorCode);
/**
@@ -1747,7 +1750,7 @@ ucnv_countAliases(const char *alias, UErrorCode *pErrorCode);
* @see ucnv_countAliases
* @stable ICU 2.0
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode);
/**
@@ -1763,7 +1766,7 @@ ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode);
* @param pErrorCode result of operation
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode);
/**
@@ -1789,7 +1792,7 @@ ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode)
* @see uenum_next
* @stable ICU 2.2
*/
-U_STABLE UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
ucnv_openStandardNames(const char *convName,
const char *standard,
UErrorCode *pErrorCode);
@@ -1799,7 +1802,7 @@ ucnv_openStandardNames(const char *convName,
* @return number of standards
* @stable ICU 2.0
*/
-U_STABLE uint16_t U_EXPORT2
+U_CAPI uint16_t U_EXPORT2
ucnv_countStandards(void);
/**
@@ -1809,7 +1812,7 @@ ucnv_countStandards(void);
* @return returns the name of the standard at given index. Owned by the library.
* @stable ICU 2.0
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);
/**
@@ -1831,7 +1834,7 @@ ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);
* then <code>NULL</code> is returned. Owned by the library.
* @stable ICU 2.0
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode);
/**
@@ -1853,7 +1856,7 @@ ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorC
* @see ucnv_getStandardName
* @stable ICU 2.4
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode);
/**
@@ -1870,7 +1873,7 @@ ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErro
* @see ucnv_setDefaultName
* @stable ICU 2.0
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucnv_getDefaultName(void);
#ifndef U_HIDE_SYSTEM_API
@@ -1890,7 +1893,7 @@ ucnv_getDefaultName(void);
* @system
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_setDefaultName(const char *name);
#endif /* U_HIDE_SYSTEM_API */
@@ -1911,18 +1914,18 @@ ucnv_setDefaultName(const char *name);
* @see ucnv_isAmbiguous
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen);
/**
* Determines if the converter contains ambiguous mappings of the same
* character or not.
* @param cnv the converter to be tested
- * @return TRUE if the converter contains ambiguous mapping of the same
- * character, FALSE otherwise.
+ * @return true if the converter contains ambiguous mapping of the same
+ * character, false otherwise.
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucnv_isAmbiguous(const UConverter *cnv);
/**
@@ -1935,12 +1938,12 @@ ucnv_isAmbiguous(const UConverter *cnv);
* http://www.icu-project.org/userguide/conversion-data.html#ucmformat
*
* @param cnv The converter to set the fallback mapping usage on.
- * @param usesFallback TRUE if the user wants the converter to take advantage of the fallback
- * mapping, FALSE otherwise.
+ * @param usesFallback true if the user wants the converter to take advantage of the fallback
+ * mapping, false otherwise.
* @stable ICU 2.0
* @see ucnv_usesFallback
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_setFallback(UConverter *cnv, UBool usesFallback);
/**
@@ -1948,11 +1951,11 @@ ucnv_setFallback(UConverter *cnv, UBool usesFallback);
* This flag has restrictions, see ucnv_setFallback().
*
* @param cnv The converter to be tested
- * @return TRUE if the converter uses fallback, FALSE otherwise.
+ * @return true if the converter uses fallback, false otherwise.
* @stable ICU 2.0
* @see ucnv_setFallback
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucnv_usesFallback(const UConverter *cnv);
/**
@@ -1984,7 +1987,7 @@ ucnv_usesFallback(const UConverter *cnv);
* @return The name of the encoding detected. NULL if encoding is not detected.
* @stable ICU 2.4
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ucnv_detectUnicodeSignature(const char* source,
int32_t sourceLength,
int32_t *signatureLength,
@@ -2001,7 +2004,7 @@ ucnv_detectUnicodeSignature(const char* source,
* @return The number of UChars in the state. -1 if an error is encountered.
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status);
/**
@@ -2015,7 +2018,7 @@ ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status);
* @return The number of chars in the state. -1 if an error is encountered.
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status);
/**
@@ -2027,13 +2030,13 @@ ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status);
* but a UTF-32 converter encodes each code point with 4 bytes.
* Note: This method is not intended to be used to determine whether the charset has a
* fixed ratio of bytes to Unicode codes <i>units</i> for any particular Unicode encoding form.
- * FALSE is returned with the UErrorCode if error occurs or cnv is NULL.
+ * false is returned with the UErrorCode if error occurs or cnv is NULL.
* @param cnv The converter to be tested
* @param status ICU error code in/out paramter
- * @return TRUE if the converter is fixed-width
+ * @return true if the converter is fixed-width
* @stable ICU 4.8
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucnv_isFixedWidth(UConverter *cnv, UErrorCode *status);
#endif
diff --git a/deps/icu-small/source/common/unicode/ucnv_cb.h b/deps/icu-small/source/common/unicode/ucnv_cb.h
index 632cc0b35f..18240990db 100644
--- a/deps/icu-small/source/common/unicode/ucnv_cb.h
+++ b/deps/icu-small/source/common/unicode/ucnv_cb.h
@@ -84,7 +84,7 @@
* @see ucnv_cbFromUWriteSub
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_cbFromUWriteBytes (UConverterFromUnicodeArgs *args,
const char* source,
int32_t length,
@@ -104,7 +104,7 @@ ucnv_cbFromUWriteBytes (UConverterFromUnicodeArgs *args,
* @see ucnv_cbFromUWriteBytes
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnv_cbFromUWriteSub (UConverterFromUnicodeArgs *args,
int32_t offsetIndex,
UErrorCode * err);
@@ -121,7 +121,7 @@ ucnv_cbFromUWriteSub (UConverterFromUnicodeArgs *args,
* @see ucnv_cbToUWriteSub
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 ucnv_cbFromUWriteUChars(UConverterFromUnicodeArgs *args,
+U_CAPI void U_EXPORT2 ucnv_cbFromUWriteUChars(UConverterFromUnicodeArgs *args,
const UChar** source,
const UChar* sourceLimit,
int32_t offsetIndex,
@@ -140,7 +140,7 @@ U_STABLE void U_EXPORT2 ucnv_cbFromUWriteUChars(UConverterFromUnicodeArgs *args,
* @see ucnv_cbToUWriteSub
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 ucnv_cbToUWriteUChars (UConverterToUnicodeArgs *args,
+U_CAPI void U_EXPORT2 ucnv_cbToUWriteUChars (UConverterToUnicodeArgs *args,
const UChar* source,
int32_t length,
int32_t offsetIndex,
@@ -156,7 +156,7 @@ U_STABLE void U_EXPORT2 ucnv_cbToUWriteUChars (UConverterToUnicodeArgs *args,
* @see ucnv_cbToUWriteUChars
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 ucnv_cbToUWriteSub (UConverterToUnicodeArgs *args,
+U_CAPI void U_EXPORT2 ucnv_cbToUWriteSub (UConverterToUnicodeArgs *args,
int32_t offsetIndex,
UErrorCode * err);
#endif
diff --git a/deps/icu-small/source/common/unicode/ucnv_err.h b/deps/icu-small/source/common/unicode/ucnv_err.h
index 08c96c1440..bff90f0ba1 100644
--- a/deps/icu-small/source/common/unicode/ucnv_err.h
+++ b/deps/icu-small/source/common/unicode/ucnv_err.h
@@ -193,7 +193,7 @@ typedef enum {
*/
typedef struct {
uint16_t size; /**< The size of this struct. @stable ICU 2.0 */
- UBool flush; /**< The internal state of converter will be reset and data flushed if set to TRUE. @stable ICU 2.0 */
+ UBool flush; /**< The internal state of converter will be reset and data flushed if set to true. @stable ICU 2.0 */
UConverter *converter; /**< Pointer to the converter that is opened and to which this struct is passed as an argument. @stable ICU 2.0 */
const UChar *source; /**< Pointer to the source source buffer. @stable ICU 2.0 */
const UChar *sourceLimit; /**< Pointer to the limit (end + 1) of source buffer. @stable ICU 2.0 */
@@ -209,7 +209,7 @@ typedef struct {
*/
typedef struct {
uint16_t size; /**< The size of this struct @stable ICU 2.0 */
- UBool flush; /**< The internal state of converter will be reset and data flushed if set to TRUE. @stable ICU 2.0 */
+ UBool flush; /**< The internal state of converter will be reset and data flushed if set to true. @stable ICU 2.0 */
UConverter *converter; /**< Pointer to the converter that is opened and to which this struct is passed as an argument. @stable ICU 2.0 */
const char *source; /**< Pointer to the source source buffer. @stable ICU 2.0 */
const char *sourceLimit; /**< Pointer to the limit (end + 1) of source buffer. @stable ICU 2.0 */
@@ -233,7 +233,7 @@ typedef struct {
* @param err This should always be set to a failure status prior to calling.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP (
+U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP (
const void *context,
UConverterFromUnicodeArgs *fromUArgs,
const UChar* codeUnits,
@@ -257,7 +257,7 @@ U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP (
* @param err This should always be set to a failure status prior to calling.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP (
+U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP (
const void *context,
UConverterToUnicodeArgs *toUArgs,
const char* codeUnits,
@@ -284,7 +284,7 @@ U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP (
* otherwise this value will be set to a failure status.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SKIP (
+U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_SKIP (
const void *context,
UConverterFromUnicodeArgs *fromUArgs,
const UChar* codeUnits,
@@ -314,7 +314,7 @@ U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SKIP (
* @see ucnv_setSubstChars
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE (
+U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE (
const void *context,
UConverterFromUnicodeArgs *fromUArgs,
const UChar* codeUnits,
@@ -370,7 +370,7 @@ U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE (
* otherwise this value will be set to a failure status.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE (
+U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE (
const void *context,
UConverterFromUnicodeArgs *fromUArgs,
const UChar* codeUnits,
@@ -398,7 +398,7 @@ U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE (
* otherwise this value will be set to a failure status.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP (
+U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP (
const void *context,
UConverterToUnicodeArgs *toUArgs,
const char* codeUnits,
@@ -424,7 +424,7 @@ U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP (
* otherwise this value will be set to a failure status.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SUBSTITUTE (
+U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_SUBSTITUTE (
const void *context,
UConverterToUnicodeArgs *toUArgs,
const char* codeUnits,
@@ -450,7 +450,7 @@ U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SUBSTITUTE (
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_ESCAPE (
+U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_ESCAPE (
const void *context,
UConverterToUnicodeArgs *toUArgs,
const char* codeUnits,
diff --git a/deps/icu-small/source/common/unicode/ucnvsel.h b/deps/icu-small/source/common/unicode/ucnvsel.h
index 5fee53f179..b84bc86bed 100644
--- a/deps/icu-small/source/common/unicode/ucnvsel.h
+++ b/deps/icu-small/source/common/unicode/ucnvsel.h
@@ -29,7 +29,10 @@
#include "unicode/utf16.h"
#include "unicode/uenum.h"
#include "unicode/ucnv.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
@@ -72,7 +75,7 @@ typedef struct UConverterSelector UConverterSelector;
*
* @stable ICU 4.2
*/
-U_STABLE UConverterSelector* U_EXPORT2
+U_CAPI UConverterSelector* U_EXPORT2
ucnvsel_open(const char* const* converterList, int32_t converterListSize,
const USet* excludedCodePoints,
const UConverterUnicodeSet whichSet, UErrorCode* status);
@@ -90,7 +93,7 @@ ucnvsel_open(const char* const* converterList, int32_t converterListSize,
*
* @stable ICU 4.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucnvsel_close(UConverterSelector *sel);
#if U_SHOW_CPLUSPLUS_API
@@ -127,7 +130,7 @@ U_NAMESPACE_END
*
* @stable ICU 4.2
*/
-U_STABLE UConverterSelector* U_EXPORT2
+U_CAPI UConverterSelector* U_EXPORT2
ucnvsel_openFromSerialized(const void* buffer, int32_t length, UErrorCode* status);
/**
@@ -144,7 +147,7 @@ ucnvsel_openFromSerialized(const void* buffer, int32_t length, UErrorCode* statu
*
* @stable ICU 4.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucnvsel_serialize(const UConverterSelector* sel,
void* buffer, int32_t bufferCapacity, UErrorCode* status);
@@ -162,7 +165,7 @@ ucnvsel_serialize(const UConverterSelector* sel,
*
* @stable ICU 4.2
*/
-U_STABLE UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
ucnvsel_selectForString(const UConverterSelector* sel,
const UChar *s, int32_t length, UErrorCode *status);
@@ -180,7 +183,7 @@ ucnvsel_selectForString(const UConverterSelector* sel,
*
* @stable ICU 4.2
*/
-U_STABLE UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
ucnvsel_selectForUTF8(const UConverterSelector* sel,
const char *s, int32_t length, UErrorCode *status);
diff --git a/deps/icu-small/source/common/unicode/ucptrie.h b/deps/icu-small/source/common/unicode/ucptrie.h
index be06a22792..b95491b183 100644
--- a/deps/icu-small/source/common/unicode/ucptrie.h
+++ b/deps/icu-small/source/common/unicode/ucptrie.h
@@ -8,11 +8,13 @@
#define __UCPTRIE_H__
#include "unicode/utypes.h"
-
-#include "unicode/localpointer.h"
#include "unicode/ucpmap.h"
#include "unicode/utf8.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
U_CDECL_BEGIN
/**
@@ -580,11 +582,11 @@ enum {
// Do not conditionalize with #ifndef U_HIDE_INTERNAL_API, needed for public API
/** @internal */
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucptrie_internalSmallIndex(const UCPTrie *trie, UChar32 c);
/** @internal */
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucptrie_internalSmallU8Index(const UCPTrie *trie, int32_t lt1, uint8_t t2, uint8_t t3);
/**
@@ -592,7 +594,7 @@ ucptrie_internalSmallU8Index(const UCPTrie *trie, int32_t lt1, uint8_t t2, uint8
* Do not call directly.
* @internal
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucptrie_internalU8PrevIndex(const UCPTrie *trie, UChar32 c,
const uint8_t *start, const uint8_t *src);
diff --git a/deps/icu-small/source/common/unicode/ucurr.h b/deps/icu-small/source/common/unicode/ucurr.h
index 7149e7adf1..4e115cd01e 100644
--- a/deps/icu-small/source/common/unicode/ucurr.h
+++ b/deps/icu-small/source/common/unicode/ucurr.h
@@ -78,7 +78,7 @@ typedef enum UCurrencyUsage UCurrencyUsage;
* invalid.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucurr_forLocale(const char* locale,
UChar* buff,
int32_t buffCapacity,
@@ -113,7 +113,29 @@ typedef enum UCurrNameStyle {
*
* @stable ICU 61
*/
- UCURR_NARROW_SYMBOL_NAME
+ UCURR_NARROW_SYMBOL_NAME,
+
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Selector for getName() indicating the formal currency symbol.
+ * The formal currency symbol is similar to the regular currency
+ * symbol, but it always takes the form used in formal settings
+ * such as banking; for example, "NT$" instead of "$" for TWD in zh-TW.
+ *
+ * @draft ICU 68
+ */
+ UCURR_FORMAL_SYMBOL_NAME,
+
+ /**
+ * Selector for getName() indicating the variant currency symbol.
+ * The variant symbol for a currency is an alternative symbol
+ * that is not necessarily as widely used as the regular symbol.
+ *
+ * @draft ICU 68
+ */
+ UCURR_VARIANT_SYMBOL_NAME
+#endif // U_HIDE_DRAFT_API
+
} UCurrNameStyle;
#if !UCONFIG_NO_SERVICE
@@ -133,7 +155,7 @@ typedef const void* UCurrRegistryKey;
* if there was an error.
* @stable ICU 2.6
*/
-U_STABLE UCurrRegistryKey U_EXPORT2
+U_CAPI UCurrRegistryKey U_EXPORT2
ucurr_register(const UChar* isoCode,
const char* locale,
UErrorCode* status);
@@ -145,10 +167,10 @@ ucurr_register(const UChar* isoCode,
* restored.
* @param key the registry key returned by a previous call to ucurr_register
* @param status the in/out status code, no special meanings are assigned
- * @return TRUE if the currency for this key was successfully unregistered
+ * @return true if the currency for this key was successfully unregistered
* @stable ICU 2.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucurr_unregister(UCurrRegistryKey key, UErrorCode* status);
#endif /* UCONFIG_NO_SERVICE */
@@ -159,7 +181,7 @@ ucurr_unregister(UCurrRegistryKey key, UErrorCode* status);
* @param currency null-terminated 3-letter ISO 4217 code
* @param locale locale in which to display currency
* @param nameStyle selector for which kind of name to return
- * @param isChoiceFormat always set to FALSE, or can be NULL;
+ * @param isChoiceFormat always set to false, or can be NULL;
* display names are static strings;
* since ICU 4.4, ChoiceFormat patterns are no longer supported
* @param len fill-in parameter to receive length of result
@@ -169,7 +191,7 @@ ucurr_unregister(UCurrRegistryKey key, UErrorCode* status);
* returned.
* @stable ICU 2.6
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ucurr_getName(const UChar* currency,
const char* locale,
UCurrNameStyle nameStyle,
@@ -183,7 +205,7 @@ ucurr_getName(const UChar* currency,
* currency object in the en_US locale is "US dollar" or "US dollars".
* @param currency null-terminated 3-letter ISO 4217 code
* @param locale locale in which to display currency
- * @param isChoiceFormat always set to FALSE, or can be NULL;
+ * @param isChoiceFormat always set to false, or can be NULL;
* display names are static strings;
* since ICU 4.4, ChoiceFormat patterns are no longer supported
* @param pluralCount plural count
@@ -194,7 +216,7 @@ ucurr_getName(const UChar* currency,
* returned.
* @stable ICU 4.2
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ucurr_getPluralName(const UChar* currency,
const char* locale,
UBool* isChoiceFormat,
@@ -219,7 +241,7 @@ ucurr_getPluralName(const UChar* currency,
* displayed, or 0 if there is an error
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucurr_getDefaultFractionDigits(const UChar* currency,
UErrorCode* ec);
@@ -240,7 +262,7 @@ ucurr_getDefaultFractionDigits(const UChar* currency,
* displayed, or 0 if there is an error
* @stable ICU 54
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucurr_getDefaultFractionDigitsForUsage(const UChar* currency,
const UCurrencyUsage usage,
UErrorCode* ec);
@@ -255,7 +277,7 @@ ucurr_getDefaultFractionDigitsForUsage(const UChar* currency,
* or 0.0 if there is an error
* @stable ICU 3.0
*/
-U_STABLE double U_EXPORT2
+U_CAPI double U_EXPORT2
ucurr_getRoundingIncrement(const UChar* currency,
UErrorCode* ec);
@@ -269,7 +291,7 @@ ucurr_getRoundingIncrement(const UChar* currency,
* or 0.0 if there is an error
* @stable ICU 54
*/
-U_STABLE double U_EXPORT2
+U_CAPI double U_EXPORT2
ucurr_getRoundingIncrementForUsage(const UChar* currency,
const UCurrencyUsage usage,
UErrorCode* ec);
@@ -326,7 +348,7 @@ typedef enum UCurrCurrencyType {
* @param pErrorCode Error code
* @stable ICU 3.2
*/
-U_STABLE UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
ucurr_openISOCurrencies(uint32_t currType, UErrorCode *pErrorCode);
/**
@@ -351,11 +373,11 @@ ucurr_openISOCurrencies(uint32_t currType, UErrorCode *pErrorCode);
* @param errorCode
* ICU error code
*
- * @return TRUE if the given ISO 4217 3-letter code is supported on the specified date range.
+ * @return true if the given ISO 4217 3-letter code is supported on the specified date range.
*
* @stable ICU 4.8
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucurr_isAvailable(const UChar* isoCode,
UDate from,
UDate to,
@@ -375,7 +397,7 @@ ucurr_isAvailable(const UChar* isoCode,
* values are invalid.
* @stable ICU 4.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucurr_countCurrencies(const char* locale,
UDate date,
UErrorCode* ec);
@@ -399,7 +421,7 @@ ucurr_countCurrencies(const char* locale,
* invalid.
* @stable ICU 4.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucurr_forLocaleAndDate(const char* locale,
UDate date,
int32_t index,
@@ -423,7 +445,7 @@ ucurr_forLocaleAndDate(const char* locale,
* @return a string enumeration over keyword values for the given key and the locale.
* @stable ICU 4.2
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
ucurr_getKeywordValuesForLocale(const char* key,
const char* locale,
UBool commonlyUsed,
@@ -438,7 +460,7 @@ ucurr_getKeywordValuesForLocale(const char* key,
* @return The ISO 4217 numeric code of the currency
* @stable ICU 49
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucurr_getNumericCode(const UChar* currency);
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/common/unicode/udata.h b/deps/icu-small/source/common/unicode/udata.h
index 8236877b44..88c0dded11 100644
--- a/deps/icu-small/source/common/unicode/udata.h
+++ b/deps/icu-small/source/common/unicode/udata.h
@@ -20,7 +20,10 @@
#define __UDATA_H__
#include "unicode/utypes.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
U_CDECL_BEGIN
@@ -166,8 +169,8 @@ typedef struct UDataMemory UDataMemory;
* @param pInfo A pointer to the <code>UDataInfo</code> structure
* of data that has been loaded and will be returned
* by <code>udata_openChoice()</code> if this function
- * returns <code>TRUE</code>.
- * @return TRUE if the current data memory is acceptable
+ * returns <code>true</code>.
+ * @return true if the current data memory is acceptable
* @stable ICU 2.0
*/
typedef UBool U_CALLCONV
@@ -197,7 +200,7 @@ UDataMemoryIsAcceptable(void *context,
* @see udata_openChoice
* @stable ICU 2.0
*/
-U_STABLE UDataMemory * U_EXPORT2
+U_CAPI UDataMemory * U_EXPORT2
udata_open(const char *path, const char *type, const char *name,
UErrorCode *pErrorCode);
@@ -239,7 +242,7 @@ udata_open(const char *path, const char *type, const char *name,
* This may be <code>NULL</code> or empty.
* @param name A string that specifies the name of the data.
* @param isAcceptable This function is called to verify that loaded data
- * is useful for the client code. If it returns FALSE
+ * is useful for the client code. If it returns false
* for all data items, then <code>udata_openChoice()</code>
* will return with an error.
* @param context Arbitrary parameter to be passed into isAcceptable.
@@ -249,7 +252,7 @@ udata_open(const char *path, const char *type, const char *name,
* to get a pointer to the actual data.
* @stable ICU 2.0
*/
-U_STABLE UDataMemory * U_EXPORT2
+U_CAPI UDataMemory * U_EXPORT2
udata_openChoice(const char *path, const char *type, const char *name,
UDataMemoryIsAcceptable *isAcceptable, void *context,
UErrorCode *pErrorCode);
@@ -261,7 +264,7 @@ udata_openChoice(const char *path, const char *type, const char *name,
* @param pData The pointer to data memory object
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udata_close(UDataMemory *pData);
/**
@@ -273,7 +276,7 @@ udata_close(UDataMemory *pData);
* @param pData The pointer to data memory object
* @stable ICU 2.0
*/
-U_STABLE const void * U_EXPORT2
+U_CAPI const void * U_EXPORT2
udata_getMemory(UDataMemory *pData);
/**
@@ -294,7 +297,7 @@ udata_getMemory(UDataMemory *pData);
* adjusted and only part of the structure will be filled.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udata_getInfo(UDataMemory *pData, UDataInfo *pInfo);
/**
@@ -303,7 +306,7 @@ udata_getInfo(UDataMemory *pData, UDataInfo *pInfo);
* area in memory.
*
* ICU data must be at least 8-aligned, and should be 16-aligned.
- * See http://userguide.icu-project.org/icudata
+ * See https://unicode-org.github.io/icu/userguide/icudata
*
* The format of this data is that of the icu common data file, as is
* generated by the pkgdata tool with mode=common or mode=dll.
@@ -340,7 +343,7 @@ udata_getInfo(UDataMemory *pData, UDataInfo *pInfo);
* @param err outgoing error status <code>U_USING_DEFAULT_WARNING, U_UNSUPPORTED_ERROR</code>
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udata_setCommonData(const void *data, UErrorCode *err);
@@ -350,7 +353,7 @@ udata_setCommonData(const void *data, UErrorCode *err);
* pointer.
*
* ICU data must be at least 8-aligned, and should be 16-aligned.
- * See http://userguide.icu-project.org/icudata
+ * See https://unicode-org.github.io/icu/userguide/icudata
*
* The format of this data is that of the icu common data file, like 'icudt26l.dat'
* or the corresponding shared library (DLL) file.
@@ -371,7 +374,7 @@ udata_setCommonData(const void *data, UErrorCode *err);
* @see udata_setCommonData
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udata_setAppData(const char *packageName, const void *data, UErrorCode *err);
/**
@@ -410,7 +413,7 @@ typedef enum UDataFileAccess {
* @see UDataFileAccess
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udata_setFileAccess(UDataFileAccess access, UErrorCode *status);
U_CDECL_END
diff --git a/deps/icu-small/source/common/unicode/udisplaycontext.h b/deps/icu-small/source/common/unicode/udisplaycontext.h
index 398481c681..6e14217980 100644
--- a/deps/icu-small/source/common/unicode/udisplaycontext.h
+++ b/deps/icu-small/source/common/unicode/udisplaycontext.h
@@ -156,7 +156,8 @@ enum UDisplayContext {
UDISPCTX_SUBSTITUTE = (UDISPCTX_TYPE_SUBSTITUTE_HANDLING<<8) + 0,
/**
* A possible setting for SUBSTITUTE_HANDLING:
- * Returns a null value when no data is available.
+ * Returns a null value with error code set to U_ILLEGAL_ARGUMENT_ERROR when no
+ * data is available.
* @stable ICU 58
*/
UDISPCTX_NO_SUBSTITUTE = (UDISPCTX_TYPE_SUBSTITUTE_HANDLING<<8) + 1
diff --git a/deps/icu-small/source/common/unicode/uenum.h b/deps/icu-small/source/common/unicode/uenum.h
index eb8ecdf88b..f1c506934b 100644
--- a/deps/icu-small/source/common/unicode/uenum.h
+++ b/deps/icu-small/source/common/unicode/uenum.h
@@ -20,13 +20,14 @@
#define __UENUM_H
#include "unicode/utypes.h"
-#include "unicode/localpointer.h"
#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+
U_NAMESPACE_BEGIN
class StringEnumeration;
U_NAMESPACE_END
-#endif
+#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
@@ -49,7 +50,7 @@ typedef struct UEnumeration UEnumeration;
* @param en UEnumeration structure pointer
* @stable ICU 2.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uenum_close(UEnumeration* en);
#if U_SHOW_CPLUSPLUS_API
@@ -85,7 +86,7 @@ U_NAMESPACE_END
* @return number of elements in the iterator
* @stable ICU 2.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uenum_count(UEnumeration* en, UErrorCode* status);
/**
@@ -109,7 +110,7 @@ uenum_count(UEnumeration* en, UErrorCode* status);
* traversed, returns NULL.
* @stable ICU 2.2
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
uenum_unext(UEnumeration* en,
int32_t* resultLength,
UErrorCode* status);
@@ -142,7 +143,7 @@ uenum_unext(UEnumeration* en,
* traversed, returns NULL.
* @stable ICU 2.2
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uenum_next(UEnumeration* en,
int32_t* resultLength,
UErrorCode* status);
@@ -156,7 +157,7 @@ uenum_next(UEnumeration* en,
* the iterator is out of sync with its service.
* @stable ICU 2.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uenum_reset(UEnumeration* en, UErrorCode* status);
#if U_SHOW_CPLUSPLUS_API
@@ -170,7 +171,7 @@ uenum_reset(UEnumeration* en, UErrorCode* status);
* @return a UEnumeration wrapping the adopted StringEnumeration.
* @stable ICU 4.2
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
uenum_openFromStringEnumeration(icu::StringEnumeration* adopted, UErrorCode* ec);
#endif
@@ -186,7 +187,7 @@ uenum_openFromStringEnumeration(icu::StringEnumeration* adopted, UErrorCode* ec)
* @see uenum_close
* @stable ICU 50
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
uenum_openUCharStringsEnumeration(const UChar* const strings[], int32_t count,
UErrorCode* ec);
@@ -201,7 +202,7 @@ uenum_openUCharStringsEnumeration(const UChar* const strings[], int32_t count,
* @see uenum_close
* @stable ICU 50
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
uenum_openCharStringsEnumeration(const char* const strings[], int32_t count,
UErrorCode* ec);
diff --git a/deps/icu-small/source/common/unicode/uidna.h b/deps/icu-small/source/common/unicode/uidna.h
index cb79ba8545..1f75562555 100644
--- a/deps/icu-small/source/common/unicode/uidna.h
+++ b/deps/icu-small/source/common/unicode/uidna.h
@@ -23,9 +23,13 @@
#if !UCONFIG_NO_IDNA
-#include "unicode/localpointer.h"
+#include <stdbool.h>
#include "unicode/parseerr.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* \file
* \brief C API: Internationalizing Domain Names in Applications (IDNA)
@@ -138,7 +142,7 @@ typedef struct UIDNA UIDNA; /**< C typedef for struct UIDNA. @stable ICU 4.6 */
* @return the UTS #46 UIDNA instance, if successful
* @stable ICU 4.6
*/
-U_STABLE UIDNA * U_EXPORT2
+U_CAPI UIDNA * U_EXPORT2
uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode);
/**
@@ -146,7 +150,7 @@ uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode);
* @param idna UIDNA instance to be closed
* @stable ICU 4.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uidna_close(UIDNA *idna);
#if U_SHOW_CPLUSPLUS_API
@@ -182,7 +186,7 @@ typedef struct UIDNAInfo {
/** sizeof(UIDNAInfo) @stable ICU 4.6 */
int16_t size;
/**
- * Set to TRUE if transitional and nontransitional processing produce different results.
+ * Set to true if transitional and nontransitional processing produce different results.
* For details see C++ IDNAInfo::isTransitionalDifferent().
* @stable ICU 4.6
*/
@@ -204,7 +208,7 @@ typedef struct UIDNAInfo {
*/
#define UIDNA_INFO_INITIALIZER { \
(int16_t)sizeof(UIDNAInfo), \
- FALSE, FALSE, \
+ false, false, \
0, 0, 0 }
/**
@@ -230,7 +234,7 @@ typedef struct UIDNAInfo {
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_labelToASCII(const UIDNA *idna,
const UChar *label, int32_t length,
UChar *dest, int32_t capacity,
@@ -257,7 +261,7 @@ uidna_labelToASCII(const UIDNA *idna,
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_labelToUnicode(const UIDNA *idna,
const UChar *label, int32_t length,
UChar *dest, int32_t capacity,
@@ -286,7 +290,7 @@ uidna_labelToUnicode(const UIDNA *idna,
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_nameToASCII(const UIDNA *idna,
const UChar *name, int32_t length,
UChar *dest, int32_t capacity,
@@ -313,7 +317,7 @@ uidna_nameToASCII(const UIDNA *idna,
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_nameToUnicode(const UIDNA *idna,
const UChar *name, int32_t length,
UChar *dest, int32_t capacity,
@@ -338,7 +342,7 @@ uidna_nameToUnicode(const UIDNA *idna,
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_labelToASCII_UTF8(const UIDNA *idna,
const char *label, int32_t length,
char *dest, int32_t capacity,
@@ -361,7 +365,7 @@ uidna_labelToASCII_UTF8(const UIDNA *idna,
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_labelToUnicodeUTF8(const UIDNA *idna,
const char *label, int32_t length,
char *dest, int32_t capacity,
@@ -384,7 +388,7 @@ uidna_labelToUnicodeUTF8(const UIDNA *idna,
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_nameToASCII_UTF8(const UIDNA *idna,
const char *name, int32_t length,
char *dest, int32_t capacity,
@@ -407,7 +411,7 @@ uidna_nameToASCII_UTF8(const UIDNA *idna,
* @return destination string length
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uidna_nameToUnicodeUTF8(const UIDNA *idna,
const char *name, int32_t length,
char *dest, int32_t capacity,
diff --git a/deps/icu-small/source/common/unicode/uiter.h b/deps/icu-small/source/common/unicode/uiter.h
index 3b8537204c..7dbe126666 100644
--- a/deps/icu-small/source/common/unicode/uiter.h
+++ b/deps/icu-small/source/common/unicode/uiter.h
@@ -492,7 +492,7 @@ struct UCharIterator {
* @see UnicodeString::char32At()
* @stable ICU 2.1
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
uiter_current32(UCharIterator *iter);
/**
@@ -509,7 +509,7 @@ uiter_current32(UCharIterator *iter);
* @see U16_NEXT
* @stable ICU 2.1
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
uiter_next32(UCharIterator *iter);
/**
@@ -526,7 +526,7 @@ uiter_next32(UCharIterator *iter);
* @see U16_PREV
* @stable ICU 2.1
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
uiter_previous32(UCharIterator *iter);
/**
@@ -547,7 +547,7 @@ uiter_previous32(UCharIterator *iter);
* @see UITER_NO_STATE
* @stable ICU 2.6
*/
-U_STABLE uint32_t U_EXPORT2
+U_CAPI uint32_t U_EXPORT2
uiter_getState(const UCharIterator *iter);
/**
@@ -565,7 +565,7 @@ uiter_getState(const UCharIterator *iter);
* @see UCharIteratorSetState
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);
/**
@@ -590,7 +590,7 @@ uiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);
* @see UCharIterator
* @stable ICU 2.1
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uiter_setString(UCharIterator *iter, const UChar *s, int32_t length);
/**
@@ -613,7 +613,7 @@ uiter_setString(UCharIterator *iter, const UChar *s, int32_t length);
* @see uiter_setString
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length);
/**
@@ -649,7 +649,7 @@ uiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length);
* @see UCharIterator
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uiter_setUTF8(UCharIterator *iter, const char *s, int32_t length);
#if U_SHOW_CPLUSPLUS_API
@@ -674,7 +674,7 @@ uiter_setUTF8(UCharIterator *iter, const char *s, int32_t length);
* @see UCharIterator
* @stable ICU 2.1
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uiter_setCharacterIterator(UCharIterator *iter, icu::CharacterIterator *charIter);
/**
@@ -699,7 +699,7 @@ uiter_setCharacterIterator(UCharIterator *iter, icu::CharacterIterator *charIter
* @see UCharIterator
* @stable ICU 2.1
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uiter_setReplaceable(UCharIterator *iter, const icu::Replaceable *rep);
#endif
diff --git a/deps/icu-small/source/common/unicode/uldnames.h b/deps/icu-small/source/common/unicode/uldnames.h
index 3a3c0a0657..10f0e91e55 100644
--- a/deps/icu-small/source/common/unicode/uldnames.h
+++ b/deps/icu-small/source/common/unicode/uldnames.h
@@ -16,10 +16,13 @@
*/
#include "unicode/utypes.h"
-#include "unicode/localpointer.h"
#include "unicode/uscript.h"
#include "unicode/udisplaycontext.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* Enum used in LocaleDisplayNames::createInstance.
* @stable ICU 4.4
@@ -65,7 +68,7 @@ typedef struct ULocaleDisplayNames ULocaleDisplayNames;
* @param pErrorCode the status code
* @stable ICU 4.4
*/
-U_STABLE ULocaleDisplayNames * U_EXPORT2
+U_CAPI ULocaleDisplayNames * U_EXPORT2
uldn_open(const char * locale,
UDialectHandling dialectHandling,
UErrorCode *pErrorCode);
@@ -75,7 +78,7 @@ uldn_open(const char * locale,
* @param ldn the ULocaleDisplayNames instance to be closed
* @stable ICU 4.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uldn_close(ULocaleDisplayNames *ldn);
#if U_SHOW_CPLUSPLUS_API
@@ -106,7 +109,7 @@ U_NAMESPACE_END
* @return the display locale
* @stable ICU 4.4
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
uldn_getLocale(const ULocaleDisplayNames *ldn);
/**
@@ -115,7 +118,7 @@ uldn_getLocale(const ULocaleDisplayNames *ldn);
* @return the dialect handling enum
* @stable ICU 4.4
*/
-U_STABLE UDialectHandling U_EXPORT2
+U_CAPI UDialectHandling U_EXPORT2
uldn_getDialectHandling(const ULocaleDisplayNames *ldn);
/* names for entire locales */
@@ -131,7 +134,7 @@ uldn_getDialectHandling(const ULocaleDisplayNames *ldn);
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_localeDisplayName(const ULocaleDisplayNames *ldn,
const char *locale,
UChar *result,
@@ -151,7 +154,7 @@ uldn_localeDisplayName(const ULocaleDisplayNames *ldn,
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_languageDisplayName(const ULocaleDisplayNames *ldn,
const char *lang,
UChar *result,
@@ -169,7 +172,7 @@ uldn_languageDisplayName(const ULocaleDisplayNames *ldn,
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_scriptDisplayName(const ULocaleDisplayNames *ldn,
const char *script,
UChar *result,
@@ -187,7 +190,7 @@ uldn_scriptDisplayName(const ULocaleDisplayNames *ldn,
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_scriptCodeDisplayName(const ULocaleDisplayNames *ldn,
UScriptCode scriptCode,
UChar *result,
@@ -205,7 +208,7 @@ uldn_scriptCodeDisplayName(const ULocaleDisplayNames *ldn,
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_regionDisplayName(const ULocaleDisplayNames *ldn,
const char *region,
UChar *result,
@@ -223,7 +226,7 @@ uldn_regionDisplayName(const ULocaleDisplayNames *ldn,
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_variantDisplayName(const ULocaleDisplayNames *ldn,
const char *variant,
UChar *result,
@@ -241,7 +244,7 @@ uldn_variantDisplayName(const ULocaleDisplayNames *ldn,
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_keyDisplayName(const ULocaleDisplayNames *ldn,
const char *key,
UChar *result,
@@ -260,7 +263,7 @@ uldn_keyDisplayName(const ULocaleDisplayNames *ldn,
* greater than maxResultSize, the returned name will be truncated.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uldn_keyValueDisplayName(const ULocaleDisplayNames *ldn,
const char *key,
const char *value,
@@ -282,7 +285,7 @@ uldn_keyValueDisplayName(const ULocaleDisplayNames *ldn,
* @return a ULocaleDisplayNames instance
* @stable ICU 51
*/
-U_STABLE ULocaleDisplayNames * U_EXPORT2
+U_CAPI ULocaleDisplayNames * U_EXPORT2
uldn_openForContext(const char * locale, UDisplayContext *contexts,
int32_t length, UErrorCode *pErrorCode);
@@ -296,7 +299,7 @@ uldn_openForContext(const char * locale, UDisplayContext *contexts,
* @return the UDisplayContextValue for the specified type.
* @stable ICU 51
*/
-U_STABLE UDisplayContext U_EXPORT2
+U_CAPI UDisplayContext U_EXPORT2
uldn_getContext(const ULocaleDisplayNames *ldn, UDisplayContextType type,
UErrorCode *pErrorCode);
diff --git a/deps/icu-small/source/common/unicode/uloc.h b/deps/icu-small/source/common/unicode/uloc.h
index a10ab526ce..56fb4c9b37 100644
--- a/deps/icu-small/source/common/unicode/uloc.h
+++ b/deps/icu-small/source/common/unicode/uloc.h
@@ -371,7 +371,7 @@ typedef enum {
* @system
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_getDefault(void);
/**
@@ -391,7 +391,7 @@ uloc_getDefault(void);
* @system
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uloc_setDefault(const char* localeID,
UErrorCode* status);
#endif /* U_HIDE_SYSTEM_API */
@@ -408,7 +408,7 @@ uloc_setDefault(const char* localeID,
* than languageCapacity, the returned language code will be truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getLanguage(const char* localeID,
char* language,
int32_t languageCapacity,
@@ -426,7 +426,7 @@ uloc_getLanguage(const char* localeID,
* than scriptCapacity, the returned language code will be truncated.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getScript(const char* localeID,
char* script,
int32_t scriptCapacity,
@@ -444,7 +444,7 @@ uloc_getScript(const char* localeID,
* than countryCapacity, the returned country code will be truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getCountry(const char* localeID,
char* country,
int32_t countryCapacity,
@@ -462,7 +462,7 @@ uloc_getCountry(const char* localeID,
* than variantCapacity, the returned variant code will be truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getVariant(const char* localeID,
char* variant,
int32_t variantCapacity,
@@ -485,7 +485,7 @@ uloc_getVariant(const char* localeID,
* than nameCapacity, the returned full name will be truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getName(const char* localeID,
char* name,
int32_t nameCapacity,
@@ -508,7 +508,7 @@ uloc_getName(const char* localeID,
* than nameCapacity, the returned full name will be truncated.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_canonicalize(const char* localeID,
char* name,
int32_t nameCapacity,
@@ -521,7 +521,7 @@ uloc_canonicalize(const char* localeID,
* @return language the ISO language code for localeID
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_getISO3Language(const char* localeID);
@@ -532,7 +532,7 @@ uloc_getISO3Language(const char* localeID);
* @return country the ISO country code for localeID
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_getISO3Country(const char* localeID);
/**
@@ -546,26 +546,31 @@ uloc_getISO3Country(const char* localeID);
* @return country the Win32 LCID for localeID
* @stable ICU 2.0
*/
-U_STABLE uint32_t U_EXPORT2
+U_CAPI uint32_t U_EXPORT2
uloc_getLCID(const char* localeID);
/**
* Gets the language name suitable for display for the specified locale.
*
* @param locale the locale to get the ISO language code with
- * @param displayLocale Specifies the locale to be used to display the name. In other words,
- * if the locale's language code is "en", passing Locale::getFrench() for
- * inLocale would result in "Anglais", while passing Locale::getGerman()
- * for inLocale would result in "Englisch".
+ * @param displayLocale Specifies the locale to be used to display the name. In
+ * other words, if the locale's language code is "en", passing
+ * Locale::getFrench() for inLocale would result in "Anglais",
+ * while passing Locale::getGerman() for inLocale would result
+ * in "Englisch".
* @param language the displayable language code for localeID
* @param languageCapacity the size of the language buffer to store the
- * displayable language code with
- * @param status error information if retrieving the displayable language code failed
- * @return the actual buffer size needed for the displayable language code. If it's greater
- * than languageCapacity, the returned language code will be truncated.
+ * displayable language code with.
+ * @param status error information if retrieving the displayable language code
+ * failed. U_USING_DEFAULT_WARNING indicates that no data was
+ * found from the locale resources and a case canonicalized
+ * language code is placed into language as fallback.
+ * @return the actual buffer size needed for the displayable language code. If
+ * it's greater than languageCapacity, the returned language
+ * code will be truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getDisplayLanguage(const char* locale,
const char* displayLocale,
UChar* language,
@@ -575,20 +580,26 @@ uloc_getDisplayLanguage(const char* locale,
/**
* Gets the script name suitable for display for the specified locale.
*
- * @param locale the locale to get the displayable script code with. NULL may be used to specify the default.
- * @param displayLocale Specifies the locale to be used to display the name. In other words,
- * if the locale's language code is "en", passing Locale::getFrench() for
- * inLocale would result in "", while passing Locale::getGerman()
- * for inLocale would result in "". NULL may be used to specify the default.
- * @param script the displayable script for the localeID
- * @param scriptCapacity the size of the script buffer to store the
- * displayable script code with
- * @param status error information if retrieving the displayable script code failed
- * @return the actual buffer size needed for the displayable script code. If it's greater
- * than scriptCapacity, the returned displayable script code will be truncated.
+ * @param locale the locale to get the displayable script code with. NULL may be
+ * used to specify the default.
+ * @param displayLocale Specifies the locale to be used to display the name. In
+ * other words, if the locale's language code is "en", passing
+ * Locale::getFrench() for inLocale would result in "", while
+ * passing Locale::getGerman() for inLocale would result in "".
+ * NULL may be used to specify the default.
+ * @param script the displayable script for the localeID.
+ * @param scriptCapacity the size of the script buffer to store the displayable
+ * script code with.
+ * @param status error information if retrieving the displayable script code
+ * failed. U_USING_DEFAULT_WARNING indicates that no data was
+ * found from the locale resources and a case canonicalized
+ * script code is placed into script as fallback.
+ * @return the actual buffer size needed for the displayable script code. If
+ * it's greater than scriptCapacity, the returned displayable
+ * script code will be truncated.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getDisplayScript(const char* locale,
const char* displayLocale,
UChar* script,
@@ -597,23 +608,30 @@ uloc_getDisplayScript(const char* locale,
/**
* Gets the country name suitable for display for the specified locale.
- * Warning: this is for the region part of a valid locale ID; it cannot just be the region code (like "FR").
- * To get the display name for a region alone, or for other options, use ULocaleDisplayNames instead.
- *
- * @param locale the locale to get the displayable country code with. NULL may be used to specify the default.
- * @param displayLocale Specifies the locale to be used to display the name. In other words,
- * if the locale's language code is "en", passing Locale::getFrench() for
- * inLocale would result in "Anglais", while passing Locale::getGerman()
- * for inLocale would result in "Englisch". NULL may be used to specify the default.
- * @param country the displayable country code for localeID
+ * Warning: this is for the region part of a valid locale ID; it cannot just be
+ * the region code (like "FR"). To get the display name for a region alone, or
+ * for other options, use ULocaleDisplayNames instead.
+ *
+ * @param locale the locale to get the displayable country code with. NULL may
+ * be used to specify the default.
+ * @param displayLocale Specifies the locale to be used to display the name. In
+ * other words, if the locale's language code is "en", passing
+ * Locale::getFrench() for inLocale would result in "Anglais",
+ * while passing Locale::getGerman() for inLocale would result
+ * in "Englisch". NULL may be used to specify the default.
+ * @param country the displayable country code for localeID.
* @param countryCapacity the size of the country buffer to store the
- * displayable country code with
- * @param status error information if retrieving the displayable country code failed
- * @return the actual buffer size needed for the displayable country code. If it's greater
- * than countryCapacity, the returned displayable country code will be truncated.
+ * displayable country code with.
+ * @param status error information if retrieving the displayable country code
+ * failed. U_USING_DEFAULT_WARNING indicates that no data was
+ * found from the locale resources and a case canonicalized
+ * country code is placed into country as fallback.
+ * @return the actual buffer size needed for the displayable country code. If
+ * it's greater than countryCapacity, the returned displayable
+ * country code will be truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getDisplayCountry(const char* locale,
const char* displayLocale,
UChar* country,
@@ -624,20 +642,26 @@ uloc_getDisplayCountry(const char* locale,
/**
* Gets the variant name suitable for display for the specified locale.
*
- * @param locale the locale to get the displayable variant code with. NULL may be used to specify the default.
- * @param displayLocale Specifies the locale to be used to display the name. In other words,
- * if the locale's language code is "en", passing Locale::getFrench() for
- * inLocale would result in "Anglais", while passing Locale::getGerman()
- * for inLocale would result in "Englisch". NULL may be used to specify the default.
- * @param variant the displayable variant code for localeID
+ * @param locale the locale to get the displayable variant code with. NULL may
+ * be used to specify the default.
+ * @param displayLocale Specifies the locale to be used to display the name. In
+ * other words, if the locale's language code is "en", passing
+ * Locale::getFrench() for inLocale would result in "Anglais",
+ * while passing Locale::getGerman() for inLocale would result
+ * in "Englisch". NULL may be used to specify the default.
+ * @param variant the displayable variant code for localeID.
* @param variantCapacity the size of the variant buffer to store the
- * displayable variant code with
- * @param status error information if retrieving the displayable variant code failed
- * @return the actual buffer size needed for the displayable variant code. If it's greater
- * than variantCapacity, the returned displayable variant code will be truncated.
+ * displayable variant code with.
+ * @param status error information if retrieving the displayable variant code
+ * failed. U_USING_DEFAULT_WARNING indicates that no data was
+ * found from the locale resources and a case canonicalized
+ * variant code is placed into variant as fallback.
+ * @return the actual buffer size needed for the displayable variant code. If
+ * it's greater than variantCapacity, the returned displayable
+ * variant code will be truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getDisplayVariant(const char* locale,
const char* displayLocale,
UChar* variant,
@@ -645,8 +669,8 @@ uloc_getDisplayVariant(const char* locale,
UErrorCode* status);
/**
- * Gets the keyword name suitable for display for the specified locale.
- * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display
+ * Gets the keyword name suitable for display for the specified locale. E.g:
+ * for the locale string de_DE\@collation=PHONEBOOK, this API gets the display
* string for the keyword collation.
* Usage:
* <code>
@@ -680,11 +704,13 @@ uloc_getDisplayVariant(const char* locale,
* result without writing any of the result string (pre-flighting).
* @param status error information if retrieving the displayable string failed.
* Should not be NULL and should not indicate failure on entry.
+ * U_USING_DEFAULT_WARNING indicates that no data was found from the locale
+ * resources and the keyword is placed into dest as fallback.
* @return the actual buffer size needed for the displayable variant code.
* @see #uloc_openKeywords
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getDisplayKeyword(const char* keyword,
const char* displayLocale,
UChar* dest,
@@ -707,10 +733,12 @@ uloc_getDisplayKeyword(const char* keyword,
* result without writing any of the result string (pre-flighting).
* @param status error information if retrieving the displayable string failed.
* Should not be NULL and must not indicate failure on entry.
+ * U_USING_DEFAULT_WARNING indicates that no data was found from the locale
+ * resources and the value of the keyword is placed into dest as fallback.
* @return the actual buffer size needed for the displayable variant code.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getDisplayKeywordValue( const char* locale,
const char* keyword,
const char* displayLocale,
@@ -733,7 +761,7 @@ uloc_getDisplayKeywordValue( const char* locale,
* than maxResultSize, the returned displayable name will be truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getDisplayName(const char* localeID,
const char* inLocaleID,
UChar* result,
@@ -757,7 +785,7 @@ uloc_getDisplayName(const char* localeID,
* @return a specified locale name of all available locales
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_getAvailable(int32_t n);
/**
@@ -766,21 +794,19 @@ uloc_getAvailable(int32_t n);
* @return the size of the locale list
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2 uloc_countAvailable(void);
-
-#ifndef U_HIDE_DRAFT_API
+U_CAPI int32_t U_EXPORT2 uloc_countAvailable(void);
/**
* Types for uloc_getAvailableByType and uloc_countAvailableByType.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
typedef enum ULocAvailableType {
/**
* Locales that return data when passed to ICU APIs,
* but not including legacy or alias locales.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
ULOC_AVAILABLE_DEFAULT,
@@ -798,7 +824,7 @@ typedef enum ULocAvailableType {
* ULOC_AVAILABLE_DEFAULT. To get both sets at the same time, use
* ULOC_AVAILABLE_WITH_LEGACY_ALIASES.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
ULOC_AVAILABLE_ONLY_LEGACY_ALIASES,
@@ -806,7 +832,7 @@ typedef enum ULocAvailableType {
* The union of the locales in ULOC_AVAILABLE_DEFAULT and
* ULOC_AVAILABLE_ONLY_LEGACY_ALIAS.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
ULOC_AVAILABLE_WITH_LEGACY_ALIASES,
@@ -827,13 +853,11 @@ typedef enum ULocAvailableType {
* @param type Type choice from ULocAvailableType.
* @param status Set if an error occurred.
* @return a UEnumeration owned by the caller, or nullptr on failure.
- * @draft ICU 65
+ * @stable ICU 65
*/
-U_DRAFT UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
uloc_openAvailableByType(ULocAvailableType type, UErrorCode* status);
-#endif // U_HIDE_DRAFT_API
-
/**
*
* Gets a list of all available 2-letter language codes defined in ISO 639,
@@ -845,7 +869,7 @@ uloc_openAvailableByType(ULocAvailableType type, UErrorCode* status);
* @return a list of all available language codes
* @stable ICU 2.0
*/
-U_STABLE const char* const* U_EXPORT2
+U_CAPI const char* const* U_EXPORT2
uloc_getISOLanguages(void);
/**
@@ -857,7 +881,7 @@ uloc_getISOLanguages(void);
* @return a list of all available country codes
* @stable ICU 2.0
*/
-U_STABLE const char* const* U_EXPORT2
+U_CAPI const char* const* U_EXPORT2
uloc_getISOCountries(void);
/**
@@ -873,7 +897,7 @@ uloc_getISOCountries(void);
* @return The length of the parent locale ID.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getParent(const char* localeID,
char* parent,
int32_t parentCapacity,
@@ -904,7 +928,7 @@ uloc_getParent(const char* localeID,
* than nameCapacity, the returned full name will be truncated.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getBaseName(const char* localeID,
char* name,
int32_t nameCapacity,
@@ -919,7 +943,7 @@ uloc_getBaseName(const char* localeID,
* @return enumeration of keywords or NULL if there are no keywords.
* @stable ICU 2.8
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
uloc_openKeywords(const char* localeID,
UErrorCode* status);
@@ -936,7 +960,7 @@ uloc_openKeywords(const char* localeID,
* @return the length of keyword value
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getKeywordValue(const char* localeID,
const char* keywordName,
char* buffer, int32_t bufferCapacity,
@@ -973,7 +997,7 @@ uloc_getKeywordValue(const char* localeID,
* @see uloc_getKeywordValue
* @stable ICU 3.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_setKeywordValue(const char* keywordName,
const char* keywordValue,
char* buffer, int32_t bufferCapacity,
@@ -982,18 +1006,18 @@ uloc_setKeywordValue(const char* keywordName,
/**
* Returns whether the locale's script is written right-to-left.
* If there is no script subtag, then the likely script is used, see uloc_addLikelySubtags().
- * If no likely script is known, then FALSE is returned.
+ * If no likely script is known, then false is returned.
*
* A script is right-to-left according to the CLDR script metadata
* which corresponds to whether the script's letters have Bidi_Class=R or AL.
*
- * Returns TRUE for "ar" and "en-Hebr", FALSE for "zh" and "fa-Cyrl".
+ * Returns true for "ar" and "en-Hebr", false for "zh" and "fa-Cyrl".
*
* @param locale input locale ID
- * @return TRUE if the locale's script is written right-to-left
+ * @return true if the locale's script is written right-to-left
* @stable ICU 54
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uloc_isRightToLeft(const char *locale);
/**
@@ -1017,7 +1041,7 @@ typedef enum {
* @return an enum indicating the layout orientation for characters.
* @stable ICU 4.0
*/
-U_STABLE ULayoutType U_EXPORT2
+U_CAPI ULayoutType U_EXPORT2
uloc_getCharacterOrientation(const char* localeId,
UErrorCode *status);
@@ -1029,7 +1053,7 @@ uloc_getCharacterOrientation(const char* localeId,
* @return an enum indicating the layout orientation for lines.
* @stable ICU 4.0
*/
-U_STABLE ULayoutType U_EXPORT2
+U_CAPI ULayoutType U_EXPORT2
uloc_getLineOrientation(const char* localeId,
UErrorCode *status);
@@ -1076,7 +1100,7 @@ typedef enum {
* @return length needed for the locale.
* @stable ICU 3.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,
UAcceptResult *outResult,
const char *httpAcceptLanguage,
@@ -1101,7 +1125,7 @@ uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,
* @return length needed for the locale.
* @stable ICU 3.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_acceptLanguage(char *result, int32_t resultAvailable,
UAcceptResult *outResult, const char **acceptList,
int32_t acceptListCount,
@@ -1121,7 +1145,7 @@ uloc_acceptLanguage(char *result, int32_t resultAvailable,
* @return actual the actual size of the locale ID, not including NUL-termination
* @stable ICU 3.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity,
UErrorCode *status);
@@ -1159,7 +1183,7 @@ uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity,
* On error, the return value is -1.
* @stable ICU 4.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_addLikelySubtags(const char* localeID,
char* maximizedLocaleID,
int32_t maximizedLocaleIDCapacity,
@@ -1199,7 +1223,7 @@ uloc_addLikelySubtags(const char* localeID,
* On error, the return value is -1.
* @stable ICU 4.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_minimizeSubtags(const char* localeID,
char* minimizedLocaleID,
int32_t minimizedLocaleIDCapacity,
@@ -1210,13 +1234,17 @@ uloc_minimizeSubtags(const char* localeID,
* If the specified language tag contains any ill-formed subtags,
* the first such subtag and all following subtags are ignored.
* <p>
- * This implements the 'Language-Tag' production of BCP47, and so
- * supports grandfathered (regular and irregular) as well as private
- * use language tags. Private use tags are represented as 'x-whatever',
- * and grandfathered tags are converted to their canonical replacements
- * where they exist. Note that a few grandfathered tags have no modern
- * replacement, these will be converted using the fallback described in
+ * This implements the 'Language-Tag' production of BCP 47, and so
+ * supports legacy language tags (marked as “Type: grandfathered” in BCP 47)
+ * (regular and irregular) as well as private use language tags.
+ *
+ * Private use tags are represented as 'x-whatever',
+ * and legacy tags are converted to their canonical replacements where they exist.
+ *
+ * Note that a few legacy tags have no modern replacement;
+ * these will be converted using the fallback described in
* the first paragraph, so some information might be lost.
+ *
* @param langtag the input BCP47 language tag.
* @param localeID the output buffer receiving a locale ID for the
* specified BCP47 language tag.
@@ -1228,7 +1256,7 @@ uloc_minimizeSubtags(const char* localeID,
* @return the length of the locale ID.
* @stable ICU 4.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_forLanguageTag(const char* langtag,
char* localeID,
int32_t localeIDCapacity,
@@ -1238,10 +1266,10 @@ uloc_forLanguageTag(const char* langtag,
/**
* Returns a well-formed language tag for this locale ID.
* <p>
- * <b>Note</b>: When <code>strict</code> is FALSE, any locale
+ * <b>Note</b>: When <code>strict</code> is false, any locale
* fields which do not satisfy the BCP47 syntax requirement will
* be omitted from the result. When <code>strict</code> is
- * TRUE, this function sets U_ILLEGAL_ARGUMENT_ERROR to the
+ * true, this function sets U_ILLEGAL_ARGUMENT_ERROR to the
* <code>err</code> if any locale fields do not satisfy the
* BCP47 syntax requirement.
* @param localeID the input locale ID
@@ -1256,7 +1284,7 @@ uloc_forLanguageTag(const char* langtag,
* @return The length of the BCP47 language tag.
* @stable ICU 4.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uloc_toLanguageTag(const char* localeID,
char* langtag,
int32_t langtagCapacity,
@@ -1284,7 +1312,7 @@ uloc_toLanguageTag(const char* localeID,
* @see uloc_toLegacyKey
* @stable ICU 54
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_toUnicodeLocaleKey(const char* keyword);
/**
@@ -1315,7 +1343,7 @@ uloc_toUnicodeLocaleKey(const char* keyword);
* @see uloc_toLegacyType
* @stable ICU 54
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_toUnicodeLocaleType(const char* keyword, const char* value);
/**
@@ -1330,7 +1358,7 @@ uloc_toUnicodeLocaleType(const char* keyword, const char* value);
* @see toUnicodeLocaleKey
* @stable ICU 54
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_toLegacyKey(const char* keyword);
/**
@@ -1359,7 +1387,7 @@ uloc_toLegacyKey(const char* keyword);
* @see toUnicodeLocaleType
* @stable ICU 54
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uloc_toLegacyType(const char* keyword, const char* value);
#endif /*_ULOC*/
diff --git a/deps/icu-small/source/common/unicode/umachine.h b/deps/icu-small/source/common/unicode/umachine.h
index ff5deb8d01..219d1ee191 100644
--- a/deps/icu-small/source/common/unicode/umachine.h
+++ b/deps/icu-small/source/common/unicode/umachine.h
@@ -49,12 +49,13 @@
* ANSI C headers:
* stddef.h defines wchar_t
*/
+#include <stdbool.h>
#include <stddef.h>
/*==========================================================================*/
-/* For C wrappers, we use the symbol U_STABLE. */
+/* For C wrappers, we use the symbol U_CAPI. */
/* This works properly if the includer is C or C++. */
-/* Functions are declared U_STABLE return-type U_EXPORT2 function-name()... */
+/* Functions are declared U_CAPI return-type U_EXPORT2 function-name()... */
/*==========================================================================*/
/**
@@ -107,15 +108,15 @@
/** This is used to declare a function as a public ICU C API @stable ICU 2.0*/
#define U_CAPI U_CFUNC U_EXPORT
-/** This is used to declare a function as a stable public ICU C API*/
+/** Obsolete/same as U_CAPI; was used to declare a function as a stable public ICU C API*/
#define U_STABLE U_CAPI
-/** This is used to declare a function as a draft public ICU C API */
+/** Obsolete/same as U_CAPI; was used to declare a function as a draft public ICU C API */
#define U_DRAFT U_CAPI
/** This is used to declare a function as a deprecated public ICU C API */
#define U_DEPRECATED U_CAPI U_ATTRIBUTE_DEPRECATED
-/** This is used to declare a function as an obsolete public ICU C API */
+/** Obsolete/same as U_CAPI; was used to declare a function as an obsolete public ICU C API */
#define U_OBSOLETE U_CAPI
-/** This is used to declare a function as an internal ICU C API */
+/** Obsolete/same as U_CAPI; was used to declare a function as an internal ICU C API */
#define U_INTERNAL U_CAPI
/**
@@ -170,11 +171,11 @@
/**
* \def UPRV_BLOCK_MACRO_END
- * Defined as "while (FALSE)" by default.
+ * Defined as "while (false)" by default.
* @internal
*/
#ifndef UPRV_BLOCK_MACRO_END
-#define UPRV_BLOCK_MACRO_END while (FALSE)
+#define UPRV_BLOCK_MACRO_END while (false)
#endif
/*==========================================================================*/
@@ -257,18 +258,59 @@
/* Boolean data type */
/*==========================================================================*/
-/** The ICU boolean type @stable ICU 2.0 */
+/**
+ * The ICU boolean type, a signed-byte integer.
+ * ICU-specific for historical reasons: The C and C++ standards used to not define type bool.
+ * Also provides a fixed type definition, as opposed to
+ * type bool whose details (e.g., sizeof) may vary by compiler and between C and C++.
+ *
+ * @stable ICU 2.0
+ */
typedef int8_t UBool;
+/**
+ * \def U_DEFINE_FALSE_AND_TRUE
+ * Normally turns off defining macros FALSE=0 & TRUE=1 in public ICU headers.
+ * These obsolete macros sometimes break compilation of other code that
+ * defines enum constants or similar with these names.
+ * C++ has long defined bool/false/true.
+ * C99 also added definitions for these, although as macros; see stdbool.h.
+ *
+ * You may transitionally define U_DEFINE_FALSE_AND_TRUE=1 if you need time to migrate code.
+ *
+ * @internal ICU 68
+ */
+#ifdef U_DEFINE_FALSE_AND_TRUE
+ // Use the predefined value.
+#elif defined(U_COMBINED_IMPLEMENTATION) || \
+ defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || \
+ defined(U_IO_IMPLEMENTATION) || defined(U_LAYOUTEX_IMPLEMENTATION) || \
+ defined(U_TOOLUTIL_IMPLEMENTATION)
+ // Inside ICU: Keep FALSE & TRUE available.
+# define U_DEFINE_FALSE_AND_TRUE 1
+#else
+ // Outside ICU: Avoid collision with non-macro definitions of FALSE & TRUE.
+# define U_DEFINE_FALSE_AND_TRUE 0
+#endif
+
+#if U_DEFINE_FALSE_AND_TRUE || defined(U_IN_DOXYGEN)
#ifndef TRUE
-/** The TRUE value of a UBool @stable ICU 2.0 */
+/**
+ * The TRUE value of a UBool.
+ *
+ * @deprecated ICU 68 Use standard "true" instead.
+ */
# define TRUE 1
#endif
#ifndef FALSE
-/** The FALSE value of a UBool @stable ICU 2.0 */
+/**
+ * The FALSE value of a UBool.
+ *
+ * @deprecated ICU 68 Use standard "false" instead.
+ */
# define FALSE 0
#endif
-
+#endif // U_DEFINE_FALSE_AND_TRUE
/*==========================================================================*/
/* Unicode data types */
diff --git a/deps/icu-small/source/common/unicode/umutablecptrie.h b/deps/icu-small/source/common/unicode/umutablecptrie.h
index f2af36477d..5325d58147 100644
--- a/deps/icu-small/source/common/unicode/umutablecptrie.h
+++ b/deps/icu-small/source/common/unicode/umutablecptrie.h
@@ -9,11 +9,14 @@
#include "unicode/utypes.h"
-#include "unicode/localpointer.h"
#include "unicode/ucpmap.h"
#include "unicode/ucptrie.h"
#include "unicode/utf8.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
U_CDECL_BEGIN
/**
diff --git a/deps/icu-small/source/common/unicode/unimatch.h b/deps/icu-small/source/common/unicode/unimatch.h
index 2d3c5210c3..10efd3d007 100644
--- a/deps/icu-small/source/common/unicode/unimatch.h
+++ b/deps/icu-small/source/common/unicode/unimatch.h
@@ -115,11 +115,11 @@ public:
* considered for matching will be text.charAt(limit-1) in the
* forward direction or text.charAt(limit+1) in the backward
* direction.
- * @param incremental if TRUE, then assume further characters may
+ * @param incremental if true, then assume further characters may
* be inserted at limit and check for partial matching. Otherwise
* assume the text as given is complete.
* @return a match degree value indicating a full match, a partial
- * match, or a mismatch. If incremental is FALSE then
+ * match, or a mismatch. If incremental is false then
* U_PARTIAL_MATCH should never be returned.
* @stable ICU 2.4
*/
@@ -134,17 +134,17 @@ public:
* will produce another matcher that is equal to this one.
* @param result the string to receive the pattern. Previous
* contents will be deleted.
- * @param escapeUnprintable if TRUE then convert unprintable
+ * @param escapeUnprintable if true then convert unprintable
* character to their hex escape representations, \\uxxxx or
* \\Uxxxxxxxx. Unprintable characters are those other than
* U+000A, U+0020..U+007E.
* @stable ICU 2.4
*/
virtual UnicodeString& toPattern(UnicodeString& result,
- UBool escapeUnprintable = FALSE) const = 0;
+ UBool escapeUnprintable = false) const = 0;
/**
- * Returns TRUE if this matcher will match a character c, where c
+ * Returns true if this matcher will match a character c, where c
* & 0xFF == v, at offset, in the forward direction (with limit >
* offset). This is used by <tt>RuleBasedTransliterator</tt> for
* indexing.
diff --git a/deps/icu-small/source/common/unicode/uniset.h b/deps/icu-small/source/common/unicode/uniset.h
index 18cc937644..4179507af1 100644
--- a/deps/icu-small/source/common/unicode/uniset.h
+++ b/deps/icu-small/source/common/unicode/uniset.h
@@ -325,7 +325,7 @@ public:
* A bogus set has no value. It is different from an empty set.
* It can be used to indicate that no set value is available.
*
- * @return TRUE if the set is bogus/invalid, FALSE otherwise
+ * @return true if the set is bogus/invalid, false otherwise
* @see setToBogus()
* @stable ICU 4.0
*/
@@ -333,7 +333,7 @@ public:
/**
* Make this UnicodeSet object invalid.
- * The string will test TRUE with isBogus().
+ * The string will test true with isBogus().
*
* A bogus set has no value. It is different from an empty set.
* It can be used to indicate that no set value is available.
@@ -563,7 +563,7 @@ public:
/**
* Determines whether the set has been frozen (made immutable) or not.
* See the ICU4J Freezable interface for details.
- * @return TRUE/FALSE for whether the set has been frozen
+ * @return true/false for whether the set has been frozen
* @see freeze
* @see cloneAsThawed
* @stable ICU 3.8
@@ -700,14 +700,14 @@ public:
* A frozen set will not be modified.
* @param result the string to receive the rules. Previous
* contents will be deleted.
- * @param escapeUnprintable if TRUE then convert unprintable
+ * @param escapeUnprintable if true then convert unprintable
* character to their hex escape representations, \\uxxxx or
* \\Uxxxxxxxx. Unprintable characters are those other than
* U+000A, U+0020..U+007E.
* @stable ICU 2.0
*/
virtual UnicodeString& toPattern(UnicodeString& result,
- UBool escapeUnprintable = FALSE) const;
+ UBool escapeUnprintable = false) const;
/**
* Modifies this set to contain those code points which have the given value
@@ -1636,7 +1636,7 @@ private:
static const UnicodeSet* getInclusions(int32_t src, UErrorCode &status);
/**
- * A filter that returns TRUE if the given code point should be
+ * A filter that returns true if the given code point should be
* included in the UnicodeSet being constructed.
*/
typedef UBool (*Filter)(UChar32 codePoint, void* context);
diff --git a/deps/icu-small/source/common/unicode/unistr.h b/deps/icu-small/source/common/unicode/unistr.h
index da79053765..456389f265 100644
--- a/deps/icu-small/source/common/unicode/unistr.h
+++ b/deps/icu-small/source/common/unicode/unistr.h
@@ -45,7 +45,7 @@ struct UConverter; // unicode/ucnv.h
/**
* \ingroup ustring_ustrlen
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strlen(const UChar *s);
#endif
@@ -113,9 +113,9 @@ class UnicodeStringAppendable; // unicode/appendable.h
* @stable ICU 2.0
*/
#if !U_CHAR16_IS_TYPEDEF
-# define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, u ## cs, _length)
+# define UNICODE_STRING(cs, _length) icu::UnicodeString(true, u ## cs, _length)
#else
-# define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const char16_t*)u ## cs, _length)
+# define UNICODE_STRING(cs, _length) icu::UnicodeString(true, (const char16_t*)u ## cs, _length)
#endif
/**
@@ -227,7 +227,7 @@ class UnicodeStringAppendable; // unicode/appendable.h
* The UnicodeString class is not suitable for subclassing.
*
* For an overview of Unicode strings in C and C++ see the
- * [User Guide Strings chapter](http://userguide.icu-project.org/strings#TOC-Strings-in-C-C-).
+ * [User Guide Strings chapter](https://unicode-org.github.io/icu/userguide/strings#strings-in-cc).
*
* In ICU, a Unicode string consists of 16-bit Unicode *code units*.
* A Unicode character may be stored with either one code unit
@@ -285,7 +285,7 @@ class UnicodeStringAppendable; // unicode/appendable.h
* significant performance improvements.
* Also, the internal buffer is accessible via special functions.
* For details see the
- * [User Guide Strings chapter](http://userguide.icu-project.org/strings#TOC-Maximizing-Performance-with-the-UnicodeString-Storage-Model).
+ * [User Guide Strings chapter](https://unicode-org.github.io/icu/userguide/strings#maximizing-performance-with-the-unicodestring-storage-model).
*
* @see utf.h
* @see CharacterIterator
@@ -320,8 +320,8 @@ public:
/**
* Equality operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return TRUE if `text` contains the same characters as this one,
- * FALSE otherwise.
+ * @return true if `text` contains the same characters as this one,
+ * false otherwise.
* @stable ICU 2.0
*/
inline UBool operator== (const UnicodeString& text) const;
@@ -329,8 +329,8 @@ public:
/**
* Inequality operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return FALSE if `text` contains the same characters as this one,
- * TRUE otherwise.
+ * @return false if `text` contains the same characters as this one,
+ * true otherwise.
* @stable ICU 2.0
*/
inline UBool operator!= (const UnicodeString& text) const;
@@ -338,8 +338,8 @@ public:
/**
* Greater than operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return TRUE if the characters in this are bitwise
- * greater than the characters in `text`, FALSE otherwise
+ * @return true if the characters in this are bitwise
+ * greater than the characters in `text`, false otherwise
* @stable ICU 2.0
*/
inline UBool operator> (const UnicodeString& text) const;
@@ -347,8 +347,8 @@ public:
/**
* Less than operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return TRUE if the characters in this are bitwise
- * less than the characters in `text`, FALSE otherwise
+ * @return true if the characters in this are bitwise
+ * less than the characters in `text`, false otherwise
* @stable ICU 2.0
*/
inline UBool operator< (const UnicodeString& text) const;
@@ -356,8 +356,8 @@ public:
/**
* Greater than or equal operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return TRUE if the characters in this are bitwise
- * greater than or equal to the characters in `text`, FALSE otherwise
+ * @return true if the characters in this are bitwise
+ * greater than or equal to the characters in `text`, false otherwise
* @stable ICU 2.0
*/
inline UBool operator>= (const UnicodeString& text) const;
@@ -365,8 +365,8 @@ public:
/**
* Less than or equal operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return TRUE if the characters in this are bitwise
- * less than or equal to the characters in `text`, FALSE otherwise
+ * @return true if the characters in this are bitwise
+ * less than or equal to the characters in `text`, false otherwise
* @stable ICU 2.0
*/
inline UBool operator<= (const UnicodeString& text) const;
@@ -855,8 +855,8 @@ public:
/**
* Determine if this starts with the characters in `text`
* @param text The text to match.
- * @return TRUE if this starts with the characters in `text`,
- * FALSE otherwise
+ * @return true if this starts with the characters in `text`,
+ * false otherwise
* @stable ICU 2.0
*/
inline UBool startsWith(const UnicodeString& text) const;
@@ -867,8 +867,8 @@ public:
* @param srcText The text to match.
* @param srcStart the offset into `srcText` to start matching
* @param srcLength the number of characters in `srcText` to match
- * @return TRUE if this starts with the characters in `text`,
- * FALSE otherwise
+ * @return true if this starts with the characters in `text`,
+ * false otherwise
* @stable ICU 2.0
*/
inline UBool startsWith(const UnicodeString& srcText,
@@ -879,8 +879,8 @@ public:
* Determine if this starts with the characters in `srcChars`
* @param srcChars The characters to match.
* @param srcLength the number of characters in `srcChars`
- * @return TRUE if this starts with the characters in `srcChars`,
- * FALSE otherwise
+ * @return true if this starts with the characters in `srcChars`,
+ * false otherwise
* @stable ICU 2.0
*/
inline UBool startsWith(ConstChar16Ptr srcChars,
@@ -892,7 +892,7 @@ public:
* @param srcChars The characters to match.
* @param srcStart the offset into `srcText` to start matching
* @param srcLength the number of characters in `srcChars` to match
- * @return TRUE if this ends with the characters in `srcChars`, FALSE otherwise
+ * @return true if this ends with the characters in `srcChars`, false otherwise
* @stable ICU 2.0
*/
inline UBool startsWith(const char16_t *srcChars,
@@ -902,8 +902,8 @@ public:
/**
* Determine if this ends with the characters in `text`
* @param text The text to match.
- * @return TRUE if this ends with the characters in `text`,
- * FALSE otherwise
+ * @return true if this ends with the characters in `text`,
+ * false otherwise
* @stable ICU 2.0
*/
inline UBool endsWith(const UnicodeString& text) const;
@@ -914,8 +914,8 @@ public:
* @param srcText The text to match.
* @param srcStart the offset into `srcText` to start matching
* @param srcLength the number of characters in `srcText` to match
- * @return TRUE if this ends with the characters in `text`,
- * FALSE otherwise
+ * @return true if this ends with the characters in `text`,
+ * false otherwise
* @stable ICU 2.0
*/
inline UBool endsWith(const UnicodeString& srcText,
@@ -926,8 +926,8 @@ public:
* Determine if this ends with the characters in `srcChars`
* @param srcChars The characters to match.
* @param srcLength the number of characters in `srcChars`
- * @return TRUE if this ends with the characters in `srcChars`,
- * FALSE otherwise
+ * @return true if this ends with the characters in `srcChars`,
+ * false otherwise
* @stable ICU 2.0
*/
inline UBool endsWith(ConstChar16Ptr srcChars,
@@ -939,8 +939,8 @@ public:
* @param srcChars The characters to match.
* @param srcStart the offset into `srcText` to start matching
* @param srcLength the number of characters in `srcChars` to match
- * @return TRUE if this ends with the characters in `srcChars`,
- * FALSE otherwise
+ * @return true if this ends with the characters in `srcChars`,
+ * false otherwise
* @stable ICU 2.0
*/
inline UBool endsWith(const char16_t *srcChars,
@@ -1804,7 +1804,7 @@ public:
/**
* Determine if this string is empty.
- * @return TRUE if this string contains 0 characters, FALSE otherwise.
+ * @return true if this string contains 0 characters, false otherwise.
* @stable ICU 2.0
*/
inline UBool isEmpty(void) const;
@@ -1832,12 +1832,12 @@ public:
/**
* Determine if this object contains a valid string.
* A bogus string has no value. It is different from an empty string,
- * although in both cases isEmpty() returns TRUE and length() returns 0.
+ * although in both cases isEmpty() returns true and length() returns 0.
* setToBogus() and isBogus() can be used to indicate that no string value is available.
* For a bogus string, getBuffer() and getTerminatedBuffer() return NULL, and
* length() returns 0.
*
- * @return TRUE if the string is bogus/invalid, FALSE otherwise
+ * @return true if the string is bogus/invalid, false otherwise
* @see setToBogus()
* @stable ICU 2.0
*/
@@ -2067,7 +2067,7 @@ public:
/**
* Make this UnicodeString object invalid.
- * The string will test TRUE with isBogus().
+ * The string will test true with isBogus().
*
* A bogus string has no value. It is different from an empty string.
* It can be used to indicate that no string value is available.
@@ -2459,7 +2459,7 @@ public:
/**
* Replaceable API
- * @return TRUE if it has MetaData
+ * @return true if it has MetaData
* @stable ICU 2.4
*/
virtual UBool hasMetaData() const;
@@ -2590,7 +2590,7 @@ public:
* @param targetLength the desired length of the string
* @param padChar the character to use for padding. Defaults to
* space (U+0020)
- * @return TRUE if the text was padded, FALSE otherwise.
+ * @return true if the text was padded, false otherwise.
* @stable ICU 2.0
*/
UBool padLeading(int32_t targetLength,
@@ -2604,7 +2604,7 @@ public:
* @param targetLength the desired length of the string
* @param padChar the character to use for padding. Defaults to
* space (U+0020)
- * @return TRUE if the text was padded, FALSE otherwise.
+ * @return true if the text was padded, false otherwise.
* @stable ICU 2.0
*/
UBool padTrailing(int32_t targetLength,
@@ -2613,7 +2613,7 @@ public:
/**
* Truncate this UnicodeString to the `targetLength`.
* @param targetLength the desired length of this UnicodeString.
- * @return TRUE if the text was truncated, FALSE otherwise
+ * @return true if the text was truncated, false otherwise
* @stable ICU 2.0
*/
inline UBool truncate(int32_t targetLength);
@@ -3615,7 +3615,7 @@ private:
void unBogus();
// implements assigment operator, copy constructor, and fastCopyFrom()
- UnicodeString &copyFrom(const UnicodeString &src, UBool fastCopy=FALSE);
+ UnicodeString &copyFrom(const UnicodeString &src, UBool fastCopy=false);
// Copies just the fields without memory management.
void copyFieldsFrom(UnicodeString &src, UBool setSrcToBogus) U_NOEXCEPT;
@@ -3668,13 +3668,13 @@ private:
* the buffer is refCounted (shared), and refCount>1, or
* the buffer is too small.
*
- * Return FALSE if memory could not be allocated.
+ * Return false if memory could not be allocated.
*/
UBool cloneArrayIfNeeded(int32_t newCapacity = -1,
int32_t growCapacity = -1,
- UBool doCopyArray = TRUE,
+ UBool doCopyArray = true,
int32_t **pBufferToDelete = 0,
- UBool forceClone = FALSE);
+ UBool forceClone = false);
/**
* Common function for UnicodeString case mappings.
@@ -4732,12 +4732,12 @@ UnicodeString::truncate(int32_t targetLength)
if(isBogus() && targetLength == 0) {
// truncate(0) of a bogus string makes the string empty and non-bogus
unBogus();
- return FALSE;
+ return false;
} else if((uint32_t)targetLength < (uint32_t)length()) {
setLength(targetLength);
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
diff --git a/deps/icu-small/source/common/unicode/unorm.h b/deps/icu-small/source/common/unicode/unorm.h
index 09dd366a96..c3c57582d4 100644
--- a/deps/icu-small/source/common/unicode/unorm.h
+++ b/deps/icu-small/source/common/unicode/unorm.h
@@ -274,7 +274,7 @@ unorm_quickCheckWithOptions(const UChar *src, int32_t srcLength,
* never a "maybe".
* For NFD, NFKD, and FCD, both functions work exactly the same.
* For NFC and NFKC where quickCheck may return "maybe", this function will
- * perform further tests to arrive at a TRUE/FALSE result.
+ * perform further tests to arrive at a true/false result.
*
* @param src String that is to be tested if it is in a normalization format.
* @param srcLength Length of source to test, or -1 if NUL-terminated.
@@ -358,10 +358,10 @@ unorm_isNormalizedWithOptions(const UChar *src, int32_t srcLength,
* It is useful for operations like a normalizing transliterator, where one would
* not want to replace a piece of text if it is not modified.
*
- * If doNormalize==TRUE and pNeededToNormalize!=NULL then *pNeeded... is set TRUE
+ * If doNormalize==true and pNeededToNormalize!=NULL then *pNeeded... is set true
* if the normalization was necessary.
*
- * If doNormalize==FALSE then *pNeededToNormalize will be set to FALSE.
+ * If doNormalize==false then *pNeededToNormalize will be set to false.
*
* If the buffer overflows, then *pNeededToNormalize will be undefined;
* essentially, whenever U_FAILURE is true (like in buffer overflows), this result
@@ -373,11 +373,11 @@ unorm_isNormalizedWithOptions(const UChar *src, int32_t srcLength,
* @param mode The normalization mode.
* @param options The normalization options, ORed together (0 for no options).
* @param doNormalize Indicates if the source text up to the next boundary
- * is to be normalized (TRUE) or just copied (FALSE).
+ * is to be normalized (true) or just copied (false).
* @param pNeededToNormalize Output flag indicating if the normalization resulted in
* different text from the input.
* Not defined if an error occurs including buffer overflow.
- * Always FALSE if !doNormalize.
+ * Always false if !doNormalize.
* @param pErrorCode ICU error code in/out parameter.
* Must fulfill U_SUCCESS before the function call.
* @return Length of output (number of UChars) when successful or buffer overflow.
@@ -406,11 +406,11 @@ unorm_next(UCharIterator *src,
* @param mode The normalization mode.
* @param options The normalization options, ORed together (0 for no options).
* @param doNormalize Indicates if the source text up to the next boundary
- * is to be normalized (TRUE) or just copied (FALSE).
+ * is to be normalized (true) or just copied (false).
* @param pNeededToNormalize Output flag indicating if the normalization resulted in
* different text from the input.
* Not defined if an error occurs including buffer overflow.
- * Always FALSE if !doNormalize.
+ * Always false if !doNormalize.
* @param pErrorCode ICU error code in/out parameter.
* Must fulfill U_SUCCESS before the function call.
* @return Length of output (number of UChars) when successful or buffer overflow.
diff --git a/deps/icu-small/source/common/unicode/unorm2.h b/deps/icu-small/source/common/unicode/unorm2.h
index a9bd02f256..24417b7103 100644
--- a/deps/icu-small/source/common/unicode/unorm2.h
+++ b/deps/icu-small/source/common/unicode/unorm2.h
@@ -31,10 +31,13 @@
*/
#include "unicode/utypes.h"
-#include "unicode/localpointer.h"
#include "unicode/stringoptions.h"
#include "unicode/uset.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* Constants for normalization modes.
* For details about standard Unicode normalization forms
@@ -132,7 +135,7 @@ typedef struct UNormalizer2 UNormalizer2; /**< C typedef for struct UNormalizer
* @return the requested Normalizer2, if successful
* @stable ICU 49
*/
-U_STABLE const UNormalizer2 * U_EXPORT2
+U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getNFCInstance(UErrorCode *pErrorCode);
/**
@@ -146,7 +149,7 @@ unorm2_getNFCInstance(UErrorCode *pErrorCode);
* @return the requested Normalizer2, if successful
* @stable ICU 49
*/
-U_STABLE const UNormalizer2 * U_EXPORT2
+U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getNFDInstance(UErrorCode *pErrorCode);
/**
@@ -160,7 +163,7 @@ unorm2_getNFDInstance(UErrorCode *pErrorCode);
* @return the requested Normalizer2, if successful
* @stable ICU 49
*/
-U_STABLE const UNormalizer2 * U_EXPORT2
+U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getNFKCInstance(UErrorCode *pErrorCode);
/**
@@ -174,7 +177,7 @@ unorm2_getNFKCInstance(UErrorCode *pErrorCode);
* @return the requested Normalizer2, if successful
* @stable ICU 49
*/
-U_STABLE const UNormalizer2 * U_EXPORT2
+U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getNFKDInstance(UErrorCode *pErrorCode);
/**
@@ -188,7 +191,7 @@ unorm2_getNFKDInstance(UErrorCode *pErrorCode);
* @return the requested Normalizer2, if successful
* @stable ICU 49
*/
-U_STABLE const UNormalizer2 * U_EXPORT2
+U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getNFKCCasefoldInstance(UErrorCode *pErrorCode);
/**
@@ -212,7 +215,7 @@ unorm2_getNFKCCasefoldInstance(UErrorCode *pErrorCode);
* @return the requested UNormalizer2, if successful
* @stable ICU 4.4
*/
-U_STABLE const UNormalizer2 * U_EXPORT2
+U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getInstance(const char *packageName,
const char *name,
UNormalization2Mode mode,
@@ -233,7 +236,7 @@ unorm2_getInstance(const char *packageName,
* @return the requested UNormalizer2, if successful
* @stable ICU 4.4
*/
-U_STABLE UNormalizer2 * U_EXPORT2
+U_CAPI UNormalizer2 * U_EXPORT2
unorm2_openFiltered(const UNormalizer2 *norm2, const USet *filterSet, UErrorCode *pErrorCode);
/**
@@ -242,7 +245,7 @@ unorm2_openFiltered(const UNormalizer2 *norm2, const USet *filterSet, UErrorCode
* @param norm2 UNormalizer2 instance to be closed
* @stable ICU 4.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unorm2_close(UNormalizer2 *norm2);
#if U_SHOW_CPLUSPLUS_API
@@ -280,7 +283,7 @@ U_NAMESPACE_END
* @return dest
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unorm2_normalize(const UNormalizer2 *norm2,
const UChar *src, int32_t length,
UChar *dest, int32_t capacity,
@@ -303,7 +306,7 @@ unorm2_normalize(const UNormalizer2 *norm2,
* @return first
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unorm2_normalizeSecondAndAppend(const UNormalizer2 *norm2,
UChar *first, int32_t firstLength, int32_t firstCapacity,
const UChar *second, int32_t secondLength,
@@ -326,7 +329,7 @@ unorm2_normalizeSecondAndAppend(const UNormalizer2 *norm2,
* @return first
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unorm2_append(const UNormalizer2 *norm2,
UChar *first, int32_t firstLength, int32_t firstCapacity,
const UChar *second, int32_t secondLength,
@@ -351,7 +354,7 @@ unorm2_append(const UNormalizer2 *norm2,
* @return the non-negative length of c's decomposition, if there is one; otherwise a negative value
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unorm2_getDecomposition(const UNormalizer2 *norm2,
UChar32 c, UChar *decomposition, int32_t capacity,
UErrorCode *pErrorCode);
@@ -385,7 +388,7 @@ unorm2_getDecomposition(const UNormalizer2 *norm2,
* @return the non-negative length of c's raw decomposition, if there is one; otherwise a negative value
* @stable ICU 49
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unorm2_getRawDecomposition(const UNormalizer2 *norm2,
UChar32 c, UChar *decomposition, int32_t capacity,
UErrorCode *pErrorCode);
@@ -405,7 +408,7 @@ unorm2_getRawDecomposition(const UNormalizer2 *norm2,
* @return The non-negative composite code point if there is one; otherwise a negative value.
* @stable ICU 49
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
unorm2_composePair(const UNormalizer2 *norm2, UChar32 a, UChar32 b);
/**
@@ -417,7 +420,7 @@ unorm2_composePair(const UNormalizer2 *norm2, UChar32 a, UChar32 b);
* @return c's combining class
* @stable ICU 49
*/
-U_STABLE uint8_t U_EXPORT2
+U_CAPI uint8_t U_EXPORT2
unorm2_getCombiningClass(const UNormalizer2 *norm2, UChar32 c);
/**
@@ -433,10 +436,10 @@ unorm2_getCombiningClass(const UNormalizer2 *norm2, UChar32 c);
* pass the U_SUCCESS() test, or else the function returns
* immediately. Check for U_FAILURE() on output or use with
* function chaining. (See User Guide for details.)
- * @return TRUE if s is normalized
+ * @return true if s is normalized
* @stable ICU 4.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
unorm2_isNormalized(const UNormalizer2 *norm2,
const UChar *s, int32_t length,
UErrorCode *pErrorCode);
@@ -458,7 +461,7 @@ unorm2_isNormalized(const UNormalizer2 *norm2,
* @return UNormalizationCheckResult
* @stable ICU 4.4
*/
-U_STABLE UNormalizationCheckResult U_EXPORT2
+U_CAPI UNormalizationCheckResult U_EXPORT2
unorm2_quickCheck(const UNormalizer2 *norm2,
const UChar *s, int32_t length,
UErrorCode *pErrorCode);
@@ -487,7 +490,7 @@ unorm2_quickCheck(const UNormalizer2 *norm2,
* @return "yes" span end index
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unorm2_spanQuickCheckYes(const UNormalizer2 *norm2,
const UChar *s, int32_t length,
UErrorCode *pErrorCode);
@@ -498,10 +501,10 @@ unorm2_spanQuickCheckYes(const UNormalizer2 *norm2,
* For details see the Normalizer2 base class documentation.
* @param norm2 UNormalizer2 instance
* @param c character to test
- * @return TRUE if c has a normalization boundary before it
+ * @return true if c has a normalization boundary before it
* @stable ICU 4.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
unorm2_hasBoundaryBefore(const UNormalizer2 *norm2, UChar32 c);
/**
@@ -510,10 +513,10 @@ unorm2_hasBoundaryBefore(const UNormalizer2 *norm2, UChar32 c);
* For details see the Normalizer2 base class documentation.
* @param norm2 UNormalizer2 instance
* @param c character to test
- * @return TRUE if c has a normalization boundary after it
+ * @return true if c has a normalization boundary after it
* @stable ICU 4.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
unorm2_hasBoundaryAfter(const UNormalizer2 *norm2, UChar32 c);
/**
@@ -521,10 +524,10 @@ unorm2_hasBoundaryAfter(const UNormalizer2 *norm2, UChar32 c);
* For details see the Normalizer2 base class documentation.
* @param norm2 UNormalizer2 instance
* @param c character to test
- * @return TRUE if c is normalization-inert
+ * @return true if c is normalization-inert
* @stable ICU 4.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
unorm2_isInert(const UNormalizer2 *norm2, UChar32 c);
/**
@@ -593,7 +596,7 @@ unorm2_isInert(const UNormalizer2 *norm2, UChar32 c);
*
* @stable ICU 2.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unorm_compare(const UChar *s1, int32_t length1,
const UChar *s2, int32_t length2,
uint32_t options,
diff --git a/deps/icu-small/source/common/unicode/urename.h b/deps/icu-small/source/common/unicode/urename.h
index 30f4b7af39..20232cd209 100644
--- a/deps/icu-small/source/common/unicode/urename.h
+++ b/deps/icu-small/source/common/unicode/urename.h
@@ -130,7 +130,6 @@
#define izrule_getStaticClassID U_ICU_ENTRY_POINT_RENAME(izrule_getStaticClassID)
#define izrule_isEquivalentTo U_ICU_ENTRY_POINT_RENAME(izrule_isEquivalentTo)
#define izrule_open U_ICU_ENTRY_POINT_RENAME(izrule_open)
-#define locale_getKeywords U_ICU_ENTRY_POINT_RENAME(locale_getKeywords)
#define locale_getKeywordsStart U_ICU_ENTRY_POINT_RENAME(locale_getKeywordsStart)
#define locale_get_default U_ICU_ENTRY_POINT_RENAME(locale_get_default)
#define locale_set_default U_ICU_ENTRY_POINT_RENAME(locale_set_default)
@@ -918,9 +917,11 @@
#define udtitvfmt_format U_ICU_ENTRY_POINT_RENAME(udtitvfmt_format)
#define udtitvfmt_formatCalendarToResult U_ICU_ENTRY_POINT_RENAME(udtitvfmt_formatCalendarToResult)
#define udtitvfmt_formatToResult U_ICU_ENTRY_POINT_RENAME(udtitvfmt_formatToResult)
+#define udtitvfmt_getContext U_ICU_ENTRY_POINT_RENAME(udtitvfmt_getContext)
#define udtitvfmt_open U_ICU_ENTRY_POINT_RENAME(udtitvfmt_open)
#define udtitvfmt_openResult U_ICU_ENTRY_POINT_RENAME(udtitvfmt_openResult)
#define udtitvfmt_resultAsValue U_ICU_ENTRY_POINT_RENAME(udtitvfmt_resultAsValue)
+#define udtitvfmt_setContext U_ICU_ENTRY_POINT_RENAME(udtitvfmt_setContext)
#define uenum_close U_ICU_ENTRY_POINT_RENAME(uenum_close)
#define uenum_count U_ICU_ENTRY_POINT_RENAME(uenum_count)
#define uenum_next U_ICU_ENTRY_POINT_RENAME(uenum_next)
@@ -1079,7 +1080,6 @@
#define uloc_getDisplayLanguage U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayLanguage)
#define uloc_getDisplayName U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayName)
#define uloc_getDisplayScript U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayScript)
-#define uloc_getDisplayScriptInContext U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayScriptInContext)
#define uloc_getDisplayVariant U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayVariant)
#define uloc_getISO3Country U_ICU_ENTRY_POINT_RENAME(uloc_getISO3Country)
#define uloc_getISO3Language U_ICU_ENTRY_POINT_RENAME(uloc_getISO3Language)
@@ -1123,10 +1123,14 @@
#define ulocimp_forLanguageTag U_ICU_ENTRY_POINT_RENAME(ulocimp_forLanguageTag)
#define ulocimp_getBaseName U_ICU_ENTRY_POINT_RENAME(ulocimp_getBaseName)
#define ulocimp_getCountry U_ICU_ENTRY_POINT_RENAME(ulocimp_getCountry)
+#define ulocimp_getKeywordValue U_ICU_ENTRY_POINT_RENAME(ulocimp_getKeywordValue)
+#define ulocimp_getKeywords U_ICU_ENTRY_POINT_RENAME(ulocimp_getKeywords)
+#define ulocimp_getKnownCanonicalizedLocaleForTest U_ICU_ENTRY_POINT_RENAME(ulocimp_getKnownCanonicalizedLocaleForTest)
#define ulocimp_getLanguage U_ICU_ENTRY_POINT_RENAME(ulocimp_getLanguage)
#define ulocimp_getName U_ICU_ENTRY_POINT_RENAME(ulocimp_getName)
#define ulocimp_getRegionForSupplementalData U_ICU_ENTRY_POINT_RENAME(ulocimp_getRegionForSupplementalData)
#define ulocimp_getScript U_ICU_ENTRY_POINT_RENAME(ulocimp_getScript)
+#define ulocimp_isCanonicalizedLocaleForTest U_ICU_ENTRY_POINT_RENAME(ulocimp_isCanonicalizedLocaleForTest)
#define ulocimp_minimizeSubtags U_ICU_ENTRY_POINT_RENAME(ulocimp_minimizeSubtags)
#define ulocimp_toBcpKey U_ICU_ENTRY_POINT_RENAME(ulocimp_toBcpKey)
#define ulocimp_toBcpType U_ICU_ENTRY_POINT_RENAME(ulocimp_toBcpType)
@@ -1245,7 +1249,18 @@
#define unumf_resultAsValue U_ICU_ENTRY_POINT_RENAME(unumf_resultAsValue)
#define unumf_resultGetAllFieldPositions U_ICU_ENTRY_POINT_RENAME(unumf_resultGetAllFieldPositions)
#define unumf_resultNextFieldPosition U_ICU_ENTRY_POINT_RENAME(unumf_resultNextFieldPosition)
+#define unumf_resultToDecimalNumber U_ICU_ENTRY_POINT_RENAME(unumf_resultToDecimalNumber)
#define unumf_resultToString U_ICU_ENTRY_POINT_RENAME(unumf_resultToString)
+#define unumrf_close U_ICU_ENTRY_POINT_RENAME(unumrf_close)
+#define unumrf_closeResult U_ICU_ENTRY_POINT_RENAME(unumrf_closeResult)
+#define unumrf_formatDecimalRange U_ICU_ENTRY_POINT_RENAME(unumrf_formatDecimalRange)
+#define unumrf_formatDoubleRange U_ICU_ENTRY_POINT_RENAME(unumrf_formatDoubleRange)
+#define unumrf_openForSkeletonWithCollapseAndIdentityFallback U_ICU_ENTRY_POINT_RENAME(unumrf_openForSkeletonWithCollapseAndIdentityFallback)
+#define unumrf_openResult U_ICU_ENTRY_POINT_RENAME(unumrf_openResult)
+#define unumrf_resultAsValue U_ICU_ENTRY_POINT_RENAME(unumrf_resultAsValue)
+#define unumrf_resultGetFirstDecimalNumber U_ICU_ENTRY_POINT_RENAME(unumrf_resultGetFirstDecimalNumber)
+#define unumrf_resultGetIdentityResult U_ICU_ENTRY_POINT_RENAME(unumrf_resultGetIdentityResult)
+#define unumrf_resultGetSecondDecimalNumber U_ICU_ENTRY_POINT_RENAME(unumrf_resultGetSecondDecimalNumber)
#define unumsys_close U_ICU_ENTRY_POINT_RENAME(unumsys_close)
#define unumsys_getDescription U_ICU_ENTRY_POINT_RENAME(unumsys_getDescription)
#define unumsys_getName U_ICU_ENTRY_POINT_RENAME(unumsys_getName)
@@ -1259,6 +1274,7 @@
#define uplrules_open U_ICU_ENTRY_POINT_RENAME(uplrules_open)
#define uplrules_openForType U_ICU_ENTRY_POINT_RENAME(uplrules_openForType)
#define uplrules_select U_ICU_ENTRY_POINT_RENAME(uplrules_select)
+#define uplrules_selectForRange U_ICU_ENTRY_POINT_RENAME(uplrules_selectForRange)
#define uplrules_selectFormatted U_ICU_ENTRY_POINT_RENAME(uplrules_selectFormatted)
#define uplrules_selectWithFormat U_ICU_ENTRY_POINT_RENAME(uplrules_selectWithFormat)
#define uplug_closeLibrary U_ICU_ENTRY_POINT_RENAME(uplug_closeLibrary)
diff --git a/deps/icu-small/source/common/unicode/ures.h b/deps/icu-small/source/common/unicode/ures.h
index 839779fada..fff84043e8 100644
--- a/deps/icu-small/source/common/unicode/ures.h
+++ b/deps/icu-small/source/common/unicode/ures.h
@@ -27,7 +27,10 @@
#include "unicode/utypes.h"
#include "unicode/uloc.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
@@ -163,7 +166,7 @@ typedef enum {
* @see ures_close
* @stable ICU 2.0
*/
-U_STABLE UResourceBundle* U_EXPORT2
+U_CAPI UResourceBundle* U_EXPORT2
ures_open(const char* packageName,
const char* locale,
UErrorCode* status);
@@ -186,7 +189,7 @@ ures_open(const char* packageName,
* @see ures_close
* @stable ICU 2.0
*/
-U_STABLE UResourceBundle* U_EXPORT2
+U_CAPI UResourceBundle* U_EXPORT2
ures_openDirect(const char* packageName,
const char* locale,
UErrorCode* status);
@@ -209,7 +212,7 @@ ures_openDirect(const char* packageName,
* @see ures_open
* @stable ICU 2.0
*/
-U_STABLE UResourceBundle* U_EXPORT2
+U_CAPI UResourceBundle* U_EXPORT2
ures_openU(const UChar* packageName,
const char* locale,
UErrorCode* status);
@@ -245,7 +248,7 @@ ures_countArrayItems(const UResourceBundle* resourceBundle,
* @see ures_open
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ures_close(UResourceBundle* resourceBundle);
#if U_SHOW_CPLUSPLUS_API
@@ -291,7 +294,7 @@ ures_getVersionNumber(const UResourceBundle* resourceBundle);
* as specified in the resource bundle or its parent.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ures_getVersion(const UResourceBundle* resB,
UVersionInfo versionInfo);
@@ -325,7 +328,7 @@ ures_getLocale(const UResourceBundle* resourceBundle,
* @return A Locale name
* @stable ICU 2.8
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ures_getLocaleByType(const UResourceBundle* resourceBundle,
ULocDataLocaleType type,
UErrorCode* status);
@@ -348,7 +351,7 @@ ures_getLocaleByType(const UResourceBundle* resourceBundle,
* @param status The error code.
* @internal
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
ures_openFillIn(UResourceBundle *r,
const char* packageName,
const char* localeID,
@@ -372,7 +375,7 @@ ures_openFillIn(UResourceBundle *r,
* @see ures_getUInt
* @stable ICU 2.0
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ures_getString(const UResourceBundle* resourceBundle,
int32_t* len,
UErrorCode* status);
@@ -383,10 +386,10 @@ ures_getString(const UResourceBundle* resourceBundle,
* it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
* or equivalent.
*
- * If forceCopy==TRUE, then the string is always written to the dest buffer
+ * If forceCopy==true, then the string is always written to the dest buffer
* and dest is returned.
*
- * If forceCopy==FALSE, then the string is returned as a pointer if possible,
+ * If forceCopy==false, then the string is returned as a pointer if possible,
* without needing a dest buffer (it can be NULL). If the string needs to be
* copied or transformed, then it may be placed into dest at an arbitrary offset.
*
@@ -404,10 +407,10 @@ ures_getString(const UResourceBundle* resourceBundle,
* terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
* Can be NULL, meaning capacity=0 and the string length is not
* returned to the caller.
- * @param forceCopy If TRUE, then the output string will always be written to
+ * @param forceCopy If true, then the output string will always be written to
* dest, with U_BUFFER_OVERFLOW_ERROR and
* U_STRING_NOT_TERMINATED_WARNING set if appropriate.
- * If FALSE, then the dest buffer may or may not contain a
+ * If false, then the dest buffer may or may not contain a
* copy of the string. dest may or may not be modified.
* If a copy needs to be written, then the UErrorCode parameter
* indicates overflow etc. as usual.
@@ -424,7 +427,7 @@ ures_getString(const UResourceBundle* resourceBundle,
* @see u_strToUTF8
* @stable ICU 3.6
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ures_getUTF8String(const UResourceBundle *resB,
char *dest, int32_t *length,
UBool forceCopy,
@@ -447,7 +450,7 @@ ures_getUTF8String(const UResourceBundle *resB,
* @see ures_getUInt
* @stable ICU 2.0
*/
-U_STABLE const uint8_t* U_EXPORT2
+U_CAPI const uint8_t* U_EXPORT2
ures_getBinary(const UResourceBundle* resourceBundle,
int32_t* len,
UErrorCode* status);
@@ -469,7 +472,7 @@ ures_getBinary(const UResourceBundle* resourceBundle,
* @see ures_getUInt
* @stable ICU 2.0
*/
-U_STABLE const int32_t* U_EXPORT2
+U_CAPI const int32_t* U_EXPORT2
ures_getIntVector(const UResourceBundle* resourceBundle,
int32_t* len,
UErrorCode* status);
@@ -490,7 +493,7 @@ ures_getIntVector(const UResourceBundle* resourceBundle,
* @see ures_getString
* @stable ICU 2.0
*/
-U_STABLE uint32_t U_EXPORT2
+U_CAPI uint32_t U_EXPORT2
ures_getUInt(const UResourceBundle* resourceBundle,
UErrorCode *status);
@@ -510,7 +513,7 @@ ures_getUInt(const UResourceBundle* resourceBundle,
* @see ures_getString
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ures_getInt(const UResourceBundle* resourceBundle,
UErrorCode *status);
@@ -524,7 +527,7 @@ ures_getInt(const UResourceBundle* resourceBundle,
* @return number of resources in a given resource.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ures_getSize(const UResourceBundle *resourceBundle);
/**
@@ -535,7 +538,7 @@ ures_getSize(const UResourceBundle *resourceBundle);
* @see UResType
* @stable ICU 2.0
*/
-U_STABLE UResType U_EXPORT2
+U_CAPI UResType U_EXPORT2
ures_getType(const UResourceBundle *resourceBundle);
/**
@@ -546,7 +549,7 @@ ures_getType(const UResourceBundle *resourceBundle);
* @return a key associated to this resource, or NULL if it doesn't have a key
* @stable ICU 2.0
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ures_getKey(const UResourceBundle *resourceBundle);
/* ITERATION API
@@ -559,17 +562,17 @@ ures_getKey(const UResourceBundle *resourceBundle);
* @param resourceBundle a resource
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ures_resetIterator(UResourceBundle *resourceBundle);
/**
* Checks whether the given resource has another element to iterate over.
*
* @param resourceBundle a resource
- * @return TRUE if there are more elements, FALSE if there is no more elements
+ * @return true if there are more elements, false if there is no more elements
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ures_hasNext(const UResourceBundle *resourceBundle);
/**
@@ -584,7 +587,7 @@ ures_hasNext(const UResourceBundle *resourceBundle);
* @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
* @stable ICU 2.0
*/
-U_STABLE UResourceBundle* U_EXPORT2
+U_CAPI UResourceBundle* U_EXPORT2
ures_getNextResource(UResourceBundle *resourceBundle,
UResourceBundle *fillIn,
UErrorCode *status);
@@ -601,7 +604,7 @@ ures_getNextResource(UResourceBundle *resourceBundle,
* @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
* @stable ICU 2.0
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ures_getNextString(UResourceBundle *resourceBundle,
int32_t* len,
const char ** key,
@@ -619,7 +622,7 @@ ures_getNextString(UResourceBundle *resourceBundle,
* @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
* @stable ICU 2.0
*/
-U_STABLE UResourceBundle* U_EXPORT2
+U_CAPI UResourceBundle* U_EXPORT2
ures_getByIndex(const UResourceBundle *resourceBundle,
int32_t indexR,
UResourceBundle *fillIn,
@@ -636,7 +639,7 @@ ures_getByIndex(const UResourceBundle *resourceBundle,
* @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
* @stable ICU 2.0
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ures_getStringByIndex(const UResourceBundle *resourceBundle,
int32_t indexS,
int32_t* len,
@@ -648,10 +651,10 @@ ures_getStringByIndex(const UResourceBundle *resourceBundle,
* it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
* or equivalent.
*
- * If forceCopy==TRUE, then the string is always written to the dest buffer
+ * If forceCopy==true, then the string is always written to the dest buffer
* and dest is returned.
*
- * If forceCopy==FALSE, then the string is returned as a pointer if possible,
+ * If forceCopy==false, then the string is returned as a pointer if possible,
* without needing a dest buffer (it can be NULL). If the string needs to be
* copied or transformed, then it may be placed into dest at an arbitrary offset.
*
@@ -670,10 +673,10 @@ ures_getStringByIndex(const UResourceBundle *resourceBundle,
* terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
* Can be NULL, meaning capacity=0 and the string length is not
* returned to the caller.
- * @param forceCopy If TRUE, then the output string will always be written to
+ * @param forceCopy If true, then the output string will always be written to
* dest, with U_BUFFER_OVERFLOW_ERROR and
* U_STRING_NOT_TERMINATED_WARNING set if appropriate.
- * If FALSE, then the dest buffer may or may not contain a
+ * If false, then the dest buffer may or may not contain a
* copy of the string. dest may or may not be modified.
* If a copy needs to be written, then the UErrorCode parameter
* indicates overflow etc. as usual.
@@ -690,7 +693,7 @@ ures_getStringByIndex(const UResourceBundle *resourceBundle,
* @see u_strToUTF8
* @stable ICU 3.6
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ures_getUTF8StringByIndex(const UResourceBundle *resB,
int32_t stringIndex,
char *dest, int32_t *pLength,
@@ -709,7 +712,7 @@ ures_getUTF8StringByIndex(const UResourceBundle *resB,
* @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
* @stable ICU 2.0
*/
-U_STABLE UResourceBundle* U_EXPORT2
+U_CAPI UResourceBundle* U_EXPORT2
ures_getByKey(const UResourceBundle *resourceBundle,
const char* key,
UResourceBundle *fillIn,
@@ -727,7 +730,7 @@ ures_getByKey(const UResourceBundle *resourceBundle,
* @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
* @stable ICU 2.0
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ures_getStringByKey(const UResourceBundle *resB,
const char* key,
int32_t* len,
@@ -741,10 +744,10 @@ ures_getStringByKey(const UResourceBundle *resB,
* it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
* or equivalent.
*
- * If forceCopy==TRUE, then the string is always written to the dest buffer
+ * If forceCopy==true, then the string is always written to the dest buffer
* and dest is returned.
*
- * If forceCopy==FALSE, then the string is returned as a pointer if possible,
+ * If forceCopy==false, then the string is returned as a pointer if possible,
* without needing a dest buffer (it can be NULL). If the string needs to be
* copied or transformed, then it may be placed into dest at an arbitrary offset.
*
@@ -763,10 +766,10 @@ ures_getStringByKey(const UResourceBundle *resB,
* terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
* Can be NULL, meaning capacity=0 and the string length is not
* returned to the caller.
- * @param forceCopy If TRUE, then the output string will always be written to
+ * @param forceCopy If true, then the output string will always be written to
* dest, with U_BUFFER_OVERFLOW_ERROR and
* U_STRING_NOT_TERMINATED_WARNING set if appropriate.
- * If FALSE, then the dest buffer may or may not contain a
+ * If false, then the dest buffer may or may not contain a
* copy of the string. dest may or may not be modified.
* If a copy needs to be written, then the UErrorCode parameter
* indicates overflow etc. as usual.
@@ -783,7 +786,7 @@ ures_getStringByKey(const UResourceBundle *resB,
* @see u_strToUTF8
* @stable ICU 3.6
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ures_getUTF8StringByKey(const UResourceBundle *resB,
const char *key,
char *dest, int32_t *pLength,
@@ -811,7 +814,7 @@ ures_getUnicodeString(const UResourceBundle *resB, UErrorCode* status) {
int32_t len = 0;
const UChar *r = ures_getString(resB, &len, status);
if(U_SUCCESS(*status)) {
- result.setTo(TRUE, r, len);
+ result.setTo(true, r, len);
} else {
result.setToBogus();
}
@@ -836,7 +839,7 @@ ures_getNextUnicodeString(UResourceBundle *resB, const char ** key, UErrorCode*
int32_t len = 0;
const UChar* r = ures_getNextString(resB, &len, key, status);
if(U_SUCCESS(*status)) {
- result.setTo(TRUE, r, len);
+ result.setTo(true, r, len);
} else {
result.setToBogus();
}
@@ -858,7 +861,7 @@ ures_getUnicodeStringByIndex(const UResourceBundle *resB, int32_t indexS, UError
int32_t len = 0;
const UChar* r = ures_getStringByIndex(resB, indexS, &len, status);
if(U_SUCCESS(*status)) {
- result.setTo(TRUE, r, len);
+ result.setTo(true, r, len);
} else {
result.setToBogus();
}
@@ -881,7 +884,7 @@ ures_getUnicodeStringByKey(const UResourceBundle *resB, const char* key, UErrorC
int32_t len = 0;
const UChar* r = ures_getStringByKey(resB, key, &len, status);
if(U_SUCCESS(*status)) {
- result.setTo(TRUE, r, len);
+ result.setTo(true, r, len);
} else {
result.setToBogus();
}
@@ -900,7 +903,7 @@ U_NAMESPACE_END
* @param status error code
* @stable ICU 3.2
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
ures_openAvailableLocales(const char *packageName, UErrorCode *status);
diff --git a/deps/icu-small/source/common/unicode/uscript.h b/deps/icu-small/source/common/unicode/uscript.h
index 53d57abed1..8448afda76 100644
--- a/deps/icu-small/source/common/unicode/uscript.h
+++ b/deps/icu-small/source/common/unicode/uscript.h
@@ -514,7 +514,7 @@ typedef enum UScriptCode {
* @return The number of script codes filled in the buffer passed in
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uscript_getCode(const char* nameOrAbbrOrLocale,UScriptCode* fillIn,int32_t capacity,UErrorCode *err);
/**
@@ -527,7 +527,7 @@ uscript_getCode(const char* nameOrAbbrOrLocale,UScriptCode* fillIn,int32_t capac
* or NULL if scriptCode is invalid
* @stable ICU 2.4
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uscript_getName(UScriptCode scriptCode);
/**
@@ -539,7 +539,7 @@ uscript_getName(UScriptCode scriptCode);
* @return short script name (4-letter code), or NULL if scriptCode is invalid
* @stable ICU 2.4
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uscript_getShortName(UScriptCode scriptCode);
/**
@@ -550,7 +550,7 @@ uscript_getShortName(UScriptCode scriptCode);
* @return The UScriptCode, or 0 if codepoint is invalid
* @stable ICU 2.4
*/
-U_STABLE UScriptCode U_EXPORT2
+U_CAPI UScriptCode U_EXPORT2
uscript_getScript(UChar32 codepoint, UErrorCode *err);
/**
@@ -562,10 +562,10 @@ uscript_getScript(UChar32 codepoint, UErrorCode *err);
* For more information, see UAX #24: http://www.unicode.org/reports/tr24/.
* @param c code point
* @param sc script code
- * @return TRUE if sc is in Script_Extensions(c)
+ * @return true if sc is in Script_Extensions(c)
* @stable ICU 49
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uscript_hasScript(UChar32 c, UScriptCode sc);
/**
@@ -597,7 +597,7 @@ uscript_hasScript(UChar32 c, UScriptCode sc);
* written to scripts unless U_BUFFER_OVERFLOW_ERROR indicates insufficient capacity
* @stable ICU 49
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uscript_getScriptExtensions(UChar32 c,
UScriptCode *scripts, int32_t capacity,
UErrorCode *errorCode);
@@ -636,7 +636,7 @@ typedef enum UScriptUsage {
* @return the string length, even if U_BUFFER_OVERFLOW_ERROR
* @stable ICU 51
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uscript_getSampleString(UScriptCode script, UChar *dest, int32_t capacity, UErrorCode *pErrorCode);
#if U_SHOW_CPLUSPLUS_API
@@ -668,41 +668,41 @@ uscript_getSampleUnicodeString(UScriptCode script);
* @see UScriptUsage
* @stable ICU 51
*/
-U_STABLE UScriptUsage U_EXPORT2
+U_CAPI UScriptUsage U_EXPORT2
uscript_getUsage(UScriptCode script);
/**
- * Returns TRUE if the script is written right-to-left.
+ * Returns true if the script is written right-to-left.
* For example, Arab and Hebr.
*
* @param script script code
- * @return TRUE if the script is right-to-left
+ * @return true if the script is right-to-left
* @stable ICU 51
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uscript_isRightToLeft(UScriptCode script);
/**
- * Returns TRUE if the script allows line breaks between letters (excluding hyphenation).
+ * Returns true if the script allows line breaks between letters (excluding hyphenation).
* Such a script typically requires dictionary-based line breaking.
* For example, Hani and Thai.
*
* @param script script code
- * @return TRUE if the script allows line breaks between letters
+ * @return true if the script allows line breaks between letters
* @stable ICU 51
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uscript_breaksBetweenLetters(UScriptCode script);
/**
- * Returns TRUE if in modern (or most recent) usage of the script case distinctions are customary.
+ * Returns true if in modern (or most recent) usage of the script case distinctions are customary.
* For example, Latn and Cyrl.
*
* @param script script code
- * @return TRUE if the script is cased
+ * @return true if the script is cased
* @stable ICU 51
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uscript_isCased(UScriptCode script);
#endif
diff --git a/deps/icu-small/source/common/unicode/uset.h b/deps/icu-small/source/common/unicode/uset.h
index ef6bbb5c38..473cc6fbae 100644
--- a/deps/icu-small/source/common/unicode/uset.h
+++ b/deps/icu-small/source/common/unicode/uset.h
@@ -31,7 +31,10 @@
#include "unicode/utypes.h"
#include "unicode/uchar.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
#ifndef USET_DEFINED
@@ -158,7 +161,7 @@ typedef enum USetSpanCondition {
* Continues a span() while there is no set element at the current position.
* Increments by one code point at a time.
* Stops before the first set element (character or string).
- * (For code points only, this is like while contains(current)==FALSE).
+ * (For code points only, this is like while contains(current)==false).
*
* When span() returns, the substring between where it started and the position
* it returned consists only of characters that are not in the set,
@@ -169,7 +172,7 @@ typedef enum USetSpanCondition {
USET_SPAN_NOT_CONTAINED = 0,
/**
* Spans the longest substring that is a concatenation of set elements (characters or strings).
- * (For characters only, this is like while contains(current)==TRUE).
+ * (For characters only, this is like while contains(current)==true).
*
* When span() returns, the substring between where it started and the position
* it returned consists only of set elements (characters or strings) that are in the set.
@@ -185,7 +188,7 @@ typedef enum USetSpanCondition {
/**
* Continues a span() while there is a set element at the current position.
* Increments by the longest matching element at each position.
- * (For characters only, this is like while contains(current)==TRUE).
+ * (For characters only, this is like while contains(current)==true).
*
* When span() returns, the substring between where it started and the position
* it returned consists only of set elements (characters or strings) that are in the set.
@@ -260,7 +263,7 @@ typedef struct USerializedSet {
* it when done.
* @stable ICU 4.2
*/
-U_STABLE USet* U_EXPORT2
+U_CAPI USet* U_EXPORT2
uset_openEmpty(void);
/**
@@ -273,7 +276,7 @@ uset_openEmpty(void);
* it when done.
* @stable ICU 2.4
*/
-U_STABLE USet* U_EXPORT2
+U_CAPI USet* U_EXPORT2
uset_open(UChar32 start, UChar32 end);
/**
@@ -285,7 +288,7 @@ uset_open(UChar32 start, UChar32 end);
* @param ec the error code
* @stable ICU 2.4
*/
-U_STABLE USet* U_EXPORT2
+U_CAPI USet* U_EXPORT2
uset_openPattern(const UChar* pattern, int32_t patternLength,
UErrorCode* ec);
@@ -300,7 +303,7 @@ uset_openPattern(const UChar* pattern, int32_t patternLength,
* @param ec the error code
* @stable ICU 2.4
*/
-U_STABLE USet* U_EXPORT2
+U_CAPI USet* U_EXPORT2
uset_openPatternOptions(const UChar* pattern, int32_t patternLength,
uint32_t options,
UErrorCode* ec);
@@ -311,7 +314,7 @@ uset_openPatternOptions(const UChar* pattern, int32_t patternLength,
* @param set the object to dispose of
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_close(USet* set);
#if U_SHOW_CPLUSPLUS_API
@@ -342,19 +345,19 @@ U_NAMESPACE_END
* @see uset_cloneAsThawed
* @stable ICU 3.8
*/
-U_STABLE USet * U_EXPORT2
+U_CAPI USet * U_EXPORT2
uset_clone(const USet *set);
/**
* Determines whether the set has been frozen (made immutable) or not.
* See the ICU4J Freezable interface for details.
* @param set the set
- * @return TRUE/FALSE for whether the set has been frozen
+ * @return true/false for whether the set has been frozen
* @see uset_freeze
* @see uset_cloneAsThawed
* @stable ICU 3.8
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_isFrozen(const USet *set);
/**
@@ -371,7 +374,7 @@ uset_isFrozen(const USet *set);
* @see uset_cloneAsThawed
* @stable ICU 3.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_freeze(USet *set);
/**
@@ -384,7 +387,7 @@ uset_freeze(USet *set);
* @see uset_clone
* @stable ICU 3.8
*/
-U_STABLE USet * U_EXPORT2
+U_CAPI USet * U_EXPORT2
uset_cloneAsThawed(const USet *set);
/**
@@ -396,7 +399,7 @@ uset_cloneAsThawed(const USet *set);
* @param end last character in the set, inclusive
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_set(USet* set,
UChar32 start, UChar32 end);
@@ -421,7 +424,7 @@ uset_set(USet* set,
*
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_applyPattern(USet *set,
const UChar *pattern, int32_t patternLength,
uint32_t options,
@@ -449,7 +452,7 @@ uset_applyPattern(USet *set,
*
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_applyIntPropertyValue(USet* set,
UProperty prop, int32_t value, UErrorCode* ec);
@@ -488,7 +491,7 @@ uset_applyIntPropertyValue(USet* set,
*
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_applyPropertyAlias(USet* set,
const UChar *prop, int32_t propLength,
const UChar *value, int32_t valueLength,
@@ -503,7 +506,7 @@ uset_applyPropertyAlias(USet* set,
* @param pos the given position
* @stable ICU 3.2
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
int32_t pos);
@@ -514,7 +517,7 @@ uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
* @param set the set
* @param result the string to receive the rules, may be NULL
* @param resultCapacity the capacity of result, may be 0 if result is NULL
- * @param escapeUnprintable if TRUE then convert unprintable
+ * @param escapeUnprintable if true then convert unprintable
* character to their hex escape representations, \\uxxxx or
* \\Uxxxxxxxx. Unprintable characters are those other than
* U+000A, U+0020..U+007E.
@@ -522,7 +525,7 @@ uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
* @return length of string, possibly larger than resultCapacity
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_toPattern(const USet* set,
UChar* result, int32_t resultCapacity,
UBool escapeUnprintable,
@@ -530,13 +533,13 @@ uset_toPattern(const USet* set,
/**
* Adds the given character to the given USet. After this call,
- * uset_contains(set, c) will return TRUE.
+ * uset_contains(set, c) will return true.
* A frozen set will not be modified.
* @param set the object to which to add the character
* @param c the character to add
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_add(USet* set, UChar32 c);
/**
@@ -551,31 +554,31 @@ uset_add(USet* set, UChar32 c);
* @param additionalSet the source set whose elements are to be added to this set.
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_addAll(USet* set, const USet *additionalSet);
/**
* Adds the given range of characters to the given USet. After this call,
- * uset_contains(set, start, end) will return TRUE.
+ * uset_contains(set, start, end) will return true.
* A frozen set will not be modified.
* @param set the object to which to add the character
* @param start the first character of the range to add, inclusive
* @param end the last character of the range to add, inclusive
* @stable ICU 2.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_addRange(USet* set, UChar32 start, UChar32 end);
/**
* Adds the given string to the given USet. After this call,
- * uset_containsString(set, str, strLen) will return TRUE.
+ * uset_containsString(set, str, strLen) will return true.
* A frozen set will not be modified.
* @param set the object to which to add the character
* @param str the string to add
* @param strLen the length of the string or -1 if null terminated.
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_addString(USet* set, const UChar* str, int32_t strLen);
/**
@@ -587,42 +590,42 @@ uset_addString(USet* set, const UChar* str, int32_t strLen);
* @param strLen the length of the string or -1 if null terminated.
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_addAllCodePoints(USet* set, const UChar *str, int32_t strLen);
/**
* Removes the given character from the given USet. After this call,
- * uset_contains(set, c) will return FALSE.
+ * uset_contains(set, c) will return false.
* A frozen set will not be modified.
* @param set the object from which to remove the character
* @param c the character to remove
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_remove(USet* set, UChar32 c);
/**
* Removes the given range of characters from the given USet. After this call,
- * uset_contains(set, start, end) will return FALSE.
+ * uset_contains(set, start, end) will return false.
* A frozen set will not be modified.
* @param set the object to which to add the character
* @param start the first character of the range to remove, inclusive
* @param end the last character of the range to remove, inclusive
* @stable ICU 2.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_removeRange(USet* set, UChar32 start, UChar32 end);
/**
* Removes the given string to the given USet. After this call,
- * uset_containsString(set, str, strLen) will return FALSE.
+ * uset_containsString(set, str, strLen) will return false.
* A frozen set will not be modified.
* @param set the object to which to add the character
* @param str the string to remove
* @param strLen the length of the string or -1 if null terminated.
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_removeString(USet* set, const UChar* str, int32_t strLen);
/**
@@ -636,7 +639,7 @@ uset_removeString(USet* set, const UChar* str, int32_t strLen);
* removed from this set
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_removeAll(USet* set, const USet* removeSet);
/**
@@ -653,7 +656,7 @@ uset_removeAll(USet* set, const USet* removeSet);
* to this set.
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_retain(USet* set, UChar32 start, UChar32 end);
/**
@@ -668,7 +671,7 @@ uset_retain(USet* set, UChar32 start, UChar32 end);
* @param retain set that defines which elements this set will retain
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_retainAll(USet* set, const USet* retain);
/**
@@ -679,7 +682,7 @@ uset_retainAll(USet* set, const USet* retain);
* @param set the object on which to perfrom the compact
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_compact(USet* set);
/**
@@ -690,7 +693,7 @@ uset_compact(USet* set);
* @param set the set
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_complement(USet* set);
/**
@@ -704,7 +707,7 @@ uset_complement(USet* set);
* from this set.
* @stable ICU 3.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_complementAll(USet* set, const USet* complement);
/**
@@ -714,7 +717,7 @@ uset_complementAll(USet* set, const USet* complement);
* @param set the set
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_clear(USet* set);
/**
@@ -743,7 +746,7 @@ uset_clear(USet* set);
* are ignored.
* @stable ICU 4.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_closeOver(USet* set, int32_t attributes);
/**
@@ -752,51 +755,51 @@ uset_closeOver(USet* set, int32_t attributes);
* @param set the set
* @stable ICU 4.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_removeAllStrings(USet* set);
/**
- * Returns TRUE if the given USet contains no characters and no
+ * Returns true if the given USet contains no characters and no
* strings.
* @param set the set
* @return true if set is empty
* @stable ICU 2.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_isEmpty(const USet* set);
/**
- * Returns TRUE if the given USet contains the given character.
+ * Returns true if the given USet contains the given character.
* This function works faster with a frozen set.
* @param set the set
* @param c The codepoint to check for within the set
* @return true if set contains c
* @stable ICU 2.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_contains(const USet* set, UChar32 c);
/**
- * Returns TRUE if the given USet contains all characters c
+ * Returns true if the given USet contains all characters c
* where start <= c && c <= end.
* @param set the set
* @param start the first character of the range to test, inclusive
* @param end the last character of the range to test, inclusive
- * @return TRUE if set contains the range
+ * @return true if set contains the range
* @stable ICU 2.2
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_containsRange(const USet* set, UChar32 start, UChar32 end);
/**
- * Returns TRUE if the given USet contains the given string.
+ * Returns true if the given USet contains the given string.
* @param set the set
* @param str the string
* @param strLen the length of the string or -1 if null terminated.
* @return true if set contains str
* @stable ICU 2.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_containsString(const USet* set, const UChar* str, int32_t strLen);
/**
@@ -809,7 +812,7 @@ uset_containsString(const USet* set, const UChar* str, int32_t strLen);
* @return an index from 0..size()-1, or -1
* @stable ICU 3.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_indexOf(const USet* set, UChar32 c);
/**
@@ -822,7 +825,7 @@ uset_indexOf(const USet* set, UChar32 c);
* @return the character at the given index, or (UChar32)-1.
* @stable ICU 3.2
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
uset_charAt(const USet* set, int32_t charIndex);
/**
@@ -833,7 +836,7 @@ uset_charAt(const USet* set, int32_t charIndex);
* contained in set
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_size(const USet* set);
/**
@@ -844,7 +847,7 @@ uset_size(const USet* set);
* and/or strings contained in set
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_getItemCount(const USet* set);
/**
@@ -865,7 +868,7 @@ uset_getItemCount(const USet* set);
* itemIndex is out of range
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_getItem(const USet* set, int32_t itemIndex,
UChar32* start, UChar32* end,
UChar* str, int32_t strCapacity,
@@ -879,7 +882,7 @@ uset_getItem(const USet* set, int32_t itemIndex,
* @return true if the test condition is met
* @stable ICU 3.2
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_containsAll(const USet* set1, const USet* set2);
/**
@@ -892,7 +895,7 @@ uset_containsAll(const USet* set1, const USet* set2);
* @return true if the test condition is met
* @stable ICU 3.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_containsAllCodePoints(const USet* set, const UChar *str, int32_t strLen);
/**
@@ -903,7 +906,7 @@ uset_containsAllCodePoints(const USet* set, const UChar *str, int32_t strLen);
* @return true if the test condition is met
* @stable ICU 3.2
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_containsNone(const USet* set1, const USet* set2);
/**
@@ -914,7 +917,7 @@ uset_containsNone(const USet* set1, const USet* set2);
* @return true if the test condition is met
* @stable ICU 3.2
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_containsSome(const USet* set1, const USet* set2);
/**
@@ -936,7 +939,7 @@ uset_containsSome(const USet* set1, const USet* set2);
* @stable ICU 3.8
* @see USetSpanCondition
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_span(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);
/**
@@ -957,7 +960,7 @@ uset_span(const USet *set, const UChar *s, int32_t length, USetSpanCondition spa
* @stable ICU 3.8
* @see USetSpanCondition
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_spanBack(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);
/**
@@ -979,7 +982,7 @@ uset_spanBack(const USet *set, const UChar *s, int32_t length, USetSpanCondition
* @stable ICU 3.8
* @see USetSpanCondition
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_spanUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);
/**
@@ -1000,7 +1003,7 @@ uset_spanUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition
* @stable ICU 3.8
* @see USetSpanCondition
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_spanBackUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);
/**
@@ -1011,7 +1014,7 @@ uset_spanBackUTF8(const USet *set, const char *s, int32_t length, USetSpanCondit
* @return true if the test condition is met
* @stable ICU 3.2
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_equals(const USet* set1, const USet* set2);
/*********************************************************************
@@ -1067,7 +1070,7 @@ uset_equals(const USet* set1, const USet* set2);
* than U_BUFFER_OVERFLOW_ERROR.
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_serialize(const USet* set, uint16_t* dest, int32_t destCapacity, UErrorCode* pErrorCode);
/**
@@ -1078,7 +1081,7 @@ uset_serialize(const USet* set, uint16_t* dest, int32_t destCapacity, UErrorCode
* @return true if the given array is valid, otherwise false
* @stable ICU 2.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_getSerializedSet(USerializedSet* fillSet, const uint16_t* src, int32_t srcLength);
/**
@@ -1088,18 +1091,18 @@ uset_getSerializedSet(USerializedSet* fillSet, const uint16_t* src, int32_t srcL
* @param c The codepoint to set
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uset_setSerializedToOne(USerializedSet* fillSet, UChar32 c);
/**
- * Returns TRUE if the given USerializedSet contains the given
+ * Returns true if the given USerializedSet contains the given
* character.
* @param set the serialized set
* @param c The codepoint to check for within the set
* @return true if set contains c
* @stable ICU 2.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_serializedContains(const USerializedSet* set, UChar32 c);
/**
@@ -1111,7 +1114,7 @@ uset_serializedContains(const USerializedSet* set, UChar32 c);
* contained in set
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uset_getSerializedRangeCount(const USerializedSet* set);
/**
@@ -1127,7 +1130,7 @@ uset_getSerializedRangeCount(const USerializedSet* set);
* @return true if rangeIndex is valid, otherwise false
* @stable ICU 2.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex,
UChar32* pStart, UChar32* pEnd);
diff --git a/deps/icu-small/source/common/unicode/usetiter.h b/deps/icu-small/source/common/unicode/usetiter.h
index f3f470f95a..45d268a05c 100644
--- a/deps/icu-small/source/common/unicode/usetiter.h
+++ b/deps/icu-small/source/common/unicode/usetiter.h
@@ -176,7 +176,7 @@ class U_COMMON_API UnicodeSetIterator : public UObject {
* If there are no more elements in the set, return false.
*
* <p>
- * If <tt>isString() == TRUE</tt>, the value is a
+ * If <tt>isString() == true</tt>, the value is a
* string, otherwise the value is a
* single code point. Elements of either type can be retrieved
* with the function <tt>getString()</tt>, while elements of
@@ -197,7 +197,7 @@ class U_COMMON_API UnicodeSetIterator : public UObject {
/**
* Returns the next element in the set, either a code point range
* or a string. If there are no more elements in the set, return
- * false. If <tt>isString() == TRUE</tt>, the value is a
+ * false. If <tt>isString() == true</tt>, the value is a
* string and can be accessed with <tt>getString()</tt>. Otherwise the value is a
* range of one or more code points from <tt>getCodepoint()</tt> to
* <tt>getCodepointeEnd()</tt> inclusive.
@@ -205,7 +205,7 @@ class U_COMMON_API UnicodeSetIterator : public UObject {
* <p>The order of iteration is all code points ranges in sorted
* order, followed by all strings sorted order. Ranges are
* disjoint and non-contiguous. The value returned from <tt>getString()</tt>
- * is undefined unless <tt>isString() == TRUE</tt>. Do not mix calls to
+ * is undefined unless <tt>isString() == true</tt>. Do not mix calls to
* <tt>next()</tt> and <tt>nextRange()</tt> without calling
* <tt>reset()</tt> between them. The results of doing so are
* undefined.
diff --git a/deps/icu-small/source/common/unicode/ushape.h b/deps/icu-small/source/common/unicode/ushape.h
index 3064e08572..9a85b73e4c 100644
--- a/deps/icu-small/source/common/unicode/ushape.h
+++ b/deps/icu-small/source/common/unicode/ushape.h
@@ -98,7 +98,7 @@
* the return value indicates the necessary destination buffer size.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_shapeArabic(const UChar *source, int32_t sourceLength,
UChar *dest, int32_t destSize,
uint32_t options,
diff --git a/deps/icu-small/source/common/unicode/usprep.h b/deps/icu-small/source/common/unicode/usprep.h
index 7cdc6cdd18..be06189e2e 100644
--- a/deps/icu-small/source/common/unicode/usprep.h
+++ b/deps/icu-small/source/common/unicode/usprep.h
@@ -25,7 +25,10 @@
*/
#include "unicode/utypes.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
*
@@ -181,7 +184,7 @@ typedef enum UStringPrepProfileType {
* @see usprep_close()
* @stable ICU 2.8
*/
-U_STABLE UStringPrepProfile* U_EXPORT2
+U_CAPI UStringPrepProfile* U_EXPORT2
usprep_open(const char* path,
const char* fileName,
UErrorCode* status);
@@ -197,7 +200,7 @@ usprep_open(const char* path,
* @see usprep_close()
* @stable ICU 4.2
*/
-U_STABLE UStringPrepProfile* U_EXPORT2
+U_CAPI UStringPrepProfile* U_EXPORT2
usprep_openByType(UStringPrepProfileType type,
UErrorCode* status);
@@ -206,7 +209,7 @@ usprep_openByType(UStringPrepProfileType type,
* @param profile The profile to close
* @stable ICU 2.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
usprep_close(UStringPrepProfile* profile);
#if U_SHOW_CPLUSPLUS_API
@@ -257,7 +260,7 @@ U_NAMESPACE_END
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
usprep_prepare( const UStringPrepProfile* prep,
const UChar* src, int32_t srcLength,
UChar* dest, int32_t destCapacity,
diff --git a/deps/icu-small/source/common/unicode/ustring.h b/deps/icu-small/source/common/unicode/ustring.h
index 0d2274a0ca..3243acbb7e 100644
--- a/deps/icu-small/source/common/unicode/ustring.h
+++ b/deps/icu-small/source/common/unicode/ustring.h
@@ -89,7 +89,7 @@
* @return The number of UChars in <code>chars</code>, minus the terminator.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strlen(const UChar *s);
/*@}*/
@@ -106,7 +106,7 @@ u_strlen(const UChar *s);
* @return The number of code points in the specified code units.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_countChar32(const UChar *s, int32_t length);
/**
@@ -127,7 +127,7 @@ u_countChar32(const UChar *s, int32_t length);
* than 'number'. Same as (u_countChar32(s, length)>number).
* @stable ICU 2.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
u_strHasMoreChar32Than(const UChar *s, int32_t length, int32_t number);
/**
@@ -140,7 +140,7 @@ u_strHasMoreChar32Than(const UChar *s, int32_t length, int32_t number);
* @return A pointer to <code>dst</code>.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strcat(UChar *dst,
const UChar *src);
@@ -158,7 +158,7 @@ u_strcat(UChar *dst,
* @return A pointer to <code>dst</code>.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strncat(UChar *dst,
const UChar *src,
int32_t n);
@@ -183,7 +183,7 @@ u_strncat(UChar *dst,
* @see u_strFindFirst
* @see u_strFindLast
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strstr(const UChar *s, const UChar *substring);
/**
@@ -207,7 +207,7 @@ u_strstr(const UChar *s, const UChar *substring);
* @see u_strstr
* @see u_strFindLast
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strFindFirst(const UChar *s, int32_t length, const UChar *substring, int32_t subLength);
/**
@@ -227,7 +227,7 @@ u_strFindFirst(const UChar *s, int32_t length, const UChar *substring, int32_t s
* @see u_strstr
* @see u_strFindFirst
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strchr(const UChar *s, UChar c);
/**
@@ -247,7 +247,7 @@ u_strchr(const UChar *s, UChar c);
* @see u_strstr
* @see u_strFindFirst
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strchr32(const UChar *s, UChar32 c);
/**
@@ -270,7 +270,7 @@ u_strchr32(const UChar *s, UChar32 c);
* @see u_strFindFirst
* @see u_strFindLast
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strrstr(const UChar *s, const UChar *substring);
/**
@@ -294,7 +294,7 @@ u_strrstr(const UChar *s, const UChar *substring);
* @see u_strstr
* @see u_strFindLast
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strFindLast(const UChar *s, int32_t length, const UChar *substring, int32_t subLength);
/**
@@ -314,7 +314,7 @@ u_strFindLast(const UChar *s, int32_t length, const UChar *substring, int32_t su
* @see u_strrstr
* @see u_strFindLast
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strrchr(const UChar *s, UChar c);
/**
@@ -334,7 +334,7 @@ u_strrchr(const UChar *s, UChar c);
* @see u_strrstr
* @see u_strFindLast
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strrchr32(const UChar *s, UChar32 c);
/**
@@ -349,7 +349,7 @@ u_strrchr32(const UChar *s, UChar32 c);
* characters in <code>matchSet</code>, or NULL if no such character is found.
* @stable ICU 2.0
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strpbrk(const UChar *string, const UChar *matchSet);
/**
@@ -365,7 +365,7 @@ u_strpbrk(const UChar *string, const UChar *matchSet);
* @see u_strspn
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strcspn(const UChar *string, const UChar *matchSet);
/**
@@ -381,7 +381,7 @@ u_strcspn(const UChar *string, const UChar *matchSet);
* @see u_strcspn
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strspn(const UChar *string, const UChar *matchSet);
/**
@@ -409,7 +409,7 @@ u_strspn(const UChar *string, const UChar *matchSet);
* when there are no more tokens.
* @stable ICU 2.0
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strtok_r(UChar *src,
const UChar *delim,
UChar **saveState);
@@ -424,7 +424,7 @@ u_strtok_r(UChar *src,
* value if <code>s1</code> is bitwise greater than <code>s2</code>.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strcmp(const UChar *s1,
const UChar *s2);
@@ -439,7 +439,7 @@ u_strcmp(const UChar *s1,
* in code point order
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strcmpCodePointOrder(const UChar *s1, const UChar *s2);
/**
@@ -462,14 +462,14 @@ u_strcmpCodePointOrder(const UChar *s1, const UChar *s2);
* @param s2 Second source string.
* @param length2 Length of second source string, or -1 if NUL-terminated.
*
- * @param codePointOrder Choose between code unit order (FALSE)
- * and code point order (TRUE).
+ * @param codePointOrder Choose between code unit order (false)
+ * and code point order (true).
*
* @return <0 or 0 or >0 as usual for string comparisons
*
* @stable ICU 2.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strCompare(const UChar *s1, int32_t length1,
const UChar *s2, int32_t length2,
UBool codePointOrder);
@@ -485,8 +485,8 @@ u_strCompare(const UChar *s1, int32_t length1,
*
* @param iter1 First source string iterator.
* @param iter2 Second source string iterator.
- * @param codePointOrder Choose between code unit order (FALSE)
- * and code point order (TRUE).
+ * @param codePointOrder Choose between code unit order (false)
+ * and code point order (true).
*
* @return <0 or 0 or >0 as usual for string comparisons
*
@@ -494,7 +494,7 @@ u_strCompare(const UChar *s1, int32_t length1,
*
* @stable ICU 2.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strCompareIter(UCharIterator *iter1, UCharIterator *iter2, UBool codePointOrder);
/**
@@ -537,7 +537,7 @@ u_strCompareIter(UCharIterator *iter1, UCharIterator *iter2, UBool codePointOrde
*
* @stable ICU 2.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strCaseCompare(const UChar *s1, int32_t length1,
const UChar *s2, int32_t length2,
uint32_t options,
@@ -555,7 +555,7 @@ u_strCaseCompare(const UChar *s1, int32_t length1,
* value if <code>s1</code> is bitwise greater than <code>s2</code>.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strncmp(const UChar *ucs1,
const UChar *ucs2,
int32_t n);
@@ -573,7 +573,7 @@ u_strncmp(const UChar *ucs1,
* in code point order
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strncmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t n);
/**
@@ -595,7 +595,7 @@ u_strncmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t n);
* @return A negative, zero, or positive integer indicating the comparison result.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strcasecmp(const UChar *s1, const UChar *s2, uint32_t options);
/**
@@ -619,7 +619,7 @@ u_strcasecmp(const UChar *s1, const UChar *s2, uint32_t options);
* @return A negative, zero, or positive integer indicating the comparison result.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strncasecmp(const UChar *s1, const UChar *s2, int32_t n, uint32_t options);
/**
@@ -643,7 +643,7 @@ u_strncasecmp(const UChar *s1, const UChar *s2, int32_t n, uint32_t options);
* @return A negative, zero, or positive integer indicating the comparison result.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_memcasecmp(const UChar *s1, const UChar *s2, int32_t length, uint32_t options);
/**
@@ -654,7 +654,7 @@ u_memcasecmp(const UChar *s1, const UChar *s2, int32_t length, uint32_t options)
* @return A pointer to <code>dst</code>.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strcpy(UChar *dst,
const UChar *src);
@@ -669,7 +669,7 @@ u_strcpy(UChar *dst,
* @return A pointer to <code>dst</code>.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strncpy(UChar *dst,
const UChar *src,
int32_t n);
@@ -686,7 +686,7 @@ u_strncpy(UChar *dst,
* @return A pointer to <code>dst</code>.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2 u_uastrcpy(UChar *dst,
+U_CAPI UChar* U_EXPORT2 u_uastrcpy(UChar *dst,
const char *src );
/**
@@ -701,7 +701,7 @@ U_STABLE UChar* U_EXPORT2 u_uastrcpy(UChar *dst,
* @return A pointer to <code>dst</code>.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2 u_uastrncpy(UChar *dst,
+U_CAPI UChar* U_EXPORT2 u_uastrncpy(UChar *dst,
const char *src,
int32_t n);
@@ -715,7 +715,7 @@ U_STABLE UChar* U_EXPORT2 u_uastrncpy(UChar *dst,
* @return A pointer to <code>dst</code>.
* @stable ICU 2.0
*/
-U_STABLE char* U_EXPORT2 u_austrcpy(char *dst,
+U_CAPI char* U_EXPORT2 u_austrcpy(char *dst,
const UChar *src );
/**
@@ -730,7 +730,7 @@ U_STABLE char* U_EXPORT2 u_austrcpy(char *dst,
* @return A pointer to <code>dst</code>.
* @stable ICU 2.0
*/
-U_STABLE char* U_EXPORT2 u_austrncpy(char *dst,
+U_CAPI char* U_EXPORT2 u_austrncpy(char *dst,
const UChar *src,
int32_t n );
@@ -744,7 +744,7 @@ U_STABLE char* U_EXPORT2 u_austrncpy(char *dst,
* @return A pointer to <code>dest</code>
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_memcpy(UChar *dest, const UChar *src, int32_t count);
/**
@@ -755,7 +755,7 @@ u_memcpy(UChar *dest, const UChar *src, int32_t count);
* @return A pointer to <code>dest</code>
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_memmove(UChar *dest, const UChar *src, int32_t count);
/**
@@ -767,7 +767,7 @@ u_memmove(UChar *dest, const UChar *src, int32_t count);
* @return A pointer to <code>dest</code>.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_memset(UChar *dest, UChar c, int32_t count);
/**
@@ -781,7 +781,7 @@ u_memset(UChar *dest, UChar c, int32_t count);
* When buf1 > buf2, a positive number is returned.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_memcmp(const UChar *buf1, const UChar *buf2, int32_t count);
/**
@@ -797,7 +797,7 @@ u_memcmp(const UChar *buf1, const UChar *buf2, int32_t count);
* in code point order
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_memcmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t count);
/**
@@ -817,7 +817,7 @@ u_memcmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t count);
* @see u_memchr32
* @see u_strFindFirst
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_memchr(const UChar *s, UChar c, int32_t count);
/**
@@ -837,7 +837,7 @@ u_memchr(const UChar *s, UChar c, int32_t count);
* @see u_memchr
* @see u_strFindFirst
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_memchr32(const UChar *s, UChar32 c, int32_t count);
/**
@@ -857,7 +857,7 @@ u_memchr32(const UChar *s, UChar32 c, int32_t count);
* @see u_memrchr32
* @see u_strFindLast
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_memrchr(const UChar *s, UChar c, int32_t count);
/**
@@ -877,7 +877,7 @@ u_memrchr(const UChar *s, UChar c, int32_t count);
* @see u_memrchr
* @see u_strFindLast
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_memrchr32(const UChar *s, UChar32 c, int32_t count);
/**
@@ -903,13 +903,13 @@ u_memrchr32(const UChar *s, UChar32 c, int32_t count);
*
* U_STRING_DECL(ustringVar1, "Quick-Fox 2", 11);
* U_STRING_DECL(ustringVar2, "jumps 5%", 8);
- * static UBool didInit=FALSE;
+ * static UBool didInit=false;
*
* int32_t function() {
* if(!didInit) {
* U_STRING_INIT(ustringVar1, "Quick-Fox 2", 11);
* U_STRING_INIT(ustringVar2, "jumps 5%", 8);
- * didInit=TRUE;
+ * didInit=true;
* }
* return u_strcmp(ustringVar1, ustringVar2);
* }
@@ -992,7 +992,7 @@ u_memrchr32(const UChar *s, UChar32 c, int32_t count);
* @see UnicodeString#unescapeAt()
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_unescape(const char *src,
UChar *dest, int32_t destCapacity);
@@ -1040,7 +1040,7 @@ U_CDECL_END
* @see UnicodeString#unescapeAt()
* @stable ICU 2.0
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
u_unescapeAt(UNESCAPE_CHAR_AT charAt,
int32_t *offset,
int32_t length,
@@ -1066,7 +1066,7 @@ u_unescapeAt(UNESCAPE_CHAR_AT charAt,
* only some of the result was written to the destination buffer.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strToUpper(UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
const char *locale,
@@ -1092,7 +1092,7 @@ u_strToUpper(UChar *dest, int32_t destCapacity,
* only some of the result was written to the destination buffer.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strToLower(UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
const char *locale,
@@ -1138,7 +1138,7 @@ u_strToLower(UChar *dest, int32_t destCapacity,
* only some of the result was written to the destination buffer.
* @stable ICU 2.1
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strToTitle(UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
UBreakIterator *titleIter,
@@ -1171,7 +1171,7 @@ u_strToTitle(UChar *dest, int32_t destCapacity,
* only some of the result was written to the destination buffer.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_strFoldCase(UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
uint32_t options,
@@ -1200,7 +1200,7 @@ u_strFoldCase(UChar *dest, int32_t destCapacity,
* @return The pointer to destination buffer.
* @stable ICU 2.0
*/
-U_STABLE wchar_t* U_EXPORT2
+U_CAPI wchar_t* U_EXPORT2
u_strToWCS(wchar_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1229,7 +1229,7 @@ u_strToWCS(wchar_t *dest,
* @return The pointer to destination buffer.
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strFromWCS(UChar *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1260,7 +1260,7 @@ u_strFromWCS(UChar *dest,
* @see u_strToUTF8WithSub
* @see u_strFromUTF8
*/
-U_STABLE char* U_EXPORT2
+U_CAPI char* U_EXPORT2
u_strToUTF8(char *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1290,7 +1290,7 @@ u_strToUTF8(char *dest,
* @see u_strFromUTF8WithSub
* @see u_strFromUTF8Lenient
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strFromUTF8(UChar *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1333,7 +1333,7 @@ u_strFromUTF8(UChar *dest,
* @see u_strFromUTF8WithSub
* @stable ICU 3.6
*/
-U_STABLE char* U_EXPORT2
+U_CAPI char* U_EXPORT2
u_strToUTF8WithSub(char *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1378,7 +1378,7 @@ u_strToUTF8WithSub(char *dest,
* @see u_strToUTF8WithSub
* @stable ICU 3.6
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strFromUTF8WithSub(UChar *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1438,7 +1438,7 @@ u_strFromUTF8WithSub(UChar *dest,
* @see u_strToUTF8WithSub
* @stable ICU 3.6
*/
-U_STABLE UChar * U_EXPORT2
+U_CAPI UChar * U_EXPORT2
u_strFromUTF8Lenient(UChar *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1468,7 +1468,7 @@ u_strFromUTF8Lenient(UChar *dest,
* @see u_strFromUTF32
* @stable ICU 2.0
*/
-U_STABLE UChar32* U_EXPORT2
+U_CAPI UChar32* U_EXPORT2
u_strToUTF32(UChar32 *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1498,7 +1498,7 @@ u_strToUTF32(UChar32 *dest,
* @see u_strToUTF32
* @stable ICU 2.0
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strFromUTF32(UChar *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1541,7 +1541,7 @@ u_strFromUTF32(UChar *dest,
* @see u_strFromUTF32WithSub
* @stable ICU 4.2
*/
-U_STABLE UChar32* U_EXPORT2
+U_CAPI UChar32* U_EXPORT2
u_strToUTF32WithSub(UChar32 *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1585,7 +1585,7 @@ u_strToUTF32WithSub(UChar32 *dest,
* @see u_strToUTF32WithSub
* @stable ICU 4.2
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strFromUTF32WithSub(UChar *dest,
int32_t destCapacity,
int32_t *pDestLength,
@@ -1626,7 +1626,7 @@ u_strFromUTF32WithSub(UChar *dest,
* @see u_strToUTF8WithSub
* @see u_strFromJavaModifiedUTF8WithSub
*/
-U_STABLE char* U_EXPORT2
+U_CAPI char* U_EXPORT2
u_strToJavaModifiedUTF8(
char *dest,
int32_t destCapacity,
@@ -1676,7 +1676,7 @@ u_strToJavaModifiedUTF8(
* @see u_strToJavaModifiedUTF8
* @stable ICU 4.4
*/
-U_STABLE UChar* U_EXPORT2
+U_CAPI UChar* U_EXPORT2
u_strFromJavaModifiedUTF8WithSub(
UChar *dest,
int32_t destCapacity,
diff --git a/deps/icu-small/source/common/unicode/utext.h b/deps/icu-small/source/common/unicode/utext.h
index d36c1c035e..084362be78 100644
--- a/deps/icu-small/source/common/unicode/utext.h
+++ b/deps/icu-small/source/common/unicode/utext.h
@@ -180,7 +180,7 @@ typedef struct UText UText; /**< C typedef for struct UText. @stable ICU 3.6 */
*
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_close(UText *ut);
/**
@@ -204,7 +204,7 @@ utext_close(UText *ut);
* will always be used and returned.
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_openUTF8(UText *ut, const char *s, int64_t length, UErrorCode *status);
@@ -222,7 +222,7 @@ utext_openUTF8(UText *ut, const char *s, int64_t length, UErrorCode *status);
* will always be used and returned.
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_openUChars(UText *ut, const UChar *s, int64_t length, UErrorCode *status);
@@ -239,7 +239,7 @@ utext_openUChars(UText *ut, const UChar *s, int64_t length, UErrorCode *status);
* will always be used and returned.
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_openUnicodeString(UText *ut, icu::UnicodeString *s, UErrorCode *status);
@@ -255,7 +255,7 @@ utext_openUnicodeString(UText *ut, icu::UnicodeString *s, UErrorCode *status);
* will always be used and returned.
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_openConstUnicodeString(UText *ut, const icu::UnicodeString *s, UErrorCode *status);
@@ -271,7 +271,7 @@ utext_openConstUnicodeString(UText *ut, const icu::UnicodeString *s, UErrorCode
* @see Replaceable
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_openReplaceable(UText *ut, icu::Replaceable *rep, UErrorCode *status);
/**
@@ -286,7 +286,7 @@ utext_openReplaceable(UText *ut, icu::Replaceable *rep, UErrorCode *status);
* @see Replaceable
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_openCharacterIterator(UText *ut, icu::CharacterIterator *ci, UErrorCode *status);
#endif
@@ -323,7 +323,7 @@ utext_openCharacterIterator(UText *ut, icu::CharacterIterator *ci, UErrorCode *s
* shallow clones provide some protection against errors of this type by
* disabling text modification via the cloned UText.
*
- * A shallow clone made with the readOnly parameter == FALSE will preserve the
+ * A shallow clone made with the readOnly parameter == false will preserve the
* utext_isWritable() state of the source object. Note, however, that
* write operations must be avoided while more than one UText exists that refer
* to the same underlying text.
@@ -339,8 +339,8 @@ utext_openCharacterIterator(UText *ut, icu::CharacterIterator *ci, UErrorCode *s
* If non-NULL, must refer to an already existing UText, which will then
* be reset to become the clone.
* @param src The UText to be cloned.
- * @param deep TRUE to request a deep clone, FALSE for a shallow clone.
- * @param readOnly TRUE to request that the cloned UText have read only access to the
+ * @param deep true to request a deep clone, false for a shallow clone.
+ * @param readOnly true to request that the cloned UText have read only access to the
* underlying text.
* @param status Errors are returned here. For deep clones, U_UNSUPPORTED_ERROR
@@ -349,7 +349,7 @@ utext_openCharacterIterator(UText *ut, icu::CharacterIterator *ci, UErrorCode *s
* @return The newly created clone, or NULL if the clone operation failed.
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_clone(UText *dest, const UText *src, UBool deep, UBool readOnly, UErrorCode *status);
@@ -357,14 +357,14 @@ utext_clone(UText *dest, const UText *src, UBool deep, UBool readOnly, UErrorCod
* Compare two UText objects for equality.
* UTexts are equal if they are iterating over the same text, and
* have the same iteration position within the text.
- * If either or both of the parameters are NULL, the comparison is FALSE.
+ * If either or both of the parameters are NULL, the comparison is false.
*
* @param a The first of the two UTexts to compare.
* @param b The other UText to be compared.
- * @return TRUE if the two UTexts are equal.
+ * @return true if the two UTexts are equal.
* @stable ICU 3.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
utext_equals(const UText *a, const UText *b);
@@ -385,11 +385,11 @@ utext_equals(const UText *a, const UText *b);
*
* @stable ICU 3.4
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
utext_nativeLength(UText *ut);
/**
- * Return TRUE if calculating the length of the text could be expensive.
+ * Return true if calculating the length of the text could be expensive.
* Finding the length of NUL terminated strings is considered to be expensive.
*
* Note that the value of this function may change
@@ -398,10 +398,10 @@ utext_nativeLength(UText *ut);
* be expensive to report it.
*
* @param ut the text to be accessed.
- * @return TRUE if determining the length of the text could be time consuming.
+ * @return true if determining the length of the text could be time consuming.
* @stable ICU 3.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
utext_isLengthExpensive(const UText *ut);
/**
@@ -429,7 +429,7 @@ utext_isLengthExpensive(const UText *ut);
* @return the code point at the specified index.
* @stable ICU 3.4
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utext_char32At(UText *ut, int64_t nativeIndex);
@@ -443,7 +443,7 @@ utext_char32At(UText *ut, int64_t nativeIndex);
* @return the Unicode code point at the current iterator position.
* @stable ICU 3.4
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utext_current32(UText *ut);
@@ -465,7 +465,7 @@ utext_current32(UText *ut);
* @see UTEXT_NEXT32
* @stable ICU 3.4
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utext_next32(UText *ut);
@@ -486,7 +486,7 @@ utext_next32(UText *ut);
* @see UTEXT_PREVIOUS32
* @stable ICU 3.4
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utext_previous32(UText *ut);
@@ -508,7 +508,7 @@ utext_previous32(UText *ut);
* or U_SENTINEL (-1) if it is out of bounds.
* @stable ICU 3.4
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utext_next32From(UText *ut, int64_t nativeIndex);
@@ -528,7 +528,7 @@ utext_next32From(UText *ut, int64_t nativeIndex);
*
* @stable ICU 3.4
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utext_previous32From(UText *ut, int64_t nativeIndex);
/**
@@ -543,7 +543,7 @@ utext_previous32From(UText *ut, int64_t nativeIndex);
* @return the current index position, in the native units of the text provider.
* @stable ICU 3.4
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
utext_getNativeIndex(const UText *ut);
/**
@@ -569,7 +569,7 @@ utext_getNativeIndex(const UText *ut);
* @param nativeIndex the native unit index of the new iteration position.
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utext_setNativeIndex(UText *ut, int64_t nativeIndex);
/**
@@ -584,11 +584,11 @@ utext_setNativeIndex(UText *ut, int64_t nativeIndex);
*
* @param ut the text to be accessed.
* @param delta the signed number of code points to move the iteration position.
- * @return TRUE if the position could be moved the requested number of positions while
+ * @return true if the position could be moved the requested number of positions while
* staying within the range [0 - text length].
* @stable ICU 3.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
utext_moveIndex32(UText *ut, int32_t delta);
/**
@@ -613,7 +613,7 @@ utext_moveIndex32(UText *ut, int32_t delta);
* or zero if the current position is at the start of the text.
* @stable ICU 3.6
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
utext_getPreviousNativeIndex(UText *ut);
@@ -651,7 +651,7 @@ utext_getPreviousNativeIndex(UText *ut);
*
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utext_extract(UText *ut,
int64_t nativeStart, int64_t nativeLimit,
UChar *dest, int32_t destCapacity,
@@ -768,16 +768,16 @@ utext_extract(UText *ut,
/**
- * Return TRUE if the text can be written (modified) with utext_replace() or
+ * Return true if the text can be written (modified) with utext_replace() or
* utext_copy(). For the text to be writable, the text provider must
* be of a type that supports writing and the UText must not be frozen.
*
- * Attempting to modify text when utext_isWriteable() is FALSE will fail -
+ * Attempting to modify text when utext_isWriteable() is false will fail -
* the text will not be modified, and an error will be returned from the function
* that attempted the modification.
*
* @param ut the UText to be tested.
- * @return TRUE if the text is modifiable.
+ * @return true if the text is modifiable.
*
* @see utext_freeze()
* @see utext_replace()
@@ -785,7 +785,7 @@ utext_extract(UText *ut,
* @stable ICU 3.4
*
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
utext_isWritable(const UText *ut);
@@ -794,10 +794,10 @@ utext_isWritable(const UText *ut);
* @see Replaceable::hasMetaData()
*
* @param ut The UText to be tested
- * @return TRUE if the underlying text includes meta data.
+ * @return true if the underlying text includes meta data.
* @stable ICU 3.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
utext_hasMetaData(const UText *ut);
@@ -808,7 +808,7 @@ utext_hasMetaData(const UText *ut);
* newly inserted replacement text.
*
* This function is only available on UText types that support writing,
- * that is, ones where utext_isWritable() returns TRUE.
+ * that is, ones where utext_isWritable() returns true.
*
* When using this function, there should be only a single UText opened onto the
* underlying native text string. Behavior after a replace operation
@@ -828,7 +828,7 @@ utext_hasMetaData(const UText *ut);
*
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utext_replace(UText *ut,
int64_t nativeStart, int64_t nativeLimit,
const UChar *replacementText, int32_t replacementLength,
@@ -850,7 +850,7 @@ utext_replace(UText *ut,
* at the destination position.
*
* This function is only available on UText types that support writing,
- * that is, ones where utext_isWritable() returns TRUE.
+ * that is, ones where utext_isWritable() returns true.
*
* When using this function, there should be only a single UText opened onto the
* underlying native text string. Behavior after a copy operation
@@ -863,12 +863,12 @@ utext_replace(UText *ut,
* to be copied.
* @param destIndex The native destination index to which the source substring is
* copied or moved.
- * @param move If TRUE, then the substring is moved, not copied/duplicated.
+ * @param move If true, then the substring is moved, not copied/duplicated.
* @param status receives any error status. Possible errors include U_NO_WRITE_PERMISSION
*
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utext_copy(UText *ut,
int64_t nativeStart, int64_t nativeLimit,
int64_t destIndex,
@@ -897,7 +897,7 @@ utext_copy(UText *ut,
* @see utext_isWritable()
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utext_freeze(UText *ut);
@@ -972,7 +972,7 @@ enum {
* @param dest A UText struct to be filled in with the result of the clone operation,
* or NULL if the clone function should heap-allocate a new UText struct.
* @param src The UText to be cloned.
- * @param deep TRUE to request a deep clone, FALSE for a shallow clone.
+ * @param deep true to request a deep clone, false for a shallow clone.
* @param status Errors are returned here. For deep clones, U_UNSUPPORTED_ERROR
* should be returned if the text provider is unable to clone the
* original text.
@@ -1008,9 +1008,9 @@ UTextNativeLength(UText *ut);
*
* @param ut the UText being accessed.
* @param nativeIndex Requested index of the text to be accessed.
- * @param forward If TRUE, then the returned chunk must contain text
+ * @param forward If true, then the returned chunk must contain text
* starting from the index, so that start<=index<limit.
- * If FALSE, then the returned chunk must contain text
+ * If false, then the returned chunk must contain text
* before the index, so that start<index<=limit.
* @return True if the requested index could be accessed. The chunk
* will contain the requested text.
@@ -1114,7 +1114,7 @@ UTextReplace(UText *ut,
* @param nativeStart The index of the start of the region to be copied or moved
* @param nativeLimit The index of the character following the region to be replaced.
* @param nativeDest The destination index to which the source substring is copied or moved.
- * @param move If TRUE, then the substring is moved, not copied/duplicated.
+ * @param move If true, then the substring is moved, not copied/duplicated.
* @param status receives any error status. Possible errors include U_NO_WRITE_PERMISSION
*
* @stable ICU 3.4
@@ -1535,7 +1535,7 @@ struct UText {
* @return pointer to the UText, allocated if necessary, with extra space set up if requested.
* @stable ICU 3.4
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
utext_setup(UText *ut, int32_t extraSpace, UErrorCode *status);
// do not use #ifndef U_HIDE_INTERNAL_API around the following!
diff --git a/deps/icu-small/source/common/unicode/utf.h b/deps/icu-small/source/common/unicode/utf.h
index aa56980691..d23345ed0b 100644
--- a/deps/icu-small/source/common/unicode/utf.h
+++ b/deps/icu-small/source/common/unicode/utf.h
@@ -103,7 +103,7 @@
* code point values (0..U+10ffff). They are indicated with negative values instead.
*
* For more information see the ICU User Guide Strings chapter
- * (http://userguide.icu-project.org/strings).
+ * (https://unicode-org.github.io/icu/userguide/strings).
*
* <em>Usage:</em>
* ICU coding guidelines for if() statements should be followed when using these macros.
@@ -124,7 +124,7 @@
/**
* Is this code point a Unicode noncharacter?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U_IS_UNICODE_NONCHAR(c) \
@@ -145,7 +145,7 @@
* and that boundary is tested first for performance.
*
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U_IS_UNICODE_CHAR(c) \
@@ -155,7 +155,7 @@
/**
* Is this code point a BMP code point (U+0000..U+ffff)?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.8
*/
#define U_IS_BMP(c) ((uint32_t)(c)<=0xffff)
@@ -163,7 +163,7 @@
/**
* Is this code point a supplementary code point (U+10000..U+10ffff)?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.8
*/
#define U_IS_SUPPLEMENTARY(c) ((uint32_t)((c)-0x10000)<=0xfffff)
@@ -171,7 +171,7 @@
/**
* Is this code point a lead surrogate (U+d800..U+dbff)?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U_IS_LEAD(c) (((c)&0xfffffc00)==0xd800)
@@ -179,7 +179,7 @@
/**
* Is this code point a trail surrogate (U+dc00..U+dfff)?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00)
@@ -187,7 +187,7 @@
/**
* Is this code point a surrogate (U+d800..U+dfff)?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U_IS_SURROGATE(c) (((c)&0xfffff800)==0xd800)
@@ -196,7 +196,7 @@
* Assuming c is a surrogate code point (U_IS_SURROGATE(c)),
* is it a lead surrogate?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U_IS_SURROGATE_LEAD(c) (((c)&0x400)==0)
@@ -205,7 +205,7 @@
* Assuming c is a surrogate code point (U_IS_SURROGATE(c)),
* is it a trail surrogate?
* @param c 32-bit code point
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 4.2
*/
#define U_IS_SURROGATE_TRAIL(c) (((c)&0x400)!=0)
diff --git a/deps/icu-small/source/common/unicode/utf16.h b/deps/icu-small/source/common/unicode/utf16.h
index 3315214ae6..9d68902d2d 100644
--- a/deps/icu-small/source/common/unicode/utf16.h
+++ b/deps/icu-small/source/common/unicode/utf16.h
@@ -23,7 +23,7 @@
* This file defines macros to deal with 16-bit Unicode (UTF-16) code units and strings.
*
* For more information see utf.h and the ICU User Guide Strings chapter
- * (http://userguide.icu-project.org/strings).
+ * (https://unicode-org.github.io/icu/userguide/strings).
*
* <em>Usage:</em>
* ICU coding guidelines for if() statements should be followed when using these macros.
@@ -34,6 +34,7 @@
#ifndef __UTF16_H__
#define __UTF16_H__
+#include <stdbool.h>
#include "unicode/umachine.h"
#ifndef __UTF_H__
# include "unicode/utf.h"
@@ -44,7 +45,7 @@
/**
* Does this code unit alone encode a code point (BMP, not a surrogate)?
* @param c 16-bit code unit
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U16_IS_SINGLE(c) !U_IS_SURROGATE(c)
@@ -52,7 +53,7 @@
/**
* Is this code unit a lead surrogate (U+d800..U+dbff)?
* @param c 16-bit code unit
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U16_IS_LEAD(c) (((c)&0xfffffc00)==0xd800)
@@ -60,7 +61,7 @@
/**
* Is this code unit a trail surrogate (U+dc00..U+dfff)?
* @param c 16-bit code unit
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U16_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00)
@@ -68,7 +69,7 @@
/**
* Is this code unit a surrogate (U+d800..U+dfff)?
* @param c 16-bit code unit
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U16_IS_SURROGATE(c) U_IS_SURROGATE(c)
@@ -77,7 +78,7 @@
* Assuming c is a surrogate code point (U16_IS_SURROGATE(c)),
* is it a lead surrogate?
* @param c 16-bit code unit
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U16_IS_SURROGATE_LEAD(c) (((c)&0x400)==0)
@@ -86,7 +87,7 @@
* Assuming c is a surrogate code point (U16_IS_SURROGATE(c)),
* is it a trail surrogate?
* @param c 16-bit code unit
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 4.2
*/
#define U16_IS_SURROGATE_TRAIL(c) (((c)&0x400)!=0)
@@ -379,13 +380,13 @@
* "Safe" macro, checks for a valid code point.
* If a surrogate pair is written, checks for sufficient space in the string.
* If the code point is not valid or a trail surrogate does not fit,
- * then isError is set to TRUE.
+ * then isError is set to true.
*
* @param s const UChar * string buffer
* @param i string offset, must be i<capacity
* @param capacity size of the string buffer
* @param c code point to append
- * @param isError output UBool set to TRUE if an error occurs, otherwise not modified
+ * @param isError output UBool set to true if an error occurs, otherwise not modified
* @see U16_APPEND_UNSAFE
* @stable ICU 2.4
*/
@@ -396,7 +397,7 @@
(s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \
(s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
} else /* c>0x10ffff or not enough space */ { \
- (isError)=TRUE; \
+ (isError)=true; \
} \
} UPRV_BLOCK_MACRO_END
diff --git a/deps/icu-small/source/common/unicode/utf8.h b/deps/icu-small/source/common/unicode/utf8.h
index bb00130374..58bda2cbe5 100644
--- a/deps/icu-small/source/common/unicode/utf8.h
+++ b/deps/icu-small/source/common/unicode/utf8.h
@@ -23,7 +23,7 @@
* This file defines macros to deal with 8-bit Unicode (UTF-8) code units (bytes) and strings.
*
* For more information see utf.h and the ICU User Guide Strings chapter
- * (http://userguide.icu-project.org/strings).
+ * (https://unicode-org.github.io/icu/userguide/strings).
*
* <em>Usage:</em>
* ICU coding guidelines for if() statements should be followed when using these macros.
@@ -34,6 +34,7 @@
#ifndef __UTF8_H__
#define __UTF8_H__
+#include <stdbool.h>
#include "unicode/umachine.h"
#ifndef __UTF_H__
# include "unicode/utf.h"
@@ -117,48 +118,48 @@
* Function for handling "next code point" with error-checking.
*
* This is internal since it is not meant to be called directly by external clients;
- * however it is U_STABLE (not U_INTERNAL) since it is called by public macros in this
+ * however it is called by public macros in this
* file and thus must remain stable, and should not be hidden when other internal
* functions are hidden (otherwise public macros would fail to compile).
* @internal
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utf8_nextCharSafeBody(const uint8_t *s, int32_t *pi, int32_t length, UChar32 c, UBool strict);
/**
* Function for handling "append code point" with error-checking.
*
* This is internal since it is not meant to be called directly by external clients;
- * however it is U_STABLE (not U_INTERNAL) since it is called by public macros in this
+ * however it is called by public macros in this
* file and thus must remain stable, and should not be hidden when other internal
* functions are hidden (otherwise public macros would fail to compile).
* @internal
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utf8_appendCharSafeBody(uint8_t *s, int32_t i, int32_t length, UChar32 c, UBool *pIsError);
/**
* Function for handling "previous code point" with error-checking.
*
* This is internal since it is not meant to be called directly by external clients;
- * however it is U_STABLE (not U_INTERNAL) since it is called by public macros in this
+ * however it is called by public macros in this
* file and thus must remain stable, and should not be hidden when other internal
* functions are hidden (otherwise public macros would fail to compile).
* @internal
*/
-U_STABLE UChar32 U_EXPORT2
+U_CAPI UChar32 U_EXPORT2
utf8_prevCharSafeBody(const uint8_t *s, int32_t start, int32_t *pi, UChar32 c, UBool strict);
/**
* Function for handling "skip backward one code point" with error-checking.
*
* This is internal since it is not meant to be called directly by external clients;
- * however it is U_STABLE (not U_INTERNAL) since it is called by public macros in this
+ * however it is called by public macros in this
* file and thus must remain stable, and should not be hidden when other internal
* functions are hidden (otherwise public macros would fail to compile).
* @internal
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i);
/* single-code point definitions -------------------------------------------- */
@@ -166,7 +167,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i);
/**
* Does this code unit (byte) encode a code point by itself (US-ASCII 0..0x7f)?
* @param c 8-bit code unit (byte)
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U8_IS_SINGLE(c) (((c)&0x80)==0)
@@ -174,7 +175,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i);
/**
* Is this code unit (byte) a UTF-8 lead byte? (0xC2..0xF4)
* @param c 8-bit code unit (byte)
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U8_IS_LEAD(c) ((uint8_t)((c)-0xc2)<=0x32)
@@ -183,7 +184,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i);
/**
* Is this code unit (byte) a UTF-8 trail byte? (0x80..0xBF)
* @param c 8-bit code unit (byte)
- * @return TRUE or FALSE
+ * @return true or false
* @stable ICU 2.4
*/
#define U8_IS_TRAIL(c) ((int8_t)(c)<-0x40)
@@ -445,13 +446,13 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i);
* "Safe" macro, checks for a valid code point.
* If a non-ASCII code point is written, checks for sufficient space in the string.
* If the code point is not valid or trail bytes do not fit,
- * then isError is set to TRUE.
+ * then isError is set to true.
*
* @param s const uint8_t * string buffer
* @param i int32_t string offset, must be i<capacity
* @param capacity int32_t size of the string buffer
* @param c UChar32 code point to append
- * @param isError output UBool set to TRUE if an error occurs, otherwise not modified
+ * @param isError output UBool set to true if an error occurs, otherwise not modified
* @see U8_APPEND_UNSAFE
* @stable ICU 2.4
*/
@@ -472,7 +473,7 @@ utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i);
(s)[(i)++]=(uint8_t)(((__uc>>6)&0x3f)|0x80); \
(s)[(i)++]=(uint8_t)((__uc&0x3f)|0x80); \
} else { \
- (isError)=TRUE; \
+ (isError)=true; \
} \
} UPRV_BLOCK_MACRO_END
diff --git a/deps/icu-small/source/common/unicode/utf_old.h b/deps/icu-small/source/common/unicode/utf_old.h
index b2428e6b31..160f5ad0a9 100644
--- a/deps/icu-small/source/common/unicode/utf_old.h
+++ b/deps/icu-small/source/common/unicode/utf_old.h
@@ -109,7 +109,7 @@
* Where such a distinction is useful, there are two versions of the macros, "unsafe" and "safe"
* ones with ..._UNSAFE and ..._SAFE suffixes. The unsafe macros are fast but may cause
* program failures if the strings are not well-formed. The safe macros have an additional, boolean
- * parameter "strict". If strict is FALSE, then only illegal sequences are detected.
+ * parameter "strict". If strict is false, then only illegal sequences are detected.
* Otherwise, irregular sequences and non-characters are detected as well (like single surrogates).
* Safe macros return special error code points for illegal/irregular sequences:
* Typically, U+ffff, or values that would result in a code unit sequence of the same length
@@ -181,7 +181,7 @@ typedef int32_t UTextOffset;
/**
* The default choice for general Unicode string macros is to use the ..._SAFE macro implementations
- * with strict=FALSE.
+ * with strict=false.
*
* @deprecated ICU 2.4. Obsolete, see utf_old.h.
*/
diff --git a/deps/icu-small/source/common/unicode/utrace.h b/deps/icu-small/source/common/unicode/utrace.h
index c7d51ff44f..bb8e3e8109 100644
--- a/deps/icu-small/source/common/unicode/utrace.h
+++ b/deps/icu-small/source/common/unicode/utrace.h
@@ -112,11 +112,9 @@ typedef enum UTraceFunctionNumber {
UTRACE_COLLATION_LIMIT,
#endif // U_HIDE_DEPRECATED_API
-#ifndef U_HIDE_DRAFT_API
-
/**
* The lowest resource/data location.
- * @draft ICU 65
+ * @stable ICU 65
*/
UTRACE_UDATA_START=0x3000,
@@ -133,7 +131,7 @@ typedef enum UTraceFunctionNumber {
* - "get" (a path was loaded, but the value was not accessed)
* - "getalias" (a path was loaded, and an alias was resolved)
*
- * @draft ICU 65
+ * @stable ICU 65
*/
UTRACE_UDATA_RESOURCE=UTRACE_UDATA_START,
@@ -141,7 +139,7 @@ typedef enum UTraceFunctionNumber {
* Indicates that a resource bundle was opened.
*
* Provides one C-style string to UTraceData: file name.
- * @draft ICU 65
+ * @stable ICU 65
*/
UTRACE_UDATA_BUNDLE,
@@ -150,7 +148,7 @@ typedef enum UTraceFunctionNumber {
*
* Provides one C-style string to UTraceData: file name.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
UTRACE_UDATA_DATA_FILE,
@@ -163,12 +161,10 @@ typedef enum UTraceFunctionNumber {
*
* Provides one C-style string to UTraceData: file name.
*
- * @draft ICU 65
+ * @stable ICU 65
*/
UTRACE_UDATA_RES_FILE,
-#endif // U_HIDE_DRAFT_API
-
#ifndef U_HIDE_INTERNAL_API
/**
* One more than the highest normal resource/data trace location.
@@ -249,7 +245,7 @@ typedef enum UTraceFunctionNumber {
* @param traceLevel A UTraceLevel value.
* @stable ICU 2.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utrace_setLevel(int32_t traceLevel);
/**
@@ -257,7 +253,7 @@ utrace_setLevel(int32_t traceLevel);
* @return The UTraceLevel value being used by ICU.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utrace_getLevel(void);
/* Trace function pointers types ----------------------------- */
@@ -331,7 +327,7 @@ UTraceData(const void *context, int32_t fnNumber, int32_t level,
*
* @stable ICU 2.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utrace_setFunctions(const void *context,
UTraceEntry *e, UTraceExit *x, UTraceData *d);
@@ -345,7 +341,7 @@ utrace_setFunctions(const void *context,
* @param d The currently installed UTraceData function.
* @stable ICU 2.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utrace_getFunctions(const void **context,
UTraceEntry **e, UTraceExit **x, UTraceData **d);
@@ -467,7 +463,7 @@ utrace_getFunctions(const void **context,
* If buffer capacity is insufficient, the required capacity is returned.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utrace_vformat(char *outBuf, int32_t capacity,
int32_t indent, const char *fmt, va_list args);
@@ -488,7 +484,7 @@ utrace_vformat(char *outBuf, int32_t capacity,
* If buffer capacity is insufficient, the required capacity is returned.
* @stable ICU 2.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utrace_format(char *outBuf, int32_t capacity,
int32_t indent, const char *fmt, ...);
@@ -505,7 +501,7 @@ utrace_format(char *outBuf, int32_t capacity,
* @see UTraceFunctionNumber
* @stable ICU 2.8
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
utrace_functionName(int32_t fnNumber);
U_CDECL_END
diff --git a/deps/icu-small/source/common/unicode/utypes.h b/deps/icu-small/source/common/unicode/utypes.h
index c98de9e6fc..6c57218db8 100644
--- a/deps/icu-small/source/common/unicode/utypes.h
+++ b/deps/icu-small/source/common/unicode/utypes.h
@@ -479,13 +479,23 @@ typedef enum UErrorCode {
U_COLLATOR_VERSION_MISMATCH = 28, /**< Collator version is not compatible with the base version */
U_USELESS_COLLATOR_ERROR = 29, /**< Collator is options only and no base is specified */
U_NO_WRITE_PERMISSION = 30, /**< Attempt to modify read-only or constant data. */
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * The input is impractically long for an operation.
+ * It is rejected because it may lead to problems such as excessive
+ * processing time, stack depth, or heap memory requirements.
+ *
+ * @draft ICU 68
+ */
+ U_INPUT_TOO_LONG_ERROR = 31,
+#endif // U_HIDE_DRAFT_API
#ifndef U_HIDE_DEPRECATED_API
/**
* One more than the highest standard error code.
* @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
*/
- U_STANDARD_ERROR_LIMIT,
+ U_STANDARD_ERROR_LIMIT = 32,
#endif // U_HIDE_DEPRECATED_API
/*
@@ -715,7 +725,7 @@ typedef enum UErrorCode {
* in the UErrorCode enum above.
* @stable ICU 2.0
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
u_errorName(UErrorCode code);
diff --git a/deps/icu-small/source/common/unicode/uvernum.h b/deps/icu-small/source/common/unicode/uvernum.h
index c66776d10b..a4cbb9e0fe 100644
--- a/deps/icu-small/source/common/unicode/uvernum.h
+++ b/deps/icu-small/source/common/unicode/uvernum.h
@@ -60,7 +60,7 @@
* This value will change in the subsequent releases of ICU
* @stable ICU 2.4
*/
-#define U_ICU_VERSION_MAJOR_NUM 67
+#define U_ICU_VERSION_MAJOR_NUM 68
/** The current ICU minor version as an integer.
* This value will change in the subsequent releases of ICU
@@ -86,7 +86,7 @@
* This value will change in the subsequent releases of ICU
* @stable ICU 2.6
*/
-#define U_ICU_VERSION_SUFFIX _67
+#define U_ICU_VERSION_SUFFIX _68
/**
* \def U_DEF2_ICU_ENTRY_POINT_RENAME
@@ -139,7 +139,7 @@
* This value will change in the subsequent releases of ICU
* @stable ICU 2.4
*/
-#define U_ICU_VERSION "67.1"
+#define U_ICU_VERSION "68.1"
/**
* The current ICU library major version number as a string, for library name suffixes.
@@ -148,17 +148,17 @@
* Until ICU 4.8, this was the combination of the single-digit major and minor ICU version numbers
* into one string without dots ("48").
* Since ICU 49, it is the double-digit major ICU version number.
- * See http://userguide.icu-project.org/design#TOC-Version-Numbers-in-ICU
+ * See https://unicode-org.github.io/icu/userguide/design#version-numbers-in-icu
*
* @stable ICU 2.6
*/
-#define U_ICU_VERSION_SHORT "67"
+#define U_ICU_VERSION_SHORT "68"
#ifndef U_HIDE_INTERNAL_API
/** Data version in ICU4C.
* @internal ICU 4.4 Internal Use Only
**/
-#define U_ICU_DATA_VERSION "67.1"
+#define U_ICU_DATA_VERSION "68.1"
#endif /* U_HIDE_INTERNAL_API */
/*===========================================================================
diff --git a/deps/icu-small/source/common/unicode/uversion.h b/deps/icu-small/source/common/unicode/uversion.h
index c8c7a374c8..dde3059261 100644
--- a/deps/icu-small/source/common/unicode/uversion.h
+++ b/deps/icu-small/source/common/unicode/uversion.h
@@ -141,7 +141,7 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH];
* values of up to 255 each.
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_versionFromString(UVersionInfo versionArray, const char *versionString);
/**
@@ -155,7 +155,7 @@ u_versionFromString(UVersionInfo versionArray, const char *versionString);
* fields with values of up to 255 each.
* @stable ICU 4.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_versionFromUString(UVersionInfo versionArray, const UChar *versionString);
@@ -171,7 +171,7 @@ u_versionFromUString(UVersionInfo versionArray, const UChar *versionString);
* The buffer size must be at least U_MAX_VERSION_STRING_LENGTH.
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_versionToString(const UVersionInfo versionArray, char *versionString);
/**
@@ -182,6 +182,6 @@ u_versionToString(const UVersionInfo versionArray, char *versionString);
* @param versionArray the version # information, the result will be filled in
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_getVersion(UVersionInfo versionArray);
#endif
diff --git a/deps/icu-small/source/common/unifiedcache.cpp b/deps/icu-small/source/common/unifiedcache.cpp
index f2dd916559..493ab79f6d 100644
--- a/deps/icu-small/source/common/unifiedcache.cpp
+++ b/deps/icu-small/source/common/unifiedcache.cpp
@@ -311,7 +311,7 @@ void UnifiedCache::_putNew(
}
keyToAdopt->fCreationStatus = creationStatus;
if (value->softRefCount == 0) {
- _registerMaster(keyToAdopt, value);
+ _registerPrimary(keyToAdopt, value);
}
void *oldValue = uhash_put(fHashtable, keyToAdopt, (void *) value, &status);
U_ASSERT(oldValue == nullptr);
@@ -338,7 +338,7 @@ void UnifiedCache::_putIfAbsentAndGet(
} else {
_put(element, value, status);
}
- // Run an eviction slice. This will run even if we added a master entry
+ // Run an eviction slice. This will run even if we added a primary entry
// which doesn't increase the unused count, but that is still o.k
_runEvictionSlice();
}
@@ -403,9 +403,9 @@ void UnifiedCache::_get(
}
}
-void UnifiedCache::_registerMaster(
+void UnifiedCache::_registerPrimary(
const CacheKeyBase *theKey, const SharedObject *value) const {
- theKey->fIsMaster = true;
+ theKey->fIsPrimary = true;
value->cachePtr = this;
++fNumValuesTotal;
++fNumValuesInUse;
@@ -420,7 +420,7 @@ void UnifiedCache::_put(
const SharedObject *oldValue = (const SharedObject *) element->value.pointer;
theKey->fCreationStatus = status;
if (value->softRefCount == 0) {
- _registerMaster(theKey, value);
+ _registerPrimary(theKey, value);
}
value->softRefCount++;
UHashElement *ptr = const_cast<UHashElement *>(element);
@@ -474,9 +474,9 @@ UBool UnifiedCache::_isEvictable(const UHashElement *element) const
return FALSE;
}
- // We can evict entries that are either not a master or have just
+ // We can evict entries that are either not a primary or have just
// one reference (The one reference being from the cache itself).
- return (!theKey->fIsMaster || (theValue->softRefCount == 1 && theValue->noHardReferences()));
+ return (!theKey->fIsPrimary || (theValue->softRefCount == 1 && theValue->noHardReferences()));
}
void UnifiedCache::removeSoftRef(const SharedObject *value) const {
diff --git a/deps/icu-small/source/common/unifiedcache.h b/deps/icu-small/source/common/unifiedcache.h
index 5c0bd76f4a..865f454510 100644
--- a/deps/icu-small/source/common/unifiedcache.h
+++ b/deps/icu-small/source/common/unifiedcache.h
@@ -34,13 +34,13 @@ class UnifiedCache;
*/
class U_COMMON_API CacheKeyBase : public UObject {
public:
- CacheKeyBase() : fCreationStatus(U_ZERO_ERROR), fIsMaster(FALSE) {}
+ CacheKeyBase() : fCreationStatus(U_ZERO_ERROR), fIsPrimary(false) {}
/**
* Copy constructor. Needed to support cloning.
*/
CacheKeyBase(const CacheKeyBase &other)
- : UObject(other), fCreationStatus(other.fCreationStatus), fIsMaster(FALSE) { }
+ : UObject(other), fCreationStatus(other.fCreationStatus), fIsPrimary(false) { }
virtual ~CacheKeyBase();
/**
@@ -88,7 +88,7 @@ class U_COMMON_API CacheKeyBase : public UObject {
}
private:
mutable UErrorCode fCreationStatus;
- mutable UBool fIsMaster;
+ mutable UBool fIsPrimary;
friend class UnifiedCache;
};
@@ -147,10 +147,10 @@ class LocaleCacheKey : public CacheKey<T> {
virtual UBool operator == (const CacheKeyBase &other) const {
// reflexive
if (this == &other) {
- return TRUE;
+ return true;
}
if (!CacheKey<T>::operator == (other)) {
- return FALSE;
+ return false;
}
// We know this and other are of same class because operator== on
// CacheKey returned true.
@@ -359,7 +359,7 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase {
/**
* Flushes the contents of the cache. If cache values hold references to other
- * cache values then _flush should be called in a loop until it returns FALSE.
+ * cache values then _flush should be called in a loop until it returns false.
*
* On entry, gCacheMutex must be held.
* On exit, those values with are evictable are flushed.
@@ -370,7 +370,7 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase {
* hard (external) references are not deleted, but are detached from
* the cache, so that a subsequent removeRefs can delete them.
* _flush is not thread safe when all is true.
- * @return TRUE if any value in cache was flushed or FALSE otherwise.
+ * @return true if any value in cache was flushed or false otherwise.
*/
UBool _flush(UBool all) const;
@@ -395,11 +395,11 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase {
* Attempts to fetch value and status for key from cache.
* On entry, gCacheMutex must not be held value must be NULL and status must
* be U_ZERO_ERROR.
- * On exit, either returns FALSE (In this
- * case caller should try to create the object) or returns TRUE with value
+ * On exit, either returns false (In this
+ * case caller should try to create the object) or returns true with value
* pointing to the fetched value and status set to fetched status. When
- * FALSE is returned status may be set to failure if an in progress hash
- * entry could not be made but value will remain unchanged. When TRUE is
+ * false is returned status may be set to failure if an in progress hash
+ * entry could not be made but value will remain unchanged. When true is
* returned, caller must call removeRef() on value.
*/
UBool _poll(
@@ -463,17 +463,17 @@ class U_COMMON_API UnifiedCache : public UnifiedCacheBase {
void _runEvictionSlice() const;
/**
- * Register a master cache entry. A master key is the first key to create
+ * Register a primary cache entry. A primary key is the first key to create
* a given SharedObject value. Subsequent keys whose create function
- * produce referneces to an already existing SharedObject are not masters -
+ * produce referneces to an already existing SharedObject are not primary -
* they can be evicted and subsequently recreated.
*
* On entry, gCacheMutex must be held.
- * On exit, items in use count incremented, entry is marked as a master
+ * On exit, items in use count incremented, entry is marked as a primary
* entry, and value registered with cache so that subsequent calls to
* addRef() and removeRef() on it correctly interact with the cache.
*/
- void _registerMaster(const CacheKeyBase *theKey, const SharedObject *value) const;
+ void _registerPrimary(const CacheKeyBase *theKey, const SharedObject *value) const;
/**
* Store a value and creation error status in given hash entry.
diff --git a/deps/icu-small/source/common/uniquecharstr.h b/deps/icu-small/source/common/uniquecharstr.h
new file mode 100644
index 0000000000..10cc924f7f
--- /dev/null
+++ b/deps/icu-small/source/common/uniquecharstr.h
@@ -0,0 +1,98 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+// uniquecharstr.h
+// created: 2020sep01 Frank Yung-Fong Tang
+
+#ifndef __UNIQUECHARSTR_H__
+#define __UNIQUECHARSTR_H__
+
+#include "charstr.h"
+#include "uassert.h"
+#include "uhash.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * Stores NUL-terminated strings with duplicate elimination.
+ * Checks for unique UTF-16 string pointers and converts to invariant characters.
+ *
+ * Intended to be stack-allocated. Add strings, get a unique number for each,
+ * freeze the object, get a char * pointer for each string,
+ * call orphanCharStrings() to capture the string storage, and let this object go out of scope.
+ */
+class UniqueCharStrings {
+public:
+ UniqueCharStrings(UErrorCode &errorCode) : strings(nullptr) {
+ // Note: We hash on string contents but store stable char16_t * pointers.
+ // If the strings are stored in resource bundles which should be built with
+ // duplicate elimination, then we should be able to hash on just the pointer values.
+ uhash_init(&map, uhash_hashUChars, uhash_compareUChars, uhash_compareLong, &errorCode);
+ if (U_FAILURE(errorCode)) { return; }
+ strings = new CharString();
+ if (strings == nullptr) {
+ errorCode = U_MEMORY_ALLOCATION_ERROR;
+ }
+ }
+ ~UniqueCharStrings() {
+ uhash_close(&map);
+ delete strings;
+ }
+
+ /** Returns/orphans the CharString that contains all strings. */
+ CharString *orphanCharStrings() {
+ CharString *result = strings;
+ strings = nullptr;
+ return result;
+ }
+
+ /**
+ * Adds a string and returns a unique number for it.
+ * The string's buffer contents must not change, nor move around in memory,
+ * while this UniqueCharStrings is in use.
+ * The string contents must be NUL-terminated exactly at s.length().
+ *
+ * Best used with read-only-alias UnicodeString objects that point to
+ * stable storage, such as strings returned by resource bundle functions.
+ */
+ int32_t add(const UnicodeString &s, UErrorCode &errorCode) {
+ if (U_FAILURE(errorCode)) { return 0; }
+ if (isFrozen) {
+ errorCode = U_NO_WRITE_PERMISSION;
+ return 0;
+ }
+ // The string points into the resource bundle.
+ const char16_t *p = s.getBuffer();
+ int32_t oldIndex = uhash_geti(&map, p);
+ if (oldIndex != 0) { // found duplicate
+ return oldIndex;
+ }
+ // Explicit NUL terminator for the previous string.
+ // The strings object is also terminated with one implicit NUL.
+ strings->append(0, errorCode);
+ int32_t newIndex = strings->length();
+ strings->appendInvariantChars(s, errorCode);
+ uhash_puti(&map, const_cast<char16_t *>(p), newIndex, &errorCode);
+ return newIndex;
+ }
+
+ void freeze() { isFrozen = true; }
+
+ /**
+ * Returns a string pointer for its unique number, if this object is frozen.
+ * Otherwise nullptr.
+ */
+ const char *get(int32_t i) const {
+ U_ASSERT(isFrozen);
+ return isFrozen && i > 0 ? strings->data() + i : nullptr;
+ }
+
+private:
+ UHashtable map;
+ CharString *strings;
+ bool isFrozen = false;
+};
+
+U_NAMESPACE_END
+
+#endif // __UNIQUECHARSTR_H__
diff --git a/deps/icu-small/source/common/unisetspan.h b/deps/icu-small/source/common/unisetspan.h
index f1e78ff3ee..9a1307a907 100644
--- a/deps/icu-small/source/common/unisetspan.h
+++ b/deps/icu-small/source/common/unisetspan.h
@@ -65,8 +65,8 @@ public:
/*
* Do the strings need to be checked in span() etc.?
- * @return TRUE if strings need to be checked (call span() here),
- * FALSE if not (use a BMPSet for best performance).
+ * @return true if strings need to be checked (call span() here),
+ * false if not (use a BMPSet for best performance).
*/
inline UBool needsStringSpanUTF16();
inline UBool needsStringSpanUTF8();
diff --git a/deps/icu-small/source/common/unormimp.h b/deps/icu-small/source/common/unormimp.h
index 7f280551f7..e09c5c1c91 100644
--- a/deps/icu-small/source/common/unormimp.h
+++ b/deps/icu-small/source/common/unormimp.h
@@ -418,7 +418,7 @@ enum {
* The same bit is used for NFC and NFKC; (c) differs for them.
* As usual, we build the "not skippable" flags so that unassigned
* code points get a 0 bit.
- * This bit is only valid after (a)..(e) test FALSE; test NFD_NO before (f) as well.
+ * This bit is only valid after (a)..(e) test false; test NFD_NO before (f) as well.
* Test Hangul LV syllables entirely in code.
*
*
diff --git a/deps/icu-small/source/common/uresbund.cpp b/deps/icu-small/source/common/uresbund.cpp
index f4efb8ccab..743df1f8c5 100644
--- a/deps/icu-small/source/common/uresbund.cpp
+++ b/deps/icu-small/source/common/uresbund.cpp
@@ -1792,7 +1792,7 @@ ures_findSubResource(const UResourceBundle *resB, char* path, UResourceBundle *f
return result;
}
-U_INTERNAL const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ures_getStringByKeyWithFallback(const UResourceBundle *resB,
const char* inKey,
int32_t* len,
@@ -2210,7 +2210,7 @@ ures_getUTF8StringByKey(const UResourceBundle *resB,
* INTERNAL: Get the name of the first real locale (not placeholder)
* that has resource bundle data.
*/
-U_INTERNAL const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ures_getLocaleInternal(const UResourceBundle* resourceBundle, UErrorCode* status)
{
if (status==NULL || U_FAILURE(*status)) {
@@ -2357,7 +2357,7 @@ ures_openDirect(const char* path, const char* localeID, UErrorCode* status) {
*
* Same as ures_open(), but uses the fill-in parameter and does not allocate a new bundle.
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
ures_openFillIn(UResourceBundle *r, const char* path,
const char* localeID, UErrorCode* status) {
if(U_SUCCESS(*status) && r == NULL) {
@@ -2370,7 +2370,7 @@ ures_openFillIn(UResourceBundle *r, const char* path,
/**
* Same as ures_openDirect(), but uses the fill-in parameter and does not allocate a new bundle.
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
ures_openDirectFillIn(UResourceBundle *r, const char* path, const char* localeID, UErrorCode* status) {
if(U_SUCCESS(*status) && r == NULL) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
@@ -2420,7 +2420,7 @@ ures_countArrayItems(const UResourceBundle* resourceBundle,
* @see ures_getVersion
* @internal
*/
-U_INTERNAL const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ures_getVersionNumberInternal(const UResourceBundle *resourceBundle)
{
if (!resourceBundle) return NULL;
@@ -3016,7 +3016,7 @@ ures_getKeywordValues(const char *path, const char *keyword, UErrorCode *status)
}
#if 0
/* This code isn't needed, and given the documentation warnings the implementation is suspect */
-U_INTERNAL UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ures_equal(const UResourceBundle* res1, const UResourceBundle* res2){
if(res1==NULL || res2==NULL){
return res1==res2; /* pointer comparision */
@@ -3052,7 +3052,7 @@ ures_equal(const UResourceBundle* res1, const UResourceBundle* res2){
}
return TRUE;
}
-U_INTERNAL UResourceBundle* U_EXPORT2
+U_CAPI UResourceBundle* U_EXPORT2
ures_clone(const UResourceBundle* res, UErrorCode* status){
UResourceBundle* bundle = NULL;
UResourceBundle* ret = NULL;
@@ -3068,7 +3068,7 @@ ures_clone(const UResourceBundle* res, UErrorCode* status){
}
return ret;
}
-U_INTERNAL const UResourceBundle* U_EXPORT2
+U_CAPI const UResourceBundle* U_EXPORT2
ures_getParentBundle(const UResourceBundle* res){
if(res==NULL){
return NULL;
@@ -3077,7 +3077,7 @@ ures_getParentBundle(const UResourceBundle* res){
}
#endif
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
ures_getVersionByKey(const UResourceBundle* res, const char *key, UVersionInfo ver, UErrorCode *status) {
const UChar *str;
int32_t len;
diff --git a/deps/icu-small/source/common/uresdata.cpp b/deps/icu-small/source/common/uresdata.cpp
index 1bb938be62..4e3309f497 100644
--- a/deps/icu-small/source/common/uresdata.cpp
+++ b/deps/icu-small/source/common/uresdata.cpp
@@ -963,7 +963,7 @@ res_findResource(const ResourceData *pResData, Resource r, char** path, const ch
if(t2 == RES_BOGUS) {
/* if we fail to get the resource by key, maybe we got an index */
indexR = uprv_strtol(pathP, &closeIndex, 10);
- if(indexR >= 0 && *closeIndex == 0) {
+ if(indexR >= 0 && *closeIndex == 0 && (*pathP != '0' || closeIndex - pathP == 1)) {
/* if we indeed have an index, try to get the item by index */
t2 = res_getTableItemByIndex(pResData, t1, indexR, key);
} // else t2 is already RES_BOGUS
diff --git a/deps/icu-small/source/common/uresdata.h b/deps/icu-small/source/common/uresdata.h
index d1b67babf2..7c2152e57b 100644
--- a/deps/icu-small/source/common/uresdata.h
+++ b/deps/icu-small/source/common/uresdata.h
@@ -402,7 +402,7 @@ typedef struct ResourceData {
/*
* Read a resource bundle from memory.
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
res_read(ResourceData *pResData,
const UDataInfo *pInfo, const void *inBytes, int32_t length,
UErrorCode *errorCode);
@@ -422,7 +422,7 @@ res_load(ResourceData *pResData,
U_CFUNC void
res_unload(ResourceData *pResData);
-U_INTERNAL UResType U_EXPORT2
+U_CAPI UResType U_EXPORT2
res_getPublicType(Resource res);
///////////////////////////////////////////////////////////////////////////
@@ -434,31 +434,31 @@ res_getPublicType(Resource res);
* and set its length in *pLength.
* Returns NULL if not found.
*/
-U_INTERNAL const UChar * U_EXPORT2
+U_CAPI const UChar * U_EXPORT2
res_getStringNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength);
-U_INTERNAL const uint8_t * U_EXPORT2
+U_CAPI const uint8_t * U_EXPORT2
res_getBinaryNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength);
-U_INTERNAL const int32_t * U_EXPORT2
+U_CAPI const int32_t * U_EXPORT2
res_getIntVectorNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength);
-U_INTERNAL const UChar * U_EXPORT2
+U_CAPI const UChar * U_EXPORT2
res_getAlias(const ResourceData *pResData, Resource res, int32_t *pLength);
-U_INTERNAL Resource U_EXPORT2
+U_CAPI Resource U_EXPORT2
res_getResource(const ResourceData *pResData, const char *key);
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
res_countArrayItems(const ResourceData *pResData, Resource res);
-U_INTERNAL Resource U_EXPORT2
+U_CAPI Resource U_EXPORT2
res_getArrayItem(const ResourceData *pResData, Resource array, int32_t indexS);
-U_INTERNAL Resource U_EXPORT2
+U_CAPI Resource U_EXPORT2
res_getTableItemByIndex(const ResourceData *pResData, Resource table, int32_t indexS, const char ** key);
-U_INTERNAL Resource U_EXPORT2
+U_CAPI Resource U_EXPORT2
res_getTableItemByKey(const ResourceData *pResData, Resource table, int32_t *indexS, const char* * key);
/**
diff --git a/deps/icu-small/source/common/uresimp.h b/deps/icu-small/source/common/uresimp.h
index 2e477dfad3..12154dcb7c 100644
--- a/deps/icu-small/source/common/uresimp.h
+++ b/deps/icu-small/source/common/uresimp.h
@@ -157,7 +157,7 @@ U_CFUNC const char* ures_getName(const UResourceBundle* resB);
U_CFUNC const char* ures_getPath(const UResourceBundle* resB);
/**
* If anything was in the RB cache, dump it to the screen.
- * @return TRUE if there was anything into the cache
+ * @return true if there was anything into the cache
*/
U_CAPI UBool U_EXPORT2 ures_dumpCacheContents(void);
#endif
@@ -218,7 +218,7 @@ ures_findSubResource(const UResourceBundle *resB,
* @param isAvailable If non-null, pointer to fillin parameter that indicates whether the
* requested locale was available. The locale is defined as 'available' if it physically
* exists within the specified tree.
- * @param omitDefault if TRUE, omit keyword and value if default. 'de_DE\@collation=standard' -> 'de_DE'
+ * @param omitDefault if true, omit keyword and value if default. 'de_DE\@collation=standard' -> 'de_DE'
* @param status error code
* @return the actual buffer size needed for the full locale. If it's greater
* than resultCapacity, the returned full name will be truncated and an error code will be returned.
diff --git a/deps/icu-small/source/common/ustr_imp.h b/deps/icu-small/source/common/ustr_imp.h
index 85d8e6d8ee..5b249ade3d 100644
--- a/deps/icu-small/source/common/ustr_imp.h
+++ b/deps/icu-small/source/common/ustr_imp.h
@@ -29,7 +29,7 @@
/**
* Compare two strings in code point order or code unit order.
* Works in strcmp style (both lengths -1),
- * strncmp style (lengths equal and >=0, flag TRUE),
+ * strncmp style (lengths equal and >=0, flag true),
* and memcmp/UnicodeString style (at least one length >=0).
*/
U_CFUNC int32_t U_EXPORT2
@@ -37,13 +37,13 @@ uprv_strCompare(const UChar *s1, int32_t length1,
const UChar *s2, int32_t length2,
UBool strncmpStyle, UBool codePointOrder);
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ustr_hashUCharsN(const UChar *str, int32_t length);
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ustr_hashCharsN(const char *str, int32_t length);
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ustr_hashICharsN(const char *str, int32_t length);
/**
@@ -53,7 +53,7 @@ ustr_hashICharsN(const char *str, int32_t length);
* @return If UChar is a lowercase ASCII character, returns the uppercase version.
* Otherwise, returns the input character.
*/
-U_INTERNAL UChar U_EXPORT2
+U_CAPI UChar U_EXPORT2
u_asciiToUpper(UChar c);
// TODO: Add u_asciiToLower if/when there is a need for it.
@@ -70,28 +70,28 @@ u_asciiToUpper(UChar c);
* @param pErrorCode ICU error code.
* @return length
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_terminateUChars(UChar *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
/**
* NUL-terminate a char * string if possible.
* Same as u_terminateUChars() but for a different string type.
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_terminateChars(char *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
/**
* NUL-terminate a UChar32 * string if possible.
* Same as u_terminateUChars() but for a different string type.
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_terminateUChar32s(UChar32 *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
/**
* NUL-terminate a wchar_t * string if possible.
* Same as u_terminateUChars() but for a different string type.
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
/**
@@ -133,7 +133,7 @@ public:
* @param t The i-th byte following the lead byte.
* @param i The index (1..3) of byte t in the byte sequence. 0<i<length
* @param length The length (2..4) of the byte sequence according to the lead byte.
- * @return TRUE if t is a valid trail byte in this context.
+ * @return true if t is a valid trail byte in this context.
*/
static inline UBool isValidTrail(int32_t prev, uint8_t t, int32_t i, int32_t length) {
// The first trail byte after a 3- or 4-byte lead byte
diff --git a/deps/icu-small/source/common/ustring.cpp b/deps/icu-small/source/common/ustring.cpp
index 375f66add4..8a6f737dc2 100644
--- a/deps/icu-small/source/common/ustring.cpp
+++ b/deps/icu-small/source/common/ustring.cpp
@@ -45,7 +45,7 @@ isMatchAtCPBoundary(const UChar *start, const UChar *match, const UChar *matchLi
/* the leading edge of the match is in the middle of a surrogate pair */
return FALSE;
}
- if(U16_IS_LEAD(*(matchLimit-1)) && match!=limit && U16_IS_TRAIL(*matchLimit)) {
+ if(U16_IS_LEAD(*(matchLimit-1)) && matchLimit!=limit && U16_IS_TRAIL(*matchLimit)) {
/* the trailing edge of the match is in the middle of a surrogate pair */
return FALSE;
}
@@ -1294,7 +1294,15 @@ u_unescapeAt(UNESCAPE_CHAR_AT charAt,
int32_t ahead = *offset + 1;
c = charAt(*offset, context);
if (c == 0x5C /*'\\'*/ && ahead < length) {
- c = (UChar) u_unescapeAt(charAt, &ahead, length, context);
+ // Calling u_unescapeAt recursively may cause a stack overflow if
+ // we have repeated surrogate lead after that. Limit the
+ // length to 5 ('u' and 4 hex) after ahead.
+ int32_t tailLimit = ahead + 5;
+ if (tailLimit > length) {
+ tailLimit = length;
+ }
+ c = (UChar) u_unescapeAt(charAt, &ahead, tailLimit,
+ context);
}
if (U16_IS_TRAIL(c)) {
*offset = ahead;
diff --git a/deps/icu-small/source/common/util.h b/deps/icu-small/source/common/util.h
index a2be25056e..2a709e408a 100644
--- a/deps/icu-small/source/common/util.h
+++ b/deps/icu-small/source/common/util.h
@@ -64,8 +64,8 @@ class U_COMMON_API ICU_Utility /* not : public UObject because all methods are s
/**
* Escape unprintable characters using \uxxxx notation for U+0000 to
* U+FFFF and \Uxxxxxxxx for U+10000 and above. If the character is
- * printable ASCII, then do nothing and return FALSE. Otherwise,
- * append the escaped notation and return TRUE.
+ * printable ASCII, then do nothing and return false. Otherwise,
+ * append the escaped notation and return true.
*/
static UBool escapeUnprintable(UnicodeString& result, UChar32 c);
@@ -95,7 +95,7 @@ class U_COMMON_API ICU_Utility /* not : public UObject because all methods are s
* after pos, or str.length(), if there is none.
*/
static int32_t skipWhitespace(const UnicodeString& str, int32_t& pos,
- UBool advance = FALSE);
+ UBool advance = false);
/**
* Skip over Pattern_White_Space in a Replaceable.
diff --git a/deps/icu-small/source/common/utrie.h b/deps/icu-small/source/common/utrie.h
index 532ba778eb..2fd2c461ff 100644
--- a/deps/icu-small/source/common/utrie.h
+++ b/deps/icu-small/source/common/utrie.h
@@ -460,13 +460,13 @@ UTrieEnumValue(const void *context, uint32_t value);
* of code points with the same value as retrieved from the trie and
* transformed by the UTrieEnumValue function.
*
- * The callback function can stop the enumeration by returning FALSE.
+ * The callback function can stop the enumeration by returning false.
*
* @param context an opaque pointer, as passed into utrie_enum()
* @param start the first code point in a contiguous range with value
* @param limit one past the last code point in a contiguous range with value
* @param value the value that is set for all code points in [start..limit[
- * @return FALSE to stop the enumeration
+ * @return false to stop the enumeration
*/
typedef UBool U_CALLCONV
UTrieEnumRange(const void *context, UChar32 start, UChar32 limit, uint32_t value);
@@ -667,7 +667,7 @@ utrie_getData(UNewTrie *trie, int32_t *pLength);
* @param trie the build-time trie
* @param c the code point
* @param value the value
- * @return FALSE if a failure occurred (illegal argument or data array overrun)
+ * @return false if a failure occurred (illegal argument or data array overrun)
*/
U_CAPI UBool U_EXPORT2
utrie_set32(UNewTrie *trie, UChar32 c, uint32_t value);
@@ -677,7 +677,7 @@ utrie_set32(UNewTrie *trie, UChar32 c, uint32_t value);
*
* @param trie the build-time trie
* @param c the code point
- * @param pInBlockZero if not NULL, then *pInBlockZero is set to TRUE
+ * @param pInBlockZero if not NULL, then *pInBlockZero is set to true
* iff the value is retrieved from block 0;
* block 0 is the all-initial-value initial block
* @return the value
@@ -688,14 +688,14 @@ utrie_get32(UNewTrie *trie, UChar32 c, UBool *pInBlockZero);
/**
* Set a value in a range of code points [start..limit[.
* All code points c with start<=c<limit will get the value if
- * overwrite is TRUE or if the old value is 0.
+ * overwrite is true or if the old value is 0.
*
* @param trie the build-time trie
* @param start the first code point to get the value
* @param limit one past the last code point to get the value
* @param value the value
* @param overwrite flag for whether old non-initial values are to be overwritten
- * @return FALSE if a failure occurred (illegal argument or data array overrun)
+ * @return false if a failure occurred (illegal argument or data array overrun)
*/
U_CAPI UBool U_EXPORT2
utrie_setRange32(UNewTrie *trie, UChar32 start, UChar32 limit, uint32_t value, UBool overwrite);
diff --git a/deps/icu-small/source/common/utrie2.h b/deps/icu-small/source/common/utrie2.h
index 671f44e16a..d1e1e15a6e 100644
--- a/deps/icu-small/source/common/utrie2.h
+++ b/deps/icu-small/source/common/utrie2.h
@@ -161,13 +161,13 @@ UTrie2EnumValue(const void *context, uint32_t value);
* of code points with the same value as retrieved from the trie and
* transformed by the UTrie2EnumValue function.
*
- * The callback function can stop the enumeration by returning FALSE.
+ * The callback function can stop the enumeration by returning false.
*
* @param context an opaque pointer, as passed into utrie2_enum()
* @param start the first code point in a contiguous range with value
* @param end the last code point in a contiguous range with value (inclusive)
* @param value the value that is set for all code points in [start..end]
- * @return FALSE to stop the enumeration
+ * @return false to stop the enumeration
*/
typedef UBool U_CALLCONV
UTrie2EnumRange(const void *context, UChar32 start, UChar32 end, uint32_t value);
@@ -256,7 +256,7 @@ utrie2_set32(UTrie2 *trie, UChar32 c, uint32_t value, UErrorCode *pErrorCode);
/**
* Set a value in a range of code points [start..end].
* All code points c with start<=c<=end will get the value if
- * overwrite is TRUE or if the old value is the initial value.
+ * overwrite is true or if the old value is the initial value.
*
* @param trie the unfrozen trie
* @param start the first code point to get the value
@@ -298,7 +298,7 @@ utrie2_freeze(UTrie2 *trie, UTrie2ValueBits valueBits, UErrorCode *pErrorCode);
* Test if the trie is frozen. (See utrie2_freeze().)
*
* @param trie the trie
- * @return TRUE if the trie is frozen, that is, immutable, ready for serialization
+ * @return true if the trie is frozen, that is, immutable, ready for serialization
* and for use with fast macros
*/
U_CAPI UBool U_EXPORT2
@@ -670,7 +670,7 @@ struct UTrie2 {
/* private: used by builder and unserialization functions */
void *memory; /* serialized bytes; NULL if not frozen yet */
int32_t length; /* number of serialized bytes at memory; 0 if not frozen yet */
- UBool isMemoryOwned; /* TRUE if the trie owns the memory */
+ UBool isMemoryOwned; /* true if the trie owns the memory */
UBool padding1;
int16_t padding2;
UNewTrie2 *newTrie; /* builder object; NULL when frozen */
@@ -796,7 +796,7 @@ enum {
* Do not call directly.
* @internal
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utrie2_internalU8NextIndex(const UTrie2 *trie, UChar32 c,
const uint8_t *src, const uint8_t *limit);
@@ -805,7 +805,7 @@ utrie2_internalU8NextIndex(const UTrie2 *trie, UChar32 c,
* Do not call directly.
* @internal
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utrie2_internalU8PrevIndex(const UTrie2 *trie, UChar32 c,
const uint8_t *start, const uint8_t *src);
diff --git a/deps/icu-small/source/common/utrie_swap.cpp b/deps/icu-small/source/common/utrie_swap.cpp
index 5abe7bd5d7..6e8b138394 100644
--- a/deps/icu-small/source/common/utrie_swap.cpp
+++ b/deps/icu-small/source/common/utrie_swap.cpp
@@ -256,20 +256,24 @@ ucptrie_swap(const UDataSwapper *ds,
ds->swapArray32(ds, &inTrie->signature, 4, &outTrie->signature, pErrorCode);
ds->swapArray16(ds, &inTrie->options, 12, &outTrie->options, pErrorCode);
- /* swap the index and the data */
+ /* swap the index */
+ const uint16_t *inIndex=reinterpret_cast<const uint16_t *>(inTrie+1);
+ uint16_t *outIndex=reinterpret_cast<uint16_t *>(outTrie+1);
+ ds->swapArray16(ds, inIndex, trie.indexLength*2, outIndex, pErrorCode);
+
+ /* swap the data */
+ const uint16_t *inData=inIndex+trie.indexLength;
+ uint16_t *outData=outIndex+trie.indexLength;
switch(valueWidth) {
case UCPTRIE_VALUE_BITS_16:
- ds->swapArray16(ds, inTrie+1, (trie.indexLength+dataLength)*2, outTrie+1, pErrorCode);
+ ds->swapArray16(ds, inData, dataLength*2, outData, pErrorCode);
break;
case UCPTRIE_VALUE_BITS_32:
- ds->swapArray16(ds, inTrie+1, trie.indexLength*2, outTrie+1, pErrorCode);
- ds->swapArray32(ds, (const uint16_t *)(inTrie+1)+trie.indexLength, dataLength*4,
- (uint16_t *)(outTrie+1)+trie.indexLength, pErrorCode);
+ ds->swapArray32(ds, inData, dataLength*4, outData, pErrorCode);
break;
case UCPTRIE_VALUE_BITS_8:
- ds->swapArray16(ds, inTrie+1, trie.indexLength*2, outTrie+1, pErrorCode);
if(inTrie!=outTrie) {
- uprv_memmove((outTrie+1)+trie.indexLength, (inTrie+1)+trie.indexLength, dataLength);
+ uprv_memmove(outData, inData, dataLength);
}
break;
default:
diff --git a/deps/icu-small/source/common/uts46.cpp b/deps/icu-small/source/common/uts46.cpp
index b9e6cb023b..f25b4e12f1 100644
--- a/deps/icu-small/source/common/uts46.cpp
+++ b/deps/icu-small/source/common/uts46.cpp
@@ -714,6 +714,16 @@ UTS46::processLabel(UnicodeString &dest,
UBool wasPunycode;
if(labelLength>=4 && label[0]==0x78 && label[1]==0x6e && label[2]==0x2d && label[3]==0x2d) {
// Label starts with "xn--", try to un-Punycode it.
+ // In IDNA2008, labels like "xn--" (decodes to an empty string) and
+ // "xn--ASCII-" (decodes to just "ASCII") fail the round-trip validation from
+ // comparing the ToUnicode input with the back-to-ToASCII output.
+ // They are alternate encodings of the respective ASCII labels.
+ // Ignore "xn---" here: It will fail Punycode.decode() which logically comes before
+ // the round-trip verification.
+ if(labelLength==4 || (labelLength>5 && label[labelLength-1]==u'-')) {
+ info.labelErrors|=UIDNA_ERROR_INVALID_ACE_LABEL;
+ return markBadACELabel(dest, labelStart, labelLength, toASCII, info, errorCode);
+ }
wasPunycode=TRUE;
UChar *unicodeBuffer=fromPunycode.getBuffer(-1); // capacity==-1: most labels should fit
if(unicodeBuffer==NULL) {
@@ -925,10 +935,10 @@ UTS46::markBadACELabel(UnicodeString &dest,
UBool isASCII=TRUE;
UBool onlyLDH=TRUE;
const UChar *label=dest.getBuffer()+labelStart;
- // Ok to cast away const because we own the UnicodeString.
- UChar *s=(UChar *)label+4; // After the initial "xn--".
const UChar *limit=label+labelLength;
- do {
+ // Start after the initial "xn--".
+ // Ok to cast away const because we own the UnicodeString.
+ for(UChar *s=const_cast<UChar *>(label+4); s<limit; ++s) {
UChar c=*s;
if(c<=0x7f) {
if(c==0x2e) {
@@ -945,7 +955,7 @@ UTS46::markBadACELabel(UnicodeString &dest,
} else {
isASCII=onlyLDH=FALSE;
}
- } while(++s<limit);
+ }
if(onlyLDH) {
dest.insert(labelStart+labelLength, (UChar)0xfffd);
if(dest.isBogus()) {
diff --git a/deps/icu-small/source/common/utypes.cpp b/deps/icu-small/source/common/utypes.cpp
index 7531e46568..63e05b1249 100644
--- a/deps/icu-small/source/common/utypes.cpp
+++ b/deps/icu-small/source/common/utypes.cpp
@@ -104,7 +104,8 @@ _uErrorName[U_STANDARD_ERROR_LIMIT]={
"U_INVALID_STATE_ERROR",
"U_COLLATOR_VERSION_MISMATCH",
"U_USELESS_COLLATOR_ERROR",
- "U_NO_WRITE_PERMISSION"
+ "U_NO_WRITE_PERMISSION",
+ "U_INPUT_TOO_LONG_ERROR"
};
static const char * const
_uFmtErrorName[U_FMT_PARSE_ERROR_LIMIT - U_FMT_PARSE_ERROR_START] = {
diff --git a/deps/icu-small/source/common/uvector.h b/deps/icu-small/source/common/uvector.h
index a7625cd01a..34f3434a97 100644
--- a/deps/icu-small/source/common/uvector.h
+++ b/deps/icu-small/source/common/uvector.h
@@ -64,7 +64,7 @@ U_NAMESPACE_BEGIN
* uses a comparison function, or "comparer." If the comparer is not
* set, or is set to zero, then all such methods will act as if the
* vector contains no element. That is, indexOf() will always return
- * -1, contains() will always return FALSE, etc.
+ * -1, contains() will always return false, etc.
*
* <p><b>To do</b>
*
diff --git a/deps/icu-small/source/common/uvectr32.h b/deps/icu-small/source/common/uvectr32.h
index 91a2dd2009..92746a4f47 100644
--- a/deps/icu-small/source/common/uvectr32.h
+++ b/deps/icu-small/source/common/uvectr32.h
@@ -214,7 +214,7 @@ public:
inline UBool UVector32::ensureCapacity(int32_t minimumCapacity, UErrorCode &status) {
if ((minimumCapacity >= 0) && (capacity >= minimumCapacity)) {
- return TRUE;
+ return true;
} else {
return expandCapacity(minimumCapacity, status);
}
@@ -233,7 +233,7 @@ inline void UVector32::addElement(int32_t elem, UErrorCode &status) {
}
inline int32_t *UVector32::reserveBlock(int32_t size, UErrorCode &status) {
- if (ensureCapacity(count+size, status) == FALSE) {
+ if (ensureCapacity(count+size, status) == false) {
return NULL;
}
int32_t *rp = elements+count;
diff --git a/deps/icu-small/source/common/uvectr64.h b/deps/icu-small/source/common/uvectr64.h
index 6d26863eab..4dab16396c 100644
--- a/deps/icu-small/source/common/uvectr64.h
+++ b/deps/icu-small/source/common/uvectr64.h
@@ -203,7 +203,7 @@ public:
inline UBool UVector64::ensureCapacity(int32_t minimumCapacity, UErrorCode &status) {
if ((minimumCapacity >= 0) && (capacity >= minimumCapacity)) {
- return TRUE;
+ return true;
} else {
return expandCapacity(minimumCapacity, status);
}
@@ -222,7 +222,7 @@ inline void UVector64::addElement(int64_t elem, UErrorCode &status) {
}
inline int64_t *UVector64::reserveBlock(int32_t size, UErrorCode &status) {
- if (ensureCapacity(count+size, status) == FALSE) {
+ if (ensureCapacity(count+size, status) == false) {
return NULL;
}
int64_t *rp = elements+count;
diff --git a/deps/icu-small/source/common/wintz.cpp b/deps/icu-small/source/common/wintz.cpp
index 115512e704..047f4290f1 100644
--- a/deps/icu-small/source/common/wintz.cpp
+++ b/deps/icu-small/source/common/wintz.cpp
@@ -16,11 +16,12 @@
#if U_PLATFORM_USES_ONLY_WIN32_API
#include "wintz.h"
+#include "charstr.h"
#include "cmemory.h"
#include "cstring.h"
#include "unicode/ures.h"
-#include "unicode/ustring.h"
+#include "unicode/unistr.h"
#include "uresimp.h"
#ifndef WIN32_LEAN_AND_MEAN
@@ -35,89 +36,111 @@
U_NAMESPACE_BEGIN
-// The max size of TimeZoneKeyName is 128, defined in DYNAMIC_TIME_ZONE_INFORMATION
-#define MAX_TIMEZONE_ID_LENGTH 128
-
/**
* Main Windows time zone detection function.
* Returns the Windows time zone converted to an ICU time zone as a heap-allocated buffer, or nullptr upon failure.
-* Note: We use the Win32 API GetDynamicTimeZoneInformation to get the current time zone info.
-* This API returns a non-localized time zone name, which we can then map to an ICU time zone name.
+*
+* Note: We use the Win32 API GetDynamicTimeZoneInformation (available since Vista+) to get the current time zone info.
+* This API returns a non-localized time zone name, which is mapped to an ICU time zone ID (~ Olsen ID).
*/
-U_INTERNAL const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uprv_detectWindowsTimeZone()
{
- UErrorCode status = U_ZERO_ERROR;
- char* icuid = nullptr;
- char dynamicTZKeyName[MAX_TIMEZONE_ID_LENGTH];
- char tmpid[MAX_TIMEZONE_ID_LENGTH];
- int32_t len;
- int id = GEOID_NOT_AVAILABLE;
- int errorCode;
- wchar_t ISOcodeW[3] = {}; /* 2 letter ISO code in UTF-16 */
- char ISOcode[3] = {}; /* 2 letter ISO code in UTF-8 */
-
+ // Obtain the DYNAMIC_TIME_ZONE_INFORMATION info to get the non-localized time zone name.
DYNAMIC_TIME_ZONE_INFORMATION dynamicTZI;
uprv_memset(&dynamicTZI, 0, sizeof(dynamicTZI));
- uprv_memset(dynamicTZKeyName, 0, sizeof(dynamicTZKeyName));
- uprv_memset(tmpid, 0, sizeof(tmpid));
+ SYSTEMTIME systemTimeAllZero;
+ uprv_memset(&systemTimeAllZero, 0, sizeof(systemTimeAllZero));
- /* Obtain TIME_ZONE_INFORMATION from the API and get the non-localized time zone name. */
- if (TIME_ZONE_ID_INVALID == GetDynamicTimeZoneInformation(&dynamicTZI)) {
+ if (GetDynamicTimeZoneInformation(&dynamicTZI) == TIME_ZONE_ID_INVALID) {
return nullptr;
}
- id = GetUserGeoID(GEOCLASS_NATION);
- errorCode = GetGeoInfoW(id, GEO_ISO2, ISOcodeW, 3, 0);
-
- // convert from wchar_t* (UTF-16 on Windows) to char* (UTF-8).
- u_strToUTF8(ISOcode, UPRV_LENGTHOF(ISOcode), nullptr,
- reinterpret_cast<const UChar*>(ISOcodeW), UPRV_LENGTHOF(ISOcodeW), &status);
-
- LocalUResourceBundlePointer bundle(ures_openDirect(nullptr, "windowsZones", &status));
- ures_getByKey(bundle.getAlias(), "mapTimezones", bundle.getAlias(), &status);
+ // If the DST setting has been turned off in the Control Panel, then return "Etc/GMT<offset>".
+ //
+ // Note: This logic is based on how the Control Panel itself determines if DST is 'off' on Windows.
+ // The code is somewhat convoluted; in a sort of pseudo-code it looks like this:
+ //
+ // IF (GetDynamicTimeZoneInformation != TIME_ZONE_ID_INVALID) && (DynamicDaylightTimeDisabled != 0) &&
+ // (StandardDate == DaylightDate) &&
+ // (
+ // (TimeZoneKeyName != Empty && StandardDate == 0) ||
+ // (TimeZoneKeyName == Empty && StandardDate != 0)
+ // )
+ // THEN
+ // DST setting is "Disabled".
+ //
+ if (dynamicTZI.DynamicDaylightTimeDisabled != 0 &&
+ uprv_memcmp(&dynamicTZI.StandardDate, &dynamicTZI.DaylightDate, sizeof(dynamicTZI.StandardDate)) == 0 &&
+ ((dynamicTZI.TimeZoneKeyName[0] != L'\0' && uprv_memcmp(&dynamicTZI.StandardDate, &systemTimeAllZero, sizeof(systemTimeAllZero)) == 0) ||
+ (dynamicTZI.TimeZoneKeyName[0] == L'\0' && uprv_memcmp(&dynamicTZI.StandardDate, &systemTimeAllZero, sizeof(systemTimeAllZero)) != 0)))
+ {
+ LONG utcOffsetMins = dynamicTZI.Bias;
+ if (utcOffsetMins == 0) {
+ return uprv_strdup("Etc/UTC");
+ }
- // convert from wchar_t* (UTF-16 on Windows) to char* (UTF-8).
- u_strToUTF8(dynamicTZKeyName, UPRV_LENGTHOF(dynamicTZKeyName), nullptr,
- reinterpret_cast<const UChar*>(dynamicTZI.TimeZoneKeyName), -1, &status);
+ // No way to support when DST is turned off and the offset in minutes is not a multiple of 60.
+ if (utcOffsetMins % 60 == 0) {
+ char gmtOffsetTz[11] = {}; // "Etc/GMT+dd" is 11-char long with a terminal null.
+ // Note '-' before 'utcOffsetMin'. The timezone ID's sign convention
+ // is that a timezone ahead of UTC is Etc/GMT-<offset> and a timezone
+ // behind UTC is Etc/GMT+<offset>.
+ int ret = snprintf(gmtOffsetTz, UPRV_LENGTHOF(gmtOffsetTz), "Etc/GMT%+d", -utcOffsetMins / 60);
+ if (ret > 0 && ret < UPRV_LENGTHOF(gmtOffsetTz)) {
+ return uprv_strdup(gmtOffsetTz);
+ }
+ }
+ }
- if (U_FAILURE(status)) {
+ // If DST is NOT disabled, but we have an empty TimeZoneKeyName, then it is unclear
+ // what we should do as this should not happen.
+ if (dynamicTZI.TimeZoneKeyName[0] == 0) {
return nullptr;
}
- if (dynamicTZI.TimeZoneKeyName[0] != 0) {
- StackUResourceBundle winTZ;
- ures_getByKey(bundle.getAlias(), dynamicTZKeyName, winTZ.getAlias(), &status);
+ CharString winTZ;
+ UErrorCode status = U_ZERO_ERROR;
+ winTZ.appendInvariantChars(UnicodeString(TRUE, dynamicTZI.TimeZoneKeyName, -1), status);
- if (U_SUCCESS(status)) {
- const UChar* icuTZ = nullptr;
- if (errorCode != 0) {
- icuTZ = ures_getStringByKey(winTZ.getAlias(), ISOcode, &len, &status);
- }
- if (errorCode == 0 || icuTZ == nullptr) {
- /* fallback to default "001" and reset status */
- status = U_ZERO_ERROR;
- icuTZ = ures_getStringByKey(winTZ.getAlias(), "001", &len, &status);
- }
+ // Map Windows Timezone name (non-localized) to ICU timezone ID (~ Olson timezone id).
+ StackUResourceBundle winTZBundle;
+ ures_openDirectFillIn(winTZBundle.getAlias(), nullptr, "windowsZones", &status);
+ ures_getByKey(winTZBundle.getAlias(), "mapTimezones", winTZBundle.getAlias(), &status);
+ ures_getByKey(winTZBundle.getAlias(), winTZ.data(), winTZBundle.getAlias(), &status);
- if (U_SUCCESS(status)) {
- int index = 0;
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
- while (!(*icuTZ == '\0' || *icuTZ == ' ')) {
- // time zone IDs only contain ASCII invariant characters.
- tmpid[index++] = (char)(*icuTZ++);
- }
- tmpid[index] = '\0';
- }
+ // Note: Since the ISO 3166 country/region codes are all invariant ASCII chars, we can
+ // directly downcast from wchar_t to do the conversion.
+ // We could call the A version of the GetGeoInfo API, but that would be slightly slower than calling the W API,
+ // as the A version of the API will end up calling MultiByteToWideChar anyways internally.
+ wchar_t regionCodeW[3] = {};
+ char regionCode[3] = {}; // 2 letter ISO 3166 country/region code made entirely of invariant chars.
+ int geoId = GetUserGeoID(GEOCLASS_NATION);
+ int regionCodeLen = GetGeoInfoW(geoId, GEO_ISO2, regionCodeW, UPRV_LENGTHOF(regionCodeW), 0);
+
+ const UChar *icuTZ16 = nullptr;
+ int32_t tzLen;
+
+ if (regionCodeLen != 0) {
+ for (int i = 0; i < UPRV_LENGTHOF(regionCodeW); i++) {
+ regionCode[i] = static_cast<char>(regionCodeW[i]);
}
+ icuTZ16 = ures_getStringByKey(winTZBundle.getAlias(), regionCode, &tzLen, &status);
}
-
- // Copy the timezone ID to icuid to be returned.
- if (tmpid[0] != 0) {
- icuid = uprv_strdup(tmpid);
+ if (regionCodeLen == 0 || U_FAILURE(status)) {
+ // fallback to default "001" (world)
+ status = U_ZERO_ERROR;
+ icuTZ16 = ures_getStringByKey(winTZBundle.getAlias(), "001", &tzLen, &status);
}
- return icuid;
+ // Note: cloneData returns nullptr if the status is a failure, so this
+ // will return nullptr if the above look-up fails.
+ CharString icuTZStr;
+ return icuTZStr.appendInvariantChars(icuTZ16, tzLen, status).cloneData(status);
}
U_NAMESPACE_END
diff --git a/deps/icu-small/source/common/wintz.h b/deps/icu-small/source/common/wintz.h
index 9140d2729a..b1ac8c0790 100644
--- a/deps/icu-small/source/common/wintz.h
+++ b/deps/icu-small/source/common/wintz.h
@@ -28,7 +28,7 @@ U_CDECL_BEGIN
typedef struct _TIME_ZONE_INFORMATION TIME_ZONE_INFORMATION;
U_CDECL_END
-U_INTERNAL const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uprv_detectWindowsTimeZone();
#endif /* U_PLATFORM_USES_ONLY_WIN32_API */
diff --git a/deps/icu-small/source/data/in/icudt67l.dat.bz2 b/deps/icu-small/source/data/in/icudt68l.dat.bz2
index 60bc3e084f..fcee4ecfa1 100644
--- a/deps/icu-small/source/data/in/icudt67l.dat.bz2
+++ b/deps/icu-small/source/data/in/icudt68l.dat.bz2
Binary files differ
diff --git a/deps/icu-small/source/i18n/buddhcal.h b/deps/icu-small/source/i18n/buddhcal.h
index c3ffa6a41d..e5ce18883a 100644
--- a/deps/icu-small/source/i18n/buddhcal.h
+++ b/deps/icu-small/source/i18n/buddhcal.h
@@ -174,7 +174,7 @@ private:
UBool useMonth) const;
/**
- * Returns TRUE because the Buddhist Calendar does have a default century
+ * Returns true because the Buddhist Calendar does have a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/calendar.cpp b/deps/icu-small/source/i18n/calendar.cpp
index e8b718f3c4..df256c154d 100644
--- a/deps/icu-small/source/i18n/calendar.cpp
+++ b/deps/icu-small/source/i18n/calendar.cpp
@@ -266,7 +266,7 @@ static ECalType getCalendarTypeForLocale(const char *locid) {
//TODO: ULOC_FULL_NAME is out of date and too small..
char canonicalName[256];
- // canonicalize, so grandfathered variant will be transformed to keywords
+ // Canonicalize, so that an old-style variant will be transformed to keywords.
// e.g ja_JP_TRADITIONAL -> ja_JP@calendar=japanese
// NOTE: Since ICU-20187, ja_JP_TRADITIONAL no longer canonicalizes, and
// the Gregorian calendar is returned instead.
@@ -870,7 +870,7 @@ Calendar::createInstance(const TimeZone& zone, UErrorCode& success)
Calendar* U_EXPORT2
Calendar::createInstance(const Locale& aLocale, UErrorCode& success)
{
- return createInstance(TimeZone::createDefault(), aLocale, success);
+ return createInstance(TimeZone::forLocaleOrDefault(aLocale), aLocale, success);
}
// ------------------------------------- Adopting
diff --git a/deps/icu-small/source/i18n/cecal.cpp b/deps/icu-small/source/i18n/cecal.cpp
index 458fe2f304..3389b72869 100644
--- a/deps/icu-small/source/i18n/cecal.cpp
+++ b/deps/icu-small/source/i18n/cecal.cpp
@@ -49,7 +49,7 @@ static const int32_t LIMITS[UCAL_FIELD_COUNT][4] = {
//-------------------------------------------------------------------------
CECalendar::CECalendar(const Locale& aLocale, UErrorCode& success)
-: Calendar(TimeZone::createDefault(), aLocale, success)
+: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success)
{
setTimeInMillis(getNow(), success);
}
diff --git a/deps/icu-small/source/i18n/cecal.h b/deps/icu-small/source/i18n/cecal.h
index c380f0bea3..80dab70f6f 100644
--- a/deps/icu-small/source/i18n/cecal.h
+++ b/deps/icu-small/source/i18n/cecal.h
@@ -88,7 +88,7 @@ protected:
virtual UBool inDaylightTime(UErrorCode&) const;
/**
- * Returns TRUE because Coptic/Ethiopic Calendar does have a default century
+ * Returns true because Coptic/Ethiopic Calendar does have a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/chnsecal.cpp b/deps/icu-small/source/i18n/chnsecal.cpp
index 2ff9f755af..2ab08dd339 100644
--- a/deps/icu-small/source/i18n/chnsecal.cpp
+++ b/deps/icu-small/source/i18n/chnsecal.cpp
@@ -123,7 +123,7 @@ ChineseCalendar* ChineseCalendar::clone() const {
}
ChineseCalendar::ChineseCalendar(const Locale& aLocale, UErrorCode& success)
-: Calendar(TimeZone::createDefault(), aLocale, success),
+: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success),
isLeapYear(FALSE),
fEpochYear(CHINESE_EPOCH_YEAR),
fZoneAstroCalc(getChineseCalZoneAstroCalc())
@@ -133,7 +133,7 @@ ChineseCalendar::ChineseCalendar(const Locale& aLocale, UErrorCode& success)
ChineseCalendar::ChineseCalendar(const Locale& aLocale, int32_t epochYear,
const TimeZone* zoneAstroCalc, UErrorCode &success)
-: Calendar(TimeZone::createDefault(), aLocale, success),
+: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success),
isLeapYear(FALSE),
fEpochYear(epochYear),
fZoneAstroCalc(zoneAstroCalc)
diff --git a/deps/icu-small/source/i18n/chnsecal.h b/deps/icu-small/source/i18n/chnsecal.h
index c7c0637381..77a68a4892 100644
--- a/deps/icu-small/source/i18n/chnsecal.h
+++ b/deps/icu-small/source/i18n/chnsecal.h
@@ -242,7 +242,7 @@ class U_I18N_API ChineseCalendar : public Calendar {
/**
- * Returns TRUE because the Islamic Calendar does have a default century
+ * Returns true because the Islamic Calendar does have a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/collation.h b/deps/icu-small/source/i18n/collation.h
index e9256c9c12..ecbba29057 100644
--- a/deps/icu-small/source/i18n/collation.h
+++ b/deps/icu-small/source/i18n/collation.h
@@ -356,7 +356,7 @@ public:
}
/**
- * @return TRUE if the ce32 yields one or more CEs without further data lookups
+ * @return true if the ce32 yields one or more CEs without further data lookups
*/
static UBool isSelfContainedCE32(uint32_t ce32) {
return !isSpecialCE32(ce32) ||
diff --git a/deps/icu-small/source/i18n/collationbuilder.h b/deps/icu-small/source/i18n/collationbuilder.h
index 2f20050f93..82f0459748 100644
--- a/deps/icu-small/source/i18n/collationbuilder.h
+++ b/deps/icu-small/source/i18n/collationbuilder.h
@@ -42,7 +42,7 @@ public:
CollationBuilder(const CollationTailoring *base, UErrorCode &errorCode);
virtual ~CollationBuilder();
- void disableFastLatin() { fastLatinEnabled = FALSE; }
+ void disableFastLatin() { fastLatinEnabled = false; }
CollationTailoring *parseAndBuild(const UnicodeString &ruleString,
const UVersionInfo rulesVersion,
diff --git a/deps/icu-small/source/i18n/collationdatabuilder.h b/deps/icu-small/source/i18n/collationdatabuilder.h
index fee444deee..6ae77772fd 100644
--- a/deps/icu-small/source/i18n/collationdatabuilder.h
+++ b/deps/icu-small/source/i18n/collationdatabuilder.h
@@ -73,12 +73,12 @@ public:
}
/**
- * @return TRUE if this builder has mappings (e.g., add() has been called)
+ * @return true if this builder has mappings (e.g., add() has been called)
*/
UBool hasMappings() const { return modified; }
/**
- * @return TRUE if c has CEs in this builder
+ * @return true if c has CEs in this builder
*/
UBool isAssigned(UChar32 c) const;
@@ -118,7 +118,7 @@ public:
* @param primary primary weight for 'start'
* @param step per-code point primary-weight increment
* @param errorCode ICU in/out error code
- * @return TRUE if an OFFSET_TAG range was used for start..end
+ * @return true if an OFFSET_TAG range was used for start..end
*/
UBool maybeSetPrimaryRange(UChar32 start, UChar32 end,
uint32_t primary, int32_t step,
@@ -150,7 +150,7 @@ public:
void optimize(const UnicodeSet &set, UErrorCode &errorCode);
void suppressContractions(const UnicodeSet &set, UErrorCode &errorCode);
- void enableFastLatin() { fastLatinEnabled = TRUE; }
+ void enableFastLatin() { fastLatinEnabled = true; }
virtual void build(CollationData &data, UErrorCode &errorCode);
/**
diff --git a/deps/icu-small/source/i18n/collationfcd.h b/deps/icu-small/source/i18n/collationfcd.h
index ec7167d76b..3a5738efb2 100644
--- a/deps/icu-small/source/i18n/collationfcd.h
+++ b/deps/icu-small/source/i18n/collationfcd.h
@@ -84,7 +84,7 @@ public:
// Handles all of Unicode 0..10FFFF.
// c can be negative, e.g., U_SENTINEL.
// U+0300 is the first character with lccc!=0.
- if(c < 0x300) { return FALSE; }
+ if(c < 0x300) { return false; }
if(c > 0xffff) { c = U16_LEAD(c); }
int32_t i;
return
@@ -101,7 +101,7 @@ public:
* This is a fast and imprecise test.
*
* @param c a code point
- * @return TRUE if c is U+0F73, U+0F75 or U+0F81 or one of several other Tibetan characters
+ * @return true if c is U+0F73, U+0F75 or U+0F81 or one of several other Tibetan characters
*/
static inline UBool maybeTibetanCompositeVowel(UChar32 c) {
return (c & 0x1fff01) == 0xf01;
@@ -116,7 +116,7 @@ public:
* They have distinct lccc/tccc combinations: 129/130 or 129/132.
*
* @param fcd16 the FCD value (lccc/tccc combination) of a code point
- * @return TRUE if fcd16 is from U+0F73, U+0F75 or U+0F81
+ * @return true if fcd16 is from U+0F73, U+0F75 or U+0F81
*/
static inline UBool isFCD16OfTibetanCompositeVowel(uint16_t fcd16) {
return fcd16 == 0x8182 || fcd16 == 0x8184;
diff --git a/deps/icu-small/source/i18n/collationiterator.h b/deps/icu-small/source/i18n/collationiterator.h
index 12e05b4482..869f0956c3 100644
--- a/deps/icu-small/source/i18n/collationiterator.h
+++ b/deps/icu-small/source/i18n/collationiterator.h
@@ -76,9 +76,9 @@ private:
// (Rather than buffer.getCapacity().)
if(length < INITIAL_CAPACITY || ensureAppendCapacity(1, errorCode)) {
++length;
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
@@ -251,9 +251,9 @@ protected:
virtual UBool foundNULTerminator();
/**
- * @return FALSE if surrogate code points U+D800..U+DFFF
+ * @return false if surrogate code points U+D800..U+DFFF
* map to their own implicit primary weights (for UTF-16),
- * or TRUE if they map to CE(U+FFFD) (for UTF-8)
+ * or true if they map to CE(U+FFFD) (for UTF-8)
*/
virtual UBool forbidSurrogateCodePoints() const;
diff --git a/deps/icu-small/source/i18n/collationkeys.h b/deps/icu-small/source/i18n/collationkeys.h
index 60d9e50c0d..c526a4f14f 100644
--- a/deps/icu-small/source/i18n/collationkeys.h
+++ b/deps/icu-small/source/i18n/collationkeys.h
@@ -65,7 +65,7 @@ public:
}
UBool Overflowed() const { return appended_ > capacity_; }
- /** @return FALSE if memory allocation failed */
+ /** @return false if memory allocation failed */
UBool IsOk() const { return buffer_ != NULL; }
protected:
@@ -94,8 +94,8 @@ public:
virtual ~LevelCallback();
/**
* @param level The next level about to be written to the ByteSink.
- * @return TRUE if the level is to be written
- * (the base class implementation always returns TRUE)
+ * @return true if the level is to be written
+ * (the base class implementation always returns true)
*/
virtual UBool needToWrite(Collation::Level level);
};
@@ -103,7 +103,7 @@ public:
/**
* Writes the sort key bytes for minLevel up to the iterator data's strength.
* Optionally writes the case level.
- * Stops writing levels when callback.needToWrite(level) returns FALSE.
+ * Stops writing levels when callback.needToWrite(level) returns false.
* Separates levels with the LEVEL_SEPARATOR_BYTE
* but does not write a TERMINATOR_BYTE.
*/
diff --git a/deps/icu-small/source/i18n/collationtailoring.h b/deps/icu-small/source/i18n/collationtailoring.h
index e1bc34c7d7..5fc2bac2d3 100644
--- a/deps/icu-small/source/i18n/collationtailoring.h
+++ b/deps/icu-small/source/i18n/collationtailoring.h
@@ -50,7 +50,7 @@ struct U_I18N_API CollationTailoring : public SharedObject {
virtual ~CollationTailoring();
/**
- * Returns TRUE if the constructor could not initialize properly.
+ * Returns true if the constructor could not initialize properly.
*/
UBool isBogus() { return settings == NULL; }
diff --git a/deps/icu-small/source/i18n/collationweights.h b/deps/icu-small/source/i18n/collationweights.h
index d8cee79e33..bbd88b27e9 100644
--- a/deps/icu-small/source/i18n/collationweights.h
+++ b/deps/icu-small/source/i18n/collationweights.h
@@ -62,7 +62,7 @@ public:
* weights less than this one.
* @param n The number of collation element weights w necessary such that
* lowerLimit<w<upperLimit in lexical order.
- * @return TRUE if it is possible to fit n elements between the limits
+ * @return true if it is possible to fit n elements between the limits
*/
UBool allocWeights(uint32_t lowerLimit, uint32_t upperLimit, int32_t n);
diff --git a/deps/icu-small/source/i18n/cpdtrans.h b/deps/icu-small/source/i18n/cpdtrans.h
index e51b209411..c9a9f0519b 100644
--- a/deps/icu-small/source/i18n/cpdtrans.h
+++ b/deps/icu-small/source/i18n/cpdtrans.h
@@ -131,7 +131,7 @@ public:
* to recreate this transliterator.
* @param result the string to receive the rules. Previous
* contents will be deleted.
- * @param escapeUnprintable if TRUE then convert unprintable
+ * @param escapeUnprintable if true then convert unprintable
* character to their hex escape representations, \uxxxx or
* \Uxxxxxxxx. Unprintable characters are those other than
* U+000A, U+0020..U+007E.
diff --git a/deps/icu-small/source/i18n/csrecog.h b/deps/icu-small/source/i18n/csrecog.h
index 51c25396ad..42c7d189e5 100644
--- a/deps/icu-small/source/i18n/csrecog.h
+++ b/deps/icu-small/source/i18n/csrecog.h
@@ -43,8 +43,8 @@ class CharsetRecognizer : public UMemory
* Try the given input text against this Charset, and fill in the results object
* with the quality of the match plus other information related to the match.
*
- * Return TRUE if the the input bytes are a potential match, and
- * FALSE if the input data is not compatible with, or illegal in this charset.
+ * Return true if the the input bytes are a potential match, and
+ * false if the input data is not compatible with, or illegal in this charset.
*/
virtual UBool match(InputText *textIn, CharsetMatch *results) const = 0;
diff --git a/deps/icu-small/source/i18n/dayperiodrules.h b/deps/icu-small/source/i18n/dayperiodrules.h
index 610c6175bf..4bfca762b8 100644
--- a/deps/icu-small/source/i18n/dayperiodrules.h
+++ b/deps/icu-small/source/i18n/dayperiodrules.h
@@ -66,7 +66,7 @@ private:
// Sets period type for all hours in [startHour, limitHour).
void add(int32_t startHour, int32_t limitHour, DayPeriod period);
- // Returns TRUE if for all i, DayPeriodForHour[i] has a type other than UNKNOWN.
+ // Returns true if for all i, DayPeriodForHour[i] has a type other than UNKNOWN.
// Values of HasNoon and HasMidnight do not affect the return value.
UBool allHoursAreSet();
diff --git a/deps/icu-small/source/i18n/decContext.h b/deps/icu-small/source/i18n/decContext.h
index 1fd18e5d3d..5f89a516d9 100644
--- a/deps/icu-small/source/i18n/decContext.h
+++ b/deps/icu-small/source/i18n/decContext.h
@@ -250,21 +250,21 @@
#define DEC_INIT_DECQUAD DEC_INIT_DECIMAL128
/* decContext routines */
- U_INTERNAL decContext * U_EXPORT2 uprv_decContextClearStatus(decContext *, uint32_t);
- U_INTERNAL decContext * U_EXPORT2 uprv_decContextDefault(decContext *, int32_t);
- U_INTERNAL enum rounding U_EXPORT2 uprv_decContextGetRounding(decContext *);
- U_INTERNAL uint32_t U_EXPORT2 uprv_decContextGetStatus(decContext *);
- U_INTERNAL decContext * U_EXPORT2 uprv_decContextRestoreStatus(decContext *, uint32_t, uint32_t);
- U_INTERNAL uint32_t U_EXPORT2 uprv_decContextSaveStatus(decContext *, uint32_t);
- U_INTERNAL decContext * U_EXPORT2 uprv_decContextSetRounding(decContext *, enum rounding);
- U_INTERNAL decContext * U_EXPORT2 uprv_decContextSetStatus(decContext *, uint32_t);
- U_INTERNAL decContext * U_EXPORT2 uprv_decContextSetStatusFromString(decContext *, const char *);
- U_INTERNAL decContext * U_EXPORT2 uprv_decContextSetStatusFromStringQuiet(decContext *, const char *);
- U_INTERNAL decContext * U_EXPORT2 uprv_decContextSetStatusQuiet(decContext *, uint32_t);
- U_INTERNAL const char * U_EXPORT2 uprv_decContextStatusToString(const decContext *);
- U_INTERNAL int32_t U_EXPORT2 uprv_decContextTestEndian(uint8_t);
- U_INTERNAL uint32_t U_EXPORT2 uprv_decContextTestSavedStatus(uint32_t, uint32_t);
- U_INTERNAL uint32_t U_EXPORT2 uprv_decContextTestStatus(decContext *, uint32_t);
- U_INTERNAL decContext * U_EXPORT2 uprv_decContextZeroStatus(decContext *);
+ U_CAPI decContext * U_EXPORT2 uprv_decContextClearStatus(decContext *, uint32_t);
+ U_CAPI decContext * U_EXPORT2 uprv_decContextDefault(decContext *, int32_t);
+ U_CAPI enum rounding U_EXPORT2 uprv_decContextGetRounding(decContext *);
+ U_CAPI uint32_t U_EXPORT2 uprv_decContextGetStatus(decContext *);
+ U_CAPI decContext * U_EXPORT2 uprv_decContextRestoreStatus(decContext *, uint32_t, uint32_t);
+ U_CAPI uint32_t U_EXPORT2 uprv_decContextSaveStatus(decContext *, uint32_t);
+ U_CAPI decContext * U_EXPORT2 uprv_decContextSetRounding(decContext *, enum rounding);
+ U_CAPI decContext * U_EXPORT2 uprv_decContextSetStatus(decContext *, uint32_t);
+ U_CAPI decContext * U_EXPORT2 uprv_decContextSetStatusFromString(decContext *, const char *);
+ U_CAPI decContext * U_EXPORT2 uprv_decContextSetStatusFromStringQuiet(decContext *, const char *);
+ U_CAPI decContext * U_EXPORT2 uprv_decContextSetStatusQuiet(decContext *, uint32_t);
+ U_CAPI const char * U_EXPORT2 uprv_decContextStatusToString(const decContext *);
+ U_CAPI int32_t U_EXPORT2 uprv_decContextTestEndian(uint8_t);
+ U_CAPI uint32_t U_EXPORT2 uprv_decContextTestSavedStatus(uint32_t, uint32_t);
+ U_CAPI uint32_t U_EXPORT2 uprv_decContextTestStatus(decContext *, uint32_t);
+ U_CAPI decContext * U_EXPORT2 uprv_decContextZeroStatus(decContext *);
#endif
diff --git a/deps/icu-small/source/i18n/decNumber.h b/deps/icu-small/source/i18n/decNumber.h
index 92be8e8c0a..7f5091d275 100644
--- a/deps/icu-small/source/i18n/decNumber.h
+++ b/deps/icu-small/source/i18n/decNumber.h
@@ -112,74 +112,74 @@
/* decNumber public functions and macros */
/* ---------------------------------------------------------------- */
/* Conversions */
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberFromInt32(decNumber *, int32_t);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberFromUInt32(decNumber *, uint32_t);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberFromString(decNumber *, const char *, decContext *);
- U_INTERNAL char * U_EXPORT2 uprv_decNumberToString(const decNumber *, char *);
- U_INTERNAL char * U_EXPORT2 uprv_decNumberToEngString(const decNumber *, char *);
- U_INTERNAL uint32_t U_EXPORT2 uprv_decNumberToUInt32(const decNumber *, decContext *);
- U_INTERNAL int32_t U_EXPORT2 uprv_decNumberToInt32(const decNumber *, decContext *);
- U_INTERNAL uint8_t * U_EXPORT2 uprv_decNumberGetBCD(const decNumber *, uint8_t *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberSetBCD(decNumber *, const uint8_t *, uint32_t);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromInt32(decNumber *, int32_t);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromUInt32(decNumber *, uint32_t);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromString(decNumber *, const char *, decContext *);
+ U_CAPI char * U_EXPORT2 uprv_decNumberToString(const decNumber *, char *);
+ U_CAPI char * U_EXPORT2 uprv_decNumberToEngString(const decNumber *, char *);
+ U_CAPI uint32_t U_EXPORT2 uprv_decNumberToUInt32(const decNumber *, decContext *);
+ U_CAPI int32_t U_EXPORT2 uprv_decNumberToInt32(const decNumber *, decContext *);
+ U_CAPI uint8_t * U_EXPORT2 uprv_decNumberGetBCD(const decNumber *, uint8_t *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberSetBCD(decNumber *, const uint8_t *, uint32_t);
/* Operators and elementary functions */
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberAbs(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberAdd(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberAnd(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberCompare(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberCompareSignal(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberCompareTotal(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberCompareTotalMag(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberDivide(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberDivideInteger(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberExp(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberFMA(decNumber *, const decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberInvert(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberLn(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberLogB(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberLog10(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberMax(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberMaxMag(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberMin(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberMinMag(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberMinus(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberMultiply(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberNormalize(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberOr(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberPlus(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberPower(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberQuantize(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberReduce(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberRemainder(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberRemainderNear(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberRescale(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberRotate(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberSameQuantum(decNumber *, const decNumber *, const decNumber *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberScaleB(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberShift(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberSquareRoot(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberSubtract(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberToIntegralExact(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberToIntegralValue(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberXor(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberAbs(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberAdd(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberAnd(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberCompare(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberCompareSignal(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberCompareTotal(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberCompareTotalMag(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberDivide(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberDivideInteger(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberExp(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFMA(decNumber *, const decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberInvert(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberLn(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberLogB(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberLog10(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberMax(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberMaxMag(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberMin(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberMinMag(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberMinus(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberMultiply(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberNormalize(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberOr(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberPlus(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberPower(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberQuantize(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberReduce(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberRemainder(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberRemainderNear(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberRescale(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberRotate(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberSameQuantum(decNumber *, const decNumber *, const decNumber *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberScaleB(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberShift(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberSquareRoot(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberSubtract(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberToIntegralExact(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberToIntegralValue(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberXor(decNumber *, const decNumber *, const decNumber *, decContext *);
/* Utilities */
enum decClass uprv_decNumberClass(const decNumber *, decContext *);
- U_INTERNAL const char * U_EXPORT2 uprv_decNumberClassToString(enum decClass);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberCopy(decNumber *, const decNumber *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberCopyAbs(decNumber *, const decNumber *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberCopyNegate(decNumber *, const decNumber *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberCopySign(decNumber *, const decNumber *, const decNumber *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberNextMinus(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberNextPlus(decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberNextToward(decNumber *, const decNumber *, const decNumber *, decContext *);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberTrim(decNumber *);
- U_INTERNAL const char * U_EXPORT2 uprv_decNumberVersion(void);
- U_INTERNAL decNumber * U_EXPORT2 uprv_decNumberZero(decNumber *);
+ U_CAPI const char * U_EXPORT2 uprv_decNumberClassToString(enum decClass);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberCopy(decNumber *, const decNumber *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberCopyAbs(decNumber *, const decNumber *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberCopyNegate(decNumber *, const decNumber *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberCopySign(decNumber *, const decNumber *, const decNumber *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberNextMinus(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberNextPlus(decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberNextToward(decNumber *, const decNumber *, const decNumber *, decContext *);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberTrim(decNumber *);
+ U_CAPI const char * U_EXPORT2 uprv_decNumberVersion(void);
+ U_CAPI decNumber * U_EXPORT2 uprv_decNumberZero(decNumber *);
/* Functions for testing decNumbers (normality depends on context) */
- U_INTERNAL int32_t U_EXPORT2 uprv_decNumberIsNormal(const decNumber *, decContext *);
- U_INTERNAL int32_t U_EXPORT2 uprv_decNumberIsSubnormal(const decNumber *, decContext *);
+ U_CAPI int32_t U_EXPORT2 uprv_decNumberIsNormal(const decNumber *, decContext *);
+ U_CAPI int32_t U_EXPORT2 uprv_decNumberIsSubnormal(const decNumber *, decContext *);
/* Macros for testing decNumber *dn */
#define decNumberIsCanonical(dn) (1) /* All decNumbers are saintly */
diff --git a/deps/icu-small/source/i18n/dtitv_impl.h b/deps/icu-small/source/i18n/dtitv_impl.h
index 7c4d8a7214..9a161ea435 100644
--- a/deps/icu-small/source/i18n/dtitv_impl.h
+++ b/deps/icu-small/source/i18n/dtitv_impl.h
@@ -64,11 +64,13 @@
#define LOW_Z ((UChar)0x007A)
#define CAP_A ((UChar)0x0041)
+#define CAP_B ((UChar)0x0042)
#define CAP_C ((UChar)0x0043)
#define CAP_D ((UChar)0x0044)
#define CAP_E ((UChar)0x0045)
#define CAP_F ((UChar)0x0046)
#define CAP_G ((UChar)0x0047)
+#define CAP_J ((UChar)0x004A)
#define CAP_H ((UChar)0x0048)
#define CAP_K ((UChar)0x004B)
#define CAP_L ((UChar)0x004C)
diff --git a/deps/icu-small/source/i18n/dtitvfmt.cpp b/deps/icu-small/source/i18n/dtitvfmt.cpp
index b71a571d1c..a913dc43c8 100644
--- a/deps/icu-small/source/i18n/dtitvfmt.cpp
+++ b/deps/icu-small/source/i18n/dtitvfmt.cpp
@@ -23,6 +23,7 @@
#include "unicode/dtptngen.h"
#include "unicode/dtitvinf.h"
#include "unicode/simpleformatter.h"
+#include "unicode/udisplaycontext.h"
#include "cmemory.h"
#include "cstring.h"
#include "dtitv_impl.h"
@@ -143,7 +144,8 @@ DateIntervalFormat::DateIntervalFormat()
fLocale(Locale::getRoot()),
fDatePattern(nullptr),
fTimePattern(nullptr),
- fDateTimeFormat(nullptr)
+ fDateTimeFormat(nullptr),
+ fCapitalizationContext(UDISPCTX_CAPITALIZATION_NONE)
{}
@@ -156,7 +158,8 @@ DateIntervalFormat::DateIntervalFormat(const DateIntervalFormat& itvfmt)
fLocale(itvfmt.fLocale),
fDatePattern(nullptr),
fTimePattern(nullptr),
- fDateTimeFormat(nullptr) {
+ fDateTimeFormat(nullptr),
+ fCapitalizationContext(UDISPCTX_CAPITALIZATION_NONE) {
*this = itvfmt;
}
@@ -203,6 +206,7 @@ DateIntervalFormat::operator=(const DateIntervalFormat& itvfmt) {
fDatePattern = (itvfmt.fDatePattern)? itvfmt.fDatePattern->clone(): nullptr;
fTimePattern = (itvfmt.fTimePattern)? itvfmt.fTimePattern->clone(): nullptr;
fDateTimeFormat = (itvfmt.fDateTimeFormat)? itvfmt.fDateTimeFormat->clone(): nullptr;
+ fCapitalizationContext = itvfmt.fCapitalizationContext;
}
return *this;
}
@@ -239,7 +243,7 @@ DateIntervalFormat::operator==(const Format& other) const {
if (fDateFormat && fmt->fDateFormat && (*fDateFormat != *fmt->fDateFormat)) {return FALSE;}
}
// note: fFromCalendar and fToCalendar hold no persistent state, and therefore do not participate in operator ==.
- // fDateFormat has the master calendar for the DateIntervalFormat.
+ // fDateFormat has the primary calendar for the DateIntervalFormat.
if (fSkeleton != fmt->fSkeleton) {return FALSE;}
if (fDatePattern != fmt->fDatePattern && (fDatePattern == nullptr || fmt->fDatePattern == nullptr)) {return FALSE;}
if (fDatePattern && fmt->fDatePattern && (*fDatePattern != *fmt->fDatePattern)) {return FALSE;}
@@ -254,6 +258,7 @@ DateIntervalFormat::operator==(const Format& other) const {
if (fIntervalPatterns[i].secondPart != fmt->fIntervalPatterns[i].secondPart ) {return FALSE;}
if (fIntervalPatterns[i].laterDateFirst != fmt->fIntervalPatterns[i].laterDateFirst) {return FALSE;}
}
+ if (fCapitalizationContext != fmt->fCapitalizationContext) {return FALSE;}
return TRUE;
}
@@ -409,6 +414,7 @@ UnicodeString& DateIntervalFormat::formatIntervalImpl(
}
+// The following is only called from within the gFormatterMutex lock
UnicodeString&
DateIntervalFormat::formatImpl(Calendar& fromCalendar,
Calendar& toCalendar,
@@ -464,6 +470,11 @@ DateIntervalFormat::formatImpl(Calendar& fromCalendar,
if ( U_FAILURE(status) ) {
return appendTo;
}
+ UErrorCode tempStatus = U_ZERO_ERROR; // for setContext, ignored
+ // Set up fDateFormat to handle the first or only part of the interval
+ // (override later for any second part). Inside lock, OK to modify fDateFormat.
+ fDateFormat->setContext(fCapitalizationContext, tempStatus);
+
if ( field == UCAL_FIELD_COUNT ) {
/* ignore the millisecond etc. small fields' difference.
* use single date when all the above are the same.
@@ -521,6 +532,9 @@ DateIntervalFormat::formatImpl(Calendar& fromCalendar,
if ( !intervalPattern.secondPart.isEmpty() ) {
fDateFormat->applyPattern(intervalPattern.secondPart);
+ // No capitalization for second part of interval
+ tempStatus = U_ZERO_ERROR;
+ fDateFormat->setContext(UDISPCTX_CAPITALIZATION_NONE, tempStatus);
fDateFormat->_format(*secondCal, appendTo, fphandler, status);
}
fDateFormat->applyPattern(originalPattern);
@@ -583,7 +597,7 @@ DateIntervalFormat::adoptTimeZone(TimeZone* zone)
if (fDateFormat != nullptr) {
fDateFormat->adoptTimeZone(zone);
}
- // The fDateFormat has the master calendar for the DateIntervalFormat and has
+ // The fDateFormat has the primary calendar for the DateIntervalFormat and has
// ownership of any adopted TimeZone; fFromCalendar and fToCalendar are internal
// work clones of that calendar (and should not also be given ownership of the
// adopted TimeZone).
@@ -601,7 +615,7 @@ DateIntervalFormat::setTimeZone(const TimeZone& zone)
if (fDateFormat != nullptr) {
fDateFormat->setTimeZone(zone);
}
- // The fDateFormat has the master calendar for the DateIntervalFormat;
+ // The fDateFormat has the primary calendar for the DateIntervalFormat;
// fFromCalendar and fToCalendar are internal work clones of that calendar.
if (fFromCalendar) {
fFromCalendar->setTimeZone(zone);
@@ -622,6 +636,30 @@ DateIntervalFormat::getTimeZone() const
return *(TimeZone::createDefault());
}
+void
+DateIntervalFormat::setContext(UDisplayContext value, UErrorCode& status)
+{
+ if (U_FAILURE(status))
+ return;
+ if ( (UDisplayContextType)((uint32_t)value >> 8) == UDISPCTX_TYPE_CAPITALIZATION ) {
+ fCapitalizationContext = value;
+ } else {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ }
+}
+
+UDisplayContext
+DateIntervalFormat::getContext(UDisplayContextType type, UErrorCode& status) const
+{
+ if (U_FAILURE(status))
+ return (UDisplayContext)0;
+ if (type != UDISPCTX_TYPE_CAPITALIZATION) {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return (UDisplayContext)0;
+ }
+ return fCapitalizationContext;
+}
+
DateIntervalFormat::DateIntervalFormat(const Locale& locale,
DateIntervalInfo* dtItvInfo,
const UnicodeString* skeleton,
@@ -633,7 +671,8 @@ DateIntervalFormat::DateIntervalFormat(const Locale& locale,
fLocale(locale),
fDatePattern(nullptr),
fTimePattern(nullptr),
- fDateTimeFormat(nullptr)
+ fDateTimeFormat(nullptr),
+ fCapitalizationContext(UDISPCTX_CAPITALIZATION_NONE)
{
LocalPointer<DateIntervalInfo> info(dtItvInfo, status);
LocalPointer<SimpleDateFormat> dtfmt(static_cast<SimpleDateFormat *>(
@@ -751,7 +790,7 @@ DateIntervalFormat::initializePattern(UErrorCode& status) {
/* the difference between time skeleton and normalizedTimeSkeleton are:
* 1. (Formerly, normalized time skeleton folded 'H' to 'h'; no longer true)
- * 2. 'a' is omitted in normalized time skeleton.
+ * 2. (Formerly, 'a' was omitted in normalized time skeleton; this is now handled elsewhere)
* 3. there is only one appearance for 'h' or 'H', 'm','v', 'z' in normalized
* time skeleton
*
@@ -760,7 +799,8 @@ DateIntervalFormat::initializePattern(UErrorCode& status) {
* 2. 'E' and 'EE' are normalized into 'EEE'
* 3. 'MM' is normalized into 'M'
*/
- getDateTimeSkeleton(fSkeleton, dateSkeleton, normalizedDateSkeleton,
+ UnicodeString convertedSkeleton = normalizeHourMetacharacters(fSkeleton);
+ getDateTimeSkeleton(convertedSkeleton, dateSkeleton, normalizedDateSkeleton,
timeSkeleton, normalizedTimeSkeleton);
#ifdef DTITVFMT_DEBUG
@@ -899,6 +939,91 @@ DateIntervalFormat::initializePattern(UErrorCode& status) {
+UnicodeString
+DateIntervalFormat::normalizeHourMetacharacters(const UnicodeString& skeleton) const {
+ UnicodeString result = skeleton;
+
+ UChar hourMetachar = u'\0';
+ int32_t metacharStart = 0;
+ int32_t metacharCount = 0;
+ for (int32_t i = 0; i < result.length(); i++) {
+ UChar c = result[i];
+ if (c == LOW_J || c == CAP_J || c == CAP_C) {
+ if (hourMetachar == u'\0') {
+ hourMetachar = c;
+ metacharStart = i;
+ }
+ ++metacharCount;
+ } else {
+ if (hourMetachar != u'\0') {
+ break;
+ }
+ }
+ }
+
+ if (hourMetachar != u'\0') {
+ UErrorCode err = U_ZERO_ERROR;
+ UChar hourChar = CAP_H;
+ UChar dayPeriodChar = LOW_A;
+ UnicodeString convertedPattern = DateFormat::getBestPattern(fLocale, UnicodeString(hourMetachar), err);
+
+ if (U_SUCCESS(err)) {
+ // strip literal text from the pattern (so literal characters don't get mistaken for pattern
+ // characters-- such as the 'h' in 'Uhr' in Germam)
+ int32_t firstQuotePos;
+ while ((firstQuotePos = convertedPattern.indexOf(u'\'')) != -1) {
+ int32_t secondQuotePos = convertedPattern.indexOf(u'\'', firstQuotePos + 1);
+ if (secondQuotePos == -1) {
+ secondQuotePos = firstQuotePos;
+ }
+ convertedPattern.replace(firstQuotePos, (secondQuotePos - firstQuotePos) + 1, UnicodeString());
+ }
+
+ if (convertedPattern.indexOf(LOW_H) != -1) {
+ hourChar = LOW_H;
+ } else if (convertedPattern.indexOf(CAP_K) != -1) {
+ hourChar = CAP_K;
+ } else if (convertedPattern.indexOf(LOW_K) != -1) {
+ hourChar = LOW_K;
+ }
+
+ if (convertedPattern.indexOf(LOW_B) != -1) {
+ dayPeriodChar = LOW_B;
+ } else if (convertedPattern.indexOf(CAP_B) != -1) {
+ dayPeriodChar = CAP_B;
+ }
+ }
+
+ if (hourChar == CAP_H || hourChar == LOW_K) {
+ result.replace(metacharStart, metacharCount, hourChar);
+ } else {
+ UnicodeString hourAndDayPeriod(hourChar);
+ switch (metacharCount) {
+ case 1:
+ case 2:
+ default:
+ hourAndDayPeriod.append(UnicodeString(dayPeriodChar));
+ break;
+ case 3:
+ case 4:
+ for (int32_t i = 0; i < 4; i++) {
+ hourAndDayPeriod.append(dayPeriodChar);
+ }
+ break;
+ case 5:
+ case 6:
+ for (int32_t i = 0; i < 5; i++) {
+ hourAndDayPeriod.append(dayPeriodChar);
+ }
+ break;
+ }
+ result.replace(metacharStart, metacharCount, hourAndDayPeriod);
+ }
+ }
+ return result;
+}
+
+
void U_EXPORT2
DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton,
UnicodeString& dateSkeleton,
@@ -911,11 +1036,10 @@ DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton,
int32_t dCount = 0;
int32_t MCount = 0;
int32_t yCount = 0;
- int32_t hCount = 0;
- int32_t HCount = 0;
int32_t mCount = 0;
int32_t vCount = 0;
int32_t zCount = 0;
+ UChar hourChar = u'\0';
int32_t i;
for (i = 0; i < skeleton.length(); ++i) {
@@ -956,17 +1080,14 @@ DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton,
normalizedDateSkeleton.append(ch);
dateSkeleton.append(ch);
break;
- case LOW_A:
- // 'a' is implicitly handled
- timeSkeleton.append(ch);
- break;
case LOW_H:
- timeSkeleton.append(ch);
- ++hCount;
- break;
case CAP_H:
+ case LOW_K:
+ case CAP_K:
timeSkeleton.append(ch);
- ++HCount;
+ if (hourChar == u'\0') {
+ hourChar = ch;
+ }
break;
case LOW_M:
timeSkeleton.append(ch);
@@ -980,14 +1101,15 @@ DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton,
++vCount;
timeSkeleton.append(ch);
break;
+ case LOW_A:
case CAP_V:
case CAP_Z:
- case LOW_K:
- case CAP_K:
case LOW_J:
case LOW_S:
case CAP_S:
case CAP_A:
+ case LOW_B:
+ case CAP_B:
timeSkeleton.append(ch);
normalizedTimeSkeleton.append(ch);
break;
@@ -1023,11 +1145,8 @@ DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton,
}
/* generate normalized form for time */
- if ( HCount != 0 ) {
- normalizedTimeSkeleton.append(CAP_H);
- }
- else if ( hCount != 0 ) {
- normalizedTimeSkeleton.append(LOW_H);
+ if ( hourChar != u'\0' ) {
+ normalizedTimeSkeleton.append(hourChar);
}
if ( mCount != 0 ) {
normalizedTimeSkeleton.append(LOW_M);
@@ -1335,10 +1454,11 @@ DateIntervalFormat::setIntervalPattern(UCalendarDateFields field,
}
}
if ( !pattern.isEmpty() ) {
- if ( differenceInfo != 0 ) {
+ UBool suppressDayPeriodField = fSkeleton.indexOf(CAP_J) != -1;
+ if ( differenceInfo != 0 || suppressDayPeriodField) {
UnicodeString adjustIntervalPattern;
adjustFieldWidth(*skeleton, *bestSkeleton, pattern, differenceInfo,
- adjustIntervalPattern);
+ suppressDayPeriodField, adjustIntervalPattern);
setIntervalPattern(field, adjustIntervalPattern);
} else {
setIntervalPattern(field, pattern);
@@ -1425,6 +1545,7 @@ DateIntervalFormat::splitPatternInto2Part(const UnicodeString& intervalPattern)
return (i - count);
}
+// The following is only called from fallbackFormat, i.e. within the gFormatterMutex lock
void DateIntervalFormat::fallbackFormatRange(
Calendar& fromCalendar,
Calendar& toCalendar,
@@ -1441,12 +1562,15 @@ void DateIntervalFormat::fallbackFormatRange(
int32_t offsets[2];
UnicodeString patternBody = sf.getTextWithNoArguments(offsets, 2);
+ UErrorCode tempStatus = U_ZERO_ERROR; // for setContext, ignored
// TODO(ICU-20406): Use SimpleFormatter Iterator interface when available.
if (offsets[0] < offsets[1]) {
firstIndex = 0;
appendTo.append(patternBody.tempSubStringBetween(0, offsets[0]));
fDateFormat->_format(fromCalendar, appendTo, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[0], offsets[1]));
+ // No capitalization for second part of interval
+ fDateFormat->setContext(UDISPCTX_CAPITALIZATION_NONE, tempStatus);
fDateFormat->_format(toCalendar, appendTo, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[1]));
} else {
@@ -1454,11 +1578,14 @@ void DateIntervalFormat::fallbackFormatRange(
appendTo.append(patternBody.tempSubStringBetween(0, offsets[1]));
fDateFormat->_format(toCalendar, appendTo, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[1], offsets[0]));
+ // No capitalization for second part of interval
+ fDateFormat->setContext(UDISPCTX_CAPITALIZATION_NONE, tempStatus);
fDateFormat->_format(fromCalendar, appendTo, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[0]));
}
}
+// The following is only called from formatImpl, i.e. within the gFormatterMutex lock
UnicodeString&
DateIntervalFormat::fallbackFormat(Calendar& fromCalendar,
Calendar& toCalendar,
@@ -1483,6 +1610,7 @@ DateIntervalFormat::fallbackFormat(Calendar& fromCalendar,
UnicodeString fullPattern; // for saving the pattern in fDateFormat
fDateFormat->toPattern(fullPattern); // save current pattern, restore later
+ UErrorCode tempStatus = U_ZERO_ERROR; // for setContext, ignored
// {0} is time range
// {1} is single date portion
// TODO(ICU-20406): Use SimpleFormatter Iterator interface when available.
@@ -1492,6 +1620,8 @@ DateIntervalFormat::fallbackFormat(Calendar& fromCalendar,
fallbackFormatRange(fromCalendar, toCalendar, appendTo, firstIndex, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[0], offsets[1]));
fDateFormat->applyPattern(*fDatePattern);
+ // No capitalization for second portion
+ fDateFormat->setContext(UDISPCTX_CAPITALIZATION_NONE, tempStatus);
fDateFormat->_format(fromCalendar, appendTo, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[1]));
} else {
@@ -1500,6 +1630,8 @@ DateIntervalFormat::fallbackFormat(Calendar& fromCalendar,
fDateFormat->_format(fromCalendar, appendTo, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[1], offsets[0]));
fDateFormat->applyPattern(*fTimePattern);
+ // No capitalization for second portion
+ fDateFormat->setContext(UDISPCTX_CAPITALIZATION_NONE, tempStatus);
fallbackFormatRange(fromCalendar, toCalendar, appendTo, firstIndex, fphandler, status);
appendTo.append(patternBody.tempSubStringBetween(offsets[0]));
}
@@ -1530,6 +1662,7 @@ DateIntervalFormat::adjustFieldWidth(const UnicodeString& inputSkeleton,
const UnicodeString& bestMatchSkeleton,
const UnicodeString& bestIntervalPattern,
int8_t differenceInfo,
+ UBool suppressDayPeriodField,
UnicodeString& adjustedPtn) {
adjustedPtn = bestIntervalPattern;
int32_t inputSkeletonFieldWidth[] =
@@ -1556,19 +1689,44 @@ DateIntervalFormat::adjustFieldWidth(const UnicodeString& inputSkeleton,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
+ const int8_t PATTERN_CHAR_BASE = 0x41;
+
DateIntervalInfo::parseSkeleton(inputSkeleton, inputSkeletonFieldWidth);
DateIntervalInfo::parseSkeleton(bestMatchSkeleton, bestMatchSkeletonFieldWidth);
+ if (suppressDayPeriodField) {
+ adjustedPtn.findAndReplace(UnicodeString(LOW_A), UnicodeString());
+ adjustedPtn.findAndReplace(UnicodeString(" "), UnicodeString(" "));
+ adjustedPtn.trim();
+ }
if ( differenceInfo == 2 ) {
- adjustedPtn.findAndReplace(UnicodeString((UChar)0x76 /* v */),
- UnicodeString((UChar)0x7a /* z */));
+ if (inputSkeleton.indexOf(LOW_Z) != -1) {
+ adjustedPtn.findAndReplace(UnicodeString(LOW_V),
+ UnicodeString(LOW_Z));
+ }
+ if (inputSkeleton.indexOf(CAP_K) != -1) {
+ adjustedPtn.findAndReplace(UnicodeString(LOW_H),
+ UnicodeString(CAP_K));
+ }
+ if (inputSkeleton.indexOf(LOW_K) != -1) {
+ adjustedPtn.findAndReplace(UnicodeString(CAP_H),
+ UnicodeString(LOW_K));
+ }
+ if (inputSkeleton.indexOf(LOW_B) != -1) {
+ adjustedPtn.findAndReplace(UnicodeString(LOW_A),
+ UnicodeString(LOW_B));
+ }
}
+ if (adjustedPtn.indexOf(LOW_A) != -1 && bestMatchSkeletonFieldWidth[LOW_A - PATTERN_CHAR_BASE] == 0) {
+ bestMatchSkeletonFieldWidth[LOW_A - PATTERN_CHAR_BASE] = 1;
+ }
+ if (adjustedPtn.indexOf(LOW_B) != -1 && bestMatchSkeletonFieldWidth[LOW_B - PATTERN_CHAR_BASE] == 0) {
+ bestMatchSkeletonFieldWidth[LOW_B - PATTERN_CHAR_BASE] = 1;
+ }
UBool inQuote = false;
UChar prevCh = 0;
int32_t count = 0;
- const int8_t PATTERN_CHAR_BASE = 0x41;
-
// loop through the pattern string character by character
int32_t adjustedPtnLength = adjustedPtn.length();
int32_t i;
diff --git a/deps/icu-small/source/i18n/dtitvinf.cpp b/deps/icu-small/source/i18n/dtitvinf.cpp
index 25536346ec..39fd44a392 100644
--- a/deps/icu-small/source/i18n/dtitvinf.cpp
+++ b/deps/icu-small/source/i18n/dtitvinf.cpp
@@ -339,6 +339,9 @@ struct DateIntervalInfo::DateIntervalSink : public ResourceSink {
return UCAL_DATE;
} else if (c0 == 'a') {
return UCAL_AM_PM;
+ } else if (c0 == 'B') {
+ // TODO: Using AM/PM as a proxy for flexible day period isn't really correct, but it's close
+ return UCAL_AM_PM;
} else if (c0 == 'h' || c0 == 'H') {
return UCAL_HOUR;
} else if (c0 == 'm') {
@@ -594,20 +597,23 @@ DateIntervalInfo::getBestSkeleton(const UnicodeString& skeleton,
const int32_t DIFFERENT_FIELD = 0x1000;
const int32_t STRING_NUMERIC_DIFFERENCE = 0x100;
const int32_t BASE = 0x41;
- const UChar CHAR_V = 0x0076;
- const UChar CHAR_Z = 0x007A;
- // hack for 'v' and 'z'.
- // resource bundle only have time skeletons ending with 'v',
- // but not for time skeletons ending with 'z'.
- UBool replaceZWithV = false;
+ // hack for certain alternate characters
+ // resource bundles only have time skeletons containing 'v', 'h', and 'H'
+ // but not time skeletons containing 'z', 'K', or 'k'
+ // the skeleton may also include 'a' or 'b', which never occur in the resource bundles, so strip them out too
+ UBool replacedAlternateChars = false;
const UnicodeString* inputSkeleton = &skeleton;
UnicodeString copySkeleton;
- if ( skeleton.indexOf(CHAR_Z) != -1 ) {
+ if ( skeleton.indexOf(LOW_Z) != -1 || skeleton.indexOf(LOW_K) != -1 || skeleton.indexOf(CAP_K) != -1 || skeleton.indexOf(LOW_A) != -1 || skeleton.indexOf(LOW_B) != -1 ) {
copySkeleton = skeleton;
- copySkeleton.findAndReplace(UnicodeString(CHAR_Z), UnicodeString(CHAR_V));
+ copySkeleton.findAndReplace(UnicodeString(LOW_Z), UnicodeString(LOW_V));
+ copySkeleton.findAndReplace(UnicodeString(LOW_K), UnicodeString(CAP_H));
+ copySkeleton.findAndReplace(UnicodeString(CAP_K), UnicodeString(LOW_H));
+ copySkeleton.findAndReplace(UnicodeString(LOW_A), UnicodeString());
+ copySkeleton.findAndReplace(UnicodeString(LOW_B), UnicodeString());
inputSkeleton = &copySkeleton;
- replaceZWithV = true;
+ replacedAlternateChars = true;
}
parseSkeleton(*inputSkeleton, inputSkeletonFieldWidth);
@@ -616,7 +622,7 @@ DateIntervalInfo::getBestSkeleton(const UnicodeString& skeleton,
// 0 means exact the same skeletons;
// 1 means having the same field, but with different length,
- // 2 means only z/v differs
+ // 2 means only z/v, h/K, or H/k differs
// -1 means having different field.
bestMatchDistanceInfo = 0;
int8_t fieldLength = UPRV_LENGTHOF(skeletonFieldWidth);
@@ -672,7 +678,7 @@ DateIntervalInfo::getBestSkeleton(const UnicodeString& skeleton,
break;
}
}
- if ( replaceZWithV && bestMatchDistanceInfo != -1 ) {
+ if ( replacedAlternateChars && bestMatchDistanceInfo != -1 ) {
bestMatchDistanceInfo = 2;
}
return bestSkeleton;
diff --git a/deps/icu-small/source/i18n/dtptngen.cpp b/deps/icu-small/source/i18n/dtptngen.cpp
index 279fb49a7a..78273ef01e 100644
--- a/deps/icu-small/source/i18n/dtptngen.cpp
+++ b/deps/icu-small/source/i18n/dtptngen.cpp
@@ -311,6 +311,16 @@ DateTimePatternGenerator::createInstance(const Locale& locale, UErrorCode& statu
return U_SUCCESS(status) ? result.orphan() : nullptr;
}
+DateTimePatternGenerator* U_EXPORT2
+DateTimePatternGenerator::createInstanceNoStdPat(const Locale& locale, UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
+ LocalPointer<DateTimePatternGenerator> result(
+ new DateTimePatternGenerator(locale, status, true), status);
+ return U_SUCCESS(status) ? result.orphan() : nullptr;
+}
+
DateTimePatternGenerator* U_EXPORT2
DateTimePatternGenerator::createEmptyInstance(UErrorCode& status) {
if (U_FAILURE(status)) {
@@ -336,7 +346,7 @@ DateTimePatternGenerator::DateTimePatternGenerator(UErrorCode &status) :
}
}
-DateTimePatternGenerator::DateTimePatternGenerator(const Locale& locale, UErrorCode &status) :
+DateTimePatternGenerator::DateTimePatternGenerator(const Locale& locale, UErrorCode &status, UBool skipStdPatterns) :
skipMatcher(nullptr),
fAvailableFormatKeyHash(nullptr),
fDefaultHourFormatChar(0),
@@ -350,7 +360,7 @@ DateTimePatternGenerator::DateTimePatternGenerator(const Locale& locale, UErrorC
internalErrorCode = status = U_MEMORY_ALLOCATION_ERROR;
}
else {
- initData(locale, status);
+ initData(locale, status, skipStdPatterns);
}
}
@@ -489,13 +499,15 @@ enum AllowedHourFormat{
} // namespace
void
-DateTimePatternGenerator::initData(const Locale& locale, UErrorCode &status) {
+DateTimePatternGenerator::initData(const Locale& locale, UErrorCode &status, UBool skipStdPatterns) {
//const char *baseLangName = locale.getBaseName(); // unused
skipMatcher = nullptr;
fAvailableFormatKeyHash=nullptr;
addCanonicalItems(status);
- addICUPatterns(locale, status);
+ if (!skipStdPatterns) { // skip to prevent circular dependency when called from SimpleDateFormat::construct
+ addICUPatterns(locale, status);
+ }
addCLDRData(locale, status);
setDateTimeFromCalendar(locale, status);
setDecimalSymbols(locale, status);
@@ -893,7 +905,7 @@ DateTimePatternGenerator::getCalendarTypeToUse(const Locale& locale, CharString&
err = localStatus;
return;
}
- if (calendarTypeLen < ULOC_KEYWORDS_CAPACITY) {
+ if (calendarTypeLen > 0 && calendarTypeLen < ULOC_KEYWORDS_CAPACITY) {
destination.clear().append(calendarType, -1, err);
if (U_FAILURE(err)) { return; }
}
diff --git a/deps/icu-small/source/i18n/dtptngen_impl.h b/deps/icu-small/source/i18n/dtptngen_impl.h
index ade9f57331..9b9442d578 100644
--- a/deps/icu-small/source/i18n/dtptngen_impl.h
+++ b/deps/icu-small/source/i18n/dtptngen_impl.h
@@ -195,7 +195,7 @@ public:
void getQuoteLiteral(UnicodeString& quote, int32_t *itemIndex);
UBool isPatternSeparator(const UnicodeString& field) const;
static UBool isQuoteLiteral(const UnicodeString& s);
- static int32_t getCanonicalIndex(const UnicodeString& s) { return getCanonicalIndex(s, TRUE); }
+ static int32_t getCanonicalIndex(const UnicodeString& s) { return getCanonicalIndex(s, true); }
static int32_t getCanonicalIndex(const UnicodeString& s, UBool strict);
private:
diff --git a/deps/icu-small/source/i18n/fmtable.cpp b/deps/icu-small/source/i18n/fmtable.cpp
index 10a6fdb0ff..44c3087fb9 100644
--- a/deps/icu-small/source/i18n/fmtable.cpp
+++ b/deps/icu-small/source/i18n/fmtable.cpp
@@ -895,7 +895,7 @@ U_NAMESPACE_END
U_NAMESPACE_USE
-U_DRAFT UFormattable* U_EXPORT2
+U_CAPI UFormattable* U_EXPORT2
ufmt_open(UErrorCode *status) {
if( U_FAILURE(*status) ) {
return NULL;
@@ -908,14 +908,14 @@ ufmt_open(UErrorCode *status) {
return fmt;
}
-U_DRAFT void U_EXPORT2
+U_CAPI void U_EXPORT2
ufmt_close(UFormattable *fmt) {
Formattable *obj = Formattable::fromUFormattable(fmt);
delete obj;
}
-U_INTERNAL UFormattableType U_EXPORT2
+U_CAPI UFormattableType U_EXPORT2
ufmt_getType(const UFormattable *fmt, UErrorCode *status) {
if(U_FAILURE(*status)) {
return (UFormattableType)UFMT_COUNT;
@@ -925,27 +925,27 @@ ufmt_getType(const UFormattable *fmt, UErrorCode *status) {
}
-U_INTERNAL UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ufmt_isNumeric(const UFormattable *fmt) {
const Formattable *obj = Formattable::fromUFormattable(fmt);
return obj->isNumeric();
}
-U_DRAFT UDate U_EXPORT2
+U_CAPI UDate U_EXPORT2
ufmt_getDate(const UFormattable *fmt, UErrorCode *status) {
const Formattable *obj = Formattable::fromUFormattable(fmt);
return obj->getDate(*status);
}
-U_DRAFT double U_EXPORT2
+U_CAPI double U_EXPORT2
ufmt_getDouble(UFormattable *fmt, UErrorCode *status) {
Formattable *obj = Formattable::fromUFormattable(fmt);
return obj->getDouble(*status);
}
-U_DRAFT int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ufmt_getLong(UFormattable *fmt, UErrorCode *status) {
Formattable *obj = Formattable::fromUFormattable(fmt);
@@ -953,7 +953,7 @@ ufmt_getLong(UFormattable *fmt, UErrorCode *status) {
}
-U_DRAFT const void *U_EXPORT2
+U_CAPI const void *U_EXPORT2
ufmt_getObject(const UFormattable *fmt, UErrorCode *status) {
const Formattable *obj = Formattable::fromUFormattable(fmt);
@@ -966,7 +966,7 @@ ufmt_getObject(const UFormattable *fmt, UErrorCode *status) {
return ret;
}
-U_DRAFT const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ufmt_getUChars(UFormattable *fmt, int32_t *len, UErrorCode *status) {
Formattable *obj = Formattable::fromUFormattable(fmt);
@@ -986,7 +986,7 @@ ufmt_getUChars(UFormattable *fmt, int32_t *len, UErrorCode *status) {
return str.getTerminatedBuffer();
}
-U_DRAFT int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ufmt_getArrayLength(const UFormattable* fmt, UErrorCode *status) {
const Formattable *obj = Formattable::fromUFormattable(fmt);
@@ -995,7 +995,7 @@ ufmt_getArrayLength(const UFormattable* fmt, UErrorCode *status) {
return count;
}
-U_DRAFT UFormattable * U_EXPORT2
+U_CAPI UFormattable * U_EXPORT2
ufmt_getArrayItemByIndex(UFormattable* fmt, int32_t n, UErrorCode *status) {
Formattable *obj = Formattable::fromUFormattable(fmt);
int32_t count;
@@ -1010,7 +1010,7 @@ ufmt_getArrayItemByIndex(UFormattable* fmt, int32_t n, UErrorCode *status) {
}
}
-U_DRAFT const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ufmt_getDecNumChars(UFormattable *fmt, int32_t *len, UErrorCode *status) {
if(U_FAILURE(*status)) {
return "";
@@ -1031,7 +1031,7 @@ ufmt_getDecNumChars(UFormattable *fmt, int32_t *len, UErrorCode *status) {
}
}
-U_DRAFT int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
ufmt_getInt64(UFormattable *fmt, UErrorCode *status) {
Formattable *obj = Formattable::fromUFormattable(fmt);
return obj->getInt64(*status);
diff --git a/deps/icu-small/source/i18n/fmtable_cnv.cpp b/deps/icu-small/source/i18n/fmtable_cnv.cpp
index 9a64792779..bc3847b696 100644
--- a/deps/icu-small/source/i18n/fmtable_cnv.cpp
+++ b/deps/icu-small/source/i18n/fmtable_cnv.cpp
@@ -30,8 +30,6 @@ U_NAMESPACE_BEGIN
// -------------------------------------
// Creates a formattable object with a char* string.
// This API is useless. The API that takes a UnicodeString is actually just as good.
-// This is just a grandfathered API.
-
Formattable::Formattable(const char* stringToCopy)
{
init();
diff --git a/deps/icu-small/source/i18n/format.cpp b/deps/icu-small/source/i18n/format.cpp
index e5abbe9eb0..a010defff9 100644
--- a/deps/icu-small/source/i18n/format.cpp
+++ b/deps/icu-small/source/i18n/format.cpp
@@ -26,7 +26,7 @@
#include "unicode/utypes.h"
#ifndef U_I18N_IMPLEMENTATION
-#error U_I18N_IMPLEMENTATION not set - must be set for all ICU source files in i18n/ - see http://userguide.icu-project.org/howtouseicu
+#error U_I18N_IMPLEMENTATION not set - must be set for all ICU source files in i18n/ - see https://unicode-org.github.io/icu/userguide/howtouseicu
#endif
/*
diff --git a/deps/icu-small/source/i18n/formatted_string_builder.h b/deps/icu-small/source/i18n/formatted_string_builder.h
index 4567dc1d66..92bcf07d78 100644
--- a/deps/icu-small/source/i18n/formatted_string_builder.h
+++ b/deps/icu-small/source/i18n/formatted_string_builder.h
@@ -25,7 +25,7 @@ class FormattedValueStringBuilderImpl;
*
* <ol>
* <li>Efficient prepend as well as append.
- * <li>Keeps tracks of Fields in an efficient manner.
+ * <li>Keeps track of Fields in an efficient manner.
* </ol>
*
* See also FormattedValueStringBuilderImpl.
@@ -55,7 +55,6 @@ class U_I18N_API FormattedStringBuilder : public UMemory {
// Convention: bottom 4 bits for field, top 4 bits for field category.
// Field category 0 implies the number category so that the number field
// literals can be directly passed as a Field type.
- // See the helper functions in "StringBuilderFieldUtils" below.
// Exported as U_I18N_API so it can be used by other exports on Windows.
struct U_I18N_API Field {
uint8_t bits;
diff --git a/deps/icu-small/source/i18n/formattedval_impl.h b/deps/icu-small/source/i18n/formattedval_impl.h
index 73ae9a3ea2..8005b0abb4 100644
--- a/deps/icu-small/source/i18n/formattedval_impl.h
+++ b/deps/icu-small/source/i18n/formattedval_impl.h
@@ -69,6 +69,9 @@ U_NAMESPACE_BEGIN
/**
* Implementation of FormattedValue using FieldPositionHandler to accept fields.
+ *
+ * TODO(ICU-20897): This class is unused. If it is not needed when fixing ICU-20897,
+ * it should be deleted.
*/
class FormattedValueFieldPositionIteratorImpl : public UMemory, public FormattedValue {
public:
@@ -114,6 +117,18 @@ private:
};
+// Export an explicit template instantiation of the MaybeStackArray that
+// is used as a data member of CEBuffer.
+//
+// When building DLLs for Windows this is required even though
+// no direct access to the MaybeStackArray leaks out of the i18n library.
+//
+// See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples.
+//
+#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
+template class U_I18N_API MaybeStackArray<int32_t, 8>;
+#endif
+
/**
* Implementation of FormattedValue based on FormattedStringBuilder.
*
@@ -147,12 +162,17 @@ public:
return fString;
}
+ void appendSpanIndex(int32_t index);
+ void prependSpanIndex(int32_t index);
+
private:
FormattedStringBuilder fString;
FormattedStringBuilder::Field fNumericField;
+ MaybeStackArray<int32_t, 8> spanIndices;
bool nextPositionImpl(ConstrainedFieldPosition& cfpos, FormattedStringBuilder::Field numericField, UErrorCode& status) const;
static bool isIntOrGroup(FormattedStringBuilder::Field field);
+ static bool isTrimmable(FormattedStringBuilder::Field field);
int32_t trimBack(int32_t limit) const;
int32_t trimFront(int32_t start) const;
};
@@ -211,7 +231,7 @@ struct UFormattedValueImpl : public UMemory, public UFormattedValueApiHelper {
return fData->appendTo(appendable, status); \
} \
UBool Name::nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const { \
- UPRV_FORMATTED_VALUE_METHOD_GUARD(FALSE) \
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(false) \
return fData->nextPosition(cfpos, status); \
}
@@ -230,7 +250,7 @@ struct UFormattedValueImpl : public UMemory, public UFormattedValueApiHelper {
} \
return static_cast<HelperType*>(impl)->exportForC(); \
} \
- U_DRAFT const UFormattedValue* U_EXPORT2 \
+ U_CAPI const UFormattedValue* U_EXPORT2 \
Prefix ## _resultAsValue (const CType* uresult, UErrorCode* ec) { \
const ImplType* result = HelperType::validate(uresult, *ec); \
if (U_FAILURE(*ec)) { return nullptr; } \
diff --git a/deps/icu-small/source/i18n/formattedval_sbimpl.cpp b/deps/icu-small/source/i18n/formattedval_sbimpl.cpp
index dfe3af6686..b2ae4c34c0 100644
--- a/deps/icu-small/source/i18n/formattedval_sbimpl.cpp
+++ b/deps/icu-small/source/i18n/formattedval_sbimpl.cpp
@@ -15,6 +15,7 @@
#include "formatted_string_builder.h"
#include "number_utils.h"
#include "static_unicode_sets.h"
+#include "unicode/listformatter.h"
U_NAMESPACE_BEGIN
@@ -102,14 +103,25 @@ static constexpr Field kEndField = Field(0xf, 0xf);
bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition& cfpos, Field numericField, UErrorCode& /*status*/) const {
int32_t fieldStart = -1;
Field currField = kUndefinedField;
+ UFieldCategory spanCategory = UFIELD_CATEGORY_UNDEFINED;
+ int32_t spanValue;
for (int32_t i = fString.fZero + cfpos.getLimit(); i <= fString.fZero + fString.fLength; i++) {
Field _field = (i < fString.fZero + fString.fLength) ? fString.getFieldPtr()[i] : kEndField;
// Case 1: currently scanning a field.
if (currField != kUndefinedField) {
if (currField != _field) {
int32_t end = i - fString.fZero;
+ // Handle span fields; don't trim them
+ if (spanCategory != UFIELD_CATEGORY_UNDEFINED) {
+ cfpos.setState(
+ spanCategory,
+ spanValue,
+ fieldStart,
+ end);
+ return true;
+ }
// Grouping separators can be whitespace; don't throw them out!
- if (currField != Field(UFIELD_CATEGORY_NUMBER, UNUM_GROUPING_SEPARATOR_FIELD)) {
+ if (isTrimmable(currField)) {
end = trimBack(i - fString.fZero);
}
if (end <= fieldStart) {
@@ -120,7 +132,7 @@ bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition&
continue;
}
int32_t start = fieldStart;
- if (currField != Field(UFIELD_CATEGORY_NUMBER, UNUM_GROUPING_SEPARATOR_FIELD)) {
+ if (isTrimmable(currField)) {
start = trimFront(start);
}
cfpos.setState(currField.getCategory(), currField.getField(), start, end);
@@ -154,7 +166,8 @@ bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition&
|| cfpos.getField() != numericField.getField())
&& fString.getFieldPtr()[i - 1].isNumeric()
&& !_field.isNumeric()) {
- int j = i - 1;
+ // Re-wind to the beginning of the field and then emit it
+ int32_t j = i - 1;
for (; j >= fString.fZero && fString.getFieldPtr()[j].isNumeric(); j--) {}
cfpos.setState(
numericField.getCategory(),
@@ -163,6 +176,23 @@ bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition&
i - fString.fZero);
return true;
}
+ // Special case: emit normalField if we are pointing at the end of spanField.
+ if (i > fString.fZero) {
+ auto elementField = fString.getFieldPtr()[i-1];
+ if (elementField == Field(UFIELD_CATEGORY_LIST, ULISTFMT_ELEMENT_FIELD)
+ && cfpos.matchesField(elementField.getCategory(), elementField.getField())
+ && (cfpos.getLimit() < i - fString.fZero || cfpos.getCategory() != elementField.getCategory())) {
+ // Re-wind to the beginning of the field and then emit it
+ int32_t j = i - 1;
+ for (; j >= fString.fZero && fString.getFieldPtr()[j] == fString.getFieldPtr()[i-1]; j--) {}
+ cfpos.setState(
+ elementField.getCategory(),
+ elementField.getField(),
+ j - fString.fZero + 1,
+ i - fString.fZero);
+ return true;
+ }
+ }
// Special case: skip over INTEGER; will be coalesced later.
if (_field == Field(UFIELD_CATEGORY_NUMBER, UNUM_INTEGER_FIELD)) {
_field = kUndefinedField;
@@ -172,6 +202,23 @@ bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition&
continue;
}
// Case 3: check for field starting at this position
+ // Case 3a: Need to add a SpanField
+ if (_field == Field(UFIELD_CATEGORY_LIST, ULISTFMT_ELEMENT_FIELD)
+ // don't return the same field twice in a row:
+ && (i == fString.fZero
+ || fString.getFieldPtr()[i-1].getCategory() != UFIELD_CATEGORY_LIST
+ || fString.getFieldPtr()[i-1].getField() != ULISTFMT_ELEMENT_FIELD)) {
+ int64_t si = cfpos.getInt64IterationContext();
+ spanValue = spanIndices[si];
+ cfpos.setInt64IterationContext(si + 1);
+ if (cfpos.matchesField(UFIELD_CATEGORY_LIST_SPAN, spanValue)) {
+ spanCategory = UFIELD_CATEGORY_LIST_SPAN;
+ fieldStart = i - fString.fZero;
+ currField = _field;
+ continue;
+ }
+ }
+ // Case 3b: No SpanField or SpanField did not match
if (cfpos.matchesField(_field.getCategory(), _field.getField())) {
fieldStart = i - fString.fZero;
currField = _field;
@@ -182,11 +229,33 @@ bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition&
return false;
}
+void FormattedValueStringBuilderImpl::appendSpanIndex(int32_t position) {
+ if (spanIndices.getCapacity() <= position) {
+ spanIndices.resize(position * 2);
+ }
+ spanIndices[position] = position;
+}
+
+void FormattedValueStringBuilderImpl::prependSpanIndex(int32_t position) {
+ if (spanIndices.getCapacity() <= position) {
+ spanIndices.resize(position * 2);
+ }
+ for (int32_t i = 0; i < position; i++) {
+ spanIndices[i+1] = spanIndices[i];
+ }
+ spanIndices[0] = position;
+}
+
bool FormattedValueStringBuilderImpl::isIntOrGroup(Field field) {
return field == Field(UFIELD_CATEGORY_NUMBER, UNUM_INTEGER_FIELD)
|| field == Field(UFIELD_CATEGORY_NUMBER, UNUM_GROUPING_SEPARATOR_FIELD);
}
+bool FormattedValueStringBuilderImpl::isTrimmable(Field field) {
+ return field != Field(UFIELD_CATEGORY_NUMBER, UNUM_GROUPING_SEPARATOR_FIELD)
+ && field.getCategory() != UFIELD_CATEGORY_LIST;
+}
+
int32_t FormattedValueStringBuilderImpl::trimBack(int32_t limit) const {
return unisets::get(unisets::DEFAULT_IGNORABLES)->spanBack(
fString.getCharPtr() + fString.fZero,
diff --git a/deps/icu-small/source/i18n/formattedvalue.cpp b/deps/icu-small/source/i18n/formattedvalue.cpp
index e2c9c42fc8..79ecf0a841 100644
--- a/deps/icu-small/source/i18n/formattedvalue.cpp
+++ b/deps/icu-small/source/i18n/formattedvalue.cpp
@@ -193,7 +193,7 @@ ucfpos_close(UConstrainedFieldPosition* ptr) {
}
-U_DRAFT const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ufmtval_getString(
const UFormattedValue* ufmtval,
int32_t* pLength,
@@ -213,7 +213,7 @@ ufmtval_getString(
}
-U_DRAFT UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ufmtval_nextPosition(
const UFormattedValue* ufmtval,
UConstrainedFieldPosition* ucfpos,
diff --git a/deps/icu-small/source/i18n/fphdlimp.h b/deps/icu-small/source/i18n/fphdlimp.h
index b9fa9b2181..4fb0c7b6fe 100644
--- a/deps/icu-small/source/i18n/fphdlimp.h
+++ b/deps/icu-small/source/i18n/fphdlimp.h
@@ -41,8 +41,8 @@ class U_I18N_API FieldPositionHandler: public UMemory {
class FieldPositionOnlyHandler : public FieldPositionHandler {
FieldPosition& pos;
- UBool acceptFirstOnly = FALSE;
- UBool seenFirst = FALSE;
+ UBool acceptFirstOnly = false;
+ UBool seenFirst = false;
public:
FieldPositionOnlyHandler(FieldPosition& pos);
diff --git a/deps/icu-small/source/i18n/gregocal.cpp b/deps/icu-small/source/i18n/gregocal.cpp
index 028ab05aa9..38a20dd93f 100644
--- a/deps/icu-small/source/i18n/gregocal.cpp
+++ b/deps/icu-small/source/i18n/gregocal.cpp
@@ -185,7 +185,7 @@ fIsGregorian(TRUE), fInvertGregorian(FALSE)
// -------------------------------------
GregorianCalendar::GregorianCalendar(const Locale& aLocale, UErrorCode& status)
-: Calendar(TimeZone::createDefault(), aLocale, status),
+: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, status),
fGregorianCutover(kPapalCutover),
fCutoverJulianDay(kCutoverJulianDay), fNormalizedGregorianCutover(fGregorianCutover), fGregorianCutoverYear(1582),
fIsGregorian(TRUE), fInvertGregorian(FALSE)
diff --git a/deps/icu-small/source/i18n/gregoimp.h b/deps/icu-small/source/i18n/gregoimp.h
index eb3844f852..edcae9dbcc 100644
--- a/deps/icu-small/source/i18n/gregoimp.h
+++ b/deps/icu-small/source/i18n/gregoimp.h
@@ -148,9 +148,9 @@ class ClockMath {
class Grego {
public:
/**
- * Return TRUE if the given year is a leap year.
+ * Return true if the given year is a leap year.
* @param year Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
- * @return TRUE if the year is a leap year
+ * @return true if the year is a leap year
*/
static inline UBool isLeapYear(int32_t year);
diff --git a/deps/icu-small/source/i18n/hebrwcal.cpp b/deps/icu-small/source/i18n/hebrwcal.cpp
index 085ded7846..98cbb4a105 100644
--- a/deps/icu-small/source/i18n/hebrwcal.cpp
+++ b/deps/icu-small/source/i18n/hebrwcal.cpp
@@ -155,7 +155,7 @@ U_NAMESPACE_BEGIN
* @internal
*/
HebrewCalendar::HebrewCalendar(const Locale& aLocale, UErrorCode& success)
-: Calendar(TimeZone::createDefault(), aLocale, success)
+: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success)
{
setTimeInMillis(getNow(), success); // Call this again now that the vtable is set up properly.
@@ -393,7 +393,8 @@ int32_t HebrewCalendar::startOfYear(int32_t year, UErrorCode &status)
int32_t day = CalendarCache::get(&gCache, year, status);
if (day == 0) {
- int32_t months = (235 * year - 234) / 19; // # of months before year
+ // # of months before year
+ int32_t months = (int32_t)ClockMath::floorDivide((235 * (int64_t)year - 234), (int64_t)19);
int64_t frac = (int64_t)months * MONTH_FRACT + BAHARAD; // Fractional part of day #
day = months * 29 + (int32_t)(frac / DAY_PARTS); // Whole # part of calculation
@@ -566,8 +567,8 @@ void HebrewCalendar::validateField(UCalendarDateFields field, UErrorCode &status
*/
void HebrewCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) {
int32_t d = julianDay - 347997;
- double m = ((d * (double)DAY_PARTS)/ (double) MONTH_PARTS); // Months (approx)
- int32_t year = (int32_t)( ((19. * m + 234.) / 235.) + 1.); // Years (approx)
+ double m = ClockMath::floorDivide((d * (double)DAY_PARTS), (double) MONTH_PARTS); // Months (approx)
+ int32_t year = (int32_t)(ClockMath::floorDivide((19. * m + 234.), 235.) + 1.); // Years (approx)
int32_t ys = startOfYear(year, status); // 1st day of year
int32_t dayOfYear = (d - ys);
diff --git a/deps/icu-small/source/i18n/hebrwcal.h b/deps/icu-small/source/i18n/hebrwcal.h
index 97e8511705..34450ffa61 100644
--- a/deps/icu-small/source/i18n/hebrwcal.h
+++ b/deps/icu-small/source/i18n/hebrwcal.h
@@ -386,7 +386,7 @@ public:
virtual UBool inDaylightTime(UErrorCode& status) const;
/**
- * Returns TRUE because the Hebrew Calendar does have a default century
+ * Returns true because the Hebrew Calendar does have a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/indiancal.cpp b/deps/icu-small/source/i18n/indiancal.cpp
index f1266bb775..42a91c55e2 100644
--- a/deps/icu-small/source/i18n/indiancal.cpp
+++ b/deps/icu-small/source/i18n/indiancal.cpp
@@ -40,7 +40,7 @@ IndianCalendar* IndianCalendar::clone() const {
}
IndianCalendar::IndianCalendar(const Locale& aLocale, UErrorCode& success)
- : Calendar(TimeZone::createDefault(), aLocale, success)
+ : Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success)
{
setTimeInMillis(getNow(), success); // Call this again now that the vtable is set up properly.
}
@@ -83,7 +83,6 @@ static const int32_t LIMITS[UCAL_FIELD_COUNT][4] = {
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // IS_LEAP_MONTH
};
-static const double JULIAN_EPOCH = 1721425.5;
static const int32_t INDIAN_ERA_START = 78;
static const int32_t INDIAN_YEAR_START = 80;
@@ -96,7 +95,7 @@ int32_t IndianCalendar::handleGetLimit(UCalendarDateFields field, ELimitType lim
*/
static UBool isGregorianLeap(int32_t year)
{
- return ((year % 4) == 0) && (!(((year % 100) == 0) && ((year % 400) != 0)));
+ return Grego::isLeapYear(year);
}
//----------------------------------------------------------------------
@@ -137,56 +136,22 @@ int32_t IndianCalendar::handleGetYearLength(int32_t eyear) const {
* Returns the Julian Day corresponding to gregorian date
*
* @param year The Gregorian year
- * @param month The month in Gregorian Year
+ * @param month The month in Gregorian Year, 0 based.
* @param date The date in Gregorian day in month
*/
static double gregorianToJD(int32_t year, int32_t month, int32_t date) {
- double julianDay = (JULIAN_EPOCH - 1) +
- (365 * (year - 1)) +
- uprv_floor((year - 1) / 4) +
- (-uprv_floor((year - 1) / 100)) +
- uprv_floor((year - 1) / 400) +
- uprv_floor((((367 * month) - 362) / 12) +
- ((month <= 2) ? 0 :
- (isGregorianLeap(year) ? -1 : -2)
- ) +
- date);
-
- return julianDay;
+ return Grego::fieldsToDay(year, month, date) + kEpochStartAsJulianDay - 0.5;
}
/*
* Returns the Gregorian Date corresponding to a given Julian Day
+ * Month is 0 based.
* @param jd The Julian Day
*/
static int32_t* jdToGregorian(double jd, int32_t gregorianDate[3]) {
- double wjd, depoch, quadricent, dqc, cent, dcent, quad, dquad, yindex, yearday, leapadj;
- int32_t year, month, day;
- wjd = uprv_floor(jd - 0.5) + 0.5;
- depoch = wjd - JULIAN_EPOCH;
- quadricent = uprv_floor(depoch / 146097);
- dqc = (int32_t)uprv_floor(depoch) % 146097;
- cent = uprv_floor(dqc / 36524);
- dcent = (int32_t)uprv_floor(dqc) % 36524;
- quad = uprv_floor(dcent / 1461);
- dquad = (int32_t)uprv_floor(dcent) % 1461;
- yindex = uprv_floor(dquad / 365);
- year = (int32_t)((quadricent * 400) + (cent * 100) + (quad * 4) + yindex);
- if (!((cent == 4) || (yindex == 4))) {
- year++;
- }
- yearday = wjd - gregorianToJD(year, 1, 1);
- leapadj = ((wjd < gregorianToJD(year, 3, 1)) ? 0
- :
- (isGregorianLeap(year) ? 1 : 2)
- );
- month = (int32_t)uprv_floor((((yearday + leapadj) * 12) + 373) / 367);
- day = (int32_t)(wjd - gregorianToJD(year, month, 1)) + 1;
-
- gregorianDate[0] = year;
- gregorianDate[1] = month;
- gregorianDate[2] = day;
-
+ int32_t gdow;
+ Grego::dayToFields(jd - kEpochStartAsJulianDay,
+ gregorianDate[0], gregorianDate[1], gregorianDate[2], gdow);
return gregorianDate;
}
@@ -203,11 +168,11 @@ static double IndianToJD(int32_t year, int32_t month, int32_t date) {
if(isGregorianLeap(gyear)) {
leapMonth = 31;
- start = gregorianToJD(gyear, 3, 21);
+ start = gregorianToJD(gyear, 2 /* The third month in 0 based month */, 21);
}
else {
leapMonth = 30;
- start = gregorianToJD(gyear, 3, 22);
+ start = gregorianToJD(gyear, 2 /* The third month in 0 based month */, 22);
}
if (month == 1) {
@@ -297,7 +262,7 @@ void IndianCalendar::handleComputeFields(int32_t julianDay, UErrorCode& /* stat
gregorianYear = jdToGregorian(julianDay, gd)[0]; // Gregorian date for Julian day
IndianYear = gregorianYear - INDIAN_ERA_START; // Year in Saka era
- jdAtStartOfGregYear = gregorianToJD(gregorianYear, 1, 1); // JD at start of Gregorian year
+ jdAtStartOfGregYear = gregorianToJD(gregorianYear, 0, 1); // JD at start of Gregorian year
yday = (int32_t)(julianDay - jdAtStartOfGregYear); // Day number in Gregorian year (starting from 0)
if (yday < INDIAN_YEAR_START) {
diff --git a/deps/icu-small/source/i18n/indiancal.h b/deps/icu-small/source/i18n/indiancal.h
index 142597ce0e..624cec73b5 100644
--- a/deps/icu-small/source/i18n/indiancal.h
+++ b/deps/icu-small/source/i18n/indiancal.h
@@ -147,7 +147,7 @@ public:
* @param aLocale The given locale.
* @param success Indicates the status of IndianCalendar object construction.
* Returns U_ZERO_ERROR if constructed successfully.
- * @param beCivil Whether the calendar should be civil (default-TRUE) or religious (FALSE)
+ * @param beCivil Whether the calendar should be civil (default-true) or religious (false)
* @internal
*/
IndianCalendar(const Locale& aLocale, UErrorCode &success);
@@ -303,7 +303,7 @@ protected:
/**
- * Returns TRUE because the Indian Calendar does have a default century
+ * Returns true because the Indian Calendar does have a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/islamcal.cpp b/deps/icu-small/source/i18n/islamcal.cpp
index 4e4a664804..6e21e51150 100644
--- a/deps/icu-small/source/i18n/islamcal.cpp
+++ b/deps/icu-small/source/i18n/islamcal.cpp
@@ -232,7 +232,7 @@ IslamicCalendar* IslamicCalendar::clone() const {
}
IslamicCalendar::IslamicCalendar(const Locale& aLocale, UErrorCode& success, ECalculationType type)
-: Calendar(TimeZone::createDefault(), aLocale, success),
+: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success),
cType(type)
{
setTimeInMillis(getNow(), success); // Call this again now that the vtable is set up properly.
@@ -368,7 +368,7 @@ int32_t IslamicCalendar::yearStart(int32_t year) const{
if (cType == CIVIL || cType == TBLA ||
(cType == UMALQURA && (year < UMALQURA_YEAR_START || year > UMALQURA_YEAR_END)))
{
- return (year-1)*354 + ClockMath::floorDivide((3+11*year),30);
+ return (year-1)*354 + ClockMath::floorDivide((3+11*(int64_t)year),(int64_t)30);
} else if(cType==ASTRONOMICAL){
return trueMonthStart(12*(year-1));
} else {
@@ -391,7 +391,7 @@ int32_t IslamicCalendar::monthStart(int32_t year, int32_t month) const {
if (cType == CIVIL || cType == TBLA) {
// This does not handle months out of the range 0..11
return (int32_t)uprv_ceil(29.5*month)
- + (year-1)*354 + (int32_t)ClockMath::floorDivide((3+11*year),30);
+ + (year-1)*354 + (int32_t)ClockMath::floorDivide((3+11*(int64_t)year),(int64_t)30);
} else if(cType==ASTRONOMICAL){
return trueMonthStart(12*(year-1) + month);
} else {
@@ -447,7 +447,8 @@ int32_t IslamicCalendar::trueMonthStart(int32_t month) const
}
} while (age < 0);
}
- start = (int32_t)ClockMath::floorDivide((origin - HIJRA_MILLIS), (double)kOneDay) + 1;
+ start = (int32_t)(ClockMath::floorDivide(
+ (int64_t)((int64_t)origin - HIJRA_MILLIS), (int64_t)kOneDay) + 1);
CalendarCache::put(&gMonthCache, month, start, status);
}
trueMonthStartEnd :
@@ -639,13 +640,14 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status)
months--;
}
- year = months / 12 + 1;
- month = months % 12;
+ year = months >= 0 ? ((months / 12) + 1) : ((months + 1 ) / 12);
+ month = ((months % 12) + 12 ) % 12;
} else if(cType == UMALQURA) {
int32_t umalquraStartdays = yearStart(UMALQURA_YEAR_START) ;
if( days < umalquraStartdays){
//Use Civil calculation
- year = (int)ClockMath::floorDivide( (double)(30 * days + 10646) , 10631.0 );
+ year = (int32_t)ClockMath::floorDivide(
+ (30 * (int64_t)days + 10646) , (int64_t)10631.0 );
month = (int32_t)uprv_ceil((days - 29 - yearStart(year)) / 29.5 );
month = month<11?month:11;
startDate = monthStart(year, month);
diff --git a/deps/icu-small/source/i18n/islamcal.h b/deps/icu-small/source/i18n/islamcal.h
index aad8f07be0..b4ead411da 100644
--- a/deps/icu-small/source/i18n/islamcal.h
+++ b/deps/icu-small/source/i18n/islamcal.h
@@ -395,7 +395,7 @@ class U_I18N_API IslamicCalendar : public Calendar {
/**
- * Returns TRUE because the Islamic Calendar does have a default century
+ * Returns true because the Islamic Calendar does have a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/japancal.h b/deps/icu-small/source/i18n/japancal.h
index ee86c4ed0e..d313fcd99a 100644
--- a/deps/icu-small/source/i18n/japancal.h
+++ b/deps/icu-small/source/i18n/japancal.h
@@ -167,7 +167,7 @@ public:
virtual const char * getType() const;
/**
- * @return FALSE - no default century in Japanese
+ * @return false - no default century in Japanese
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/listformatter.cpp b/deps/icu-small/source/i18n/listformatter.cpp
index 4b27587555..ab04ac9080 100644
--- a/deps/icu-small/source/i18n/listformatter.cpp
+++ b/deps/icu-small/source/i18n/listformatter.cpp
@@ -52,10 +52,12 @@ public:
virtual PatternHandler* clone() const { return new PatternHandler(twoPattern, endPattern); }
+ /** Argument: final string in the list. */
virtual const SimpleFormatter& getTwoPattern(const UnicodeString&) const {
return twoPattern;
}
+ /** Argument: final string in the list. */
virtual const SimpleFormatter& getEndPattern(const UnicodeString&) const {
return endPattern;
}
@@ -237,9 +239,9 @@ ListFormatInternal(const ListFormatInternal &other) :
#if !UCONFIG_NO_FORMATTING
-class FormattedListData : public FormattedValueFieldPositionIteratorImpl {
+class FormattedListData : public FormattedValueStringBuilderImpl {
public:
- FormattedListData(UErrorCode& status) : FormattedValueFieldPositionIteratorImpl(5, status) {}
+ FormattedListData(UErrorCode&) : FormattedValueStringBuilderImpl(kUndefinedField) {}
virtual ~FormattedListData();
};
@@ -557,50 +559,89 @@ ListFormatter::~ListFormatter() {
delete owned;
}
-/**
- * Joins first and second using the pattern pat.
- * On entry offset is an offset into first or -1 if offset unspecified.
- * On exit offset is offset of second in result if recordOffset was set
- * Otherwise if it was >=0 it is set to point into result where it used
- * to point into first. On exit, result is the join of first and second
- * according to pat. Any previous value of result gets replaced.
- */
-static void joinStringsAndReplace(
- const SimpleFormatter& pat,
- const UnicodeString& first,
- const UnicodeString& second,
- UnicodeString &result,
- UBool recordOffset,
- int32_t &offset,
- int32_t *offsetFirst,
- int32_t *offsetSecond,
- UErrorCode& errorCode) {
- if (U_FAILURE(errorCode)) {
- return;
- }
- const UnicodeString *params[2] = {&first, &second};
- int32_t offsets[2];
- pat.formatAndReplace(
- params,
- UPRV_LENGTHOF(params),
- result,
- offsets,
- UPRV_LENGTHOF(offsets),
- errorCode);
- if (U_FAILURE(errorCode)) {
- return;
+namespace {
+
+class FormattedListBuilder {
+public:
+ LocalPointer<FormattedListData> data;
+
+ /** For lists of length 1+ */
+ FormattedListBuilder(const UnicodeString& start, UErrorCode& status)
+ : data(new FormattedListData(status), status) {
+ if (U_SUCCESS(status)) {
+ data->getStringRef().append(
+ start,
+ {UFIELD_CATEGORY_LIST, ULISTFMT_ELEMENT_FIELD},
+ status);
+ data->appendSpanIndex(0);
+ }
}
- if (offsets[0] == -1 || offsets[1] == -1) {
- errorCode = U_INVALID_FORMAT_ERROR;
- return;
+
+ /** For lists of length 0 */
+ FormattedListBuilder(UErrorCode& status)
+ : data(new FormattedListData(status), status) {
}
- if (recordOffset) {
- offset = offsets[1];
- } else if (offset >= 0) {
- offset += offsets[0];
+
+ void append(const SimpleFormatter& pattern, const UnicodeString& next, int32_t position, UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
+ if (pattern.getArgumentLimit() != 2) {
+ status = U_INTERNAL_PROGRAM_ERROR;
+ return;
+ }
+ // In the pattern, {0} are the pre-existing elements and {1} is the new element.
+ int32_t offsets[] = {0, 0};
+ UnicodeString temp = pattern.getTextWithNoArguments(offsets, 2);
+ if (offsets[0] <= offsets[1]) {
+ // prefix{0}infix{1}suffix
+ // Prepend prefix, then append infix, element, and suffix
+ data->getStringRef().insert(
+ 0,
+ temp.tempSubStringBetween(0, offsets[0]),
+ {UFIELD_CATEGORY_LIST, ULISTFMT_LITERAL_FIELD},
+ status);
+ data->getStringRef().append(
+ temp.tempSubStringBetween(offsets[0], offsets[1]),
+ {UFIELD_CATEGORY_LIST, ULISTFMT_LITERAL_FIELD},
+ status);
+ data->getStringRef().append(
+ next,
+ {UFIELD_CATEGORY_LIST, ULISTFMT_ELEMENT_FIELD},
+ status);
+ data->appendSpanIndex(position);
+ data->getStringRef().append(
+ temp.tempSubString(offsets[1]),
+ {UFIELD_CATEGORY_LIST, ULISTFMT_LITERAL_FIELD},
+ status);
+ } else {
+ // prefix{1}infix{0}suffix
+ // Prepend infix, element, and prefix, then append suffix.
+ // (We prepend in reverse order because prepending at index 0 is fast.)
+ data->getStringRef().insert(
+ 0,
+ temp.tempSubStringBetween(offsets[1], offsets[0]),
+ {UFIELD_CATEGORY_LIST, ULISTFMT_LITERAL_FIELD},
+ status);
+ data->getStringRef().insert(
+ 0,
+ next,
+ {UFIELD_CATEGORY_LIST, ULISTFMT_ELEMENT_FIELD},
+ status);
+ data->prependSpanIndex(position);
+ data->getStringRef().insert(
+ 0,
+ temp.tempSubStringBetween(0, offsets[1]),
+ {UFIELD_CATEGORY_LIST, ULISTFMT_LITERAL_FIELD},
+ status);
+ data->getStringRef().append(
+ temp.tempSubString(offsets[0]),
+ {UFIELD_CATEGORY_LIST, ULISTFMT_LITERAL_FIELD},
+ status);
+ }
}
- if (offsetFirst != nullptr) *offsetFirst = offsets[0];
- if (offsetSecond != nullptr) *offsetSecond = offsets[1];
+};
+
}
UnicodeString& ListFormatter::format(
@@ -619,7 +660,19 @@ UnicodeString& ListFormatter::format(
int32_t index,
int32_t &offset,
UErrorCode& errorCode) const {
- return format_(items, nItems, appendTo, index, offset, nullptr, errorCode);
+#if !UCONFIG_NO_FORMATTING
+ int32_t initialOffset = appendTo.length();
+ auto result = formatStringsToValue(items, nItems, errorCode);
+ UnicodeStringAppendable appendable(appendTo);
+ result.appendTo(appendable, errorCode);
+ if (index >= 0) {
+ ConstrainedFieldPosition cfpos;
+ cfpos.constrainField(UFIELD_CATEGORY_LIST_SPAN, index);
+ result.nextPosition(cfpos, errorCode);
+ offset = initialOffset + cfpos.getStart();
+ }
+#endif
+ return appendTo;
}
#if !UCONFIG_NO_FORMATTING
@@ -627,182 +680,68 @@ FormattedList ListFormatter::formatStringsToValue(
const UnicodeString items[],
int32_t nItems,
UErrorCode& errorCode) const {
- LocalPointer<FormattedListData> result(new FormattedListData(errorCode), errorCode);
- if (U_FAILURE(errorCode)) {
- return FormattedList(errorCode);
+ if (nItems == 0) {
+ FormattedListBuilder result(errorCode);
+ if (U_FAILURE(errorCode)) {
+ return FormattedList(errorCode);
+ } else {
+ return FormattedList(result.data.orphan());
+ }
+ } else if (nItems == 1) {
+ FormattedListBuilder result(items[0], errorCode);
+ result.data->getStringRef().writeTerminator(errorCode);
+ if (U_FAILURE(errorCode)) {
+ return FormattedList(errorCode);
+ } else {
+ return FormattedList(result.data.orphan());
+ }
+ } else if (nItems == 2) {
+ FormattedListBuilder result(items[0], errorCode);
+ if (U_FAILURE(errorCode)) {
+ return FormattedList(errorCode);
+ }
+ result.append(
+ data->patternHandler->getTwoPattern(items[1]),
+ items[1],
+ 1,
+ errorCode);
+ result.data->getStringRef().writeTerminator(errorCode);
+ if (U_FAILURE(errorCode)) {
+ return FormattedList(errorCode);
+ } else {
+ return FormattedList(result.data.orphan());
+ }
}
- UnicodeString string;
- int32_t offset;
- auto handler = result->getHandler(errorCode);
- handler.setCategory(UFIELD_CATEGORY_LIST);
- format_(items, nItems, string, -1, offset, &handler, errorCode);
- handler.getError(errorCode);
- result->appendString(string, errorCode);
+
+ FormattedListBuilder result(items[0], errorCode);
if (U_FAILURE(errorCode)) {
return FormattedList(errorCode);
}
-
- // Add span fields and sort
- ConstrainedFieldPosition cfpos;
- cfpos.constrainField(UFIELD_CATEGORY_LIST, ULISTFMT_ELEMENT_FIELD);
- int32_t i = 0;
- handler.setCategory(UFIELD_CATEGORY_LIST_SPAN);
- while (result->nextPosition(cfpos, errorCode)) {
- handler.addAttribute(i++, cfpos.getStart(), cfpos.getLimit());
+ result.append(
+ data->startPattern,
+ items[1],
+ 1,
+ errorCode);
+ for (int32_t i = 2; i < nItems - 1; i++) {
+ result.append(
+ data->middlePattern,
+ items[i],
+ i,
+ errorCode);
}
- handler.getError(errorCode);
+ result.append(
+ data->patternHandler->getEndPattern(items[nItems-1]),
+ items[nItems-1],
+ nItems-1,
+ errorCode);
+ result.data->getStringRef().writeTerminator(errorCode);
if (U_FAILURE(errorCode)) {
return FormattedList(errorCode);
+ } else {
+ return FormattedList(result.data.orphan());
}
- result->sort();
-
- return FormattedList(result.orphan());
}
#endif
-UnicodeString& ListFormatter::format_(
- const UnicodeString items[],
- int32_t nItems,
- UnicodeString& appendTo,
- int32_t index,
- int32_t &offset,
- FieldPositionHandler* handler,
- UErrorCode& errorCode) const {
-#if !UCONFIG_NO_FORMATTING
- offset = -1;
- if (U_FAILURE(errorCode)) {
- return appendTo;
- }
- if (data == nullptr) {
- errorCode = U_INVALID_STATE_ERROR;
- return appendTo;
- }
-
- if (nItems <= 0) {
- return appendTo;
- }
- if (nItems == 1) {
- if (index == 0) {
- offset = appendTo.length();
- }
- if (handler != nullptr) {
- handler->addAttribute(ULISTFMT_ELEMENT_FIELD,
- appendTo.length(),
- appendTo.length() + items[0].length());
- }
- appendTo.append(items[0]);
- return appendTo;
- }
- UnicodeString result(items[0]);
- if (index == 0) {
- offset = 0;
- }
- int32_t offsetFirst = 0;
- int32_t offsetSecond = 0;
- int32_t prefixLength = 0;
- // for n items, there are 2 * (n + 1) boundary including 0 and the upper
- // edge.
- MaybeStackArray<int32_t, 10> offsets((handler != nullptr) ? 2 * (nItems + 1): 0);
- if (nItems == 2) {
- joinStringsAndReplace(
- data->patternHandler->getTwoPattern(items[1]),
- result,
- items[1],
- result,
- index == 1,
- offset,
- &offsetFirst,
- &offsetSecond,
- errorCode);
- } else {
- joinStringsAndReplace(
- data->startPattern,
- result,
- items[1],
- result,
- index == 1,
- offset,
- &offsetFirst,
- &offsetSecond,
- errorCode);
- }
- if (handler != nullptr) {
- offsets[0] = 0;
- prefixLength += offsetFirst;
- offsets[1] = offsetSecond - prefixLength;
- }
- if (nItems > 2) {
- for (int32_t i = 2; i < nItems - 1; ++i) {
- joinStringsAndReplace(
- data->middlePattern,
- result,
- items[i],
- result,
- index == i,
- offset,
- &offsetFirst,
- &offsetSecond,
- errorCode);
- if (handler != nullptr) {
- prefixLength += offsetFirst;
- offsets[i] = offsetSecond - prefixLength;
- }
- }
- joinStringsAndReplace(
- data->patternHandler->getEndPattern(items[nItems - 1]),
- result,
- items[nItems - 1],
- result,
- index == nItems - 1,
- offset,
- &offsetFirst,
- &offsetSecond,
- errorCode);
- if (handler != nullptr) {
- prefixLength += offsetFirst;
- offsets[nItems - 1] = offsetSecond - prefixLength;
- }
- }
- if (handler != nullptr) {
- // If there are already some data in appendTo, we need to adjust the index
- // by shifting that lenght while insert into handler.
- int32_t shift = appendTo.length() + prefixLength;
- // Output the ULISTFMT_ELEMENT_FIELD in the order of the input elements
- for (int32_t i = 0; i < nItems; ++i) {
- offsets[i + nItems] = offsets[i] + items[i].length() + shift;
- offsets[i] += shift;
- handler->addAttribute(
- ULISTFMT_ELEMENT_FIELD, // id
- offsets[i], // index
- offsets[i + nItems]); // limit
- }
- // The locale pattern may reorder the items (such as in ur-IN locale),
- // so we cannot assume the array is in accendning order.
- // To handle the edging case, just insert the two ends into the array
- // and sort. Then we output ULISTFMT_LITERAL_FIELD if the indecies
- // between the even and odd position are not the same in the sorted array.
- offsets[2 * nItems] = shift - prefixLength;
- offsets[2 * nItems + 1] = result.length() + shift - prefixLength;
- uprv_sortArray(offsets.getAlias(), 2 * (nItems + 1), sizeof(int32_t),
- uprv_int32Comparator, nullptr,
- false, &errorCode);
- for (int32_t i = 0; i <= nItems; ++i) {
- if (offsets[i * 2] != offsets[i * 2 + 1]) {
- handler->addAttribute(
- ULISTFMT_LITERAL_FIELD, // id
- offsets[i * 2], // index
- offsets[i * 2 + 1]); // limit
- }
- }
- }
- if (U_SUCCESS(errorCode)) {
- if (offset >= 0) {
- offset += appendTo.length();
- }
- appendTo += result;
- }
-#endif
- return appendTo;
-}
U_NAMESPACE_END
diff --git a/deps/icu-small/source/i18n/measfmt.cpp b/deps/icu-small/source/i18n/measfmt.cpp
index a98a6dda47..3e7f7bae15 100644
--- a/deps/icu-small/source/i18n/measfmt.cpp
+++ b/deps/icu-small/source/i18n/measfmt.cpp
@@ -861,7 +861,7 @@ UnicodeString &MeasureFormat::formatMeasuresSlowTrack(
return appendTo;
}
// Fix up FieldPosition indexes if our field is found.
- if (offset != -1) {
+ if (fieldPositionFoundIndex != -1 && offset != -1) {
pos.setBeginIndex(fpos.getBeginIndex() + offset);
pos.setEndIndex(fpos.getEndIndex() + offset);
}
diff --git a/deps/icu-small/source/i18n/measunit.cpp b/deps/icu-small/source/i18n/measunit.cpp
index 2486ca9b15..dab3abb5e2 100644
--- a/deps/icu-small/source/i18n/measunit.cpp
+++ b/deps/icu-small/source/i18n/measunit.cpp
@@ -33,9 +33,9 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(MeasureUnit)
// update this code, refer to:
// http://site.icu-project.org/design/formatting/measureformat/updating-measure-unit
//
-// Start generated code
-
+// Start generated code for measunit.cpp
+// Maps from Type ID to offset in gSubTypes.
static const int32_t gOffsets[] = {
0,
2,
@@ -50,45 +50,20 @@ static const int32_t gOffsets[] = {
368,
370,
374,
- 381,
- 402,
+ 382,
404,
- 418,
- 421,
- 427,
- 437,
- 441,
- 445,
- 447,
- 474
+ 408,
+ 423,
+ 424,
+ 430,
+ 440,
+ 444,
+ 448,
+ 450,
+ 484
};
-static const int32_t gIndexes[] = {
- 0,
- 2,
- 7,
- 17,
- 25,
- 29,
- 29,
- 40,
- 56,
- 60,
- 69,
- 71,
- 75,
- 82,
- 103,
- 105,
- 119,
- 122,
- 128,
- 138,
- 142,
- 146,
- 148,
- 175
-};
+static const int32_t kCurrencyOffset = 5;
// Must be sorted alphabetically.
static const char * const gTypes[] = {
@@ -493,6 +468,7 @@ static const char * const gSubTypes[] = {
"hertz",
"kilohertz",
"megahertz",
+ "dot",
"dot-per-centimeter",
"dot-per-inch",
"em",
@@ -503,6 +479,7 @@ static const char * const gSubTypes[] = {
"astronomical-unit",
"centimeter",
"decimeter",
+ "earth-radius",
"fathom",
"foot",
"furlong",
@@ -521,11 +498,14 @@ static const char * const gSubTypes[] = {
"point",
"solar-radius",
"yard",
+ "candela",
+ "lumen",
"lux",
"solar-luminosity",
"carat",
"dalton",
"earth-mass",
+ "grain",
"gram",
"kilogram",
"metric-ton",
@@ -537,9 +517,7 @@ static const char * const gSubTypes[] = {
"solar-mass",
"stone",
"ton",
- "", // TODO(ICU-21076): manual edit of what should have been generated by Java.
- "percent", // TODO(ICU-21076): regenerate, deal with duplication.
- "permille", // TODO(ICU-21076): regenerate, deal with duplication.
+ "",
"gigawatt",
"horsepower",
"kilowatt",
@@ -580,35 +558,28 @@ static const char * const gSubTypes[] = {
"cup",
"cup-metric",
"deciliter",
+ "dessert-spoon",
+ "dessert-spoon-imperial",
+ "dram",
+ "drop",
"fluid-ounce",
"fluid-ounce-imperial",
"gallon",
"gallon-imperial",
"hectoliter",
+ "jigger",
"liter",
"megaliter",
"milliliter",
+ "pinch",
"pint",
"pint-metric",
"quart",
+ "quart-imperial",
"tablespoon",
"teaspoon"
};
-// Must be sorted by first value and then second value.
-static int32_t unitPerUnitToSingleUnit[][4] = {
- {378, 382, 12, 5},
- {378, 387, 12, 6},
- {388, 343, 19, 0},
- {390, 350, 19, 2},
- {392, 343, 19, 3},
- {392, 463, 4, 2},
- {392, 464, 4, 3},
- {411, 460, 3, 1},
- {414, 12, 18, 9},
- {466, 388, 4, 1}
-};
-
// Shortcuts to the base unit in order to make the default constructor fast
static const int32_t kBaseTypeIdx = 16;
static const int32_t kBaseSubTypeIdx = 0;
@@ -781,14 +752,6 @@ MeasureUnit MeasureUnit::getMole() {
return MeasureUnit(3, 3);
}
-MeasureUnit *MeasureUnit::createPartPerMillion(UErrorCode &status) {
- return MeasureUnit::create(3, 6, status);
-}
-
-MeasureUnit MeasureUnit::getPartPerMillion() {
- return MeasureUnit(3, 6);
-}
-
MeasureUnit *MeasureUnit::createPercent(UErrorCode &status) {
return MeasureUnit::create(3, 4, status);
}
@@ -805,6 +768,14 @@ MeasureUnit MeasureUnit::getPermille() {
return MeasureUnit(3, 5);
}
+MeasureUnit *MeasureUnit::createPartPerMillion(UErrorCode &status) {
+ return MeasureUnit::create(3, 6, status);
+}
+
+MeasureUnit MeasureUnit::getPartPerMillion() {
+ return MeasureUnit(3, 6);
+}
+
MeasureUnit *MeasureUnit::createPermyriad(UErrorCode &status) {
return MeasureUnit::create(3, 7, status);
}
@@ -1213,62 +1184,70 @@ MeasureUnit MeasureUnit::getMegahertz() {
return MeasureUnit(11, 3);
}
-MeasureUnit *MeasureUnit::createDotPerCentimeter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createDot(UErrorCode &status) {
return MeasureUnit::create(12, 0, status);
}
-MeasureUnit MeasureUnit::getDotPerCentimeter() {
+MeasureUnit MeasureUnit::getDot() {
return MeasureUnit(12, 0);
}
-MeasureUnit *MeasureUnit::createDotPerInch(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createDotPerCentimeter(UErrorCode &status) {
return MeasureUnit::create(12, 1, status);
}
-MeasureUnit MeasureUnit::getDotPerInch() {
+MeasureUnit MeasureUnit::getDotPerCentimeter() {
return MeasureUnit(12, 1);
}
-MeasureUnit *MeasureUnit::createEm(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createDotPerInch(UErrorCode &status) {
return MeasureUnit::create(12, 2, status);
}
-MeasureUnit MeasureUnit::getEm() {
+MeasureUnit MeasureUnit::getDotPerInch() {
return MeasureUnit(12, 2);
}
-MeasureUnit *MeasureUnit::createMegapixel(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createEm(UErrorCode &status) {
return MeasureUnit::create(12, 3, status);
}
-MeasureUnit MeasureUnit::getMegapixel() {
+MeasureUnit MeasureUnit::getEm() {
return MeasureUnit(12, 3);
}
-MeasureUnit *MeasureUnit::createPixel(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMegapixel(UErrorCode &status) {
return MeasureUnit::create(12, 4, status);
}
-MeasureUnit MeasureUnit::getPixel() {
+MeasureUnit MeasureUnit::getMegapixel() {
return MeasureUnit(12, 4);
}
-MeasureUnit *MeasureUnit::createPixelPerCentimeter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createPixel(UErrorCode &status) {
return MeasureUnit::create(12, 5, status);
}
-MeasureUnit MeasureUnit::getPixelPerCentimeter() {
+MeasureUnit MeasureUnit::getPixel() {
return MeasureUnit(12, 5);
}
-MeasureUnit *MeasureUnit::createPixelPerInch(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createPixelPerCentimeter(UErrorCode &status) {
return MeasureUnit::create(12, 6, status);
}
-MeasureUnit MeasureUnit::getPixelPerInch() {
+MeasureUnit MeasureUnit::getPixelPerCentimeter() {
return MeasureUnit(12, 6);
}
+MeasureUnit *MeasureUnit::createPixelPerInch(UErrorCode &status) {
+ return MeasureUnit::create(12, 7, status);
+}
+
+MeasureUnit MeasureUnit::getPixelPerInch() {
+ return MeasureUnit(12, 7);
+}
+
MeasureUnit *MeasureUnit::createAstronomicalUnit(UErrorCode &status) {
return MeasureUnit::create(13, 0, status);
}
@@ -1293,166 +1272,190 @@ MeasureUnit MeasureUnit::getDecimeter() {
return MeasureUnit(13, 2);
}
-MeasureUnit *MeasureUnit::createFathom(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createEarthRadius(UErrorCode &status) {
return MeasureUnit::create(13, 3, status);
}
-MeasureUnit MeasureUnit::getFathom() {
+MeasureUnit MeasureUnit::getEarthRadius() {
return MeasureUnit(13, 3);
}
-MeasureUnit *MeasureUnit::createFoot(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createFathom(UErrorCode &status) {
return MeasureUnit::create(13, 4, status);
}
-MeasureUnit MeasureUnit::getFoot() {
+MeasureUnit MeasureUnit::getFathom() {
return MeasureUnit(13, 4);
}
-MeasureUnit *MeasureUnit::createFurlong(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createFoot(UErrorCode &status) {
return MeasureUnit::create(13, 5, status);
}
-MeasureUnit MeasureUnit::getFurlong() {
+MeasureUnit MeasureUnit::getFoot() {
return MeasureUnit(13, 5);
}
-MeasureUnit *MeasureUnit::createInch(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createFurlong(UErrorCode &status) {
return MeasureUnit::create(13, 6, status);
}
-MeasureUnit MeasureUnit::getInch() {
+MeasureUnit MeasureUnit::getFurlong() {
return MeasureUnit(13, 6);
}
-MeasureUnit *MeasureUnit::createKilometer(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createInch(UErrorCode &status) {
return MeasureUnit::create(13, 7, status);
}
-MeasureUnit MeasureUnit::getKilometer() {
+MeasureUnit MeasureUnit::getInch() {
return MeasureUnit(13, 7);
}
-MeasureUnit *MeasureUnit::createLightYear(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createKilometer(UErrorCode &status) {
return MeasureUnit::create(13, 8, status);
}
-MeasureUnit MeasureUnit::getLightYear() {
+MeasureUnit MeasureUnit::getKilometer() {
return MeasureUnit(13, 8);
}
-MeasureUnit *MeasureUnit::createMeter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createLightYear(UErrorCode &status) {
return MeasureUnit::create(13, 9, status);
}
-MeasureUnit MeasureUnit::getMeter() {
+MeasureUnit MeasureUnit::getLightYear() {
return MeasureUnit(13, 9);
}
-MeasureUnit *MeasureUnit::createMicrometer(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMeter(UErrorCode &status) {
return MeasureUnit::create(13, 10, status);
}
-MeasureUnit MeasureUnit::getMicrometer() {
+MeasureUnit MeasureUnit::getMeter() {
return MeasureUnit(13, 10);
}
-MeasureUnit *MeasureUnit::createMile(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMicrometer(UErrorCode &status) {
return MeasureUnit::create(13, 11, status);
}
-MeasureUnit MeasureUnit::getMile() {
+MeasureUnit MeasureUnit::getMicrometer() {
return MeasureUnit(13, 11);
}
-MeasureUnit *MeasureUnit::createMileScandinavian(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMile(UErrorCode &status) {
return MeasureUnit::create(13, 12, status);
}
-MeasureUnit MeasureUnit::getMileScandinavian() {
+MeasureUnit MeasureUnit::getMile() {
return MeasureUnit(13, 12);
}
-MeasureUnit *MeasureUnit::createMillimeter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMileScandinavian(UErrorCode &status) {
return MeasureUnit::create(13, 13, status);
}
-MeasureUnit MeasureUnit::getMillimeter() {
+MeasureUnit MeasureUnit::getMileScandinavian() {
return MeasureUnit(13, 13);
}
-MeasureUnit *MeasureUnit::createNanometer(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMillimeter(UErrorCode &status) {
return MeasureUnit::create(13, 14, status);
}
-MeasureUnit MeasureUnit::getNanometer() {
+MeasureUnit MeasureUnit::getMillimeter() {
return MeasureUnit(13, 14);
}
-MeasureUnit *MeasureUnit::createNauticalMile(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createNanometer(UErrorCode &status) {
return MeasureUnit::create(13, 15, status);
}
-MeasureUnit MeasureUnit::getNauticalMile() {
+MeasureUnit MeasureUnit::getNanometer() {
return MeasureUnit(13, 15);
}
-MeasureUnit *MeasureUnit::createParsec(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createNauticalMile(UErrorCode &status) {
return MeasureUnit::create(13, 16, status);
}
-MeasureUnit MeasureUnit::getParsec() {
+MeasureUnit MeasureUnit::getNauticalMile() {
return MeasureUnit(13, 16);
}
-MeasureUnit *MeasureUnit::createPicometer(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createParsec(UErrorCode &status) {
return MeasureUnit::create(13, 17, status);
}
-MeasureUnit MeasureUnit::getPicometer() {
+MeasureUnit MeasureUnit::getParsec() {
return MeasureUnit(13, 17);
}
-MeasureUnit *MeasureUnit::createPoint(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createPicometer(UErrorCode &status) {
return MeasureUnit::create(13, 18, status);
}
-MeasureUnit MeasureUnit::getPoint() {
+MeasureUnit MeasureUnit::getPicometer() {
return MeasureUnit(13, 18);
}
-MeasureUnit *MeasureUnit::createSolarRadius(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createPoint(UErrorCode &status) {
return MeasureUnit::create(13, 19, status);
}
-MeasureUnit MeasureUnit::getSolarRadius() {
+MeasureUnit MeasureUnit::getPoint() {
return MeasureUnit(13, 19);
}
-MeasureUnit *MeasureUnit::createYard(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createSolarRadius(UErrorCode &status) {
return MeasureUnit::create(13, 20, status);
}
-MeasureUnit MeasureUnit::getYard() {
+MeasureUnit MeasureUnit::getSolarRadius() {
return MeasureUnit(13, 20);
}
-MeasureUnit *MeasureUnit::createLux(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createYard(UErrorCode &status) {
+ return MeasureUnit::create(13, 21, status);
+}
+
+MeasureUnit MeasureUnit::getYard() {
+ return MeasureUnit(13, 21);
+}
+
+MeasureUnit *MeasureUnit::createCandela(UErrorCode &status) {
return MeasureUnit::create(14, 0, status);
}
-MeasureUnit MeasureUnit::getLux() {
+MeasureUnit MeasureUnit::getCandela() {
return MeasureUnit(14, 0);
}
-MeasureUnit *MeasureUnit::createSolarLuminosity(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createLumen(UErrorCode &status) {
return MeasureUnit::create(14, 1, status);
}
-MeasureUnit MeasureUnit::getSolarLuminosity() {
+MeasureUnit MeasureUnit::getLumen() {
return MeasureUnit(14, 1);
}
+MeasureUnit *MeasureUnit::createLux(UErrorCode &status) {
+ return MeasureUnit::create(14, 2, status);
+}
+
+MeasureUnit MeasureUnit::getLux() {
+ return MeasureUnit(14, 2);
+}
+
+MeasureUnit *MeasureUnit::createSolarLuminosity(UErrorCode &status) {
+ return MeasureUnit::create(14, 3, status);
+}
+
+MeasureUnit MeasureUnit::getSolarLuminosity() {
+ return MeasureUnit(14, 3);
+}
+
MeasureUnit *MeasureUnit::createCarat(UErrorCode &status) {
return MeasureUnit::create(15, 0, status);
}
@@ -1477,94 +1480,102 @@ MeasureUnit MeasureUnit::getEarthMass() {
return MeasureUnit(15, 2);
}
-MeasureUnit *MeasureUnit::createGram(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createGrain(UErrorCode &status) {
return MeasureUnit::create(15, 3, status);
}
-MeasureUnit MeasureUnit::getGram() {
+MeasureUnit MeasureUnit::getGrain() {
return MeasureUnit(15, 3);
}
-MeasureUnit *MeasureUnit::createKilogram(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createGram(UErrorCode &status) {
return MeasureUnit::create(15, 4, status);
}
-MeasureUnit MeasureUnit::getKilogram() {
+MeasureUnit MeasureUnit::getGram() {
return MeasureUnit(15, 4);
}
-MeasureUnit *MeasureUnit::createMetricTon(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createKilogram(UErrorCode &status) {
return MeasureUnit::create(15, 5, status);
}
-MeasureUnit MeasureUnit::getMetricTon() {
+MeasureUnit MeasureUnit::getKilogram() {
return MeasureUnit(15, 5);
}
-MeasureUnit *MeasureUnit::createMicrogram(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMetricTon(UErrorCode &status) {
return MeasureUnit::create(15, 6, status);
}
-MeasureUnit MeasureUnit::getMicrogram() {
+MeasureUnit MeasureUnit::getMetricTon() {
return MeasureUnit(15, 6);
}
-MeasureUnit *MeasureUnit::createMilligram(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMicrogram(UErrorCode &status) {
return MeasureUnit::create(15, 7, status);
}
-MeasureUnit MeasureUnit::getMilligram() {
+MeasureUnit MeasureUnit::getMicrogram() {
return MeasureUnit(15, 7);
}
-MeasureUnit *MeasureUnit::createOunce(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMilligram(UErrorCode &status) {
return MeasureUnit::create(15, 8, status);
}
-MeasureUnit MeasureUnit::getOunce() {
+MeasureUnit MeasureUnit::getMilligram() {
return MeasureUnit(15, 8);
}
-MeasureUnit *MeasureUnit::createOunceTroy(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createOunce(UErrorCode &status) {
return MeasureUnit::create(15, 9, status);
}
-MeasureUnit MeasureUnit::getOunceTroy() {
+MeasureUnit MeasureUnit::getOunce() {
return MeasureUnit(15, 9);
}
-MeasureUnit *MeasureUnit::createPound(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createOunceTroy(UErrorCode &status) {
return MeasureUnit::create(15, 10, status);
}
-MeasureUnit MeasureUnit::getPound() {
+MeasureUnit MeasureUnit::getOunceTroy() {
return MeasureUnit(15, 10);
}
-MeasureUnit *MeasureUnit::createSolarMass(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createPound(UErrorCode &status) {
return MeasureUnit::create(15, 11, status);
}
-MeasureUnit MeasureUnit::getSolarMass() {
+MeasureUnit MeasureUnit::getPound() {
return MeasureUnit(15, 11);
}
-MeasureUnit *MeasureUnit::createStone(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createSolarMass(UErrorCode &status) {
return MeasureUnit::create(15, 12, status);
}
-MeasureUnit MeasureUnit::getStone() {
+MeasureUnit MeasureUnit::getSolarMass() {
return MeasureUnit(15, 12);
}
-MeasureUnit *MeasureUnit::createTon(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createStone(UErrorCode &status) {
return MeasureUnit::create(15, 13, status);
}
-MeasureUnit MeasureUnit::getTon() {
+MeasureUnit MeasureUnit::getStone() {
return MeasureUnit(15, 13);
}
+MeasureUnit *MeasureUnit::createTon(UErrorCode &status) {
+ return MeasureUnit::create(15, 14, status);
+}
+
+MeasureUnit MeasureUnit::getTon() {
+ return MeasureUnit(15, 14);
+}
+
MeasureUnit *MeasureUnit::createGigawatt(UErrorCode &status) {
return MeasureUnit::create(17, 0, status);
}
@@ -1885,111 +1896,167 @@ MeasureUnit MeasureUnit::getDeciliter() {
return MeasureUnit(22, 13);
}
-MeasureUnit *MeasureUnit::createFluidOunce(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createDessertSpoon(UErrorCode &status) {
return MeasureUnit::create(22, 14, status);
}
-MeasureUnit MeasureUnit::getFluidOunce() {
+MeasureUnit MeasureUnit::getDessertSpoon() {
return MeasureUnit(22, 14);
}
-MeasureUnit *MeasureUnit::createFluidOunceImperial(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createDessertSpoonImperial(UErrorCode &status) {
return MeasureUnit::create(22, 15, status);
}
-MeasureUnit MeasureUnit::getFluidOunceImperial() {
+MeasureUnit MeasureUnit::getDessertSpoonImperial() {
return MeasureUnit(22, 15);
}
-MeasureUnit *MeasureUnit::createGallon(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createDram(UErrorCode &status) {
return MeasureUnit::create(22, 16, status);
}
-MeasureUnit MeasureUnit::getGallon() {
+MeasureUnit MeasureUnit::getDram() {
return MeasureUnit(22, 16);
}
-MeasureUnit *MeasureUnit::createGallonImperial(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createDrop(UErrorCode &status) {
return MeasureUnit::create(22, 17, status);
}
-MeasureUnit MeasureUnit::getGallonImperial() {
+MeasureUnit MeasureUnit::getDrop() {
return MeasureUnit(22, 17);
}
-MeasureUnit *MeasureUnit::createHectoliter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createFluidOunce(UErrorCode &status) {
return MeasureUnit::create(22, 18, status);
}
-MeasureUnit MeasureUnit::getHectoliter() {
+MeasureUnit MeasureUnit::getFluidOunce() {
return MeasureUnit(22, 18);
}
-MeasureUnit *MeasureUnit::createLiter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createFluidOunceImperial(UErrorCode &status) {
return MeasureUnit::create(22, 19, status);
}
-MeasureUnit MeasureUnit::getLiter() {
+MeasureUnit MeasureUnit::getFluidOunceImperial() {
return MeasureUnit(22, 19);
}
-MeasureUnit *MeasureUnit::createMegaliter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createGallon(UErrorCode &status) {
return MeasureUnit::create(22, 20, status);
}
-MeasureUnit MeasureUnit::getMegaliter() {
+MeasureUnit MeasureUnit::getGallon() {
return MeasureUnit(22, 20);
}
-MeasureUnit *MeasureUnit::createMilliliter(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createGallonImperial(UErrorCode &status) {
return MeasureUnit::create(22, 21, status);
}
-MeasureUnit MeasureUnit::getMilliliter() {
+MeasureUnit MeasureUnit::getGallonImperial() {
return MeasureUnit(22, 21);
}
-MeasureUnit *MeasureUnit::createPint(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createHectoliter(UErrorCode &status) {
return MeasureUnit::create(22, 22, status);
}
-MeasureUnit MeasureUnit::getPint() {
+MeasureUnit MeasureUnit::getHectoliter() {
return MeasureUnit(22, 22);
}
-MeasureUnit *MeasureUnit::createPintMetric(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createJigger(UErrorCode &status) {
return MeasureUnit::create(22, 23, status);
}
-MeasureUnit MeasureUnit::getPintMetric() {
+MeasureUnit MeasureUnit::getJigger() {
return MeasureUnit(22, 23);
}
-MeasureUnit *MeasureUnit::createQuart(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createLiter(UErrorCode &status) {
return MeasureUnit::create(22, 24, status);
}
-MeasureUnit MeasureUnit::getQuart() {
+MeasureUnit MeasureUnit::getLiter() {
return MeasureUnit(22, 24);
}
-MeasureUnit *MeasureUnit::createTablespoon(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMegaliter(UErrorCode &status) {
return MeasureUnit::create(22, 25, status);
}
-MeasureUnit MeasureUnit::getTablespoon() {
+MeasureUnit MeasureUnit::getMegaliter() {
return MeasureUnit(22, 25);
}
-MeasureUnit *MeasureUnit::createTeaspoon(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMilliliter(UErrorCode &status) {
return MeasureUnit::create(22, 26, status);
}
-MeasureUnit MeasureUnit::getTeaspoon() {
+MeasureUnit MeasureUnit::getMilliliter() {
return MeasureUnit(22, 26);
}
-// End generated code
+MeasureUnit *MeasureUnit::createPinch(UErrorCode &status) {
+ return MeasureUnit::create(22, 27, status);
+}
+
+MeasureUnit MeasureUnit::getPinch() {
+ return MeasureUnit(22, 27);
+}
+
+MeasureUnit *MeasureUnit::createPint(UErrorCode &status) {
+ return MeasureUnit::create(22, 28, status);
+}
+
+MeasureUnit MeasureUnit::getPint() {
+ return MeasureUnit(22, 28);
+}
+
+MeasureUnit *MeasureUnit::createPintMetric(UErrorCode &status) {
+ return MeasureUnit::create(22, 29, status);
+}
+
+MeasureUnit MeasureUnit::getPintMetric() {
+ return MeasureUnit(22, 29);
+}
+
+MeasureUnit *MeasureUnit::createQuart(UErrorCode &status) {
+ return MeasureUnit::create(22, 30, status);
+}
+
+MeasureUnit MeasureUnit::getQuart() {
+ return MeasureUnit(22, 30);
+}
+
+MeasureUnit *MeasureUnit::createQuartImperial(UErrorCode &status) {
+ return MeasureUnit::create(22, 31, status);
+}
+
+MeasureUnit MeasureUnit::getQuartImperial() {
+ return MeasureUnit(22, 31);
+}
+
+MeasureUnit *MeasureUnit::createTablespoon(UErrorCode &status) {
+ return MeasureUnit::create(22, 32, status);
+}
+
+MeasureUnit MeasureUnit::getTablespoon() {
+ return MeasureUnit(22, 32);
+}
+
+MeasureUnit *MeasureUnit::createTeaspoon(UErrorCode &status) {
+ return MeasureUnit::create(22, 33, status);
+}
+
+MeasureUnit MeasureUnit::getTeaspoon() {
+ return MeasureUnit(22, 33);
+}
+
+// End generated code for measunit.cpp
static int32_t binarySearch(
const char * const * array, int32_t start, int32_t end, StringPiece key) {
@@ -2107,10 +2174,6 @@ UBool MeasureUnit::operator==(const UObject& other) const {
return uprv_strcmp(getIdentifier(), rhs.getIdentifier()) == 0;
}
-int32_t MeasureUnit::getIndex() const {
- return gIndexes[fTypeId] + fSubTypeId;
-}
-
int32_t MeasureUnit::getAvailable(
MeasureUnit *dest,
int32_t destCapacity,
@@ -2173,26 +2236,14 @@ StringEnumeration* MeasureUnit::getAvailableTypes(UErrorCode &errorCode) {
return result;
}
-int32_t MeasureUnit::getIndexCount() {
- return gIndexes[UPRV_LENGTHOF(gIndexes) - 1];
-}
-
-int32_t MeasureUnit::internalGetIndexForTypeAndSubtype(const char *type, const char *subtype) {
- int32_t t = binarySearch(gTypes, 0, UPRV_LENGTHOF(gTypes), type);
- if (t < 0) {
- return t;
- }
- int32_t st = binarySearch(gSubTypes, gOffsets[t], gOffsets[t + 1], subtype);
- if (st < 0) {
- return st;
- }
- return gIndexes[t] + st - gOffsets[t];
-}
-
bool MeasureUnit::findBySubType(StringPiece subType, MeasureUnit* output) {
+ // Sanity checking kCurrencyOffset and final entry in gOffsets
+ U_ASSERT(uprv_strcmp(gTypes[kCurrencyOffset], "currency") == 0);
+ U_ASSERT(gOffsets[UPRV_LENGTHOF(gOffsets) - 1] == UPRV_LENGTHOF(gSubTypes));
+
for (int32_t t = 0; t < UPRV_LENGTHOF(gOffsets) - 1; t++) {
// Skip currency units
- if (gIndexes[t] == gIndexes[t + 1]) {
+ if (t == kCurrencyOffset) {
continue;
}
int32_t st = binarySearch(gSubTypes, gOffsets[t], gOffsets[t + 1], subType);
@@ -2204,41 +2255,6 @@ bool MeasureUnit::findBySubType(StringPiece subType, MeasureUnit* output) {
return false;
}
-MeasureUnit MeasureUnit::resolveUnitPerUnit(
- const MeasureUnit &unit, const MeasureUnit &perUnit, bool* isResolved) {
- int32_t unitOffset = unit.getOffset();
- int32_t perUnitOffset = perUnit.getOffset();
- if (unitOffset == -1 || perUnitOffset == -1) {
- *isResolved = false;
- return MeasureUnit();
- }
-
- // binary search for (unitOffset, perUnitOffset)
- int32_t start = 0;
- int32_t end = UPRV_LENGTHOF(unitPerUnitToSingleUnit);
- while (start < end) {
- int32_t mid = (start + end) / 2;
- int32_t *midRow = unitPerUnitToSingleUnit[mid];
- if (unitOffset < midRow[0]) {
- end = mid;
- } else if (unitOffset > midRow[0]) {
- start = mid + 1;
- } else if (perUnitOffset < midRow[1]) {
- end = mid;
- } else if (perUnitOffset > midRow[1]) {
- start = mid + 1;
- } else {
- // We found a resolution for our unit / per-unit combo
- // return it.
- *isResolved = true;
- return MeasureUnit(midRow[2], midRow[3]);
- }
- }
-
- *isResolved = false;
- return MeasureUnit();
-}
-
MeasureUnit *MeasureUnit::create(int typeId, int subTypeId, UErrorCode &status) {
if (U_FAILURE(status)) {
return NULL;
@@ -2279,15 +2295,6 @@ void MeasureUnit::initCurrency(StringPiece isoCurrency) {
fSubTypeId = result - gOffsets[fTypeId];
}
-void MeasureUnit::initNoUnit(const char *subtype) {
- int32_t result = binarySearch(gTypes, 0, UPRV_LENGTHOF(gTypes), "none");
- U_ASSERT(result != -1);
- fTypeId = result;
- result = binarySearch(gSubTypes, gOffsets[fTypeId], gOffsets[fTypeId + 1], subtype);
- U_ASSERT(result != -1);
- fSubTypeId = result - gOffsets[fTypeId];
-}
-
void MeasureUnit::setTo(int32_t typeId, int32_t subTypeId) {
fTypeId = typeId;
fSubTypeId = subTypeId;
@@ -2302,6 +2309,20 @@ int32_t MeasureUnit::getOffset() const {
return gOffsets[fTypeId] + fSubTypeId;
}
+MeasureUnitImpl MeasureUnitImpl::copy(UErrorCode &status) const {
+ MeasureUnitImpl result;
+ result.complexity = complexity;
+ result.identifier.append(identifier, status);
+ for (int32_t i = 0; i < units.length(); i++) {
+ SingleUnitImpl *item = result.units.emplaceBack(*units[i]);
+ if (!item) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return result;
+ }
+ }
+ return result;
+}
+
U_NAMESPACE_END
#endif /* !UNCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/measunit_extra.cpp b/deps/icu-small/source/i18n/measunit_extra.cpp
index aeb60017a1..2eb3f06614 100644
--- a/deps/icu-small/source/i18n/measunit_extra.cpp
+++ b/deps/icu-small/source/i18n/measunit_extra.cpp
@@ -12,20 +12,25 @@
// Helpful in toString methods and elsewhere.
#define UNISTR_FROM_STRING_EXPLICIT
-#include <cstdlib>
+#include "charstr.h"
+#include "cmemory.h"
#include "cstring.h"
#include "measunit_impl.h"
+#include "resource.h"
#include "uarrsort.h"
#include "uassert.h"
#include "ucln_in.h"
#include "umutex.h"
-#include "unicode/errorcode.h"
+#include "unicode/bytestrie.h"
+#include "unicode/bytestriebuilder.h"
#include "unicode/localpointer.h"
#include "unicode/measunit.h"
-#include "unicode/ucharstrie.h"
-#include "unicode/ucharstriebuilder.h"
-
-#include "cstr.h"
+#include "unicode/stringpiece.h"
+#include "unicode/stringtriebuilder.h"
+#include "unicode/ures.h"
+#include "unicode/ustringtrie.h"
+#include "uresimp.h"
+#include <cstdlib>
U_NAMESPACE_BEGIN
@@ -60,7 +65,7 @@ enum InitialCompoundPart {
INITIAL_COMPOUND_PART_PER = kInitialCompoundPartOffset,
};
-// Trie value offset for powers like "square-", "cubic-", "p2-" etc.
+// Trie value offset for powers like "square-", "cubic-", "pow2-" etc.
constexpr int32_t kPowerPartOffset = 256;
enum PowerPart {
@@ -110,119 +115,101 @@ const struct SIPrefixStrings {
{ "yocto", UMEASURE_SI_PREFIX_YOCTO },
};
-// TODO(ICU-21059): Get this list from data
-const char16_t* const gSimpleUnits[] = {
- u"candela",
- u"carat",
- u"gram",
- u"ounce",
- u"ounce-troy",
- u"pound",
- u"kilogram",
- u"stone",
- u"ton",
- u"metric-ton",
- u"earth-mass",
- u"solar-mass",
- u"point",
- u"inch",
- u"foot",
- u"yard",
- u"meter",
- u"fathom",
- u"furlong",
- u"mile",
- u"nautical-mile",
- u"mile-scandinavian",
- u"100-kilometer",
- u"earth-radius",
- u"solar-radius",
- u"astronomical-unit",
- u"light-year",
- u"parsec",
- u"second",
- u"minute",
- u"hour",
- u"day",
- u"day-person",
- u"week",
- u"week-person",
- u"month",
- u"month-person",
- u"year",
- u"year-person",
- u"decade",
- u"century",
- u"ampere",
- u"fahrenheit",
- u"kelvin",
- u"celsius",
- u"arc-second",
- u"arc-minute",
- u"degree",
- u"radian",
- u"revolution",
- u"item",
- u"mole",
- u"permillion",
- u"permyriad",
- u"permille",
- u"percent",
- u"karat",
- u"portion",
- u"bit",
- u"byte",
- u"dot",
- u"pixel",
- u"em",
- u"hertz",
- u"newton",
- u"pound-force",
- u"pascal",
- u"bar",
- u"atmosphere",
- u"ofhg",
- u"electronvolt",
- u"dalton",
- u"joule",
- u"calorie",
- u"british-thermal-unit",
- u"foodcalorie",
- u"therm-us",
- u"watt",
- u"horsepower",
- u"solar-luminosity",
- u"volt",
- u"ohm",
- u"dunam",
- u"acre",
- u"hectare",
- u"teaspoon",
- u"tablespoon",
- u"fluid-ounce-imperial",
- u"fluid-ounce",
- u"cup",
- u"cup-metric",
- u"pint",
- u"pint-metric",
- u"quart",
- u"liter",
- u"gallon",
- u"gallon-imperial",
- u"bushel",
- u"barrel",
- u"knot",
- u"g-force",
- u"lux",
+/**
+ * A ResourceSink that collects simple unit identifiers from the keys of the
+ * convertUnits table into an array, and adds these values to a TrieBuilder,
+ * with associated values being their index into this array plus a specified
+ * offset, to a trie.
+ *
+ * Example code:
+ *
+ * UErrorCode status = U_ZERO_ERROR;
+ * BytesTrieBuilder b(status);
+ * const char *unitIdentifiers[200];
+ * SimpleUnitIdentifiersSink identifierSink(unitIdentifiers, 200, b, kTrieValueOffset);
+ * LocalUResourceBundlePointer unitsBundle(ures_openDirect(NULL, "units", &status));
+ * ures_getAllItemsWithFallback(unitsBundle.getAlias(), "convertUnits", identifierSink, status);
+ */
+class SimpleUnitIdentifiersSink : public icu::ResourceSink {
+ public:
+ /**
+ * Constructor.
+ * @param out Array of char* to which the simple unit identifiers will be
+ * saved.
+ * @param outSize The size of `out`.
+ * @param trieBuilder The trie builder to which the simple unit identifier
+ * should be added. The trie builder must outlive this resource sink.
+ * @param trieValueOffset This is added to the index of the identifier in
+ * the `out` array, before adding to `trieBuilder` as the value
+ * associated with the identifier.
+ */
+ explicit SimpleUnitIdentifiersSink(const char **out, int32_t outSize, BytesTrieBuilder &trieBuilder,
+ int32_t trieValueOffset)
+ : outArray(out), outSize(outSize), trieBuilder(trieBuilder), trieValueOffset(trieValueOffset),
+ outIndex(0) {
+ }
+
+ /**
+ * Adds the table keys found in value to the output vector.
+ * @param key The key of the resource passed to `value`: the second
+ * parameter of the ures_getAllItemsWithFallback() call.
+ * @param value Should be a ResourceTable value, if
+ * ures_getAllItemsWithFallback() was called correctly for this sink.
+ * @param noFallback Ignored.
+ * @param status The standard ICU error code output parameter.
+ */
+ void put(const char * /*key*/, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) {
+ ResourceTable table = value.getTable(status);
+ if (U_FAILURE(status)) return;
+
+ if (outIndex + table.getSize() > outSize) {
+ status = U_INDEX_OUTOFBOUNDS_ERROR;
+ return;
+ }
+
+ // Collect keys from the table resource.
+ const char *key;
+ for (int32_t i = 0; table.getKeyAndValue(i, key, value); ++i) {
+ U_ASSERT(i < table.getSize());
+ U_ASSERT(outIndex < outSize);
+ if (uprv_strcmp(key, "kilogram") == 0) {
+ // For parsing, we use "gram", the prefixless metric mass unit. We
+ // thus ignore the SI Base Unit of Mass: it exists due to being the
+ // mass conversion target unit, but not needed for MeasureUnit
+ // parsing.
+ continue;
+ }
+ outArray[outIndex] = key;
+ trieBuilder.add(key, trieValueOffset + outIndex, status);
+ outIndex++;
+ }
+ }
+
+ private:
+ const char **outArray;
+ int32_t outSize;
+ BytesTrieBuilder &trieBuilder;
+ int32_t trieValueOffset;
+
+ int32_t outIndex;
};
icu::UInitOnce gUnitExtrasInitOnce = U_INITONCE_INITIALIZER;
-char16_t* kSerializedUnitExtrasStemTrie = nullptr;
+// Array of simple unit IDs.
+//
+// The array memory itself is owned by this pointer, but the individual char* in
+// that array point at static memory. (Note that these char* are also returned
+// by SingleUnitImpl::getSimpleUnitID().)
+const char **gSimpleUnits = nullptr;
+
+char *gSerializedUnitExtrasStemTrie = nullptr;
UBool U_CALLCONV cleanupUnitExtras() {
- uprv_free(kSerializedUnitExtrasStemTrie);
- kSerializedUnitExtrasStemTrie = nullptr;
+ uprv_free(gSerializedUnitExtrasStemTrie);
+ gSerializedUnitExtrasStemTrie = nullptr;
+ uprv_free(gSimpleUnits);
+ gSimpleUnits = nullptr;
gUnitExtrasInitOnce.reset();
return TRUE;
}
@@ -230,55 +217,75 @@ UBool U_CALLCONV cleanupUnitExtras() {
void U_CALLCONV initUnitExtras(UErrorCode& status) {
ucln_i18n_registerCleanup(UCLN_I18N_UNIT_EXTRAS, cleanupUnitExtras);
- UCharsTrieBuilder b(status);
+ BytesTrieBuilder b(status);
if (U_FAILURE(status)) { return; }
// Add SI prefixes
for (const auto& siPrefixInfo : gSIPrefixStrings) {
- UnicodeString uSIPrefix(siPrefixInfo.string, -1, US_INV);
- b.add(uSIPrefix, siPrefixInfo.value + kSIPrefixOffset, status);
+ b.add(siPrefixInfo.string, siPrefixInfo.value + kSIPrefixOffset, status);
}
if (U_FAILURE(status)) { return; }
// Add syntax parts (compound, power prefixes)
- b.add(u"-per-", COMPOUND_PART_PER, status);
- b.add(u"-", COMPOUND_PART_TIMES, status);
- b.add(u"-and-", COMPOUND_PART_AND, status);
- b.add(u"per-", INITIAL_COMPOUND_PART_PER, status);
- b.add(u"square-", POWER_PART_P2, status);
- b.add(u"cubic-", POWER_PART_P3, status);
- b.add(u"p2-", POWER_PART_P2, status);
- b.add(u"p3-", POWER_PART_P3, status);
- b.add(u"p4-", POWER_PART_P4, status);
- b.add(u"p5-", POWER_PART_P5, status);
- b.add(u"p6-", POWER_PART_P6, status);
- b.add(u"p7-", POWER_PART_P7, status);
- b.add(u"p8-", POWER_PART_P8, status);
- b.add(u"p9-", POWER_PART_P9, status);
- b.add(u"p10-", POWER_PART_P10, status);
- b.add(u"p11-", POWER_PART_P11, status);
- b.add(u"p12-", POWER_PART_P12, status);
- b.add(u"p13-", POWER_PART_P13, status);
- b.add(u"p14-", POWER_PART_P14, status);
- b.add(u"p15-", POWER_PART_P15, status);
+ b.add("-per-", COMPOUND_PART_PER, status);
+ b.add("-", COMPOUND_PART_TIMES, status);
+ b.add("-and-", COMPOUND_PART_AND, status);
+ b.add("per-", INITIAL_COMPOUND_PART_PER, status);
+ b.add("square-", POWER_PART_P2, status);
+ b.add("cubic-", POWER_PART_P3, status);
+ b.add("pow2-", POWER_PART_P2, status);
+ b.add("pow3-", POWER_PART_P3, status);
+ b.add("pow4-", POWER_PART_P4, status);
+ b.add("pow5-", POWER_PART_P5, status);
+ b.add("pow6-", POWER_PART_P6, status);
+ b.add("pow7-", POWER_PART_P7, status);
+ b.add("pow8-", POWER_PART_P8, status);
+ b.add("pow9-", POWER_PART_P9, status);
+ b.add("pow10-", POWER_PART_P10, status);
+ b.add("pow11-", POWER_PART_P11, status);
+ b.add("pow12-", POWER_PART_P12, status);
+ b.add("pow13-", POWER_PART_P13, status);
+ b.add("pow14-", POWER_PART_P14, status);
+ b.add("pow15-", POWER_PART_P15, status);
+ if (U_FAILURE(status)) { return; }
+
+ // Add sanctioned simple units by offset: simple units all have entries in
+ // units/convertUnits resources.
+ // TODO(ICU-21059): confirm whether this is clean enough, or whether we need to
+ // filter units' validity list instead.
+ LocalUResourceBundlePointer unitsBundle(ures_openDirect(NULL, "units", &status));
+ LocalUResourceBundlePointer convertUnits(
+ ures_getByKey(unitsBundle.getAlias(), "convertUnits", NULL, &status));
if (U_FAILURE(status)) { return; }
- // Add sanctioned simple units by offset
- int32_t simpleUnitOffset = kSimpleUnitOffset;
- for (auto simpleUnit : gSimpleUnits) {
- b.add(simpleUnit, simpleUnitOffset++, status);
+ // Allocate enough space: with identifierSink below skipping kilogram, we're
+ // probably allocating one more than needed.
+ int32_t simpleUnitsCount = convertUnits.getAlias()->fSize;
+ int32_t arrayMallocSize = sizeof(char *) * simpleUnitsCount;
+ gSimpleUnits = static_cast<const char **>(uprv_malloc(arrayMallocSize));
+ if (gSimpleUnits == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
}
+ uprv_memset(gSimpleUnits, 0, arrayMallocSize);
+
+ // Populate gSimpleUnits and build the associated trie.
+ SimpleUnitIdentifiersSink identifierSink(gSimpleUnits, simpleUnitsCount, b, kSimpleUnitOffset);
+ ures_getAllItemsWithFallback(unitsBundle.getAlias(), "convertUnits", identifierSink, status);
// Build the CharsTrie
// TODO: Use SLOW or FAST here?
- UnicodeString result;
- b.buildUnicodeString(USTRINGTRIE_BUILD_FAST, result, status);
+ StringPiece result = b.buildStringPiece(USTRINGTRIE_BUILD_FAST, status);
if (U_FAILURE(status)) { return; }
// Copy the result into the global constant pointer
- size_t numBytes = result.length() * sizeof(char16_t);
- kSerializedUnitExtrasStemTrie = static_cast<char16_t*>(uprv_malloc(numBytes));
- uprv_memcpy(kSerializedUnitExtrasStemTrie, result.getBuffer(), numBytes);
+ size_t numBytes = result.length();
+ gSerializedUnitExtrasStemTrie = static_cast<char *>(uprv_malloc(numBytes));
+ if (gSerializedUnitExtrasStemTrie == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ uprv_memcpy(gSerializedUnitExtrasStemTrie, result.data(), numBytes);
}
class Token {
@@ -385,7 +392,7 @@ private:
// should live longer than this Parser - and the parser shouldn't return any
// references to that string.
StringPiece fSource;
- UCharsTrie fTrie;
+ BytesTrie fTrie;
// Set to true when we've seen a "-per-" or a "per-", after which all units
// are in the denominator. Until we find an "-and-", at which point the
@@ -395,7 +402,7 @@ private:
Parser() : fSource(""), fTrie(u"") {}
Parser(StringPiece source)
- : fSource(source), fTrie(kSerializedUnitExtrasStemTrie) {}
+ : fSource(source), fTrie(gSerializedUnitExtrasStemTrie) {}
inline bool hasNext() const {
return fIndex < fSource.length();
@@ -640,11 +647,11 @@ void serializeSingle(const SingleUnitImpl& singleUnit, bool first, CharString& o
} else if (posPower == 3) {
output.append("cubic-", status);
} else if (posPower < 10) {
- output.append('p', status);
+ output.append("pow", status);
output.append(posPower + '0', status);
output.append('-', status);
} else if (posPower <= 15) {
- output.append("p1", status);
+ output.append("pow1", status);
output.append('0' + (posPower % 10), status);
output.append('-', status);
} else {
@@ -666,7 +673,7 @@ void serializeSingle(const SingleUnitImpl& singleUnit, bool first, CharString& o
return;
}
- output.appendInvariantChars(gSimpleUnits[singleUnit.index], status);
+ output.append(singleUnit.getSimpleUnitID(), status);
}
/**
@@ -777,6 +784,17 @@ MeasureUnit SingleUnitImpl::build(UErrorCode& status) const {
return std::move(temp).build(status);
}
+const char *SingleUnitImpl::getSimpleUnitID() const {
+ return gSimpleUnits[index];
+}
+
+MeasureUnitImpl::MeasureUnitImpl(const MeasureUnitImpl &other, UErrorCode &status) {
+ *this = other.copy(status);
+}
+
+MeasureUnitImpl::MeasureUnitImpl(const SingleUnitImpl &singleUnit, UErrorCode &status) {
+ this->append(singleUnit, status);
+}
MeasureUnitImpl MeasureUnitImpl::forIdentifier(StringPiece identifier, UErrorCode& status) {
return Parser::from(identifier, status).parse(status);
@@ -813,12 +831,26 @@ bool MeasureUnitImpl::append(const SingleUnitImpl& singleUnit, UErrorCode& statu
return appendImpl(*this, singleUnit, status);
}
+MaybeStackVector<MeasureUnitImpl> MeasureUnitImpl::extractIndividualUnits(UErrorCode &status) const {
+ MaybeStackVector<MeasureUnitImpl> result;
+
+ if (this->complexity != UMeasureUnitComplexity::UMEASURE_UNIT_MIXED) {
+ result.emplaceBackAndCheckErrorCode(status, *this, status);
+ return result;
+ }
+
+ for (int32_t i = 0; i < units.length(); i++) {
+ result.emplaceBackAndCheckErrorCode(status, *units[i], status);
+ }
+
+ return result;
+}
+
MeasureUnit MeasureUnitImpl::build(UErrorCode& status) && {
serialize(*this, status);
return MeasureUnit(std::move(*this));
}
-
MeasureUnit MeasureUnit::forIdentifier(StringPiece identifier, UErrorCode& status) {
return Parser::from(identifier, status).parse(status).build(status);
}
@@ -876,11 +908,15 @@ MeasureUnit MeasureUnit::product(const MeasureUnit& other, UErrorCode& status) c
return std::move(impl).build(status);
}
-LocalArray<MeasureUnit> MeasureUnit::splitToSingleUnits(int32_t& outCount, UErrorCode& status) const {
+LocalArray<MeasureUnit> MeasureUnit::splitToSingleUnitsImpl(int32_t& outCount, UErrorCode& status) const {
MeasureUnitImpl temp;
const MeasureUnitImpl& impl = MeasureUnitImpl::forMeasureUnit(*this, temp, status);
outCount = impl.units.length();
MeasureUnit* arr = new MeasureUnit[outCount];
+ if (arr == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return LocalArray<MeasureUnit>();
+ }
for (int32_t i = 0; i < outCount; i++) {
arr[i] = impl.units[i]->build(status);
}
diff --git a/deps/icu-small/source/i18n/measunit_impl.h b/deps/icu-small/source/i18n/measunit_impl.h
index c886d3c29a..1024cd6554 100644
--- a/deps/icu-small/source/i18n/measunit_impl.h
+++ b/deps/icu-small/source/i18n/measunit_impl.h
@@ -22,7 +22,7 @@ static const char kDefaultCurrency8[] = "XXX";
/**
* A struct representing a single unit (optional SI prefix and dimensionality).
*/
-struct SingleUnitImpl : public UMemory {
+struct U_I18N_API SingleUnitImpl : public UMemory {
/**
* Gets a single unit from the MeasureUnit. If there are multiple single units, sets an error
* code and returns the base dimensionless unit. Parses if necessary.
@@ -33,6 +33,16 @@ struct SingleUnitImpl : public UMemory {
MeasureUnit build(UErrorCode& status) const;
/**
+ * Returns the "simple unit ID", without SI or dimensionality prefix: this
+ * instance may represent a square-kilometer, but only "meter" will be
+ * returned.
+ *
+ * The returned pointer points at memory that exists for the duration of the
+ * program's running.
+ */
+ const char *getSimpleUnitID() const;
+
+ /**
* Compare this SingleUnitImpl to another SingleUnitImpl for the sake of
* sorting and coalescing.
*
@@ -110,12 +120,27 @@ struct SingleUnitImpl : public UMemory {
int32_t dimensionality = 1;
};
+// Export explicit template instantiations of MaybeStackArray, MemoryPool and
+// MaybeStackVector. This is required when building DLLs for Windows. (See
+// datefmt.h, collationiterator.h, erarules.h and others for similar examples.)
+#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
+template class U_I18N_API MaybeStackArray<SingleUnitImpl*, 8>;
+template class U_I18N_API MemoryPool<SingleUnitImpl, 8>;
+template class U_I18N_API MaybeStackVector<SingleUnitImpl, 8>;
+#endif
/**
* Internal representation of measurement units. Capable of representing all complexities of units,
* including mixed and compound units.
*/
-struct MeasureUnitImpl : public UMemory {
+struct U_I18N_API MeasureUnitImpl : public UMemory {
+ MeasureUnitImpl() = default;
+ MeasureUnitImpl(MeasureUnitImpl &&other) = default;
+ MeasureUnitImpl(const MeasureUnitImpl &other, UErrorCode &status);
+ MeasureUnitImpl(const SingleUnitImpl &singleUnit, UErrorCode &status);
+
+ MeasureUnitImpl &operator=(MeasureUnitImpl &&other) noexcept = default;
+
/** Extract the MeasureUnitImpl from a MeasureUnit. */
static inline const MeasureUnitImpl* get(const MeasureUnit& measureUnit) {
return measureUnit.fImpl;
@@ -169,13 +194,17 @@ struct MeasureUnitImpl : public UMemory {
/**
* Create a copy of this MeasureUnitImpl. Don't use copy constructor to make this explicit.
*/
- inline MeasureUnitImpl copy(UErrorCode& status) const {
- MeasureUnitImpl result;
- result.complexity = complexity;
- result.units.appendAll(units, status);
- result.identifier.append(identifier, status);
- return result;
- }
+ MeasureUnitImpl copy(UErrorCode& status) const;
+
+ /**
+ * Extracts the list of all the individual units inside the `MeasureUnitImpl`.
+ * For example:
+ * - if the `MeasureUnitImpl` is `foot-per-hour`
+ * it will return a list of 1 {`foot-per-hour`}
+ * - if the `MeasureUnitImpl` is `foot-and-inch`
+ * it will return a list of 2 { `foot`, `inch`}
+ */
+ MaybeStackVector<MeasureUnitImpl> extractIndividualUnits(UErrorCode &status) const;
/** Mutates this MeasureUnitImpl to take the reciprocal. */
void takeReciprocal(UErrorCode& status);
@@ -206,7 +235,6 @@ struct MeasureUnitImpl : public UMemory {
CharString identifier;
};
-
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/measure.cpp b/deps/icu-small/source/i18n/measure.cpp
index bffa44215e..23adba1007 100644
--- a/deps/icu-small/source/i18n/measure.cpp
+++ b/deps/icu-small/source/i18n/measure.cpp
@@ -23,7 +23,7 @@ U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(Measure)
-Measure::Measure() {}
+Measure::Measure() : unit(nullptr) {}
Measure::Measure(const Formattable& _number, MeasureUnit* adoptedUnit,
UErrorCode& ec) :
@@ -35,7 +35,7 @@ Measure::Measure(const Formattable& _number, MeasureUnit* adoptedUnit,
}
Measure::Measure(const Measure& other) :
- UObject(other), unit(0) {
+ UObject(other), unit(nullptr) {
*this = other;
}
@@ -43,7 +43,11 @@ Measure& Measure::operator=(const Measure& other) {
if (this != &other) {
delete unit;
number = other.number;
- unit = other.unit->clone();
+ if (other.unit != nullptr) {
+ unit = other.unit->clone();
+ } else {
+ unit = nullptr;
+ }
}
return *this;
}
diff --git a/deps/icu-small/source/i18n/nfrs.cpp b/deps/icu-small/source/i18n/nfrs.cpp
index 659cfcbbf5..dd91d7833d 100644
--- a/deps/icu-small/source/i18n/nfrs.cpp
+++ b/deps/icu-small/source/i18n/nfrs.cpp
@@ -37,7 +37,7 @@ enum {
/** 0.x */
PROPER_FRACTION_RULE_INDEX = 2,
/** x.0 */
- MASTER_RULE_INDEX = 3,
+ DEFAULT_RULE_INDEX = 3,
/** Inf */
INFINITY_RULE_INDEX = 4,
/** NaN */
@@ -278,8 +278,8 @@ void NFRuleSet::setNonNumericalRule(NFRule *rule) {
else if (baseValue == NFRule::kProperFractionRule) {
setBestFractionRule(PROPER_FRACTION_RULE_INDEX, rule, TRUE);
}
- else if (baseValue == NFRule::kMasterRule) {
- setBestFractionRule(MASTER_RULE_INDEX, rule, TRUE);
+ else if (baseValue == NFRule::kDefaultRule) {
+ setBestFractionRule(DEFAULT_RULE_INDEX, rule, TRUE);
}
else if (baseValue == NFRule::kInfinityRule) {
delete nonNumericalRules[INFINITY_RULE_INDEX];
@@ -323,7 +323,7 @@ NFRuleSet::~NFRuleSet()
for (int i = 0; i < NON_NUMERICAL_RULE_LENGTH; i++) {
if (i != IMPROPER_FRACTION_RULE_INDEX
&& i != PROPER_FRACTION_RULE_INDEX
- && i != MASTER_RULE_INDEX)
+ && i != DEFAULT_RULE_INDEX)
{
delete nonNumericalRules[i];
}
@@ -375,7 +375,7 @@ NFRuleSet::setDecimalFormatSymbols(const DecimalFormatSymbols &newSymbols, UErro
rules[i]->setDecimalFormatSymbols(newSymbols, status);
}
// Switch the fraction rules to mirror the DecimalFormatSymbols.
- for (int32_t nonNumericalIdx = IMPROPER_FRACTION_RULE_INDEX; nonNumericalIdx <= MASTER_RULE_INDEX; nonNumericalIdx++) {
+ for (int32_t nonNumericalIdx = IMPROPER_FRACTION_RULE_INDEX; nonNumericalIdx <= DEFAULT_RULE_INDEX; nonNumericalIdx++) {
if (nonNumericalRules[nonNumericalIdx]) {
for (uint32_t fIdx = 0; fIdx < fractionRules.size(); fIdx++) {
NFRule *fractionRule = fractionRules[fIdx];
@@ -472,9 +472,9 @@ NFRuleSet::findDoubleRule(double number) const
}
}
- // if there's a master rule, use it to format the number
- if (nonNumericalRules[MASTER_RULE_INDEX]) {
- return nonNumericalRules[MASTER_RULE_INDEX];
+ // if there's a default rule, use it to format the number
+ if (nonNumericalRules[DEFAULT_RULE_INDEX]) {
+ return nonNumericalRules[DEFAULT_RULE_INDEX];
}
// and if we haven't yet returned a rule, use findNormalRule()
@@ -507,13 +507,13 @@ NFRuleSet::findNormalRule(int64_t number) const
// do them in findRule(), because the version of format() that
// takes a long bypasses findRule() and goes straight to this
// function. This function does skip the fraction rules since
- // we know the value is an integer (it also skips the master
+ // we know the value is an integer (it also skips the default
// rule, since it's considered a fraction rule. Skipping the
- // master rule in this function is also how we avoid infinite
+ // default rule in this function is also how we avoid infinite
// recursion)
// {dlf} unfortunately this fails if there are no rules except
- // special rules. If there are no rules, use the master rule.
+ // special rules. If there are no rules, use the default rule.
// binary-search the rule list for the applicable rule
// (a rule is used for all values from its base value to
@@ -553,8 +553,8 @@ NFRuleSet::findNormalRule(int64_t number) const
}
return result;
}
- // else use the master rule
- return nonNumericalRules[MASTER_RULE_INDEX];
+ // else use the default rule
+ return nonNumericalRules[DEFAULT_RULE_INDEX];
}
/**
@@ -792,7 +792,7 @@ NFRuleSet::appendRules(UnicodeString& result) const
if (nonNumericalRules[i]) {
if (rule->getBaseValue() == NFRule::kImproperFractionRule
|| rule->getBaseValue() == NFRule::kProperFractionRule
- || rule->getBaseValue() == NFRule::kMasterRule)
+ || rule->getBaseValue() == NFRule::kDefaultRule)
{
for (uint32_t fIdx = 0; fIdx < fractionRules.size(); fIdx++) {
NFRule *fractionRule = fractionRules[fIdx];
diff --git a/deps/icu-small/source/i18n/nfrs.h b/deps/icu-small/source/i18n/nfrs.h
index c56fc07078..e9b955ddff 100644
--- a/deps/icu-small/source/i18n/nfrs.h
+++ b/deps/icu-small/source/i18n/nfrs.h
@@ -36,7 +36,7 @@ public:
void parseRules(UnicodeString& rules, UErrorCode& status);
void setNonNumericalRule(NFRule *rule);
void setBestFractionRule(int32_t originalIndex, NFRule *newRule, UBool rememberRule);
- void makeIntoFractionRuleSet() { fIsFractionRuleSet = TRUE; }
+ void makeIntoFractionRuleSet() { fIsFractionRuleSet = true; }
~NFRuleSet();
@@ -93,11 +93,11 @@ int64_t util64_fromDouble(double d);
uint64_t util64_pow(uint32_t radix, uint16_t exponent);
// convert n to digit string in buffer, return length of string
-uint32_t util64_tou(int64_t n, UChar* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE);
+uint32_t util64_tou(int64_t n, UChar* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = false);
#ifdef RBNF_DEBUG
int64_t util64_utoi(const UChar* str, uint32_t radix = 10);
-uint32_t util64_toa(int64_t n, char* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE);
+uint32_t util64_toa(int64_t n, char* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = false);
int64_t util64_atoi(const char* str, uint32_t radix);
#endif
diff --git a/deps/icu-small/source/i18n/nfrule.cpp b/deps/icu-small/source/i18n/nfrule.cpp
index b5e7892d5e..cba41d14bb 100644
--- a/deps/icu-small/source/i18n/nfrule.cpp
+++ b/deps/icu-small/source/i18n/nfrule.cpp
@@ -153,7 +153,7 @@ NFRule::makeRules(UnicodeString& description,
if ((rule1->baseValue > 0
&& (rule1->baseValue % util64_pow(rule1->radix, rule1->exponent)) == 0)
|| rule1->getType() == kImproperFractionRule
- || rule1->getType() == kMasterRule) {
+ || rule1->getType() == kDefaultRule) {
// if it passes that test, new up the second rule. If the
// rule set both rules will belong to is a fraction rule
@@ -181,9 +181,9 @@ NFRule::makeRules(UnicodeString& description,
}
// if the description began with "x.0" and contains bracketed
- // text, it describes both the master rule and the
+ // text, it describes both the default rule and the
// improper fraction rule
- else if (rule1->getType() == kMasterRule) {
+ else if (rule1->getType() == kDefaultRule) {
rule2->baseValue = rule1->baseValue;
rule1->setType(kImproperFractionRule);
}
@@ -376,7 +376,7 @@ NFRule::parseRuleDescriptor(UnicodeString& description, UErrorCode& status)
decimalPoint = descriptor.charAt(1);
}
else if (firstChar == gX && lastChar == gZero) {
- setBaseValue(kMasterRule, status);
+ setBaseValue(kDefaultRule, status);
decimalPoint = descriptor.charAt(1);
}
else if (descriptor.compare(gNaN, 3) == 0) {
@@ -663,7 +663,7 @@ NFRule::_appendRuleText(UnicodeString& result) const
case kNegativeNumberRule: result.append(gMinusX, 2); break;
case kImproperFractionRule: result.append(gX).append(decimalPoint == 0 ? gDot : decimalPoint).append(gX); break;
case kProperFractionRule: result.append(gZero).append(decimalPoint == 0 ? gDot : decimalPoint).append(gX); break;
- case kMasterRule: result.append(gX).append(decimalPoint == 0 ? gDot : decimalPoint).append(gZero); break;
+ case kDefaultRule: result.append(gX).append(decimalPoint == 0 ? gDot : decimalPoint).append(gZero); break;
case kInfinityRule: result.append(gInf, 3); break;
case kNaNRule: result.append(gNaN, 3); break;
default:
@@ -1297,6 +1297,10 @@ NFRule::prefixLength(const UnicodeString& str, const UnicodeString& prefix, UErr
#if !UCONFIG_NO_COLLATION
// go through all this grief if we're in lenient-parse mode
if (formatter->isLenient()) {
+ // Check if non-lenient rule finds the text before call lenient parsing
+ if (str.startsWith(prefix)) {
+ return prefix.length();
+ }
// get the formatter's collator and use it to create two
// collation element iterators, one over the target string
// and another over the prefix (right now, we'll throw an
@@ -1505,9 +1509,15 @@ NFRule::findText(const UnicodeString& str,
return str.indexOf(key, startingAt);
}
else {
- // but if lenient parsing is turned ON, we've got some work
- // ahead of us
- return findTextLenient(str, key, startingAt, length);
+ // Check if non-lenient rule finds the text before call lenient parsing
+ *length = key.length();
+ int32_t pos = str.indexOf(key, startingAt);
+ if(pos >= 0) {
+ return pos;
+ } else {
+ // but if lenient parsing is turned ON, we've got some work ahead of us
+ return findTextLenient(str, key, startingAt, length);
+ }
}
}
diff --git a/deps/icu-small/source/i18n/nfrule.h b/deps/icu-small/source/i18n/nfrule.h
index 2b030390ea..12431c0dba 100644
--- a/deps/icu-small/source/i18n/nfrule.h
+++ b/deps/icu-small/source/i18n/nfrule.h
@@ -38,7 +38,7 @@ public:
kNegativeNumberRule = -1,
kImproperFractionRule = -2,
kProperFractionRule = -3,
- kMasterRule = -4,
+ kDefaultRule = -4,
kInfinityRule = -5,
kNaNRule = -6,
kOtherRule = -7
diff --git a/deps/icu-small/source/i18n/nfsubs.cpp b/deps/icu-small/source/i18n/nfsubs.cpp
index 3733f0ca74..e3ea393883 100644
--- a/deps/icu-small/source/i18n/nfsubs.cpp
+++ b/deps/icu-small/source/i18n/nfsubs.cpp
@@ -342,7 +342,7 @@ NFSubstitution::makeSubstitution(int32_t pos,
// IntegralPartSubstitution
else if (rule->getBaseValue() == NFRule::kImproperFractionRule
|| rule->getBaseValue() == NFRule::kProperFractionRule
- || rule->getBaseValue() == NFRule::kMasterRule) {
+ || rule->getBaseValue() == NFRule::kDefaultRule) {
return new IntegralPartSubstitution(pos, ruleSet, description, status);
}
@@ -371,7 +371,7 @@ NFSubstitution::makeSubstitution(int32_t pos,
// FractionalPartSubstitution
else if (rule->getBaseValue() == NFRule::kImproperFractionRule
|| rule->getBaseValue() == NFRule::kProperFractionRule
- || rule->getBaseValue() == NFRule::kMasterRule) {
+ || rule->getBaseValue() == NFRule::kDefaultRule) {
return new FractionalPartSubstitution(pos, ruleSet, description, status);
}
diff --git a/deps/icu-small/source/i18n/nounit.cpp b/deps/icu-small/source/i18n/nounit.cpp
deleted file mode 100644
index 1d4aa05506..0000000000
--- a/deps/icu-small/source/i18n/nounit.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-// © 2017 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html
-
-#include "unicode/nounit.h"
-#include "uassert.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-U_NAMESPACE_BEGIN
-
-UOBJECT_DEFINE_RTTI_IMPLEMENTATION(NoUnit)
-
-NoUnit U_EXPORT2 NoUnit::base() {
- return NoUnit("");
-}
-
-NoUnit U_EXPORT2 NoUnit::percent() {
- return NoUnit("percent");
-}
-
-NoUnit U_EXPORT2 NoUnit::permille() {
- return NoUnit("permille");
-}
-
-NoUnit::NoUnit(const char* subtype) {
- initNoUnit(subtype);
-}
-
-NoUnit::NoUnit(const NoUnit& other) : MeasureUnit(other) {
-}
-
-NoUnit* NoUnit::clone() const {
- return new NoUnit(*this);
-}
-
-NoUnit::~NoUnit() {
-}
-
-
-U_NAMESPACE_END
-
-#endif
diff --git a/deps/icu-small/source/i18n/number_asformat.h b/deps/icu-small/source/i18n/number_asformat.h
index 7b0a1dee6f..3a2fe3185b 100644
--- a/deps/icu-small/source/i18n/number_asformat.h
+++ b/deps/icu-small/source/i18n/number_asformat.h
@@ -25,7 +25,6 @@ namespace impl {
* A wrapper around LocalizedNumberFormatter implementing the Format interface, enabling improved
* compatibility with other APIs.
*
- * @draft ICU 62
* @see NumberFormatter
*/
class U_I18N_API LocalizedNumberFormatterAsFormat : public Format {
diff --git a/deps/icu-small/source/i18n/number_capi.cpp b/deps/icu-small/source/i18n/number_capi.cpp
index d61440d081..ef5f0a41ff 100644
--- a/deps/icu-small/source/i18n/number_capi.cpp
+++ b/deps/icu-small/source/i18n/number_capi.cpp
@@ -13,6 +13,7 @@
#include "number_utypes.h"
#include "numparse_types.h"
#include "formattedval_impl.h"
+#include "number_decnum.h"
#include "unicode/numberformatter.h"
#include "unicode/unumberformatter.h"
@@ -196,6 +197,23 @@ unumf_resultGetAllFieldPositions(const UFormattedNumber* uresult, UFieldPosition
result->fData.getAllFieldPositions(fpih, *ec);
}
+U_CAPI int32_t U_EXPORT2
+unumf_resultToDecimalNumber(
+ const UFormattedNumber* uresult,
+ char* dest,
+ int32_t destCapacity,
+ UErrorCode* ec) {
+ const auto* result = UFormattedNumberApiHelper::validate(uresult, *ec);
+ if (U_FAILURE(*ec)) {
+ return 0;
+ }
+ DecNum decnum;
+ return result->fData.quantity
+ .toDecNum(decnum, *ec)
+ .toCharString(*ec)
+ .extract(dest, destCapacity, *ec);
+}
+
U_CAPI void U_EXPORT2
unumf_close(UNumberFormatter* f) {
UErrorCode localStatus = U_ZERO_ERROR;
diff --git a/deps/icu-small/source/i18n/number_compact.cpp b/deps/icu-small/source/i18n/number_compact.cpp
index e1fef8feb5..d781b6fada 100644
--- a/deps/icu-small/source/i18n/number_compact.cpp
+++ b/deps/icu-small/source/i18n/number_compact.cpp
@@ -167,6 +167,11 @@ void CompactData::CompactDataSink::put(const char *key, ResourceValue &value, UB
if (U_FAILURE(status)) { return; }
for (int i4 = 0; pluralVariantsTable.getKeyAndValue(i4, key, value); ++i4) {
+ if (uprv_strcmp(key, "0") == 0 || uprv_strcmp(key, "1") == 0) {
+ // TODO(ICU-21258): Handle this case. For now, skip.
+ continue;
+ }
+
// Skip this magnitude/plural if we already have it from a child locale.
// Note: This also skips USE_FALLBACK entries.
StandardPlural::Form plural = StandardPlural::fromString(key, status);
diff --git a/deps/icu-small/source/i18n/number_currencysymbols.cpp b/deps/icu-small/source/i18n/number_currencysymbols.cpp
index 4d6fb2cb1d..9208427904 100644
--- a/deps/icu-small/source/i18n/number_currencysymbols.cpp
+++ b/deps/icu-small/source/i18n/number_currencysymbols.cpp
@@ -44,6 +44,16 @@ UnicodeString CurrencySymbols::getNarrowCurrencySymbol(UErrorCode& status) const
return loadSymbol(UCURR_NARROW_SYMBOL_NAME, status);
}
+UnicodeString CurrencySymbols::getFormalCurrencySymbol(UErrorCode& status) const {
+ // Note: currently no override is available for formal currency symbol
+ return loadSymbol(UCURR_FORMAL_SYMBOL_NAME, status);
+}
+
+UnicodeString CurrencySymbols::getVariantCurrencySymbol(UErrorCode& status) const {
+ // Note: currently no override is available for variant currency symbol
+ return loadSymbol(UCURR_VARIANT_SYMBOL_NAME, status);
+}
+
UnicodeString CurrencySymbols::getCurrencySymbol(UErrorCode& status) const {
if (!fCurrencySymbol.isBogus()) {
return fCurrencySymbol;
diff --git a/deps/icu-small/source/i18n/number_currencysymbols.h b/deps/icu-small/source/i18n/number_currencysymbols.h
index 9996bf96ae..7e38fdf828 100644
--- a/deps/icu-small/source/i18n/number_currencysymbols.h
+++ b/deps/icu-small/source/i18n/number_currencysymbols.h
@@ -31,6 +31,10 @@ class U_I18N_API CurrencySymbols : public UMemory {
UnicodeString getNarrowCurrencySymbol(UErrorCode& status) const;
+ UnicodeString getFormalCurrencySymbol(UErrorCode& status) const;
+
+ UnicodeString getVariantCurrencySymbol(UErrorCode& status) const;
+
UnicodeString getCurrencySymbol(UErrorCode& status) const;
UnicodeString getIntlCurrencySymbol(UErrorCode& status) const;
diff --git a/deps/icu-small/source/i18n/number_decimalquantity.cpp b/deps/icu-small/source/i18n/number_decimalquantity.cpp
index 5ce9c27cbf..75af5e9974 100644
--- a/deps/icu-small/source/i18n/number_decimalquantity.cpp
+++ b/deps/icu-small/source/i18n/number_decimalquantity.cpp
@@ -20,6 +20,7 @@
#include "charstr.h"
#include "number_utils.h"
#include "uassert.h"
+#include "util.h"
using namespace icu;
using namespace icu::number;
@@ -626,7 +627,7 @@ double DecimalQuantity::toDouble() const {
&count);
}
-void DecimalQuantity::toDecNum(DecNum& output, UErrorCode& status) const {
+DecNum& DecimalQuantity::toDecNum(DecNum& output, UErrorCode& status) const {
// Special handling for zero
if (precision == 0) {
output.setTo("0", status);
@@ -634,11 +635,15 @@ void DecimalQuantity::toDecNum(DecNum& output, UErrorCode& status) const {
// Use the BCD constructor. We need to do a little bit of work to convert, though.
// The decNumber constructor expects most-significant first, but we store least-significant first.
- MaybeStackArray<uint8_t, 20> ubcd(precision);
+ MaybeStackArray<uint8_t, 20> ubcd(precision, status);
+ if (U_FAILURE(status)) {
+ return output;
+ }
for (int32_t m = 0; m < precision; m++) {
ubcd[precision - m - 1] = static_cast<uint8_t>(getDigitPos(m));
}
output.setTo(ubcd.getAlias(), precision, scale, isNegative(), status);
+ return output;
}
void DecimalQuantity::truncate() {
@@ -1004,13 +1009,8 @@ void DecimalQuantity::shiftLeft(int32_t numDigits) {
}
if (usingBytes) {
ensureCapacity(precision + numDigits);
- int i = precision + numDigits - 1;
- for (; i >= numDigits; i--) {
- fBCD.bcdBytes.ptr[i] = fBCD.bcdBytes.ptr[i - numDigits];
- }
- for (; i >= 0; i--) {
- fBCD.bcdBytes.ptr[i] = 0;
- }
+ uprv_memmove(fBCD.bcdBytes.ptr + numDigits, fBCD.bcdBytes.ptr, precision);
+ uprv_memset(fBCD.bcdBytes.ptr, 0, numDigits);
} else {
fBCD.bcdLong <<= (numDigits * 4);
}
@@ -1324,7 +1324,11 @@ bool DecimalQuantity::operator==(const DecimalQuantity& other) const {
}
UnicodeString DecimalQuantity::toString() const {
- MaybeStackArray<char, 30> digits(precision + 1);
+ UErrorCode localStatus = U_ZERO_ERROR;
+ MaybeStackArray<char, 30> digits(precision + 1, localStatus);
+ if (U_FAILURE(localStatus)) {
+ return ICU_Utility::makeBogusString();
+ }
for (int32_t i = 0; i < precision; i++) {
digits[i] = getDigitPos(precision - i - 1) + '0';
}
diff --git a/deps/icu-small/source/i18n/number_decimalquantity.h b/deps/icu-small/source/i18n/number_decimalquantity.h
index 53a9eb33b2..839424775a 100644
--- a/deps/icu-small/source/i18n/number_decimalquantity.h
+++ b/deps/icu-small/source/i18n/number_decimalquantity.h
@@ -20,7 +20,7 @@ namespace impl {
class DecNum;
/**
- * An class for representing a number to be processed by the decimal formatting pipeline. Includes
+ * A class for representing a number to be processed by the decimal formatting pipeline. Includes
* methods for rounding, plural rules, and decimal digit extraction.
*
* <p>By design, this is NOT IMMUTABLE and NOT THREAD SAFE. It is intended to be an intermediate
@@ -209,7 +209,7 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory {
double toDouble() const;
/** Computes a DecNum representation of this DecimalQuantity, saving it to the output parameter. */
- void toDecNum(DecNum& output, UErrorCode& status) const;
+ DecNum& toDecNum(DecNum& output, UErrorCode& status) const;
DecimalQuantity &setToInt(int32_t n);
@@ -217,7 +217,13 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory {
DecimalQuantity &setToDouble(double n);
- /** decNumber is similar to BigDecimal in Java. */
+ /**
+ * Produces a DecimalQuantity that was parsed from a string by the decNumber
+ * C Library.
+ *
+ * decNumber is similar to BigDecimal in Java, and supports parsing strings
+ * such as "123.456621E+40".
+ */
DecimalQuantity &setToDecNumber(StringPiece n, UErrorCode& status);
/** Internal method if the caller already has a DecNum. */
diff --git a/deps/icu-small/source/i18n/number_decnum.h b/deps/icu-small/source/i18n/number_decnum.h
index 0c7399dbdd..3bb8d10780 100644
--- a/deps/icu-small/source/i18n/number_decnum.h
+++ b/deps/icu-small/source/i18n/number_decnum.h
@@ -9,6 +9,7 @@
#include "decNumber.h"
#include "charstr.h"
+#include "bytesinkutil.h"
U_NAMESPACE_BEGIN
@@ -57,6 +58,13 @@ class U_I18N_API DecNum : public UMemory {
void toString(ByteSink& output, UErrorCode& status) const;
+ inline CharString toCharString(UErrorCode& status) const {
+ CharString cstr;
+ CharStringByteSink sink(&cstr);
+ toString(sink, status);
+ return cstr;
+ }
+
inline const decNumber* getRawDecNumber() const {
return fData.getAlias();
}
diff --git a/deps/icu-small/source/i18n/number_fluent.cpp b/deps/icu-small/source/i18n/number_fluent.cpp
index 9cdb8b7156..8569a36e5b 100644
--- a/deps/icu-small/source/i18n/number_fluent.cpp
+++ b/deps/icu-small/source/i18n/number_fluent.cpp
@@ -13,6 +13,7 @@
#include "number_asformat.h"
#include "number_utils.h"
#include "number_utypes.h"
+#include "number_mapper.h"
#include "util.h"
#include "fphdlimp.h"
@@ -274,6 +275,20 @@ Derived NumberFormatterSettings<Derived>::scale(const Scale& scale)&& {
}
template<typename Derived>
+Derived NumberFormatterSettings<Derived>::usage(const StringPiece usage) const& {
+ Derived copy(*this);
+ copy.fMacros.usage.set(usage);
+ return copy;
+}
+
+template<typename Derived>
+Derived NumberFormatterSettings<Derived>::usage(const StringPiece usage)&& {
+ Derived move(std::move(*this));
+ move.fMacros.usage.set(usage);
+ return move;
+}
+
+template<typename Derived>
Derived NumberFormatterSettings<Derived>::padding(const Padder& padder) const& {
Derived copy(*this);
copy.fMacros.padder = padder;
@@ -400,7 +415,8 @@ LocalizedNumberFormatter::LocalizedNumberFormatter(const LNF& other)
LocalizedNumberFormatter::LocalizedNumberFormatter(const NFS<LNF>& other)
: NFS<LNF>(other) {
- // No additional fields to assign (let call count and compiled formatter reset to defaults)
+ UErrorCode localStatus = U_ZERO_ERROR; // Can't bubble up the error
+ lnfCopyHelper(static_cast<const LNF&>(other), localStatus);
}
LocalizedNumberFormatter::LocalizedNumberFormatter(LocalizedNumberFormatter&& src) U_NOEXCEPT
@@ -408,38 +424,25 @@ LocalizedNumberFormatter::LocalizedNumberFormatter(LocalizedNumberFormatter&& sr
LocalizedNumberFormatter::LocalizedNumberFormatter(NFS<LNF>&& src) U_NOEXCEPT
: NFS<LNF>(std::move(src)) {
- // For the move operators, copy over the compiled formatter.
- // Note: if the formatter is not compiled, call count information is lost.
- if (static_cast<LNF&&>(src).fCompiled != nullptr) {
- lnfMoveHelper(static_cast<LNF&&>(src));
- }
+ lnfMoveHelper(std::move(static_cast<LNF&&>(src)));
}
LocalizedNumberFormatter& LocalizedNumberFormatter::operator=(const LNF& other) {
NFS<LNF>::operator=(static_cast<const NFS<LNF>&>(other));
- // Reset to default values.
- clear();
+ UErrorCode localStatus = U_ZERO_ERROR; // Can't bubble up the error
+ lnfCopyHelper(other, localStatus);
return *this;
}
LocalizedNumberFormatter& LocalizedNumberFormatter::operator=(LNF&& src) U_NOEXCEPT {
NFS<LNF>::operator=(static_cast<NFS<LNF>&&>(src));
- // For the move operators, copy over the compiled formatter.
- // Note: if the formatter is not compiled, call count information is lost.
- if (static_cast<LNF&&>(src).fCompiled != nullptr) {
- // Formatter is compiled
- lnfMoveHelper(static_cast<LNF&&>(src));
- } else {
- clear();
- }
+ lnfMoveHelper(std::move(src));
return *this;
}
-void LocalizedNumberFormatter::clear() {
- // Reset to default values.
+void LocalizedNumberFormatter::resetCompiled() {
auto* callCount = reinterpret_cast<u_atomic_int32_t*>(fUnsafeCallCount);
umtx_storeRelease(*callCount, 0);
- delete fCompiled;
fCompiled = nullptr;
}
@@ -447,19 +450,56 @@ void LocalizedNumberFormatter::lnfMoveHelper(LNF&& src) {
// Copy over the compiled formatter and set call count to INT32_MIN as in computeCompiled().
// Don't copy the call count directly because doing so requires a loadAcquire/storeRelease.
// The bits themselves appear to be platform-dependent, so copying them might not be safe.
- auto* callCount = reinterpret_cast<u_atomic_int32_t*>(fUnsafeCallCount);
- umtx_storeRelease(*callCount, INT32_MIN);
delete fCompiled;
- fCompiled = src.fCompiled;
- // Reset the source object to leave it in a safe state.
- auto* srcCallCount = reinterpret_cast<u_atomic_int32_t*>(src.fUnsafeCallCount);
- umtx_storeRelease(*srcCallCount, 0);
- src.fCompiled = nullptr;
+ if (src.fCompiled != nullptr) {
+ auto* callCount = reinterpret_cast<u_atomic_int32_t*>(fUnsafeCallCount);
+ umtx_storeRelease(*callCount, INT32_MIN);
+ fCompiled = src.fCompiled;
+ // Reset the source object to leave it in a safe state.
+ src.resetCompiled();
+ } else {
+ resetCompiled();
+ }
+
+ // Unconditionally move the warehouse
+ delete fWarehouse;
+ fWarehouse = src.fWarehouse;
+ src.fWarehouse = nullptr;
+}
+
+void LocalizedNumberFormatter::lnfCopyHelper(const LNF&, UErrorCode& status) {
+ // When copying, always reset the compiled formatter.
+ delete fCompiled;
+ resetCompiled();
+
+ // If MacroProps has a reference to AffixPatternProvider, we need to copy it.
+ // If MacroProps has a reference to PluralRules, copy that one, too.
+ delete fWarehouse;
+ if (fMacros.affixProvider || fMacros.rules) {
+ LocalPointer<DecimalFormatWarehouse> warehouse(new DecimalFormatWarehouse(), status);
+ if (U_FAILURE(status)) {
+ fWarehouse = nullptr;
+ return;
+ }
+ if (fMacros.affixProvider) {
+ warehouse->affixProvider.setTo(fMacros.affixProvider, status);
+ fMacros.affixProvider = &warehouse->affixProvider.get();
+ }
+ if (fMacros.rules) {
+ warehouse->rules.adoptInsteadAndCheckErrorCode(
+ new PluralRules(*fMacros.rules), status);
+ fMacros.rules = warehouse->rules.getAlias();
+ }
+ fWarehouse = warehouse.orphan();
+ } else {
+ fWarehouse = nullptr;
+ }
}
LocalizedNumberFormatter::~LocalizedNumberFormatter() {
delete fCompiled;
+ delete fWarehouse;
}
LocalizedNumberFormatter::LocalizedNumberFormatter(const MacroProps& macros, const Locale& locale) {
@@ -480,123 +520,6 @@ LocalizedNumberFormatter UnlocalizedNumberFormatter::locale(const Locale& locale
return LocalizedNumberFormatter(std::move(fMacros), locale);
}
-SymbolsWrapper::SymbolsWrapper(const SymbolsWrapper& other) {
- doCopyFrom(other);
-}
-
-SymbolsWrapper::SymbolsWrapper(SymbolsWrapper&& src) U_NOEXCEPT {
- doMoveFrom(std::move(src));
-}
-
-SymbolsWrapper& SymbolsWrapper::operator=(const SymbolsWrapper& other) {
- if (this == &other) {
- return *this;
- }
- doCleanup();
- doCopyFrom(other);
- return *this;
-}
-
-SymbolsWrapper& SymbolsWrapper::operator=(SymbolsWrapper&& src) U_NOEXCEPT {
- if (this == &src) {
- return *this;
- }
- doCleanup();
- doMoveFrom(std::move(src));
- return *this;
-}
-
-SymbolsWrapper::~SymbolsWrapper() {
- doCleanup();
-}
-
-void SymbolsWrapper::setTo(const DecimalFormatSymbols& dfs) {
- doCleanup();
- fType = SYMPTR_DFS;
- fPtr.dfs = new DecimalFormatSymbols(dfs);
-}
-
-void SymbolsWrapper::setTo(const NumberingSystem* ns) {
- doCleanup();
- fType = SYMPTR_NS;
- fPtr.ns = ns;
-}
-
-void SymbolsWrapper::doCopyFrom(const SymbolsWrapper& other) {
- fType = other.fType;
- switch (fType) {
- case SYMPTR_NONE:
- // No action necessary
- break;
- case SYMPTR_DFS:
- // Memory allocation failures are exposed in copyErrorTo()
- if (other.fPtr.dfs != nullptr) {
- fPtr.dfs = new DecimalFormatSymbols(*other.fPtr.dfs);
- } else {
- fPtr.dfs = nullptr;
- }
- break;
- case SYMPTR_NS:
- // Memory allocation failures are exposed in copyErrorTo()
- if (other.fPtr.ns != nullptr) {
- fPtr.ns = new NumberingSystem(*other.fPtr.ns);
- } else {
- fPtr.ns = nullptr;
- }
- break;
- }
-}
-
-void SymbolsWrapper::doMoveFrom(SymbolsWrapper&& src) {
- fType = src.fType;
- switch (fType) {
- case SYMPTR_NONE:
- // No action necessary
- break;
- case SYMPTR_DFS:
- fPtr.dfs = src.fPtr.dfs;
- src.fPtr.dfs = nullptr;
- break;
- case SYMPTR_NS:
- fPtr.ns = src.fPtr.ns;
- src.fPtr.ns = nullptr;
- break;
- }
-}
-
-void SymbolsWrapper::doCleanup() {
- switch (fType) {
- case SYMPTR_NONE:
- // No action necessary
- break;
- case SYMPTR_DFS:
- delete fPtr.dfs;
- break;
- case SYMPTR_NS:
- delete fPtr.ns;
- break;
- }
-}
-
-bool SymbolsWrapper::isDecimalFormatSymbols() const {
- return fType == SYMPTR_DFS;
-}
-
-bool SymbolsWrapper::isNumberingSystem() const {
- return fType == SYMPTR_NS;
-}
-
-const DecimalFormatSymbols* SymbolsWrapper::getDecimalFormatSymbols() const {
- U_ASSERT(fType == SYMPTR_DFS);
- return fPtr.dfs;
-}
-
-const NumberingSystem* SymbolsWrapper::getNumberingSystem() const {
- U_ASSERT(fType == SYMPTR_NS);
- return fPtr.ns;
-}
-
-
FormattedNumber LocalizedNumberFormatter::formatInt(int64_t value, UErrorCode& status) const {
if (U_FAILURE(status)) { return FormattedNumber(U_ILLEGAL_ARGUMENT_ERROR); }
auto results = new UFormattedNumberData();
@@ -676,9 +599,9 @@ LocalizedNumberFormatter::formatDecimalQuantity(const DecimalQuantity& dq, UErro
void LocalizedNumberFormatter::formatImpl(impl::UFormattedNumberData* results, UErrorCode& status) const {
if (computeCompiled(status)) {
- fCompiled->format(results->quantity, results->getStringRef(), status);
+ fCompiled->format(results, status);
} else {
- NumberFormatterImpl::formatStatic(fMacros, results->quantity, results->getStringRef(), status);
+ NumberFormatterImpl::formatStatic(fMacros, results, status);
}
if (U_FAILURE(status)) {
return;
diff --git a/deps/icu-small/source/i18n/number_formatimpl.cpp b/deps/icu-small/source/i18n/number_formatimpl.cpp
index 5bba09cfb5..9a9f3c8b71 100644
--- a/deps/icu-small/source/i18n/number_formatimpl.cpp
+++ b/deps/icu-small/source/i18n/number_formatimpl.cpp
@@ -25,20 +25,20 @@ using namespace icu::number;
using namespace icu::number::impl;
-MicroPropsGenerator::~MicroPropsGenerator() = default;
-
-
NumberFormatterImpl::NumberFormatterImpl(const MacroProps& macros, UErrorCode& status)
: NumberFormatterImpl(macros, true, status) {
}
-int32_t NumberFormatterImpl::formatStatic(const MacroProps& macros, DecimalQuantity& inValue,
- FormattedStringBuilder& outString, UErrorCode& status) {
+int32_t NumberFormatterImpl::formatStatic(const MacroProps &macros, UFormattedNumberData *results,
+ UErrorCode &status) {
+ DecimalQuantity &inValue = results->quantity;
+ FormattedStringBuilder &outString = results->getStringRef();
NumberFormatterImpl impl(macros, false, status);
MicroProps& micros = impl.preProcessUnsafe(inValue, status);
if (U_FAILURE(status)) { return 0; }
int32_t length = writeNumber(micros, inValue, outString, 0, status);
length += writeAffixes(micros, outString, 0, length, status);
+ results->outputUnit = std::move(micros.outputUnit);
return length;
}
@@ -54,13 +54,15 @@ int32_t NumberFormatterImpl::getPrefixSuffixStatic(const MacroProps& macros, Sig
// The "unsafe" method simply re-uses fMicros, eliminating the extra copy operation.
// See MicroProps::processQuantity() for details.
-int32_t NumberFormatterImpl::format(DecimalQuantity& inValue, FormattedStringBuilder& outString,
- UErrorCode& status) const {
+int32_t NumberFormatterImpl::format(UFormattedNumberData *results, UErrorCode &status) const {
+ DecimalQuantity &inValue = results->quantity;
+ FormattedStringBuilder &outString = results->getStringRef();
MicroProps micros;
preProcess(inValue, micros, status);
if (U_FAILURE(status)) { return 0; }
int32_t length = writeNumber(micros, inValue, outString, 0, status);
length += writeAffixes(micros, outString, 0, length, status);
+ results->outputUnit = std::move(micros.outputUnit);
return length;
}
@@ -130,9 +132,10 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
// Pre-compute a few values for efficiency.
bool isCurrency = utils::unitIsCurrency(macros.unit);
- bool isNoUnit = utils::unitIsNoUnit(macros.unit);
+ bool isBaseUnit = utils::unitIsBaseUnit(macros.unit);
bool isPercent = utils::unitIsPercent(macros.unit);
bool isPermille = utils::unitIsPermille(macros.unit);
+ bool isCompactNotation = macros.notation.fType == Notation::NTN_COMPACT;
bool isAccounting =
macros.sign == UNUM_SIGN_ACCOUNTING || macros.sign == UNUM_SIGN_ACCOUNTING_ALWAYS ||
macros.sign == UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO;
@@ -144,8 +147,20 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
if (macros.unitWidth != UNUM_UNIT_WIDTH_COUNT) {
unitWidth = macros.unitWidth;
}
- bool isCldrUnit = !isCurrency && !isNoUnit &&
- (unitWidth == UNUM_UNIT_WIDTH_FULL_NAME || !(isPercent || isPermille));
+ // Use CLDR unit data for all MeasureUnits (not currency and not
+ // no-unit), except use the dedicated percent pattern for percent and
+ // permille. However, use the CLDR unit data for percent/permille if a
+ // long name was requested OR if compact notation is being used, since
+ // compact notation overrides the middle modifier (micros.modMiddle)
+ // normally used for the percent pattern.
+ bool isCldrUnit = !isCurrency
+ && !isBaseUnit
+ && (unitWidth == UNUM_UNIT_WIDTH_FULL_NAME
+ || !(isPercent || isPermille)
+ || isCompactNotation
+ );
+ bool isMixedUnit = isCldrUnit && (uprv_strcmp(macros.unit.getType(), "") == 0) &&
+ macros.unit.getComplexity(status) == UMEASURE_UNIT_MIXED;
// Select the numbering system.
LocalPointer<const NumberingSystem> nsLocal;
@@ -222,6 +237,27 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
/// START POPULATING THE DEFAULT MICROPROPS AND BUILDING THE MICROPROPS GENERATOR ///
/////////////////////////////////////////////////////////////////////////////////////
+ // Unit Preferences and Conversions as our first step
+ if (macros.usage.isSet()) {
+ if (!isCldrUnit) {
+ // We only support "usage" when the input unit is specified, and is
+ // a CLDR Unit.
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return nullptr;
+ }
+ auto usagePrefsHandler =
+ new UsagePrefsHandler(macros.locale, macros.unit, macros.usage.fUsage, chain, status);
+ fUsagePrefsHandler.adoptInsteadAndCheckErrorCode(usagePrefsHandler, status);
+ chain = fUsagePrefsHandler.getAlias();
+ } else if (isMixedUnit) {
+ MeasureUnitImpl temp;
+ const MeasureUnitImpl &outputUnit = MeasureUnitImpl::forMeasureUnit(macros.unit, temp, status);
+ auto unitConversionHandler =
+ new UnitConversionHandler(outputUnit.units[0]->build(status), macros.unit, chain, status);
+ fUnitConversionHandler.adoptInsteadAndCheckErrorCode(unitConversionHandler, status);
+ chain = fUnitConversionHandler.getAlias();
+ }
+
// Multiplier
if (macros.scale.isValid()) {
fMicros.helpers.multiplier.setAndChain(macros.scale, chain);
@@ -232,20 +268,18 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
Precision precision;
if (!macros.precision.isBogus()) {
precision = macros.precision;
- } else if (macros.notation.fType == Notation::NTN_COMPACT) {
+ } else if (isCompactNotation) {
precision = Precision::integer().withMinDigits(2);
} else if (isCurrency) {
precision = Precision::currency(UCURR_USAGE_STANDARD);
+ } else if (macros.usage.isSet()) {
+ // Bogus Precision - it will get set in the UsagePrefsHandler instead
+ precision = Precision();
} else {
precision = Precision::maxFraction(6);
}
UNumberFormatRoundingMode roundingMode;
- if (macros.roundingMode != kDefaultMode) {
- roundingMode = macros.roundingMode;
- } else {
- // Temporary until ICU 64
- roundingMode = precision.fRoundingMode;
- }
+ roundingMode = macros.roundingMode;
fMicros.rounder = {precision, roundingMode, currency, status};
if (U_FAILURE(status)) {
return nullptr;
@@ -254,7 +288,7 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
// Grouping strategy
if (!macros.grouper.isBogus()) {
fMicros.grouping = macros.grouper;
- } else if (macros.notation.fType == Notation::NTN_COMPACT) {
+ } else if (isCompactNotation) {
// Compact notation uses minGrouping by default since ICU 59
fMicros.grouping = Grouper::forStrategy(UNUM_GROUPING_MIN2);
} else {
@@ -330,7 +364,8 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
patternModifier->setSymbols(fMicros.symbols, currency, unitWidth, nullptr, status);
}
if (safe) {
- fImmutablePatternModifier.adoptInstead(patternModifier->createImmutable(status));
+ fImmutablePatternModifier.adoptInsteadAndCheckErrorCode(patternModifier->createImmutable(status),
+ status);
}
if (U_FAILURE(status)) {
return nullptr;
@@ -338,24 +373,34 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
// Outer modifier (CLDR units and currency long names)
if (isCldrUnit) {
- fLongNameHandler.adoptInstead(
- LongNameHandler::forMeasureUnit(
- macros.locale,
- macros.unit,
- macros.perUnit,
- unitWidth,
- resolvePluralRules(macros.rules, macros.locale, status),
- chain,
- status));
- chain = fLongNameHandler.getAlias();
+ if (macros.usage.isSet()) {
+ fLongNameMultiplexer.adoptInsteadAndCheckErrorCode(
+ LongNameMultiplexer::forMeasureUnits(
+ macros.locale, *fUsagePrefsHandler->getOutputUnits(), unitWidth,
+ resolvePluralRules(macros.rules, macros.locale, status), chain, status),
+ status);
+ chain = fLongNameMultiplexer.getAlias();
+ } else if (isMixedUnit) {
+ fMixedUnitLongNameHandler.adoptInsteadAndCheckErrorCode(new MixedUnitLongNameHandler(),
+ status);
+ MixedUnitLongNameHandler::forMeasureUnit(
+ macros.locale, macros.unit, unitWidth,
+ resolvePluralRules(macros.rules, macros.locale, status), chain,
+ fMixedUnitLongNameHandler.getAlias(), status);
+ chain = fMixedUnitLongNameHandler.getAlias();
+ } else {
+ fLongNameHandler.adoptInsteadAndCheckErrorCode(new LongNameHandler(), status);
+ LongNameHandler::forMeasureUnit(macros.locale, macros.unit, macros.perUnit, unitWidth,
+ resolvePluralRules(macros.rules, macros.locale, status),
+ chain, fLongNameHandler.getAlias(), status);
+ chain = fLongNameHandler.getAlias();
+ }
} else if (isCurrency && unitWidth == UNUM_UNIT_WIDTH_FULL_NAME) {
- fLongNameHandler.adoptInstead(
- LongNameHandler::forCurrencyLongNames(
- macros.locale,
- currency,
- resolvePluralRules(macros.rules, macros.locale, status),
- chain,
- status));
+ fLongNameHandler.adoptInsteadAndCheckErrorCode(
+ LongNameHandler::forCurrencyLongNames(
+ macros.locale, currency, resolvePluralRules(macros.rules, macros.locale, status), chain,
+ status),
+ status);
chain = fLongNameHandler.getAlias();
} else {
// No outer modifier required
@@ -366,7 +411,7 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
}
// Compact notation
- if (macros.notation.fType == Notation::NTN_COMPACT) {
+ if (isCompactNotation) {
CompactType compactType = (isCurrency && unitWidth != UNUM_UNIT_WIDTH_FULL_NAME)
? CompactType::TYPE_CURRENCY : CompactType::TYPE_DECIMAL;
auto newCompactHandler = new CompactHandler(
@@ -379,6 +424,9 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
safe,
chain,
status);
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
if (newCompactHandler == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return nullptr;
@@ -417,6 +465,7 @@ NumberFormatterImpl::resolvePluralRules(const PluralRules* rulesPtr, const Local
int32_t NumberFormatterImpl::writeAffixes(const MicroProps& micros, FormattedStringBuilder& string,
int32_t start, int32_t end, UErrorCode& status) {
+ U_ASSERT(micros.modOuter != nullptr);
// Always apply the inner modifier (which is "strong").
int32_t length = micros.modInner->apply(string, start, end, status);
if (micros.padding.isValid()) {
diff --git a/deps/icu-small/source/i18n/number_formatimpl.h b/deps/icu-small/source/i18n/number_formatimpl.h
index 084bc4a9d0..5cd549e54a 100644
--- a/deps/icu-small/source/i18n/number_formatimpl.h
+++ b/deps/icu-small/source/i18n/number_formatimpl.h
@@ -10,11 +10,13 @@
#include "number_types.h"
#include "formatted_string_builder.h"
#include "number_patternstring.h"
+#include "number_usageprefs.h"
#include "number_utils.h"
#include "number_patternmodifier.h"
#include "number_longnames.h"
#include "number_compact.h"
#include "number_microprops.h"
+#include "number_utypes.h"
U_NAMESPACE_BEGIN namespace number {
namespace impl {
@@ -34,9 +36,8 @@ class NumberFormatterImpl : public UMemory {
/**
* Builds and evaluates an "unsafe" MicroPropsGenerator, which is cheaper but can be used only once.
*/
- static int32_t
- formatStatic(const MacroProps &macros, DecimalQuantity &inValue, FormattedStringBuilder &outString,
- UErrorCode &status);
+ static int32_t formatStatic(const MacroProps &macros, UFormattedNumberData *results,
+ UErrorCode &status);
/**
* Prints only the prefix and suffix; used for DecimalFormat getters.
@@ -51,7 +52,7 @@ class NumberFormatterImpl : public UMemory {
/**
* Evaluates the "safe" MicroPropsGenerator created by "fromMacros".
*/
- int32_t format(DecimalQuantity& inValue, FormattedStringBuilder& outString, UErrorCode& status) const;
+ int32_t format(UFormattedNumberData *results, UErrorCode &status) const;
/**
* Like format(), but saves the result into an output MicroProps without additional processing.
@@ -82,7 +83,9 @@ class NumberFormatterImpl : public UMemory {
int32_t end, UErrorCode& status);
private:
- // Head of the MicroPropsGenerator linked list:
+ // Head of the MicroPropsGenerator linked list. Subclasses' processQuantity
+ // methods process this list in a parent-first order, such that the last
+ // item added, which this points to, typically has its logic executed last.
const MicroPropsGenerator *fMicroPropsGenerator = nullptr;
// Tail of the list:
@@ -90,13 +93,20 @@ class NumberFormatterImpl : public UMemory {
// Other fields possibly used by the number formatting pipeline:
// TODO: Convert more of these LocalPointers to value objects to reduce the number of news?
+ LocalPointer<const UsagePrefsHandler> fUsagePrefsHandler;
+ LocalPointer<const UnitConversionHandler> fUnitConversionHandler;
LocalPointer<const DecimalFormatSymbols> fSymbols;
LocalPointer<const PluralRules> fRules;
LocalPointer<const ParsedPatternInfo> fPatternInfo;
LocalPointer<const ScientificHandler> fScientificHandler;
LocalPointer<MutablePatternModifier> fPatternModifier;
LocalPointer<ImmutablePatternModifier> fImmutablePatternModifier;
- LocalPointer<const LongNameHandler> fLongNameHandler;
+ LocalPointer<LongNameHandler> fLongNameHandler;
+ // TODO: use a common base class that enables fLongNameHandler,
+ // fLongNameMultiplexer, and fMixedUnitLongNameHandler to be merged into one
+ // member?
+ LocalPointer<MixedUnitLongNameHandler> fMixedUnitLongNameHandler;
+ LocalPointer<const LongNameMultiplexer> fLongNameMultiplexer;
LocalPointer<const CompactHandler> fCompactHandler;
// Value objects possibly used by the number formatting pipeline:
diff --git a/deps/icu-small/source/i18n/number_grouping.cpp b/deps/icu-small/source/i18n/number_grouping.cpp
index 41f727a458..6b1642cfd3 100644
--- a/deps/icu-small/source/i18n/number_grouping.cpp
+++ b/deps/icu-small/source/i18n/number_grouping.cpp
@@ -64,6 +64,13 @@ Grouper Grouper::forProperties(const DecimalFormatProperties& properties) {
}
void Grouper::setLocaleData(const impl::ParsedPatternInfo &patternInfo, const Locale& locale) {
+ if (fMinGrouping == -2) {
+ fMinGrouping = getMinGroupingForLocale(locale);
+ } else if (fMinGrouping == -3) {
+ fMinGrouping = static_cast<int16_t>(uprv_max(2, getMinGroupingForLocale(locale)));
+ } else {
+ // leave fMinGrouping alone
+ }
if (fGrouping1 != -2 && fGrouping2 != -4) {
return;
}
@@ -76,13 +83,6 @@ void Grouper::setLocaleData(const impl::ParsedPatternInfo &patternInfo, const Lo
if (grouping3 == -1) {
grouping2 = grouping1;
}
- if (fMinGrouping == -2) {
- fMinGrouping = getMinGroupingForLocale(locale);
- } else if (fMinGrouping == -3) {
- fMinGrouping = static_cast<int16_t>(uprv_max(2, getMinGroupingForLocale(locale)));
- } else {
- // leave fMinGrouping alone
- }
fGrouping1 = grouping1;
fGrouping2 = grouping2;
}
diff --git a/deps/icu-small/source/i18n/number_integerwidth.cpp b/deps/icu-small/source/i18n/number_integerwidth.cpp
index d62aef444d..10b853423c 100644
--- a/deps/icu-small/source/i18n/number_integerwidth.cpp
+++ b/deps/icu-small/source/i18n/number_integerwidth.cpp
@@ -40,6 +40,9 @@ IntegerWidth IntegerWidth::truncateAt(int32_t maxInt) {
}
void IntegerWidth::apply(impl::DecimalQuantity& quantity, UErrorCode& status) const {
+ if (U_FAILURE(status)) {
+ return;
+ }
if (fHasError) {
status = U_ILLEGAL_ARGUMENT_ERROR;
} else if (fUnion.minMaxInt.fMaxInt == -1) {
diff --git a/deps/icu-small/source/i18n/number_longnames.cpp b/deps/icu-small/source/i18n/number_longnames.cpp
index bb32d0381a..3891d532de 100644
--- a/deps/icu-small/source/i18n/number_longnames.cpp
+++ b/deps/icu-small/source/i18n/number_longnames.cpp
@@ -10,6 +10,7 @@
#include "ureslocs.h"
#include "charstr.h"
#include "uresimp.h"
+#include "measunit_impl.h"
#include "number_longnames.h"
#include "number_microprops.h"
#include <algorithm>
@@ -22,8 +23,23 @@ using namespace icu::number::impl;
namespace {
+/**
+ * Display Name (this format has no placeholder).
+ *
+ * Used as an index into the LongNameHandler::simpleFormats array. Units
+ * resources cover the normal set of PluralRules keys, as well as `dnam` and
+ * `per` forms.
+ */
constexpr int32_t DNAM_INDEX = StandardPlural::Form::COUNT;
+/**
+ * "per" form (e.g. "{0} per day" is day's "per" form).
+ *
+ * Used as an index into the LongNameHandler::simpleFormats array. Units
+ * resources cover the normal set of PluralRules keys, as well as `dnam` and
+ * `per` forms.
+ */
constexpr int32_t PER_INDEX = StandardPlural::Form::COUNT + 1;
+// Number of keys in the array populated by PluralTableSink.
constexpr int32_t ARRAY_LENGTH = StandardPlural::Form::COUNT + 2;
static int32_t getIndex(const char* pluralKeyword, UErrorCode& status) {
@@ -38,6 +54,11 @@ static int32_t getIndex(const char* pluralKeyword, UErrorCode& status) {
}
}
+// Selects a string out of the `strings` array which corresponds to the
+// specified plural form, with fallback to the OTHER form.
+//
+// The `strings` array must have ARRAY_LENGTH items: one corresponding to each
+// of the plural forms, plus a display name ("dnam") and a "per" form.
static UnicodeString getWithPlural(
const UnicodeString* strings,
StandardPlural::Form plural,
@@ -87,6 +108,18 @@ class PluralTableSink : public ResourceSink {
// NOTE: outArray MUST have room for all StandardPlural values. No bounds checking is performed.
+/**
+ * Populates outArray with `locale`-specific values for `unit` through use of
+ * PluralTableSink. Only the set of basic units are supported!
+ *
+ * Reading from resources *unitsNarrow* and *unitsShort* (for width
+ * UNUM_UNIT_WIDTH_NARROW), or just *unitsShort* (for width
+ * UNUM_UNIT_WIDTH_SHORT). For other widths, it reads just "units".
+ *
+ * @param unit must have a type and subtype (i.e. it must be a unit listed in
+ * gTypes and gSubTypes in measunit.cpp).
+ * @param outArray must be of fixed length ARRAY_LENGTH.
+ */
void getMeasureData(const Locale &locale, const MeasureUnit &unit, const UNumberUnitWidth &width,
UnicodeString *outArray, UErrorCode &status) {
PluralTableSink sink(outArray);
@@ -184,78 +217,107 @@ UnicodeString getPerUnitFormat(const Locale& locale, const UNumberUnitWidth &wid
} // namespace
-LongNameHandler*
-LongNameHandler::forMeasureUnit(const Locale &loc, const MeasureUnit &unitRef, const MeasureUnit &perUnit,
- const UNumberUnitWidth &width, const PluralRules *rules,
- const MicroPropsGenerator *parent, UErrorCode &status) {
- if (uprv_strlen(unitRef.getType()) == 0 || uprv_strlen(perUnit.getType()) == 0) {
- // TODO(ICU-20941): Unsanctioned unit. Not yet fully supported. Set an error code.
- status = U_UNSUPPORTED_ERROR;
- return nullptr;
- }
+void LongNameHandler::forMeasureUnit(const Locale &loc, const MeasureUnit &unitRef,
+ const MeasureUnit &perUnit, const UNumberUnitWidth &width,
+ const PluralRules *rules, const MicroPropsGenerator *parent,
+ LongNameHandler *fillIn, UErrorCode &status) {
+ // Not valid for mixed units that aren't built-in units, and there should
+ // not be any built-in mixed units!
+ U_ASSERT(uprv_strcmp(unitRef.getType(), "") != 0 ||
+ unitRef.getComplexity(status) != UMEASURE_UNIT_MIXED);
+ U_ASSERT(fillIn != nullptr);
MeasureUnit unit = unitRef;
if (uprv_strcmp(perUnit.getType(), "none") != 0) {
// Compound unit: first try to simplify (e.g., meters per second is its own unit).
- bool isResolved = false;
- MeasureUnit resolved = MeasureUnit::resolveUnitPerUnit(unit, perUnit, &isResolved);
- if (isResolved) {
- unit = resolved;
+ MeasureUnit simplified = unit.product(perUnit.reciprocal(status), status);
+ if (uprv_strcmp(simplified.getType(), "") != 0) {
+ unit = simplified;
} else {
// No simplified form is available.
- return forCompoundUnit(loc, unit, perUnit, width, rules, parent, status);
+ forCompoundUnit(loc, unit, perUnit, width, rules, parent, fillIn, status);
+ return;
}
}
- auto* result = new LongNameHandler(rules, parent);
- if (result == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return nullptr;
+ if (uprv_strcmp(unit.getType(), "") == 0) {
+ // TODO(ICU-20941): Unsanctioned unit. Not yet fully supported. Set an
+ // error code. Once we support not-built-in units here, unitRef may be
+ // anything, but if not built-in, perUnit has to be "none".
+ status = U_UNSUPPORTED_ERROR;
+ return;
}
+
UnicodeString simpleFormats[ARRAY_LENGTH];
getMeasureData(loc, unit, width, simpleFormats, status);
- if (U_FAILURE(status)) { return result; }
- result->simpleFormatsToModifiers(simpleFormats, {UFIELD_CATEGORY_NUMBER, UNUM_MEASURE_UNIT_FIELD}, status);
- return result;
+ if (U_FAILURE(status)) {
+ return;
+ }
+ fillIn->rules = rules;
+ fillIn->parent = parent;
+ fillIn->simpleFormatsToModifiers(simpleFormats, {UFIELD_CATEGORY_NUMBER, UNUM_MEASURE_UNIT_FIELD},
+ status);
}
-LongNameHandler*
-LongNameHandler::forCompoundUnit(const Locale &loc, const MeasureUnit &unit, const MeasureUnit &perUnit,
- const UNumberUnitWidth &width, const PluralRules *rules,
- const MicroPropsGenerator *parent, UErrorCode &status) {
- auto* result = new LongNameHandler(rules, parent);
- if (result == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return nullptr;
+void LongNameHandler::forCompoundUnit(const Locale &loc, const MeasureUnit &unit,
+ const MeasureUnit &perUnit, const UNumberUnitWidth &width,
+ const PluralRules *rules, const MicroPropsGenerator *parent,
+ LongNameHandler *fillIn, UErrorCode &status) {
+ if (uprv_strcmp(unit.getType(), "") == 0 || uprv_strcmp(perUnit.getType(), "") == 0) {
+ // TODO(ICU-20941): Unsanctioned unit. Not yet fully supported. Set an
+ // error code. Once we support not-built-in units here, unitRef may be
+ // anything, but if not built-in, perUnit has to be "none".
+ status = U_UNSUPPORTED_ERROR;
+ return;
+ }
+ if (fillIn == nullptr) {
+ status = U_INTERNAL_PROGRAM_ERROR;
+ return;
}
UnicodeString primaryData[ARRAY_LENGTH];
getMeasureData(loc, unit, width, primaryData, status);
- if (U_FAILURE(status)) { return result; }
+ if (U_FAILURE(status)) {
+ return;
+ }
UnicodeString secondaryData[ARRAY_LENGTH];
getMeasureData(loc, perUnit, width, secondaryData, status);
- if (U_FAILURE(status)) { return result; }
+ if (U_FAILURE(status)) {
+ return;
+ }
UnicodeString perUnitFormat;
if (!secondaryData[PER_INDEX].isBogus()) {
perUnitFormat = secondaryData[PER_INDEX];
} else {
UnicodeString rawPerUnitFormat = getPerUnitFormat(loc, width, status);
- if (U_FAILURE(status)) { return result; }
+ if (U_FAILURE(status)) {
+ return;
+ }
// rawPerUnitFormat is something like "{0}/{1}"; we need to substitute in the secondary unit.
SimpleFormatter compiled(rawPerUnitFormat, 2, 2, status);
- if (U_FAILURE(status)) { return result; }
+ if (U_FAILURE(status)) {
+ return;
+ }
UnicodeString secondaryFormat = getWithPlural(secondaryData, StandardPlural::Form::ONE, status);
- if (U_FAILURE(status)) { return result; }
+ if (U_FAILURE(status)) {
+ return;
+ }
// Some "one" pattern may not contain "{0}". For example in "ar" or "ne" locale.
SimpleFormatter secondaryCompiled(secondaryFormat, 0, 1, status);
- if (U_FAILURE(status)) { return result; }
+ if (U_FAILURE(status)) {
+ return;
+ }
UnicodeString secondaryString = secondaryCompiled.getTextWithNoArguments().trim();
// TODO: Why does UnicodeString need to be explicit in the following line?
compiled.format(UnicodeString(u"{0}"), secondaryString, perUnitFormat, status);
- if (U_FAILURE(status)) { return result; }
+ if (U_FAILURE(status)) {
+ return;
+ }
}
- result->multiSimpleFormatsToModifiers(primaryData, perUnitFormat, {UFIELD_CATEGORY_NUMBER, UNUM_MEASURE_UNIT_FIELD}, status);
- return result;
+ fillIn->rules = rules;
+ fillIn->parent = parent;
+ fillIn->multiSimpleFormatsToModifiers(primaryData, perUnitFormat,
+ {UFIELD_CATEGORY_NUMBER, UNUM_MEASURE_UNIT_FIELD}, status);
}
UnicodeString LongNameHandler::getUnitDisplayName(
@@ -338,7 +400,9 @@ void LongNameHandler::multiSimpleFormatsToModifiers(const UnicodeString *leadFor
void LongNameHandler::processQuantity(DecimalQuantity &quantity, MicroProps &micros,
UErrorCode &status) const {
- parent->processQuantity(quantity, micros, status);
+ if (parent != NULL) {
+ parent->processQuantity(quantity, micros, status);
+ }
StandardPlural::Form pluralForm = utils::getPluralSafe(micros.rounder, rules, quantity, status);
micros.modOuter = &fModifiers[pluralForm];
}
@@ -347,4 +411,199 @@ const Modifier* LongNameHandler::getModifier(Signum /*signum*/, StandardPlural::
return &fModifiers[plural];
}
+void MixedUnitLongNameHandler::forMeasureUnit(const Locale &loc, const MeasureUnit &mixedUnit,
+ const UNumberUnitWidth &width, const PluralRules *rules,
+ const MicroPropsGenerator *parent,
+ MixedUnitLongNameHandler *fillIn, UErrorCode &status) {
+ U_ASSERT(mixedUnit.getComplexity(status) == UMEASURE_UNIT_MIXED);
+ U_ASSERT(fillIn != nullptr);
+
+ MeasureUnitImpl temp;
+ const MeasureUnitImpl& impl = MeasureUnitImpl::forMeasureUnit(mixedUnit, temp, status);
+ fillIn->fMixedUnitCount = impl.units.length();
+ fillIn->fMixedUnitData.adoptInstead(new UnicodeString[fillIn->fMixedUnitCount * ARRAY_LENGTH]);
+ for (int32_t i = 0; i < fillIn->fMixedUnitCount; i++) {
+ // Grab data for each of the components.
+ UnicodeString *unitData = &fillIn->fMixedUnitData[i * ARRAY_LENGTH];
+ getMeasureData(loc, impl.units[i]->build(status), width, unitData, status);
+ }
+
+ UListFormatterWidth listWidth = ULISTFMT_WIDTH_SHORT;
+ if (width == UNUM_UNIT_WIDTH_NARROW) {
+ listWidth = ULISTFMT_WIDTH_NARROW;
+ } else if (width == UNUM_UNIT_WIDTH_FULL_NAME) {
+ // This might be the same as SHORT in most languages:
+ listWidth = ULISTFMT_WIDTH_WIDE;
+ }
+ fillIn->fListFormatter.adoptInsteadAndCheckErrorCode(
+ ListFormatter::createInstance(loc, ULISTFMT_TYPE_UNITS, listWidth, status), status);
+ fillIn->rules = rules;
+ fillIn->parent = parent;
+
+ // We need a localised NumberFormatter for the integers of the bigger units
+ // (providing Arabic numerals, for example).
+ fillIn->fIntegerFormatter = NumberFormatter::withLocale(loc);
+}
+
+void MixedUnitLongNameHandler::processQuantity(DecimalQuantity &quantity, MicroProps &micros,
+ UErrorCode &status) const {
+ U_ASSERT(fMixedUnitCount > 1);
+ if (parent != nullptr) {
+ parent->processQuantity(quantity, micros, status);
+ }
+ micros.modOuter = getMixedUnitModifier(quantity, micros, status);
+}
+
+const Modifier *MixedUnitLongNameHandler::getMixedUnitModifier(DecimalQuantity &quantity,
+ MicroProps &micros,
+ UErrorCode &status) const {
+ if (micros.mixedMeasuresCount == 0) {
+ U_ASSERT(micros.mixedMeasuresCount > 0); // Mixed unit: we must have more than one unit value
+ status = U_UNSUPPORTED_ERROR;
+ return &micros.helpers.emptyWeakModifier;
+ }
+ // If we don't have at least one mixedMeasure, the LongNameHandler would be
+ // sufficient and we shouldn't be running MixedUnitLongNameHandler code:
+ U_ASSERT(micros.mixedMeasuresCount > 0);
+ // mixedMeasures does not contain the last value:
+ U_ASSERT(fMixedUnitCount == micros.mixedMeasuresCount + 1);
+ U_ASSERT(fListFormatter.isValid());
+
+ // Algorithm:
+ //
+ // For the mixed-units measurement of: "3 yard, 1 foot, 2.6 inch", we should
+ // find "3 yard" and "1 foot" in micros.mixedMeasures.
+ //
+ // Obtain long-names with plural forms corresponding to measure values:
+ // * {0} yards, {0} foot, {0} inches
+ //
+ // Format the integer values appropriately and modify with the format
+ // strings:
+ // - 3 yards, 1 foot
+ //
+ // Use ListFormatter to combine, with one placeholder:
+ // - 3 yards, 1 foot and {0} inches
+ //
+ // Return a SimpleModifier for this pattern, letting the rest of the
+ // pipeline take care of the remaining inches.
+
+ LocalArray<UnicodeString> outputMeasuresList(new UnicodeString[fMixedUnitCount], status);
+ if (U_FAILURE(status)) {
+ return &micros.helpers.emptyWeakModifier;
+ }
+
+ for (int32_t i = 0; i < micros.mixedMeasuresCount; i++) {
+ DecimalQuantity fdec;
+ fdec.setToLong(micros.mixedMeasures[i]);
+ if (i > 0 && fdec.isNegative()) {
+ // If numbers are negative, only the first number needs to have its
+ // negative sign formatted.
+ fdec.negate();
+ }
+ StandardPlural::Form pluralForm = utils::getStandardPlural(rules, fdec);
+
+ UnicodeString simpleFormat =
+ getWithPlural(&fMixedUnitData[i * ARRAY_LENGTH], pluralForm, status);
+ SimpleFormatter compiledFormatter(simpleFormat, 0, 1, status);
+
+ UnicodeString num;
+ auto appendable = UnicodeStringAppendable(num);
+ fIntegerFormatter.formatDecimalQuantity(fdec, status).appendTo(appendable, status);
+ compiledFormatter.format(num, outputMeasuresList[i], status);
+ // TODO(icu-units#67): fix field positions
+ }
+
+ // Reiterated: we have at least one mixedMeasure:
+ U_ASSERT(micros.mixedMeasuresCount > 0);
+ // Thus if negative, a negative has already been formatted:
+ if (quantity.isNegative()) {
+ quantity.negate();
+ }
+
+ UnicodeString *finalSimpleFormats = &fMixedUnitData[(fMixedUnitCount - 1) * ARRAY_LENGTH];
+ StandardPlural::Form finalPlural = utils::getPluralSafe(micros.rounder, rules, quantity, status);
+ UnicodeString finalSimpleFormat = getWithPlural(finalSimpleFormats, finalPlural, status);
+ SimpleFormatter finalFormatter(finalSimpleFormat, 0, 1, status);
+ finalFormatter.format(UnicodeString(u"{0}"), outputMeasuresList[fMixedUnitCount - 1], status);
+
+ // Combine list into a "premixed" pattern
+ UnicodeString premixedFormatPattern;
+ fListFormatter->format(outputMeasuresList.getAlias(), fMixedUnitCount, premixedFormatPattern,
+ status);
+ SimpleFormatter premixedCompiled(premixedFormatPattern, 0, 1, status);
+ if (U_FAILURE(status)) {
+ return &micros.helpers.emptyWeakModifier;
+ }
+
+ // TODO(icu-units#67): fix field positions
+ // Return a SimpleModifier for the "premixed" pattern
+ micros.helpers.mixedUnitModifier =
+ SimpleModifier(premixedCompiled, kUndefinedField, false, {this, SIGNUM_POS_ZERO, finalPlural});
+ return &micros.helpers.mixedUnitModifier;
+}
+
+const Modifier *MixedUnitLongNameHandler::getModifier(Signum /*signum*/,
+ StandardPlural::Form /*plural*/) const {
+ // TODO(units): investigate this method when investigating where
+ // LongNameHandler::getModifier() gets used. To be sure it remains
+ // unreachable:
+ UPRV_UNREACHABLE;
+ return nullptr;
+}
+
+LongNameMultiplexer *
+LongNameMultiplexer::forMeasureUnits(const Locale &loc, const MaybeStackVector<MeasureUnit> &units,
+ const UNumberUnitWidth &width, const PluralRules *rules,
+ const MicroPropsGenerator *parent, UErrorCode &status) {
+ LocalPointer<LongNameMultiplexer> result(new LongNameMultiplexer(parent), status);
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
+ U_ASSERT(units.length() > 0);
+ if (result->fHandlers.resize(units.length()) == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return nullptr;
+ }
+ result->fMeasureUnits.adoptInstead(new MeasureUnit[units.length()]);
+ for (int32_t i = 0, length = units.length(); i < length; i++) {
+ const MeasureUnit& unit = *units[i];
+ result->fMeasureUnits[i] = unit;
+ if (unit.getComplexity(status) == UMEASURE_UNIT_MIXED) {
+ MixedUnitLongNameHandler *mlnh = result->fMixedUnitHandlers.createAndCheckErrorCode(status);
+ MixedUnitLongNameHandler::forMeasureUnit(loc, unit, width, rules, NULL, mlnh, status);
+ result->fHandlers[i] = mlnh;
+ } else {
+ LongNameHandler *lnh = result->fLongNameHandlers.createAndCheckErrorCode(status);
+ LongNameHandler::forMeasureUnit(loc, unit, MeasureUnit(), width, rules, NULL, lnh, status);
+ result->fHandlers[i] = lnh;
+ }
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
+ }
+ return result.orphan();
+}
+
+void LongNameMultiplexer::processQuantity(DecimalQuantity &quantity, MicroProps &micros,
+ UErrorCode &status) const {
+ // We call parent->processQuantity() from the Multiplexer, instead of
+ // letting LongNameHandler handle it: we don't know which LongNameHandler to
+ // call until we've called the parent!
+ fParent->processQuantity(quantity, micros, status);
+
+ // Call the correct LongNameHandler based on outputUnit
+ for (int i = 0; i < fHandlers.getCapacity(); i++) {
+ if (fMeasureUnits[i] == micros.outputUnit) {
+ fHandlers[i]->processQuantity(quantity, micros, status);
+ return;
+ }
+ }
+ if (U_FAILURE(status)) {
+ return;
+ }
+ // We shouldn't receive any outputUnit for which we haven't already got a
+ // LongNameHandler:
+ status = U_INTERNAL_PROGRAM_ERROR;
+}
+
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/number_longnames.h b/deps/icu-small/source/i18n/number_longnames.h
index a19425aa26..67f2316a9c 100644
--- a/deps/icu-small/source/i18n/number_longnames.h
+++ b/deps/icu-small/source/i18n/number_longnames.h
@@ -7,6 +7,8 @@
#ifndef __NUMBER_LONGNAMES_H__
#define __NUMBER_LONGNAMES_H__
+#include "cmemory.h"
+#include "unicode/listformatter.h"
#include "unicode/uversion.h"
#include "number_utils.h"
#include "number_modifiers.h"
@@ -33,34 +35,206 @@ class LongNameHandler : public MicroPropsGenerator, public ModifierStore, public
forCurrencyLongNames(const Locale &loc, const CurrencyUnit &currency, const PluralRules *rules,
const MicroPropsGenerator *parent, UErrorCode &status);
- static LongNameHandler*
- forMeasureUnit(const Locale &loc, const MeasureUnit &unit, const MeasureUnit &perUnit,
- const UNumberUnitWidth &width, const PluralRules *rules,
- const MicroPropsGenerator *parent, UErrorCode &status);
-
+ /**
+ * Construct a localized LongNameHandler for the specified MeasureUnit.
+ *
+ * Compound units can be constructed via `unit` and `perUnit`. Both of these
+ * must then be built-in units.
+ *
+ * Mixed units are not supported, use MixedUnitLongNameHandler::forMeasureUnit.
+ *
+ * This function uses a fillIn intead of returning a pointer, because we
+ * want to fill in instances in a MemoryPool (which cannot adopt pointers it
+ * didn't create itself).
+ *
+ * @param loc The desired locale.
+ * @param unit The measure unit to construct a LongNameHandler for. If
+ * `perUnit` is also defined, `unit` must not be a mixed unit.
+ * @param perUnit If `unit` is a mixed unit, `perUnit` must be "none".
+ * @param width Specifies the desired unit rendering.
+ * @param rules Does not take ownership.
+ * @param parent Does not take ownership.
+ * @param fillIn Required.
+ */
+ static void forMeasureUnit(const Locale &loc, const MeasureUnit &unit, const MeasureUnit &perUnit,
+ const UNumberUnitWidth &width, const PluralRules *rules,
+ const MicroPropsGenerator *parent, LongNameHandler *fillIn,
+ UErrorCode &status);
+
+ /**
+ * Selects the plural-appropriate Modifier from the set of fModifiers based
+ * on the plural form.
+ */
void
processQuantity(DecimalQuantity &quantity, MicroProps &micros, UErrorCode &status) const U_OVERRIDE;
+ // TODO(units): investigate whether we might run into Mixed Unit trouble
+ // with this. This override for ModifierStore::getModifier does not support
+ // mixed units: investigate under which circumstances it gets called (check
+ // both ImmutablePatternModifier and in NumberRangeFormatterImpl).
const Modifier* getModifier(Signum signum, StandardPlural::Form plural) const U_OVERRIDE;
private:
+ // A set of pre-computed modifiers, one for each plural form.
SimpleModifier fModifiers[StandardPlural::Form::COUNT];
+ // Not owned
const PluralRules *rules;
+ // Not owned
const MicroPropsGenerator *parent;
LongNameHandler(const PluralRules *rules, const MicroPropsGenerator *parent)
- : rules(rules), parent(parent) {}
+ : rules(rules), parent(parent) {
+ }
- static LongNameHandler*
- forCompoundUnit(const Locale &loc, const MeasureUnit &unit, const MeasureUnit &perUnit,
- const UNumberUnitWidth &width, const PluralRules *rules,
- const MicroPropsGenerator *parent, UErrorCode &status);
+ LongNameHandler() : rules(nullptr), parent(nullptr) {
+ }
+
+ // Enables MemoryPool<LongNameHandler>::emplaceBack(): requires access to
+ // the private constructors.
+ friend class MemoryPool<LongNameHandler>;
+
+ // Allow macrosToMicroGenerator to call the private default constructor.
+ friend class NumberFormatterImpl;
+ // Fills in LongNameHandler fields for formatting compound units identified
+ // via `unit` and `perUnit`. Both `unit` and `perUnit` need to be built-in
+ // units (for which data exists).
+ static void forCompoundUnit(const Locale &loc, const MeasureUnit &unit, const MeasureUnit &perUnit,
+ const UNumberUnitWidth &width, const PluralRules *rules,
+ const MicroPropsGenerator *parent, LongNameHandler *fillIn,
+ UErrorCode &status);
+
+ // Sets fModifiers to use the patterns from `simpleFormats`.
void simpleFormatsToModifiers(const UnicodeString *simpleFormats, Field field, UErrorCode &status);
+
+ // Sets fModifiers to a combination of `leadFormats` (one per plural form)
+ // and `trailFormat` appended to each.
+ //
+ // With a leadFormat of "{0}m" and a trailFormat of "{0}/s", it produces a
+ // pattern of "{0}m/s" by inserting the leadFormat pattern into trailFormat.
void multiSimpleFormatsToModifiers(const UnicodeString *leadFormats, UnicodeString trailFormat,
Field field, UErrorCode &status);
};
+// Similar to LongNameHandler, but only for MIXED units.
+class MixedUnitLongNameHandler : public MicroPropsGenerator, public ModifierStore, public UMemory {
+ public:
+ /**
+ * Construct a localized MixedUnitLongNameHandler for the specified
+ * MeasureUnit. It must be a MIXED unit.
+ *
+ * This function uses a fillIn intead of returning a pointer, because we
+ * want to fill in instances in a MemoryPool (which cannot adopt pointers it
+ * didn't create itself).
+ *
+ * @param loc The desired locale.
+ * @param mixedUnit The mixed measure unit to construct a
+ * MixedUnitLongNameHandler for.
+ * @param width Specifies the desired unit rendering.
+ * @param rules Does not take ownership.
+ * @param parent Does not take ownership.
+ * @param fillIn Required.
+ */
+ static void forMeasureUnit(const Locale &loc, const MeasureUnit &mixedUnit,
+ const UNumberUnitWidth &width, const PluralRules *rules,
+ const MicroPropsGenerator *parent, MixedUnitLongNameHandler *fillIn,
+ UErrorCode &status);
+
+ /**
+ * Produces a plural-appropriate Modifier for a mixed unit: `quantity` is
+ * taken as the final smallest unit, while the larger unit values must be
+ * provided via `micros.mixedMeasures`.
+ */
+ void processQuantity(DecimalQuantity &quantity, MicroProps &micros,
+ UErrorCode &status) const U_OVERRIDE;
+
+ // Required for ModifierStore. And ModifierStore is required by
+ // SimpleModifier constructor's last parameter. We assert his will never get
+ // called though.
+ const Modifier *getModifier(Signum signum, StandardPlural::Form plural) const U_OVERRIDE;
+
+ private:
+ // Not owned
+ const PluralRules *rules;
+ // Not owned
+ const MicroPropsGenerator *parent;
+
+ // Total number of units in the MeasureUnit this handler was configured for:
+ // for "foot-and-inch", this will be 2.
+ int32_t fMixedUnitCount = 1;
+ // Stores unit data for each of the individual units. For each unit, it
+ // stores ARRAY_LENGTH strings, as returned by getMeasureData. (Each unit
+ // with index `i` has ARRAY_LENGTH strings starting at index
+ // `i*ARRAY_LENGTH` in this array.)
+ LocalArray<UnicodeString> fMixedUnitData;
+ // A localized NumberFormatter used to format the integer-valued bigger
+ // units of Mixed Unit measurements.
+ LocalizedNumberFormatter fIntegerFormatter;
+ // A localised list formatter for joining mixed units together.
+ LocalPointer<ListFormatter> fListFormatter;
+
+ MixedUnitLongNameHandler(const PluralRules *rules, const MicroPropsGenerator *parent)
+ : rules(rules), parent(parent) {
+ }
+
+ MixedUnitLongNameHandler() : rules(nullptr), parent(nullptr) {
+ }
+
+ // Allow macrosToMicroGenerator to call the private default constructor.
+ friend class NumberFormatterImpl;
+
+ // Enables MemoryPool<LongNameHandler>::emplaceBack(): requires access to
+ // the private constructors.
+ friend class MemoryPool<MixedUnitLongNameHandler>;
+
+ // For a mixed unit, returns a Modifier that takes only one parameter: the
+ // smallest and final unit of the set. The bigger units' values and labels
+ // get baked into this Modifier, together with the unit label of the final
+ // unit.
+ const Modifier *getMixedUnitModifier(DecimalQuantity &quantity, MicroProps &micros,
+ UErrorCode &status) const;
+};
+
+/**
+ * A MicroPropsGenerator that multiplexes between different LongNameHandlers,
+ * depending on the outputUnit.
+ *
+ * See processQuantity() for the input requirements.
+ */
+class LongNameMultiplexer : public MicroPropsGenerator, public UMemory {
+ public:
+ // Produces a multiplexer for LongNameHandlers, one for each unit in
+ // `units`. An individual unit might be a mixed unit.
+ static LongNameMultiplexer *forMeasureUnits(const Locale &loc,
+ const MaybeStackVector<MeasureUnit> &units,
+ const UNumberUnitWidth &width, const PluralRules *rules,
+ const MicroPropsGenerator *parent, UErrorCode &status);
+
+ // The output unit must be provided via `micros.outputUnit`, it must match
+ // one of the units provided to the factory function.
+ void processQuantity(DecimalQuantity &quantity, MicroProps &micros,
+ UErrorCode &status) const U_OVERRIDE;
+
+ private:
+ /**
+ * Because we only know which LongNameHandler we wish to call after calling
+ * earlier MicroPropsGenerators in the chain, LongNameMultiplexer keeps the
+ * parent link, while the LongNameHandlers are given no parents.
+ */
+ MemoryPool<LongNameHandler> fLongNameHandlers;
+ MemoryPool<MixedUnitLongNameHandler> fMixedUnitHandlers;
+ // Unowned pointers to instances owned by MaybeStackVectors.
+ MaybeStackArray<MicroPropsGenerator *, 8> fHandlers;
+ // Each MeasureUnit corresponds to the same-index MicroPropsGenerator
+ // pointed to in fHandlers.
+ LocalArray<MeasureUnit> fMeasureUnits;
+
+ const MicroPropsGenerator *fParent;
+
+ LongNameMultiplexer(const MicroPropsGenerator *parent) : fParent(parent) {
+ }
+};
+
} // namespace impl
} // namespace number
U_NAMESPACE_END
diff --git a/deps/icu-small/source/i18n/number_mapper.cpp b/deps/icu-small/source/i18n/number_mapper.cpp
index ec617438c9..e2a0d284b7 100644
--- a/deps/icu-small/source/i18n/number_mapper.cpp
+++ b/deps/icu-small/source/i18n/number_mapper.cpp
@@ -92,6 +92,8 @@ MacroProps NumberPropertyMapper::oldToNew(const DecimalFormatProperties& propert
int32_t minSig = properties.minimumSignificantDigits;
int32_t maxSig = properties.maximumSignificantDigits;
double roundingIncrement = properties.roundingIncrement;
+ // Not assigning directly to macros.roundingMode here: we change
+ // roundingMode if and when we also change macros.precision.
RoundingMode roundingMode = properties.roundingMode.getOrDefault(UNUM_ROUND_HALFEVEN);
bool explicitMinMaxFrac = minFrac != -1 || maxFrac != -1;
bool explicitMinMaxSig = minSig != -1 || maxSig != -1;
@@ -145,7 +147,7 @@ MacroProps NumberPropertyMapper::oldToNew(const DecimalFormatProperties& propert
precision = Precision::constructCurrency(currencyUsage);
}
if (!precision.isBogus()) {
- precision.fRoundingMode = roundingMode;
+ macros.roundingMode = roundingMode;
macros.precision = precision;
}
@@ -239,7 +241,7 @@ MacroProps NumberPropertyMapper::oldToNew(const DecimalFormatProperties& propert
// TODO: Reset maxSig_ = 1 + minFrac_ to follow the spec.
macros.precision = Precision::constructSignificant(minSig_, maxSig_);
}
- macros.precision.fRoundingMode = roundingMode;
+ macros.roundingMode = roundingMode;
}
}
diff --git a/deps/icu-small/source/i18n/number_mapper.h b/deps/icu-small/source/i18n/number_mapper.h
index d18b8b3c43..9ecd776b3b 100644
--- a/deps/icu-small/source/i18n/number_mapper.h
+++ b/deps/icu-small/source/i18n/number_mapper.h
@@ -136,6 +136,16 @@ class AutoAffixPatternProvider {
}
}
+ inline void setTo(const AffixPatternProvider* provider, UErrorCode& status) {
+ if (auto ptr = dynamic_cast<const PropertiesAffixPatternProvider*>(provider)) {
+ propertiesAPP = *ptr;
+ } else if (auto ptr = dynamic_cast<const CurrencyPluralInfoAffixProvider*>(provider)) {
+ currencyPluralInfoAPP = *ptr;
+ } else {
+ status = U_INTERNAL_PROGRAM_ERROR;
+ }
+ }
+
inline const AffixPatternProvider& get() const {
if (!currencyPluralInfoAPP.isBogus()) {
return currencyPluralInfoAPP;
@@ -153,9 +163,9 @@ class AutoAffixPatternProvider {
/**
* A struct for ownership of a few objects needed for formatting.
*/
-struct DecimalFormatWarehouse {
+struct DecimalFormatWarehouse : public UMemory {
AutoAffixPatternProvider affixProvider;
-
+ LocalPointer<PluralRules> rules;
};
diff --git a/deps/icu-small/source/i18n/number_microprops.h b/deps/icu-small/source/i18n/number_microprops.h
index 56512f5e6f..058c5923b4 100644
--- a/deps/icu-small/source/i18n/number_microprops.h
+++ b/deps/icu-small/source/i18n/number_microprops.h
@@ -22,6 +22,56 @@
U_NAMESPACE_BEGIN namespace number {
namespace impl {
+/**
+ * A copyable container for the integer values of mixed unit measurements.
+ *
+ * If memory allocation fails during copying, no values are copied and status is
+ * set to U_MEMORY_ALLOCATION_ERROR.
+ */
+class IntMeasures : public MaybeStackArray<int64_t, 2> {
+ public:
+ /**
+ * Default constructor initializes with internal T[stackCapacity] buffer.
+ *
+ * Stack Capacity: most mixed units are expected to consist of two or three
+ * subunits, so one or two integer measures should be enough.
+ */
+ IntMeasures() : MaybeStackArray<int64_t, 2>() {
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * If memory allocation fails during copying, no values are copied and
+ * status is set to U_MEMORY_ALLOCATION_ERROR.
+ */
+ IntMeasures(const IntMeasures &other) : MaybeStackArray<int64_t, 2>() {
+ this->operator=(other);
+ }
+
+ // Assignment operator
+ IntMeasures &operator=(const IntMeasures &rhs) {
+ if (this == &rhs) {
+ return *this;
+ }
+ copyFrom(rhs, status);
+ return *this;
+ }
+
+ /** Move constructor */
+ IntMeasures(IntMeasures &&src) = default;
+
+ /** Move assignment */
+ IntMeasures &operator=(IntMeasures &&src) = default;
+
+ UErrorCode status = U_ZERO_ERROR;
+};
+
+/**
+ * MicroProps is the first MicroPropsGenerator that should be should be called,
+ * producing an initialized MicroProps instance that will be passed on and
+ * modified throughout the rest of the chain of MicroPropsGenerator instances.
+ */
struct MicroProps : public MicroPropsGenerator {
// NOTE: All of these fields are properly initialized in NumberFormatterImpl.
@@ -36,19 +86,47 @@ struct MicroProps : public MicroPropsGenerator {
// Note: This struct has no direct ownership of the following pointers.
const DecimalFormatSymbols* symbols;
+
+ // Pointers to Modifiers provided by the number formatting pipeline (when
+ // the value is known):
+
+ // A Modifier provided by LongNameHandler, used for currency long names and
+ // units. If there is no LongNameHandler needed, this should be an
+ // EmptyModifier. (This is typically the third modifier applied.)
const Modifier* modOuter;
+ // A Modifier for short currencies and compact notation. (This is typically
+ // the second modifier applied.)
const Modifier* modMiddle = nullptr;
+ // A Modifier provided by ScientificHandler, used for scientific notation.
+ // This is typically the first modifier applied.
const Modifier* modInner;
// The following "helper" fields may optionally be used during the MicroPropsGenerator.
// They live here to retain memory.
struct {
+ // The ScientificModifier for which ScientificHandler is responsible.
+ // ScientificHandler::processQuantity() modifies this Modifier.
ScientificModifier scientificModifier;
+ // EmptyModifier used for modOuter
EmptyModifier emptyWeakModifier{false};
+ // EmptyModifier used for modInner
EmptyModifier emptyStrongModifier{true};
MultiplierFormatHandler multiplier;
+ // A Modifier used for Mixed Units. When formatting mixed units,
+ // LongNameHandler assigns this Modifier.
+ SimpleModifier mixedUnitModifier;
} helpers;
+ // The MeasureUnit with which the output is represented. May also have
+ // UMEASURE_UNIT_MIXED complexity, in which case mixedMeasures comes into
+ // play.
+ MeasureUnit outputUnit;
+
+ // In the case of mixed units, this is the set of integer-only units
+ // *preceding* the final unit.
+ IntMeasures mixedMeasures;
+ // Number of mixedMeasures that have been populated
+ int32_t mixedMeasuresCount = 0;
MicroProps() = default;
@@ -56,7 +134,23 @@ struct MicroProps : public MicroPropsGenerator {
MicroProps& operator=(const MicroProps& other) = default;
- void processQuantity(DecimalQuantity&, MicroProps& micros, UErrorCode& status) const U_OVERRIDE {
+ /**
+ * As MicroProps is the "base instance", this implementation of
+ * MicroPropsGenerator::processQuantity() just ensures that the output
+ * `micros` is correctly initialized.
+ *
+ * For the "safe" invocation of this function, micros must not be *this,
+ * such that a copy of the base instance is made. For the "unsafe" path,
+ * this function can be used only once, because the base MicroProps instance
+ * will be modified and thus not be available for re-use.
+ *
+ * @param quantity The quantity for consideration and optional mutation.
+ * @param micros The MicroProps instance to populate. If this parameter is
+ * not already `*this`, it will be overwritten with a copy of `*this`.
+ */
+ void processQuantity(DecimalQuantity &quantity, MicroProps &micros,
+ UErrorCode &status) const U_OVERRIDE {
+ (void) quantity;
(void) status;
if (this == &micros) {
// Unsafe path: no need to perform a copy.
@@ -65,6 +159,7 @@ struct MicroProps : public MicroPropsGenerator {
U_ASSERT(exhausted);
} else {
// Safe path: copy self into the output micros.
+ U_ASSERT(!exhausted);
micros = *this;
}
}
diff --git a/deps/icu-small/source/i18n/number_modifiers.cpp b/deps/icu-small/source/i18n/number_modifiers.cpp
index 3becb7ba85..b7d825f499 100644
--- a/deps/icu-small/source/i18n/number_modifiers.cpp
+++ b/deps/icu-small/source/i18n/number_modifiers.cpp
@@ -25,13 +25,13 @@ const int32_t ARG_NUM_LIMIT = 0x100;
icu::UInitOnce gDefaultCurrencySpacingInitOnce = U_INITONCE_INITIALIZER;
UnicodeSet *UNISET_DIGIT = nullptr;
-UnicodeSet *UNISET_NOTS = nullptr;
+UnicodeSet *UNISET_NOTSZ = nullptr;
UBool U_CALLCONV cleanupDefaultCurrencySpacing() {
delete UNISET_DIGIT;
UNISET_DIGIT = nullptr;
- delete UNISET_NOTS;
- UNISET_NOTS = nullptr;
+ delete UNISET_NOTSZ;
+ UNISET_NOTSZ = nullptr;
gDefaultCurrencySpacingInitOnce.reset();
return TRUE;
}
@@ -39,13 +39,13 @@ UBool U_CALLCONV cleanupDefaultCurrencySpacing() {
void U_CALLCONV initDefaultCurrencySpacing(UErrorCode &status) {
ucln_i18n_registerCleanup(UCLN_I18N_CURRENCY_SPACING, cleanupDefaultCurrencySpacing);
UNISET_DIGIT = new UnicodeSet(UnicodeString(u"[:digit:]"), status);
- UNISET_NOTS = new UnicodeSet(UnicodeString(u"[:^S:]"), status);
- if (UNISET_DIGIT == nullptr || UNISET_NOTS == nullptr) {
+ UNISET_NOTSZ = new UnicodeSet(UnicodeString(u"[[:^S:]&[:^Z:]]"), status);
+ if (UNISET_DIGIT == nullptr || UNISET_NOTSZ == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
UNISET_DIGIT->freeze();
- UNISET_NOTS->freeze();
+ UNISET_NOTSZ->freeze();
}
} // namespace
@@ -469,8 +469,8 @@ CurrencySpacingEnabledModifier::getUnicodeSet(const DecimalFormatSymbols &symbol
status);
if (pattern.compare(u"[:digit:]", -1) == 0) {
return *UNISET_DIGIT;
- } else if (pattern.compare(u"[:^S:]", -1) == 0) {
- return *UNISET_NOTS;
+ } else if (pattern.compare(u"[[:^S:]&[:^Z:]]", -1) == 0) {
+ return *UNISET_NOTSZ;
} else {
return UnicodeSet(pattern, status);
}
diff --git a/deps/icu-small/source/i18n/number_output.cpp b/deps/icu-small/source/i18n/number_output.cpp
index 40192a9225..7129b94e0f 100644
--- a/deps/icu-small/source/i18n/number_output.cpp
+++ b/deps/icu-small/source/i18n/number_output.cpp
@@ -5,11 +5,13 @@
#if !UCONFIG_NO_FORMATTING
+#include "unicode/measunit.h"
#include "unicode/numberformatter.h"
#include "number_utypes.h"
#include "util.h"
#include "number_decimalquantity.h"
#include "number_decnum.h"
+#include "numrange_impl.h"
U_NAMESPACE_BEGIN
namespace number {
@@ -32,6 +34,11 @@ void FormattedNumber::getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpi
fData->getAllFieldPositions(fpih, status);
}
+MeasureUnit FormattedNumber::getOutputUnit(UErrorCode& status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(MeasureUnit())
+ return fData->outputUnit;
+}
+
void FormattedNumber::getDecimalQuantity(impl::DecimalQuantity& output, UErrorCode& status) const {
UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
output = fData->quantity;
@@ -41,6 +48,42 @@ void FormattedNumber::getDecimalQuantity(impl::DecimalQuantity& output, UErrorCo
impl::UFormattedNumberData::~UFormattedNumberData() = default;
+UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumberRange)
+
+#define UPRV_NOARG
+
+UnicodeString FormattedNumberRange::getFirstDecimal(UErrorCode& status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(ICU_Utility::makeBogusString())
+ return fData->quantity1.toScientificString();
+}
+
+UnicodeString FormattedNumberRange::getSecondDecimal(UErrorCode& status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(ICU_Utility::makeBogusString())
+ return fData->quantity2.toScientificString();
+}
+
+void FormattedNumberRange::getDecimalNumbers(ByteSink& sink1, ByteSink& sink2, UErrorCode& status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(UPRV_NOARG)
+ impl::DecNum decnum1;
+ impl::DecNum decnum2;
+ fData->quantity1.toDecNum(decnum1, status).toString(sink1, status);
+ fData->quantity2.toDecNum(decnum2, status).toString(sink2, status);
+}
+
+UNumberRangeIdentityResult FormattedNumberRange::getIdentityResult(UErrorCode& status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(UNUM_IDENTITY_RESULT_NOT_EQUAL)
+ return fData->identityResult;
+}
+
+const impl::UFormattedNumberRangeData* FormattedNumberRange::getData(UErrorCode& status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(nullptr)
+ return fData;
+}
+
+
+impl::UFormattedNumberRangeData::~UFormattedNumberRangeData() = default;
+
+
} // namespace number
U_NAMESPACE_END
diff --git a/deps/icu-small/source/i18n/number_patternmodifier.cpp b/deps/icu-small/source/i18n/number_patternmodifier.cpp
index 45602942ae..314e7cb75e 100644
--- a/deps/icu-small/source/i18n/number_patternmodifier.cpp
+++ b/deps/icu-small/source/i18n/number_patternmodifier.cpp
@@ -294,14 +294,20 @@ UnicodeString MutablePatternModifier::getSymbol(AffixPatternType type) const {
case AffixPatternType::TYPE_PERMILLE:
return fSymbols->getSymbol(DecimalFormatSymbols::ENumberFormatSymbol::kPerMillSymbol);
case AffixPatternType::TYPE_CURRENCY_SINGLE: {
- // UnitWidth ISO and HIDDEN overrides the singular currency symbol.
- if (fUnitWidth == UNumberUnitWidth::UNUM_UNIT_WIDTH_ISO_CODE) {
+ switch (fUnitWidth) {
+ case UNumberUnitWidth::UNUM_UNIT_WIDTH_NARROW:
+ return fCurrencySymbols.getNarrowCurrencySymbol(localStatus);
+ case UNumberUnitWidth::UNUM_UNIT_WIDTH_SHORT:
+ return fCurrencySymbols.getCurrencySymbol(localStatus);
+ case UNumberUnitWidth::UNUM_UNIT_WIDTH_ISO_CODE:
return fCurrencySymbols.getIntlCurrencySymbol(localStatus);
- } else if (fUnitWidth == UNumberUnitWidth::UNUM_UNIT_WIDTH_HIDDEN) {
+ case UNumberUnitWidth::UNUM_UNIT_WIDTH_FORMAL:
+ return fCurrencySymbols.getFormalCurrencySymbol(localStatus);
+ case UNumberUnitWidth::UNUM_UNIT_WIDTH_VARIANT:
+ return fCurrencySymbols.getVariantCurrencySymbol(localStatus);
+ case UNumberUnitWidth::UNUM_UNIT_WIDTH_HIDDEN:
return UnicodeString();
- } else if (fUnitWidth == UNumberUnitWidth::UNUM_UNIT_WIDTH_NARROW) {
- return fCurrencySymbols.getNarrowCurrencySymbol(localStatus);
- } else {
+ default:
return fCurrencySymbols.getCurrencySymbol(localStatus);
}
}
diff --git a/deps/icu-small/source/i18n/number_rounding.cpp b/deps/icu-small/source/i18n/number_rounding.cpp
index 3ffce673ad..a8fd6bc892 100644
--- a/deps/icu-small/source/i18n/number_rounding.cpp
+++ b/deps/icu-small/source/i18n/number_rounding.cpp
@@ -5,13 +5,16 @@
#if !UCONFIG_NO_FORMATTING
+#include "charstr.h"
#include "uassert.h"
#include "unicode/numberformatter.h"
#include "number_types.h"
#include "number_decimalquantity.h"
#include "double-conversion.h"
#include "number_roundingutils.h"
+#include "number_skeletons.h"
#include "putilimp.h"
+#include "string_segment.h"
using namespace icu;
using namespace icu::number;
@@ -19,6 +22,39 @@ using namespace icu::number::impl;
using double_conversion::DoubleToStringConverter;
+using icu::StringSegment;
+
+void number::impl::parseIncrementOption(const StringSegment &segment,
+ Precision &outPrecision,
+ UErrorCode &status) {
+ // Need to do char <-> UChar conversion...
+ U_ASSERT(U_SUCCESS(status));
+ CharString buffer;
+ SKELETON_UCHAR_TO_CHAR(buffer, segment.toTempUnicodeString(), 0, segment.length(), status);
+
+ // Utilize DecimalQuantity/decNumber to parse this for us.
+ DecimalQuantity dq;
+ UErrorCode localStatus = U_ZERO_ERROR;
+ dq.setToDecNumber({buffer.data(), buffer.length()}, localStatus);
+ if (U_FAILURE(localStatus)) {
+ // throw new SkeletonSyntaxException("Invalid rounding increment", segment, e);
+ status = U_NUMBER_SKELETON_SYNTAX_ERROR;
+ return;
+ }
+ double increment = dq.toDouble();
+
+ // We also need to figure out how many digits. Do a brute force string operation.
+ int decimalOffset = 0;
+ while (decimalOffset < segment.length() && segment.charAt(decimalOffset) != '.') {
+ decimalOffset++;
+ }
+ if (decimalOffset == segment.length()) {
+ outPrecision = Precision::increment(increment);
+ } else {
+ int32_t fractionLength = segment.length() - decimalOffset - 1;
+ outPrecision = Precision::increment(increment).withMinFraction(fractionLength);
+ }
+}
namespace {
@@ -84,7 +120,7 @@ digits_t roundingutils::doubleFractionLength(double input, int8_t* singleDigit)
Precision Precision::unlimited() {
- return Precision(RND_NONE, {}, kDefaultMode);
+ return Precision(RND_NONE, {});
}
FractionPrecision Precision::integer() {
@@ -229,7 +265,7 @@ FractionPrecision Precision::constructFraction(int32_t minFrac, int32_t maxFrac)
settings.fMaxSig = -1;
PrecisionUnion union_;
union_.fracSig = settings;
- return {RND_FRACTION, union_, kDefaultMode};
+ return {RND_FRACTION, union_};
}
Precision Precision::constructSignificant(int32_t minSig, int32_t maxSig) {
@@ -240,7 +276,7 @@ Precision Precision::constructSignificant(int32_t minSig, int32_t maxSig) {
settings.fMaxSig = static_cast<digits_t>(maxSig);
PrecisionUnion union_;
union_.fracSig = settings;
- return {RND_SIGNIFICANT, union_, kDefaultMode};
+ return {RND_SIGNIFICANT, union_};
}
Precision
@@ -250,7 +286,7 @@ Precision::constructFractionSignificant(const FractionPrecision &base, int32_t m
settings.fMaxSig = static_cast<digits_t>(maxSig);
PrecisionUnion union_;
union_.fracSig = settings;
- return {RND_FRACTION_SIGNIFICANT, union_, kDefaultMode};
+ return {RND_FRACTION_SIGNIFICANT, union_};
}
IncrementPrecision Precision::constructIncrement(double increment, int32_t minFrac) {
@@ -270,18 +306,18 @@ IncrementPrecision Precision::constructIncrement(double increment, int32_t minFr
// NOTE: In C++, we must return the correct value type with the correct union.
// It would be invalid to return a RND_FRACTION here because the methods on the
// IncrementPrecision type assume that the union is backed by increment data.
- return {RND_INCREMENT_ONE, union_, kDefaultMode};
+ return {RND_INCREMENT_ONE, union_};
} else if (singleDigit == 5) {
- return {RND_INCREMENT_FIVE, union_, kDefaultMode};
+ return {RND_INCREMENT_FIVE, union_};
} else {
- return {RND_INCREMENT, union_, kDefaultMode};
+ return {RND_INCREMENT, union_};
}
}
CurrencyPrecision Precision::constructCurrency(UCurrencyUsage usage) {
PrecisionUnion union_;
union_.currencyUsage = usage;
- return {RND_CURRENCY, union_, kDefaultMode};
+ return {RND_CURRENCY, union_};
}
@@ -341,6 +377,9 @@ RoundingImpl::chooseMultiplierAndApply(impl::DecimalQuantity &input, const impl:
/** This is the method that contains the actual rounding logic. */
void RoundingImpl::apply(impl::DecimalQuantity &value, UErrorCode& status) const {
+ if (U_FAILURE(status)) {
+ return;
+ }
if (fPassThrough) {
return;
}
diff --git a/deps/icu-small/source/i18n/number_roundingutils.h b/deps/icu-small/source/i18n/number_roundingutils.h
index 3e37f31954..e85cbae9fd 100644
--- a/deps/icu-small/source/i18n/number_roundingutils.h
+++ b/deps/icu-small/source/i18n/number_roundingutils.h
@@ -8,6 +8,7 @@
#define __NUMBER_ROUNDINGUTILS_H__
#include "number_types.h"
+#include "string_segment.h"
U_NAMESPACE_BEGIN
namespace number {
@@ -44,6 +45,9 @@ enum Section {
inline bool
getRoundingDirection(bool isEven, bool isNegative, Section section, RoundingMode roundingMode,
UErrorCode &status) {
+ if (U_FAILURE(status)) {
+ return false;
+ }
switch (roundingMode) {
case RoundingMode::UNUM_ROUND_UP:
// round away from zero
@@ -187,8 +191,22 @@ class RoundingImpl {
Precision fPrecision;
UNumberFormatRoundingMode fRoundingMode;
bool fPassThrough = true; // default value
+
+ // Permits access to fPrecision.
+ friend class units::UnitsRouter;
+
+ // Permits access to fPrecision.
+ friend class UnitConversionHandler;
};
+/**
+ * Parses Precision-related skeleton strings without knowledge of MacroProps
+ * - see blueprint_helpers::parseIncrementOption().
+ *
+ * Referencing MacroProps means needing to pull in the .o files that have the
+ * destructors for the SymbolsWrapper, Usage, and Scale classes.
+ */
+void parseIncrementOption(const StringSegment &segment, Precision &outPrecision, UErrorCode &status);
} // namespace impl
} // namespace number
diff --git a/deps/icu-small/source/i18n/number_skeletons.cpp b/deps/icu-small/source/i18n/number_skeletons.cpp
index 4ba2647986..e6d94d27b2 100644
--- a/deps/icu-small/source/i18n/number_skeletons.cpp
+++ b/deps/icu-small/source/i18n/number_skeletons.cpp
@@ -10,6 +10,7 @@
#define UNISTR_FROM_STRING_EXPLICIT
#include "number_decnum.h"
+#include "number_roundingutils.h"
#include "number_skeletons.h"
#include "umutex.h"
#include "ucln_in.h"
@@ -80,6 +81,8 @@ void U_CALLCONV initNumberSkeletons(UErrorCode& status) {
b.add(u"unit-width-short", STEM_UNIT_WIDTH_SHORT, status);
b.add(u"unit-width-full-name", STEM_UNIT_WIDTH_FULL_NAME, status);
b.add(u"unit-width-iso-code", STEM_UNIT_WIDTH_ISO_CODE, status);
+ b.add(u"unit-width-formal", STEM_UNIT_WIDTH_FORMAL, status);
+ b.add(u"unit-width-variant", STEM_UNIT_WIDTH_VARIANT, status);
b.add(u"unit-width-hidden", STEM_UNIT_WIDTH_HIDDEN, status);
b.add(u"sign-auto", STEM_SIGN_AUTO, status);
b.add(u"sign-always", STEM_SIGN_ALWAYS, status);
@@ -97,6 +100,7 @@ void U_CALLCONV initNumberSkeletons(UErrorCode& status) {
b.add(u"measure-unit", STEM_MEASURE_UNIT, status);
b.add(u"per-measure-unit", STEM_PER_MEASURE_UNIT, status);
b.add(u"unit", STEM_UNIT, status);
+ b.add(u"usage", STEM_UNIT_USAGE, status);
b.add(u"currency", STEM_CURRENCY, status);
b.add(u"integer-width", STEM_INTEGER_WIDTH, status);
b.add(u"numbering-system", STEM_NUMBERING_SYSTEM, status);
@@ -149,21 +153,6 @@ UPRV_BLOCK_MACRO_BEGIN { \
} UPRV_BLOCK_MACRO_END
-#define SKELETON_UCHAR_TO_CHAR(dest, src, start, end, status) (void)(dest); \
-UPRV_BLOCK_MACRO_BEGIN { \
- UErrorCode conversionStatus = U_ZERO_ERROR; \
- (dest).appendInvariantChars({FALSE, (src).getBuffer() + (start), (end) - (start)}, conversionStatus); \
- if (conversionStatus == U_INVARIANT_CONVERSION_ERROR) { \
- /* Don't propagate the invariant conversion error; it is a skeleton syntax error */ \
- (status) = U_NUMBER_SKELETON_SYNTAX_ERROR; \
- return; \
- } else if (U_FAILURE(conversionStatus)) { \
- (status) = conversionStatus; \
- return; \
- } \
-} UPRV_BLOCK_MACRO_END
-
-
} // anonymous namespace
@@ -187,14 +176,11 @@ Notation stem_to_object::notation(skeleton::StemEnum stem) {
MeasureUnit stem_to_object::unit(skeleton::StemEnum stem) {
switch (stem) {
case STEM_BASE_UNIT:
- // Slicing is okay
- return NoUnit::base(); // NOLINT
+ return MeasureUnit();
case STEM_PERCENT:
- // Slicing is okay
- return NoUnit::percent(); // NOLINT
+ return MeasureUnit::getPercent();
case STEM_PERMILLE:
- // Slicing is okay
- return NoUnit::permille(); // NOLINT
+ return MeasureUnit::getPermille();
default:
UPRV_UNREACHABLE;
}
@@ -265,6 +251,10 @@ UNumberUnitWidth stem_to_object::unitWidth(skeleton::StemEnum stem) {
return UNUM_UNIT_WIDTH_FULL_NAME;
case STEM_UNIT_WIDTH_ISO_CODE:
return UNUM_UNIT_WIDTH_ISO_CODE;
+ case STEM_UNIT_WIDTH_FORMAL:
+ return UNUM_UNIT_WIDTH_FORMAL;
+ case STEM_UNIT_WIDTH_VARIANT:
+ return UNUM_UNIT_WIDTH_VARIANT;
case STEM_UNIT_WIDTH_HIDDEN:
return UNUM_UNIT_WIDTH_HIDDEN;
default:
@@ -372,6 +362,12 @@ void enum_to_stem_string::unitWidth(UNumberUnitWidth value, UnicodeString& sb) {
case UNUM_UNIT_WIDTH_ISO_CODE:
sb.append(u"unit-width-iso-code", -1);
break;
+ case UNUM_UNIT_WIDTH_FORMAL:
+ sb.append(u"unit-width-formal", -1);
+ break;
+ case UNUM_UNIT_WIDTH_VARIANT:
+ sb.append(u"unit-width-variant", -1);
+ break;
case UNUM_UNIT_WIDTH_HIDDEN:
sb.append(u"unit-width-hidden", -1);
break;
@@ -470,6 +466,7 @@ UnicodeString skeleton::generate(const MacroProps& macros, UErrorCode& status) {
MacroProps skeleton::parseSkeleton(
const UnicodeString& skeletonString, int32_t& errOffset, UErrorCode& status) {
U_ASSERT(U_SUCCESS(status));
+ U_ASSERT(kSerializedStemTrie != nullptr);
// Add a trailing whitespace to the end of the skeleton string to make code cleaner.
UnicodeString tempSkeletonString(skeletonString);
@@ -550,6 +547,7 @@ MacroProps skeleton::parseSkeleton(
case STATE_MEASURE_UNIT:
case STATE_PER_MEASURE_UNIT:
case STATE_IDENTIFIER_UNIT:
+ case STATE_UNIT_USAGE:
case STATE_CURRENCY_UNIT:
case STATE_INTEGER_WIDTH:
case STATE_NUMBERING_SYSTEM:
@@ -575,6 +573,8 @@ MacroProps skeleton::parseSkeleton(
ParseState
skeleton::parseStem(const StringSegment& segment, const UCharsTrie& stemTrie, SeenMacroProps& seen,
MacroProps& macros, UErrorCode& status) {
+ U_ASSERT(U_SUCCESS(status));
+
// First check for "blueprint" stems, which start with a "signal char"
switch (segment.charAt(0)) {
case u'.':
@@ -683,6 +683,8 @@ skeleton::parseStem(const StringSegment& segment, const UCharsTrie& stemTrie, Se
case STEM_UNIT_WIDTH_SHORT:
case STEM_UNIT_WIDTH_FULL_NAME:
case STEM_UNIT_WIDTH_ISO_CODE:
+ case STEM_UNIT_WIDTH_FORMAL:
+ case STEM_UNIT_WIDTH_VARIANT:
case STEM_UNIT_WIDTH_HIDDEN:
CHECK_NULL(seen, unitWidth, status);
macros.unitWidth = stem_to_object::unitWidth(stem);
@@ -705,7 +707,7 @@ skeleton::parseStem(const StringSegment& segment, const UCharsTrie& stemTrie, Se
macros.decimal = stem_to_object::decimalSeparatorDisplay(stem);
return STATE_NULL;
- // Stems requiring an option:
+ // Stems requiring an option:
case STEM_PRECISION_INCREMENT:
CHECK_NULL(seen, precision, status);
@@ -724,6 +726,10 @@ skeleton::parseStem(const StringSegment& segment, const UCharsTrie& stemTrie, Se
CHECK_NULL(seen, perUnit, status);
return STATE_IDENTIFIER_UNIT;
+ case STEM_UNIT_USAGE:
+ CHECK_NULL(seen, usage, status);
+ return STATE_UNIT_USAGE;
+
case STEM_CURRENCY:
CHECK_NULL(seen, unit, status);
return STATE_CURRENCY_UNIT;
@@ -747,6 +753,7 @@ skeleton::parseStem(const StringSegment& segment, const UCharsTrie& stemTrie, Se
ParseState skeleton::parseOption(ParseState stem, const StringSegment& segment, MacroProps& macros,
UErrorCode& status) {
+ U_ASSERT(U_SUCCESS(status));
///// Required options: /////
@@ -763,6 +770,9 @@ ParseState skeleton::parseOption(ParseState stem, const StringSegment& segment,
case STATE_IDENTIFIER_UNIT:
blueprint_helpers::parseIdentifierUnitOption(segment, macros, status);
return STATE_NULL;
+ case STATE_UNIT_USAGE:
+ blueprint_helpers::parseUnitUsageOption(segment, macros, status);
+ return STATE_NULL;
case STATE_INCREMENT_PRECISION:
blueprint_helpers::parseIncrementOption(segment, macros, status);
return STATE_NULL;
@@ -833,7 +843,7 @@ void GeneratorHelpers::generateSkeleton(const MacroProps& macros, UnicodeString&
sb.append(u' ');
}
if (U_FAILURE(status)) { return; }
- if (GeneratorHelpers::perUnit(macros, sb, status)) {
+ if (GeneratorHelpers::usage(macros, sb, status)) {
sb.append(u' ');
}
if (U_FAILURE(status)) { return; }
@@ -968,6 +978,7 @@ blueprint_helpers::generateCurrencyOption(const CurrencyUnit& currency, UnicodeS
void blueprint_helpers::parseMeasureUnitOption(const StringSegment& segment, MacroProps& macros,
UErrorCode& status) {
+ U_ASSERT(U_SUCCESS(status));
const UnicodeString stemString = segment.toTempUnicodeString();
// NOTE: The category (type) of the unit is guaranteed to be a valid subtag (alphanumeric)
@@ -983,14 +994,13 @@ void blueprint_helpers::parseMeasureUnitOption(const StringSegment& segment, Mac
}
// Need to do char <-> UChar conversion...
- U_ASSERT(U_SUCCESS(status));
CharString type;
SKELETON_UCHAR_TO_CHAR(type, stemString, 0, firstHyphen, status);
CharString subType;
SKELETON_UCHAR_TO_CHAR(subType, stemString, firstHyphen + 1, stemString.length(), status);
- // Note: the largest type as of this writing (March 2018) is "volume", which has 24 units.
- static constexpr int32_t CAPACITY = 30;
+ // Note: the largest type as of this writing (Aug 2020) is "volume", which has 33 units.
+ static constexpr int32_t CAPACITY = 40;
MeasureUnit units[CAPACITY];
UErrorCode localStatus = U_ZERO_ERROR;
int32_t numUnits = MeasureUnit::getAvailable(type.data(), units, CAPACITY, localStatus);
@@ -1011,14 +1021,6 @@ void blueprint_helpers::parseMeasureUnitOption(const StringSegment& segment, Mac
status = U_NUMBER_SKELETON_SYNTAX_ERROR;
}
-void blueprint_helpers::generateMeasureUnitOption(const MeasureUnit& measureUnit, UnicodeString& sb,
- UErrorCode&) {
- // Need to do char <-> UChar conversion...
- sb.append(UnicodeString(measureUnit.getType(), -1, US_INV));
- sb.append(u'-');
- sb.append(UnicodeString(measureUnit.getSubtype(), -1, US_INV));
-}
-
void blueprint_helpers::parseMeasurePerUnitOption(const StringSegment& segment, MacroProps& macros,
UErrorCode& status) {
// A little bit of a hack: save the current unit (numerator), call the main measure unit
@@ -1045,6 +1047,20 @@ void blueprint_helpers::parseIdentifierUnitOption(const StringSegment& segment,
return;
}
+ // Mixed units can only be represented by full MeasureUnit instances, so we
+ // don't split the denominator into macros.perUnit.
+ if (fullUnit.complexity == UMEASURE_UNIT_MIXED) {
+ macros.unit = std::move(fullUnit).build(status);
+ return;
+ }
+
+ // When we have a built-in unit (e.g. meter-per-second), we don't split it up
+ MeasureUnit testBuiltin = fullUnit.copy(status).build(status);
+ if (uprv_strcmp(testBuiltin.getType(), "") != 0) {
+ macros.unit = std::move(testBuiltin);
+ return;
+ }
+
// TODO(ICU-20941): Clean this up.
for (int32_t i = 0; i < fullUnit.units.length(); i++) {
SingleUnitImpl* subUnit = fullUnit.units[i];
@@ -1057,6 +1073,17 @@ void blueprint_helpers::parseIdentifierUnitOption(const StringSegment& segment,
}
}
+void blueprint_helpers::parseUnitUsageOption(const StringSegment &segment, MacroProps &macros,
+ UErrorCode &status) {
+ // Need to do char <-> UChar conversion...
+ U_ASSERT(U_SUCCESS(status));
+ CharString buffer;
+ SKELETON_UCHAR_TO_CHAR(buffer, segment.toTempUnicodeString(), 0, segment.length(), status);
+ macros.usage.set(buffer.toStringPiece());
+ // We do not do any validation of the usage string: it depends on the
+ // unitPreferenceData in the units resources.
+}
+
void blueprint_helpers::parseFractionStem(const StringSegment& segment, MacroProps& macros,
UErrorCode& status) {
U_ASSERT(segment.charAt(0) == u'.');
@@ -1301,35 +1328,9 @@ bool blueprint_helpers::parseFracSigOption(const StringSegment& segment, MacroPr
return true;
}
-void blueprint_helpers::parseIncrementOption(const StringSegment& segment, MacroProps& macros,
- UErrorCode& status) {
- // Need to do char <-> UChar conversion...
- U_ASSERT(U_SUCCESS(status));
- CharString buffer;
- SKELETON_UCHAR_TO_CHAR(buffer, segment.toTempUnicodeString(), 0, segment.length(), status);
-
- // Utilize DecimalQuantity/decNumber to parse this for us.
- DecimalQuantity dq;
- UErrorCode localStatus = U_ZERO_ERROR;
- dq.setToDecNumber({buffer.data(), buffer.length()}, localStatus);
- if (U_FAILURE(localStatus)) {
- // throw new SkeletonSyntaxException("Invalid rounding increment", segment, e);
- status = U_NUMBER_SKELETON_SYNTAX_ERROR;
- return;
- }
- double increment = dq.toDouble();
-
- // We also need to figure out how many digits. Do a brute force string operation.
- int decimalOffset = 0;
- while (decimalOffset < segment.length() && segment.charAt(decimalOffset) != '.') {
- decimalOffset++;
- }
- if (decimalOffset == segment.length()) {
- macros.precision = Precision::increment(increment);
- } else {
- int32_t fractionLength = segment.length() - decimalOffset - 1;
- macros.precision = Precision::increment(increment).withMinFraction(fractionLength);
- }
+void blueprint_helpers::parseIncrementOption(const StringSegment &segment, MacroProps &macros,
+ UErrorCode &status) {
+ number::impl::parseIncrementOption(segment, macros.precision, status);
}
void blueprint_helpers::generateIncrementOption(double increment, int32_t trailingZeros, UnicodeString& sb,
@@ -1507,42 +1508,37 @@ bool GeneratorHelpers::unit(const MacroProps& macros, UnicodeString& sb, UErrorC
}
blueprint_helpers::generateCurrencyOption(currency, sb, status);
return true;
- } else if (utils::unitIsNoUnit(macros.unit)) {
- if (utils::unitIsPercent(macros.unit)) {
- sb.append(u"percent", -1);
- return true;
- } else if (utils::unitIsPermille(macros.unit)) {
- sb.append(u"permille", -1);
- return true;
- } else {
- // Default value is not shown in normalized form
+ } else if (utils::unitIsBaseUnit(macros.unit)) {
+ // Default value is not shown in normalized form
+ return false;
+ } else if (utils::unitIsPercent(macros.unit)) {
+ sb.append(u"percent", -1);
+ return true;
+ } else if (utils::unitIsPermille(macros.unit)) {
+ sb.append(u"permille", -1);
+ return true;
+ } else {
+ MeasureUnit unit = macros.unit;
+ if (utils::unitIsCurrency(macros.perUnit)) {
+ status = U_UNSUPPORTED_ERROR;
return false;
}
- } else {
- sb.append(u"measure-unit/", -1);
- blueprint_helpers::generateMeasureUnitOption(macros.unit, sb, status);
+ if (!utils::unitIsBaseUnit(macros.perUnit)) {
+ unit = unit.product(macros.perUnit.reciprocal(status), status);
+ }
+ sb.append(u"unit/", -1);
+ sb.append(unit.getIdentifier());
return true;
}
}
-bool GeneratorHelpers::perUnit(const MacroProps& macros, UnicodeString& sb, UErrorCode& status) {
- // Per-units are currently expected to be only MeasureUnits.
- if (utils::unitIsNoUnit(macros.perUnit)) {
- if (utils::unitIsPercent(macros.perUnit) || utils::unitIsPermille(macros.perUnit)) {
- status = U_UNSUPPORTED_ERROR;
- return false;
- } else {
- // Default value: ok to ignore
- return false;
- }
- } else if (utils::unitIsCurrency(macros.perUnit)) {
- status = U_UNSUPPORTED_ERROR;
- return false;
- } else {
- sb.append(u"per-measure-unit/", -1);
- blueprint_helpers::generateMeasureUnitOption(macros.perUnit, sb, status);
+bool GeneratorHelpers::usage(const MacroProps& macros, UnicodeString& sb, UErrorCode& /* status */) {
+ if (macros.usage.isSet()) {
+ sb.append(u"usage/", -1);
+ sb.append(UnicodeString(macros.usage.fUsage, -1, US_INV));
return true;
}
+ return false;
}
bool GeneratorHelpers::precision(const MacroProps& macros, UnicodeString& sb, UErrorCode& status) {
diff --git a/deps/icu-small/source/i18n/number_skeletons.h b/deps/icu-small/source/i18n/number_skeletons.h
index d9b2c0ee0b..201267e635 100644
--- a/deps/icu-small/source/i18n/number_skeletons.h
+++ b/deps/icu-small/source/i18n/number_skeletons.h
@@ -22,10 +22,12 @@ struct SeenMacroProps;
// namespace for enums and entrypoint functions
namespace skeleton {
-///////////////////////////////////////////////////////////////////////////////////////
-// NOTE: For an example of how to add a new stem to the number skeleton parser, see: //
-// http://bugs.icu-project.org/trac/changeset/41193 //
-///////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////
+// NOTE: For examples of how to add a new stem to the number skeleton parser, see: //
+// https://github.com/unicode-org/icu/commit/a2a7982216b2348070dc71093775ac7195793d73 //
+// and //
+// https://github.com/unicode-org/icu/commit/6fe86f3934a8a5701034f648a8f7c5087e84aa28 //
+////////////////////////////////////////////////////////////////////////////////////////
/**
* While parsing a skeleton, this enum records what type of option we expect to find next.
@@ -47,6 +49,7 @@ enum ParseState {
STATE_MEASURE_UNIT,
STATE_PER_MEASURE_UNIT,
STATE_IDENTIFIER_UNIT,
+ STATE_UNIT_USAGE,
STATE_CURRENCY_UNIT,
STATE_INTEGER_WIDTH,
STATE_NUMBERING_SYSTEM,
@@ -95,6 +98,8 @@ enum StemEnum {
STEM_UNIT_WIDTH_SHORT,
STEM_UNIT_WIDTH_FULL_NAME,
STEM_UNIT_WIDTH_ISO_CODE,
+ STEM_UNIT_WIDTH_FORMAL,
+ STEM_UNIT_WIDTH_VARIANT,
STEM_UNIT_WIDTH_HIDDEN,
STEM_SIGN_AUTO,
STEM_SIGN_ALWAYS,
@@ -112,6 +117,7 @@ enum StemEnum {
STEM_MEASURE_UNIT,
STEM_PER_MEASURE_UNIT,
STEM_UNIT,
+ STEM_UNIT_USAGE,
STEM_CURRENCY,
STEM_INTEGER_WIDTH,
STEM_NUMBERING_SYSTEM,
@@ -234,14 +240,20 @@ void parseCurrencyOption(const StringSegment& segment, MacroProps& macros, UErro
void generateCurrencyOption(const CurrencyUnit& currency, UnicodeString& sb, UErrorCode& status);
+// "measure-unit/" is deprecated in favour of "unit/".
void parseMeasureUnitOption(const StringSegment& segment, MacroProps& macros, UErrorCode& status);
-void generateMeasureUnitOption(const MeasureUnit& measureUnit, UnicodeString& sb, UErrorCode& status);
-
+// "per-measure-unit/" is deprecated in favour of "unit/".
void parseMeasurePerUnitOption(const StringSegment& segment, MacroProps& macros, UErrorCode& status);
+/**
+ * Parses unit identifiers like "meter-per-second" and "foot-and-inch", as
+ * specified via a "unit/" concise skeleton.
+ */
void parseIdentifierUnitOption(const StringSegment& segment, MacroProps& macros, UErrorCode& status);
+void parseUnitUsageOption(const StringSegment& segment, MacroProps& macros, UErrorCode& status);
+
void parseFractionStem(const StringSegment& segment, MacroProps& macros, UErrorCode& status);
void generateFractionStem(int32_t minFrac, int32_t maxFrac, UnicodeString& sb, UErrorCode& status);
@@ -302,7 +314,7 @@ class GeneratorHelpers {
static bool unit(const MacroProps& macros, UnicodeString& sb, UErrorCode& status);
- static bool perUnit(const MacroProps& macros, UnicodeString& sb, UErrorCode& status);
+ static bool usage(const MacroProps& macros, UnicodeString& sb, UErrorCode& status);
static bool precision(const MacroProps& macros, UnicodeString& sb, UErrorCode& status);
@@ -332,6 +344,7 @@ struct SeenMacroProps {
bool notation = false;
bool unit = false;
bool perUnit = false;
+ bool usage = false;
bool precision = false;
bool roundingMode = false;
bool grouper = false;
@@ -344,6 +357,24 @@ struct SeenMacroProps {
bool scale = false;
};
+namespace {
+
+#define SKELETON_UCHAR_TO_CHAR(dest, src, start, end, status) (void)(dest); \
+UPRV_BLOCK_MACRO_BEGIN { \
+ UErrorCode conversionStatus = U_ZERO_ERROR; \
+ (dest).appendInvariantChars({false, (src).getBuffer() + (start), (end) - (start)}, conversionStatus); \
+ if (conversionStatus == U_INVARIANT_CONVERSION_ERROR) { \
+ /* Don't propagate the invariant conversion error; it is a skeleton syntax error */ \
+ (status) = U_NUMBER_SKELETON_SYNTAX_ERROR; \
+ return; \
+ } else if (U_FAILURE(conversionStatus)) { \
+ (status) = conversionStatus; \
+ return; \
+ } \
+} UPRV_BLOCK_MACRO_END
+
+} // namespace
+
} // namespace impl
} // namespace number
U_NAMESPACE_END
diff --git a/deps/icu-small/source/i18n/number_symbolswrapper.cpp b/deps/icu-small/source/i18n/number_symbolswrapper.cpp
new file mode 100644
index 0000000000..ac3043d1ca
--- /dev/null
+++ b/deps/icu-small/source/i18n/number_symbolswrapper.cpp
@@ -0,0 +1,131 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "number_microprops.h"
+#include "unicode/numberformatter.h"
+
+using namespace icu;
+using namespace icu::number;
+using namespace icu::number::impl;
+
+SymbolsWrapper::SymbolsWrapper(const SymbolsWrapper &other) {
+ doCopyFrom(other);
+}
+
+SymbolsWrapper::SymbolsWrapper(SymbolsWrapper &&src) U_NOEXCEPT {
+ doMoveFrom(std::move(src));
+}
+
+SymbolsWrapper &SymbolsWrapper::operator=(const SymbolsWrapper &other) {
+ if (this == &other) {
+ return *this;
+ }
+ doCleanup();
+ doCopyFrom(other);
+ return *this;
+}
+
+SymbolsWrapper &SymbolsWrapper::operator=(SymbolsWrapper &&src) U_NOEXCEPT {
+ if (this == &src) {
+ return *this;
+ }
+ doCleanup();
+ doMoveFrom(std::move(src));
+ return *this;
+}
+
+SymbolsWrapper::~SymbolsWrapper() {
+ doCleanup();
+}
+
+void SymbolsWrapper::setTo(const DecimalFormatSymbols &dfs) {
+ doCleanup();
+ fType = SYMPTR_DFS;
+ fPtr.dfs = new DecimalFormatSymbols(dfs);
+}
+
+void SymbolsWrapper::setTo(const NumberingSystem *ns) {
+ doCleanup();
+ fType = SYMPTR_NS;
+ fPtr.ns = ns;
+}
+
+void SymbolsWrapper::doCopyFrom(const SymbolsWrapper &other) {
+ fType = other.fType;
+ switch (fType) {
+ case SYMPTR_NONE:
+ // No action necessary
+ break;
+ case SYMPTR_DFS:
+ // Memory allocation failures are exposed in copyErrorTo()
+ if (other.fPtr.dfs != nullptr) {
+ fPtr.dfs = new DecimalFormatSymbols(*other.fPtr.dfs);
+ } else {
+ fPtr.dfs = nullptr;
+ }
+ break;
+ case SYMPTR_NS:
+ // Memory allocation failures are exposed in copyErrorTo()
+ if (other.fPtr.ns != nullptr) {
+ fPtr.ns = new NumberingSystem(*other.fPtr.ns);
+ } else {
+ fPtr.ns = nullptr;
+ }
+ break;
+ }
+}
+
+void SymbolsWrapper::doMoveFrom(SymbolsWrapper &&src) {
+ fType = src.fType;
+ switch (fType) {
+ case SYMPTR_NONE:
+ // No action necessary
+ break;
+ case SYMPTR_DFS:
+ fPtr.dfs = src.fPtr.dfs;
+ src.fPtr.dfs = nullptr;
+ break;
+ case SYMPTR_NS:
+ fPtr.ns = src.fPtr.ns;
+ src.fPtr.ns = nullptr;
+ break;
+ }
+}
+
+void SymbolsWrapper::doCleanup() {
+ switch (fType) {
+ case SYMPTR_NONE:
+ // No action necessary
+ break;
+ case SYMPTR_DFS:
+ delete fPtr.dfs;
+ break;
+ case SYMPTR_NS:
+ delete fPtr.ns;
+ break;
+ }
+}
+
+bool SymbolsWrapper::isDecimalFormatSymbols() const {
+ return fType == SYMPTR_DFS;
+}
+
+bool SymbolsWrapper::isNumberingSystem() const {
+ return fType == SYMPTR_NS;
+}
+
+const DecimalFormatSymbols *SymbolsWrapper::getDecimalFormatSymbols() const {
+ U_ASSERT(fType == SYMPTR_DFS);
+ return fPtr.dfs;
+}
+
+const NumberingSystem *SymbolsWrapper::getNumberingSystem() const {
+ U_ASSERT(fType == SYMPTR_NS);
+ return fPtr.ns;
+}
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/number_types.h b/deps/icu-small/source/i18n/number_types.h
index 5c2b8cf8b5..8078851ba3 100644
--- a/deps/icu-small/source/i18n/number_types.h
+++ b/deps/icu-small/source/i18n/number_types.h
@@ -246,31 +246,31 @@ class U_I18N_API ModifierStore {
* itself. The {@link #processQuantity} method performs the final step in the number processing pipeline: it uses the
* quantity to generate a finalized {@link MicroProps}, which can be used to render the number to output.
*
- * <p>
* In other words, this interface is used for the parts of number processing that are <em>quantity-dependent</em>.
*
- * <p>
* In order to allow for multiple different objects to all mutate the same MicroProps, a "chain" of MicroPropsGenerators
* are linked together, and each one is responsible for manipulating a certain quantity-dependent part of the
* MicroProps. At the tail of the linked list is a base instance of {@link MicroProps} with properties that are not
* quantity-dependent. Each element in the linked list calls {@link #processQuantity} on its "parent", then does its
* work, and then returns the result.
*
+ * This chain of MicroPropsGenerators is typically constructed by NumberFormatterImpl::macrosToMicroGenerator() when
+ * constructing a NumberFormatter.
+ *
* Exported as U_I18N_API because it is a base class for other exported types
*
*/
class U_I18N_API MicroPropsGenerator {
public:
- virtual ~MicroPropsGenerator();
+ virtual ~MicroPropsGenerator() = default;
/**
- * Considers the given {@link DecimalQuantity}, optionally mutates it, and returns a {@link MicroProps}.
+ * Considers the given {@link DecimalQuantity}, optionally mutates it, and
+ * populates a {@link MicroProps} instance.
*
- * @param quantity
- * The quantity for consideration and optional mutation.
- * @param micros
- * The MicroProps instance to populate.
- * @return A MicroProps instance resolved for the quantity.
+ * @param quantity The quantity for consideration and optional mutation.
+ * @param micros The MicroProps instance to populate. It will be modified as
+ * needed for the given quantity.
*/
virtual void processQuantity(DecimalQuantity& quantity, MicroProps& micros,
UErrorCode& status) const = 0;
diff --git a/deps/icu-small/source/i18n/number_usageprefs.cpp b/deps/icu-small/source/i18n/number_usageprefs.cpp
new file mode 100644
index 0000000000..0d9cb06c50
--- /dev/null
+++ b/deps/icu-small/source/i18n/number_usageprefs.cpp
@@ -0,0 +1,208 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "number_usageprefs.h"
+#include "cstring.h"
+#include "number_decimalquantity.h"
+#include "number_microprops.h"
+#include "number_roundingutils.h"
+#include "number_skeletons.h"
+#include "unicode/char16ptr.h"
+#include "unicode/currunit.h"
+#include "unicode/fmtable.h"
+#include "unicode/measure.h"
+#include "unicode/numberformatter.h"
+#include "unicode/platform.h"
+#include "unicode/unum.h"
+#include "unicode/urename.h"
+#include "units_data.h"
+
+using namespace icu;
+using namespace icu::number;
+using namespace icu::number::impl;
+using icu::StringSegment;
+using icu::units::ConversionRates;
+
+// Copy constructor
+Usage::Usage(const Usage &other) : Usage() {
+ this->operator=(other);
+}
+
+// Copy assignment operator
+Usage &Usage::operator=(const Usage &other) {
+ fLength = 0;
+ fError = other.fError;
+ if (fUsage != nullptr) {
+ uprv_free(fUsage);
+ fUsage = nullptr;
+ }
+ if (other.fUsage == nullptr) {
+ return *this;
+ }
+ if (U_FAILURE(other.fError)) {
+ // We don't bother trying to allocating memory if we're in any case busy
+ // copying an errored Usage.
+ return *this;
+ }
+ fUsage = (char *)uprv_malloc(other.fLength + 1);
+ if (fUsage == nullptr) {
+ fError = U_MEMORY_ALLOCATION_ERROR;
+ return *this;
+ }
+ fLength = other.fLength;
+ uprv_strncpy(fUsage, other.fUsage, fLength + 1);
+ return *this;
+}
+
+// Move constructor
+Usage::Usage(Usage &&src) U_NOEXCEPT : fUsage(src.fUsage), fLength(src.fLength), fError(src.fError) {
+ // Take ownership away from src if necessary
+ src.fUsage = nullptr;
+}
+
+// Move assignment operator
+Usage &Usage::operator=(Usage &&src) U_NOEXCEPT {
+ if (this == &src) {
+ return *this;
+ }
+ if (fUsage != nullptr) {
+ uprv_free(fUsage);
+ }
+ fUsage = src.fUsage;
+ fLength = src.fLength;
+ fError = src.fError;
+ // Take ownership away from src if necessary
+ src.fUsage = nullptr;
+ return *this;
+}
+
+Usage::~Usage() {
+ if (fUsage != nullptr) {
+ uprv_free(fUsage);
+ fUsage = nullptr;
+ }
+}
+
+void Usage::set(StringPiece value) {
+ if (fUsage != nullptr) {
+ uprv_free(fUsage);
+ fUsage = nullptr;
+ }
+ fLength = value.length();
+ fUsage = (char *)uprv_malloc(fLength + 1);
+ if (fUsage == nullptr) {
+ fLength = 0;
+ fError = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ uprv_strncpy(fUsage, value.data(), fLength);
+ fUsage[fLength] = 0;
+}
+
+// Populates micros.mixedMeasures and modifies quantity, based on the values in
+// measures.
+void mixedMeasuresToMicros(const MaybeStackVector<Measure> &measures, DecimalQuantity *quantity,
+ MicroProps *micros, UErrorCode status) {
+ micros->mixedMeasuresCount = measures.length() - 1;
+ if (micros->mixedMeasuresCount > 0) {
+#ifdef U_DEBUG
+ U_ASSERT(micros->outputUnit.getComplexity(status) == UMEASURE_UNIT_MIXED);
+ U_ASSERT(U_SUCCESS(status));
+ // Check that we received measurements with the expected MeasureUnits:
+ MeasureUnitImpl temp;
+ const MeasureUnitImpl& impl = MeasureUnitImpl::forMeasureUnit(micros->outputUnit, temp, status);
+ U_ASSERT(U_SUCCESS(status));
+ U_ASSERT(measures.length() == impl.units.length());
+ for (int32_t i = 0; i < measures.length(); i++) {
+ U_ASSERT(measures[i]->getUnit() == impl.units[i]->build(status));
+ }
+ (void)impl;
+#endif
+ // Mixed units: except for the last value, we pass all values to the
+ // LongNameHandler via micros->mixedMeasures.
+ if (micros->mixedMeasures.getCapacity() < micros->mixedMeasuresCount) {
+ if (micros->mixedMeasures.resize(micros->mixedMeasuresCount) == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ }
+ for (int32_t i = 0; i < micros->mixedMeasuresCount; i++) {
+ micros->mixedMeasures[i] = measures[i]->getNumber().getInt64();
+ }
+ } else {
+ micros->mixedMeasuresCount = 0;
+ }
+ // The last value (potentially the only value) gets passed on via quantity.
+ quantity->setToDouble(measures[measures.length() - 1]->getNumber().getDouble());
+}
+
+UsagePrefsHandler::UsagePrefsHandler(const Locale &locale,
+ const MeasureUnit &inputUnit,
+ const StringPiece usage,
+ const MicroPropsGenerator *parent,
+ UErrorCode &status)
+ : fUnitsRouter(inputUnit, StringPiece(locale.getCountry()), usage, status),
+ fParent(parent) {
+}
+
+void UsagePrefsHandler::processQuantity(DecimalQuantity &quantity, MicroProps &micros,
+ UErrorCode &status) const {
+ fParent->processQuantity(quantity, micros, status);
+ if (U_FAILURE(status)) {
+ return;
+ }
+
+ quantity.roundToInfinity(); // Enables toDouble
+ const units::RouteResult routed = fUnitsRouter.route(quantity.toDouble(), &micros.rounder, status);
+ if (U_FAILURE(status)) {
+ return;
+ }
+ const MaybeStackVector<Measure>& routedMeasures = routed.measures;
+ micros.outputUnit = routed.outputUnit.copy(status).build(status);
+ if (U_FAILURE(status)) {
+ return;
+ }
+
+ mixedMeasuresToMicros(routedMeasures, &quantity, &micros, status);
+}
+
+UnitConversionHandler::UnitConversionHandler(const MeasureUnit &inputUnit, const MeasureUnit &outputUnit,
+ const MicroPropsGenerator *parent, UErrorCode &status)
+ : fOutputUnit(outputUnit), fParent(parent) {
+ MeasureUnitImpl tempInput, tempOutput;
+ const MeasureUnitImpl &inputUnitImpl = MeasureUnitImpl::forMeasureUnit(inputUnit, tempInput, status);
+ const MeasureUnitImpl &outputUnitImpl =
+ MeasureUnitImpl::forMeasureUnit(outputUnit, tempOutput, status);
+
+ // TODO: this should become an initOnce thing? Review with other
+ // ConversionRates usages.
+ ConversionRates conversionRates(status);
+ if (U_FAILURE(status)) {
+ return;
+ }
+ fUnitConverter.adoptInsteadAndCheckErrorCode(
+ new ComplexUnitsConverter(inputUnitImpl, outputUnitImpl, conversionRates, status), status);
+}
+
+void UnitConversionHandler::processQuantity(DecimalQuantity &quantity, MicroProps &micros,
+ UErrorCode &status) const {
+ fParent->processQuantity(quantity, micros, status);
+ if (U_FAILURE(status)) {
+ return;
+ }
+ quantity.roundToInfinity(); // Enables toDouble
+ MaybeStackVector<Measure> measures =
+ fUnitConverter->convert(quantity.toDouble(), &micros.rounder, status);
+ micros.outputUnit = fOutputUnit;
+ if (U_FAILURE(status)) {
+ return;
+ }
+
+ mixedMeasuresToMicros(measures, &quantity, &micros, status);
+}
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/number_usageprefs.h b/deps/icu-small/source/i18n/number_usageprefs.h
new file mode 100644
index 0000000000..9e8bd936bd
--- /dev/null
+++ b/deps/icu-small/source/i18n/number_usageprefs.h
@@ -0,0 +1,125 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+#ifndef __NUMBER_USAGEPREFS_H__
+#define __NUMBER_USAGEPREFS_H__
+
+#include "cmemory.h"
+#include "number_types.h"
+#include "unicode/listformatter.h"
+#include "unicode/localpointer.h"
+#include "unicode/locid.h"
+#include "unicode/measunit.h"
+#include "unicode/stringpiece.h"
+#include "unicode/uobject.h"
+#include "units_converter.h"
+#include "units_router.h"
+
+U_NAMESPACE_BEGIN
+
+using ::icu::units::ComplexUnitsConverter;
+using ::icu::units::UnitsRouter;
+
+namespace number {
+namespace impl {
+
+/**
+ * A MicroPropsGenerator which uses UnitsRouter to produce output converted to a
+ * MeasureUnit appropriate for a particular localized usage: see
+ * NumberFormatterSettings::usage().
+ */
+class U_I18N_API UsagePrefsHandler : public MicroPropsGenerator, public UMemory {
+ public:
+ UsagePrefsHandler(const Locale &locale, const MeasureUnit &inputUnit, const StringPiece usage,
+ const MicroPropsGenerator *parent, UErrorCode &status);
+
+ /**
+ * Obtains the appropriate output value, MeasureUnit and
+ * rounding/precision behaviour from the UnitsRouter.
+ *
+ * The output unit is passed on to the LongNameHandler via
+ * micros.outputUnit.
+ */
+ void processQuantity(DecimalQuantity &quantity, MicroProps &micros,
+ UErrorCode &status) const U_OVERRIDE;
+
+ /**
+ * Returns the list of possible output units, i.e. the full set of
+ * preferences, for the localized, usage-specific unit preferences.
+ *
+ * The returned pointer should be valid for the lifetime of the
+ * UsagePrefsHandler instance.
+ */
+ const MaybeStackVector<MeasureUnit> *getOutputUnits() const {
+ return fUnitsRouter.getOutputUnits();
+ }
+
+ private:
+ UnitsRouter fUnitsRouter;
+ const MicroPropsGenerator *fParent;
+};
+
+} // namespace impl
+} // namespace number
+
+// Export explicit template instantiations of LocalPointerBase and LocalPointer.
+// This is required when building DLLs for Windows. (See datefmt.h,
+// collationiterator.h, erarules.h and others for similar examples.)
+//
+// Note: These need to be outside of the number::impl namespace, or Clang will
+// generate a compile error.
+#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
+#if defined(_MSC_VER)
+// Ignore warning 4661 as LocalPointerBase does not use operator== or operator!=
+#pragma warning(push)
+#pragma warning(disable: 4661)
+#endif
+template class U_I18N_API LocalPointerBase<ComplexUnitsConverter>;
+template class U_I18N_API LocalPointer<ComplexUnitsConverter>;
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif
+#endif
+
+namespace number {
+namespace impl {
+
+/**
+ * A MicroPropsGenerator which converts a measurement from one MeasureUnit to
+ * another. In particular, the output MeasureUnit may be a mixed unit. (The
+ * input unit may not be a mixed unit.)
+ */
+class U_I18N_API UnitConversionHandler : public MicroPropsGenerator, public UMemory {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param inputUnit Specifies the input MeasureUnit. Mixed units are not
+ * supported as input (because input is just a single decimal quantity).
+ * @param outputUnit Specifies the output MeasureUnit.
+ * @param parent The parent MicroPropsGenerator.
+ * @param status Receives status.
+ */
+ UnitConversionHandler(const MeasureUnit &inputUnit, const MeasureUnit &outputUnit,
+ const MicroPropsGenerator *parent, UErrorCode &status);
+
+ /**
+ * Obtains the appropriate output values from the Unit Converter.
+ */
+ void processQuantity(DecimalQuantity &quantity, MicroProps &micros,
+ UErrorCode &status) const U_OVERRIDE;
+ private:
+ MeasureUnit fOutputUnit;
+ LocalPointer<ComplexUnitsConverter> fUnitConverter;
+ const MicroPropsGenerator *fParent;
+};
+
+} // namespace impl
+} // namespace number
+U_NAMESPACE_END
+
+#endif // __NUMBER_USAGEPREFS_H__
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/number_utils.cpp b/deps/icu-small/source/i18n/number_utils.cpp
index 91d7f335cd..bef7ea6c61 100644
--- a/deps/icu-small/source/i18n/number_utils.cpp
+++ b/deps/icu-small/source/i18n/number_utils.cpp
@@ -258,7 +258,10 @@ void DecNum::toString(ByteSink& output, UErrorCode& status) const {
}
// "string must be at least dn->digits+14 characters long"
int32_t minCapacity = fData.getAlias()->digits + 14;
- MaybeStackArray<char, 30> buffer(minCapacity);
+ MaybeStackArray<char, 30> buffer(minCapacity, status);
+ if (U_FAILURE(status)) {
+ return;
+ }
uprv_decNumberToString(fData, buffer.getAlias());
output.Append(buffer.getAlias(), static_cast<int32_t>(uprv_strlen(buffer.getAlias())));
}
diff --git a/deps/icu-small/source/i18n/number_utils.h b/deps/icu-small/source/i18n/number_utils.h
index 93195f080b..bc369c940f 100644
--- a/deps/icu-small/source/i18n/number_utils.h
+++ b/deps/icu-small/source/i18n/number_utils.h
@@ -49,8 +49,8 @@ inline bool unitIsCurrency(const MeasureUnit& unit) {
return uprv_strcmp("currency", unit.getType()) == 0;
}
-inline bool unitIsNoUnit(const MeasureUnit& unit) {
- return uprv_strcmp("none", unit.getType()) == 0;
+inline bool unitIsBaseUnit(const MeasureUnit& unit) {
+ return unit == MeasureUnit();
}
inline bool unitIsPercent(const MeasureUnit& unit) {
diff --git a/deps/icu-small/source/i18n/number_utypes.h b/deps/icu-small/source/i18n/number_utypes.h
index 7a1b7a4e80..d97eadc5cd 100644
--- a/deps/icu-small/source/i18n/number_utypes.h
+++ b/deps/icu-small/source/i18n/number_utypes.h
@@ -28,9 +28,6 @@ const DecimalQuantity* validateUFormattedNumberToDecimalQuantity(
* This struct is held internally by the C++ version FormattedNumber since the member types are not
* declared in the public header file.
*
- * The DecimalQuantity is not currently being used by FormattedNumber, but at some point it could be used
- * to add a toDecNumber() or similar method.
- *
* Exported as U_I18N_API for tests
*/
class U_I18N_API UFormattedNumberData : public FormattedValueStringBuilderImpl {
@@ -38,7 +35,13 @@ public:
UFormattedNumberData() : FormattedValueStringBuilderImpl(kUndefinedField) {}
virtual ~UFormattedNumberData();
+ // The formatted quantity.
DecimalQuantity quantity;
+
+ // The output unit for the formatted quantity.
+ // TODO(units,hugovdm): populate this correctly for the general case - it's
+ // currently only implemented for the .usage() use case.
+ MeasureUnit outputUnit;
};
diff --git a/deps/icu-small/source/i18n/numparse_affixes.cpp b/deps/icu-small/source/i18n/numparse_affixes.cpp
index 187830fb6f..cef1685d03 100644
--- a/deps/icu-small/source/i18n/numparse_affixes.cpp
+++ b/deps/icu-small/source/i18n/numparse_affixes.cpp
@@ -127,8 +127,8 @@ void AffixPatternMatcherBuilder::addMatcher(NumberParseMatcher& matcher) {
fMatchers[fMatchersLen++] = &matcher;
}
-AffixPatternMatcher AffixPatternMatcherBuilder::build() {
- return AffixPatternMatcher(fMatchers, fMatchersLen, fPattern);
+AffixPatternMatcher AffixPatternMatcherBuilder::build(UErrorCode& status) {
+ return AffixPatternMatcher(fMatchers, fMatchersLen, fPattern, status);
}
AffixTokenMatcherWarehouse::AffixTokenMatcherWarehouse(const AffixTokenMatcherSetupData* setupData)
@@ -209,12 +209,13 @@ AffixPatternMatcher AffixPatternMatcher::fromAffixPattern(const UnicodeString& a
AffixPatternMatcherBuilder builder(affixPattern, tokenWarehouse, ignorables);
AffixUtils::iterateWithConsumer(affixPattern, builder, status);
- return builder.build();
+ return builder.build(status);
}
AffixPatternMatcher::AffixPatternMatcher(MatcherArray& matchers, int32_t matchersLen,
- const UnicodeString& pattern)
- : ArraySeriesMatcher(matchers, matchersLen), fPattern(pattern) {}
+ const UnicodeString& pattern, UErrorCode& status)
+ : ArraySeriesMatcher(matchers, matchersLen), fPattern(pattern, status) {
+}
UnicodeString AffixPatternMatcher::getPattern() const {
return fPattern.toAliasedUnicodeString();
diff --git a/deps/icu-small/source/i18n/numparse_affixes.h b/deps/icu-small/source/i18n/numparse_affixes.h
index 2ac69df109..511c73c745 100644
--- a/deps/icu-small/source/i18n/numparse_affixes.h
+++ b/deps/icu-small/source/i18n/numparse_affixes.h
@@ -128,7 +128,7 @@ class AffixPatternMatcherBuilder : public TokenConsumer, public MutableMatcherCo
void consumeToken(::icu::number::impl::AffixPatternType type, UChar32 cp, UErrorCode& status) override;
/** NOTE: You can build only once! */
- AffixPatternMatcher build();
+ AffixPatternMatcher build(UErrorCode& status);
private:
ArraySeriesMatcher::MatcherArray fMatchers;
@@ -160,7 +160,8 @@ class U_I18N_API AffixPatternMatcher : public ArraySeriesMatcher {
private:
CompactUnicodeString<4> fPattern;
- AffixPatternMatcher(MatcherArray& matchers, int32_t matchersLen, const UnicodeString& pattern);
+ AffixPatternMatcher(MatcherArray& matchers, int32_t matchersLen, const UnicodeString& pattern,
+ UErrorCode& status);
friend class AffixPatternMatcherBuilder;
};
diff --git a/deps/icu-small/source/i18n/numparse_types.h b/deps/icu-small/source/i18n/numparse_types.h
index b4007c2ff5..623f0e80f1 100644
--- a/deps/icu-small/source/i18n/numparse_types.h
+++ b/deps/icu-small/source/i18n/numparse_types.h
@@ -64,14 +64,15 @@ class CompactUnicodeString {
fBuffer[0] = 0;
}
- CompactUnicodeString(const UnicodeString& text)
- : fBuffer(text.length() + 1) {
+ CompactUnicodeString(const UnicodeString& text, UErrorCode& status)
+ : fBuffer(text.length() + 1, status) {
+ if (U_FAILURE(status)) { return; }
uprv_memcpy(fBuffer.getAlias(), text.getBuffer(), sizeof(UChar) * text.length());
fBuffer[text.length()] = 0;
}
inline UnicodeString toAliasedUnicodeString() const {
- return UnicodeString(TRUE, fBuffer.getAlias(), -1);
+ return UnicodeString(true, fBuffer.getAlias(), -1);
}
bool operator==(const CompactUnicodeString& other) const {
diff --git a/deps/icu-small/source/i18n/numrange_capi.cpp b/deps/icu-small/source/i18n/numrange_capi.cpp
new file mode 100644
index 0000000000..a440a53fe6
--- /dev/null
+++ b/deps/icu-small/source/i18n/numrange_capi.cpp
@@ -0,0 +1,193 @@
+// © 2018 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+// Allow implicit conversion from char16_t* to UnicodeString for this file:
+// Helpful in toString methods and elsewhere.
+#define UNISTR_FROM_STRING_EXPLICIT
+
+#include "fphdlimp.h"
+#include "number_utypes.h"
+#include "numparse_types.h"
+#include "formattedval_impl.h"
+#include "numrange_impl.h"
+#include "number_decnum.h"
+#include "unicode/numberrangeformatter.h"
+#include "unicode/unumberrangeformatter.h"
+
+using namespace icu;
+using namespace icu::number;
+using namespace icu::number::impl;
+
+
+U_NAMESPACE_BEGIN
+namespace number {
+namespace impl {
+
+/**
+ * Implementation class for UNumberRangeFormatter. Wraps a LocalizedRangeNumberFormatter.
+ */
+struct UNumberRangeFormatterData : public UMemory,
+ // Magic number as ASCII == "NRF" (NumberRangeFormatter)
+ public IcuCApiHelper<UNumberRangeFormatter, UNumberRangeFormatterData, 0x4E524600> {
+ LocalizedNumberRangeFormatter fFormatter;
+};
+
+struct UFormattedNumberRangeImpl;
+
+// Magic number as ASCII == "FDN" (FormatteDNumber)
+typedef IcuCApiHelper<UFormattedNumberRange, UFormattedNumberRangeImpl, 0x46444E00> UFormattedNumberRangeApiHelper;
+
+struct UFormattedNumberRangeImpl : public UFormattedValueImpl, public UFormattedNumberRangeApiHelper {
+ UFormattedNumberRangeImpl();
+ ~UFormattedNumberRangeImpl();
+
+ FormattedNumberRange fImpl;
+ UFormattedNumberRangeData fData;
+};
+
+UFormattedNumberRangeImpl::UFormattedNumberRangeImpl()
+ : fImpl(&fData) {
+ fFormattedValue = &fImpl;
+}
+
+UFormattedNumberRangeImpl::~UFormattedNumberRangeImpl() {
+ // Disown the data from fImpl so it doesn't get deleted twice
+ fImpl.fData = nullptr;
+}
+
+} // namespace impl
+} // namespace number
+U_NAMESPACE_END
+
+
+UPRV_FORMATTED_VALUE_CAPI_NO_IMPLTYPE_AUTO_IMPL(
+ UFormattedNumberRange,
+ UFormattedNumberRangeImpl,
+ UFormattedNumberRangeApiHelper,
+ unumrf)
+
+
+const UFormattedNumberRangeData* number::impl::validateUFormattedNumberRange(
+ const UFormattedNumberRange* uresult, UErrorCode& status) {
+ auto* result = UFormattedNumberRangeApiHelper::validate(uresult, status);
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
+ return &result->fData;
+}
+
+
+U_CAPI UNumberRangeFormatter* U_EXPORT2
+unumrf_openForSkeletonWithCollapseAndIdentityFallback(
+ const UChar* skeleton,
+ int32_t skeletonLen,
+ UNumberRangeCollapse collapse,
+ UNumberRangeIdentityFallback identityFallback,
+ const char* locale,
+ UParseError* perror,
+ UErrorCode* ec) {
+ auto* impl = new UNumberRangeFormatterData();
+ if (impl == nullptr) {
+ *ec = U_MEMORY_ALLOCATION_ERROR;
+ return nullptr;
+ }
+ // Readonly-alias constructor (first argument is whether we are NUL-terminated)
+ UnicodeString skeletonString(skeletonLen == -1, skeleton, skeletonLen);
+ impl->fFormatter = NumberRangeFormatter::withLocale(locale)
+ .numberFormatterBoth(NumberFormatter::forSkeleton(skeletonString, *perror, *ec))
+ .collapse(collapse)
+ .identityFallback(identityFallback);
+ return impl->exportForC();
+}
+
+U_CAPI void U_EXPORT2
+unumrf_formatDoubleRange(
+ const UNumberRangeFormatter* uformatter,
+ double first,
+ double second,
+ UFormattedNumberRange* uresult,
+ UErrorCode* ec) {
+ const UNumberRangeFormatterData* formatter = UNumberRangeFormatterData::validate(uformatter, *ec);
+ auto* result = UFormattedNumberRangeApiHelper::validate(uresult, *ec);
+ if (U_FAILURE(*ec)) { return; }
+
+ result->fData.getStringRef().clear();
+ result->fData.quantity1.setToDouble(first);
+ result->fData.quantity2.setToDouble(second);
+ formatter->fFormatter.formatImpl(result->fData, first == second, *ec);
+}
+
+U_CAPI void U_EXPORT2
+unumrf_formatDecimalRange(
+ const UNumberRangeFormatter* uformatter,
+ const char* first, int32_t firstLen,
+ const char* second, int32_t secondLen,
+ UFormattedNumberRange* uresult,
+ UErrorCode* ec) {
+ const UNumberRangeFormatterData* formatter = UNumberRangeFormatterData::validate(uformatter, *ec);
+ auto* result = UFormattedNumberRangeApiHelper::validate(uresult, *ec);
+ if (U_FAILURE(*ec)) { return; }
+
+ result->fData.getStringRef().clear();
+ result->fData.quantity1.setToDecNumber({first, firstLen}, *ec);
+ result->fData.quantity2.setToDecNumber({second, secondLen}, *ec);
+ formatter->fFormatter.formatImpl(result->fData, first == second, *ec);
+}
+
+U_CAPI UNumberRangeIdentityResult U_EXPORT2
+unumrf_resultGetIdentityResult(
+ const UFormattedNumberRange* uresult,
+ UErrorCode* ec) {
+ auto* result = UFormattedNumberRangeApiHelper::validate(uresult, *ec);
+ if (U_FAILURE(*ec)) {
+ return UNUM_IDENTITY_RESULT_COUNT;
+ }
+ return result->fData.identityResult;
+}
+
+U_CAPI int32_t U_EXPORT2
+unumrf_resultGetFirstDecimalNumber(
+ const UFormattedNumberRange* uresult,
+ char* dest,
+ int32_t destCapacity,
+ UErrorCode* ec) {
+ const auto* result = UFormattedNumberRangeApiHelper::validate(uresult, *ec);
+ if (U_FAILURE(*ec)) {
+ return 0;
+ }
+ DecNum decnum;
+ return result->fData.quantity1.toDecNum(decnum, *ec)
+ .toCharString(*ec)
+ .extract(dest, destCapacity, *ec);
+}
+
+U_CAPI int32_t U_EXPORT2
+unumrf_resultGetSecondDecimalNumber(
+ const UFormattedNumberRange* uresult,
+ char* dest,
+ int32_t destCapacity,
+ UErrorCode* ec) {
+ const auto* result = UFormattedNumberRangeApiHelper::validate(uresult, *ec);
+ if (U_FAILURE(*ec)) {
+ return 0;
+ }
+ DecNum decnum;
+ return result->fData.quantity2
+ .toDecNum(decnum, *ec)
+ .toCharString(*ec)
+ .extract(dest, destCapacity, *ec);
+}
+
+U_CAPI void U_EXPORT2
+unumrf_close(UNumberRangeFormatter* f) {
+ UErrorCode localStatus = U_ZERO_ERROR;
+ const UNumberRangeFormatterData* impl = UNumberRangeFormatterData::validate(f, localStatus);
+ delete impl;
+}
+
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/numrange_fluent.cpp b/deps/icu-small/source/i18n/numrange_fluent.cpp
index 33179026f8..d9286d1d71 100644
--- a/deps/icu-small/source/i18n/numrange_fluent.cpp
+++ b/deps/icu-small/source/i18n/numrange_fluent.cpp
@@ -12,6 +12,7 @@
#include "numrange_impl.h"
#include "util.h"
#include "number_utypes.h"
+#include "number_decnum.h"
using namespace icu;
using namespace icu::number;
@@ -375,28 +376,4 @@ LocalizedNumberRangeFormatter::getFormatter(UErrorCode& status) const {
}
-UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedNumberRange)
-
-#define UPRV_NOARG
-
-UnicodeString FormattedNumberRange::getFirstDecimal(UErrorCode& status) const {
- UPRV_FORMATTED_VALUE_METHOD_GUARD(ICU_Utility::makeBogusString())
- return fData->quantity1.toScientificString();
-}
-
-UnicodeString FormattedNumberRange::getSecondDecimal(UErrorCode& status) const {
- UPRV_FORMATTED_VALUE_METHOD_GUARD(ICU_Utility::makeBogusString())
- return fData->quantity2.toScientificString();
-}
-
-UNumberRangeIdentityResult FormattedNumberRange::getIdentityResult(UErrorCode& status) const {
- UPRV_FORMATTED_VALUE_METHOD_GUARD(UNUM_IDENTITY_RESULT_NOT_EQUAL)
- return fData->identityResult;
-}
-
-
-UFormattedNumberRangeData::~UFormattedNumberRangeData() = default;
-
-
-
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/numrange_impl.cpp b/deps/icu-small/source/i18n/numrange_impl.cpp
index 9fb3dee861..3aae5c2354 100644
--- a/deps/icu-small/source/i18n/numrange_impl.cpp
+++ b/deps/icu-small/source/i18n/numrange_impl.cpp
@@ -12,6 +12,7 @@
#include "unicode/numberrangeformatter.h"
#include "numrange_impl.h"
#include "patternprops.h"
+#include "pluralranges.h"
#include "uresimp.h"
#include "util.h"
@@ -106,92 +107,9 @@ void getNumberRangeData(const char* localeName, const char* nsName, NumberRangeD
sink.fillInDefaults(status);
}
-class PluralRangesDataSink : public ResourceSink {
- public:
- PluralRangesDataSink(StandardPluralRanges& output) : fOutput(output) {}
-
- void put(const char* /*key*/, ResourceValue& value, UBool /*noFallback*/, UErrorCode& status) U_OVERRIDE {
- ResourceArray entriesArray = value.getArray(status);
- if (U_FAILURE(status)) { return; }
- fOutput.setCapacity(entriesArray.getSize());
- for (int i = 0; entriesArray.getValue(i, value); i++) {
- ResourceArray pluralFormsArray = value.getArray(status);
- if (U_FAILURE(status)) { return; }
- pluralFormsArray.getValue(0, value);
- StandardPlural::Form first = StandardPlural::fromString(value.getUnicodeString(status), status);
- if (U_FAILURE(status)) { return; }
- pluralFormsArray.getValue(1, value);
- StandardPlural::Form second = StandardPlural::fromString(value.getUnicodeString(status), status);
- if (U_FAILURE(status)) { return; }
- pluralFormsArray.getValue(2, value);
- StandardPlural::Form result = StandardPlural::fromString(value.getUnicodeString(status), status);
- if (U_FAILURE(status)) { return; }
- fOutput.addPluralRange(first, second, result);
- }
- }
-
- private:
- StandardPluralRanges& fOutput;
-};
-
-void getPluralRangesData(const Locale& locale, StandardPluralRanges& output, UErrorCode& status) {
- if (U_FAILURE(status)) { return; }
- LocalUResourceBundlePointer rb(ures_openDirect(nullptr, "pluralRanges", &status));
- if (U_FAILURE(status)) { return; }
-
- CharString dataPath;
- dataPath.append("locales/", -1, status);
- dataPath.append(locale.getLanguage(), -1, status);
- if (U_FAILURE(status)) { return; }
- int32_t setLen;
- // Not all languages are covered: fail gracefully
- UErrorCode internalStatus = U_ZERO_ERROR;
- const UChar* set = ures_getStringByKeyWithFallback(rb.getAlias(), dataPath.data(), &setLen, &internalStatus);
- if (U_FAILURE(internalStatus)) { return; }
-
- dataPath.clear();
- dataPath.append("rules/", -1, status);
- dataPath.appendInvariantChars(set, setLen, status);
- if (U_FAILURE(status)) { return; }
- PluralRangesDataSink sink(output);
- ures_getAllItemsWithFallback(rb.getAlias(), dataPath.data(), sink, status);
- if (U_FAILURE(status)) { return; }
-}
-
} // namespace
-void StandardPluralRanges::initialize(const Locale& locale, UErrorCode& status) {
- getPluralRangesData(locale, *this, status);
-}
-
-void StandardPluralRanges::addPluralRange(
- StandardPlural::Form first,
- StandardPlural::Form second,
- StandardPlural::Form result) {
- U_ASSERT(fTriplesLen < fTriples.getCapacity());
- fTriples[fTriplesLen] = {first, second, result};
- fTriplesLen++;
-}
-
-void StandardPluralRanges::setCapacity(int32_t length) {
- if (length > fTriples.getCapacity()) {
- fTriples.resize(length, 0);
- }
-}
-
-StandardPlural::Form
-StandardPluralRanges::resolve(StandardPlural::Form first, StandardPlural::Form second) const {
- for (int32_t i=0; i<fTriplesLen; i++) {
- const auto& triple = fTriples[i];
- if (triple.first == first && triple.second == second) {
- return triple.result;
- }
- }
- // Default fallback
- return StandardPlural::OTHER;
-}
-
NumberRangeFormatterImpl::NumberRangeFormatterImpl(const RangeMacroProps& macros, UErrorCode& status)
: formatterImpl1(macros.formatter1.fMacros, status),
@@ -213,7 +131,7 @@ NumberRangeFormatterImpl::NumberRangeFormatterImpl(const RangeMacroProps& macros
fApproximatelyModifier = {data.approximatelyPattern, kUndefinedField, false};
// TODO: Get locale from PluralRules instead?
- fPluralRanges.initialize(macros.locale, status);
+ fPluralRanges = StandardPluralRanges::forLocale(macros.locale, status);
if (U_FAILURE(status)) { return; }
}
diff --git a/deps/icu-small/source/i18n/numrange_impl.h b/deps/icu-small/source/i18n/numrange_impl.h
index 8f4c8a40ba..b81a311a5f 100644
--- a/deps/icu-small/source/i18n/numrange_impl.h
+++ b/deps/icu-small/source/i18n/numrange_impl.h
@@ -15,6 +15,7 @@
#include "number_formatimpl.h"
#include "formatted_string_builder.h"
#include "formattedval_impl.h"
+#include "pluralranges.h"
U_NAMESPACE_BEGIN namespace number {
namespace impl {
@@ -40,36 +41,6 @@ public:
};
-class StandardPluralRanges : public UMemory {
- public:
- void initialize(const Locale& locale, UErrorCode& status);
- StandardPlural::Form resolve(StandardPlural::Form first, StandardPlural::Form second) const;
-
- /** Used for data loading. */
- void addPluralRange(
- StandardPlural::Form first,
- StandardPlural::Form second,
- StandardPlural::Form result);
-
- /** Used for data loading. */
- void setCapacity(int32_t length);
-
- private:
- struct StandardPluralRangeTriple {
- StandardPlural::Form first;
- StandardPlural::Form second;
- StandardPlural::Form result;
- };
-
- // TODO: An array is simple here, but it results in linear lookup time.
- // Certain locales have 20-30 entries in this list.
- // Consider changing to a smarter data structure.
- typedef MaybeStackArray<StandardPluralRangeTriple, 3> PluralRangeTriples;
- PluralRangeTriples fTriples;
- int32_t fTriplesLen = 0;
-};
-
-
class NumberRangeFormatterImpl : public UMemory {
public:
NumberRangeFormatterImpl(const RangeMacroProps& macros, UErrorCode& status);
@@ -105,6 +76,11 @@ class NumberRangeFormatterImpl : public UMemory {
};
+/** Helper function used in upluralrules.cpp */
+const UFormattedNumberRangeData* validateUFormattedNumberRange(
+ const UFormattedNumberRange* uresult, UErrorCode& status);
+
+
} // namespace impl
} // namespace number
U_NAMESPACE_END
diff --git a/deps/icu-small/source/i18n/olsontz.cpp b/deps/icu-small/source/i18n/olsontz.cpp
index dd01180f8c..cb142f7b9e 100644
--- a/deps/icu-small/source/i18n/olsontz.cpp
+++ b/deps/icu-small/source/i18n/olsontz.cpp
@@ -197,58 +197,60 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top,
}
// Process final rule and data, if any
- const UChar *ruleIdUStr = ures_getStringByKey(res, kFINALRULE, &len, &ec);
- ures_getByKey(res, kFINALRAW, r.getAlias(), &ec);
- int32_t ruleRaw = ures_getInt(r.getAlias(), &ec);
- ures_getByKey(res, kFINALYEAR, r.getAlias(), &ec);
- int32_t ruleYear = ures_getInt(r.getAlias(), &ec);
if (U_SUCCESS(ec)) {
- UnicodeString ruleID(TRUE, ruleIdUStr, len);
- UResourceBundle *rule = TimeZone::loadRule(top, ruleID, NULL, ec);
- const int32_t *ruleData = ures_getIntVector(rule, &len, &ec);
- if (U_SUCCESS(ec) && len == 11) {
- UnicodeString emptyStr;
- finalZone = new SimpleTimeZone(
- ruleRaw * U_MILLIS_PER_SECOND,
- emptyStr,
- (int8_t)ruleData[0], (int8_t)ruleData[1], (int8_t)ruleData[2],
- ruleData[3] * U_MILLIS_PER_SECOND,
- (SimpleTimeZone::TimeMode) ruleData[4],
- (int8_t)ruleData[5], (int8_t)ruleData[6], (int8_t)ruleData[7],
- ruleData[8] * U_MILLIS_PER_SECOND,
- (SimpleTimeZone::TimeMode) ruleData[9],
- ruleData[10] * U_MILLIS_PER_SECOND, ec);
- if (finalZone == NULL) {
- ec = U_MEMORY_ALLOCATION_ERROR;
- } else {
- finalStartYear = ruleYear;
+ const UChar *ruleIdUStr = ures_getStringByKey(res, kFINALRULE, &len, &ec);
+ ures_getByKey(res, kFINALRAW, r.getAlias(), &ec);
+ int32_t ruleRaw = ures_getInt(r.getAlias(), &ec);
+ ures_getByKey(res, kFINALYEAR, r.getAlias(), &ec);
+ int32_t ruleYear = ures_getInt(r.getAlias(), &ec);
+ if (U_SUCCESS(ec)) {
+ UnicodeString ruleID(TRUE, ruleIdUStr, len);
+ UResourceBundle *rule = TimeZone::loadRule(top, ruleID, NULL, ec);
+ const int32_t *ruleData = ures_getIntVector(rule, &len, &ec);
+ if (U_SUCCESS(ec) && len == 11) {
+ UnicodeString emptyStr;
+ finalZone = new SimpleTimeZone(
+ ruleRaw * U_MILLIS_PER_SECOND,
+ emptyStr,
+ (int8_t)ruleData[0], (int8_t)ruleData[1], (int8_t)ruleData[2],
+ ruleData[3] * U_MILLIS_PER_SECOND,
+ (SimpleTimeZone::TimeMode) ruleData[4],
+ (int8_t)ruleData[5], (int8_t)ruleData[6], (int8_t)ruleData[7],
+ ruleData[8] * U_MILLIS_PER_SECOND,
+ (SimpleTimeZone::TimeMode) ruleData[9],
+ ruleData[10] * U_MILLIS_PER_SECOND, ec);
+ if (finalZone == NULL) {
+ ec = U_MEMORY_ALLOCATION_ERROR;
+ } else {
+ finalStartYear = ruleYear;
- // Note: Setting finalStartYear to the finalZone is problematic. When a date is around
- // year boundary, SimpleTimeZone may return false result when DST is observed at the
- // beginning of year. We could apply safe margin (day or two), but when one of recurrent
- // rules falls around year boundary, it could return false result. Without setting the
- // start year, finalZone works fine around the year boundary of the start year.
+ // Note: Setting finalStartYear to the finalZone is problematic. When a date is around
+ // year boundary, SimpleTimeZone may return false result when DST is observed at the
+ // beginning of year. We could apply safe margin (day or two), but when one of recurrent
+ // rules falls around year boundary, it could return false result. Without setting the
+ // start year, finalZone works fine around the year boundary of the start year.
- // finalZone->setStartYear(finalStartYear);
+ // finalZone->setStartYear(finalStartYear);
- // Compute the millis for Jan 1, 0:00 GMT of the finalYear
+ // Compute the millis for Jan 1, 0:00 GMT of the finalYear
- // Note: finalStartMillis is used for detecting either if
- // historic transition data or finalZone to be used. In an
- // extreme edge case - for example, two transitions fall into
- // small windows of time around the year boundary, this may
- // result incorrect offset computation. But I think it will
- // never happen practically. Yoshito - Feb 20, 2010
- finalStartMillis = Grego::fieldsToDay(finalStartYear, 0, 1) * U_MILLIS_PER_DAY;
+ // Note: finalStartMillis is used for detecting either if
+ // historic transition data or finalZone to be used. In an
+ // extreme edge case - for example, two transitions fall into
+ // small windows of time around the year boundary, this may
+ // result incorrect offset computation. But I think it will
+ // never happen practically. Yoshito - Feb 20, 2010
+ finalStartMillis = Grego::fieldsToDay(finalStartYear, 0, 1) * U_MILLIS_PER_DAY;
+ }
+ } else {
+ ec = U_INVALID_FORMAT_ERROR;
}
- } else {
- ec = U_INVALID_FORMAT_ERROR;
+ ures_close(rule);
+ } else if (ec == U_MISSING_RESOURCE_ERROR) {
+ // No final zone
+ ec = U_ZERO_ERROR;
}
- ures_close(rule);
- } else if (ec == U_MISSING_RESOURCE_ERROR) {
- // No final zone
- ec = U_ZERO_ERROR;
}
// initialize canonical ID
diff --git a/deps/icu-small/source/i18n/olsontz.h b/deps/icu-small/source/i18n/olsontz.h
index 7960154698..643a695369 100644
--- a/deps/icu-small/source/i18n/olsontz.h
+++ b/deps/icu-small/source/i18n/olsontz.h
@@ -208,7 +208,7 @@ class U_I18N_API OlsonTimeZone: public BasicTimeZone {
/**
* TimeZone API. For a historical zone, whether DST is used or
* not varies over time. In order to approximate expected
- * behavior, this method returns TRUE if DST is observed at any
+ * behavior, this method returns true if DST is observed at any
* point in the current year.
*/
virtual UBool useDaylightTime() const;
@@ -234,7 +234,7 @@ class U_I18N_API OlsonTimeZone: public BasicTimeZone {
* @param base The base time.
* @param inclusive Whether the base time is inclusive or not.
* @param result Receives the first transition after the base time.
- * @return TRUE if the transition is found.
+ * @return true if the transition is found.
*/
virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const;
@@ -244,7 +244,7 @@ class U_I18N_API OlsonTimeZone: public BasicTimeZone {
* @param base The base time.
* @param inclusive Whether the base time is inclusive or not.
* @param result Receives the most recent transition before the base time.
- * @return TRUE if the transition is found.
+ * @return true if the transition is found.
*/
virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const;
diff --git a/deps/icu-small/source/i18n/persncal.cpp b/deps/icu-small/source/i18n/persncal.cpp
index 4d366d41f0..ba306653af 100644
--- a/deps/icu-small/source/i18n/persncal.cpp
+++ b/deps/icu-small/source/i18n/persncal.cpp
@@ -79,7 +79,7 @@ PersianCalendar* PersianCalendar::clone() const {
}
PersianCalendar::PersianCalendar(const Locale& aLocale, UErrorCode& success)
- : Calendar(TimeZone::createDefault(), aLocale, success)
+ : Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success)
{
setTimeInMillis(getNow(), success); // Call this again now that the vtable is set up properly.
}
diff --git a/deps/icu-small/source/i18n/persncal.h b/deps/icu-small/source/i18n/persncal.h
index a9d940db78..f330ea8a03 100644
--- a/deps/icu-small/source/i18n/persncal.h
+++ b/deps/icu-small/source/i18n/persncal.h
@@ -295,7 +295,7 @@ class PersianCalendar : public Calendar {
virtual UBool inDaylightTime(UErrorCode& status) const;
/**
- * Returns TRUE because the Persian Calendar does have a default century
+ * Returns true because the Persian Calendar does have a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/pluralranges.cpp b/deps/icu-small/source/i18n/pluralranges.cpp
new file mode 100644
index 0000000000..da10e2117d
--- /dev/null
+++ b/deps/icu-small/source/i18n/pluralranges.cpp
@@ -0,0 +1,144 @@
+// © 2018 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+// Allow implicit conversion from char16_t* to UnicodeString for this file:
+// Helpful in toString methods and elsewhere.
+#define UNISTR_FROM_STRING_EXPLICIT
+
+#include "unicode/numberrangeformatter.h"
+#include "pluralranges.h"
+#include "uresimp.h"
+#include "charstr.h"
+#include "uassert.h"
+#include "util.h"
+#include "numrange_impl.h"
+
+U_NAMESPACE_BEGIN
+
+
+namespace {
+
+class PluralRangesDataSink : public ResourceSink {
+ public:
+ PluralRangesDataSink(StandardPluralRanges& output) : fOutput(output) {}
+
+ void put(const char* /*key*/, ResourceValue& value, UBool /*noFallback*/, UErrorCode& status) U_OVERRIDE {
+ ResourceArray entriesArray = value.getArray(status);
+ if (U_FAILURE(status)) { return; }
+ fOutput.setCapacity(entriesArray.getSize(), status);
+ if (U_FAILURE(status)) { return; }
+ for (int i = 0; entriesArray.getValue(i, value); i++) {
+ ResourceArray pluralFormsArray = value.getArray(status);
+ if (U_FAILURE(status)) { return; }
+ if (pluralFormsArray.getSize() != 3) {
+ status = U_RESOURCE_TYPE_MISMATCH;
+ return;
+ }
+ pluralFormsArray.getValue(0, value);
+ StandardPlural::Form first = StandardPlural::fromString(value.getUnicodeString(status), status);
+ if (U_FAILURE(status)) { return; }
+ pluralFormsArray.getValue(1, value);
+ StandardPlural::Form second = StandardPlural::fromString(value.getUnicodeString(status), status);
+ if (U_FAILURE(status)) { return; }
+ pluralFormsArray.getValue(2, value);
+ StandardPlural::Form result = StandardPlural::fromString(value.getUnicodeString(status), status);
+ if (U_FAILURE(status)) { return; }
+ fOutput.addPluralRange(first, second, result);
+ }
+ }
+
+ private:
+ StandardPluralRanges& fOutput;
+};
+
+void getPluralRangesData(const Locale& locale, StandardPluralRanges& output, UErrorCode& status) {
+ LocalUResourceBundlePointer rb(ures_openDirect(nullptr, "pluralRanges", &status));
+ if (U_FAILURE(status)) { return; }
+
+ CharString dataPath;
+ dataPath.append("locales/", -1, status);
+ dataPath.append(locale.getLanguage(), -1, status);
+ if (U_FAILURE(status)) { return; }
+ int32_t setLen;
+ // Not all languages are covered: fail gracefully
+ UErrorCode internalStatus = U_ZERO_ERROR;
+ const UChar* set = ures_getStringByKeyWithFallback(rb.getAlias(), dataPath.data(), &setLen, &internalStatus);
+ if (U_FAILURE(internalStatus)) { return; }
+
+ dataPath.clear();
+ dataPath.append("rules/", -1, status);
+ dataPath.appendInvariantChars(set, setLen, status);
+ if (U_FAILURE(status)) { return; }
+ PluralRangesDataSink sink(output);
+ ures_getAllItemsWithFallback(rb.getAlias(), dataPath.data(), sink, status);
+}
+
+} // namespace
+
+
+StandardPluralRanges
+StandardPluralRanges::forLocale(const Locale& locale, UErrorCode& status) {
+ StandardPluralRanges result;
+ getPluralRangesData(locale, result, status);
+ return result;
+}
+
+StandardPluralRanges
+StandardPluralRanges::copy(UErrorCode& status) const {
+ StandardPluralRanges result;
+ if (fTriplesLen > result.fTriples.getCapacity()) {
+ if (result.fTriples.resize(fTriplesLen) == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return result;
+ }
+ }
+ uprv_memcpy(result.fTriples.getAlias(),
+ fTriples.getAlias(),
+ fTriplesLen * sizeof(fTriples[0]));
+ result.fTriplesLen = fTriplesLen;
+ return result;
+}
+
+LocalPointer<StandardPluralRanges>
+StandardPluralRanges::toPointer(UErrorCode& status) && noexcept {
+ return LocalPointer<StandardPluralRanges>(new StandardPluralRanges(std::move(*this)), status);
+}
+
+void StandardPluralRanges::addPluralRange(
+ StandardPlural::Form first,
+ StandardPlural::Form second,
+ StandardPlural::Form result) {
+ U_ASSERT(fTriplesLen < fTriples.getCapacity());
+ fTriples[fTriplesLen] = {first, second, result};
+ fTriplesLen++;
+}
+
+void StandardPluralRanges::setCapacity(int32_t length, UErrorCode& status) {
+ if (U_FAILURE(status)) { return; }
+ if (length > fTriples.getCapacity()) {
+ if (fTriples.resize(length, 0) == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ }
+ }
+}
+
+StandardPlural::Form
+StandardPluralRanges::resolve(StandardPlural::Form first, StandardPlural::Form second) const {
+ for (int32_t i=0; i<fTriplesLen; i++) {
+ const auto& triple = fTriples[i];
+ if (triple.first == first && triple.second == second) {
+ return triple.result;
+ }
+ }
+ // Default fallback
+ return StandardPlural::OTHER;
+}
+
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/pluralranges.h b/deps/icu-small/source/i18n/pluralranges.h
new file mode 100644
index 0000000000..eba59c70ed
--- /dev/null
+++ b/deps/icu-small/source/i18n/pluralranges.h
@@ -0,0 +1,67 @@
+// © 2018 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#ifndef __PLURALRANGES_H__
+#define __PLURALRANGES_H__
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uobject.h"
+#include "unicode/locid.h"
+#include "unicode/plurrule.h"
+#include "standardplural.h"
+#include "cmemory.h"
+
+U_NAMESPACE_BEGIN
+
+// Forward declarations
+namespace number {
+namespace impl {
+class UFormattedNumberRangeData;
+}
+}
+
+class StandardPluralRanges : public UMemory {
+ public:
+ /** Create a new StandardPluralRanges for the given locale */
+ static StandardPluralRanges forLocale(const Locale& locale, UErrorCode& status);
+
+ /** Explicit copy constructor */
+ StandardPluralRanges copy(UErrorCode& status) const;
+
+ /** Create an object (called on an rvalue) */
+ LocalPointer<StandardPluralRanges> toPointer(UErrorCode& status) && noexcept;
+
+ /** Select rule based on the first and second forms */
+ StandardPlural::Form resolve(StandardPlural::Form first, StandardPlural::Form second) const;
+
+ /** Used for data loading. */
+ void addPluralRange(
+ StandardPlural::Form first,
+ StandardPlural::Form second,
+ StandardPlural::Form result);
+
+ /** Used for data loading. */
+ void setCapacity(int32_t length, UErrorCode& status);
+
+ private:
+ struct StandardPluralRangeTriple {
+ StandardPlural::Form first;
+ StandardPlural::Form second;
+ StandardPlural::Form result;
+ };
+
+ // TODO: An array is simple here, but it results in linear lookup time.
+ // Certain locales have 20-30 entries in this list.
+ // Consider changing to a smarter data structure.
+ typedef MaybeStackArray<StandardPluralRangeTriple, 3> PluralRangeTriples;
+ PluralRangeTriples fTriples;
+ int32_t fTriplesLen = 0;
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+#endif //__PLURALRANGES_H__
diff --git a/deps/icu-small/source/i18n/plurfmt.cpp b/deps/icu-small/source/i18n/plurfmt.cpp
index b99437630e..aac35c5b09 100644
--- a/deps/icu-small/source/i18n/plurfmt.cpp
+++ b/deps/icu-small/source/i18n/plurfmt.cpp
@@ -549,9 +549,15 @@ void PluralFormat::parseType(const UnicodeString& source, const NFRule *rbnfLeni
UnicodeString currArg = pattern.tempSubString(partStart->getLimit(), partLimit->getIndex() - partStart->getLimit());
if (rbnfLenientScanner != NULL) {
- // If lenient parsing is turned ON, we've got some time consuming parsing ahead of us.
- int32_t length = -1;
- currMatchIndex = rbnfLenientScanner->findTextLenient(source, currArg, startingAt, &length);
+ // Check if non-lenient rule finds the text before call lenient parsing
+ int32_t tempIndex = source.indexOf(currArg, startingAt);
+ if (tempIndex >= 0) {
+ currMatchIndex = tempIndex;
+ } else {
+ // If lenient parsing is turned ON, we've got some time consuming parsing ahead of us.
+ int32_t length = -1;
+ currMatchIndex = rbnfLenientScanner->findTextLenient(source, currArg, startingAt, &length);
+ }
}
else {
currMatchIndex = source.indexOf(currArg, startingAt);
diff --git a/deps/icu-small/source/i18n/plurrule.cpp b/deps/icu-small/source/i18n/plurrule.cpp
index 54e3b2cd86..884db7c4f5 100644
--- a/deps/icu-small/source/i18n/plurrule.cpp
+++ b/deps/icu-small/source/i18n/plurrule.cpp
@@ -19,6 +19,7 @@
#include "unicode/ures.h"
#include "unicode/numfmt.h"
#include "unicode/decimfmt.h"
+#include "unicode/numberrangeformatter.h"
#include "charstr.h"
#include "cmemory.h"
#include "cstring.h"
@@ -36,6 +37,8 @@
#include "unifiedcache.h"
#include "number_decimalquantity.h"
#include "util.h"
+#include "pluralranges.h"
+#include "numrange_impl.h"
#if !UCONFIG_NO_FORMATTING
@@ -56,6 +59,7 @@ static const UChar PK_VAR_N[]={LOW_N,0};
static const UChar PK_VAR_I[]={LOW_I,0};
static const UChar PK_VAR_F[]={LOW_F,0};
static const UChar PK_VAR_T[]={LOW_T,0};
+static const UChar PK_VAR_E[]={LOW_E,0};
static const UChar PK_VAR_V[]={LOW_V,0};
static const UChar PK_WITHIN[]={LOW_W,LOW_I,LOW_T,LOW_H,LOW_I,LOW_N,0};
static const UChar PK_DECIMAL[]={LOW_D,LOW_E,LOW_C,LOW_I,LOW_M,LOW_A,LOW_L,0};
@@ -67,6 +71,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(PluralKeywordEnumeration)
PluralRules::PluralRules(UErrorCode& /*status*/)
: UObject(),
mRules(nullptr),
+ mStandardPluralRanges(nullptr),
mInternalStatus(U_ZERO_ERROR)
{
}
@@ -74,6 +79,7 @@ PluralRules::PluralRules(UErrorCode& /*status*/)
PluralRules::PluralRules(const PluralRules& other)
: UObject(other),
mRules(nullptr),
+ mStandardPluralRanges(nullptr),
mInternalStatus(U_ZERO_ERROR)
{
*this=other;
@@ -81,6 +87,7 @@ PluralRules::PluralRules(const PluralRules& other)
PluralRules::~PluralRules() {
delete mRules;
+ delete mStandardPluralRanges;
}
SharedPluralRules::~SharedPluralRules() {
@@ -89,14 +96,20 @@ SharedPluralRules::~SharedPluralRules() {
PluralRules*
PluralRules::clone() const {
- PluralRules* newObj = new PluralRules(*this);
// Since clone doesn't have a 'status' parameter, the best we can do is return nullptr if
// the newly created object was not fully constructed properly (an error occurred).
- if (newObj != nullptr && U_FAILURE(newObj->mInternalStatus)) {
- delete newObj;
- newObj = nullptr;
+ UErrorCode localStatus = U_ZERO_ERROR;
+ return clone(localStatus);
+}
+
+PluralRules*
+PluralRules::clone(UErrorCode& status) const {
+ LocalPointer<PluralRules> newObj(new PluralRules(*this), status);
+ if (U_SUCCESS(status) && U_FAILURE(newObj->mInternalStatus)) {
+ status = newObj->mInternalStatus;
+ newObj.adoptInstead(nullptr);
}
- return newObj;
+ return newObj.orphan();
}
PluralRules&
@@ -104,6 +117,8 @@ PluralRules::operator=(const PluralRules& other) {
if (this != &other) {
delete mRules;
mRules = nullptr;
+ delete mStandardPluralRanges;
+ mStandardPluralRanges = nullptr;
mInternalStatus = other.mInternalStatus;
if (U_FAILURE(mInternalStatus)) {
// bail out early if the object we were copying from was already 'invalid'.
@@ -119,6 +134,11 @@ PluralRules::operator=(const PluralRules& other) {
mInternalStatus = mRules->fInternalStatus;
}
}
+ if (other.mStandardPluralRanges != nullptr) {
+ mStandardPluralRanges = other.mStandardPluralRanges->copy(mInternalStatus)
+ .toPointer(mInternalStatus)
+ .orphan();
+ }
}
return *this;
}
@@ -211,11 +231,8 @@ PluralRules::forLocale(const Locale& locale, UPluralType type, UErrorCode& statu
if (U_FAILURE(status)) {
return nullptr;
}
- PluralRules *result = (*shared)->clone();
+ PluralRules *result = (*shared)->clone(status);
shared->removeRef();
- if (result == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- }
return result;
}
@@ -252,6 +269,10 @@ PluralRules::internalForLocale(const Locale& locale, UPluralType type, UErrorCod
// Original impl used default rules.
// Ask the question to ICU Core.
+ newObj->mStandardPluralRanges = StandardPluralRanges::forLocale(locale, status)
+ .toPointer(status)
+ .orphan();
+
return newObj.orphan();
}
@@ -272,6 +293,10 @@ PluralRules::select(const number::FormattedNumber& number, UErrorCode& status) c
if (U_FAILURE(status)) {
return ICU_Utility::makeBogusString();
}
+ if (U_FAILURE(mInternalStatus)) {
+ status = mInternalStatus;
+ return ICU_Utility::makeBogusString();
+ }
return select(dq);
}
@@ -285,6 +310,33 @@ PluralRules::select(const IFixedDecimal &number) const {
}
}
+UnicodeString
+PluralRules::select(const number::FormattedNumberRange& range, UErrorCode& status) const {
+ return select(range.getData(status), status);
+}
+
+UnicodeString
+PluralRules::select(const number::impl::UFormattedNumberRangeData* impl, UErrorCode& status) const {
+ if (U_FAILURE(status)) {
+ return ICU_Utility::makeBogusString();
+ }
+ if (U_FAILURE(mInternalStatus)) {
+ status = mInternalStatus;
+ return ICU_Utility::makeBogusString();
+ }
+ if (mStandardPluralRanges == nullptr) {
+ // Happens if PluralRules was constructed via createRules()
+ status = U_UNSUPPORTED_ERROR;
+ return ICU_Utility::makeBogusString();
+ }
+ auto form1 = StandardPlural::fromString(select(impl->quantity1), status);
+ auto form2 = StandardPlural::fromString(select(impl->quantity2), status);
+ if (U_FAILURE(status)) {
+ return ICU_Utility::makeBogusString();
+ }
+ auto result = mStandardPluralRanges->resolve(form1, form2);
+ return UnicodeString(StandardPlural::getKeyword(result), -1, US_INV);
+}
StringEnumeration*
@@ -326,9 +378,23 @@ static double scaleForInt(double d) {
return scale;
}
+/**
+ * Helper method for the overrides of getSamples() for double and FixedDecimal
+ * return value types. Provide only one of an allocated array of doubles or
+ * FixedDecimals, and a nullptr for the other.
+ */
static int32_t
-getSamplesFromString(const UnicodeString &samples, double *dest,
- int32_t destCapacity, UErrorCode& status) {
+getSamplesFromString(const UnicodeString &samples, double *destDbl,
+ FixedDecimal* destFd, int32_t destCapacity,
+ UErrorCode& status) {
+
+ if ((destDbl == nullptr && destFd == nullptr)
+ || (destDbl != nullptr && destFd != nullptr)) {
+ status = U_INTERNAL_PROGRAM_ERROR;
+ return 0;
+ }
+
+ bool isDouble = destDbl != nullptr;
int32_t sampleCount = 0;
int32_t sampleStartIdx = 0;
int32_t sampleEndIdx = 0;
@@ -346,9 +412,13 @@ getSamplesFromString(const UnicodeString &samples, double *dest,
int32_t tildeIndex = sampleRange.indexOf(TILDE);
if (tildeIndex < 0) {
FixedDecimal fixed(sampleRange, status);
- double sampleValue = fixed.source;
- if (fixed.visibleDecimalDigitCount == 0 || sampleValue != floor(sampleValue)) {
- dest[sampleCount++] = sampleValue;
+ if (isDouble) {
+ double sampleValue = fixed.source;
+ if (fixed.visibleDecimalDigitCount == 0 || sampleValue != floor(sampleValue)) {
+ destDbl[sampleCount++] = sampleValue;
+ }
+ } else {
+ destFd[sampleCount++] = fixed;
}
} else {
@@ -375,14 +445,21 @@ getSamplesFromString(const UnicodeString &samples, double *dest,
rangeLo *= scale;
rangeHi *= scale;
for (double n=rangeLo; n<=rangeHi; n+=1) {
- // Hack Alert: don't return any decimal samples with integer values that
- // originated from a format with trailing decimals.
- // This API is returning doubles, which can't distinguish having displayed
- // zeros to the right of the decimal.
- // This results in test failures with values mapping back to a different keyword.
double sampleValue = n/scale;
- if (!(sampleValue == floor(sampleValue) && fixedLo.visibleDecimalDigitCount > 0)) {
- dest[sampleCount++] = sampleValue;
+ if (isDouble) {
+ // Hack Alert: don't return any decimal samples with integer values that
+ // originated from a format with trailing decimals.
+ // This API is returning doubles, which can't distinguish having displayed
+ // zeros to the right of the decimal.
+ // This results in test failures with values mapping back to a different keyword.
+ if (!(sampleValue == floor(sampleValue) && fixedLo.visibleDecimalDigitCount > 0)) {
+ destDbl[sampleCount++] = sampleValue;
+ }
+ } else {
+ int32_t v = (int32_t) fixedLo.getPluralOperand(PluralOperand::PLURAL_OPERAND_V);
+ int32_t e = (int32_t) fixedLo.getPluralOperand(PluralOperand::PLURAL_OPERAND_E);
+ FixedDecimal newSample = FixedDecimal::createWithExponent(sampleValue, v, e);
+ destFd[sampleCount++] = newSample;
}
if (sampleCount >= destCapacity) {
break;
@@ -394,24 +471,52 @@ getSamplesFromString(const UnicodeString &samples, double *dest,
return sampleCount;
}
-
int32_t
PluralRules::getSamples(const UnicodeString &keyword, double *dest,
int32_t destCapacity, UErrorCode& status) {
- if (destCapacity == 0 || U_FAILURE(status)) {
+ if (U_FAILURE(status)) {
return 0;
}
if (U_FAILURE(mInternalStatus)) {
status = mInternalStatus;
return 0;
}
+ if (dest != nullptr ? destCapacity < 0 : destCapacity != 0) {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return 0;
+ }
RuleChain *rc = rulesForKeyword(keyword);
if (rc == nullptr) {
return 0;
}
- int32_t numSamples = getSamplesFromString(rc->fIntegerSamples, dest, destCapacity, status);
+ int32_t numSamples = getSamplesFromString(rc->fIntegerSamples, dest, nullptr, destCapacity, status);
if (numSamples == 0) {
- numSamples = getSamplesFromString(rc->fDecimalSamples, dest, destCapacity, status);
+ numSamples = getSamplesFromString(rc->fDecimalSamples, dest, nullptr, destCapacity, status);
+ }
+ return numSamples;
+}
+
+int32_t
+PluralRules::getSamples(const UnicodeString &keyword, FixedDecimal *dest,
+ int32_t destCapacity, UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return 0;
+ }
+ if (U_FAILURE(mInternalStatus)) {
+ status = mInternalStatus;
+ return 0;
+ }
+ if (dest != nullptr ? destCapacity < 0 : destCapacity != 0) {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return 0;
+ }
+ RuleChain *rc = rulesForKeyword(keyword);
+ if (rc == nullptr) {
+ return 0;
+ }
+ int32_t numSamples = getSamplesFromString(rc->fIntegerSamples, nullptr, dest, destCapacity, status);
+ if (numSamples == 0) {
+ numSamples = getSamplesFromString(rc->fDecimalSamples, nullptr, dest, destCapacity, status);
}
return numSamples;
}
@@ -600,6 +705,7 @@ PluralRuleParser::parse(const UnicodeString& ruleData, PluralRules *prules, UErr
case tVariableI:
case tVariableF:
case tVariableT:
+ case tVariableE:
case tVariableV:
U_ASSERT(curAndConstraint != nullptr);
curAndConstraint->digitsType = type;
@@ -984,6 +1090,8 @@ static UnicodeString tokenString(tokenType tok) {
s.append(LOW_V); break;
case tVariableT:
s.append(LOW_T); break;
+ case tVariableE:
+ s.append(LOW_E); break;
default:
s.append(TILDE);
}
@@ -1160,6 +1268,7 @@ PluralRuleParser::checkSyntax(UErrorCode &status)
case tVariableI:
case tVariableF:
case tVariableT:
+ case tVariableE:
case tVariableV:
if (type != tIs && type != tMod && type != tIn &&
type != tNot && type != tWithin && type != tEqual && type != tNotEqual) {
@@ -1176,6 +1285,7 @@ PluralRuleParser::checkSyntax(UErrorCode &status)
type == tVariableI ||
type == tVariableF ||
type == tVariableT ||
+ type == tVariableE ||
type == tVariableV ||
type == tAt)) {
status = U_UNEXPECTED_TOKEN;
@@ -1207,6 +1317,7 @@ PluralRuleParser::checkSyntax(UErrorCode &status)
type != tVariableI &&
type != tVariableF &&
type != tVariableT &&
+ type != tVariableE &&
type != tVariableV) {
status = U_UNEXPECTED_TOKEN;
}
@@ -1384,6 +1495,8 @@ PluralRuleParser::getKeyType(const UnicodeString &token, tokenType keyType)
keyType = tVariableF;
} else if (0 == token.compare(PK_VAR_T, 1)) {
keyType = tVariableT;
+ } else if (0 == token.compare(PK_VAR_E, 1)) {
+ keyType = tVariableE;
} else if (0 == token.compare(PK_VAR_V, 1)) {
keyType = tVariableV;
} else if (0 == token.compare(PK_IS, 2)) {
@@ -1481,13 +1594,15 @@ PluralOperand tokenTypeToPluralOperand(tokenType tt) {
return PLURAL_OPERAND_V;
case tVariableT:
return PLURAL_OPERAND_T;
+ case tVariableE:
+ return PLURAL_OPERAND_E;
default:
UPRV_UNREACHABLE; // unexpected.
}
}
-FixedDecimal::FixedDecimal(double n, int32_t v, int64_t f) {
- init(n, v, f);
+FixedDecimal::FixedDecimal(double n, int32_t v, int64_t f, int32_t e) {
+ init(n, v, f, e);
// check values. TODO make into unit test.
//
// long visiblePower = (int) Math.pow(10, v);
@@ -1503,6 +1618,10 @@ FixedDecimal::FixedDecimal(double n, int32_t v, int64_t f) {
// }
}
+FixedDecimal::FixedDecimal(double n, int32_t v, int64_t f) {
+ init(n, v, f);
+}
+
FixedDecimal::FixedDecimal(double n, int32_t v) {
// Ugly, but for samples we don't care.
init(n, v, getFractionalDigits(n, v));
@@ -1522,20 +1641,36 @@ FixedDecimal::FixedDecimal() {
FixedDecimal::FixedDecimal(const UnicodeString &num, UErrorCode &status) {
CharString cs;
- cs.appendInvariantChars(num, status);
+ int32_t parsedExponent = 0;
+
+ int32_t exponentIdx = num.indexOf(u'e');
+ if (exponentIdx < 0) {
+ exponentIdx = num.indexOf(u'E');
+ }
+ if (exponentIdx >= 0) {
+ cs.appendInvariantChars(num.tempSubString(0, exponentIdx), status);
+ int32_t expSubstrStart = exponentIdx + 1;
+ parsedExponent = ICU_Utility::parseAsciiInteger(num, expSubstrStart);
+ }
+ else {
+ cs.appendInvariantChars(num, status);
+ }
+
DecimalQuantity dl;
dl.setToDecNumber(cs.toStringPiece(), status);
if (U_FAILURE(status)) {
init(0, 0, 0);
return;
}
+
int32_t decimalPoint = num.indexOf(DOT);
double n = dl.toDouble();
if (decimalPoint == -1) {
- init(n, 0, 0);
+ init(n, 0, 0, parsedExponent);
} else {
- int32_t v = num.length() - decimalPoint - 1;
- init(n, v, getFractionalDigits(n, v));
+ int32_t fractionNumLength = exponentIdx < 0 ? num.length() : cs.length();
+ int32_t v = fractionNumLength - decimalPoint - 1;
+ init(n, v, getFractionalDigits(n, v), parsedExponent);
}
}
@@ -1546,6 +1681,7 @@ FixedDecimal::FixedDecimal(const FixedDecimal &other) {
decimalDigits = other.decimalDigits;
decimalDigitsWithoutTrailingZeros = other.decimalDigitsWithoutTrailingZeros;
intValue = other.intValue;
+ exponent = other.exponent;
_hasIntegerValue = other._hasIntegerValue;
isNegative = other.isNegative;
_isNaN = other._isNaN;
@@ -1554,6 +1690,10 @@ FixedDecimal::FixedDecimal(const FixedDecimal &other) {
FixedDecimal::~FixedDecimal() = default;
+FixedDecimal FixedDecimal::createWithExponent(double n, int32_t v, int32_t e) {
+ return FixedDecimal(n, v, getFractionalDigits(n, v), e);
+}
+
void FixedDecimal::init(double n) {
int32_t numFractionDigits = decimals(n);
@@ -1562,10 +1702,17 @@ void FixedDecimal::init(double n) {
void FixedDecimal::init(double n, int32_t v, int64_t f) {
+ int32_t exponent = 0;
+ init(n, v, f, exponent);
+}
+
+
+void FixedDecimal::init(double n, int32_t v, int64_t f, int32_t e) {
isNegative = n < 0.0;
source = fabs(n);
_isNaN = uprv_isNaN(source);
_isInfinite = uprv_isInfinite(source);
+ exponent = e;
if (_isNaN || _isInfinite) {
v = 0;
f = 0;
@@ -1661,7 +1808,9 @@ int64_t FixedDecimal::getFractionalDigits(double n, int32_t v) {
case 3: return (int64_t)(fract*1000.0 + 0.5);
default:
double scaled = floor(fract * pow(10.0, (double)v) + 0.5);
- if (scaled > U_INT64_MAX) {
+ if (scaled >= static_cast<double>(U_INT64_MAX)) {
+ // Note: a double cannot accurately represent U_INT64_MAX. Casting it to double
+ // will round up to the next representable value, which is U_INT64_MAX + 1.
return U_INT64_MAX;
} else {
return (int64_t)scaled;
@@ -1693,7 +1842,7 @@ double FixedDecimal::getPluralOperand(PluralOperand operand) const {
case PLURAL_OPERAND_F: return static_cast<double>(decimalDigits);
case PLURAL_OPERAND_T: return static_cast<double>(decimalDigitsWithoutTrailingZeros);
case PLURAL_OPERAND_V: return visibleDecimalDigitCount;
- case PLURAL_OPERAND_E: return 0;
+ case PLURAL_OPERAND_E: return exponent;
default:
UPRV_UNREACHABLE; // unexpected.
}
@@ -1719,6 +1868,23 @@ int32_t FixedDecimal::getVisibleFractionDigitCount() const {
return visibleDecimalDigitCount;
}
+bool FixedDecimal::operator==(const FixedDecimal &other) const {
+ return source == other.source && visibleDecimalDigitCount == other.visibleDecimalDigitCount
+ && decimalDigits == other.decimalDigits && exponent == other.exponent;
+}
+
+UnicodeString FixedDecimal::toString() const {
+ char pattern[15];
+ char buffer[20];
+ if (exponent == 0) {
+ snprintf(pattern, sizeof(pattern), "%%.%df", visibleDecimalDigitCount);
+ snprintf(buffer, sizeof(buffer), pattern, source);
+ } else {
+ snprintf(pattern, sizeof(pattern), "%%.%dfe%%d", visibleDecimalDigitCount);
+ snprintf(buffer, sizeof(buffer), pattern, source, exponent);
+ }
+ return UnicodeString(buffer, -1, US_INV);
+}
PluralAvailableLocalesEnumeration::PluralAvailableLocalesEnumeration(UErrorCode &status) {
diff --git a/deps/icu-small/source/i18n/plurrule_impl.h b/deps/icu-small/source/i18n/plurrule_impl.h
index a18cb0847a..8849e67e57 100644
--- a/deps/icu-small/source/i18n/plurrule_impl.h
+++ b/deps/icu-small/source/i18n/plurrule_impl.h
@@ -30,6 +30,12 @@
#include "hash.h"
#include "uassert.h"
+/**
+ * A FixedDecimal version of UPLRULES_NO_UNIQUE_VALUE used in PluralRulesTest
+ * for parsing of samples.
+ */
+#define UPLRULES_NO_UNIQUE_VALUE_DECIMAL (FixedDecimal((double)-0.00123456777))
+
class PluralRulesTest;
U_NAMESPACE_BEGIN
@@ -138,6 +144,7 @@ enum tokenType {
tVariableF,
tVariableV,
tVariableT,
+ tVariableE,
tDecimal,
tInteger,
tEOF
@@ -273,7 +280,9 @@ class U_I18N_API FixedDecimal: public IFixedDecimal, public UObject {
* @param n the number, e.g. 12.345
* @param v The number of visible fraction digits, e.g. 3
* @param f The fraction digits, e.g. 345
+ * @param e The exponent, e.g. 7 in 1.2e7 (for compact/scientific)
*/
+ FixedDecimal(double n, int32_t v, int64_t f, int32_t e);
FixedDecimal(double n, int32_t v, int64_t f);
FixedDecimal(double n, int32_t);
explicit FixedDecimal(double n);
@@ -282,6 +291,8 @@ class U_I18N_API FixedDecimal: public IFixedDecimal, public UObject {
FixedDecimal(const UnicodeString &s, UErrorCode &ec);
FixedDecimal(const FixedDecimal &other);
+ static FixedDecimal createWithExponent(double n, int32_t v, int32_t e);
+
double getPluralOperand(PluralOperand operand) const U_OVERRIDE;
bool isNaN() const U_OVERRIDE;
bool isInfinite() const U_OVERRIDE;
@@ -291,19 +302,25 @@ class U_I18N_API FixedDecimal: public IFixedDecimal, public UObject {
int32_t getVisibleFractionDigitCount() const;
+ void init(double n, int32_t v, int64_t f, int32_t e);
void init(double n, int32_t v, int64_t f);
void init(double n);
UBool quickInit(double n); // Try a fast-path only initialization,
- // return TRUE if successful.
+ // return true if successful.
void adjustForMinFractionDigits(int32_t min);
static int64_t getFractionalDigits(double n, int32_t v);
static int32_t decimals(double n);
+ bool operator==(const FixedDecimal &other) const;
+
+ UnicodeString toString() const;
+
double source;
int32_t visibleDecimalDigitCount;
int64_t decimalDigits;
int64_t decimalDigitsWithoutTrailingZeros;
int64_t intValue;
+ int32_t exponent;
UBool _hasIntegerValue;
UBool isNegative;
UBool _isNaN;
@@ -320,8 +337,8 @@ public:
int32_t opNum = -1; // for mod expressions, the right operand of the mod.
int32_t value = -1; // valid for 'is' rules only.
UVector32 *rangeList = nullptr; // for 'in', 'within' rules. Null otherwise.
- UBool negated = FALSE; // TRUE for negated rules.
- UBool integerOnly = FALSE; // TRUE for 'within' rules.
+ UBool negated = false; // true for negated rules.
+ UBool integerOnly = false; // true for 'within' rules.
tokenType digitsType = none; // n | i | v | f constraint.
AndConstraint *next = nullptr;
// Internal error status, used for errors that occur during the copy constructor.
@@ -357,8 +374,8 @@ public:
OrConstraint *ruleHeader = nullptr;
UnicodeString fDecimalSamples; // Samples strings from rule source
UnicodeString fIntegerSamples; // without @decimal or @integer, otherwise unprocessed.
- UBool fDecimalSamplesUnbounded = FALSE;
- UBool fIntegerSamplesUnbounded = FALSE;
+ UBool fDecimalSamplesUnbounded = false;
+ UBool fIntegerSamplesUnbounded = false;
// Internal error status, used for errors that occur during the copy constructor.
UErrorCode fInternalStatus = U_ZERO_ERROR;
diff --git a/deps/icu-small/source/i18n/quant.h b/deps/icu-small/source/i18n/quant.h
index d5aa8e5eee..df6924cc12 100644
--- a/deps/icu-small/source/i18n/quant.h
+++ b/deps/icu-small/source/i18n/quant.h
@@ -62,11 +62,11 @@ class Quantifier : public UnicodeFunctor, public UnicodeMatcher {
* considered for matching will be text.charAt(limit-1) in the
* forward direction or text.charAt(limit+1) in the backward
* direction.
- * @param incremental if TRUE, then assume further characters may
+ * @param incremental if true, then assume further characters may
* be inserted at limit and check for partial matching. Otherwise
* assume the text as given is complete.
* @return a match degree value indicating a full match, a partial
- * match, or a mismatch. If incremental is FALSE then
+ * match, or a mismatch. If incremental is false then
* U_PARTIAL_MATCH should never be returned.
*/
virtual UMatchDegree matches(const Replaceable& text,
@@ -81,7 +81,7 @@ class Quantifier : public UnicodeFunctor, public UnicodeMatcher {
* @return A reference to 'result'.
*/
virtual UnicodeString& toPattern(UnicodeString& result,
- UBool escapeUnprintable = FALSE) const;
+ UBool escapeUnprintable = false) const;
/**
* Implement UnicodeMatcher
diff --git a/deps/icu-small/source/i18n/quantityformatter.h b/deps/icu-small/source/i18n/quantityformatter.h
index 88c3f3844e..30bef08634 100644
--- a/deps/icu-small/source/i18n/quantityformatter.h
+++ b/deps/icu-small/source/i18n/quantityformatter.h
@@ -74,18 +74,18 @@ public:
* @param variant "zero", "one", "two", "few", "many", "other"
* @param rawPattern the pattern for the variant e.g "{0} meters"
* @param status any error returned here.
- * @return TRUE on success; FALSE if status was set to a non zero error.
+ * @return true on success; false if status was set to a non zero error.
*/
UBool addIfAbsent(const char *variant, const UnicodeString &rawPattern, UErrorCode &status);
/**
- * returns TRUE if this object has at least the "other" variant.
+ * returns true if this object has at least the "other" variant.
*/
UBool isValid() const;
/**
* Gets the pattern formatter that would be used for a particular variant.
- * If isValid() returns TRUE, this method is guaranteed to return a
+ * If isValid() returns true, this method is guaranteed to return a
* non-NULL value.
*/
const SimpleFormatter *getByVariant(const char *variant) const;
@@ -112,7 +112,7 @@ public:
/**
* Selects the standard plural form for the number/formatter/rules.
- * TODO(13591): Remove this method.
+ * Used in MeasureFormat for backwards compatibility with NumberFormat.
*/
static StandardPlural::Form selectPlural(
const Formattable &number,
diff --git a/deps/icu-small/source/i18n/rbt.h b/deps/icu-small/source/i18n/rbt.h
index b450dc23f4..6c34824181 100644
--- a/deps/icu-small/source/i18n/rbt.h
+++ b/deps/icu-small/source/i18n/rbt.h
@@ -161,7 +161,7 @@ public:
* to construct a new transliterator.
* @param result the string to receive the rules. Previous
* contents will be deleted.
- * @param escapeUnprintable if TRUE then convert unprintable
+ * @param escapeUnprintable if true then convert unprintable
* character to their hex escape representations, \uxxxx or
* \Uxxxxxxxx. Unprintable characters are those other than
* U+000A, U+0020..U+007E.
diff --git a/deps/icu-small/source/i18n/rbt_pars.cpp b/deps/icu-small/source/i18n/rbt_pars.cpp
index 3eb58a2a90..802d65d0ac 100644
--- a/deps/icu-small/source/i18n/rbt_pars.cpp
+++ b/deps/icu-small/source/i18n/rbt_pars.cpp
@@ -1557,7 +1557,7 @@ UChar TransliteratorParser::getSegmentStandin(int32_t seg, UErrorCode& status) {
return 0;
}
c = variableNext++;
- // Set a placeholder in the master variables vector that will be
+ // Set a placeholder in the primary variables vector that will be
// filled in later by setSegmentObject(). We know that we will get
// called first because setSegmentObject() will call us.
variablesVector.addElement((void*) NULL, status);
diff --git a/deps/icu-small/source/i18n/rbt_pars.h b/deps/icu-small/source/i18n/rbt_pars.h
index d51f2e852b..3e6517cfeb 100644
--- a/deps/icu-small/source/i18n/rbt_pars.h
+++ b/deps/icu-small/source/i18n/rbt_pars.h
@@ -210,7 +210,7 @@ private:
/**
* Assert that the given character is NOT within the variable range.
- * If it is, return FALSE. This is neccesary to ensure that the
+ * If it is, return false. This is neccesary to ensure that the
* variable range does not overlap characters used in a rule.
* @param ch the given character.
* @return True, if the given character is NOT within the variable range.
diff --git a/deps/icu-small/source/i18n/rbt_rule.h b/deps/icu-small/source/i18n/rbt_rule.h
index eb8556df0c..76feeee391 100644
--- a/deps/icu-small/source/i18n/rbt_rule.h
+++ b/deps/icu-small/source/i18n/rbt_rule.h
@@ -172,9 +172,9 @@ public:
* segments, or null if there are none. The array itself is adopted,
* but the pointers within it are not.
* @param segsCount number of elements in segs[].
- * @param anchorStart TRUE if the the rule is anchored on the left to
+ * @param anchorStart true if the the rule is anchored on the left to
* the context start.
- * @param anchorEnd TRUE if the rule is anchored on the right to the
+ * @param anchorEnd true if the rule is anchored on the right to the
* context limit.
* @param data the rule data.
* @param status Output parameter filled in with success or failure status.
@@ -267,11 +267,11 @@ public:
*
* @param text the text
* @param pos the position indices
- * @param incremental if TRUE, test for partial matches that may
+ * @param incremental if true, test for partial matches that may
* be completed by additional text inserted at pos.limit.
* @return one of <code>U_MISMATCH</code>,
* <code>U_PARTIAL_MATCH</code>, or <code>U_MATCH</code>. If
- * incremental is FALSE then U_PARTIAL_MATCH will not be returned.
+ * incremental is false then U_PARTIAL_MATCH will not be returned.
*/
UMatchDegree matchAndReplace(Replaceable& text,
UTransPosition& pos,
diff --git a/deps/icu-small/source/i18n/rbt_set.h b/deps/icu-small/source/i18n/rbt_set.h
index 9b2b8b38db..b1163a0193 100644
--- a/deps/icu-small/source/i18n/rbt_set.h
+++ b/deps/icu-small/source/i18n/rbt_set.h
@@ -123,14 +123,14 @@ public:
/**
* Transliterate the given text with the given UTransPosition
- * indices. Return TRUE if the transliteration should continue
- * or FALSE if it should halt (because of a U_PARTIAL_MATCH match).
- * Note that FALSE is only ever returned if isIncremental is TRUE.
+ * indices. Return true if the transliteration should continue
+ * or false if it should halt (because of a U_PARTIAL_MATCH match).
+ * Note that false is only ever returned if isIncremental is true.
* @param text the text to be transliterated
* @param index the position indices, which will be updated
- * @param isIncremental if TRUE, assume new text may be inserted
- * at index.limit, and return FALSE if thre is a partial match.
- * @return TRUE unless a U_PARTIAL_MATCH has been obtained,
+ * @param isIncremental if true, assume new text may be inserted
+ * at index.limit, and return false if thre is a partial match.
+ * @return true unless a U_PARTIAL_MATCH has been obtained,
* indicating that transliteration should stop until more text
* arrives.
*/
diff --git a/deps/icu-small/source/i18n/regexcmp.h b/deps/icu-small/source/i18n/regexcmp.h
index 85b7586793..5804ff3026 100644
--- a/deps/icu-small/source/i18n/regexcmp.h
+++ b/deps/icu-small/source/i18n/regexcmp.h
@@ -104,7 +104,7 @@ private:
int32_t LoopOp);
UBool compileInlineInterval(); // Generate inline code for a {min,max} quantifier
void literalChar(UChar32 c); // Compile a literal char
- void fixLiterals(UBool split=FALSE); // Generate code for pending literal characters.
+ void fixLiterals(UBool split=false); // Generate code for pending literal characters.
void insertOp(int32_t where); // Open up a slot for a new op in the
// generated code at the specified location.
void appendOp(int32_t op); // Append a new op to the compiled pattern.
diff --git a/deps/icu-small/source/i18n/regextxt.h b/deps/icu-small/source/i18n/regextxt.h
index 9cfabbe415..0f64b8437e 100644
--- a/deps/icu-small/source/i18n/regextxt.h
+++ b/deps/icu-small/source/i18n/regextxt.h
@@ -29,7 +29,7 @@ U_NAMESPACE_BEGIN
#endif
#ifdef REGEX_DISABLE_CHUNK_MODE
-# define UTEXT_FULL_TEXT_IN_CHUNK(ut,len) (FALSE)
+# define UTEXT_FULL_TEXT_IN_CHUNK(ut,len) (false)
#else
# define UTEXT_FULL_TEXT_IN_CHUNK(ut,len) ((0==((ut)->chunkNativeStart))&&((len)==((ut)->chunkNativeLimit))&&((len)==((ut)->nativeIndexingLimit)))
#endif
diff --git a/deps/icu-small/source/i18n/region.cpp b/deps/icu-small/source/i18n/region.cpp
index 198bea8f64..8364bd1c1b 100644
--- a/deps/icu-small/source/i18n/region.cpp
+++ b/deps/icu-small/source/i18n/region.cpp
@@ -217,7 +217,7 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) {
if ( aliasToRegion != NULL && aliasFromRegion == NULL ) { // This is just an alias from some string to a region
uhash_put(newRegionAliases.getAlias(),(void *)aliasFromStr.orphan(), (void *)aliasToRegion,&status);
} else {
- if ( aliasFromRegion == NULL ) { // Deprecated region code not in the master codes list - so need to create a deprecated region for it.
+ if ( aliasFromRegion == NULL ) { // Deprecated region code not in the primary codes list - so need to create a deprecated region for it.
LocalPointer<Region> newRgn(new Region, status);
if ( U_SUCCESS(status) ) {
aliasFromRegion = newRgn.orphan();
diff --git a/deps/icu-small/source/i18n/reldatefmt.cpp b/deps/icu-small/source/i18n/reldatefmt.cpp
index f10c5ba488..5d43606169 100644
--- a/deps/icu-small/source/i18n/reldatefmt.cpp
+++ b/deps/icu-small/source/i18n/reldatefmt.cpp
@@ -1326,7 +1326,7 @@ ureldatefmt_formatNumeric( const URelativeDateTimeFormatter* reldatefmt,
return res.extract(result, resultCapacity, *status);
}
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ureldatefmt_formatNumericToResult(
const URelativeDateTimeFormatter* reldatefmt,
double offset,
@@ -1369,7 +1369,7 @@ ureldatefmt_format( const URelativeDateTimeFormatter* reldatefmt,
return res.extract(result, resultCapacity, *status);
}
-U_DRAFT void U_EXPORT2
+U_CAPI void U_EXPORT2
ureldatefmt_formatToResult(
const URelativeDateTimeFormatter* reldatefmt,
double offset,
diff --git a/deps/icu-small/source/i18n/rematch.cpp b/deps/icu-small/source/i18n/rematch.cpp
index 123aa8602b..653ef4d6c1 100644
--- a/deps/icu-small/source/i18n/rematch.cpp
+++ b/deps/icu-small/source/i18n/rematch.cpp
@@ -2072,7 +2072,7 @@ int32_t RegexMatcher::split(UText *input,
UErrorCode &status)
{
//
- // Check arguements for validity
+ // Check arguments for validity
//
if (U_FAILURE(status)) {
return 0;
diff --git a/deps/icu-small/source/i18n/rulebasedcollator.cpp b/deps/icu-small/source/i18n/rulebasedcollator.cpp
index 60acf17815..917482d65b 100644
--- a/deps/icu-small/source/i18n/rulebasedcollator.cpp
+++ b/deps/icu-small/source/i18n/rulebasedcollator.cpp
@@ -1600,10 +1600,7 @@ RuleBasedCollator::internalGetShortDefinitionString(const char *locale,
appendSubtag(result, 'Z', subtag, length, errorCode);
if(U_FAILURE(errorCode)) { return 0; }
- if(result.length() <= capacity) {
- uprv_memcpy(buffer, result.data(), result.length());
- }
- return u_terminateChars(buffer, capacity, result.length(), &errorCode);
+ return result.extract(buffer, capacity, errorCode);
}
UBool
diff --git a/deps/icu-small/source/i18n/smpdtfmt.cpp b/deps/icu-small/source/i18n/smpdtfmt.cpp
index d704642b05..4717899cf3 100644
--- a/deps/icu-small/source/i18n/smpdtfmt.cpp
+++ b/deps/icu-small/source/i18n/smpdtfmt.cpp
@@ -54,6 +54,7 @@
#include "unicode/udisplaycontext.h"
#include "unicode/brkiter.h"
#include "unicode/rbnf.h"
+#include "unicode/dtptngen.h"
#include "uresimp.h"
#include "olsontz.h"
#include "patternprops.h"
@@ -650,6 +651,12 @@ SimpleDateFormat::operator==(const Format& other) const
}
//----------------------------------------------------------------------
+static const UChar* timeSkeletons[4] = {
+ u"jmmsszzzz", // kFull
+ u"jmmssz", // kLong
+ u"jmmss", // kMedium
+ u"jmm", // kShort
+};
void SimpleDateFormat::construct(EStyle timeStyle,
EStyle dateStyle,
@@ -714,35 +721,75 @@ void SimpleDateFormat::construct(EStyle timeStyle,
fDateOverride.setToBogus();
fTimeOverride.setToBogus();
+ UnicodeString timePattern;
+ if (timeStyle >= kFull && timeStyle <= kShort) {
+ const char* baseLocID = locale.getBaseName();
+ if (baseLocID[0]!=0 && uprv_strcmp(baseLocID,"und")!=0) {
+ UErrorCode useStatus = U_ZERO_ERROR;
+ Locale baseLoc(baseLocID);
+ Locale validLoc(getLocale(ULOC_VALID_LOCALE, useStatus));
+ if (U_SUCCESS(useStatus) && validLoc!=baseLoc) {
+ bool useDTPG = false;
+ const char* baseReg = baseLoc.getCountry(); // empty string if no region
+ if ((baseReg[0]!=0 && uprv_strncmp(baseReg,validLoc.getCountry(),ULOC_COUNTRY_CAPACITY)!=0)
+ || uprv_strncmp(baseLoc.getLanguage(),validLoc.getLanguage(),ULOC_LANG_CAPACITY)!=0) {
+ // use DTPG if
+ // * baseLoc has a region and validLoc does not have the same one (or has none), OR
+ // * validLoc has a different language code than baseLoc
+ useDTPG = true;
+ }
+ if (useDTPG) {
+ // The standard time formats may have the wrong time cycle, because:
+ // the valid locale differs in important ways (region, language) from
+ // the base locale.
+ // We could *also* check whether they do actually have a mismatch with
+ // the time cycle preferences for the region, but that is a lot more
+ // work for little or no additional benefit, since just going ahead
+ // and always synthesizing the time format as per the following should
+ // create a locale-appropriate pattern with cycle that matches the
+ // region preferences anyway.
+ LocalPointer<DateTimePatternGenerator> dtpg(DateTimePatternGenerator::createInstanceNoStdPat(locale, useStatus));
+ if (U_SUCCESS(useStatus)) {
+ UnicodeString timeSkeleton(TRUE, timeSkeletons[timeStyle], -1);
+ timePattern = dtpg->getBestPattern(timeSkeleton, useStatus);
+ }
+ }
+ }
+ }
+ }
+
// if the pattern should include both date and time information, use the date/time
// pattern string as a guide to tell use how to glue together the appropriate date
// and time pattern strings.
if ((timeStyle != kNone) && (dateStyle != kNone))
{
- currentBundle.adoptInstead(
- ures_getByIndex(dateTimePatterns.getAlias(), (int32_t)timeStyle, NULL, &status));
- if (U_FAILURE(status)) {
- status = U_INVALID_FORMAT_ERROR;
- return;
- }
- switch (ures_getType(currentBundle.getAlias())) {
- case URES_STRING: {
- resStr = ures_getString(currentBundle.getAlias(), &resStrLen, &status);
- break;
- }
- case URES_ARRAY: {
- resStr = ures_getStringByIndex(currentBundle.getAlias(), 0, &resStrLen, &status);
- ovrStr = ures_getStringByIndex(currentBundle.getAlias(), 1, &ovrStrLen, &status);
- fTimeOverride.setTo(TRUE, ovrStr, ovrStrLen);
- break;
- }
- default: {
+ UnicodeString tempus1(timePattern);
+ if (tempus1.length() == 0) {
+ currentBundle.adoptInstead(
+ ures_getByIndex(dateTimePatterns.getAlias(), (int32_t)timeStyle, NULL, &status));
+ if (U_FAILURE(status)) {
status = U_INVALID_FORMAT_ERROR;
return;
}
- }
+ switch (ures_getType(currentBundle.getAlias())) {
+ case URES_STRING: {
+ resStr = ures_getString(currentBundle.getAlias(), &resStrLen, &status);
+ break;
+ }
+ case URES_ARRAY: {
+ resStr = ures_getStringByIndex(currentBundle.getAlias(), 0, &resStrLen, &status);
+ ovrStr = ures_getStringByIndex(currentBundle.getAlias(), 1, &ovrStrLen, &status);
+ fTimeOverride.setTo(TRUE, ovrStr, ovrStrLen);
+ break;
+ }
+ default: {
+ status = U_INVALID_FORMAT_ERROR;
+ return;
+ }
+ }
- UnicodeString tempus1(TRUE, resStr, resStrLen);
+ tempus1.setTo(TRUE, resStr, resStrLen);
+ }
currentBundle.adoptInstead(
ures_getByIndex(dateTimePatterns.getAlias(), (int32_t)dateStyle, NULL, &status));
@@ -784,29 +831,32 @@ void SimpleDateFormat::construct(EStyle timeStyle,
// pattern string from the resources
// setTo() - see DateFormatSymbols::assignArray comments
else if (timeStyle != kNone) {
- currentBundle.adoptInstead(
- ures_getByIndex(dateTimePatterns.getAlias(), (int32_t)timeStyle, NULL, &status));
- if (U_FAILURE(status)) {
- status = U_INVALID_FORMAT_ERROR;
- return;
- }
- switch (ures_getType(currentBundle.getAlias())) {
- case URES_STRING: {
- resStr = ures_getString(currentBundle.getAlias(), &resStrLen, &status);
- break;
- }
- case URES_ARRAY: {
- resStr = ures_getStringByIndex(currentBundle.getAlias(), 0, &resStrLen, &status);
- ovrStr = ures_getStringByIndex(currentBundle.getAlias(), 1, &ovrStrLen, &status);
- fDateOverride.setTo(TRUE, ovrStr, ovrStrLen);
- break;
- }
- default: {
+ fPattern.setTo(timePattern);
+ if (fPattern.length() == 0) {
+ currentBundle.adoptInstead(
+ ures_getByIndex(dateTimePatterns.getAlias(), (int32_t)timeStyle, NULL, &status));
+ if (U_FAILURE(status)) {
status = U_INVALID_FORMAT_ERROR;
return;
}
+ switch (ures_getType(currentBundle.getAlias())) {
+ case URES_STRING: {
+ resStr = ures_getString(currentBundle.getAlias(), &resStrLen, &status);
+ break;
+ }
+ case URES_ARRAY: {
+ resStr = ures_getStringByIndex(currentBundle.getAlias(), 0, &resStrLen, &status);
+ ovrStr = ures_getStringByIndex(currentBundle.getAlias(), 1, &ovrStrLen, &status);
+ fDateOverride.setTo(TRUE, ovrStr, ovrStrLen);
+ break;
+ }
+ default: {
+ status = U_INVALID_FORMAT_ERROR;
+ return;
+ }
+ }
+ fPattern.setTo(TRUE, resStr, resStrLen);
}
- fPattern.setTo(TRUE, resStr, resStrLen);
}
else if (dateStyle != kNone) {
currentBundle.adoptInstead(
@@ -848,7 +898,8 @@ Calendar*
SimpleDateFormat::initializeCalendar(TimeZone* adoptZone, const Locale& locale, UErrorCode& status)
{
if(!U_FAILURE(status)) {
- fCalendar = Calendar::createInstance(adoptZone?adoptZone:TimeZone::createDefault(), locale, status);
+ fCalendar = Calendar::createInstance(
+ adoptZone ? adoptZone : TimeZone::forLocaleOrDefault(locale), locale, status);
}
return fCalendar;
}
diff --git a/deps/icu-small/source/i18n/strmatch.h b/deps/icu-small/source/i18n/strmatch.h
index 09d04ede13..84b1d47398 100644
--- a/deps/icu-small/source/i18n/strmatch.h
+++ b/deps/icu-small/source/i18n/strmatch.h
@@ -109,11 +109,11 @@ class StringMatcher : public UnicodeFunctor, public UnicodeMatcher, public Unico
* considered for matching will be text.charAt(limit-1) in the
* forward direction or text.charAt(limit+1) in the backward
* direction.
- * @param incremental if TRUE, then assume further characters may
+ * @param incremental if true, then assume further characters may
* be inserted at limit and check for partial matching. Otherwise
* assume the text as given is complete.
* @return a match degree value indicating a full match, a partial
- * match, or a mismatch. If incremental is FALSE then
+ * match, or a mismatch. If incremental is false then
* U_PARTIAL_MATCH should never be returned.
*/
virtual UMatchDegree matches(const Replaceable& text,
@@ -128,16 +128,16 @@ class StringMatcher : public UnicodeFunctor, public UnicodeMatcher, public Unico
* @return A reference to 'result'.
*/
virtual UnicodeString& toPattern(UnicodeString& result,
- UBool escapeUnprintable = FALSE) const;
+ UBool escapeUnprintable = false) const;
/**
* Implement UnicodeMatcher
- * Returns TRUE if this matcher will match a character c, where c
+ * Returns true if this matcher will match a character c, where c
* & 0xFF == v, at offset, in the forward direction (with limit >
* offset). This is used by <tt>RuleBasedTransliterator</tt> for
* indexing.
* @param v the given value
- * @return TRUE if this matcher will match a character c,
+ * @return true if this matcher will match a character c,
* where c & 0xFF == v
*/
virtual UBool matchesIndexValue(uint8_t v) const;
@@ -181,7 +181,7 @@ class StringMatcher : public UnicodeFunctor, public UnicodeMatcher, public Unico
* replacer that is equal to this one.
* @param result the string to receive the pattern. Previous
* contents will be deleted.
- * @param escapeUnprintable if TRUE then convert unprintable
+ * @param escapeUnprintable if true then convert unprintable
* character to their hex escape representations, \\uxxxx or
* \\Uxxxxxxxx. Unprintable characters are defined by
* Utility.isUnprintable().
diff --git a/deps/icu-small/source/i18n/taiwncal.h b/deps/icu-small/source/i18n/taiwncal.h
index daadc124f4..bf384fa714 100644
--- a/deps/icu-small/source/i18n/taiwncal.h
+++ b/deps/icu-small/source/i18n/taiwncal.h
@@ -156,7 +156,7 @@ private:
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
/**
- * Returns TRUE because the Taiwan Calendar does have a default century
+ * Returns true because the Taiwan Calendar does have a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/timezone.cpp b/deps/icu-small/source/i18n/timezone.cpp
index b90b78614a..1461b80494 100644
--- a/deps/icu-small/source/i18n/timezone.cpp
+++ b/deps/icu-small/source/i18n/timezone.cpp
@@ -579,6 +579,24 @@ TimeZone::createDefault()
// -------------------------------------
+TimeZone* U_EXPORT2
+TimeZone::forLocaleOrDefault(const Locale& locale)
+{
+ char buffer[ULOC_KEYWORDS_CAPACITY] = "";
+ UErrorCode localStatus = U_ZERO_ERROR;
+ int32_t count = locale.getKeywordValue("timezone", buffer, sizeof(buffer), localStatus);
+ if (U_FAILURE(localStatus) || localStatus == U_STRING_NOT_TERMINATED_WARNING) {
+ // the "timezone" keyword exceeds ULOC_KEYWORDS_CAPACITY; ignore and use default.
+ count = 0;
+ }
+ if (count > 0) {
+ return TimeZone::createTimeZone(UnicodeString(buffer, count, US_INV));
+ }
+ return TimeZone::createDefault();
+}
+
+// -------------------------------------
+
void U_EXPORT2
TimeZone::adoptDefault(TimeZone* zone)
{
diff --git a/deps/icu-small/source/i18n/transreg.h b/deps/icu-small/source/i18n/transreg.h
index 041244e1b0..04ed3fb501 100644
--- a/deps/icu-small/source/i18n/transreg.h
+++ b/deps/icu-small/source/i18n/transreg.h
@@ -69,7 +69,7 @@ class TransliteratorAlias : public UMemory {
* it when the registry mutex is NOT held, to prevent deadlock.
* It may only be called once.
*
- * Note: Only call create() if isRuleBased() returns FALSE.
+ * Note: Only call create() if isRuleBased() returns false.
*
* This method must be called *outside* of the TransliteratorRegistry
* mutex.
@@ -77,17 +77,17 @@ class TransliteratorAlias : public UMemory {
Transliterator* create(UParseError&, UErrorCode&);
/**
- * Return TRUE if this alias is rule-based. If so, the caller
+ * Return true if this alias is rule-based. If so, the caller
* must call parse() on it, then call TransliteratorRegistry::reget().
*/
UBool isRuleBased() const;
/**
- * If isRuleBased() returns TRUE, then the caller must call this
+ * If isRuleBased() returns true, then the caller must call this
* method, followed by TransliteratorRegistry::reget(). The latter
* method must be called inside the TransliteratorRegistry mutex.
*
- * Note: Only call parse() if isRuleBased() returns TRUE.
+ * Note: Only call parse() if isRuleBased() returns true.
*
* This method must be called *outside* of the TransliteratorRegistry
* mutex, because it can instantiate Transliterators embedded in
diff --git a/deps/icu-small/source/i18n/tridpars.h b/deps/icu-small/source/i18n/tridpars.h
index 3d657ed17c..cd56146023 100644
--- a/deps/icu-small/source/i18n/tridpars.h
+++ b/deps/icu-small/source/i18n/tridpars.h
@@ -222,7 +222,7 @@ class TransliteratorIDParser /* not : public UObject because all methods are sta
* @param source the given source.
* @param target the given target.
* @param variant the given variant
- * @param isSourcePresent If TRUE then the source is present.
+ * @param isSourcePresent If true then the source is present.
* If the source is not present, ANY will be
* given as the source, and isSourcePresent will be null
* @return an array of 4 strings: source, target, variant, and
diff --git a/deps/icu-small/source/i18n/tznames_impl.h b/deps/icu-small/source/i18n/tznames_impl.h
index 1286eeb80d..417c0511f8 100644
--- a/deps/icu-small/source/i18n/tznames_impl.h
+++ b/deps/icu-small/source/i18n/tznames_impl.h
@@ -92,9 +92,9 @@ struct CharacterNode {
UBool fHasValuesVector;
UBool fPadding;
- // No value: fValues == NULL and fHasValuesVector == FALSE
- // One value: fValues == value and fHasValuesVector == FALSE
- // >=2 values: fValues == UVector of values and fHasValuesVector == TRUE
+ // No value: fValues == NULL and fHasValuesVector == false
+ // One value: fValues == value and fHasValuesVector == false
+ // >=2 values: fValues == UVector of values and fHasValuesVector == true
};
inline UBool CharacterNode::hasValues() const {
diff --git a/deps/icu-small/source/i18n/ucal.cpp b/deps/icu-small/source/i18n/ucal.cpp
index 8ea7fbf4f5..275ef7ea87 100644
--- a/deps/icu-small/source/i18n/ucal.cpp
+++ b/deps/icu-small/source/i18n/ucal.cpp
@@ -91,7 +91,7 @@ ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec) {
}
}
-U_DRAFT int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_getHostTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec) {
int32_t len = 0;
if (ec != NULL && U_SUCCESS(*ec)) {
diff --git a/deps/icu-small/source/i18n/ucol_imp.h b/deps/icu-small/source/i18n/ucol_imp.h
index a251fc461d..f463957fd4 100644
--- a/deps/icu-small/source/i18n/ucol_imp.h
+++ b/deps/icu-small/source/i18n/ucol_imp.h
@@ -41,10 +41,10 @@
* rules must be equivalent.
* @param source first collator
* @param target second collator
- * @return TRUE or FALSE
+ * @return true or false
* @internal ICU 3.0
*/
-U_INTERNAL UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucol_equals(const UCollator *source, const UCollator *target);
/**
diff --git a/deps/icu-small/source/i18n/ucol_sit.cpp b/deps/icu-small/source/i18n/ucol_sit.cpp
index 9fa7cd5fd7..d6bbf97b31 100644
--- a/deps/icu-small/source/i18n/ucol_sit.cpp
+++ b/deps/icu-small/source/i18n/ucol_sit.cpp
@@ -372,10 +372,7 @@ int32_t ucol_sit_dumpSpecs(CollatorSpec *s, char *destination, int32_t capacity,
}
len += s->entries[i].length();
} else {
- len += s->entries[i].length();
- if(len < capacity) {
- uprv_strncat(destination,s->entries[i].data(), s->entries[i].length());
- }
+ len += s->entries[i].extract(destination + len, capacity - len, *status);
}
}
}
diff --git a/deps/icu-small/source/i18n/ucsdet.cpp b/deps/icu-small/source/i18n/ucsdet.cpp
index 46f69cf90c..63f204d0e1 100644
--- a/deps/icu-small/source/i18n/ucsdet.cpp
+++ b/deps/icu-small/source/i18n/ucsdet.cpp
@@ -193,7 +193,7 @@ ucsdet_getAllDetectableCharsets(const UCharsetDetector * /*ucsd*/, UErrorCode *s
return CharsetDetector::getAllDetectableCharsets(*status);
}
-U_DRAFT UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
ucsdet_getDetectableCharsets(const UCharsetDetector *ucsd, UErrorCode *status)
{
return ((CharsetDetector *)ucsd)->getDetectableCharsets(*status);
diff --git a/deps/icu-small/source/i18n/udat.cpp b/deps/icu-small/source/i18n/udat.cpp
index da8befc9e3..016805aab6 100644
--- a/deps/icu-small/source/i18n/udat.cpp
+++ b/deps/icu-small/source/i18n/udat.cpp
@@ -82,19 +82,24 @@ static UCalendarDateFields gDateFieldMapping[] = {
UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_ISO_FIELD = 32 (also UCAL_DST_OFFSET)
UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_ISO_LOCAL_FIELD = 33 (also UCAL_DST_OFFSET)
UCAL_EXTENDED_YEAR, // UDAT_RELATED_YEAR_FIELD = 34 (not an exact match)
- UCAL_FIELD_COUNT, // UDAT_FIELD_COUNT = 35
+ UCAL_FIELD_COUNT, // UDAT_AM_PM_MIDNIGHT_NOON_FIELD=35 (no match)
+ UCAL_FIELD_COUNT, // UDAT_FLEXIBLE_DAY_PERIOD_FIELD=36 (no match)
+ UCAL_FIELD_COUNT, // UDAT_TIME_SEPARATOR_FIELD = 37 (no match)
+ // UDAT_FIELD_COUNT = 38 as of ICU 67
// UCAL_IS_LEAP_MONTH is not the target of a mapping
};
U_CAPI UCalendarDateFields U_EXPORT2
udat_toCalendarDateField(UDateFormatField field) {
- return gDateFieldMapping[field];
+ static_assert(UDAT_FIELD_COUNT == UPRV_LENGTHOF(gDateFieldMapping),
+ "UDateFormatField and gDateFieldMapping should have the same number of entries and be kept in sync.");
+ return (field >= UDAT_ERA_FIELD && field < UPRV_LENGTHOF(gDateFieldMapping))? gDateFieldMapping[field]: UCAL_FIELD_COUNT;
}
/* For now- one opener. */
static UDateFormatOpener gOpener = NULL;
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
udat_registerOpener(UDateFormatOpener opener, UErrorCode *status)
{
if(U_FAILURE(*status)) return;
@@ -107,7 +112,7 @@ udat_registerOpener(UDateFormatOpener opener, UErrorCode *status)
umtx_unlock(NULL);
}
-U_INTERNAL UDateFormatOpener U_EXPORT2
+U_CAPI UDateFormatOpener U_EXPORT2
udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status)
{
if(U_FAILURE(*status)) return NULL;
@@ -419,7 +424,7 @@ udat_setLenient( UDateFormat* fmt,
((DateFormat*)fmt)->setLenient(isLenient);
}
-U_DRAFT UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
udat_getBooleanAttribute(const UDateFormat* fmt,
UDateFormatBooleanAttribute attr,
UErrorCode* status)
@@ -429,7 +434,7 @@ udat_getBooleanAttribute(const UDateFormat* fmt,
//return FALSE;
}
-U_DRAFT void U_EXPORT2
+U_CAPI void U_EXPORT2
udat_setBooleanAttribute(UDateFormat *fmt,
UDateFormatBooleanAttribute attr,
UBool newValue,
@@ -452,7 +457,7 @@ udat_setCalendar(UDateFormat* fmt,
((DateFormat*)fmt)->setCalendar(*((Calendar*)calendarToSet));
}
-U_DRAFT const UNumberFormat* U_EXPORT2
+U_CAPI const UNumberFormat* U_EXPORT2
udat_getNumberFormatForField(const UDateFormat* fmt, UChar field)
{
UErrorCode status = U_ZERO_ERROR;
@@ -467,7 +472,7 @@ udat_getNumberFormat(const UDateFormat* fmt)
return (const UNumberFormat*) ((DateFormat*)fmt)->getNumberFormat();
}
-U_DRAFT void U_EXPORT2
+U_CAPI void U_EXPORT2
udat_adoptNumberFormatForFields( UDateFormat* fmt,
const UChar* fields,
UNumberFormat* numberFormatToSet,
@@ -489,7 +494,7 @@ udat_setNumberFormat(UDateFormat* fmt,
((DateFormat*)fmt)->setNumberFormat(*((NumberFormat*)numberFormatToSet));
}
-U_DRAFT void U_EXPORT2
+U_CAPI void U_EXPORT2
udat_adoptNumberFormat( UDateFormat* fmt,
UNumberFormat* numberFormatToAdopt)
{
diff --git a/deps/icu-small/source/i18n/udateintervalformat.cpp b/deps/icu-small/source/i18n/udateintervalformat.cpp
index 388960384b..355744346a 100644
--- a/deps/icu-small/source/i18n/udateintervalformat.cpp
+++ b/deps/icu-small/source/i18n/udateintervalformat.cpp
@@ -18,6 +18,7 @@
#include "unicode/timezone.h"
#include "unicode/locid.h"
#include "unicode/unistr.h"
+#include "unicode/udisplaycontext.h"
#include "formattedval_impl.h"
U_NAMESPACE_USE
@@ -116,7 +117,7 @@ udtitvfmt_format(const UDateIntervalFormat* formatter,
}
-U_DRAFT void U_EXPORT2
+U_CAPI void U_EXPORT2
udtitvfmt_formatToResult(
const UDateIntervalFormat* formatter,
UDate fromDate,
@@ -134,7 +135,7 @@ udtitvfmt_formatToResult(
}
}
-U_DRAFT void U_EXPORT2
+U_CAPI void U_EXPORT2
udtitvfmt_formatCalendarToResult(
const UDateIntervalFormat* formatter,
UCalendar* fromCalendar,
@@ -151,5 +152,25 @@ udtitvfmt_formatCalendarToResult(
}
}
+U_CAPI void U_EXPORT2
+udtitvfmt_setContext(UDateIntervalFormat* formatter,
+ UDisplayContext value,
+ UErrorCode* status) {
+ if (U_FAILURE(*status)) {
+ return;
+ }
+ reinterpret_cast<DateIntervalFormat*>(formatter)->setContext( value, *status );
+}
+
+U_CAPI UDisplayContext U_EXPORT2
+udtitvfmt_getContext(const UDateIntervalFormat* formatter,
+ UDisplayContextType type,
+ UErrorCode* status) {
+ if (U_FAILURE(*status)) {
+ return (UDisplayContext)0;
+ }
+ return reinterpret_cast<const DateIntervalFormat*>(formatter)->getContext( type, *status );
+}
+
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/uitercollationiterator.h b/deps/icu-small/source/i18n/uitercollationiterator.h
index 62b6f83419..3a7b1a0ec2 100644
--- a/deps/icu-small/source/i18n/uitercollationiterator.h
+++ b/deps/icu-small/source/i18n/uitercollationiterator.h
@@ -96,7 +96,7 @@ private:
/**
* Extends the FCD text segment forward or normalizes around pos.
- * @return TRUE if success
+ * @return true if success
*/
UBool nextSegment(UErrorCode &errorCode);
@@ -107,7 +107,7 @@ private:
/**
* Extends the FCD text segment backward or normalizes around pos.
- * @return TRUE if success
+ * @return true if success
*/
UBool previousSegment(UErrorCode &errorCode);
diff --git a/deps/icu-small/source/i18n/ulocdata.cpp b/deps/icu-small/source/i18n/ulocdata.cpp
index f651fee6fc..3046167b32 100644
--- a/deps/icu-small/source/i18n/ulocdata.cpp
+++ b/deps/icu-small/source/i18n/ulocdata.cpp
@@ -172,7 +172,7 @@ ulocdata_getDelimiter(ULocaleData *uld, ULocaleDataDelimiterType type,
return 0;
}
- delimiter = ures_getStringByKey(delimiterBundle, delimiterKeys[type], &len, &localStatus);
+ delimiter = ures_getStringByKeyWithFallback(delimiterBundle, delimiterKeys[type], &len, &localStatus);
ures_close(delimiterBundle);
if ( (localStatus == U_USING_DEFAULT_WARNING) && uld->noSubstitute ) {
diff --git a/deps/icu-small/source/i18n/unicode/alphaindex.h b/deps/icu-small/source/i18n/unicode/alphaindex.h
index fe43995fe8..d72abce9ac 100644
--- a/deps/icu-small/source/i18n/unicode/alphaindex.h
+++ b/deps/icu-small/source/i18n/unicode/alphaindex.h
@@ -549,14 +549,14 @@ public:
/**
- * Advance the iteration over the Buckets of this index. Return FALSE if
+ * Advance the iteration over the Buckets of this index. Return false if
* there are no more Buckets.
*
* @param status Error code, will be set with the reason if the operation fails.
* U_ENUM_OUT_OF_SYNC_ERROR will be reported if the index is modified while
* an enumeration of its contents are in process.
*
- * @return TRUE if success, FALSE if at end of iteration
+ * @return true if success, false if at end of iteration
* @stable ICU 4.8
*/
virtual UBool nextBucket(UErrorCode &status);
@@ -609,7 +609,7 @@ public:
* @param status Error code, will be set with the reason if the operation fails.
* U_ENUM_OUT_OF_SYNC_ERROR will be reported if the index is modified while
* an enumeration of its contents are in process.
- * @return TRUE if successful, FALSE when the iteration advances past the last item.
+ * @return true if successful, false when the iteration advances past the last item.
* @stable ICU 4.8
*/
virtual UBool nextRecord(UErrorCode &status);
diff --git a/deps/icu-small/source/i18n/unicode/basictz.h b/deps/icu-small/source/i18n/unicode/basictz.h
index cc8059709f..7199fb341d 100644
--- a/deps/icu-small/source/i18n/unicode/basictz.h
+++ b/deps/icu-small/source/i18n/unicode/basictz.h
@@ -56,7 +56,7 @@ public:
* @param base The base time.
* @param inclusive Whether the base time is inclusive or not.
* @param result Receives the first transition after the base time.
- * @return TRUE if the transition is found.
+ * @return true if the transition is found.
* @stable ICU 3.8
*/
virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const = 0;
@@ -66,7 +66,7 @@ public:
* @param base The base time.
* @param inclusive Whether the base time is inclusive or not.
* @param result Receives the most recent transition before the base time.
- * @return TRUE if the transition is found.
+ * @return true if the transition is found.
* @stable ICU 3.8
*/
virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const = 0;
diff --git a/deps/icu-small/source/i18n/unicode/calendar.h b/deps/icu-small/source/i18n/unicode/calendar.h
index 2a8c2935ca..cc84bb274d 100644
--- a/deps/icu-small/source/i18n/unicode/calendar.h
+++ b/deps/icu-small/source/i18n/unicode/calendar.h
@@ -464,10 +464,10 @@ public:
UBool operator!=(const Calendar& that) const {return !operator==(that);}
/**
- * Returns TRUE if the given Calendar object is equivalent to this
+ * Returns true if the given Calendar object is equivalent to this
* one. An equivalent Calendar will behave exactly as this one
* does, but it may be set to a different time. By contrast, for
- * the operator==() method to return TRUE, the other Calendar must
+ * the operator==() method to return true, the other Calendar must
* be set to the same time.
*
* @param other the Calendar to be compared with this Calendar
@@ -1359,7 +1359,7 @@ public:
* localeID.append(calType);
* char langTag[100];
* UErrorCode errorCode = U_ZERO_ERROR;
- * int32_t length = uloc_toLanguageTag(localeID.c_str(), langTag, (int32_t)sizeof(langTag), TRUE, &errorCode);
+ * int32_t length = uloc_toLanguageTag(localeID.c_str(), langTag, (int32_t)sizeof(langTag), true, &errorCode);
* if (U_FAILURE(errorCode)) {
* // deal with errors & overflow
* }
@@ -1410,21 +1410,21 @@ public:
virtual int32_t getWeekendTransition(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;
/**
- * Returns TRUE if the given UDate is in the weekend in
+ * Returns true if the given UDate is in the weekend in
* this calendar system.
* @param date The UDate in question.
* @param status The error code for the operation.
- * @return TRUE if the given UDate is in the weekend in
- * this calendar system, FALSE otherwise.
+ * @return true if the given UDate is in the weekend in
+ * this calendar system, false otherwise.
* @stable ICU 4.4
*/
virtual UBool isWeekend(UDate date, UErrorCode &status) const;
/**
- * Returns TRUE if this Calendar's current date-time is in the weekend in
+ * Returns true if this Calendar's current date-time is in the weekend in
* this calendar system.
- * @return TRUE if this Calendar's current date-time is in the weekend in
- * this calendar system, FALSE otherwise.
+ * @return true if this Calendar's current date-time is in the weekend in
+ * this calendar system, false otherwise.
* @stable ICU 4.4
*/
virtual UBool isWeekend(void) const;
@@ -2372,7 +2372,7 @@ private:
*
* @param key the registry key returned by a previous call to registerFactory
* @param status the in/out status code, no special meanings are assigned
- * @return TRUE if the factory for the key was successfully unregistered
+ * @return true if the factory for the key was successfully unregistered
* @internal
*/
static UBool unregister(URegistryKey key, UErrorCode& status);
@@ -2398,7 +2398,7 @@ private:
#endif /* !UCONFIG_NO_SERVICE */
/**
- * @return TRUE if this calendar has a default century (i.e. 03 -> 2003)
+ * @return true if this calendar has a default century (i.e. 03 -> 2003)
* @internal
*/
virtual UBool haveDefaultCentury() const = 0;
@@ -2458,7 +2458,7 @@ private:
* @param base The base time, inclusive
* @param transitionTime Receives the result time
* @param status The error status
- * @return TRUE if a transition is found.
+ * @return true if a transition is found.
*/
UBool getImmediatePreviousZoneTransition(UDate base, UDate *transitionTime, UErrorCode& status) const;
@@ -2531,7 +2531,7 @@ Calendar::internalSet(UCalendarDateFields field, int32_t value)
{
fFields[field] = value;
fStamp[field] = kInternallySet;
- fIsSet[field] = TRUE; // Remove later
+ fIsSet[field] = true; // Remove later
}
diff --git a/deps/icu-small/source/i18n/unicode/choicfmt.h b/deps/icu-small/source/i18n/unicode/choicfmt.h
index 3b2f48cb1f..cb01fca253 100644
--- a/deps/icu-small/source/i18n/unicode/choicfmt.h
+++ b/deps/icu-small/source/i18n/unicode/choicfmt.h
@@ -106,7 +106,7 @@ class MessageFormat;
* arrays of numbers, closure flags and strings,
* they are interpreted just like
* the sequence of <code>(number separator string)</code> in an equivalent pattern string.
- * <code>closure[i]==TRUE</code> corresponds to a <code>less_than</code> separator sign.
+ * <code>closure[i]==true</code> corresponds to a <code>less_than</code> separator sign.
* The equivalent pattern string will be constructed automatically.</p>
*
* <p>During formatting, a number is mapped to the first range
@@ -126,7 +126,7 @@ class MessageFormat;
* <p>Here is an example of two arrays that map the number
* <code>1..7</code> to the English day of the week abbreviations
* <code>Sun..Sat</code>. No closures array is given; this is the same as
- * specifying all closures to be <code>FALSE</code>.</p>
+ * specifying all closures to be <code>false</code>.</p>
*
* <pre> {1,2,3,4,5,6,7},
* {&quot;Sun&quot;,&quot;Mon&quot;,&quot;Tue&quot;,&quot;Wed&quot;,&quot;Thur&quot;,&quot;Fri&quot;,&quot;Sat&quot;}</pre>
@@ -138,7 +138,7 @@ class MessageFormat;
* like the turned bracket in European notation: [-Inf, 1) == [-Inf, 1[ )</p>
*
* <pre> {0, 1, 1},
- * {FALSE, FALSE, TRUE},
+ * {false, false, true},
* {&quot;no files&quot;, &quot;one file&quot;, &quot;many files&quot;}</pre>
*
* <p>Here is an example that shows formatting and parsing: </p>
@@ -189,7 +189,7 @@ public:
/**
* Constructs a new ChoiceFormat with the given limits and message strings.
- * All closure flags default to <code>FALSE</code>,
+ * All closure flags default to <code>false</code>,
* equivalent to <code>less_than_or_equal</code> separators.
*
* Copies the limits and formats instead of adopting them.
@@ -210,9 +210,9 @@ public:
*
* @param limits Array of limit values
* @param closures Array of booleans specifying whether each
- * element of 'limits' is open or closed. If FALSE, then the
+ * element of 'limits' is open or closed. If false, then the
* corresponding limit number is a member of its range.
- * If TRUE, then the limit number belongs to the previous range it.
+ * If true, then the limit number belongs to the previous range it.
* @param formats Array of formats
* @param count Size of 'limits', 'closures', and 'formats' arrays
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
@@ -568,13 +568,13 @@ private:
* The intervals may be closed, half open, or open. This affects
* formatting but does not affect parsing. Interval i is affected
* by fClosures[i] and fClosures[i+1]. If fClosures[i]
- * is FALSE, then the value fChoiceLimits[i] is in interval i.
+ * is false, then the value fChoiceLimits[i] is in interval i.
* That is, intervals i and i are:
*
* i-1: ... x < fChoiceLimits[i]
* i: fChoiceLimits[i] <= x ...
*
- * If fClosures[i] is TRUE, then the value fChoiceLimits[i] is
+ * If fClosures[i] is true, then the value fChoiceLimits[i] is
* in interval i-1. That is, intervals i-1 and i are:
*
* i-1: ... x <= fChoiceLimits[i]
diff --git a/deps/icu-small/source/i18n/unicode/coleitr.h b/deps/icu-small/source/i18n/unicode/coleitr.h
index 809d435e50..2696b58827 100644
--- a/deps/icu-small/source/i18n/unicode/coleitr.h
+++ b/deps/icu-small/source/i18n/unicode/coleitr.h
@@ -253,7 +253,7 @@ public:
/**
* Checks if a comparison order is ignorable.
* @param order the collation order.
- * @return TRUE if a character is ignorable, FALSE otherwise.
+ * @return true if a character is ignorable, false otherwise.
* @stable ICU 2.0
*/
static inline UBool isIgnorable(int32_t order);
diff --git a/deps/icu-small/source/i18n/unicode/coll.h b/deps/icu-small/source/i18n/unicode/coll.h
index f5564c7394..c750711fc1 100644
--- a/deps/icu-small/source/i18n/unicode/coll.h
+++ b/deps/icu-small/source/i18n/unicode/coll.h
@@ -236,21 +236,21 @@ public:
// Collator public methods --------------------------------------------
/**
- * Returns TRUE if "other" is the same as "this".
+ * Returns true if "other" is the same as "this".
*
- * The base class implementation returns TRUE if "other" has the same type/class as "this":
+ * The base class implementation returns true if "other" has the same type/class as "this":
* `typeid(*this) == typeid(other)`.
*
* Subclass implementations should do something like the following:
*
- * if (this == &other) { return TRUE; }
- * if (!Collator::operator==(other)) { return FALSE; } // not the same class
+ * if (this == &other) { return true; }
+ * if (!Collator::operator==(other)) { return false; } // not the same class
*
* const MyCollator &o = (const MyCollator&)other;
* (compare this vs. o's subclass fields)
*
* @param other Collator object to be compared
- * @return TRUE if other is the same as this.
+ * @return true if other is the same as this.
* @stable ICU 2.0
*/
virtual UBool operator==(const Collator& other) const;
@@ -259,7 +259,7 @@ public:
* Returns true if "other" is not the same as "this".
* Calls ! operator==(const Collator&) const which works for all subclasses.
* @param other Collator object to be compared
- * @return TRUE if other is not the same as this.
+ * @return true if other is not the same as this.
* @stable ICU 2.0
*/
virtual UBool operator!=(const Collator& other) const;
@@ -304,7 +304,7 @@ public:
* Starting with ICU 54, collation attributes can be specified via locale keywords as well,
* in the old locale extension syntax ("el@colCaseFirst=upper")
* or in language tag syntax ("el-u-kf-upper").
- * See <a href="http://userguide.icu-project.org/collation/api">User Guide: Collation API</a>.
+ * See <a href="https://unicode-org.github.io/icu/userguide/collation/api">User Guide: Collation API</a>.
*
* The UErrorCode& err parameter is used to return status information to the user.
* To check whether the construction succeeded or not, you should check
@@ -788,7 +788,7 @@ public:
* applications who wish to cache collators, or otherwise reuse
* collators when possible. The functional equivalent may change
* over time. For more information, please see the <a
- * href="http://userguide.icu-project.org/locale#TOC-Locales-and-Services">
+ * href="https://unicode-org.github.io/icu/userguide/locale#locales-and-services">
* Locales and Services</a> section of the ICU User Guide.
* @param keyword a particular keyword as enumerated by
* ucol_getKeywords.
@@ -841,7 +841,7 @@ public:
* Collator::createInstance to avoid undefined behavior.
* @param key the registry key returned by a previous call to registerInstance
* @param status the in/out status code, no special meanings are assigned
- * @return TRUE if the collator for the key was successfully unregistered
+ * @return true if the collator for the key was successfully unregistered
* @stable ICU 2.6
*/
static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
@@ -1139,7 +1139,7 @@ public:
* This string will be normalized.
* The structure and the syntax of the string is defined in the "Naming collators"
* section of the users guide:
- * http://userguide.icu-project.org/collation/concepts#TOC-Collator-naming-scheme
+ * https://unicode-org.github.io/icu/userguide/collation/concepts#collator-naming-scheme
* This function supports preflighting.
*
* This is internal, and intended to be used with delegate converters.
diff --git a/deps/icu-small/source/i18n/unicode/curramt.h b/deps/icu-small/source/i18n/unicode/curramt.h
index 65e6619db3..9c8496381d 100644
--- a/deps/icu-small/source/i18n/unicode/curramt.h
+++ b/deps/icu-small/source/i18n/unicode/curramt.h
@@ -41,7 +41,7 @@ class U_I18N_API CurrencyAmount: public Measure {
/**
* Construct an object with the given numeric amount and the given
* ISO currency code.
- * @param amount a numeric object; amount.isNumeric() must be TRUE
+ * @param amount a numeric object; amount.isNumeric() must be true
* @param isoCode the 3-letter ISO 4217 currency code; must not be
* NULL and must have length 3
* @param ec input-output error code. If the amount or the isoCode
diff --git a/deps/icu-small/source/i18n/unicode/dcfmtsym.h b/deps/icu-small/source/i18n/unicode/dcfmtsym.h
index 582e7533a4..b2c39a0236 100644
--- a/deps/icu-small/source/i18n/unicode/dcfmtsym.h
+++ b/deps/icu-small/source/i18n/unicode/dcfmtsym.h
@@ -378,7 +378,7 @@ private:
* back to the locale.
*/
void initialize(const Locale& locale, UErrorCode& success,
- UBool useLastResortData = FALSE, const NumberingSystem* ns = nullptr);
+ UBool useLastResortData = false, const NumberingSystem* ns = nullptr);
/**
* Initialize the symbols with default values.
@@ -543,12 +543,12 @@ inline const UnicodeString& DecimalFormatSymbols::getConstDigitSymbol(int32_t di
// -------------------------------------
inline void
-DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value, const UBool propogateDigits = TRUE) {
+DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value, const UBool propagateDigits = true) {
if (symbol == kCurrencySymbol) {
- fIsCustomCurrencySymbol = TRUE;
+ fIsCustomCurrencySymbol = true;
}
else if (symbol == kIntlCurrencySymbol) {
- fIsCustomIntlCurrencySymbol = TRUE;
+ fIsCustomIntlCurrencySymbol = true;
}
if(symbol<kFormatSymbolCount) {
fSymbols[symbol]=value;
@@ -559,7 +559,7 @@ DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString
// Also record updates to fCodePointZero. Be conservative if in doubt.
if (symbol == kZeroDigitSymbol) {
UChar32 sym = value.char32At(0);
- if ( propogateDigits && u_charDigitValue(sym) == 0 && value.countChar32() == 1 ) {
+ if ( propagateDigits && u_charDigitValue(sym) == 0 && value.countChar32() == 1 ) {
fCodePointZero = sym;
for ( int8_t i = 1 ; i<= 9 ; i++ ) {
sym++;
diff --git a/deps/icu-small/source/i18n/unicode/decimfmt.h b/deps/icu-small/source/i18n/unicode/decimfmt.h
index b176ee78fa..b0da8efb1e 100644
--- a/deps/icu-small/source/i18n/unicode/decimfmt.h
+++ b/deps/icu-small/source/i18n/unicode/decimfmt.h
@@ -564,11 +564,11 @@ class NumberParserImpl;
*
* <li>In order to enable significant digits formatting, use a pattern
* containing the <code>'@'</code> pattern character. Alternatively,
- * call setSignificantDigitsUsed(TRUE).
+ * call setSignificantDigitsUsed(true).
*
* <li>In order to disable significant digits formatting, use a
* pattern that does not contain the <code>'@'</code> pattern
- * character. Alternatively, call setSignificantDigitsUsed(FALSE).
+ * character. Alternatively, call setSignificantDigitsUsed(false).
*
* <li>The number of significant digits has no effect on parsing.
*
@@ -817,8 +817,8 @@ class U_I18N_API DecimalFormat : public NumberFormat {
/**
* Sets whether lenient parsing should be enabled (it is off by default).
*
- * @param enable \c TRUE if lenient parsing should be used,
- * \c FALSE otherwise.
+ * @param enable \c true if lenient parsing should be used,
+ * \c false otherwise.
* @stable ICU 4.8
*/
void setLenient(UBool enable) U_OVERRIDE;
@@ -1507,7 +1507,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
/**
* Return whether or not scientific notation is used.
- * @return TRUE if this object formats and parses scientific notation
+ * @return true if this object formats and parses scientific notation
* @see #setScientificNotation
* @see #getMinimumExponentDigits
* @see #setMinimumExponentDigits
@@ -1523,7 +1523,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* maximum number of integer digits is set to more than 8, the effective
* maximum will be 1. This allows this call to generate a 'default' scientific
* number format without additional changes.
- * @param useScientific TRUE if this object formats and parses scientific
+ * @param useScientific true if this object formats and parses scientific
* notation
* @see #isScientificNotation
* @see #getMinimumExponentDigits
@@ -1562,7 +1562,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
/**
* Return whether the exponent sign is always shown.
- * @return TRUE if the exponent is always prefixed with either the
+ * @return true if the exponent is always prefixed with either the
* localized minus sign or the localized plus sign, false if only negative
* exponents are prefixed with the localized minus sign.
* @see #setScientificNotation
@@ -1577,7 +1577,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
/**
* Set whether the exponent sign is always shown. This has no effect
* unless scientific notation is in use.
- * @param expSignAlways TRUE if the exponent is always prefixed with either
+ * @param expSignAlways true if the exponent is always prefixed with either
* the localized minus sign or the localized plus sign, false if only
* negative exponents are prefixed with the localized minus sign.
* @see #setScientificNotation
@@ -1674,8 +1674,15 @@ class U_I18N_API DecimalFormat : public NumberFormat {
int32_t getMinimumGroupingDigits() const;
/**
- * Sets the minimum grouping digits. Setting to a value less than or
- * equal to 1 turns off minimum grouping digits.
+ * Sets the minimum grouping digits. Setting the value to
+ * - 1: Turns off minimum grouping digits.
+ * - 0 or -1: The behavior is undefined.
+ * - UNUM_MINIMUM_GROUPING_DIGITS_AUTO: Display grouping using the default
+ * strategy for all locales.
+ * - UNUM_MINIMUM_GROUPING_DIGITS_MIN2: Display grouping using locale
+ * defaults, except do not show grouping on values smaller than 10000
+ * (such that there is a minimum of two digits before the first
+ * separator).
*
* For more control over grouping strategies, use NumberFormatter.
*
@@ -1689,7 +1696,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* Allows you to get the behavior of the decimal separator with integers.
* (The decimal separator will always appear with decimals.)
*
- * @return TRUE if the decimal separator always appear with decimals.
+ * @return true if the decimal separator always appear with decimals.
* Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345
* @stable ICU 2.0
*/
@@ -1699,7 +1706,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* Allows you to set the behavior of the decimal separator with integers.
* (The decimal separator will always appear with decimals.)
*
- * @param newValue set TRUE if the decimal separator will always appear with decimals.
+ * @param newValue set true if the decimal separator will always appear with decimals.
* Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345
* @stable ICU 2.0
*/
@@ -1708,7 +1715,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
/**
* Allows you to get the parse behavior of the pattern decimal mark.
*
- * @return TRUE if input must contain a match to decimal mark in pattern
+ * @return true if input must contain a match to decimal mark in pattern
* @stable ICU 54
*/
UBool isDecimalPatternMatchRequired(void) const;
@@ -1716,10 +1723,10 @@ class U_I18N_API DecimalFormat : public NumberFormat {
/**
* Allows you to set the parse behavior of the pattern decimal mark.
*
- * if TRUE, the input must have a decimal mark if one was specified in the pattern. When
- * FALSE the decimal mark may be omitted from the input.
+ * if true, the input must have a decimal mark if one was specified in the pattern. When
+ * false the decimal mark may be omitted from the input.
*
- * @param newValue set TRUE if input must contain a match to decimal mark in pattern
+ * @param newValue set true if input must contain a match to decimal mark in pattern
* @stable ICU 54
*/
virtual void setDecimalPatternMatchRequired(UBool newValue);
@@ -1962,7 +1969,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* to one. If the maximum significant digits count is less than
* <code>min</code>, then it is set to <code>min</code>.
* This function also enables the use of significant digits
- * by this formatter - areSignificantDigitsUsed() will return TRUE.
+ * by this formatter - areSignificantDigitsUsed() will return true.
* @see #areSignificantDigitsUsed
* @param min the fewest significant digits to be shown
* @stable ICU 3.0
@@ -1975,7 +1982,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* to one. If the minimum significant digits count is greater
* than <code>max</code>, then it is set to <code>max</code>.
* This function also enables the use of significant digits
- * by this formatter - areSignificantDigitsUsed() will return TRUE.
+ * by this formatter - areSignificantDigitsUsed() will return true.
* @see #areSignificantDigitsUsed
* @param max the most significant digits to be shown
* @stable ICU 3.0
diff --git a/deps/icu-small/source/i18n/unicode/dtfmtsym.h b/deps/icu-small/source/i18n/unicode/dtfmtsym.h
index f9ec88272b..f368eaef55 100644
--- a/deps/icu-small/source/i18n/unicode/dtfmtsym.h
+++ b/deps/icu-small/source/i18n/unicode/dtfmtsym.h
@@ -919,7 +919,8 @@ private:
* failure code upon return.
* @param useLastResortData determine if use last resort data
*/
- void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE);
+ void initializeData(const Locale& locale, const char *type,
+ UErrorCode& status, UBool useLastResortData = false);
/**
* Copy or alias an array in another object, as appropriate.
@@ -983,12 +984,12 @@ private:
static UDateFormatField U_EXPORT2 getPatternCharIndex(char16_t c);
/**
- * Returns TRUE if f (with its pattern character repeated count times) is a numeric field.
+ * Returns true if f (with its pattern character repeated count times) is a numeric field.
*/
static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
/**
- * Returns TRUE if c (repeated count times) is the pattern character for a numeric field.
+ * Returns true if c (repeated count times) is the pattern character for a numeric field.
*/
static UBool U_EXPORT2 isNumericPatternChar(char16_t c, int32_t count);
public:
diff --git a/deps/icu-small/source/i18n/unicode/dtitvfmt.h b/deps/icu-small/source/i18n/unicode/dtitvfmt.h
index 4e4d712b4f..3d20d8e9c4 100644
--- a/deps/icu-small/source/i18n/unicode/dtitvfmt.h
+++ b/deps/icu-small/source/i18n/unicode/dtitvfmt.h
@@ -31,6 +31,7 @@
#include "unicode/dtitvinf.h"
#include "unicode/dtptngen.h"
#include "unicode/formattedvalue.h"
+#include "unicode/udisplaycontext.h"
U_NAMESPACE_BEGIN
@@ -651,6 +652,34 @@ public:
*/
virtual void setTimeZone(const TimeZone& zone);
+#ifndef U_FORCE_HIDE_DRAFT_API
+ /**
+ * Set a particular UDisplayContext value in the formatter, such as
+ * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. This causes the formatted
+ * result to be capitalized appropriately for the context in which
+ * it is intended to be used, considering both the locale and the
+ * type of field at the beginning of the formatted result.
+ * @param value The UDisplayContext value to set.
+ * @param status Input/output status. If at entry this indicates a failure
+ * status, the function will do nothing; otherwise this will be
+ * updated with any new status from the function.
+ * @draft ICU 68
+ */
+ virtual void setContext(UDisplayContext value, UErrorCode& status);
+
+ /**
+ * Get the formatter's UDisplayContext value for the specified UDisplayContextType,
+ * such as UDISPCTX_TYPE_CAPITALIZATION.
+ * @param type The UDisplayContextType whose value to return
+ * @param status Input/output status. If at entry this indicates a failure
+ * status, the function will do nothing; otherwise this will be
+ * updated with any new status from the function.
+ * @return The UDisplayContextValue for the specified type.
+ * @draft ICU 68
+ */
+ virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& status) const;
+#endif // U_FORCE_HIDE_DRAFT_API
+
/**
* Return the class ID for this class. This is useful only for comparing to
* a return value from getDynamicClassID(). For example:
@@ -796,7 +825,7 @@ private:
* to be formatted into date interval string
* @param toCalendar calendar set to the to date in date interval
* to be formatted into date interval string
- * @param fromToOnSameDay TRUE iff from and to dates are on the same day
+ * @param fromToOnSameDay true iff from and to dates are on the same day
* (any difference is in ampm/hours or below)
* @param appendTo Output parameter to receive result.
* Result is appended to existing contents.
@@ -868,6 +897,19 @@ private:
/**
+ * Converts special hour metacharacters (such as 'j') in the skeleton into locale-appropriate
+ * pattern characters.
+ *
+ *
+ * @param skeleton The skeleton to convert
+ * @return A copy of the skeleton, which "j" and any other special hour metacharacters converted to the regular ones.
+ *
+ */
+ UnicodeString normalizeHourMetacharacters(const UnicodeString& skeleton) const;
+
+
+
+ /**
* get separated date and time skeleton from a combined skeleton.
*
* The difference between date skeleton and normalizedDateSkeleton are:
@@ -919,8 +961,8 @@ private:
* @param dateSkeleton normalized date skeleton
* @param timeSkeleton normalized time skeleton
* @return whether the resource is found for the skeleton.
- * TRUE if interval pattern found for the skeleton,
- * FALSE otherwise.
+ * true if interval pattern found for the skeleton,
+ * false otherwise.
*/
UBool setSeparateDateTimePtn(const UnicodeString& dateSkeleton,
const UnicodeString& timeSkeleton);
@@ -948,8 +990,8 @@ private:
* @param extendedBestSkeleton extended best match skeleton
* @return whether the interval pattern is found
* through extending skeleton or not.
- * TRUE if interval pattern is found by
- * extending skeleton, FALSE otherwise.
+ * true if interval pattern is found by
+ * extending skeleton, false otherwise.
*/
UBool setIntervalPattern(UCalendarDateFields field,
const UnicodeString* skeleton,
@@ -984,6 +1026,7 @@ private:
* @param differenceInfo the difference between 2 skeletons
* 1 means only field width differs
* 2 means v/z exchange
+ * @param suppressDayPeriodField if true, remove the day period field from the pattern, if there is one
* @param adjustedIntervalPattern adjusted interval pattern
*/
static void U_EXPORT2 adjustFieldWidth(
@@ -991,6 +1034,7 @@ private:
const UnicodeString& bestMatchSkeleton,
const UnicodeString& bestMatchIntervalPattern,
int8_t differenceInfo,
+ UBool suppressDayPeriodField,
UnicodeString& adjustedIntervalPattern);
/**
@@ -1137,6 +1181,11 @@ private:
UnicodeString* fDatePattern;
UnicodeString* fTimePattern;
UnicodeString* fDateTimeFormat;
+
+ /**
+ * Other formatting information
+ */
+ UDisplayContext fCapitalizationContext;
};
inline UBool
diff --git a/deps/icu-small/source/i18n/unicode/dtitvinf.h b/deps/icu-small/source/i18n/unicode/dtitvinf.h
index 50e19abb4c..8452614bfb 100644
--- a/deps/icu-small/source/i18n/unicode/dtitvinf.h
+++ b/deps/icu-small/source/i18n/unicode/dtitvinf.h
@@ -307,8 +307,8 @@ public:
/** Get default order -- whether the first date in pattern is later date
or not.
- * return default date ordering in interval pattern. TRUE if the first date
- * in pattern is later date, FALSE otherwise.
+ * return default date ordering in interval pattern. true if the first date
+ * in pattern is later date, false otherwise.
* @stable ICU 4.0
*/
UBool getDefaultOrder() const;
diff --git a/deps/icu-small/source/i18n/unicode/dtptngen.h b/deps/icu-small/source/i18n/unicode/dtptngen.h
index f79c6d45dc..357a25d9a8 100644
--- a/deps/icu-small/source/i18n/unicode/dtptngen.h
+++ b/deps/icu-small/source/i18n/unicode/dtptngen.h
@@ -77,6 +77,13 @@ public:
#ifndef U_HIDE_INTERNAL_API
/**
+ * For ICU use only. Skips loading the standard date/time patterns (which is done via DateFormat).
+ *
+ * @internal
+ */
+ static DateTimePatternGenerator* U_EXPORT2 createInstanceNoStdPat(const Locale& uLocale, UErrorCode& status);
+
+ /**
* For ICU use only
*
* @internal
@@ -526,7 +533,7 @@ private:
/**
* Constructor.
*/
- DateTimePatternGenerator(const Locale& locale, UErrorCode & status);
+ DateTimePatternGenerator(const Locale& locale, UErrorCode & status, UBool skipStdPatterns = false);
/**
* Copy constructor.
@@ -573,7 +580,7 @@ private:
// with #13183, no longer need flags for b, B
};
- void initData(const Locale &locale, UErrorCode &status);
+ void initData(const Locale &locale, UErrorCode &status, UBool skipStdPatterns = false);
void addCanonicalItems(UErrorCode &status);
void addICUPatterns(const Locale& locale, UErrorCode& status);
void hackTimes(const UnicodeString& hackPattern, UErrorCode& status);
diff --git a/deps/icu-small/source/i18n/unicode/fieldpos.h b/deps/icu-small/source/i18n/unicode/fieldpos.h
index c9849d67a3..6c28d2d315 100644
--- a/deps/icu-small/source/i18n/unicode/fieldpos.h
+++ b/deps/icu-small/source/i18n/unicode/fieldpos.h
@@ -161,7 +161,7 @@ public:
/**
* Equality operator.
* @param that the object to be compared with.
- * @return TRUE if the two field positions are equal, FALSE otherwise.
+ * @return true if the two field positions are equal, false otherwise.
* @stable ICU 2.0
*/
UBool operator==(const FieldPosition& that) const;
@@ -169,7 +169,7 @@ public:
/**
* Equality operator.
* @param that the object to be compared with.
- * @return TRUE if the two field positions are not equal, FALSE otherwise.
+ * @return true if the two field positions are not equal, false otherwise.
* @stable ICU 2.0
*/
UBool operator!=(const FieldPosition& that) const;
diff --git a/deps/icu-small/source/i18n/unicode/fmtable.h b/deps/icu-small/source/i18n/unicode/fmtable.h
index 7bec4f6906..3a090393ac 100644
--- a/deps/icu-small/source/i18n/unicode/fmtable.h
+++ b/deps/icu-small/source/i18n/unicode/fmtable.h
@@ -179,7 +179,7 @@ public:
/**
* Equality comparison.
* @param other the object to be compared with.
- * @return TRUE if other are equal to this, FALSE otherwise.
+ * @return true if other are equal to this, false otherwise.
* @stable ICU 2.0
*/
UBool operator==(const Formattable &other) const;
@@ -187,7 +187,7 @@ public:
/**
* Equality operator.
* @param other the object to be compared with.
- * @return TRUE if other are unequal to this, FALSE otherwise.
+ * @return true if other are unequal to this, false otherwise.
* @stable ICU 2.0
*/
UBool operator!=(const Formattable& other) const
@@ -277,9 +277,9 @@ public:
Type getType(void) const;
/**
- * Returns TRUE if the data type of this Formattable object
+ * Returns true if the data type of this Formattable object
* is kDouble, kLong, or kInt64
- * @return TRUE if this is a pure numeric object
+ * @return true if this is a pure numeric object
* @stable ICU 3.0
*/
UBool isNumeric() const;
diff --git a/deps/icu-small/source/i18n/unicode/formattedvalue.h b/deps/icu-small/source/i18n/unicode/formattedvalue.h
index 4469b6328e..f4e588d01c 100644
--- a/deps/icu-small/source/i18n/unicode/formattedvalue.h
+++ b/deps/icu-small/source/i18n/unicode/formattedvalue.h
@@ -116,7 +116,7 @@ class U_I18N_API ConstrainedFieldPosition : public UMemory {
* Gets the field category for the current position.
*
* The return value is well-defined only after
- * FormattedValue#nextPosition returns TRUE.
+ * FormattedValue#nextPosition returns true.
*
* @return The field category saved in the instance.
* @stable ICU 64
@@ -129,7 +129,7 @@ class U_I18N_API ConstrainedFieldPosition : public UMemory {
* Gets the field for the current position.
*
* The return value is well-defined only after
- * FormattedValue#nextPosition returns TRUE.
+ * FormattedValue#nextPosition returns true.
*
* @return The field saved in the instance.
* @stable ICU 64
@@ -141,7 +141,7 @@ class U_I18N_API ConstrainedFieldPosition : public UMemory {
/**
* Gets the INCLUSIVE start index for the current position.
*
- * The return value is well-defined only after FormattedValue#nextPosition returns TRUE.
+ * The return value is well-defined only after FormattedValue#nextPosition returns true.
*
* @return The start index saved in the instance.
* @stable ICU 64
@@ -153,7 +153,7 @@ class U_I18N_API ConstrainedFieldPosition : public UMemory {
/**
* Gets the EXCLUSIVE end index stored for the current position.
*
- * The return value is well-defined only after FormattedValue#nextPosition returns TRUE.
+ * The return value is well-defined only after FormattedValue#nextPosition returns true.
*
* @return The end index saved in the instance.
* @stable ICU 64
@@ -301,8 +301,8 @@ class U_I18N_API FormattedValue /* not : public UObject because this is an inter
* see ConstrainedFieldPosition#constrainCategory
* and ConstrainedFieldPosition#constrainField.
* @param status Set if an error occurs.
- * @return TRUE if a new occurrence of the field was found;
- * FALSE otherwise or if an error was set.
+ * @return true if a new occurrence of the field was found;
+ * false otherwise or if an error was set.
*
* @stable ICU 64
*/
diff --git a/deps/icu-small/source/i18n/unicode/fpositer.h b/deps/icu-small/source/i18n/unicode/fpositer.h
index ba2a838315..35aa5da20f 100644
--- a/deps/icu-small/source/i18n/unicode/fpositer.h
+++ b/deps/icu-small/source/i18n/unicode/fpositer.h
@@ -96,7 +96,7 @@ public:
/**
* If the current position is valid, updates the FieldPosition values, advances the iterator,
- * and returns TRUE, otherwise returns FALSE.
+ * and returns true, otherwise returns false.
* @stable ICU 4.4
*/
UBool next(FieldPosition& fp);
diff --git a/deps/icu-small/source/i18n/unicode/gregocal.h b/deps/icu-small/source/i18n/unicode/gregocal.h
index 236bd003c1..139258d822 100644
--- a/deps/icu-small/source/i18n/unicode/gregocal.h
+++ b/deps/icu-small/source/i18n/unicode/gregocal.h
@@ -344,7 +344,7 @@ public:
UBool isLeapYear(int32_t year) const;
/**
- * Returns TRUE if the given Calendar object is equivalent to this
+ * Returns true if the given Calendar object is equivalent to this
* one. Calendar override.
*
* @param other the Calendar to be compared with this Calendar
@@ -756,7 +756,7 @@ public:
public: // internal implementation
/**
- * @return TRUE if this calendar has the notion of a default century
+ * @return true if this calendar has the notion of a default century
* @internal
*/
virtual UBool haveDefaultCentury() const;
diff --git a/deps/icu-small/source/i18n/unicode/measfmt.h b/deps/icu-small/source/i18n/unicode/measfmt.h
index 8f73de87fa..f95f39f0d5 100644
--- a/deps/icu-small/source/i18n/unicode/measfmt.h
+++ b/deps/icu-small/source/i18n/unicode/measfmt.h
@@ -309,7 +309,7 @@ class U_I18N_API MeasureFormat : public Format {
/**
* ICU use only.
* Allows subclass to change locale. Note that this method also changes
- * the NumberFormat object. Returns TRUE if locale changed; FALSE if no
+ * the NumberFormat object. Returns true if locale changed; false if no
* change was made.
* @internal.
*/
diff --git a/deps/icu-small/source/i18n/unicode/measunit.h b/deps/icu-small/source/i18n/unicode/measunit.h
index 8b65497e12..b9f732ae99 100644
--- a/deps/icu-small/source/i18n/unicode/measunit.h
+++ b/deps/icu-small/source/i18n/unicode/measunit.h
@@ -434,7 +434,7 @@ class U_I18N_API MeasureUnit: public UObject {
* For example, if the receiver is "kilowatt" and the argument is "hour-per-day", then the
* unit "kilowatt-hour-per-day" is returned.
*
- * NOTE: Only works on SINGLE and COMPOUND units. If either unit (receivee and argument) is a
+ * NOTE: Only works on SINGLE and COMPOUND units. If either unit (receiver and argument) is a
* MIXED unit, an error will occur. For more information, see UMeasureUnitComplexity.
*
* @param other The MeasureUnit to multiply with the target.
@@ -445,9 +445,9 @@ class U_I18N_API MeasureUnit: public UObject {
MeasureUnit product(const MeasureUnit& other, UErrorCode& status) const;
#endif // U_HIDE_DRAFT_API
-#ifndef U_HIDE_INTERNAL_API
+#ifndef U_HIDE_DRAFT_API
/**
- * Gets the list of SINGLE units contained within a MIXED of COMPOUND unit.
+ * Gets the list of SINGLE units contained within a MIXED or COMPOUND unit.
*
* Examples:
* - Given "meter-kilogram-per-second", three units will be returned: "meter",
@@ -457,15 +457,12 @@ class U_I18N_API MeasureUnit: public UObject {
*
* If this is a SINGLE unit, an array of length 1 will be returned.
*
- * TODO(ICU-21021): Finalize this API and propose it as draft.
- *
- * @param outCount The number of elements in the return array.
* @param status Set if an error occurs.
- * @return An array of single units, owned by the caller.
- * @internal ICU 67 Technical Preview
+ * @return A pair with the list of units as a LocalArray and the number of units in the list.
+ * @draft ICU 68
*/
- LocalArray<MeasureUnit> splitToSingleUnits(int32_t& outCount, UErrorCode& status) const;
-#endif // U_HIDE_INTERNAL_API
+ inline std::pair<LocalArray<MeasureUnit>, int32_t> splitToSingleUnits(UErrorCode& status) const;
+#endif // U_HIDE_DRAFT_API
/**
* getAvailable gets all of the available units.
@@ -540,33 +537,10 @@ class U_I18N_API MeasureUnit: public UObject {
#ifndef U_HIDE_INTERNAL_API
/**
* ICU use only.
- * Returns associated array index for this measure unit. Only valid for
- * non-currency measure units.
- * @internal
- */
- int32_t getIndex() const;
-
- /**
- * ICU use only.
- * Returns maximum value from getIndex plus 1.
- * @internal
- */
- static int32_t getIndexCount();
-
- /**
- * ICU use only.
- * @return the unit.getIndex() of the unit which has this unit.getType() and unit.getSubtype(),
- * or a negative value if there is no such unit
+ * Returns associated array index for this measure unit.
* @internal
*/
- static int32_t internalGetIndexForTypeAndSubtype(const char *type, const char *subtype);
-
- /**
- * ICU use only.
- * @internal
- */
- static MeasureUnit resolveUnitPerUnit(
- const MeasureUnit &unit, const MeasureUnit &perUnit, bool* isResolved);
+ int32_t getOffset() const;
#endif /* U_HIDE_INTERNAL_API */
// All code between the "Start generated createXXX methods" comment and
@@ -914,22 +888,6 @@ class U_I18N_API MeasureUnit: public UObject {
static MeasureUnit getMole();
/**
- * Returns by pointer, unit of concentr: permillion.
- * Caller owns returned value and must free it.
- * Also see {@link #getPartPerMillion()}.
- * @param status ICU error code.
- * @stable ICU 57
- */
- static MeasureUnit *createPartPerMillion(UErrorCode &status);
-
- /**
- * Returns by value, unit of concentr: permillion.
- * Also see {@link #createPartPerMillion()}.
- * @stable ICU 64
- */
- static MeasureUnit getPartPerMillion();
-
- /**
* Returns by pointer, unit of concentr: percent.
* Caller owns returned value and must free it.
* Also see {@link #getPercent()}.
@@ -962,6 +920,22 @@ class U_I18N_API MeasureUnit: public UObject {
static MeasureUnit getPermille();
/**
+ * Returns by pointer, unit of concentr: permillion.
+ * Caller owns returned value and must free it.
+ * Also see {@link #getPartPerMillion()}.
+ * @param status ICU error code.
+ * @stable ICU 57
+ */
+ static MeasureUnit *createPartPerMillion(UErrorCode &status);
+
+ /**
+ * Returns by value, unit of concentr: permillion.
+ * Also see {@link #createPartPerMillion()}.
+ * @stable ICU 64
+ */
+ static MeasureUnit getPartPerMillion();
+
+ /**
* Returns by pointer, unit of concentr: permyriad.
* Caller owns returned value and must free it.
* Also see {@link #getPermyriad()}.
@@ -1265,23 +1239,21 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit getDayPerson();
-#ifndef U_HIDE_DRAFT_API
/**
* Returns by pointer, unit of duration: decade.
* Caller owns returned value and must free it.
* Also see {@link #getDecade()}.
* @param status ICU error code.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit *createDecade(UErrorCode &status);
/**
* Returns by value, unit of duration: decade.
* Also see {@link #createDecade()}.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit getDecade();
-#endif /* U_HIDE_DRAFT_API */
/**
* Returns by pointer, unit of duration: hour.
@@ -1667,23 +1639,21 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit getKilowattHour();
-#ifndef U_HIDE_DRAFT_API
/**
* Returns by pointer, unit of energy: therm-us.
* Caller owns returned value and must free it.
* Also see {@link #getThermUs()}.
* @param status ICU error code.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit *createThermUs(UErrorCode &status);
/**
* Returns by value, unit of energy: therm-us.
* Also see {@link #createThermUs()}.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit getThermUs();
-#endif /* U_HIDE_DRAFT_API */
/**
* Returns by pointer, unit of force: newton.
@@ -1783,129 +1753,133 @@ class U_I18N_API MeasureUnit: public UObject {
#ifndef U_HIDE_DRAFT_API
/**
+ * Returns by pointer, unit of graphics: dot.
+ * Caller owns returned value and must free it.
+ * Also see {@link #getDot()}.
+ * @param status ICU error code.
+ * @draft ICU 68
+ */
+ static MeasureUnit *createDot(UErrorCode &status);
+
+ /**
+ * Returns by value, unit of graphics: dot.
+ * Also see {@link #createDot()}.
+ * @draft ICU 68
+ */
+ static MeasureUnit getDot();
+#endif /* U_HIDE_DRAFT_API */
+
+ /**
* Returns by pointer, unit of graphics: dot-per-centimeter.
* Caller owns returned value and must free it.
* Also see {@link #getDotPerCentimeter()}.
* @param status ICU error code.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit *createDotPerCentimeter(UErrorCode &status);
/**
* Returns by value, unit of graphics: dot-per-centimeter.
* Also see {@link #createDotPerCentimeter()}.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit getDotPerCentimeter();
-#endif /* U_HIDE_DRAFT_API */
-#ifndef U_HIDE_DRAFT_API
/**
* Returns by pointer, unit of graphics: dot-per-inch.
* Caller owns returned value and must free it.
* Also see {@link #getDotPerInch()}.
* @param status ICU error code.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit *createDotPerInch(UErrorCode &status);
/**
* Returns by value, unit of graphics: dot-per-inch.
* Also see {@link #createDotPerInch()}.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit getDotPerInch();
-#endif /* U_HIDE_DRAFT_API */
-#ifndef U_HIDE_DRAFT_API
/**
* Returns by pointer, unit of graphics: em.
* Caller owns returned value and must free it.
* Also see {@link #getEm()}.
* @param status ICU error code.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit *createEm(UErrorCode &status);
/**
* Returns by value, unit of graphics: em.
* Also see {@link #createEm()}.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit getEm();
-#endif /* U_HIDE_DRAFT_API */
-#ifndef U_HIDE_DRAFT_API
/**
* Returns by pointer, unit of graphics: megapixel.
* Caller owns returned value and must free it.
* Also see {@link #getMegapixel()}.
* @param status ICU error code.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit *createMegapixel(UErrorCode &status);
/**
* Returns by value, unit of graphics: megapixel.
* Also see {@link #createMegapixel()}.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit getMegapixel();
-#endif /* U_HIDE_DRAFT_API */
-#ifndef U_HIDE_DRAFT_API
/**
* Returns by pointer, unit of graphics: pixel.
* Caller owns returned value and must free it.
* Also see {@link #getPixel()}.
* @param status ICU error code.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit *createPixel(UErrorCode &status);
/**
* Returns by value, unit of graphics: pixel.
* Also see {@link #createPixel()}.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit getPixel();
-#endif /* U_HIDE_DRAFT_API */
-#ifndef U_HIDE_DRAFT_API
/**
* Returns by pointer, unit of graphics: pixel-per-centimeter.
* Caller owns returned value and must free it.
* Also see {@link #getPixelPerCentimeter()}.
* @param status ICU error code.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit *createPixelPerCentimeter(UErrorCode &status);
/**
* Returns by value, unit of graphics: pixel-per-centimeter.
* Also see {@link #createPixelPerCentimeter()}.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit getPixelPerCentimeter();
-#endif /* U_HIDE_DRAFT_API */
-#ifndef U_HIDE_DRAFT_API
/**
* Returns by pointer, unit of graphics: pixel-per-inch.
* Caller owns returned value and must free it.
* Also see {@link #getPixelPerInch()}.
* @param status ICU error code.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit *createPixelPerInch(UErrorCode &status);
/**
* Returns by value, unit of graphics: pixel-per-inch.
* Also see {@link #createPixelPerInch()}.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit getPixelPerInch();
-#endif /* U_HIDE_DRAFT_API */
/**
* Returns by pointer, unit of length: astronomical-unit.
@@ -1955,6 +1929,24 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit getDecimeter();
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Returns by pointer, unit of length: earth-radius.
+ * Caller owns returned value and must free it.
+ * Also see {@link #getEarthRadius()}.
+ * @param status ICU error code.
+ * @draft ICU 68
+ */
+ static MeasureUnit *createEarthRadius(UErrorCode &status);
+
+ /**
+ * Returns by value, unit of length: earth-radius.
+ * Also see {@link #createEarthRadius()}.
+ * @draft ICU 68
+ */
+ static MeasureUnit getEarthRadius();
+#endif /* U_HIDE_DRAFT_API */
+
/**
* Returns by pointer, unit of length: fathom.
* Caller owns returned value and must free it.
@@ -2243,6 +2235,42 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit getYard();
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Returns by pointer, unit of light: candela.
+ * Caller owns returned value and must free it.
+ * Also see {@link #getCandela()}.
+ * @param status ICU error code.
+ * @draft ICU 68
+ */
+ static MeasureUnit *createCandela(UErrorCode &status);
+
+ /**
+ * Returns by value, unit of light: candela.
+ * Also see {@link #createCandela()}.
+ * @draft ICU 68
+ */
+ static MeasureUnit getCandela();
+#endif /* U_HIDE_DRAFT_API */
+
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Returns by pointer, unit of light: lumen.
+ * Caller owns returned value and must free it.
+ * Also see {@link #getLumen()}.
+ * @param status ICU error code.
+ * @draft ICU 68
+ */
+ static MeasureUnit *createLumen(UErrorCode &status);
+
+ /**
+ * Returns by value, unit of light: lumen.
+ * Also see {@link #createLumen()}.
+ * @draft ICU 68
+ */
+ static MeasureUnit getLumen();
+#endif /* U_HIDE_DRAFT_API */
+
/**
* Returns by pointer, unit of light: lux.
* Caller owns returned value and must free it.
@@ -2323,6 +2351,24 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit getEarthMass();
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Returns by pointer, unit of mass: grain.
+ * Caller owns returned value and must free it.
+ * Also see {@link #getGrain()}.
+ * @param status ICU error code.
+ * @draft ICU 68
+ */
+ static MeasureUnit *createGrain(UErrorCode &status);
+
+ /**
+ * Returns by value, unit of mass: grain.
+ * Also see {@link #createGrain()}.
+ * @draft ICU 68
+ */
+ static MeasureUnit getGrain();
+#endif /* U_HIDE_DRAFT_API */
+
/**
* Returns by pointer, unit of mass: gram.
* Caller owns returned value and must free it.
@@ -2611,23 +2657,21 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit getAtmosphere();
-#ifndef U_HIDE_DRAFT_API
/**
* Returns by pointer, unit of pressure: bar.
* Caller owns returned value and must free it.
* Also see {@link #getBar()}.
* @param status ICU error code.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit *createBar(UErrorCode &status);
/**
* Returns by value, unit of pressure: bar.
* Also see {@link #createBar()}.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit getBar();
-#endif /* U_HIDE_DRAFT_API */
/**
* Returns by pointer, unit of pressure: hectopascal.
@@ -2725,23 +2769,21 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit getMillimeterOfMercury();
-#ifndef U_HIDE_DRAFT_API
/**
* Returns by pointer, unit of pressure: pascal.
* Caller owns returned value and must free it.
* Also see {@link #getPascal()}.
* @param status ICU error code.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit *createPascal(UErrorCode &status);
/**
* Returns by value, unit of pressure: pascal.
* Also see {@link #createPascal()}.
- * @draft ICU 65
+ * @stable ICU 65
*/
static MeasureUnit getPascal();
-#endif /* U_HIDE_DRAFT_API */
/**
* Returns by pointer, unit of pressure: pound-force-per-square-inch.
@@ -3143,6 +3185,78 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit getDeciliter();
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Returns by pointer, unit of volume: dessert-spoon.
+ * Caller owns returned value and must free it.
+ * Also see {@link #getDessertSpoon()}.
+ * @param status ICU error code.
+ * @draft ICU 68
+ */
+ static MeasureUnit *createDessertSpoon(UErrorCode &status);
+
+ /**
+ * Returns by value, unit of volume: dessert-spoon.
+ * Also see {@link #createDessertSpoon()}.
+ * @draft ICU 68
+ */
+ static MeasureUnit getDessertSpoon();
+#endif /* U_HIDE_DRAFT_API */
+
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Returns by pointer, unit of volume: dessert-spoon-imperial.
+ * Caller owns returned value and must free it.
+ * Also see {@link #getDessertSpoonImperial()}.
+ * @param status ICU error code.
+ * @draft ICU 68
+ */
+ static MeasureUnit *createDessertSpoonImperial(UErrorCode &status);
+
+ /**
+ * Returns by value, unit of volume: dessert-spoon-imperial.
+ * Also see {@link #createDessertSpoonImperial()}.
+ * @draft ICU 68
+ */
+ static MeasureUnit getDessertSpoonImperial();
+#endif /* U_HIDE_DRAFT_API */
+
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Returns by pointer, unit of volume: dram.
+ * Caller owns returned value and must free it.
+ * Also see {@link #getDram()}.
+ * @param status ICU error code.
+ * @draft ICU 68
+ */
+ static MeasureUnit *createDram(UErrorCode &status);
+
+ /**
+ * Returns by value, unit of volume: dram.
+ * Also see {@link #createDram()}.
+ * @draft ICU 68
+ */
+ static MeasureUnit getDram();
+#endif /* U_HIDE_DRAFT_API */
+
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Returns by pointer, unit of volume: drop.
+ * Caller owns returned value and must free it.
+ * Also see {@link #getDrop()}.
+ * @param status ICU error code.
+ * @draft ICU 68
+ */
+ static MeasureUnit *createDrop(UErrorCode &status);
+
+ /**
+ * Returns by value, unit of volume: drop.
+ * Also see {@link #createDrop()}.
+ * @draft ICU 68
+ */
+ static MeasureUnit getDrop();
+#endif /* U_HIDE_DRAFT_API */
+
/**
* Returns by pointer, unit of volume: fluid-ounce.
* Caller owns returned value and must free it.
@@ -3223,6 +3337,24 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit getHectoliter();
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Returns by pointer, unit of volume: jigger.
+ * Caller owns returned value and must free it.
+ * Also see {@link #getJigger()}.
+ * @param status ICU error code.
+ * @draft ICU 68
+ */
+ static MeasureUnit *createJigger(UErrorCode &status);
+
+ /**
+ * Returns by value, unit of volume: jigger.
+ * Also see {@link #createJigger()}.
+ * @draft ICU 68
+ */
+ static MeasureUnit getJigger();
+#endif /* U_HIDE_DRAFT_API */
+
/**
* Returns by pointer, unit of volume: liter.
* Caller owns returned value and must free it.
@@ -3271,6 +3403,24 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit getMilliliter();
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Returns by pointer, unit of volume: pinch.
+ * Caller owns returned value and must free it.
+ * Also see {@link #getPinch()}.
+ * @param status ICU error code.
+ * @draft ICU 68
+ */
+ static MeasureUnit *createPinch(UErrorCode &status);
+
+ /**
+ * Returns by value, unit of volume: pinch.
+ * Also see {@link #createPinch()}.
+ * @draft ICU 68
+ */
+ static MeasureUnit getPinch();
+#endif /* U_HIDE_DRAFT_API */
+
/**
* Returns by pointer, unit of volume: pint.
* Caller owns returned value and must free it.
@@ -3319,6 +3469,24 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit getQuart();
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Returns by pointer, unit of volume: quart-imperial.
+ * Caller owns returned value and must free it.
+ * Also see {@link #getQuartImperial()}.
+ * @param status ICU error code.
+ * @draft ICU 68
+ */
+ static MeasureUnit *createQuartImperial(UErrorCode &status);
+
+ /**
+ * Returns by value, unit of volume: quart-imperial.
+ * Also see {@link #createQuartImperial()}.
+ * @draft ICU 68
+ */
+ static MeasureUnit getQuartImperial();
+#endif /* U_HIDE_DRAFT_API */
+
/**
* Returns by pointer, unit of volume: tablespoon.
* Caller owns returned value and must free it.
@@ -3351,7 +3519,6 @@ class U_I18N_API MeasureUnit: public UObject {
*/
static MeasureUnit getTeaspoon();
-
// End generated createXXX methods
protected:
@@ -3369,12 +3536,6 @@ class U_I18N_API MeasureUnit: public UObject {
*/
void initCurrency(StringPiece isoCurrency);
- /**
- * For ICU use only.
- * @internal
- */
- void initNoUnit(const char *subtype);
-
#endif /* U_HIDE_INTERNAL_API */
private:
@@ -3393,7 +3554,6 @@ private:
MeasureUnit(int32_t typeId, int32_t subTypeId);
MeasureUnit(MeasureUnitImpl&& impl);
void setTo(int32_t typeId, int32_t subTypeId);
- int32_t getOffset() const;
static MeasureUnit *create(int typeId, int subTypeId, UErrorCode &status);
/**
@@ -3405,9 +3565,21 @@ private:
*/
static bool findBySubType(StringPiece subType, MeasureUnit* output);
+ /** Internal version of public API */
+ LocalArray<MeasureUnit> splitToSingleUnitsImpl(int32_t& outCount, UErrorCode& status) const;
+
friend struct MeasureUnitImpl;
};
+#ifndef U_HIDE_DRAFT_API // @draft ICU 68
+inline std::pair<LocalArray<MeasureUnit>, int32_t>
+MeasureUnit::splitToSingleUnits(UErrorCode& status) const {
+ int32_t length;
+ auto array = splitToSingleUnitsImpl(length, status);
+ return std::make_pair(std::move(array), length);
+}
+#endif // U_HIDE_DRAFT_API
+
U_NAMESPACE_END
#endif // !UNCONFIG_NO_FORMATTING
diff --git a/deps/icu-small/source/i18n/unicode/measure.h b/deps/icu-small/source/i18n/unicode/measure.h
index a15173d739..0ed02626b1 100644
--- a/deps/icu-small/source/i18n/unicode/measure.h
+++ b/deps/icu-small/source/i18n/unicode/measure.h
@@ -48,7 +48,7 @@ class U_I18N_API Measure: public UObject {
* Construct an object with the given numeric amount and the given
* unit. After this call, the caller must not delete the given
* unit object.
- * @param number a numeric object; amount.isNumeric() must be TRUE
+ * @param number a numeric object; amount.isNumeric() must be true
* @param adoptedUnit the unit object, which must not be NULL
* @param ec input-output error code. If the amount or the unit
* is invalid, then this will be set to a failing value.
diff --git a/deps/icu-small/source/i18n/unicode/msgfmt.h b/deps/icu-small/source/i18n/unicode/msgfmt.h
index 99b0eaeec1..2d9bc8f2e2 100644
--- a/deps/icu-small/source/i18n/unicode/msgfmt.h
+++ b/deps/icu-small/source/i18n/unicode/msgfmt.h
@@ -255,7 +255,7 @@ class NumberFormat;
* or preformatted values, but not pattern strings or custom format objects.</p>
*
* <p>For more details, see the
- * <a href="http://userguide.icu-project.org/formatparse/messages">ICU User Guide</a>.</p>
+ * <a href="https://unicode-org.github.io/icu/userguide/format_parse/messages">ICU User Guide</a>.</p>
*
* <h4>Usage Information</h4>
*
@@ -920,7 +920,7 @@ private:
int32_t argTypeCapacity;
/**
- * TRUE if there are different argTypes for the same argument.
+ * true if there are different argTypes for the same argument.
* This only matters when the MessageFormat is used in the plain C (umsg_xxx) API
* where the pattern argTypes determine how the va_arg list is read.
*/
diff --git a/deps/icu-small/source/i18n/unicode/nounit.h b/deps/icu-small/source/i18n/unicode/nounit.h
index 61b5c16ee3..cee45e352d 100644
--- a/deps/icu-small/source/i18n/unicode/nounit.h
+++ b/deps/icu-small/source/i18n/unicode/nounit.h
@@ -29,80 +29,53 @@ U_NAMESPACE_BEGIN
/**
* Dimensionless unit for percent and permille.
+ * Prior to ICU 68, this namespace was a class with the same name.
* @see NumberFormatter
- * @draft ICU 60
+ * @draft ICU 68
*/
-class U_I18N_API NoUnit: public MeasureUnit {
-public:
+namespace NoUnit {
/**
* Returns an instance for the base unit (dimensionless and no scaling).
*
- * @return a NoUnit instance
- * @draft ICU 60
+ * Prior to ICU 68, this function returned a NoUnit by value.
+ *
+ * Since ICU 68, this function returns the same value as the default MeasureUnit constructor.
+ *
+ * @return a MeasureUnit instance
+ * @draft ICU 68
*/
- static NoUnit U_EXPORT2 base();
+ static inline MeasureUnit U_EXPORT2 base() {
+ return MeasureUnit();
+ }
/**
* Returns an instance for percent, or 1/100 of a base unit.
*
- * @return a NoUnit instance
- * @draft ICU 60
+ * Prior to ICU 68, this function returned a NoUnit by value.
+ *
+ * Since ICU 68, this function returns the same value as MeasureUnit::getPercent().
+ *
+ * @return a MeasureUnit instance
+ * @draft ICU 68
*/
- static NoUnit U_EXPORT2 percent();
+ static inline MeasureUnit U_EXPORT2 percent() {
+ return MeasureUnit::getPercent();
+ }
/**
* Returns an instance for permille, or 1/1000 of a base unit.
*
- * @return a NoUnit instance
- * @draft ICU 60
- */
- static NoUnit U_EXPORT2 permille();
-
- /**
- * Copy operator.
- * @draft ICU 60
- */
- NoUnit(const NoUnit& other);
-
- /**
- * Destructor.
- * @draft ICU 60
- */
- virtual ~NoUnit();
-
- /**
- * Return a polymorphic clone of this object. The result will
- * have the same class as returned by getDynamicClassID().
- * @draft ICU 60
- */
- virtual NoUnit* clone() const;
-
- /**
- * Returns a unique class ID for this object POLYMORPHICALLY.
- * This method implements a simple form of RTTI used by ICU.
- * @return The class ID for this object. All objects of a given
- * class have the same class ID. Objects of other classes have
- * different class IDs.
- * @draft ICU 60
- */
- virtual UClassID getDynamicClassID() const;
-
- /**
- * Returns the class ID for this class. This is used to compare to
- * the return value of getDynamicClassID().
- * @return The class ID for all objects of this class.
- * @draft ICU 60
- */
- static UClassID U_EXPORT2 getStaticClassID();
-
-private:
- /**
- * Constructor
- * @internal (private)
+ * Prior to ICU 68, this function returned a NoUnit by value.
+ *
+ * Since ICU 68, this function returns the same value as MeasureUnit::getPermille().
+ *
+ * @return a MeasureUnit instance
+ * @draft ICU 68
*/
- NoUnit(const char* subtype);
-
-};
+ static inline MeasureUnit U_EXPORT2 permille() {
+ return MeasureUnit::getPermille();
+ }
+}
U_NAMESPACE_END
diff --git a/deps/icu-small/source/i18n/unicode/numberformatter.h b/deps/icu-small/source/i18n/unicode/numberformatter.h
index 615cf49f7b..06329b8e7a 100644
--- a/deps/icu-small/source/i18n/unicode/numberformatter.h
+++ b/deps/icu-small/source/i18n/unicode/numberformatter.h
@@ -99,6 +99,13 @@ class MultiplierParseHandler;
}
}
+namespace units {
+
+// Forward declarations:
+class UnitsRouter;
+
+} // namespace units
+
namespace number { // icu::number
// Forward declarations:
@@ -157,6 +164,7 @@ struct RangeMacroProps;
struct UFormattedNumberImpl;
class MutablePatternModifier;
class ImmutablePatternModifier;
+struct DecimalFormatWarehouse;
/**
* Used for NumberRangeFormatter and implemented in numrange_fluent.cpp.
@@ -371,9 +379,9 @@ class U_I18N_API Notation : public UMemory {
UBool copyErrorTo(UErrorCode &status) const {
if (fType == NTN_ERROR) {
status = fUnion.errorCode;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
// To allow MacroProps to initialize empty instances:
@@ -705,12 +713,8 @@ class U_I18N_API Precision : public UMemory {
typedef PrecisionUnion::FractionSignificantSettings FractionSignificantSettings;
typedef PrecisionUnion::IncrementSettings IncrementSettings;
- /** The Precision encapsulates the RoundingMode when used within the implementation. */
- UNumberFormatRoundingMode fRoundingMode;
-
- Precision(const PrecisionType& type, const PrecisionUnion& union_,
- UNumberFormatRoundingMode roundingMode)
- : fType(type), fUnion(union_), fRoundingMode(roundingMode) {}
+ Precision(const PrecisionType& type, const PrecisionUnion& union_)
+ : fType(type), fUnion(union_) {}
Precision(UErrorCode errorCode) : fType(RND_ERROR) {
fUnion.errorCode = errorCode;
@@ -725,9 +729,9 @@ class U_I18N_API Precision : public UMemory {
UBool copyErrorTo(UErrorCode &status) const {
if (fType == RND_ERROR) {
status = fUnion.errorCode;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
// On the parent type so that this method can be called internally on Precision instances.
@@ -744,8 +748,6 @@ class U_I18N_API Precision : public UMemory {
static CurrencyPrecision constructCurrency(UCurrencyUsage usage);
- static Precision constructPassThrough();
-
// To allow MacroProps/MicroProps to initialize bogus instances:
friend struct impl::MacroProps;
friend struct impl::MicroProps;
@@ -766,6 +768,9 @@ class U_I18N_API Precision : public UMemory {
// To allow access to the skeleton generation code:
friend class impl::GeneratorHelpers;
+
+ // To allow access to isBogus and the default (bogus) constructor:
+ friend class units::UnitsRouter;
};
/**
@@ -969,9 +974,9 @@ class U_I18N_API IntegerWidth : public UMemory {
UBool copyErrorTo(UErrorCode &status) const {
if (fHasError) {
status = fUnion.errorCode;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
void apply(impl::DecimalQuantity &quantity, UErrorCode &status) const;
@@ -1095,11 +1100,11 @@ class U_I18N_API Scale : public UMemory {
}
UBool copyErrorTo(UErrorCode &status) const {
- if (fError != U_ZERO_ERROR) {
+ if (U_FAILURE(fError)) {
status = fError;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
void applyTo(impl::DecimalQuantity& quantity) const;
@@ -1126,6 +1131,71 @@ class U_I18N_API Scale : public UMemory {
namespace impl {
+// Do not enclose entire Usage with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
+/**
+ * Manages NumberFormatterSettings::usage()'s char* instance on the heap.
+ * @internal
+ */
+class U_I18N_API Usage : public UMemory {
+
+#ifndef U_HIDE_INTERNAL_API
+
+ public:
+ /** @internal */
+ Usage(const Usage& other);
+
+ /** @internal */
+ Usage& operator=(const Usage& other);
+
+ /** @internal */
+ Usage(Usage &&src) U_NOEXCEPT;
+
+ /** @internal */
+ Usage& operator=(Usage&& src) U_NOEXCEPT;
+
+ /** @internal */
+ ~Usage();
+
+ /** @internal */
+ int16_t length() const { return fLength; }
+
+ /** @internal
+ * Makes a copy of value. Set to "" to unset.
+ */
+ void set(StringPiece value);
+
+ /** @internal */
+ bool isSet() const { return fLength > 0; }
+
+#endif // U_HIDE_INTERNAL_API
+
+ private:
+ char *fUsage;
+ int16_t fLength;
+ UErrorCode fError;
+
+ Usage() : fUsage(nullptr), fLength(0), fError(U_ZERO_ERROR) {}
+
+ /** @internal */
+ UBool copyErrorTo(UErrorCode &status) const {
+ if (U_FAILURE(fError)) {
+ status = fError;
+ return true;
+ }
+ return false;
+ }
+
+ // Allow NumberFormatterImpl to access fUsage.
+ friend class impl::NumberFormatterImpl;
+
+ // Allow skeleton generation code to access private members.
+ friend class impl::GeneratorHelpers;
+
+ // Allow MacroProps/MicroProps to initialize empty instances and to call
+ // copyErrorTo().
+ friend struct impl::MacroProps;
+};
+
// Do not enclose entire SymbolsWrapper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
/** @internal */
class U_I18N_API SymbolsWrapper : public UMemory {
@@ -1192,12 +1262,12 @@ class U_I18N_API SymbolsWrapper : public UMemory {
UBool copyErrorTo(UErrorCode &status) const {
if (fType == SYMPTR_DFS && fPtr.dfs == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return TRUE;
+ return true;
} else if (fType == SYMPTR_NS && fPtr.ns == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
private:
@@ -1239,13 +1309,13 @@ class U_I18N_API Grouper : public UMemory {
fGrouping2(grouping2),
fMinGrouping(minGrouping),
fStrategy(strategy) {}
-#endif // U_HIDE_INTERNAL_API
/** @internal */
int16_t getPrimary() const;
/** @internal */
int16_t getSecondary() const;
+#endif // U_HIDE_INTERNAL_API
private:
/**
@@ -1309,10 +1379,10 @@ class U_I18N_API Padder : public UMemory {
/** @internal */
static Padder codePoints(UChar32 cp, int32_t targetWidth, UNumberFormatPadPosition position);
-#endif // U_HIDE_INTERNAL_API
/** @internal */
static Padder forProperties(const DecimalFormatProperties& properties);
+#endif // U_HIDE_INTERNAL_API
private:
UChar32 fWidth; // -3 = error; -2 = bogus; -1 = no padding
@@ -1341,9 +1411,9 @@ class U_I18N_API Padder : public UMemory {
UBool copyErrorTo(UErrorCode &status) const {
if (fWidth == -3) {
status = fUnion.errorCode;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
bool isValid() const {
@@ -1372,10 +1442,10 @@ struct U_I18N_API MacroProps : public UMemory {
Notation notation;
/** @internal */
- MeasureUnit unit; // = NoUnit::base();
+ MeasureUnit unit; // = MeasureUnit(); (the base dimensionless unit)
/** @internal */
- MeasureUnit perUnit; // = NoUnit::base();
+ MeasureUnit perUnit; // = MeasureUnit(); (the base dimensionless unit)
/** @internal */
Precision precision; // = Precision(); (bogus)
@@ -1410,6 +1480,9 @@ struct U_I18N_API MacroProps : public UMemory {
Scale scale; // = Scale(); (benign value)
/** @internal */
+ Usage usage; // = Usage(); (no usage)
+
+ /** @internal */
const AffixPatternProvider* affixProvider = nullptr; // no ownership
/** @internal */
@@ -1430,7 +1503,7 @@ struct U_I18N_API MacroProps : public UMemory {
bool copyErrorTo(UErrorCode &status) const {
return notation.copyErrorTo(status) || precision.copyErrorTo(status) ||
padder.copyErrorTo(status) || integerWidth.copyErrorTo(status) ||
- symbols.copyErrorTo(status) || scale.copyErrorTo(status);
+ symbols.copyErrorTo(status) || scale.copyErrorTo(status) || usage.copyErrorTo(status);
}
};
@@ -1507,10 +1580,15 @@ class U_I18N_API NumberFormatterSettings {
* All units will be properly localized with locale data, and all units are compatible with notation styles,
* rounding precisions, and other number formatter settings.
*
+ * \note If the usage() is set, the output unit **will be changed** to
+ * produce localised units, according to usage, locale and unit. See
+ * FormattedNumber::getOutputUnit().
+ *
* Pass this method any instance of {@link MeasureUnit}. For units of measure:
*
* <pre>
* NumberFormatter::with().unit(MeasureUnit::getMeter())
+ * NumberFormatter::with().unit(MeasureUnit::forIdentifier("foot-per-second", status))
* </pre>
*
* Currency:
@@ -1693,7 +1771,7 @@ class U_I18N_API NumberFormatterSettings {
*
* The default is HALF_EVEN. For more information on rounding mode, see the ICU userguide here:
*
- * http://userguide.icu-project.org/formatparse/numbers/rounding-modes
+ * https://unicode-org.github.io/icu/userguide/format_parse/numbers/rounding-modes
*
* @param roundingMode The rounding mode to use.
* @return The fluent chain.
@@ -2038,6 +2116,61 @@ class U_I18N_API NumberFormatterSettings {
*/
Derived scale(const Scale &scale) &&;
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Specifies the usage for which numbers will be formatted ("person-height",
+ * "road", "rainfall", etc.)
+ *
+ * When a `usage` is specified, the output unit will change depending on the
+ * `Locale` and the unit quantity. For example, formatting length
+ * measurements specified in meters:
+ *
+ * `NumberFormatter::with().usage("person").unit(MeasureUnit::getMeter()).locale("en-US")`
+ * * When formatting 0.25, the output will be "10 inches".
+ * * When formatting 1.50, the output will be "4 feet and 11 inches".
+ *
+ * The input unit specified via unit() determines the type of measurement
+ * being formatted (e.g. "length" when the unit is "foot"). The usage
+ * requested will be looked for only within this category of measurement
+ * units.
+ *
+ * The output unit can be found via FormattedNumber::getOutputUnit().
+ *
+ * If the usage has multiple parts (e.g. "land-agriculture-grain") and does
+ * not match a known usage preference, the last part will be dropped
+ * repeatedly until a match is found (e.g. trying "land-agriculture", then
+ * "land"). If a match is still not found, usage will fall back to
+ * "default".
+ *
+ * Setting usage to an empty string clears the usage (disables usage-based
+ * localized formatting).
+ *
+ * Setting a usage string but not a correct input unit will result in an
+ * U_ILLEGAL_ARGUMENT_ERROR.
+ *
+ * When using usage, specifying rounding or precision is unnecessary.
+ * Specifying a precision in some manner will override the default
+ * formatting.
+ *
+ * @param usage A `usage` parameter from the units resource. See the
+ * unitPreferenceData in *source/data/misc/units.txt*, generated from
+ * `unitPreferenceData` in [CLDR's
+ * supplemental/units.xml](https://github.com/unicode-org/cldr/blob/master/common/supplemental/units.xml).
+ * @return The fluent chain.
+ * @draft ICU 68
+ */
+ Derived usage(StringPiece usage) const &;
+
+ /**
+ * Overload of usage() for use on an rvalue reference.
+ *
+ * @param usage The unit `usage`.
+ * @return The fluent chain.
+ * @draft ICU 68
+ */
+ Derived usage(StringPiece usage) &&;
+#endif // U_HIDE_DRAFT_API
+
#ifndef U_HIDE_INTERNAL_API
/**
@@ -2120,13 +2253,13 @@ class U_I18N_API NumberFormatterSettings {
/**
* Sets the UErrorCode if an error occurred in the fluent chain.
* Preserves older error codes in the outErrorCode.
- * @return TRUE if U_FAILURE(outErrorCode)
+ * @return true if U_FAILURE(outErrorCode)
* @stable ICU 60
*/
UBool copyErrorTo(UErrorCode &outErrorCode) const {
if (U_FAILURE(outErrorCode)) {
// Do not overwrite the older error code
- return TRUE;
+ return true;
}
fMacros.copyErrorTo(outErrorCode);
return U_FAILURE(outErrorCode);
@@ -2385,6 +2518,10 @@ class U_I18N_API LocalizedNumberFormatter
const impl::NumberFormatterImpl* fCompiled {nullptr};
char fUnsafeCallCount[8] {}; // internally cast to u_atomic_int32_t
+ // Owned pointer to a DecimalFormatWarehouse, used when copying a LocalizedNumberFormatter
+ // from a DecimalFormat.
+ const impl::DecimalFormatWarehouse* fWarehouse {nullptr};
+
explicit LocalizedNumberFormatter(const NumberFormatterSettings<LocalizedNumberFormatter>& other);
explicit LocalizedNumberFormatter(NumberFormatterSettings<LocalizedNumberFormatter>&& src) U_NOEXCEPT;
@@ -2393,10 +2530,12 @@ class U_I18N_API LocalizedNumberFormatter
LocalizedNumberFormatter(impl::MacroProps &&macros, const Locale &locale);
- void clear();
+ void resetCompiled();
void lnfMoveHelper(LocalizedNumberFormatter&& src);
+ void lnfCopyHelper(const LocalizedNumberFormatter& src, UErrorCode& status);
+
/**
* @return true if the compiled formatter is available.
*/
@@ -2485,7 +2624,6 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue {
/** @copydoc FormattedValue::nextPosition() */
UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE;
-#ifndef U_HIDE_DRAFT_API
/**
* Export the formatted number as a "numeric string" conforming to the
* syntax defined in the Decimal Arithmetic Specification, available at
@@ -2502,10 +2640,24 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue {
* for example, std::string.
* @param status Set if an error occurs.
* @return A StringClass containing the numeric string.
- * @draft ICU 65
+ * @stable ICU 65
*/
template<typename StringClass>
inline StringClass toDecimalNumber(UErrorCode& status) const;
+
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Gets the resolved output unit.
+ *
+ * The output unit is dependent upon the localized preferences for the usage
+ * specified via NumberFormatterSettings::usage(), and may be a unit with
+ * UMEASURE_UNIT_MIXED unit complexity (MeasureUnit::getComplexity()), such
+ * as "foot-and-inch" or "hour-and-minute-and-second".
+ *
+ * @return `MeasureUnit`.
+ * @draft ICU 68
+ */
+ MeasureUnit getOutputUnit(UErrorCode& status) const;
#endif // U_HIDE_DRAFT_API
#ifndef U_HIDE_INTERNAL_API
@@ -2541,7 +2693,6 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue {
explicit FormattedNumber(UErrorCode errorCode)
: fData(nullptr), fErrorCode(errorCode) {}
- // TODO(ICU-20775): Propose this as API.
void toDecimalNumber(ByteSink& sink, UErrorCode& status) const;
// To give LocalizedNumberFormatter format methods access to this class's constructor:
@@ -2639,4 +2790,3 @@ U_NAMESPACE_END
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // __NUMBERFORMATTER_H__
-
diff --git a/deps/icu-small/source/i18n/unicode/numberrangeformatter.h b/deps/icu-small/source/i18n/unicode/numberrangeformatter.h
index 59f14d8be5..67339bb6e6 100644
--- a/deps/icu-small/source/i18n/unicode/numberrangeformatter.h
+++ b/deps/icu-small/source/i18n/unicode/numberrangeformatter.h
@@ -16,6 +16,7 @@
#include "unicode/formattedvalue.h"
#include "unicode/fpositer.h"
#include "unicode/numberformatter.h"
+#include "unicode/unumberrangeformatter.h"
/**
* \file
@@ -31,7 +32,7 @@
* .numberFormatterFirst(NumberFormatter::with().adoptUnit(MeasureUnit::createMeter()))
* .numberFormatterSecond(NumberFormatter::with().adoptUnit(MeasureUnit::createKilometer()))
* .locale("en-GB")
- * .formatRange(750, 1.2, status)
+ * .formatFormattableRange(750, 1.2, status)
* .toString(status);
* // => "750 m - 1.2 km"
* </pre>
@@ -44,130 +45,11 @@
*/
-/**
- * Defines how to merge fields that are identical across the range sign.
- *
- * @stable ICU 63
- */
-typedef enum UNumberRangeCollapse {
- /**
- * Use locale data and heuristics to determine how much of the string to collapse. Could end up collapsing none,
- * some, or all repeated pieces in a locale-sensitive way.
- *
- * The heuristics used for this option are subject to change over time.
- *
- * @stable ICU 63
- */
- UNUM_RANGE_COLLAPSE_AUTO,
-
- /**
- * Do not collapse any part of the number. Example: "3.2 thousand kilograms – 5.3 thousand kilograms"
- *
- * @stable ICU 63
- */
- UNUM_RANGE_COLLAPSE_NONE,
-
- /**
- * Collapse the unit part of the number, but not the notation, if present. Example: "3.2 thousand – 5.3 thousand
- * kilograms"
- *
- * @stable ICU 63
- */
- UNUM_RANGE_COLLAPSE_UNIT,
-
- /**
- * Collapse any field that is equal across the range sign. May introduce ambiguity on the magnitude of the
- * number. Example: "3.2 – 5.3 thousand kilograms"
- *
- * @stable ICU 63
- */
- UNUM_RANGE_COLLAPSE_ALL
-} UNumberRangeCollapse;
-
-/**
- * Defines the behavior when the two numbers in the range are identical after rounding. To programmatically detect
- * when the identity fallback is used, compare the lower and upper BigDecimals via FormattedNumber.
- *
- * @stable ICU 63
- * @see NumberRangeFormatter
- */
-typedef enum UNumberRangeIdentityFallback {
- /**
- * Show the number as a single value rather than a range. Example: "$5"
- *
- * @stable ICU 63
- */
- UNUM_IDENTITY_FALLBACK_SINGLE_VALUE,
-
- /**
- * Show the number using a locale-sensitive approximation pattern. If the numbers were the same before rounding,
- * show the single value. Example: "~$5" or "$5"
- *
- * @stable ICU 63
- */
- UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE,
-
- /**
- * Show the number using a locale-sensitive approximation pattern. Use the range pattern always, even if the
- * inputs are the same. Example: "~$5"
- *
- * @stable ICU 63
- */
- UNUM_IDENTITY_FALLBACK_APPROXIMATELY,
-
- /**
- * Show the number as the range of two equal values. Use the range pattern always, even if the inputs are the
- * same. Example (with RangeCollapse.NONE): "$5 – $5"
- *
- * @stable ICU 63
- */
- UNUM_IDENTITY_FALLBACK_RANGE
-} UNumberRangeIdentityFallback;
-
-/**
- * Used in the result class FormattedNumberRange to indicate to the user whether the numbers formatted in the range
- * were equal or not, and whether or not the identity fallback was applied.
- *
- * @stable ICU 63
- * @see NumberRangeFormatter
- */
-typedef enum UNumberRangeIdentityResult {
- /**
- * Used to indicate that the two numbers in the range were equal, even before any rounding rules were applied.
- *
- * @stable ICU 63
- * @see NumberRangeFormatter
- */
- UNUM_IDENTITY_RESULT_EQUAL_BEFORE_ROUNDING,
-
- /**
- * Used to indicate that the two numbers in the range were equal, but only after rounding rules were applied.
- *
- * @stable ICU 63
- * @see NumberRangeFormatter
- */
- UNUM_IDENTITY_RESULT_EQUAL_AFTER_ROUNDING,
-
- /**
- * Used to indicate that the two numbers in the range were not equal, even after rounding rules were applied.
- *
- * @stable ICU 63
- * @see NumberRangeFormatter
- */
- UNUM_IDENTITY_RESULT_NOT_EQUAL,
-
-#ifndef U_HIDE_INTERNAL_API
- /**
- * The number of entries in this enum.
- * @internal
- */
- UNUM_IDENTITY_RESULT_COUNT
-#endif
-
-} UNumberRangeIdentityResult;
-
U_NAMESPACE_BEGIN
+// Forward declarations:
+class PluralRules;
+
namespace number { // icu::number
// Forward declarations:
@@ -182,6 +64,7 @@ struct RangeMacroProps;
class DecimalQuantity;
class UFormattedNumberRangeData;
class NumberRangeFormatterImpl;
+struct UFormattedNumberRangeImpl;
} // namespace impl
@@ -418,8 +301,8 @@ class U_I18N_API NumberRangeFormatterSettings {
/**
* Sets the behavior when the two sides of the range are the same. This could happen if the same two numbers are
- * passed to the formatRange function, or if different numbers are passed to the function but they become the same
- * after rounding rules are applied. Possible values:
+ * passed to the formatFormattableRange function, or if different numbers are passed to the function but they
+ * become the same after rounding rules are applied. Possible values:
* <p>
* <ul>
* <li>SINGLE_VALUE: "5 miles"</li>
@@ -474,13 +357,13 @@ class U_I18N_API NumberRangeFormatterSettings {
/**
* Sets the UErrorCode if an error occurred in the fluent chain.
* Preserves older error codes in the outErrorCode.
- * @return TRUE if U_FAILURE(outErrorCode)
+ * @return true if U_FAILURE(outErrorCode)
* @stable ICU 63
*/
UBool copyErrorTo(UErrorCode &outErrorCode) const {
if (U_FAILURE(outErrorCode)) {
// Do not overwrite the older error code
- return TRUE;
+ return true;
}
fMacros.copyErrorTo(outErrorCode);
return U_FAILURE(outErrorCode);
@@ -725,7 +608,7 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue {
/** @copydoc FormattedValue::nextPosition() */
UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE;
-#ifndef U_HIDE_DRAFT_API
+#ifndef U_HIDE_DEPRECATED_API
/**
* Export the first formatted number as a decimal number. This endpoint
* is useful for obtaining the exact number being printed after scaling
@@ -735,8 +618,12 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue {
* as defined in the Decimal Arithmetic Specification, available at
* http://speleotrove.com/decimal
*
+ * TODO(ICU-21275): This function will be removed in ICU 69.
+ * Use getDecimalNumbers() instead.
+ *
+ * @param status Set if an error occurs.
* @return A decimal representation of the first formatted number.
- * @draft ICU 63
+ * @deprecated ICU 68 Use getDecimalNumbers instead.
* @see NumberRangeFormatter
* @see #getSecondDecimal
*/
@@ -751,12 +638,41 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue {
* as defined in the Decimal Arithmetic Specification, available at
* http://speleotrove.com/decimal
*
+ * TODO(ICU-21275): This function will be removed in ICU 69.
+ * Use getDecimalNumbers() instead.
+ *
+ * @param status Set if an error occurs.
* @return A decimal representation of the second formatted number.
- * @draft ICU 63
+ * @deprecated ICU 68 Use getDecimalNumbers instead.
* @see NumberRangeFormatter
* @see #getFirstDecimal
*/
UnicodeString getSecondDecimal(UErrorCode& status) const;
+#endif // U_HIDE_DEPRECATED_API
+
+
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Extracts the formatted range as a pair of decimal numbers. This endpoint
+ * is useful for obtaining the exact number being printed after scaling
+ * and rounding have been applied by the number range formatting pipeline.
+ *
+ * The syntax of the unformatted numbers is a "numeric string"
+ * as defined in the Decimal Arithmetic Specification, available at
+ * http://speleotrove.com/decimal
+ *
+ * Example C++17 call site:
+ *
+ * auto [ first, second ] = range.getDecimalNumbers<std::string>(status);
+ *
+ * @tparam StringClass A string class compatible with StringByteSink;
+ * for example, std::string.
+ * @param status Set if an error occurs.
+ * @return A pair of StringClasses containing the numeric strings.
+ * @draft ICU 68
+ */
+ template<typename StringClass>
+ inline std::pair<StringClass, StringClass> getDecimalNumbers(UErrorCode& status) const;
#endif // U_HIDE_DRAFT_API
/**
@@ -818,10 +734,33 @@ class U_I18N_API FormattedNumberRange : public UMemory, public FormattedValue {
void getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih, UErrorCode& status) const;
+ void getDecimalNumbers(ByteSink& sink1, ByteSink& sink2, UErrorCode& status) const;
+
+ const impl::UFormattedNumberRangeData* getData(UErrorCode& status) const;
+
+ // To allow PluralRules to access the underlying data
+ friend class ::icu::PluralRules;
+
// To give LocalizedNumberRangeFormatter format methods access to this class's constructor:
friend class LocalizedNumberRangeFormatter;
+
+ // To give C API access to internals
+ friend struct impl::UFormattedNumberRangeImpl;
};
+#ifndef U_HIDE_DRAFT_API
+// Note: This is draft ICU 68
+template<typename StringClass>
+std::pair<StringClass, StringClass> FormattedNumberRange::getDecimalNumbers(UErrorCode& status) const {
+ StringClass str1;
+ StringClass str2;
+ StringByteSink<StringClass> sink1(&str1);
+ StringByteSink<StringClass> sink2(&str2);
+ getDecimalNumbers(sink1, sink2, status);
+ return std::make_pair(str1, str2);
+}
+#endif // U_HIDE_DRAFT_API
+
/**
* See the main description in numberrangeformatter.h for documentation and examples.
*
diff --git a/deps/icu-small/source/i18n/unicode/numfmt.h b/deps/icu-small/source/i18n/unicode/numfmt.h
index a882b6d2e5..058ccb38c7 100644
--- a/deps/icu-small/source/i18n/unicode/numfmt.h
+++ b/deps/icu-small/source/i18n/unicode/numfmt.h
@@ -179,7 +179,7 @@ public:
*
* <p>
* For more detail on rounding modes, see:
- * http://userguide.icu-project.org/formatparse/numbers/rounding-modes
+ * https://unicode-org.github.io/icu/userguide/format_parse/numbers/rounding-modes
*
* @stable ICU 2.4
*/
@@ -704,8 +704,8 @@ public:
/**
* Sets whether lenient parsing should be enabled (it is off by default).
*
- * @param enable \c TRUE if lenient parsing should be used,
- * \c FALSE otherwise.
+ * @param enable \c true if lenient parsing should be used,
+ * \c false otherwise.
* @stable ICU 4.8
*/
virtual void setLenient(UBool enable);
@@ -713,8 +713,8 @@ public:
/**
* Returns whether lenient parsing is enabled (it is off by default).
*
- * @return \c TRUE if lenient parsing is enabled,
- * \c FALSE otherwise.
+ * @return \c true if lenient parsing is enabled,
+ * \c false otherwise.
* @see #setLenient
* @stable ICU 4.8
*/
@@ -870,7 +870,7 @@ public:
* NumberFormat::createInstance to avoid undefined behavior.
* @param key the registry key returned by a previous call to registerFactory
* @param status the in/out status code, no special meanings are assigned
- * @return TRUE if the factory for the key was successfully unregistered
+ * @return true if the factory for the key was successfully unregistered
* @stable ICU 2.6
*/
static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
@@ -1112,7 +1112,7 @@ protected:
#ifndef U_HIDE_INTERNAL_API
/**
* Creates the specified number format style of the desired locale.
- * If mustBeDecimalFormat is TRUE, then the returned pointer is
+ * If mustBeDecimalFormat is true, then the returned pointer is
* either a DecimalFormat or it is NULL.
* @internal
*/
@@ -1151,7 +1151,7 @@ private:
private:
UBool fParseIntegerOnly;
- UBool fLenient; // TRUE => lenient parse is enabled
+ UBool fLenient; // true => lenient parse is enabled
// ISO currency code
char16_t fCurrency[4];
@@ -1228,7 +1228,7 @@ public:
/**
* @stable ICU 2.6
*/
- SimpleNumberFormatFactory(const Locale& locale, UBool visible = TRUE);
+ SimpleNumberFormatFactory(const Locale& locale, UBool visible = true);
/**
* @stable ICU 3.0
diff --git a/deps/icu-small/source/i18n/unicode/numsys.h b/deps/icu-small/source/i18n/unicode/numsys.h
index 88c172bd42..efdf0c0f66 100644
--- a/deps/icu-small/source/i18n/unicode/numsys.h
+++ b/deps/icu-small/source/i18n/unicode/numsys.h
@@ -102,7 +102,7 @@ public:
/**
* Create a numbering system using the specified radix, type, and description.
* @param radix The radix (base) for this numbering system.
- * @param isAlgorithmic TRUE if the numbering system is algorithmic rather than numeric.
+ * @param isAlgorithmic true if the numbering system is algorithmic rather than numeric.
* @param description The string representing the set of digits used in a numeric system, or the name of the RBNF
* ruleset to be used in an algorithmic system.
* @param status ICU status
@@ -171,10 +171,10 @@ public:
/**
- * Returns TRUE if the given numbering system is algorithmic
+ * Returns true if the given numbering system is algorithmic
*
- * @return TRUE if the numbering system is algorithmic.
- * Otherwise, return FALSE.
+ * @return true if the numbering system is algorithmic.
+ * Otherwise, return false.
* @stable ICU 4.2
*/
UBool isAlgorithmic() const;
diff --git a/deps/icu-small/source/i18n/unicode/plurfmt.h b/deps/icu-small/source/i18n/unicode/plurfmt.h
index 7373476dca..fde2abcfae 100644
--- a/deps/icu-small/source/i18n/unicode/plurfmt.h
+++ b/deps/icu-small/source/i18n/unicode/plurfmt.h
@@ -587,7 +587,7 @@ private:
*/
static int32_t findSubMessage(
const MessagePattern& pattern, int32_t partIndex,
- const PluralSelector& selector, void *context, double number, UErrorCode& ec); /**< @internal */
+ const PluralSelector& selector, void *context, double number, UErrorCode& ec);
void parseType(const UnicodeString& source, const NFRule *rbnfLenientScanner,
Formattable& result, FieldPosition& pos) const;
diff --git a/deps/icu-small/source/i18n/unicode/plurrule.h b/deps/icu-small/source/i18n/unicode/plurrule.h
index 408efbcc4a..19956cd32c 100644
--- a/deps/icu-small/source/i18n/unicode/plurrule.h
+++ b/deps/icu-small/source/i18n/unicode/plurrule.h
@@ -46,14 +46,20 @@ U_NAMESPACE_BEGIN
class Hashtable;
class IFixedDecimal;
+class FixedDecimal;
class RuleChain;
class PluralRuleParser;
class PluralKeywordEnumeration;
class AndConstraint;
class SharedPluralRules;
+class StandardPluralRanges;
namespace number {
class FormattedNumber;
+class FormattedNumberRange;
+namespace impl {
+class UFormattedNumberRangeData;
+}
}
/**
@@ -367,11 +373,35 @@ public:
*/
UnicodeString select(const number::FormattedNumber& number, UErrorCode& status) const;
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Given a formatted number range, returns the overall plural form of the
+ * range. For example, "3-5" returns "other" in English.
+ *
+ * To get a FormattedNumberRange, see NumberRangeFormatter.
+ *
+ * This method only works if PluralRules was created with a locale. If it was created
+ * from PluralRules::createRules(), this method sets status code U_UNSUPPORTED_ERROR.
+ *
+ * @param range The number range onto which the rules will be applied.
+ * @param status Set if an error occurs while selecting plural keyword.
+ * This could happen if the FormattedNumberRange is invalid,
+ * or if plural ranges data is unavailable.
+ * @return The keyword of the selected rule.
+ * @draft ICU 68
+ */
+ UnicodeString select(const number::FormattedNumberRange& range, UErrorCode& status) const;
+#endif // U_HIDE_DRAFT_API
+
#ifndef U_HIDE_INTERNAL_API
/**
- * @internal
- */
+ * @internal
+ */
UnicodeString select(const IFixedDecimal &number) const;
+ /**
+ * @internal
+ */
+ UnicodeString select(const number::impl::UFormattedNumberRangeData* urange, UErrorCode& status) const;
#endif /* U_HIDE_INTERNAL_API */
/**
@@ -446,13 +476,39 @@ public:
double *dest, int32_t destCapacity,
UErrorCode& status);
+#ifndef U_HIDE_INTERNAL_API
+ /**
+ * Internal-only function that returns FixedDecimals instead of doubles.
+ *
+ * Returns sample values for which select() would return the keyword. If
+ * the keyword is unknown, returns no values, but this is not an error.
+ *
+ * The number of returned values is typically small.
+ *
+ * @param keyword The keyword.
+ * @param dest Array into which to put the returned values. May
+ * be NULL if destCapacity is 0.
+ * @param destCapacity The capacity of the array, must be at least 0.
+ * @param status The error code.
+ * @return The count of values written.
+ * If more than destCapacity samples are available, then
+ * only destCapacity are written, and destCapacity is returned as the count,
+ * rather than setting a U_BUFFER_OVERFLOW_ERROR.
+ * (The actual number of keyword values could be unlimited.)
+ * @internal
+ */
+ int32_t getSamples(const UnicodeString &keyword,
+ FixedDecimal *dest, int32_t destCapacity,
+ UErrorCode& status);
+#endif /* U_HIDE_INTERNAL_API */
+
/**
- * Returns TRUE if the given keyword is defined in this
+ * Returns true if the given keyword is defined in this
* <code>PluralRules</code> object.
*
* @param keyword the input keyword.
- * @return TRUE if the input keyword is defined.
- * Otherwise, return FALSE.
+ * @return true if the input keyword is defined.
+ * Otherwise, return false.
* @stable ICU 4.0
*/
UBool isKeyword(const UnicodeString& keyword) const;
@@ -513,12 +569,14 @@ public:
private:
RuleChain *mRules;
+ StandardPluralRanges *mStandardPluralRanges;
PluralRules(); // default constructor not implemented
void parseDescription(const UnicodeString& ruleData, UErrorCode &status);
int32_t getNumberValue(const UnicodeString& token) const;
UnicodeString getRuleFromResource(const Locale& locale, UPluralType type, UErrorCode& status);
RuleChain *rulesForKeyword(const UnicodeString &keyword) const;
+ PluralRules *clone(UErrorCode& status) const;
/**
* An internal status variable used to indicate that the object is in an 'invalid' state.
diff --git a/deps/icu-small/source/i18n/unicode/rbnf.h b/deps/icu-small/source/i18n/unicode/rbnf.h
index 1144bd2fb8..13bb7385b1 100644
--- a/deps/icu-small/source/i18n/unicode/rbnf.h
+++ b/deps/icu-small/source/i18n/unicode/rbnf.h
@@ -297,7 +297,7 @@ enum URBNFRuleSetTag {
* </tr>
* <tr>
* <td>x.0:</td>
- * <td>The rule is a <em>master rule</em>. If the full stop in
+ * <td>The rule is a <em>default rule</em>. If the full stop in
* the middle of the rule name is replaced with the decimal point
* that is used in the language or DecimalFormatSymbols, then that rule will
* have precedence when formatting and parsing this rule. For example, some
@@ -332,9 +332,9 @@ enum URBNFRuleSetTag {
* algorithms: If the rule set is a regular rule set, do the following:
*
* <ul>
- * <li>If the rule set includes a master rule (and the number was passed in as a <tt>double</tt>),
- * use the master rule.&nbsp; (If the number being formatted was passed in as a <tt>long</tt>,
- * the master rule is ignored.)</li>
+ * <li>If the rule set includes a default rule (and the number was passed in as a <tt>double</tt>),
+ * use the default rule.&nbsp; (If the number being formatted was passed in as a <tt>long</tt>,
+ * the default rule is ignored.)</li>
* <li>If the number is negative, use the negative-number rule.</li>
* <li>If the number has a fractional part and is greater than 1, use the improper fraction
* rule.</li>
@@ -393,7 +393,7 @@ enum URBNFRuleSetTag {
* </tr>
* <tr>
* <td></td>
- * <td>in fraction or master rule</td>
+ * <td>in fraction or default rule</td>
* <td>Isolate the number's fractional part and format it.</td>
* </tr>
* <tr>
@@ -425,7 +425,7 @@ enum URBNFRuleSetTag {
* </tr>
* <tr>
* <td></td>
- * <td>in fraction or master rule</td>
+ * <td>in fraction or default rule</td>
* <td>Isolate the number's integral part and format it.</td>
* </tr>
* <tr>
@@ -456,7 +456,7 @@ enum URBNFRuleSetTag {
* </tr>
* <tr>
* <td></td>
- * <td>in master rule</td>
+ * <td>in default rule</td>
* <td>Omit the optional text if the number is an integer (same as specifying both an x.x
* rule and an x.0 rule)</td>
* </tr>
diff --git a/deps/icu-small/source/i18n/unicode/rbtz.h b/deps/icu-small/source/i18n/unicode/rbtz.h
index 95fd7ab85d..f7b45fb8ed 100644
--- a/deps/icu-small/source/i18n/unicode/rbtz.h
+++ b/deps/icu-small/source/i18n/unicode/rbtz.h
@@ -258,7 +258,7 @@ public:
* @param base The base time.
* @param inclusive Whether the base time is inclusive or not.
* @param result Receives the first transition after the base time.
- * @return TRUE if the transition is found.
+ * @return true if the transition is found.
* @stable ICU 3.8
*/
virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const;
@@ -268,7 +268,7 @@ public:
* @param base The base time.
* @param inclusive Whether the base time is inclusive or not.
* @param result Receives the most recent transition before the base time.
- * @return TRUE if the transition is found.
+ * @return true if the transition is found.
* @stable ICU 3.8
*/
virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const;
diff --git a/deps/icu-small/source/i18n/unicode/regex.h b/deps/icu-small/source/i18n/unicode/regex.h
index 2f8d31d97f..8ee74c3903 100644
--- a/deps/icu-small/source/i18n/unicode/regex.h
+++ b/deps/icu-small/source/i18n/unicode/regex.h
@@ -116,7 +116,7 @@ public:
* were constructed from identical source patterns using the same #URegexpFlag
* settings.
* @param that a RegexPattern object to compare with "this".
- * @return TRUE if the objects are equivalent.
+ * @return true if the objects are equivalent.
* @stable ICU 2.4
*/
UBool operator==(const RegexPattern& that) const;
@@ -126,7 +126,7 @@ public:
* were constructed from identical source patterns using the same #URegexpFlag
* settings.
* @param that a RegexPattern object to compare with "this".
- * @return TRUE if the objects are different.
+ * @return true if the objects are different.
* @stable ICU 2.4
*/
inline UBool operator!=(const RegexPattern& that) const {return ! operator ==(that);}
@@ -764,7 +764,7 @@ public:
/**
* Attempts to match the entire input region against the pattern.
* @param status A reference to a UErrorCode to receive any errors.
- * @return TRUE if there is a match
+ * @return true if there is a match
* @stable ICU 2.4
*/
virtual UBool matches(UErrorCode &status);
@@ -777,7 +777,7 @@ public:
* A successful match must extend to the end of the input.
* @param startIndex The input string (native) index at which to begin matching.
* @param status A reference to a UErrorCode to receive any errors.
- * @return TRUE if there is a match
+ * @return true if there is a match
* @stable ICU 2.8
*/
virtual UBool matches(int64_t startIndex, UErrorCode &status);
@@ -793,7 +793,7 @@ public:
* end(), and group() functions.
*
* @param status A reference to a UErrorCode to receive any errors.
- * @return TRUE if there is a match at the start of the input string.
+ * @return true if there is a match at the start of the input string.
* @stable ICU 2.4
*/
virtual UBool lookingAt(UErrorCode &status);
@@ -809,7 +809,7 @@ public:
*
* @param startIndex The input string (native) index at which to begin matching.
* @param status A reference to a UErrorCode to receive any errors.
- * @return TRUE if there is a match.
+ * @return true if there is a match.
* @stable ICU 2.8
*/
virtual UBool lookingAt(int64_t startIndex, UErrorCode &status);
@@ -824,7 +824,7 @@ public:
* Note that if the input string is changed by the application,
* use find(startPos, status) instead of find(), because the saved starting
* position may not be valid with the altered input string.
- * @return TRUE if a match is found.
+ * @return true if a match is found.
* @stable ICU 2.4
*/
virtual UBool find();
@@ -841,7 +841,7 @@ public:
* use find(startPos, status) instead of find(), because the saved starting
* position may not be valid with the altered input string.
* @param status A reference to a UErrorCode to receive any errors.
- * @return TRUE if a match is found.
+ * @return true if a match is found.
* @stable ICU 55
*/
virtual UBool find(UErrorCode &status);
@@ -852,7 +852,7 @@ public:
*
* @param start The (native) index in the input string to begin the search.
* @param status A reference to a UErrorCode to receive any errors.
- * @return TRUE if a match is found.
+ * @return true if a match is found.
* @stable ICU 2.4
*/
virtual UBool find(int64_t start, UErrorCode &status);
@@ -1271,7 +1271,7 @@ public:
* See useTransparentBounds for a description of transparent and opaque bounds.
* By default, a matcher uses opaque region boundaries.
*
- * @return TRUE if this matcher is using opaque bounds, false if it is not.
+ * @return true if this matcher is using opaque bounds, false if it is not.
* @stable ICU 4.0
*/
virtual UBool hasTransparentBounds() const;
@@ -1290,7 +1290,7 @@ public:
*
* By default, a matcher uses opaque bounds.
*
- * @param b TRUE for transparent bounds; FALSE for opaque bounds
+ * @param b true for transparent bounds; false for opaque bounds
* @return This Matcher;
* @stable ICU 4.0
**/
@@ -1301,7 +1301,7 @@ public:
* Return true if this matcher is using anchoring bounds.
* By default, matchers use anchoring region bounds.
*
- * @return TRUE if this matcher is using anchoring bounds.
+ * @return true if this matcher is using anchoring bounds.
* @stable ICU 4.0
*/
virtual UBool hasAnchoringBounds() const;
@@ -1315,7 +1315,7 @@ public:
*
* Anchoring Bounds are the default for regions.
*
- * @param b TRUE if to enable anchoring bounds; FALSE to disable them.
+ * @param b true if to enable anchoring bounds; false to disable them.
* @return This Matcher
* @stable ICU 4.0
*/
@@ -1323,26 +1323,26 @@ public:
/**
- * Return TRUE if the most recent matching operation attempted to access
+ * Return true if the most recent matching operation attempted to access
* additional input beyond the available input text.
* In this case, additional input text could change the results of the match.
*
* hitEnd() is defined for both successful and unsuccessful matches.
- * In either case hitEnd() will return TRUE if if the end of the text was
+ * In either case hitEnd() will return true if if the end of the text was
* reached at any point during the matching process.
*
- * @return TRUE if the most recent match hit the end of input
+ * @return true if the most recent match hit the end of input
* @stable ICU 4.0
*/
virtual UBool hitEnd() const;
/**
- * Return TRUE the most recent match succeeded and additional input could cause
+ * Return true the most recent match succeeded and additional input could cause
* it to fail. If this method returns false and a match was found, then more input
* might change the match but the match won't be lost. If a match was not found,
* then requireEnd has no meaning.
*
- * @return TRUE if more input could cause the most recent match to no longer match.
+ * @return true if more input could cause the most recent match to no longer match.
* @stable ICU 4.0
*/
virtual UBool requireEnd() const;
@@ -1781,7 +1781,7 @@ private:
inline REStackFrame *StateSave(REStackFrame *fp, int64_t savePatIdx, UErrorCode &status);
void IncrementTime(UErrorCode &status);
- // Call user find callback function, if set. Return TRUE if operation should be interrupted.
+ // Call user find callback function, if set. Return true if operation should be interrupted.
inline UBool findProgressInterrupt(int64_t matchIndex, UErrorCode &status);
int64_t appendGroup(int32_t groupNum, UText *dest, UErrorCode &status) const;
diff --git a/deps/icu-small/source/i18n/unicode/reldatefmt.h b/deps/icu-small/source/i18n/unicode/reldatefmt.h
index a991bc7986..f3feeead87 100644
--- a/deps/icu-small/source/i18n/unicode/reldatefmt.h
+++ b/deps/icu-small/source/i18n/unicode/reldatefmt.h
@@ -175,19 +175,17 @@ typedef enum UDateAbsoluteUnit {
*/
UDAT_ABSOLUTE_QUARTER,
-#ifndef U_HIDE_DRAFT_API
/**
* Hour
- * @draft ICU 65
+ * @stable ICU 65
*/
UDAT_ABSOLUTE_HOUR,
/**
* Minute
- * @draft ICU 65
+ * @stable ICU 65
*/
UDAT_ABSOLUTE_MINUTE,
-#endif // U_HIDE_DRAFT_API
#ifndef U_HIDE_DEPRECATED_API
/**
diff --git a/deps/icu-small/source/i18n/unicode/search.h b/deps/icu-small/source/i18n/unicode/search.h
index 986205c62f..3074839b5f 100644
--- a/deps/icu-small/source/i18n/unicode/search.h
+++ b/deps/icu-small/source/i18n/unicode/search.h
@@ -267,9 +267,9 @@ public:
/**
* Equality operator.
* @param that SearchIterator instance to be compared.
- * @return TRUE if both BreakIterators are of the same class, have the
+ * @return true if both BreakIterators are of the same class, have the
* same behavior, terates over the same text and have the same
- * attributes. FALSE otherwise.
+ * attributes. false otherwise.
* @stable ICU 2.0
*/
virtual UBool operator==(const SearchIterator &that) const;
@@ -277,7 +277,7 @@ public:
/**
* Not-equal operator.
* @param that SearchIterator instance to be compared.
- * @return FALSE if operator== returns TRUE, and vice versa.
+ * @return false if operator== returns true, and vice versa.
* @stable ICU 2.0
*/
UBool operator!=(const SearchIterator &that) const;
diff --git a/deps/icu-small/source/i18n/unicode/simpletz.h b/deps/icu-small/source/i18n/unicode/simpletz.h
index d7d4123187..8e5a877dab 100644
--- a/deps/icu-small/source/i18n/unicode/simpletz.h
+++ b/deps/icu-small/source/i18n/unicode/simpletz.h
@@ -714,7 +714,7 @@ public:
* @param base The base time.
* @param inclusive Whether the base time is inclusive or not.
* @param result Receives the first transition after the base time.
- * @return TRUE if the transition is found.
+ * @return true if the transition is found.
* @stable ICU 3.8
*/
virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const;
@@ -724,7 +724,7 @@ public:
* @param base The base time.
* @param inclusive Whether the base time is inclusive or not.
* @param result Receives the most recent transition before the base time.
- * @return TRUE if the transition is found.
+ * @return true if the transition is found.
* @stable ICU 3.8
*/
virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const;
diff --git a/deps/icu-small/source/i18n/unicode/smpdtfmt.h b/deps/icu-small/source/i18n/unicode/smpdtfmt.h
index b4b0e5fb39..3296c6b3ab 100644
--- a/deps/icu-small/source/i18n/unicode/smpdtfmt.h
+++ b/deps/icu-small/source/i18n/unicode/smpdtfmt.h
@@ -81,7 +81,7 @@ class LocalizedNumberFormatter;
* the date and time formatting algorithm and pattern letters defined by
* <a href="http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table">UTS#35
* Unicode Locale Data Markup Language (LDML)</a> and further documented for ICU in the
- * <a href="https://sites.google.com/site/icuprojectuserguide/formatparse/datetime?pli=1#TOC-Date-Field-Symbol-Table">ICU
+ * <a href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#date-field-symbol-table">ICU
* User Guide</a>. The following pattern letters are currently available (note that the actual
* values depend on CLDR and may change from the examples shown here):</p>
*
@@ -1183,11 +1183,11 @@ public:
/**
* This is for ICU internal use only. Please do not use.
* Check whether the 'field' is smaller than all the fields covered in
- * pattern, return TRUE if it is. The sequence of calendar field,
+ * pattern, return true if it is. The sequence of calendar field,
* from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,...
* @param field the calendar field need to check against
- * @return TRUE if the 'field' is smaller than all the fields
- * covered in pattern. FALSE otherwise.
+ * @return true if the 'field' is smaller than all the fields
+ * covered in pattern. false otherwise.
* @internal ICU 4.0
*/
UBool isFieldUnitIgnored(UCalendarDateFields field) const;
@@ -1196,12 +1196,12 @@ public:
/**
* This is for ICU internal use only. Please do not use.
* Check whether the 'field' is smaller than all the fields covered in
- * pattern, return TRUE if it is. The sequence of calendar field,
+ * pattern, return true if it is. The sequence of calendar field,
* from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,...
* @param pattern the pattern to check against
* @param field the calendar field need to check against
- * @return TRUE if the 'field' is smaller than all the fields
- * covered in pattern. FALSE otherwise.
+ * @return true if the 'field' is smaller than all the fields
+ * covered in pattern. false otherwise.
* @internal ICU 4.0
*/
static UBool isFieldUnitIgnored(const UnicodeString& pattern,
@@ -1305,12 +1305,12 @@ private:
static UBool isNumeric(char16_t formatChar, int32_t count);
/**
- * Returns TRUE if the patternOffset is at the start of a numeric field.
+ * Returns true if the patternOffset is at the start of a numeric field.
*/
static UBool isAtNumericField(const UnicodeString &pattern, int32_t patternOffset);
/**
- * Returns TRUE if the patternOffset is right after a non-numeric field.
+ * Returns true if the patternOffset is right after a non-numeric field.
*/
static UBool isAfterNonNumericField(const UnicodeString &pattern, int32_t patternOffset);
@@ -1390,11 +1390,11 @@ private:
* @param text the text being parsed
* @param textOffset the starting offset into the text. On output
* will be set to the offset of the character after the match
- * @param whitespaceLenient <code>TRUE</code> if whitespace parse is lenient, <code>FALSE</code> otherwise.
- * @param partialMatchLenient <code>TRUE</code> if partial match parse is lenient, <code>FALSE</code> otherwise.
- * @param oldLeniency <code>TRUE</code> if old leniency control is lenient, <code>FALSE</code> otherwise.
+ * @param whitespaceLenient <code>true</code> if whitespace parse is lenient, <code>false</code> otherwise.
+ * @param partialMatchLenient <code>true</code> if partial match parse is lenient, <code>false</code> otherwise.
+ * @param oldLeniency <code>true</code> if old leniency control is lenient, <code>false</code> otherwise.
*
- * @return <code>TRUE</code> if the literal text could be matched, <code>FALSE</code> otherwise.
+ * @return <code>true</code> if the literal text could be matched, <code>false</code> otherwise.
*/
static UBool matchLiterals(const UnicodeString &pattern, int32_t &patternOffset,
const UnicodeString &text, int32_t &textOffset,
diff --git a/deps/icu-small/source/i18n/unicode/sortkey.h b/deps/icu-small/source/i18n/unicode/sortkey.h
index d2d3ca9fd5..14902668a2 100644
--- a/deps/icu-small/source/i18n/unicode/sortkey.h
+++ b/deps/icu-small/source/i18n/unicode/sortkey.h
@@ -150,7 +150,7 @@ public:
/**
* Compare if two collation keys are not the same.
* @param source the collation key to compare to.
- * @return Returns TRUE if two collation keys are different, FALSE otherwise.
+ * @return Returns true if two collation keys are different, false otherwise.
* @stable ICU 2.0
*/
UBool operator!=(const CollationKey& source) const;
@@ -159,7 +159,7 @@ public:
/**
* Test to see if the key is in an invalid state. The key will be in an
* invalid state if it couldn't allocate memory for some operation.
- * @return Returns TRUE if the key is in an invalid, FALSE otherwise.
+ * @return Returns true if the key is in an invalid, false otherwise.
* @stable ICU 2.0
*/
UBool isBogus(void) const;
diff --git a/deps/icu-small/source/i18n/unicode/stsearch.h b/deps/icu-small/source/i18n/unicode/stsearch.h
index f396371143..3cfd68d647 100644
--- a/deps/icu-small/source/i18n/unicode/stsearch.h
+++ b/deps/icu-small/source/i18n/unicode/stsearch.h
@@ -292,7 +292,7 @@ public:
/**
* Equality operator.
* @param that instance to be compared.
- * @return TRUE if both instances have the same attributes,
+ * @return true if both instances have the same attributes,
* breakiterators, collators and iterate over the same text
* while looking for the same pattern.
* @stable ICU 2.0
diff --git a/deps/icu-small/source/i18n/unicode/tblcoll.h b/deps/icu-small/source/i18n/unicode/tblcoll.h
index f5dc135bc4..a004dd6644 100644
--- a/deps/icu-small/source/i18n/unicode/tblcoll.h
+++ b/deps/icu-small/source/i18n/unicode/tblcoll.h
@@ -99,14 +99,14 @@ class UVector64;
* table-based collation.
* <p>
* For more information about the collation service see
- * <a href="http://userguide.icu-project.org/collation">the User Guide</a>.
+ * <a href="https://unicode-org.github.io/icu/userguide/collation">the User Guide</a>.
* <p>
* Collation service provides correct sorting orders for most locales supported in ICU.
* If specific data for a locale is not available, the orders eventually falls back
* to the <a href="http://www.unicode.org/reports/tr35/tr35-collation.html#Root_Collation">CLDR root sort order</a>.
* <p>
* Sort ordering may be customized by providing your own set of rules. For more on
- * this subject see the <a href="http://userguide.icu-project.org/collation/customization">
+ * this subject see the <a href="https://unicode-org.github.io/icu/userguide/collation/customization">
* Collation Customization</a> section of the User Guide.
* <p>
* Note, RuleBasedCollator is not to be subclassed.
@@ -495,7 +495,7 @@ public:
* just the tailoring.
*
* getRules(void) should normally be used instead.
- * See http://userguide.icu-project.org/collation/customization#TOC-Building-on-Existing-Locales
+ * See https://unicode-org.github.io/icu/userguide/collation/customization#building-on-existing-locales
* @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES.
* @param buffer UnicodeString to store the result rules
* @stable ICU 2.2
@@ -702,7 +702,7 @@ public:
* This string will be normalized.
* The structure and the syntax of the string is defined in the "Naming collators"
* section of the users guide:
- * http://userguide.icu-project.org/collation/concepts#TOC-Collator-naming-scheme
+ * https://unicode-org.github.io/icu/userguide/collation/concepts#collator-naming-scheme
* This function supports preflighting.
*
* This is internal, and intended to be used with delegate converters.
@@ -752,7 +752,7 @@ public:
* Implements ucol_getContractionsAndExpansions().
* Gets this collator's sets of contraction strings and/or
* characters and strings that map to multiple collation elements (expansions).
- * If addPrefixes is TRUE, then contractions that are expressed as
+ * If addPrefixes is true, then contractions that are expressed as
* prefix/pre-context rules are included.
* @param contractions if not NULL, the set to hold the contractions
* @param expansions if not NULL, the set to hold the expansions
@@ -857,7 +857,7 @@ private:
* Tests whether a character is "unsafe" for use as a collation starting point.
*
* @param c code point or code unit
- * @return TRUE if c is unsafe
+ * @return true if c is unsafe
* @see CollationElementIterator#setOffset(int)
*/
UBool isUnsafe(UChar32 c) const;
diff --git a/deps/icu-small/source/i18n/unicode/timezone.h b/deps/icu-small/source/i18n/unicode/timezone.h
index 4d321186be..73cae44d53 100644
--- a/deps/icu-small/source/i18n/unicode/timezone.h
+++ b/deps/icu-small/source/i18n/unicode/timezone.h
@@ -317,6 +317,19 @@ public:
*/
static TimeZone* U_EXPORT2 createDefault(void);
+#ifndef U_HIDE_INTERNAL_API
+ /**
+ * If the locale contains the timezone keyword, creates a copy of that TimeZone.
+ * Otherwise, create the default timezone.
+ *
+ * @param locale a locale which may contains 'timezone' keyword/value.
+ * @return A TimeZone. Clients are responsible for deleting the time zone
+ * object returned.
+ * @internal
+ */
+ static TimeZone* U_EXPORT2 forLocaleOrDefault(const Locale& locale);
+#endif /* U_HIDE_INTERNAL_API */
+
/**
* Sets the default time zone (i.e., what's returned by createDefault()) to be the
* specified time zone. If NULL is specified for the time zone, the default time
@@ -392,7 +405,7 @@ public:
*
* <p>This implementation utilizes <a href="http://unicode.org/cldr/charts/supplemental/zone_tzid.html">
* Zone-Tzid mapping data</a>. The mapping data is updated time to time. To get the latest changes,
- * please read the ICU user guide section <a href="http://userguide.icu-project.org/datetime/timezone#TOC-Updating-the-Time-Zone-Data">
+ * please read the ICU user guide section <a href="https://unicode-org.github.io/icu/userguide/datetime/timezone#updating-the-time-zone-data">
* Updating the Time Zone Data</a>.
*
* @param id A system time zone ID.
@@ -420,7 +433,7 @@ public:
*
* <p>This implementation utilizes <a href="http://unicode.org/cldr/charts/supplemental/zone_tzid.html">
* Zone-Tzid mapping data</a>. The mapping data is updated time to time. To get the latest changes,
- * please read the ICU user guide section <a href="http://userguide.icu-project.org/datetime/timezone#TOC-Updating-the-Time-Zone-Data">
+ * please read the ICU user guide section <a href="https://unicode-org.github.io/icu/userguide/datetime/timezone#updating-the-time-zone-data">
* Updating the Time Zone Data</a>.
*
* @param winid A Windows time zone ID.
@@ -696,8 +709,8 @@ public:
* there are time zones that used daylight savings time in the
* past, but no longer used currently. For example, Asia/Tokyo has
* never used daylight savings time since 1951. Most clients would
- * expect that this method to return <code>FALSE</code> for such case.
- * The default implementation of this method returns <code>TRUE</code>
+ * expect that this method to return <code>false</code> for such case.
+ * The default implementation of this method returns <code>true</code>
* when the time zone uses daylight savings time in the current
* (Gregorian) calendar year.
* <p>In Java 7, <code>observesDaylightTime()</code> was added in
@@ -914,7 +927,7 @@ private:
* @param hour Receives parsed hour field
* @param minute Receives parsed minute field
* @param second Receives parsed second field
- * @return Returns TRUE when the given custom id is valid.
+ * @return Returns true when the given custom id is valid.
*/
static UBool parseCustomID(const UnicodeString& id, int32_t& sign, int32_t& hour,
int32_t& minute, int32_t& second);
@@ -937,7 +950,7 @@ private:
* @param hour offset hours
* @param min offset minutes
* @param sec offset seconds
- * @param negative sign of the offset, TRUE for negative offset.
+ * @param negative sign of the offset, true for negative offset.
* @param id Receves the format result (normalized custom ID)
* @return The reference to id
*/
diff --git a/deps/icu-small/source/i18n/unicode/tmutamt.h b/deps/icu-small/source/i18n/unicode/tmutamt.h
index 5ce5922cea..bb9144e2d0 100644
--- a/deps/icu-small/source/i18n/unicode/tmutamt.h
+++ b/deps/icu-small/source/i18n/unicode/tmutamt.h
@@ -39,7 +39,7 @@ public:
/**
* Construct TimeUnitAmount object with the given number and the
* given time unit.
- * @param number a numeric object; number.isNumeric() must be TRUE
+ * @param number a numeric object; number.isNumeric() must be true
* @param timeUnitField the time unit field of a time unit
* @param status the input-output error code.
* If the number is not numeric or the timeUnitField
diff --git a/deps/icu-small/source/i18n/unicode/translit.h b/deps/icu-small/source/i18n/unicode/translit.h
index fe2568d50a..2aa02c39f1 100644
--- a/deps/icu-small/source/i18n/unicode/translit.h
+++ b/deps/icu-small/source/i18n/unicode/translit.h
@@ -882,7 +882,7 @@ public:
* another transliterator.
* @param text the text to be transliterated
* @param index the position indices
- * @param incremental if TRUE, then assume more characters may be inserted
+ * @param incremental if true, then assume more characters may be inserted
* at index.limit, and postpone processing to accomodate future incoming
* characters
* @stable ICU 2.4
@@ -897,14 +897,14 @@ private:
* Top-level transliteration method, handling filtering, incremental and
* non-incremental transliteration, and rollback. All transliteration
* public API methods eventually call this method with a rollback argument
- * of TRUE. Other entities may call this method but rollback should be
- * FALSE.
+ * of true. Other entities may call this method but rollback should be
+ * false.
*
* <p>If this transliterator has a filter, break up the input text into runs
* of unfiltered characters. Pass each run to
* subclass.handleTransliterate().
*
- * <p>In incremental mode, if rollback is TRUE, perform a special
+ * <p>In incremental mode, if rollback is true, perform a special
* incremental procedure in which several passes are made over the input
* text, adding one character at a time, and committing successful
* transliterations as they occur. Unsuccessful transliterations are rolled
@@ -912,12 +912,12 @@ private:
*
* @param text the text to be transliterated
* @param index the position indices
- * @param incremental if TRUE, then assume more characters may be inserted
+ * @param incremental if true, then assume more characters may be inserted
* at index.limit, and postpone processing to accomodate future incoming
* characters
- * @param rollback if TRUE and if incremental is TRUE, then perform special
+ * @param rollback if true and if incremental is true, then perform special
* incremental processing, as described above, and undo partial
- * transliterations where necessary. If incremental is FALSE then this
+ * transliterations where necessary. If incremental is false then this
* parameter is ignored.
*/
virtual void filteredTransliterate(Replaceable& text,
@@ -1119,7 +1119,7 @@ public:
* to recreate this transliterator.
* @param result the string to receive the rules. Previous
* contents will be deleted.
- * @param escapeUnprintable if TRUE then convert unprintable
+ * @param escapeUnprintable if true then convert unprintable
* character to their hex escape representations, \\uxxxx or
* \\Uxxxxxxxx. Unprintable characters are those other than
* U+000A, U+0020..U+007E.
diff --git a/deps/icu-small/source/i18n/unicode/tzfmt.h b/deps/icu-small/source/i18n/unicode/tzfmt.h
index 6d3863b1e5..4411865984 100644
--- a/deps/icu-small/source/i18n/unicode/tzfmt.h
+++ b/deps/icu-small/source/i18n/unicode/tzfmt.h
@@ -295,7 +295,7 @@ public:
* Return true if the given Format objects are semantically equal.
* Objects of different subclasses are considered unequal.
* @param other The object to be compared with.
- * @return Return TRUE if the given Format objects are semantically equal.
+ * @return Return true if the given Format objects are semantically equal.
* Objects of different subclasses are considered unequal.
* @stable ICU 50
*/
@@ -814,7 +814,7 @@ private:
* @param str the string
* @param codeArray receives the result
* @param capacity the capacity of codeArray
- * @return TRUE when the specified code array is fully filled with code points
+ * @return true when the specified code array is fully filled with code points
* (no under/overflow).
*/
static UBool toCodePoints(const UnicodeString& str, UChar32* codeArray, int32_t capacity);
@@ -849,8 +849,8 @@ private:
* @param text the text contains ISO 8601 style time zone string (e.g. "-08:00", "Z")
* at the position.
* @param pos the position, non-negative error index will be set on failure.
- * @param extendedOnly TRUE if parsing the text as ISO 8601 extended offset format (e.g. "-08:00"),
- * or FALSE to evaluate the text as basic format.
+ * @param extendedOnly true if parsing the text as ISO 8601 extended offset format (e.g. "-08:00"),
+ * or false to evaluate the text as basic format.
* @param hasDigitOffset receiving if the parsed zone string contains offset digits.
* @return the offset from GMT(UTC) in milliseconds for the given ISO 8601 style
* time zone string.
diff --git a/deps/icu-small/source/i18n/unicode/tznames.h b/deps/icu-small/source/i18n/unicode/tznames.h
index 860494221d..2e20eff608 100644
--- a/deps/icu-small/source/i18n/unicode/tznames.h
+++ b/deps/icu-small/source/i18n/unicode/tznames.h
@@ -139,7 +139,7 @@ public:
/**
* Return true if the given TimeZoneNames objects are semantically equal.
* @param other the object to be compared with.
- * @return Return TRUE if the given Format objects are semantically equal.
+ * @return Return true if the given Format objects are semantically equal.
* @stable ICU 50
*/
virtual UBool operator==(const TimeZoneNames& other) const = 0;
@@ -148,7 +148,7 @@ public:
* Return true if the given TimeZoneNames objects are not semantically
* equal.
* @param other the object to be compared with.
- * @return Return TRUE if the given Format objects are not semantically equal.
+ * @return Return true if the given Format objects are not semantically equal.
* @stable ICU 50
*/
UBool operator!=(const TimeZoneNames& other) const { return !operator==(other); }
@@ -373,7 +373,7 @@ public:
* Gets the zone ID of a match at the specified index.
* @param idx The index
* @param tzID Receives the zone ID.
- * @return TRUE if the zone ID was set to tzID.
+ * @return true if the zone ID was set to tzID.
* @internal
*/
UBool getTimeZoneIDAt(int32_t idx, UnicodeString& tzID) const;
@@ -382,7 +382,7 @@ public:
* Gets the metazone ID of a match at the specified index.
* @param idx The index
* @param mzID Receives the metazone ID
- * @return TRUE if the meta zone ID was set to mzID.
+ * @return true if the meta zone ID was set to mzID.
* @internal
*/
UBool getMetaZoneIDAt(int32_t idx, UnicodeString& mzID) const;
diff --git a/deps/icu-small/source/i18n/unicode/ucal.h b/deps/icu-small/source/i18n/unicode/ucal.h
index eee2ae9e22..d491f5d610 100644
--- a/deps/icu-small/source/i18n/unicode/ucal.h
+++ b/deps/icu-small/source/i18n/unicode/ucal.h
@@ -13,7 +13,10 @@
#include "unicode/utypes.h"
#include "unicode/uenum.h"
#include "unicode/uloc.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_FORMATTING
@@ -32,7 +35,7 @@
*
* <p>
* Types of <code>UCalendar</code> interpret a <code>UDate</code>
- * according to the rules of a specific calendar system. The U_STABLE
+ * according to the rules of a specific calendar system. The C API
* provides the enum UCalendarType with UCAL_TRADITIONAL and
* UCAL_GREGORIAN.
* <p>
@@ -584,7 +587,7 @@ typedef enum USystemTimeZoneType USystemTimeZoneType;
* *ec will indicate the error.
* @stable ICU 4.8
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
ucal_openTimeZoneIDEnumeration(USystemTimeZoneType zoneType, const char* region,
const int32_t* rawOffset, UErrorCode* ec);
@@ -599,7 +602,7 @@ ucal_openTimeZoneIDEnumeration(USystemTimeZoneType zoneType, const char* region,
*
* @stable ICU 2.6
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
ucal_openTimeZones(UErrorCode* ec);
/**
@@ -618,7 +621,7 @@ ucal_openTimeZones(UErrorCode* ec);
*
* @stable ICU 2.6
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
ucal_openCountryTimeZones(const char* country, UErrorCode* ec);
/**
@@ -644,7 +647,7 @@ ucal_openCountryTimeZones(const char* country, UErrorCode* ec);
*
* @stable ICU 2.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec);
/**
@@ -656,11 +659,9 @@ ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec);
*
* @stable ICU 2.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec);
-#ifndef U_HIDE_DRAFT_API
-
/**
* Return the current host time zone. The host time zone is detected from
* the current host system configuration by querying the host operating
@@ -688,13 +689,11 @@ ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec);
*
* @see #UCAL_UNKNOWN_ZONE_ID
*
- * @draft ICU 65
+ * @stable ICU 65
*/
-U_DRAFT int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_getHostTimeZone(UChar *result, int32_t resultCapacity, UErrorCode *ec);
-#endif // U_HIDE_DRAFT_API
-
/**
* Return the amount of time in milliseconds that the clock is
* advanced during daylight savings time for the given time zone, or
@@ -711,7 +710,7 @@ ucal_getHostTimeZone(UChar *result, int32_t resultCapacity, UErrorCode *ec);
*
* @stable ICU 2.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec);
/**
@@ -720,7 +719,7 @@ ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec);
* @return The current date and time.
* @stable ICU 2.0
*/
-U_STABLE UDate U_EXPORT2
+U_CAPI UDate U_EXPORT2
ucal_getNow(void);
/**
@@ -746,7 +745,7 @@ ucal_getNow(void);
* @see #UCAL_UNKNOWN_ZONE_ID
* @stable ICU 2.0
*/
-U_STABLE UCalendar* U_EXPORT2
+U_CAPI UCalendar* U_EXPORT2
ucal_open(const UChar* zoneID,
int32_t len,
const char* locale,
@@ -759,7 +758,7 @@ ucal_open(const UChar* zoneID,
* @param cal The UCalendar to close.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucal_close(UCalendar *cal);
#if U_SHOW_CPLUSPLUS_API
@@ -789,7 +788,7 @@ U_NAMESPACE_END
* @return A pointer to a UCalendar identical to cal.
* @stable ICU 4.0
*/
-U_STABLE UCalendar* U_EXPORT2
+U_CAPI UCalendar* U_EXPORT2
ucal_clone(const UCalendar* cal,
UErrorCode* status);
@@ -802,7 +801,7 @@ ucal_clone(const UCalendar* cal,
* @param status A pointer to an UErrorCode to receive any errors.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucal_setTimeZone(UCalendar* cal,
const UChar* zoneID,
int32_t len,
@@ -818,7 +817,7 @@ ucal_setTimeZone(UCalendar* cal,
* @return The total buffer size needed; if greater than resultLength, the output was truncated.
* @stable ICU 51
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_getTimeZoneID(const UCalendar *cal,
UChar *result,
int32_t resultLength,
@@ -855,7 +854,7 @@ typedef enum UCalendarDisplayNameType UCalendarDisplayNameType;
* @return The total buffer size needed; if greater than resultLength, the output was truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_getTimeZoneDisplayName(const UCalendar* cal,
UCalendarDisplayNameType type,
const char* locale,
@@ -868,10 +867,10 @@ ucal_getTimeZoneDisplayName(const UCalendar* cal,
* Daylight savings time is not used in all parts of the world.
* @param cal The UCalendar to query.
* @param status A pointer to an UErrorCode to receive any errors
- * @return TRUE if cal is currently in daylight savings time, FALSE otherwise
+ * @return true if cal is currently in daylight savings time, false otherwise
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucal_inDaylightTime(const UCalendar* cal,
UErrorCode* status );
@@ -895,7 +894,7 @@ ucal_inDaylightTime(const UCalendar* cal,
* @see ucal_getGregorianChange
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucal_setGregorianChange(UCalendar *cal, UDate date, UErrorCode *pErrorCode);
/**
@@ -918,7 +917,7 @@ ucal_setGregorianChange(UCalendar *cal, UDate date, UErrorCode *pErrorCode);
* @see ucal_setGregorianChange
* @stable ICU 3.6
*/
-U_STABLE UDate U_EXPORT2
+U_CAPI UDate U_EXPORT2
ucal_getGregorianChange(const UCalendar *cal, UErrorCode *pErrorCode);
/**
@@ -999,7 +998,7 @@ typedef enum UCalendarWallTimeOption UCalendarWallTimeOption;
* @see ucal_setAttribute
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_getAttribute(const UCalendar* cal,
UCalendarAttribute attr);
@@ -1014,7 +1013,7 @@ ucal_getAttribute(const UCalendar* cal,
* @see ucal_getAttribute
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucal_setAttribute(UCalendar* cal,
UCalendarAttribute attr,
int32_t newValue);
@@ -1028,7 +1027,7 @@ ucal_setAttribute(UCalendar* cal,
* @see ucal_countAvailable
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ucal_getAvailable(int32_t localeIndex);
/**
@@ -1039,7 +1038,7 @@ ucal_getAvailable(int32_t localeIndex);
* @see ucal_getAvailable
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_countAvailable(void);
/**
@@ -1053,7 +1052,7 @@ ucal_countAvailable(void);
* @see ucal_setDateTime
* @stable ICU 2.0
*/
-U_STABLE UDate U_EXPORT2
+U_CAPI UDate U_EXPORT2
ucal_getMillis(const UCalendar* cal,
UErrorCode* status);
@@ -1068,7 +1067,7 @@ ucal_getMillis(const UCalendar* cal,
* @see ucal_setDateTime
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucal_setMillis(UCalendar* cal,
UDate dateTime,
UErrorCode* status );
@@ -1087,7 +1086,7 @@ ucal_setMillis(UCalendar* cal,
* @see ucal_setDateTime
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucal_setDate(UCalendar* cal,
int32_t year,
int32_t month,
@@ -1111,7 +1110,7 @@ ucal_setDate(UCalendar* cal,
* @see ucal_setDate
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucal_setDateTime(UCalendar* cal,
int32_t year,
int32_t month,
@@ -1122,15 +1121,15 @@ ucal_setDateTime(UCalendar* cal,
UErrorCode* status);
/**
- * Returns TRUE if two UCalendars are equivalent. Equivalent
+ * Returns true if two UCalendars are equivalent. Equivalent
* UCalendars will behave identically, but they may be set to
* different times.
* @param cal1 The first of the UCalendars to compare.
* @param cal2 The second of the UCalendars to compare.
- * @return TRUE if cal1 and cal2 are equivalent, FALSE otherwise.
+ * @return true if cal1 and cal2 are equivalent, false otherwise.
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucal_equivalentTo(const UCalendar* cal1,
const UCalendar* cal2);
@@ -1152,7 +1151,7 @@ ucal_equivalentTo(const UCalendar* cal1,
* @see ucal_roll
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucal_add(UCalendar* cal,
UCalendarDateFields field,
int32_t amount,
@@ -1182,7 +1181,7 @@ ucal_add(UCalendar* cal,
* @see ucal_add
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucal_roll(UCalendar* cal,
UCalendarDateFields field,
int32_t amount,
@@ -1204,7 +1203,7 @@ ucal_roll(UCalendar* cal,
* @see ucal_clear
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_get(const UCalendar* cal,
UCalendarDateFields field,
UErrorCode* status );
@@ -1224,7 +1223,7 @@ ucal_get(const UCalendar* cal,
* @see ucal_clear
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucal_set(UCalendar* cal,
UCalendarDateFields field,
int32_t value);
@@ -1237,14 +1236,14 @@ ucal_set(UCalendar* cal,
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
- * @return TRUE if field is set, FALSE otherwise.
+ * @return true if field is set, false otherwise.
* @see ucal_get
* @see ucal_set
* @see ucal_clearField
* @see ucal_clear
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucal_isSet(const UCalendar* cal,
UCalendarDateFields field);
@@ -1262,7 +1261,7 @@ ucal_isSet(const UCalendar* cal,
* @see ucal_clear
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucal_clearField(UCalendar* cal,
UCalendarDateFields field);
@@ -1276,7 +1275,7 @@ ucal_clearField(UCalendar* cal,
* @see ucal_clearField
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucal_clear(UCalendar* calendar);
/**
@@ -1315,7 +1314,7 @@ typedef enum UCalendarLimitType UCalendarLimitType;
* @return The requested value.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_getLimit(const UCalendar* cal,
UCalendarDateFields field,
UCalendarLimitType type,
@@ -1328,7 +1327,7 @@ ucal_getLimit(const UCalendar* cal,
* @return the locale name
* @stable ICU 2.8
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucal_getLocaleByType(const UCalendar *cal, ULocDataLocaleType type, UErrorCode* status);
/**
@@ -1337,7 +1336,7 @@ ucal_getLocaleByType(const UCalendar *cal, ULocDataLocaleType type, UErrorCode*
* @return the version string, such as "2007f"
* @stable ICU 3.8
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucal_getTZDataVersion(UErrorCode* status);
/**
@@ -1358,7 +1357,7 @@ ucal_getTZDataVersion(UErrorCode* status);
* null.
* @stable ICU 4.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_getCanonicalTimeZoneID(const UChar* id, int32_t len,
UChar* result, int32_t resultCapacity, UBool *isSystemID, UErrorCode* status);
/**
@@ -1368,7 +1367,7 @@ ucal_getCanonicalTimeZoneID(const UChar* id, int32_t len,
* @return The resource keyword value string.
* @stable ICU 4.2
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucal_getType(const UCalendar *cal, UErrorCode* status);
/**
@@ -1387,7 +1386,7 @@ ucal_getType(const UCalendar *cal, UErrorCode* status);
* @return a string enumeration over keyword values for the given key and the locale.
* @stable ICU 4.2
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
ucal_getKeywordValuesForLocale(const char* key,
const char* locale,
UBool commonlyUsed,
@@ -1442,7 +1441,7 @@ typedef enum UCalendarWeekdayType UCalendarWeekdayType;
* @return The UCalendarWeekdayType for the day of the week.
* @stable ICU 4.4
*/
-U_STABLE UCalendarWeekdayType U_EXPORT2
+U_CAPI UCalendarWeekdayType U_EXPORT2
ucal_getDayOfWeekType(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode* status);
/**
@@ -1460,20 +1459,20 @@ ucal_getDayOfWeekType(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErro
* @return The milliseconds after midnight at which the weekend begins or ends.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_getWeekendTransition(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode *status);
/**
- * Returns TRUE if the given UDate is in the weekend in
+ * Returns true if the given UDate is in the weekend in
* this calendar system.
* @param cal The UCalendar to query.
* @param date The UDate in question.
* @param status The error code for the operation.
- * @return TRUE if the given UDate is in the weekend in
- * this calendar system, FALSE otherwise.
+ * @return true if the given UDate is in the weekend in
+ * this calendar system, false otherwise.
* @stable ICU 4.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status);
/**
@@ -1500,7 +1499,7 @@ ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status);
* @return The date difference for the specified field.
* @stable ICU 4.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_getFieldDifference(UCalendar* cal,
UDate target,
UCalendarDateFields field,
@@ -1544,17 +1543,17 @@ typedef enum UTimeZoneTransitionType UTimeZoneTransitionType; /**< @stable ICU 5
* the calendar's current date, in the time zone to which the calendar
* is currently set. If there is no known time zone transition of the
* requested type relative to the calendar's date, the function returns
-* FALSE.
+* false.
* @param cal The UCalendar to query.
* @param type The type of transition desired.
* @param transition A pointer to a UDate to be set to the transition time.
-* If the function returns FALSE, the value set is unspecified.
+* If the function returns false, the value set is unspecified.
* @param status A pointer to a UErrorCode to receive any errors.
-* @return TRUE if a valid transition time is set in *transition, FALSE
+* @return true if a valid transition time is set in *transition, false
* otherwise.
* @stable ICU 50
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucal_getTimeZoneTransitionDate(const UCalendar* cal, UTimeZoneTransitionType type,
UDate* transition, UErrorCode* status);
@@ -1569,7 +1568,7 @@ ucal_getTimeZoneTransitionDate(const UCalendar* cal, UTimeZoneTransitionType typ
*
* <p>This implementation utilizes <a href="http://unicode.org/cldr/charts/supplemental/zone_tzid.html">
* Zone-Tzid mapping data</a>. The mapping data is updated time to time. To get the latest changes,
-* please read the ICU user guide section <a href="http://userguide.icu-project.org/datetime/timezone#TOC-Updating-the-Time-Zone-Data">
+* please read the ICU user guide section <a href="https://unicode-org.github.io/icu/userguide/datetime/timezone#updating-the-time-zone-data">
* Updating the Time Zone Data</a>.
*
* @param id A system time zone ID.
@@ -1582,7 +1581,7 @@ ucal_getTimeZoneTransitionDate(const UCalendar* cal, UTimeZoneTransitionType typ
*
* @stable ICU 52
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_getWindowsTimeZoneID(const UChar* id, int32_t len,
UChar* winid, int32_t winidCapacity, UErrorCode* status);
@@ -1600,7 +1599,7 @@ ucal_getWindowsTimeZoneID(const UChar* id, int32_t len,
*
* <p>This implementation utilizes <a href="http://unicode.org/cldr/charts/supplemental/zone_tzid.html">
* Zone-Tzid mapping data</a>. The mapping data is updated time to time. To get the latest changes,
-* please read the ICU user guide section <a href="http://userguide.icu-project.org/datetime/timezone#TOC-Updating-the-Time-Zone-Data">
+* please read the ICU user guide section <a href="https://unicode-org.github.io/icu/userguide/datetime/timezone#updating-the-time-zone-data">
* Updating the Time Zone Data</a>.
*
* @param winid A Windows time zone ID.
@@ -1614,7 +1613,7 @@ ucal_getWindowsTimeZoneID(const UChar* id, int32_t len,
*
* @stable ICU 52
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucal_getTimeZoneIDForWindowsID(const UChar* winid, int32_t len, const char* region,
UChar* id, int32_t idCapacity, UErrorCode* status);
diff --git a/deps/icu-small/source/i18n/unicode/ucol.h b/deps/icu-small/source/i18n/unicode/ucol.h
index 34b5d2476a..83774bc8ec 100644
--- a/deps/icu-small/source/i18n/unicode/ucol.h
+++ b/deps/icu-small/source/i18n/unicode/ucol.h
@@ -15,12 +15,15 @@
#if !UCONFIG_NO_COLLATION
#include "unicode/unorm.h"
-#include "unicode/localpointer.h"
#include "unicode/parseerr.h"
#include "unicode/uloc.h"
#include "unicode/uset.h"
#include "unicode/uscript.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* \file
* \brief C API: Collator
@@ -32,14 +35,14 @@
* searching and sorting routines for natural language text.
* <p>
* For more information about the collation service see
- * <a href="http://userguide.icu-project.org/collation">the User Guide</a>.
+ * <a href="https://unicode-org.github.io/icu/userguide/collation">the User Guide</a>.
* <p>
* Collation service provides correct sorting orders for most locales supported in ICU.
* If specific data for a locale is not available, the orders eventually falls back
* to the <a href="http://www.unicode.org/reports/tr35/tr35-collation.html#Root_Collation">CLDR root sort order</a>.
* <p>
* Sort ordering may be customized by providing your own set of rules. For more on
- * this subject see the <a href="http://userguide.icu-project.org/collation/customization">
+ * this subject see the <a href="https://unicode-org.github.io/icu/userguide/collation/customization">
* Collation Customization</a> section of the User Guide.
* <p>
* @see UCollationResult
@@ -367,7 +370,7 @@ typedef enum {
* Retrieves the "UCA rules" concatenated with the tailoring rules.
* The "UCA rules" are an <i>approximation</i> of the root collator's sort order.
* They are almost never used or useful at runtime and can be removed from the data.
- * See http://userguide.icu-project.org/collation/customization#TOC-Building-on-Existing-Locales
+ * See https://unicode-org.github.io/icu/userguide/collation/customization#building-on-existing-locales
* @stable ICU 2.0
*/
UCOL_FULL_RULES
@@ -381,7 +384,7 @@ typedef enum {
* Starting with ICU 54, collation attributes can be specified via locale keywords as well,
* in the old locale extension syntax ("el@colCaseFirst=upper")
* or in language tag syntax ("el-u-kf-upper").
- * See <a href="http://userguide.icu-project.org/collation/api">User Guide: Collation API</a>.
+ * See <a href="https://unicode-org.github.io/icu/userguide/collation/api">User Guide: Collation API</a>.
*
* The UCollator pointer is used in all the calls to the Collation
* service. After finished, collator must be disposed of by calling
@@ -398,7 +401,7 @@ typedef enum {
* @see ucol_close
* @stable ICU 2.0
*/
-U_STABLE UCollator* U_EXPORT2
+U_CAPI UCollator* U_EXPORT2
ucol_open(const char *loc, UErrorCode *status);
/**
@@ -426,7 +429,7 @@ ucol_open(const char *loc, UErrorCode *status);
* @see ucol_close
* @stable ICU 2.0
*/
-U_STABLE UCollator* U_EXPORT2
+U_CAPI UCollator* U_EXPORT2
ucol_openRules( const UChar *rules,
int32_t rulesLength,
UColAttributeValue normalizationMode,
@@ -439,7 +442,7 @@ ucol_openRules( const UChar *rules,
* Open a collator defined by a short form string.
* The structure and the syntax of the string is defined in the "Naming collators"
* section of the users guide:
- * http://userguide.icu-project.org/collation/concepts#TOC-Collator-naming-scheme
+ * https://unicode-org.github.io/icu/userguide/collation/concepts#collator-naming-scheme
* Attributes are overriden by the subsequent attributes. So, for "S2_S3", final
* strength will be 3. 3066bis locale overrides individual locale parts.
* The call to this function is equivalent to a call to ucol_open, followed by a
@@ -449,12 +452,12 @@ ucol_openRules( const UChar *rules,
* state for a locale.
* @param parseError if not NULL, structure that will get filled with error's pre
* and post context in case of error.
- * @param forceDefaults if FALSE, the settings that are the same as the collator
+ * @param forceDefaults if false, the settings that are the same as the collator
* default settings will not be applied (for example, setting
* French secondary on a French collator would not be executed).
- * If TRUE, all the settings will be applied regardless of the
+ * If true, all the settings will be applied regardless of the
* collator default value. If the definition
- * strings are to be cached, should be set to FALSE.
+ * strings are to be cached, should be set to false.
* @param status Error code. Apart from regular error conditions connected to
* instantiating collators (like out of memory or similar), this
* API will return an error if an invalid attribute or attribute/value
@@ -506,7 +509,7 @@ ucol_getContractions( const UCollator *coll,
*
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucol_getContractionsAndExpansions( const UCollator *coll,
USet *contractions, USet *expansions,
UBool addPrefixes, UErrorCode *status);
@@ -521,7 +524,7 @@ ucol_getContractionsAndExpansions( const UCollator *coll,
* @see ucol_safeClone
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucol_close(UCollator *coll);
#if U_SHOW_CPLUSPLUS_API
@@ -558,7 +561,7 @@ U_NAMESPACE_END
* @see ucol_equal
* @stable ICU 2.0
*/
-U_STABLE UCollationResult U_EXPORT2
+U_CAPI UCollationResult U_EXPORT2
ucol_strcoll( const UCollator *coll,
const UChar *source,
int32_t sourceLength,
@@ -583,7 +586,7 @@ ucol_strcoll( const UCollator *coll,
* @see ucol_equal
* @stable ICU 50
*/
-U_STABLE UCollationResult U_EXPORT2
+U_CAPI UCollationResult U_EXPORT2
ucol_strcollUTF8(
const UCollator *coll,
const char *source,
@@ -600,13 +603,13 @@ ucol_strcollUTF8(
* @param sourceLength The length of source, or -1 if null-terminated.
* @param target The target string.
* @param targetLength The length of target, or -1 if null-terminated.
- * @return TRUE if source is greater than target, FALSE otherwise.
+ * @return true if source is greater than target, false otherwise.
* @see ucol_strcoll
* @see ucol_greaterOrEqual
* @see ucol_equal
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucol_greater(const UCollator *coll,
const UChar *source, int32_t sourceLength,
const UChar *target, int32_t targetLength);
@@ -619,13 +622,13 @@ ucol_greater(const UCollator *coll,
* @param sourceLength The length of source, or -1 if null-terminated.
* @param target The target string.
* @param targetLength The length of target, or -1 if null-terminated.
- * @return TRUE if source is greater than or equal to target, FALSE otherwise.
+ * @return true if source is greater than or equal to target, false otherwise.
* @see ucol_strcoll
* @see ucol_greater
* @see ucol_equal
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucol_greaterOrEqual(const UCollator *coll,
const UChar *source, int32_t sourceLength,
const UChar *target, int32_t targetLength);
@@ -638,13 +641,13 @@ ucol_greaterOrEqual(const UCollator *coll,
* @param sourceLength The length of source, or -1 if null-terminated.
* @param target The target string.
* @param targetLength The length of target, or -1 if null-terminated.
- * @return TRUE if source is equal to target, FALSE otherwise
+ * @return true if source is equal to target, false otherwise
* @see ucol_strcoll
* @see ucol_greater
* @see ucol_greaterOrEqual
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucol_equal(const UCollator *coll,
const UChar *source, int32_t sourceLength,
const UChar *target, int32_t targetLength);
@@ -661,7 +664,7 @@ ucol_equal(const UCollator *coll,
* @see ucol_strcoll
* @stable ICU 2.6
*/
-U_STABLE UCollationResult U_EXPORT2
+U_CAPI UCollationResult U_EXPORT2
ucol_strcollIter( const UCollator *coll,
UCharIterator *sIter,
UCharIterator *tIter,
@@ -676,7 +679,7 @@ ucol_strcollIter( const UCollator *coll,
* @see ucol_setStrength
* @stable ICU 2.0
*/
-U_STABLE UCollationStrength U_EXPORT2
+U_CAPI UCollationStrength U_EXPORT2
ucol_getStrength(const UCollator *coll);
/**
@@ -688,7 +691,7 @@ ucol_getStrength(const UCollator *coll);
* @see ucol_getStrength
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucol_setStrength(UCollator *coll,
UCollationStrength strength);
@@ -708,7 +711,7 @@ ucol_setStrength(UCollator *coll,
* @see UColReorderCode
* @stable ICU 4.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_getReorderCodes(const UCollator* coll,
int32_t* dest,
int32_t destCapacity,
@@ -753,7 +756,7 @@ ucol_getReorderCodes(const UCollator* coll,
* @see UColReorderCode
* @stable ICU 4.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucol_setReorderCodes(UCollator* coll,
const int32_t* reorderCodes,
int32_t reorderCodesLength,
@@ -778,7 +781,7 @@ ucol_setReorderCodes(UCollator* coll,
* @see UColReorderCode
* @stable ICU 4.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_getEquivalentReorderCodes(int32_t reorderCode,
int32_t* dest,
int32_t destCapacity,
@@ -796,7 +799,7 @@ ucol_getEquivalentReorderCodes(int32_t reorderCode,
* the output was truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_getDisplayName( const char *objLoc,
const char *dispLoc,
UChar *result,
@@ -812,7 +815,7 @@ ucol_getDisplayName( const char *objLoc,
* @see ucol_countAvailable
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
ucol_getAvailable(int32_t localeIndex);
/**
@@ -823,7 +826,7 @@ ucol_getAvailable(int32_t localeIndex);
* @see ucol_getAvailable
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_countAvailable(void);
#if !UCONFIG_NO_SERVICE
@@ -835,7 +838,7 @@ ucol_countAvailable(void);
* responsible for closing the result.
* @stable ICU 3.0
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
ucol_openAvailableLocales(UErrorCode *status);
#endif
@@ -848,7 +851,7 @@ ucol_openAvailableLocales(UErrorCode *status);
* responsible for closing the result.
* @stable ICU 3.0
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
ucol_getKeywords(UErrorCode *status);
/**
@@ -862,7 +865,7 @@ ucol_getKeywords(UErrorCode *status);
* upon error. The caller is responsible for closing the result.
* @stable ICU 3.0
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
ucol_getKeywordValues(const char *keyword, UErrorCode *status);
/**
@@ -881,7 +884,7 @@ ucol_getKeywordValues(const char *keyword, UErrorCode *status);
* @return a string enumeration over keyword values for the given key and the locale.
* @stable ICU 4.2
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
ucol_getKeywordValuesForLocale(const char* key,
const char* locale,
UBool commonlyUsed,
@@ -901,7 +904,7 @@ ucol_getKeywordValuesForLocale(const char* key,
* applications who wish to cache collators, or otherwise reuse
* collators when possible. The functional equivalent may change
* over time. For more information, please see the <a
- * href="http://userguide.icu-project.org/locale#TOC-Locales-and-Services">
+ * href="https://unicode-org.github.io/icu/userguide/locale#locales-and-services">
* Locales and Services</a> section of the ICU User Guide.
* @param result fillin for the functionally equivalent result locale
* @param resultCapacity capacity of the fillin buffer
@@ -918,7 +921,7 @@ ucol_getKeywordValuesForLocale(const char* key,
* an error code will be returned.
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_getFunctionalEquivalent(char* result, int32_t resultCapacity,
const char* keyword, const char* locale,
UBool* isAvailable, UErrorCode* status);
@@ -931,7 +934,7 @@ ucol_getFunctionalEquivalent(char* result, int32_t resultCapacity,
* @return The collation tailoring rules.
* @stable ICU 2.0
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ucol_getRules( const UCollator *coll,
int32_t *length);
@@ -942,7 +945,7 @@ ucol_getRules( const UCollator *coll,
* This string will be normalized.
* The structure and the syntax of the string is defined in the "Naming collators"
* section of the users guide:
- * http://userguide.icu-project.org/collation/concepts#TOC-Collator-naming-scheme
+ * https://unicode-org.github.io/icu/userguide/collation/concepts#collator-naming-scheme
* This API supports preflighting.
* @param coll a collator
* @param locale a locale that will appear as a collators locale in the resulting
@@ -1014,7 +1017,7 @@ ucol_normalizeShortDefinitionString(const char *source,
* @see ucol_keyHashCode
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_getSortKey(const UCollator *coll,
const UChar *source,
int32_t sourceLength,
@@ -1042,7 +1045,7 @@ ucol_getSortKey(const UCollator *coll,
* the sort key.
* @stable ICU 2.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_nextSortKeyPart(const UCollator *coll,
UCharIterator *iter,
uint32_t state[2],
@@ -1109,7 +1112,7 @@ typedef enum {
* @see ucol_keyHashCode
* @stable ICU 2.1
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_getBound(const uint8_t *source,
int32_t sourceLength,
UColBoundMode boundType,
@@ -1126,7 +1129,7 @@ ucol_getBound(const uint8_t *source,
* @param info the version # information, the result will be filled in
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucol_getVersion(const UCollator* coll, UVersionInfo info);
/**
@@ -1136,7 +1139,7 @@ ucol_getVersion(const UCollator* coll, UVersionInfo info);
* @param info the version # information, the result will be filled in
* @stable ICU 2.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucol_getUCAVersion(const UCollator* coll, UVersionInfo info);
/**
@@ -1155,7 +1158,7 @@ ucol_getUCAVersion(const UCollator* coll, UVersionInfo info);
* Using strings with U+FFFE may yield shorter sort keys.
*
* For details about Sort Key Features see
- * http://userguide.icu-project.org/collation/api#TOC-Sort-Key-Features
+ * https://unicode-org.github.io/icu/userguide/collation/api#sort-key-features
*
* It is possible to merge multiple sort keys by consecutively merging
* another one with the intermediate result.
@@ -1186,7 +1189,7 @@ ucol_getUCAVersion(const UCollator* coll, UVersionInfo info);
* in which cases the contents of dest is undefined
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length,
const uint8_t *src2, int32_t src2Length,
uint8_t *dest, int32_t destCapacity);
@@ -1202,7 +1205,7 @@ ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length,
* @see ucol_getAttribute
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status);
/**
@@ -1216,7 +1219,7 @@ ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value,
* @see ucol_setAttribute
* @stable ICU 2.0
*/
-U_STABLE UColAttributeValue U_EXPORT2
+U_CAPI UColAttributeValue U_EXPORT2
ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status);
/**
@@ -1235,7 +1238,7 @@ ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status)
* @see ucol_getMaxVariable
* @stable ICU 53
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucol_setMaxVariable(UCollator *coll, UColReorderCode group, UErrorCode *pErrorCode);
/**
@@ -1245,7 +1248,7 @@ ucol_setMaxVariable(UCollator *coll, UColReorderCode group, UErrorCode *pErrorCo
* @see ucol_setMaxVariable
* @stable ICU 53
*/
-U_STABLE UColReorderCode U_EXPORT2
+U_CAPI UColReorderCode U_EXPORT2
ucol_getMaxVariable(const UCollator *coll);
#ifndef U_HIDE_DEPRECATED_API
@@ -1286,7 +1289,7 @@ ucol_setVariableTop(UCollator *coll,
* @see ucol_restoreVariableTop
* @stable ICU 2.0
*/
-U_STABLE uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode *status);
+U_CAPI uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode *status);
#ifndef U_HIDE_DEPRECATED_API
/**
@@ -1330,7 +1333,7 @@ ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *stat
* @see ucol_close
* @stable ICU 2.0
*/
-U_STABLE UCollator* U_EXPORT2
+U_CAPI UCollator* U_EXPORT2
ucol_safeClone(const UCollator *coll,
void *stackBuffer,
int32_t *pBufferSize,
@@ -1351,7 +1354,7 @@ ucol_safeClone(const UCollator *coll,
* to store rules, will store up to available space.
*
* ucol_getRules() should normally be used instead.
- * See http://userguide.icu-project.org/collation/customization#TOC-Building-on-Existing-Locales
+ * See https://unicode-org.github.io/icu/userguide/collation/customization#building-on-existing-locales
* @param coll collator to get the rules from
* @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES.
* @param buffer buffer to store the result in. If NULL, you'll get no rules.
@@ -1360,7 +1363,7 @@ ucol_safeClone(const UCollator *coll,
* @stable ICU 2.0
* @see UCOL_FULL_RULES
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen);
#ifndef U_HIDE_DEPRECATED_API
@@ -1396,7 +1399,7 @@ ucol_getLocale(const UCollator *coll, ULocDataLocaleType type, UErrorCode *statu
* NULL.
* @stable ICU 2.8
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucol_getLocaleByType(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status);
/**
@@ -1409,7 +1412,7 @@ ucol_getLocaleByType(const UCollator *coll, ULocDataLocaleType type, UErrorCode
* @see uset_close
* @stable ICU 2.4
*/
-U_STABLE USet * U_EXPORT2
+U_CAPI USet * U_EXPORT2
ucol_getTailoredSet(const UCollator *coll, UErrorCode *status);
#ifndef U_HIDE_INTERNAL_API
@@ -1424,7 +1427,7 @@ ucol_getTailoredSet(const UCollator *coll, UErrorCode *status);
* @return number of elements in the set
* @internal ICU 3.0
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_getUnsafeSet( const UCollator *coll,
USet *unsafe,
UErrorCode *status);
@@ -1436,12 +1439,12 @@ ucol_getUnsafeSet( const UCollator *coll,
* state for a locale.
* @param parseError if not NULL, structure that will get filled with error's pre
* and post context in case of error.
- * @param forceDefaults if FALSE, the settings that are the same as the collator
+ * @param forceDefaults if false, the settings that are the same as the collator
* default settings will not be applied (for example, setting
* French secondary on a French collator would not be executed).
- * If TRUE, all the settings will be applied regardless of the
+ * If true, all the settings will be applied regardless of the
* collator default value. If the definition
- * strings are to be cached, should be set to FALSE.
+ * strings are to be cached, should be set to false.
* @param status Error code. Apart from regular error conditions connected to
* instantiating collators (like out of memory or similar), this
* API will return an error if an invalid attribute or attribute/value
@@ -1449,7 +1452,7 @@ ucol_getUnsafeSet( const UCollator *coll,
* @see ucol_openFromShortString
* @internal ICU 3.2.1
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
ucol_prepareShortStringOpen( const char *definition,
UBool forceDefaults,
UParseError *parseError,
@@ -1467,7 +1470,7 @@ ucol_prepareShortStringOpen( const char *definition,
* @see ucol_openBinary
* @stable ICU 3.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_cloneBinary(const UCollator *coll,
uint8_t *buffer, int32_t capacity,
UErrorCode *status);
@@ -1489,7 +1492,7 @@ ucol_cloneBinary(const UCollator *coll,
* @see ucol_cloneBinary
* @stable ICU 3.2
*/
-U_STABLE UCollator* U_EXPORT2
+U_CAPI UCollator* U_EXPORT2
ucol_openBinary(const uint8_t *bin, int32_t length,
const UCollator *base,
UErrorCode *status);
diff --git a/deps/icu-small/source/i18n/unicode/ucoleitr.h b/deps/icu-small/source/i18n/unicode/ucoleitr.h
index 96c67f2018..e8bcd368d4 100644
--- a/deps/icu-small/source/i18n/unicode/ucoleitr.h
+++ b/deps/icu-small/source/i18n/unicode/ucoleitr.h
@@ -23,7 +23,7 @@
#if !UCONFIG_NO_COLLATION
/**
- * This indicates an error has occured during processing or if no more CEs is
+ * This indicates an error has occurred during processing or if no more CEs is
* to be returned.
* @stable ICU 2.0
*/
@@ -66,14 +66,14 @@ typedef struct UCollationElements UCollationElements;
* . UCollationElements *c;
* . UCollatorOld *coll;
* . UErrorCode success = U_ZERO_ERROR;
- * . s=(UChar*)malloc(sizeof(UChar) * (strlen("This is a test")+1) );
- * . u_uastrcpy(s, "This is a test");
+ * . str=(UChar*)malloc(sizeof(UChar) * (strlen("This is a test")+1) );
+ * . u_uastrcpy(str, "This is a test");
* . coll = ucol_open(NULL, &success);
* . c = ucol_openElements(coll, str, u_strlen(str), &status);
* . order = ucol_next(c, &success);
* . ucol_reset(c);
* . order = ucol_prev(c, &success);
- * . free(s);
+ * . free(str);
* . ucol_close(coll);
* . ucol_closeElements(c);
* . }
@@ -102,6 +102,10 @@ typedef struct UCollationElements UCollationElements;
/**
* Open the collation elements for a string.
*
+ * The UCollationElements retains a pointer to the supplied text.
+ * The caller must not modify or delete the text while the UCollationElements
+ * object is used to iterate over this text.
+ *
* @param coll The collator containing the desired collation rules.
* @param text The text to iterate over.
* @param textLength The number of characters in text, or -1 if null-terminated
@@ -109,13 +113,12 @@ typedef struct UCollationElements UCollationElements;
* @return a struct containing collation element information
* @stable ICU 2.0
*/
-U_STABLE UCollationElements* U_EXPORT2
+U_CAPI UCollationElements* U_EXPORT2
ucol_openElements(const UCollator *coll,
const UChar *text,
int32_t textLength,
UErrorCode *status);
-
/**
* get a hash code for a key... Not very useful!
* @param key the given key.
@@ -123,7 +126,7 @@ ucol_openElements(const UCollator *coll,
* @return the hash code.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_keyHashCode(const uint8_t* key, int32_t length);
/**
@@ -132,7 +135,7 @@ ucol_keyHashCode(const uint8_t* key, int32_t length);
* @param elems The UCollationElements to close.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucol_closeElements(UCollationElements *elems);
/**
@@ -144,7 +147,7 @@ ucol_closeElements(UCollationElements *elems);
* @see ucol_previous
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucol_reset(UCollationElements *elems);
/**
@@ -153,10 +156,10 @@ ucol_reset(UCollationElements *elems);
* @param elems The UCollationElements containing the text.
* @param status A pointer to a UErrorCode to receive any errors.
* @return The next collation elements ordering, otherwise returns UCOL_NULLORDER
- * if an error has occured or if the end of string has been reached
+ * if an error has occurred or if the end of string has been reached
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_next(UCollationElements *elems, UErrorCode *status);
/**
@@ -168,11 +171,11 @@ ucol_next(UCollationElements *elems, UErrorCode *status);
* a U_BUFFER_OVERFLOW_ERROR is returned if the internal stack
* buffer has been exhausted.
* @return The previous collation elements ordering, otherwise returns
- * UCOL_NULLORDER if an error has occured or if the start of string has
+ * UCOL_NULLORDER if an error has occurred or if the start of string has
* been reached.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_previous(UCollationElements *elems, UErrorCode *status);
/**
@@ -186,7 +189,7 @@ ucol_previous(UCollationElements *elems, UErrorCode *status);
* expansion sequence
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_getMaxExpansion(const UCollationElements *elems, int32_t order);
/**
@@ -194,6 +197,11 @@ ucol_getMaxExpansion(const UCollationElements *elems, int32_t order);
* Property settings for collation will remain the same.
* In order to reset the iterator to the current collation property settings,
* the API reset() has to be called.
+ *
+ * The UCollationElements retains a pointer to the supplied text.
+ * The caller must not modify or delete the text while the UCollationElements
+ * object is used to iterate over this text.
+ *
* @param elems The UCollationElements to set.
* @param text The source text containing the collation elements.
* @param textLength The length of text, or -1 if null-terminated.
@@ -201,7 +209,7 @@ ucol_getMaxExpansion(const UCollationElements *elems, int32_t order);
* @see ucol_getText
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucol_setText( UCollationElements *elems,
const UChar *text,
int32_t textLength,
@@ -216,7 +224,7 @@ ucol_setText( UCollationElements *elems,
* @see ucol_setOffset
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_getOffset(const UCollationElements *elems);
/**
@@ -231,9 +239,9 @@ ucol_getOffset(const UCollationElements *elems);
* @see ucol_getOffset
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucol_setOffset(UCollationElements *elems,
- int32_t offset,
+ int32_t offset,
UErrorCode *status);
/**
@@ -242,7 +250,7 @@ ucol_setOffset(UCollationElements *elems,
* @return the primary order of a collation order.
* @stable ICU 2.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_primaryOrder (int32_t order);
/**
@@ -251,7 +259,7 @@ ucol_primaryOrder (int32_t order);
* @return the secondary order of a collation order.
* @stable ICU 2.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_secondaryOrder (int32_t order);
/**
@@ -260,7 +268,7 @@ ucol_secondaryOrder (int32_t order);
* @return the tertiary order of a collation order.
* @stable ICU 2.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucol_tertiaryOrder (int32_t order);
#endif /* #if !UCONFIG_NO_COLLATION */
diff --git a/deps/icu-small/source/i18n/unicode/ucsdet.h b/deps/icu-small/source/i18n/unicode/ucsdet.h
index 7a8564f9ea..50281ad1fb 100644
--- a/deps/icu-small/source/i18n/unicode/ucsdet.h
+++ b/deps/icu-small/source/i18n/unicode/ucsdet.h
@@ -25,9 +25,12 @@
#if !UCONFIG_NO_CONVERSION
-#include "unicode/localpointer.h"
#include "unicode/uenum.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* \file
* \brief C API: Charset Detection API
@@ -75,7 +78,7 @@ typedef struct UCharsetMatch UCharsetMatch;
* @return the newly opened charset detector.
* @stable ICU 3.6
*/
-U_STABLE UCharsetDetector * U_EXPORT2
+U_CAPI UCharsetDetector * U_EXPORT2
ucsdet_open(UErrorCode *status);
/**
@@ -87,7 +90,7 @@ ucsdet_open(UErrorCode *status);
* @param ucsd The charset detector to be closed.
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucsdet_close(UCharsetDetector *ucsd);
#if U_SHOW_CPLUSPLUS_API
@@ -124,7 +127,7 @@ U_NAMESPACE_END
*
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucsdet_setText(UCharsetDetector *ucsd, const char *textIn, int32_t len, UErrorCode *status);
@@ -146,7 +149,7 @@ ucsdet_setText(UCharsetDetector *ucsd, const char *textIn, int32_t len, UErrorCo
*
* @stable ICU 3.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucsdet_setDeclaredEncoding(UCharsetDetector *ucsd, const char *encoding, int32_t length, UErrorCode *status);
@@ -175,7 +178,7 @@ ucsdet_setDeclaredEncoding(UCharsetDetector *ucsd, const char *encoding, int32_t
*
* @stable ICU 3.6
*/
-U_STABLE const UCharsetMatch * U_EXPORT2
+U_CAPI const UCharsetMatch * U_EXPORT2
ucsdet_detect(UCharsetDetector *ucsd, UErrorCode *status);
@@ -209,7 +212,7 @@ ucsdet_detect(UCharsetDetector *ucsd, UErrorCode *status);
* the detector is closed or modified.
* @stable ICU 3.6
*/
-U_STABLE const UCharsetMatch ** U_EXPORT2
+U_CAPI const UCharsetMatch ** U_EXPORT2
ucsdet_detectAll(UCharsetDetector *ucsd, int32_t *matchesFound, UErrorCode *status);
@@ -229,7 +232,7 @@ ucsdet_detectAll(UCharsetDetector *ucsd, int32_t *matchesFound, UErrorCode *stat
*
* @stable ICU 3.6
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucsdet_getName(const UCharsetMatch *ucsm, UErrorCode *status);
/**
@@ -255,7 +258,7 @@ ucsdet_getName(const UCharsetMatch *ucsm, UErrorCode *status);
*
* @stable ICU 3.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucsdet_getConfidence(const UCharsetMatch *ucsm, UErrorCode *status);
/**
@@ -287,7 +290,7 @@ ucsdet_getConfidence(const UCharsetMatch *ucsm, UErrorCode *status);
*
* @stable ICU 3.6
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ucsdet_getLanguage(const UCharsetMatch *ucsm, UErrorCode *status);
@@ -313,7 +316,7 @@ ucsdet_getLanguage(const UCharsetMatch *ucsm, UErrorCode *status);
*
* @stable ICU 3.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucsdet_getUChars(const UCharsetMatch *ucsm,
UChar *buf, int32_t cap, UErrorCode *status);
@@ -347,7 +350,7 @@ ucsdet_getUChars(const UCharsetMatch *ucsm,
* @return an iterator providing access to the detectable charset names.
* @stable ICU 3.6
*/
-U_STABLE UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
ucsdet_getAllDetectableCharsets(const UCharsetDetector *ucsd, UErrorCode *status);
/**
@@ -357,11 +360,11 @@ ucsdet_getAllDetectableCharsets(const UCharsetDetector *ucsd, UErrorCode *statu
* heuristics.
*
* @param ucsd The charset detector to check.
- * @return TRUE if filtering is enabled.
+ * @return true if filtering is enabled.
* @stable ICU 3.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucsdet_isInputFilterEnabled(const UCharsetDetector *ucsd);
@@ -376,7 +379,7 @@ ucsdet_isInputFilterEnabled(const UCharsetDetector *ucsd);
*
* @stable ICU 3.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucsdet_enableInputFilter(UCharsetDetector *ucsd, UBool filter);
#ifndef U_HIDE_INTERNAL_API
@@ -393,7 +396,7 @@ ucsdet_enableInputFilter(UCharsetDetector *ucsd, UBool filter);
* the specified charset detector.
* @internal
*/
-U_INTERNAL UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
ucsdet_getDetectableCharsets(const UCharsetDetector *ucsd, UErrorCode *status);
/**
@@ -403,13 +406,13 @@ ucsdet_getDetectableCharsets(const UCharsetDetector *ucsd, UErrorCode *status);
*
* @param ucsd a Charset detector.
* @param encoding encoding the name of charset encoding.
- * @param enabled <code>TRUE</code> to enable, or <code>FALSE</code> to disable the
+ * @param enabled <code>true</code> to enable, or <code>false</code> to disable the
* charset encoding.
* @param status receives the return status. When the name of charset encoding
* is not supported, U_ILLEGAL_ARGUMENT_ERROR is set.
* @internal
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
ucsdet_setDetectableCharset(UCharsetDetector *ucsd, const char *encoding, UBool enabled, UErrorCode *status);
#endif /* U_HIDE_INTERNAL_API */
diff --git a/deps/icu-small/source/i18n/unicode/udat.h b/deps/icu-small/source/i18n/unicode/udat.h
index cf7a165e70..ec25eba808 100644
--- a/deps/icu-small/source/i18n/unicode/udat.h
+++ b/deps/icu-small/source/i18n/unicode/udat.h
@@ -14,11 +14,15 @@
#if !UCONFIG_NO_FORMATTING
-#include "unicode/localpointer.h"
#include "unicode/ucal.h"
#include "unicode/unum.h"
#include "unicode/udisplaycontext.h"
#include "unicode/ufieldpositer.h"
+
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* \file
* \brief C API: DateFormat
@@ -142,7 +146,7 @@
* the date and time formatting algorithm and pattern letters defined by
* <a href="http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table">UTS#35
* Unicode Locale Data Markup Language (LDML)</a> and further documented for ICU in the
- * <a href="https://sites.google.com/site/icuprojectuserguide/formatparse/datetime?pli=1#TOC-Date-Field-Symbol-Table">ICU
+ * <a href="https://unicode-org.github.io/icu/userguide/format_parse/datetime#date-field-symbol-table">ICU
* User Guide</a>.</p>
*/
@@ -832,10 +836,24 @@ typedef enum UDateFormatField {
/**
* Maps from a UDateFormatField to the corresponding UCalendarDateFields.
- * Note: since the mapping is many-to-one, there is no inverse mapping.
+ *
+ * Note 1: Since the mapping is many-to-one, there is no inverse mapping.
+ *
+ * Note 2: There is no UErrorCode parameter, so in case of error (UDateFormatField is
+ * unknown or has no corresponding UCalendarDateFields value), the function returns the
+ * current value of UCAL_FIELD_COUNT. However, that value may change from release to
+ * release and is consequently deprecated. For a future-proof runtime way of checking
+ * for errors:
+ * a) First save the value returned by the function when it is passed an invalid value
+ * such as "(UDateFormatField)-1".
+ * b) Then, to test for errors when passing some other UDateFormatField value, check
+ * whether the function returns that saved value.
+ *
* @param field the UDateFormatField.
- * @return the UCalendarDateField. This will be UCAL_FIELD_COUNT in case
- * of error (e.g., the input field is UDAT_FIELD_COUNT).
+ * @return the UCalendarDateField. In case of error (UDateFormatField is unknown or has
+ * no corresponding UCalendarDateFields value) this will be the current value of
+ * UCAL_FIELD_COUNT, but that value may change from release to release.
+ * See Note 2 above.
* @stable ICU 4.4
*/
U_CAPI UCalendarDateFields U_EXPORT2
@@ -1217,7 +1235,7 @@ udat_parseCalendar(const UDateFormat* format,
* With lenient parsing, the parser may use heuristics to interpret inputs that do not
* precisely match the pattern. With strict parsing, inputs must match the pattern.
* @param fmt The formatter to query
-* @return TRUE if fmt is set to perform lenient parsing, FALSE otherwise.
+* @return true if fmt is set to perform lenient parsing, false otherwise.
* @see udat_setLenient
* @stable ICU 2.0
*/
@@ -1229,7 +1247,7 @@ udat_isLenient(const UDateFormat* fmt);
* With lenient parsing, the parser may use heuristics to interpret inputs that do not
* precisely match the pattern. With strict parsing, inputs must match the pattern.
* @param fmt The formatter to set
-* @param isLenient TRUE if fmt should perform lenient parsing, FALSE otherwise.
+* @param isLenient true if fmt should perform lenient parsing, false otherwise.
* @see dat_isLenient
* @stable ICU 2.0
*/
@@ -1389,7 +1407,7 @@ udat_set2DigitYearStart( UDateFormat *fmt,
* Extract the pattern from a UDateFormat.
* The pattern will follow the pattern syntax rules.
* @param fmt The formatter to query.
-* @param localized TRUE if the pattern should be localized, FALSE otherwise.
+* @param localized true if the pattern should be localized, false otherwise.
* @param result A pointer to a buffer to receive the pattern.
* @param resultLength The maximum size of result.
* @param status A pointer to an UErrorCode to receive any errors
@@ -1408,7 +1426,7 @@ udat_toPattern( const UDateFormat *fmt,
* Set the pattern used by an UDateFormat.
* The pattern should follow the pattern syntax rules.
* @param format The formatter to set.
-* @param localized TRUE if the pattern is localized, FALSE otherwise.
+* @param localized true if the pattern is localized, false otherwise.
* @param pattern The new pattern
* @param patternLength The length of pattern, or -1 if null-terminated.
* @see udat_toPattern
@@ -1636,7 +1654,7 @@ udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* st
* @see udat_applyPatternRelative
* @internal ICU 4.2 technology preview
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
udat_toPatternRelativeDate(const UDateFormat *fmt,
UChar *result,
int32_t resultLength,
@@ -1653,7 +1671,7 @@ udat_toPatternRelativeDate(const UDateFormat *fmt,
* @see udat_applyPatternRelative
* @internal ICU 4.2 technology preview
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
udat_toPatternRelativeTime(const UDateFormat *fmt,
UChar *result,
int32_t resultLength,
@@ -1671,7 +1689,7 @@ udat_toPatternRelativeTime(const UDateFormat *fmt,
* @see udat_toPatternRelativeDate, udat_toPatternRelativeTime
* @internal ICU 4.2 technology preview
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
udat_applyPatternRelative(UDateFormat *format,
const UChar *datePattern,
int32_t datePatternLength,
@@ -1696,14 +1714,14 @@ typedef UDateFormat* (U_EXPORT2 *UDateFormatOpener) (UDateFormatStyle timeStyle
* Register a provider factory
* @internal ICU 49
*/
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
udat_registerOpener(UDateFormatOpener opener, UErrorCode *status);
/**
* Un-Register a provider factory
* @internal ICU 49
*/
-U_INTERNAL UDateFormatOpener U_EXPORT2
+U_CAPI UDateFormatOpener U_EXPORT2
udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status);
#endif /* U_HIDE_INTERNAL_API */
diff --git a/deps/icu-small/source/i18n/unicode/udateintervalformat.h b/deps/icu-small/source/i18n/unicode/udateintervalformat.h
index 6235ab7106..a840ed595b 100644
--- a/deps/icu-small/source/i18n/unicode/udateintervalformat.h
+++ b/deps/icu-small/source/i18n/unicode/udateintervalformat.h
@@ -16,8 +16,12 @@
#include "unicode/ucal.h"
#include "unicode/umisc.h"
-#include "unicode/localpointer.h"
#include "unicode/uformattedvalue.h"
+#include "unicode/udisplaycontext.h"
+
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
@@ -114,7 +118,7 @@ typedef struct UFormattedDateInterval UFormattedDateInterval;
* or NULL if an error occurred.
* @stable ICU 4.8
*/
-U_STABLE UDateIntervalFormat* U_EXPORT2
+U_CAPI UDateIntervalFormat* U_EXPORT2
udtitvfmt_open(const char* locale,
const UChar* skeleton,
int32_t skeletonLength,
@@ -128,7 +132,7 @@ udtitvfmt_open(const char* locale,
* The UDateIntervalFormat object to close.
* @stable ICU 4.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udtitvfmt_close(UDateIntervalFormat *formatter);
/**
@@ -238,7 +242,7 @@ U_NAMESPACE_END
* output was truncated.
* @stable ICU 4.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
udtitvfmt_format(const UDateIntervalFormat* formatter,
UDate fromDate,
UDate toDate,
@@ -265,7 +269,7 @@ udtitvfmt_format(const UDateIntervalFormat* formatter,
* A pointer to a UErrorCode to receive any errors.
* @draft ICU 67
*/
-U_DRAFT void U_EXPORT2
+U_CAPI void U_EXPORT2
udtitvfmt_formatToResult(
const UDateIntervalFormat* formatter,
UDate fromDate,
@@ -290,7 +294,7 @@ udtitvfmt_formatToResult(
* @draft ICU 67
*/
-U_DRAFT void U_EXPORT2
+U_CAPI void U_EXPORT2
udtitvfmt_formatCalendarToResult(
const UDateIntervalFormat* formatter,
UCalendar* fromCalendar,
@@ -299,6 +303,34 @@ udtitvfmt_formatCalendarToResult(
UErrorCode* status);
#endif /* U_HIDE_DRAFT_API */
+#ifndef U_HIDE_DRAFT_API
+/**
+ * Set a particular UDisplayContext value in the formatter, such as
+ * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. This causes the formatted
+ * result to be capitalized appropriately for the context in which
+ * it is intended to be used, considering both the locale and the
+ * type of field at the beginning of the formatted result.
+ * @param formatter The formatter for which to set a UDisplayContext value.
+ * @param value The UDisplayContext value to set.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @draft ICU 68
+ */
+U_CAPI void U_EXPORT2
+udtitvfmt_setContext(UDateIntervalFormat* formatter, UDisplayContext value, UErrorCode* status);
+
+/**
+ * Get the formatter's UDisplayContext value for the specified UDisplayContextType,
+ * such as UDISPCTX_TYPE_CAPITALIZATION.
+ * @param formatter The formatter to query.
+ * @param type The UDisplayContextType whose value to return
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @return The UDisplayContextValue for the specified type.
+ * @draft ICU 68
+ */
+U_CAPI UDisplayContext U_EXPORT2
+udtitvfmt_getContext(const UDateIntervalFormat* formatter, UDisplayContextType type, UErrorCode* status);
+
+#endif /* U_HIDE_DRAFT_API */
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/unicode/udatpg.h b/deps/icu-small/source/i18n/unicode/udatpg.h
index 4ec4a2d051..9fe267a3f4 100644
--- a/deps/icu-small/source/i18n/unicode/udatpg.h
+++ b/deps/icu-small/source/i18n/unicode/udatpg.h
@@ -22,7 +22,10 @@
#include "unicode/utypes.h"
#include "unicode/udat.h"
#include "unicode/uenum.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
@@ -161,7 +164,7 @@ typedef enum UDateTimePatternConflict {
* @return a pointer to UDateTimePatternGenerator.
* @stable ICU 3.8
*/
-U_STABLE UDateTimePatternGenerator * U_EXPORT2
+U_CAPI UDateTimePatternGenerator * U_EXPORT2
udatpg_open(const char *locale, UErrorCode *pErrorCode);
/**
@@ -171,7 +174,7 @@ udatpg_open(const char *locale, UErrorCode *pErrorCode);
* @return a pointer to UDateTimePatternGenerator.
* @stable ICU 3.8
*/
-U_STABLE UDateTimePatternGenerator * U_EXPORT2
+U_CAPI UDateTimePatternGenerator * U_EXPORT2
udatpg_openEmpty(UErrorCode *pErrorCode);
/**
@@ -179,7 +182,7 @@ udatpg_openEmpty(UErrorCode *pErrorCode);
* @param dtpg a pointer to UDateTimePatternGenerator.
* @stable ICU 3.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udatpg_close(UDateTimePatternGenerator *dtpg);
#if U_SHOW_CPLUSPLUS_API
@@ -209,7 +212,7 @@ U_NAMESPACE_END
* @return a pointer to a new UDateTimePatternGenerator.
* @stable ICU 3.8
*/
-U_STABLE UDateTimePatternGenerator * U_EXPORT2
+U_CAPI UDateTimePatternGenerator * U_EXPORT2
udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
/**
@@ -235,7 +238,7 @@ udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
* @return the length of bestPattern.
* @stable ICU 3.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
udatpg_getBestPattern(UDateTimePatternGenerator *dtpg,
const UChar *skeleton, int32_t length,
UChar *bestPattern, int32_t capacity,
@@ -271,7 +274,7 @@ udatpg_getBestPattern(UDateTimePatternGenerator *dtpg,
* @return the length of bestPattern.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg,
const UChar *skeleton, int32_t length,
UDateTimePatternMatchOptions options,
@@ -299,7 +302,7 @@ udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg,
* @return the length of skeleton.
* @stable ICU 3.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
udatpg_getSkeleton(UDateTimePatternGenerator *unusedDtpg,
const UChar *pattern, int32_t length,
UChar *skeleton, int32_t capacity,
@@ -329,7 +332,7 @@ udatpg_getSkeleton(UDateTimePatternGenerator *unusedDtpg,
* @return the length of baseSkeleton.
* @stable ICU 3.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
udatpg_getBaseSkeleton(UDateTimePatternGenerator *unusedDtpg,
const UChar *pattern, int32_t length,
UChar *baseSkeleton, int32_t capacity,
@@ -359,7 +362,7 @@ udatpg_getBaseSkeleton(UDateTimePatternGenerator *unusedDtpg,
* UDATPG_BASE_CONFLICT or UDATPG_CONFLICT.
* @stable ICU 3.8
*/
-U_STABLE UDateTimePatternConflict U_EXPORT2
+U_CAPI UDateTimePatternConflict U_EXPORT2
udatpg_addPattern(UDateTimePatternGenerator *dtpg,
const UChar *pattern, int32_t patternLength,
UBool override,
@@ -386,7 +389,7 @@ udatpg_addPattern(UDateTimePatternGenerator *dtpg,
* @param length the length of value.
* @stable ICU 3.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
const UChar *value, int32_t length);
@@ -401,7 +404,7 @@ udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg,
* @return appendItemFormat for field.
* @stable ICU 3.8
*/
-U_STABLE const UChar * U_EXPORT2
+U_CAPI const UChar * U_EXPORT2
udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
int32_t *pLength);
@@ -419,7 +422,7 @@ udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg,
* @param length the length of value.
* @stable ICU 3.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
const UChar *value, int32_t length);
@@ -436,7 +439,7 @@ udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg,
* @see udatpg_getFieldDisplayName
* @stable ICU 3.8
*/
-U_STABLE const UChar * U_EXPORT2
+U_CAPI const UChar * U_EXPORT2
udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
int32_t *pLength);
@@ -466,7 +469,7 @@ udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg,
* truncated result.
* @stable ICU 61
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
udatpg_getFieldDisplayName(const UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
UDateTimePGDisplayWidth width,
@@ -496,7 +499,7 @@ udatpg_getFieldDisplayName(const UDateTimePatternGenerator *dtpg,
* @param length the length of dtFormat.
* @stable ICU 3.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg,
const UChar *dtFormat, int32_t length);
@@ -507,7 +510,7 @@ udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg,
* @return dateTimeFormat.
* @stable ICU 3.8
*/
-U_STABLE const UChar * U_EXPORT2
+U_CAPI const UChar * U_EXPORT2
udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg,
int32_t *pLength);
@@ -524,7 +527,7 @@ udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg,
* @param length the length of decimal.
* @stable ICU 3.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
udatpg_setDecimal(UDateTimePatternGenerator *dtpg,
const UChar *decimal, int32_t length);
@@ -536,7 +539,7 @@ udatpg_setDecimal(UDateTimePatternGenerator *dtpg,
* @return corresponding to the decimal point.
* @stable ICU 3.8
*/
-U_STABLE const UChar * U_EXPORT2
+U_CAPI const UChar * U_EXPORT2
udatpg_getDecimal(const UDateTimePatternGenerator *dtpg,
int32_t *pLength);
@@ -565,7 +568,7 @@ udatpg_getDecimal(const UDateTimePatternGenerator *dtpg,
* @return the length of dest.
* @stable ICU 3.8
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg,
const UChar *pattern, int32_t patternLength,
const UChar *skeleton, int32_t skeletonLength,
@@ -602,7 +605,7 @@ udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg,
* @return the length of dest.
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg,
const UChar *pattern, int32_t patternLength,
const UChar *skeleton, int32_t skeletonLength,
@@ -621,7 +624,7 @@ udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg,
* The caller must close the object.
* @stable ICU 3.8
*/
-U_STABLE UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
udatpg_openSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
/**
@@ -634,7 +637,7 @@ udatpg_openSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCo
* The caller must close the object.
* @stable ICU 3.8
*/
-U_STABLE UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
/**
@@ -647,7 +650,7 @@ udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErr
* @return pattern corresponding to a given skeleton.
* @stable ICU 3.8
*/
-U_STABLE const UChar * U_EXPORT2
+U_CAPI const UChar * U_EXPORT2
udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg,
const UChar *skeleton, int32_t skeletonLength,
int32_t *pLength);
@@ -668,7 +671,7 @@ udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg,
* @return the default hour cycle.
* @draft ICU 67
*/
-U_DRAFT UDateFormatHourCycle U_EXPORT2
+U_CAPI UDateFormatHourCycle U_EXPORT2
udatpg_getDefaultHourCycle(const UDateTimePatternGenerator *dtpg, UErrorCode* pErrorCode);
#endif /* U_HIDE_DRAFT_API */
diff --git a/deps/icu-small/source/i18n/unicode/ufieldpositer.h b/deps/icu-small/source/i18n/unicode/ufieldpositer.h
index 3ae73b6d84..83df184f0a 100644
--- a/deps/icu-small/source/i18n/unicode/ufieldpositer.h
+++ b/deps/icu-small/source/i18n/unicode/ufieldpositer.h
@@ -14,7 +14,9 @@
#if !UCONFIG_NO_FORMATTING
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
@@ -52,7 +54,7 @@ typedef struct UFieldPositionIterator UFieldPositionIterator; /**< C typedef fo
* or NULL if an error occurred.
* @stable ICU 55
*/
-U_STABLE UFieldPositionIterator* U_EXPORT2
+U_CAPI UFieldPositionIterator* U_EXPORT2
ufieldpositer_open(UErrorCode* status);
/**
@@ -61,7 +63,7 @@ ufieldpositer_open(UErrorCode* status);
* A pointer to the UFieldPositionIterator object to close.
* @stable ICU 55
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ufieldpositer_close(UFieldPositionIterator *fpositer);
@@ -112,7 +114,7 @@ U_NAMESPACE_END
*
* @stable ICU 55
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ufieldpositer_next(UFieldPositionIterator *fpositer,
int32_t *beginIndex, int32_t *endIndex);
diff --git a/deps/icu-small/source/i18n/unicode/uformattable.h b/deps/icu-small/source/i18n/unicode/uformattable.h
index 9ba2a36901..6b8bee1f3d 100644
--- a/deps/icu-small/source/i18n/unicode/uformattable.h
+++ b/deps/icu-small/source/i18n/unicode/uformattable.h
@@ -34,7 +34,9 @@
#if !UCONFIG_NO_FORMATTING
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* Enum designating the type of a UFormattable instance.
@@ -79,7 +81,7 @@ typedef void *UFormattable;
* @see ufmt_close
* @see icu::Formattable::Formattable()
*/
-U_STABLE UFormattable* U_EXPORT2
+U_CAPI UFormattable* U_EXPORT2
ufmt_open(UErrorCode* status);
/**
@@ -88,7 +90,7 @@ ufmt_open(UErrorCode* status);
* @stable ICU 52
* @see ufmt_open
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ufmt_close(UFormattable* fmt);
#if U_SHOW_CPLUSPLUS_API
@@ -120,7 +122,7 @@ U_NAMESPACE_END
* @see icu::Formattable::getType() const
* @stable ICU 52
*/
-U_STABLE UFormattableType U_EXPORT2
+U_CAPI UFormattableType U_EXPORT2
ufmt_getType(const UFormattable* fmt, UErrorCode *status);
/**
@@ -131,7 +133,7 @@ ufmt_getType(const UFormattable* fmt, UErrorCode *status);
* @see icu::Formattable::isNumeric() const
* @stable ICU 52
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ufmt_isNumeric(const UFormattable* fmt);
/**
@@ -144,7 +146,7 @@ ufmt_isNumeric(const UFormattable* fmt);
* @stable ICU 52
* @see icu::Formattable::getDate(UErrorCode&) const
*/
-U_STABLE UDate U_EXPORT2
+U_CAPI UDate U_EXPORT2
ufmt_getDate(const UFormattable* fmt, UErrorCode *status);
/**
@@ -162,7 +164,7 @@ ufmt_getDate(const UFormattable* fmt, UErrorCode *status);
* @stable ICU 52
* @see icu::Formattable::getDouble(UErrorCode&) const
*/
-U_STABLE double U_EXPORT2
+U_CAPI double U_EXPORT2
ufmt_getDouble(UFormattable* fmt, UErrorCode *status);
/**
@@ -183,7 +185,7 @@ ufmt_getDouble(UFormattable* fmt, UErrorCode *status);
* @stable ICU 52
* @see icu::Formattable::getLong(UErrorCode&) const
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ufmt_getLong(UFormattable* fmt, UErrorCode *status);
@@ -204,7 +206,7 @@ ufmt_getLong(UFormattable* fmt, UErrorCode *status);
* @stable ICU 52
* @see icu::Formattable::getInt64(UErrorCode&) const
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
ufmt_getInt64(UFormattable* fmt, UErrorCode *status);
/**
@@ -217,7 +219,7 @@ ufmt_getInt64(UFormattable* fmt, UErrorCode *status);
* @stable ICU 52
* @see icu::Formattable::getObject() const
*/
-U_STABLE const void *U_EXPORT2
+U_CAPI const void *U_EXPORT2
ufmt_getObject(const UFormattable* fmt, UErrorCode *status);
/**
@@ -232,7 +234,7 @@ ufmt_getObject(const UFormattable* fmt, UErrorCode *status);
* @stable ICU 52
* @see icu::Formattable::getString(UnicodeString&)const
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ufmt_getUChars(UFormattable* fmt, int32_t *len, UErrorCode *status);
/**
@@ -243,7 +245,7 @@ ufmt_getUChars(UFormattable* fmt, int32_t *len, UErrorCode *status);
* @stable ICU 52
* @see ufmt_getArrayItemByIndex
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ufmt_getArrayLength(const UFormattable* fmt, UErrorCode *status);
/**
@@ -255,7 +257,7 @@ ufmt_getArrayLength(const UFormattable* fmt, UErrorCode *status);
* @stable ICU 52
* @see icu::Formattable::getArray(int32_t&, UErrorCode&) const
*/
-U_STABLE UFormattable * U_EXPORT2
+U_CAPI UFormattable * U_EXPORT2
ufmt_getArrayItemByIndex(UFormattable* fmt, int32_t n, UErrorCode *status);
/**
@@ -280,7 +282,7 @@ ufmt_getArrayItemByIndex(UFormattable* fmt, int32_t n, UErrorCode *status);
* @stable ICU 52
* @see icu::Formattable::getDecimalNumber(UErrorCode&)
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
ufmt_getDecNumChars(UFormattable *fmt, int32_t *len, UErrorCode *status);
#endif
diff --git a/deps/icu-small/source/i18n/unicode/uformattedvalue.h b/deps/icu-small/source/i18n/unicode/uformattedvalue.h
index 71a6592e9d..3017372d8b 100644
--- a/deps/icu-small/source/i18n/unicode/uformattedvalue.h
+++ b/deps/icu-small/source/i18n/unicode/uformattedvalue.h
@@ -120,7 +120,7 @@ typedef struct UConstrainedFieldPosition UConstrainedFieldPosition;
* @return The new object, or NULL if an error occurs.
* @stable ICU 64
*/
-U_STABLE UConstrainedFieldPosition* U_EXPORT2
+U_CAPI UConstrainedFieldPosition* U_EXPORT2
ucfpos_open(UErrorCode* ec);
@@ -133,7 +133,7 @@ ucfpos_open(UErrorCode* ec);
* @param ec Set if an error occurs.
* @stable ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucfpos_reset(
UConstrainedFieldPosition* ucfpos,
UErrorCode* ec);
@@ -145,7 +145,7 @@ ucfpos_reset(
* @param ucfpos The instance of UConstrainedFieldPosition.
* @stable ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucfpos_close(UConstrainedFieldPosition* ucfpos);
@@ -174,7 +174,7 @@ ucfpos_close(UConstrainedFieldPosition* ucfpos);
* @param ec Set if an error occurs.
* @stable ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucfpos_constrainCategory(
UConstrainedFieldPosition* ucfpos,
int32_t category,
@@ -207,7 +207,7 @@ ucfpos_constrainCategory(
* @param ec Set if an error occurs.
* @stable ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucfpos_constrainField(
UConstrainedFieldPosition* ucfpos,
int32_t category,
@@ -220,14 +220,14 @@ ucfpos_constrainField(
*
* If a category or field constraint was set, this function returns the constrained
* category. Otherwise, the return value is well-defined only after
- * ufmtval_nextPosition returns TRUE.
+ * ufmtval_nextPosition returns true.
*
* @param ucfpos The instance of UConstrainedFieldPosition.
* @param ec Set if an error occurs.
* @return The field category saved in the instance.
* @stable ICU 64
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucfpos_getCategory(
const UConstrainedFieldPosition* ucfpos,
UErrorCode* ec);
@@ -238,14 +238,14 @@ ucfpos_getCategory(
*
* If a field constraint was set, this function returns the constrained
* field. Otherwise, the return value is well-defined only after
- * ufmtval_nextPosition returns TRUE.
+ * ufmtval_nextPosition returns true.
*
* @param ucfpos The instance of UConstrainedFieldPosition.
* @param ec Set if an error occurs.
* @return The field saved in the instance.
* @stable ICU 64
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ucfpos_getField(
const UConstrainedFieldPosition* ucfpos,
UErrorCode* ec);
@@ -254,7 +254,7 @@ ucfpos_getField(
/**
* Gets the INCLUSIVE start and EXCLUSIVE end index stored for the current position.
*
- * The output values are well-defined only after ufmtval_nextPosition returns TRUE.
+ * The output values are well-defined only after ufmtval_nextPosition returns true.
*
* @param ucfpos The instance of UConstrainedFieldPosition.
* @param pStart Set to the start index saved in the instance. Ignored if nullptr.
@@ -262,7 +262,7 @@ ucfpos_getField(
* @param ec Set if an error occurs.
* @stable ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucfpos_getIndexes(
const UConstrainedFieldPosition* ucfpos,
int32_t* pStart,
@@ -282,7 +282,7 @@ ucfpos_getIndexes(
* @return The current iteration context from ucfpos_setInt64IterationContext.
* @stable ICU 64
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
ucfpos_getInt64IterationContext(
const UConstrainedFieldPosition* ucfpos,
UErrorCode* ec);
@@ -298,7 +298,7 @@ ucfpos_getInt64IterationContext(
* @param ec Set if an error occurs.
* @stable ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucfpos_setInt64IterationContext(
UConstrainedFieldPosition* ucfpos,
int64_t context,
@@ -317,7 +317,7 @@ ucfpos_setInt64IterationContext(
* @param ec Set if an error occurs.
* @stable ICU 64
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ucfpos_matchesField(
const UConstrainedFieldPosition* ucfpos,
int32_t category,
@@ -341,7 +341,7 @@ ucfpos_matchesField(
* @param ec Set if an error occurs.
* @stable ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ucfpos_setState(
UConstrainedFieldPosition* ucfpos,
int32_t category,
@@ -374,7 +374,7 @@ typedef struct UFormattedValue UFormattedValue;
* @return A NUL-terminated char16 string owned by the UFormattedValue.
* @stable ICU 64
*/
-U_STABLE const UChar* U_EXPORT2
+U_CAPI const UChar* U_EXPORT2
ufmtval_getString(
const UFormattedValue* ufmtval,
int32_t* pLength,
@@ -401,10 +401,10 @@ ufmtval_getString(
* see ucfpos_constrainCategory
* and ucfpos_constrainField.
* @param ec Set if an error occurs.
- * @return TRUE if another position was found; FALSE otherwise.
+ * @return true if another position was found; false otherwise.
* @stable ICU 64
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ufmtval_nextPosition(
const UFormattedValue* ufmtval,
UConstrainedFieldPosition* ucfpos,
diff --git a/deps/icu-small/source/i18n/unicode/ugender.h b/deps/icu-small/source/i18n/unicode/ugender.h
index 903f3dd5de..7093686b8f 100644
--- a/deps/icu-small/source/i18n/unicode/ugender.h
+++ b/deps/icu-small/source/i18n/unicode/ugender.h
@@ -14,7 +14,9 @@
#if !UCONFIG_NO_FORMATTING
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
@@ -63,7 +65,7 @@ typedef struct UGenderInfo UGenderInfo;
* @return A UGenderInfo for the specified locale, or NULL if an error occurred.
* @stable ICU 50
*/
-U_STABLE const UGenderInfo* U_EXPORT2
+U_CAPI const UGenderInfo* U_EXPORT2
ugender_getInstance(const char *locale, UErrorCode *status);
@@ -76,7 +78,7 @@ ugender_getInstance(const char *locale, UErrorCode *status);
* @return The gender of the list.
* @stable ICU 50
*/
-U_STABLE UGender U_EXPORT2
+U_CAPI UGender U_EXPORT2
ugender_getListGender(const UGenderInfo* genderInfo, const UGender *genders, int32_t size, UErrorCode *status);
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/unicode/ulistformatter.h b/deps/icu-small/source/i18n/unicode/ulistformatter.h
index 66cf50190b..3dfa9f2d56 100644
--- a/deps/icu-small/source/i18n/unicode/ulistformatter.h
+++ b/deps/icu-small/source/i18n/unicode/ulistformatter.h
@@ -14,9 +14,12 @@
#if !UCONFIG_NO_FORMATTING
-#include "unicode/localpointer.h"
#include "unicode/uformattedvalue.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* \file
* \brief C API: Format a list in a locale-appropriate way.
@@ -161,7 +164,7 @@ ulistfmt_open(const char* locale,
* or NULL if an error occurred.
* @draft ICU 67
*/
-U_DRAFT UListFormatter* U_EXPORT2
+U_CAPI UListFormatter* U_EXPORT2
ulistfmt_openForType(const char* locale, UListFormatterType type,
UListFormatterWidth width, UErrorCode* status);
#endif /* U_HIDE_DRAFT_API */
diff --git a/deps/icu-small/source/i18n/unicode/ulocdata.h b/deps/icu-small/source/i18n/unicode/ulocdata.h
index de8d8539c6..3977743e32 100644
--- a/deps/icu-small/source/i18n/unicode/ulocdata.h
+++ b/deps/icu-small/source/i18n/unicode/ulocdata.h
@@ -22,7 +22,10 @@
#include "unicode/ures.h"
#include "unicode/uloc.h"
#include "unicode/uset.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
@@ -87,7 +90,7 @@ typedef enum ULocaleDataDelimiterType {
* @param status Pointer to error status code.
* @stable ICU 3.4
*/
-U_STABLE ULocaleData* U_EXPORT2
+U_CAPI ULocaleData* U_EXPORT2
ulocdata_open(const char *localeID, UErrorCode *status);
/**
@@ -96,7 +99,7 @@ ulocdata_open(const char *localeID, UErrorCode *status);
* @param uld The locale data object to close
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocdata_close(ULocaleData *uld);
#if U_SHOW_CPLUSPLUS_API
@@ -129,7 +132,7 @@ U_NAMESPACE_END
* @param setting Value of the "no substitute" attribute.
* @stable ICU 3.4
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocdata_setNoSubstitute(ULocaleData *uld, UBool setting);
/**
@@ -143,7 +146,7 @@ ulocdata_setNoSubstitute(ULocaleData *uld, UBool setting);
* @return UBool Value of the "no substitute" attribute.
* @stable ICU 3.4
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
ulocdata_getNoSubstitute(ULocaleData *uld);
/**
@@ -173,7 +176,7 @@ ulocdata_getNoSubstitute(ULocaleData *uld);
* In case of error, NULL is returned.
* @stable ICU 3.4
*/
-U_STABLE USet* U_EXPORT2
+U_CAPI USet* U_EXPORT2
ulocdata_getExemplarSet(ULocaleData *uld, USet *fillIn,
uint32_t options, ULocaleDataExemplarSetType extype, UErrorCode *status);
@@ -190,7 +193,7 @@ ulocdata_getExemplarSet(ULocaleData *uld, USet *fillIn,
* the output was truncated.
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ulocdata_getDelimiter(ULocaleData *uld, ULocaleDataDelimiterType type, UChar *result, int32_t resultLength, UErrorCode *status);
/**
@@ -220,7 +223,7 @@ typedef enum UMeasurementSystem {
* @return UMeasurementSystem the measurement system used in the locale.
* @stable ICU 2.8
*/
-U_STABLE UMeasurementSystem U_EXPORT2
+U_CAPI UMeasurementSystem U_EXPORT2
ulocdata_getMeasurementSystem(const char *localeID, UErrorCode *status);
/**
@@ -239,7 +242,7 @@ ulocdata_getMeasurementSystem(const char *localeID, UErrorCode *status);
* which must not indicate a failure before the function call.
* @stable ICU 2.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocdata_getPaperSize(const char *localeID, int32_t *height, int32_t *width, UErrorCode *status);
/**
@@ -248,7 +251,7 @@ ulocdata_getPaperSize(const char *localeID, int32_t *height, int32_t *width, UEr
* @param status error code - could be U_MISSING_RESOURCE_ERROR if the version was not found.
* @stable ICU 4.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ulocdata_getCLDRVersion(UVersionInfo versionArray, UErrorCode *status);
/**
@@ -266,7 +269,7 @@ ulocdata_getCLDRVersion(UVersionInfo versionArray, UErrorCode *status);
*
* @stable ICU 4.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ulocdata_getLocaleDisplayPattern(ULocaleData *uld,
UChar *pattern,
int32_t patternCapacity,
@@ -288,7 +291,7 @@ ulocdata_getLocaleDisplayPattern(ULocaleData *uld,
*
* @stable ICU 4.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ulocdata_getLocaleSeparator(ULocaleData *uld,
UChar *separator,
int32_t separatorCapacity,
diff --git a/deps/icu-small/source/i18n/unicode/umsg.h b/deps/icu-small/source/i18n/unicode/umsg.h
index 6818820612..c087031c6d 100644
--- a/deps/icu-small/source/i18n/unicode/umsg.h
+++ b/deps/icu-small/source/i18n/unicode/umsg.h
@@ -24,11 +24,14 @@
#if !UCONFIG_NO_FORMATTING
-#include "unicode/localpointer.h"
#include "unicode/uloc.h"
#include "unicode/parseerr.h"
#include <stdarg.h>
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* \file
* \brief C API: MessageFormat
@@ -175,7 +178,7 @@
* @see u_parseMessage
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_formatMessage(const char *locale,
const UChar *pattern,
int32_t patternLength,
@@ -202,7 +205,7 @@ u_formatMessage(const char *locale,
* @see u_parseMessage
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_vformatMessage( const char *locale,
const UChar *pattern,
int32_t patternLength,
@@ -227,7 +230,7 @@ u_vformatMessage( const char *locale,
* @see u_formatMessage
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_parseMessage( const char *locale,
const UChar *pattern,
int32_t patternLength,
@@ -252,7 +255,7 @@ u_parseMessage( const char *locale,
* @see u_formatMessage
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_vparseMessage(const char *locale,
const UChar *pattern,
int32_t patternLength,
@@ -281,7 +284,7 @@ u_vparseMessage(const char *locale,
* @see u_parseMessage
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_formatMessageWithError( const char *locale,
const UChar *pattern,
int32_t patternLength,
@@ -310,7 +313,7 @@ u_formatMessageWithError( const char *locale,
* output was truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
u_vformatMessageWithError( const char *locale,
const UChar *pattern,
int32_t patternLength,
@@ -338,7 +341,7 @@ u_vformatMessageWithError( const char *locale,
* @see u_formatMessage
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_parseMessageWithError(const char *locale,
const UChar *pattern,
int32_t patternLength,
@@ -366,7 +369,7 @@ u_parseMessageWithError(const char *locale,
* @see u_formatMessage
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
u_vparseMessageWithError(const char *locale,
const UChar *pattern,
int32_t patternLength,
@@ -396,7 +399,7 @@ typedef void* UMessageFormat;
* messages, or 0 if an error occurred.
* @stable ICU 2.0
*/
-U_STABLE UMessageFormat* U_EXPORT2
+U_CAPI UMessageFormat* U_EXPORT2
umsg_open( const UChar *pattern,
int32_t patternLength,
const char *locale,
@@ -409,7 +412,7 @@ umsg_open( const UChar *pattern,
* @param format The formatter to close.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
umsg_close(UMessageFormat* format);
#if U_SHOW_CPLUSPLUS_API
@@ -439,7 +442,7 @@ U_NAMESPACE_END
* @return A pointer to a UDateFormat identical to fmt.
* @stable ICU 2.0
*/
-U_STABLE UMessageFormat U_EXPORT2
+U_CAPI UMessageFormat U_EXPORT2
umsg_clone(const UMessageFormat *fmt,
UErrorCode *status);
@@ -450,7 +453,7 @@ umsg_clone(const UMessageFormat *fmt,
* @param locale The locale the formatter should use.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
umsg_setLocale(UMessageFormat *fmt,
const char* locale);
@@ -461,7 +464,7 @@ umsg_setLocale(UMessageFormat *fmt,
* @return the locale.
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
umsg_getLocale(const UMessageFormat *fmt);
/**
@@ -476,7 +479,7 @@ umsg_getLocale(const UMessageFormat *fmt);
* set to a failure result.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
umsg_applyPattern( UMessageFormat *fmt,
const UChar* pattern,
int32_t patternLength,
@@ -494,7 +497,7 @@ umsg_applyPattern( UMessageFormat *fmt,
* @return the pattern of the format
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
umsg_toPattern(const UMessageFormat *fmt,
UChar* result,
int32_t resultLength,
@@ -515,7 +518,7 @@ umsg_toPattern(const UMessageFormat *fmt,
* the output was truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
umsg_format( const UMessageFormat *fmt,
UChar *result,
int32_t resultLength,
@@ -537,7 +540,7 @@ umsg_format( const UMessageFormat *fmt,
* the output was truncated.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
umsg_vformat( const UMessageFormat *fmt,
UChar *result,
int32_t resultLength,
@@ -558,7 +561,7 @@ umsg_vformat( const UMessageFormat *fmt,
* specified in pattern.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
umsg_parse( const UMessageFormat *fmt,
const UChar *source,
int32_t sourceLength,
@@ -581,7 +584,7 @@ umsg_parse( const UMessageFormat *fmt,
* @see u_formatMessage
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
umsg_vparse(const UMessageFormat *fmt,
const UChar *source,
int32_t sourceLength,
@@ -613,7 +616,7 @@ umsg_vparse(const UMessageFormat *fmt,
* not
* @stable ICU 3.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
umsg_autoQuoteApostrophe(const UChar* pattern,
int32_t patternLength,
UChar* dest,
diff --git a/deps/icu-small/source/i18n/unicode/unirepl.h b/deps/icu-small/source/i18n/unicode/unirepl.h
index 61ee37f070..891a1d527f 100644
--- a/deps/icu-small/source/i18n/unicode/unirepl.h
+++ b/deps/icu-small/source/i18n/unicode/unirepl.h
@@ -77,7 +77,7 @@ class U_I18N_API UnicodeReplacer /* not : public UObject because this is an inte
* replacer that is equal to this one.
* @param result the string to receive the pattern. Previous
* contents will be deleted.
- * @param escapeUnprintable if TRUE then convert unprintable
+ * @param escapeUnprintable if true then convert unprintable
* character to their hex escape representations, \\uxxxx or
* \\Uxxxxxxxx. Unprintable characters are defined by
* Utility.isUnprintable().
diff --git a/deps/icu-small/source/i18n/unicode/unum.h b/deps/icu-small/source/i18n/unicode/unum.h
index b5f21ea585..ce1685f129 100644
--- a/deps/icu-small/source/i18n/unicode/unum.h
+++ b/deps/icu-small/source/i18n/unicode/unum.h
@@ -18,7 +18,6 @@
#if !UCONFIG_NO_FORMATTING
-#include "unicode/localpointer.h"
#include "unicode/uloc.h"
#include "unicode/ucurr.h"
#include "unicode/umisc.h"
@@ -27,6 +26,10 @@
#include "unicode/udisplaycontext.h"
#include "unicode/ufieldpositer.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* \file
* \brief C API: Compatibility APIs for number formatting.
@@ -272,7 +275,7 @@ typedef enum UNumberFormatStyle {
*
* <p>
* For more detail on rounding modes, see:
- * http://userguide.icu-project.org/formatparse/numbers/rounding-modes
+ * https://unicode-org.github.io/icu/userguide/format_parse/numbers/rounding-modes
*
* @stable ICU 2.0
*/
@@ -392,6 +395,30 @@ typedef enum UNumberFormatFields {
} UNumberFormatFields;
+#ifndef U_HIDE_DRAFT_API
+/**
+ * Selectors with special numeric values to use locale default minimum grouping
+ * digits for the DecimalFormat/UNumberFormat setMinimumGroupingDigits method.
+ * Do not use these constants with the [U]NumberFormatter API.
+ *
+ * @draft ICU 68
+ */
+typedef enum UNumberFormatMinimumGroupingDigits {
+ /**
+ * Display grouping using the default strategy for all locales.
+ * @draft ICU 68
+ */
+ UNUM_MINIMUM_GROUPING_DIGITS_AUTO = -2,
+ /**
+ * Display grouping using locale defaults, except do not show grouping on
+ * values smaller than 10000 (such that there is a minimum of two digits
+ * before the first separator).
+ * @draft ICU 68
+ */
+ UNUM_MINIMUM_GROUPING_DIGITS_MIN2 = -3,
+} UNumberFormatMinimumGroupingDigits;
+#endif // U_HIDE_DRAFT_API
+
/**
* Create and return a new UNumberFormat for formatting and parsing
* numbers. A UNumberFormat may be used to format numbers by calling
@@ -429,7 +456,7 @@ typedef enum UNumberFormatFields {
* @see DecimalFormat
* @stable ICU 2.0
*/
-U_STABLE UNumberFormat* U_EXPORT2
+U_CAPI UNumberFormat* U_EXPORT2
unum_open( UNumberFormatStyle style,
const UChar* pattern,
int32_t patternLength,
@@ -444,7 +471,7 @@ unum_open( UNumberFormatStyle style,
* @param fmt The formatter to close.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unum_close(UNumberFormat* fmt);
#if U_SHOW_CPLUSPLUS_API
@@ -474,7 +501,7 @@ U_NAMESPACE_END
* @return A pointer to a UNumberFormat identical to fmt.
* @stable ICU 2.0
*/
-U_STABLE UNumberFormat* U_EXPORT2
+U_CAPI UNumberFormat* U_EXPORT2
unum_clone(const UNumberFormat *fmt,
UErrorCode *status);
@@ -502,7 +529,7 @@ unum_clone(const UNumberFormat *fmt,
* @see UFieldPosition
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_format( const UNumberFormat* fmt,
int32_t number,
UChar* result,
@@ -534,7 +561,7 @@ unum_format( const UNumberFormat* fmt,
* @see UFieldPosition
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_formatInt64(const UNumberFormat *fmt,
int64_t number,
UChar* result,
@@ -566,7 +593,7 @@ unum_formatInt64(const UNumberFormat *fmt,
* @see UFieldPosition
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_formatDouble( const UNumberFormat* fmt,
double number,
UChar* result,
@@ -616,7 +643,7 @@ unum_formatDouble( const UNumberFormat* fmt,
* @see UNumberFormatFields
* @stable ICU 59
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_formatDoubleForFields(const UNumberFormat* format,
double number,
UChar* result,
@@ -653,7 +680,7 @@ unum_formatDoubleForFields(const UNumberFormat* format,
* @see UFieldPosition
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_formatDecimal( const UNumberFormat* fmt,
const char * number,
int32_t length,
@@ -686,7 +713,7 @@ unum_formatDecimal( const UNumberFormat* fmt,
* @see UFieldPosition
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_formatDoubleCurrency(const UNumberFormat* fmt,
double number,
UChar* currency,
@@ -715,7 +742,7 @@ unum_formatDoubleCurrency(const UNumberFormat* fmt,
* @see unum_parseToUFormattable
* @stable ICU 52
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_formatUFormattable(const UNumberFormat* fmt,
const UFormattable *number,
UChar *result,
@@ -742,7 +769,7 @@ unum_formatUFormattable(const UNumberFormat* fmt,
* @see unum_formatDouble
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_parse( const UNumberFormat* fmt,
const UChar* text,
int32_t textLength,
@@ -768,7 +795,7 @@ unum_parse( const UNumberFormat* fmt,
* @see unum_formatDouble
* @stable ICU 2.8
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
unum_parseInt64(const UNumberFormat* fmt,
const UChar* text,
int32_t textLength,
@@ -794,7 +821,7 @@ unum_parseInt64(const UNumberFormat* fmt,
* @see unum_formatDouble
* @stable ICU 2.0
*/
-U_STABLE double U_EXPORT2
+U_CAPI double U_EXPORT2
unum_parseDouble( const UNumberFormat* fmt,
const UChar* text,
int32_t textLength,
@@ -829,7 +856,7 @@ unum_parseDouble( const UNumberFormat* fmt,
* @see unum_formatDouble
* @stable ICU 4.4
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_parseDecimal(const UNumberFormat* fmt,
const UChar* text,
int32_t textLength,
@@ -857,7 +884,7 @@ unum_parseDecimal(const UNumberFormat* fmt,
* @see unum_formatDoubleCurrency
* @stable ICU 3.0
*/
-U_STABLE double U_EXPORT2
+U_CAPI double U_EXPORT2
unum_parseDoubleCurrency(const UNumberFormat* fmt,
const UChar* text,
int32_t textLength,
@@ -885,7 +912,7 @@ unum_parseDoubleCurrency(const UNumberFormat* fmt,
* @see ufmt_close
* @stable ICU 52
*/
-U_STABLE UFormattable* U_EXPORT2
+U_CAPI UFormattable* U_EXPORT2
unum_parseToUFormattable(const UNumberFormat* fmt,
UFormattable *result,
const UChar* text,
@@ -898,7 +925,7 @@ unum_parseToUFormattable(const UNumberFormat* fmt,
* on a DecimalFormat, other formats return U_UNSUPPORTED_ERROR
* in the status.
* @param format The formatter to set.
- * @param localized TRUE if the pattern is localized, FALSE otherwise.
+ * @param localized true if the pattern is localized, false otherwise.
* @param pattern The new pattern
* @param patternLength The length of pattern, or -1 if null-terminated.
* @param parseError A pointer to UParseError to receive information
@@ -909,7 +936,7 @@ unum_parseToUFormattable(const UNumberFormat* fmt,
* @see DecimalFormat
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unum_applyPattern( UNumberFormat *format,
UBool localized,
const UChar *pattern,
@@ -928,7 +955,7 @@ unum_applyPattern( UNumberFormat *format,
* @see unum_countAvailable
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
unum_getAvailable(int32_t localeIndex);
/**
@@ -940,7 +967,7 @@ unum_getAvailable(int32_t localeIndex);
* @see unum_getAvailable
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_countAvailable(void);
#if UCONFIG_HAVE_PARSEALLINPUT
@@ -1121,7 +1148,7 @@ typedef enum UNumberFormatAttribute {
* @see unum_setTextAttribute
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_getAttribute(const UNumberFormat* fmt,
UNumberFormatAttribute attr);
@@ -1144,7 +1171,7 @@ unum_getAttribute(const UNumberFormat* fmt,
* @see unum_setTextAttribute
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unum_setAttribute( UNumberFormat* fmt,
UNumberFormatAttribute attr,
int32_t newValue);
@@ -1164,7 +1191,7 @@ unum_setAttribute( UNumberFormat* fmt,
* @see unum_setTextAttribute
* @stable ICU 2.0
*/
-U_STABLE double U_EXPORT2
+U_CAPI double U_EXPORT2
unum_getDoubleAttribute(const UNumberFormat* fmt,
UNumberFormatAttribute attr);
@@ -1182,7 +1209,7 @@ unum_getDoubleAttribute(const UNumberFormat* fmt,
* @see unum_setTextAttribute
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unum_setDoubleAttribute( UNumberFormat* fmt,
UNumberFormatAttribute attr,
double newValue);
@@ -1239,7 +1266,7 @@ typedef enum UNumberFormatTextAttribute {
* @see unum_setAttribute
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_getTextAttribute( const UNumberFormat* fmt,
UNumberFormatTextAttribute tag,
UChar* result,
@@ -1262,7 +1289,7 @@ unum_getTextAttribute( const UNumberFormat* fmt,
* @see unum_setAttribute
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unum_setTextAttribute( UNumberFormat* fmt,
UNumberFormatTextAttribute tag,
const UChar* newValue,
@@ -1273,8 +1300,8 @@ unum_setTextAttribute( UNumberFormat* fmt,
* Extract the pattern from a UNumberFormat. The pattern will follow
* the DecimalFormat pattern syntax.
* @param fmt The formatter to query.
- * @param isPatternLocalized TRUE if the pattern should be localized,
- * FALSE otherwise. This is ignored if the formatter is a rule-based
+ * @param isPatternLocalized true if the pattern should be localized,
+ * false otherwise. This is ignored if the formatter is a rule-based
* formatter.
* @param result A pointer to a buffer to receive the pattern.
* @param resultLength The maximum size of result.
@@ -1285,7 +1312,7 @@ unum_setTextAttribute( UNumberFormat* fmt,
* @see DecimalFormat
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_toPattern( const UNumberFormat* fmt,
UBool isPatternLocalized,
UChar* result,
@@ -1404,7 +1431,7 @@ typedef enum UNumberFormatSymbol {
* @see unum_setSymbol
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_getSymbol(const UNumberFormat *fmt,
UNumberFormatSymbol symbol,
UChar *buffer,
@@ -1424,7 +1451,7 @@ unum_getSymbol(const UNumberFormat *fmt,
* @see unum_getSymbol
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unum_setSymbol(UNumberFormat *fmt,
UNumberFormatSymbol symbol,
const UChar *value,
@@ -1441,7 +1468,7 @@ unum_setSymbol(UNumberFormat *fmt,
* @return the locale name
* @stable ICU 2.8
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
unum_getLocaleByType(const UNumberFormat *fmt,
ULocDataLocaleType type,
UErrorCode* status);
@@ -1454,7 +1481,7 @@ unum_getLocaleByType(const UNumberFormat *fmt,
* @param status A pointer to an UErrorCode to receive any errors
* @stable ICU 53
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unum_setContext(UNumberFormat* fmt, UDisplayContext value, UErrorCode* status);
/**
@@ -1466,7 +1493,7 @@ unum_setContext(UNumberFormat* fmt, UDisplayContext value, UErrorCode* status);
* @return The UDisplayContextValue for the specified type.
* @stable ICU 53
*/
-U_STABLE UDisplayContext U_EXPORT2
+U_CAPI UDisplayContext U_EXPORT2
unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode* status);
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/unicode/unumberformatter.h b/deps/icu-small/source/i18n/unicode/unumberformatter.h
index af98ba0027..754987aea0 100644
--- a/deps/icu-small/source/i18n/unicode/unumberformatter.h
+++ b/deps/icu-small/source/i18n/unicode/unumberformatter.h
@@ -1,11 +1,12 @@
// © 2018 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
+#ifndef __UNUMBERFORMATTER_H__
+#define __UNUMBERFORMATTER_H__
+
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
-#ifndef __UNUMBERFORMATTER_H__
-#define __UNUMBERFORMATTER_H__
#include "unicode/parseerr.h"
#include "unicode/ufieldpositer.h"
@@ -147,6 +148,30 @@ typedef enum UNumberUnitWidth {
*/
UNUM_UNIT_WIDTH_ISO_CODE,
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Use the formal variant of the currency symbol; for example, "NT$" for the New Taiwan
+ * dollar in zh-TW.
+ *
+ * <p>
+ * Behavior of this option with non-currency units is not defined at this time.
+ *
+ * @draft ICU 68
+ */
+ UNUM_UNIT_WIDTH_FORMAL,
+
+ /**
+ * Use the alternate variant of the currency symbol; for example, "TL" for the Turkish
+ * lira (TRY).
+ *
+ * <p>
+ * Behavior of this option with non-currency units is not defined at this time.
+ *
+ * @draft ICU 68
+ */
+ UNUM_UNIT_WIDTH_VARIANT,
+#endif // U_HIDE_DRAFT_API
+
/**
* Format the number according to the specified unit, but do not display the unit. For currencies, apply
* monetary symbols and formats as with SHORT, but omit the currency symbol. For measure units, the behavior is
@@ -432,7 +457,7 @@ typedef struct UFormattedNumber UFormattedNumber;
* @param ec Set if an error occurs.
* @stable ICU 62
*/
-U_STABLE UNumberFormatter* U_EXPORT2
+U_CAPI UNumberFormatter* U_EXPORT2
unumf_openForSkeletonAndLocale(const UChar* skeleton, int32_t skeletonLen, const char* locale,
UErrorCode* ec);
@@ -449,7 +474,7 @@ unumf_openForSkeletonAndLocale(const UChar* skeleton, int32_t skeletonLen, const
* @param ec Set if an error occurs.
* @stable ICU 64
*/
-U_STABLE UNumberFormatter* U_EXPORT2
+U_CAPI UNumberFormatter* U_EXPORT2
unumf_openForSkeletonAndLocaleWithError(
const UChar* skeleton, int32_t skeletonLen, const char* locale, UParseError* perror, UErrorCode* ec);
@@ -462,7 +487,7 @@ unumf_openForSkeletonAndLocaleWithError(
* @param ec Set if an error occurs.
* @stable ICU 62
*/
-U_STABLE UFormattedNumber* U_EXPORT2
+U_CAPI UFormattedNumber* U_EXPORT2
unumf_openResult(UErrorCode* ec);
@@ -481,7 +506,7 @@ unumf_openResult(UErrorCode* ec);
* @param ec Set if an error occurs.
* @stable ICU 62
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unumf_formatInt(const UNumberFormatter* uformatter, int64_t value, UFormattedNumber* uresult,
UErrorCode* ec);
@@ -501,7 +526,7 @@ unumf_formatInt(const UNumberFormatter* uformatter, int64_t value, UFormattedNum
* @param ec Set if an error occurs.
* @stable ICU 62
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unumf_formatDouble(const UNumberFormatter* uformatter, double value, UFormattedNumber* uresult,
UErrorCode* ec);
@@ -525,7 +550,7 @@ unumf_formatDouble(const UNumberFormatter* uformatter, double value, UFormattedN
* @param ec Set if an error occurs.
* @stable ICU 62
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unumf_formatDecimal(const UNumberFormatter* uformatter, const char* value, int32_t valueLen,
UFormattedNumber* uresult, UErrorCode* ec);
@@ -543,7 +568,7 @@ unumf_formatDecimal(const UNumberFormatter* uformatter, const char* value, int32
* @return A UFormattedValue owned by the input object.
* @stable ICU 64
*/
-U_STABLE const UFormattedValue* U_EXPORT2
+U_CAPI const UFormattedValue* U_EXPORT2
unumf_resultAsValue(const UFormattedNumber* uresult, UErrorCode* ec);
@@ -566,7 +591,7 @@ unumf_resultAsValue(const UFormattedNumber* uresult, UErrorCode* ec);
* @return The required length.
* @stable ICU 62
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t bufferCapacity,
UErrorCode* ec);
@@ -600,11 +625,11 @@ unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t buf
* "beginIndex" field is set to the beginning of the first occurrence of the field after the
* input "endIndex", and "endIndex" is set to the end of that occurrence of the field
* (exclusive index). If a field position is not found, the FieldPosition is not changed and
- * the method returns FALSE.
+ * the method returns false.
* @param ec Set if an error occurs.
* @stable ICU 62
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
unumf_resultNextFieldPosition(const UFormattedNumber* uresult, UFieldPosition* ufpos, UErrorCode* ec);
@@ -629,16 +654,37 @@ unumf_resultNextFieldPosition(const UFormattedNumber* uresult, UFieldPosition* u
* @param ec Set if an error occurs.
* @stable ICU 62
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unumf_resultGetAllFieldPositions(const UFormattedNumber* uresult, UFieldPositionIterator* ufpositer,
UErrorCode* ec);
-// TODO(ICU-20775): Propose this as API.
-// NOTE: This is not currently implemented.
-// U_DRAFT int32_t U_EXPORT2
-// unumf_resultToDecimalNumber(const UFormattedNumber* uresult, char* buffer, int32_t bufferCapacity,
-// UErrorCode* ec);
+#ifndef U_HIDE_DRAFT_API
+/**
+ * Extracts the formatted number as a "numeric string" conforming to the
+ * syntax defined in the Decimal Arithmetic Specification, available at
+ * http://speleotrove.com/decimal
+ *
+ * This endpoint is useful for obtaining the exact number being printed
+ * after scaling and rounding have been applied by the number formatter.
+ *
+ * @param uresult The input object containing the formatted number.
+ * @param dest the 8-bit char buffer into which the decimal number is placed
+ * @param destCapacity The size, in chars, of the destination buffer. May be zero
+ * for precomputing the required size.
+ * @param ec receives any error status.
+ * If U_BUFFER_OVERFLOW_ERROR: Returns number of chars for
+ * preflighting.
+ * @return Number of chars in the data. Does not include a trailing NUL.
+ * @draft ICU 68
+ */
+U_CAPI int32_t U_EXPORT2
+unumf_resultToDecimalNumber(
+ const UFormattedNumber* uresult,
+ char* dest,
+ int32_t destCapacity,
+ UErrorCode* ec);
+#endif // U_HIDE_DRAFT_API
/**
@@ -647,7 +693,7 @@ unumf_resultGetAllFieldPositions(const UFormattedNumber* uresult, UFieldPosition
* @param uformatter An object created by unumf_openForSkeletonAndLocale().
* @stable ICU 62
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unumf_close(UNumberFormatter* uformatter);
@@ -657,7 +703,7 @@ unumf_close(UNumberFormatter* uformatter);
* @param uresult An object created by unumf_openResult().
* @stable ICU 62
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unumf_closeResult(UFormattedNumber* uresult);
@@ -701,5 +747,5 @@ U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedNumberPointer, UFormattedNumber, unum
U_NAMESPACE_END
#endif // U_SHOW_CPLUSPLUS_API
-#endif //__UNUMBERFORMATTER_H__
#endif /* #if !UCONFIG_NO_FORMATTING */
+#endif //__UNUMBERFORMATTER_H__
diff --git a/deps/icu-small/source/i18n/unicode/unumberrangeformatter.h b/deps/icu-small/source/i18n/unicode/unumberrangeformatter.h
new file mode 100644
index 0000000000..738bfb9f70
--- /dev/null
+++ b/deps/icu-small/source/i18n/unicode/unumberrangeformatter.h
@@ -0,0 +1,477 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#ifndef __UNUMBERRANGEFORMATTER_H__
+#define __UNUMBERRANGEFORMATTER_H__
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/parseerr.h"
+#include "unicode/ufieldpositer.h"
+#include "unicode/umisc.h"
+#include "unicode/uformattedvalue.h"
+#include "unicode/uformattable.h"
+
+
+/**
+ * \file
+ * \brief C-compatible API for localized number range formatting.
+ *
+ * This is the C-compatible version of the NumberRangeFormatter API. C++ users
+ * should include unicode/numberrangeformatter.h and use the proper C++ APIs.
+ *
+ * First create a UNumberRangeFormatter, which is immutable, and then format to
+ * a UFormattedNumberRange.
+ *
+ * Example code:
+ * <pre>
+ * // Setup:
+ * UErrorCode ec = U_ZERO_ERROR;
+ * UNumberRangeFormatter* uformatter = unumrf_openForSkeletonCollapseIdentityFallbackAndLocaleWithError(
+ * u"currency/USD precision-integer",
+ * -1,
+ * UNUM_RANGE_COLLAPSE_AUTO,
+ * UNUM_IDENTITY_FALLBACK_APPROXIMATELY,
+ * "en-US",
+ * NULL,
+ * &ec);
+ * UFormattedNumberRange* uresult = unumrf_openResult(&ec);
+ * if (U_FAILURE(ec)) { return; }
+ *
+ * // Format a double range:
+ * unumrf_formatDoubleRange(uformatter, 3.0, 5.0, uresult, &ec);
+ * if (U_FAILURE(ec)) { return; }
+ *
+ * // Get the result string:
+ * int32_t len;
+ * const UChar* str = ufmtval_getString(unumrf_resultAsValue(uresult, &ec), &len, &ec);
+ * if (U_FAILURE(ec)) { return; }
+ * // str should equal "$3 – $5"
+ *
+ * // Cleanup:
+ * unumf_close(uformatter);
+ * unumf_closeResult(uresult);
+ * </pre>
+ *
+ * If you are a C++ user linking against the C libraries, you can use the LocalPointer versions of these
+ * APIs. The following example uses LocalPointer with the decimal number and field position APIs:
+ *
+ * <pre>
+ * // Setup:
+ * LocalUNumberRangeFormatterPointer uformatter(
+ * unumrf_openForSkeletonCollapseIdentityFallbackAndLocaleWithError(...));
+ * LocalUFormattedNumberRangePointer uresult(unumrf_openResult(&ec));
+ * if (U_FAILURE(ec)) { return; }
+ *
+ * // Format a double number range:
+ * unumrf_formatDoubleRange(uformatter.getAlias(), 3.0, 5.0, uresult.getAlias(), &ec);
+ * if (U_FAILURE(ec)) { return; }
+ *
+ * // No need to do any cleanup since we are using LocalPointer.
+ * </pre>
+ *
+ * You can also get field positions. For more information, see uformattedvalue.h.
+ */
+
+/**
+ * Defines how to merge fields that are identical across the range sign.
+ *
+ * @stable ICU 63
+ */
+typedef enum UNumberRangeCollapse {
+ /**
+ * Use locale data and heuristics to determine how much of the string to collapse. Could end up collapsing none,
+ * some, or all repeated pieces in a locale-sensitive way.
+ *
+ * The heuristics used for this option are subject to change over time.
+ *
+ * @stable ICU 63
+ */
+ UNUM_RANGE_COLLAPSE_AUTO,
+
+ /**
+ * Do not collapse any part of the number. Example: "3.2 thousand kilograms – 5.3 thousand kilograms"
+ *
+ * @stable ICU 63
+ */
+ UNUM_RANGE_COLLAPSE_NONE,
+
+ /**
+ * Collapse the unit part of the number, but not the notation, if present. Example: "3.2 thousand – 5.3 thousand
+ * kilograms"
+ *
+ * @stable ICU 63
+ */
+ UNUM_RANGE_COLLAPSE_UNIT,
+
+ /**
+ * Collapse any field that is equal across the range sign. May introduce ambiguity on the magnitude of the
+ * number. Example: "3.2 – 5.3 thousand kilograms"
+ *
+ * @stable ICU 63
+ */
+ UNUM_RANGE_COLLAPSE_ALL
+} UNumberRangeCollapse;
+
+/**
+ * Defines the behavior when the two numbers in the range are identical after rounding. To programmatically detect
+ * when the identity fallback is used, compare the lower and upper BigDecimals via FormattedNumber.
+ *
+ * @stable ICU 63
+ * @see NumberRangeFormatter
+ */
+typedef enum UNumberRangeIdentityFallback {
+ /**
+ * Show the number as a single value rather than a range. Example: "$5"
+ *
+ * @stable ICU 63
+ */
+ UNUM_IDENTITY_FALLBACK_SINGLE_VALUE,
+
+ /**
+ * Show the number using a locale-sensitive approximation pattern. If the numbers were the same before rounding,
+ * show the single value. Example: "~$5" or "$5"
+ *
+ * @stable ICU 63
+ */
+ UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE,
+
+ /**
+ * Show the number using a locale-sensitive approximation pattern. Use the range pattern always, even if the
+ * inputs are the same. Example: "~$5"
+ *
+ * @stable ICU 63
+ */
+ UNUM_IDENTITY_FALLBACK_APPROXIMATELY,
+
+ /**
+ * Show the number as the range of two equal values. Use the range pattern always, even if the inputs are the
+ * same. Example (with RangeCollapse.NONE): "$5 – $5"
+ *
+ * @stable ICU 63
+ */
+ UNUM_IDENTITY_FALLBACK_RANGE
+} UNumberRangeIdentityFallback;
+
+/**
+ * Used in the result class FormattedNumberRange to indicate to the user whether the numbers formatted in the range
+ * were equal or not, and whether or not the identity fallback was applied.
+ *
+ * @stable ICU 63
+ * @see NumberRangeFormatter
+ */
+typedef enum UNumberRangeIdentityResult {
+ /**
+ * Used to indicate that the two numbers in the range were equal, even before any rounding rules were applied.
+ *
+ * @stable ICU 63
+ * @see NumberRangeFormatter
+ */
+ UNUM_IDENTITY_RESULT_EQUAL_BEFORE_ROUNDING,
+
+ /**
+ * Used to indicate that the two numbers in the range were equal, but only after rounding rules were applied.
+ *
+ * @stable ICU 63
+ * @see NumberRangeFormatter
+ */
+ UNUM_IDENTITY_RESULT_EQUAL_AFTER_ROUNDING,
+
+ /**
+ * Used to indicate that the two numbers in the range were not equal, even after rounding rules were applied.
+ *
+ * @stable ICU 63
+ * @see NumberRangeFormatter
+ */
+ UNUM_IDENTITY_RESULT_NOT_EQUAL,
+
+#ifndef U_HIDE_INTERNAL_API
+ /**
+ * The number of entries in this enum.
+ * @internal
+ */
+ UNUM_IDENTITY_RESULT_COUNT
+#endif
+
+} UNumberRangeIdentityResult;
+
+
+#ifndef U_HIDE_DRAFT_API
+
+struct UNumberRangeFormatter;
+/**
+ * C-compatible version of icu::number::LocalizedNumberRangeFormatter.
+ *
+ * NOTE: This is a C-compatible API; C++ users should build against numberrangeformatter.h instead.
+ *
+ * @draft ICU 68
+ */
+typedef struct UNumberRangeFormatter UNumberRangeFormatter;
+
+
+struct UFormattedNumberRange;
+/**
+ * C-compatible version of icu::number::FormattedNumberRange.
+ *
+ * NOTE: This is a C-compatible API; C++ users should build against numberrangeformatter.h instead.
+ *
+ * @draft ICU 68
+ */
+typedef struct UFormattedNumberRange UFormattedNumberRange;
+
+
+/**
+ * Creates a new UNumberFormatter for the given skeleton string, collapse option, identity fallback
+ * option, and locale. This is currently the only method for creating a new UNumberRangeFormatter.
+ *
+ * Objects of type UNumberRangeFormatter returned by this method are threadsafe.
+ *
+ * For more details on skeleton strings, see the documentation in numberrangeformatter.h. For more
+ * details on the usage of this API, see the documentation at the top of unumberrangeformatter.h.
+ *
+ * NOTE: This is a C-compatible API; C++ users should build against numberrangeformatter.h instead.
+ *
+ * @param skeleton The skeleton string, like u"percent precision-integer"
+ * @param skeletonLen The number of UChars in the skeleton string, or -1 if it is NUL-terminated.
+ * @param collapse Option for how to merge affixes (if unsure, use UNUM_RANGE_COLLAPSE_AUTO)
+ * @param identityFallback Option for resolving when both sides of the range are equal.
+ * @param locale The NUL-terminated locale ID.
+ * @param perror A parse error struct populated if an error occurs when parsing. Can be NULL.
+ * If no error occurs, perror->offset will be set to -1.
+ * @param ec Set if an error occurs.
+ * @draft ICU 68
+ */
+U_CAPI UNumberRangeFormatter* U_EXPORT2
+unumrf_openForSkeletonWithCollapseAndIdentityFallback(
+ const UChar* skeleton,
+ int32_t skeletonLen,
+ UNumberRangeCollapse collapse,
+ UNumberRangeIdentityFallback identityFallback,
+ const char* locale,
+ UParseError* perror,
+ UErrorCode* ec);
+
+
+/**
+ * Creates an object to hold the result of a UNumberRangeFormatter
+ * operation. The object can be used repeatedly; it is cleared whenever
+ * passed to a format function.
+ *
+ * @param ec Set if an error occurs.
+ * @draft ICU 68
+ */
+U_CAPI UFormattedNumberRange* U_EXPORT2
+unumrf_openResult(UErrorCode* ec);
+
+
+/**
+ * Uses a UNumberRangeFormatter to format a range of doubles.
+ *
+ * The UNumberRangeFormatter can be shared between threads. Each thread should have its own local
+ * UFormattedNumberRange, however, for storing the result of the formatting operation.
+ *
+ * NOTE: This is a C-compatible API; C++ users should build against numberrangeformatter.h instead.
+ *
+ * @param uformatter A formatter object; see unumberrangeformatter.h.
+ * @param first The first (usually smaller) number in the range.
+ * @param second The second (usually larger) number in the range.
+ * @param uresult The object that will be mutated to store the result; see unumrf_openResult.
+ * @param ec Set if an error occurs.
+ * @draft ICU 68
+ */
+U_CAPI void U_EXPORT2
+unumrf_formatDoubleRange(
+ const UNumberRangeFormatter* uformatter,
+ double first,
+ double second,
+ UFormattedNumberRange* uresult,
+ UErrorCode* ec);
+
+
+/**
+ * Uses a UNumberRangeFormatter to format a range of decimal numbers.
+ *
+ * With a decimal number string, you can specify an input with arbitrary precision.
+ *
+ * The UNumberRangeFormatter can be shared between threads. Each thread should have its own local
+ * UFormattedNumberRange, however, for storing the result of the formatting operation.
+ *
+ * NOTE: This is a C-compatible API; C++ users should build against numberrangeformatter.h instead.
+ *
+ * @param uformatter A formatter object; see unumberrangeformatter.h.
+ * @param first The first (usually smaller) number in the range.
+ * @param firstLen The length of the first decimal number string.
+ * @param second The second (usually larger) number in the range.
+ * @param secondLen The length of the second decimal number string.
+ * @param uresult The object that will be mutated to store the result; see unumrf_openResult.
+ * @param ec Set if an error occurs.
+ * @draft ICU 68
+ */
+U_CAPI void U_EXPORT2
+unumrf_formatDecimalRange(
+ const UNumberRangeFormatter* uformatter,
+ const char* first,
+ int32_t firstLen,
+ const char* second,
+ int32_t secondLen,
+ UFormattedNumberRange* uresult,
+ UErrorCode* ec);
+
+
+/**
+ * Returns a representation of a UFormattedNumberRange as a UFormattedValue,
+ * which can be subsequently passed to any API requiring that type.
+ *
+ * The returned object is owned by the UFormattedNumberRange and is valid
+ * only as long as the UFormattedNumber is present and unchanged in memory.
+ *
+ * You can think of this method as a cast between types.
+ *
+ * @param uresult The object containing the formatted number range.
+ * @param ec Set if an error occurs.
+ * @return A UFormattedValue owned by the input object.
+ * @draft ICU 68
+ */
+U_CAPI const UFormattedValue* U_EXPORT2
+unumrf_resultAsValue(const UFormattedNumberRange* uresult, UErrorCode* ec);
+
+
+/**
+ * Extracts the identity result from a UFormattedNumberRange.
+ *
+ * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
+ *
+ * @param uresult The object containing the formatted number range.
+ * @param ec Set if an error occurs.
+ * @return The identity result; see UNumberRangeIdentityResult.
+ * @draft ICU 68
+ */
+U_CAPI UNumberRangeIdentityResult U_EXPORT2
+unumrf_resultGetIdentityResult(
+ const UFormattedNumberRange* uresult,
+ UErrorCode* ec);
+
+
+#ifndef U_HIDE_DRAFT_API
+/**
+ * Extracts the first formatted number as a decimal number. This endpoint
+ * is useful for obtaining the exact number being printed after scaling
+ * and rounding have been applied by the number range formatting pipeline.
+ *
+ * The syntax of the unformatted number is a "numeric string"
+ * as defined in the Decimal Arithmetic Specification, available at
+ * http://speleotrove.com/decimal
+ *
+ * @param uresult The input object containing the formatted number range.
+ * @param dest the 8-bit char buffer into which the decimal number is placed
+ * @param destCapacity The size, in chars, of the destination buffer. May be zero
+ * for precomputing the required size.
+ * @param ec receives any error status.
+ * If U_BUFFER_OVERFLOW_ERROR: Returns number of chars for
+ * preflighting.
+ * @return Number of chars in the data. Does not include a trailing NUL.
+ * @draft ICU 68
+ */
+U_CAPI int32_t U_EXPORT2
+unumrf_resultGetFirstDecimalNumber(
+ const UFormattedNumberRange* uresult,
+ char* dest,
+ int32_t destCapacity,
+ UErrorCode* ec);
+
+
+/**
+ * Extracts the second formatted number as a decimal number. This endpoint
+ * is useful for obtaining the exact number being printed after scaling
+ * and rounding have been applied by the number range formatting pipeline.
+ *
+ * The syntax of the unformatted number is a "numeric string"
+ * as defined in the Decimal Arithmetic Specification, available at
+ * http://speleotrove.com/decimal
+ *
+ * @param uresult The input object containing the formatted number range.
+ * @param dest the 8-bit char buffer into which the decimal number is placed
+ * @param destCapacity The size, in chars, of the destination buffer. May be zero
+ * for precomputing the required size.
+ * @param ec receives any error status.
+ * If U_BUFFER_OVERFLOW_ERROR: Returns number of chars for
+ * preflighting.
+ * @return Number of chars in the data. Does not include a trailing NUL.
+ * @draft ICU 68
+ */
+U_CAPI int32_t U_EXPORT2
+unumrf_resultGetSecondDecimalNumber(
+ const UFormattedNumberRange* uresult,
+ char* dest,
+ int32_t destCapacity,
+ UErrorCode* ec);
+#endif // U_HIDE_DRAFT_API
+
+
+/**
+ * Releases the UNumberFormatter created by unumf_openForSkeletonAndLocale().
+ *
+ * @param uformatter An object created by unumf_openForSkeletonAndLocale().
+ * @draft ICU 68
+ */
+U_CAPI void U_EXPORT2
+unumrf_close(UNumberRangeFormatter* uformatter);
+
+
+/**
+ * Releases the UFormattedNumber created by unumf_openResult().
+ *
+ * @param uresult An object created by unumf_openResult().
+ * @draft ICU 68
+ */
+U_CAPI void U_EXPORT2
+unumrf_closeResult(UFormattedNumberRange* uresult);
+
+
+#if U_SHOW_CPLUSPLUS_API
+U_NAMESPACE_BEGIN
+
+/**
+ * \class LocalUNumberRangeFormatterPointer
+ * "Smart pointer" class; closes a UNumberFormatter via unumf_close().
+ * For most methods see the LocalPointerBase base class.
+ *
+ * Usage:
+ * <pre>
+ * LocalUNumberRangeFormatterPointer uformatter(
+ * unumrf_openForSkeletonCollapseIdentityFallbackAndLocaleWithError(...));
+ * // no need to explicitly call unumrf_close()
+ * </pre>
+ *
+ * @see LocalPointerBase
+ * @see LocalPointer
+ * @draft ICU 68
+ */
+U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberRangeFormatterPointer, UNumberRangeFormatter, unumrf_close);
+
+/**
+ * \class LocalUFormattedNumberPointer
+ * "Smart pointer" class; closes a UFormattedNumber via unumf_closeResult().
+ * For most methods see the LocalPointerBase base class.
+ *
+ * Usage:
+ * <pre>
+ * LocalUFormattedNumberRangePointer uresult(unumrf_openResult(...));
+ * // no need to explicitly call unumrf_closeResult()
+ * </pre>
+ *
+ * @see LocalPointerBase
+ * @see LocalPointer
+ * @draft ICU 68
+ */
+U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedNumberRangePointer, UFormattedNumberRange, unumrf_closeResult);
+
+U_NAMESPACE_END
+#endif // U_SHOW_CPLUSPLUS_API
+
+#endif // U_HIDE_DRAFT_API
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+#endif //__UNUMBERRANGEFORMATTER_H__
diff --git a/deps/icu-small/source/i18n/unicode/unumsys.h b/deps/icu-small/source/i18n/unicode/unumsys.h
index 84ceddf84f..c767cf3d79 100644
--- a/deps/icu-small/source/i18n/unicode/unumsys.h
+++ b/deps/icu-small/source/i18n/unicode/unumsys.h
@@ -15,7 +15,10 @@
#if !UCONFIG_NO_FORMATTING
#include "unicode/uenum.h"
+
+#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
@@ -54,7 +57,7 @@ typedef struct UNumberingSystem UNumberingSystem; /**< C typedef for struct UNu
* occurred.
* @stable ICU 52
*/
-U_STABLE UNumberingSystem * U_EXPORT2
+U_CAPI UNumberingSystem * U_EXPORT2
unumsys_open(const char *locale, UErrorCode *status);
/**
@@ -75,7 +78,7 @@ unumsys_open(const char *locale, UErrorCode *status);
* occurred.
* @stable ICU 52
*/
-U_STABLE UNumberingSystem * U_EXPORT2
+U_CAPI UNumberingSystem * U_EXPORT2
unumsys_openByName(const char *name, UErrorCode *status);
/**
@@ -83,7 +86,7 @@ unumsys_openByName(const char *name, UErrorCode *status);
* @param unumsys The UNumberingSystem object to close.
* @stable ICU 52
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
unumsys_close(UNumberingSystem *unumsys);
#if U_SHOW_CPLUSPLUS_API
@@ -111,7 +114,7 @@ U_NAMESPACE_END
* or NULL if an error occurred.
* @stable ICU 52
*/
-U_STABLE UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
unumsys_openAvailableNames(UErrorCode *status);
/**
@@ -123,18 +126,18 @@ unumsys_openAvailableNames(UErrorCode *status);
* is only valid for the lifetime of the UNumberingSystem object.
* @stable ICU 52
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
unumsys_getName(const UNumberingSystem *unumsys);
/**
* Returns whether the given UNumberingSystem object is for an algorithmic (not purely
* positional) system.
* @param unumsys The UNumberingSystem whose algorithmic status is desired.
- * @return TRUE if the specified UNumberingSystem object is for an algorithmic
+ * @return true if the specified UNumberingSystem object is for an algorithmic
* system.
* @stable ICU 52
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
unumsys_isAlgorithmic(const UNumberingSystem *unumsys);
/**
@@ -145,7 +148,7 @@ unumsys_isAlgorithmic(const UNumberingSystem *unumsys);
* @return The radix of the specified UNumberingSystem object.
* @stable ICU 52
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unumsys_getRadix(const UNumberingSystem *unumsys);
/**
@@ -164,7 +167,7 @@ unumsys_getRadix(const UNumberingSystem *unumsys);
* output was truncated.
* @stable ICU 52
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unumsys_getDescription(const UNumberingSystem *unumsys, UChar *result,
int32_t resultLength, UErrorCode *status);
diff --git a/deps/icu-small/source/i18n/unicode/upluralrules.h b/deps/icu-small/source/i18n/unicode/upluralrules.h
index 9c09dfab8b..71a45ddf85 100644
--- a/deps/icu-small/source/i18n/unicode/upluralrules.h
+++ b/deps/icu-small/source/i18n/unicode/upluralrules.h
@@ -14,14 +14,19 @@
#if !UCONFIG_NO_FORMATTING
-#include "unicode/localpointer.h"
#include "unicode/uenum.h"
+
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
#ifndef U_HIDE_INTERNAL_API
#include "unicode/unum.h"
#endif /* U_HIDE_INTERNAL_API */
// Forward-declaration
struct UFormattedNumber;
+struct UFormattedNumberRange;
/**
* \file
@@ -163,7 +168,7 @@ uplrules_select(const UPluralRules *uplrules,
* @param uplrules The UPluralRules object specifying the rules.
* @param number The formatted number for which the rule has to be determined.
* @param keyword The destination buffer for the keyword of the rule that
- * applies to number.
+ * applies to the number.
* @param capacity The capacity of the keyword buffer.
* @param status A pointer to a UErrorCode to receive any errors.
* @return The length of the keyword.
@@ -175,6 +180,29 @@ uplrules_selectFormatted(const UPluralRules *uplrules,
UChar *keyword, int32_t capacity,
UErrorCode *status);
+#ifndef U_HIDE_DRAFT_API
+/**
+ * Given a formatted number range, returns the overall plural form of the
+ * range. For example, "3-5" returns "other" in English.
+ *
+ * To get a UFormattedNumberRange, see UNumberRangeFormatter.
+ *
+ * @param uplrules The UPluralRules object specifying the rules.
+ * @param urange The number range onto which the rules will be applied.
+ * @param keyword The destination buffer for the keyword of the rule that
+ * applies to the number range.
+ * @param capacity The capacity of the keyword buffer.
+ * @param status A pointer to a UErrorCode to receive any errors.
+ * @return The length of the keyword.
+ * @draft ICU 68
+ */
+U_CAPI int32_t U_EXPORT2
+uplrules_selectForRange(const UPluralRules *uplrules,
+ const struct UFormattedNumberRange* urange,
+ UChar *keyword, int32_t capacity,
+ UErrorCode *status);
+#endif // U_HIDE_DRAFT_API
+
#ifndef U_HIDE_INTERNAL_API
/**
* Given a number, returns the keyword of the first rule that applies to the
@@ -194,7 +222,7 @@ uplrules_selectFormatted(const UPluralRules *uplrules,
* @return The length of keyword.
* @internal ICU 59 technology preview, may be removed in the future
*/
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uplrules_selectWithFormat(const UPluralRules *uplrules,
double number,
const UNumberFormat *fmt,
@@ -213,7 +241,7 @@ uplrules_selectWithFormat(const UPluralRules *uplrules,
* upon error. The caller is responsible for closing the result.
* @stable ICU 59
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
uplrules_getKeywords(const UPluralRules *uplrules,
UErrorCode *status);
diff --git a/deps/icu-small/source/i18n/unicode/uregex.h b/deps/icu-small/source/i18n/unicode/uregex.h
index cb5e51ef01..7095688247 100644
--- a/deps/icu-small/source/i18n/unicode/uregex.h
+++ b/deps/icu-small/source/i18n/unicode/uregex.h
@@ -30,9 +30,12 @@
#if !UCONFIG_NO_REGULAR_EXPRESSIONS
-#include "unicode/localpointer.h"
#include "unicode/parseerr.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
struct URegularExpression;
/**
* Structure representing a compiled regular expression, plus the results
@@ -131,7 +134,7 @@ typedef enum URegexpFlag{
* @stable ICU 3.0
*
*/
-U_STABLE URegularExpression * U_EXPORT2
+U_CAPI URegularExpression * U_EXPORT2
uregex_open( const UChar *pattern,
int32_t patternLength,
uint32_t flags,
@@ -161,7 +164,7 @@ uregex_open( const UChar *pattern,
*
* @stable ICU 4.6
*/
-U_STABLE URegularExpression * U_EXPORT2
+U_CAPI URegularExpression * U_EXPORT2
uregex_openUText(UText *pattern,
uint32_t flags,
UParseError *pe,
@@ -191,7 +194,7 @@ uregex_openUText(UText *pattern,
*
* @stable ICU 3.0
*/
-U_STABLE URegularExpression * U_EXPORT2
+U_CAPI URegularExpression * U_EXPORT2
uregex_openC( const char *pattern,
uint32_t flags,
UParseError *pe,
@@ -207,7 +210,7 @@ uregex_openC( const char *pattern,
* @param regexp The regular expression to be closed.
* @stable ICU 3.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_close(URegularExpression *regexp);
#if U_SHOW_CPLUSPLUS_API
@@ -247,7 +250,7 @@ U_NAMESPACE_END
* @return the cloned copy of the compiled regular expression.
* @stable ICU 3.0
*/
-U_STABLE URegularExpression * U_EXPORT2
+U_CAPI URegularExpression * U_EXPORT2
uregex_clone(const URegularExpression *regexp, UErrorCode *status);
/**
@@ -267,7 +270,7 @@ uregex_clone(const URegularExpression *regexp, UErrorCode *status);
* will remain valid until the regular expression is closed.
* @stable ICU 3.0
*/
-U_STABLE const UChar * U_EXPORT2
+U_CAPI const UChar * U_EXPORT2
uregex_pattern(const URegularExpression *regexp,
int32_t *patLength,
UErrorCode *status);
@@ -283,7 +286,7 @@ uregex_pattern(const URegularExpression *regexp,
*
* @stable ICU 4.6
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
uregex_patternUText(const URegularExpression *regexp,
UErrorCode *status);
@@ -295,7 +298,7 @@ uregex_patternUText(const URegularExpression *regexp,
* @see URegexpFlag
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_flags(const URegularExpression *regexp,
UErrorCode *status);
@@ -320,7 +323,7 @@ uregex_flags(const URegularExpression *regexp,
* @param status Receives errors detected by this function.
* @stable ICU 3.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_setText(URegularExpression *regexp,
const UChar *text,
int32_t textLength,
@@ -343,7 +346,7 @@ uregex_setText(URegularExpression *regexp,
*
* @stable ICU 4.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_setUText(URegularExpression *regexp,
UText *text,
UErrorCode *status);
@@ -368,7 +371,7 @@ uregex_setUText(URegularExpression *regexp,
* this regular expression.
* @stable ICU 3.0
*/
-U_STABLE const UChar * U_EXPORT2
+U_CAPI const UChar * U_EXPORT2
uregex_getText(URegularExpression *regexp,
int32_t *textLength,
UErrorCode *status);
@@ -389,7 +392,7 @@ uregex_getText(URegularExpression *regexp,
*
* @stable ICU 4.6
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
uregex_getUText(URegularExpression *regexp,
UText *dest,
UErrorCode *status);
@@ -419,7 +422,7 @@ uregex_getUText(URegularExpression *regexp,
*
* @stable ICU 4.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_refreshUText(URegularExpression *regexp,
UText *text,
UErrorCode *status);
@@ -441,10 +444,10 @@ uregex_refreshUText(URegularExpression *regexp,
* @param startIndex The input string (native) index at which to begin matching, or -1
* to match the input Region.
* @param status Receives errors detected by this function.
- * @return TRUE if there is a match
+ * @return true if there is a match
* @stable ICU 3.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uregex_matches(URegularExpression *regexp,
int32_t startIndex,
UErrorCode *status);
@@ -467,10 +470,10 @@ uregex_matches(URegularExpression *regexp,
* @param startIndex The input string (native) index at which to begin matching, or -1
* to match the input Region.
* @param status Receives errors detected by this function.
- * @return TRUE if there is a match
+ * @return true if there is a match
* @stable ICU 4.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uregex_matches64(URegularExpression *regexp,
int64_t startIndex,
UErrorCode *status);
@@ -495,10 +498,10 @@ uregex_matches64(URegularExpression *regexp,
* @param startIndex The input string (native) index at which to begin matching, or
* -1 to match the Input Region
* @param status A reference to a UErrorCode to receive any errors.
- * @return TRUE if there is a match.
+ * @return true if there is a match.
* @stable ICU 3.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uregex_lookingAt(URegularExpression *regexp,
int32_t startIndex,
UErrorCode *status);
@@ -524,10 +527,10 @@ uregex_lookingAt(URegularExpression *regexp,
* @param startIndex The input string (native) index at which to begin matching, or
* -1 to match the Input Region
* @param status A reference to a UErrorCode to receive any errors.
- * @return TRUE if there is a match.
+ * @return true if there is a match.
* @stable ICU 4.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uregex_lookingAt64(URegularExpression *regexp,
int64_t startIndex,
UErrorCode *status);
@@ -548,10 +551,10 @@ uregex_lookingAt64(URegularExpression *regexp,
* @param startIndex The position (native) in the input string to begin the search, or
* -1 to search within the Input Region.
* @param status A reference to a UErrorCode to receive any errors.
- * @return TRUE if a match is found.
+ * @return true if a match is found.
* @stable ICU 3.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uregex_find(URegularExpression *regexp,
int32_t startIndex,
UErrorCode *status);
@@ -573,10 +576,10 @@ uregex_find(URegularExpression *regexp,
* @param startIndex The position (native) in the input string to begin the search, or
* -1 to search within the Input Region.
* @param status A reference to a UErrorCode to receive any errors.
- * @return TRUE if a match is found.
+ * @return true if a match is found.
* @stable ICU 4.6
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uregex_find64(URegularExpression *regexp,
int64_t startIndex,
UErrorCode *status);
@@ -590,11 +593,11 @@ uregex_find64(URegularExpression *regexp,
*
* @param regexp The compiled regular expression.
* @param status A reference to a UErrorCode to receive any errors.
- * @return TRUE if a match is found.
+ * @return true if a match is found.
* @see uregex_reset
* @stable ICU 3.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uregex_findNext(URegularExpression *regexp,
UErrorCode *status);
@@ -605,7 +608,7 @@ uregex_findNext(URegularExpression *regexp,
* @return the number of capture groups
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_groupCount(URegularExpression *regexp,
UErrorCode *status);
@@ -625,7 +628,7 @@ uregex_groupCount(URegularExpression *regexp,
*
* @stable ICU 55
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_groupNumberFromName(URegularExpression *regexp,
const UChar *groupName,
int32_t nameLength,
@@ -649,7 +652,7 @@ uregex_groupNumberFromName(URegularExpression *regexp,
*
* @stable ICU 55
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_groupNumberFromCName(URegularExpression *regexp,
const char *groupName,
int32_t nameLength,
@@ -671,7 +674,7 @@ uregex_groupNumberFromCName(URegularExpression *regexp,
* or -1 if no applicable match.
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_group(URegularExpression *regexp,
int32_t groupNum,
UChar *dest,
@@ -700,7 +703,7 @@ uregex_group(URegularExpression *regexp,
*
* @stable ICU 4.6
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
uregex_groupUText(URegularExpression *regexp,
int32_t groupNum,
UText *dest,
@@ -721,7 +724,7 @@ uregex_groupUText(URegularExpression *regexp,
* by the specified group.
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_start(URegularExpression *regexp,
int32_t groupNum,
UErrorCode *status);
@@ -741,7 +744,7 @@ uregex_start(URegularExpression *regexp,
* by the specified group.
* @stable ICU 4.6
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
uregex_start64(URegularExpression *regexp,
int32_t groupNum,
UErrorCode *status);
@@ -759,7 +762,7 @@ uregex_start64(URegularExpression *regexp,
* @return the (native) index of the position following the last matched character.
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_end(URegularExpression *regexp,
int32_t groupNum,
UErrorCode *status);
@@ -778,7 +781,7 @@ uregex_end(URegularExpression *regexp,
* @return the (native) index of the position following the last matched character.
* @stable ICU 4.6
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
uregex_end64(URegularExpression *regexp,
int32_t groupNum,
UErrorCode *status);
@@ -796,7 +799,7 @@ uregex_end64(URegularExpression *regexp,
* @param status A reference to a UErrorCode to receive any errors.
* @stable ICU 3.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_reset(URegularExpression *regexp,
int32_t index,
UErrorCode *status);
@@ -815,7 +818,7 @@ uregex_reset(URegularExpression *regexp,
* @param status A reference to a UErrorCode to receive any errors.
* @stable ICU 4.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_reset64(URegularExpression *regexp,
int64_t index,
UErrorCode *status);
@@ -840,7 +843,7 @@ uregex_reset64(URegularExpression *regexp,
* @param status A pointer to a UErrorCode to receive any errors.
* @stable ICU 4.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_setRegion(URegularExpression *regexp,
int32_t regionStart,
int32_t regionLimit,
@@ -867,7 +870,7 @@ uregex_setRegion(URegularExpression *regexp,
* @param status A pointer to a UErrorCode to receive any errors.
* @stable ICU 4.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_setRegion64(URegularExpression *regexp,
int64_t regionStart,
int64_t regionLimit,
@@ -887,7 +890,7 @@ uregex_setRegion64(URegularExpression *regexp,
* @param status A pointer to a UErrorCode to receive any errors.
* @stable ICU 4.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_setRegionAndStart(URegularExpression *regexp,
int64_t regionStart,
int64_t regionLimit,
@@ -903,7 +906,7 @@ uregex_setRegionAndStart(URegularExpression *regexp,
* @return The starting (native) index of this matcher's region.
* @stable ICU 4.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_regionStart(const URegularExpression *regexp,
UErrorCode *status);
@@ -917,7 +920,7 @@ uregex_regionStart(const URegularExpression *regexp,
* @return The starting (native) index of this matcher's region.
* @stable ICU 4.6
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
uregex_regionStart64(const URegularExpression *regexp,
UErrorCode *status);
@@ -931,7 +934,7 @@ uregex_regionStart64(const URegularExpression *regexp,
* @return The ending point (native) of this matcher's region.
* @stable ICU 4.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_regionEnd(const URegularExpression *regexp,
UErrorCode *status);
@@ -946,7 +949,7 @@ uregex_regionEnd(const URegularExpression *regexp,
* @return The ending point (native) of this matcher's region.
* @stable ICU 4.6
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
uregex_regionEnd64(const URegularExpression *regexp,
UErrorCode *status);
@@ -957,18 +960,18 @@ uregex_regionEnd64(const URegularExpression *regexp,
*
* @param regexp The compiled regular expression.
* @param status A pointer to a UErrorCode to receive any errors.
- * @return TRUE if this matcher is using opaque bounds, false if it is not.
+ * @return true if this matcher is using opaque bounds, false if it is not.
* @stable ICU 4.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uregex_hasTransparentBounds(const URegularExpression *regexp,
UErrorCode *status);
/**
* Sets the transparency of region bounds for this URegularExpression.
- * Invoking this function with an argument of TRUE will set matches to use transparent bounds.
- * If the boolean argument is FALSE, then opaque bounds will be used.
+ * Invoking this function with an argument of true will set matches to use transparent bounds.
+ * If the boolean argument is false, then opaque bounds will be used.
*
* Using transparent bounds, the boundaries of the matching region are transparent
* to lookahead, lookbehind, and boundary matching constructs. Those constructs can
@@ -980,11 +983,11 @@ uregex_hasTransparentBounds(const URegularExpression *regexp,
* By default, opaque bounds are used.
*
* @param regexp The compiled regular expression.
- * @param b TRUE for transparent bounds; FALSE for opaque bounds
+ * @param b true for transparent bounds; false for opaque bounds
* @param status A pointer to a UErrorCode to receive any errors.
* @stable ICU 4.0
**/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_useTransparentBounds(URegularExpression *regexp,
UBool b,
UErrorCode *status);
@@ -996,10 +999,10 @@ uregex_useTransparentBounds(URegularExpression *regexp,
*
* @param regexp The compiled regular expression.
* @param status A pointer to a UErrorCode to receive any errors.
- * @return TRUE if this matcher is using anchoring bounds.
+ * @return true if this matcher is using anchoring bounds.
* @stable ICU 4.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uregex_hasAnchoringBounds(const URegularExpression *regexp,
UErrorCode *status);
@@ -1013,41 +1016,41 @@ uregex_hasAnchoringBounds(const URegularExpression *regexp,
* Anchoring Bounds are the default for regions.
*
* @param regexp The compiled regular expression.
- * @param b TRUE if to enable anchoring bounds; FALSE to disable them.
+ * @param b true if to enable anchoring bounds; false to disable them.
* @param status A pointer to a UErrorCode to receive any errors.
* @stable ICU 4.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_useAnchoringBounds(URegularExpression *regexp,
UBool b,
UErrorCode *status);
/**
- * Return TRUE if the most recent matching operation touched the
+ * Return true if the most recent matching operation touched the
* end of the text being processed. In this case, additional input text could
* change the results of that match.
*
* @param regexp The compiled regular expression.
* @param status A pointer to a UErrorCode to receive any errors.
- * @return TRUE if the most recent match hit the end of input
+ * @return true if the most recent match hit the end of input
* @stable ICU 4.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uregex_hitEnd(const URegularExpression *regexp,
UErrorCode *status);
/**
- * Return TRUE the most recent match succeeded and additional input could cause
+ * Return true the most recent match succeeded and additional input could cause
* it to fail. If this function returns false and a match was found, then more input
* might change the match but the match won't be lost. If a match was not found,
* then requireEnd has no meaning.
*
* @param regexp The compiled regular expression.
* @param status A pointer to a UErrorCode to receive any errors.
- * @return TRUE if more input could cause the most recent match to no longer match.
+ * @return true if more input could cause the most recent match to no longer match.
* @stable ICU 4.0
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uregex_requireEnd(const URegularExpression *regexp,
UErrorCode *status);
@@ -1079,7 +1082,7 @@ uregex_requireEnd(const URegularExpression *regexp,
* is still the full length of the untruncated string.
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_replaceAll(URegularExpression *regexp,
const UChar *replacementText,
int32_t replacementLength,
@@ -1108,7 +1111,7 @@ uregex_replaceAll(URegularExpression *regexp,
*
* @stable ICU 4.6
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
uregex_replaceAllUText(URegularExpression *regexp,
UText *replacement,
UText *dest,
@@ -1138,7 +1141,7 @@ uregex_replaceAllUText(URegularExpression *regexp,
* is still the full length of the untruncated string.
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_replaceFirst(URegularExpression *regexp,
const UChar *replacementText,
int32_t replacementLength,
@@ -1167,7 +1170,7 @@ uregex_replaceFirst(URegularExpression *regexp,
*
* @stable ICU 4.6
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
uregex_replaceFirstUText(URegularExpression *regexp,
UText *replacement,
UText *dest,
@@ -1219,7 +1222,7 @@ uregex_replaceFirstUText(URegularExpression *regexp,
* @stable ICU 3.0
*
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_appendReplacement(URegularExpression *regexp,
const UChar *replacementText,
int32_t replacementLength,
@@ -1249,7 +1252,7 @@ uregex_appendReplacement(URegularExpression *regexp,
*
* @stable ICU 4.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_appendReplacementUText(URegularExpression *regexp,
UText *replacementText,
UText *dest,
@@ -1279,7 +1282,7 @@ uregex_appendReplacementUText(URegularExpression *regexp,
*
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_appendTail(URegularExpression *regexp,
UChar **destBuf,
int32_t *destCapacity,
@@ -1303,7 +1306,7 @@ uregex_appendTail(URegularExpression *regexp,
*
* @stable ICU 4.6
*/
-U_STABLE UText * U_EXPORT2
+U_CAPI UText * U_EXPORT2
uregex_appendTailUText(URegularExpression *regexp,
UText *dest,
UErrorCode *status);
@@ -1359,7 +1362,7 @@ uregex_appendTailUText(URegularExpression *regexp,
* @return The number of fields into which the input string was split.
* @stable ICU 3.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_split( URegularExpression *regexp,
UChar *destBuf,
int32_t destCapacity,
@@ -1394,7 +1397,7 @@ uregex_split( URegularExpression *regexp,
*
* @stable ICU 4.6
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_splitUText(URegularExpression *regexp,
UText *destFields[],
int32_t destFieldsCapacity,
@@ -1422,7 +1425,7 @@ uregex_splitUText(URegularExpression *regexp,
* @param status A reference to a UErrorCode to receive any errors.
* @stable ICU 4.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_setTimeLimit(URegularExpression *regexp,
int32_t limit,
UErrorCode *status);
@@ -1436,7 +1439,7 @@ uregex_setTimeLimit(URegularExpression *regexp,
* @return the maximum allowed time for a match, in units of processing steps.
* @stable ICU 4.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_getTimeLimit(const URegularExpression *regexp,
UErrorCode *status);
@@ -1460,7 +1463,7 @@ uregex_getTimeLimit(const URegularExpression *regexp,
*
* @stable ICU 4.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_setStackLimit(URegularExpression *regexp,
int32_t limit,
UErrorCode *status);
@@ -1472,7 +1475,7 @@ uregex_setStackLimit(URegularExpression *regexp,
* stack size is unlimited.
* @stable ICU 4.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregex_getStackLimit(const URegularExpression *regexp,
UErrorCode *status);
@@ -1480,7 +1483,7 @@ uregex_getStackLimit(const URegularExpression *regexp,
/**
* Function pointer for a regular expression matching callback function.
* When set, a callback function will be called periodically during matching
- * operations. If the call back function returns FALSE, the matching
+ * operations. If the call back function returns false, the matching
* operation will be terminated early.
*
* Note: the callback function must not call other functions on this
@@ -1491,8 +1494,8 @@ uregex_getStackLimit(const URegularExpression *regexp,
* uregex_setMatchCallback() is called.
* @param steps the accumulated processing time, in match steps,
* for this matching operation.
- * @return TRUE to continue the matching operation.
- * FALSE to terminate the matching operation.
+ * @return true to continue the matching operation.
+ * false to terminate the matching operation.
* @stable ICU 4.0
*/
U_CDECL_BEGIN
@@ -1515,7 +1518,7 @@ U_CDECL_END
* @param status A reference to a UErrorCode to receive any errors.
* @stable ICU 4.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_setMatchCallback(URegularExpression *regexp,
URegexMatchCallback *callback,
const void *context,
@@ -1533,7 +1536,7 @@ uregex_setMatchCallback(URegularExpression *regexp,
* @param status A reference to a UErrorCode to receive any errors.
* @stable ICU 4.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_getMatchCallback(const URegularExpression *regexp,
URegexMatchCallback **callback,
const void **context,
@@ -1554,7 +1557,7 @@ uregex_getMatchCallback(const URegularExpression *regexp,
* to be attempted, giving the application the opportunity to terminate a long-running
* find operation.
*
- * If the call back function returns FALSE, the find operation will be terminated early.
+ * If the call back function returns false, the find operation will be terminated early.
*
* Note: the callback function must not call other functions on this
* URegularExpression
@@ -1565,8 +1568,8 @@ uregex_getMatchCallback(const URegularExpression *regexp,
* @param matchIndex the next index at which a match attempt will be attempted for this
* find operation. If this callback interrupts the search, this is the
* index at which a find/findNext operation may be re-initiated.
- * @return TRUE to continue the matching operation.
- * FALSE to terminate the matching operation.
+ * @return true to continue the matching operation.
+ * false to terminate the matching operation.
* @stable ICU 4.6
*/
U_CDECL_BEGIN
@@ -1587,7 +1590,7 @@ U_CDECL_END
* @param status A reference to a UErrorCode to receive any errors.
* @stable ICU 4.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_setFindProgressCallback(URegularExpression *regexp,
URegexFindProgressCallback *callback,
const void *context,
@@ -1604,7 +1607,7 @@ uregex_setFindProgressCallback(URegularExpression *regexp,
* @param status A reference to a UErrorCode to receive any errors.
* @stable ICU 4.6
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uregex_getFindProgressCallback(const URegularExpression *regexp,
URegexFindProgressCallback **callback,
const void **context,
diff --git a/deps/icu-small/source/i18n/unicode/uregion.h b/deps/icu-small/source/i18n/unicode/uregion.h
index 9d0c1e99de..4e4e6aac9f 100644
--- a/deps/icu-small/source/i18n/unicode/uregion.h
+++ b/deps/icu-small/source/i18n/unicode/uregion.h
@@ -133,7 +133,7 @@ typedef struct URegion URegion; /**< @stable ICU 52 */
* (U_ILLEGAL_ARGUMENT_ERROR).
* @stable ICU 52
*/
-U_STABLE const URegion* U_EXPORT2
+U_CAPI const URegion* U_EXPORT2
uregion_getRegionFromCode(const char *regionCode, UErrorCode *status);
/**
@@ -141,7 +141,7 @@ uregion_getRegionFromCode(const char *regionCode, UErrorCode *status);
* code is not recognized, the appropriate error code will be set (U_ILLEGAL_ARGUMENT_ERROR).
* @stable ICU 52
*/
-U_STABLE const URegion* U_EXPORT2
+U_CAPI const URegion* U_EXPORT2
uregion_getRegionFromNumericCode (int32_t code, UErrorCode *status);
/**
@@ -149,14 +149,14 @@ uregion_getRegionFromNumericCode (int32_t code, UErrorCode *status);
* The enumeration must be closed with with uenum_close().
* @stable ICU 52
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
uregion_getAvailable(URegionType type, UErrorCode *status);
/**
* Returns true if the specified uregion is equal to the specified otherRegion.
* @stable ICU 52
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uregion_areEqual(const URegion* uregion, const URegion* otherRegion);
/**
@@ -165,7 +165,7 @@ uregion_areEqual(const URegion* uregion, const URegion* otherRegion);
* this method with region "IT" (Italy) returns the URegion for "039" (Southern Europe).
* @stable ICU 52
*/
-U_STABLE const URegion* U_EXPORT2
+U_CAPI const URegion* U_EXPORT2
uregion_getContainingRegion(const URegion* uregion);
/**
@@ -177,7 +177,7 @@ uregion_getContainingRegion(const URegion* uregion);
* URegion "150" (Europe).
* @stable ICU 52
*/
-U_STABLE const URegion* U_EXPORT2
+U_CAPI const URegion* U_EXPORT2
uregion_getContainingRegionOfType(const URegion* uregion, URegionType type);
/**
@@ -190,7 +190,7 @@ uregion_getContainingRegionOfType(const URegion* uregion, URegionType type);
* and "155" (Western Europe). The enumeration must be closed with with uenum_close().
* @stable ICU 52
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
uregion_getContainedRegions(const URegion* uregion, UErrorCode *status);
/**
@@ -202,7 +202,7 @@ uregion_getContainedRegions(const URegion* uregion, UErrorCode *status);
* etc. The enumeration must be closed with with uenum_close().
* @stable ICU 52
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
uregion_getContainedRegionsOfType(const URegion* uregion, URegionType type, UErrorCode *status);
/**
@@ -210,7 +210,7 @@ uregion_getContainedRegionsOfType(const URegion* uregion, URegionType type, UErr
* hierarchy.
* @stable ICU 52
*/
-U_STABLE UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
uregion_contains(const URegion* uregion, const URegion* otherRegion);
/**
@@ -221,14 +221,14 @@ uregion_contains(const URegion* uregion, const URegion* otherRegion);
* "AZ" (Azerbaijan), etc... The enumeration must be closed with with uenum_close().
* @stable ICU 52
*/
-U_STABLE UEnumeration* U_EXPORT2
+U_CAPI UEnumeration* U_EXPORT2
uregion_getPreferredValues(const URegion* uregion, UErrorCode *status);
/**
* Returns the specified uregion's canonical code.
* @stable ICU 52
*/
-U_STABLE const char* U_EXPORT2
+U_CAPI const char* U_EXPORT2
uregion_getRegionCode(const URegion* uregion);
/**
@@ -236,14 +236,14 @@ uregion_getRegionCode(const URegion* uregion);
* for the specified uregion.
* @stable ICU 52
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uregion_getNumericCode(const URegion* uregion);
/**
* Returns the URegionType of the specified uregion.
* @stable ICU 52
*/
-U_STABLE URegionType U_EXPORT2
+U_CAPI URegionType U_EXPORT2
uregion_getType(const URegion* uregion);
diff --git a/deps/icu-small/source/i18n/unicode/ureldatefmt.h b/deps/icu-small/source/i18n/unicode/ureldatefmt.h
index d12f0988a8..b66139461b 100644
--- a/deps/icu-small/source/i18n/unicode/ureldatefmt.h
+++ b/deps/icu-small/source/i18n/unicode/ureldatefmt.h
@@ -16,9 +16,12 @@
#include "unicode/unum.h"
#include "unicode/udisplaycontext.h"
-#include "unicode/localpointer.h"
#include "unicode/uformattedvalue.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* \file
* \brief C API: URelativeDateTimeFormatter, relative date formatting of unit + numeric offset.
@@ -234,7 +237,7 @@ typedef struct URelativeDateTimeFormatter URelativeDateTimeFormatter; /**< C ty
* or NULL if an error occurred.
* @stable ICU 57
*/
-U_STABLE URelativeDateTimeFormatter* U_EXPORT2
+U_CAPI URelativeDateTimeFormatter* U_EXPORT2
ureldatefmt_open( const char* locale,
UNumberFormat* nfToAdopt,
UDateRelativeDateTimeFormatterStyle width,
@@ -247,7 +250,7 @@ ureldatefmt_open( const char* locale,
* The URelativeDateTimeFormatter object to close.
* @stable ICU 57
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ureldatefmt_close(URelativeDateTimeFormatter *reldatefmt);
struct UFormattedRelativeDateTime;
@@ -266,7 +269,7 @@ typedef struct UFormattedRelativeDateTime UFormattedRelativeDateTime;
* @return A pointer needing ownership.
* @stable ICU 64
*/
-U_STABLE UFormattedRelativeDateTime* U_EXPORT2
+U_CAPI UFormattedRelativeDateTime* U_EXPORT2
ureldatefmt_openResult(UErrorCode* ec);
/**
@@ -283,7 +286,7 @@ ureldatefmt_openResult(UErrorCode* ec);
* @return A UFormattedValue owned by the input object.
* @stable ICU 64
*/
-U_STABLE const UFormattedValue* U_EXPORT2
+U_CAPI const UFormattedValue* U_EXPORT2
ureldatefmt_resultAsValue(const UFormattedRelativeDateTime* ufrdt, UErrorCode* ec);
/**
@@ -292,7 +295,7 @@ ureldatefmt_resultAsValue(const UFormattedRelativeDateTime* ufrdt, UErrorCode* e
* @param ufrdt The object to release.
* @stable ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ureldatefmt_closeResult(UFormattedRelativeDateTime* ufrdt);
@@ -354,7 +357,7 @@ U_NAMESPACE_END
* than resultCapacity, in which case an error is returned.
* @stable ICU 57
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ureldatefmt_formatNumeric( const URelativeDateTimeFormatter* reldatefmt,
double offset,
URelativeDateTimeUnit unit,
@@ -385,7 +388,7 @@ ureldatefmt_formatNumeric( const URelativeDateTimeFormatter* reldatefmt,
* undefined.
* @stable ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ureldatefmt_formatNumericToResult(
const URelativeDateTimeFormatter* reldatefmt,
double offset,
@@ -421,7 +424,7 @@ ureldatefmt_formatNumericToResult(
* than resultCapacity, in which case an error is returned.
* @stable ICU 57
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ureldatefmt_format( const URelativeDateTimeFormatter* reldatefmt,
double offset,
URelativeDateTimeUnit unit,
@@ -455,7 +458,7 @@ ureldatefmt_format( const URelativeDateTimeFormatter* reldatefmt,
* undefined.
* @stable ICU 64
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
ureldatefmt_formatToResult(
const URelativeDateTimeFormatter* reldatefmt,
double offset,
@@ -492,7 +495,7 @@ ureldatefmt_formatToResult(
* in which case an error is returned.
* @stable ICU 57
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
ureldatefmt_combineDateAndTime( const URelativeDateTimeFormatter* reldatefmt,
const UChar * relativeDateString,
int32_t relativeDateStringLen,
diff --git a/deps/icu-small/source/i18n/unicode/usearch.h b/deps/icu-small/source/i18n/unicode/usearch.h
index d9d84b4f6a..26c22b7353 100644
--- a/deps/icu-small/source/i18n/unicode/usearch.h
+++ b/deps/icu-small/source/i18n/unicode/usearch.h
@@ -15,18 +15,21 @@
#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION
-#include "unicode/localpointer.h"
#include "unicode/ucol.h"
#include "unicode/ucoleitr.h"
#include "unicode/ubrk.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/**
* \file
* \brief C API: StringSearch
*
* C APIs for an engine that provides language-sensitive text searching based
- * on the comparison rules defined in a <tt>UCollator</tt> data struct,
- * see <tt>ucol.h</tt>. This ensures that language eccentricity can be
+ * on the comparison rules defined in a <code>UCollator</code> data struct,
+ * see <code>ucol.h</code>. This ensures that language eccentricity can be
* handled, e.g. for the German collator, characters &szlig; and SS will be matched
* if case is chosen to be ignored.
* See the <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm">
@@ -54,18 +57,18 @@
* Option 2. will be the default.
* <p>
* This search has APIs similar to that of other text iteration mechanisms
- * such as the break iterators in <tt>ubrk.h</tt>. Using these
+ * such as the break iterators in <code>ubrk.h</code>. Using these
* APIs, it is easy to scan through text looking for all occurrences of
* a given pattern. This search iterator allows changing of direction by
- * calling a <tt>reset</tt> followed by a <tt>next</tt> or <tt>previous</tt>.
- * Though a direction change can occur without calling <tt>reset</tt> first,
+ * calling a <code>reset</code> followed by a <code>next</code> or <code>previous</code>.
+ * Though a direction change can occur without calling <code>reset</code> first,
* this operation comes with some speed penalty.
* Generally, match results in the forward direction will match the result
* matches in the backwards direction in the reverse order
* <p>
- * <tt>usearch.h</tt> provides APIs to specify the starting position
- * within the text string to be searched, e.g. <tt>usearch_setOffset</tt>,
- * <tt>usearch_preceding</tt> and <tt>usearch_following</tt>. Since the
+ * <code>usearch.h</code> provides APIs to specify the starting position
+ * within the text string to be searched, e.g. <code>usearch_setOffset</code>,
+ * <code>usearch_preceding</code> and <code>usearch_following</code>. Since the
* starting position will be set as it is specified, please take note that
* there are some dangerous positions which the search may render incorrect
* results:
@@ -101,7 +104,7 @@
* Though collator attributes will be taken into consideration while
* performing matches, there are no APIs here for setting and getting the
* attributes. These attributes can be set by getting the collator
- * from <tt>usearch_getCollator</tt> and using the APIs in <tt>ucol.h</tt>.
+ * from <code>usearch_getCollator</code> and using the APIs in <code>ucol.h</code>.
* Lastly to update String Search to the new collator attributes,
* usearch_reset() has to be called.
* <p>
@@ -277,9 +280,13 @@ typedef enum {
/* open and close ------------------------------------------------------ */
/**
-* Creating a search iterator data struct using the argument locale language
+* Creates a String Search iterator data struct using the argument locale language
* rule set. A collator will be created in the process, which will be owned by
-* this search and will be deleted in <tt>usearch_close</tt>.
+* this String Search and will be deleted in <code>usearch_close</code>.
+*
+* The UStringSearch retains a pointer to both the pattern and text strings.
+* The caller must not modify or delete them while using the UStringSearch.
+*
* @param pattern for matching
* @param patternlength length of the pattern, -1 for null-termination
* @param text text string
@@ -288,9 +295,9 @@ typedef enum {
* @param breakiter A BreakIterator that will be used to restrict the points
* at which matches are detected. If a match is found, but
* the match's start or end index is not a boundary as
-* determined by the <tt>BreakIterator</tt>, the match will
+* determined by the <code>BreakIterator</code>, the match will
* be rejected and another will be searched for.
-* If this parameter is <tt>NULL</tt>, no break detection is
+* If this parameter is <code>NULL</code>, no break detection is
* attempted.
* @param status for errors if it occurs. If pattern or text is NULL, or if
* patternlength or textlength is 0 then an
@@ -298,7 +305,7 @@ typedef enum {
* @return search iterator data structure, or NULL if there is an error.
* @stable ICU 2.4
*/
-U_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar *pattern,
+U_CAPI UStringSearch * U_EXPORT2 usearch_open(const UChar *pattern,
int32_t patternlength,
const UChar *text,
int32_t textlength,
@@ -307,11 +314,16 @@ U_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar *pattern,
UErrorCode *status);
/**
-* Creating a search iterator data struct using the argument collator language
+* Creates a String Search iterator data struct using the argument collator language
* rule set. Note, user retains the ownership of this collator, thus the
* responsibility of deletion lies with the user.
-* NOTE: string search cannot be instantiated from a collator that has
-* collate digits as numbers (CODAN) turned on.
+
+* NOTE: String Search cannot be instantiated from a collator that has
+* collate digits as numbers (CODAN) turned on (UCOL_NUMERIC_COLLATION).
+*
+* The UStringSearch retains a pointer to both the pattern and text strings.
+* The caller must not modify or delete them while using the UStringSearch.
+*
* @param pattern for matching
* @param patternlength length of the pattern, -1 for null-termination
* @param text text string
@@ -320,9 +332,9 @@ U_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar *pattern,
* @param breakiter A BreakIterator that will be used to restrict the points
* at which matches are detected. If a match is found, but
* the match's start or end index is not a boundary as
-* determined by the <tt>BreakIterator</tt>, the match will
+* determined by the <code>BreakIterator</code>, the match will
* be rejected and another will be searched for.
-* If this parameter is <tt>NULL</tt>, no break detection is
+* If this parameter is <code>NULL</code>, no break detection is
* attempted.
* @param status for errors if it occurs. If collator, pattern or text is NULL,
* or if patternlength or textlength is 0 then an
@@ -330,8 +342,8 @@ U_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar *pattern,
* @return search iterator data structure, or NULL if there is an error.
* @stable ICU 2.4
*/
-U_STABLE UStringSearch * U_EXPORT2 usearch_openFromCollator(
- const UChar *pattern,
+U_CAPI UStringSearch * U_EXPORT2 usearch_openFromCollator(
+ const UChar *pattern,
int32_t patternlength,
const UChar *text,
int32_t textlength,
@@ -340,12 +352,12 @@ U_STABLE UStringSearch * U_EXPORT2 usearch_openFromCollator(
UErrorCode *status);
/**
-* Destroying and cleaning up the search iterator data struct.
-* If a collator is created in <tt>usearch_open</tt>, it will be destroyed here.
-* @param searchiter data struct to clean up
-* @stable ICU 2.4
-*/
-U_STABLE void U_EXPORT2 usearch_close(UStringSearch *searchiter);
+ * Destroys and cleans up the String Search iterator data struct.
+ * If a collator was created in <code>usearch_open</code>, then it will be destroyed here.
+ * @param searchiter The UStringSearch to clean up
+ * @stable ICU 2.4
+ */
+U_CAPI void U_EXPORT2 usearch_close(UStringSearch *searchiter);
#if U_SHOW_CPLUSPLUS_API
@@ -383,24 +395,24 @@ U_NAMESPACE_END
* @param status error status if any.
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2 usearch_setOffset(UStringSearch *strsrch,
- int32_t position,
+U_CAPI void U_EXPORT2 usearch_setOffset(UStringSearch *strsrch,
+ int32_t position,
UErrorCode *status);
/**
* Return the current index in the string text being searched.
* If the iteration has gone past the end of the text (or past the beginning
-* for a backwards search), <tt>USEARCH_DONE</tt> is returned.
+* for a backwards search), <code>USEARCH_DONE</code> is returned.
* @param strsrch search iterator data struct
* @see #USEARCH_DONE
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2 usearch_getOffset(const UStringSearch *strsrch);
+U_CAPI int32_t U_EXPORT2 usearch_getOffset(const UStringSearch *strsrch);
/**
* Sets the text searching attributes located in the enum USearchAttribute
* with values from the enum USearchAttributeValue.
-* <tt>USEARCH_DEFAULT</tt> can be used for all attributes for resetting.
+* <code>USEARCH_DEFAULT</code> can be used for all attributes for resetting.
* @param strsrch search iterator data struct
* @param attribute text attribute to be set
* @param value text attribute value
@@ -408,7 +420,7 @@ U_STABLE int32_t U_EXPORT2 usearch_getOffset(const UStringSearch *strsrch);
* @see #usearch_getAttribute
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2 usearch_setAttribute(UStringSearch *strsrch,
+U_CAPI void U_EXPORT2 usearch_setAttribute(UStringSearch *strsrch,
USearchAttribute attribute,
USearchAttributeValue value,
UErrorCode *status);
@@ -421,19 +433,19 @@ U_STABLE void U_EXPORT2 usearch_setAttribute(UStringSearch *strsrch,
* @see #usearch_setAttribute
* @stable ICU 2.4
*/
-U_STABLE USearchAttributeValue U_EXPORT2 usearch_getAttribute(
+U_CAPI USearchAttributeValue U_EXPORT2 usearch_getAttribute(
const UStringSearch *strsrch,
USearchAttribute attribute);
/**
* Returns the index to the match in the text string that was searched.
* This call returns a valid result only after a successful call to
-* <tt>usearch_first</tt>, <tt>usearch_next</tt>, <tt>usearch_previous</tt>,
-* or <tt>usearch_last</tt>.
+* <code>usearch_first</code>, <code>usearch_next</code>, <code>usearch_previous</code>,
+* or <code>usearch_last</code>.
* Just after construction, or after a searching method returns
-* <tt>USEARCH_DONE</tt>, this method will return <tt>USEARCH_DONE</tt>.
+* <code>USEARCH_DONE</code>, this method will return <code>USEARCH_DONE</code>.
* <p>
-* Use <tt>usearch_getMatchedLength</tt> to get the matched string length.
+* Use <code>usearch_getMatchedLength</code> to get the matched string length.
* @param strsrch search iterator data struct
* @return index to a substring within the text string that is being
* searched.
@@ -444,16 +456,16 @@ U_STABLE USearchAttributeValue U_EXPORT2 usearch_getAttribute(
* @see #USEARCH_DONE
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2 usearch_getMatchedStart(
+U_CAPI int32_t U_EXPORT2 usearch_getMatchedStart(
const UStringSearch *strsrch);
/**
* Returns the length of text in the string which matches the search pattern.
* This call returns a valid result only after a successful call to
-* <tt>usearch_first</tt>, <tt>usearch_next</tt>, <tt>usearch_previous</tt>,
-* or <tt>usearch_last</tt>.
+* <code>usearch_first</code>, <code>usearch_next</code>, <code>usearch_previous</code>,
+* or <code>usearch_last</code>.
* Just after construction, or after a searching method returns
-* <tt>USEARCH_DONE</tt>, this method will return 0.
+* <code>USEARCH_DONE</code>, this method will return 0.
* @param strsrch search iterator data struct
* @return The length of the match in the string text, or 0 if there is no
* match currently.
@@ -464,22 +476,22 @@ U_STABLE int32_t U_EXPORT2 usearch_getMatchedStart(
* @see #USEARCH_DONE
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2 usearch_getMatchedLength(
+U_CAPI int32_t U_EXPORT2 usearch_getMatchedLength(
const UStringSearch *strsrch);
/**
* Returns the text that was matched by the most recent call to
-* <tt>usearch_first</tt>, <tt>usearch_next</tt>, <tt>usearch_previous</tt>,
-* or <tt>usearch_last</tt>.
+* <code>usearch_first</code>, <code>usearch_next</code>, <code>usearch_previous</code>,
+* or <code>usearch_last</code>.
* If the iterator is not pointing at a valid match (e.g. just after
-* construction or after <tt>USEARCH_DONE</tt> has been returned, returns
+* construction or after <code>USEARCH_DONE</code> has been returned, returns
* an empty string. If result is not large enough to store the matched text,
* result will be filled with the partial text and an U_BUFFER_OVERFLOW_ERROR
* will be returned in status. result will be null-terminated whenever
* possible. If the buffer fits the matched text exactly, a null-termination
* is not possible, then a U_STRING_NOT_TERMINATED_ERROR set in status.
* Pre-flighting can be either done with length = 0 or the API
-* <tt>usearch_getMatchedLength</tt>.
+* <code>usearch_getMatchedLength</code>.
* @param strsrch search iterator data struct
* @param result UChar buffer to store the matched string
* @param resultCapacity length of the result buffer
@@ -492,7 +504,7 @@ U_STABLE int32_t U_EXPORT2 usearch_getMatchedLength(
* @see #USEARCH_DONE
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch,
+U_CAPI int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch,
UChar *result,
int32_t resultCapacity,
UErrorCode *status);
@@ -506,30 +518,30 @@ U_STABLE int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch,
* @param breakiter A BreakIterator that will be used to restrict the points
* at which matches are detected. If a match is found, but
* the match's start or end index is not a boundary as
-* determined by the <tt>BreakIterator</tt>, the match will
+* determined by the <code>BreakIterator</code>, the match will
* be rejected and another will be searched for.
-* If this parameter is <tt>NULL</tt>, no break detection is
+* If this parameter is <code>NULL</code>, no break detection is
* attempted.
* @param status for errors if it occurs
* @see #usearch_getBreakIterator
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2 usearch_setBreakIterator(UStringSearch *strsrch,
+U_CAPI void U_EXPORT2 usearch_setBreakIterator(UStringSearch *strsrch,
UBreakIterator *breakiter,
UErrorCode *status);
/**
* Returns the BreakIterator that is used to restrict the points at which
* matches are detected. This will be the same object that was passed to the
-* constructor or to <tt>usearch_setBreakIterator</tt>. Note that
-* <tt>NULL</tt>
+* constructor or to <code>usearch_setBreakIterator</code>. Note that
+* <code>NULL</code>
* is a legal value; it means that break detection should not be attempted.
* @param strsrch search iterator data struct
* @return break iterator used
* @see #usearch_setBreakIterator
* @stable ICU 2.4
*/
-U_STABLE const UBreakIterator * U_EXPORT2 usearch_getBreakIterator(
+U_CAPI const UBreakIterator * U_EXPORT2 usearch_getBreakIterator(
const UStringSearch *strsrch);
#endif
@@ -538,6 +550,10 @@ U_STABLE const UBreakIterator * U_EXPORT2 usearch_getBreakIterator(
* Set the string text to be searched. Text iteration will hence begin at the
* start of the text string. This method is useful if you want to re-use an
* iterator to search for the same pattern within a different body of text.
+*
+* The UStringSearch retains a pointer to the text string. The caller must not
+* modify or delete the string while using the UStringSearch.
+*
* @param strsrch search iterator data struct
* @param text new string to look for match
* @param textlength length of the new string, -1 for null-termination
@@ -547,7 +563,7 @@ U_STABLE const UBreakIterator * U_EXPORT2 usearch_getBreakIterator(
* @see #usearch_getText
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2 usearch_setText( UStringSearch *strsrch,
+U_CAPI void U_EXPORT2 usearch_setText( UStringSearch *strsrch,
const UChar *text,
int32_t textlength,
UErrorCode *status);
@@ -560,20 +576,20 @@ U_STABLE void U_EXPORT2 usearch_setText( UStringSearch *strsrch,
* @see #usearch_setText
* @stable ICU 2.4
*/
-U_STABLE const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch,
+U_CAPI const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch,
int32_t *length);
/**
* Gets the collator used for the language rules.
* <p>
-* Deleting the returned <tt>UCollator</tt> before calling
-* <tt>usearch_close</tt> would cause the string search to fail.
-* <tt>usearch_close</tt> will delete the collator if this search owns it.
+* Deleting the returned <code>UCollator</code> before calling
+* <code>usearch_close</code> would cause the string search to fail.
+* <code>usearch_close</code> will delete the collator if this search owns it.
* @param strsrch search iterator data struct
* @return collator
* @stable ICU 2.4
*/
-U_STABLE UCollator * U_EXPORT2 usearch_getCollator(
+U_CAPI UCollator * U_EXPORT2 usearch_getCollator(
const UStringSearch *strsrch);
/**
@@ -586,7 +602,7 @@ U_STABLE UCollator * U_EXPORT2 usearch_getCollator(
* @param status for errors if it occurs
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch,
+U_CAPI void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch,
const UCollator *collator,
UErrorCode *status);
@@ -594,6 +610,10 @@ U_STABLE void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch,
* Sets the pattern used for matching.
* Internal data like the Boyer Moore table will be recalculated, but the
* iterator's position is unchanged.
+*
+* The UStringSearch retains a pointer to the pattern string. The caller must not
+* modify or delete the string while using the UStringSearch.
+*
* @param strsrch search iterator data struct
* @param pattern string
* @param patternlength pattern length, -1 for null-terminated string
@@ -602,7 +622,7 @@ U_STABLE void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch,
* done to strsrch.
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch,
+U_CAPI void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch,
const UChar *pattern,
int32_t patternlength,
UErrorCode *status);
@@ -615,7 +635,7 @@ U_STABLE void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch,
* @return pattern string
* @stable ICU 2.4
*/
-U_STABLE const UChar * U_EXPORT2 usearch_getPattern(
+U_CAPI const UChar * U_EXPORT2 usearch_getPattern(
const UStringSearch *strsrch,
int32_t *length);
@@ -625,28 +645,28 @@ U_STABLE const UChar * U_EXPORT2 usearch_getPattern(
* Returns the first index at which the string text matches the search
* pattern.
* The iterator is adjusted so that its current index (as returned by
-* <tt>usearch_getOffset</tt>) is the match position if one was found.
-* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
-* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>.
+* <code>usearch_getOffset</code>) is the match position if one was found.
+* If a match is not found, <code>USEARCH_DONE</code> will be returned and
+* the iterator will be adjusted to the index <code>USEARCH_DONE</code>.
* @param strsrch search iterator data struct
* @param status for errors if it occurs
* @return The character index of the first match, or
-* <tt>USEARCH_DONE</tt> if there are no matches.
+* <code>USEARCH_DONE</code> if there are no matches.
* @see #usearch_getOffset
* @see #USEARCH_DONE
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch,
+U_CAPI int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch,
UErrorCode *status);
/**
-* Returns the first index equal or greater than <tt>position</tt> at which
+* Returns the first index equal or greater than <code>position</code> at which
* the string text
* matches the search pattern. The iterator is adjusted so that its current
-* index (as returned by <tt>usearch_getOffset</tt>) is the match position if
+* index (as returned by <code>usearch_getOffset</code>) is the match position if
* one was found.
-* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
-* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>
+* If a match is not found, <code>USEARCH_DONE</code> will be returned and
+* the iterator will be adjusted to the index <code>USEARCH_DONE</code>
* <p>
* Search positions that may render incorrect results are highlighted in the
* header comments. If position is less than or greater than the text range
@@ -654,60 +674,60 @@ U_STABLE int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch,
* @param strsrch search iterator data struct
* @param position to start the search at
* @param status for errors if it occurs
-* @return The character index of the first match following <tt>pos</tt>,
-* or <tt>USEARCH_DONE</tt> if there are no matches.
+* @return The character index of the first match following <code>pos</code>,
+* or <code>USEARCH_DONE</code> if there are no matches.
* @see #usearch_getOffset
* @see #USEARCH_DONE
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch,
+U_CAPI int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch,
int32_t position,
UErrorCode *status);
/**
* Returns the last index in the target text at which it matches the search
* pattern. The iterator is adjusted so that its current
-* index (as returned by <tt>usearch_getOffset</tt>) is the match position if
+* index (as returned by <code>usearch_getOffset</code>) is the match position if
* one was found.
-* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
-* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>.
+* If a match is not found, <code>USEARCH_DONE</code> will be returned and
+* the iterator will be adjusted to the index <code>USEARCH_DONE</code>.
* @param strsrch search iterator data struct
* @param status for errors if it occurs
-* @return The index of the first match, or <tt>USEARCH_DONE</tt> if there
+* @return The index of the first match, or <code>USEARCH_DONE</code> if there
* are no matches.
* @see #usearch_getOffset
* @see #USEARCH_DONE
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch,
+U_CAPI int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch,
UErrorCode *status);
/**
-* Returns the first index less than <tt>position</tt> at which the string text
+* Returns the first index less than <code>position</code> at which the string text
* matches the search pattern. The iterator is adjusted so that its current
-* index (as returned by <tt>usearch_getOffset</tt>) is the match position if
+* index (as returned by <code>usearch_getOffset</code>) is the match position if
* one was found.
-* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
-* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>
+* If a match is not found, <code>USEARCH_DONE</code> will be returned and
+* the iterator will be adjusted to the index <code>USEARCH_DONE</code>
* <p>
* Search positions that may render incorrect results are highlighted in the
* header comments. If position is less than or greater than the text range
* for searching, an U_INDEX_OUTOFBOUNDS_ERROR will be returned.
* <p>
-* When <tt>USEARCH_OVERLAP</tt> option is off, the last index of the
-* result match is always less than <tt>position</tt>.
-* When <tt>USERARCH_OVERLAP</tt> is on, the result match may span across
-* <tt>position</tt>.
+* When <code>USEARCH_OVERLAP</code> option is off, the last index of the
+* result match is always less than <code>position</code>.
+* When <code>USERARCH_OVERLAP</code> is on, the result match may span across
+* <code>position</code>.
* @param strsrch search iterator data struct
* @param position index position the search is to begin at
* @param status for errors if it occurs
-* @return The character index of the first match preceding <tt>pos</tt>,
-* or <tt>USEARCH_DONE</tt> if there are no matches.
+* @return The character index of the first match preceding <code>pos</code>,
+* or <code>USEARCH_DONE</code> if there are no matches.
* @see #usearch_getOffset
* @see #USEARCH_DONE
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch,
+U_CAPI int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch,
int32_t position,
UErrorCode *status);
@@ -715,40 +735,40 @@ U_STABLE int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch,
* Returns the index of the next point at which the string text matches the
* search pattern, starting from the current position.
* The iterator is adjusted so that its current
-* index (as returned by <tt>usearch_getOffset</tt>) is the match position if
+* index (as returned by <code>usearch_getOffset</code>) is the match position if
* one was found.
-* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
-* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>
+* If a match is not found, <code>USEARCH_DONE</code> will be returned and
+* the iterator will be adjusted to the index <code>USEARCH_DONE</code>
* @param strsrch search iterator data struct
* @param status for errors if it occurs
* @return The index of the next match after the current position, or
-* <tt>USEARCH_DONE</tt> if there are no more matches.
+* <code>USEARCH_DONE</code> if there are no more matches.
* @see #usearch_first
* @see #usearch_getOffset
* @see #USEARCH_DONE
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch,
+U_CAPI int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch,
UErrorCode *status);
/**
* Returns the index of the previous point at which the string text matches
* the search pattern, starting at the current position.
* The iterator is adjusted so that its current
-* index (as returned by <tt>usearch_getOffset</tt>) is the match position if
+* index (as returned by <code>usearch_getOffset</code>) is the match position if
* one was found.
-* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
-* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>
+* If a match is not found, <code>USEARCH_DONE</code> will be returned and
+* the iterator will be adjusted to the index <code>USEARCH_DONE</code>
* @param strsrch search iterator data struct
* @param status for errors if it occurs
* @return The index of the previous match before the current position,
-* or <tt>USEARCH_DONE</tt> if there are no more matches.
+* or <code>USEARCH_DONE</code> if there are no more matches.
* @see #usearch_last
* @see #usearch_getOffset
* @see #USEARCH_DONE
* @stable ICU 2.4
*/
-U_STABLE int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch,
+U_CAPI int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch,
UErrorCode *status);
/**
@@ -761,7 +781,7 @@ U_STABLE int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch,
* @see #usearch_first
* @stable ICU 2.4
*/
-U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch);
+U_CAPI void U_EXPORT2 usearch_reset(UStringSearch *strsrch);
#ifndef U_HIDE_INTERNAL_API
/**
@@ -814,11 +834,11 @@ U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch);
* A value of -1 will be returned if no match was found.
*
* @param status Report any errors. Note that no match found is not an error.
- * @return TRUE if a match was found, FALSE otherwise.
+ * @return true if a match was found, false otherwise.
*
* @internal
*/
-U_INTERNAL UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
+U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
int32_t startIdx,
int32_t *matchStart,
int32_t *matchLimit,
@@ -874,11 +894,11 @@ U_INTERNAL UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
* A value of -1 will be returned if no match was found.
*
* @param status Report any errors. Note that no match found is not an error.
- * @return TRUE if a match was found, FALSE otherwise.
+ * @return true if a match was found, false otherwise.
*
* @internal
*/
-U_INTERNAL UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
+U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
int32_t startIdx,
int32_t *matchStart,
int32_t *matchLimit,
diff --git a/deps/icu-small/source/i18n/unicode/uspoof.h b/deps/icu-small/source/i18n/unicode/uspoof.h
index 63a13387b0..7680c687ce 100644
--- a/deps/icu-small/source/i18n/unicode/uspoof.h
+++ b/deps/icu-small/source/i18n/unicode/uspoof.h
@@ -22,12 +22,12 @@
#include "unicode/utypes.h"
#include "unicode/uset.h"
#include "unicode/parseerr.h"
-#include "unicode/localpointer.h"
#if !UCONFIG_NO_NORMALIZATION
#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
#include "unicode/unistr.h"
#include "unicode/uniset.h"
#endif
@@ -154,10 +154,10 @@
* UChar* skel = (UChar*) malloc(++len * sizeof(UChar));
* status = U_ZERO_ERROR;
* uspoof_getSkeleton(sc, 0, str, -1, skel, len, &status);
- * UBool result = FALSE;
+ * UBool result = false;
* for (size_t i=0; i<DICTIONARY_LENGTH; i++) {
* result = u_strcmp(skel, skeletons[i]) == 0;
- * if (result == TRUE) { break; }
+ * if (result == true) { break; }
* }
* // Has confusable in dictionary: 1 (status: U_ZERO_ERROR)
* printf("Has confusable in dictionary: %d (status: %s)\n", result, u_errorName(status));
@@ -601,7 +601,7 @@ typedef enum USpoofChecks {
* @return the newly created Spoof Checker
* @stable ICU 4.2
*/
-U_STABLE USpoofChecker * U_EXPORT2
+U_CAPI USpoofChecker * U_EXPORT2
uspoof_open(UErrorCode *status);
@@ -626,7 +626,7 @@ uspoof_open(UErrorCode *status);
* @see uspoof_serialize
* @stable ICU 4.2
*/
-U_STABLE USpoofChecker * U_EXPORT2
+U_CAPI USpoofChecker * U_EXPORT2
uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength,
UErrorCode *pErrorCode);
@@ -660,7 +660,7 @@ uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLeng
* @return A spoof checker that uses the rules from the input files.
* @stable ICU 4.2
*/
-U_STABLE USpoofChecker * U_EXPORT2
+U_CAPI USpoofChecker * U_EXPORT2
uspoof_openFromSource(const char *confusables, int32_t confusablesLen,
const char *confusablesWholeScript, int32_t confusablesWholeScriptLen,
int32_t *errType, UParseError *pe, UErrorCode *status);
@@ -671,7 +671,7 @@ uspoof_openFromSource(const char *confusables, int32_t confusablesLen,
* its implementation.
* @stable ICU 4.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uspoof_close(USpoofChecker *sc);
/**
@@ -683,7 +683,7 @@ uspoof_close(USpoofChecker *sc);
* @return
* @stable ICU 4.2
*/
-U_STABLE USpoofChecker * U_EXPORT2
+U_CAPI USpoofChecker * U_EXPORT2
uspoof_clone(const USpoofChecker *sc, UErrorCode *status);
@@ -691,8 +691,10 @@ uspoof_clone(const USpoofChecker *sc, UErrorCode *status);
* Specify the bitmask of checks that will be performed by {@link uspoof_check}. Calling this method
* overwrites any checks that may have already been enabled. By default, all checks are enabled.
*
- * To enable specific checks and disable all others, the "whitelisted" checks should be ORed together. For
- * example, to fail strings containing characters outside of the set specified by {@link uspoof_setAllowedChars} and
+ * To enable specific checks and disable all others,
+ * OR together only the bit constants for the desired checks.
+ * For example, to fail strings containing characters outside of
+ * the set specified by {@link uspoof_setAllowedChars} and
* also strings that contain digits from mixed numbering systems:
*
* <pre>
@@ -701,8 +703,9 @@ uspoof_clone(const USpoofChecker *sc, UErrorCode *status);
* }
* </pre>
*
- * To disable specific checks and enable all others, the "blacklisted" checks should be ANDed away from
- * ALL_CHECKS. For example, if you are not planning to use the {@link uspoof_areConfusable} functionality,
+ * To disable specific checks and enable all others,
+ * start with ALL_CHECKS and "AND away" the not-desired checks.
+ * For example, if you are not planning to use the {@link uspoof_areConfusable} functionality,
* it is good practice to disable the CONFUSABLE check:
*
* <pre>
@@ -724,7 +727,7 @@ uspoof_clone(const USpoofChecker *sc, UErrorCode *status);
* @stable ICU 4.2
*
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status);
/**
@@ -738,7 +741,7 @@ uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status);
* @stable ICU 4.2
*
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status);
/**
@@ -752,7 +755,7 @@ uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status);
* @see URestrictionLevel
* @stable ICU 51
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uspoof_setRestrictionLevel(USpoofChecker *sc, URestrictionLevel restrictionLevel);
@@ -763,7 +766,7 @@ uspoof_setRestrictionLevel(USpoofChecker *sc, URestrictionLevel restrictionLevel
* @see URestrictionLevel
* @stable ICU 51
*/
-U_STABLE URestrictionLevel U_EXPORT2
+U_CAPI URestrictionLevel U_EXPORT2
uspoof_getRestrictionLevel(const USpoofChecker *sc);
/**
@@ -808,7 +811,7 @@ uspoof_getRestrictionLevel(const USpoofChecker *sc);
* @param status The error code, set if this function encounters a problem.
* @stable ICU 4.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status);
/**
@@ -832,7 +835,7 @@ uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode
*
* @stable ICU 4.2
*/
-U_STABLE const char * U_EXPORT2
+U_CAPI const char * U_EXPORT2
uspoof_getAllowedLocales(USpoofChecker *sc, UErrorCode *status);
@@ -854,7 +857,7 @@ uspoof_getAllowedLocales(USpoofChecker *sc, UErrorCode *status);
* @param status The error code, set if this function encounters a problem.
* @stable ICU 4.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status);
@@ -878,7 +881,7 @@ uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status)
* the USPOOF_CHAR_LIMIT test.
* @stable ICU 4.2
*/
-U_STABLE const USet * U_EXPORT2
+U_CAPI const USet * U_EXPORT2
uspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status);
@@ -914,7 +917,7 @@ uspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status);
* @see uspoof_check2
* @stable ICU 4.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uspoof_check(const USpoofChecker *sc,
const UChar *id, int32_t length,
int32_t *position,
@@ -953,7 +956,7 @@ uspoof_check(const USpoofChecker *sc,
* @see uspoof_check2UTF8
* @stable ICU 4.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uspoof_checkUTF8(const USpoofChecker *sc,
const char *id, int32_t length,
int32_t *position,
@@ -988,7 +991,7 @@ uspoof_checkUTF8(const USpoofChecker *sc,
* @see uspoof_check2UnicodeString
* @stable ICU 58
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uspoof_check2(const USpoofChecker *sc,
const UChar* id, int32_t length,
USpoofCheckResult* checkResult,
@@ -1025,7 +1028,7 @@ uspoof_check2(const USpoofChecker *sc,
* @see uspoof_check2UnicodeString
* @stable ICU 58
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uspoof_check2UTF8(const USpoofChecker *sc,
const char *id, int32_t length,
USpoofCheckResult* checkResult,
@@ -1049,7 +1052,7 @@ uspoof_check2UTF8(const USpoofChecker *sc,
* @see uspoof_check2UnicodeString
* @stable ICU 58
*/
-U_STABLE USpoofCheckResult* U_EXPORT2
+U_CAPI USpoofCheckResult* U_EXPORT2
uspoof_openCheckResult(UErrorCode *status);
/**
@@ -1059,7 +1062,7 @@ uspoof_openCheckResult(UErrorCode *status);
* @param checkResult The instance of USpoofCheckResult to close
* @stable ICU 58
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uspoof_closeCheckResult(USpoofCheckResult *checkResult);
/**
@@ -1076,7 +1079,7 @@ uspoof_closeCheckResult(USpoofCheckResult *checkResult);
* @see uspoof_setChecks
* @stable ICU 58
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uspoof_getCheckResultChecks(const USpoofCheckResult *checkResult, UErrorCode *status);
/**
@@ -1089,7 +1092,7 @@ uspoof_getCheckResultChecks(const USpoofCheckResult *checkResult, UErrorCode *st
* @see uspoof_setRestrictionLevel
* @stable ICU 58
*/
-U_STABLE URestrictionLevel U_EXPORT2
+U_CAPI URestrictionLevel U_EXPORT2
uspoof_getCheckResultRestrictionLevel(const USpoofCheckResult *checkResult, UErrorCode *status);
/**
@@ -1103,7 +1106,7 @@ uspoof_getCheckResultRestrictionLevel(const USpoofCheckResult *checkResult, UErr
* @param status The error code, set if an error occurred.
* @stable ICU 58
*/
-U_STABLE const USet* U_EXPORT2
+U_CAPI const USet* U_EXPORT2
uspoof_getCheckResultNumerics(const USpoofCheckResult *checkResult, UErrorCode *status);
@@ -1150,7 +1153,7 @@ uspoof_getCheckResultNumerics(const USpoofCheckResult *checkResult, UErrorCode *
*
* @stable ICU 4.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uspoof_areConfusable(const USpoofChecker *sc,
const UChar *id1, int32_t length1,
const UChar *id2, int32_t length2,
@@ -1183,7 +1186,7 @@ uspoof_areConfusable(const USpoofChecker *sc,
*
* @see uspoof_areConfusable
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uspoof_areConfusableUTF8(const USpoofChecker *sc,
const char *id1, int32_t length1,
const char *id2, int32_t length2,
@@ -1223,7 +1226,7 @@ uspoof_areConfusableUTF8(const USpoofChecker *sc,
* @stable ICU 4.2
* @see uspoof_areConfusable
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uspoof_getSkeleton(const USpoofChecker *sc,
uint32_t type,
const UChar *id, int32_t length,
@@ -1263,7 +1266,7 @@ uspoof_getSkeleton(const USpoofChecker *sc,
*
* @stable ICU 4.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uspoof_getSkeletonUTF8(const USpoofChecker *sc,
uint32_t type,
const char *id, int32_t length,
@@ -1282,7 +1285,7 @@ uspoof_getSkeletonUTF8(const USpoofChecker *sc,
*
* @stable ICU 51
*/
-U_STABLE const USet * U_EXPORT2
+U_CAPI const USet * U_EXPORT2
uspoof_getInclusionSet(UErrorCode *status);
/**
@@ -1297,7 +1300,7 @@ uspoof_getInclusionSet(UErrorCode *status);
*
* @stable ICU 51
*/
-U_STABLE const USet * U_EXPORT2
+U_CAPI const USet * U_EXPORT2
uspoof_getRecommendedSet(UErrorCode *status);
/**
@@ -1322,7 +1325,7 @@ uspoof_getRecommendedSet(UErrorCode *status);
* @see utrie2_openFromSerialized()
* @stable ICU 4.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uspoof_serialize(USpoofChecker *sc,
void *data, int32_t capacity,
UErrorCode *status);
@@ -1388,7 +1391,7 @@ U_NAMESPACE_END
* @param status The error code, set if this function encounters a problem.
* @stable ICU 4.2
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UErrorCode *status);
@@ -1412,7 +1415,7 @@ uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UEr
* the USPOOF_CHAR_LIMIT test.
* @stable ICU 4.2
*/
-U_STABLE const icu::UnicodeSet * U_EXPORT2
+U_CAPI const icu::UnicodeSet * U_EXPORT2
uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status);
/**
@@ -1443,7 +1446,7 @@ uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status);
* @see uspoof_check2UnicodeString
* @stable ICU 4.2
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uspoof_checkUnicodeString(const USpoofChecker *sc,
const icu::UnicodeString &id,
int32_t *position,
@@ -1474,7 +1477,7 @@ uspoof_checkUnicodeString(const USpoofChecker *sc,
* @see uspoof_check2UTF8
* @stable ICU 58
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uspoof_check2UnicodeString(const USpoofChecker *sc,
const icu::UnicodeString &id,
USpoofCheckResult* checkResult,
@@ -1501,7 +1504,7 @@ uspoof_check2UnicodeString(const USpoofChecker *sc,
*
* @see uspoof_areConfusable
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
uspoof_areConfusableUnicodeString(const USpoofChecker *sc,
const icu::UnicodeString &s1,
const icu::UnicodeString &s2,
@@ -1549,7 +1552,7 @@ uspoof_getSkeletonUnicodeString(const USpoofChecker *sc,
*
* @stable ICU 51
*/
-U_STABLE const icu::UnicodeSet * U_EXPORT2
+U_CAPI const icu::UnicodeSet * U_EXPORT2
uspoof_getInclusionUnicodeSet(UErrorCode *status);
/**
@@ -1564,7 +1567,7 @@ uspoof_getInclusionUnicodeSet(UErrorCode *status);
*
* @stable ICU 51
*/
-U_STABLE const icu::UnicodeSet * U_EXPORT2
+U_CAPI const icu::UnicodeSet * U_EXPORT2
uspoof_getRecommendedUnicodeSet(UErrorCode *status);
#endif /* U_SHOW_CPLUSPLUS_API */
diff --git a/deps/icu-small/source/i18n/unicode/utmscale.h b/deps/icu-small/source/i18n/unicode/utmscale.h
index 2392c6414e..b7dca15367 100644
--- a/deps/icu-small/source/i18n/unicode/utmscale.h
+++ b/deps/icu-small/source/i18n/unicode/utmscale.h
@@ -449,7 +449,7 @@ typedef enum UTimeScaleValue {
*
* @stable ICU 3.2
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
utmscale_getTimeScaleValue(UDateTimeScale timeScale, UTimeScaleValue value, UErrorCode *status);
/* Conversion to 'universal time scale' */
@@ -465,7 +465,7 @@ U_STABLE int64_t U_EXPORT2
*
* @stable ICU 3.2
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
utmscale_fromInt64(int64_t otherTime, UDateTimeScale timeScale, UErrorCode *status);
/* Conversion from 'universal time scale' */
@@ -481,7 +481,7 @@ U_STABLE int64_t U_EXPORT2
*
* @stable ICU 3.2
*/
-U_STABLE int64_t U_EXPORT2
+U_CAPI int64_t U_EXPORT2
utmscale_toInt64(int64_t universalTime, UDateTimeScale timeScale, UErrorCode *status);
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/unicode/utrans.h b/deps/icu-small/source/i18n/unicode/utrans.h
index 56640eda96..e959378285 100644
--- a/deps/icu-small/source/i18n/unicode/utrans.h
+++ b/deps/icu-small/source/i18n/unicode/utrans.h
@@ -17,12 +17,15 @@
#if !UCONFIG_NO_TRANSLITERATION
-#include "unicode/localpointer.h"
#include "unicode/urep.h"
#include "unicode/parseerr.h"
#include "unicode/uenum.h"
#include "unicode/uset.h"
+#if U_SHOW_CPLUSPLUS_API
+#include "unicode/localpointer.h"
+#endif // U_SHOW_CPLUSPLUS_API
+
/********************************************************************
* General Notes
********************************************************************
@@ -188,7 +191,7 @@ typedef struct UTransPosition {
* utrans_xxx() functions, or NULL if the open call fails.
* @stable ICU 2.8
*/
-U_STABLE UTransliterator* U_EXPORT2
+U_CAPI UTransliterator* U_EXPORT2
utrans_openU(const UChar *id,
int32_t idLength,
UTransDirection dir,
@@ -212,7 +215,7 @@ utrans_openU(const UChar *id,
* inverse of trans, or NULL if the open call fails.
* @stable ICU 2.0
*/
-U_STABLE UTransliterator* U_EXPORT2
+U_CAPI UTransliterator* U_EXPORT2
utrans_openInverse(const UTransliterator* trans,
UErrorCode* status);
@@ -226,7 +229,7 @@ utrans_openInverse(const UTransliterator* trans,
* utrans_xxx() functions, or NULL if the clone call fails.
* @stable ICU 2.0
*/
-U_STABLE UTransliterator* U_EXPORT2
+U_CAPI UTransliterator* U_EXPORT2
utrans_clone(const UTransliterator* trans,
UErrorCode* status);
@@ -236,7 +239,7 @@ utrans_clone(const UTransliterator* trans,
* @param trans the transliterator to be closed.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utrans_close(UTransliterator* trans);
#if U_SHOW_CPLUSPLUS_API
@@ -272,7 +275,7 @@ U_NAMESPACE_END
*
* @stable ICU 2.8
*/
-U_STABLE const UChar * U_EXPORT2
+U_CAPI const UChar * U_EXPORT2
utrans_getUnicodeID(const UTransliterator *trans,
int32_t *resultLength);
@@ -290,7 +293,7 @@ utrans_getUnicodeID(const UTransliterator *trans,
* @param status a pointer to the UErrorCode
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utrans_register(UTransliterator* adoptedTrans,
UErrorCode* status);
@@ -303,7 +306,7 @@ utrans_register(UTransliterator* adoptedTrans,
* @param idLength the length of id, or -1 if id is zero-terminated
* @stable ICU 2.8
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utrans_unregisterID(const UChar* id, int32_t idLength);
/**
@@ -324,7 +327,7 @@ utrans_unregisterID(const UChar* id, int32_t idLength);
* @see UnicodeSet
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utrans_setFilter(UTransliterator* trans,
const UChar* filterPattern,
int32_t filterPatternLen,
@@ -337,7 +340,7 @@ utrans_setFilter(UTransliterator* trans,
* @return the number of system transliterators.
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utrans_countAvailableIDs(void);
/**
@@ -349,7 +352,7 @@ utrans_countAvailableIDs(void);
*
* @stable ICU 2.8
*/
-U_STABLE UEnumeration * U_EXPORT2
+U_CAPI UEnumeration * U_EXPORT2
utrans_openIDs(UErrorCode *pErrorCode);
/********************************************************************
@@ -379,7 +382,7 @@ utrans_openIDs(UErrorCode *pErrorCode);
* @param status a pointer to the UErrorCode
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utrans_trans(const UTransliterator* trans,
UReplaceable* rep,
const UReplaceableCallbacks* repFunc,
@@ -430,7 +433,7 @@ utrans_trans(const UTransliterator* trans,
* @param status a pointer to the UErrorCode
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utrans_transIncremental(const UTransliterator* trans,
UReplaceable* rep,
const UReplaceableCallbacks* repFunc,
@@ -467,7 +470,7 @@ utrans_transIncremental(const UTransliterator* trans,
* @param status a pointer to the UErrorCode
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utrans_transUChars(const UTransliterator* trans,
UChar* text,
int32_t* textLength,
@@ -502,7 +505,7 @@ utrans_transUChars(const UTransliterator* trans,
* @see utrans_transIncremental
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_CAPI void U_EXPORT2
utrans_transIncrementalUChars(const UTransliterator* trans,
UChar* text,
int32_t* textLength,
@@ -515,7 +518,7 @@ utrans_transIncrementalUChars(const UTransliterator* trans,
* transliterator.
*
* @param trans The transliterator
- * @param escapeUnprintable if TRUE then convert unprintable characters to their
+ * @param escapeUnprintable if true then convert unprintable characters to their
* hex escape representations, \\uxxxx or \\Uxxxxxxxx.
* Unprintable characters are those other than
* U+000A, U+0020..U+007E.
@@ -527,7 +530,7 @@ utrans_transIncrementalUChars(const UTransliterator* trans,
* in which case an error is returned).
* @stable ICU 53
*/
-U_STABLE int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
utrans_toRules( const UTransliterator* trans,
UBool escapeUnprintable,
UChar* result, int32_t resultLength,
@@ -537,9 +540,9 @@ utrans_toRules( const UTransliterator* trans,
* Returns the set of all characters that may be modified in the input text by
* this UTransliterator, optionally ignoring the transliterator's current filter.
* @param trans The transliterator.
- * @param ignoreFilter If FALSE, the returned set incorporates the
+ * @param ignoreFilter If false, the returned set incorporates the
* UTransliterator's current filter; if the filter is changed,
- * the return value of this function will change. If TRUE, the
+ * the return value of this function will change. If true, the
* returned set ignores the effect of the UTransliterator's
* current filter.
* @param fillIn Pointer to a USet object to receive the modifiable characters
@@ -552,7 +555,7 @@ utrans_toRules( const UTransliterator* trans,
* error, NULL is returned.
* @stable ICU 53
*/
-U_STABLE USet* U_EXPORT2
+U_CAPI USet* U_EXPORT2
utrans_getSourceSet(const UTransliterator* trans,
UBool ignoreFilter,
USet* fillIn,
diff --git a/deps/icu-small/source/i18n/unicode/vtzone.h b/deps/icu-small/source/i18n/unicode/vtzone.h
index 43a5652d6a..89a79c07b3 100644
--- a/deps/icu-small/source/i18n/unicode/vtzone.h
+++ b/deps/icu-small/source/i18n/unicode/vtzone.h
@@ -119,7 +119,7 @@ public:
* created from VTIMEZONE data, the initial value is set by the TZURL property value
* in the data. Otherwise, the initial value is not set.
* @param url Receives the RFC2445 TZURL property value.
- * @return TRUE if TZURL attribute is available and value is set.
+ * @return true if TZURL attribute is available and value is set.
* @stable ICU 3.8
*/
UBool getTZURL(UnicodeString& url) const;
@@ -136,7 +136,7 @@ public:
* was created from VTIMEZONE data, the initial value is set by the LAST-MODIFIED property
* value in the data. Otherwise, the initial value is not set.
* @param lastModified Receives the last modified date.
- * @return TRUE if lastModified attribute is available and value is set.
+ * @return true if lastModified attribute is available and value is set.
* @stable ICU 3.8
*/
UBool getLastModified(UDate& lastModified) const;
@@ -322,7 +322,7 @@ public:
* @param base The base time.
* @param inclusive Whether the base time is inclusive or not.
* @param result Receives the first transition after the base time.
- * @return TRUE if the transition is found.
+ * @return true if the transition is found.
* @stable ICU 3.8
*/
virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const;
@@ -332,7 +332,7 @@ public:
* @param base The base time.
* @param inclusive Whether the base time is inclusive or not.
* @param result Receives the most recent transition before the base time.
- * @return TRUE if the transition is found.
+ * @return true if the transition is found.
* @stable ICU 3.8
*/
virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const;
diff --git a/deps/icu-small/source/i18n/units_complexconverter.cpp b/deps/icu-small/source/i18n/units_complexconverter.cpp
new file mode 100644
index 0000000000..27f835e6dd
--- /dev/null
+++ b/deps/icu-small/source/i18n/units_complexconverter.cpp
@@ -0,0 +1,253 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include <cmath>
+
+#include "cmemory.h"
+#include "number_decimalquantity.h"
+#include "number_roundingutils.h"
+#include "uarrsort.h"
+#include "uassert.h"
+#include "unicode/fmtable.h"
+#include "unicode/localpointer.h"
+#include "unicode/measunit.h"
+#include "unicode/measure.h"
+#include "units_complexconverter.h"
+#include "units_converter.h"
+
+U_NAMESPACE_BEGIN
+namespace units {
+
+ComplexUnitsConverter::ComplexUnitsConverter(const MeasureUnitImpl &inputUnit,
+ const MeasureUnitImpl &outputUnits,
+ const ConversionRates &ratesInfo, UErrorCode &status)
+ : units_(outputUnits.extractIndividualUnits(status)) {
+ if (U_FAILURE(status)) {
+ return;
+ }
+
+ U_ASSERT(units_.length() != 0);
+
+ // Save the desired order of output units before we sort units_
+ for (int32_t i = 0; i < units_.length(); i++) {
+ outputUnits_.emplaceBackAndCheckErrorCode(status, units_[i]->copy(status).build(status));
+ }
+
+ // NOTE:
+ // This comparator is used to sort the units in a descending order. Therefore, we return -1 if
+ // the left is bigger than right and so on.
+ auto descendingCompareUnits = [](const void *context, const void *left, const void *right) {
+ UErrorCode status = U_ZERO_ERROR;
+
+ const auto *leftPointer = static_cast<const MeasureUnitImpl *const *>(left);
+ const auto *rightPointer = static_cast<const MeasureUnitImpl *const *>(right);
+
+ UnitConverter fromLeftToRight(**leftPointer, //
+ **rightPointer, //
+ *static_cast<const ConversionRates *>(context), //
+ status);
+
+ double rightFromOneLeft = fromLeftToRight.convert(1.0);
+ if (std::abs(rightFromOneLeft - 1.0) < 0.0000000001) { // Equals To
+ return 0;
+ } else if (rightFromOneLeft > 1.0) { // Greater Than
+ return -1;
+ }
+
+ return 1; // Less Than
+ };
+
+ uprv_sortArray(units_.getAlias(), //
+ units_.length(), //
+ sizeof units_[0], /* NOTE: we have already asserted that the units_ is not empty.*/ //
+ descendingCompareUnits, //
+ &ratesInfo, //
+ false, //
+ &status //
+ );
+
+ // In case the `outputUnits` are `UMEASURE_UNIT_MIXED` such as `foot+inch`. In this case we need more
+ // converters to convert from the `inputUnit` to the first unit in the `outputUnits`. Then, a
+ // converter from the first unit in the `outputUnits` to the second unit and so on.
+ // For Example:
+ // - inputUnit is `meter`
+ // - outputUnits is `foot+inch`
+ // - Therefore, we need to have two converters:
+ // 1. a converter from `meter` to `foot`
+ // 2. a converter from `foot` to `inch`
+ // - Therefore, if the input is `2 meter`:
+ // 1. convert `meter` to `foot` --> 2 meter to 6.56168 feet
+ // 2. convert the residual of 6.56168 feet (0.56168) to inches, which will be (6.74016
+ // inches)
+ // 3. then, the final result will be (6 feet and 6.74016 inches)
+ for (int i = 0, n = units_.length(); i < n; i++) {
+ if (i == 0) { // first element
+ unitConverters_.emplaceBackAndCheckErrorCode(status, inputUnit, *units_[i], ratesInfo,
+ status);
+ } else {
+ unitConverters_.emplaceBackAndCheckErrorCode(status, *units_[i - 1], *units_[i], ratesInfo,
+ status);
+ }
+
+ if (U_FAILURE(status)) {
+ return;
+ }
+ }
+}
+
+UBool ComplexUnitsConverter::greaterThanOrEqual(double quantity, double limit) const {
+ U_ASSERT(unitConverters_.length() > 0);
+
+ // First converter converts to the biggest quantity.
+ double newQuantity = unitConverters_[0]->convert(quantity);
+ return newQuantity >= limit;
+}
+
+MaybeStackVector<Measure> ComplexUnitsConverter::convert(double quantity,
+ icu::number::impl::RoundingImpl *rounder,
+ UErrorCode &status) const {
+ // TODO(hugovdm): return an error for "foot-and-foot"?
+ MaybeStackVector<Measure> result;
+ int sign = 1;
+ if (quantity < 0) {
+ quantity *= -1;
+ sign = -1;
+ }
+
+ // For N converters:
+ // - the first converter converts from the input unit to the largest unit,
+ // - N-1 converters convert to bigger units for which we want integers,
+ // - the Nth converter (index N-1) converts to the smallest unit, for which
+ // we keep a double.
+ MaybeStackArray<int64_t, 5> intValues(unitConverters_.length() - 1, status);
+ if (U_FAILURE(status)) {
+ return result;
+ }
+ uprv_memset(intValues.getAlias(), 0, (unitConverters_.length() - 1) * sizeof(int64_t));
+
+ for (int i = 0, n = unitConverters_.length(); i < n; ++i) {
+ quantity = (*unitConverters_[i]).convert(quantity);
+ if (i < n - 1) {
+ // The double type has 15 decimal digits of precision. For choosing
+ // whether to use the current unit or the next smaller unit, we
+ // therefore nudge up the number with which the thresholding
+ // decision is made. However after the thresholding, we use the
+ // original values to ensure unbiased accuracy (to the extent of
+ // double's capabilities).
+ int64_t roundedQuantity = floor(quantity * (1 + DBL_EPSILON));
+ intValues[i] = roundedQuantity;
+
+ // Keep the residual of the quantity.
+ // For example: `3.6 feet`, keep only `0.6 feet`
+ //
+ // When the calculation is near enough +/- DBL_EPSILON, we round to
+ // zero. (We also ensure no negative values here.)
+ if ((quantity - roundedQuantity) / quantity < DBL_EPSILON) {
+ quantity = 0;
+ } else {
+ quantity -= roundedQuantity;
+ }
+ } else { // LAST ELEMENT
+ if (rounder == nullptr) {
+ // Nothing to do for the last element.
+ break;
+ }
+
+ // Round the last value
+ // TODO(ICU-21288): get smarter about precision for mixed units.
+ number::impl::DecimalQuantity quant;
+ quant.setToDouble(quantity);
+ rounder->apply(quant, status);
+ if (U_FAILURE(status)) {
+ return result;
+ }
+ quantity = quant.toDouble();
+ if (i == 0) {
+ // Last element is also the first element, so we're done
+ break;
+ }
+
+ // Check if there's a carry, and bubble it back up the resulting intValues.
+ int64_t carry = floor(unitConverters_[i]->convertInverse(quantity) * (1 + DBL_EPSILON));
+ if (carry <= 0) {
+ break;
+ }
+ quantity -= unitConverters_[i]->convert(carry);
+ intValues[i - 1] += carry;
+
+ // We don't use the first converter: that one is for the input unit
+ for (int32_t j = i - 1; j > 0; j--) {
+ carry = floor(unitConverters_[j]->convertInverse(intValues[j]) * (1 + DBL_EPSILON));
+ if (carry <= 0) {
+ break;
+ }
+ intValues[j] -= round(unitConverters_[j]->convert(carry));
+ intValues[j - 1] += carry;
+ }
+ }
+ }
+
+ // Package values into Measure instances in result:
+ for (int i = 0, n = unitConverters_.length(); i < n; ++i) {
+ if (i < n - 1) {
+ Formattable formattableQuantity(intValues[i] * sign);
+ // Measure takes ownership of the MeasureUnit*
+ MeasureUnit *type = new MeasureUnit(units_[i]->copy(status).build(status));
+ if (result.emplaceBackAndCheckErrorCode(status, formattableQuantity, type, status) ==
+ nullptr) {
+ // Ownership wasn't taken
+ U_ASSERT(U_FAILURE(status));
+ delete type;
+ }
+ if (U_FAILURE(status)) {
+ return result;
+ }
+ } else { // LAST ELEMENT
+ // Add the last element, not an integer:
+ Formattable formattableQuantity(quantity * sign);
+ // Measure takes ownership of the MeasureUnit*
+ MeasureUnit *type = new MeasureUnit(units_[i]->copy(status).build(status));
+ if (result.emplaceBackAndCheckErrorCode(status, formattableQuantity, type, status) ==
+ nullptr) {
+ // Ownership wasn't taken
+ U_ASSERT(U_FAILURE(status));
+ delete type;
+ }
+ if (U_FAILURE(status)) {
+ return result;
+ }
+ U_ASSERT(result.length() == i + 1);
+ U_ASSERT(result[i] != nullptr);
+ }
+ }
+
+ MaybeStackVector<Measure> orderedResult;
+ int32_t unitsCount = outputUnits_.length();
+ U_ASSERT(unitsCount == units_.length());
+ Measure **arr = result.getAlias();
+ // O(N^2) is fine: mixed units' unitsCount is usually 2 or 3.
+ for (int32_t i = 0; i < unitsCount; i++) {
+ for (int32_t j = i; j < unitsCount; j++) {
+ // Find the next expected unit, and swap it into place.
+ U_ASSERT(result[j] != nullptr);
+ if (result[j]->getUnit() == *outputUnits_[i]) {
+ if (j != i) {
+ Measure *tmp = arr[j];
+ arr[j] = arr[i];
+ arr[i] = tmp;
+ }
+ }
+ }
+ }
+
+ return result;
+}
+
+} // namespace units
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/units_complexconverter.h b/deps/icu-small/source/i18n/units_complexconverter.h
new file mode 100644
index 0000000000..83c5b94342
--- /dev/null
+++ b/deps/icu-small/source/i18n/units_complexconverter.h
@@ -0,0 +1,93 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+#ifndef __UNITS_COMPLEXCONVERTER_H__
+#define __UNITS_COMPLEXCONVERTER_H__
+
+#include "cmemory.h"
+#include "measunit_impl.h"
+#include "number_roundingutils.h"
+#include "unicode/errorcode.h"
+#include "unicode/measure.h"
+#include "units_converter.h"
+#include "units_data.h"
+
+U_NAMESPACE_BEGIN
+
+// Export explicit template instantiations of MaybeStackArray, MemoryPool and
+// MaybeStackVector. This is required when building DLLs for Windows. (See
+// datefmt.h, collationiterator.h, erarules.h and others for similar examples.)
+//
+// Note: These need to be outside of the units namespace, or Clang will generate
+// a compile error.
+#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
+template class U_I18N_API MaybeStackArray<units::UnitConverter*, 8>;
+template class U_I18N_API MemoryPool<units::UnitConverter, 8>;
+template class U_I18N_API MaybeStackVector<units::UnitConverter, 8>;
+template class U_I18N_API MaybeStackArray<MeasureUnitImpl*, 8>;
+template class U_I18N_API MemoryPool<MeasureUnitImpl, 8>;
+template class U_I18N_API MaybeStackVector<MeasureUnitImpl, 8>;
+template class U_I18N_API MaybeStackArray<MeasureUnit*, 8>;
+template class U_I18N_API MemoryPool<MeasureUnit, 8>;
+template class U_I18N_API MaybeStackVector<MeasureUnit, 8>;
+#endif
+
+namespace units {
+
+/**
+ * Converts from single or compound unit to single, compound or mixed units.
+ * For example, from `meter` to `foot+inch`.
+ *
+ * DESIGN:
+ * This class uses `UnitConverter` in order to perform the single converter (i.e. converters from a
+ * single unit to another single unit). Therefore, `ComplexUnitsConverter` class contains multiple
+ * instances of the `UnitConverter` to perform the conversion.
+ */
+class U_I18N_API ComplexUnitsConverter : public UMemory {
+ public:
+ /**
+ * Constructor of `ComplexUnitsConverter`.
+ * NOTE:
+ * - inputUnit and outputUnits must be under the same category
+ * - e.g. meter to feet and inches --> all of them are length units.
+ *
+ * @param inputUnit represents the source unit. (should be single or compound unit).
+ * @param outputUnits represents the output unit. could be any type. (single, compound or mixed).
+ * @param status
+ */
+ ComplexUnitsConverter(const MeasureUnitImpl &inputUnit, const MeasureUnitImpl &outputUnits,
+ const ConversionRates &ratesInfo, UErrorCode &status);
+
+ // Returns true if the specified `quantity` of the `inputUnit`, expressed in terms of the biggest
+ // unit in the MeasureUnit `outputUnit`, is greater than or equal to `limit`.
+ // For example, if the input unit is `meter` and the target unit is `foot+inch`. Therefore, this
+ // function will convert the `quantity` from `meter` to `foot`, then, it will compare the value in
+ // `foot` with the `limit`.
+ UBool greaterThanOrEqual(double quantity, double limit) const;
+
+ // Returns outputMeasures which is an array with the corresponding values.
+ // - E.g. converting meters to feet and inches.
+ // 1 meter --> 3 feet, 3.3701 inches
+ // NOTE:
+ // the smallest element is the only element that could have fractional values. And all
+ // other elements are floored to the nearest integer
+ MaybeStackVector<Measure>
+ convert(double quantity, icu::number::impl::RoundingImpl *rounder, UErrorCode &status) const;
+
+ private:
+ MaybeStackVector<UnitConverter> unitConverters_;
+ // Individual units of mixed units, sorted big to small
+ MaybeStackVector<MeasureUnitImpl> units_;
+ // Individual units of mixed units, sorted in desired output order
+ MaybeStackVector<MeasureUnit> outputUnits_;
+};
+
+} // namespace units
+U_NAMESPACE_END
+
+#endif //__UNITS_COMPLEXCONVERTER_H__
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/units_converter.cpp b/deps/icu-small/source/i18n/units_converter.cpp
new file mode 100644
index 0000000000..a777d026b9
--- /dev/null
+++ b/deps/icu-small/source/i18n/units_converter.cpp
@@ -0,0 +1,546 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "charstr.h"
+#include "cmemory.h"
+#include "double-conversion-string-to-double.h"
+#include "measunit_impl.h"
+#include "uassert.h"
+#include "unicode/errorcode.h"
+#include "unicode/localpointer.h"
+#include "unicode/stringpiece.h"
+#include "units_converter.h"
+#include <algorithm>
+#include <cmath>
+#include <stdlib.h>
+#include <utility>
+
+U_NAMESPACE_BEGIN
+namespace units {
+
+void U_I18N_API Factor::multiplyBy(const Factor &rhs) {
+ factorNum *= rhs.factorNum;
+ factorDen *= rhs.factorDen;
+ for (int i = 0; i < CONSTANTS_COUNT; i++) {
+ constants[i] += rhs.constants[i];
+ }
+
+ // NOTE
+ // We need the offset when the source and the target are simple units. e.g. the source is
+ // celsius and the target is Fahrenheit. Therefore, we just keep the value using `std::max`.
+ offset = std::max(rhs.offset, offset);
+}
+
+void U_I18N_API Factor::divideBy(const Factor &rhs) {
+ factorNum *= rhs.factorDen;
+ factorDen *= rhs.factorNum;
+ for (int i = 0; i < CONSTANTS_COUNT; i++) {
+ constants[i] -= rhs.constants[i];
+ }
+
+ // NOTE
+ // We need the offset when the source and the target are simple units. e.g. the source is
+ // celsius and the target is Fahrenheit. Therefore, we just keep the value using `std::max`.
+ offset = std::max(rhs.offset, offset);
+}
+
+void U_I18N_API Factor::power(int32_t power) {
+ // multiply all the constant by the power.
+ for (int i = 0; i < CONSTANTS_COUNT; i++) {
+ constants[i] *= power;
+ }
+
+ bool shouldFlip = power < 0; // This means that after applying the absolute power, we should flip
+ // the Numerator and Denominator.
+
+ factorNum = std::pow(factorNum, std::abs(power));
+ factorDen = std::pow(factorDen, std::abs(power));
+
+ if (shouldFlip) {
+ // Flip Numerator and Denominator.
+ std::swap(factorNum, factorDen);
+ }
+}
+
+void U_I18N_API Factor::flip() {
+ std::swap(factorNum, factorDen);
+
+ for (int i = 0; i < CONSTANTS_COUNT; i++) {
+ constants[i] *= -1;
+ }
+}
+
+void U_I18N_API Factor::applySiPrefix(UMeasureSIPrefix siPrefix) {
+ if (siPrefix == UMeasureSIPrefix::UMEASURE_SI_PREFIX_ONE) return; // No need to do anything
+
+ double siApplied = std::pow(10.0, std::abs(siPrefix));
+
+ if (siPrefix < 0) {
+ factorDen *= siApplied;
+ return;
+ }
+
+ factorNum *= siApplied;
+}
+
+void U_I18N_API Factor::substituteConstants() {
+ for (int i = 0; i < CONSTANTS_COUNT; i++) {
+ if (this->constants[i] == 0) {
+ continue;
+ }
+
+ auto absPower = std::abs(this->constants[i]);
+ Signum powerSig = this->constants[i] < 0 ? Signum::NEGATIVE : Signum::POSITIVE;
+ double absConstantValue = std::pow(constantsValues[i], absPower);
+
+ if (powerSig == Signum::NEGATIVE) {
+ this->factorDen *= absConstantValue;
+ } else {
+ this->factorNum *= absConstantValue;
+ }
+
+ this->constants[i] = 0;
+ }
+}
+
+namespace {
+
+/* Helpers */
+
+using icu::double_conversion::StringToDoubleConverter;
+
+// TODO: Make this a shared-utility function.
+// Returns `double` from a scientific number(i.e. "1", "2.01" or "3.09E+4")
+double strToDouble(StringPiece strNum, UErrorCode &status) {
+ // We are processing well-formed input, so we don't need any special options to
+ // StringToDoubleConverter.
+ StringToDoubleConverter converter(0, 0, 0, "", "");
+ int32_t count;
+ double result = converter.StringToDouble(strNum.data(), strNum.length(), &count);
+ if (count != strNum.length()) {
+ status = U_INVALID_FORMAT_ERROR;
+ }
+
+ return result;
+}
+
+// Returns `double` from a scientific number that could has a division sign (i.e. "1", "2.01", "3.09E+4"
+// or "2E+2/3")
+double strHasDivideSignToDouble(StringPiece strWithDivide, UErrorCode &status) {
+ int divisionSignInd = -1;
+ for (int i = 0, n = strWithDivide.length(); i < n; ++i) {
+ if (strWithDivide.data()[i] == '/') {
+ divisionSignInd = i;
+ break;
+ }
+ }
+
+ if (divisionSignInd >= 0) {
+ return strToDouble(strWithDivide.substr(0, divisionSignInd), status) /
+ strToDouble(strWithDivide.substr(divisionSignInd + 1), status);
+ }
+
+ return strToDouble(strWithDivide, status);
+}
+
+/*
+ Adds single factor to a `Factor` object. Single factor means "23^2", "23.3333", "ft2m^3" ...etc.
+ However, complex factor are not included, such as "ft2m^3*200/3"
+*/
+void addFactorElement(Factor &factor, StringPiece elementStr, Signum signum, UErrorCode &status) {
+ StringPiece baseStr;
+ StringPiece powerStr;
+ int32_t power =
+ 1; // In case the power is not written, then, the power is equal 1 ==> `ft2m^1` == `ft2m`
+
+ // Search for the power part
+ int32_t powerInd = -1;
+ for (int32_t i = 0, n = elementStr.length(); i < n; ++i) {
+ if (elementStr.data()[i] == '^') {
+ powerInd = i;
+ break;
+ }
+ }
+
+ if (powerInd > -1) {
+ // There is power
+ baseStr = elementStr.substr(0, powerInd);
+ powerStr = elementStr.substr(powerInd + 1);
+
+ power = static_cast<int32_t>(strToDouble(powerStr, status));
+ } else {
+ baseStr = elementStr;
+ }
+
+ addSingleFactorConstant(baseStr, power, signum, factor, status);
+}
+
+/*
+ * Extracts `Factor` from a complete string factor. e.g. "ft2m^3*1007/cup2m3*3"
+ */
+Factor extractFactorConversions(StringPiece stringFactor, UErrorCode &status) {
+ Factor result;
+ Signum signum = Signum::POSITIVE;
+ auto factorData = stringFactor.data();
+ for (int32_t i = 0, start = 0, n = stringFactor.length(); i < n; i++) {
+ if (factorData[i] == '*' || factorData[i] == '/') {
+ StringPiece factorElement = stringFactor.substr(start, i - start);
+ addFactorElement(result, factorElement, signum, status);
+
+ start = i + 1; // Set `start` to point to the start of the new element.
+ } else if (i == n - 1) {
+ // Last element
+ addFactorElement(result, stringFactor.substr(start, i + 1), signum, status);
+ }
+
+ if (factorData[i] == '/') {
+ signum = Signum::NEGATIVE; // Change the signum because we reached the Denominator.
+ }
+ }
+
+ return result;
+}
+
+// Load factor for a single source
+Factor loadSingleFactor(StringPiece source, const ConversionRates &ratesInfo, UErrorCode &status) {
+ const auto conversionUnit = ratesInfo.extractConversionInfo(source, status);
+ if (U_FAILURE(status)) return Factor();
+ if (conversionUnit == nullptr) {
+ status = U_INTERNAL_PROGRAM_ERROR;
+ return Factor();
+ }
+
+ Factor result = extractFactorConversions(conversionUnit->factor.toStringPiece(), status);
+ result.offset = strHasDivideSignToDouble(conversionUnit->offset.toStringPiece(), status);
+
+ return result;
+}
+
+// Load Factor of a compound source unit.
+Factor loadCompoundFactor(const MeasureUnitImpl &source, const ConversionRates &ratesInfo,
+ UErrorCode &status) {
+
+ Factor result;
+ for (int32_t i = 0, n = source.units.length(); i < n; i++) {
+ SingleUnitImpl singleUnit = *source.units[i];
+
+ Factor singleFactor = loadSingleFactor(singleUnit.getSimpleUnitID(), ratesInfo, status);
+ if (U_FAILURE(status)) return result;
+
+ // Apply SiPrefix before the power, because the power may be will flip the factor.
+ singleFactor.applySiPrefix(singleUnit.siPrefix);
+
+ // Apply the power of the `dimensionality`
+ singleFactor.power(singleUnit.dimensionality);
+
+ result.multiplyBy(singleFactor);
+ }
+
+ return result;
+}
+
+/**
+ * Checks if the source unit and the target unit are simple. For example celsius or fahrenheit. But not
+ * square-celsius or square-fahrenheit.
+ *
+ * NOTE:
+ * Empty unit means simple unit.
+ */
+UBool checkSimpleUnit(const MeasureUnitImpl &unit, UErrorCode &status) {
+ if (U_FAILURE(status)) return false;
+
+ if (unit.complexity != UMEASURE_UNIT_SINGLE) {
+ return false;
+ }
+ if (unit.units.length() == 0) {
+ // Empty units means simple unit.
+ return true;
+ }
+
+ auto singleUnit = *(unit.units[0]);
+
+ if (singleUnit.dimensionality != 1 || singleUnit.siPrefix != UMEASURE_SI_PREFIX_ONE) {
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Extract conversion rate from `source` to `target`
+ */
+void loadConversionRate(ConversionRate &conversionRate, const MeasureUnitImpl &source,
+ const MeasureUnitImpl &target, Convertibility unitsState,
+ const ConversionRates &ratesInfo, UErrorCode &status) {
+ // Represents the conversion factor from the source to the target.
+ Factor finalFactor;
+
+ // Represents the conversion factor from the source to the base unit that specified in the conversion
+ // data which is considered as the root of the source and the target.
+ Factor sourceToBase = loadCompoundFactor(source, ratesInfo, status);
+ Factor targetToBase = loadCompoundFactor(target, ratesInfo, status);
+
+ // Merger Factors
+ finalFactor.multiplyBy(sourceToBase);
+ if (unitsState == Convertibility::CONVERTIBLE) {
+ finalFactor.divideBy(targetToBase);
+ } else if (unitsState == Convertibility::RECIPROCAL) {
+ finalFactor.multiplyBy(targetToBase);
+ } else {
+ status = UErrorCode::U_ARGUMENT_TYPE_MISMATCH;
+ return;
+ }
+
+ finalFactor.substituteConstants();
+
+ conversionRate.factorNum = finalFactor.factorNum;
+ conversionRate.factorDen = finalFactor.factorDen;
+
+ // In case of simple units (such as: celsius or fahrenheit), offsets are considered.
+ if (checkSimpleUnit(source, status) && checkSimpleUnit(target, status)) {
+ conversionRate.sourceOffset =
+ sourceToBase.offset * sourceToBase.factorDen / sourceToBase.factorNum;
+ conversionRate.targetOffset =
+ targetToBase.offset * targetToBase.factorDen / targetToBase.factorNum;
+ }
+
+ conversionRate.reciprocal = unitsState == Convertibility::RECIPROCAL;
+}
+
+struct UnitIndexAndDimension : UMemory {
+ int32_t index = 0;
+ int32_t dimensionality = 0;
+
+ UnitIndexAndDimension(const SingleUnitImpl &singleUnit, int32_t multiplier) {
+ index = singleUnit.index;
+ dimensionality = singleUnit.dimensionality * multiplier;
+ }
+};
+
+void mergeSingleUnitWithDimension(MaybeStackVector<UnitIndexAndDimension> &unitIndicesWithDimension,
+ const SingleUnitImpl &shouldBeMerged, int32_t multiplier) {
+ for (int32_t i = 0; i < unitIndicesWithDimension.length(); i++) {
+ auto &unitWithIndex = *unitIndicesWithDimension[i];
+ if (unitWithIndex.index == shouldBeMerged.index) {
+ unitWithIndex.dimensionality += shouldBeMerged.dimensionality * multiplier;
+ return;
+ }
+ }
+
+ unitIndicesWithDimension.emplaceBack(shouldBeMerged, multiplier);
+}
+
+void mergeUnitsAndDimensions(MaybeStackVector<UnitIndexAndDimension> &unitIndicesWithDimension,
+ const MeasureUnitImpl &shouldBeMerged, int32_t multiplier) {
+ for (int32_t unit_i = 0; unit_i < shouldBeMerged.units.length(); unit_i++) {
+ auto singleUnit = *shouldBeMerged.units[unit_i];
+ mergeSingleUnitWithDimension(unitIndicesWithDimension, singleUnit, multiplier);
+ }
+}
+
+UBool checkAllDimensionsAreZeros(const MaybeStackVector<UnitIndexAndDimension> &dimensionVector) {
+ for (int32_t i = 0; i < dimensionVector.length(); i++) {
+ if (dimensionVector[i]->dimensionality != 0) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+} // namespace
+
+// Conceptually, this modifies factor: factor *= baseStr^(signum*power).
+//
+// baseStr must be a known constant or a value that strToDouble() is able to
+// parse.
+void U_I18N_API addSingleFactorConstant(StringPiece baseStr, int32_t power, Signum signum,
+ Factor &factor, UErrorCode &status) {
+ if (baseStr == "ft_to_m") {
+ factor.constants[CONSTANT_FT2M] += power * signum;
+ } else if (baseStr == "ft2_to_m2") {
+ factor.constants[CONSTANT_FT2M] += 2 * power * signum;
+ } else if (baseStr == "ft3_to_m3") {
+ factor.constants[CONSTANT_FT2M] += 3 * power * signum;
+ } else if (baseStr == "in3_to_m3") {
+ factor.constants[CONSTANT_FT2M] += 3 * power * signum;
+ factor.factorDen *= 12 * 12 * 12;
+ } else if (baseStr == "gal_to_m3") {
+ factor.factorNum *= 231;
+ factor.constants[CONSTANT_FT2M] += 3 * power * signum;
+ factor.factorDen *= 12 * 12 * 12;
+ } else if (baseStr == "gal_imp_to_m3") {
+ factor.constants[CONSTANT_GAL_IMP2M3] += power * signum;
+ } else if (baseStr == "G") {
+ factor.constants[CONSTANT_G] += power * signum;
+ } else if (baseStr == "gravity") {
+ factor.constants[CONSTANT_GRAVITY] += power * signum;
+ } else if (baseStr == "lb_to_kg") {
+ factor.constants[CONSTANT_LB2KG] += power * signum;
+ } else if (baseStr == "PI") {
+ factor.constants[CONSTANT_PI] += power * signum;
+ } else {
+ if (signum == Signum::NEGATIVE) {
+ factor.factorDen *= std::pow(strToDouble(baseStr, status), power);
+ } else {
+ factor.factorNum *= std::pow(strToDouble(baseStr, status), power);
+ }
+ }
+}
+
+/**
+ * Extracts the compound base unit of a compound unit (`source`). For example, if the source unit is
+ * `square-mile-per-hour`, the compound base unit will be `square-meter-per-second`
+ */
+MeasureUnitImpl U_I18N_API extractCompoundBaseUnit(const MeasureUnitImpl &source,
+ const ConversionRates &conversionRates,
+ UErrorCode &status) {
+
+ MeasureUnitImpl result;
+ if (U_FAILURE(status)) return result;
+
+ const auto &singleUnits = source.units;
+ for (int i = 0, count = singleUnits.length(); i < count; ++i) {
+ const auto &singleUnit = *singleUnits[i];
+ // Extract `ConversionRateInfo` using the absolute unit. For example: in case of `square-meter`,
+ // we will use `meter`
+ const auto rateInfo =
+ conversionRates.extractConversionInfo(singleUnit.getSimpleUnitID(), status);
+ if (U_FAILURE(status)) {
+ return result;
+ }
+ if (rateInfo == nullptr) {
+ status = U_INTERNAL_PROGRAM_ERROR;
+ return result;
+ }
+
+ // Multiply the power of the singleUnit by the power of the baseUnit. For example, square-hectare
+ // must be pow4-meter. (NOTE: hectare --> square-meter)
+ auto baseUnits =
+ MeasureUnitImpl::forIdentifier(rateInfo->baseUnit.toStringPiece(), status).units;
+ for (int32_t i = 0, baseUnitsCount = baseUnits.length(); i < baseUnitsCount; i++) {
+ baseUnits[i]->dimensionality *= singleUnit.dimensionality;
+ // TODO: Deal with SI-prefix
+ result.append(*baseUnits[i], status);
+
+ if (U_FAILURE(status)) {
+ return result;
+ }
+ }
+ }
+
+ return result;
+}
+
+/**
+ * Determine the convertibility between `source` and `target`.
+ * For example:
+ * `meter` and `foot` are `CONVERTIBLE`.
+ * `meter-per-second` and `second-per-meter` are `RECIPROCAL`.
+ * `meter` and `pound` are `UNCONVERTIBLE`.
+ *
+ * NOTE:
+ * Only works with SINGLE and COMPOUND units. If one of the units is a
+ * MIXED unit, an error will occur. For more information, see UMeasureUnitComplexity.
+ */
+Convertibility U_I18N_API extractConvertibility(const MeasureUnitImpl &source,
+ const MeasureUnitImpl &target,
+ const ConversionRates &conversionRates,
+ UErrorCode &status) {
+
+ if (source.complexity == UMeasureUnitComplexity::UMEASURE_UNIT_MIXED ||
+ target.complexity == UMeasureUnitComplexity::UMEASURE_UNIT_MIXED) {
+ status = U_INTERNAL_PROGRAM_ERROR;
+ return UNCONVERTIBLE;
+ }
+
+ MeasureUnitImpl sourceBaseUnit = extractCompoundBaseUnit(source, conversionRates, status);
+ MeasureUnitImpl targetBaseUnit = extractCompoundBaseUnit(target, conversionRates, status);
+ if (U_FAILURE(status)) return UNCONVERTIBLE;
+
+ MaybeStackVector<UnitIndexAndDimension> convertible;
+ MaybeStackVector<UnitIndexAndDimension> reciprocal;
+
+ mergeUnitsAndDimensions(convertible, sourceBaseUnit, 1);
+ mergeUnitsAndDimensions(reciprocal, sourceBaseUnit, 1);
+
+ mergeUnitsAndDimensions(convertible, targetBaseUnit, -1);
+ mergeUnitsAndDimensions(reciprocal, targetBaseUnit, 1);
+
+ if (checkAllDimensionsAreZeros(convertible)) {
+ return CONVERTIBLE;
+ }
+
+ if (checkAllDimensionsAreZeros(reciprocal)) {
+ return RECIPROCAL;
+ }
+
+ return UNCONVERTIBLE;
+}
+
+UnitConverter::UnitConverter(const MeasureUnitImpl &source, const MeasureUnitImpl &target,
+ const ConversionRates &ratesInfo, UErrorCode &status)
+ : conversionRate_(source.copy(status), target.copy(status)) {
+ if (source.complexity == UMeasureUnitComplexity::UMEASURE_UNIT_MIXED ||
+ target.complexity == UMeasureUnitComplexity::UMEASURE_UNIT_MIXED) {
+ status = U_INTERNAL_PROGRAM_ERROR;
+ return;
+ }
+
+ Convertibility unitsState = extractConvertibility(source, target, ratesInfo, status);
+ if (U_FAILURE(status)) return;
+ if (unitsState == Convertibility::UNCONVERTIBLE) {
+ status = U_INTERNAL_PROGRAM_ERROR;
+ return;
+ }
+
+ loadConversionRate(conversionRate_, conversionRate_.source, conversionRate_.target, unitsState,
+ ratesInfo, status);
+}
+
+double UnitConverter::convert(double inputValue) const {
+ double result =
+ inputValue + conversionRate_.sourceOffset; // Reset the input to the target zero index.
+ // Convert the quantity to from the source scale to the target scale.
+ result *= conversionRate_.factorNum / conversionRate_.factorDen;
+
+ result -= conversionRate_.targetOffset; // Set the result to its index.
+
+ if (conversionRate_.reciprocal) {
+ if (result == 0) {
+ // TODO: demonstrate the resulting behaviour in tests... and figure
+ // out desired behaviour. (Theoretical result should be infinity,
+ // not 0.)
+ return 0.0;
+ }
+ result = 1.0 / result;
+ }
+
+ return result;
+}
+
+double UnitConverter::convertInverse(double inputValue) const {
+ double result = inputValue;
+ if (conversionRate_.reciprocal) {
+ if (result == 0) {
+ // TODO: demonstrate the resulting behaviour in tests... and figure
+ // out desired behaviour. (Theoretical result should be infinity,
+ // not 0.)
+ return 0.0;
+ }
+ result = 1.0 / result;
+ }
+ result += conversionRate_.targetOffset;
+ result *= conversionRate_.factorDen / conversionRate_.factorNum;
+ result -= conversionRate_.sourceOffset;
+ return result;
+}
+
+} // namespace units
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/units_converter.h b/deps/icu-small/source/i18n/units_converter.h
new file mode 100644
index 0000000000..7650131b1f
--- /dev/null
+++ b/deps/icu-small/source/i18n/units_converter.h
@@ -0,0 +1,173 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+#ifndef __UNITS_CONVERTER_H__
+#define __UNITS_CONVERTER_H__
+
+#include "cmemory.h"
+#include "measunit_impl.h"
+#include "unicode/errorcode.h"
+#include "unicode/stringpiece.h"
+#include "unicode/uobject.h"
+#include "units_converter.h"
+#include "units_data.h"
+
+U_NAMESPACE_BEGIN
+namespace units {
+
+/* Internal Structure */
+
+enum Constants {
+ CONSTANT_FT2M, // ft2m stands for foot to meter.
+ CONSTANT_PI, // PI
+ CONSTANT_GRAVITY, // Gravity
+ CONSTANT_G,
+ CONSTANT_GAL_IMP2M3, // Gallon imp to m3
+ CONSTANT_LB2KG, // Pound to Kilogram
+
+ // Must be the last element.
+ CONSTANTS_COUNT
+};
+
+// These values are a hard-coded subset of unitConstants in the units
+// resources file. A unit test checks that all constants in the resource
+// file are at least recognised by the code. Derived constants' values or
+// hard-coded derivations are not checked.
+static const double constantsValues[CONSTANTS_COUNT] = {
+ 0.3048, // CONSTANT_FT2M
+ 411557987.0 / 131002976.0, // CONSTANT_PI
+ 9.80665, // CONSTANT_GRAVITY
+ 6.67408E-11, // CONSTANT_G
+ 0.00454609, // CONSTANT_GAL_IMP2M3
+ 0.45359237, // CONSTANT_LB2KG
+};
+
+typedef enum Signum {
+ NEGATIVE = -1,
+ POSITIVE = 1,
+} Signum;
+
+/* Represents a conversion factor */
+struct U_I18N_API Factor {
+ double factorNum = 1;
+ double factorDen = 1;
+ double offset = 0;
+ bool reciprocal = false;
+ int32_t constants[CONSTANTS_COUNT] = {};
+
+ void multiplyBy(const Factor &rhs);
+ void divideBy(const Factor &rhs);
+
+ // Apply the power to the factor.
+ void power(int32_t power);
+
+ // Flip the `Factor`, for example, factor= 2/3, flippedFactor = 3/2
+ void flip();
+
+ // Apply SI prefix to the `Factor`
+ void applySiPrefix(UMeasureSIPrefix siPrefix);
+ void substituteConstants();
+};
+
+/*
+ * Adds a single factor element to the `Factor`. e.g "ft3m", "2.333" or "cup2m3". But not "cup2m3^3".
+ */
+void U_I18N_API addSingleFactorConstant(StringPiece baseStr, int32_t power, Signum sigNum,
+ Factor &factor, UErrorCode &status);
+
+/**
+ * Represents the conversion rate between `source` and `target`.
+ */
+struct U_I18N_API ConversionRate : public UMemory {
+ const MeasureUnitImpl source;
+ const MeasureUnitImpl target;
+ double factorNum = 1;
+ double factorDen = 1;
+ double sourceOffset = 0;
+ double targetOffset = 0;
+ bool reciprocal = false;
+
+ ConversionRate(MeasureUnitImpl &&source, MeasureUnitImpl &&target)
+ : source(std::move(source)), target(std::move(target)) {}
+};
+
+enum Convertibility {
+ RECIPROCAL,
+ CONVERTIBLE,
+ UNCONVERTIBLE,
+};
+
+MeasureUnitImpl U_I18N_API extractCompoundBaseUnit(const MeasureUnitImpl &source,
+ const ConversionRates &conversionRates,
+ UErrorCode &status);
+
+/**
+ * Check if the convertibility between `source` and `target`.
+ * For example:
+ * `meter` and `foot` are `CONVERTIBLE`.
+ * `meter-per-second` and `second-per-meter` are `RECIPROCAL`.
+ * `meter` and `pound` are `UNCONVERTIBLE`.
+ *
+ * NOTE:
+ * Only works with SINGLE and COMPOUND units. If one of the units is a
+ * MIXED unit, an error will occur. For more information, see UMeasureUnitComplexity.
+ */
+Convertibility U_I18N_API extractConvertibility(const MeasureUnitImpl &source,
+ const MeasureUnitImpl &target,
+ const ConversionRates &conversionRates,
+ UErrorCode &status);
+
+/**
+ * Converts from a source `MeasureUnit` to a target `MeasureUnit`.
+ *
+ * NOTE:
+ * Only works with SINGLE and COMPOUND units. If one of the units is a
+ * MIXED unit, an error will occur. For more information, see UMeasureUnitComplexity.
+ */
+class U_I18N_API UnitConverter : public UMemory {
+ public:
+ /**
+ * Constructor of `UnitConverter`.
+ * NOTE:
+ * - source and target must be under the same category
+ * - e.g. meter to mile --> both of them are length units.
+ *
+ * @param source represents the source unit.
+ * @param target represents the target unit.
+ * @param ratesInfo Contains all the needed conversion rates.
+ * @param status
+ */
+ UnitConverter(const MeasureUnitImpl &source, const MeasureUnitImpl &target,
+ const ConversionRates &ratesInfo, UErrorCode &status);
+
+ /**
+ * Convert a measurement expressed in the source unit to a measurement
+ * expressed in the target unit.
+ *
+ * @param inputValue the value to be converted.
+ * @return the converted value.
+ */
+ double convert(double inputValue) const;
+
+ /**
+ * The inverse of convert(): convert a measurement expressed in the target
+ * unit to a measurement expressed in the source unit.
+ *
+ * @param inputValue the value to be converted.
+ * @return the converted value.
+ */
+ double convertInverse(double inputValue) const;
+
+ private:
+ ConversionRate conversionRate_;
+};
+
+} // namespace units
+U_NAMESPACE_END
+
+#endif //__UNITS_CONVERTER_H__
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/units_data.cpp b/deps/icu-small/source/i18n/units_data.cpp
new file mode 100644
index 0000000000..42bd6248b0
--- /dev/null
+++ b/deps/icu-small/source/i18n/units_data.cpp
@@ -0,0 +1,428 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "cstring.h"
+#include "number_decimalquantity.h"
+#include "resource.h"
+#include "uassert.h"
+#include "unicode/unistr.h"
+#include "unicode/ures.h"
+#include "units_data.h"
+#include "uresimp.h"
+#include "util.h"
+#include <utility>
+
+U_NAMESPACE_BEGIN
+namespace units {
+
+namespace {
+
+using icu::number::impl::DecimalQuantity;
+
+void trimSpaces(CharString& factor, UErrorCode& status){
+ CharString trimmed;
+ for (int i = 0 ; i < factor.length(); i++) {
+ if (factor[i] == ' ') continue;
+
+ trimmed.append(factor[i], status);
+ }
+
+ factor = std::move(trimmed);
+}
+
+/**
+ * A ResourceSink that collects conversion rate information.
+ *
+ * This class is for use by ures_getAllItemsWithFallback.
+ */
+class ConversionRateDataSink : public ResourceSink {
+ public:
+ /**
+ * Constructor.
+ * @param out The vector to which ConversionRateInfo instances are to be
+ * added. This vector must outlive the use of the ResourceSink.
+ */
+ explicit ConversionRateDataSink(MaybeStackVector<ConversionRateInfo> *out) : outVector(out) {}
+
+ /**
+ * Method for use by `ures_getAllItemsWithFallback`. Adds the unit
+ * conversion rates that are found in `value` to the output vector.
+ *
+ * @param source This string must be "convertUnits": the resource that this
+ * class supports reading.
+ * @param value The "convertUnits" resource, containing unit conversion rate
+ * information.
+ * @param noFallback Ignored.
+ * @param status The standard ICU error code output parameter.
+ */
+ void put(const char *source, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) {
+ if (U_FAILURE(status)) { return; }
+ if (uprv_strcmp(source, "convertUnits") != 0) {
+ // This is very strict, however it is the cheapest way to be sure
+ // that with `value`, we're looking at the convertUnits table.
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return;
+ }
+ ResourceTable conversionRateTable = value.getTable(status);
+ const char *srcUnit;
+ // We're reusing `value`, which seems to be a common pattern:
+ for (int32_t unit = 0; conversionRateTable.getKeyAndValue(unit, srcUnit, value); unit++) {
+ ResourceTable unitTable = value.getTable(status);
+ const char *key;
+ UnicodeString baseUnit = ICU_Utility::makeBogusString();
+ UnicodeString factor = ICU_Utility::makeBogusString();
+ UnicodeString offset = ICU_Utility::makeBogusString();
+ for (int32_t i = 0; unitTable.getKeyAndValue(i, key, value); i++) {
+ if (uprv_strcmp(key, "target") == 0) {
+ baseUnit = value.getUnicodeString(status);
+ } else if (uprv_strcmp(key, "factor") == 0) {
+ factor = value.getUnicodeString(status);
+ } else if (uprv_strcmp(key, "offset") == 0) {
+ offset = value.getUnicodeString(status);
+ }
+ }
+ if (U_FAILURE(status)) { return; }
+ if (baseUnit.isBogus() || factor.isBogus()) {
+ // We could not find a usable conversion rate: bad resource.
+ status = U_MISSING_RESOURCE_ERROR;
+ return;
+ }
+
+ // We don't have this ConversionRateInfo yet: add it.
+ ConversionRateInfo *cr = outVector->emplaceBack();
+ if (!cr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ } else {
+ cr->sourceUnit.append(srcUnit, status);
+ cr->baseUnit.appendInvariantChars(baseUnit, status);
+ cr->factor.appendInvariantChars(factor, status);
+ trimSpaces(cr->factor, status);
+ if (!offset.isBogus()) cr->offset.appendInvariantChars(offset, status);
+ }
+ }
+ return;
+ }
+
+ private:
+ MaybeStackVector<ConversionRateInfo> *outVector;
+};
+
+bool operator<(const UnitPreferenceMetadata &a, const UnitPreferenceMetadata &b) {
+ return a.compareTo(b) < 0;
+}
+
+/**
+ * A ResourceSink that collects unit preferences information.
+ *
+ * This class is for use by ures_getAllItemsWithFallback.
+ */
+class UnitPreferencesSink : public ResourceSink {
+ public:
+ /**
+ * Constructor.
+ * @param outPrefs The vector to which UnitPreference instances are to be
+ * added. This vector must outlive the use of the ResourceSink.
+ * @param outMetadata The vector to which UnitPreferenceMetadata instances
+ * are to be added. This vector must outlive the use of the ResourceSink.
+ */
+ explicit UnitPreferencesSink(MaybeStackVector<UnitPreference> *outPrefs,
+ MaybeStackVector<UnitPreferenceMetadata> *outMetadata)
+ : preferences(outPrefs), metadata(outMetadata) {}
+
+ /**
+ * Method for use by `ures_getAllItemsWithFallback`. Adds the unit
+ * preferences info that are found in `value` to the output vector.
+ *
+ * @param source This string must be "unitPreferenceData": the resource that
+ * this class supports reading.
+ * @param value The "unitPreferenceData" resource, containing unit
+ * preferences data.
+ * @param noFallback Ignored.
+ * @param status The standard ICU error code output parameter. Note: if an
+ * error is returned, outPrefs and outMetadata may be inconsistent.
+ */
+ void put(const char *key, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) {
+ if (U_FAILURE(status)) { return; }
+ if (uprv_strcmp(key, "unitPreferenceData") != 0) {
+ // This is very strict, however it is the cheapest way to be sure
+ // that with `value`, we're looking at the convertUnits table.
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return;
+ }
+ // The unitPreferenceData structure (see data/misc/units.txt) contains a
+ // hierarchy of category/usage/region, within which are a set of
+ // preferences. Hence three for-loops and another loop for the
+ // preferences themselves:
+ ResourceTable unitPreferenceDataTable = value.getTable(status);
+ const char *category;
+ for (int32_t i = 0; unitPreferenceDataTable.getKeyAndValue(i, category, value); i++) {
+ ResourceTable categoryTable = value.getTable(status);
+ const char *usage;
+ for (int32_t j = 0; categoryTable.getKeyAndValue(j, usage, value); j++) {
+ ResourceTable regionTable = value.getTable(status);
+ const char *region;
+ for (int32_t k = 0; regionTable.getKeyAndValue(k, region, value); k++) {
+ // `value` now contains the set of preferences for
+ // category/usage/region.
+ ResourceArray unitPrefs = value.getArray(status);
+ if (U_FAILURE(status)) { return; }
+ int32_t prefLen = unitPrefs.getSize();
+
+ // Update metadata for this set of preferences.
+ UnitPreferenceMetadata *meta = metadata->emplaceBack(
+ category, usage, region, preferences->length(), prefLen, status);
+ if (!meta) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ if (U_FAILURE(status)) { return; }
+ if (metadata->length() > 1) {
+ // Verify that unit preferences are sorted and
+ // without duplicates.
+ if (!(*(*metadata)[metadata->length() - 2] <
+ *(*metadata)[metadata->length() - 1])) {
+ status = U_INVALID_FORMAT_ERROR;
+ return;
+ }
+ }
+
+ // Collect the individual preferences.
+ for (int32_t i = 0; unitPrefs.getValue(i, value); i++) {
+ UnitPreference *up = preferences->emplaceBack();
+ if (!up) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ ResourceTable unitPref = value.getTable(status);
+ if (U_FAILURE(status)) { return; }
+ for (int32_t i = 0; unitPref.getKeyAndValue(i, key, value); ++i) {
+ if (uprv_strcmp(key, "unit") == 0) {
+ int32_t length;
+ const UChar *u = value.getString(length, status);
+ up->unit.appendInvariantChars(u, length, status);
+ } else if (uprv_strcmp(key, "geq") == 0) {
+ int32_t length;
+ const UChar *g = value.getString(length, status);
+ CharString geq;
+ geq.appendInvariantChars(g, length, status);
+ DecimalQuantity dq;
+ dq.setToDecNumber(geq.data(), status);
+ up->geq = dq.toDouble();
+ } else if (uprv_strcmp(key, "skeleton") == 0) {
+ up->skeleton = value.getUnicodeString(status);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private:
+ MaybeStackVector<UnitPreference> *preferences;
+ MaybeStackVector<UnitPreferenceMetadata> *metadata;
+};
+
+int32_t binarySearch(const MaybeStackVector<UnitPreferenceMetadata> *metadata,
+ const UnitPreferenceMetadata &desired, bool *foundCategory, bool *foundUsage,
+ bool *foundRegion, UErrorCode &status) {
+ if (U_FAILURE(status)) { return -1; }
+ int32_t start = 0;
+ int32_t end = metadata->length();
+ *foundCategory = false;
+ *foundUsage = false;
+ *foundRegion = false;
+ while (start < end) {
+ int32_t mid = (start + end) / 2;
+ int32_t cmp = (*metadata)[mid]->compareTo(desired, foundCategory, foundUsage, foundRegion);
+ if (cmp < 0) {
+ start = mid + 1;
+ } else if (cmp > 0) {
+ end = mid;
+ } else {
+ return mid;
+ }
+ }
+ return -1;
+}
+
+/**
+ * Finds the UnitPreferenceMetadata instance that matches the given category,
+ * usage and region: if missing, region falls back to "001", and usage
+ * repeatedly drops tailing components, eventually trying "default"
+ * ("land-agriculture-grain" -> "land-agriculture" -> "land" -> "default").
+ *
+ * @param metadata The full list of UnitPreferenceMetadata instances.
+ * @param category The category to search for. See getUnitCategory().
+ * @param usage The usage for which formatting preferences is needed. If the
+ * given usage is not known, automatic fallback occurs, see function description
+ * above.
+ * @param region The region for which preferences are needed. If there are no
+ * region-specific preferences, this function automatically falls back to the
+ * "001" region (global).
+ * @param status The standard ICU error code output parameter.
+ * * If an invalid category is given, status will be U_ILLEGAL_ARGUMENT_ERROR.
+ * * If fallback to "default" or "001" didn't resolve, status will be
+ * U_MISSING_RESOURCE.
+ * @return The index into the metadata vector which represents the appropriate
+ * preferences. If appropriate preferences are not found, -1 is returned.
+ */
+int32_t getPreferenceMetadataIndex(const MaybeStackVector<UnitPreferenceMetadata> *metadata,
+ StringPiece category, StringPiece usage, StringPiece region,
+ UErrorCode &status) {
+ if (U_FAILURE(status)) { return -1; }
+ bool foundCategory, foundUsage, foundRegion;
+ UnitPreferenceMetadata desired(category, usage, region, -1, -1, status);
+ int32_t idx = binarySearch(metadata, desired, &foundCategory, &foundUsage, &foundRegion, status);
+ if (U_FAILURE(status)) { return -1; }
+ if (idx >= 0) { return idx; }
+ if (!foundCategory) {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return -1;
+ }
+ U_ASSERT(foundCategory);
+ while (!foundUsage) {
+ int32_t lastDashIdx = desired.usage.lastIndexOf('-');
+ if (lastDashIdx > 0) {
+ desired.usage.truncate(lastDashIdx);
+ } else if (uprv_strcmp(desired.usage.data(), "default") != 0) {
+ desired.usage.truncate(0).append("default", status);
+ } else {
+ // "default" is not supposed to be missing for any valid category.
+ status = U_MISSING_RESOURCE_ERROR;
+ return -1;
+ }
+ idx = binarySearch(metadata, desired, &foundCategory, &foundUsage, &foundRegion, status);
+ if (U_FAILURE(status)) { return -1; }
+ }
+ U_ASSERT(foundCategory);
+ U_ASSERT(foundUsage);
+ if (!foundRegion) {
+ if (uprv_strcmp(desired.region.data(), "001") != 0) {
+ desired.region.truncate(0).append("001", status);
+ idx = binarySearch(metadata, desired, &foundCategory, &foundUsage, &foundRegion, status);
+ }
+ if (!foundRegion) {
+ // "001" is not supposed to be missing for any valid usage.
+ status = U_MISSING_RESOURCE_ERROR;
+ return -1;
+ }
+ }
+ U_ASSERT(foundCategory);
+ U_ASSERT(foundUsage);
+ U_ASSERT(foundRegion);
+ U_ASSERT(idx >= 0);
+ return idx;
+}
+
+} // namespace
+
+UnitPreferenceMetadata::UnitPreferenceMetadata(StringPiece category, StringPiece usage,
+ StringPiece region, int32_t prefsOffset,
+ int32_t prefsCount, UErrorCode &status) {
+ this->category.append(category, status);
+ this->usage.append(usage, status);
+ this->region.append(region, status);
+ this->prefsOffset = prefsOffset;
+ this->prefsCount = prefsCount;
+}
+
+int32_t UnitPreferenceMetadata::compareTo(const UnitPreferenceMetadata &other) const {
+ int32_t cmp = uprv_strcmp(category.data(), other.category.data());
+ if (cmp == 0) {
+ cmp = uprv_strcmp(usage.data(), other.usage.data());
+ }
+ if (cmp == 0) {
+ cmp = uprv_strcmp(region.data(), other.region.data());
+ }
+ return cmp;
+}
+
+int32_t UnitPreferenceMetadata::compareTo(const UnitPreferenceMetadata &other, bool *foundCategory,
+ bool *foundUsage, bool *foundRegion) const {
+ int32_t cmp = uprv_strcmp(category.data(), other.category.data());
+ if (cmp == 0) {
+ *foundCategory = true;
+ cmp = uprv_strcmp(usage.data(), other.usage.data());
+ }
+ if (cmp == 0) {
+ *foundUsage = true;
+ cmp = uprv_strcmp(region.data(), other.region.data());
+ }
+ if (cmp == 0) {
+ *foundRegion = true;
+ }
+ return cmp;
+}
+
+CharString U_I18N_API getUnitCategory(const char *baseUnitIdentifier, UErrorCode &status) {
+ CharString result;
+ LocalUResourceBundlePointer unitsBundle(ures_openDirect(NULL, "units", &status));
+ LocalUResourceBundlePointer unitQuantities(
+ ures_getByKey(unitsBundle.getAlias(), "unitQuantities", NULL, &status));
+ int32_t categoryLength;
+ if (U_FAILURE(status)) { return result; }
+ const UChar *uCategory =
+ ures_getStringByKey(unitQuantities.getAlias(), baseUnitIdentifier, &categoryLength, &status);
+ if (U_FAILURE(status)) {
+ // TODO(CLDR-13787,hugovdm): special-casing the consumption-inverse
+ // case. Once CLDR-13787 is clarified, this should be generalised (or
+ // possibly removed):
+ if (uprv_strcmp(baseUnitIdentifier, "meter-per-cubic-meter") == 0) {
+ status = U_ZERO_ERROR;
+ result.append("consumption-inverse", status);
+ return result;
+ }
+ }
+ result.appendInvariantChars(uCategory, categoryLength, status);
+ return result;
+}
+
+// TODO: this may be unnecessary. Fold into ConversionRates class? Or move to anonymous namespace?
+void U_I18N_API getAllConversionRates(MaybeStackVector<ConversionRateInfo> &result, UErrorCode &status) {
+ LocalUResourceBundlePointer unitsBundle(ures_openDirect(NULL, "units", &status));
+ ConversionRateDataSink sink(&result);
+ ures_getAllItemsWithFallback(unitsBundle.getAlias(), "convertUnits", sink, status);
+}
+
+const ConversionRateInfo *ConversionRates::extractConversionInfo(StringPiece source,
+ UErrorCode &status) const {
+ for (size_t i = 0, n = conversionInfo_.length(); i < n; ++i) {
+ if (conversionInfo_[i]->sourceUnit.toStringPiece() == source) return conversionInfo_[i];
+ }
+
+ status = U_INTERNAL_PROGRAM_ERROR;
+ return nullptr;
+}
+
+U_I18N_API UnitPreferences::UnitPreferences(UErrorCode &status) {
+ LocalUResourceBundlePointer unitsBundle(ures_openDirect(NULL, "units", &status));
+ UnitPreferencesSink sink(&unitPrefs_, &metadata_);
+ ures_getAllItemsWithFallback(unitsBundle.getAlias(), "unitPreferenceData", sink, status);
+}
+
+// TODO: make outPreferences const?
+//
+// TODO: consider replacing `UnitPreference **&outPreferences` with slice class
+// of some kind.
+void U_I18N_API UnitPreferences::getPreferencesFor(StringPiece category, StringPiece usage,
+ StringPiece region,
+ const UnitPreference *const *&outPreferences,
+ int32_t &preferenceCount, UErrorCode &status) const {
+ int32_t idx = getPreferenceMetadataIndex(&metadata_, category, usage, region, status);
+ if (U_FAILURE(status)) { return; }
+ U_ASSERT(idx >= 0); // Failures should have been taken care of by `status`.
+ const UnitPreferenceMetadata *m = metadata_[idx];
+ outPreferences = unitPrefs_.getAlias() + m->prefsOffset;
+ preferenceCount = m->prefsCount;
+}
+
+} // namespace units
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/units_data.h b/deps/icu-small/source/i18n/units_data.h
new file mode 100644
index 0000000000..b6fe8e88de
--- /dev/null
+++ b/deps/icu-small/source/i18n/units_data.h
@@ -0,0 +1,229 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+#ifndef __UNITS_DATA_H__
+#define __UNITS_DATA_H__
+
+#include <limits>
+
+#include "charstr.h"
+#include "cmemory.h"
+#include "unicode/stringpiece.h"
+#include "unicode/uobject.h"
+
+U_NAMESPACE_BEGIN
+namespace units {
+
+/**
+ * Looks up the unit category of a base unit identifier.
+ *
+ * Only supports base units, other units must be resolved to base units before
+ * passing to this function.
+ *
+ * Categories are found in `unitQuantities` in the `units` resource (see
+ * `units.txt`).
+ *
+ * TODO(hugovdm): if we give units_data.cpp access to the functionality of
+ * `extractCompoundBaseUnit` which is currently in units_converter.cpp, we could
+ * support all units for which there is a category. Does it make sense to move
+ * that function to units_data.cpp?
+ */
+CharString U_I18N_API getUnitCategory(const char *baseUnitIdentifier, UErrorCode &status);
+
+/**
+ * Encapsulates "convertUnits" information from units resources, specifying how
+ * to convert from one unit to another.
+ *
+ * Information in this class is still in the form of strings: symbolic constants
+ * need to be interpreted. Rationale: symbols can cancel out for higher
+ * precision conversion - going from feet to inches should cancel out the
+ * `ft_to_m` constant.
+ */
+class U_I18N_API ConversionRateInfo : public UMemory {
+ public:
+ ConversionRateInfo() {}
+ ConversionRateInfo(StringPiece sourceUnit, StringPiece baseUnit, StringPiece factor,
+ StringPiece offset, UErrorCode &status)
+ : sourceUnit(), baseUnit(), factor(), offset() {
+ this->sourceUnit.append(sourceUnit, status);
+ this->baseUnit.append(baseUnit, status);
+ this->factor.append(factor, status);
+ this->offset.append(offset, status);
+ }
+ CharString sourceUnit;
+ CharString baseUnit;
+ CharString factor;
+ CharString offset;
+};
+
+} // namespace units
+
+// Export explicit template instantiations of MaybeStackArray, MemoryPool and
+// MaybeStackVector. This is required when building DLLs for Windows. (See
+// datefmt.h, collationiterator.h, erarules.h and others for similar examples.)
+//
+// Note: These need to be outside of the units namespace, or Clang will generate
+// a compile error.
+#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
+template class U_I18N_API MaybeStackArray<units::ConversionRateInfo*, 8>;
+template class U_I18N_API MemoryPool<units::ConversionRateInfo, 8>;
+template class U_I18N_API MaybeStackVector<units::ConversionRateInfo, 8>;
+#endif
+
+namespace units {
+
+/**
+ * Returns ConversionRateInfo for all supported conversions.
+ *
+ * @param result Receives the set of conversion rates.
+ * @param status Receives status.
+ */
+void U_I18N_API getAllConversionRates(MaybeStackVector<ConversionRateInfo> &result, UErrorCode &status);
+
+/**
+ * Contains all the supported conversion rates.
+ */
+class U_I18N_API ConversionRates {
+ public:
+ /**
+ * Constructor
+ *
+ * @param status Receives status.
+ */
+ ConversionRates(UErrorCode &status) { getAllConversionRates(conversionInfo_, status); }
+
+ /**
+ * Returns a pointer to the conversion rate info that match the `source`.
+ *
+ * @param source Contains the source.
+ * @param status Receives status.
+ */
+ const ConversionRateInfo *extractConversionInfo(StringPiece source, UErrorCode &status) const;
+
+ private:
+ MaybeStackVector<ConversionRateInfo> conversionInfo_;
+};
+
+// Encapsulates unitPreferenceData information from units resources, specifying
+// a sequence of output unit preferences.
+struct U_I18N_API UnitPreference : public UMemory {
+ // Set geq to 1.0 by default
+ UnitPreference() : geq(1.0) {}
+ CharString unit;
+ double geq;
+ UnicodeString skeleton;
+};
+
+/**
+ * Metadata about the preferences in UnitPreferences::unitPrefs_.
+ *
+ * This class owns all of its data.
+ *
+ * UnitPreferenceMetadata lives in the anonymous namespace, because it should
+ * only be useful to internal code and unit testing code.
+ */
+class U_I18N_API UnitPreferenceMetadata : public UMemory {
+ public:
+ UnitPreferenceMetadata() {}
+ // Constructor, makes copies of the parameters passed to it.
+ UnitPreferenceMetadata(StringPiece category, StringPiece usage, StringPiece region,
+ int32_t prefsOffset, int32_t prefsCount, UErrorCode &status);
+
+ // Unit category (e.g. "length", "mass", "electric-capacitance").
+ CharString category;
+ // Usage (e.g. "road", "vehicle-fuel", "blood-glucose"). Every category
+ // should have an entry for "default" usage. TODO(hugovdm): add a test for
+ // this.
+ CharString usage;
+ // Region code (e.g. "US", "CZ", "001"). Every usage should have an entry
+ // for the "001" region ("world"). TODO(hugovdm): add a test for this.
+ CharString region;
+ // Offset into the UnitPreferences::unitPrefs_ list where the relevant
+ // preferences are found.
+ int32_t prefsOffset;
+ // The number of preferences that form this set.
+ int32_t prefsCount;
+
+ int32_t compareTo(const UnitPreferenceMetadata &other) const;
+ int32_t compareTo(const UnitPreferenceMetadata &other, bool *foundCategory, bool *foundUsage,
+ bool *foundRegion) const;
+};
+
+} // namespace units
+
+// Export explicit template instantiations of MaybeStackArray, MemoryPool and
+// MaybeStackVector. This is required when building DLLs for Windows. (See
+// datefmt.h, collationiterator.h, erarules.h and others for similar examples.)
+//
+// Note: These need to be outside of the units namespace, or Clang will generate
+// a compile error.
+#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
+template class U_I18N_API MaybeStackArray<units::UnitPreferenceMetadata*, 8>;
+template class U_I18N_API MemoryPool<units::UnitPreferenceMetadata, 8>;
+template class U_I18N_API MaybeStackVector<units::UnitPreferenceMetadata, 8>;
+template class U_I18N_API MaybeStackArray<units::UnitPreference*, 8>;
+template class U_I18N_API MemoryPool<units::UnitPreference, 8>;
+template class U_I18N_API MaybeStackVector<units::UnitPreference, 8>;
+#endif
+
+namespace units {
+
+/**
+ * Unit Preferences information for various locales and usages.
+ */
+class U_I18N_API UnitPreferences {
+ public:
+ /**
+ * Constructor, loads all the preference data.
+ *
+ * @param status Receives status.
+ */
+ UnitPreferences(UErrorCode &status);
+
+ /**
+ * Returns the set of unit preferences in the particular category that best
+ * matches the specified usage and region.
+ *
+ * If region can't be found, falls back to global (001). If usage can't be
+ * found, falls back to "default".
+ *
+ * @param category The category within which to look up usage and region.
+ * (TODO(hugovdm): improve docs on how to find the category, once the lookup
+ * function is added.)
+ * @param usage The usage parameter. (TODO(hugovdm): improve this
+ * documentation. Add reference to some list of usages we support.) If the
+ * given usage is not found, the method automatically falls back to
+ * "default".
+ * @param region The region whose preferences are desired. If there are no
+ * specific preferences for the requested region, the method automatically
+ * falls back to region "001" ("world").
+ * @param outPreferences A pointer into an array of preferences: essentially
+ * an array slice in combination with preferenceCount.
+ * @param preferenceCount The number of unit preferences that belong to the
+ * result set.
+ * @param status Receives status.
+ *
+ * TODO(hugovdm): maybe replace `UnitPreference **&outPreferences` with a slice class?
+ */
+ void getPreferencesFor(StringPiece category, StringPiece usage, StringPiece region,
+ const UnitPreference *const *&outPreferences, int32_t &preferenceCount,
+ UErrorCode &status) const;
+
+ protected:
+ // Metadata about the sets of preferences, this is the index for looking up
+ // preferences in the unitPrefs_ list.
+ MaybeStackVector<UnitPreferenceMetadata> metadata_;
+ // All the preferences as a flat list: which usage and region preferences
+ // are associated with is stored in `metadata_`.
+ MaybeStackVector<UnitPreference> unitPrefs_;
+};
+
+} // namespace units
+U_NAMESPACE_END
+
+#endif //__UNITS_DATA_H__
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/units_router.cpp b/deps/icu-small/source/i18n/units_router.cpp
new file mode 100644
index 0000000000..3158718fd2
--- /dev/null
+++ b/deps/icu-small/source/i18n/units_router.cpp
@@ -0,0 +1,132 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "charstr.h"
+#include "cmemory.h"
+#include "cstring.h"
+#include "measunit_impl.h"
+#include "number_decimalquantity.h"
+#include "number_roundingutils.h"
+#include "resource.h"
+#include "unicode/measure.h"
+#include "units_data.h"
+#include "units_router.h"
+#include <cmath>
+
+U_NAMESPACE_BEGIN
+namespace units {
+
+using number::Precision;
+using number::impl::parseIncrementOption;
+
+Precision UnitsRouter::parseSkeletonToPrecision(icu::UnicodeString precisionSkeleton,
+ UErrorCode &status) {
+ if (U_FAILURE(status)) {
+ // As a member of UsagePrefsHandler, which is a friend of Precision, we
+ // get access to the default constructor.
+ return {};
+ }
+ constexpr int32_t kSkelPrefixLen = 20;
+ if (!precisionSkeleton.startsWith(UNICODE_STRING_SIMPLE("precision-increment/"))) {
+ status = U_INVALID_FORMAT_ERROR;
+ return {};
+ }
+ U_ASSERT(precisionSkeleton[kSkelPrefixLen - 1] == u'/');
+ StringSegment segment(precisionSkeleton, false);
+ segment.adjustOffset(kSkelPrefixLen);
+ Precision result;
+ parseIncrementOption(segment, result, status);
+ return result;
+}
+
+UnitsRouter::UnitsRouter(MeasureUnit inputUnit, StringPiece region, StringPiece usage,
+ UErrorCode &status) {
+ // TODO: do we want to pass in ConversionRates and UnitPreferences instead
+ // of loading in each UnitsRouter instance? (Or make global?)
+ ConversionRates conversionRates(status);
+ UnitPreferences prefs(status);
+
+ MeasureUnitImpl inputUnitImpl = MeasureUnitImpl::forMeasureUnitMaybeCopy(inputUnit, status);
+ MeasureUnit baseUnit =
+ (extractCompoundBaseUnit(inputUnitImpl, conversionRates, status)).build(status);
+ CharString category = getUnitCategory(baseUnit.getIdentifier(), status);
+
+ const UnitPreference *const *unitPreferences;
+ int32_t preferencesCount;
+ prefs.getPreferencesFor(category.data(), usage, region, unitPreferences, preferencesCount, status);
+
+ for (int i = 0; i < preferencesCount; ++i) {
+ const auto &preference = *unitPreferences[i];
+
+ MeasureUnitImpl complexTargetUnitImpl =
+ MeasureUnitImpl::forIdentifier(preference.unit.data(), status);
+ if (U_FAILURE(status)) {
+ return;
+ }
+
+ UnicodeString precision = preference.skeleton;
+
+ // For now, we only have "precision-increment" in Units Preferences skeleton.
+ // Therefore, we check if the skeleton starts with "precision-increment" and force the program to
+ // fail otherwise.
+ // NOTE:
+ // It is allowed to have an empty precision.
+ if (!precision.isEmpty() && !precision.startsWith(u"precision-increment", 19)) {
+ status = U_INTERNAL_PROGRAM_ERROR;
+ return;
+ }
+
+ outputUnits_.emplaceBackAndCheckErrorCode(status,
+ complexTargetUnitImpl.copy(status).build(status));
+ converterPreferences_.emplaceBackAndCheckErrorCode(status, inputUnitImpl, complexTargetUnitImpl,
+ preference.geq, std::move(precision),
+ conversionRates, status);
+
+ if (U_FAILURE(status)) {
+ return;
+ }
+ }
+}
+
+RouteResult UnitsRouter::route(double quantity, icu::number::impl::RoundingImpl *rounder, UErrorCode &status) const {
+ // Find the matching preference
+ const ConverterPreference *converterPreference = nullptr;
+ for (int32_t i = 0, n = converterPreferences_.length(); i < n; i++) {
+ converterPreference = converterPreferences_[i];
+ if (converterPreference->converter.greaterThanOrEqual(std::abs(quantity) * (1 + DBL_EPSILON),
+ converterPreference->limit)) {
+ break;
+ }
+ }
+ U_ASSERT(converterPreference != nullptr);
+
+ // Set up the rounder for this preference's precision
+ if (rounder != nullptr && rounder->fPrecision.isBogus()) {
+ if (converterPreference->precision.length() > 0) {
+ rounder->fPrecision = parseSkeletonToPrecision(converterPreference->precision, status);
+ } else {
+ // We use the same rounding mode as COMPACT notation: known to be a
+ // human-friendly rounding mode: integers, but add a decimal digit
+ // as needed to ensure we have at least 2 significant digits.
+ rounder->fPrecision = Precision::integer().withMinDigits(2);
+ }
+ }
+
+ return RouteResult(converterPreference->converter.convert(quantity, rounder, status),
+ converterPreference->targetUnit.copy(status));
+}
+
+const MaybeStackVector<MeasureUnit> *UnitsRouter::getOutputUnits() const {
+ // TODO: consider pulling this from converterPreferences_ and dropping
+ // outputUnits_?
+ return &outputUnits_;
+}
+
+} // namespace units
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/units_router.h b/deps/icu-small/source/i18n/units_router.h
new file mode 100644
index 0000000000..bd7a93d2d8
--- /dev/null
+++ b/deps/icu-small/source/i18n/units_router.h
@@ -0,0 +1,162 @@
+// © 2020 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+#ifndef __UNITS_ROUTER_H__
+#define __UNITS_ROUTER_H__
+
+#include <limits>
+
+#include "cmemory.h"
+#include "measunit_impl.h"
+#include "unicode/measunit.h"
+#include "unicode/stringpiece.h"
+#include "unicode/uobject.h"
+#include "units_complexconverter.h"
+#include "units_data.h"
+
+U_NAMESPACE_BEGIN
+
+// Forward declarations
+class Measure;
+namespace number {
+class Precision;
+}
+
+namespace units {
+
+struct RouteResult : UMemory {
+ // A list of measures: a single measure for single units, multiple measures
+ // for mixed units.
+ //
+ // TODO(icu-units/icu#21): figure out the right mixed unit API.
+ MaybeStackVector<Measure> measures;
+
+ // The output unit for this RouteResult. This may be a MIXED unit - for
+ // example: "yard-and-foot-and-inch", for which `measures` will have three
+ // elements.
+ MeasureUnitImpl outputUnit;
+
+ RouteResult(MaybeStackVector<Measure> measures, MeasureUnitImpl outputUnit)
+ : measures(std::move(measures)), outputUnit(std::move(outputUnit)) {}
+};
+
+/**
+ * Contains the complex unit converter and the limit which representing the smallest value that the
+ * converter should accept. For example, if the converter is converting to `foot+inch` and the limit
+ * equals 3.0, thus means the converter should not convert to a value less than `3.0 feet`.
+ *
+ * NOTE:
+ * if the limit doest not has a value `i.e. (std::numeric_limits<double>::lowest())`, this mean there
+ * is no limit for the converter.
+ */
+struct ConverterPreference : UMemory {
+ ComplexUnitsConverter converter;
+ double limit;
+ UnicodeString precision;
+
+ // The output unit for this ConverterPreference. This may be a MIXED unit -
+ // for example: "yard-and-foot-and-inch".
+ MeasureUnitImpl targetUnit;
+
+ // In case there is no limit, the limit will be -inf.
+ ConverterPreference(const MeasureUnitImpl &source, const MeasureUnitImpl &complexTarget,
+ UnicodeString precision, const ConversionRates &ratesInfo, UErrorCode &status)
+ : ConverterPreference(source, complexTarget, std::numeric_limits<double>::lowest(), precision,
+ ratesInfo, status) {}
+
+ ConverterPreference(const MeasureUnitImpl &source, const MeasureUnitImpl &complexTarget,
+ double limit, UnicodeString precision, const ConversionRates &ratesInfo,
+ UErrorCode &status)
+ : converter(source, complexTarget, ratesInfo, status), limit(limit),
+ precision(std::move(precision)), targetUnit(complexTarget.copy(status)) {}
+};
+
+} // namespace units
+
+// Export explicit template instantiations of MaybeStackArray, MemoryPool and
+// MaybeStackVector. This is required when building DLLs for Windows. (See
+// datefmt.h, collationiterator.h, erarules.h and others for similar examples.)
+//
+// Note: These need to be outside of the units namespace, or Clang will generate
+// a compile error.
+#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
+template class U_I18N_API MaybeStackArray<units::ConverterPreference*, 8>;
+template class U_I18N_API MemoryPool<units::ConverterPreference, 8>;
+template class U_I18N_API MaybeStackVector<units::ConverterPreference, 8>;
+#endif
+
+namespace units {
+
+/**
+ * `UnitsRouter` responsible for converting from a single unit (such as `meter` or `meter-per-second`) to
+ * one of the complex units based on the limits.
+ * For example:
+ * if the input is `meter` and the output as following
+ * {`foot+inch`, limit: 3.0}
+ * {`inch` , limit: no value (-inf)}
+ * Thus means if the input in `meter` is greater than or equal to `3.0 feet`, the output will be in
+ * `foot+inch`, otherwise, the output will be in `inch`.
+ *
+ * NOTE:
+ * the output units and the their limits MUST BE in order, for example, if the output units, from the
+ * previous example, are the following:
+ * {`inch` , limit: no value (-inf)}
+ * {`foot+inch`, limit: 3.0}
+ * IN THIS CASE THE OUTPUT WILL BE ALWAYS IN `inch`.
+ *
+ * NOTE:
+ * the output units and their limits will be extracted from the units preferences database by knowing
+ * the followings:
+ * - input unit
+ * - locale
+ * - usage
+ *
+ * DESIGN:
+ * `UnitRouter` uses internally `ComplexUnitConverter` in order to convert the input units to the
+ * desired complex units and to check the limit too.
+ */
+class U_I18N_API UnitsRouter {
+ public:
+ UnitsRouter(MeasureUnit inputUnit, StringPiece locale, StringPiece usage, UErrorCode &status);
+
+ /**
+ * Performs locale and usage sensitive unit conversion.
+ * @param quantity The quantity to convert, expressed in terms of inputUnit.
+ * @param rounder If not null, this RoundingImpl will be used to do rounding
+ * on the converted value. If the rounder lacks an fPrecision, the
+ * rounder will be modified to use the preferred precision for the usage
+ * and locale preference, alternatively with the default precision.
+ * @param status Receives status.
+ */
+ RouteResult route(double quantity, icu::number::impl::RoundingImpl *rounder, UErrorCode &status) const;
+
+ /**
+ * Returns the list of possible output units, i.e. the full set of
+ * preferences, for the localized, usage-specific unit preferences.
+ *
+ * The returned pointer should be valid for the lifetime of the
+ * UnitsRouter instance.
+ */
+ const MaybeStackVector<MeasureUnit> *getOutputUnits() const;
+
+ private:
+ // List of possible output units. TODO: converterPreferences_ now also has
+ // this data available. Maybe drop outputUnits_ and have getOutputUnits
+ // construct a the list from data in converterPreferences_ instead?
+ MaybeStackVector<MeasureUnit> outputUnits_;
+
+ MaybeStackVector<ConverterPreference> converterPreferences_;
+
+ static number::Precision parseSkeletonToPrecision(icu::UnicodeString precisionSkeleton,
+ UErrorCode &status);
+};
+
+} // namespace units
+U_NAMESPACE_END
+
+#endif //__UNITS_ROUTER_H__
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/deps/icu-small/source/i18n/unum.cpp b/deps/icu-small/source/i18n/unum.cpp
index ba3d519162..de693fc727 100644
--- a/deps/icu-small/source/i18n/unum.cpp
+++ b/deps/icu-small/source/i18n/unum.cpp
@@ -898,7 +898,7 @@ unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode*
return ((const NumberFormat*)fmt)->getContext(type, *status);
}
-U_INTERNAL UFormattable * U_EXPORT2
+U_CAPI UFormattable * U_EXPORT2
unum_parseToUFormattable(const UNumberFormat* fmt,
UFormattable *result,
const UChar* text,
@@ -922,7 +922,7 @@ unum_parseToUFormattable(const UNumberFormat* fmt,
return result;
}
-U_INTERNAL int32_t U_EXPORT2
+U_CAPI int32_t U_EXPORT2
unum_formatUFormattable(const UNumberFormat* fmt,
const UFormattable *number,
UChar *result,
diff --git a/deps/icu-small/source/i18n/upluralrules.cpp b/deps/icu-small/source/i18n/upluralrules.cpp
index 5119257fd8..73e59a75c4 100644
--- a/deps/icu-small/source/i18n/upluralrules.cpp
+++ b/deps/icu-small/source/i18n/upluralrules.cpp
@@ -20,6 +20,7 @@
#include "unicode/unumberformatter.h"
#include "number_decimalquantity.h"
#include "number_utypes.h"
+#include "numrange_impl.h"
U_NAMESPACE_USE
@@ -116,6 +117,25 @@ uplrules_selectFormatted(const UPluralRules *uplrules,
}
U_CAPI int32_t U_EXPORT2
+uplrules_selectForRange(const UPluralRules *uplrules,
+ const UFormattedNumberRange* urange,
+ UChar *keyword, int32_t capacity,
+ UErrorCode *status)
+{
+ if (U_FAILURE(*status)) {
+ return 0;
+ }
+ if (keyword == NULL ? capacity != 0 : capacity < 0) {
+ *status = U_ILLEGAL_ARGUMENT_ERROR;
+ return 0;
+ }
+ const number::impl::UFormattedNumberRangeData* impl =
+ number::impl::validateUFormattedNumberRange(urange, *status);
+ UnicodeString result = ((PluralRules*)uplrules)->select(impl, *status);
+ return result.extract(keyword, capacity, *status);
+}
+
+U_CAPI int32_t U_EXPORT2
uplrules_selectWithFormat(const UPluralRules *uplrules,
double number,
const UNumberFormat *fmt,
diff --git a/deps/icu-small/source/i18n/uspoof_impl.h b/deps/icu-small/source/i18n/uspoof_impl.h
index 8844a96446..b0bd8cefc8 100644
--- a/deps/icu-small/source/i18n/uspoof_impl.h
+++ b/deps/icu-small/source/i18n/uspoof_impl.h
@@ -222,7 +222,7 @@ class SpoofData: public UMemory {
SpoofData(const void *serializedData, int32_t length, UErrorCode &status);
// Check raw Spoof Data Version compatibility.
- // Return TRUE it looks good.
+ // Return true it looks good.
UBool validateDataVersion(UErrorCode &status) const;
~SpoofData(); // Destructor not normally used.
diff --git a/deps/icu-small/source/i18n/usrchimp.h b/deps/icu-small/source/i18n/usrchimp.h
index 5438417e7e..e056337cae 100644
--- a/deps/icu-small/source/i18n/usrchimp.h
+++ b/deps/icu-small/source/i18n/usrchimp.h
@@ -206,7 +206,7 @@ struct UStringSearch {
* the text "\u00e6"
* @param strsrch string search data
* @param status error status if any
-* @return TRUE if an exact match is found, FALSE otherwise
+* @return true if an exact match is found, false otherwise
*/
U_CFUNC
UBool usearch_handleNextExact(UStringSearch *strsrch, UErrorCode *status);
@@ -217,7 +217,7 @@ UBool usearch_handleNextExact(UStringSearch *strsrch, UErrorCode *status);
* of beginning and ending accents if it overlaps that region.
* @param strsrch string search data
* @param status error status if any
-* @return TRUE if a canonical match is found, FALSE otherwise
+* @return true if a canonical match is found, false otherwise
*/
U_CFUNC
UBool usearch_handleNextCanonical(UStringSearch *strsrch, UErrorCode *status);
@@ -227,7 +227,7 @@ UBool usearch_handleNextCanonical(UStringSearch *strsrch, UErrorCode *status);
* Comments follows from handleNextExact
* @param strsrch string search data
* @param status error status if any
-* @return True if a exact math is found, FALSE otherwise.
+* @return True if a exact math is found, false otherwise.
*/
U_CFUNC
UBool usearch_handlePreviousExact(UStringSearch *strsrch, UErrorCode *status);
@@ -238,7 +238,7 @@ UBool usearch_handlePreviousExact(UStringSearch *strsrch, UErrorCode *status);
* of beginning and ending accents if it overlaps that region.
* @param strsrch string search data
* @param status error status if any
-* @return TRUE if a canonical match is found, FALSE otherwise
+* @return true if a canonical match is found, false otherwise
*/
U_CFUNC
UBool usearch_handlePreviousCanonical(UStringSearch *strsrch,
diff --git a/deps/icu-small/source/i18n/utf16collationiterator.h b/deps/icu-small/source/i18n/utf16collationiterator.h
index fd3a05e9ef..6305d81c30 100644
--- a/deps/icu-small/source/i18n/utf16collationiterator.h
+++ b/deps/icu-small/source/i18n/utf16collationiterator.h
@@ -125,7 +125,7 @@ private:
/**
* Extend the FCD text segment forward or normalize around pos.
* To be called when checkDir > 0 && pos != limit.
- * @return TRUE if success, checkDir == 0 and pos != limit
+ * @return true if success, checkDir == 0 and pos != limit
*/
UBool nextSegment(UErrorCode &errorCode);
@@ -139,7 +139,7 @@ private:
/**
* Extend the FCD text segment backward or normalize around pos.
* To be called when checkDir < 0 && pos != start.
- * @return TRUE if success, checkDir == 0 and pos != start
+ * @return true if success, checkDir == 0 and pos != start
*/
UBool previousSegment(UErrorCode &errorCode);
diff --git a/deps/icu-small/source/i18n/utf8collationiterator.h b/deps/icu-small/source/i18n/utf8collationiterator.h
index 9a3ec45aeb..9059e72dcf 100644
--- a/deps/icu-small/source/i18n/utf8collationiterator.h
+++ b/deps/icu-small/source/i18n/utf8collationiterator.h
@@ -54,7 +54,7 @@ protected:
* together with a bogus code point. The caller will ignore that code point.
*
* Special values may be returned for surrogate code points, which are also illegal in UTF-8,
- * but the caller will treat them like U+FFFD because forbidSurrogateCodePoints() returns TRUE.
+ * but the caller will treat them like U+FFFD because forbidSurrogateCodePoints() returns true.
*
* Valid lead surrogates are returned from inside a normalized text segment,
* where handleGetTrailSurrogate() will return the matching trail surrogate.
@@ -117,7 +117,7 @@ private:
/**
* Extends the FCD text segment forward or normalizes around pos.
- * @return TRUE if success
+ * @return true if success
*/
UBool nextSegment(UErrorCode &errorCode);
@@ -128,7 +128,7 @@ private:
/**
* Extends the FCD text segment backward or normalizes around pos.
- * @return TRUE if success
+ * @return true if success
*/
UBool previousSegment(UErrorCode &errorCode);
diff --git a/deps/icu-small/source/i18n/vzone.h b/deps/icu-small/source/i18n/vzone.h
index 700687e0cb..9c83c1b7e6 100644
--- a/deps/icu-small/source/i18n/vzone.h
+++ b/deps/icu-small/source/i18n/vzone.h
@@ -91,7 +91,7 @@ vzone_equals(const VZone* zone1, const VZone* zone2);
* @param zone, the vzone to use
* @param url Receives the RFC2445 TZURL property value.
* @param urlLength, length of the url
- * @return TRUE if TZURL attribute is available and value is set.
+ * @return true if TZURL attribute is available and value is set.
*/
U_CAPI UBool U_EXPORT2
vzone_getTZURL(VZone* zone, UChar* & url, int32_t & urlLength);
@@ -112,7 +112,7 @@ vzone_setTZURL(VZone* zone, UChar* url, int32_t urlLength);
* is not set.
* @param zone, the vzone to use
* @param lastModified Receives the last modified date.
- * @return TRUE if lastModified attribute is available and value is set.
+ * @return true if lastModified attribute is available and value is set.
*/
U_CAPI UBool U_EXPORT2
vzone_getLastModified(VZone* zone, UDate& lastModified);
@@ -283,7 +283,7 @@ vzone_useDaylightTime(VZone* zone);
* @return true if the given date is in daylight savings time,
* false, otherwise.
*/
-U_INTERNAL UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
vzone_inDaylightTime(VZone* zone, UDate date, UErrorCode& status);
/**
@@ -303,7 +303,7 @@ vzone_hasSameRules(VZone* zone, const VZone* other);
* @param base The base time.
* @param inclusive Whether the base time is inclusive or not.
* @param result Receives the first transition after the base time.
- * @return TRUE if the transition is found.
+ * @return true if the transition is found.
*/
U_CAPI UBool U_EXPORT2
vzone_getNextTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result);
@@ -314,7 +314,7 @@ vzone_getNextTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result
* @param base The base time.
* @param inclusive Whether the base time is inclusive or not.
* @param result Receives the most recent transition before the base time.
- * @return TRUE if the transition is found.
+ * @return true if the transition is found.
*/
U_CAPI UBool U_EXPORT2
vzone_getPreviousTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result);
diff --git a/deps/icu-small/source/i18n/zonemeta.h b/deps/icu-small/source/i18n/zonemeta.h
index 9dbcc878a2..58724ea3b7 100644
--- a/deps/icu-small/source/i18n/zonemeta.h
+++ b/deps/icu-small/source/i18n/zonemeta.h
@@ -59,7 +59,7 @@ public:
* is not associated with a country, return bogus string.
* @param tzid Zone ID
* @param country [output] Country code
- * @param isPrimary [output] TRUE if the zone is the primary zone for the country
+ * @param isPrimary [output] true if the zone is the primary zone for the country
* @return A reference to the result country
*/
static UnicodeString& U_EXPORT2 getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country, UBool *isPrimary = NULL);
diff --git a/deps/icu-small/source/python/icutools/databuilder/filtration_schema.json b/deps/icu-small/source/python/icutools/databuilder/filtration_schema.json
index 2b7ff99899..3aed41a334 100644
--- a/deps/icu-small/source/python/icutools/databuilder/filtration_schema.json
+++ b/deps/icu-small/source/python/icutools/databuilder/filtration_schema.json
@@ -90,7 +90,7 @@
{
"properties": {
"filterType": {
- "$ref": "#/definitions/blacklistWhitelistFilterTypes"
+ "$ref": "#/definitions/includeExcludeFilterTypes"
},
"whitelist": { "$ref": "#/definitions/stringList" }
},
@@ -100,7 +100,7 @@
{
"properties": {
"filterType": {
- "$ref": "#/definitions/blacklistWhitelistFilterTypes"
+ "$ref": "#/definitions/includeExcludeFilterTypes"
},
"blacklist": { "$ref": "#/definitions/stringList" }
},
@@ -110,6 +110,26 @@
{
"properties": {
"filterType": {
+ "$ref": "#/definitions/includeExcludeFilterTypes"
+ },
+ "includelist": { "$ref": "#/definitions/stringList" }
+ },
+ "required": ["includelist"],
+ "additionalProperties": false
+ },
+ {
+ "properties": {
+ "filterType": {
+ "$ref": "#/definitions/includeExcludeFilterTypes"
+ },
+ "excludelist": { "$ref": "#/definitions/stringList" }
+ },
+ "required": ["excludelist"],
+ "additionalProperties": false
+ },
+ {
+ "properties": {
+ "filterType": {
"type": "string",
"enum": ["exclude"]
}
@@ -138,6 +158,23 @@
"properties": {
"filterType": {
"type": "string",
+ "enum": ["locale"]
+ },
+ "includeChildren": {
+ "type": "boolean"
+ },
+ "includeScripts": {
+ "type": "boolean"
+ },
+ "includelist": { "$ref": "#/definitions/stringList" }
+ },
+ "required": ["filterType", "includelist"],
+ "additionalProperties": false
+ },
+ {
+ "properties": {
+ "filterType": {
+ "type": "string",
"enum": ["union"]
},
"unionOf": {
@@ -150,7 +187,7 @@
}
]
},
- "blacklistWhitelistFilterTypes": {
+ "includeExcludeFilterTypes": {
"type": "string",
"enum": [
"language",
diff --git a/deps/icu-small/source/python/icutools/databuilder/test/sample_data/brkitr/LOCALE_DEPS.json b/deps/icu-small/source/python/icutools/databuilder/test/sample_data/brkitr/LOCALE_DEPS.json
index 89329e87ee..674db09278 100644
--- a/deps/icu-small/source/python/icutools/databuilder/test/sample_data/brkitr/LOCALE_DEPS.json
+++ b/deps/icu-small/source/python/icutools/databuilder/test/sample_data/brkitr/LOCALE_DEPS.json
@@ -1,5 +1,5 @@
// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
//////////////////////////////////////////////////////////////
// This is a sample LOCALE_DEPS.json file for testing only. //
diff --git a/deps/icu-small/source/python/icutools/databuilder/test/sample_data/locales/LOCALE_DEPS.json b/deps/icu-small/source/python/icutools/databuilder/test/sample_data/locales/LOCALE_DEPS.json
index fd28a741ef..1456ea0d9a 100644
--- a/deps/icu-small/source/python/icutools/databuilder/test/sample_data/locales/LOCALE_DEPS.json
+++ b/deps/icu-small/source/python/icutools/databuilder/test/sample_data/locales/LOCALE_DEPS.json
@@ -1,5 +1,5 @@
// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
//////////////////////////////////////////////////////////////
// This is a sample LOCALE_DEPS.json file for testing only. //
diff --git a/deps/icu-small/source/python/icutools/databuilder/test/sample_data/rbnf/LOCALE_DEPS.json b/deps/icu-small/source/python/icutools/databuilder/test/sample_data/rbnf/LOCALE_DEPS.json
index f079619a36..c6ec208add 100644
--- a/deps/icu-small/source/python/icutools/databuilder/test/sample_data/rbnf/LOCALE_DEPS.json
+++ b/deps/icu-small/source/python/icutools/databuilder/test/sample_data/rbnf/LOCALE_DEPS.json
@@ -1,5 +1,5 @@
// © 2019 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html#License
+// License & terms of use: http://www.unicode.org/copyright.html
//////////////////////////////////////////////////////////////
// This is a sample LOCALE_DEPS.json file for testing only. //
diff --git a/deps/icu-small/source/tools/genrb/errmsg.c b/deps/icu-small/source/tools/genrb/errmsg.c
index 603f26a174..91dfd3265e 100644
--- a/deps/icu-small/source/tools/genrb/errmsg.c
+++ b/deps/icu-small/source/tools/genrb/errmsg.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include "cstring.h"
#include "errmsg.h"
+#include "toolutil.h"
U_CFUNC void error(uint32_t linenumber, const char *msg, ...)
{
diff --git a/deps/icu-small/source/tools/genrb/read.c b/deps/icu-small/source/tools/genrb/read.c
index c20b4510a2..141e285d25 100644
--- a/deps/icu-small/source/tools/genrb/read.c
+++ b/deps/icu-small/source/tools/genrb/read.c
@@ -20,6 +20,7 @@
#include "read.h"
#include "errmsg.h"
+#include "toolutil.h"
#include "unicode/ustring.h"
#include "unicode/utf16.h"
diff --git a/deps/icu-small/source/tools/genrb/reslist.cpp b/deps/icu-small/source/tools/genrb/reslist.cpp
index 3186c781e9..4bc6adc128 100644
--- a/deps/icu-small/source/tools/genrb/reslist.cpp
+++ b/deps/icu-small/source/tools/genrb/reslist.cpp
@@ -39,6 +39,7 @@
#include "unicode/putil.h"
#include "errmsg.h"
#include "filterrb.h"
+#include "toolutil.h"
#include "uarrsort.h"
#include "uelement.h"
diff --git a/deps/icu-small/source/tools/genrb/reslist.h b/deps/icu-small/source/tools/genrb/reslist.h
index 34b710c423..e7b10fa096 100644
--- a/deps/icu-small/source/tools/genrb/reslist.h
+++ b/deps/icu-small/source/tools/genrb/reslist.h
@@ -355,7 +355,7 @@ public:
fNumCopies(0), fNumUnitsSaved(0), fNumCharsForLength(numCharsForLength) {
// v3 pool string encoded as string-v2 with low offset
fRes = URES_MAKE_RESOURCE(URES_STRING_V2, poolStringIndex);
- fWritten = TRUE;
+ fWritten = true;
}
virtual ~StringResource();
diff --git a/deps/icu-small/source/tools/genrb/rle.c b/deps/icu-small/source/tools/genrb/rle.c
index 3d034f78ca..c5d29ba1d2 100644
--- a/deps/icu-small/source/tools/genrb/rle.c
+++ b/deps/icu-small/source/tools/genrb/rle.c
@@ -16,6 +16,7 @@
* 01/11/02 Ram Creation.
*******************************************************************************
*/
+#include <stdbool.h>
#include "rle.h"
/**
* The ESCAPE character is used during run-length encoding. It signals
@@ -297,7 +298,7 @@ int32_t
rleStringToByteArray(uint16_t* src, int32_t srcLen, uint8_t* target, int32_t tgtLen, UErrorCode* status) {
int32_t length = 0;
- UBool nextChar = TRUE;
+ UBool nextChar = true;
uint16_t c = 0;
int32_t node = 0;
int32_t runLength = 0;
@@ -334,11 +335,11 @@ rleStringToByteArray(uint16_t* src, int32_t srcLen, uint8_t* target, int32_t tgt
if (nextChar) {
c = src[i++];
b = (uint8_t) (c >> 8);
- nextChar = FALSE;
+ nextChar = false;
}
else {
b = (uint8_t) (c & 0xFF);
- nextChar = TRUE;
+ nextChar = true;
}
/* This part of the loop is a tiny state machine which handles
diff --git a/deps/icu-small/source/tools/icupkg/icupkg.cpp b/deps/icu-small/source/tools/icupkg/icupkg.cpp
index ea7be4a909..39707946b0 100644
--- a/deps/icu-small/source/tools/icupkg/icupkg.cpp
+++ b/deps/icu-small/source/tools/icupkg/icupkg.cpp
@@ -59,6 +59,7 @@ printUsage(const char *pname, UBool isHelp) {
"%csage: %s [-h|-?|--help ] [-tl|-tb|-te] [-c] [-C comment]\n"
"\t[-a list] [-r list] [-x list] [-l [-o outputListFileName]]\n"
"\t[-s path] [-d path] [-w] [-m mode]\n"
+ "\t[--ignore-deps]\n"
"\t[--auto_toc_prefix] [--auto_toc_prefix_with_type] [--toc_prefix]\n"
"\tinfilename [outfilename]\n",
isHelp ? 'U' : 'u', pname);
@@ -121,6 +122,10 @@ printUsage(const char *pname, UBool isHelp) {
"\t noslash: the '*' wildcard does not match the '/' tree separator\n");
fprintf(where,
"\n"
+ "\t--ignore-deps Do not fail if not all resource dependencies are met. Use this\n"
+ "\t option if the missing resources come from another source.");
+ fprintf(where,
+ "\n"
"\tIn the .dat package, the Table of Contents (ToC) contains an entry\n"
"\tfor each item of the form prefix/tree/itemname .\n"
"\tThe prefix normally matches the package basename, and icupkg checks that,\n"
@@ -198,6 +203,8 @@ static UOption options[]={
UOPTION_DEF("matchmode", 'm', UOPT_REQUIRES_ARG),
+ UOPTION_DEF("ignore-deps", '\1', UOPT_NO_ARG),
+
UOPTION_DEF("add", 'a', UOPT_REQUIRES_ARG),
UOPTION_DEF("remove", 'r', UOPT_REQUIRES_ARG),
UOPTION_DEF("extract", 'x', UOPT_REQUIRES_ARG),
@@ -225,6 +232,8 @@ enum {
OPT_MATCHMODE,
+ OPT_IGNORE_DEPS,
+
OPT_ADD_LIST,
OPT_REMOVE_LIST,
OPT_EXTRACT_LIST,
@@ -501,7 +510,7 @@ main(int argc, char *argv[]) {
}
/* check dependencies between items */
- if(!pkg->checkDependencies()) {
+ if(!options[OPT_IGNORE_DEPS].doesOccur && !pkg->checkDependencies()) {
/* some dependencies are not fulfilled */
return U_MISSING_RESOURCE_ERROR;
}
diff --git a/deps/icu-small/source/tools/pkgdata/pkgtypes.c b/deps/icu-small/source/tools/pkgdata/pkgtypes.c
index 43ee3dfb5e..26bd945df7 100644
--- a/deps/icu-small/source/tools/pkgdata/pkgtypes.c
+++ b/deps/icu-small/source/tools/pkgdata/pkgtypes.c
@@ -17,6 +17,7 @@
* common types for pkgdata
*/
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "unicode/utypes.h"
@@ -294,9 +295,9 @@ UBool pkg_listContains(CharList *l, const char *str)
{
for(;l;l=l->next){
if(!uprv_strcmp(l->str, str)) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
diff --git a/deps/icu-small/source/tools/toolutil/dbgutil.cpp b/deps/icu-small/source/tools/toolutil/dbgutil.cpp
index 29bab92753..17fdfbb144 100644
--- a/deps/icu-small/source/tools/toolutil/dbgutil.cpp
+++ b/deps/icu-small/source/tools/toolutil/dbgutil.cpp
@@ -29,7 +29,7 @@ static const UnicodeString& _fieldString(UDebugEnumType type, int32_t field, Un
if(str == NULL) {
return fillin.remove();
} else {
- return fillin = UnicodeString(str, ""); // optimize?
+ return fillin = UnicodeString(str, -1, US_INV);
}
}
diff --git a/deps/icu-small/source/tools/toolutil/filetools.h b/deps/icu-small/source/tools/toolutil/filetools.h
index 6a25c3601c..40a606a7d4 100644
--- a/deps/icu-small/source/tools/toolutil/filetools.h
+++ b/deps/icu-small/source/tools/toolutil/filetools.h
@@ -26,7 +26,7 @@
#include "unicode/utypes.h"
U_CAPI UBool U_EXPORT2
-isFileModTimeLater(const char *filePath, const char *checkAgainst, UBool isDir=FALSE);
+isFileModTimeLater(const char *filePath, const char *checkAgainst, UBool isDir=false);
U_CAPI void U_EXPORT2
swapFileSepChar(char *filePath, const char oldFileSepChar, const char newFileSepChar);
diff --git a/deps/icu-small/source/tools/toolutil/package.h b/deps/icu-small/source/tools/toolutil/package.h
index 3263c84feb..5f74eb73ef 100644
--- a/deps/icu-small/source/tools/toolutil/package.h
+++ b/deps/icu-small/source/tools/toolutil/package.h
@@ -57,13 +57,13 @@ public:
* Uses the prefix of the first entry of the package in readPackage(),
* rather than the package basename.
*/
- void setAutoPrefix() { doAutoPrefix=TRUE; }
+ void setAutoPrefix() { doAutoPrefix=true; }
/**
* Same as setAutoPrefix(), plus the prefix must end with the platform type letter.
*/
void setAutoPrefixWithType() {
- doAutoPrefix=TRUE;
- prefixEndsWithType=TRUE;
+ doAutoPrefix=true;
+ prefixEndsWithType=true;
}
void setPrefix(const char *p);
@@ -128,7 +128,7 @@ public:
const Item *getItem(int32_t idx) const;
/*
- * Check dependencies and return TRUE if all dependencies are fulfilled.
+ * Check dependencies and return true if all dependencies are fulfilled.
*/
UBool checkDependencies();
diff --git a/deps/icu-small/source/tools/toolutil/pkg_genc.cpp b/deps/icu-small/source/tools/toolutil/pkg_genc.cpp
index 31db2e2184..f9400c5058 100644
--- a/deps/icu-small/source/tools/toolutil/pkg_genc.cpp
+++ b/deps/icu-small/source/tools/toolutil/pkg_genc.cpp
@@ -738,8 +738,8 @@ getOutFilename(
exit(U_ILLEGAL_ARGUMENT_ERROR);
}
- uprv_strcpy(outFilename, outFilenameBuilder.data());
- uprv_strcpy(entryName, entryNameBuilder.data());
+ outFilenameBuilder.extract(outFilename, outFilenameCapacity, status);
+ entryNameBuilder.extract(entryName, entryNameCapacity, status);
}
#ifdef CAN_GENERATE_OBJECTS
diff --git a/deps/icu-small/source/tools/toolutil/pkg_genc.h b/deps/icu-small/source/tools/toolutil/pkg_genc.h
index b231aa6170..72d9687035 100644
--- a/deps/icu-small/source/tools/toolutil/pkg_genc.h
+++ b/deps/icu-small/source/tools/toolutil/pkg_genc.h
@@ -68,13 +68,13 @@
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
printAssemblyHeadersToStdErr(void);
-U_INTERNAL UBool U_EXPORT2
+U_CAPI UBool U_EXPORT2
checkAssemblyHeaderName(const char* optAssembly);
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
writeCCode(
const char *filename,
const char *destdir,
@@ -83,7 +83,7 @@ writeCCode(
char *outFilePath,
size_t outFilePathCapacity);
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
writeAssemblyCode(
const char *filename,
const char *destdir,
@@ -92,7 +92,7 @@ writeAssemblyCode(
char *outFilePath,
size_t outFilePathCapacity);
-U_INTERNAL void U_EXPORT2
+U_CAPI void U_EXPORT2
writeObjectCode(
const char *filename,
const char *destdir,
diff --git a/deps/icu-small/source/tools/toolutil/pkgitems.cpp b/deps/icu-small/source/tools/toolutil/pkgitems.cpp
index b0ea980d60..16b18a3e27 100644
--- a/deps/icu-small/source/tools/toolutil/pkgitems.cpp
+++ b/deps/icu-small/source/tools/toolutil/pkgitems.cpp
@@ -441,6 +441,7 @@ ures_enumDependencies(const char *itemName, const UDataInfo *pInfo,
// get dependencies from conversion tables --------------------------------- ***
+#if !UCONFIG_NO_CONVERSION
/* code adapted from ucnv_swap() */
static void
ucnv_enumDependencies(const UDataSwapper *ds,
@@ -631,5 +632,6 @@ Package::enumDependencies(Item *pItem, void *context, CheckDependency check) {
}
}
}
+#endif /* UCONFIG_NO_CONVERSION */
U_NAMESPACE_END
diff --git a/deps/icu-small/source/tools/toolutil/toolutil.cpp b/deps/icu-small/source/tools/toolutil/toolutil.cpp
index f0d6be5cf5..0ce9b02115 100644
--- a/deps/icu-small/source/tools/toolutil/toolutil.cpp
+++ b/deps/icu-small/source/tools/toolutil/toolutil.cpp
@@ -33,7 +33,7 @@
#include "unicode/utypes.h"
#ifndef U_TOOLUTIL_IMPLEMENTATION
-#error U_TOOLUTIL_IMPLEMENTATION not set - must be set for all ICU source files in common/ - see http://userguide.icu-project.org/howtouseicu
+#error U_TOOLUTIL_IMPLEMENTATION not set - must be set for all ICU source files in common/ - see https://unicode-org.github.io/icu/userguide/howtouseicu
#endif
#if U_PLATFORM_USES_ONLY_WIN32_API
@@ -166,14 +166,11 @@ findBasename(const char *filename) {
const char *basename=uprv_strrchr(filename, U_FILE_SEP_CHAR);
#if U_FILE_ALT_SEP_CHAR!=U_FILE_SEP_CHAR
-#if !(U_PLATFORM == U_PF_CYGWIN && U_PLATFORM_USES_ONLY_WIN32_API)
- if(basename==NULL)
-#endif
- {
- /* Use lenient matching on Windows, which can accept either \ or /
- This is useful for environments like Win32+CygWin which have both.
- */
- basename=uprv_strrchr(filename, U_FILE_ALT_SEP_CHAR);
+ //be lenient about pathname separators on Windows, like official implementation of C++17 std::filesystem in MSVC
+ //would be convenient to merge this loop with the one above, but alas, there is no such solution in the standard library
+ const char *alt_basename=uprv_strrchr(filename, U_FILE_ALT_SEP_CHAR);
+ if(alt_basename>basename) {
+ basename=alt_basename;
}
#endif
diff --git a/deps/icu-small/source/tools/toolutil/toolutil.h b/deps/icu-small/source/tools/toolutil/toolutil.h
index be07787a9f..1d0d26c974 100644
--- a/deps/icu-small/source/tools/toolutil/toolutil.h
+++ b/deps/icu-small/source/tools/toolutil/toolutil.h
@@ -23,6 +23,12 @@
#include "unicode/utypes.h"
+#ifndef TRUE
+# define TRUE 1
+#endif
+#ifndef FALSE
+# define FALSE 0
+#endif
#ifdef __cplusplus
diff --git a/deps/icu-small/source/tools/toolutil/udbgutil.cpp b/deps/icu-small/source/tools/toolutil/udbgutil.cpp
index 285f68a0ec..993694546f 100644
--- a/deps/icu-small/source/tools/toolutil/udbgutil.cpp
+++ b/deps/icu-small/source/tools/toolutil/udbgutil.cpp
@@ -594,24 +594,11 @@ U_CAPI void udbg_writeIcuInfo(FILE *out) {
fprintf(out, " </icuSystemParams>\n");
}
-#define ICU_TRAC_URL "http://bugs.icu-project.org/trac/ticket/"
-#define CLDR_TRAC_URL "http://unicode.org/cldr/trac/ticket/"
-#define CLDR_TICKET_PREFIX "cldrbug:"
+#define UNICODE_BUG_URL "https://unicode-org.atlassian.net/browse/"
+#define OLD_CLDR_PREFIX "cldrbug:"
+#define CLDR_BUG_PREFIX "CLDR-"
+#define ICU_BUG_PREFIX "ICU-"
-U_CAPI char *udbg_knownIssueURLFrom(const char *ticket, char *buf) {
- if( ticket==NULL ) {
- return NULL;
- }
-
- if( !strncmp(ticket, CLDR_TICKET_PREFIX, strlen(CLDR_TICKET_PREFIX)) ) {
- strcpy( buf, CLDR_TRAC_URL );
- strcat( buf, ticket+strlen(CLDR_TICKET_PREFIX) );
- } else {
- strcpy( buf, ICU_TRAC_URL );
- strcat( buf, ticket );
- }
- return buf;
-}
#include <set>
@@ -641,8 +628,27 @@ KnownIssues::~KnownIssues()
{
}
-void KnownIssues::add(const char *ticket, const char *where, const UChar *msg, UBool *firstForTicket, UBool *firstForWhere)
+/**
+ * Map cldr:1234 to CLDR-1234
+ * Map 1234 to ICU-1234
+ */
+static std::string mapTicketId(const char *ticketStr) {
+ std::string ticket(ticketStr);
+ // TODO: Can remove this function once all logKnownIssue calls are switched over
+ // to the ICU-1234 and CLDR-1234 format.
+ if(ticket.rfind(OLD_CLDR_PREFIX) == 0) {
+ // map cldrbug:1234 to CLDR-1234
+ ticket.replace(0, uprv_strlen(OLD_CLDR_PREFIX), CLDR_BUG_PREFIX);
+ } else if(::isdigit(ticket[0])) {
+ // map 1234 to ICU-1234
+ ticket.insert(0, ICU_BUG_PREFIX);
+ }
+ return ticket;
+}
+
+void KnownIssues::add(const char *ticketStr, const char *where, const UChar *msg, UBool *firstForTicket, UBool *firstForWhere)
{
+ const std::string ticket = mapTicketId(ticketStr);
if(fTable.find(ticket) == fTable.end()) {
if(firstForTicket!=NULL) *firstForTicket = TRUE;
fTable[ticket] = std::map < std::string, std::set < std::string > >();
@@ -664,8 +670,9 @@ void KnownIssues::add(const char *ticket, const char *where, const UChar *msg, U
fTable[ticket][where].insert(std::string(icu::CStr(ustr)()));
}
-void KnownIssues::add(const char *ticket, const char *where, const char *msg, UBool *firstForTicket, UBool *firstForWhere)
+void KnownIssues::add(const char *ticketStr, const char *where, const char *msg, UBool *firstForTicket, UBool *firstForWhere)
{
+ const std::string ticket = mapTicketId(ticketStr);
if(fTable.find(ticket) == fTable.end()) {
if(firstForTicket!=NULL) *firstForTicket = TRUE;
fTable[ticket] = std::map < std::string, std::set < std::string > >();
@@ -697,8 +704,13 @@ UBool KnownIssues::print()
std::map < std::string, std::set < std::string > > >::iterator i = fTable.begin();
i != fTable.end();
i++ ) {
- char URL[1024];
- std::cout << '#' << (*i).first << " <" << udbg_knownIssueURLFrom( (*i).first.c_str(), URL ) << ">" << std::endl;
+ const std::string ticketid = (*i).first;
+ std::cout << "[" << ticketid << "] ";
+ if(ticketid.rfind(ICU_BUG_PREFIX) == 0 || ticketid.rfind(CLDR_BUG_PREFIX) == 0) {
+ // If it's a unicode.org bug.
+ std::cout << UNICODE_BUG_URL << ticketid;
+ } // Else: some other kind of bug. Allow this, but without a URL.
+ std::cout << std::endl;
for( std::map< std::string, std::set < std::string > >::iterator ii = (*i).second.begin();
ii != (*i).second.end();
diff --git a/deps/icu-small/source/tools/toolutil/udbgutil.h b/deps/icu-small/source/tools/toolutil/udbgutil.h
index 2f186e6ed8..b9af132da5 100644
--- a/deps/icu-small/source/tools/toolutil/udbgutil.h
+++ b/deps/icu-small/source/tools/toolutil/udbgutil.h
@@ -114,14 +114,6 @@ U_CAPI void udbg_writeIcuInfo(FILE *f);
#define UDBG_KNOWNISSUE_LEN 255
/**
- * Convert a "known issue" string into a URL
- * @param ticket ticket string such as "10245" or "cldrbug:5013"
- * @param buf output buffer - must be UDBG_KNOWNISSUE_LEN in size
- * @return pointer to output buffer, or NULL on err
- */
-U_CAPI char *udbg_knownIssueURLFrom(const char *ticket, char *buf);
-
-/**
* Open (or reopen) a 'known issue' table.
* @param ptr pointer to 'table'. Opaque.
* @return new or existing ptr
diff --git a/deps/icu-small/source/tools/toolutil/unewdata.cpp b/deps/icu-small/source/tools/toolutil/unewdata.cpp
index 22d8540881..20f13be5b8 100644
--- a/deps/icu-small/source/tools/toolutil/unewdata.cpp
+++ b/deps/icu-small/source/tools/toolutil/unewdata.cpp
@@ -57,6 +57,16 @@ udata_create(const char *dir, const char *type, const char *name,
return NULL;
}
+ char dirSepChar = U_FILE_SEP_CHAR;
+#if (U_FILE_SEP_CHAR != U_FILE_ALT_SEP_CHAR)
+ // We may need to append a different directory separator when building for Cygwin or MSYS2.
+ if(dir && *dir) {
+ if(!uprv_strchr(dir, U_FILE_SEP_CHAR) && uprv_strchr(dir, U_FILE_ALT_SEP_CHAR)) {
+ dirSepChar = U_FILE_ALT_SEP_CHAR;
+ }
+ }
+#endif
+
/* Check that the full path won't be too long */
length = 0; /* Start with nothing */
if(dir != NULL && *dir !=0) /* Add directory length if one was given */
@@ -64,7 +74,7 @@ udata_create(const char *dir, const char *type, const char *name,
length += static_cast<int32_t>(strlen(dir));
/* Add 1 if dir doesn't end with path sep */
- if (dir[strlen(dir) - 1]!= U_FILE_SEP_CHAR) {
+ if (dir[strlen(dir) - 1]!= dirSepChar) {
length++;
}
}
@@ -87,8 +97,8 @@ udata_create(const char *dir, const char *type, const char *name,
if(dir!=NULL && *dir!=0) { /* if dir has a value, we prepend it to the filename */
char *p=filename+strlen(dir);
uprv_strcpy(filename, dir);
- if (*(p-1)!=U_FILE_SEP_CHAR) {
- *p++=U_FILE_SEP_CHAR;
+ if (*(p-1)!=dirSepChar) {
+ *p++=dirSepChar;
*p=0;
}
} else { /* otherwise, we'll output to the current dir */