aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/i18n
diff options
context:
space:
mode:
authorromankoshelev <romankoshelev@yandex-team.com>2023-08-14 19:51:50 +0300
committerromankoshelev <romankoshelev@yandex-team.com>2023-08-15 01:24:11 +0300
commitcfcd865e05c0d0525ea27d1e153a043b32a85138 (patch)
tree68d3b3b25271e8a4998505897a269ff7ce119b76 /contrib/libs/icu/i18n
parentccb790c507bd5e8ffe2ef9886ce5ee0a7ce22a15 (diff)
downloadydb-cfcd865e05c0d0525ea27d1e153a043b32a85138.tar.gz
Update ICU to 73.2
Diffstat (limited to 'contrib/libs/icu/i18n')
-rw-r--r--contrib/libs/icu/i18n/alphaindex.cpp340
-rw-r--r--contrib/libs/icu/i18n/anytrans.cpp56
-rw-r--r--contrib/libs/icu/i18n/anytrans.h2
-rw-r--r--contrib/libs/icu/i18n/astro.cpp40
-rw-r--r--contrib/libs/icu/i18n/basictz.cpp94
-rw-r--r--contrib/libs/icu/i18n/bocsu.cpp2
-rw-r--r--contrib/libs/icu/i18n/brktrans.cpp8
-rw-r--r--contrib/libs/icu/i18n/buddhcal.cpp11
-rw-r--r--contrib/libs/icu/i18n/buddhcal.h19
-rw-r--r--contrib/libs/icu/i18n/calendar.cpp755
-rw-r--r--contrib/libs/icu/i18n/casetrn.cpp8
-rw-r--r--contrib/libs/icu/i18n/cecal.cpp37
-rw-r--r--contrib/libs/icu/i18n/cecal.h41
-rw-r--r--contrib/libs/icu/i18n/chnsecal.cpp220
-rw-r--r--contrib/libs/icu/i18n/chnsecal.h90
-rw-r--r--contrib/libs/icu/i18n/choicfmt.cpp50
-rw-r--r--contrib/libs/icu/i18n/coleitr.cpp42
-rw-r--r--contrib/libs/icu/i18n/coll.cpp116
-rw-r--r--contrib/libs/icu/i18n/collation.cpp9
-rw-r--r--contrib/libs/icu/i18n/collation.h7
-rw-r--r--contrib/libs/icu/i18n/collationbuilder.cpp222
-rw-r--r--contrib/libs/icu/i18n/collationbuilder.h2
-rw-r--r--contrib/libs/icu/i18n/collationcompare.cpp6
-rw-r--r--contrib/libs/icu/i18n/collationdata.cpp8
-rw-r--r--contrib/libs/icu/i18n/collationdata.h38
-rw-r--r--contrib/libs/icu/i18n/collationdatabuilder.cpp381
-rw-r--r--contrib/libs/icu/i18n/collationdatabuilder.h12
-rw-r--r--contrib/libs/icu/i18n/collationdatareader.cpp88
-rw-r--r--contrib/libs/icu/i18n/collationdatareader.h6
-rw-r--r--contrib/libs/icu/i18n/collationdatawriter.cpp42
-rw-r--r--contrib/libs/icu/i18n/collationdatawriter.h2
-rw-r--r--contrib/libs/icu/i18n/collationfastlatin.cpp54
-rw-r--r--contrib/libs/icu/i18n/collationfastlatin.h10
-rw-r--r--contrib/libs/icu/i18n/collationfastlatinbuilder.cpp124
-rw-r--r--contrib/libs/icu/i18n/collationfcd.cpp4
-rw-r--r--contrib/libs/icu/i18n/collationfcd.h2
-rw-r--r--contrib/libs/icu/i18n/collationiterator.cpp52
-rw-r--r--contrib/libs/icu/i18n/collationiterator.h10
-rw-r--r--contrib/libs/icu/i18n/collationkeys.cpp20
-rw-r--r--contrib/libs/icu/i18n/collationkeys.h6
-rw-r--r--contrib/libs/icu/i18n/collationroot.cpp68
-rw-r--r--contrib/libs/icu/i18n/collationroot.h5
-rw-r--r--contrib/libs/icu/i18n/collationruleparser.cpp60
-rw-r--r--contrib/libs/icu/i18n/collationruleparser.h4
-rw-r--r--contrib/libs/icu/i18n/collationsets.cpp120
-rw-r--r--contrib/libs/icu/i18n/collationsets.h16
-rw-r--r--contrib/libs/icu/i18n/collationsettings.cpp20
-rw-r--r--contrib/libs/icu/i18n/collationsettings.h10
-rw-r--r--contrib/libs/icu/i18n/collationtailoring.cpp28
-rw-r--r--contrib/libs/icu/i18n/collationtailoring.h12
-rw-r--r--contrib/libs/icu/i18n/collationweights.cpp26
-rw-r--r--contrib/libs/icu/i18n/coptccal.cpp20
-rw-r--r--contrib/libs/icu/i18n/coptccal.h18
-rw-r--r--contrib/libs/icu/i18n/cpdtrans.cpp74
-rw-r--r--contrib/libs/icu/i18n/cpdtrans.h12
-rw-r--r--contrib/libs/icu/i18n/csdetect.cpp147
-rw-r--r--contrib/libs/icu/i18n/csmatch.cpp10
-rw-r--r--contrib/libs/icu/i18n/csmatch.h8
-rw-r--r--contrib/libs/icu/i18n/csrmbcs.cpp65
-rw-r--r--contrib/libs/icu/i18n/csrsbcs.cpp4
-rw-r--r--contrib/libs/icu/i18n/csrucode.cpp10
-rw-r--r--contrib/libs/icu/i18n/csrutf8.cpp4
-rw-r--r--contrib/libs/icu/i18n/curramt.cpp6
-rw-r--r--contrib/libs/icu/i18n/currfmt.cpp2
-rw-r--r--contrib/libs/icu/i18n/currpinf.cpp30
-rw-r--r--contrib/libs/icu/i18n/currunit.cpp2
-rw-r--r--contrib/libs/icu/i18n/dangical.cpp27
-rw-r--r--contrib/libs/icu/i18n/dangical.h18
-rw-r--r--contrib/libs/icu/i18n/datefmt.cpp85
-rw-r--r--contrib/libs/icu/i18n/dayperiodrules.cpp34
-rw-r--r--contrib/libs/icu/i18n/dcfmtsym.cpp154
-rw-r--r--contrib/libs/icu/i18n/decContext.cpp8
-rw-r--r--contrib/libs/icu/i18n/decContext.h1
-rw-r--r--contrib/libs/icu/i18n/decNumber.cpp316
-rw-r--r--contrib/libs/icu/i18n/decNumber.h2
-rw-r--r--contrib/libs/icu/i18n/decimfmt.cpp32
-rw-r--r--contrib/libs/icu/i18n/displayoptions.cpp167
-rw-r--r--contrib/libs/icu/i18n/double-conversion-bignum.cpp15
-rw-r--r--contrib/libs/icu/i18n/double-conversion-double-to-string.cpp4
-rw-r--r--contrib/libs/icu/i18n/double-conversion-double-to-string.h4
-rw-r--r--contrib/libs/icu/i18n/double-conversion-ieee.h25
-rw-r--r--contrib/libs/icu/i18n/double-conversion-string-to-double.cpp4
-rw-r--r--contrib/libs/icu/i18n/double-conversion-string-to-double.h4
-rw-r--r--contrib/libs/icu/i18n/double-conversion-utils.h55
-rw-r--r--contrib/libs/icu/i18n/dt_impl.h114
-rw-r--r--contrib/libs/icu/i18n/dtfmtsym.cpp464
-rw-r--r--contrib/libs/icu/i18n/dtitv_impl.h112
-rw-r--r--contrib/libs/icu/i18n/dtitvfmt.cpp140
-rw-r--r--contrib/libs/icu/i18n/dtitvinf.cpp32
-rw-r--r--contrib/libs/icu/i18n/dtptngen.cpp319
-rw-r--r--contrib/libs/icu/i18n/dtptngen_impl.h140
-rw-r--r--contrib/libs/icu/i18n/dtrule.cpp14
-rw-r--r--contrib/libs/icu/i18n/erarules.cpp18
-rw-r--r--contrib/libs/icu/i18n/esctrn.cpp42
-rw-r--r--contrib/libs/icu/i18n/ethpccal.cpp180
-rw-r--r--contrib/libs/icu/i18n/ethpccal.h171
-rw-r--r--contrib/libs/icu/i18n/fmtable.cpp82
-rw-r--r--contrib/libs/icu/i18n/formatted_string_builder.cpp57
-rw-r--r--contrib/libs/icu/i18n/formatted_string_builder.h4
-rw-r--r--contrib/libs/icu/i18n/formattedval_impl.h23
-rw-r--r--contrib/libs/icu/i18n/formattedval_iterimpl.cpp2
-rw-r--r--contrib/libs/icu/i18n/formattedval_sbimpl.cpp5
-rw-r--r--contrib/libs/icu/i18n/formattedvalue.cpp6
-rw-r--r--contrib/libs/icu/i18n/fphdlimp.cpp10
-rw-r--r--contrib/libs/icu/i18n/fphdlimp.h22
-rw-r--r--contrib/libs/icu/i18n/fpositer.cpp18
-rw-r--r--contrib/libs/icu/i18n/funcrepl.cpp6
-rw-r--r--contrib/libs/icu/i18n/gender.cpp52
-rw-r--r--contrib/libs/icu/i18n/gregocal.cpp83
-rw-r--r--contrib/libs/icu/i18n/gregoimp.cpp44
-rw-r--r--contrib/libs/icu/i18n/gregoimp.h4
-rw-r--r--contrib/libs/icu/i18n/hebrwcal.cpp99
-rw-r--r--contrib/libs/icu/i18n/hebrwcal.h84
-rw-r--r--contrib/libs/icu/i18n/indiancal.cpp33
-rw-r--r--contrib/libs/icu/i18n/indiancal.h30
-rw-r--r--contrib/libs/icu/i18n/inputext.cpp14
-rw-r--r--contrib/libs/icu/i18n/islamcal.cpp607
-rw-r--r--contrib/libs/icu/i18n/islamcal.h478
-rw-r--r--contrib/libs/icu/i18n/iso8601cal.cpp37
-rw-r--r--contrib/libs/icu/i18n/iso8601cal.h102
-rw-r--r--contrib/libs/icu/i18n/japancal.cpp20
-rw-r--r--contrib/libs/icu/i18n/japancal.h8
-rw-r--r--contrib/libs/icu/i18n/listformatter.cpp11
-rw-r--r--contrib/libs/icu/i18n/measfmt.cpp82
-rw-r--r--contrib/libs/icu/i18n/measunit.cpp142
-rw-r--r--contrib/libs/icu/i18n/measunit_extra.cpp40
-rw-r--r--contrib/libs/icu/i18n/measure.cpp4
-rw-r--r--contrib/libs/icu/i18n/msgfmt.cpp408
-rw-r--r--contrib/libs/icu/i18n/msgfmt_impl.h8
-rw-r--r--contrib/libs/icu/i18n/name2uni.cpp26
-rw-r--r--contrib/libs/icu/i18n/nfrlist.h18
-rw-r--r--contrib/libs/icu/i18n/nfrs.cpp58
-rw-r--r--contrib/libs/icu/i18n/nfrs.h4
-rw-r--r--contrib/libs/icu/i18n/nfrule.cpp184
-rw-r--r--contrib/libs/icu/i18n/nfrule.h4
-rw-r--r--contrib/libs/icu/i18n/nfsubs.cpp168
-rw-r--r--contrib/libs/icu/i18n/nfsubs.h10
-rw-r--r--contrib/libs/icu/i18n/nortrans.cpp12
-rw-r--r--contrib/libs/icu/i18n/number_affixutils.cpp3
-rw-r--r--contrib/libs/icu/i18n/number_asformat.h14
-rw-r--r--contrib/libs/icu/i18n/number_capi.cpp189
-rw-r--r--contrib/libs/icu/i18n/number_compact.cpp28
-rw-r--r--contrib/libs/icu/i18n/number_compact.h16
-rw-r--r--contrib/libs/icu/i18n/number_currencysymbols.cpp4
-rw-r--r--contrib/libs/icu/i18n/number_currencysymbols.h2
-rw-r--r--contrib/libs/icu/i18n/number_decimalquantity.cpp127
-rw-r--r--contrib/libs/icu/i18n/number_decimalquantity.h38
-rw-r--r--contrib/libs/icu/i18n/number_decimfmtprops.cpp2
-rw-r--r--contrib/libs/icu/i18n/number_fluent.cpp40
-rw-r--r--contrib/libs/icu/i18n/number_formatimpl.cpp86
-rw-r--r--contrib/libs/icu/i18n/number_formatimpl.h32
-rw-r--r--contrib/libs/icu/i18n/number_grouping.cpp2
-rw-r--r--contrib/libs/icu/i18n/number_longnames.cpp58
-rw-r--r--contrib/libs/icu/i18n/number_longnames.h10
-rw-r--r--contrib/libs/icu/i18n/number_mapper.cpp12
-rw-r--r--contrib/libs/icu/i18n/number_mapper.h40
-rw-r--r--contrib/libs/icu/i18n/number_microprops.h22
-rw-r--r--contrib/libs/icu/i18n/number_modifiers.cpp15
-rw-r--r--contrib/libs/icu/i18n/number_modifiers.h132
-rw-r--r--contrib/libs/icu/i18n/number_multiplier.cpp4
-rw-r--r--contrib/libs/icu/i18n/number_multiplier.h2
-rw-r--r--contrib/libs/icu/i18n/number_output.cpp7
-rw-r--r--contrib/libs/icu/i18n/number_patternmodifier.cpp34
-rw-r--r--contrib/libs/icu/i18n/number_patternmodifier.h27
-rw-r--r--contrib/libs/icu/i18n/number_patternstring.cpp23
-rw-r--r--contrib/libs/icu/i18n/number_patternstring.h30
-rw-r--r--contrib/libs/icu/i18n/number_rounding.cpp157
-rw-r--r--contrib/libs/icu/i18n/number_roundingutils.h9
-rw-r--r--contrib/libs/icu/i18n/number_scientific.h18
-rw-r--r--contrib/libs/icu/i18n/number_simple.cpp255
-rw-r--r--contrib/libs/icu/i18n/number_skeletons.cpp61
-rw-r--r--contrib/libs/icu/i18n/number_skeletons.h2
-rw-r--r--contrib/libs/icu/i18n/number_symbolswrapper.cpp4
-rw-r--r--contrib/libs/icu/i18n/number_usageprefs.cpp10
-rw-r--r--contrib/libs/icu/i18n/number_usageprefs.h4
-rw-r--r--contrib/libs/icu/i18n/number_utypes.h3
-rw-r--r--contrib/libs/icu/i18n/numfmt.cpp262
-rw-r--r--contrib/libs/icu/i18n/numparse_affixes.cpp20
-rw-r--r--contrib/libs/icu/i18n/numparse_affixes.h14
-rw-r--r--contrib/libs/icu/i18n/numparse_currency.h2
-rw-r--r--contrib/libs/icu/i18n/numparse_types.h6
-rw-r--r--contrib/libs/icu/i18n/numparse_utils.h4
-rw-r--r--contrib/libs/icu/i18n/numparse_validators.h26
-rw-r--r--contrib/libs/icu/i18n/numrange_capi.cpp5
-rw-r--r--contrib/libs/icu/i18n/numrange_fluent.cpp13
-rw-r--r--contrib/libs/icu/i18n/numrange_impl.cpp14
-rw-r--r--contrib/libs/icu/i18n/numsys.cpp27
-rw-r--r--contrib/libs/icu/i18n/numsys_impl.h4
-rw-r--r--contrib/libs/icu/i18n/olsontz.cpp205
-rw-r--r--contrib/libs/icu/i18n/olsontz.h24
-rw-r--r--contrib/libs/icu/i18n/persncal.cpp38
-rw-r--r--contrib/libs/icu/i18n/persncal.h28
-rw-r--r--contrib/libs/icu/i18n/pluralranges.cpp4
-rw-r--r--contrib/libs/icu/i18n/plurfmt.cpp78
-rw-r--r--contrib/libs/icu/i18n/plurrule.cpp228
-rw-r--r--contrib/libs/icu/i18n/plurrule_impl.h140
-rw-r--r--contrib/libs/icu/i18n/quant.cpp12
-rw-r--r--contrib/libs/icu/i18n/quantityformatter.cpp36
-rw-r--r--contrib/libs/icu/i18n/quantityformatter.h2
-rw-r--r--contrib/libs/icu/i18n/rbnf.cpp538
-rw-r--r--contrib/libs/icu/i18n/rbt.cpp20
-rw-r--r--contrib/libs/icu/i18n/rbt.h4
-rw-r--r--contrib/libs/icu/i18n/rbt_data.cpp12
-rw-r--r--contrib/libs/icu/i18n/rbt_data.h10
-rw-r--r--contrib/libs/icu/i18n/rbt_pars.cpp288
-rw-r--r--contrib/libs/icu/i18n/rbt_pars.h18
-rw-r--r--contrib/libs/icu/i18n/rbt_rule.cpp88
-rw-r--r--contrib/libs/icu/i18n/rbt_rule.h4
-rw-r--r--contrib/libs/icu/i18n/rbt_set.cpp93
-rw-r--r--contrib/libs/icu/i18n/rbt_set.h2
-rw-r--r--contrib/libs/icu/i18n/rbtz.cpp229
-rw-r--r--contrib/libs/icu/i18n/regexcmp.cpp308
-rw-r--r--contrib/libs/icu/i18n/regexcmp.h14
-rw-r--r--contrib/libs/icu/i18n/regexcst.h414
-rw-r--r--contrib/libs/icu/i18n/regeximp.cpp22
-rw-r--r--contrib/libs/icu/i18n/regeximp.h14
-rw-r--r--contrib/libs/icu/i18n/regexst.cpp20
-rw-r--r--contrib/libs/icu/i18n/regextxt.cpp8
-rw-r--r--contrib/libs/icu/i18n/region.cpp302
-rw-r--r--contrib/libs/icu/i18n/region_impl.h10
-rw-r--r--contrib/libs/icu/i18n/reldatefmt.cpp100
-rw-r--r--contrib/libs/icu/i18n/reldtfmt.cpp98
-rw-r--r--contrib/libs/icu/i18n/reldtfmt.h12
-rw-r--r--contrib/libs/icu/i18n/rematch.cpp816
-rw-r--r--contrib/libs/icu/i18n/remtrans.cpp10
-rw-r--r--contrib/libs/icu/i18n/repattrn.cpp146
-rw-r--r--contrib/libs/icu/i18n/rulebasedcollator.cpp205
-rw-r--r--contrib/libs/icu/i18n/scientificnumberformatter.cpp28
-rw-r--r--contrib/libs/icu/i18n/scriptset.cpp18
-rw-r--r--contrib/libs/icu/i18n/scriptset.h5
-rw-r--r--contrib/libs/icu/i18n/search.cpp76
-rw-r--r--contrib/libs/icu/i18n/selfmt.cpp8
-rw-r--r--contrib/libs/icu/i18n/selfmtimpl.h110
-rw-r--r--contrib/libs/icu/i18n/sharedbreakiterator.h4
-rw-r--r--contrib/libs/icu/i18n/sharedcalendar.h10
-rw-r--r--contrib/libs/icu/i18n/shareddateformatsymbols.h10
-rw-r--r--contrib/libs/icu/i18n/sharednumberformat.h9
-rw-r--r--contrib/libs/icu/i18n/sharedpluralrules.h9
-rw-r--r--contrib/libs/icu/i18n/simpletz.cpp124
-rw-r--r--contrib/libs/icu/i18n/smpdtfmt.cpp769
-rw-r--r--contrib/libs/icu/i18n/smpdtfst.cpp38
-rw-r--r--contrib/libs/icu/i18n/sortkey.cpp14
-rw-r--r--contrib/libs/icu/i18n/standardplural.cpp16
-rw-r--r--contrib/libs/icu/i18n/string_segment.cpp6
-rw-r--r--contrib/libs/icu/i18n/strmatch.cpp26
-rw-r--r--contrib/libs/icu/i18n/strrepl.cpp42
-rw-r--r--contrib/libs/icu/i18n/stsearch.cpp55
-rw-r--r--contrib/libs/icu/i18n/taiwncal.cpp4
-rw-r--r--contrib/libs/icu/i18n/taiwncal.h4
-rw-r--r--contrib/libs/icu/i18n/timezone.cpp351
-rw-r--r--contrib/libs/icu/i18n/titletrn.cpp10
-rw-r--r--contrib/libs/icu/i18n/tmunit.cpp4
-rw-r--r--contrib/libs/icu/i18n/tmutamt.cpp2
-rw-r--r--contrib/libs/icu/i18n/tmutfmt.cpp168
-rw-r--r--contrib/libs/icu/i18n/translit.cpp188
-rw-r--r--contrib/libs/icu/i18n/transreg.cpp116
-rw-r--r--contrib/libs/icu/i18n/transreg.h14
-rw-r--r--contrib/libs/icu/i18n/tridpars.cpp214
-rw-r--r--contrib/libs/icu/i18n/tzfmt.cpp497
-rw-r--r--contrib/libs/icu/i18n/tzgnames.cpp343
-rw-r--r--contrib/libs/icu/i18n/tznames.cpp104
-rw-r--r--contrib/libs/icu/i18n/tznames_impl.cpp695
-rw-r--r--contrib/libs/icu/i18n/tznames_impl.h24
-rw-r--r--contrib/libs/icu/i18n/tzrule.cpp110
-rw-r--r--contrib/libs/icu/i18n/tztrans.cpp36
-rw-r--r--contrib/libs/icu/i18n/ucal.cpp110
-rw-r--r--contrib/libs/icu/i18n/ucln_in.cpp6
-rw-r--r--contrib/libs/icu/i18n/ucol.cpp110
-rw-r--r--contrib/libs/icu/i18n/ucol_res.cpp152
-rw-r--r--contrib/libs/icu/i18n/ucol_sit.cpp34
-rw-r--r--contrib/libs/icu/i18n/ucoleitr.cpp46
-rw-r--r--contrib/libs/icu/i18n/ucsdet.cpp20
-rw-r--r--contrib/libs/icu/i18n/udat.cpp203
-rw-r--r--contrib/libs/icu/i18n/udateintervalformat.cpp26
-rw-r--r--contrib/libs/icu/i18n/udatpg.cpp123
-rw-r--r--contrib/libs/icu/i18n/ufieldpositer.cpp4
-rw-r--r--contrib/libs/icu/i18n/uitercollationiterator.cpp26
-rw-r--r--contrib/libs/icu/i18n/uitercollationiterator.h4
-rw-r--r--contrib/libs/icu/i18n/ulistformatter.cpp28
-rw-r--r--contrib/libs/icu/i18n/ulocdata.cpp89
-rw-r--r--contrib/libs/icu/i18n/umsg.cpp118
-rw-r--r--contrib/libs/icu/i18n/unesctrn.cpp44
-rw-r--r--contrib/libs/icu/i18n/unesctrn.h4
-rw-r--r--contrib/libs/icu/i18n/uni2name.cpp10
-rw-r--r--contrib/libs/icu/i18n/units_complexconverter.cpp15
-rw-r--r--contrib/libs/icu/i18n/units_complexconverter.h4
-rw-r--r--contrib/libs/icu/i18n/units_converter.cpp17
-rw-r--r--contrib/libs/icu/i18n/units_converter.h6
-rw-r--r--contrib/libs/icu/i18n/units_data.cpp116
-rw-r--r--contrib/libs/icu/i18n/units_data.h16
-rw-r--r--contrib/libs/icu/i18n/units_router.cpp29
-rw-r--r--contrib/libs/icu/i18n/units_router.h10
-rw-r--r--contrib/libs/icu/i18n/unum.cpp217
-rw-r--r--contrib/libs/icu/i18n/unumsys.cpp4
-rw-r--r--contrib/libs/icu/i18n/upluralrules.cpp30
-rw-r--r--contrib/libs/icu/i18n/uregex.cpp376
-rw-r--r--contrib/libs/icu/i18n/uregexc.cpp6
-rw-r--r--contrib/libs/icu/i18n/usearch.cpp240
-rw-r--r--contrib/libs/icu/i18n/uspoof.cpp173
-rw-r--r--contrib/libs/icu/i18n/uspoof_build.cpp22
-rw-r--r--contrib/libs/icu/i18n/uspoof_conf.cpp99
-rw-r--r--contrib/libs/icu/i18n/uspoof_conf.h13
-rw-r--r--contrib/libs/icu/i18n/uspoof_impl.cpp104
-rw-r--r--contrib/libs/icu/i18n/uspoof_impl.h13
-rw-r--r--contrib/libs/icu/i18n/utf16collationiterator.cpp70
-rw-r--r--contrib/libs/icu/i18n/utf16collationiterator.h34
-rw-r--r--contrib/libs/icu/i18n/utf8collationiterator.cpp34
-rw-r--r--contrib/libs/icu/i18n/utf8collationiterator.h2
-rw-r--r--contrib/libs/icu/i18n/utmscale.cpp12
-rw-r--r--contrib/libs/icu/i18n/utrans.cpp114
-rw-r--r--contrib/libs/icu/i18n/vtzone.cpp611
-rw-r--r--contrib/libs/icu/i18n/vzone.cpp20
-rw-r--r--contrib/libs/icu/i18n/vzone.h2
-rw-r--r--contrib/libs/icu/i18n/windtfmt.cpp42
-rw-r--r--contrib/libs/icu/i18n/windtfmt.h4
-rw-r--r--contrib/libs/icu/i18n/winnmfmt.cpp28
-rw-r--r--contrib/libs/icu/i18n/winnmfmt.h4
-rw-r--r--contrib/libs/icu/i18n/wintzimpl.cpp24
-rw-r--r--contrib/libs/icu/i18n/zonemeta.cpp392
-rw-r--r--contrib/libs/icu/i18n/zonemeta.h30
-rw-r--r--contrib/libs/icu/i18n/zrule.cpp8
-rw-r--r--contrib/libs/icu/i18n/zrule.h4
-rw-r--r--contrib/libs/icu/i18n/ztrans.h4
323 files changed, 13644 insertions, 10869 deletions
diff --git a/contrib/libs/icu/i18n/alphaindex.cpp b/contrib/libs/icu/i18n/alphaindex.cpp
index 34407f677a..1b49d3b544 100644
--- a/contrib/libs/icu/i18n/alphaindex.cpp
+++ b/contrib/libs/icu/i18n/alphaindex.cpp
@@ -40,7 +40,7 @@ namespace {
* Prefix string for Chinese index buckets.
* See http://unicode.org/repos/cldr/trunk/specs/ldml/tr35-collation.html#Collation_Indexes
*/
-const UChar BASE[1] = { 0xFDD0 };
+const char16_t BASE[1] = { 0xFDD0 };
const int32_t BASE_LENGTH = 1;
UBool isOneLabelBetterThanOther(const Normalizer2 &nfkdNormalizer,
@@ -64,12 +64,12 @@ namespace {
UnicodeString *ownedString(const UnicodeString &s, LocalPointer<UnicodeString> &owned,
UErrorCode &errorCode) {
- if (U_FAILURE(errorCode)) { return NULL; }
+ if (U_FAILURE(errorCode)) { return nullptr; }
if (owned.isValid()) {
return owned.orphan();
}
UnicodeString *p = new UnicodeString(s);
- if (p == NULL) {
+ if (p == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
}
return p;
@@ -158,7 +158,7 @@ public:
}
}
const AlphabeticIndex::Bucket *bucket = getBucket(*bucketList_, start);
- if (bucket->displayBucket_ != NULL) {
+ if (bucket->displayBucket_ != nullptr) {
bucket = bucket->displayBucket_;
}
return bucket->displayIndex_;
@@ -198,29 +198,29 @@ AlphabeticIndex::ImmutableIndex::getBucket(int32_t index) const {
if (0 <= index && index < buckets_->getBucketCount()) {
return icu::getBucket(*buckets_->immutableVisibleList_, index);
} else {
- return NULL;
+ return nullptr;
}
}
AlphabeticIndex::AlphabeticIndex(const Locale &locale, UErrorCode &status)
- : inputList_(NULL),
- labelsIterIndex_(-1), itemsIterIndex_(0), currentBucket_(NULL),
+ : inputList_(nullptr),
+ labelsIterIndex_(-1), itemsIterIndex_(0), currentBucket_(nullptr),
maxLabelCount_(99),
- initialLabels_(NULL), firstCharsInScripts_(NULL),
- collator_(NULL), collatorPrimaryOnly_(NULL),
- buckets_(NULL) {
+ initialLabels_(nullptr), firstCharsInScripts_(nullptr),
+ collator_(nullptr), collatorPrimaryOnly_(nullptr),
+ buckets_(nullptr) {
init(&locale, status);
}
AlphabeticIndex::AlphabeticIndex(RuleBasedCollator *collator, UErrorCode &status)
- : inputList_(NULL),
- labelsIterIndex_(-1), itemsIterIndex_(0), currentBucket_(NULL),
+ : inputList_(nullptr),
+ labelsIterIndex_(-1), itemsIterIndex_(0), currentBucket_(nullptr),
maxLabelCount_(99),
- initialLabels_(NULL), firstCharsInScripts_(NULL),
- collator_(collator), collatorPrimaryOnly_(NULL),
- buckets_(NULL) {
- init(NULL, status);
+ initialLabels_(nullptr), firstCharsInScripts_(nullptr),
+ collator_(collator), collatorPrimaryOnly_(nullptr),
+ buckets_(nullptr) {
+ init(nullptr, status);
}
@@ -253,22 +253,22 @@ AlphabeticIndex &AlphabeticIndex::addLabels(const Locale &locale, UErrorCode &st
AlphabeticIndex::ImmutableIndex *AlphabeticIndex::buildImmutableIndex(UErrorCode &errorCode) {
- if (U_FAILURE(errorCode)) { return NULL; }
+ if (U_FAILURE(errorCode)) { return nullptr; }
// In C++, the ImmutableIndex must own its copy of the BucketList,
// even if it contains no records, for proper memory management.
- // We could clone the buckets_ if they are not NULL,
+ // We could clone the buckets_ if they are not nullptr,
// but that would be worth it only if this method is called multiple times,
// or called after using the old-style bucket iterator API.
LocalPointer<BucketList> immutableBucketList(createBucketList(errorCode));
LocalPointer<RuleBasedCollator> coll(collatorPrimaryOnly_->clone());
if (immutableBucketList.isNull() || coll.isNull()) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
ImmutableIndex *immIndex = new ImmutableIndex(immutableBucketList.getAlias(), coll.getAlias());
- if (immIndex == NULL) {
+ if (immIndex == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
// The ImmutableIndex adopted its parameter objects.
immutableBucketList.orphan();
@@ -286,7 +286,7 @@ int32_t AlphabeticIndex::getBucketCount(UErrorCode &status) {
int32_t AlphabeticIndex::getRecordCount(UErrorCode &status) {
- if (U_FAILURE(status) || inputList_ == NULL) {
+ if (U_FAILURE(status) || inputList_ == nullptr) {
return 0;
}
return inputList_->size();
@@ -312,20 +312,20 @@ void AlphabeticIndex::initLabels(UVector &indexCharacters, UErrorCode &errorCode
UBool checkDistinct;
int32_t itemLength = item->length();
if (!item->hasMoreChar32Than(0, itemLength, 1)) {
- checkDistinct = FALSE;
+ checkDistinct = false;
} else if(item->charAt(itemLength - 1) == 0x2a && // '*'
item->charAt(itemLength - 2) != 0x2a) {
// Use a label if it is marked with one trailing star,
// even if the label string sorts the same when all contractions are suppressed.
ownedItem.adoptInstead(new UnicodeString(*item, 0, itemLength - 1));
item = ownedItem.getAlias();
- if (item == NULL) {
+ if (item == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
- checkDistinct = FALSE;
+ checkDistinct = false;
} else {
- checkDistinct = TRUE;
+ checkDistinct = true;
}
if (collatorPrimaryOnly_->compare(*item, firstScriptBoundary, errorCode) < 0) {
// Ignore a primary-ignorable or non-alphabetic index character.
@@ -376,19 +376,19 @@ const UnicodeString &fixLabel(const UnicodeString &current, UnicodeString &temp)
if (!current.startsWith(BASE, BASE_LENGTH)) {
return current;
}
- UChar rest = current.charAt(BASE_LENGTH);
+ char16_t rest = current.charAt(BASE_LENGTH);
if (0x2800 < rest && rest <= 0x28FF) { // stroke count
int32_t count = rest-0x2800;
- temp.setTo((UChar)(0x30 + count % 10));
+ temp.setTo((char16_t)(0x30 + count % 10));
if (count >= 10) {
count /= 10;
- temp.insert(0, (UChar)(0x30 + count % 10));
+ temp.insert(0, (char16_t)(0x30 + count % 10));
if (count >= 10) {
count /= 10;
- temp.insert(0, (UChar)(0x30 + count));
+ temp.insert(0, (char16_t)(0x30 + count));
}
}
- return temp.append((UChar)0x5283);
+ return temp.append((char16_t)0x5283);
}
return temp.setTo(current, BASE_LENGTH);
}
@@ -398,20 +398,20 @@ UBool hasMultiplePrimaryWeights(
const UnicodeString &s, UVector64 &ces, UErrorCode &errorCode) {
ces.removeAllElements();
coll.internalGetCEs(s, ces, errorCode);
- if (U_FAILURE(errorCode)) { return FALSE; }
- UBool seenPrimary = FALSE;
+ if (U_FAILURE(errorCode)) { return false; }
+ UBool seenPrimary = false;
for (int32_t i = 0; i < ces.size(); ++i) {
int64_t ce = ces.elementAti(i);
uint32_t p = (uint32_t)(ce >> 32);
if (p > variableTop) {
// not primary ignorable
if (seenPrimary) {
- return TRUE;
+ return true;
}
- seenPrimary = TRUE;
+ seenPrimary = true;
}
}
- return FALSE;
+ return false;
}
} // namespace
@@ -421,7 +421,7 @@ BucketList *AlphabeticIndex::createBucketList(UErrorCode &errorCode) const {
UVector indexCharacters(errorCode);
indexCharacters.setDeleter(uprv_deleteUObject);
initLabels(indexCharacters, errorCode);
- if (U_FAILURE(errorCode)) { return NULL; }
+ if (U_FAILURE(errorCode)) { return nullptr; }
// Variables for hasMultiplePrimaryWeights().
UVector64 ces(errorCode);
@@ -431,33 +431,32 @@ BucketList *AlphabeticIndex::createBucketList(UErrorCode &errorCode) const {
} else {
variableTop = 0;
}
- UBool hasInvisibleBuckets = FALSE;
+ UBool hasInvisibleBuckets = false;
// Helper arrays for Chinese Pinyin collation.
Bucket *asciiBuckets[26] = {
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr
};
Bucket *pinyinBuckets[26] = {
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr
};
- UBool hasPinyin = FALSE;
+ UBool hasPinyin = false;
LocalPointer<UVector> bucketList(new UVector(errorCode), errorCode);
if (U_FAILURE(errorCode)) {
- return NULL;
+ return nullptr;
}
bucketList->setDeleter(uprv_deleteUObject);
// underflow bucket
- Bucket *bucket = new Bucket(getUnderflowLabel(), emptyString_, U_ALPHAINDEX_UNDERFLOW);
- if (bucket == NULL) {
- errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ LocalPointer<Bucket> bucket(new Bucket(getUnderflowLabel(), emptyString_, U_ALPHAINDEX_UNDERFLOW), errorCode);
+ if (U_FAILURE(errorCode)) {
+ return nullptr;
}
- bucketList->addElementX(bucket, errorCode);
- if (U_FAILURE(errorCode)) { return NULL; }
+ bucketList->adoptElement(bucket.orphan(), errorCode);
+ if (U_FAILURE(errorCode)) { return nullptr; }
UnicodeString temp;
@@ -470,40 +469,36 @@ BucketList *AlphabeticIndex::createBucketList(UErrorCode &errorCode) const {
if (collatorPrimaryOnly_->compare(current, *scriptUpperBoundary, errorCode) >= 0) {
// We crossed the script boundary into a new script.
const UnicodeString &inflowBoundary = *scriptUpperBoundary;
- UBool skippedScript = FALSE;
+ UBool skippedScript = false;
for (;;) {
scriptUpperBoundary = getString(*firstCharsInScripts_, ++scriptIndex);
if (collatorPrimaryOnly_->compare(current, *scriptUpperBoundary, errorCode) < 0) {
break;
}
- skippedScript = TRUE;
+ skippedScript = true;
}
if (skippedScript && bucketList->size() > 1) {
// We are skipping one or more scripts,
// and we are not just getting out of the underflow label.
- bucket = new Bucket(getInflowLabel(), inflowBoundary, U_ALPHAINDEX_INFLOW);
- if (bucket == NULL) {
- errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
- }
- bucketList->addElementX(bucket, errorCode);
+ bucket.adoptInsteadAndCheckErrorCode(
+ new Bucket(getInflowLabel(), inflowBoundary, U_ALPHAINDEX_INFLOW), errorCode);
+ bucketList->adoptElement(bucket.orphan(), errorCode);
+ if (U_FAILURE(errorCode)) { return nullptr; }
}
}
// Add a bucket with the current label.
- bucket = new Bucket(fixLabel(current, temp), current, U_ALPHAINDEX_NORMAL);
- if (bucket == NULL) {
- errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
- }
- bucketList->addElementX(bucket, errorCode);
+ bucket.adoptInsteadAndCheckErrorCode(
+ new Bucket(fixLabel(current, temp), current, U_ALPHAINDEX_NORMAL), errorCode);
+ bucketList->adoptElement(bucket.orphan(), errorCode);
+ if (U_FAILURE(errorCode)) { return nullptr; }
// Remember ASCII and Pinyin buckets for Pinyin redirects.
- UChar c;
+ char16_t c;
if (current.length() == 1 && 0x41 <= (c = current.charAt(0)) && c <= 0x5A) { // A-Z
- asciiBuckets[c - 0x41] = bucket;
+ asciiBuckets[c - 0x41] = (Bucket *)bucketList->lastElement();
} else if (current.length() == BASE_LENGTH + 1 && current.startsWith(BASE, BASE_LENGTH) &&
0x41 <= (c = current.charAt(BASE_LENGTH)) && c <= 0x5A) {
- pinyinBuckets[c - 0x41] = bucket;
- hasPinyin = TRUE;
+ pinyinBuckets[c - 0x41] = (Bucket *)bucketList->lastElement();
+ hasPinyin = true;
}
// Check for multiple primary weights.
if (!current.startsWith(BASE, BASE_LENGTH) &&
@@ -518,7 +513,7 @@ BucketList *AlphabeticIndex::createBucketList(UErrorCode &errorCode) const {
// underflow or inflow label.
break;
}
- if (singleBucket->displayBucket_ == NULL &&
+ if (singleBucket->displayBucket_ == nullptr &&
!hasMultiplePrimaryWeights(*collatorPrimaryOnly_, variableTop,
singleBucket->lowerBoundary_,
ces, errorCode)) {
@@ -526,60 +521,59 @@ BucketList *AlphabeticIndex::createBucketList(UErrorCode &errorCode) const {
// to the previous single-character bucket.
// For example, after ... Q R S Sch we add Sch\uFFFF->S
// and after ... Q R S Sch Sch\uFFFF St we add St\uFFFF->S.
- bucket = new Bucket(emptyString_,
- UnicodeString(current).append((UChar)0xFFFF),
- U_ALPHAINDEX_NORMAL);
- if (bucket == NULL) {
- errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ bucket.adoptInsteadAndCheckErrorCode(new Bucket(emptyString_,
+ UnicodeString(current).append((char16_t)0xFFFF),
+ U_ALPHAINDEX_NORMAL),
+ errorCode);
+ if (U_FAILURE(errorCode)) {
+ return nullptr;
}
bucket->displayBucket_ = singleBucket;
- bucketList->addElementX(bucket, errorCode);
- hasInvisibleBuckets = TRUE;
+ bucketList->adoptElement(bucket.orphan(), errorCode);
+ if (U_FAILURE(errorCode)) { return nullptr; }
+ hasInvisibleBuckets = true;
break;
}
}
}
}
- if (U_FAILURE(errorCode)) { return NULL; }
+ if (U_FAILURE(errorCode)) { return nullptr; }
if (bucketList->size() == 1) {
// No real labels, show only the underflow label.
BucketList *bl = new BucketList(bucketList.getAlias(), bucketList.getAlias());
- if (bl == NULL) {
+ if (bl == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
bucketList.orphan();
return bl;
}
// overflow bucket
- bucket = new Bucket(getOverflowLabel(), *scriptUpperBoundary, U_ALPHAINDEX_OVERFLOW);
- if (bucket == NULL) {
- errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
- }
- bucketList->addElementX(bucket, errorCode); // final
+ bucket.adoptInsteadAndCheckErrorCode(
+ new Bucket(getOverflowLabel(), *scriptUpperBoundary, U_ALPHAINDEX_OVERFLOW), errorCode);
+ bucketList->adoptElement(bucket.orphan(), errorCode); // final
+ if (U_FAILURE(errorCode)) { return nullptr; }
if (hasPinyin) {
// Redirect Pinyin buckets.
- Bucket *asciiBucket = NULL;
+ Bucket *asciiBucket = nullptr;
for (int32_t i = 0; i < 26; ++i) {
- if (asciiBuckets[i] != NULL) {
+ if (asciiBuckets[i] != nullptr) {
asciiBucket = asciiBuckets[i];
}
- if (pinyinBuckets[i] != NULL && asciiBucket != NULL) {
+ if (pinyinBuckets[i] != nullptr && asciiBucket != nullptr) {
pinyinBuckets[i]->displayBucket_ = asciiBucket;
- hasInvisibleBuckets = TRUE;
+ hasInvisibleBuckets = true;
}
}
}
- if (U_FAILURE(errorCode)) { return NULL; }
+ if (U_FAILURE(errorCode)) { return nullptr; }
if (!hasInvisibleBuckets) {
BucketList *bl = new BucketList(bucketList.getAlias(), bucketList.getAlias());
- if (bl == NULL) {
+ if (bl == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
bucketList.orphan();
return bl;
@@ -589,8 +583,8 @@ BucketList *AlphabeticIndex::createBucketList(UErrorCode &errorCode) const {
int32_t i = bucketList->size() - 1;
Bucket *nextBucket = getBucket(*bucketList, i);
while (--i > 0) {
- bucket = getBucket(*bucketList, i);
- if (bucket->displayBucket_ != NULL) {
+ Bucket *bucket = getBucket(*bucketList, i);
+ if (bucket->displayBucket_ != nullptr) {
continue; // skip invisible buckets
}
if (bucket->labelType_ == U_ALPHAINDEX_INFLOW) {
@@ -604,21 +598,21 @@ BucketList *AlphabeticIndex::createBucketList(UErrorCode &errorCode) const {
LocalPointer<UVector> publicBucketList(new UVector(errorCode), errorCode);
if (U_FAILURE(errorCode)) {
- return NULL;
+ return nullptr;
}
// Do not call publicBucketList->setDeleter():
// This vector shares its objects with the bucketList.
for (int32_t j = 0; j < bucketList->size(); ++j) {
- bucket = getBucket(*bucketList, j);
- if (bucket->displayBucket_ == NULL) {
- publicBucketList->addElementX(bucket, errorCode);
+ Bucket *bucket = getBucket(*bucketList, j);
+ if (bucket->displayBucket_ == nullptr) {
+ publicBucketList->addElement(bucket, errorCode);
}
}
- if (U_FAILURE(errorCode)) { return NULL; }
+ if (U_FAILURE(errorCode)) { return nullptr; }
BucketList *bl = new BucketList(bucketList.getAlias(), publicBucketList.getAlias());
- if (bl == NULL) {
+ if (bl == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
bucketList.orphan();
publicBucketList.orphan();
@@ -629,11 +623,11 @@ BucketList *AlphabeticIndex::createBucketList(UErrorCode &errorCode) const {
* Creates an index, and buckets and sorts the list of records into the index.
*/
void AlphabeticIndex::initBuckets(UErrorCode &errorCode) {
- if (U_FAILURE(errorCode) || buckets_ != NULL) {
+ if (U_FAILURE(errorCode) || buckets_ != nullptr) {
return;
}
buckets_ = createBucketList(errorCode);
- if (U_FAILURE(errorCode) || inputList_ == NULL || inputList_->isEmpty()) {
+ if (U_FAILURE(errorCode) || inputList_ == nullptr || inputList_->isEmpty()) {
return;
}
@@ -655,14 +649,14 @@ void AlphabeticIndex::initBuckets(UErrorCode &errorCode) {
nextBucket = getBucket(*buckets_->bucketList_, bucketIndex++);
upperBoundary = &nextBucket->lowerBoundary_;
} else {
- nextBucket = NULL;
- upperBoundary = NULL;
+ nextBucket = nullptr;
+ upperBoundary = nullptr;
}
for (int32_t i = 0; i < inputList_->size(); ++i) {
Record *r = getRecord(*inputList_, i);
// if the current bucket isn't the right one, find the one that is
// We have a special flag for the last bucket so that we don't look any further
- while (upperBoundary != NULL &&
+ while (upperBoundary != nullptr &&
collatorPrimaryOnly_->compare(r->name_, *upperBoundary, errorCode) >= 0) {
currentBucket = nextBucket;
// now reset the boundary that we compare against
@@ -670,36 +664,36 @@ void AlphabeticIndex::initBuckets(UErrorCode &errorCode) {
nextBucket = getBucket(*buckets_->bucketList_, bucketIndex++);
upperBoundary = &nextBucket->lowerBoundary_;
} else {
- upperBoundary = NULL;
+ upperBoundary = nullptr;
}
}
// now put the record into the bucket.
Bucket *bucket = currentBucket;
- if (bucket->displayBucket_ != NULL) {
+ if (bucket->displayBucket_ != nullptr) {
bucket = bucket->displayBucket_;
}
- if (bucket->records_ == NULL) {
- bucket->records_ = new UVector(errorCode);
- if (bucket->records_ == NULL) {
- errorCode = U_MEMORY_ALLOCATION_ERROR;
+ if (bucket->records_ == nullptr) {
+ LocalPointer<UVector> records(new UVector(errorCode), errorCode);
+ if (U_FAILURE(errorCode)) {
return;
}
+ bucket->records_ = records.orphan();
}
- bucket->records_->addElementX(r, errorCode);
+ bucket->records_->addElement(r, errorCode);
}
}
void AlphabeticIndex::clearBuckets() {
- if (buckets_ != NULL) {
+ if (buckets_ != nullptr) {
delete buckets_;
- buckets_ = NULL;
+ buckets_ = nullptr;
internalResetBucketIterator();
}
}
void AlphabeticIndex::internalResetBucketIterator() {
labelsIterIndex_ = -1;
- currentBucket_ = NULL;
+ currentBucket_ = nullptr;
}
@@ -760,27 +754,27 @@ void AlphabeticIndex::addIndexExemplars(const Locale &locale, UErrorCode &status
UBool AlphabeticIndex::addChineseIndexCharacters(UErrorCode &errorCode) {
UnicodeSet contractions;
collatorPrimaryOnly_->internalAddContractions(BASE[0], contractions, errorCode);
- if (U_FAILURE(errorCode) || contractions.isEmpty()) { return FALSE; }
+ if (U_FAILURE(errorCode) || contractions.isEmpty()) { return false; }
initialLabels_->addAll(contractions);
UnicodeSetIterator iter(contractions);
while (iter.next()) {
const UnicodeString &s = iter.getString();
U_ASSERT (s.startsWith(BASE, BASE_LENGTH));
- UChar c = s.charAt(s.length() - 1);
+ char16_t c = s.charAt(s.length() - 1);
if (0x41 <= c && c <= 0x5A) { // A-Z
// There are Pinyin labels, add ASCII A-Z labels as well.
initialLabels_->add(0x41, 0x5A); // A-Z
break;
}
}
- return TRUE;
+ return true;
}
/*
* Return the string with interspersed CGJs. Input must have more than 2 codepoints.
*/
-static const UChar CGJ = 0x034F;
+static const char16_t CGJ = 0x034F;
UnicodeString AlphabeticIndex::separated(const UnicodeString &item) {
UnicodeString result;
if (item.length() == 0) {
@@ -875,40 +869,40 @@ AlphabeticIndex &AlphabeticIndex::setMaxLabelCount(int32_t maxLabelCount, UError
void AlphabeticIndex::init(const Locale *locale, UErrorCode &status) {
if (U_FAILURE(status)) { return; }
- if (locale == NULL && collator_ == NULL) {
+ if (locale == nullptr && collator_ == nullptr) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
initialLabels_ = new UnicodeSet();
- if (initialLabels_ == NULL) {
+ if (initialLabels_ == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
- inflowLabel_.setTo((UChar)0x2026); // Ellipsis
+ inflowLabel_.setTo((char16_t)0x2026); // Ellipsis
overflowLabel_ = inflowLabel_;
underflowLabel_ = inflowLabel_;
- if (collator_ == NULL) {
+ if (collator_ == nullptr) {
Collator *coll = Collator::createInstance(*locale, status);
if (U_FAILURE(status)) {
delete coll;
return;
}
- if (coll == NULL) {
+ if (coll == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
collator_ = dynamic_cast<RuleBasedCollator *>(coll);
- if (collator_ == NULL) {
+ if (collator_ == nullptr) {
delete coll;
status = U_UNSUPPORTED_ERROR;
return;
}
}
collatorPrimaryOnly_ = collator_->clone();
- if (collatorPrimaryOnly_ == NULL) {
+ if (collatorPrimaryOnly_ == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -936,7 +930,7 @@ void AlphabeticIndex::init(const Locale *locale, UErrorCode &status) {
// Chinese index characters, which are specific to each of the several Chinese tailorings,
// take precedence over the single locale data exemplar set per language.
- if (!addChineseIndexCharacters(status) && locale != NULL) {
+ if (!addChineseIndexCharacters(status) && locale != nullptr) {
addIndexExemplars(*locale, status);
}
}
@@ -953,13 +947,13 @@ collatorComparator(const void *context, const void *left, const void *right) {
const UnicodeString *rightString = static_cast<const UnicodeString *>(rightElement->pointer);
if (leftString == rightString) {
- // Catches case where both are NULL
+ // Catches case where both are nullptr
return 0;
}
- if (leftString == NULL) {
+ if (leftString == nullptr) {
return 1;
}
- if (rightString == NULL) {
+ if (rightString == nullptr) {
return -1;
}
const Collator *col = static_cast<const Collator *>(context);
@@ -983,11 +977,11 @@ recordCompareFn(const void *context, const void *left, const void *right) {
UVector *AlphabeticIndex::firstStringsInScript(UErrorCode &status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
LocalPointer<UVector> dest(new UVector(status), status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
dest->setDeleter(uprv_deleteUObject);
// Fetch the script-first-primary contractions which are defined in the root collator.
@@ -995,11 +989,11 @@ UVector *AlphabeticIndex::firstStringsInScript(UErrorCode &status) {
UnicodeSet set;
collatorPrimaryOnly_->internalAddContractions(0xFDD1, set, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
if (set.isEmpty()) {
status = U_UNSUPPORTED_ERROR;
- return NULL;
+ return nullptr;
}
UnicodeSetIterator iter(set);
while (iter.next()) {
@@ -1011,12 +1005,11 @@ UVector *AlphabeticIndex::firstStringsInScript(UErrorCode &status) {
// and the one for unassigned implicit weights (Cn).
continue;
}
- UnicodeString *s = new UnicodeString(boundary);
- if (s == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ LocalPointer<UnicodeString> s(new UnicodeString(boundary), status);
+ dest->adoptElement(s.orphan(), status);
+ if (U_FAILURE(status)) {
+ return nullptr;
}
- dest->addElementX(s, status);
}
return dest.orphan();
}
@@ -1035,7 +1028,7 @@ UBool isOneLabelBetterThanOther(const Normalizer2 &nfkdNormalizer,
UErrorCode status = U_ZERO_ERROR;
UnicodeString n1 = nfkdNormalizer.normalize(one, status);
UnicodeString n2 = nfkdNormalizer.normalize(other, status);
- if (U_FAILURE(status)) { return FALSE; }
+ if (U_FAILURE(status)) { return false; }
int32_t result = n1.countChar32() - n2.countChar32();
if (result != 0) {
return result < 0;
@@ -1066,20 +1059,19 @@ AlphabeticIndex & AlphabeticIndex::addRecord(const UnicodeString &name, const vo
if (U_FAILURE(status)) {
return *this;
}
- if (inputList_ == NULL) {
- inputList_ = new UVector(status);
- if (inputList_ == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
+ if (inputList_ == nullptr) {
+ LocalPointer<UVector> inputList(new UVector(status), status);
+ if (U_FAILURE(status)) {
return *this;
}
+ inputList_ = inputList.orphan();
inputList_->setDeleter(alphaIndex_deleteRecord);
}
- Record *r = new Record(name, data);
- if (r == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
+ LocalPointer<Record> r(new Record(name, data), status);
+ inputList_->adoptElement(r.orphan(), status);
+ if (U_FAILURE(status)) {
return *this;
}
- inputList_->addElementX(r, status);
clearBuckets();
//std::string ss;
//std::string ss2;
@@ -1090,7 +1082,7 @@ AlphabeticIndex & AlphabeticIndex::addRecord(const UnicodeString &name, const vo
AlphabeticIndex &AlphabeticIndex::clearRecords(UErrorCode &status) {
- if (U_SUCCESS(status) && inputList_ != NULL && !inputList_->isEmpty()) {
+ if (U_SUCCESS(status) && inputList_ != nullptr && !inputList_->isEmpty()) {
inputList_->removeAllElements();
clearBuckets();
}
@@ -1113,28 +1105,28 @@ int32_t AlphabeticIndex::getBucketIndex() const {
UBool AlphabeticIndex::nextBucket(UErrorCode &status) {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
- if (buckets_ == NULL && currentBucket_ != NULL) {
+ if (buckets_ == nullptr && currentBucket_ != nullptr) {
status = U_ENUM_OUT_OF_SYNC_ERROR;
- return FALSE;
+ return false;
}
initBuckets(status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
++labelsIterIndex_;
if (labelsIterIndex_ >= buckets_->getBucketCount()) {
labelsIterIndex_ = buckets_->getBucketCount();
- return FALSE;
+ return false;
}
currentBucket_ = getBucket(*buckets_->immutableVisibleList_, labelsIterIndex_);
resetRecordIterator();
- return TRUE;
+ return true;
}
const UnicodeString &AlphabeticIndex::getBucketLabel() const {
- if (currentBucket_ != NULL) {
+ if (currentBucket_ != nullptr) {
return currentBucket_->label_;
} else {
return emptyString_;
@@ -1143,7 +1135,7 @@ const UnicodeString &AlphabeticIndex::getBucketLabel() const {
UAlphabeticIndexLabelType AlphabeticIndex::getBucketLabelType() const {
- if (currentBucket_ != NULL) {
+ if (currentBucket_ != nullptr) {
return currentBucket_->labelType_;
} else {
return U_ALPHAINDEX_NORMAL;
@@ -1152,7 +1144,7 @@ UAlphabeticIndexLabelType AlphabeticIndex::getBucketLabelType() const {
int32_t AlphabeticIndex::getBucketRecordCount() const {
- if (currentBucket_ != NULL && currentBucket_->records_ != NULL) {
+ if (currentBucket_ != nullptr && currentBucket_->records_ != nullptr) {
return currentBucket_->records_->size();
} else {
return 0;
@@ -1171,33 +1163,33 @@ AlphabeticIndex &AlphabeticIndex::resetBucketIterator(UErrorCode &status) {
UBool AlphabeticIndex::nextRecord(UErrorCode &status) {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
- if (currentBucket_ == NULL) {
+ if (currentBucket_ == nullptr) {
// We are trying to iterate over the items in a bucket, but there is no
// current bucket from the enumeration of buckets.
status = U_INVALID_STATE_ERROR;
- return FALSE;
+ return false;
}
- if (buckets_ == NULL) {
+ if (buckets_ == nullptr) {
status = U_ENUM_OUT_OF_SYNC_ERROR;
- return FALSE;
+ return false;
}
- if (currentBucket_->records_ == NULL) {
- return FALSE;
+ if (currentBucket_->records_ == nullptr) {
+ return false;
}
++itemsIterIndex_;
if (itemsIterIndex_ >= currentBucket_->records_->size()) {
itemsIterIndex_ = currentBucket_->records_->size();
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
const UnicodeString &AlphabeticIndex::getRecordName() const {
const UnicodeString *retStr = &emptyString_;
- if (currentBucket_ != NULL && currentBucket_->records_ != NULL &&
+ if (currentBucket_ != nullptr && currentBucket_->records_ != nullptr &&
itemsIterIndex_ >= 0 &&
itemsIterIndex_ < currentBucket_->records_->size()) {
Record *item = static_cast<Record *>(currentBucket_->records_->elementAt(itemsIterIndex_));
@@ -1207,8 +1199,8 @@ const UnicodeString &AlphabeticIndex::getRecordName() const {
}
const void *AlphabeticIndex::getRecordData() const {
- const void *retPtr = NULL;
- if (currentBucket_ != NULL && currentBucket_->records_ != NULL &&
+ const void *retPtr = nullptr;
+ if (currentBucket_ != nullptr && currentBucket_->records_ != nullptr &&
itemsIterIndex_ >= 0 &&
itemsIterIndex_ < currentBucket_->records_->size()) {
Record *item = static_cast<Record *>(currentBucket_->records_->elementAt(itemsIterIndex_));
@@ -1229,8 +1221,8 @@ AlphabeticIndex::Bucket::Bucket(const UnicodeString &label,
const UnicodeString &lowerBoundary,
UAlphabeticIndexLabelType type)
: label_(label), lowerBoundary_(lowerBoundary), labelType_(type),
- displayBucket_(NULL), displayIndex_(-1),
- records_(NULL) {
+ displayBucket_(nullptr), displayIndex_(-1),
+ records_(nullptr) {
}
diff --git a/contrib/libs/icu/i18n/anytrans.cpp b/contrib/libs/icu/i18n/anytrans.cpp
index 167b018528..4972b68733 100644
--- a/contrib/libs/icu/i18n/anytrans.cpp
+++ b/contrib/libs/icu/i18n/anytrans.cpp
@@ -29,11 +29,11 @@
//------------------------------------------------------------
// Constants
-static const UChar TARGET_SEP = 45; // '-'
-static const UChar VARIANT_SEP = 47; // '/'
-static const UChar ANY[] = {0x41,0x6E,0x79,0}; // "Any"
-static const UChar NULL_ID[] = {78,117,108,108,0}; // "Null"
-static const UChar LATIN_PIVOT[] = {0x2D,0x4C,0x61,0x74,0x6E,0x3B,0x4C,0x61,0x74,0x6E,0x2D,0}; // "-Latn;Latn-"
+static const char16_t TARGET_SEP = 45; // '-'
+static const char16_t VARIANT_SEP = 47; // '/'
+static const char16_t ANY[] = {0x41,0x6E,0x79,0}; // "Any"
+static const char16_t NULL_ID[] = {78,117,108,108,0}; // "Null"
+static const char16_t LATIN_PIVOT[] = {0x2D,0x4C,0x61,0x74,0x6E,0x3B,0x4C,0x61,0x74,0x6E,0x2D,0}; // "-Latn;Latn-"
// initial size for an Any-XXXX transform's cache of script-XXXX transforms
// (will grow as necessary, but we don't expect to have source text with more than 7 scripts)
@@ -101,7 +101,7 @@ public:
ScriptRunIterator(const Replaceable& text, int32_t start, int32_t limit);
/**
- * Returns TRUE if there are any more runs. TRUE is always
+ * Returns true if there are any more runs. true is always
* returned at least once. Upon return, the caller should
* examine scriptCode, start, and limit.
*/
@@ -137,7 +137,7 @@ UBool ScriptRunIterator::next() {
// Are we done?
if (start == textLimit) {
- return FALSE;
+ return false;
}
// Move start back to include adjacent COMMON or INHERITED
@@ -167,9 +167,9 @@ UBool ScriptRunIterator::next() {
++limit;
}
- // Return TRUE even if the entire text is COMMON / INHERITED, in
+ // Return true even if the entire text is COMMON / INHERITED, in
// which case scriptCode will be USCRIPT_INVALID_CODE.
- return TRUE;
+ return true;
}
void ScriptRunIterator::adjustLimit(int32_t delta) {
@@ -187,10 +187,10 @@ AnyTransliterator::AnyTransliterator(const UnicodeString& id,
const UnicodeString& theVariant,
UScriptCode theTargetScript,
UErrorCode& ec) :
- Transliterator(id, NULL),
+ Transliterator(id, nullptr),
targetScript(theTargetScript)
{
- cache = uhash_openSize(uhash_hashLong, uhash_compareLong, NULL, ANY_TRANS_CACHE_INIT_SIZE, &ec);
+ cache = uhash_openSize(uhash_hashLong, uhash_compareLong, nullptr, ANY_TRANS_CACHE_INIT_SIZE, &ec);
if (U_FAILURE(ec)) {
return;
}
@@ -216,7 +216,7 @@ AnyTransliterator::AnyTransliterator(const AnyTransliterator& o) :
{
// Don't copy the cache contents
UErrorCode ec = U_ZERO_ERROR;
- cache = uhash_openSize(uhash_hashLong, uhash_compareLong, NULL, ANY_TRANS_CACHE_INIT_SIZE, &ec);
+ cache = uhash_openSize(uhash_hashLong, uhash_compareLong, nullptr, ANY_TRANS_CACHE_INIT_SIZE, &ec);
if (U_FAILURE(ec)) {
return;
}
@@ -248,7 +248,7 @@ void AnyTransliterator::handleTransliterate(Replaceable& text, UTransPosition& p
// our target or target/variant
Transliterator* t = getTransliterator(it.scriptCode);
- if (t == NULL) {
+ if (t == nullptr) {
// We have no transliterator. Do nothing, but keep
// pos.start up to date.
pos.start = it.limit;
@@ -280,40 +280,40 @@ void AnyTransliterator::handleTransliterate(Replaceable& text, UTransPosition& p
Transliterator* AnyTransliterator::getTransliterator(UScriptCode source) const {
if (source == targetScript || source == USCRIPT_INVALID_CODE) {
- return NULL;
+ return nullptr;
}
- Transliterator* t = NULL;
+ Transliterator* t = nullptr;
{
- Mutex m(NULL);
+ Mutex m(nullptr);
t = (Transliterator*) uhash_iget(cache, (int32_t) source);
}
- if (t == NULL) {
+ if (t == nullptr) {
UErrorCode ec = U_ZERO_ERROR;
UnicodeString sourceName(uscript_getShortName(source), -1, US_INV);
UnicodeString id(sourceName);
id.append(TARGET_SEP).append(target);
t = Transliterator::createInstance(id, UTRANS_FORWARD, ec);
- if (U_FAILURE(ec) || t == NULL) {
+ if (U_FAILURE(ec) || t == nullptr) {
delete t;
// Try to pivot around Latin, our most common script
id = sourceName;
id.append(LATIN_PIVOT, -1).append(target);
t = Transliterator::createInstance(id, UTRANS_FORWARD, ec);
- if (U_FAILURE(ec) || t == NULL) {
+ if (U_FAILURE(ec) || t == nullptr) {
delete t;
- t = NULL;
+ t = nullptr;
}
}
- if (t != NULL) {
- Transliterator *rt = NULL;
+ if (t != nullptr) {
+ Transliterator *rt = nullptr;
{
- Mutex m(NULL);
+ Mutex m(nullptr);
rt = static_cast<Transliterator *> (uhash_iget(cache, (int32_t) source));
- if (rt == NULL) {
+ if (rt == nullptr) {
// Common case, no race to cache this new transliterator.
uhash_iput(cache, (int32_t) source, t, &ec);
} else {
@@ -341,7 +341,7 @@ static UScriptCode scriptNameToCode(const UnicodeString& name) {
if (isInvariant) {
name.extract(0, nameLen, buf, (int32_t)sizeof(buf), US_INV);
- buf[127] = 0; // Make sure that we NULL terminate the string.
+ buf[127] = 0; // Make sure that we nullptr terminate the string.
}
if (!isInvariant || uscript_getCode(buf, &code, 1, &ec) != 1 || U_FAILURE(ec))
{
@@ -358,7 +358,7 @@ static UScriptCode scriptNameToCode(const UnicodeString& name) {
void AnyTransliterator::registerIDs() {
UErrorCode ec = U_ZERO_ERROR;
- Hashtable seen(TRUE, ec);
+ Hashtable seen(true, ec);
int32_t sourceCount = Transliterator::_countAvailableSources();
for (int32_t s=0; s<sourceCount; ++s) {
@@ -389,7 +389,7 @@ void AnyTransliterator::registerIDs() {
Transliterator::_getAvailableVariant(v, source, target, variant);
UnicodeString id;
- TransliteratorIDParser::STVtoID(UnicodeString(TRUE, ANY, 3), target, variant, id);
+ TransliteratorIDParser::STVtoID(UnicodeString(true, ANY, 3), target, variant, id);
ec = U_ZERO_ERROR;
AnyTransliterator* tl = new AnyTransliterator(id, target, variant,
targetScript, ec);
@@ -397,7 +397,7 @@ void AnyTransliterator::registerIDs() {
delete tl;
} else {
Transliterator::_registerInstance(tl);
- Transliterator::_registerSpecialInverse(target, UnicodeString(TRUE, NULL_ID, 4), FALSE);
+ Transliterator::_registerSpecialInverse(target, UnicodeString(true, NULL_ID, 4), false);
}
}
}
diff --git a/contrib/libs/icu/i18n/anytrans.h b/contrib/libs/icu/i18n/anytrans.h
index 67ebb2e7d2..9aa7eef2ce 100644
--- a/contrib/libs/icu/i18n/anytrans.h
+++ b/contrib/libs/icu/i18n/anytrans.h
@@ -107,7 +107,7 @@ private:
/**
* Returns a transliterator from the given source to our target or
- * target/variant. Returns NULL if the source is the same as our
+ * target/variant. Returns nullptr if the source is the same as our
* target script, or if the source is USCRIPT_INVALID_CODE.
* Caches the result and returns the same transliterator the next
* time. The caller does NOT own the result and must not delete
diff --git a/contrib/libs/icu/i18n/astro.cpp b/contrib/libs/icu/i18n/astro.cpp
index 6dc463b4ca..575efeb175 100644
--- a/contrib/libs/icu/i18n/astro.cpp
+++ b/contrib/libs/icu/i18n/astro.cpp
@@ -44,8 +44,8 @@ static void debug_astro_msg(const char *pat, ...)
#include "unicode/ustring.h"
static const char * debug_astro_date(UDate d) {
static char gStrBuf[1024];
- static DateFormat *df = NULL;
- if(df == NULL) {
+ static DateFormat *df = nullptr;
+ if(df == nullptr) {
df = DateFormat::createDateTimeInstance(DateFormat::MEDIUM, DateFormat::MEDIUM, Locale::getUS());
df->adoptTimeZone(TimeZone::getGMT()->clone());
}
@@ -68,8 +68,8 @@ static inline UBool isINVALID(double d) {
static icu::UMutex ccLock;
U_CDECL_BEGIN
-static UBool calendar_astro_cleanup(void) {
- return TRUE;
+static UBool calendar_astro_cleanup() {
+ return true;
}
U_CDECL_END
@@ -242,7 +242,7 @@ inline static double normPI(double angle) {
* @deprecated ICU 2.4. This class may be removed or modified.
*/
CalendarAstronomer::CalendarAstronomer():
- fTime(Calendar::getNow()), fLongitude(0.0), fLatitude(0.0), fGmtOffset(0.0), moonPosition(0,0), moonPositionSet(FALSE) {
+ fTime(Calendar::getNow()), fLongitude(0.0), fLatitude(0.0), fGmtOffset(0.0), moonPosition(0,0), moonPositionSet(false) {
clearCache();
}
@@ -252,7 +252,7 @@ CalendarAstronomer::CalendarAstronomer():
* @internal
* @deprecated ICU 2.4. This class may be removed or modified.
*/
-CalendarAstronomer::CalendarAstronomer(UDate d): fTime(d), fLongitude(0.0), fLatitude(0.0), fGmtOffset(0.0), moonPosition(0,0), moonPositionSet(FALSE) {
+CalendarAstronomer::CalendarAstronomer(UDate d): fTime(d), fLongitude(0.0), fLatitude(0.0), fGmtOffset(0.0), moonPosition(0,0), moonPositionSet(false) {
clearCache();
}
@@ -272,7 +272,7 @@ CalendarAstronomer::CalendarAstronomer(UDate d): fTime(d), fLongitude(0.0), fLat
* @deprecated ICU 2.4. This class may be removed or modified.
*/
CalendarAstronomer::CalendarAstronomer(double longitude, double latitude) :
- fTime(Calendar::getNow()), moonPosition(0,0), moonPositionSet(FALSE) {
+ fTime(Calendar::getNow()), moonPosition(0,0), moonPositionSet(false) {
fLongitude = normPI(longitude * (double)DEG_RAD);
fLatitude = normPI(latitude * (double)DEG_RAD);
fGmtOffset = (double)(fLongitude * 24. * (double)HOUR_MS / (double)CalendarAstronomer_PI2);
@@ -1069,7 +1069,7 @@ const CalendarAstronomer::Equatorial& CalendarAstronomer::getMoonPosition()
// See page 142 of "Practical Astronomy with your Calculator",
// by Peter Duffet-Smith, for details on the algorithm.
//
- if (moonPositionSet == FALSE) {
+ if (moonPositionSet == false) {
// Calculate the solar longitude. Has the side effect of
// filling in "meanAnomalySun" as well.
getSunLongitude();
@@ -1138,7 +1138,7 @@ const CalendarAstronomer::Equatorial& CalendarAstronomer::getMoonPosition()
double moonEclipLat = ::asin(y * ::sin(moonI));
eclipticToEquatorial(moonPosition, moonEclipLong, moonEclipLat);
- moonPositionSet = TRUE;
+ moonPositionSet = true;
}
return moonPosition;
}
@@ -1446,7 +1446,7 @@ void CalendarAstronomer::clearCache() {
eclipObliquity = INVALID;
siderealTime = INVALID;
siderealT0 = INVALID;
- moonPositionSet = FALSE;
+ moonPositionSet = false;
}
//private static void out(String s) {
@@ -1471,7 +1471,7 @@ void CalendarAstronomer::clearCache() {
int32_t rawOffset;
int32_t dstOffset;
UErrorCode status = U_ZERO_ERROR;
- tz->getOffset(localMillis, TRUE, rawOffset, dstOffset, status);
+ tz->getOffset(localMillis, true, rawOffset, dstOffset, status);
delete tz;
return localMillis - rawOffset;
}*/
@@ -1481,7 +1481,7 @@ UnicodeString CalendarAstronomer::Ecliptic::toString() const
{
#ifdef U_DEBUG_ASTRO
char tmp[800];
- sprintf(tmp, "[%.5f,%.5f]", longitude*RAD_DEG, latitude*RAD_DEG);
+ snprintf(tmp, sizeof(tmp), "[%.5f,%.5f]", longitude*RAD_DEG, latitude*RAD_DEG);
return UnicodeString(tmp, "");
#else
return UnicodeString();
@@ -1492,7 +1492,7 @@ UnicodeString CalendarAstronomer::Equatorial::toString() const
{
#ifdef U_DEBUG_ASTRO
char tmp[400];
- sprintf(tmp, "%f,%f",
+ snprintf(tmp, sizeof(tmp), "%f,%f",
(ascension*RAD_DEG), (declination*RAD_DEG));
return UnicodeString(tmp, "");
#else
@@ -1504,7 +1504,7 @@ UnicodeString CalendarAstronomer::Horizon::toString() const
{
#ifdef U_DEBUG_ASTRO
char tmp[800];
- sprintf(tmp, "[%.5f,%.5f]", altitude*RAD_DEG, azimuth*RAD_DEG);
+ snprintf(tmp, sizeof(tmp), "[%.5f,%.5f]", altitude*RAD_DEG, azimuth*RAD_DEG);
return UnicodeString(tmp, "");
#else
return UnicodeString();
@@ -1532,13 +1532,13 @@ UnicodeString CalendarAstronomer::Horizon::toString() const
void CalendarCache::createCache(CalendarCache** cache, UErrorCode& status) {
ucln_i18n_registerCleanup(UCLN_I18N_ASTRO_CALENDAR, calendar_astro_cleanup);
- if(cache == NULL) {
+ if(cache == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
*cache = new CalendarCache(32, status);
if(U_FAILURE(status)) {
delete *cache;
- *cache = NULL;
+ *cache = nullptr;
}
}
}
@@ -1551,7 +1551,7 @@ int32_t CalendarCache::get(CalendarCache** cache, int32_t key, UErrorCode &statu
}
umtx_lock(&ccLock);
- if(*cache == NULL) {
+ if(*cache == nullptr) {
createCache(cache, status);
if(U_FAILURE(status)) {
umtx_unlock(&ccLock);
@@ -1572,7 +1572,7 @@ void CalendarCache::put(CalendarCache** cache, int32_t key, int32_t value, UErro
}
umtx_lock(&ccLock);
- if(*cache == NULL) {
+ if(*cache == nullptr) {
createCache(cache, status);
if(U_FAILURE(status)) {
umtx_unlock(&ccLock);
@@ -1587,12 +1587,12 @@ void CalendarCache::put(CalendarCache** cache, int32_t key, int32_t value, UErro
}
CalendarCache::CalendarCache(int32_t size, UErrorCode &status) {
- fTable = uhash_openSize(uhash_hashLong, uhash_compareLong, NULL, size, &status);
+ fTable = uhash_openSize(uhash_hashLong, uhash_compareLong, nullptr, size, &status);
U_DEBUG_ASTRO_MSG(("%p: Opening.\n", fTable));
}
CalendarCache::~CalendarCache() {
- if(fTable != NULL) {
+ if(fTable != nullptr) {
U_DEBUG_ASTRO_MSG(("%p: Closing.\n", fTable));
uhash_close(fTable);
}
diff --git a/contrib/libs/icu/i18n/basictz.cpp b/contrib/libs/icu/i18n/basictz.cpp
index 7b5449f416..2490fadcc9 100644
--- a/contrib/libs/icu/i18n/basictz.cpp
+++ b/contrib/libs/icu/i18n/basictz.cpp
@@ -39,59 +39,59 @@ UBool
BasicTimeZone::hasEquivalentTransitions(const BasicTimeZone& tz, UDate start, UDate end,
UBool ignoreDstAmount, UErrorCode& status) const {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (hasSameRules(tz)) {
- return TRUE;
+ return true;
}
// Check the offsets at the start time
int32_t raw1, raw2, dst1, dst2;
- getOffset(start, FALSE, raw1, dst1, status);
+ getOffset(start, false, raw1, dst1, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
- tz.getOffset(start, FALSE, raw2, dst2, status);
+ tz.getOffset(start, false, raw2, dst2, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (ignoreDstAmount) {
if ((raw1 + dst1 != raw2 + dst2)
|| (dst1 != 0 && dst2 == 0)
|| (dst1 == 0 && dst2 != 0)) {
- return FALSE;
+ return false;
}
} else {
if (raw1 != raw2 || dst1 != dst2) {
- return FALSE;
+ return false;
}
}
// Check transitions in the range
UDate time = start;
TimeZoneTransition tr1, tr2;
- while (TRUE) {
- UBool avail1 = getNextTransition(time, FALSE, tr1);
- UBool avail2 = tz.getNextTransition(time, FALSE, tr2);
+ while (true) {
+ UBool avail1 = getNextTransition(time, false, tr1);
+ UBool avail2 = tz.getNextTransition(time, false, tr2);
if (ignoreDstAmount) {
// Skip a transition which only differ the amount of DST savings
- while (TRUE) {
+ while (true) {
if (avail1
&& tr1.getTime() <= end
&& (tr1.getFrom()->getRawOffset() + tr1.getFrom()->getDSTSavings()
== tr1.getTo()->getRawOffset() + tr1.getTo()->getDSTSavings())
&& (tr1.getFrom()->getDSTSavings() != 0 && tr1.getTo()->getDSTSavings() != 0)) {
- getNextTransition(tr1.getTime(), FALSE, tr1);
+ getNextTransition(tr1.getTime(), false, tr1);
} else {
break;
}
}
- while (TRUE) {
+ while (true) {
if (avail2
&& tr2.getTime() <= end
&& (tr2.getFrom()->getRawOffset() + tr2.getFrom()->getDSTSavings()
== tr2.getTo()->getRawOffset() + tr2.getTo()->getDSTSavings())
&& (tr2.getFrom()->getDSTSavings() != 0 && tr2.getTo()->getDSTSavings() != 0)) {
- tz.getNextTransition(tr2.getTime(), FALSE, tr2);
+ tz.getNextTransition(tr2.getTime(), false, tr2);
} else {
break;
}
@@ -105,49 +105,49 @@ BasicTimeZone::hasEquivalentTransitions(const BasicTimeZone& tz, UDate start, UD
break;
}
if (!inRange1 || !inRange2) {
- return FALSE;
+ return false;
}
if (tr1.getTime() != tr2.getTime()) {
- return FALSE;
+ return false;
}
if (ignoreDstAmount) {
if (tr1.getTo()->getRawOffset() + tr1.getTo()->getDSTSavings()
!= tr2.getTo()->getRawOffset() + tr2.getTo()->getDSTSavings()
|| (tr1.getTo()->getDSTSavings() != 0 && tr2.getTo()->getDSTSavings() == 0)
|| (tr1.getTo()->getDSTSavings() == 0 && tr2.getTo()->getDSTSavings() != 0)) {
- return FALSE;
+ return false;
}
} else {
if (tr1.getTo()->getRawOffset() != tr2.getTo()->getRawOffset() ||
tr1.getTo()->getDSTSavings() != tr2.getTo()->getDSTSavings()) {
- return FALSE;
+ return false;
}
}
time = tr1.getTime();
}
- return TRUE;
+ return true;
}
void
BasicTimeZone::getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial,
AnnualTimeZoneRule*& std, AnnualTimeZoneRule*& dst, UErrorCode& status) const {
- initial = NULL;
- std = NULL;
- dst = NULL;
+ initial = nullptr;
+ std = nullptr;
+ dst = nullptr;
if (U_FAILURE(status)) {
return;
}
int32_t initialRaw, initialDst;
UnicodeString initialName;
- AnnualTimeZoneRule *ar1 = NULL;
- AnnualTimeZoneRule *ar2 = NULL;
+ AnnualTimeZoneRule *ar1 = nullptr;
+ AnnualTimeZoneRule *ar2 = nullptr;
UnicodeString name;
UBool avail;
TimeZoneTransition tr;
// Get the next transition
- avail = getNextTransition(date, FALSE, tr);
+ avail = getNextTransition(date, false, tr);
if (avail) {
tr.getFrom()->getName(initialName);
initialRaw = tr.getFrom()->getRawOffset();
@@ -182,7 +182,7 @@ BasicTimeZone::getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial,
if (tr.getTo()->getRawOffset() == initialRaw) {
// Get the next next transition
- avail = getNextTransition(nextTransitionTime, FALSE, tr);
+ avail = getNextTransition(nextTransitionTime, false, tr);
if (avail) {
// Check if the next next transition is either DST->STD or STD->DST
// and within roughly 1 year from the next transition
@@ -201,20 +201,20 @@ BasicTimeZone::getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial,
dtr, year - 1, AnnualTimeZoneRule::MAX_YEAR);
// Make sure this rule can be applied to the specified date
- avail = ar2->getPreviousStart(date, tr.getFrom()->getRawOffset(), tr.getFrom()->getDSTSavings(), TRUE, d);
+ avail = ar2->getPreviousStart(date, tr.getFrom()->getRawOffset(), tr.getFrom()->getDSTSavings(), true, d);
if (!avail || d > date
|| initialRaw != tr.getTo()->getRawOffset()
|| initialDst != tr.getTo()->getDSTSavings()) {
// We cannot use this rule as the second transition rule
delete ar2;
- ar2 = NULL;
+ ar2 = nullptr;
}
}
}
}
- if (ar2 == NULL) {
+ if (ar2 == nullptr) {
// Try previous transition
- avail = getPreviousTransition(date, TRUE, tr);
+ avail = getPreviousTransition(date, true, tr);
if (avail) {
// Check if the previous transition is either DST->STD or STD->DST.
// The actual transition time does not matter here.
@@ -234,19 +234,19 @@ BasicTimeZone::getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial,
dtr, ar1->getStartYear() - 1, AnnualTimeZoneRule::MAX_YEAR);
// Check if this rule start after the first rule after the specified date
- avail = ar2->getNextStart(date, tr.getFrom()->getRawOffset(), tr.getFrom()->getDSTSavings(), FALSE, d);
+ avail = ar2->getNextStart(date, tr.getFrom()->getRawOffset(), tr.getFrom()->getDSTSavings(), false, d);
if (!avail || d <= nextTransitionTime) {
// We cannot use this rule as the second transition rule
delete ar2;
- ar2 = NULL;
+ ar2 = nullptr;
}
}
}
}
- if (ar2 == NULL) {
+ if (ar2 == nullptr) {
// Cannot find a good pair of AnnualTimeZoneRule
delete ar1;
- ar1 = NULL;
+ ar1 = nullptr;
} else {
// The initial rule should represent the rule before the previous transition
ar1->getName(initialName);
@@ -257,14 +257,14 @@ BasicTimeZone::getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial,
}
else {
// Try the previous one
- avail = getPreviousTransition(date, TRUE, tr);
+ avail = getPreviousTransition(date, true, tr);
if (avail) {
tr.getTo()->getName(initialName);
initialRaw = tr.getTo()->getRawOffset();
initialDst = tr.getTo()->getDSTSavings();
} else {
// No transitions in the past. Just use the current offsets
- getOffset(date, FALSE, initialRaw, initialDst, status);
+ getOffset(date, false, initialRaw, initialDst, status);
if (U_FAILURE(status)) {
return;
}
@@ -274,7 +274,7 @@ BasicTimeZone::getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial,
initial = new InitialTimeZoneRule(initialName, initialRaw, initialDst);
// Set the standard and daylight saving rules
- if (ar1 != NULL && ar2 != NULL) {
+ if (ar1 != nullptr && ar2 != nullptr) {
if (ar1->getDSTSavings() != 0) {
dst = ar1;
std = ar2;
@@ -334,7 +334,7 @@ BasicTimeZone::getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial,
}
}
- avail = getPreviousTransition(start, TRUE, tzt);
+ avail = getPreviousTransition(start, true, tzt);
if (!avail) {
// No need to filter out rules only applicable to time before the start
initial = orgini->clone();
@@ -368,13 +368,13 @@ BasicTimeZone::getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial,
// Mark rules which does not need to be processed
for (i = 0; i < ruleCount; i++) {
r = (TimeZoneRule*)orgRules->elementAt(i);
- avail = r->getNextStart(start, res_initial->getRawOffset(), res_initial->getDSTSavings(), FALSE, time);
+ avail = r->getNextStart(start, res_initial->getRawOffset(), res_initial->getDSTSavings(), false, time);
done[i] = !avail;
}
time = start;
while (!bFinalStd || !bFinalDst) {
- avail = getNextTransition(time, FALSE, tzt);
+ avail = getNextTransition(time, false, tzt);
if (!avail) {
break;
}
@@ -405,12 +405,12 @@ BasicTimeZone::getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial,
}
const TimeArrayTimeZoneRule *tar = dynamic_cast<const TimeArrayTimeZoneRule *>(toRule);
const AnnualTimeZoneRule *ar;
- if (tar != NULL) {
+ if (tar != nullptr) {
// Get the previous raw offset and DST savings before the very first start time
TimeZoneTransition tzt0;
t = start;
- while (TRUE) {
- avail = getNextTransition(t, FALSE, tzt0);
+ while (true) {
+ avail = getNextTransition(t, false, tzt0);
if (!avail) {
break;
}
@@ -472,7 +472,7 @@ BasicTimeZone::getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial,
}
}
}
- } else if ((ar = dynamic_cast<const AnnualTimeZoneRule *>(toRule)) != NULL) {
+ } else if ((ar = dynamic_cast<const AnnualTimeZoneRule *>(toRule)) != nullptr) {
ar->getFirstStart(tzt.getFrom()->getRawOffset(), tzt.getFrom()->getDSTSavings(), firstStart);
if (firstStart == tzt.getTime()) {
// Just add the rule as is
@@ -499,9 +499,9 @@ BasicTimeZone::getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial,
// After bot final standard and dst rules are processed,
// exit this while loop.
if (ar->getDSTSavings() == 0) {
- bFinalStd = TRUE;
+ bFinalStd = true;
} else {
- bFinalDst = TRUE;
+ bFinalDst = true;
}
}
}
diff --git a/contrib/libs/icu/i18n/bocsu.cpp b/contrib/libs/icu/i18n/bocsu.cpp
index 861a76a042..585415643b 100644
--- a/contrib/libs/icu/i18n/bocsu.cpp
+++ b/contrib/libs/icu/i18n/bocsu.cpp
@@ -98,7 +98,7 @@ u_writeDiff(int32_t diff, uint8_t *p) {
* NFD text - there are never Hangul characters included.
*/
U_CFUNC UChar32
-u_writeIdenticalLevelRun(UChar32 prev, const UChar *s, int32_t length, icu::ByteSink &sink) {
+u_writeIdenticalLevelRun(UChar32 prev, const char16_t *s, int32_t length, icu::ByteSink &sink) {
char scratch[64];
int32_t capacity;
diff --git a/contrib/libs/icu/i18n/brktrans.cpp b/contrib/libs/icu/i18n/brktrans.cpp
index f0ec8407db..1ec0b2ad44 100644
--- a/contrib/libs/icu/i18n/brktrans.cpp
+++ b/contrib/libs/icu/i18n/brktrans.cpp
@@ -34,7 +34,7 @@ U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(BreakTransliterator)
-static const UChar SPACE = 32; // ' '
+static const char16_t SPACE = 32; // ' '
/**
@@ -43,7 +43,7 @@ static const UChar SPACE = 32; // ' '
*/
BreakTransliterator::BreakTransliterator(UnicodeFilter* adoptedFilter) :
Transliterator(UNICODE_STRING("Any-BreakInternal", 17), adoptedFilter),
- cachedBI(NULL), cachedBoundaries(NULL), fInsertion(SPACE) {
+ cachedBI(nullptr), cachedBoundaries(nullptr), fInsertion(SPACE) {
}
@@ -57,7 +57,7 @@ BreakTransliterator::~BreakTransliterator() {
* Copy constructor.
*/
BreakTransliterator::BreakTransliterator(const BreakTransliterator& o) :
- Transliterator(o), cachedBI(NULL), cachedBoundaries(NULL), fInsertion(o.fInsertion) {
+ Transliterator(o), cachedBI(nullptr), cachedBoundaries(nullptr), fInsertion(o.fInsertion) {
}
@@ -182,7 +182,7 @@ void BreakTransliterator::setInsertion(const UnicodeString &insertion) {
UnicodeString BreakTransliterator::replaceableAsString(Replaceable &r) {
UnicodeString s;
UnicodeString *rs = dynamic_cast<UnicodeString *>(&r);
- if (rs != NULL) {
+ if (rs != nullptr) {
s = *rs;
} else {
r.extractBetween(0, r.length(), s);
diff --git a/contrib/libs/icu/i18n/buddhcal.cpp b/contrib/libs/icu/i18n/buddhcal.cpp
index 6083349ecd..dc14af00bf 100644
--- a/contrib/libs/icu/i18n/buddhcal.cpp
+++ b/contrib/libs/icu/i18n/buddhcal.cpp
@@ -78,13 +78,6 @@ int32_t BuddhistCalendar::handleGetExtendedYear()
return year;
}
-int32_t BuddhistCalendar::handleComputeMonthStart(int32_t eyear, int32_t month,
-
- UBool useMonth) const
-{
- return GregorianCalendar::handleComputeMonthStart(eyear, month, useMonth);
-}
-
void BuddhistCalendar::handleComputeFields(int32_t julianDay, UErrorCode& status)
{
GregorianCalendar::handleComputeFields(julianDay, status);
@@ -133,12 +126,12 @@ void BuddhistCalendar::timeToFields(UDate theTime, UBool quick, UErrorCode& stat
*/
static UDate gSystemDefaultCenturyStart = DBL_MIN;
static int32_t gSystemDefaultCenturyStartYear = -1;
-static icu::UInitOnce gBCInitOnce = U_INITONCE_INITIALIZER;
+static icu::UInitOnce gBCInitOnce {};
UBool BuddhistCalendar::haveDefaultCentury() const
{
- return TRUE;
+ return true;
}
static void U_CALLCONV
diff --git a/contrib/libs/icu/i18n/buddhcal.h b/contrib/libs/icu/i18n/buddhcal.h
index 2ef5c52493..01b59341c1 100644
--- a/contrib/libs/icu/i18n/buddhcal.h
+++ b/contrib/libs/icu/i18n/buddhcal.h
@@ -107,7 +107,7 @@ public:
* same class ID. Objects of other classes have different class IDs.
* @internal
*/
- virtual UClassID getDynamicClassID(void) const override;
+ virtual UClassID getDynamicClassID() const override;
/**
* Return the class ID for this class. This is useful only for comparing to a return
@@ -120,7 +120,7 @@ public:
* @return The class ID for all objects of this class.
* @internal
*/
- U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
+ U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
/**
* return the calendar type, "buddhist".
@@ -157,21 +157,6 @@ private:
* @internal
*/
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const override;
- /**
- * Return the Julian day number of day before the first day of the
- * given month in the given extended year. Subclasses should override
- * this method to implement their calendar system.
- * @param eyear the extended year
- * @param month the zero-based month, or 0 if useMonth is false
- * @param useMonth if false, compute the day before the first day of
- * the given year, otherwise, compute the day before the first day of
- * the given month
- * @param return the Julian day number of the day before the first
- * day of the given month and year
- * @internal
- */
- virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
- UBool useMonth) const override;
/**
* Returns true because the Buddhist Calendar does have a default century
diff --git a/contrib/libs/icu/i18n/calendar.cpp b/contrib/libs/icu/i18n/calendar.cpp
index 8405d08d3c..72d5d10ed5 100644
--- a/contrib/libs/icu/i18n/calendar.cpp
+++ b/contrib/libs/icu/i18n/calendar.cpp
@@ -22,7 +22,7 @@
* 07/28/98 stephen Sync up with JDK 1.2
* 09/02/98 stephen Sync with JDK 1.2 8/31 build (getActualMin/Max)
* 03/17/99 stephen Changed adoptTimeZone() - now fAreFieldsSet is
-* set to FALSE to force update of time.
+* set to false to force update of time.
*******************************************************************************
*/
@@ -45,6 +45,7 @@
#include "hebrwcal.h"
#include "persncal.h"
#include "indiancal.h"
+#include "iso8601cal.h"
#include "chnsecal.h"
#include "coptccal.h"
#include "dangical.h"
@@ -64,20 +65,20 @@
#include "ulocimp.h"
#if !UCONFIG_NO_SERVICE
-static icu::ICULocaleService* gService = NULL;
-static icu::UInitOnce gServiceInitOnce = U_INITONCE_INITIALIZER;
+static icu::ICULocaleService* gService = nullptr;
+static icu::UInitOnce gServiceInitOnce {};
// INTERNAL - for cleanup
U_CDECL_BEGIN
-static UBool calendar_cleanup(void) {
+static UBool calendar_cleanup() {
#if !UCONFIG_NO_SERVICE
if (gService) {
delete gService;
- gService = NULL;
+ gService = nullptr;
}
gServiceInitOnce.reset();
#endif
- return TRUE;
+ return true;
}
U_CDECL_END
#endif
@@ -175,7 +176,7 @@ static const char * const gCalTypes[] = {
"islamic-umalqura",
"islamic-tbla",
"islamic-rgsa",
- NULL
+ nullptr
};
// Must be in the order of gCalTypes above
@@ -210,22 +211,25 @@ SharedCalendar::~SharedCalendar() {
template<> U_I18N_API
const SharedCalendar *LocaleCacheKey<SharedCalendar>::createObject(
const void * /*unusedCreationContext*/, UErrorCode &status) const {
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
Calendar *calendar = Calendar::makeInstance(fLoc, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
SharedCalendar *shared = new SharedCalendar(calendar);
- if (shared == NULL) {
+ if (shared == nullptr) {
delete calendar;
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
shared->addRef();
return shared;
}
static ECalType getCalendarType(const char *s) {
- for (int i = 0; gCalTypes[i] != NULL; i++) {
+ for (int i = 0; gCalTypes[i] != nullptr; i++) {
if (uprv_stricmp(s, gCalTypes[i]) == 0) {
return (ECalType)i;
}
@@ -237,7 +241,7 @@ static ECalType getCalendarType(const char *s) {
// Only used with service registration.
static UBool isStandardSupportedKeyword(const char *keyword, UErrorCode& status) {
if(U_FAILURE(status)) {
- return FALSE;
+ return false;
}
ECalType calType = getCalendarType(keyword);
return (calType != CALTYPE_UNKNOWN);
@@ -249,7 +253,7 @@ static void getCalendarKeyword(const UnicodeString &id, char *targetBuffer, int3
int32_t calKeyLen = calendarKeyword.length();
int32_t keyLen = 0;
- int32_t keywordIdx = id.indexOf((UChar)0x003D); /* '=' */
+ int32_t keywordIdx = id.indexOf((char16_t)0x003D); /* '=' */
if (id[0] == 0x40/*'@'*/
&& id.compareBetween(1, keywordIdx+1, calendarKeyword, 0, calKeyLen) == 0)
{
@@ -292,25 +296,25 @@ static ECalType getCalendarTypeForLocale(const char *locid) {
// when calendar keyword is not available or not supported, read supplementalData
// to get the default calendar type for the locale's region
char region[ULOC_COUNTRY_CAPACITY];
- (void)ulocimp_getRegionForSupplementalData(canonicalName, TRUE, region, sizeof(region), &status);
+ (void)ulocimp_getRegionForSupplementalData(canonicalName, true, region, sizeof(region), &status);
if (U_FAILURE(status)) {
return CALTYPE_GREGORIAN;
}
// Read preferred calendar values from supplementalData calendarPreference
- UResourceBundle *rb = ures_openDirect(NULL, "supplementalData", &status);
+ UResourceBundle *rb = ures_openDirect(nullptr, "supplementalData", &status);
ures_getByKey(rb, "calendarPreferenceData", rb, &status);
- UResourceBundle *order = ures_getByKey(rb, region, NULL, &status);
- if (status == U_MISSING_RESOURCE_ERROR && rb != NULL) {
+ UResourceBundle *order = ures_getByKey(rb, region, nullptr, &status);
+ if (status == U_MISSING_RESOURCE_ERROR && rb != nullptr) {
status = U_ZERO_ERROR;
- order = ures_getByKey(rb, "001", NULL, &status);
+ order = ures_getByKey(rb, "001", nullptr, &status);
}
calTypeBuf[0] = 0;
- if (U_SUCCESS(status) && order != NULL) {
+ if (U_SUCCESS(status) && order != nullptr) {
// the first calendar type is the default for the region
int32_t len = 0;
- const UChar *uCalType = ures_getStringByIndex(order, 0, &len, &status);
+ const char16_t *uCalType = ures_getStringByIndex(order, 0, &len, &status);
if (len < (int32_t)sizeof(calTypeBuf)) {
u_UCharsToChars(uCalType, calTypeBuf, len);
*(calTypeBuf + len) = 0; // terminate;
@@ -351,18 +355,19 @@ static Calendar *createStandardCalendar(ECalType calType, const Locale &loc, UEr
cal.adoptInsteadAndCheckErrorCode(new PersianCalendar(loc, status), status);
break;
case CALTYPE_ISLAMIC_TBLA:
- cal.adoptInsteadAndCheckErrorCode(new IslamicCalendar(loc, status, IslamicCalendar::TBLA), status);
+ cal.adoptInsteadAndCheckErrorCode(new IslamicTBLACalendar(loc, status), status);
break;
case CALTYPE_ISLAMIC_CIVIL:
- cal.adoptInsteadAndCheckErrorCode(new IslamicCalendar(loc, status, IslamicCalendar::CIVIL), status);
+ cal.adoptInsteadAndCheckErrorCode(new IslamicCivilCalendar(loc, status), status);
break;
case CALTYPE_ISLAMIC_RGSA:
- // default any region specific not handled individually to islamic
+ cal.adoptInsteadAndCheckErrorCode(new IslamicRGSACalendar(loc, status), status);
+ break;
case CALTYPE_ISLAMIC:
- cal.adoptInsteadAndCheckErrorCode(new IslamicCalendar(loc, status, IslamicCalendar::ASTRONOMICAL), status);
+ cal.adoptInsteadAndCheckErrorCode(new IslamicCalendar(loc, status), status);
break;
case CALTYPE_ISLAMIC_UMALQURA:
- cal.adoptInsteadAndCheckErrorCode(new IslamicCalendar(loc, status, IslamicCalendar::UMALQURA), status);
+ cal.adoptInsteadAndCheckErrorCode(new IslamicUmalquraCalendar(loc, status), status);
break;
case CALTYPE_HEBREW:
cal.adoptInsteadAndCheckErrorCode(new HebrewCalendar(loc, status), status);
@@ -377,17 +382,13 @@ static Calendar *createStandardCalendar(ECalType calType, const Locale &loc, UEr
cal.adoptInsteadAndCheckErrorCode(new CopticCalendar(loc, status), status);
break;
case CALTYPE_ETHIOPIC:
- cal.adoptInsteadAndCheckErrorCode(new EthiopicCalendar(loc, status, EthiopicCalendar::AMETE_MIHRET_ERA), status);
+ cal.adoptInsteadAndCheckErrorCode(new EthiopicCalendar(loc, status), status);
break;
case CALTYPE_ETHIOPIC_AMETE_ALEM:
- cal.adoptInsteadAndCheckErrorCode(new EthiopicCalendar(loc, status, EthiopicCalendar::AMETE_ALEM_ERA), status);
+ cal.adoptInsteadAndCheckErrorCode(new EthiopicAmeteAlemCalendar(loc, status), status);
break;
case CALTYPE_ISO8601:
- cal.adoptInsteadAndCheckErrorCode(new GregorianCalendar(loc, status), status);
- if (cal.isValid()) {
- cal->setFirstDayOfWeek(UCAL_MONDAY);
- cal->setMinimalDaysInFirstWeek(4);
- }
+ cal.adoptInsteadAndCheckErrorCode(new ISO8601Calendar(loc, status), status);
break;
case CALTYPE_DANGI:
cal.adoptInsteadAndCheckErrorCode(new DangiCalendar(loc, status), status);
@@ -420,7 +421,7 @@ public:
protected:
//virtual UBool isSupportedID( const UnicodeString& id, UErrorCode& status) const {
// if(U_FAILURE(status)) {
- // return FALSE;
+ // return false;
// }
// char keyword[ULOC_FULLNAME_CAPACITY];
// getCalendarKeyword(id, keyword, (int32_t)sizeof(keyword));
@@ -430,8 +431,8 @@ protected:
virtual void updateVisibleIDs(Hashtable& result, UErrorCode& status) const override
{
if (U_SUCCESS(status)) {
- for(int32_t i=0;gCalTypes[i] != NULL;i++) {
- UnicodeString id((UChar)0x40); /* '@' a variant character */
+ for(int32_t i=0;gCalTypes[i] != nullptr;i++) {
+ UnicodeString id((char16_t)0x40); /* '@' a variant character */
id.append(UNICODE_STRING_SIMPLE("calendar="));
id.append(UnicodeString(gCalTypes[i], -1, US_INV));
result.put(id, (void*)this, status);
@@ -440,17 +441,21 @@ protected:
}
virtual UObject* create(const ICUServiceKey& key, const ICUService* /*service*/, UErrorCode& status) const override {
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
#ifdef U_DEBUG_CALSVC
- if(dynamic_cast<const LocaleKey*>(&key) == NULL) {
+ if(dynamic_cast<const LocaleKey*>(&key) == nullptr) {
fprintf(stderr, "::create - not a LocaleKey!\n");
}
#endif
- const LocaleKey& lkey = (LocaleKey&)key;
+ const LocaleKey* lkey = dynamic_cast<const LocaleKey*>(&key);
+ U_ASSERT(lkey != nullptr);
Locale curLoc; // current locale
Locale canLoc; // Canonical locale
- lkey.currentLocale(curLoc);
- lkey.canonicalLocale(canLoc);
+ lkey->currentLocale(curLoc);
+ lkey->canonicalLocale(canLoc);
char keyword[ULOC_FULLNAME_CAPACITY];
UnicodeString str;
@@ -467,7 +472,7 @@ protected:
fprintf(stderr, "BasicCalendarFactory - not handling %s.[%s]\n", (const char*) curLoc.getName(), tmp );
#endif
- return NULL;
+ return nullptr;
}
return createStandardCalendar(getCalendarType(keyword), canLoc, status);
@@ -486,16 +491,20 @@ public:
virtual ~DefaultCalendarFactory();
protected:
virtual UObject* create(const ICUServiceKey& key, const ICUService* /*service*/, UErrorCode& status) const override {
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
- LocaleKey &lkey = (LocaleKey&)key;
+ const LocaleKey *lkey = dynamic_cast<const LocaleKey*>(&key);
+ U_ASSERT(lkey != nullptr);
Locale loc;
- lkey.currentLocale(loc);
+ lkey->currentLocale(loc);
UnicodeString *ret = new UnicodeString();
- if (ret == NULL) {
+ if (ret == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
- ret->append((UChar)0x40); // '@' is a variant character
+ ret->append((char16_t)0x40); // '@' is a variant character
ret->append(UNICODE_STRING("calendar=", 9));
ret->append(UnicodeString(gCalTypes[getCalendarTypeForLocale(loc.getName())], -1, US_INV));
}
@@ -519,7 +528,7 @@ public:
virtual UObject* cloneInstance(UObject* instance) const override {
UnicodeString *s = dynamic_cast<UnicodeString *>(instance);
- if(s != NULL) {
+ if(s != nullptr) {
return s->clone();
} else {
#ifdef U_DEBUG_CALSVC_F
@@ -531,7 +540,10 @@ public:
}
virtual UObject* handleDefault(const ICUServiceKey& key, UnicodeString* /*actualID*/, UErrorCode& status) const override {
- LocaleKey& lkey = (LocaleKey&)key;
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
+ LocaleKey& lkey = static_cast<LocaleKey&>(const_cast<ICUServiceKey&>(key));
//int32_t kind = lkey.kind();
Locale loc;
@@ -577,9 +589,12 @@ initCalendarService(UErrorCode &status)
#ifdef U_DEBUG_CALSVC
fprintf(stderr, "Spinning up Calendar Service\n");
#endif
+ if (U_FAILURE(status)) {
+ return;
+ }
ucln_i18n_registerCleanup(UCLN_I18N_CALENDAR, calendar_cleanup);
gService = new CalendarService();
- if (gService == NULL) {
+ if (gService == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -599,7 +614,7 @@ initCalendarService(UErrorCode &status)
fprintf(stderr, "err (%s) registering classes, deleting service.....\n", u_errorName(status));
#endif
delete gService;
- gService = NULL;
+ gService = nullptr;
}
}
@@ -639,14 +654,15 @@ static const int32_t kCalendarLimits[UCAL_FIELD_COUNT][4] = {
{ 0, 0, 59, 59 }, // MINUTE
{ 0, 0, 59, 59 }, // SECOND
{ 0, 0, 999, 999 }, // MILLISECOND
- {-12*kOneHour, -12*kOneHour, 12*kOneHour, 15*kOneHour }, // ZONE_OFFSET
- { 0, 0, 1*kOneHour, 1*kOneHour }, // DST_OFFSET
+ {-16*kOneHour, -16*kOneHour, 12*kOneHour, 30*kOneHour }, // ZONE_OFFSET
+ { -1*kOneHour, -1*kOneHour, 2*kOneHour, 2*kOneHour }, // DST_OFFSET
{/*N/A*/-1, /*N/A*/-1, /*N/A*/-1, /*N/A*/-1}, // YEAR_WOY
{ 1, 1, 7, 7 }, // DOW_LOCAL
{/*N/A*/-1, /*N/A*/-1, /*N/A*/-1, /*N/A*/-1}, // EXTENDED_YEAR
{ -0x7F000000, -0x7F000000, 0x7F000000, 0x7F000000 }, // JULIAN_DAY
{ 0, 0, 24*kOneHour-1, 24*kOneHour-1 }, // MILLISECONDS_IN_DAY
{ 0, 0, 1, 1 }, // IS_LEAP_MONTH
+ { 0, 0, 11, 11 } // ORDINAL_MONTH
};
// Resource bundle tags read by this class
@@ -708,14 +724,14 @@ static const char gGregorian[] = "gregorian";
Calendar::Calendar(UErrorCode& success)
: UObject(),
-fIsTimeSet(FALSE),
-fAreFieldsSet(FALSE),
-fAreAllFieldsSet(FALSE),
-fAreFieldsVirtuallySet(FALSE),
+fIsTimeSet(false),
+fAreFieldsSet(false),
+fAreAllFieldsSet(false),
+fAreFieldsVirtuallySet(false),
fNextStamp((int32_t)kMinimumUserStamp),
fTime(0),
-fLenient(TRUE),
-fZone(NULL),
+fLenient(true),
+fZone(nullptr),
fRepeatedWallTime(UCAL_WALLTIME_LAST),
fSkippedWallTime(UCAL_WALLTIME_LAST)
{
@@ -726,24 +742,24 @@ fSkippedWallTime(UCAL_WALLTIME_LAST)
return;
}
fZone = TimeZone::createDefault();
- if (fZone == NULL) {
+ if (fZone == nullptr) {
success = U_MEMORY_ALLOCATION_ERROR;
}
- setWeekData(Locale::getDefault(), NULL, success);
+ setWeekData(Locale::getDefault(), nullptr, success);
}
// -------------------------------------
Calendar::Calendar(TimeZone* zone, const Locale& aLocale, UErrorCode& success)
: UObject(),
-fIsTimeSet(FALSE),
-fAreFieldsSet(FALSE),
-fAreAllFieldsSet(FALSE),
-fAreFieldsVirtuallySet(FALSE),
+fIsTimeSet(false),
+fAreFieldsSet(false),
+fAreAllFieldsSet(false),
+fAreFieldsVirtuallySet(false),
fNextStamp((int32_t)kMinimumUserStamp),
fTime(0),
-fLenient(TRUE),
-fZone(NULL),
+fLenient(true),
+fZone(nullptr),
fRepeatedWallTime(UCAL_WALLTIME_LAST),
fSkippedWallTime(UCAL_WALLTIME_LAST)
{
@@ -764,21 +780,21 @@ fSkippedWallTime(UCAL_WALLTIME_LAST)
clear();
fZone = zone;
- setWeekData(aLocale, NULL, success);
+ setWeekData(aLocale, nullptr, success);
}
// -------------------------------------
Calendar::Calendar(const TimeZone& zone, const Locale& aLocale, UErrorCode& success)
: UObject(),
-fIsTimeSet(FALSE),
-fAreFieldsSet(FALSE),
-fAreAllFieldsSet(FALSE),
-fAreFieldsVirtuallySet(FALSE),
+fIsTimeSet(false),
+fAreFieldsSet(false),
+fAreAllFieldsSet(false),
+fAreFieldsVirtuallySet(false),
fNextStamp((int32_t)kMinimumUserStamp),
fTime(0),
-fLenient(TRUE),
-fZone(NULL),
+fLenient(true),
+fZone(nullptr),
fRepeatedWallTime(UCAL_WALLTIME_LAST),
fSkippedWallTime(UCAL_WALLTIME_LAST)
{
@@ -789,10 +805,10 @@ fSkippedWallTime(UCAL_WALLTIME_LAST)
}
clear();
fZone = zone.clone();
- if (fZone == NULL) {
+ if (fZone == nullptr) {
success = U_MEMORY_ALLOCATION_ERROR;
}
- setWeekData(aLocale, NULL, success);
+ setWeekData(aLocale, nullptr, success);
}
// -------------------------------------
@@ -807,7 +823,7 @@ Calendar::~Calendar()
Calendar::Calendar(const Calendar &source)
: UObject(source)
{
- fZone = NULL;
+ fZone = nullptr;
*this = source;
}
@@ -829,8 +845,8 @@ Calendar::operator=(const Calendar &right)
fRepeatedWallTime = right.fRepeatedWallTime;
fSkippedWallTime = right.fSkippedWallTime;
delete fZone;
- fZone = NULL;
- if (right.fZone != NULL) {
+ fZone = nullptr;
+ if (right.fZone != nullptr) {
fZone = right.fZone->clone();
}
fFirstDayOfWeek = right.fFirstDayOfWeek;
@@ -880,11 +896,11 @@ Calendar::createInstance(const Locale& aLocale, UErrorCode& success)
Calendar * U_EXPORT2
Calendar::makeInstance(const Locale& aLocale, UErrorCode& success) {
if (U_FAILURE(success)) {
- return NULL;
+ return nullptr;
}
Locale actualLoc;
- UObject* u = NULL;
+ UObject* u = nullptr;
#if !UCONFIG_NO_SERVICE
if (isCalendarServiceUsed()) {
@@ -895,18 +911,18 @@ Calendar::makeInstance(const Locale& aLocale, UErrorCode& success) {
{
u = createStandardCalendar(getCalendarTypeForLocale(aLocale.getName()), aLocale, success);
}
- Calendar* c = NULL;
+ Calendar* c = nullptr;
if(U_FAILURE(success) || !u) {
if(U_SUCCESS(success)) { // Propagate some kind of err
success = U_INTERNAL_PROGRAM_ERROR;
}
- return NULL;
+ return nullptr;
}
#if !UCONFIG_NO_SERVICE
const UnicodeString* str = dynamic_cast<const UnicodeString*>(u);
- if(str != NULL) {
+ if(str != nullptr) {
// It's a unicode string telling us what type of calendar to load ("gregorian", etc)
// Create a Locale over this string
Locale l("");
@@ -918,7 +934,7 @@ Calendar::makeInstance(const Locale& aLocale, UErrorCode& success) {
Locale actualLoc2;
delete u;
- u = NULL;
+ u = nullptr;
// Don't overwrite actualLoc, since the actual loc from this call
// may be something like "@calendar=gregorian" -- TODO investigate
@@ -929,11 +945,11 @@ Calendar::makeInstance(const Locale& aLocale, UErrorCode& success) {
if(U_SUCCESS(success)) {
success = U_INTERNAL_PROGRAM_ERROR; // Propagate some err
}
- return NULL;
+ return nullptr;
}
str = dynamic_cast<const UnicodeString*>(c);
- if(str != NULL) {
+ if(str != nullptr) {
// recursed! Second lookup returned a UnicodeString.
// Perhaps DefaultCalendar{} was set to another locale.
#ifdef U_DEBUG_CALSVC
@@ -951,7 +967,7 @@ Calendar::makeInstance(const Locale& aLocale, UErrorCode& success) {
#endif
success = U_MISSING_RESOURCE_ERROR; // requested a calendar type which could NOT be found.
delete c;
- return NULL;
+ return nullptr;
}
#ifdef U_DEBUG_CALSVC
fprintf(stderr, "%p: setting week count data to locale %s, actual locale %s\n", c, (const char*)aLocale.getName(), (const char *)actualLoc.getName());
@@ -980,16 +996,16 @@ Calendar* U_EXPORT2
Calendar::createInstance(TimeZone* zone, const Locale& aLocale, UErrorCode& success)
{
LocalPointer<TimeZone> zonePtr(zone);
- const SharedCalendar *shared = NULL;
+ const SharedCalendar *shared = nullptr;
UnifiedCache::getByLocale(aLocale, shared, success);
if (U_FAILURE(success)) {
- return NULL;
+ return nullptr;
}
Calendar *c = (*shared)->clone();
shared->removeRef();
- if (c == NULL) {
+ if (c == nullptr) {
success = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
// Now, reset calendar to default state:
@@ -1019,7 +1035,7 @@ Calendar::getCalendarTypeFromLocale(
char *typeBuffer,
int32_t typeBufferSize,
UErrorCode &success) {
- const SharedCalendar *shared = NULL;
+ const SharedCalendar *shared = nullptr;
UnifiedCache::getByLocale(aLocale, shared, success);
if (U_FAILURE(success)) {
return;
@@ -1103,7 +1119,7 @@ Calendar::getKeywordValuesForLocale(const char* key,
commonlyUsed, &status);
if (U_FAILURE(status)) {
uenum_close(uenum);
- return NULL;
+ return nullptr;
}
UStringEnumeration* ustringenum = new UStringEnumeration(uenum);
if (ustringenum == nullptr) {
@@ -1173,13 +1189,13 @@ Calendar::setTimeInMillis( double millis, UErrorCode& status ) {
}
fTime = millis;
- fAreFieldsSet = fAreAllFieldsSet = FALSE;
- fIsTimeSet = fAreFieldsVirtuallySet = TRUE;
+ fAreFieldsSet = fAreAllFieldsSet = false;
+ fIsTimeSet = fAreFieldsVirtuallySet = true;
for (int32_t i=0; i<UCAL_FIELD_COUNT; ++i) {
fFields[i] = 0;
fStamp[i] = kUnset;
- fIsSet[i] = FALSE;
+ fIsSet[i] = false;
}
@@ -1212,8 +1228,8 @@ Calendar::set(UCalendarDateFields field, int32_t value)
recalculateStamp();
}
fStamp[field] = fNextStamp++;
- fIsSet[field] = TRUE; // Remove later
- fIsTimeSet = fAreFieldsSet = fAreFieldsVirtuallySet = FALSE;
+ fIsSet[field] = true; // Remove later
+ fIsTimeSet = fAreFieldsSet = fAreFieldsVirtuallySet = false;
}
// -------------------------------------
@@ -1252,130 +1268,14 @@ Calendar::set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t m
}
// -------------------------------------
-// For now the full getRelatedYear implementation is here;
-// per #10752 move the non-default implementation to subclasses
-// (default implementation will do no year adjustment)
-
-static int32_t gregoYearFromIslamicStart(int32_t year) {
- // ad hoc conversion, improve under #10752
- // rough est for now, ok for grego 1846-2138,
- // otherwise occasionally wrong (for 3% of years)
- int cycle, offset, shift = 0;
- if (year >= 1397) {
- cycle = (year - 1397) / 67;
- offset = (year - 1397) % 67;
- shift = 2*cycle + ((offset >= 33)? 1: 0);
- } else {
- cycle = (year - 1396) / 67 - 1;
- offset = -(year - 1396) % 67;
- shift = 2*cycle + ((offset <= 33)? 1: 0);
- }
- return year + 579 - shift;
-}
-
int32_t Calendar::getRelatedYear(UErrorCode &status) const
{
- if (U_FAILURE(status)) {
- return 0;
- }
- int32_t year = get(UCAL_EXTENDED_YEAR, status);
- if (U_FAILURE(status)) {
- return 0;
- }
- // modify for calendar type
- ECalType type = getCalendarType(getType());
- switch (type) {
- case CALTYPE_PERSIAN:
- year += 622; break;
- case CALTYPE_HEBREW:
- year -= 3760; break;
- case CALTYPE_CHINESE:
- year -= 2637; break;
- case CALTYPE_INDIAN:
- year += 79; break;
- case CALTYPE_COPTIC:
- year += 284; break;
- case CALTYPE_ETHIOPIC:
- year += 8; break;
- case CALTYPE_ETHIOPIC_AMETE_ALEM:
- year -=5492; break;
- case CALTYPE_DANGI:
- year -= 2333; break;
- case CALTYPE_ISLAMIC_CIVIL:
- case CALTYPE_ISLAMIC:
- case CALTYPE_ISLAMIC_UMALQURA:
- case CALTYPE_ISLAMIC_TBLA:
- case CALTYPE_ISLAMIC_RGSA:
- year = gregoYearFromIslamicStart(year); break;
- default:
- // CALTYPE_GREGORIAN
- // CALTYPE_JAPANESE
- // CALTYPE_BUDDHIST
- // CALTYPE_ROC
- // CALTYPE_ISO8601
- // do nothing, EXTENDED_YEAR same as Gregorian
- break;
- }
- return year;
+ return get(UCAL_EXTENDED_YEAR, status);
}
// -------------------------------------
-// For now the full setRelatedYear implementation is here;
-// per #10752 move the non-default implementation to subclasses
-// (default implementation will do no year adjustment)
-
-static int32_t firstIslamicStartYearFromGrego(int32_t year) {
- // ad hoc conversion, improve under #10752
- // rough est for now, ok for grego 1846-2138,
- // otherwise occasionally wrong (for 3% of years)
- int cycle, offset, shift = 0;
- if (year >= 1977) {
- cycle = (year - 1977) / 65;
- offset = (year - 1977) % 65;
- shift = 2*cycle + ((offset >= 32)? 1: 0);
- } else {
- cycle = (year - 1976) / 65 - 1;
- offset = -(year - 1976) % 65;
- shift = 2*cycle + ((offset <= 32)? 1: 0);
- }
- return year - 579 + shift;
-}
void Calendar::setRelatedYear(int32_t year)
{
- // modify for calendar type
- ECalType type = getCalendarType(getType());
- switch (type) {
- case CALTYPE_PERSIAN:
- year -= 622; break;
- case CALTYPE_HEBREW:
- year += 3760; break;
- case CALTYPE_CHINESE:
- year += 2637; break;
- case CALTYPE_INDIAN:
- year -= 79; break;
- case CALTYPE_COPTIC:
- year -= 284; break;
- case CALTYPE_ETHIOPIC:
- year -= 8; break;
- case CALTYPE_ETHIOPIC_AMETE_ALEM:
- year +=5492; break;
- case CALTYPE_DANGI:
- year += 2333; break;
- case CALTYPE_ISLAMIC_CIVIL:
- case CALTYPE_ISLAMIC:
- case CALTYPE_ISLAMIC_UMALQURA:
- case CALTYPE_ISLAMIC_TBLA:
- case CALTYPE_ISLAMIC_RGSA:
- year = firstIslamicStartYearFromGrego(year); break;
- default:
- // CALTYPE_GREGORIAN
- // CALTYPE_JAPANESE
- // CALTYPE_BUDDHIST
- // CALTYPE_ROC
- // CALTYPE_ISO8601
- // do nothing, EXTENDED_YEAR same as Gregorian
- break;
- }
// set extended year
set(UCAL_EXTENDED_YEAR, year);
}
@@ -1388,9 +1288,9 @@ Calendar::clear()
for (int32_t i=0; i<UCAL_FIELD_COUNT; ++i) {
fFields[i] = 0; // Must do this; other code depends on it
fStamp[i] = kUnset;
- fIsSet[i] = FALSE; // Remove later
+ fIsSet[i] = false; // Remove later
}
- fIsTimeSet = fAreFieldsSet = fAreAllFieldsSet = fAreFieldsVirtuallySet = FALSE;
+ fIsTimeSet = fAreFieldsSet = fAreAllFieldsSet = fAreFieldsVirtuallySet = false;
// fTime is not 'cleared' - may be used if no fields are set.
}
@@ -1405,8 +1305,8 @@ Calendar::clear(UCalendarDateFields field)
}
fFields[field] = 0;
fStamp[field] = kUnset;
- fIsSet[field] = FALSE; // Remove later
- fIsTimeSet = fAreFieldsSet = fAreAllFieldsSet = fAreFieldsVirtuallySet = FALSE;
+ fIsSet[field] = false; // Remove later
+ fIsTimeSet = fAreFieldsSet = fAreAllFieldsSet = fAreFieldsVirtuallySet = false;
}
// -------------------------------------
@@ -1435,6 +1335,9 @@ int32_t Calendar::newestStamp(UCalendarDateFields first, UCalendarDateFields las
void
Calendar::complete(UErrorCode& status)
{
+ if (U_FAILURE(status)) {
+ return;
+ }
if (!fIsTimeSet) {
updateTime(status);
/* Test for buffer overflows */
@@ -1448,8 +1351,8 @@ Calendar::complete(UErrorCode& status)
if(U_FAILURE(status)) {
return;
}
- fAreFieldsSet = TRUE;
- fAreAllFieldsSet = TRUE;
+ fAreFieldsSet = true;
+ fAreAllFieldsSet = true;
}
}
@@ -1486,6 +1389,9 @@ Calendar::complete(UErrorCode& status)
* @stable ICU 2.0
*/
void Calendar::pinField(UCalendarDateFields field, UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
int32_t max = getActualMaximum(field, status);
int32_t min = getActualMinimum(field, status);
@@ -1499,13 +1405,16 @@ void Calendar::pinField(UCalendarDateFields field, UErrorCode& status) {
void Calendar::computeFields(UErrorCode &ec)
{
- if (U_FAILURE(ec)) {
+ if (U_FAILURE(ec)) {
return;
}
// Compute local wall millis
double localMillis = internalGetTime();
int32_t rawOffset, dstOffset;
- getTimeZone().getOffset(localMillis, FALSE, rawOffset, dstOffset, ec);
+ getTimeZone().getOffset(localMillis, false, rawOffset, dstOffset, ec);
+ if (U_FAILURE(ec)) {
+ return;
+ }
localMillis += (rawOffset + dstOffset);
// Mark fields as set. Do this before calling handleComputeFields().
@@ -1515,15 +1424,16 @@ void Calendar::computeFields(UErrorCode &ec)
(1 << UCAL_MONTH) |
(1 << UCAL_DAY_OF_MONTH) | // = UCAL_DATE
(1 << UCAL_DAY_OF_YEAR) |
- (1 << UCAL_EXTENDED_YEAR);
+ (1 << UCAL_EXTENDED_YEAR) |
+ (1 << UCAL_ORDINAL_MONTH);
for (int32_t i=0; i<UCAL_FIELD_COUNT; ++i) {
if ((mask & 1) == 0) {
fStamp[i] = kInternallySet;
- fIsSet[i] = TRUE; // Remove later
+ fIsSet[i] = true; // Remove later
} else {
fStamp[i] = kUnset;
- fIsSet[i] = FALSE; // Remove later
+ fIsSet[i] = false; // Remove later
}
mask >>= 1;
}
@@ -1537,7 +1447,8 @@ void Calendar::computeFields(UErrorCode &ec)
// JULIAN_DAY field and also removes some inelegant code. - Liu
// 11/6/00
- int32_t days = (int32_t)ClockMath::floorDivide(localMillis, (double)kOneDay);
+ int32_t millisInDay;
+ int32_t days = ClockMath::floorDivide(localMillis, kOneDay, &millisInDay);
internalSet(UCAL_JULIAN_DAY,days + kEpochStartAsJulianDay);
@@ -1561,19 +1472,50 @@ void Calendar::computeFields(UErrorCode &ec)
// Compute time-related fields. These are independent of the date and
// of the subclass algorithm. They depend only on the local zone
// wall milliseconds in day.
- int32_t millisInDay = (int32_t) (localMillis - (days * kOneDay));
+ if (U_FAILURE(ec)) {
+ return;
+ }
+
fFields[UCAL_MILLISECONDS_IN_DAY] = millisInDay;
+ U_ASSERT(getMinimum(UCAL_MILLISECONDS_IN_DAY) <=
+ fFields[UCAL_MILLISECONDS_IN_DAY]);
+ U_ASSERT(fFields[UCAL_MILLISECONDS_IN_DAY] <=
+ getMaximum(UCAL_MILLISECONDS_IN_DAY));
+
fFields[UCAL_MILLISECOND] = millisInDay % 1000;
+ U_ASSERT(getMinimum(UCAL_MILLISECOND) <= fFields[UCAL_MILLISECOND]);
+ U_ASSERT(fFields[UCAL_MILLISECOND] <= getMaximum(UCAL_MILLISECOND));
+
millisInDay /= 1000;
fFields[UCAL_SECOND] = millisInDay % 60;
+ U_ASSERT(getMinimum(UCAL_SECOND) <= fFields[UCAL_SECOND]);
+ U_ASSERT(fFields[UCAL_SECOND] <= getMaximum(UCAL_SECOND));
+
millisInDay /= 60;
fFields[UCAL_MINUTE] = millisInDay % 60;
+ U_ASSERT(getMinimum(UCAL_MINUTE) <= fFields[UCAL_MINUTE]);
+ U_ASSERT(fFields[UCAL_MINUTE] <= getMaximum(UCAL_MINUTE));
+
millisInDay /= 60;
fFields[UCAL_HOUR_OF_DAY] = millisInDay;
+ U_ASSERT(getMinimum(UCAL_HOUR_OF_DAY) <= fFields[UCAL_HOUR_OF_DAY]);
+ U_ASSERT(fFields[UCAL_HOUR_OF_DAY] <= getMaximum(UCAL_HOUR_OF_DAY));
+
fFields[UCAL_AM_PM] = millisInDay / 12; // Assume AM == 0
+ U_ASSERT(getMinimum(UCAL_AM_PM) <= fFields[UCAL_AM_PM]);
+ U_ASSERT(fFields[UCAL_AM_PM] <= getMaximum(UCAL_AM_PM));
+
fFields[UCAL_HOUR] = millisInDay % 12;
+ U_ASSERT(getMinimum(UCAL_HOUR) <= fFields[UCAL_HOUR]);
+ U_ASSERT(fFields[UCAL_HOUR] <= getMaximum(UCAL_HOUR));
+
fFields[UCAL_ZONE_OFFSET] = rawOffset;
+ U_ASSERT(getMinimum(UCAL_ZONE_OFFSET) <= fFields[UCAL_ZONE_OFFSET]);
+ U_ASSERT(fFields[UCAL_ZONE_OFFSET] <= getMaximum(UCAL_ZONE_OFFSET));
+
fFields[UCAL_DST_OFFSET] = dstOffset;
+ U_ASSERT(getMinimum(UCAL_DST_OFFSET) <= fFields[UCAL_DST_OFFSET]);
+ U_ASSERT(fFields[UCAL_DST_OFFSET] <= getMaximum(UCAL_DST_OFFSET));
}
uint8_t Calendar::julianDayToDayOfWeek(double julian)
@@ -1595,6 +1537,9 @@ uint8_t Calendar::julianDayToDayOfWeek(double julian)
void Calendar::computeGregorianAndDOWFields(int32_t julianDay, UErrorCode &ec)
{
computeGregorianFields(julianDay, ec);
+ if (U_FAILURE(ec)) {
+ return;
+ }
// Compute day of week: JD 0 = Monday
int32_t dow = julianDayToDayOfWeek(julianDay);
@@ -1616,7 +1561,10 @@ void Calendar::computeGregorianAndDOWFields(int32_t julianDay, UErrorCode &ec)
* subclasses that are Gregorian derivatives. Subclasses may call this
* method to perform a Gregorian calendar millis->fields computation.
*/
-void Calendar::computeGregorianFields(int32_t julianDay, UErrorCode & /* ec */) {
+void Calendar::computeGregorianFields(int32_t julianDay, UErrorCode& ec) {
+ if (U_FAILURE(ec)) {
+ return;
+ }
int32_t gregorianDayOfWeekUnused;
Grego::dayToFields(julianDay - kEpochStartAsJulianDay, fGregorianYear, fGregorianMonth, fGregorianDayOfMonth, gregorianDayOfWeekUnused, fGregorianDayOfYear);
}
@@ -1699,11 +1647,20 @@ void Calendar::computeWeekFields(UErrorCode &ec) {
}
fFields[UCAL_WEEK_OF_YEAR] = woy;
fFields[UCAL_YEAR_WOY] = yearOfWeekOfYear;
+ // min/max of years are not constrains for caller, so not assert here.
// WEEK_OF_YEAR end
int32_t dayOfMonth = fFields[UCAL_DAY_OF_MONTH];
fFields[UCAL_WEEK_OF_MONTH] = weekNumber(dayOfMonth, dayOfWeek);
+ U_ASSERT(getMinimum(UCAL_WEEK_OF_MONTH) <= fFields[UCAL_WEEK_OF_MONTH]);
+ U_ASSERT(fFields[UCAL_WEEK_OF_MONTH] <= getMaximum(UCAL_WEEK_OF_MONTH));
+
fFields[UCAL_DAY_OF_WEEK_IN_MONTH] = (dayOfMonth-1) / 7 + 1;
+ U_ASSERT(getMinimum(UCAL_DAY_OF_WEEK_IN_MONTH) <=
+ fFields[UCAL_DAY_OF_WEEK_IN_MONTH]);
+ U_ASSERT(fFields[UCAL_DAY_OF_WEEK_IN_MONTH] <=
+ getMaximum(UCAL_DAY_OF_WEEK_IN_MONTH));
+
#if defined (U_DEBUG_CAL)
if(fFields[UCAL_DAY_OF_WEEK_IN_MONTH]==0) fprintf(stderr, "%s:%d: DOWIM %d on %g\n",
__FILE__, __LINE__,fFields[UCAL_DAY_OF_WEEK_IN_MONTH], fTime);
@@ -1732,9 +1689,14 @@ int32_t Calendar::weekNumber(int32_t desiredDay, int32_t dayOfPeriod, int32_t da
return weekNo;
}
-void Calendar::handleComputeFields(int32_t /* julianDay */, UErrorCode &/* status */)
+void Calendar::handleComputeFields(int32_t /* julianDay */, UErrorCode& status)
{
- internalSet(UCAL_MONTH, getGregorianMonth());
+ if (U_FAILURE(status)) {
+ return;
+ }
+ int32_t month = getGregorianMonth();
+ internalSet(UCAL_MONTH, month);
+ internalSet(UCAL_ORDINAL_MONTH, month);
internalSet(UCAL_DAY_OF_MONTH, getGregorianDayOfMonth());
internalSet(UCAL_DAY_OF_YEAR, getGregorianDayOfYear());
int32_t eyear = getGregorianYear();
@@ -1755,8 +1717,7 @@ void Calendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
roll((UCalendarDateFields)field, amount, status);
}
-void Calendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& status)
-{
+void Calendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) UPRV_NO_SANITIZE_UNDEFINED {
if (amount == 0) {
return; // Nothing to do
}
@@ -1816,6 +1777,7 @@ void Calendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& statu
}
case UCAL_MONTH:
+ case UCAL_ORDINAL_MONTH:
// Rolling the month involves both pinning the final value
// and adjusting the DAY_OF_MONTH if necessary. We only adjust the
// DAY_OF_MONTH if, after updating the MONTH field, it is illegal.
@@ -1842,13 +1804,13 @@ void Calendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& statu
// * If era==0 and years go backwards in time, change sign of amount.
// * Until we have new API per #9393, we temporarily hardcode knowledge of
// which calendars have era 0 years that go backwards.
- UBool era0WithYearsThatGoBackwards = FALSE;
+ UBool era0WithYearsThatGoBackwards = false;
int32_t era = get(UCAL_ERA, status);
if (era == 0) {
const char * calType = getType();
if ( uprv_strcmp(calType,"gregorian")==0 || uprv_strcmp(calType,"roc")==0 || uprv_strcmp(calType,"coptic")==0 ) {
amount = -amount;
- era0WithYearsThatGoBackwards = TRUE;
+ era0WithYearsThatGoBackwards = true;
}
}
int32_t newYear = internalGet(field) + amount;
@@ -1873,6 +1835,7 @@ void Calendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& statu
}
set(field, newYear);
pinField(UCAL_MONTH,status);
+ pinField(UCAL_ORDINAL_MONTH,status);
pinField(UCAL_DAY_OF_MONTH,status);
return;
}
@@ -1881,6 +1844,7 @@ void Calendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& statu
// Rolling the year can involve pinning the DAY_OF_MONTH.
set(field, internalGet(field) + amount);
pinField(UCAL_MONTH,status);
+ pinField(UCAL_ORDINAL_MONTH,status);
pinField(UCAL_DAY_OF_MONTH,status);
return;
@@ -2020,6 +1984,7 @@ void Calendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& statu
// have to be updated as well.
set(UCAL_DAY_OF_YEAR, day_of_year);
clear(UCAL_MONTH);
+ clear(UCAL_ORDINAL_MONTH);
return;
}
case UCAL_DAY_OF_YEAR:
@@ -2103,6 +2068,9 @@ void Calendar::add(EDateFields field, int32_t amount, UErrorCode& status)
// -------------------------------------
void Calendar::add(UCalendarDateFields field, int32_t amount, UErrorCode& status)
{
+ if (U_FAILURE(status)) {
+ return;
+ }
if (amount == 0) {
return; // Do nothing!
}
@@ -2114,7 +2082,7 @@ void Calendar::add(UCalendarDateFields field, int32_t amount, UErrorCode& status
// we don't want the wall time to shift due to changes in DST. If the
// result of the add operation is to move from DST to Standard, or
// vice versa, we need to adjust by an hour forward or back,
- // respectively. For such fields we set keepWallTimeInvariant to TRUE.
+ // respectively. For such fields we set keepWallTimeInvariant to true.
// We only adjust the DST for fields larger than an hour. For
// fields smaller than an hour, we cannot adjust for DST without
@@ -2129,7 +2097,7 @@ void Calendar::add(UCalendarDateFields field, int32_t amount, UErrorCode& status
// <April 30>, rather than <April 31> => <May 1>.
double delta = amount; // delta in ms
- UBool keepWallTimeInvariant = TRUE;
+ UBool keepWallTimeInvariant = true;
switch (field) {
case UCAL_ERA:
@@ -2159,12 +2127,13 @@ void Calendar::add(UCalendarDateFields field, int32_t amount, UErrorCode& status
U_FALLTHROUGH;
case UCAL_EXTENDED_YEAR:
case UCAL_MONTH:
+ case UCAL_ORDINAL_MONTH:
{
UBool oldLenient = isLenient();
- setLenient(TRUE);
+ setLenient(true);
set(field, get(field, status) + amount);
pinField(UCAL_DAY_OF_MONTH, status);
- if(oldLenient==FALSE) {
+ if(oldLenient==false) {
complete(status); /* force recalculate */
setLenient(oldLenient);
}
@@ -2192,22 +2161,22 @@ void Calendar::add(UCalendarDateFields field, int32_t amount, UErrorCode& status
case UCAL_HOUR_OF_DAY:
case UCAL_HOUR:
delta *= kOneHour;
- keepWallTimeInvariant = FALSE;
+ keepWallTimeInvariant = false;
break;
case UCAL_MINUTE:
delta *= kOneMinute;
- keepWallTimeInvariant = FALSE;
+ keepWallTimeInvariant = false;
break;
case UCAL_SECOND:
delta *= kOneSecond;
- keepWallTimeInvariant = FALSE;
+ keepWallTimeInvariant = false;
break;
case UCAL_MILLISECOND:
case UCAL_MILLISECONDS_IN_DAY:
- keepWallTimeInvariant = FALSE;
+ keepWallTimeInvariant = false;
break;
default:
@@ -2350,7 +2319,7 @@ int32_t Calendar::fieldDifference(UDate targetMs, UCalendarDateFields field, UEr
break;
} else {
min = max;
- max <<= 1;
+ max = (int32_t)((uint32_t)(max) << 1);
if (max == 0) {
// Field difference too large to fit into int32_t
#if defined (U_DEBUG_CAL)
@@ -2392,15 +2361,15 @@ int32_t Calendar::fieldDifference(UDate targetMs, UCalendarDateFields field, UEr
void
Calendar::adoptTimeZone(TimeZone* zone)
{
- // Do nothing if passed-in zone is NULL
- if (zone == NULL) return;
+ // Do nothing if passed-in zone is nullptr
+ if (zone == nullptr) return;
// fZone should always be non-null
delete fZone;
fZone = zone;
// if the zone changes, we need to recompute the time fields
- fAreFieldsSet = FALSE;
+ fAreFieldsSet = false;
}
// -------------------------------------
@@ -2415,7 +2384,7 @@ Calendar::setTimeZone(const TimeZone& zone)
const TimeZone&
Calendar::getTimeZone() const
{
- U_ASSERT(fZone != NULL);
+ U_ASSERT(fZone != nullptr);
return *fZone;
}
@@ -2426,9 +2395,9 @@ Calendar::orphanTimeZone()
{
// we let go of the time zone; the new time zone is the system default time zone
TimeZone *defaultZone = TimeZone::createDefault();
- if (defaultZone == NULL) {
- // No error handling available. Must keep fZone non-NULL, there are many unchecked uses.
- return NULL;
+ if (defaultZone == nullptr) {
+ // No error handling available. Must keep fZone non-nullptr, there are many unchecked uses.
+ return nullptr;
}
TimeZone *z = fZone;
fZone = defaultZone;
@@ -2464,7 +2433,7 @@ Calendar::setRepeatedWallTimeOption(UCalendarWallTimeOption option)
// -------------------------------------
UCalendarWallTimeOption
-Calendar::getRepeatedWallTimeOption(void) const
+Calendar::getRepeatedWallTimeOption() const
{
return fRepeatedWallTime;
}
@@ -2480,7 +2449,7 @@ Calendar::setSkippedWallTimeOption(UCalendarWallTimeOption option)
// -------------------------------------
UCalendarWallTimeOption
-Calendar::getSkippedWallTimeOption(void) const
+Calendar::getSkippedWallTimeOption() const
{
return fSkippedWallTime;
}
@@ -2488,12 +2457,11 @@ Calendar::getSkippedWallTimeOption(void) const
// -------------------------------------
void
-Calendar::setFirstDayOfWeek(UCalendarDaysOfWeek value)
-{
+Calendar::setFirstDayOfWeek(UCalendarDaysOfWeek value) UPRV_NO_SANITIZE_UNDEFINED {
if (fFirstDayOfWeek != value &&
value >= UCAL_SUNDAY && value <= UCAL_SATURDAY) {
fFirstDayOfWeek = value;
- fAreFieldsSet = FALSE;
+ fAreFieldsSet = false;
}
}
@@ -2525,7 +2493,7 @@ Calendar::setMinimalDaysInFirstWeek(uint8_t value)
}
if (fMinimalDaysInFirstWeek != value) {
fMinimalDaysInFirstWeek = value;
- fAreFieldsSet = FALSE;
+ fAreFieldsSet = false;
}
}
@@ -2592,15 +2560,15 @@ UBool
Calendar::isWeekend(UDate date, UErrorCode &status) const
{
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
// clone the calendar so we don't mess with the real one.
Calendar *work = this->clone();
- if (work == NULL) {
+ if (work == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return FALSE;
+ return false;
}
- UBool result = FALSE;
+ UBool result = false;
work->setTime(date, status);
if (U_SUCCESS(status)) {
result = work->isWeekend();
@@ -2610,7 +2578,7 @@ Calendar::isWeekend(UDate date, UErrorCode &status) const
}
UBool
-Calendar::isWeekend(void) const
+Calendar::isWeekend() const
{
UErrorCode status = U_ZERO_ERROR;
UCalendarDaysOfWeek dayOfWeek = (UCalendarDaysOfWeek)get(UCAL_DAY_OF_WEEK, status);
@@ -2618,9 +2586,9 @@ Calendar::isWeekend(void) const
if (U_SUCCESS(status)) {
switch (dayType) {
case UCAL_WEEKDAY:
- return FALSE;
+ return false;
case UCAL_WEEKEND:
- return TRUE;
+ return true;
case UCAL_WEEKEND_ONSET:
case UCAL_WEEKEND_CEASE:
// Use internalGet() because the above call to get() populated all fields.
@@ -2632,14 +2600,14 @@ Calendar::isWeekend(void) const
(millisInDay >= transitionMillis):
(millisInDay < transitionMillis);
}
- // else fall through, return FALSE
+ // else fall through, return false
U_FALLTHROUGH;
}
default:
break;
}
}
- return FALSE;
+ return false;
}
// ------------------------------------- limits
@@ -2741,10 +2709,12 @@ int32_t Calendar::getLimit(UCalendarDateFields field, ELimitType limitType) cons
}
}
-
int32_t
Calendar::getActualMinimum(UCalendarDateFields field, UErrorCode& status) const
{
+ if (U_FAILURE(status)) {
+ return 0;
+ }
int32_t fieldValue = getGreatestMinimum(field);
int32_t endValue = getMinimum(field);
@@ -2756,11 +2726,11 @@ Calendar::getActualMinimum(UCalendarDateFields field, UErrorCode& status) const
// clone the calendar so we don't mess with the real one, and set it to
// accept anything for the field values
Calendar *work = this->clone();
- if (work == NULL) {
+ if (work == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
- work->setLenient(TRUE);
+ work->setLenient(true);
// now try each value from getLeastMaximum() to getMaximum() one by one until
// we get a value that normalizes to another value. The last value that
@@ -2789,7 +2759,61 @@ Calendar::getActualMinimum(UCalendarDateFields field, UErrorCode& status) const
// -------------------------------------
+UBool
+Calendar::inDaylightTime(UErrorCode& status) const
+{
+ if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) {
+ return false;
+ }
+
+ // Force an update of the state of the Calendar.
+ ((Calendar*)this)->complete(status); // cast away const
+
+ return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : false);
+}
+
+bool
+Calendar::inTemporalLeapYear(UErrorCode& status) const
+{
+ // Default to Gregorian based leap year rule.
+ return getActualMaximum(UCAL_DAY_OF_YEAR, status) == 366;
+}
+
+// -------------------------------------
+
+static const char * const gTemporalMonthCodes[] = {
+ "M01", "M02", "M03", "M04", "M05", "M06",
+ "M07", "M08", "M09", "M10", "M11", "M12", nullptr
+};
+const char*
+Calendar::getTemporalMonthCode(UErrorCode& status) const
+{
+ int32_t month = get(UCAL_MONTH, status);
+ if (U_FAILURE(status)) return nullptr;
+ U_ASSERT(month < 12);
+ U_ASSERT(internalGet(UCAL_IS_LEAP_MONTH) == 0);
+ return gTemporalMonthCodes[month];
+}
+
+void
+Calendar::setTemporalMonthCode(const char* code, UErrorCode& status )
+{
+ if (U_FAILURE(status)) return;
+ int32_t len = static_cast<int32_t>(uprv_strlen(code));
+ if (len == 3 && code[0] == 'M') {
+ for (int m = 0; gTemporalMonthCodes[m] != nullptr; m++) {
+ if (uprv_strcmp(code, gTemporalMonthCodes[m]) == 0) {
+ set(UCAL_MONTH, m);
+ set(UCAL_IS_LEAP_MONTH, 0);
+ return;
+ }
+ }
+ }
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+}
+
+// -------------------------------------
/**
* Ensure that each field is within its valid range by calling {@link
@@ -2799,6 +2823,9 @@ Calendar::getActualMinimum(UCalendarDateFields field, UErrorCode& status) const
* @see #validateField(int)
*/
void Calendar::validateFields(UErrorCode &status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
for (int32_t field = 0; U_SUCCESS(status) && (field < UCAL_FIELD_COUNT); field++) {
if (fStamp[field] >= kMinimumUserStamp) {
validateField((UCalendarDateFields)field, status);
@@ -2814,11 +2841,14 @@ void Calendar::validateFields(UErrorCode &status) {
* @see #validateField(int, int, int)
*/
void Calendar::validateField(UCalendarDateFields field, UErrorCode &status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
int32_t y;
switch (field) {
case UCAL_DAY_OF_MONTH:
y = handleGetExtendedYear();
- validateField(field, 1, handleGetMonthLength(y, internalGet(UCAL_MONTH)), status);
+ validateField(field, 1, handleGetMonthLength(y, internalGetMonth()), status);
break;
case UCAL_DAY_OF_YEAR:
y = handleGetExtendedYear();
@@ -2850,6 +2880,9 @@ void Calendar::validateField(UCalendarDateFields field, UErrorCode &status) {
*/
void Calendar::validateField(UCalendarDateFields field, int32_t min, int32_t max, UErrorCode& status)
{
+ if (U_FAILURE(status)) {
+ return;
+ }
int32_t value = fFields[field];
if (value < min || value > max) {
#if defined (U_DEBUG_CAL)
@@ -2876,7 +2909,7 @@ UCalendarDateFields Calendar::newerField(UCalendarDateFields defaultField, UCale
return defaultField;
}
-UCalendarDateFields Calendar::resolveFields(const UFieldResolutionTable* precedenceTable) {
+UCalendarDateFields Calendar::resolveFields(const UFieldResolutionTable* precedenceTable) const {
int32_t bestField = UCAL_FIELD_COUNT;
int32_t tempBestField;
for (int32_t g=0; precedenceTable[g][0][0] != -1 && (bestField == UCAL_FIELD_COUNT); ++g) {
@@ -2945,6 +2978,16 @@ const UFieldResolutionTable Calendar::kDatePrecedence[] =
};
+const UFieldResolutionTable Calendar::kMonthPrecedence[] =
+{
+ {
+ { UCAL_MONTH,kResolveSTOP, kResolveSTOP },
+ { UCAL_ORDINAL_MONTH,kResolveSTOP, kResolveSTOP },
+ {kResolveSTOP}
+ },
+ {{kResolveSTOP}}
+};
+
const UFieldResolutionTable Calendar::kDOWPrecedence[] =
{
{
@@ -2972,6 +3015,9 @@ const UFieldResolutionTable Calendar::kYearPrecedence[] =
void Calendar::computeTime(UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
if (!isLenient()) {
validateFields(status);
if (U_FAILURE(status)) {
@@ -3050,7 +3096,7 @@ void Calendar::computeTime(UErrorCode& status) {
UDate tmpTime = millis + millisInDay - zoneOffset;
int32_t raw, dst;
- fZone->getOffset(tmpTime, FALSE, raw, dst, status);
+ fZone->getOffset(tmpTime, false, raw, dst, status);
if (U_SUCCESS(status)) {
// zoneOffset != (raw + dst) only when the given wall time fall into
@@ -3086,13 +3132,16 @@ void Calendar::computeTime(UErrorCode& status) {
* Find the previous zone transition near the given time.
*/
UBool Calendar::getImmediatePreviousZoneTransition(UDate base, UDate *transitionTime, UErrorCode& status) const {
+ if (U_FAILURE(status)) {
+ return false;
+ }
BasicTimeZone *btz = getBasicTimeZone();
if (btz) {
TimeZoneTransition trans;
- UBool hasTransition = btz->getPreviousTransition(base, TRUE, trans);
+ UBool hasTransition = btz->getPreviousTransition(base, true, trans);
if (hasTransition) {
*transitionTime = trans.getTime();
- return TRUE;
+ return true;
} else {
// Could not find any transitions.
// Note: This should never happen.
@@ -3103,7 +3152,7 @@ UBool Calendar::getImmediatePreviousZoneTransition(UDate base, UDate *transition
// TODO: We may support non-BasicTimeZone in future.
status = U_UNSUPPORTED_ERROR;
}
- return FALSE;
+ return false;
}
/**
@@ -3159,6 +3208,9 @@ double Calendar::computeMillisInDay() {
* @stable ICU 2.0
*/
int32_t Calendar::computeZoneOffset(double millis, double millisInDay, UErrorCode &ec) {
+ if (U_FAILURE(ec)) {
+ return 0;
+ }
int32_t rawOffset, dstOffset;
UDate wall = millis + millisInDay;
BasicTimeZone* btz = getBasicTimeZone();
@@ -3169,9 +3221,9 @@ int32_t Calendar::computeZoneOffset(double millis, double millisInDay, UErrorCod
} else {
const TimeZone& tz = getTimeZone();
// By default, TimeZone::getOffset behaves UCAL_WALLTIME_LAST for both.
- tz.getOffset(wall, TRUE, rawOffset, dstOffset, ec);
+ tz.getOffset(wall, true, rawOffset, dstOffset, ec);
- UBool sawRecentNegativeShift = FALSE;
+ UBool sawRecentNegativeShift = false;
if (fRepeatedWallTime == UCAL_WALLTIME_FIRST) {
// Check if the given wall time falls into repeated time range
UDate tgmt = wall - (rawOffset + dstOffset);
@@ -3180,16 +3232,16 @@ int32_t Calendar::computeZoneOffset(double millis, double millisInDay, UErrorCod
// Note: The maximum historic negative zone transition is -3 hours in the tz database.
// 6 hour window would be sufficient for this purpose.
int32_t tmpRaw, tmpDst;
- tz.getOffset(tgmt - 6*60*60*1000, FALSE, tmpRaw, tmpDst, ec);
+ tz.getOffset(tgmt - 6*60*60*1000, false, tmpRaw, tmpDst, ec);
int32_t offsetDelta = (rawOffset + dstOffset) - (tmpRaw + tmpDst);
U_ASSERT(offsetDelta < -6*60*60*1000);
if (offsetDelta < 0) {
- sawRecentNegativeShift = TRUE;
+ sawRecentNegativeShift = true;
// Negative shift within last 6 hours. When UCAL_WALLTIME_FIRST is used and the given wall time falls
// into the repeated time range, use offsets before the transition.
// Note: If it does not fall into the repeated time range, offsets remain unchanged below.
- tz.getOffset(wall + offsetDelta, TRUE, rawOffset, dstOffset, ec);
+ tz.getOffset(wall + offsetDelta, true, rawOffset, dstOffset, ec);
}
}
if (!sawRecentNegativeShift && fSkippedWallTime == UCAL_WALLTIME_FIRST) {
@@ -3199,7 +3251,7 @@ int32_t Calendar::computeZoneOffset(double millis, double millisInDay, UErrorCod
// the offsets will be based on the zone offsets AFTER
// the transition (which means, earliest possible interpretation).
UDate tgmt = wall - (rawOffset + dstOffset);
- tz.getOffset(tgmt, FALSE, rawOffset, dstOffset, ec);
+ tz.getOffset(tgmt, false, rawOffset, dstOffset, ec);
}
}
return rawOffset + dstOffset;
@@ -3218,6 +3270,7 @@ int32_t Calendar::computeJulianDay()
if (fStamp[UCAL_JULIAN_DAY] >= (int32_t)kMinimumUserStamp) {
int32_t bestStamp = newestStamp(UCAL_ERA, UCAL_DAY_OF_WEEK_IN_MONTH, kUnset);
bestStamp = newestStamp(UCAL_YEAR_WOY, UCAL_EXTENDED_YEAR, bestStamp);
+ bestStamp = newestStamp(UCAL_ORDINAL_MONTH, UCAL_ORDINAL_MONTH, bestStamp);
if (bestStamp <= fStamp[UCAL_JULIAN_DAY]) {
return internalGet(UCAL_JULIAN_DAY);
}
@@ -3257,8 +3310,8 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) {
// give calendar subclass a chance to have a default 'first' month
int32_t month;
- if(isSet(UCAL_MONTH)) {
- month = internalGet(UCAL_MONTH);
+ if(isSet(UCAL_MONTH) || isSet(UCAL_ORDINAL_MONTH)) {
+ month = internalGetMonth();
} else {
month = getDefaultMonthInYear(year);
}
@@ -3326,7 +3379,7 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) {
// past the first of the given day-of-week in this month.
// Note that we handle -2, -3, etc. correctly, even though
// values < -1 are technically disallowed.
- int32_t m = internalGet(UCAL_MONTH, UCAL_JANUARY);
+ int32_t m = internalGetMonth(UCAL_JANUARY);
int32_t monthLength = handleGetMonthLength(year, m);
date += ((monthLength - date) / 7 + dim + 1) * 7;
}
@@ -3343,7 +3396,7 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) {
// need to be sure to stay in 'real' year.
int32_t woy = internalGet(bestField);
- int32_t nextJulianDay = handleComputeMonthStart(year+1, 0, FALSE); // jd of day before jan 1
+ int32_t nextJulianDay = handleComputeMonthStart(year+1, 0, false); // jd of day before jan 1
int32_t nextFirst = julianDayToDayOfWeek(nextJulianDay + 1) - firstDayOfWeek;
if (nextFirst < 0) { // 0..6 ldow of Jan 1
@@ -3394,7 +3447,7 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) {
#endif
if(julianDay+testDate > nextJulianDay) { // is it past Dec 31? (nextJulianDay is day BEFORE year+1's Jan 1)
// Fire up the calculating engines.. retry YWOY = (year-1)
- julianDay = handleComputeMonthStart(year-1, 0, FALSE); // jd before Jan 1 of previous year
+ julianDay = handleComputeMonthStart(year-1, 0, false); // jd before Jan 1 of previous year
first = julianDayToDayOfWeek(julianDay + 1) - firstDayOfWeek; // 0 based local dow of first week
if(first < 0) { // 0..6
@@ -3474,8 +3527,8 @@ int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t w
// Now, a local DOW
int32_t dowLocal = getLocalDOW(); // 0..6
int32_t firstDayOfWeek = getFirstDayOfWeek(); // Localized fdw
- int32_t jan1Start = handleComputeMonthStart(yearWoy, 0, FALSE);
- int32_t nextJan1Start = handleComputeMonthStart(yearWoy+1, 0, FALSE); // next year's Jan1 start
+ int32_t jan1Start = handleComputeMonthStart(yearWoy, 0, false);
+ int32_t nextJan1Start = handleComputeMonthStart(yearWoy+1, 0, false); // next year's Jan1 start
// At this point julianDay is the 0-based day BEFORE the first day of
// January 1, year 1 of the given calendar. If julianDay == 0, it
@@ -3501,21 +3554,21 @@ int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t w
//}
int32_t minDays = getMinimalDaysInFirstWeek();
- UBool jan1InPrevYear = FALSE; // January 1st in the year of WOY is the 1st week? (i.e. first week is < minimal )
- //UBool nextJan1InPrevYear = FALSE; // January 1st of Year of WOY + 1 is in the first week?
+ UBool jan1InPrevYear = false; // January 1st in the year of WOY is the 1st week? (i.e. first week is < minimal )
+ //UBool nextJan1InPrevYear = false; // January 1st of Year of WOY + 1 is in the first week?
if((7 - first) < minDays) {
- jan1InPrevYear = TRUE;
+ jan1InPrevYear = true;
}
// if((7 - nextFirst) < minDays) {
- // nextJan1InPrevYear = TRUE;
+ // nextJan1InPrevYear = true;
// }
switch(bestField) {
case UCAL_WEEK_OF_YEAR:
if(woy == 1) {
- if(jan1InPrevYear == TRUE) {
+ if(jan1InPrevYear) {
// the first week of January is in the previous year
// therefore WOY1 is always solidly within yearWoy
return yearWoy;
@@ -3534,7 +3587,7 @@ int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t w
(7-first) + // days in the first week (Jan 1.. )
(woy-1)*7 + // add the weeks of the year
dowLocal; // the local dow (0..6) of last week
- if(jan1InPrevYear==FALSE) {
+ if(jan1InPrevYear==false) {
jd -= 7; // woy already includes Jan 1's week.
}
@@ -3551,23 +3604,25 @@ int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t w
}
case UCAL_DATE:
- if((internalGet(UCAL_MONTH)==0) &&
+ {
+ int32_t m = internalGetMonth();
+ if((m == 0) &&
(woy >= getLeastMaximum(UCAL_WEEK_OF_YEAR))) {
return yearWoy+1; // month 0, late woy = in the next year
} else if(woy==1) {
//if(nextJan1InPrevYear) {
- if(internalGet(UCAL_MONTH)==0) {
+ if(m == 0) {
return yearWoy;
} else {
return yearWoy-1;
}
//}
}
-
- //(internalGet(UCAL_DATE) <= (7-first)) /* && in minDow */ ) {
- //within 1st week and in this month..
- //return yearWoy+1;
- return yearWoy;
+ }
+ //(internalGet(UCAL_DATE) <= (7-first)) /* && in minDow */ ) {
+ //within 1st week and in this month..
+ //return yearWoy+1;
+ return yearWoy;
default: // assume the year is appropriate
return yearWoy;
@@ -3576,18 +3631,21 @@ int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t w
int32_t Calendar::handleGetMonthLength(int32_t extendedYear, int32_t month) const
{
- return handleComputeMonthStart(extendedYear, month+1, TRUE) -
- handleComputeMonthStart(extendedYear, month, TRUE);
+ return handleComputeMonthStart(extendedYear, month+1, true) -
+ handleComputeMonthStart(extendedYear, month, true);
}
int32_t Calendar::handleGetYearLength(int32_t eyear) const {
- return handleComputeMonthStart(eyear+1, 0, FALSE) -
- handleComputeMonthStart(eyear, 0, FALSE);
+ return handleComputeMonthStart(eyear+1, 0, false) -
+ handleComputeMonthStart(eyear, 0, false);
}
int32_t
Calendar::getActualMaximum(UCalendarDateFields field, UErrorCode& status) const
{
+ if (U_FAILURE(status)) {
+ return 0;
+ }
int32_t result;
switch (field) {
case UCAL_DATE:
@@ -3595,8 +3653,8 @@ Calendar::getActualMaximum(UCalendarDateFields field, UErrorCode& status) const
if(U_FAILURE(status)) return 0;
Calendar *cal = clone();
if(!cal) { status = U_MEMORY_ALLOCATION_ERROR; return 0; }
- cal->setLenient(TRUE);
- cal->prepareGetActual(field,FALSE,status);
+ cal->setLenient(true);
+ cal->prepareGetActual(field,false,status);
result = handleGetMonthLength(cal->get(UCAL_EXTENDED_YEAR, status), cal->get(UCAL_MONTH, status));
delete cal;
}
@@ -3607,8 +3665,8 @@ Calendar::getActualMaximum(UCalendarDateFields field, UErrorCode& status) const
if(U_FAILURE(status)) return 0;
Calendar *cal = clone();
if(!cal) { status = U_MEMORY_ALLOCATION_ERROR; return 0; }
- cal->setLenient(TRUE);
- cal->prepareGetActual(field,FALSE,status);
+ cal->setLenient(true);
+ cal->prepareGetActual(field,false,status);
result = handleGetYearLength(cal->get(UCAL_EXTENDED_YEAR, status));
delete cal;
}
@@ -3630,6 +3688,10 @@ Calendar::getActualMaximum(UCalendarDateFields field, UErrorCode& status) const
result = getMaximum(field);
break;
+ case UCAL_ORDINAL_MONTH:
+ result = inTemporalLeapYear(status) ? getMaximum(UCAL_ORDINAL_MONTH) : getLeastMaximum(UCAL_ORDINAL_MONTH);
+ break;
+
default:
// For all other fields, do it the hard way....
result = getActualHelper(field, getLeastMaximum(field), getMaximum(field),status);
@@ -3662,6 +3724,9 @@ Calendar::getActualMaximum(UCalendarDateFields field, UErrorCode& status) const
*/
void Calendar::prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErrorCode &status)
{
+ if (U_FAILURE(status)) {
+ return;
+ }
set(UCAL_MILLISECONDS_IN_DAY, 0);
switch (field) {
@@ -3717,6 +3782,9 @@ int32_t Calendar::getActualHelper(UCalendarDateFields field, int32_t startValue,
#if defined (U_DEBUG_CAL)
fprintf(stderr, "getActualHelper(%d,%d .. %d, %s)\n", field, startValue, endValue, u_errorName(status));
#endif
+ if (U_FAILURE(status)) {
+ return 0;
+ }
if (startValue == endValue) {
// if we know that the maximum value is always the same, just return it
return startValue;
@@ -3734,7 +3802,7 @@ int32_t Calendar::getActualHelper(UCalendarDateFields field, int32_t startValue,
// may cause conflict with fields previously set (but not yet resolved).
work->complete(status);
- work->setLenient(TRUE);
+ work->setLenient(true);
work->prepareGetActual(field, delta < 0, status);
// now try each value from the start to the end one by one until
@@ -3822,12 +3890,12 @@ Calendar::setWeekData(const Locale& desiredLocale, const char *type, UErrorCode&
// Get the monthNames resource bundle for the calendar 'type'. Fallback to gregorian if the resource is not
// found.
- LocalUResourceBundlePointer calData(ures_open(NULL, useLocale.getBaseName(), &status));
+ LocalUResourceBundlePointer calData(ures_open(nullptr, useLocale.getBaseName(), &status));
ures_getByKey(calData.getAlias(), gCalendar, calData.getAlias(), &status);
LocalUResourceBundlePointer monthNames;
- if (type != NULL && *type != '\0' && uprv_strcmp(type, gGregorian) != 0) {
- monthNames.adoptInstead(ures_getByKeyWithFallback(calData.getAlias(), type, NULL, &status));
+ if (type != nullptr && *type != '\0' && uprv_strcmp(type, gGregorian) != 0) {
+ monthNames.adoptInstead(ures_getByKeyWithFallback(calData.getAlias(), type, nullptr, &status));
ures_getByKeyWithFallback(monthNames.getAlias(), gMonthNames,
monthNames.getAlias(), &status);
}
@@ -3850,15 +3918,15 @@ Calendar::setWeekData(const Locale& desiredLocale, const char *type, UErrorCode&
}
char region[ULOC_COUNTRY_CAPACITY];
- (void)ulocimp_getRegionForSupplementalData(desiredLocale.getName(), TRUE, region, sizeof(region), &status);
+ (void)ulocimp_getRegionForSupplementalData(desiredLocale.getName(), true, region, sizeof(region), &status);
// Read week data values from supplementalData week data
- UResourceBundle *rb = ures_openDirect(NULL, "supplementalData", &status);
+ UResourceBundle *rb = ures_openDirect(nullptr, "supplementalData", &status);
ures_getByKey(rb, "weekData", rb, &status);
- UResourceBundle *weekData = ures_getByKey(rb, region, NULL, &status);
- if (status == U_MISSING_RESOURCE_ERROR && rb != NULL) {
+ UResourceBundle *weekData = ures_getByKey(rb, region, nullptr, &status);
+ if (status == U_MISSING_RESOURCE_ERROR && rb != nullptr) {
status = U_ZERO_ERROR;
- weekData = ures_getByKey(rb, "001", NULL, &status);
+ weekData = ures_getByKey(rb, "001", nullptr, &status);
}
if (U_FAILURE(status)) {
@@ -3880,6 +3948,29 @@ Calendar::setWeekData(const Locale& desiredLocale, const char *type, UErrorCode&
} else {
status = U_INVALID_FORMAT_ERROR;
}
+
+ // Check if the locale has a "fw" u extension and we honor it if present.
+ // And we don't change the overal status, as the presence / lack of "fw" is not an error.
+ UErrorCode fwStatus = U_ZERO_ERROR;
+ char fwExt[ULOC_FULLNAME_CAPACITY] = "";
+ desiredLocale.getKeywordValue("fw", fwExt, ULOC_FULLNAME_CAPACITY, fwStatus);
+ if (U_SUCCESS(fwStatus)) {
+ if (uprv_strcmp(fwExt, "sun") == 0) {
+ fFirstDayOfWeek = UCAL_SUNDAY;
+ } else if (uprv_strcmp(fwExt, "mon") == 0) {
+ fFirstDayOfWeek = UCAL_MONDAY;
+ } else if (uprv_strcmp(fwExt, "tue") == 0) {
+ fFirstDayOfWeek = UCAL_TUESDAY;
+ } else if (uprv_strcmp(fwExt, "wed") == 0) {
+ fFirstDayOfWeek = UCAL_WEDNESDAY;
+ } else if (uprv_strcmp(fwExt, "thu") == 0) {
+ fFirstDayOfWeek = UCAL_THURSDAY;
+ } else if (uprv_strcmp(fwExt, "fri") == 0) {
+ fFirstDayOfWeek = UCAL_FRIDAY;
+ } else if (uprv_strcmp(fwExt, "sat") == 0) {
+ fFirstDayOfWeek = UCAL_SATURDAY;
+ }
+ }
}
ures_close(weekData);
ures_close(rb);
@@ -3901,10 +3992,10 @@ Calendar::updateTime(UErrorCode& status)
// the values. Also, if we haven't set all the fields yet (i.e.,
// in a newly-created object), we need to fill in the fields. [LIU]
if (isLenient() || ! fAreAllFieldsSet)
- fAreFieldsSet = FALSE;
+ fAreFieldsSet = false;
- fIsTimeSet = TRUE;
- fAreFieldsVirtuallySet = FALSE;
+ fIsTimeSet = true;
+ fAreFieldsVirtuallySet = false;
}
Locale
@@ -3953,15 +4044,29 @@ Calendar::internalSet(EDateFields field, int32_t value)
internalSet((UCalendarDateFields) field, value);
}
+int32_t Calendar::internalGetMonth() const {
+ if (resolveFields(kMonthPrecedence) == UCAL_MONTH) {
+ return internalGet(UCAL_MONTH);
+ }
+ return internalGet(UCAL_ORDINAL_MONTH);
+}
+
+int32_t Calendar::internalGetMonth(int32_t defaultValue) const {
+ if (resolveFields(kMonthPrecedence) == UCAL_MONTH) {
+ return internalGet(UCAL_MONTH, defaultValue);
+ }
+ return internalGet(UCAL_ORDINAL_MONTH);
+}
+
BasicTimeZone*
-Calendar::getBasicTimeZone(void) const {
- if (dynamic_cast<const OlsonTimeZone *>(fZone) != NULL
- || dynamic_cast<const SimpleTimeZone *>(fZone) != NULL
- || dynamic_cast<const RuleBasedTimeZone *>(fZone) != NULL
- || dynamic_cast<const VTimeZone *>(fZone) != NULL) {
+Calendar::getBasicTimeZone() const {
+ if (dynamic_cast<const OlsonTimeZone *>(fZone) != nullptr
+ || dynamic_cast<const SimpleTimeZone *>(fZone) != nullptr
+ || dynamic_cast<const RuleBasedTimeZone *>(fZone) != nullptr
+ || dynamic_cast<const VTimeZone *>(fZone) != nullptr) {
return (BasicTimeZone*)fZone;
}
- return NULL;
+ return nullptr;
}
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/casetrn.cpp b/contrib/libs/icu/i18n/casetrn.cpp
index bb650f8fa2..2f9699ee9d 100644
--- a/contrib/libs/icu/i18n/casetrn.cpp
+++ b/contrib/libs/icu/i18n/casetrn.cpp
@@ -71,13 +71,13 @@ utrans_rep_caseContextIterator(void *context, int8_t dir)
c=rep->char32At(csc->index);
if(c<0) {
csc->limit=csc->index;
- csc->b1=TRUE;
+ csc->b1=true;
} else {
csc->index+=U16_LENGTH(c);
return c;
}
} else {
- csc->b1=TRUE;
+ csc->b1=true;
}
}
return U_SENTINEL;
@@ -147,7 +147,7 @@ void CaseMapTransliterator::handleTransliterate(Replaceable& text,
csc.limit = offsets.contextLimit;
UnicodeString tmp;
- const UChar *s;
+ const char16_t *s;
UChar32 c;
int32_t textPos, delta, result;
@@ -170,7 +170,7 @@ void CaseMapTransliterator::handleTransliterate(Replaceable& text,
// see UCASE_MAX_STRING_LENGTH
if(result<=UCASE_MAX_STRING_LENGTH) {
// string s[result]
- tmp.setTo(FALSE, s, result);
+ tmp.setTo(false, s, result);
delta=result-U16_LENGTH(c);
} else {
// single code point
diff --git a/contrib/libs/icu/i18n/cecal.cpp b/contrib/libs/icu/i18n/cecal.cpp
index cb97c40a3c..456801ee37 100644
--- a/contrib/libs/icu/i18n/cecal.cpp
+++ b/contrib/libs/icu/i18n/cecal.cpp
@@ -13,6 +13,7 @@
#include "cecal.h"
#include "gregoimp.h" //Math
+#include "cstring.h"
U_NAMESPACE_BEGIN
@@ -42,6 +43,7 @@ static const int32_t LIMITS[UCAL_FIELD_COUNT][4] = {
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // JULIAN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // MILLISECONDS_IN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // IS_LEAP_MONTH
+ { 0, 0, 12, 12}, // ORDINAL_MONTH
};
//-------------------------------------------------------------------------
@@ -87,22 +89,9 @@ CECalendar::handleGetLimit(UCalendarDateFields field, ELimitType limitType) cons
}
UBool
-CECalendar::inDaylightTime(UErrorCode& status) const
-{
- if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) {
- return FALSE;
- }
-
- // Force an update of the state of the Calendar.
- ((CECalendar*)this)->complete(status); // cast away const
-
- return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : FALSE);
-}
-
-UBool
CECalendar::haveDefaultCentury() const
{
- return TRUE;
+ return true;
}
//-------------------------------------------------------------------------
@@ -135,7 +124,7 @@ CECalendar::jdToCE(int32_t julianDay, int32_t jdEpochOffset, int32_t& year, int3
int32_t c4; // number of 4 year cycle (1461 days)
int32_t r4; // remainder of 4 year cycle, always positive
- c4 = ClockMath::floorDivide(julianDay - jdEpochOffset, 1461, r4);
+ c4 = ClockMath::floorDivide(julianDay - jdEpochOffset, 1461, &r4);
year = 4 * c4 + (r4/365 - r4/1460); // 4 * <number of 4year cycle> + <years within the last cycle>
@@ -145,6 +134,24 @@ CECalendar::jdToCE(int32_t julianDay, int32_t jdEpochOffset, int32_t& year, int3
day = (doy % 30) + 1; // 1-based days in a month
}
+static const char* kMonthCode13 = "M13";
+
+const char* CECalendar::getTemporalMonthCode(UErrorCode& status) const {
+ if (get(UCAL_MONTH, status) == 12) return kMonthCode13;
+ return Calendar::getTemporalMonthCode(status);
+}
+
+void
+CECalendar::setTemporalMonthCode(const char* code, UErrorCode& status) {
+ if (U_FAILURE(status)) return;
+ if (uprv_strcmp(code, kMonthCode13) == 0) {
+ set(UCAL_MONTH, 12);
+ set(UCAL_IS_LEAP_MONTH, 0);
+ return;
+ }
+ Calendar::setTemporalMonthCode(code, status);
+}
+
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/contrib/libs/icu/i18n/cecal.h b/contrib/libs/icu/i18n/cecal.h
index 9ac71f6ba3..16f36a7976 100644
--- a/contrib/libs/icu/i18n/cecal.h
+++ b/contrib/libs/icu/i18n/cecal.h
@@ -24,6 +24,36 @@ U_NAMESPACE_BEGIN
*/
class U_I18N_API CECalendar : public Calendar {
+public:
+
+ /**
+ * Gets The Temporal monthCode value corresponding to the month for the date.
+ * The value is a string identifier that starts with the literal grapheme
+ * "M" followed by two graphemes representing the zero-padded month number
+ * of the current month in a normal (non-leap) year. For the short thirteen
+ * month in each year in the CECalendar, the value is "M13".
+ *
+ * @param status ICU Error Code
+ * @return One of 13 possible strings in {"M01".. "M12", "M13"}.
+ * @draft ICU 73
+ */
+ virtual const char* getTemporalMonthCode(UErrorCode& status) const override;
+
+ /**
+ * Sets The Temporal monthCode which is a string identifier that starts
+ * with the literal grapheme "M" followed by two graphemes representing
+ * the zero-padded month number of the current month in a normal
+ * (non-leap) year. For CECalendar calendar, the values
+ * are "M01" .. "M13" while the "M13" is represent the short thirteen month
+ * in each year.
+ *
+ * @param temporalMonth The value to be set for temporal monthCode.
+ * @param status ICU Error Code
+ *
+ * @draft ICU 73
+ */
+ virtual void setTemporalMonthCode(const char* code, UErrorCode& status) override;
+
protected:
//-------------------------------------------------------------------------
// Constructors...
@@ -77,17 +107,6 @@ protected:
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const override;
/**
- * (Overrides Calendar) Return true if the current date for this Calendar is in
- * Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
- *
- * @param status Fill-in parameter which receives the status of this operation.
- * @return True if the current date for this Calendar is in Daylight Savings Time,
- * false, otherwise.
- * @internal
- */
- virtual UBool inDaylightTime(UErrorCode&) const override;
-
- /**
* Returns true because Coptic/Ethiopic Calendar does have a default century
* @internal
*/
diff --git a/contrib/libs/icu/i18n/chnsecal.cpp b/contrib/libs/icu/i18n/chnsecal.cpp
index f8fb4a40f1..58685632e0 100644
--- a/contrib/libs/icu/i18n/chnsecal.cpp
+++ b/contrib/libs/icu/i18n/chnsecal.cpp
@@ -26,6 +26,7 @@
#include "unicode/simpletz.h"
#include "uhash.h"
#include "ucln_in.h"
+#include "cstring.h"
// Debugging
#ifdef U_DEBUG_CHNSECAL
@@ -52,14 +53,14 @@ static void debug_chnsecal_msg(const char *pat, ...)
// --- The cache --
static icu::UMutex astroLock;
-static icu::CalendarAstronomer *gChineseCalendarAstro = NULL;
+static icu::CalendarAstronomer *gChineseCalendarAstro = nullptr;
// Lazy Creation & Access synchronized by class CalendarCache with a mutex.
-static icu::CalendarCache *gChineseCalendarWinterSolsticeCache = NULL;
-static icu::CalendarCache *gChineseCalendarNewYearCache = NULL;
+static icu::CalendarCache *gChineseCalendarWinterSolsticeCache = nullptr;
+static icu::CalendarCache *gChineseCalendarNewYearCache = nullptr;
-static icu::TimeZone *gChineseCalendarZoneAstroCalc = NULL;
-static icu::UInitOnce gChineseCalendarZoneAstroCalcInitOnce = U_INITONCE_INITIALIZER;
+static icu::TimeZone *gChineseCalendarZoneAstroCalc = nullptr;
+static icu::UInitOnce gChineseCalendarZoneAstroCalcInitOnce {};
/**
* The start year of the Chinese calendar, the 61st year of the reign
@@ -85,25 +86,25 @@ static const int32_t SYNODIC_GAP = 25;
U_CDECL_BEGIN
-static UBool calendar_chinese_cleanup(void) {
+static UBool calendar_chinese_cleanup() {
if (gChineseCalendarAstro) {
delete gChineseCalendarAstro;
- gChineseCalendarAstro = NULL;
+ gChineseCalendarAstro = nullptr;
}
if (gChineseCalendarWinterSolsticeCache) {
delete gChineseCalendarWinterSolsticeCache;
- gChineseCalendarWinterSolsticeCache = NULL;
+ gChineseCalendarWinterSolsticeCache = nullptr;
}
if (gChineseCalendarNewYearCache) {
delete gChineseCalendarNewYearCache;
- gChineseCalendarNewYearCache = NULL;
+ gChineseCalendarNewYearCache = nullptr;
}
if (gChineseCalendarZoneAstroCalc) {
delete gChineseCalendarZoneAstroCalc;
- gChineseCalendarZoneAstroCalc = NULL;
+ gChineseCalendarZoneAstroCalc = nullptr;
}
gChineseCalendarZoneAstroCalcInitOnce.reset();
- return TRUE;
+ return true;
}
U_CDECL_END
@@ -124,7 +125,7 @@ ChineseCalendar* ChineseCalendar::clone() const {
ChineseCalendar::ChineseCalendar(const Locale& aLocale, UErrorCode& success)
: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success),
- isLeapYear(FALSE),
+ hasLeapMonthBetweenWinterSolstices(false),
fEpochYear(CHINESE_EPOCH_YEAR),
fZoneAstroCalc(getChineseCalZoneAstroCalc())
{
@@ -134,7 +135,7 @@ ChineseCalendar::ChineseCalendar(const Locale& aLocale, UErrorCode& success)
ChineseCalendar::ChineseCalendar(const Locale& aLocale, int32_t epochYear,
const TimeZone* zoneAstroCalc, UErrorCode &success)
: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success),
- isLeapYear(FALSE),
+ hasLeapMonthBetweenWinterSolstices(false),
fEpochYear(epochYear),
fZoneAstroCalc(zoneAstroCalc)
{
@@ -142,7 +143,7 @@ ChineseCalendar::ChineseCalendar(const Locale& aLocale, int32_t epochYear,
}
ChineseCalendar::ChineseCalendar(const ChineseCalendar& other) : Calendar(other) {
- isLeapYear = other.isLeapYear;
+ hasLeapMonthBetweenWinterSolstices = other.hasLeapMonthBetweenWinterSolstices;
fEpochYear = other.fEpochYear;
fZoneAstroCalc = other.fZoneAstroCalc;
}
@@ -160,7 +161,7 @@ static void U_CALLCONV initChineseCalZoneAstroCalc() {
ucln_i18n_registerCleanup(UCLN_I18N_CHINESE_CALENDAR, calendar_chinese_cleanup);
}
-const TimeZone* ChineseCalendar::getChineseCalZoneAstroCalc(void) const {
+const TimeZone* ChineseCalendar::getChineseCalZoneAstroCalc() const {
umtx_initOnce(gChineseCalendarZoneAstroCalcInitOnce, &initChineseCalZoneAstroCalc);
return gChineseCalendarZoneAstroCalc;
}
@@ -196,6 +197,7 @@ static const int32_t LIMITS[UCAL_FIELD_COUNT][4] = {
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // JULIAN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // MILLISECONDS_IN_DAY
{ 0, 0, 1, 1}, // IS_LEAP_MONTH
+ { 0, 0, 11, 12}, // ORDINAL_MONTH
};
@@ -239,9 +241,9 @@ int32_t ChineseCalendar::handleGetExtendedYear() {
* @stable ICU 2.8
*/
int32_t ChineseCalendar::handleGetMonthLength(int32_t extendedYear, int32_t month) const {
- int32_t thisStart = handleComputeMonthStart(extendedYear, month, TRUE) -
+ int32_t thisStart = handleComputeMonthStart(extendedYear, month, true) -
kEpochStartAsJulianDay + 1; // Julian day -> local days
- int32_t nextStart = newMoonNear(thisStart + SYNODIC_GAP, TRUE);
+ int32_t nextStart = newMoonNear(thisStart + SYNODIC_GAP, true);
return nextStart - thisStart;
}
@@ -267,7 +269,7 @@ void ChineseCalendar::handleComputeFields(int32_t julianDay, UErrorCode &/*statu
computeChineseFields(julianDay - kEpochStartAsJulianDay, // local days
getGregorianYear(), getGregorianMonth(),
- TRUE); // set all fields
+ true); // set all fields
}
/**
@@ -321,25 +323,25 @@ const UFieldResolutionTable* ChineseCalendar::getFieldResolutionTable() const {
* @stable ICU 2.8
*/
int32_t ChineseCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, UBool useMonth) const {
-
ChineseCalendar *nonConstThis = (ChineseCalendar*)this; // cast away const
// If the month is out of range, adjust it into range, and
// modify the extended year value accordingly.
if (month < 0 || month > 11) {
double m = month;
- eyear += (int32_t)ClockMath::floorDivide(m, 12.0, m);
+ eyear += (int32_t)ClockMath::floorDivide(m, 12.0, &m);
month = (int32_t)m;
}
int32_t gyear = eyear + fEpochYear - 1; // Gregorian year
int32_t theNewYear = newYear(gyear);
- int32_t newMoon = newMoonNear(theNewYear + month * 29, TRUE);
+ int32_t newMoon = newMoonNear(theNewYear + month * 29, true);
int32_t julianDay = newMoon + kEpochStartAsJulianDay;
// Save fields for later restoration
int32_t saveMonth = internalGet(UCAL_MONTH);
+ int32_t saveOrdinalMonth = internalGet(UCAL_ORDINAL_MONTH);
int32_t saveIsLeapMonth = internalGet(UCAL_IS_LEAP_MONTH);
// Ignore IS_LEAP_MONTH field if useMonth is false
@@ -352,17 +354,17 @@ int32_t ChineseCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, U
// This will modify the MONTH and IS_LEAP_MONTH fields (only)
nonConstThis->computeChineseFields(newMoon, getGregorianYear(),
- getGregorianMonth(), FALSE);
+ getGregorianMonth(), false);
if (month != internalGet(UCAL_MONTH) ||
isLeapMonth != internalGet(UCAL_IS_LEAP_MONTH)) {
- newMoon = newMoonNear(newMoon + SYNODIC_GAP, TRUE);
+ newMoon = newMoonNear(newMoon + SYNODIC_GAP, true);
julianDay = newMoon + kEpochStartAsJulianDay;
}
nonConstThis->internalSet(UCAL_MONTH, saveMonth);
+ nonConstThis->internalSet(UCAL_ORDINAL_MONTH, saveOrdinalMonth);
nonConstThis->internalSet(UCAL_IS_LEAP_MONTH, saveIsLeapMonth);
-
return julianDay - 1;
}
@@ -374,6 +376,7 @@ int32_t ChineseCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, U
void ChineseCalendar::add(UCalendarDateFields field, int32_t amount, UErrorCode& status) {
switch (field) {
case UCAL_MONTH:
+ case UCAL_ORDINAL_MONTH:
if (amount != 0) {
int32_t dom = get(UCAL_DAY_OF_MONTH, status);
if (U_FAILURE(status)) break;
@@ -404,6 +407,7 @@ void ChineseCalendar::add(EDateFields field, int32_t amount, UErrorCode& status)
void ChineseCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) {
switch (field) {
case UCAL_MONTH:
+ case UCAL_ORDINAL_MONTH:
if (amount != 0) {
int32_t dom = get(UCAL_DAY_OF_MONTH, status);
if (U_FAILURE(status)) break;
@@ -419,7 +423,7 @@ void ChineseCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode
// leap year.
int32_t m = get(UCAL_MONTH, status); // 0-based month
if (U_FAILURE(status)) break;
- if (isLeapYear) { // (member variable)
+ if (hasLeapMonthBetweenWinterSolstices) { // (member variable)
if (get(UCAL_IS_LEAP_MONTH, status) == 1) {
++m;
} else {
@@ -432,7 +436,7 @@ void ChineseCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode
// otherwise it will be the start of month 1.
int moon1 = moon -
(int) (CalendarAstronomer::SYNODIC_MONTH * (m - 0.5));
- moon1 = newMoonNear(moon1, TRUE);
+ moon1 = newMoonNear(moon1, true);
if (isLeapMonthBetween(moon1, moon)) {
++m;
}
@@ -442,7 +446,7 @@ void ChineseCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode
// Now do the standard roll computation on m, with the
// allowed range of 0..n-1, where n is 12 or 13.
- int32_t n = isLeapYear ? 13 : 12; // Months in this year
+ int32_t n = hasLeapMonthBetweenWinterSolstices ? 13 : 12; // Months in this year
int32_t newM = (m + amount) % n;
if (newM < 0) {
newM += n;
@@ -482,10 +486,10 @@ void ChineseCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status
*/
double ChineseCalendar::daysToMillis(double days) const {
double millis = days * (double)kOneDay;
- if (fZoneAstroCalc != NULL) {
+ if (fZoneAstroCalc != nullptr) {
int32_t rawOffset, dstOffset;
UErrorCode status = U_ZERO_ERROR;
- fZoneAstroCalc->getOffset(millis, FALSE, rawOffset, dstOffset, status);
+ fZoneAstroCalc->getOffset(millis, false, rawOffset, dstOffset, status);
if (U_SUCCESS(status)) {
return millis - (double)(rawOffset + dstOffset);
}
@@ -499,10 +503,10 @@ double ChineseCalendar::daysToMillis(double days) const {
* @return days after January 1, 1970 0:00 in the astronomical base zone
*/
double ChineseCalendar::millisToDays(double millis) const {
- if (fZoneAstroCalc != NULL) {
+ if (fZoneAstroCalc != nullptr) {
int32_t rawOffset, dstOffset;
UErrorCode status = U_ZERO_ERROR;
- fZoneAstroCalc->getOffset(millis, FALSE, rawOffset, dstOffset, status);
+ fZoneAstroCalc->getOffset(millis, false, rawOffset, dstOffset, status);
if (U_SUCCESS(status)) {
return ClockMath::floorDivide(millis + (double)(rawOffset + dstOffset), kOneDay);
}
@@ -536,12 +540,12 @@ int32_t ChineseCalendar::winterSolstice(int32_t gyear) const {
double ms = daysToMillis(Grego::fieldsToDay(gyear, UCAL_DECEMBER, 1));
umtx_lock(&astroLock);
- if(gChineseCalendarAstro == NULL) {
+ if(gChineseCalendarAstro == nullptr) {
gChineseCalendarAstro = new CalendarAstronomer();
ucln_i18n_registerCleanup(UCLN_I18N_CHINESE_CALENDAR, calendar_chinese_cleanup);
}
gChineseCalendarAstro->setTime(ms);
- UDate solarLong = gChineseCalendarAstro->getSunTime(CalendarAstronomer::WINTER_SOLSTICE(), TRUE);
+ UDate solarLong = gChineseCalendarAstro->getSunTime(CalendarAstronomer::WINTER_SOLSTICE(), true);
umtx_unlock(&astroLock);
// Winter solstice is 270 degrees solar longitude aka Dongzhi
@@ -566,7 +570,7 @@ int32_t ChineseCalendar::winterSolstice(int32_t gyear) const {
int32_t ChineseCalendar::newMoonNear(double days, UBool after) const {
umtx_lock(&astroLock);
- if(gChineseCalendarAstro == NULL) {
+ if(gChineseCalendarAstro == nullptr) {
gChineseCalendarAstro = new CalendarAstronomer();
ucln_i18n_registerCleanup(UCLN_I18N_CHINESE_CALENDAR, calendar_chinese_cleanup);
}
@@ -598,7 +602,7 @@ int32_t ChineseCalendar::synodicMonthsBetween(int32_t day1, int32_t day2) const
int32_t ChineseCalendar::majorSolarTerm(int32_t days) const {
umtx_lock(&astroLock);
- if(gChineseCalendarAstro == NULL) {
+ if(gChineseCalendarAstro == nullptr) {
gChineseCalendarAstro = new CalendarAstronomer();
ucln_i18n_registerCleanup(UCLN_I18N_CHINESE_CALENDAR, calendar_chinese_cleanup);
}
@@ -621,7 +625,7 @@ int32_t ChineseCalendar::majorSolarTerm(int32_t days) const {
*/
UBool ChineseCalendar::hasNoMajorSolarTerm(int32_t newMoon) const {
return majorSolarTerm(newMoon) ==
- majorSolarTerm(newMoonNear(newMoon + SYNODIC_GAP, TRUE));
+ majorSolarTerm(newMoonNear(newMoon + SYNODIC_GAP, true));
}
@@ -650,7 +654,7 @@ UBool ChineseCalendar::isLeapMonthBetween(int32_t newMoon1, int32_t newMoon2) co
#endif
return (newMoon2 >= newMoon1) &&
- (isLeapMonthBetween(newMoon1, newMoonNear(newMoon2 - SYNODIC_GAP, FALSE)) ||
+ (isLeapMonthBetween(newMoon1, newMoonNear(newMoon2 - SYNODIC_GAP, false)) ||
hasNoMajorSolarTerm(newMoon2));
}
@@ -661,7 +665,7 @@ UBool ChineseCalendar::isLeapMonthBetween(int32_t newMoon1, int32_t newMoon2) co
* IS_LEAP_MONTH fields, as required by
* <code>handleComputeMonthStart()</code>.
*
- * <p>As a side effect, this method sets {@link #isLeapYear}.
+ * <p>As a side effect, this method sets {@link #hasLeapMonthBetweenWinterSolstices}.
* @param days days after January 1, 1970 0:00 astronomical base zone
* of the date to compute fields for
* @param gyear the Gregorian year of the given date
@@ -672,7 +676,6 @@ UBool ChineseCalendar::isLeapMonthBetween(int32_t newMoon1, int32_t newMoon2) co
*/
void ChineseCalendar::computeChineseFields(int32_t days, int32_t gyear, int32_t gmonth,
UBool setAllFields) {
-
// Find the winter solstices before and after the target date.
// These define the boundaries of this Chinese year, specifically,
// the position of month 11, which always contains the solstice.
@@ -689,27 +692,36 @@ void ChineseCalendar::computeChineseFields(int32_t days, int32_t gyear, int32_t
// Find the start of the month after month 11. This will be either
// the prior month 12 or leap month 11 (very rare). Also find the
// start of the following month 11.
- int32_t firstMoon = newMoonNear(solsticeBefore + 1, TRUE);
- int32_t lastMoon = newMoonNear(solsticeAfter + 1, FALSE);
- int32_t thisMoon = newMoonNear(days + 1, FALSE); // Start of this month
- // Note: isLeapYear is a member variable
- isLeapYear = synodicMonthsBetween(firstMoon, lastMoon) == 12;
+ int32_t firstMoon = newMoonNear(solsticeBefore + 1, true);
+ int32_t lastMoon = newMoonNear(solsticeAfter + 1, false);
+ int32_t thisMoon = newMoonNear(days + 1, false); // Start of this month
+ // Note: hasLeapMonthBetweenWinterSolstices is a member variable
+ hasLeapMonthBetweenWinterSolstices = synodicMonthsBetween(firstMoon, lastMoon) == 12;
int32_t month = synodicMonthsBetween(firstMoon, thisMoon);
- if (isLeapYear && isLeapMonthBetween(firstMoon, thisMoon)) {
+ int32_t theNewYear = newYear(gyear);
+ if (days < theNewYear) {
+ theNewYear = newYear(gyear-1);
+ }
+ if (hasLeapMonthBetweenWinterSolstices && isLeapMonthBetween(firstMoon, thisMoon)) {
month--;
}
if (month < 1) {
month += 12;
}
-
- UBool isLeapMonth = isLeapYear &&
+ int32_t ordinalMonth = synodicMonthsBetween(theNewYear, thisMoon);
+ if (ordinalMonth < 0) {
+ ordinalMonth += 12;
+ }
+ UBool isLeapMonth = hasLeapMonthBetweenWinterSolstices &&
hasNoMajorSolarTerm(thisMoon) &&
- !isLeapMonthBetween(firstMoon, newMoonNear(thisMoon - SYNODIC_GAP, FALSE));
+ !isLeapMonthBetween(firstMoon, newMoonNear(thisMoon - SYNODIC_GAP, false));
internalSet(UCAL_MONTH, month-1); // Convert from 1-based to 0-based
+ internalSet(UCAL_ORDINAL_MONTH, ordinalMonth); // Convert from 1-based to 0-based
internalSet(UCAL_IS_LEAP_MONTH, isLeapMonth?1:0);
+
if (setAllFields) {
// Extended year and cycle year is based on the epoch year
@@ -727,7 +739,7 @@ void ChineseCalendar::computeChineseFields(int32_t days, int32_t gyear, int32_t
// 0->0,60 1->1,1 60->1,60 61->2,1 etc.
int32_t yearOfCycle;
- int32_t cycle = ClockMath::floorDivide(cycle_year - 1, 60, yearOfCycle);
+ int32_t cycle = ClockMath::floorDivide(cycle_year - 1, 60, &yearOfCycle);
internalSet(UCAL_ERA, cycle + 1);
internalSet(UCAL_YEAR, yearOfCycle + 1);
@@ -764,13 +776,13 @@ int32_t ChineseCalendar::newYear(int32_t gyear) const {
int32_t solsticeBefore= winterSolstice(gyear - 1);
int32_t solsticeAfter = winterSolstice(gyear);
- int32_t newMoon1 = newMoonNear(solsticeBefore + 1, TRUE);
- int32_t newMoon2 = newMoonNear(newMoon1 + SYNODIC_GAP, TRUE);
- int32_t newMoon11 = newMoonNear(solsticeAfter + 1, FALSE);
+ int32_t newMoon1 = newMoonNear(solsticeBefore + 1, true);
+ int32_t newMoon2 = newMoonNear(newMoon1 + SYNODIC_GAP, true);
+ int32_t newMoon11 = newMoonNear(solsticeAfter + 1, false);
if (synodicMonthsBetween(newMoon1, newMoon11) == 12 &&
(hasNoMajorSolarTerm(newMoon1) || hasNoMajorSolarTerm(newMoon2))) {
- cacheValue = newMoonNear(newMoon2 + SYNODIC_GAP, TRUE);
+ cacheValue = newMoonNear(newMoon2 + SYNODIC_GAP, true);
} else {
cacheValue = newMoon2;
}
@@ -801,7 +813,7 @@ void ChineseCalendar::offsetMonth(int32_t newMoon, int32_t dom, int32_t delta) {
newMoon += (int32_t) (CalendarAstronomer::SYNODIC_MONTH * (delta - 0.5));
// Search forward to the target month's new moon
- newMoon = newMoonNear(newMoon, TRUE);
+ newMoon = newMoonNear(newMoon, true);
// Find the target dom
int32_t jd = newMoon + kEpochStartAsJulianDay - 1 + dom;
@@ -825,30 +837,33 @@ void ChineseCalendar::offsetMonth(int32_t newMoon, int32_t dom, int32_t delta) {
}
}
+constexpr uint32_t kChineseRelatedYearDiff = -2637;
-UBool
-ChineseCalendar::inDaylightTime(UErrorCode& status) const
+int32_t ChineseCalendar::getRelatedYear(UErrorCode &status) const
{
- // copied from GregorianCalendar
- if (U_FAILURE(status) || !getTimeZone().useDaylightTime())
- return FALSE;
-
- // Force an update of the state of the Calendar.
- ((ChineseCalendar*)this)->complete(status); // cast away const
+ int32_t year = get(UCAL_EXTENDED_YEAR, status);
+ if (U_FAILURE(status)) {
+ return 0;
+ }
+ return year + kChineseRelatedYearDiff;
+}
- return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : FALSE);
+void ChineseCalendar::setRelatedYear(int32_t year)
+{
+ // set extended year
+ set(UCAL_EXTENDED_YEAR, year - kChineseRelatedYearDiff);
}
// default century
static UDate gSystemDefaultCenturyStart = DBL_MIN;
static int32_t gSystemDefaultCenturyStartYear = -1;
-static icu::UInitOnce gSystemDefaultCenturyInitOnce = U_INITONCE_INITIALIZER;
+static icu::UInitOnce gSystemDefaultCenturyInitOnce {};
UBool ChineseCalendar::haveDefaultCentury() const
{
- return TRUE;
+ return true;
}
UDate ChineseCalendar::defaultCenturyStart() const
@@ -894,8 +909,83 @@ ChineseCalendar::internalGetDefaultCenturyStartYear() const
return gSystemDefaultCenturyStartYear;
}
+bool
+ChineseCalendar::inTemporalLeapYear(UErrorCode &status) const
+{
+ int32_t days = getActualMaximum(UCAL_DAY_OF_YEAR, status);
+ if (U_FAILURE(status)) return false;
+ return days > 360;
+}
+
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ChineseCalendar)
+
+static const char * const gTemporalLeapMonthCodes[] = {
+ "M01L", "M02L", "M03L", "M04L", "M05L", "M06L",
+ "M07L", "M08L", "M09L", "M10L", "M11L", "M12L", nullptr
+};
+
+const char* ChineseCalendar::getTemporalMonthCode(UErrorCode &status) const {
+ // We need to call get, not internalGet, to force the calculation
+ // from UCAL_ORDINAL_MONTH.
+ int32_t is_leap = get(UCAL_IS_LEAP_MONTH, status);
+ if (U_FAILURE(status)) return nullptr;
+ if (is_leap != 0) {
+ int32_t month = get(UCAL_MONTH, status);
+ if (U_FAILURE(status)) return nullptr;
+ return gTemporalLeapMonthCodes[month];
+ }
+ return Calendar::getTemporalMonthCode(status);
+}
+
+void
+ChineseCalendar::setTemporalMonthCode(const char* code, UErrorCode& status )
+{
+ if (U_FAILURE(status)) return;
+ int32_t len = static_cast<int32_t>(uprv_strlen(code));
+ if (len != 4 || code[0] != 'M' || code[3] != 'L') {
+ set(UCAL_IS_LEAP_MONTH, 0);
+ return Calendar::setTemporalMonthCode(code, status);
+ }
+ for (int m = 0; gTemporalLeapMonthCodes[m] != nullptr; m++) {
+ if (uprv_strcmp(code, gTemporalLeapMonthCodes[m]) == 0) {
+ set(UCAL_MONTH, m);
+ set(UCAL_IS_LEAP_MONTH, 1);
+ return;
+ }
+ }
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+}
+
+int32_t ChineseCalendar::internalGetMonth() const {
+ if (resolveFields(kMonthPrecedence) == UCAL_MONTH) {
+ return internalGet(UCAL_MONTH);
+ }
+ LocalPointer<Calendar> temp(this->clone());
+ temp->set(UCAL_MONTH, 0);
+ temp->set(UCAL_IS_LEAP_MONTH, 0);
+ temp->set(UCAL_DATE, 1);
+ // Calculate the UCAL_MONTH and UCAL_IS_LEAP_MONTH by adding number of
+ // months.
+ UErrorCode status = U_ZERO_ERROR;
+ temp->roll(UCAL_MONTH, internalGet(UCAL_ORDINAL_MONTH), status);
+
+
+ ChineseCalendar *nonConstThis = (ChineseCalendar*)this; // cast away const
+ nonConstThis->internalSet(UCAL_IS_LEAP_MONTH, temp->get(UCAL_IS_LEAP_MONTH, status));
+ int32_t month = temp->get(UCAL_MONTH, status);
+ U_ASSERT(U_SUCCESS(status));
+ nonConstThis->internalSet(UCAL_MONTH, month);
+ return month;
+}
+
+int32_t ChineseCalendar::internalGetMonth(int32_t defaultValue) const {
+ if (resolveFields(kMonthPrecedence) == UCAL_MONTH) {
+ return internalGet(UCAL_MONTH, defaultValue);
+ }
+ return internalGetMonth();
+}
+
U_NAMESPACE_END
#endif
diff --git a/contrib/libs/icu/i18n/chnsecal.h b/contrib/libs/icu/i18n/chnsecal.h
index 61ef2d3cad..9b5a629fad 100644
--- a/contrib/libs/icu/i18n/chnsecal.h
+++ b/contrib/libs/icu/i18n/chnsecal.h
@@ -113,6 +113,49 @@ class U_I18N_API ChineseCalendar : public Calendar {
*/
ChineseCalendar(const Locale& aLocale, UErrorCode &success);
+ /**
+ * Returns true if the date is in a leap year.
+ *
+ * @param status ICU Error Code
+ * @return True if the date in the fields is in a Temporal proposal
+ * defined leap year. False otherwise.
+ */
+ virtual bool inTemporalLeapYear(UErrorCode &status) const override;
+
+ /**
+ * Gets The Temporal monthCode value corresponding to the month for the date.
+ * The value is a string identifier that starts with the literal grapheme
+ * "M" followed by two graphemes representing the zero-padded month number
+ * of the current month in a normal (non-leap) year and suffixed by an
+ * optional literal grapheme "L" if this is a leap month in a lunisolar
+ * calendar. For Chinese calendars (including Dangi), the values are
+ * "M01" .. "M12" for non-leap year, and "M01" .. "M12" with one of
+ * "M01L" .. "M12L" for leap year.
+ *
+ * @param status ICU Error Code
+ * @return One of 24 possible strings in
+ * {"M01" .. "M12", "M01L" .. "M12L"}.
+ * @draft ICU 73
+ */
+ virtual const char* getTemporalMonthCode(UErrorCode &status) const override;
+
+ /**
+ * Sets The Temporal monthCode which is a string identifier that starts
+ * with the literal grapheme "M" followed by two graphemes representing
+ * the zero-padded month number of the current month in a normal
+ * (non-leap) year and suffixed by an optional literal grapheme "L" if this
+ * is a leap month in a lunisolar calendar. For Chinese calendars, the values
+ * are "M01" .. "M12" for non-leap years, and "M01" .. "M12" plus one in
+ * "M01L" .. "M12L" for leap year.
+ *
+ * @param temporalMonth The value to be set for temporal monthCode. One of
+ * 24 possible strings in {"M01" .. "M12", "M01L" .. "M12L"}.
+ * @param status ICU Error Code
+ *
+ * @draft ICU 73
+ */
+ virtual void setTemporalMonthCode(const char* code, UErrorCode& status) override;
+
protected:
/**
@@ -152,7 +195,12 @@ class U_I18N_API ChineseCalendar : public Calendar {
// Internal data....
//-------------------------------------------------------------------------
- UBool isLeapYear;
+ // There is a leap month between the Winter Solstice before and after the
+ // current date.This is different from leap year because in some year, such as
+ // 1813 and 2033, the leap month is after the Winter Solstice of that year. So
+ // this value could be false for a date prior to the Winter Solstice of that
+ // year but that year still has a leap month and therefor is a leap year.
+ UBool hasLeapMonthBetweenWinterSolstices;
int32_t fEpochYear; // Start year of this Chinese calendar instance.
const TimeZone* fZoneAstroCalc; // Zone used for the astronomical calculation
// of this Chinese calendar instance.
@@ -175,6 +223,20 @@ class U_I18N_API ChineseCalendar : public Calendar {
virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode &status) override;
virtual void roll(EDateFields field, int32_t amount, UErrorCode &status) override;
+ /**
+ * @return The related Gregorian year; will be obtained by modifying the value
+ * obtained by get from UCAL_EXTENDED_YEAR field
+ * @internal
+ */
+ virtual int32_t getRelatedYear(UErrorCode &status) const override;
+
+ /**
+ * @param year The related Gregorian year to set; will be modified as necessary then
+ * set in UCAL_EXTENDED_YEAR field
+ * @internal
+ */
+ virtual void setRelatedYear(int32_t year) override;
+
//----------------------------------------------------------------------
// Internal methods & astronomical calculations
//----------------------------------------------------------------------
@@ -195,7 +257,7 @@ class U_I18N_API ChineseCalendar : public Calendar {
int32_t gmonth, UBool setAllFields);
virtual int32_t newYear(int32_t gyear) const;
virtual void offsetMonth(int32_t newMoon, int32_t dom, int32_t delta);
- const TimeZone* getChineseCalZoneAstroCalc(void) const;
+ const TimeZone* getChineseCalZoneAstroCalc() const;
// UObject stuff
public:
@@ -204,7 +266,7 @@ class U_I18N_API ChineseCalendar : public Calendar {
* same class ID. Objects of other classes have different class IDs.
* @internal
*/
- virtual UClassID getDynamicClassID(void) const override;
+ virtual UClassID getDynamicClassID() const override;
/**
* Return the class ID for this class. This is useful only for comparing to a return
@@ -217,7 +279,7 @@ class U_I18N_API ChineseCalendar : public Calendar {
* @return The class ID for all objects of this class.
* @internal
*/
- static UClassID U_EXPORT2 getStaticClassID(void);
+ static UClassID U_EXPORT2 getStaticClassID();
/**
* return the calendar type, "chinese".
@@ -227,20 +289,12 @@ class U_I18N_API ChineseCalendar : public Calendar {
*/
virtual const char * getType() const override;
-
protected:
- /**
- * (Overrides Calendar) Return true if the current date for this Calendar is in
- * Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
- *
- * @param status Fill-in parameter which receives the status of this operation.
- * @return True if the current date for this Calendar is in Daylight Savings Time,
- * false, otherwise.
- * @internal
- */
- virtual UBool inDaylightTime(UErrorCode& status) const override;
+ virtual int32_t internalGetMonth(int32_t defaultValue) const override;
+ virtual int32_t internalGetMonth() const override;
+ protected:
/**
* Returns true because the Islamic Calendar does have a default century
* @internal
@@ -266,15 +320,15 @@ class U_I18N_API ChineseCalendar : public Calendar {
* Returns the beginning date of the 100-year window that dates
* with 2-digit years are considered to fall within.
*/
- UDate internalGetDefaultCenturyStart(void) const;
+ UDate internalGetDefaultCenturyStart() const;
/**
* Returns the first year of the 100-year window that dates with
* 2-digit years are considered to fall within.
*/
- int32_t internalGetDefaultCenturyStartYear(void) const;
+ int32_t internalGetDefaultCenturyStartYear() const;
- ChineseCalendar(); // default constructor not implemented
+ ChineseCalendar() = delete; // default constructor not implemented
};
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/choicfmt.cpp b/contrib/libs/icu/i18n/choicfmt.cpp
index d06eec35fa..96e73fabcf 100644
--- a/contrib/libs/icu/i18n/choicfmt.cpp
+++ b/contrib/libs/icu/i18n/choicfmt.cpp
@@ -51,23 +51,23 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ChoiceFormat)
// Special characters used by ChoiceFormat. There are two characters
// used interchangeably to indicate <=. Either is parsed, but only
// LESS_EQUAL is generated by toPattern().
-#define SINGLE_QUOTE ((UChar)0x0027) /*'*/
-#define LESS_THAN ((UChar)0x003C) /*<*/
-#define LESS_EQUAL ((UChar)0x0023) /*#*/
-#define LESS_EQUAL2 ((UChar)0x2264)
-#define VERTICAL_BAR ((UChar)0x007C) /*|*/
-#define MINUS ((UChar)0x002D) /*-*/
+#define SINGLE_QUOTE ((char16_t)0x0027) /*'*/
+#define LESS_THAN ((char16_t)0x003C) /*<*/
+#define LESS_EQUAL ((char16_t)0x0023) /*#*/
+#define LESS_EQUAL2 ((char16_t)0x2264)
+#define VERTICAL_BAR ((char16_t)0x007C) /*|*/
+#define MINUS ((char16_t)0x002D) /*-*/
-static const UChar LEFT_CURLY_BRACE = 0x7B; /*{*/
-static const UChar RIGHT_CURLY_BRACE = 0x7D; /*}*/
+static const char16_t LEFT_CURLY_BRACE = 0x7B; /*{*/
+static const char16_t RIGHT_CURLY_BRACE = 0x7D; /*}*/
#ifdef INFINITY
#undef INFINITY
#endif
-#define INFINITY ((UChar)0x221E)
+#define INFINITY ((char16_t)0x221E)
-//static const UChar gPositiveInfinity[] = {INFINITY, 0};
-//static const UChar gNegativeInfinity[] = {MINUS, INFINITY, 0};
+//static const char16_t gPositiveInfinity[] = {INFINITY, 0};
+//static const char16_t gNegativeInfinity[] = {MINUS, INFINITY, 0};
#define POSITIVE_INF_STRLEN 1
#define NEGATIVE_INF_STRLEN 2
@@ -92,7 +92,7 @@ ChoiceFormat::ChoiceFormat(const double* limits,
: constructorErrorCode(U_ZERO_ERROR),
msgPattern(constructorErrorCode)
{
- setChoices(limits, NULL, formats, cnt, constructorErrorCode);
+ setChoices(limits, nullptr, formats, cnt, constructorErrorCode);
}
// -------------------------------------
@@ -137,7 +137,7 @@ ChoiceFormat::operator==(const Format& that) const
{
if (this == &that) return true;
if (!NumberFormat::operator==(that)) return false;
- ChoiceFormat& thatAlias = (ChoiceFormat&)that;
+ const ChoiceFormat& thatAlias = static_cast<const ChoiceFormat&>(that);
return msgPattern == thatAlias.msgPattern;
}
@@ -175,10 +175,10 @@ ChoiceFormat::dtos(double value,
char *itrPtr = temp;
char *expPtr;
- sprintf(temp, "%.*g", DBL_DIG, value);
+ snprintf(temp, sizeof(temp), "%.*g", DBL_DIG, value);
/* Find and convert the decimal point.
- Using setlocale on some machines will cause sprintf to use a comma for certain locales.
+ Using setlocale on some machines will cause snprintf to use a comma for certain locales.
*/
while (*itrPtr && (*itrPtr == '-' || isdigit(*itrPtr))) {
itrPtr++;
@@ -209,7 +209,7 @@ ChoiceFormat::dtos(double value,
while (*itrPtr) {
*(expPtr++) = *(itrPtr++);
}
- // NULL terminate
+ // NUL terminate
*expPtr = 0;
}
}
@@ -225,7 +225,7 @@ void
ChoiceFormat::applyPattern(const UnicodeString& pattern,
UErrorCode& status)
{
- msgPattern.parseChoiceStyle(pattern, NULL, status);
+ msgPattern.parseChoiceStyle(pattern, nullptr, status);
constructorErrorCode = status;
}
@@ -257,7 +257,7 @@ ChoiceFormat::setChoices( const double* limits,
int32_t cnt )
{
UErrorCode errorCode = U_ZERO_ERROR;
- setChoices(limits, NULL, formats, cnt, errorCode);
+ setChoices(limits, nullptr, formats, cnt, errorCode);
}
// -------------------------------------
@@ -281,7 +281,7 @@ ChoiceFormat::setChoices(const double* limits,
if (U_FAILURE(errorCode)) {
return;
}
- if (limits == NULL || formats == NULL) {
+ if (limits == nullptr || formats == nullptr) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@@ -301,7 +301,7 @@ ChoiceFormat::setChoices(const double* limits,
} else {
result += dtos(limits[i], buf);
}
- if (closures != NULL && closures[i]) {
+ if (closures != nullptr && closures[i]) {
result += LESS_THAN;
} else {
result += LESS_EQUAL;
@@ -313,7 +313,7 @@ ChoiceFormat::setChoices(const double* limits,
int32_t textLength = text.length();
int32_t nestingLevel = 0;
for (int32_t j = 0; j < textLength; ++j) {
- UChar c = text[j];
+ char16_t c = text[j];
if (c == SINGLE_QUOTE && nestingLevel == 0) {
// Double each top-level apostrophe.
result.append(c);
@@ -347,7 +347,7 @@ const double*
ChoiceFormat::getLimits(int32_t& cnt) const
{
cnt = 0;
- return NULL;
+ return nullptr;
}
// -------------------------------------
@@ -357,7 +357,7 @@ const UBool*
ChoiceFormat::getClosures(int32_t& cnt) const
{
cnt = 0;
- return NULL;
+ return nullptr;
}
// -------------------------------------
@@ -367,7 +367,7 @@ const UnicodeString*
ChoiceFormat::getFormats(int32_t& cnt) const
{
cnt = 0;
- return NULL;
+ return nullptr;
}
// -------------------------------------
@@ -450,7 +450,7 @@ ChoiceFormat::findSubMessage(const MessagePattern &pattern, int32_t partIndex, d
double boundary = pattern.getNumericValue(part);
// Fetch the ARG_SELECTOR character.
int32_t selectorIndex = pattern.getPatternIndex(partIndex++);
- UChar boundaryChar = pattern.getPatternString().charAt(selectorIndex);
+ char16_t boundaryChar = pattern.getPatternString().charAt(selectorIndex);
if (boundaryChar == LESS_THAN ? !(number > boundary) : !(number >= boundary)) {
// The number is in the interval between the previous boundary and the current one.
// Return with the sub-message between them.
diff --git a/contrib/libs/icu/i18n/coleitr.cpp b/contrib/libs/icu/i18n/coleitr.cpp
index 48c1da9015..be0a8e4690 100644
--- a/contrib/libs/icu/i18n/coleitr.cpp
+++ b/contrib/libs/icu/i18n/coleitr.cpp
@@ -54,7 +54,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CollationElementIterator)
CollationElementIterator::CollationElementIterator(
const CollationElementIterator& other)
- : UObject(other), iter_(NULL), rbc_(NULL), otherHalf_(0), dir_(0), offsets_(NULL) {
+ : UObject(other), iter_(nullptr), rbc_(nullptr), otherHalf_(0), dir_(0), offsets_(nullptr) {
*this = other;
}
@@ -82,7 +82,7 @@ UBool ceNeedsTwoParts(int64_t ce) {
int32_t CollationElementIterator::getOffset() const
{
- if (dir_ < 0 && offsets_ != NULL && !offsets_->isEmpty()) {
+ if (dir_ < 0 && offsets_ != nullptr && !offsets_->isEmpty()) {
// CollationIterator::previousCE() decrements the CEs length
// while it pops CEs from its internal buffer.
int32_t i = iter_->getCEsLength();
@@ -185,9 +185,9 @@ int32_t CollationElementIterator::previous(UErrorCode& status)
status = U_INVALID_STATE_ERROR;
return NULLORDER;
}
- if (offsets_ == NULL) {
+ if (offsets_ == nullptr) {
offsets_ = new UVector32(status);
- if (offsets_ == NULL) {
+ if (offsets_ == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return NULLORDER;
}
@@ -234,7 +234,7 @@ void CollationElementIterator::setOffset(int32_t newOffset,
if (0 < newOffset && newOffset < string_.length()) {
int32_t offset = newOffset;
do {
- UChar c = string_.charAt(offset);
+ char16_t c = string_.charAt(offset);
if (!rbc_->isUnsafe(c) ||
(U16_IS_LEAD(c) && !rbc_->isUnsafe(string_.char32At(offset)))) {
break;
@@ -278,7 +278,7 @@ void CollationElementIterator::setText(const UnicodeString& source,
}
string_ = source;
- const UChar *s = string_.getBuffer();
+ const char16_t *s = string_.getBuffer();
CollationIterator *newIter;
UBool numeric = rbc_->settings->isNumeric();
if (rbc_->settings->dontCheckFCD()) {
@@ -286,7 +286,7 @@ void CollationElementIterator::setText(const UnicodeString& source,
} else {
newIter = new FCDUTF16CollationIterator(rbc_->data, numeric, s, s, s + string_.length());
}
- if (newIter == NULL) {
+ if (newIter == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -331,7 +331,7 @@ CollationElementIterator::CollationElementIterator(
const UnicodeString &source,
const RuleBasedCollator *coll,
UErrorCode &status)
- : iter_(NULL), rbc_(coll), otherHalf_(0), dir_(0), offsets_(NULL) {
+ : iter_(nullptr), rbc_(coll), otherHalf_(0), dir_(0), offsets_(nullptr) {
setText(source, status);
}
@@ -343,7 +343,7 @@ CollationElementIterator::CollationElementIterator(
const CharacterIterator &source,
const RuleBasedCollator *coll,
UErrorCode &status)
- : iter_(NULL), rbc_(coll), otherHalf_(0), dir_(0), offsets_(NULL) {
+ : iter_(nullptr), rbc_(coll), otherHalf_(0), dir_(0), offsets_(nullptr) {
// We only call source.getText() which should be const anyway.
setText(const_cast<CharacterIterator &>(source), status);
}
@@ -360,18 +360,18 @@ const CollationElementIterator& CollationElementIterator::operator=(
CollationIterator *newIter;
const FCDUTF16CollationIterator *otherFCDIter =
dynamic_cast<const FCDUTF16CollationIterator *>(other.iter_);
- if(otherFCDIter != NULL) {
+ if(otherFCDIter != nullptr) {
newIter = new FCDUTF16CollationIterator(*otherFCDIter, string_.getBuffer());
} else {
const UTF16CollationIterator *otherIter =
dynamic_cast<const UTF16CollationIterator *>(other.iter_);
- if(otherIter != NULL) {
+ if(otherIter != nullptr) {
newIter = new UTF16CollationIterator(*otherIter, string_.getBuffer());
} else {
- newIter = NULL;
+ newIter = nullptr;
}
}
- if(newIter != NULL) {
+ if(newIter != nullptr) {
delete iter_;
iter_ = newIter;
rbc_ = other.rbc_;
@@ -380,12 +380,12 @@ const CollationElementIterator& CollationElementIterator::operator=(
string_ = other.string_;
}
- if(other.dir_ < 0 && other.offsets_ != NULL && !other.offsets_->isEmpty()) {
+ if(other.dir_ < 0 && other.offsets_ != nullptr && !other.offsets_->isEmpty()) {
UErrorCode errorCode = U_ZERO_ERROR;
- if(offsets_ == NULL) {
+ if(offsets_ == nullptr) {
offsets_ = new UVector32(other.offsets_->size(), errorCode);
}
- if(offsets_ != NULL) {
+ if(offsets_ != nullptr) {
offsets_->assign(*other.offsets_, errorCode);
}
}
@@ -435,15 +435,15 @@ MaxExpSink::~MaxExpSink() {}
UHashtable *
CollationElementIterator::computeMaxExpansions(const CollationData *data, UErrorCode &errorCode) {
- if (U_FAILURE(errorCode)) { return NULL; }
+ if (U_FAILURE(errorCode)) { return nullptr; }
UHashtable *maxExpansions = uhash_open(uhash_hashLong, uhash_compareLong,
uhash_compareLong, &errorCode);
- if (U_FAILURE(errorCode)) { return NULL; }
+ if (U_FAILURE(errorCode)) { return nullptr; }
MaxExpSink sink(maxExpansions, errorCode);
- ContractionsAndExpansions(NULL, NULL, &sink, TRUE).forData(data, errorCode);
+ ContractionsAndExpansions(nullptr, nullptr, &sink, true).forData(data, errorCode);
if (U_FAILURE(errorCode)) {
uhash_close(maxExpansions);
- return NULL;
+ return nullptr;
}
return maxExpansions;
}
@@ -457,7 +457,7 @@ int32_t
CollationElementIterator::getMaxExpansion(const UHashtable *maxExpansions, int32_t order) {
if (order == 0) { return 1; }
int32_t max;
- if(maxExpansions != NULL && (max = uhash_igeti(maxExpansions, order)) != 0) {
+ if(maxExpansions != nullptr && (max = uhash_igeti(maxExpansions, order)) != 0) {
return max;
}
if ((order & 0xc0) == 0xc0) {
diff --git a/contrib/libs/icu/i18n/coll.cpp b/contrib/libs/icu/i18n/coll.cpp
index fe73118da0..ced55c8dbf 100644
--- a/contrib/libs/icu/i18n/coll.cpp
+++ b/contrib/libs/icu/i18n/coll.cpp
@@ -61,33 +61,33 @@
#include "uresimp.h"
#include "ucln_in.h"
-static icu::Locale* availableLocaleList = NULL;
+static icu::Locale* availableLocaleList = nullptr;
static int32_t availableLocaleListCount;
#if !UCONFIG_NO_SERVICE
-static icu::ICULocaleService* gService = NULL;
-static icu::UInitOnce gServiceInitOnce = U_INITONCE_INITIALIZER;
+static icu::ICULocaleService* gService = nullptr;
+static icu::UInitOnce gServiceInitOnce {};
#endif
-static icu::UInitOnce gAvailableLocaleListInitOnce = U_INITONCE_INITIALIZER;
+static icu::UInitOnce gAvailableLocaleListInitOnce {};
/**
* Release all static memory held by collator.
*/
U_CDECL_BEGIN
-static UBool U_CALLCONV collator_cleanup(void) {
+static UBool U_CALLCONV collator_cleanup() {
#if !UCONFIG_NO_SERVICE
if (gService) {
delete gService;
- gService = NULL;
+ gService = nullptr;
}
gServiceInitOnce.reset();
#endif
if (availableLocaleList) {
delete []availableLocaleList;
- availableLocaleList = NULL;
+ availableLocaleList = nullptr;
}
availableLocaleListCount = 0;
gAvailableLocaleListInitOnce.reset();
- return TRUE;
+ return true;
}
U_CDECL_END
@@ -108,8 +108,8 @@ CollatorFactory::~CollatorFactory() {}
//-------------------------------------------
UBool
-CollatorFactory::visible(void) const {
- return TRUE;
+CollatorFactory::visible() const {
+ return true;
}
//-------------------------------------------
@@ -137,7 +137,7 @@ ICUCollatorFactory::~ICUCollatorFactory() {}
UObject*
ICUCollatorFactory::create(const ICUServiceKey& key, const ICUService* /* service */, UErrorCode& status) const {
if (handlesKey(key, status)) {
- const LocaleKey& lkey = (const LocaleKey&)key;
+ const LocaleKey& lkey = static_cast<const LocaleKey&>(key);
Locale loc;
// make sure the requested locale is correct
// default LocaleFactory uses currentLocale since that's the one vetted by handlesKey
@@ -146,7 +146,7 @@ ICUCollatorFactory::create(const ICUServiceKey& key, const ICUService* /* servic
return Collator::makeInstance(loc, status);
}
- return NULL;
+ return nullptr;
}
// -------------------------------------
@@ -167,7 +167,8 @@ public:
}
virtual UObject* handleDefault(const ICUServiceKey& key, UnicodeString* actualID, UErrorCode& status) const override {
- LocaleKey& lkey = (LocaleKey&)key;
+ const LocaleKey* lkey = dynamic_cast<const LocaleKey*>(&key);
+ U_ASSERT(lkey != nullptr);
if (actualID) {
// Ugly Hack Alert! We return an empty actualID to signal
// to callers that this is a default object, not a "real"
@@ -175,13 +176,13 @@ public:
actualID->truncate(0);
}
Locale loc("");
- lkey.canonicalLocale(loc);
+ lkey->canonicalLocale(loc);
return Collator::makeInstance(loc, status);
}
virtual UObject* getKey(ICUServiceKey& key, UnicodeString* actualReturn, UErrorCode& status) const override {
UnicodeString ar;
- if (actualReturn == NULL) {
+ if (actualReturn == nullptr) {
actualReturn = &ar;
}
return (Collator*)ICULocaleService::getKey(key, actualReturn, status);
@@ -203,7 +204,7 @@ static void U_CALLCONV initService() {
static ICULocaleService*
-getService(void)
+getService()
{
umtx_initOnce(gServiceInitOnce, &initService);
return gService;
@@ -212,9 +213,9 @@ getService(void)
// -------------------------------------
static inline UBool
-hasService(void)
+hasService()
{
- UBool retVal = !gServiceInitOnce.isReset() && (getService() != NULL);
+ UBool retVal = !gServiceInitOnce.isReset() && (getService() != nullptr);
return retVal;
}
@@ -223,9 +224,9 @@ hasService(void)
static void U_CALLCONV
initAvailableLocaleList(UErrorCode &status) {
U_ASSERT(availableLocaleListCount == 0);
- U_ASSERT(availableLocaleList == NULL);
+ U_ASSERT(availableLocaleList == nullptr);
// for now, there is a hardcoded list, so just walk through that list and set it up.
- UResourceBundle *index = NULL;
+ UResourceBundle *index = nullptr;
StackUResourceBundle installed;
int32_t i = 0;
@@ -236,11 +237,11 @@ initAvailableLocaleList(UErrorCode &status) {
availableLocaleListCount = ures_getSize(installed.getAlias());
availableLocaleList = new Locale[availableLocaleListCount];
- if (availableLocaleList != NULL) {
+ if (availableLocaleList != nullptr) {
ures_resetIterator(installed.getAlias());
while(ures_hasNext(installed.getAlias())) {
- const char *tempKey = NULL;
- ures_getNextString(installed.getAlias(), NULL, &tempKey, &status);
+ const char *tempKey = nullptr;
+ ures_getNextString(installed.getAlias(), nullptr, &tempKey, &status);
availableLocaleList[i++] = Locale(tempKey);
}
}
@@ -372,7 +373,7 @@ void setAttributesFromKeywords(const Locale &loc, Collator &coll, UErrorCode &er
return;
}
if (length != 0) {
- int32_t codes[USCRIPT_CODE_LIMIT + UCOL_REORDER_CODE_LIMIT - UCOL_REORDER_CODE_FIRST];
+ int32_t codes[USCRIPT_CODE_LIMIT + (UCOL_REORDER_CODE_LIMIT - UCOL_REORDER_CODE_FIRST)];
int32_t codesLength = 0;
char *scriptName = value;
for (;;) {
@@ -434,7 +435,7 @@ Collator* U_EXPORT2 Collator::createInstance(const Locale& desiredLocale,
if (desiredLocale.isBogus()) {
// Locale constructed from malformed locale ID or language tag.
status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
Collator* coll;
@@ -446,18 +447,18 @@ Collator* U_EXPORT2 Collator::createInstance(const Locale& desiredLocale,
#endif
{
coll = makeInstance(desiredLocale, status);
- // Either returns NULL with U_FAILURE(status), or non-NULL with U_SUCCESS(status)
+ // Either returns nullptr with U_FAILURE(status), or non-nullptr with U_SUCCESS(status)
}
- // The use of *coll in setAttributesFromKeywords can cause the NULL check to be
+ // The use of *coll in setAttributesFromKeywords can cause the nullptr check to be
// optimized out of the delete even though setAttributesFromKeywords returns
// immediately if U_FAILURE(status), so we add a check here.
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
setAttributesFromKeywords(desiredLocale, *coll, status);
if (U_FAILURE(status)) {
delete coll;
- return NULL;
+ return nullptr;
}
return coll;
}
@@ -467,7 +468,7 @@ Collator* Collator::makeInstance(const Locale& desiredLocale, UErrorCode& statu
const CollationCacheEntry *entry = CollationLoader::loadTailoring(desiredLocale, status);
if (U_SUCCESS(status)) {
Collator *result = new RuleBasedCollator(entry);
- if (result != NULL) {
+ if (result != nullptr) {
// Both the unified cache's get() and the RBC constructor
// did addRef(). Undo one of them.
entry->removeRef();
@@ -475,11 +476,11 @@ Collator* Collator::makeInstance(const Locale& desiredLocale, UErrorCode& statu
}
status = U_MEMORY_ALLOCATION_ERROR;
}
- if (entry != NULL) {
+ if (entry != nullptr) {
// Undo the addRef() from the cache.get().
entry->removeRef();
}
- return NULL;
+ return nullptr;
}
Collator *
@@ -505,8 +506,8 @@ Collator::EComparisonResult Collator::compare(const UnicodeString& source,
}
// implement deprecated, previously abstract method
-Collator::EComparisonResult Collator::compare(const UChar* source, int32_t sourceLength,
- const UChar* target, int32_t targetLength)
+Collator::EComparisonResult Collator::compare(const char16_t* source, int32_t sourceLength,
+ const char16_t* target, int32_t targetLength)
const
{
UErrorCode ec = U_ZERO_ERROR;
@@ -561,7 +562,7 @@ UBool Collator::greater(const UnicodeString& source,
const Locale* U_EXPORT2 Collator::getAvailableLocales(int32_t& count)
{
UErrorCode status = U_ZERO_ERROR;
- Locale *result = NULL;
+ Locale *result = nullptr;
count = 0;
if (isAvailableLocaleListInitialized(status))
{
@@ -594,7 +595,7 @@ UnicodeString& U_EXPORT2 Collator::getDisplayName(const Locale& objectLocale,
/* This is useless information */
/*void Collator::getVersion(UVersionInfo versionInfo) const
{
- if (versionInfo!=NULL)
+ if (versionInfo!=nullptr)
uprv_memcpy(versionInfo, fVersion, U_MAX_VERSION_LENGTH);
}
*/
@@ -665,7 +666,7 @@ Collator::setLocales(const Locale& /* requestedLocale */, const Locale& /* valid
UnicodeSet *Collator::getTailoredSet(UErrorCode &status) const
{
if(U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
// everything can be changed
return new UnicodeSet(0, 0x10FFFF);
@@ -684,7 +685,7 @@ Collator::registerInstance(Collator* toAdopt, const Locale& locale, UErrorCode&
toAdopt->setLocales(locale, locale, locale);
return getService()->registerInstance(toAdopt, locale, status);
}
- return NULL;
+ return nullptr;
}
// -------------------------------------
@@ -698,7 +699,7 @@ public:
CFactory(CollatorFactory* delegate, UErrorCode& status)
: LocaleKeyFactory(delegate->visible() ? VISIBLE : INVISIBLE)
, _delegate(delegate)
- , _ids(NULL)
+ , _ids(nullptr)
{
if (U_SUCCESS(status)) {
int32_t count = 0;
@@ -709,7 +710,7 @@ public:
_ids->put(idlist[i], (void*)this, status);
if (U_FAILURE(status)) {
delete _ids;
- _ids = NULL;
+ _ids = nullptr;
return;
}
}
@@ -729,7 +730,7 @@ protected:
if (U_SUCCESS(status)) {
return _ids;
}
- return NULL;
+ return nullptr;
}
virtual UnicodeString&
@@ -746,12 +747,13 @@ UObject*
CFactory::create(const ICUServiceKey& key, const ICUService* /* service */, UErrorCode& status) const
{
if (handlesKey(key, status)) {
- const LocaleKey& lkey = (const LocaleKey&)key;
+ const LocaleKey* lkey = dynamic_cast<const LocaleKey*>(&key);
+ U_ASSERT(lkey != nullptr);
Locale validLoc;
- lkey.currentLocale(validLoc);
+ lkey->currentLocale(validLoc);
return _delegate->createCollator(validLoc);
}
- return NULL;
+ return nullptr;
}
UnicodeString&
@@ -760,7 +762,7 @@ CFactory::getDisplayName(const UnicodeString& id, const Locale& locale, UnicodeS
if ((_coverage & 0x1) == 0) {
UErrorCode status = U_ZERO_ERROR;
const Hashtable* ids = getSupportedIDs(status);
- if (ids && (ids->get(id) != NULL)) {
+ if (ids && (ids->get(id) != nullptr)) {
Locale loc;
LocaleUtility::initLocaleFromName(id, loc);
return _delegate->getDisplayName(loc, locale, result);
@@ -780,7 +782,7 @@ Collator::registerFactory(CollatorFactory* toAdopt, UErrorCode& status)
}
status = U_MEMORY_ALLOCATION_ERROR;
}
- return NULL;
+ return nullptr;
}
// -------------------------------------
@@ -794,7 +796,7 @@ Collator::unregister(URegistryKey key, UErrorCode& status)
}
status = U_ILLEGAL_ARGUMENT_ERROR;
}
- return FALSE;
+ return false;
}
#endif /* UCONFIG_NO_SERVICE */
@@ -802,8 +804,8 @@ class CollationLocaleListEnumeration : public StringEnumeration {
private:
int32_t index;
public:
- static UClassID U_EXPORT2 getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID U_EXPORT2 getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
public:
CollationLocaleListEnumeration()
: index(0)
@@ -831,14 +833,14 @@ public:
const char* result;
if(index < availableLocaleListCount) {
result = availableLocaleList[index++].getName();
- if(resultLength != NULL) {
+ if(resultLength != nullptr) {
*resultLength = (int32_t)uprv_strlen(result);
}
} else {
- if(resultLength != NULL) {
+ if(resultLength != nullptr) {
*resultLength = 0;
}
- result = NULL;
+ result = nullptr;
}
return result;
}
@@ -862,7 +864,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CollationLocaleListEnumeration)
// -------------------------------------
StringEnumeration* U_EXPORT2
-Collator::getAvailableLocales(void)
+Collator::getAvailableLocales()
{
#if !UCONFIG_NO_SERVICE
if (hasService()) {
@@ -873,7 +875,7 @@ Collator::getAvailableLocales(void)
if (isAvailableLocaleListInitialized(status)) {
return new CollationLocaleListEnumeration();
}
- return NULL;
+ return nullptr;
}
StringEnumeration* U_EXPORT2
@@ -911,7 +913,7 @@ Collator::getFunctionalEquivalent(const char* keyword, const Locale& locale,
}
Collator::ECollationStrength
-Collator::getStrength(void) const {
+Collator::getStrength() const {
UErrorCode intStatus = U_ZERO_ERROR;
return (ECollationStrength)getAttribute(UCOL_STRENGTH, intStatus);
}
@@ -961,7 +963,7 @@ Collator::getEquivalentReorderCodes(int32_t reorderCode,
int32_t *dest, int32_t capacity,
UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return 0; }
- if(capacity < 0 || (dest == NULL && capacity > 0)) {
+ if(capacity < 0 || (dest == nullptr && capacity > 0)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -986,7 +988,7 @@ Collator::internalCompareUTF8(const char *left, int32_t leftLength,
const char *right, int32_t rightLength,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return UCOL_EQUAL; }
- if((left == NULL && leftLength != 0) || (right == NULL && rightLength != 0)) {
+ if((left == nullptr && leftLength != 0) || (right == nullptr && rightLength != 0)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return UCOL_EQUAL;
}
diff --git a/contrib/libs/icu/i18n/collation.cpp b/contrib/libs/icu/i18n/collation.cpp
index 14cb86576b..705ee12e23 100644
--- a/contrib/libs/icu/i18n/collation.cpp
+++ b/contrib/libs/icu/i18n/collation.cpp
@@ -20,15 +20,6 @@
U_NAMESPACE_BEGIN
-// Some compilers don't care if constants are defined in the .cpp file.
-// MS Visual C++ does not like it, but gcc requires it. clang does not care.
-#ifndef _MSC_VER
-const uint8_t Collation::LEVEL_SEPARATOR_BYTE;
-const uint8_t Collation::MERGE_SEPARATOR_BYTE;
-const uint32_t Collation::ONLY_TERTIARY_MASK;
-const uint32_t Collation::CASE_AND_TERTIARY_MASK;
-#endif
-
uint32_t
Collation::incTwoBytePrimaryByOffset(uint32_t basePrimary, UBool isCompressible, int32_t offset) {
// Extract the second byte, minus the minimum byte value,
diff --git a/contrib/libs/icu/i18n/collation.h b/contrib/libs/icu/i18n/collation.h
index 6a449a3eb6..2062ef2946 100644
--- a/contrib/libs/icu/i18n/collation.h
+++ b/contrib/libs/icu/i18n/collation.h
@@ -221,7 +221,8 @@ public:
/**
* Points to contraction data.
* Bits 31..13: Index into prefix/contraction data.
- * Bits 12..11: Unused, 0.
+ * Bit 12: Unused, 0.
+ * Bit 11: CONTRACT_HAS_STARTER flag. (Used by ICU4X only.)
* Bit 10: CONTRACT_TRAILING_CCC flag.
* Bit 9: CONTRACT_NEXT_CCC flag.
* Bit 8: CONTRACT_SINGLE_CP_NO_MATCH flag.
@@ -298,6 +299,8 @@ public:
static const uint32_t CONTRACT_NEXT_CCC = 0x200;
/** Set if any contraction suffix ends with lccc!=0. */
static const uint32_t CONTRACT_TRAILING_CCC = 0x400;
+ /** Set if any contraction suffix contains a starter. (Used by ICU4X only.) */
+ static const uint32_t CONTRACT_HAS_STARTER = 0x800;
/** For HANGUL_TAG: None of its Jamo CE32s isSpecialCE32(). */
static const uint32_t HANGUL_NO_SPECIAL_JAMO = 0x100;
@@ -491,7 +494,7 @@ public:
}
private:
- Collation(); // No instantiation.
+ Collation() = delete; // No instantiation.
};
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/collationbuilder.cpp b/contrib/libs/icu/i18n/collationbuilder.cpp
index 5d4611b851..d8fb89738c 100644
--- a/contrib/libs/icu/i18n/collationbuilder.cpp
+++ b/contrib/libs/icu/i18n/collationbuilder.cpp
@@ -83,75 +83,75 @@ BundleImporter::getRules(
// most code will not have a static dependency on the builder code.
RuleBasedCollator::RuleBasedCollator()
- : data(NULL),
- settings(NULL),
- tailoring(NULL),
- cacheEntry(NULL),
+ : data(nullptr),
+ settings(nullptr),
+ tailoring(nullptr),
+ cacheEntry(nullptr),
validLocale(""),
explicitlySetAttributes(0),
- actualLocaleIsSameAsValid(FALSE) {
+ actualLocaleIsSameAsValid(false) {
}
RuleBasedCollator::RuleBasedCollator(const UnicodeString &rules, UErrorCode &errorCode)
- : data(NULL),
- settings(NULL),
- tailoring(NULL),
- cacheEntry(NULL),
+ : data(nullptr),
+ settings(nullptr),
+ tailoring(nullptr),
+ cacheEntry(nullptr),
validLocale(""),
explicitlySetAttributes(0),
- actualLocaleIsSameAsValid(FALSE) {
- internalBuildTailoring(rules, UCOL_DEFAULT, UCOL_DEFAULT, NULL, NULL, errorCode);
+ actualLocaleIsSameAsValid(false) {
+ internalBuildTailoring(rules, UCOL_DEFAULT, UCOL_DEFAULT, nullptr, nullptr, errorCode);
}
RuleBasedCollator::RuleBasedCollator(const UnicodeString &rules, ECollationStrength strength,
UErrorCode &errorCode)
- : data(NULL),
- settings(NULL),
- tailoring(NULL),
- cacheEntry(NULL),
+ : data(nullptr),
+ settings(nullptr),
+ tailoring(nullptr),
+ cacheEntry(nullptr),
validLocale(""),
explicitlySetAttributes(0),
- actualLocaleIsSameAsValid(FALSE) {
- internalBuildTailoring(rules, strength, UCOL_DEFAULT, NULL, NULL, errorCode);
+ actualLocaleIsSameAsValid(false) {
+ internalBuildTailoring(rules, strength, UCOL_DEFAULT, nullptr, nullptr, errorCode);
}
RuleBasedCollator::RuleBasedCollator(const UnicodeString &rules,
UColAttributeValue decompositionMode,
UErrorCode &errorCode)
- : data(NULL),
- settings(NULL),
- tailoring(NULL),
- cacheEntry(NULL),
+ : data(nullptr),
+ settings(nullptr),
+ tailoring(nullptr),
+ cacheEntry(nullptr),
validLocale(""),
explicitlySetAttributes(0),
- actualLocaleIsSameAsValid(FALSE) {
- internalBuildTailoring(rules, UCOL_DEFAULT, decompositionMode, NULL, NULL, errorCode);
+ actualLocaleIsSameAsValid(false) {
+ internalBuildTailoring(rules, UCOL_DEFAULT, decompositionMode, nullptr, nullptr, errorCode);
}
RuleBasedCollator::RuleBasedCollator(const UnicodeString &rules,
ECollationStrength strength,
UColAttributeValue decompositionMode,
UErrorCode &errorCode)
- : data(NULL),
- settings(NULL),
- tailoring(NULL),
- cacheEntry(NULL),
+ : data(nullptr),
+ settings(nullptr),
+ tailoring(nullptr),
+ cacheEntry(nullptr),
validLocale(""),
explicitlySetAttributes(0),
- actualLocaleIsSameAsValid(FALSE) {
- internalBuildTailoring(rules, strength, decompositionMode, NULL, NULL, errorCode);
+ actualLocaleIsSameAsValid(false) {
+ internalBuildTailoring(rules, strength, decompositionMode, nullptr, nullptr, errorCode);
}
RuleBasedCollator::RuleBasedCollator(const UnicodeString &rules,
UParseError &parseError, UnicodeString &reason,
UErrorCode &errorCode)
- : data(NULL),
- settings(NULL),
- tailoring(NULL),
- cacheEntry(NULL),
+ : data(nullptr),
+ settings(nullptr),
+ tailoring(nullptr),
+ cacheEntry(nullptr),
validLocale(""),
explicitlySetAttributes(0),
- actualLocaleIsSameAsValid(FALSE) {
+ actualLocaleIsSameAsValid(false) {
internalBuildTailoring(rules, UCOL_DEFAULT, UCOL_DEFAULT, &parseError, &reason, errorCode);
}
@@ -163,7 +163,7 @@ RuleBasedCollator::internalBuildTailoring(const UnicodeString &rules,
UErrorCode &errorCode) {
const CollationTailoring *base = CollationRoot::getRoot(errorCode);
if(U_FAILURE(errorCode)) { return; }
- if(outReason != NULL) { outReason->remove(); }
+ if(outReason != nullptr) { outReason->remove(); }
CollationBuilder builder(base, errorCode);
UVersionInfo noVersion = { 0, 0, 0, 0 };
BundleImporter importer;
@@ -172,7 +172,7 @@ RuleBasedCollator::internalBuildTailoring(const UnicodeString &rules,
outParseError, errorCode));
if(U_FAILURE(errorCode)) {
const char *reason = builder.getErrorReason();
- if(reason != NULL && outReason != NULL) {
+ if(reason != nullptr && outReason != nullptr) {
*outReason = UnicodeString(reason, -1, US_INV);
}
return;
@@ -191,14 +191,7 @@ RuleBasedCollator::internalBuildTailoring(const UnicodeString &rules,
// CollationBuilder implementation ----------------------------------------- ***
-// Some compilers don't care if constants are defined in the .cpp file.
-// MS Visual C++ does not like it, but gcc requires it. clang does not care.
-#ifndef _MSC_VER
-const int32_t CollationBuilder::HAS_BEFORE2;
-const int32_t CollationBuilder::HAS_BEFORE3;
-#endif
-
-CollationBuilder::CollationBuilder(const CollationTailoring *b, UErrorCode &errorCode)
+CollationBuilder::CollationBuilder(const CollationTailoring *b, UBool icu4xMode, UErrorCode &errorCode)
: nfd(*Normalizer2::getNFDInstance(errorCode)),
fcd(*Normalizer2Factory::getFCDInstance(errorCode)),
nfcImpl(*Normalizer2Factory::getNFCImpl(errorCode)),
@@ -206,8 +199,9 @@ CollationBuilder::CollationBuilder(const CollationTailoring *b, UErrorCode &erro
baseData(b->data),
rootElements(b->data->rootElements, b->data->rootElementsLength),
variableTop(0),
- dataBuilder(new CollationDataBuilder(errorCode)), fastLatinEnabled(TRUE),
- errorReason(NULL),
+ dataBuilder(new CollationDataBuilder(icu4xMode, errorCode)), fastLatinEnabled(true),
+ icu4xMode(icu4xMode),
+ errorReason(nullptr),
cesLength(0),
rootPrimaryIndexes(errorCode), nodes(errorCode) {
nfcImpl.ensureCanonIterData(errorCode);
@@ -215,7 +209,7 @@ CollationBuilder::CollationBuilder(const CollationTailoring *b, UErrorCode &erro
errorReason = "CollationBuilder fields initialization failed";
return;
}
- if(dataBuilder == NULL) {
+ if(dataBuilder == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -225,6 +219,10 @@ CollationBuilder::CollationBuilder(const CollationTailoring *b, UErrorCode &erro
}
}
+CollationBuilder::CollationBuilder(const CollationTailoring *b, UErrorCode &errorCode)
+ : CollationBuilder(b, false, errorCode)
+{}
+
CollationBuilder::~CollationBuilder() {
delete dataBuilder;
}
@@ -235,19 +233,19 @@ CollationBuilder::parseAndBuild(const UnicodeString &ruleString,
CollationRuleParser::Importer *importer,
UParseError *outParseError,
UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return NULL; }
- if(baseData->rootElements == NULL) {
+ if(U_FAILURE(errorCode)) { return nullptr; }
+ if(baseData->rootElements == nullptr) {
errorCode = U_MISSING_RESOURCE_ERROR;
errorReason = "missing root elements data, tailoring not supported";
- return NULL;
+ return nullptr;
}
LocalPointer<CollationTailoring> tailoring(new CollationTailoring(base->settings));
if(tailoring.isNull() || tailoring->isBogus()) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
CollationRuleParser parser(baseData, errorCode);
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
// Note: This always bases &[last variable] and &[first regular]
// on the root collator's maxVariable/variableTop.
// If we wanted this to change after [maxVariable x], then we would keep
@@ -259,28 +257,32 @@ CollationBuilder::parseAndBuild(const UnicodeString &ruleString,
CollationSettings &ownedSettings = *SharedObject::copyOnWrite(tailoring->settings);
parser.parse(ruleString, ownedSettings, outParseError, errorCode);
errorReason = parser.getErrorReason();
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
if(dataBuilder->hasMappings()) {
makeTailoredCEs(errorCode);
- closeOverComposites(errorCode);
+ if (!icu4xMode) {
+ closeOverComposites(errorCode);
+ }
finalizeCEs(errorCode);
- // Copy all of ASCII, and Latin-1 letters, into each tailoring.
- optimizeSet.add(0, 0x7f);
- optimizeSet.add(0xc0, 0xff);
- // Hangul is decomposed on the fly during collation,
- // and the tailoring data is always built with HANGUL_TAG specials.
- optimizeSet.remove(Hangul::HANGUL_BASE, Hangul::HANGUL_END);
- dataBuilder->optimize(optimizeSet, errorCode);
+ if (!icu4xMode) {
+ // Copy all of ASCII, and Latin-1 letters, into each tailoring.
+ optimizeSet.add(0, 0x7f);
+ optimizeSet.add(0xc0, 0xff);
+ // Hangul is decomposed on the fly during collation,
+ // and the tailoring data is always built with HANGUL_TAG specials.
+ optimizeSet.remove(Hangul::HANGUL_BASE, Hangul::HANGUL_END);
+ dataBuilder->optimize(optimizeSet, errorCode);
+ }
tailoring->ensureOwnedData(errorCode);
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
if(fastLatinEnabled) { dataBuilder->enableFastLatin(); }
dataBuilder->build(*tailoring->ownedData, errorCode);
tailoring->builder = dataBuilder;
- dataBuilder = NULL;
+ dataBuilder = nullptr;
} else {
tailoring->data = baseData;
}
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
ownedSettings.fastLatinOptions = CollationFastLatin::getOptions(
tailoring->data, ownedSettings,
ownedSettings.fastLatinPrimaries, UPRV_LENGTHOF(ownedSettings.fastLatinPrimaries));
@@ -484,7 +486,7 @@ CollationBuilder::getSpecialResetPosition(const UnicodeString &str,
U_ASSERT(str.length() == 2);
int64_t ce;
int32_t strength = UCOL_PRIMARY;
- UBool isBoundary = FALSE;
+ UBool isBoundary = false;
UChar32 pos = str.charAt(1) - CollationRuleParser::POS_BASE;
U_ASSERT(0 <= pos && pos <= CollationRuleParser::LAST_TRAILING);
switch(pos) {
@@ -544,14 +546,14 @@ CollationBuilder::getSpecialResetPosition(const UnicodeString &str,
break;
case CollationRuleParser::FIRST_VARIABLE:
ce = rootElements.getFirstPrimaryCE();
- isBoundary = TRUE; // FractionalUCA.txt: FDD1 00A0, SPACE first primary
+ isBoundary = true; // FractionalUCA.txt: FDD1 00A0, SPACE first primary
break;
case CollationRuleParser::LAST_VARIABLE:
ce = rootElements.lastCEWithPrimaryBefore(variableTop + 1);
break;
case CollationRuleParser::FIRST_REGULAR:
ce = rootElements.firstCEWithPrimaryAtLeast(variableTop + 1);
- isBoundary = TRUE; // FractionalUCA.txt: FDD1 263A, SYMBOL first primary
+ isBoundary = true; // FractionalUCA.txt: FDD1 263A, SYMBOL first primary
break;
case CollationRuleParser::LAST_REGULAR:
// Use the Hani-first-primary rather than the actual last "regular" CE before it,
@@ -570,7 +572,7 @@ CollationBuilder::getSpecialResetPosition(const UnicodeString &str,
return 0;
case CollationRuleParser::FIRST_TRAILING:
ce = Collation::makeCE(Collation::FIRST_TRAILING_PRIMARY);
- isBoundary = TRUE; // trailing first primary (there is no mapping for it)
+ isBoundary = true; // trailing first primary (there is no mapping for it)
break;
case CollationRuleParser::LAST_TRAILING:
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
@@ -667,7 +669,7 @@ CollationBuilder::addRelation(int32_t strength, const UnicodeString &prefix,
// It does not work with certain types of contextual mappings.
int32_t nfdLength = nfdString.length();
if(nfdLength >= 2) {
- UChar c = nfdString.charAt(0);
+ char16_t c = nfdString.charAt(0);
if(Hangul::isJamoL(c) || Hangul::isJamoV(c)) {
// While handling a Hangul syllable, contractions starting with Jamo L or V
// would not see the following Jamo of that syllable.
@@ -743,14 +745,18 @@ CollationBuilder::addRelation(int32_t strength, const UnicodeString &prefix,
}
}
uint32_t ce32 = Collation::UNASSIGNED_CE32;
- if((prefix != nfdPrefix || str != nfdString) &&
+ if(!icu4xMode && (prefix != nfdPrefix || str != nfdString) &&
!ignorePrefix(prefix, errorCode) && !ignoreString(str, errorCode)) {
// Map from the original input to the CEs.
// We do this in case the canonical closure is incomplete,
// so that it is possible to explicitly provide the missing mappings.
ce32 = addIfDifferent(prefix, str, ces, cesLength, ce32, errorCode);
}
- addWithClosure(nfdPrefix, nfdString, ces, cesLength, ce32, errorCode);
+ if (!icu4xMode) {
+ addWithClosure(nfdPrefix, nfdString, ces, cesLength, ce32, errorCode);
+ } else {
+ addIfDifferent(nfdPrefix, nfdString, ces, cesLength, ce32, errorCode);
+ }
if(U_FAILURE(errorCode)) {
parserErrorReason = "writing collation elements";
return;
@@ -1024,8 +1030,8 @@ CollationBuilder::setCaseBits(const UnicodeString &nfdString,
int64_t cases = 0;
if(numTailoredPrimaries > 0) {
- const UChar *s = nfdString.getBuffer();
- UTF16CollationIterator baseCEs(baseData, FALSE, s, s, s + nfdString.length());
+ const char16_t *s = nfdString.getBuffer();
+ UTF16CollationIterator baseCEs(baseData, false, s, s, s + nfdString.length());
int32_t baseCEsLength = baseCEs.fetchCEs(errorCode) - 1;
if(U_FAILURE(errorCode)) {
parserErrorReason = "fetching root CEs for tailored string";
@@ -1217,18 +1223,18 @@ CollationBuilder::mergeCompositeIntoString(const UnicodeString &nfdString,
UChar32 composite, const UnicodeString &decomp,
UnicodeString &newNFDString, UnicodeString &newString,
UErrorCode &errorCode) const {
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
U_ASSERT(nfdString.char32At(indexAfterLastStarter - 1) == decomp.char32At(0));
int32_t lastStarterLength = decomp.moveIndex32(0, 1);
if(lastStarterLength == decomp.length()) {
// Singleton decompositions should be found by addWithClosure()
// and the CanonicalIterator, so we can ignore them here.
- return FALSE;
+ return false;
}
if(nfdString.compare(indexAfterLastStarter, 0x7fffffff,
decomp, lastStarterLength, 0x7fffffff) == 0) {
// same strings, nothing new to be found here
- return FALSE;
+ return false;
}
// Make new FCD strings that combine a composite, or its decomposition,
@@ -1238,7 +1244,7 @@ CollationBuilder::mergeCompositeIntoString(const UnicodeString &nfdString,
newString.setTo(nfdString, 0, indexAfterLastStarter - lastStarterLength).append(composite);
// The following is related to discontiguous contraction matching,
- // but builds only FCD strings (or else returns FALSE).
+ // but builds only FCD strings (or else returns false).
int32_t sourceIndex = indexAfterLastStarter;
int32_t decompIndex = lastStarterLength;
// Small optimization: We keep the source character across loop iterations
@@ -1265,16 +1271,16 @@ CollationBuilder::mergeCompositeIntoString(const UnicodeString &nfdString,
// Unable to merge because the source contains a non-zero combining mark
// but the composite's decomposition contains another starter.
// The strings would not be equivalent.
- return FALSE;
+ return false;
} else if(sourceCC < decompCC) {
// Composite + sourceChar would not be FCD.
- return FALSE;
+ return false;
} else if(decompCC < sourceCC) {
newNFDString.append(decompChar);
decompIndex += U16_LENGTH(decompChar);
} else if(decompChar != sourceChar) {
// Blocked because same combining class.
- return FALSE;
+ return false;
} else { // match: decompChar == sourceChar
newNFDString.append(decompChar);
decompIndex += U16_LENGTH(decompChar);
@@ -1286,7 +1292,7 @@ CollationBuilder::mergeCompositeIntoString(const UnicodeString &nfdString,
if(sourceChar >= 0) { // more characters from nfdString but not from decomp
if(sourceCC < decompCC) {
// Appending the next source character to the composite would not be FCD.
- return FALSE;
+ return false;
}
newNFDString.append(nfdString, sourceIndex, 0x7fffffff);
newString.append(nfdString, sourceIndex, 0x7fffffff);
@@ -1296,7 +1302,7 @@ CollationBuilder::mergeCompositeIntoString(const UnicodeString &nfdString,
U_ASSERT(nfd.isNormalized(newNFDString, errorCode));
U_ASSERT(fcd.isNormalized(newString, errorCode));
U_ASSERT(nfd.normalize(newString, errorCode) == newNFDString); // canonically equivalent
- return TRUE;
+ return true;
}
UBool
@@ -1361,13 +1367,13 @@ UBool
CollationBuilder::sameCEs(const int64_t ces1[], int32_t ces1Length,
const int64_t ces2[], int32_t ces2Length) {
if(ces1Length != ces2Length) {
- return FALSE;
+ return false;
}
U_ASSERT(ces1Length <= Collation::MAX_EXPANSION_LENGTH);
for(int32_t i = 0; i < ces1Length; ++i) {
- if(ces1[i] != ces2[i]) { return FALSE; }
+ if(ces1[i] != ces2[i]) { return false; }
}
- return TRUE;
+ return true;
}
#ifdef DEBUG_COLLATION_BUILDER
@@ -1399,9 +1405,9 @@ CollationBuilder::makeTailoredCEs(UErrorCode &errorCode) {
uint32_t s = p == 0 ? 0 : Collation::COMMON_WEIGHT16;
uint32_t t = s;
uint32_t q = 0;
- UBool pIsTailored = FALSE;
- UBool sIsTailored = FALSE;
- UBool tIsTailored = FALSE;
+ UBool pIsTailored = false;
+ UBool sIsTailored = false;
+ UBool tIsTailored = false;
#ifdef DEBUG_COLLATION_BUILDER
printf("\nprimary %lx\n", (long)alignWeightRight(p));
#endif
@@ -1455,13 +1461,13 @@ CollationBuilder::makeTailoredCEs(UErrorCode &errorCode) {
errorReason = "tertiary tailoring gap too small";
return;
}
- tIsTailored = TRUE;
+ tIsTailored = true;
}
t = tertiaries.nextWeight();
U_ASSERT(t != 0xffffffff);
} else {
t = weight16FromNode(node);
- tIsTailored = FALSE;
+ tIsTailored = false;
#ifdef DEBUG_COLLATION_BUILDER
printf(" ter %lx\n", (long)alignWeightRight(t));
#endif
@@ -1507,13 +1513,13 @@ CollationBuilder::makeTailoredCEs(UErrorCode &errorCode) {
#endif
return;
}
- sIsTailored = TRUE;
+ sIsTailored = true;
}
s = secondaries.nextWeight();
U_ASSERT(s != 0xffffffff);
} else {
s = weight16FromNode(node);
- sIsTailored = FALSE;
+ sIsTailored = false;
#ifdef DEBUG_COLLATION_BUILDER
printf(" sec %lx\n", (long)alignWeightRight(s));
#endif
@@ -1536,15 +1542,15 @@ CollationBuilder::makeTailoredCEs(UErrorCode &errorCode) {
errorReason = "primary tailoring gap too small";
return;
}
- pIsTailored = TRUE;
+ pIsTailored = true;
}
p = primaries.nextWeight();
U_ASSERT(p != 0xffffffff);
s = Collation::COMMON_WEIGHT16;
- sIsTailored = FALSE;
+ sIsTailored = false;
}
t = s == 0 ? 0 : Collation::COMMON_WEIGHT16;
- tIsTailored = FALSE;
+ tIsTailored = false;
}
q = 0;
}
@@ -1608,7 +1614,7 @@ CEFinalizer::~CEFinalizer() {}
void
CollationBuilder::finalizeCEs(UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
- LocalPointer<CollationDataBuilder> newBuilder(new CollationDataBuilder(errorCode), errorCode);
+ LocalPointer<CollationDataBuilder> newBuilder(new CollationDataBuilder(icu4xMode, errorCode), errorCode);
if(U_FAILURE(errorCode)) {
return;
}
@@ -1635,24 +1641,24 @@ U_NAMESPACE_END
U_NAMESPACE_USE
U_CAPI UCollator * U_EXPORT2
-ucol_openRules(const UChar *rules, int32_t rulesLength,
+ucol_openRules(const char16_t *rules, int32_t rulesLength,
UColAttributeValue normalizationMode, UCollationStrength strength,
UParseError *parseError, UErrorCode *pErrorCode) {
- if(U_FAILURE(*pErrorCode)) { return NULL; }
- if(rules == NULL && rulesLength != 0) {
+ if(U_FAILURE(*pErrorCode)) { return nullptr; }
+ if(rules == nullptr && rulesLength != 0) {
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
RuleBasedCollator *coll = new RuleBasedCollator();
- if(coll == NULL) {
+ if(coll == nullptr) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
UnicodeString r((UBool)(rulesLength < 0), rules, rulesLength);
- coll->internalBuildTailoring(r, strength, normalizationMode, parseError, NULL, *pErrorCode);
+ coll->internalBuildTailoring(r, strength, normalizationMode, parseError, nullptr, *pErrorCode);
if(U_FAILURE(*pErrorCode)) {
delete coll;
- return NULL;
+ return nullptr;
}
return coll->toUCollator();
}
@@ -1670,13 +1676,13 @@ ucol_getUnsafeSet( const UCollator *coll,
USet *unsafe,
UErrorCode *status)
{
- UChar buffer[internalBufferSize];
+ char16_t buffer[internalBufferSize];
int32_t len = 0;
uset_clear(unsafe);
// cccpattern = "[[:^tccc=0:][:^lccc=0:]]", unfortunately variant
- static const UChar cccpattern[25] = { 0x5b, 0x5b, 0x3a, 0x5e, 0x74, 0x63, 0x63, 0x63, 0x3d, 0x30, 0x3a, 0x5d,
+ static const char16_t cccpattern[25] = { 0x5b, 0x5b, 0x3a, 0x5e, 0x74, 0x63, 0x63, 0x63, 0x3d, 0x30, 0x3a, 0x5d,
0x5b, 0x3a, 0x5e, 0x6c, 0x63, 0x63, 0x63, 0x3d, 0x30, 0x3a, 0x5d, 0x5d, 0x00 };
// add chars that fail the fcd check
@@ -1690,14 +1696,14 @@ ucol_getUnsafeSet( const UCollator *coll,
USet *contractions = uset_open(0,0);
int32_t i = 0, j = 0;
- ucol_getContractionsAndExpansions(coll, contractions, NULL, FALSE, status);
+ ucol_getContractionsAndExpansions(coll, contractions, nullptr, false, status);
int32_t contsSize = uset_size(contractions);
UChar32 c = 0;
// Contraction set consists only of strings
// to get unsafe code points, we need to
// break the strings apart and add them to the unsafe set
for(i = 0; i < contsSize; i++) {
- len = uset_getItem(contractions, i, NULL, NULL, buffer, internalBufferSize, status);
+ len = uset_getItem(contractions, i, nullptr, nullptr, buffer, internalBufferSize, status);
if(len > 0) {
j = 0;
while(j < len) {
diff --git a/contrib/libs/icu/i18n/collationbuilder.h b/contrib/libs/icu/i18n/collationbuilder.h
index 59d3c5d24b..22e24ddb81 100644
--- a/contrib/libs/icu/i18n/collationbuilder.h
+++ b/contrib/libs/icu/i18n/collationbuilder.h
@@ -39,6 +39,7 @@ class Normalizer2Impl;
class U_I18N_API CollationBuilder : public CollationRuleParser::Sink {
public:
+ CollationBuilder(const CollationTailoring *b, UBool icu4xMode, UErrorCode &errorCode);
CollationBuilder(const CollationTailoring *base, UErrorCode &errorCode);
virtual ~CollationBuilder();
@@ -302,6 +303,7 @@ private:
CollationDataBuilder *dataBuilder;
UBool fastLatinEnabled;
+ UBool icu4xMode;
UnicodeSet optimizeSet;
const char *errorReason;
diff --git a/contrib/libs/icu/i18n/collationcompare.cpp b/contrib/libs/icu/i18n/collationcompare.cpp
index cbf32c9fe6..d9048afc27 100644
--- a/contrib/libs/icu/i18n/collationcompare.cpp
+++ b/contrib/libs/icu/i18n/collationcompare.cpp
@@ -39,7 +39,7 @@ CollationCompare::compareUpToQuaternary(CollationIterator &left, CollationIterat
// +1 so that we can use "<" and primary ignorables test out early.
variableTop = settings.variableTop + 1;
}
- UBool anyVariable = FALSE;
+ UBool anyVariable = false;
// Fetch CEs, compare primaries, store secondary & tertiary weights.
for(;;) {
@@ -51,7 +51,7 @@ CollationCompare::compareUpToQuaternary(CollationIterator &left, CollationIterat
if(leftPrimary < variableTop && leftPrimary > Collation::MERGE_SEPARATOR_PRIMARY) {
// Variable CE, shift it to quaternary level.
// Ignore all following primary ignorables, and shift further variable CEs.
- anyVariable = TRUE;
+ anyVariable = true;
do {
// Store only the primary of the variable CE.
left.setCurrentCE(ce & INT64_C(0xffffffff00000000));
@@ -76,7 +76,7 @@ CollationCompare::compareUpToQuaternary(CollationIterator &left, CollationIterat
if(rightPrimary < variableTop && rightPrimary > Collation::MERGE_SEPARATOR_PRIMARY) {
// Variable CE, shift it to quaternary level.
// Ignore all following primary ignorables, and shift further variable CEs.
- anyVariable = TRUE;
+ anyVariable = true;
do {
// Store only the primary of the variable CE.
right.setCurrentCE(ce & INT64_C(0xffffffff00000000));
diff --git a/contrib/libs/icu/i18n/collationdata.cpp b/contrib/libs/icu/i18n/collationdata.cpp
index 688770f8f6..1b8b6a76de 100644
--- a/contrib/libs/icu/i18n/collationdata.cpp
+++ b/contrib/libs/icu/i18n/collationdata.cpp
@@ -205,7 +205,7 @@ CollationData::getEquivalentScripts(int32_t script,
void
CollationData::makeReorderRanges(const int32_t *reorder, int32_t length,
UVector32 &ranges, UErrorCode &errorCode) const {
- makeReorderRanges(reorder, length, FALSE, ranges, errorCode);
+ makeReorderRanges(reorder, length, false, ranges, errorCode);
}
void
@@ -277,12 +277,12 @@ CollationData::makeReorderRanges(const int32_t *reorder, int32_t length,
// Reorder according to the input scripts, continuing from the bottom of the primary range.
int32_t originalLength = length; // length will be decremented if "others" is in the list.
- UBool hasReorderToEnd = FALSE;
+ UBool hasReorderToEnd = false;
for(int32_t i = 0; i < length;) {
int32_t script = reorder[i++];
if(script == USCRIPT_UNKNOWN) {
// Put the remaining scripts at the top.
- hasReorderToEnd = TRUE;
+ hasReorderToEnd = true;
while(i < length) {
script = reorder[--length];
if(script == USCRIPT_UNKNOWN || // Must occur at most once.
@@ -329,7 +329,7 @@ CollationData::makeReorderRanges(const int32_t *reorder, int32_t length,
if(lowStart > highLimit) {
if((lowStart - (skippedReserved & 0xff00)) <= highLimit) {
// Try not skipping the before-Latin reserved range.
- makeReorderRanges(reorder, originalLength, TRUE, ranges, errorCode);
+ makeReorderRanges(reorder, originalLength, true, ranges, errorCode);
return;
}
// We need more primary lead bytes than available, despite the reserved ranges.
diff --git a/contrib/libs/icu/i18n/collationdata.h b/contrib/libs/icu/i18n/collationdata.h
index ab9b4c47ec..d4f66828fb 100644
--- a/contrib/libs/icu/i18n/collationdata.h
+++ b/contrib/libs/icu/i18n/collationdata.h
@@ -41,29 +41,25 @@ struct U_I18N_API CollationData : public UMemory {
// Note: The ucadata.icu loader could discover the reserved ranges by setting an array
// parallel with the ranges, and resetting ranges that are indexed.
// The reordering builder code could clone the resulting template array.
- enum {
- REORDER_RESERVED_BEFORE_LATIN = UCOL_REORDER_CODE_FIRST + 14,
- REORDER_RESERVED_AFTER_LATIN
- };
+ static constexpr int32_t REORDER_RESERVED_BEFORE_LATIN = UCOL_REORDER_CODE_FIRST + 14;
+ static constexpr int32_t REORDER_RESERVED_AFTER_LATIN = REORDER_RESERVED_BEFORE_LATIN + 1;
- enum {
- MAX_NUM_SPECIAL_REORDER_CODES = 8,
- /** C++ only, data reader check scriptStartsLength. */
- MAX_NUM_SCRIPT_RANGES = 256
- };
+ static constexpr int32_t MAX_NUM_SPECIAL_REORDER_CODES = 8;
+ /** C++ only, data reader check scriptStartsLength. */
+ static constexpr int32_t MAX_NUM_SCRIPT_RANGES = 256;
CollationData(const Normalizer2Impl &nfc)
- : trie(NULL),
- ce32s(NULL), ces(NULL), contexts(NULL), base(NULL),
- jamoCE32s(NULL),
+ : trie(nullptr),
+ ce32s(nullptr), ces(nullptr), contexts(nullptr), base(nullptr),
+ jamoCE32s(nullptr),
nfcImpl(nfc),
numericPrimary(0x12000000),
ce32sLength(0), cesLength(0), contextsLength(0),
- compressibleBytes(NULL),
- unsafeBackwardSet(NULL),
- fastLatinTable(NULL), fastLatinTableLength(0),
- numScripts(0), scriptsIndex(NULL), scriptStarts(NULL), scriptStartsLength(0),
- rootElements(NULL), rootElementsLength(0) {}
+ compressibleBytes(nullptr),
+ unsafeBackwardSet(nullptr),
+ fastLatinTable(nullptr), fastLatinTableLength(0),
+ numScripts(0), scriptsIndex(nullptr), scriptStarts(nullptr), scriptStartsLength(0),
+ rootElements(nullptr), rootElementsLength(0) {}
uint32_t getCE32(UChar32 c) const {
return UTRIE2_GET32(trie, c);
@@ -94,7 +90,7 @@ struct U_I18N_API CollationData : public UMemory {
* Returns the CE32 from two contexts words.
* Access to the defaultCE32 for contraction and prefix matching.
*/
- static uint32_t readCE32(const UChar *p) {
+ static uint32_t readCE32(const char16_t *p) {
return ((uint32_t)p[0] << 16) | p[1];
}
@@ -182,8 +178,8 @@ struct U_I18N_API CollationData : public UMemory {
/** Array of CE values for expansions and OFFSET_TAG. */
const int64_t *ces;
/** Array of prefix and contraction-suffix matching data. */
- const UChar *contexts;
- /** Base collation data, or NULL if this data itself is a base. */
+ const char16_t *contexts;
+ /** Base collation data, or nullptr if this data itself is a base. */
const CollationData *base;
/**
* Simple array of JAMO_CE32S_LENGTH=19+21+27 CE32s, one per canonical Jamo L/V/T.
@@ -242,7 +238,7 @@ struct U_I18N_API CollationData : public UMemory {
/**
* Collation elements in the root collator.
* Used by the CollationRootElements class. The data structure is described there.
- * NULL in a tailoring.
+ * nullptr in a tailoring.
*/
const uint32_t *rootElements;
int32_t rootElementsLength;
diff --git a/contrib/libs/icu/i18n/collationdatabuilder.cpp b/contrib/libs/icu/i18n/collationdatabuilder.cpp
index 25050aa777..7c6f1b881e 100644
--- a/contrib/libs/icu/i18n/collationdatabuilder.cpp
+++ b/contrib/libs/icu/i18n/collationdatabuilder.cpp
@@ -86,18 +86,30 @@ struct ConditionalCE32 : public UMemory {
* When fetching CEs from the builder, the contexts are built into their runtime form
* so that the normal collation implementation can process them.
* The result is cached in the list head. It is reset when the contexts are modified.
+ * All of these builtCE32 are invalidated by clearContexts(),
+ * via incrementing the contextsEra.
*/
uint32_t builtCE32;
/**
+ * The "era" of building intermediate contexts when the above builtCE32 was set.
+ * When the array of cached, temporary contexts overflows, then clearContexts()
+ * removes them all and invalidates the builtCE32 that used to point to built tries.
+ */
+ int32_t era = -1;
+ /**
* Index of the next ConditionalCE32.
* Negative for the end of the list.
*/
int32_t next;
+ // Note: We could create a separate class for all of the contextual mappings for
+ // a code point, with the builtCE32, the era, and a list of the actual mappings.
+ // The class that represents one mapping would then not need to
+ // store those fields in each element.
};
U_CDECL_BEGIN
-U_CAPI void U_CALLCONV
+void U_CALLCONV
uprv_deleteConditionalCE32(void *obj) {
delete static_cast<ConditionalCE32 *>(obj);
}
@@ -152,9 +164,9 @@ protected:
};
DataBuilderCollationIterator::DataBuilderCollationIterator(CollationDataBuilder &b)
- : CollationIterator(&builderData, /*numeric=*/ FALSE),
+ : CollationIterator(&builderData, /*numeric=*/ false),
builder(b), builderData(b.nfcImpl),
- s(NULL), pos(0) {
+ s(nullptr), pos(0) {
builderData.base = builder.base;
// Set all of the jamoCE32s[] to indirection CE32s.
for(int32_t j = 0; j < CollationData::JAMO_CE32S_LENGTH; ++j) { // Count across Jamo types.
@@ -192,7 +204,7 @@ DataBuilderCollationIterator::fetchCEs(const UnicodeString &str, int32_t start,
} else {
d = &builderData;
}
- appendCEsFromCE32(d, c, ce32, /*forward=*/ TRUE, errorCode);
+ appendCEsFromCE32(d, c, ce32, /*forward=*/ true, errorCode);
U_ASSERT(U_SUCCESS(errorCode));
for(int32_t i = 0; i < getCEsLength(); ++i) {
int64_t ce = getCE(i);
@@ -267,7 +279,7 @@ DataBuilderCollationIterator::getCE32FromBuilderData(uint32_t ce32, UErrorCode &
// TODO: ICU-21531 figure out why this happens.
return 0;
}
- if(cond->builtCE32 == Collation::NO_CE32) {
+ if(cond->builtCE32 == Collation::NO_CE32 || cond->era != builder.contextsEra) {
// Build the context-sensitive mappings into their runtime form and cache the result.
cond->builtCE32 = builder.buildContext(cond, errorCode);
if(errorCode == U_BUFFER_OVERFLOW_ERROR) {
@@ -275,6 +287,7 @@ DataBuilderCollationIterator::getCE32FromBuilderData(uint32_t ce32, UErrorCode &
builder.clearContexts();
cond->builtCE32 = builder.buildContext(cond, errorCode);
}
+ cond->era = builder.contextsEra;
builderData.contexts = builder.contexts.getBuffer();
}
return cond->builtCE32;
@@ -283,16 +296,19 @@ DataBuilderCollationIterator::getCE32FromBuilderData(uint32_t ce32, UErrorCode &
// ------------------------------------------------------------------------- ***
-CollationDataBuilder::CollationDataBuilder(UErrorCode &errorCode)
+CollationDataBuilder::CollationDataBuilder(UBool icu4xMode, UErrorCode &errorCode)
: nfcImpl(*Normalizer2Factory::getNFCImpl(errorCode)),
- base(NULL), baseSettings(NULL),
- trie(NULL),
+ base(nullptr), baseSettings(nullptr),
+ trie(nullptr),
ce32s(errorCode), ce64s(errorCode), conditionalCE32s(errorCode),
- modified(FALSE),
- fastLatinEnabled(FALSE), fastLatinBuilder(NULL),
- collIter(NULL) {
+ modified(false),
+ icu4xMode(icu4xMode),
+ fastLatinEnabled(false), fastLatinBuilder(nullptr),
+ collIter(nullptr) {
// Reserve the first CE32 for U+0000.
- ce32s.addElement(0, errorCode);
+ if (!icu4xMode) {
+ ce32s.addElement(0, errorCode);
+ }
conditionalCE32s.setDeleter(uprv_deleteConditionalCE32);
}
@@ -305,38 +321,42 @@ CollationDataBuilder::~CollationDataBuilder() {
void
CollationDataBuilder::initForTailoring(const CollationData *b, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
- if(trie != NULL) {
+ if(trie != nullptr) {
errorCode = U_INVALID_STATE_ERROR;
return;
}
- if(b == NULL) {
+ if(b == nullptr) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
base = b;
// For a tailoring, the default is to fall back to the base.
- trie = utrie2_open(Collation::FALLBACK_CE32, Collation::FFFD_CE32, &errorCode);
-
- // Set the Latin-1 letters block so that it is allocated first in the data array,
- // to try to improve locality of reference when sorting Latin-1 text.
- // Do not use utrie2_setRange32() since that will not actually allocate blocks
- // that are filled with the default value.
- // ASCII (0..7F) is already preallocated anyway.
- for(UChar32 c = 0xc0; c <= 0xff; ++c) {
- utrie2_set32(trie, c, Collation::FALLBACK_CE32, &errorCode);
- }
+ // For ICU4X, use the same value for fallback as for the default
+ // to avoid having to have different blocks for the two.
+ trie = utrie2_open(Collation::FALLBACK_CE32, icu4xMode ? Collation::FALLBACK_CE32 : Collation::FFFD_CE32, &errorCode);
+
+ if (!icu4xMode) {
+ // Set the Latin-1 letters block so that it is allocated first in the data array,
+ // to try to improve locality of reference when sorting Latin-1 text.
+ // Do not use utrie2_setRange32() since that will not actually allocate blocks
+ // that are filled with the default value.
+ // ASCII (0..7F) is already preallocated anyway.
+ for(UChar32 c = 0xc0; c <= 0xff; ++c) {
+ utrie2_set32(trie, c, Collation::FALLBACK_CE32, &errorCode);
+ }
- // Hangul syllables are not tailorable (except via tailoring Jamos).
- // Always set the Hangul tag to help performance.
- // Do this here, rather than in buildMappings(),
- // so that we see the HANGUL_TAG in various assertions.
- uint32_t hangulCE32 = Collation::makeCE32FromTagAndIndex(Collation::HANGUL_TAG, 0);
- utrie2_setRange32(trie, Hangul::HANGUL_BASE, Hangul::HANGUL_END, hangulCE32, TRUE, &errorCode);
+ // Hangul syllables are not tailorable (except via tailoring Jamos).
+ // Always set the Hangul tag to help performance.
+ // Do this here, rather than in buildMappings(),
+ // so that we see the HANGUL_TAG in various assertions.
+ uint32_t hangulCE32 = Collation::makeCE32FromTagAndIndex(Collation::HANGUL_TAG, 0);
+ utrie2_setRange32(trie, Hangul::HANGUL_BASE, Hangul::HANGUL_END, hangulCE32, true, &errorCode);
- // Copy the set contents but don't copy/clone the set as a whole because
- // that would copy the isFrozen state too.
- unsafeBackwardSet.addAll(*b->unsafeBackwardSet);
+ // Copy the set contents but don't copy/clone the set as a whole because
+ // that would copy the isFrozen state too.
+ unsafeBackwardSet.addAll(*b->unsafeBackwardSet);
+ }
if(U_FAILURE(errorCode)) { return; }
}
@@ -345,7 +365,7 @@ UBool
CollationDataBuilder::maybeSetPrimaryRange(UChar32 start, UChar32 end,
uint32_t primary, int32_t step,
UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
U_ASSERT(start <= end);
// TODO: Do we need to check what values are currently set for start..end?
// An offset range is worth it only if we can achieve an overlap between
@@ -370,11 +390,11 @@ CollationDataBuilder::maybeSetPrimaryRange(UChar32 start, UChar32 end,
return 0;
}
uint32_t offsetCE32 = Collation::makeCE32FromTagAndIndex(Collation::OFFSET_TAG, index);
- utrie2_setRange32(trie, start, end, offsetCE32, TRUE, &errorCode);
- modified = TRUE;
- return TRUE;
+ utrie2_setRange32(trie, start, end, offsetCE32, true, &errorCode);
+ modified = true;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
@@ -395,7 +415,7 @@ CollationDataBuilder::setPrimaryRangeAndReturnNext(UChar32 start, UChar32 end,
primary = Collation::incThreeBytePrimaryByOffset(primary, isCompressible, step);
if(start > end) { return primary; }
}
- modified = TRUE;
+ modified = true;
}
}
@@ -431,10 +451,10 @@ int64_t
CollationDataBuilder::getSingleCE(UChar32 c, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return 0; }
// Keep parallel with CollationData::getSingleCE().
- UBool fromBase = FALSE;
+ UBool fromBase = false;
uint32_t ce32 = utrie2_get32(trie, c);
if(ce32 == Collation::FALLBACK_CE32) {
- fromBase = TRUE;
+ fromBase = true;
ce32 = base->getCE32(c);
}
while(Collation::isSpecialCE32(ce32)) {
@@ -522,12 +542,11 @@ CollationDataBuilder::addConditionalCE32(const UnicodeString &context, uint32_t
errorCode = U_BUFFER_OVERFLOW_ERROR;
return -1;
}
- ConditionalCE32 *cond = new ConditionalCE32(context, ce32);
- if(cond == NULL) {
- errorCode = U_MEMORY_ALLOCATION_ERROR;
+ LocalPointer<ConditionalCE32> cond(new ConditionalCE32(context, ce32), errorCode);
+ conditionalCE32s.adoptElement(cond.orphan(), errorCode);
+ if(U_FAILURE(errorCode)) {
return -1;
}
- conditionalCE32s.addElementX(cond, errorCode);
return index;
}
@@ -547,7 +566,7 @@ CollationDataBuilder::addCE32(const UnicodeString &prefix, const UnicodeString &
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
- if(trie == NULL || utrie2_isFrozen(trie)) {
+ if(trie == nullptr || utrie2_isFrozen(trie)) {
errorCode = U_INVALID_STATE_ERROR;
return;
}
@@ -555,6 +574,98 @@ CollationDataBuilder::addCE32(const UnicodeString &prefix, const UnicodeString &
int32_t cLength = U16_LENGTH(c);
uint32_t oldCE32 = utrie2_get32(trie, c);
UBool hasContext = !prefix.isEmpty() || s.length() > cLength;
+
+ if (icu4xMode) {
+ if (base && c >= 0x1100 && c < 0x1200) {
+ // Omit jamo tailorings.
+ // TODO(https://github.com/unicode-org/icu4x/issues/1941).
+ }
+ const Normalizer2* nfdNormalizer = Normalizer2::getNFDInstance(errorCode);
+ UnicodeString sInNfd;
+ nfdNormalizer->normalize(s, sInNfd, errorCode);
+ if (s != sInNfd) {
+ // s is not in NFD, so it cannot match in ICU4X, since ICU4X only
+ // does NFD lookups.
+ // Now check that we're only rejecting known cases.
+ if (s.length() == 2) {
+ char16_t second = s.charAt(1);
+ if (second == 0x0F73 || second == 0x0F75 || second == 0x0F81) {
+ // Second is a special decomposing Tibetan vowel sign.
+ // These also get added in the decomposed form, so ignoring
+ // this instance is OK.
+ return;
+ }
+ if (c == 0xFDD1 && second == 0xAC00) {
+ // This strange contraction exists in the root and
+ // doesn't have a decomposed counterpart there.
+ // This won't match in ICU4X anyway and is very strange:
+ // Unassigned Arabic presentation form contracting with
+ // the very first Hangul syllable. Let's ignore this
+ // explicitly.
+ return;
+ }
+ }
+ // Unknown case worth investigating if ever found.
+ errorCode = U_UNSUPPORTED_ERROR;
+ return;
+ }
+
+ if (!prefix.isEmpty()) {
+ UnicodeString prefixInNfd;
+ nfdNormalizer->normalize(prefix, prefixInNfd, errorCode);
+ if (prefix != prefixInNfd) {
+ errorCode = U_UNSUPPORTED_ERROR;
+ return;
+ }
+
+ int32_t count = prefix.countChar32();
+ if (count > 2) {
+ // Prefix too long for ICU4X.
+ errorCode = U_UNSUPPORTED_ERROR;
+ return;
+ }
+ UChar32 utf32[4];
+ int32_t len = prefix.toUTF32(utf32, 4, errorCode);
+ if (len != count) {
+ errorCode = U_INVALID_STATE_ERROR;
+ return;
+ }
+ UChar32 c = utf32[0];
+ if (u_getCombiningClass(c)) {
+ // Prefix must start with as starter for ICU4X.
+ errorCode = U_UNSUPPORTED_ERROR;
+ return;
+ }
+ // XXX: Korean searchjl has jamo in prefix, so commenting out this
+ // check for now. ICU4X currently ignores non-root jamo tables anyway.
+ // searchjl was added in
+ // https://unicode-org.atlassian.net/browse/CLDR-3560
+ // Contractions were changed to prefixes in
+ // https://unicode-org.atlassian.net/browse/CLDR-6546
+ //
+ // if ((c >= 0x1100 && c < 0x1200) || (c >= 0xAC00 && c < 0xD7A4)) {
+ // errorCode = U_UNSUPPORTED_ERROR;
+ // return;
+ // }
+ if ((len > 1) && !(utf32[1] == 0x3099 || utf32[1] == 0x309A)) {
+ // Second character in prefix, if present, must be a kana voicing mark for ICU4X.
+ errorCode = U_UNSUPPORTED_ERROR;
+ return;
+ }
+ }
+
+ if (s.length() > cLength) {
+ // Check that there's no modern Hangul in contractions.
+ for (int32_t i = 0; i < s.length(); ++i) {
+ char16_t c = s.charAt(i);
+ if ((c >= 0x1100 && c < 0x1100 + 19) || (c >= 0x1161 && c < 0x1161 + 21) || (c >= 0x11A7 && c < 0x11A7 + 28) || (c >= 0xAC00 && c < 0xD7A4)) {
+ errorCode = U_UNSUPPORTED_ERROR;
+ return;
+ }
+ }
+ }
+ }
+
if(oldCE32 == Collation::FALLBACK_CE32) {
// First tailoring for c.
// If c has contextual base mappings or if we add a contextual mapping,
@@ -562,7 +673,7 @@ CollationDataBuilder::addCE32(const UnicodeString &prefix, const UnicodeString &
// Otherwise we just override the base mapping.
uint32_t baseCE32 = base->getFinalCE32(base->getCE32(c));
if(hasContext || Collation::ce32HasContext(baseCE32)) {
- oldCE32 = copyFromBaseCE32(c, baseCE32, TRUE, errorCode);
+ oldCE32 = copyFromBaseCE32(c, baseCE32, true, errorCode);
utrie2_set32(trie, c, oldCE32, &errorCode);
if(U_FAILURE(errorCode)) { return; }
}
@@ -581,7 +692,7 @@ CollationDataBuilder::addCE32(const UnicodeString &prefix, const UnicodeString &
if(!isBuilderContextCE32(oldCE32)) {
// Replace the simple oldCE32 with a builder context CE32
// pointing to a new ConditionalCE32 list head.
- int32_t index = addConditionalCE32(UnicodeString((UChar)0), oldCE32, errorCode);
+ int32_t index = addConditionalCE32(UnicodeString((char16_t)0), oldCE32, errorCode);
if(U_FAILURE(errorCode)) { return; }
uint32_t contextCE32 = makeBuilderContextCE32(index);
utrie2_set32(trie, c, contextCE32, &errorCode);
@@ -592,7 +703,7 @@ CollationDataBuilder::addCE32(const UnicodeString &prefix, const UnicodeString &
cond->builtCE32 = Collation::NO_CE32;
}
UnicodeString suffix(s, cLength);
- UnicodeString context((UChar)prefix.length());
+ UnicodeString context((char16_t)prefix.length());
context.append(prefix).append(suffix);
unsafeBackwardSet.addAll(suffix);
for(;;) {
@@ -622,7 +733,7 @@ CollationDataBuilder::addCE32(const UnicodeString &prefix, const UnicodeString &
cond = nextCond;
}
}
- modified = TRUE;
+ modified = true;
}
uint32_t
@@ -666,7 +777,7 @@ CollationDataBuilder::encodeCEs(const int64_t ces[], int32_t cesLength,
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
- if(trie == NULL || utrie2_isFrozen(trie)) {
+ if(trie == nullptr || utrie2_isFrozen(trie)) {
errorCode = U_INVALID_STATE_ERROR;
return 0;
}
@@ -676,8 +787,11 @@ CollationDataBuilder::encodeCEs(const int64_t ces[], int32_t cesLength,
return encodeOneCEAsCE32(0);
} else if(cesLength == 1) {
return encodeOneCE(ces[0], errorCode);
- } else if(cesLength == 2) {
+ } else if(cesLength == 2 && !icu4xMode) {
// Try to encode two CEs as one CE32.
+ // Turn this off for ICU4X, because without the canonical closure
+ // these are so rare that it doesn't make sense to spend a branch
+ // on checking this tag when using the data.
int64_t ce0 = ces[0];
int64_t ce1 = ces[1];
uint32_t p0 = (uint32_t)(ce0 >> 32);
@@ -800,18 +914,18 @@ CollationDataBuilder::copyFromBaseCE32(UChar32 c, uint32_t ce32, UBool withConte
case Collation::PREFIX_TAG: {
// Flatten prefixes and nested suffixes (contractions)
// into a linear list of ConditionalCE32.
- const UChar *p = base->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = base->contexts + Collation::indexFromCE32(ce32);
ce32 = CollationData::readCE32(p); // Default if no prefix match.
if(!withContext) {
- return copyFromBaseCE32(c, ce32, FALSE, errorCode);
+ return copyFromBaseCE32(c, ce32, false, errorCode);
}
ConditionalCE32 head;
- UnicodeString context((UChar)0);
+ UnicodeString context((char16_t)0);
int32_t index;
if(Collation::isContractionCE32(ce32)) {
index = copyContractionsFromBaseCE32(context, c, ce32, &head, errorCode);
} else {
- ce32 = copyFromBaseCE32(c, ce32, TRUE, errorCode);
+ ce32 = copyFromBaseCE32(c, ce32, true, errorCode);
head.next = index = addConditionalCE32(context, ce32, errorCode);
}
if(U_FAILURE(errorCode)) { return 0; }
@@ -820,12 +934,12 @@ CollationDataBuilder::copyFromBaseCE32(UChar32 c, uint32_t ce32, UBool withConte
while(prefixes.next(errorCode)) {
context = prefixes.getString();
context.reverse();
- context.insert(0, (UChar)context.length());
+ context.insert(0, (char16_t)context.length());
ce32 = (uint32_t)prefixes.getValue();
if(Collation::isContractionCE32(ce32)) {
index = copyContractionsFromBaseCE32(context, c, ce32, cond, errorCode);
} else {
- ce32 = copyFromBaseCE32(c, ce32, TRUE, errorCode);
+ ce32 = copyFromBaseCE32(c, ce32, true, errorCode);
cond->next = index = addConditionalCE32(context, ce32, errorCode);
}
if(U_FAILURE(errorCode)) { return 0; }
@@ -837,12 +951,12 @@ CollationDataBuilder::copyFromBaseCE32(UChar32 c, uint32_t ce32, UBool withConte
}
case Collation::CONTRACTION_TAG: {
if(!withContext) {
- const UChar *p = base->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = base->contexts + Collation::indexFromCE32(ce32);
ce32 = CollationData::readCE32(p); // Default if no suffix match.
- return copyFromBaseCE32(c, ce32, FALSE, errorCode);
+ return copyFromBaseCE32(c, ce32, false, errorCode);
}
ConditionalCE32 head;
- UnicodeString context((UChar)0);
+ UnicodeString context((char16_t)0);
copyContractionsFromBaseCE32(context, c, ce32, &head, errorCode);
ce32 = makeBuilderContextCE32(head.next);
contextChars.add(c);
@@ -852,7 +966,7 @@ CollationDataBuilder::copyFromBaseCE32(UChar32 c, uint32_t ce32, UBool withConte
errorCode = U_UNSUPPORTED_ERROR; // We forbid tailoring of Hangul syllables.
break;
case Collation::OFFSET_TAG:
- ce32 = getCE32FromOffsetCE32(TRUE, c, ce32);
+ ce32 = getCE32FromOffsetCE32(true, c, ce32);
break;
case Collation::IMPLICIT_TAG:
ce32 = encodeOneCE(Collation::unassignedCEFromCodePoint(c), errorCode);
@@ -867,7 +981,7 @@ int32_t
CollationDataBuilder::copyContractionsFromBaseCE32(UnicodeString &context, UChar32 c, uint32_t ce32,
ConditionalCE32 *cond, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return 0; }
- const UChar *p = base->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = base->contexts + Collation::indexFromCE32(ce32);
int32_t index;
if((ce32 & Collation::CONTRACT_SINGLE_CP_NO_MATCH) != 0) {
// No match on the single code point.
@@ -878,7 +992,7 @@ CollationDataBuilder::copyContractionsFromBaseCE32(UnicodeString &context, UChar
} else {
ce32 = CollationData::readCE32(p); // Default if no suffix match.
U_ASSERT(!Collation::isContractionCE32(ce32));
- ce32 = copyFromBaseCE32(c, ce32, TRUE, errorCode);
+ ce32 = copyFromBaseCE32(c, ce32, true, errorCode);
cond->next = index = addConditionalCE32(context, ce32, errorCode);
if(U_FAILURE(errorCode)) { return 0; }
cond = getConditionalCE32(index);
@@ -888,7 +1002,7 @@ CollationDataBuilder::copyContractionsFromBaseCE32(UnicodeString &context, UChar
UCharsTrie::Iterator suffixes(p + 2, 0, errorCode);
while(suffixes.next(errorCode)) {
context.append(suffixes.getString());
- ce32 = copyFromBaseCE32(c, (uint32_t)suffixes.getValue(), TRUE, errorCode);
+ ce32 = copyFromBaseCE32(c, (uint32_t)suffixes.getValue(), true, errorCode);
cond->next = index = addConditionalCE32(context, ce32, errorCode);
if(U_FAILURE(errorCode)) { return 0; }
// No need to update the unsafeBackwardSet because the tailoring set
@@ -909,7 +1023,7 @@ public:
UBool copyRangeCE32(UChar32 start, UChar32 end, uint32_t ce32) {
ce32 = copyCE32(ce32);
- utrie2_setRange32(dest.trie, start, end, ce32, TRUE, &errorCode);
+ utrie2_setRange32(dest.trie, start, end, ce32, true, &errorCode);
if(CollationDataBuilder::isBuilderContextCE32(ce32)) {
dest.contextChars.add(start, end);
}
@@ -930,7 +1044,7 @@ public:
int32_t length = Collation::lengthFromCE32(ce32);
// Inspect the source CE32s. Just copy them if none are modified.
// Otherwise copy to modifiedCEs, with modifications.
- UBool isModified = FALSE;
+ UBool isModified = false;
for(int32_t i = 0; i < length; ++i) {
ce32 = srcCE32s[i];
int64_t ce;
@@ -944,7 +1058,7 @@ public:
for(int32_t j = 0; j < i; ++j) {
modifiedCEs[j] = Collation::ceFromCE32(srcCE32s[j]);
}
- isModified = TRUE;
+ isModified = true;
}
modifiedCEs[i] = ce;
}
@@ -961,7 +1075,7 @@ public:
int32_t length = Collation::lengthFromCE32(ce32);
// Inspect the source CEs. Just copy them if none are modified.
// Otherwise copy to modifiedCEs, with modifications.
- UBool isModified = FALSE;
+ UBool isModified = false;
for(int32_t i = 0; i < length; ++i) {
int64_t srcCE = srcCEs[i];
int64_t ce = modifier.modifyCE(srcCE);
@@ -974,7 +1088,7 @@ public:
for(int32_t j = 0; j < i; ++j) {
modifiedCEs[j] = srcCEs[j];
}
- isModified = TRUE;
+ isModified = true;
}
modifiedCEs[i] = ce;
}
@@ -1034,12 +1148,12 @@ void
CollationDataBuilder::copyFrom(const CollationDataBuilder &src, const CEModifier &modifier,
UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
- if(trie == NULL || utrie2_isFrozen(trie)) {
+ if(trie == nullptr || utrie2_isFrozen(trie)) {
errorCode = U_INVALID_STATE_ERROR;
return;
}
CopyHelper helper(src, *this, modifier, errorCode);
- utrie2_enum(src.trie, NULL, enumRangeForCopy, &helper);
+ utrie2_enum(src.trie, nullptr, enumRangeForCopy, &helper);
errorCode = helper.errorCode;
// Update the contextChars and the unsafeBackwardSet while copying,
// in case a character had conditional mappings in the source builder
@@ -1056,11 +1170,11 @@ CollationDataBuilder::optimize(const UnicodeSet &set, UErrorCode &errorCode) {
uint32_t ce32 = utrie2_get32(trie, c);
if(ce32 == Collation::FALLBACK_CE32) {
ce32 = base->getFinalCE32(base->getCE32(c));
- ce32 = copyFromBaseCE32(c, ce32, TRUE, errorCode);
+ ce32 = copyFromBaseCE32(c, ce32, true, errorCode);
utrie2_set32(trie, c, ce32, &errorCode);
}
}
- modified = TRUE;
+ modified = true;
}
void
@@ -1073,7 +1187,7 @@ CollationDataBuilder::suppressContractions(const UnicodeSet &set, UErrorCode &er
if(ce32 == Collation::FALLBACK_CE32) {
ce32 = base->getFinalCE32(base->getCE32(c));
if(Collation::ce32HasContext(ce32)) {
- ce32 = copyFromBaseCE32(c, ce32, FALSE /* without context */, errorCode);
+ ce32 = copyFromBaseCE32(c, ce32, false /* without context */, errorCode);
utrie2_set32(trie, c, ce32, &errorCode);
}
} else if(isBuilderContextCE32(ce32)) {
@@ -1085,23 +1199,23 @@ CollationDataBuilder::suppressContractions(const UnicodeSet &set, UErrorCode &er
contextChars.remove(c);
}
}
- modified = TRUE;
+ modified = true;
}
UBool
CollationDataBuilder::getJamoCE32s(uint32_t jamoCE32s[], UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
- UBool anyJamoAssigned = base == NULL; // always set jamoCE32s in the base data
- UBool needToCopyFromBase = FALSE;
+ if(U_FAILURE(errorCode)) { return false; }
+ UBool anyJamoAssigned = base == nullptr; // always set jamoCE32s in the base data
+ UBool needToCopyFromBase = false;
for(int32_t j = 0; j < CollationData::JAMO_CE32S_LENGTH; ++j) { // Count across Jamo types.
UChar32 jamo = jamoCpFromIndex(j);
- UBool fromBase = FALSE;
+ UBool fromBase = false;
uint32_t ce32 = utrie2_get32(trie, jamo);
anyJamoAssigned |= Collation::isAssignedCE32(ce32);
// TODO: Try to prevent [optimize [Jamo]] from counting as anyJamoAssigned.
// (As of CLDR 24 [2013] the Korean tailoring does not optimize conjoining Jamo.)
if(ce32 == Collation::FALLBACK_CE32) {
- fromBase = TRUE;
+ fromBase = true;
ce32 = base->getCE32(jamo);
}
if(Collation::isSpecialCE32(ce32)) {
@@ -1118,14 +1232,14 @@ CollationDataBuilder::getJamoCE32s(uint32_t jamoCE32s[], UErrorCode &errorCode)
if(fromBase) {
// Defer copying until we know if anyJamoAssigned.
ce32 = Collation::FALLBACK_CE32;
- needToCopyFromBase = TRUE;
+ needToCopyFromBase = true;
}
break;
case Collation::IMPLICIT_TAG:
// An unassigned Jamo should only occur in tests with incomplete bases.
U_ASSERT(fromBase);
ce32 = Collation::FALLBACK_CE32;
- needToCopyFromBase = TRUE;
+ needToCopyFromBase = true;
break;
case Collation::OFFSET_TAG:
ce32 = getCE32FromOffsetCE32(fromBase, jamo, ce32);
@@ -1138,7 +1252,7 @@ CollationDataBuilder::getJamoCE32s(uint32_t jamoCE32s[], UErrorCode &errorCode)
case Collation::HANGUL_TAG:
case Collation::LEAD_SURROGATE_TAG:
errorCode = U_INTERNAL_PROGRAM_ERROR;
- return FALSE;
+ return false;
}
}
jamoCE32s[j] = ce32;
@@ -1148,7 +1262,7 @@ CollationDataBuilder::getJamoCE32s(uint32_t jamoCE32s[], UErrorCode &errorCode)
if(jamoCE32s[j] == Collation::FALLBACK_CE32) {
UChar32 jamo = jamoCpFromIndex(j);
jamoCE32s[j] = copyFromBaseCE32(jamo, base->getCE32(jamo),
- /*withContext=*/ TRUE, errorCode);
+ /*withContext=*/ true, errorCode);
}
}
}
@@ -1189,24 +1303,24 @@ enumRangeLeadValue(const void *context, UChar32 /*start*/, UChar32 /*end*/, uint
value = Collation::LEAD_ALL_FALLBACK;
} else {
*pValue = Collation::LEAD_MIXED;
- return FALSE;
+ return false;
}
if(*pValue < 0) {
*pValue = (int32_t)value;
} else if(*pValue != (int32_t)value) {
*pValue = Collation::LEAD_MIXED;
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
U_CDECL_END
void
CollationDataBuilder::setLeadSurrogates(UErrorCode &errorCode) {
- for(UChar lead = 0xd800; lead < 0xdc00; ++lead) {
+ for(char16_t lead = 0xd800; lead < 0xdc00; ++lead) {
int32_t value = -1;
- utrie2_enumForLeadSurrogate(trie, lead, NULL, enumRangeLeadValue, &value);
+ utrie2_enumForLeadSurrogate(trie, lead, nullptr, enumRangeLeadValue, &value);
utrie2_set32ForLeadSurrogateCodeUnit(
trie, lead,
Collation::makeCE32FromTagAndIndex(Collation::LEAD_SURROGATE_TAG, 0) | (uint32_t)value,
@@ -1217,7 +1331,7 @@ CollationDataBuilder::setLeadSurrogates(UErrorCode &errorCode) {
void
CollationDataBuilder::build(CollationData &data, UErrorCode &errorCode) {
buildMappings(data, errorCode);
- if(base != NULL) {
+ if(base != nullptr) {
data.numericPrimary = base->numericPrimary;
data.compressibleBytes = base->compressibleBytes;
data.numScripts = base->numScripts;
@@ -1231,7 +1345,7 @@ CollationDataBuilder::build(CollationData &data, UErrorCode &errorCode) {
void
CollationDataBuilder::buildMappings(CollationData &data, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
- if(trie == NULL || utrie2_isFrozen(trie)) {
+ if(trie == nullptr || utrie2_isFrozen(trie)) {
errorCode = U_INVALID_STATE_ERROR;
return;
}
@@ -1252,10 +1366,10 @@ CollationDataBuilder::buildMappings(CollationData &data, UErrorCode &errorCode)
// In order to still have good trie compression and keep this code simple,
// we only set this flag if a whole block of 588 Hangul syllables starting with
// a common leading consonant (Jamo L) has this property.
- UBool isAnyJamoVTSpecial = FALSE;
+ UBool isAnyJamoVTSpecial = false;
for(int32_t i = Hangul::JAMO_L_COUNT; i < CollationData::JAMO_CE32S_LENGTH; ++i) {
if(Collation::isSpecialCE32(jamoCE32s[i])) {
- isAnyJamoVTSpecial = TRUE;
+ isAnyJamoVTSpecial = true;
break;
}
}
@@ -1267,7 +1381,7 @@ CollationDataBuilder::buildMappings(CollationData &data, UErrorCode &errorCode)
ce32 |= Collation::HANGUL_NO_SPECIAL_JAMO;
}
UChar32 limit = c + Hangul::JAMO_VT_COUNT;
- utrie2_setRange32(trie, c, limit - 1, ce32, TRUE, &errorCode);
+ utrie2_setRange32(trie, c, limit - 1, ce32, true, &errorCode);
c = limit;
}
} else {
@@ -1277,7 +1391,7 @@ CollationDataBuilder::buildMappings(CollationData &data, UErrorCode &errorCode)
uint32_t ce32 = base->getCE32(c);
U_ASSERT(Collation::hasCE32Tag(ce32, Collation::HANGUL_TAG));
UChar32 limit = c + Hangul::JAMO_VT_COUNT;
- utrie2_setRange32(trie, c, limit - 1, ce32, TRUE, &errorCode);
+ utrie2_setRange32(trie, c, limit - 1, ce32, true, &errorCode);
c = limit;
}
}
@@ -1285,9 +1399,11 @@ CollationDataBuilder::buildMappings(CollationData &data, UErrorCode &errorCode)
setDigitTags(errorCode);
setLeadSurrogates(errorCode);
- // For U+0000, move its normal ce32 into CE32s[0] and set U0000_TAG.
- ce32s.setElementAt((int32_t)utrie2_get32(trie, 0), 0);
- utrie2_set32(trie, 0, Collation::makeCE32FromTagAndIndex(Collation::U0000_TAG, 0), &errorCode);
+ if (!icu4xMode) {
+ // For U+0000, move its normal ce32 into CE32s[0] and set U0000_TAG.
+ ce32s.setElementAt((int32_t)utrie2_get32(trie, 0), 0);
+ utrie2_set32(trie, 0, Collation::makeCE32FromTagAndIndex(Collation::U0000_TAG, 0), &errorCode);
+ }
utrie2_freeze(trie, UTRIE2_32_VALUE_BITS, &errorCode);
if(U_FAILURE(errorCode)) { return; }
@@ -1295,7 +1411,7 @@ CollationDataBuilder::buildMappings(CollationData &data, UErrorCode &errorCode)
// Mark each lead surrogate as "unsafe"
// if any of its 1024 associated supplementary code points is "unsafe".
UChar32 c = 0x10000;
- for(UChar lead = 0xd800; lead < 0xdc00; ++lead, c += 0x400) {
+ for(char16_t lead = 0xd800; lead < 0xdc00; ++lead, c += 0x400) {
if(unsafeBackwardSet.containsSome(c, c + 0x3ff)) {
unsafeBackwardSet.add(lead);
}
@@ -1323,13 +1439,10 @@ CollationDataBuilder::buildMappings(CollationData &data, UErrorCode &errorCode)
void
CollationDataBuilder::clearContexts() {
contexts.remove();
- UnicodeSetIterator iter(contextChars);
- while(iter.next()) {
- U_ASSERT(!iter.isString());
- uint32_t ce32 = utrie2_get32(trie, iter.getCodepoint());
- U_ASSERT(isBuilderContextCE32(ce32));
- getConditionalCE32ForCE32(ce32)->builtCE32 = Collation::NO_CE32;
- }
+ // Incrementing the contexts build "era" invalidates all of the builtCE32
+ // from before this clearContexts() call.
+ // Simpler than finding and resetting all of those fields.
+ ++contextsEra;
}
void
@@ -1337,7 +1450,7 @@ CollationDataBuilder::buildContexts(UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
// Ignore abandoned lists and the cached builtCE32,
// and build all contexts from scratch.
- contexts.remove();
+ clearContexts();
UnicodeSetIterator iter(contextChars);
while(U_SUCCESS(errorCode) && iter.next()) {
U_ASSERT(!iter.isString());
@@ -1363,18 +1476,34 @@ CollationDataBuilder::buildContext(ConditionalCE32 *head, UErrorCode &errorCode)
U_ASSERT(head->next >= 0);
UCharsTrieBuilder prefixBuilder(errorCode);
UCharsTrieBuilder contractionBuilder(errorCode);
+ // This outer loop goes from each prefix to the next.
+ // For each prefix it finds the one or more same-prefix entries (firstCond..lastCond).
+ // If there are multiple suffixes for the same prefix,
+ // then an inner loop builds a contraction trie for them.
for(ConditionalCE32 *cond = head;; cond = getConditionalCE32(cond->next)) {
+ if(U_FAILURE(errorCode)) { return 0; } // early out for memory allocation errors
// After the list head, the prefix or suffix can be empty, but not both.
U_ASSERT(cond == head || cond->hasContext());
int32_t prefixLength = cond->prefixLength();
UnicodeString prefix(cond->context, 0, prefixLength + 1);
// Collect all contraction suffixes for one prefix.
ConditionalCE32 *firstCond = cond;
- ConditionalCE32 *lastCond = cond;
- while(cond->next >= 0 &&
- (cond = getConditionalCE32(cond->next))->context.startsWith(prefix)) {
+ ConditionalCE32 *lastCond;
+ do {
lastCond = cond;
- }
+ // Clear the defaultCE32 fields as we go.
+ // They are left over from building a previous version of this list of contexts.
+ //
+ // One of the code paths below may copy a preceding defaultCE32
+ // into its emptySuffixCE32.
+ // If a new suffix has been inserted before what used to be
+ // the firstCond for its prefix, then that previous firstCond could still
+ // contain an outdated defaultCE32 from an earlier buildContext() and
+ // result in an incorrect emptySuffixCE32.
+ // So we reset all defaultCE32 before reading and setting new values.
+ cond->defaultCE32 = Collation::NO_CE32;
+ } while(cond->next >= 0 &&
+ (cond = getConditionalCE32(cond->next))->context.startsWith(prefix));
uint32_t ce32;
int32_t suffixStart = prefixLength + 1; // == prefix.length()
if(lastCond->context.length() == suffixStart) {
@@ -1429,6 +1558,20 @@ CollationDataBuilder::buildContext(ConditionalCE32 *head, UErrorCode &errorCode)
// The last suffix character has lccc!=0, allowing for discontiguous contractions.
flags |= Collation::CONTRACT_TRAILING_CCC;
}
+ if (icu4xMode && (flags & Collation::CONTRACT_HAS_STARTER) == 0) {
+ for (int32_t i = 0; i < suffix.length();) {
+ UChar32 c = suffix.char32At(i);
+ if (!u_getCombiningClass(c)) {
+ flags |= Collation::CONTRACT_HAS_STARTER;
+ break;
+ }
+ if (c > 0xFFFF) {
+ i += 2;
+ } else {
+ ++i;
+ }
+ }
+ }
contractionBuilder.add(suffix, (int32_t)cond->ce32, errorCode);
if(cond == lastCond) { break; }
cond = getConditionalCE32(cond->next);
@@ -1469,7 +1612,7 @@ int32_t
CollationDataBuilder::addContextTrie(uint32_t defaultCE32, UCharsTrieBuilder &trieBuilder,
UErrorCode &errorCode) {
UnicodeString context;
- context.append((UChar)(defaultCE32 >> 16)).append((UChar)defaultCE32);
+ context.append((char16_t)(defaultCE32 >> 16)).append((char16_t)defaultCE32);
UnicodeString trieString;
context.append(trieBuilder.buildUnicodeString(USTRINGTRIE_BUILD_SMALL, trieString, errorCode));
if(U_FAILURE(errorCode)) { return -1; }
@@ -1487,25 +1630,25 @@ CollationDataBuilder::buildFastLatinTable(CollationData &data, UErrorCode &error
delete fastLatinBuilder;
fastLatinBuilder = new CollationFastLatinBuilder(errorCode);
- if(fastLatinBuilder == NULL) {
+ if(fastLatinBuilder == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
if(fastLatinBuilder->forData(data, errorCode)) {
const uint16_t *table = fastLatinBuilder->getTable();
int32_t length = fastLatinBuilder->lengthOfTable();
- if(base != NULL && length == base->fastLatinTableLength &&
+ if(base != nullptr && length == base->fastLatinTableLength &&
uprv_memcmp(table, base->fastLatinTable, length * 2) == 0) {
// Same fast Latin table as in the base, use that one instead.
delete fastLatinBuilder;
- fastLatinBuilder = NULL;
+ fastLatinBuilder = nullptr;
table = base->fastLatinTable;
}
data.fastLatinTable = table;
data.fastLatinTableLength = length;
} else {
delete fastLatinBuilder;
- fastLatinBuilder = NULL;
+ fastLatinBuilder = nullptr;
}
}
@@ -1528,9 +1671,9 @@ CollationDataBuilder::getCEs(const UnicodeString &prefix, const UnicodeString &s
int32_t
CollationDataBuilder::getCEs(const UnicodeString &s, int32_t start,
int64_t ces[], int32_t cesLength) {
- if(collIter == NULL) {
+ if(collIter == nullptr) {
collIter = new DataBuilderCollationIterator(*this);
- if(collIter == NULL) { return 0; }
+ if(collIter == nullptr) { return 0; }
}
return collIter->fetchCEs(s, start, ces, cesLength);
}
diff --git a/contrib/libs/icu/i18n/collationdatabuilder.h b/contrib/libs/icu/i18n/collationdatabuilder.h
index 6ae77772fd..cbbd8f264b 100644
--- a/contrib/libs/icu/i18n/collationdatabuilder.h
+++ b/contrib/libs/icu/i18n/collationdatabuilder.h
@@ -60,7 +60,7 @@ public:
virtual int64_t modifyCE(int64_t ce) const = 0;
};
- CollationDataBuilder(UErrorCode &errorCode);
+ CollationDataBuilder(UBool icu4xMode, UErrorCode &errorCode);
virtual ~CollationDataBuilder();
@@ -244,8 +244,18 @@ protected:
UnicodeSet contextChars;
// Serialized UCharsTrie structures for finalized contexts.
UnicodeString contexts;
+private:
+ /**
+ * The "era" of building intermediate contexts.
+ * When the array of cached, temporary contexts overflows, then clearContexts()
+ * removes them all and invalidates the builtCE32 that used to point to built tries.
+ * See ConditionalCE32::era.
+ */
+ int32_t contextsEra = 0;
+protected:
UnicodeSet unsafeBackwardSet;
UBool modified;
+ UBool icu4xMode;
UBool fastLatinEnabled;
CollationFastLatinBuilder *fastLatinBuilder;
diff --git a/contrib/libs/icu/i18n/collationdatareader.cpp b/contrib/libs/icu/i18n/collationdatareader.cpp
index 0eb1861343..1884208eaa 100644
--- a/contrib/libs/icu/i18n/collationdatareader.cpp
+++ b/contrib/libs/icu/i18n/collationdatareader.cpp
@@ -47,14 +47,14 @@ void
CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes, int32_t inLength,
CollationTailoring &tailoring, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
- if(base != NULL) {
- if(inBytes == NULL || (0 <= inLength && inLength < 24)) {
+ if(base != nullptr) {
+ if(inBytes == nullptr || (0 <= inLength && inLength < 24)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
const DataHeader *header = reinterpret_cast<const DataHeader *>(inBytes);
if(!(header->dataHeader.magic1 == 0xda && header->dataHeader.magic2 == 0x27 &&
- isAcceptable(tailoring.version, NULL, NULL, &header->info))) {
+ isAcceptable(tailoring.version, nullptr, nullptr, &header->info))) {
errorCode = U_INVALID_FORMAT_ERROR;
return;
}
@@ -69,7 +69,7 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
}
}
- if(inBytes == NULL || (0 <= inLength && inLength < 8)) {
+ if(inBytes == nullptr || (0 <= inLength && inLength < 8)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@@ -81,7 +81,7 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
}
// Assume that the tailoring data is in initial state,
- // with NULL pointers and 0 lengths.
+ // with nullptr pointers and 0 lengths.
// Set pointers to non-empty data parts.
// Do this in order of their byte offsets. (Should help porting to Java.)
@@ -102,16 +102,16 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
return;
}
- const CollationData *baseData = base == NULL ? NULL : base->data;
- const int32_t *reorderCodes = NULL;
+ const CollationData *baseData = base == nullptr ? nullptr : base->data;
+ const int32_t *reorderCodes = nullptr;
int32_t reorderCodesLength = 0;
- const uint32_t *reorderRanges = NULL;
+ const uint32_t *reorderRanges = nullptr;
int32_t reorderRangesLength = 0;
index = IX_REORDER_CODES_OFFSET;
offset = getIndex(inIndexes, indexesLength, index);
length = getIndex(inIndexes, indexesLength, index + 1) - offset;
if(length >= 4) {
- if(baseData == NULL) {
+ if(baseData == nullptr) {
// We assume for collation settings that
// the base data does not have a reordering.
errorCode = U_INVALID_FORMAT_ERROR;
@@ -138,7 +138,7 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
// There should be a reorder table only if there are reorder codes.
// However, when there are reorder codes the reorder table may be omitted to reduce
// the data size.
- const uint8_t *reorderTable = NULL;
+ const uint8_t *reorderTable = nullptr;
index = IX_REORDER_TABLE_OFFSET;
offset = getIndex(inIndexes, indexesLength, index);
length = getIndex(inIndexes, indexesLength, index + 1) - offset;
@@ -153,11 +153,11 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
// when the CollationData is otherwise complete.
}
- if(baseData != NULL && baseData->numericPrimary != (inIndexes[IX_OPTIONS] & 0xff000000)) {
+ if(baseData != nullptr && baseData->numericPrimary != (inIndexes[IX_OPTIONS] & 0xff000000)) {
errorCode = U_INVALID_FORMAT_ERROR;
return;
}
- CollationData *data = NULL; // Remains NULL if there are no mappings.
+ CollationData *data = nullptr; // Remains nullptr if there are no mappings.
index = IX_TRIE_OFFSET;
offset = getIndex(inIndexes, indexesLength, index);
@@ -168,10 +168,10 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
data->base = baseData;
data->numericPrimary = inIndexes[IX_OPTIONS] & 0xff000000;
data->trie = tailoring.trie = utrie2_openFromSerialized(
- UTRIE2_32_VALUE_BITS, inBytes + offset, length, NULL,
+ UTRIE2_32_VALUE_BITS, inBytes + offset, length, nullptr,
&errorCode);
if(U_FAILURE(errorCode)) { return; }
- } else if(baseData != NULL) {
+ } else if(baseData != nullptr) {
// Use the base data. Only the settings are tailored.
tailoring.data = baseData;
} else {
@@ -183,7 +183,7 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
offset = getIndex(inIndexes, indexesLength, index);
length = getIndex(inIndexes, indexesLength, index + 1) - offset;
if(length >= 8) {
- if(data == NULL) {
+ if(data == nullptr) {
errorCode = U_INVALID_FORMAT_ERROR; // Tailored ces without tailored trie.
return;
}
@@ -195,7 +195,7 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
offset = getIndex(inIndexes, indexesLength, index);
length = getIndex(inIndexes, indexesLength, index + 1) - offset;
if(length >= 4) {
- if(data == NULL) {
+ if(data == nullptr) {
errorCode = U_INVALID_FORMAT_ERROR; // Tailored ce32s without tailored trie.
return;
}
@@ -205,14 +205,14 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
int32_t jamoCE32sStart = getIndex(inIndexes, indexesLength, IX_JAMO_CE32S_START);
if(jamoCE32sStart >= 0) {
- if(data == NULL || data->ce32s == NULL) {
+ if(data == nullptr || data->ce32s == nullptr) {
errorCode = U_INVALID_FORMAT_ERROR; // Index into non-existent ce32s[].
return;
}
data->jamoCE32s = data->ce32s + jamoCE32sStart;
- } else if(data == NULL) {
+ } else if(data == nullptr) {
// Nothing to do.
- } else if(baseData != NULL) {
+ } else if(baseData != nullptr) {
data->jamoCE32s = baseData->jamoCE32s;
} else {
errorCode = U_INVALID_FORMAT_ERROR; // No Jamo CE32s for Hangul processing.
@@ -224,7 +224,7 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
length = getIndex(inIndexes, indexesLength, index + 1) - offset;
if(length >= 4) {
length /= 4;
- if(data == NULL || length <= CollationRootElements::IX_SEC_TER_BOUNDARIES) {
+ if(data == nullptr || length <= CollationRootElements::IX_SEC_TER_BOUNDARIES) {
errorCode = U_INVALID_FORMAT_ERROR;
return;
}
@@ -248,11 +248,11 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
offset = getIndex(inIndexes, indexesLength, index);
length = getIndex(inIndexes, indexesLength, index + 1) - offset;
if(length >= 2) {
- if(data == NULL) {
+ if(data == nullptr) {
errorCode = U_INVALID_FORMAT_ERROR; // Tailored contexts without tailored trie.
return;
}
- data->contexts = reinterpret_cast<const UChar *>(inBytes + offset);
+ data->contexts = reinterpret_cast<const char16_t *>(inBytes + offset);
data->contextsLength = length / 2;
}
@@ -260,14 +260,14 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
offset = getIndex(inIndexes, indexesLength, index);
length = getIndex(inIndexes, indexesLength, index + 1) - offset;
if(length >= 2) {
- if(data == NULL) {
+ if(data == nullptr) {
errorCode = U_INVALID_FORMAT_ERROR;
return;
}
- if(baseData == NULL) {
+ if(baseData == nullptr) {
#if defined(COLLUNSAFE_COLL_VERSION) && defined (COLLUNSAFE_SERIALIZE)
tailoring.unsafeBackwardSet = new UnicodeSet(unsafe_serializedData, unsafe_serializedCount, UnicodeSet::kSerialized, errorCode);
- if(tailoring.unsafeBackwardSet == NULL) {
+ if(tailoring.unsafeBackwardSet == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
} else if (U_FAILURE(errorCode)) {
@@ -286,7 +286,7 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
// new UnicodeSet("[[:^lccc=0:][\\udc00-\\udfff]]").
// It is faster and requires fewer code dependencies.
tailoring.unsafeBackwardSet = new UnicodeSet(0xdc00, 0xdfff); // trail surrogates
- if(tailoring.unsafeBackwardSet == NULL) {
+ if(tailoring.unsafeBackwardSet == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -296,7 +296,7 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
// Clone the root collator's set contents.
tailoring.unsafeBackwardSet = static_cast<UnicodeSet *>(
baseData->unsafeBackwardSet->cloneAsThawed());
- if(tailoring.unsafeBackwardSet == NULL) {
+ if(tailoring.unsafeBackwardSet == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -317,16 +317,16 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
// Mark each lead surrogate as "unsafe"
// if any of its 1024 associated supplementary code points is "unsafe".
UChar32 c = 0x10000;
- for(UChar lead = 0xd800; lead < 0xdc00; ++lead, c += 0x400) {
+ for(char16_t lead = 0xd800; lead < 0xdc00; ++lead, c += 0x400) {
if(!tailoring.unsafeBackwardSet->containsNone(c, c + 0x3ff)) {
tailoring.unsafeBackwardSet->add(lead);
}
}
tailoring.unsafeBackwardSet->freeze();
data->unsafeBackwardSet = tailoring.unsafeBackwardSet;
- } else if(data == NULL) {
+ } else if(data == nullptr) {
// Nothing to do.
- } else if(baseData != NULL) {
+ } else if(baseData != nullptr) {
// No tailoring-specific data: Alias the root collator's set.
data->unsafeBackwardSet = baseData->unsafeBackwardSet;
} else {
@@ -337,8 +337,8 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
// If the fast Latin format version is different,
// or the version is set to 0 for "no fast Latin table",
// then just always use the normal string comparison path.
- if(data != NULL) {
- data->fastLatinTable = NULL;
+ if(data != nullptr) {
+ data->fastLatinTable = nullptr;
data->fastLatinTableLength = 0;
if(((inIndexes[IX_OPTIONS] >> 16) & 0xff) == CollationFastLatin::VERSION) {
index = IX_FAST_LATIN_TABLE_OFFSET;
@@ -351,7 +351,7 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
errorCode = U_INVALID_FORMAT_ERROR; // header vs. table version mismatch
return;
}
- } else if(baseData != NULL) {
+ } else if(baseData != nullptr) {
data->fastLatinTable = baseData->fastLatinTable;
data->fastLatinTableLength = baseData->fastLatinTableLength;
}
@@ -362,7 +362,7 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
offset = getIndex(inIndexes, indexesLength, index);
length = getIndex(inIndexes, indexesLength, index + 1) - offset;
if(length >= 2) {
- if(data == NULL) {
+ if(data == nullptr) {
errorCode = U_INVALID_FORMAT_ERROR;
return;
}
@@ -385,9 +385,9 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
errorCode = U_INVALID_FORMAT_ERROR;
return;
}
- } else if(data == NULL) {
+ } else if(data == nullptr) {
// Nothing to do.
- } else if(baseData != NULL) {
+ } else if(baseData != nullptr) {
data->numScripts = baseData->numScripts;
data->scriptsIndex = baseData->scriptsIndex;
data->scriptStarts = baseData->scriptStarts;
@@ -398,14 +398,14 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
offset = getIndex(inIndexes, indexesLength, index);
length = getIndex(inIndexes, indexesLength, index + 1) - offset;
if(length >= 256) {
- if(data == NULL) {
+ if(data == nullptr) {
errorCode = U_INVALID_FORMAT_ERROR;
return;
}
data->compressibleBytes = reinterpret_cast<const UBool *>(inBytes + offset);
- } else if(data == NULL) {
+ } else if(data == nullptr) {
// Nothing to do.
- } else if(baseData != NULL) {
+ } else if(baseData != nullptr) {
data->compressibleBytes = baseData->compressibleBytes;
} else {
errorCode = U_INVALID_FORMAT_ERROR; // No compressibleBytes[].
@@ -429,14 +429,14 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
}
CollationSettings *settings = SharedObject::copyOnWrite(tailoring.settings);
- if(settings == NULL) {
+ if(settings == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
settings->options = options;
// Set variableTop from options and scripts data.
settings->variableTop = tailoring.data->getLastPrimaryForGroup(
- UCOL_REORDER_CODE_FIRST + settings->getMaxVariable());
+ UCOL_REORDER_CODE_FIRST + int32_t{settings->getMaxVariable()});
if(settings->variableTop == 0) {
errorCode = U_INVALID_FORMAT_ERROR;
return;
@@ -468,12 +468,12 @@ CollationDataReader::isAcceptable(void *context,
pInfo->formatVersion[0] == 5
) {
UVersionInfo *version = static_cast<UVersionInfo *>(context);
- if(version != NULL) {
+ if(version != nullptr) {
uprv_memcpy(version, pInfo->dataVersion, 4);
}
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
diff --git a/contrib/libs/icu/i18n/collationdatareader.h b/contrib/libs/icu/i18n/collationdatareader.h
index 44e69399e3..5030f6c852 100644
--- a/contrib/libs/icu/i18n/collationdatareader.h
+++ b/contrib/libs/icu/i18n/collationdatareader.h
@@ -80,7 +80,7 @@ struct U_I18N_API CollationDataReader /* all static */ {
/** Byte offset to uint32_t rootElements[]. */
IX_ROOT_ELEMENTS_OFFSET, // 12
- /** Byte offset to UChar *contexts[]. */
+ /** Byte offset to char16_t *contexts[]. */
IX_CONTEXTS_OFFSET,
/** Byte offset to uint16_t [] with serialized unsafeBackwardSet. */
IX_UNSAFE_BWD_OFFSET,
@@ -106,7 +106,7 @@ struct U_I18N_API CollationDataReader /* all static */ {
isAcceptable(void *context, const char *type, const char *name, const UDataInfo *pInfo);
private:
- CollationDataReader(); // no constructor
+ CollationDataReader() = delete; // no constructor
};
/*
@@ -198,7 +198,7 @@ private:
* Compact storage for all of the CEs that occur in the root collation.
* See the CollationRootElements class.
*
- * UChar *contexts[];
+ * char16_t *contexts[];
* Serialized UCharsTrie structures with prefix (pre-context) and contraction mappings.
*
* uint16_t unsafeBackwardSet[]; -- see UnicodeSet::serialize()
diff --git a/contrib/libs/icu/i18n/collationdatawriter.cpp b/contrib/libs/icu/i18n/collationdatawriter.cpp
index 823c8eb011..ce78a0526a 100644
--- a/contrib/libs/icu/i18n/collationdatawriter.cpp
+++ b/contrib/libs/icu/i18n/collationdatawriter.cpp
@@ -33,22 +33,22 @@ U_NAMESPACE_BEGIN
uint8_t *
RuleBasedCollator::cloneRuleData(int32_t &length, UErrorCode &errorCode) const {
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
LocalMemory<uint8_t> buffer((uint8_t *)uprv_malloc(20000));
if(buffer.isNull()) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
length = cloneBinary(buffer.getAlias(), 20000, errorCode);
if(errorCode == U_BUFFER_OVERFLOW_ERROR) {
- if(buffer.allocateInsteadAndCopy(length, 0) == NULL) {
+ if(buffer.allocateInsteadAndCopy(length, 0) == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
errorCode = U_ZERO_ERROR;
length = cloneBinary(buffer.getAlias(), length, errorCode);
}
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
return buffer.orphan();
}
@@ -79,7 +79,7 @@ CollationDataWriter::writeBase(const CollationData &data, const CollationSetting
const void *rootElements, int32_t rootElementsLength,
int32_t indexes[], uint8_t *dest, int32_t capacity,
UErrorCode &errorCode) {
- return write(TRUE, NULL,
+ return write(true, nullptr,
data, settings,
rootElements, rootElementsLength,
indexes, dest, capacity, errorCode);
@@ -89,9 +89,9 @@ int32_t
CollationDataWriter::writeTailoring(const CollationTailoring &t, const CollationSettings &settings,
int32_t indexes[], uint8_t *dest, int32_t capacity,
UErrorCode &errorCode) {
- return write(FALSE, t.version,
+ return write(false, t.version,
*t.data, settings,
- NULL, 0,
+ nullptr, 0,
indexes, dest, capacity, errorCode);
}
@@ -102,7 +102,7 @@ CollationDataWriter::write(UBool isBase, const UVersionInfo dataVersion,
int32_t indexes[], uint8_t *dest, int32_t capacity,
UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return 0; }
- if(capacity < 0 || (capacity > 0 && dest == NULL)) {
+ if(capacity < 0 || (capacity > 0 && dest == nullptr)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -117,7 +117,7 @@ CollationDataWriter::write(UBool isBase, const UVersionInfo dataVersion,
const CollationData *baseData = data.base;
int32_t fastLatinVersion;
- if(data.fastLatinTable != NULL) {
+ if(data.fastLatinTable != nullptr) {
fastLatinVersion = (int32_t)CollationFastLatin::VERSION << 16;
} else {
fastLatinVersion = 0;
@@ -129,11 +129,11 @@ CollationDataWriter::write(UBool isBase, const UVersionInfo dataVersion,
// so that we start with an 8-aligned offset.
indexesLength = CollationDataReader::IX_TOTAL_SIZE + 1;
U_ASSERT(settings.reorderCodesLength == 0);
- hasMappings = TRUE;
+ hasMappings = true;
unsafeBackwardSet = *data.unsafeBackwardSet;
fastLatinTableLength = data.fastLatinTableLength;
- } else if(baseData == NULL) {
- hasMappings = FALSE;
+ } else if(baseData == nullptr) {
+ hasMappings = false;
if(settings.reorderCodesLength == 0) {
// only options
indexesLength = CollationDataReader::IX_OPTIONS + 1; // no limit offset here
@@ -142,7 +142,7 @@ CollationDataWriter::write(UBool isBase, const UVersionInfo dataVersion,
indexesLength = CollationDataReader::IX_REORDER_TABLE_OFFSET + 2;
}
} else {
- hasMappings = TRUE;
+ hasMappings = true;
// Tailored mappings, and what else?
// Check in ascending order of optional tailoring data items.
indexesLength = CollationDataReader::IX_CE32S_OFFSET + 2;
@@ -207,7 +207,7 @@ CollationDataWriter::write(UBool isBase, const UVersionInfo dataVersion,
dest += headerSize;
capacity -= headerSize;
} else {
- dest = NULL;
+ dest = nullptr;
capacity = 0;
}
}
@@ -233,7 +233,7 @@ CollationDataWriter::write(UBool isBase, const UVersionInfo dataVersion,
totalSize += reorderCodesLength * 4;
indexes[CollationDataReader::IX_REORDER_TABLE_OFFSET] = totalSize;
- if(settings.reorderTable != NULL) {
+ if(settings.reorderTable != nullptr) {
totalSize += 256;
}
@@ -245,7 +245,7 @@ CollationDataWriter::write(UBool isBase, const UVersionInfo dataVersion,
length = utrie2_serialize(data.trie, dest + totalSize,
capacity - totalSize, &errorCode2);
} else {
- length = utrie2_serialize(data.trie, NULL, 0, &errorCode2);
+ length = utrie2_serialize(data.trie, nullptr, 0, &errorCode2);
}
if(U_FAILURE(errorCode2) && errorCode2 != U_BUFFER_OVERFLOW_ERROR) {
errorCode = errorCode2;
@@ -287,7 +287,7 @@ CollationDataWriter::write(UBool isBase, const UVersionInfo dataVersion,
length = unsafeBackwardSet.serialize(
p, (capacity - totalSize) / 2, errorCode2);
} else {
- length = unsafeBackwardSet.serialize(NULL, 0, errorCode2);
+ length = unsafeBackwardSet.serialize(nullptr, 0, errorCode2);
}
if(U_FAILURE(errorCode2) && errorCode2 != U_BUFFER_OVERFLOW_ERROR) {
errorCode = errorCode2;
@@ -302,9 +302,9 @@ CollationDataWriter::write(UBool isBase, const UVersionInfo dataVersion,
UnicodeString scripts;
indexes[CollationDataReader::IX_SCRIPTS_OFFSET] = totalSize;
if(isBase) {
- scripts.append((UChar)data.numScripts);
- scripts.append(reinterpret_cast<const UChar *>(data.scriptsIndex), data.numScripts + 16);
- scripts.append(reinterpret_cast<const UChar *>(data.scriptStarts), data.scriptStartsLength);
+ scripts.append((char16_t)data.numScripts);
+ scripts.append(reinterpret_cast<const char16_t *>(data.scriptsIndex), data.numScripts + 16);
+ scripts.append(reinterpret_cast<const char16_t *>(data.scriptStarts), data.scriptStartsLength);
totalSize += scripts.length() * 2;
}
diff --git a/contrib/libs/icu/i18n/collationdatawriter.h b/contrib/libs/icu/i18n/collationdatawriter.h
index 197cd5309f..6ba9a9c2c7 100644
--- a/contrib/libs/icu/i18n/collationdatawriter.h
+++ b/contrib/libs/icu/i18n/collationdatawriter.h
@@ -39,7 +39,7 @@ public:
UErrorCode &errorCode);
private:
- CollationDataWriter(); // no constructor
+ CollationDataWriter() = delete; // no constructor
static int32_t write(UBool isBase, const UVersionInfo dataVersion,
const CollationData &data, const CollationSettings &settings,
diff --git a/contrib/libs/icu/i18n/collationfastlatin.cpp b/contrib/libs/icu/i18n/collationfastlatin.cpp
index b98b8457f4..f40781a117 100644
--- a/contrib/libs/icu/i18n/collationfastlatin.cpp
+++ b/contrib/libs/icu/i18n/collationfastlatin.cpp
@@ -27,7 +27,7 @@ int32_t
CollationFastLatin::getOptions(const CollationData *data, const CollationSettings &settings,
uint16_t *primaries, int32_t capacity) {
const uint16_t *table = data->fastLatinTable;
- if(table == NULL) { return -1; }
+ if(table == nullptr) { return -1; }
U_ASSERT(capacity == LATIN_LIMIT);
if(capacity != LATIN_LIMIT) { return -1; }
@@ -45,7 +45,7 @@ CollationFastLatin::getOptions(const CollationData *data, const CollationSetting
miniVarTop = table[i];
}
- UBool digitsAreReordered = FALSE;
+ UBool digitsAreReordered = false;
if(settings.hasReordering()) {
uint32_t prevStart = 0;
uint32_t beforeDigitStart = 0;
@@ -80,7 +80,7 @@ CollationFastLatin::getOptions(const CollationData *data, const CollationSetting
afterDigitStart = latinStart;
}
if(!(beforeDigitStart < digitStart && digitStart < afterDigitStart)) {
- digitsAreReordered = TRUE;
+ digitsAreReordered = true;
}
}
@@ -107,8 +107,8 @@ CollationFastLatin::getOptions(const CollationData *data, const CollationSetting
int32_t
CollationFastLatin::compareUTF16(const uint16_t *table, const uint16_t *primaries, int32_t options,
- const UChar *left, int32_t leftLength,
- const UChar *right, int32_t rightLength) {
+ const char16_t *left, int32_t leftLength,
+ const char16_t *right, int32_t rightLength) {
// This is a modified copy of CollationCompare::compareUpToQuaternary(),
// optimized for common Latin text.
// Keep them in sync!
@@ -154,7 +154,7 @@ CollationFastLatin::compareUTF16(const uint16_t *table, const uint16_t *primarie
leftPair &= LONG_PRIMARY_MASK;
break;
} else {
- leftPair = nextPair(table, c, leftPair, left, NULL, leftIndex, leftLength);
+ leftPair = nextPair(table, c, leftPair, left, nullptr, leftIndex, leftLength);
if(leftPair == BAIL_OUT) { return BAIL_OUT_RESULT; }
leftPair = getPrimaries(variableTop, leftPair);
}
@@ -185,7 +185,7 @@ CollationFastLatin::compareUTF16(const uint16_t *table, const uint16_t *primarie
rightPair &= LONG_PRIMARY_MASK;
break;
} else {
- rightPair = nextPair(table, c, rightPair, right, NULL, rightIndex, rightLength);
+ rightPair = nextPair(table, c, rightPair, right, nullptr, rightIndex, rightLength);
if(rightPair == BAIL_OUT) { return BAIL_OUT_RESULT; }
rightPair = getPrimaries(variableTop, rightPair);
}
@@ -236,7 +236,7 @@ CollationFastLatin::compareUTF16(const uint16_t *table, const uint16_t *primarie
leftPair = COMMON_SEC_PLUS_OFFSET;
break;
} else {
- leftPair = nextPair(table, c, leftPair, left, NULL, leftIndex, leftLength);
+ leftPair = nextPair(table, c, leftPair, left, nullptr, leftIndex, leftLength);
leftPair = getSecondaries(variableTop, leftPair);
}
}
@@ -261,7 +261,7 @@ CollationFastLatin::compareUTF16(const uint16_t *table, const uint16_t *primarie
rightPair = COMMON_SEC_PLUS_OFFSET;
break;
} else {
- rightPair = nextPair(table, c, rightPair, right, NULL, rightIndex, rightLength);
+ rightPair = nextPair(table, c, rightPair, right, nullptr, rightIndex, rightLength);
rightPair = getSecondaries(variableTop, rightPair);
}
}
@@ -300,7 +300,7 @@ CollationFastLatin::compareUTF16(const uint16_t *table, const uint16_t *primarie
UChar32 c = left[leftIndex++];
leftPair = (c <= LATIN_MAX) ? table[c] : lookup(table, c);
if(leftPair < MIN_LONG) {
- leftPair = nextPair(table, c, leftPair, left, NULL, leftIndex, leftLength);
+ leftPair = nextPair(table, c, leftPair, left, nullptr, leftIndex, leftLength);
}
leftPair = getCases(variableTop, strengthIsPrimary, leftPair);
}
@@ -313,7 +313,7 @@ CollationFastLatin::compareUTF16(const uint16_t *table, const uint16_t *primarie
UChar32 c = right[rightIndex++];
rightPair = (c <= LATIN_MAX) ? table[c] : lookup(table, c);
if(rightPair < MIN_LONG) {
- rightPair = nextPair(table, c, rightPair, right, NULL, rightIndex, rightLength);
+ rightPair = nextPair(table, c, rightPair, right, nullptr, rightIndex, rightLength);
}
rightPair = getCases(variableTop, strengthIsPrimary, rightPair);
}
@@ -353,7 +353,7 @@ CollationFastLatin::compareUTF16(const uint16_t *table, const uint16_t *primarie
UChar32 c = left[leftIndex++];
leftPair = (c <= LATIN_MAX) ? table[c] : lookup(table, c);
if(leftPair < MIN_LONG) {
- leftPair = nextPair(table, c, leftPair, left, NULL, leftIndex, leftLength);
+ leftPair = nextPair(table, c, leftPair, left, nullptr, leftIndex, leftLength);
}
leftPair = getTertiaries(variableTop, withCaseBits, leftPair);
}
@@ -366,7 +366,7 @@ CollationFastLatin::compareUTF16(const uint16_t *table, const uint16_t *primarie
UChar32 c = right[rightIndex++];
rightPair = (c <= LATIN_MAX) ? table[c] : lookup(table, c);
if(rightPair < MIN_LONG) {
- rightPair = nextPair(table, c, rightPair, right, NULL, rightIndex, rightLength);
+ rightPair = nextPair(table, c, rightPair, right, nullptr, rightIndex, rightLength);
}
rightPair = getTertiaries(variableTop, withCaseBits, rightPair);
}
@@ -409,7 +409,7 @@ CollationFastLatin::compareUTF16(const uint16_t *table, const uint16_t *primarie
UChar32 c = left[leftIndex++];
leftPair = (c <= LATIN_MAX) ? table[c] : lookup(table, c);
if(leftPair < MIN_LONG) {
- leftPair = nextPair(table, c, leftPair, left, NULL, leftIndex, leftLength);
+ leftPair = nextPair(table, c, leftPair, left, nullptr, leftIndex, leftLength);
}
leftPair = getQuaternaries(variableTop, leftPair);
}
@@ -422,7 +422,7 @@ CollationFastLatin::compareUTF16(const uint16_t *table, const uint16_t *primarie
UChar32 c = right[rightIndex++];
rightPair = (c <= LATIN_MAX) ? table[c] : lookup(table, c);
if(rightPair < MIN_LONG) {
- rightPair = nextPair(table, c, rightPair, right, NULL, rightIndex, rightLength);
+ rightPair = nextPair(table, c, rightPair, right, nullptr, rightIndex, rightLength);
}
rightPair = getQuaternaries(variableTop, rightPair);
}
@@ -499,7 +499,7 @@ CollationFastLatin::compareUTF8(const uint16_t *table, const uint16_t *primaries
leftPair &= LONG_PRIMARY_MASK;
break;
} else {
- leftPair = nextPair(table, c, leftPair, NULL, left, leftIndex, leftLength);
+ leftPair = nextPair(table, c, leftPair, nullptr, left, leftIndex, leftLength);
if(leftPair == BAIL_OUT) { return BAIL_OUT_RESULT; }
leftPair = getPrimaries(variableTop, leftPair);
}
@@ -536,7 +536,7 @@ CollationFastLatin::compareUTF8(const uint16_t *table, const uint16_t *primaries
rightPair &= LONG_PRIMARY_MASK;
break;
} else {
- rightPair = nextPair(table, c, rightPair, NULL, right, rightIndex, rightLength);
+ rightPair = nextPair(table, c, rightPair, nullptr, right, rightIndex, rightLength);
if(rightPair == BAIL_OUT) { return BAIL_OUT_RESULT; }
rightPair = getPrimaries(variableTop, rightPair);
}
@@ -587,7 +587,7 @@ CollationFastLatin::compareUTF8(const uint16_t *table, const uint16_t *primaries
leftPair = COMMON_SEC_PLUS_OFFSET;
break;
} else {
- leftPair = nextPair(table, c, leftPair, NULL, left, leftIndex, leftLength);
+ leftPair = nextPair(table, c, leftPair, nullptr, left, leftIndex, leftLength);
leftPair = getSecondaries(variableTop, leftPair);
}
}
@@ -612,7 +612,7 @@ CollationFastLatin::compareUTF8(const uint16_t *table, const uint16_t *primaries
rightPair = COMMON_SEC_PLUS_OFFSET;
break;
} else {
- rightPair = nextPair(table, c, rightPair, NULL, right, rightIndex, rightLength);
+ rightPair = nextPair(table, c, rightPair, nullptr, right, rightIndex, rightLength);
rightPair = getSecondaries(variableTop, rightPair);
}
}
@@ -651,7 +651,7 @@ CollationFastLatin::compareUTF8(const uint16_t *table, const uint16_t *primaries
UChar32 c = left[leftIndex++];
leftPair = (c <= 0x7f) ? table[c] : lookupUTF8Unsafe(table, c, left, leftIndex);
if(leftPair < MIN_LONG) {
- leftPair = nextPair(table, c, leftPair, NULL, left, leftIndex, leftLength);
+ leftPair = nextPair(table, c, leftPair, nullptr, left, leftIndex, leftLength);
}
leftPair = getCases(variableTop, strengthIsPrimary, leftPair);
}
@@ -664,7 +664,7 @@ CollationFastLatin::compareUTF8(const uint16_t *table, const uint16_t *primaries
UChar32 c = right[rightIndex++];
rightPair = (c <= 0x7f) ? table[c] : lookupUTF8Unsafe(table, c, right, rightIndex);
if(rightPair < MIN_LONG) {
- rightPair = nextPair(table, c, rightPair, NULL, right, rightIndex, rightLength);
+ rightPair = nextPair(table, c, rightPair, nullptr, right, rightIndex, rightLength);
}
rightPair = getCases(variableTop, strengthIsPrimary, rightPair);
}
@@ -704,7 +704,7 @@ CollationFastLatin::compareUTF8(const uint16_t *table, const uint16_t *primaries
UChar32 c = left[leftIndex++];
leftPair = (c <= 0x7f) ? table[c] : lookupUTF8Unsafe(table, c, left, leftIndex);
if(leftPair < MIN_LONG) {
- leftPair = nextPair(table, c, leftPair, NULL, left, leftIndex, leftLength);
+ leftPair = nextPair(table, c, leftPair, nullptr, left, leftIndex, leftLength);
}
leftPair = getTertiaries(variableTop, withCaseBits, leftPair);
}
@@ -717,7 +717,7 @@ CollationFastLatin::compareUTF8(const uint16_t *table, const uint16_t *primaries
UChar32 c = right[rightIndex++];
rightPair = (c <= 0x7f) ? table[c] : lookupUTF8Unsafe(table, c, right, rightIndex);
if(rightPair < MIN_LONG) {
- rightPair = nextPair(table, c, rightPair, NULL, right, rightIndex, rightLength);
+ rightPair = nextPair(table, c, rightPair, nullptr, right, rightIndex, rightLength);
}
rightPair = getTertiaries(variableTop, withCaseBits, rightPair);
}
@@ -760,7 +760,7 @@ CollationFastLatin::compareUTF8(const uint16_t *table, const uint16_t *primaries
UChar32 c = left[leftIndex++];
leftPair = (c <= 0x7f) ? table[c] : lookupUTF8Unsafe(table, c, left, leftIndex);
if(leftPair < MIN_LONG) {
- leftPair = nextPair(table, c, leftPair, NULL, left, leftIndex, leftLength);
+ leftPair = nextPair(table, c, leftPair, nullptr, left, leftIndex, leftLength);
}
leftPair = getQuaternaries(variableTop, leftPair);
}
@@ -773,7 +773,7 @@ CollationFastLatin::compareUTF8(const uint16_t *table, const uint16_t *primaries
UChar32 c = right[rightIndex++];
rightPair = (c <= 0x7f) ? table[c] : lookupUTF8Unsafe(table, c, right, rightIndex);
if(rightPair < MIN_LONG) {
- rightPair = nextPair(table, c, rightPair, NULL, right, rightIndex, rightLength);
+ rightPair = nextPair(table, c, rightPair, nullptr, right, rightIndex, rightLength);
}
rightPair = getQuaternaries(variableTop, rightPair);
}
@@ -854,7 +854,7 @@ CollationFastLatin::lookupUTF8Unsafe(const uint16_t *table, UChar32 c,
uint32_t
CollationFastLatin::nextPair(const uint16_t *table, UChar32 c, uint32_t ce,
- const UChar *s16, const uint8_t *s8, int32_t &sIndex, int32_t &sLength) {
+ const char16_t *s16, const uint8_t *s8, int32_t &sIndex, int32_t &sLength) {
if(ce >= MIN_LONG || ce < CONTRACTION) {
return ce; // simple or special mini CE
} else if(ce >= EXPANSION) {
@@ -872,7 +872,7 @@ CollationFastLatin::nextPair(const uint16_t *table, UChar32 c, uint32_t ce,
// Read the next character.
int32_t c2;
int32_t nextIndex = sIndex;
- if(s16 != NULL) {
+ if(s16 != nullptr) {
c2 = s16[nextIndex++];
if(c2 > LATIN_MAX) {
if(PUNCT_START <= c2 && c2 < PUNCT_LIMIT) {
diff --git a/contrib/libs/icu/i18n/collationfastlatin.h b/contrib/libs/icu/i18n/collationfastlatin.h
index 4bac797409..d4caddcb63 100644
--- a/contrib/libs/icu/i18n/collationfastlatin.h
+++ b/contrib/libs/icu/i18n/collationfastlatin.h
@@ -188,7 +188,7 @@ public:
*/
static const int32_t BAIL_OUT_RESULT = -2;
- static inline int32_t getCharIndex(UChar c) {
+ static inline int32_t getCharIndex(char16_t c) {
if(c <= LATIN_MAX) {
return c;
} else if(PUNCT_START <= c && c < PUNCT_LIMIT) {
@@ -211,8 +211,8 @@ public:
uint16_t *primaries, int32_t capacity);
static int32_t compareUTF16(const uint16_t *table, const uint16_t *primaries, int32_t options,
- const UChar *left, int32_t leftLength,
- const UChar *right, int32_t rightLength);
+ const char16_t *left, int32_t leftLength,
+ const char16_t *right, int32_t rightLength);
static int32_t compareUTF8(const uint16_t *table, const uint16_t *primaries, int32_t options,
const uint8_t *left, int32_t leftLength,
@@ -226,7 +226,7 @@ private:
const uint8_t *s8, int32_t &sIndex);
static uint32_t nextPair(const uint16_t *table, UChar32 c, uint32_t ce,
- const UChar *s16, const uint8_t *s8, int32_t &sIndex, int32_t &sLength);
+ const char16_t *s16, const uint8_t *s8, int32_t &sIndex, int32_t &sLength);
static inline uint32_t getPrimaries(uint32_t variableTop, uint32_t pair) {
uint32_t ce = pair & 0xffff;
@@ -249,7 +249,7 @@ private:
static uint32_t getQuaternaries(uint32_t variableTop, uint32_t pair);
private:
- CollationFastLatin(); // no constructor
+ CollationFastLatin() = delete; // no constructor
};
/*
diff --git a/contrib/libs/icu/i18n/collationfastlatinbuilder.cpp b/contrib/libs/icu/i18n/collationfastlatinbuilder.cpp
index e5ba2f0e21..b1fd3af70a 100644
--- a/contrib/libs/icu/i18n/collationfastlatinbuilder.cpp
+++ b/contrib/libs/icu/i18n/collationfastlatinbuilder.cpp
@@ -89,9 +89,9 @@ binarySearch(const int64_t list[], int32_t limit, int64_t ce) {
CollationFastLatinBuilder::CollationFastLatinBuilder(UErrorCode &errorCode)
: ce0(0), ce1(0),
contractionCEs(errorCode), uniqueCEs(errorCode),
- miniCEs(NULL),
+ miniCEs(nullptr),
firstDigitPrimary(0), firstLatinPrimary(0), lastLatinPrimary(0),
- firstShortPrimary(0), shortPrimaryOverflow(FALSE),
+ firstShortPrimary(0), shortPrimaryOverflow(false),
headerLength(0) {
}
@@ -101,24 +101,24 @@ CollationFastLatinBuilder::~CollationFastLatinBuilder() {
UBool
CollationFastLatinBuilder::forData(const CollationData &data, UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
if(!result.isEmpty()) { // This builder is not reusable.
errorCode = U_INVALID_STATE_ERROR;
- return FALSE;
+ return false;
}
- if(!loadGroups(data, errorCode)) { return FALSE; }
+ if(!loadGroups(data, errorCode)) { return false; }
// Fast handling of digits.
firstShortPrimary = firstDigitPrimary;
getCEs(data, errorCode);
- if(!encodeUniqueCEs(errorCode)) { return FALSE; }
+ if(!encodeUniqueCEs(errorCode)) { return false; }
if(shortPrimaryOverflow) {
// Give digits long mini primaries,
// so that there are more short primaries for letters.
firstShortPrimary = firstLatinPrimary;
resetCEs();
getCEs(data, errorCode);
- if(!encodeUniqueCEs(errorCode)) { return FALSE; }
+ if(!encodeUniqueCEs(errorCode)) { return false; }
}
// Note: If we still have a short-primary overflow but not a long-primary overflow,
// then we could calculate how many more long primaries would fit,
@@ -126,7 +126,7 @@ CollationFastLatinBuilder::forData(const CollationData &data, UErrorCode &errorC
// and try again.
// However, this might only benefit the en_US_POSIX tailoring,
// and it is simpler to suppress building fast Latin data for it in genrb,
- // or by returning FALSE here if shortPrimaryOverflow.
+ // or by returning false here if shortPrimaryOverflow.
UBool ok = !shortPrimaryOverflow &&
encodeCharCEs(errorCode) && encodeContractions(errorCode);
@@ -137,19 +137,19 @@ CollationFastLatinBuilder::forData(const CollationData &data, UErrorCode &errorC
UBool
CollationFastLatinBuilder::loadGroups(const CollationData &data, UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
headerLength = 1 + NUM_SPECIAL_GROUPS;
uint32_t r0 = (CollationFastLatin::VERSION << 8) | headerLength;
- result.append((UChar)r0);
+ result.append((char16_t)r0);
// The first few reordering groups should be special groups
// (space, punct, ..., digit) followed by Latn, then Grek and other scripts.
for(int32_t i = 0; i < NUM_SPECIAL_GROUPS; ++i) {
lastSpecialPrimaries[i] = data.getLastPrimaryForGroup(UCOL_REORDER_CODE_FIRST + i);
if(lastSpecialPrimaries[i] == 0) {
// missing data
- return FALSE;
+ return false;
}
- result.append((UChar)0); // reserve a slot for this group
+ result.append((char16_t)0); // reserve a slot for this group
}
firstDigitPrimary = data.getFirstPrimaryForGroup(UCOL_REORDER_CODE_DIGIT);
@@ -157,9 +157,9 @@ CollationFastLatinBuilder::loadGroups(const CollationData &data, UErrorCode &err
lastLatinPrimary = data.getLastPrimaryForGroup(USCRIPT_LATIN);
if(firstDigitPrimary == 0 || firstLatinPrimary == 0) {
// missing data
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
UBool
@@ -169,7 +169,7 @@ CollationFastLatinBuilder::inSameGroup(uint32_t p, uint32_t q) const {
if(p >= firstShortPrimary) {
return q >= firstShortPrimary;
} else if(q >= firstShortPrimary) {
- return FALSE;
+ return false;
}
// Both or neither must be potentially-variable,
// so that we can test only one and determine if both are variable.
@@ -177,7 +177,7 @@ CollationFastLatinBuilder::inSameGroup(uint32_t p, uint32_t q) const {
if(p > lastVariablePrimary) {
return q > lastVariablePrimary;
} else if(q > lastVariablePrimary) {
- return FALSE;
+ return false;
}
// Both will be encoded with long mini primaries.
// They must be in the same special reordering group,
@@ -188,7 +188,7 @@ CollationFastLatinBuilder::inSameGroup(uint32_t p, uint32_t q) const {
if(p <= lastPrimary) {
return q <= lastPrimary;
} else if(q <= lastPrimary) {
- return FALSE;
+ return false;
}
}
}
@@ -197,7 +197,7 @@ void
CollationFastLatinBuilder::resetCEs() {
contractionCEs.removeAllElements();
uniqueCEs.removeAllElements();
- shortPrimaryOverflow = FALSE;
+ shortPrimaryOverflow = false;
result.truncate(headerLength);
}
@@ -205,7 +205,7 @@ void
CollationFastLatinBuilder::getCEs(const CollationData &data, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
int32_t i = 0;
- for(UChar c = 0;; ++i, ++c) {
+ for(char16_t c = 0;; ++i, ++c) {
if(c == CollationFastLatin::LATIN_LIMIT) {
c = CollationFastLatin::PUNCT_START;
} else if(c == CollationFastLatin::PUNCT_LIMIT) {
@@ -245,7 +245,7 @@ CollationFastLatinBuilder::getCEs(const CollationData &data, UErrorCode &errorCo
UBool
CollationFastLatinBuilder::getCEsFromCE32(const CollationData &data, UChar32 c, uint32_t ce32,
UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
ce32 = data.getFinalCE32(ce32);
ce1 = 0;
if(Collation::isSimpleOrLongCE32(ce32)) {
@@ -266,7 +266,7 @@ CollationFastLatinBuilder::getCEsFromCE32(const CollationData &data, UChar32 c,
}
break;
} else {
- return FALSE;
+ return false;
}
}
case Collation::EXPANSION_TAG: {
@@ -279,7 +279,7 @@ CollationFastLatinBuilder::getCEsFromCE32(const CollationData &data, UChar32 c,
}
break;
} else {
- return FALSE;
+ return false;
}
}
// Note: We could support PREFIX_TAG (assert c>=0)
@@ -295,24 +295,24 @@ CollationFastLatinBuilder::getCEsFromCE32(const CollationData &data, UChar32 c,
ce0 = data.getCEFromOffsetCE32(c, ce32);
break;
default:
- return FALSE;
+ return false;
}
}
// A mapping can be completely ignorable.
if(ce0 == 0) { return ce1 == 0; }
// We do not support an ignorable ce0 unless it is completely ignorable.
uint32_t p0 = (uint32_t)(ce0 >> 32);
- if(p0 == 0) { return FALSE; }
+ if(p0 == 0) { return false; }
// We only support primaries up to the Latin script.
- if(p0 > lastLatinPrimary) { return FALSE; }
+ if(p0 > lastLatinPrimary) { return false; }
// We support non-common secondary and case weights only together with short primaries.
uint32_t lower32_0 = (uint32_t)ce0;
if(p0 < firstShortPrimary) {
uint32_t sc0 = lower32_0 & Collation::SECONDARY_AND_CASE_MASK;
- if(sc0 != Collation::COMMON_SECONDARY_CE) { return FALSE; }
+ if(sc0 != Collation::COMMON_SECONDARY_CE) { return false; }
}
// No below-common tertiary weights.
- if((lower32_0 & Collation::ONLY_TERTIARY_MASK) < Collation::COMMON_WEIGHT16) { return FALSE; }
+ if((lower32_0 & Collation::ONLY_TERTIARY_MASK) < Collation::COMMON_WEIGHT16) { return false; }
if(ce1 != 0) {
// Both primaries must be in the same group,
// or both must get short mini primaries,
@@ -320,29 +320,29 @@ CollationFastLatinBuilder::getCEsFromCE32(const CollationData &data, UChar32 c,
// This is so that we can test the first primary and use the same mask for both,
// and determine for both whether they are variable.
uint32_t p1 = (uint32_t)(ce1 >> 32);
- if(p1 == 0 ? p0 < firstShortPrimary : !inSameGroup(p0, p1)) { return FALSE; }
+ if(p1 == 0 ? p0 < firstShortPrimary : !inSameGroup(p0, p1)) { return false; }
uint32_t lower32_1 = (uint32_t)ce1;
// No tertiary CEs.
- if((lower32_1 >> 16) == 0) { return FALSE; }
+ if((lower32_1 >> 16) == 0) { return false; }
// We support non-common secondary and case weights
// only for secondary CEs or together with short primaries.
if(p1 != 0 && p1 < firstShortPrimary) {
uint32_t sc1 = lower32_1 & Collation::SECONDARY_AND_CASE_MASK;
- if(sc1 != Collation::COMMON_SECONDARY_CE) { return FALSE; }
+ if(sc1 != Collation::COMMON_SECONDARY_CE) { return false; }
}
// No below-common tertiary weights.
- if((lower32_1 & Collation::ONLY_TERTIARY_MASK) < Collation::COMMON_WEIGHT16) { return FALSE; }
+ if((lower32_1 & Collation::ONLY_TERTIARY_MASK) < Collation::COMMON_WEIGHT16) { return false; }
}
// No quaternary weights.
- if(((ce0 | ce1) & Collation::QUATERNARY_MASK) != 0) { return FALSE; }
- return TRUE;
+ if(((ce0 | ce1) & Collation::QUATERNARY_MASK) != 0) { return false; }
+ return true;
}
UBool
CollationFastLatinBuilder::getCEsFromContractionCE32(const CollationData &data, uint32_t ce32,
UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
- const UChar *p = data.contexts + Collation::indexFromCE32(ce32);
+ if(U_FAILURE(errorCode)) { return false; }
+ const char16_t *p = data.contexts + Collation::indexFromCE32(ce32);
ce32 = CollationData::readCE32(p); // Default if no suffix match.
// Since the original ce32 is not a prefix mapping,
// the default ce32 must not be another contraction.
@@ -357,7 +357,7 @@ CollationFastLatinBuilder::getCEsFromContractionCE32(const CollationData &data,
// Handle an encodable contraction unless the next contraction is too long
// and starts with the same character.
int32_t prevX = -1;
- UBool addContraction = FALSE;
+ UBool addContraction = false;
UCharsTrie::Iterator suffixes(p + 2, 0, errorCode);
while(suffixes.next(errorCode)) {
const UnicodeString &suffix = suffixes.getString();
@@ -367,7 +367,7 @@ CollationFastLatinBuilder::getCEsFromContractionCE32(const CollationData &data,
if(addContraction) {
// Bail out for all contractions starting with this character.
addContractionEntry(x, Collation::NO_CE, 0, errorCode);
- addContraction = FALSE;
+ addContraction = false;
}
continue;
}
@@ -376,17 +376,17 @@ CollationFastLatinBuilder::getCEsFromContractionCE32(const CollationData &data,
}
ce32 = (uint32_t)suffixes.getValue();
if(suffix.length() == 1 && getCEsFromCE32(data, U_SENTINEL, ce32, errorCode)) {
- addContraction = TRUE;
+ addContraction = true;
} else {
addContractionEntry(x, Collation::NO_CE, 0, errorCode);
- addContraction = FALSE;
+ addContraction = false;
}
prevX = x;
}
if(addContraction) {
addContractionEntry(prevX, ce0, ce1, errorCode);
}
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
// Note: There might not be any fast Latin contractions, but
// we need to enter contraction handling anyway so that we can bail out
// when there is a non-fast-Latin character following.
@@ -394,7 +394,7 @@ CollationFastLatinBuilder::getCEsFromContractionCE32(const CollationData &data,
// following umlaut and bail out, rather than return the difference of Y vs. u.
ce0 = ((int64_t)Collation::NO_CE_PRIMARY << 32) | CONTRACTION_FLAG | contractionIndex;
ce1 = 0;
- return TRUE;
+ return true;
}
void
@@ -428,12 +428,12 @@ CollationFastLatinBuilder::getMiniCE(int64_t ce) const {
UBool
CollationFastLatinBuilder::encodeUniqueCEs(UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
uprv_free(miniCEs);
miniCEs = (uint16_t *)uprv_malloc(uniqueCEs.size() * 2);
- if(miniCEs == NULL) {
+ if(miniCEs == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return FALSE;
+ return false;
}
int32_t group = 0;
uint32_t lastGroupPrimary = lastSpecialPrimaries[group];
@@ -454,7 +454,7 @@ CollationFastLatinBuilder::encodeUniqueCEs(UErrorCode &errorCode) {
U_ASSERT(pri <= CollationFastLatin::MAX_LONG);
// Set the group's header entry to the
// last "long primary" in or before the group.
- result.setCharAt(1 + group, (UChar)pri);
+ result.setCharAt(1 + group, (char16_t)pri);
if(++group < NUM_SPECIAL_GROUPS) {
lastGroupPrimary = lastSpecialPrimaries[group];
} else {
@@ -484,7 +484,7 @@ CollationFastLatinBuilder::encodeUniqueCEs(UErrorCode &errorCode) {
#if DEBUG_COLLATION_FAST_LATIN_BUILDER
printf("short-primary overflow for %08x\n", p);
#endif
- shortPrimaryOverflow = TRUE;
+ shortPrimaryOverflow = true;
miniCEs[i] = CollationFastLatin::BAIL_OUT;
continue;
}
@@ -563,10 +563,10 @@ CollationFastLatinBuilder::encodeUniqueCEs(UErrorCode &errorCode) {
UBool
CollationFastLatinBuilder::encodeCharCEs(UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
int32_t miniCEsStart = result.length();
for(int32_t i = 0; i < CollationFastLatin::NUM_FAST_CHARS; ++i) {
- result.append((UChar)0); // initialize to completely ignorable
+ result.append((char16_t)0); // initialize to completely ignorable
}
int32_t indexBase = result.length();
for(int32_t i = 0; i < CollationFastLatin::NUM_FAST_CHARS; ++i) {
@@ -581,11 +581,11 @@ CollationFastLatinBuilder::encodeCharCEs(UErrorCode &errorCode) {
if(expansionIndex > (int32_t)CollationFastLatin::INDEX_MASK) {
miniCE = CollationFastLatin::BAIL_OUT;
} else {
- result.append((UChar)(miniCE >> 16)).append((UChar)miniCE);
+ result.append((char16_t)(miniCE >> 16)).append((char16_t)miniCE);
miniCE = CollationFastLatin::EXPANSION | expansionIndex;
}
}
- result.setCharAt(miniCEsStart + i, (UChar)miniCE);
+ result.setCharAt(miniCEsStart + i, (char16_t)miniCE);
}
return U_SUCCESS(errorCode);
}
@@ -594,7 +594,7 @@ UBool
CollationFastLatinBuilder::encodeContractions(UErrorCode &errorCode) {
// We encode all contraction lists so that the first word of a list
// terminates the previous list, and we only need one additional terminator at the end.
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
int32_t indexBase = headerLength + CollationFastLatin::NUM_FAST_CHARS;
int32_t firstContractionIndex = result.length();
for(int32_t i = 0; i < CollationFastLatin::NUM_FAST_CHARS; ++i) {
@@ -605,7 +605,7 @@ CollationFastLatinBuilder::encodeContractions(UErrorCode &errorCode) {
result.setCharAt(headerLength + i, CollationFastLatin::BAIL_OUT);
continue;
}
- UBool firstTriple = TRUE;
+ UBool firstTriple = true;
for(int32_t index = (int32_t)ce & 0x7fffffff;; index += 3) {
int32_t x = static_cast<int32_t>(contractionCEs.elementAti(index));
if((uint32_t)x == CollationFastLatin::CONTR_CHAR_MASK && !firstTriple) { break; }
@@ -613,29 +613,29 @@ CollationFastLatinBuilder::encodeContractions(UErrorCode &errorCode) {
int64_t cce1 = contractionCEs.elementAti(index + 2);
uint32_t miniCE = encodeTwoCEs(cce0, cce1);
if(miniCE == CollationFastLatin::BAIL_OUT) {
- result.append((UChar)(x | (1 << CollationFastLatin::CONTR_LENGTH_SHIFT)));
+ result.append((char16_t)(x | (1 << CollationFastLatin::CONTR_LENGTH_SHIFT)));
} else if(miniCE <= 0xffff) {
- result.append((UChar)(x | (2 << CollationFastLatin::CONTR_LENGTH_SHIFT)));
- result.append((UChar)miniCE);
+ result.append((char16_t)(x | (2 << CollationFastLatin::CONTR_LENGTH_SHIFT)));
+ result.append((char16_t)miniCE);
} else {
- result.append((UChar)(x | (3 << CollationFastLatin::CONTR_LENGTH_SHIFT)));
- result.append((UChar)(miniCE >> 16)).append((UChar)miniCE);
+ result.append((char16_t)(x | (3 << CollationFastLatin::CONTR_LENGTH_SHIFT)));
+ result.append((char16_t)(miniCE >> 16)).append((char16_t)miniCE);
}
- firstTriple = FALSE;
+ firstTriple = false;
}
// Note: There is a chance that this new contraction list is the same as a previous one,
// and if so, then we could truncate the result and reuse the other list.
// However, that seems unlikely.
result.setCharAt(headerLength + i,
- (UChar)(CollationFastLatin::CONTRACTION | contractionIndex));
+ (char16_t)(CollationFastLatin::CONTRACTION | contractionIndex));
}
if(result.length() > firstContractionIndex) {
// Terminate the last contraction list.
- result.append((UChar)CollationFastLatin::CONTR_CHAR_MASK);
+ result.append((char16_t)CollationFastLatin::CONTR_CHAR_MASK);
}
if(result.isBogus()) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return FALSE;
+ return false;
}
#if DEBUG_COLLATION_FAST_LATIN_BUILDER
printf("** fast Latin %d * 2 = %d bytes\n", result.length(), result.length() * 2);
@@ -663,7 +663,7 @@ CollationFastLatinBuilder::encodeContractions(UErrorCode &errorCode) {
}
puts("");
#endif
- return TRUE;
+ return true;
}
uint32_t
diff --git a/contrib/libs/icu/i18n/collationfcd.cpp b/contrib/libs/icu/i18n/collationfcd.cpp
index 0be4150b09..e1f1d0330c 100644
--- a/contrib/libs/icu/i18n/collationfcd.cpp
+++ b/contrib/libs/icu/i18n/collationfcd.cpp
@@ -151,7 +151,7 @@ const uint32_t CollationFCD::lcccBits[73]={
0x200ff800,0xfbc00000,0x3eef,0xe000000,0xff000000,0xfffffc00,0xfffffffb,0x10000000,0x1e2000,0x2000,0x40000000,0x602000,0x18000000,0x400,0x7000000,0xf00,
0x3000000,0x2a00000,0x3c3e0000,0xdf,0x40,0x6800000,0xe0000000,0x300000,0x100000,0x20040000,0x200,0x1800000,0x9fe00001,0xbfff0000,0x7fff,0x10,
0xff800,0xc00,0xc0040,0x800000,0xfff70000,0x31021fd,0x1fff0000,0x1ffe2,0x38000,0x80000000,0xfc00,0x6000000,0x3ff08000,0xc0000000,0x30000,0x1000,
-0x3ffff,0x3800,0x80000,1,0xc19d0000,2,0x400000,0xc0000fd,0x5108000
+0x3ffff,0x3800,0x80000,1,0xc19d0000,2,0x400000,0xc0000fd,0x7108000
};
const uint8_t CollationFCD::tcccIndex[2048]={
@@ -293,7 +293,7 @@ const uint32_t CollationFCD::tcccBits[123]={
0xe0000000,0x300000,0x100000,0x20040000,0x200,0x1800000,0x9fe00001,0xbfff0000,0x7fff,0x10,0xff800,0xc00,0xc0040,0x800000,0xfff70000,0x31021fd,
0xbffffff,0x3ffffff,0x3f3fffff,0xaaff3f3f,0x3fffffff,0x1fdfffff,0xefcfffde,0x1fdc7fff,0x1fff0000,0x1ffe2,0x800,0xc000000,0x4000,0xe000,0x1210,0x50,
0x292,0x333e005,0x333,0xf000,0x3c0f,0x38000,0x80000000,0xfc00,0x55555000,0x36db02a5,0x46100000,0x47900000,0x3ff08000,0xc0000000,0x30000,0x1000,
-0x3ffff,0x3800,0x80000,1,0xc19d0000,2,0x400000,0xc0000fd,0x5108000,0x5f7ffc00,0x7fdb
+0x3ffff,0x3800,0x80000,1,0xc19d0000,2,0x400000,0xc0000fd,0x7108000,0x5f7ffc00,0x7fdb
};
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/collationfcd.h b/contrib/libs/icu/i18n/collationfcd.h
index 3a5738efb2..9620452b97 100644
--- a/contrib/libs/icu/i18n/collationfcd.h
+++ b/contrib/libs/icu/i18n/collationfcd.h
@@ -123,7 +123,7 @@ public:
}
private:
- CollationFCD(); // No instantiation.
+ CollationFCD() = delete; // No instantiation.
static const uint8_t lcccIndex[2048];
static const uint8_t tcccIndex[2048];
diff --git a/contrib/libs/icu/i18n/collationiterator.cpp b/contrib/libs/icu/i18n/collationiterator.cpp
index 6bfdfbe7c7..f8c6da22b2 100644
--- a/contrib/libs/icu/i18n/collationiterator.cpp
+++ b/contrib/libs/icu/i18n/collationiterator.cpp
@@ -36,8 +36,8 @@ CollationIterator::CEBuffer::~CEBuffer() {}
UBool
CollationIterator::CEBuffer::ensureAppendCapacity(int32_t appCap, UErrorCode &errorCode) {
int32_t capacity = buffer.getCapacity();
- if((length + appCap) <= capacity) { return TRUE; }
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if((length + appCap) <= capacity) { return true; }
+ if(U_FAILURE(errorCode)) { return false; }
do {
if(capacity < 1000) {
capacity *= 4;
@@ -46,11 +46,11 @@ CollationIterator::CEBuffer::ensureAppendCapacity(int32_t appCap, UErrorCode &er
}
} while(capacity < (length + appCap));
int64_t *p = buffer.resize(capacity, length);
- if(p == NULL) {
+ if(p == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
// State of combining marks skipped in discontiguous contraction.
@@ -149,7 +149,7 @@ CollationIterator::CollationIterator(const CollationIterator &other)
trie(other.trie),
data(other.data),
cesIndex(other.cesIndex),
- skipped(NULL),
+ skipped(nullptr),
numCpFwd(other.numCpFwd),
isNumeric(other.isNumeric) {
UErrorCode errorCode = U_ZERO_ERROR;
@@ -191,7 +191,7 @@ CollationIterator::operator==(const CollationIterator &other) const {
void
CollationIterator::reset() {
cesIndex = ceBuffer.length = 0;
- if(skipped != NULL) { skipped->clear(); }
+ if(skipped != nullptr) { skipped->clear(); }
}
int32_t
@@ -209,19 +209,19 @@ CollationIterator::handleNextCE32(UChar32 &c, UErrorCode &errorCode) {
return (c < 0) ? Collation::FALLBACK_CE32 : data->getCE32(c);
}
-UChar
+char16_t
CollationIterator::handleGetTrailSurrogate() {
return 0;
}
UBool
CollationIterator::foundNULTerminator() {
- return FALSE;
+ return false;
}
UBool
CollationIterator::forbidSurrogateCodePoints() const {
- return FALSE;
+ return false;
}
uint32_t
@@ -239,7 +239,7 @@ int64_t
CollationIterator::nextCEFromCE32(const CollationData *d, UChar32 c, uint32_t ce32,
UErrorCode &errorCode) {
--ceBuffer.length; // Undo ceBuffer.incLength().
- appendCEsFromCE32(d, c, ce32, TRUE, errorCode);
+ appendCEsFromCE32(d, c, ce32, true, errorCode);
if(U_SUCCESS(errorCode)) {
return ceBuffer.get(cesIndex++);
} else {
@@ -303,7 +303,7 @@ CollationIterator::appendCEsFromCE32(const CollationData *d, UChar32 c, uint32_t
if(forward) { forwardNumCodePoints(1, errorCode); }
break;
case Collation::CONTRACTION_TAG: {
- const UChar *p = d->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = d->contexts + Collation::indexFromCE32(ce32);
uint32_t defaultCE32 = CollationData::readCE32(p); // Default if no suffix match.
if(!forward) {
// Backward contractions are handled by previousCEUnsafe().
@@ -312,7 +312,7 @@ CollationIterator::appendCEsFromCE32(const CollationData *d, UChar32 c, uint32_t
break;
}
UChar32 nextCp;
- if(skipped == NULL && numCpFwd < 0) {
+ if(skipped == nullptr && numCpFwd < 0) {
// Some portion of nextCE32FromContraction() pulled out here as an ASCII fast path,
// avoiding the function call and the nextSkippedCodePoint() overhead.
nextCp = nextCodePoint(errorCode);
@@ -408,7 +408,7 @@ CollationIterator::appendCEsFromCE32(const CollationData *d, UChar32 c, uint32_t
case Collation::LEAD_SURROGATE_TAG: {
U_ASSERT(forward); // Backward iteration should never see lead surrogate code _unit_ data.
U_ASSERT(U16_IS_LEAD(c));
- UChar trail;
+ char16_t trail;
if(U16_IS_TRAIL(trail = handleGetTrailSurrogate())) {
c = U16_GET_SUPPLEMENTARY(c, trail);
ce32 &= Collation::LEAD_TYPE_MASK;
@@ -447,7 +447,7 @@ CollationIterator::appendCEsFromCE32(const CollationData *d, UChar32 c, uint32_t
uint32_t
CollationIterator::getCE32FromPrefix(const CollationData *d, uint32_t ce32,
UErrorCode &errorCode) {
- const UChar *p = d->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = d->contexts + Collation::indexFromCE32(ce32);
ce32 = CollationData::readCE32(p); // Default if no prefix match.
p += 2;
// Number of code points read before the original code point.
@@ -469,17 +469,17 @@ CollationIterator::getCE32FromPrefix(const CollationData *d, uint32_t ce32,
UChar32
CollationIterator::nextSkippedCodePoint(UErrorCode &errorCode) {
- if(skipped != NULL && skipped->hasNext()) { return skipped->next(); }
+ if(skipped != nullptr && skipped->hasNext()) { return skipped->next(); }
if(numCpFwd == 0) { return U_SENTINEL; }
UChar32 c = nextCodePoint(errorCode);
- if(skipped != NULL && !skipped->isEmpty() && c >= 0) { skipped->incBeyond(); }
+ if(skipped != nullptr && !skipped->isEmpty() && c >= 0) { skipped->incBeyond(); }
if(numCpFwd > 0 && c >= 0) { --numCpFwd; }
return c;
}
void
CollationIterator::backwardNumSkipped(int32_t n, UErrorCode &errorCode) {
- if(skipped != NULL && !skipped->isEmpty()) {
+ if(skipped != nullptr && !skipped->isEmpty()) {
n = skipped->backwardNumCodePoints(n);
}
backwardNumCodePoints(n, errorCode);
@@ -488,7 +488,7 @@ CollationIterator::backwardNumSkipped(int32_t n, UErrorCode &errorCode) {
uint32_t
CollationIterator::nextCE32FromContraction(const CollationData *d, uint32_t contractionCE32,
- const UChar *p, uint32_t ce32, UChar32 c,
+ const char16_t *p, uint32_t ce32, UChar32 c,
UErrorCode &errorCode) {
// c: next code point after the original one
@@ -501,7 +501,7 @@ CollationIterator::nextCE32FromContraction(const CollationData *d, uint32_t cont
// and therefore need not remember the suffixes state from before a mismatch for retrying.
// If we are already processing skipped combining marks, then we do track the state.
UCharsTrie suffixes(p);
- if(skipped != NULL && !skipped->isEmpty()) { skipped->saveTrieState(suffixes); }
+ if(skipped != nullptr && !skipped->isEmpty()) { skipped->saveTrieState(suffixes); }
UStringTrieResult match = suffixes.firstForCodePoint(c);
for(;;) {
UChar32 nextCp;
@@ -510,7 +510,7 @@ CollationIterator::nextCE32FromContraction(const CollationData *d, uint32_t cont
if(!USTRINGTRIE_HAS_NEXT(match) || (c = nextSkippedCodePoint(errorCode)) < 0) {
return ce32;
}
- if(skipped != NULL && !skipped->isEmpty()) { skipped->saveTrieState(suffixes); }
+ if(skipped != nullptr && !skipped->isEmpty()) { skipped->saveTrieState(suffixes); }
sinceMatch = 1;
} else if(match == USTRINGTRIE_NO_MATCH || (nextCp = nextSkippedCodePoint(errorCode)) < 0) {
// No match for c, or partial match (USTRINGTRIE_NO_VALUE) and no further text.
@@ -597,10 +597,10 @@ CollationIterator::nextCE32FromDiscontiguousContraction(
// We have read and matched (lookAhead-2) code points,
// read non-matching c and peeked ahead at nextCp.
// Return to the state before the mismatch and continue matching with nextCp.
- if(skipped == NULL || skipped->isEmpty()) {
- if(skipped == NULL) {
+ if(skipped == nullptr || skipped->isEmpty()) {
+ if(skipped == nullptr) {
skipped = new SkippedState();
- if(skipped == NULL) {
+ if(skipped == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
@@ -661,7 +661,7 @@ CollationIterator::nextCE32FromDiscontiguousContraction(
// and then from the combining marks that we skipped before the match.
c = U_SENTINEL;
for(;;) {
- appendCEsFromCE32(d, c, ce32, TRUE, errorCode);
+ appendCEsFromCE32(d, c, ce32, true, errorCode);
// Fetch CE32s for skipped combining marks from the normal data, with fallback,
// rather than from the CollationData where we found the contraction.
if(!skipped->hasNext()) { break; }
@@ -864,7 +864,7 @@ CollationIterator::previousCE(UVector32 &offsets, UErrorCode &errorCode) {
if(Collation::isSimpleOrLongCE32(ce32)) {
return Collation::ceFromCE32(ce32);
}
- appendCEsFromCE32(d, c, ce32, FALSE, errorCode);
+ appendCEsFromCE32(d, c, ce32, false, errorCode);
if(U_SUCCESS(errorCode)) {
if(ceBuffer.length > 1) {
offsets.addElement(getOffset(), errorCode);
diff --git a/contrib/libs/icu/i18n/collationiterator.h b/contrib/libs/icu/i18n/collationiterator.h
index 73cb93b934..07bdf61985 100644
--- a/contrib/libs/icu/i18n/collationiterator.h
+++ b/contrib/libs/icu/i18n/collationiterator.h
@@ -92,8 +92,8 @@ private:
int32_t length;
private:
- CEBuffer(const CEBuffer &);
- void operator=(const CEBuffer &);
+ CEBuffer(const CEBuffer &) = delete;
+ void operator=(const CEBuffer &) = delete;
MaybeStackArray<int64_t, INITIAL_CAPACITY> buffer;
};
@@ -103,7 +103,7 @@ public:
: trie(d->trie),
data(d),
cesIndex(0),
- skipped(NULL),
+ skipped(nullptr),
numCpFwd(-1),
isNumeric(numeric) {}
@@ -242,7 +242,7 @@ protected:
* if a trail surrogate follows the lead surrogate.
* Otherwise returns any other code unit and does not advance.
*/
- virtual UChar handleGetTrailSurrogate();
+ virtual char16_t handleGetTrailSurrogate();
/**
* Called when handleNextCE32() returns with c==0, to see whether it is a NUL terminator.
@@ -290,7 +290,7 @@ private:
uint32_t nextCE32FromContraction(
const CollationData *d, uint32_t contractionCE32,
- const UChar *p, uint32_t ce32, UChar32 c,
+ const char16_t *p, uint32_t ce32, UChar32 c,
UErrorCode &errorCode);
uint32_t nextCE32FromDiscontiguousContraction(
diff --git a/contrib/libs/icu/i18n/collationkeys.cpp b/contrib/libs/icu/i18n/collationkeys.cpp
index b5c322fb44..c429ac3f8f 100644
--- a/contrib/libs/icu/i18n/collationkeys.cpp
+++ b/contrib/libs/icu/i18n/collationkeys.cpp
@@ -28,7 +28,7 @@ SortKeyByteSink::~SortKeyByteSink() {}
void
SortKeyByteSink::Append(const char *bytes, int32_t n) {
- if (n <= 0 || bytes == NULL) {
+ if (n <= 0 || bytes == nullptr) {
return;
}
if (ignore_ > 0) {
@@ -63,7 +63,7 @@ SortKeyByteSink::GetAppendBuffer(int32_t min_capacity,
int32_t *result_capacity) {
if (min_capacity < 1 || scratch_capacity < min_capacity) {
*result_capacity = 0;
- return NULL;
+ return nullptr;
}
if (ignore_ > 0) {
// Do not write ignored bytes right at the end of the buffer.
@@ -90,10 +90,10 @@ namespace {
*/
class SortKeyLevel : public UMemory {
public:
- SortKeyLevel() : len(0), ok(TRUE) {}
+ SortKeyLevel() : len(0), ok(true) {}
~SortKeyLevel() {}
- /** @return FALSE if memory allocation failed */
+ /** @return false if memory allocation failed */
UBool isOk() const { return ok; }
UBool isEmpty() const { return len == 0; }
int32_t length() const { return len; }
@@ -182,7 +182,7 @@ SortKeyLevel::appendReverseWeight16(uint32_t w) {
UBool SortKeyLevel::ensureCapacity(int32_t appendCapacity) {
if(!ok) {
- return FALSE;
+ return false;
}
int32_t newCapacity = 2 * buffer.getCapacity();
int32_t altCapacity = len + 2 * appendCapacity;
@@ -192,10 +192,10 @@ UBool SortKeyLevel::ensureCapacity(int32_t appendCapacity) {
if (newCapacity < 200) {
newCapacity = 200;
}
- if(buffer.resize(newCapacity, len)==NULL) {
- return ok = FALSE;
+ if(buffer.resize(newCapacity, len)==nullptr) {
+ return ok = false;
}
- return TRUE;
+ return true;
}
} // namespace
@@ -203,7 +203,7 @@ UBool SortKeyLevel::ensureCapacity(int32_t appendCapacity) {
CollationKeys::LevelCallback::~LevelCallback() {}
UBool
-CollationKeys::LevelCallback::needToWrite(Collation::Level /*level*/) { return TRUE; }
+CollationKeys::LevelCallback::needToWrite(Collation::Level /*level*/) { return true; }
/**
* Map from collation strength (UColAttributeValue)
@@ -619,7 +619,7 @@ CollationKeys::writeSortKeyUpToQuaternary(CollationIterator &iter,
if(U_FAILURE(errorCode)) { return; }
// Append the beyond-primary levels.
- UBool ok = TRUE;
+ UBool ok = true;
if((levels & Collation::SECONDARY_LEVEL_FLAG) != 0) {
if(!callback.needToWrite(Collation::SECONDARY_LEVEL)) { return; }
ok &= secondaries.isOk();
diff --git a/contrib/libs/icu/i18n/collationkeys.h b/contrib/libs/icu/i18n/collationkeys.h
index 5b41d14c0b..d133156612 100644
--- a/contrib/libs/icu/i18n/collationkeys.h
+++ b/contrib/libs/icu/i18n/collationkeys.h
@@ -66,14 +66,14 @@ public:
UBool Overflowed() const { return appended_ > capacity_; }
/** @return false if memory allocation failed */
- UBool IsOk() const { return buffer_ != NULL; }
+ UBool IsOk() const { return buffer_ != nullptr; }
protected:
virtual void AppendBeyondCapacity(const char *bytes, int32_t n, int32_t length) = 0;
virtual UBool Resize(int32_t appendCapacity, int32_t length) = 0;
void SetNotOk() {
- buffer_ = NULL;
+ buffer_ = nullptr;
capacity_ = 0;
}
@@ -116,7 +116,7 @@ public:
private:
friend struct CollationDataReader;
- CollationKeys(); // no instantiation
+ CollationKeys() = delete; // no instantiation
// Secondary level: Compress up to 33 common weights as 05..25 or 25..45.
static const uint32_t SEC_COMMON_LOW = Collation::COMMON_BYTE;
diff --git a/contrib/libs/icu/i18n/collationroot.cpp b/contrib/libs/icu/i18n/collationroot.cpp
index 71753bd6f4..99686345f9 100644
--- a/contrib/libs/icu/i18n/collationroot.cpp
+++ b/contrib/libs/icu/i18n/collationroot.cpp
@@ -27,13 +27,14 @@
#include "ucln_in.h"
#include "udatamem.h"
#include "umutex.h"
+#include "umapfile.h"
U_NAMESPACE_BEGIN
namespace {
-static const CollationCacheEntry *rootSingleton = NULL;
-static UInitOnce initOnce = U_INITONCE_INITIALIZER;
+static const CollationCacheEntry *rootSingleton = nullptr;
+static UInitOnce initOnce {};
} // namespace
@@ -42,29 +43,58 @@ U_CDECL_BEGIN
static UBool U_CALLCONV uprv_collation_root_cleanup() {
SharedObject::clearPtr(rootSingleton);
initOnce.reset();
- return TRUE;
+ return true;
}
U_CDECL_END
+UDataMemory*
+CollationRoot::loadFromFile(const char* ucadataPath, UErrorCode &errorCode) {
+ UDataMemory dataMemory;
+ UDataMemory *rDataMem = nullptr;
+ if (U_FAILURE(errorCode)) {
+ return nullptr;
+ }
+ if (uprv_mapFile(&dataMemory, ucadataPath, &errorCode)) {
+ if (dataMemory.pHeader->dataHeader.magic1 == 0xda &&
+ dataMemory.pHeader->dataHeader.magic2 == 0x27 &&
+ CollationDataReader::isAcceptable(nullptr, "icu", "ucadata", &dataMemory.pHeader->info)) {
+ rDataMem = UDataMemory_createNewInstance(&errorCode);
+ if (U_FAILURE(errorCode)) {
+ return nullptr;
+ }
+ rDataMem->pHeader = dataMemory.pHeader;
+ rDataMem->mapAddr = dataMemory.mapAddr;
+ rDataMem->map = dataMemory.map;
+ return rDataMem;
+ }
+ errorCode = U_INVALID_FORMAT_ERROR;
+ return nullptr;
+ }
+ errorCode = U_MISSING_RESOURCE_ERROR;
+ return nullptr;
+}
+
void U_CALLCONV
-CollationRoot::load(UErrorCode &errorCode) {
+CollationRoot::load(const char* ucadataPath, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
- LocalPointer<CollationTailoring> t(new CollationTailoring(NULL));
+ LocalPointer<CollationTailoring> t(new CollationTailoring(nullptr));
if(t.isNull() || t->isBogus()) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
- t->memory = udata_openChoice(U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "coll",
- "icu", "ucadata",
- CollationDataReader::isAcceptable, t->version, &errorCode);
+ t->memory = ucadataPath ? CollationRoot::loadFromFile(ucadataPath, errorCode) :
+ udata_openChoice(U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "coll",
+ "icu", "ucadata",
+ CollationDataReader::isAcceptable,
+ t->version, &errorCode);
if(U_FAILURE(errorCode)) { return; }
const uint8_t *inBytes = static_cast<const uint8_t *>(udata_getMemory(t->memory));
- CollationDataReader::read(NULL, inBytes, udata_getLength(t->memory), *t, errorCode);
+ CollationDataReader::read(nullptr, inBytes, udata_getLength(t->memory), *t, errorCode);
if(U_FAILURE(errorCode)) { return; }
ucln_i18n_registerCleanup(UCLN_I18N_COLLATION_ROOT, uprv_collation_root_cleanup);
CollationCacheEntry *entry = new CollationCacheEntry(Locale::getRoot(), t.getAlias());
- if(entry != NULL) {
+ if(entry != nullptr) {
t.orphan(); // The rootSingleton took ownership of the tailoring.
entry->addRef();
rootSingleton = entry;
@@ -73,32 +103,38 @@ CollationRoot::load(UErrorCode &errorCode) {
const CollationCacheEntry *
CollationRoot::getRootCacheEntry(UErrorCode &errorCode) {
- umtx_initOnce(initOnce, CollationRoot::load, errorCode);
- if(U_FAILURE(errorCode)) { return NULL; }
+ umtx_initOnce(initOnce, CollationRoot::load, static_cast<const char*>(nullptr), errorCode);
+ if(U_FAILURE(errorCode)) { return nullptr; }
return rootSingleton;
}
const CollationTailoring *
CollationRoot::getRoot(UErrorCode &errorCode) {
- umtx_initOnce(initOnce, CollationRoot::load, errorCode);
- if(U_FAILURE(errorCode)) { return NULL; }
+ umtx_initOnce(initOnce, CollationRoot::load, static_cast<const char*>(nullptr), errorCode);
+ if(U_FAILURE(errorCode)) { return nullptr; }
return rootSingleton->tailoring;
}
const CollationData *
CollationRoot::getData(UErrorCode &errorCode) {
const CollationTailoring *root = getRoot(errorCode);
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
return root->data;
}
const CollationSettings *
CollationRoot::getSettings(UErrorCode &errorCode) {
const CollationTailoring *root = getRoot(errorCode);
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
return root->settings;
}
+void
+CollationRoot::forceLoadFromFile(const char* ucadataPath, UErrorCode &errorCode) {
+ umtx_initOnce(initOnce, CollationRoot::load, ucadataPath, errorCode);
+}
+
+
U_NAMESPACE_END
#endif // !UCONFIG_NO_COLLATION
diff --git a/contrib/libs/icu/i18n/collationroot.h b/contrib/libs/icu/i18n/collationroot.h
index 8cd3046cdf..b203f612b3 100644
--- a/contrib/libs/icu/i18n/collationroot.h
+++ b/contrib/libs/icu/i18n/collationroot.h
@@ -15,6 +15,7 @@
#define __COLLATIONROOT_H__
#include "unicode/utypes.h"
+#include "unicode/udata.h"
#if !UCONFIG_NO_COLLATION
@@ -34,9 +35,11 @@ public:
static const CollationTailoring *getRoot(UErrorCode &errorCode);
static const CollationData *getData(UErrorCode &errorCode);
static const CollationSettings *getSettings(UErrorCode &errorCode);
+ static void U_EXPORT2 forceLoadFromFile(const char* ucadataPath, UErrorCode &errorCode);
private:
- static void U_CALLCONV load(UErrorCode &errorCode);
+ static void U_CALLCONV load(const char* ucadataPath, UErrorCode &errorCode);
+ static UDataMemory* loadFromFile(const char* ucadataPath, UErrorCode &errorCode);
};
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/collationruleparser.cpp b/contrib/libs/icu/i18n/collationruleparser.cpp
index ade6ecb552..4cc25a1f5c 100644
--- a/contrib/libs/icu/i18n/collationruleparser.cpp
+++ b/contrib/libs/icu/i18n/collationruleparser.cpp
@@ -40,7 +40,7 @@ U_NAMESPACE_BEGIN
namespace {
-static const UChar BEFORE[] = { 0x5b, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0 }; // "[before"
+static const char16_t BEFORE[] = { 0x5b, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0 }; // "[before"
const int32_t BEFORE_LENGTH = 7;
} // namespace
@@ -58,9 +58,9 @@ CollationRuleParser::Importer::~Importer() {}
CollationRuleParser::CollationRuleParser(const CollationData *base, UErrorCode &errorCode)
: nfd(*Normalizer2::getNFDInstance(errorCode)),
nfc(*Normalizer2::getNFCInstance(errorCode)),
- rules(NULL), baseData(base), settings(NULL),
- parseError(NULL), errorReason(NULL),
- sink(NULL), importer(NULL),
+ rules(nullptr), baseData(base), settings(nullptr),
+ parseError(nullptr), errorReason(nullptr),
+ sink(nullptr), importer(nullptr),
ruleIndex(0) {
}
@@ -75,13 +75,13 @@ CollationRuleParser::parse(const UnicodeString &ruleString,
if(U_FAILURE(errorCode)) { return; }
settings = &outSettings;
parseError = outParseError;
- if(parseError != NULL) {
+ if(parseError != nullptr) {
parseError->line = 0;
parseError->offset = -1;
parseError->preContext[0] = 0;
parseError->postContext[0] = 0;
}
- errorReason = NULL;
+ errorReason = nullptr;
parse(ruleString, errorCode);
}
@@ -92,7 +92,7 @@ CollationRuleParser::parse(const UnicodeString &ruleString, UErrorCode &errorCod
ruleIndex = 0;
while(ruleIndex < rules->length()) {
- UChar c = rules->charAt(ruleIndex);
+ char16_t c = rules->charAt(ruleIndex);
if(PatternProps::isWhiteSpace(c)) {
++ruleIndex;
continue;
@@ -128,7 +128,7 @@ CollationRuleParser::parse(const UnicodeString &ruleString, UErrorCode &errorCod
void
CollationRuleParser::parseRuleChain(UErrorCode &errorCode) {
int32_t resetStrength = parseResetAndPosition(errorCode);
- UBool isFirstRelation = TRUE;
+ UBool isFirstRelation = true;
for(;;) {
int32_t result = parseRelationOperator(errorCode);
if(U_FAILURE(errorCode)) { return; }
@@ -165,7 +165,7 @@ CollationRuleParser::parseRuleChain(UErrorCode &errorCode) {
parseStarredCharacters(strength, i, errorCode);
}
if(U_FAILURE(errorCode)) { return; }
- isFirstRelation = FALSE;
+ isFirstRelation = false;
}
}
@@ -174,7 +174,7 @@ CollationRuleParser::parseResetAndPosition(UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return UCOL_DEFAULT; }
int32_t i = skipWhiteSpace(ruleIndex + 1);
int32_t j;
- UChar c;
+ char16_t c;
int32_t resetStrength;
if(rules->compare(i, BEFORE_LENGTH, BEFORE, 0, BEFORE_LENGTH) == 0 &&
(j = i + BEFORE_LENGTH) < rules->length() &&
@@ -211,7 +211,7 @@ CollationRuleParser::parseRelationOperator(UErrorCode &errorCode) {
if(ruleIndex >= rules->length()) { return UCOL_DEFAULT; }
int32_t strength;
int32_t i = ruleIndex;
- UChar c = rules->charAt(i++);
+ char16_t c = rules->charAt(i++);
switch(c) {
case 0x3c: // '<'
if(i < rules->length() && rules->charAt(i) == 0x3c) { // <<
@@ -262,7 +262,7 @@ CollationRuleParser::parseRelationStrings(int32_t strength, int32_t i, UErrorCod
UnicodeString prefix, str, extension;
i = parseTailoringString(i, str, errorCode);
if(U_FAILURE(errorCode)) { return; }
- UChar next = (i < rules->length()) ? rules->charAt(i) : 0;
+ char16_t next = (i < rules->length()) ? rules->charAt(i) : 0;
if(next == 0x7c) { // '|' separates the context prefix from the string.
prefix = str;
i = parseTailoringString(i + 1, str, errorCode);
@@ -377,7 +377,7 @@ CollationRuleParser::parseString(int32_t i, UnicodeString &raw, UErrorCode &erro
if(c == 0x27) { // apostrophe
if(i < rules->length() && rules->charAt(i) == 0x27) {
// Double apostrophe, encodes a single one.
- raw.append((UChar)0x27);
+ raw.append((char16_t)0x27);
++i;
continue;
}
@@ -397,7 +397,7 @@ CollationRuleParser::parseString(int32_t i, UnicodeString &raw, UErrorCode &erro
break;
}
}
- raw.append((UChar)c);
+ raw.append((char16_t)c);
}
} else if(c == 0x5c) { // backslash
if(i == rules->length()) {
@@ -417,7 +417,7 @@ CollationRuleParser::parseString(int32_t i, UnicodeString &raw, UErrorCode &erro
--i;
break;
} else {
- raw.append((UChar)c);
+ raw.append((char16_t)c);
}
}
for(int32_t j = 0; j < raw.length();) {
@@ -465,16 +465,16 @@ CollationRuleParser::parseSpecialPosition(int32_t i, UnicodeString &str, UErrorC
++j;
for(int32_t pos = 0; pos < UPRV_LENGTHOF(positions); ++pos) {
if(raw == UnicodeString(positions[pos], -1, US_INV)) {
- str.setTo((UChar)POS_LEAD).append((UChar)(POS_BASE + pos));
+ str.setTo((char16_t)POS_LEAD).append((char16_t)(POS_BASE + pos));
return j;
}
}
if(raw == UNICODE_STRING_SIMPLE("top")) {
- str.setTo((UChar)POS_LEAD).append((UChar)(POS_BASE + LAST_REGULAR));
+ str.setTo((char16_t)POS_LEAD).append((char16_t)(POS_BASE + LAST_REGULAR));
return j;
}
if(raw == UNICODE_STRING_SIMPLE("variable top")) {
- str.setTo((UChar)POS_LEAD).append((UChar)(POS_BASE + LAST_VARIABLE));
+ str.setTo((char16_t)POS_LEAD).append((char16_t)(POS_BASE + LAST_VARIABLE));
return j;
}
}
@@ -506,14 +506,14 @@ CollationRuleParser::parseSetting(UErrorCode &errorCode) {
return;
}
UnicodeString v;
- int32_t valueIndex = raw.lastIndexOf((UChar)0x20);
+ int32_t valueIndex = raw.lastIndexOf((char16_t)0x20);
if(valueIndex >= 0) {
v.setTo(raw, valueIndex + 1);
raw.truncate(valueIndex);
}
if(raw == UNICODE_STRING_SIMPLE("strength") && v.length() == 1) {
int32_t value = UCOL_DEFAULT;
- UChar c = v.charAt(0);
+ char16_t c = v.charAt(0);
if(0x31 <= c && c <= 0x34) { // 1..4
value = UCOL_PRIMARY + (c - 0x31);
} else if(c == 0x49) { // 'I'
@@ -638,14 +638,14 @@ CollationRuleParser::parseSetting(UErrorCode &errorCode) {
setParseError("expected language tag in [import langTag]", errorCode);
return;
}
- if(importer == NULL) {
+ if(importer == nullptr) {
setParseError("[import langTag] is not supported", errorCode);
} else {
UnicodeString importedRules;
importer->getRules(baseID, length > 0 ? collationType : "standard",
importedRules, errorReason, errorCode);
if(U_FAILURE(errorCode)) {
- if(errorReason == NULL) {
+ if(errorReason == nullptr) {
errorReason = "[import langTag] failed";
}
setErrorContext();
@@ -655,7 +655,7 @@ CollationRuleParser::parseSetting(UErrorCode &errorCode) {
int32_t outerRuleIndex = ruleIndex;
parse(importedRules, errorCode);
if(U_FAILURE(errorCode)) {
- if(parseError != NULL) {
+ if(parseError != nullptr) {
parseError->offset = outerRuleIndex;
}
}
@@ -698,7 +698,7 @@ CollationRuleParser::parseReordering(const UnicodeString &raw, UErrorCode &error
CharString word;
while(i < raw.length()) {
++i; // skip the word-separating space
- int32_t limit = raw.indexOf((UChar)0x20, i);
+ int32_t limit = raw.indexOf((char16_t)0x20, i);
if(limit < 0) { limit = raw.length(); }
word.clear().appendInvariantChars(raw.tempSubStringBetween(i, limit), errorCode);
if(U_FAILURE(errorCode)) { return; }
@@ -756,7 +756,7 @@ CollationRuleParser::parseUnicodeSet(int32_t i, UnicodeSet &set, UErrorCode &err
setParseError("unbalanced UnicodeSet pattern brackets", errorCode);
return j;
}
- UChar c = rules->charAt(j++);
+ char16_t c = rules->charAt(j++);
if(c == 0x5b) { // '['
++level;
} else if(c == 0x5d) { // ']'
@@ -779,12 +779,12 @@ CollationRuleParser::parseUnicodeSet(int32_t i, UnicodeSet &set, UErrorCode &err
int32_t
CollationRuleParser::readWords(int32_t i, UnicodeString &raw) const {
- static const UChar sp = 0x20;
+ static const char16_t sp = 0x20;
raw.remove();
i = skipWhiteSpace(i);
for(;;) {
if(i >= rules->length()) { return 0; }
- UChar c = rules->charAt(i);
+ char16_t c = rules->charAt(i);
if(isSyntaxChar(c) && c != 0x2d && c != 0x5f) { // syntax except -_
if(raw.isEmpty()) { return i; }
if(raw.endsWith(&sp, 1)) { // remove trailing space
@@ -806,7 +806,7 @@ int32_t
CollationRuleParser::skipComment(int32_t i) const {
// skip to past the newline
while(i < rules->length()) {
- UChar c = rules->charAt(i++);
+ char16_t c = rules->charAt(i++);
// LF or FF or CR or NEL or LS or PS
if(c == 0xa || c == 0xc || c == 0xd || c == 0x85 || c == 0x2028 || c == 0x2029) {
// Unicode Newline Guidelines: "A readline function should stop at NLF, LS, FF, or PS."
@@ -825,12 +825,12 @@ CollationRuleParser::setParseError(const char *reason, UErrorCode &errorCode) {
// rather than U_PARSE_ERROR;
errorCode = U_INVALID_FORMAT_ERROR;
errorReason = reason;
- if(parseError != NULL) { setErrorContext(); }
+ if(parseError != nullptr) { setErrorContext(); }
}
void
CollationRuleParser::setErrorContext() {
- if(parseError == NULL) { return; }
+ if(parseError == nullptr) { return; }
// Note: This relies on the calling code maintaining the ruleIndex
// at a position that is useful for debugging.
diff --git a/contrib/libs/icu/i18n/collationruleparser.h b/contrib/libs/icu/i18n/collationruleparser.h
index e124881fcf..aabdf03f57 100644
--- a/contrib/libs/icu/i18n/collationruleparser.h
+++ b/contrib/libs/icu/i18n/collationruleparser.h
@@ -60,13 +60,13 @@ public:
*
* The second contraction character is POS_BASE + Position.
*/
- static const UChar POS_LEAD = 0xfffe;
+ static const char16_t POS_LEAD = 0xfffe;
/**
* Base for the second character of contractions that encode special reset positions.
* Braille characters U+28xx are printable and normalization-inert.
* @see POS_LEAD
*/
- static const UChar POS_BASE = 0x2800;
+ static const char16_t POS_BASE = 0x2800;
class U_I18N_API Sink : public UObject {
public:
diff --git a/contrib/libs/icu/i18n/collationsets.cpp b/contrib/libs/icu/i18n/collationsets.cpp
index 09581416a8..62e6a5d180 100644
--- a/contrib/libs/icu/i18n/collationsets.cpp
+++ b/contrib/libs/icu/i18n/collationsets.cpp
@@ -34,7 +34,7 @@ U_CDECL_BEGIN
static UBool U_CALLCONV
enumTailoredRange(const void *context, UChar32 start, UChar32 end, uint32_t ce32) {
if(ce32 == Collation::FALLBACK_CE32) {
- return TRUE; // fallback to base, not tailored
+ return true; // fallback to base, not tailored
}
TailoredSet *ts = (TailoredSet *)context;
return ts->handleCE32(start, end, ce32);
@@ -48,8 +48,8 @@ TailoredSet::forData(const CollationData *d, UErrorCode &ec) {
errorCode = ec; // Preserve info & warning codes.
data = d;
baseData = d->base;
- U_ASSERT(baseData != NULL);
- utrie2_enum(data->trie, NULL, enumTailoredRange, this);
+ U_ASSERT(baseData != nullptr);
+ utrie2_enum(data->trie, nullptr, enumTailoredRange, this);
ec = errorCode;
}
@@ -82,30 +82,30 @@ TailoredSet::handleCE32(UChar32 start, UChar32 end, uint32_t ce32) {
void
TailoredSet::compare(UChar32 c, uint32_t ce32, uint32_t baseCE32) {
if(Collation::isPrefixCE32(ce32)) {
- const UChar *p = data->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = data->contexts + Collation::indexFromCE32(ce32);
ce32 = data->getFinalCE32(CollationData::readCE32(p));
if(Collation::isPrefixCE32(baseCE32)) {
- const UChar *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
+ const char16_t *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
baseCE32 = baseData->getFinalCE32(CollationData::readCE32(q));
comparePrefixes(c, p + 2, q + 2);
} else {
addPrefixes(data, c, p + 2);
}
} else if(Collation::isPrefixCE32(baseCE32)) {
- const UChar *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
+ const char16_t *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
baseCE32 = baseData->getFinalCE32(CollationData::readCE32(q));
addPrefixes(baseData, c, q + 2);
}
if(Collation::isContractionCE32(ce32)) {
- const UChar *p = data->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = data->contexts + Collation::indexFromCE32(ce32);
if((ce32 & Collation::CONTRACT_SINGLE_CP_NO_MATCH) != 0) {
ce32 = Collation::NO_CE32;
} else {
ce32 = data->getFinalCE32(CollationData::readCE32(p));
}
if(Collation::isContractionCE32(baseCE32)) {
- const UChar *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
+ const char16_t *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
if((baseCE32 & Collation::CONTRACT_SINGLE_CP_NO_MATCH) != 0) {
baseCE32 = Collation::NO_CE32;
} else {
@@ -116,7 +116,7 @@ TailoredSet::compare(UChar32 c, uint32_t ce32, uint32_t baseCE32) {
addContractions(c, p + 2);
}
} else if(Collation::isContractionCE32(baseCE32)) {
- const UChar *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
+ const char16_t *q = baseData->contexts + Collation::indexFromCE32(baseCE32);
baseCE32 = baseData->getFinalCE32(CollationData::readCE32(q));
addContractions(c, q + 2);
}
@@ -202,7 +202,7 @@ TailoredSet::compare(UChar32 c, uint32_t ce32, uint32_t baseCE32) {
}
}
} else if(tag == Collation::HANGUL_TAG) {
- UChar jamos[3];
+ char16_t jamos[3];
int32_t length = Hangul::decompose(c, jamos);
if(tailored->contains(jamos[0]) || tailored->contains(jamos[1]) ||
(length == 3 && tailored->contains(jamos[2]))) {
@@ -214,24 +214,24 @@ TailoredSet::compare(UChar32 c, uint32_t ce32, uint32_t baseCE32) {
}
void
-TailoredSet::comparePrefixes(UChar32 c, const UChar *p, const UChar *q) {
+TailoredSet::comparePrefixes(UChar32 c, const char16_t *p, const char16_t *q) {
// Parallel iteration over prefixes of both tables.
UCharsTrie::Iterator prefixes(p, 0, errorCode);
UCharsTrie::Iterator basePrefixes(q, 0, errorCode);
- const UnicodeString *tp = NULL; // Tailoring prefix.
- const UnicodeString *bp = NULL; // Base prefix.
+ const UnicodeString *tp = nullptr; // Tailoring prefix.
+ const UnicodeString *bp = nullptr; // Base prefix.
// Use a string with a U+FFFF as the limit sentinel.
// U+FFFF is untailorable and will not occur in prefixes.
- UnicodeString none((UChar)0xffff);
+ UnicodeString none((char16_t)0xffff);
for(;;) {
- if(tp == NULL) {
+ if(tp == nullptr) {
if(prefixes.next(errorCode)) {
tp = &prefixes.getString();
} else {
tp = &none;
}
}
- if(bp == NULL) {
+ if(bp == nullptr) {
if(basePrefixes.next(errorCode)) {
bp = &basePrefixes.getString();
} else {
@@ -243,42 +243,42 @@ TailoredSet::comparePrefixes(UChar32 c, const UChar *p, const UChar *q) {
if(cmp < 0) {
// tp occurs in the tailoring but not in the base.
addPrefix(data, *tp, c, (uint32_t)prefixes.getValue());
- tp = NULL;
+ tp = nullptr;
} else if(cmp > 0) {
// bp occurs in the base but not in the tailoring.
addPrefix(baseData, *bp, c, (uint32_t)basePrefixes.getValue());
- bp = NULL;
+ bp = nullptr;
} else {
setPrefix(*tp);
compare(c, (uint32_t)prefixes.getValue(), (uint32_t)basePrefixes.getValue());
resetPrefix();
- tp = NULL;
- bp = NULL;
+ tp = nullptr;
+ bp = nullptr;
}
}
}
void
-TailoredSet::compareContractions(UChar32 c, const UChar *p, const UChar *q) {
+TailoredSet::compareContractions(UChar32 c, const char16_t *p, const char16_t *q) {
// Parallel iteration over suffixes of both tables.
UCharsTrie::Iterator suffixes(p, 0, errorCode);
UCharsTrie::Iterator baseSuffixes(q, 0, errorCode);
- const UnicodeString *ts = NULL; // Tailoring suffix.
- const UnicodeString *bs = NULL; // Base suffix.
+ const UnicodeString *ts = nullptr; // Tailoring suffix.
+ const UnicodeString *bs = nullptr; // Base suffix.
// Use a string with two U+FFFF as the limit sentinel.
// U+FFFF is untailorable and will not occur in contractions except maybe
// as a single suffix character for a root-collator boundary contraction.
- UnicodeString none((UChar)0xffff);
- none.append((UChar)0xffff);
+ UnicodeString none((char16_t)0xffff);
+ none.append((char16_t)0xffff);
for(;;) {
- if(ts == NULL) {
+ if(ts == nullptr) {
if(suffixes.next(errorCode)) {
ts = &suffixes.getString();
} else {
ts = &none;
}
}
- if(bs == NULL) {
+ if(bs == nullptr) {
if(baseSuffixes.next(errorCode)) {
bs = &baseSuffixes.getString();
} else {
@@ -290,23 +290,23 @@ TailoredSet::compareContractions(UChar32 c, const UChar *p, const UChar *q) {
if(cmp < 0) {
// ts occurs in the tailoring but not in the base.
addSuffix(c, *ts);
- ts = NULL;
+ ts = nullptr;
} else if(cmp > 0) {
// bs occurs in the base but not in the tailoring.
addSuffix(c, *bs);
- bs = NULL;
+ bs = nullptr;
} else {
suffix = ts;
compare(c, (uint32_t)suffixes.getValue(), (uint32_t)baseSuffixes.getValue());
- suffix = NULL;
- ts = NULL;
- bs = NULL;
+ suffix = nullptr;
+ ts = nullptr;
+ bs = nullptr;
}
}
}
void
-TailoredSet::addPrefixes(const CollationData *d, UChar32 c, const UChar *p) {
+TailoredSet::addPrefixes(const CollationData *d, UChar32 c, const char16_t *p) {
UCharsTrie::Iterator prefixes(p, 0, errorCode);
while(prefixes.next(errorCode)) {
addPrefix(d, prefixes.getString(), c, (uint32_t)prefixes.getValue());
@@ -318,7 +318,7 @@ TailoredSet::addPrefix(const CollationData *d, const UnicodeString &pfx, UChar32
setPrefix(pfx);
ce32 = d->getFinalCE32(ce32);
if(Collation::isContractionCE32(ce32)) {
- const UChar *p = d->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = d->contexts + Collation::indexFromCE32(ce32);
addContractions(c, p + 2);
}
tailored->add(UnicodeString(unreversedPrefix).append(c));
@@ -326,7 +326,7 @@ TailoredSet::addPrefix(const CollationData *d, const UnicodeString &pfx, UChar32
}
void
-TailoredSet::addContractions(UChar32 c, const UChar *p) {
+TailoredSet::addContractions(UChar32 c, const char16_t *p) {
UCharsTrie::Iterator suffixes(p, 0, errorCode);
while(suffixes.next(errorCode)) {
addSuffix(c, suffixes.getString());
@@ -340,12 +340,12 @@ TailoredSet::addSuffix(UChar32 c, const UnicodeString &sfx) {
void
TailoredSet::add(UChar32 c) {
- if(unreversedPrefix.isEmpty() && suffix == NULL) {
+ if(unreversedPrefix.isEmpty() && suffix == nullptr) {
tailored->add(c);
} else {
UnicodeString s(unreversedPrefix);
s.append(c);
- if(suffix != NULL) {
+ if(suffix != nullptr) {
s.append(*suffix);
}
tailored->add(s);
@@ -365,14 +365,14 @@ enumCnERange(const void *context, UChar32 start, UChar32 end, uint32_t ce32) {
} else if(cne->checkTailored < 0) {
// Collect the set of code points with mappings in the tailoring data.
if(ce32 == Collation::FALLBACK_CE32) {
- return TRUE; // fallback to base, not tailored
+ return true; // fallback to base, not tailored
} else {
cne->tailored.add(start, end);
}
// checkTailored > 0: Exclude tailored ranges from the base data enumeration.
} else if(start == end) {
if(cne->tailored.contains(start)) {
- return TRUE;
+ return true;
}
} else if(cne->tailored.containsSome(start, end)) {
cne->ranges.set(start, end).removeAll(cne->tailored);
@@ -393,12 +393,12 @@ ContractionsAndExpansions::forData(const CollationData *d, UErrorCode &ec) {
if(U_FAILURE(ec)) { return; }
errorCode = ec; // Preserve info & warning codes.
// Add all from the data, can be tailoring or base.
- if(d->base != NULL) {
+ if(d->base != nullptr) {
checkTailored = -1;
}
data = d;
- utrie2_enum(data->trie, NULL, enumCnERange, this);
- if(d->base == NULL || U_FAILURE(errorCode)) {
+ utrie2_enum(data->trie, nullptr, enumCnERange, this);
+ if(d->base == nullptr || U_FAILURE(errorCode)) {
ec = errorCode;
return;
}
@@ -406,7 +406,7 @@ ContractionsAndExpansions::forData(const CollationData *d, UErrorCode &ec) {
tailored.freeze();
checkTailored = 1;
data = d->base;
- utrie2_enum(data->trie, NULL, enumCnERange, this);
+ utrie2_enum(data->trie, nullptr, enumCnERange, this);
ec = errorCode;
}
@@ -429,7 +429,7 @@ ContractionsAndExpansions::handleCE32(UChar32 start, UChar32 end, uint32_t ce32)
for(;;) {
if((ce32 & 0xff) < Collation::SPECIAL_CE32_LOW_BYTE) {
// !isSpecialCE32()
- if(sink != NULL) {
+ if(sink != nullptr) {
sink->handleCE(Collation::ceFromSimpleCE32(ce32));
}
return;
@@ -443,17 +443,17 @@ ContractionsAndExpansions::handleCE32(UChar32 start, UChar32 end, uint32_t ce32)
if(U_SUCCESS(errorCode)) { errorCode = U_INTERNAL_PROGRAM_ERROR; }
return;
case Collation::LONG_PRIMARY_TAG:
- if(sink != NULL) {
+ if(sink != nullptr) {
sink->handleCE(Collation::ceFromLongPrimaryCE32(ce32));
}
return;
case Collation::LONG_SECONDARY_TAG:
- if(sink != NULL) {
+ if(sink != nullptr) {
sink->handleCE(Collation::ceFromLongSecondaryCE32(ce32));
}
return;
case Collation::LATIN_EXPANSION_TAG:
- if(sink != NULL) {
+ if(sink != nullptr) {
ces[0] = Collation::latinCE0FromCE32(ce32);
ces[1] = Collation::latinCE1FromCE32(ce32);
sink->handleExpansion(ces, 2);
@@ -465,7 +465,7 @@ ContractionsAndExpansions::handleCE32(UChar32 start, UChar32 end, uint32_t ce32)
}
return;
case Collation::EXPANSION32_TAG:
- if(sink != NULL) {
+ if(sink != nullptr) {
const uint32_t *ce32s = data->ce32s + Collation::indexFromCE32(ce32);
int32_t length = Collation::lengthFromCE32(ce32);
for(int32_t i = 0; i < length; ++i) {
@@ -480,7 +480,7 @@ ContractionsAndExpansions::handleCE32(UChar32 start, UChar32 end, uint32_t ce32)
}
return;
case Collation::EXPANSION_TAG:
- if(sink != NULL) {
+ if(sink != nullptr) {
int32_t length = Collation::lengthFromCE32(ce32);
sink->handleExpansion(data->ces + Collation::indexFromCE32(ce32), length);
}
@@ -506,13 +506,13 @@ ContractionsAndExpansions::handleCE32(UChar32 start, UChar32 end, uint32_t ce32)
ce32 = data->ce32s[0];
break;
case Collation::HANGUL_TAG:
- if(sink != NULL) {
+ if(sink != nullptr) {
// TODO: This should be optimized,
// especially if [start..end] is the complete Hangul range. (assert that)
- UTF16CollationIterator iter(data, FALSE, NULL, NULL, NULL);
- UChar hangul[1] = { 0 };
+ UTF16CollationIterator iter(data, false, nullptr, nullptr, nullptr);
+ char16_t hangul[1] = { 0 };
for(UChar32 c = start; c <= end; ++c) {
- hangul[0] = (UChar)c;
+ hangul[0] = (char16_t)c;
iter.setText(hangul, hangul + 1);
int32_t length = iter.fetchCEs(errorCode);
if(U_FAILURE(errorCode)) { return; }
@@ -540,7 +540,7 @@ ContractionsAndExpansions::handleCE32(UChar32 start, UChar32 end, uint32_t ce32)
void
ContractionsAndExpansions::handlePrefixes(
UChar32 start, UChar32 end, uint32_t ce32) {
- const UChar *p = data->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = data->contexts + Collation::indexFromCE32(ce32);
ce32 = CollationData::readCE32(p); // Default if no prefix match.
handleCE32(start, end, ce32);
if(!addPrefixes) { return; }
@@ -559,7 +559,7 @@ ContractionsAndExpansions::handlePrefixes(
void
ContractionsAndExpansions::handleContractions(
UChar32 start, UChar32 end, uint32_t ce32) {
- const UChar *p = data->contexts + Collation::indexFromCE32(ce32);
+ const char16_t *p = data->contexts + Collation::indexFromCE32(ce32);
if((ce32 & Collation::CONTRACT_SINGLE_CP_NO_MATCH) != 0) {
// No match on the single code point.
// We are underneath a prefix, and the default mapping is just
@@ -579,13 +579,13 @@ ContractionsAndExpansions::handleContractions(
}
handleCE32(start, end, (uint32_t)suffixes.getValue());
}
- suffix = NULL;
+ suffix = nullptr;
}
void
ContractionsAndExpansions::addExpansions(UChar32 start, UChar32 end) {
- if(unreversedPrefix.isEmpty() && suffix == NULL) {
- if(expansions != NULL) {
+ if(unreversedPrefix.isEmpty() && suffix == nullptr) {
+ if(expansions != nullptr) {
expansions->add(start, end);
}
} else {
@@ -595,11 +595,11 @@ ContractionsAndExpansions::addExpansions(UChar32 start, UChar32 end) {
void
ContractionsAndExpansions::addStrings(UChar32 start, UChar32 end, UnicodeSet *set) {
- if(set == NULL) { return; }
+ if(set == nullptr) { return; }
UnicodeString s(unreversedPrefix);
do {
s.append(start);
- if(suffix != NULL) {
+ if(suffix != nullptr) {
s.append(*suffix);
}
set->add(s);
diff --git a/contrib/libs/icu/i18n/collationsets.h b/contrib/libs/icu/i18n/collationsets.h
index aed41f7ac8..99aa194e76 100644
--- a/contrib/libs/icu/i18n/collationsets.h
+++ b/contrib/libs/icu/i18n/collationsets.h
@@ -43,9 +43,9 @@ struct CollationData;
class TailoredSet : public UMemory {
public:
TailoredSet(UnicodeSet *t)
- : data(NULL), baseData(NULL),
+ : data(nullptr), baseData(nullptr),
tailored(t),
- suffix(NULL),
+ suffix(nullptr),
errorCode(U_ZERO_ERROR) {}
void forData(const CollationData *d, UErrorCode &errorCode);
@@ -58,12 +58,12 @@ public:
private:
void compare(UChar32 c, uint32_t ce32, uint32_t baseCE32);
- void comparePrefixes(UChar32 c, const UChar *p, const UChar *q);
- void compareContractions(UChar32 c, const UChar *p, const UChar *q);
+ void comparePrefixes(UChar32 c, const char16_t *p, const char16_t *q);
+ void compareContractions(UChar32 c, const char16_t *p, const char16_t *q);
- void addPrefixes(const CollationData *d, UChar32 c, const UChar *p);
+ void addPrefixes(const CollationData *d, UChar32 c, const char16_t *p);
void addPrefix(const CollationData *d, const UnicodeString &pfx, UChar32 c, uint32_t ce32);
- void addContractions(UChar32 c, const UChar *p);
+ void addContractions(UChar32 c, const char16_t *p);
void addSuffix(UChar32 c, const UnicodeString &sfx);
void add(UChar32 c);
@@ -94,12 +94,12 @@ public:
};
ContractionsAndExpansions(UnicodeSet *con, UnicodeSet *exp, CESink *s, UBool prefixes)
- : data(NULL),
+ : data(nullptr),
contractions(con), expansions(exp),
sink(s),
addPrefixes(prefixes),
checkTailored(0),
- suffix(NULL),
+ suffix(nullptr),
errorCode(U_ZERO_ERROR) {}
void forData(const CollationData *d, UErrorCode &errorCode);
diff --git a/contrib/libs/icu/i18n/collationsettings.cpp b/contrib/libs/icu/i18n/collationsettings.cpp
index 9eeab48331..1533daf38c 100644
--- a/contrib/libs/icu/i18n/collationsettings.cpp
+++ b/contrib/libs/icu/i18n/collationsettings.cpp
@@ -30,10 +30,10 @@ U_NAMESPACE_BEGIN
CollationSettings::CollationSettings(const CollationSettings &other)
: SharedObject(other),
options(other.options), variableTop(other.variableTop),
- reorderTable(NULL),
+ reorderTable(nullptr),
minHighNoReorder(other.minHighNoReorder),
- reorderRanges(NULL), reorderRangesLength(0),
- reorderCodes(NULL), reorderCodesLength(0), reorderCodesCapacity(0),
+ reorderRanges(nullptr), reorderRangesLength(0),
+ reorderCodes(nullptr), reorderCodesLength(0), reorderCodesCapacity(0),
fastLatinOptions(other.fastLatinOptions) {
UErrorCode errorCode = U_ZERO_ERROR;
copyReorderingFrom(other, errorCode);
@@ -72,10 +72,10 @@ CollationSettings::hashCode() const {
void
CollationSettings::resetReordering() {
- // When we turn off reordering, we want to set a NULL permutation
+ // When we turn off reordering, we want to set a nullptr permutation
// rather than a no-op permutation.
// Keep the memory via reorderCodes and its capacity.
- reorderTable = NULL;
+ reorderTable = nullptr;
minHighNoReorder = 0;
reorderRangesLength = 0;
reorderCodesLength = 0;
@@ -86,7 +86,7 @@ CollationSettings::aliasReordering(const CollationData &data, const int32_t *cod
const uint32_t *ranges, int32_t rangesLength,
const uint8_t *table, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
- if(table != NULL &&
+ if(table != nullptr &&
(rangesLength == 0 ?
!reorderTableHasSplitBytes(table) :
rangesLength >= 2 &&
@@ -111,7 +111,7 @@ CollationSettings::aliasReordering(const CollationData &data, const int32_t *cod
if(firstSplitByteRangeIndex == rangesLength) {
U_ASSERT(!reorderTableHasSplitBytes(table));
minHighNoReorder = 0;
- reorderRanges = NULL;
+ reorderRanges = nullptr;
reorderRangesLength = 0;
} else {
U_ASSERT(table[ranges[firstSplitByteRangeIndex] >> 24] == 0);
@@ -201,7 +201,7 @@ CollationSettings::setReorderArrays(const int32_t *codes, int32_t codesLength,
// Allocate one memory block for the codes, the ranges, and the 16-aligned table.
int32_t capacity = (totalLength + 3) & ~3; // round up to a multiple of 4 ints
ownedCodes = (int32_t *)uprv_malloc(capacity * 4 + 256);
- if(ownedCodes == NULL) {
+ if(ownedCodes == nullptr) {
resetReordering();
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -248,10 +248,10 @@ CollationSettings::reorderTableHasSplitBytes(const uint8_t table[256]) {
U_ASSERT(table[0] == 0);
for(int32_t i = 1; i < 256; ++i) {
if(table[i] == 0) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
uint32_t
diff --git a/contrib/libs/icu/i18n/collationsettings.h b/contrib/libs/icu/i18n/collationsettings.h
index 3da8f6214f..43a181211c 100644
--- a/contrib/libs/icu/i18n/collationsettings.h
+++ b/contrib/libs/icu/i18n/collationsettings.h
@@ -106,10 +106,10 @@ struct U_I18N_API CollationSettings : public SharedObject {
: options((UCOL_DEFAULT_STRENGTH << STRENGTH_SHIFT) |
(MAX_VAR_PUNCT << MAX_VARIABLE_SHIFT)),
variableTop(0),
- reorderTable(NULL),
+ reorderTable(nullptr),
minHighNoReorder(0),
- reorderRanges(NULL), reorderRangesLength(0),
- reorderCodes(NULL), reorderCodesLength(0), reorderCodesCapacity(0),
+ reorderRanges(nullptr), reorderRangesLength(0),
+ reorderCodes(nullptr), reorderCodesLength(0), reorderCodesCapacity(0),
fastLatinOptions(-1) {}
CollationSettings(const CollationSettings &other);
@@ -131,7 +131,7 @@ struct U_I18N_API CollationSettings : public SharedObject {
UErrorCode &errorCode);
void copyReorderingFrom(const CollationSettings &other, UErrorCode &errorCode);
- inline UBool hasReordering() const { return reorderTable != NULL; }
+ inline UBool hasReordering() const { return reorderTable != nullptr; }
static UBool reorderTableHasSplitBytes(const uint8_t table[256]);
inline uint32_t reorder(uint32_t p) const {
uint8_t b = reorderTable[p >> 24];
@@ -216,7 +216,7 @@ struct U_I18N_API CollationSettings : public SharedObject {
/** Variable-top primary weight. */
uint32_t variableTop;
/**
- * 256-byte table for reordering permutation of primary lead bytes; NULL if no reordering.
+ * 256-byte table for reordering permutation of primary lead bytes; nullptr if no reordering.
* A 0 entry at a non-zero index means that the primary lead byte is "split"
* (there are different offsets for primaries that share that lead byte)
* and the reordering offset must be determined via the reorderRanges.
diff --git a/contrib/libs/icu/i18n/collationtailoring.cpp b/contrib/libs/icu/i18n/collationtailoring.cpp
index 78a11fbb26..8d22cf2516 100644
--- a/contrib/libs/icu/i18n/collationtailoring.cpp
+++ b/contrib/libs/icu/i18n/collationtailoring.cpp
@@ -33,20 +33,20 @@
U_NAMESPACE_BEGIN
CollationTailoring::CollationTailoring(const CollationSettings *baseSettings)
- : data(NULL), settings(baseSettings),
+ : data(nullptr), settings(baseSettings),
actualLocale(""),
- ownedData(NULL),
- builder(NULL), memory(NULL), bundle(NULL),
- trie(NULL), unsafeBackwardSet(NULL),
- maxExpansions(NULL) {
- if(baseSettings != NULL) {
+ ownedData(nullptr),
+ builder(nullptr), memory(nullptr), bundle(nullptr),
+ trie(nullptr), unsafeBackwardSet(nullptr),
+ maxExpansions(nullptr) {
+ if(baseSettings != nullptr) {
U_ASSERT(baseSettings->reorderCodesLength == 0);
- U_ASSERT(baseSettings->reorderTable == NULL);
+ U_ASSERT(baseSettings->reorderTable == nullptr);
U_ASSERT(baseSettings->minHighNoReorder == 0);
} else {
settings = new CollationSettings();
}
- if(settings != NULL) {
+ if(settings != nullptr) {
settings->addRef();
}
rules.getTerminatedBuffer(); // ensure NUL-termination
@@ -68,18 +68,18 @@ CollationTailoring::~CollationTailoring() {
UBool
CollationTailoring::ensureOwnedData(UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
- if(ownedData == NULL) {
+ if(U_FAILURE(errorCode)) { return false; }
+ if(ownedData == nullptr) {
const Normalizer2Impl *nfcImpl = Normalizer2Factory::getNFCImpl(errorCode);
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
ownedData = new CollationData(*nfcImpl);
- if(ownedData == NULL) {
+ if(ownedData == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return FALSE;
+ return false;
}
}
data = ownedData;
- return TRUE;
+ return true;
}
void
diff --git a/contrib/libs/icu/i18n/collationtailoring.h b/contrib/libs/icu/i18n/collationtailoring.h
index 5fc2bac2d3..ed7e46e3b9 100644
--- a/contrib/libs/icu/i18n/collationtailoring.h
+++ b/contrib/libs/icu/i18n/collationtailoring.h
@@ -24,6 +24,8 @@
#include "collationsettings.h"
#include "uhash.h"
#include "umutex.h"
+#include "unifiedcache.h"
+
struct UDataMemory;
struct UResourceBundle;
@@ -52,7 +54,7 @@ struct U_I18N_API CollationTailoring : public SharedObject {
/**
* Returns true if the constructor could not initialize properly.
*/
- UBool isBogus() { return settings == NULL; }
+ UBool isBogus() { return settings == nullptr; }
UBool ensureOwnedData(UErrorCode &errorCode);
@@ -89,13 +91,13 @@ private:
* No copy constructor: A CollationTailoring cannot be copied.
* It is immutable, and the data trie cannot be copied either.
*/
- CollationTailoring(const CollationTailoring &other);
+ CollationTailoring(const CollationTailoring &other) = delete;
};
struct U_I18N_API CollationCacheEntry : public SharedObject {
CollationCacheEntry(const Locale &loc, const CollationTailoring *t)
: validLocale(loc), tailoring(t) {
- if(t != NULL) {
+ if(t != nullptr) {
t->addRef();
}
}
@@ -105,6 +107,10 @@ struct U_I18N_API CollationCacheEntry : public SharedObject {
const CollationTailoring *tailoring;
};
+template<> U_I18N_API
+const CollationCacheEntry *
+LocaleCacheKey<CollationCacheEntry>::createObject(const void *creationContext,
+ UErrorCode &errorCode) const;
U_NAMESPACE_END
#endif // !UCONFIG_NO_COLLATION
diff --git a/contrib/libs/icu/i18n/collationweights.cpp b/contrib/libs/icu/i18n/collationweights.cpp
index 05458962c6..2351484590 100644
--- a/contrib/libs/icu/i18n/collationweights.cpp
+++ b/contrib/libs/icu/i18n/collationweights.cpp
@@ -227,7 +227,7 @@ CollationWeights::getWeightRanges(uint32_t lowerLimit, uint32_t upperLimit) {
#ifdef UCOL_DEBUG
printf("error: no space between lower & upper limits\n");
#endif
- return FALSE;
+ return false;
}
/* check that neither is a prefix of the other */
@@ -236,7 +236,7 @@ CollationWeights::getWeightRanges(uint32_t lowerLimit, uint32_t upperLimit) {
#ifdef UCOL_DEBUG
printf("error: lower limit 0x%08lx is a prefix of upper limit 0x%08lx\n", lowerLimit, upperLimit);
#endif
- return FALSE;
+ return false;
}
}
/* if the upper limit is a prefix of the lower limit then the earlier test lowerLimit>=upperLimit has caught it */
@@ -307,7 +307,7 @@ CollationWeights::getWeightRanges(uint32_t lowerLimit, uint32_t upperLimit) {
// maxByte (for lowerEnd) or minByte (for upperStart).
const uint32_t lowerEnd=lower[length].end;
const uint32_t upperStart=upper[length].start;
- UBool merged=FALSE;
+ UBool merged=false;
if(lowerEnd>upperStart) {
// These two lower and upper ranges collide.
@@ -326,7 +326,7 @@ CollationWeights::getWeightRanges(uint32_t lowerLimit, uint32_t upperLimit) {
(int32_t)getWeightTrail(lower[length].start, length)+1;
// count might be <=0 in which case there is no room,
// and the range-collecting code below will ignore this range.
- merged=TRUE;
+ merged=true;
} else if(lowerEnd==upperStart) {
// Not possible, unless minByte==maxByte which is not allowed.
U_ASSERT(minBytes[length]<maxBytes[length]);
@@ -335,7 +335,7 @@ CollationWeights::getWeightRanges(uint32_t lowerLimit, uint32_t upperLimit) {
// Merge adjacent ranges.
lower[length].end=upper[length].end;
lower[length].count+=upper[length].count; // might be >countBytes
- merged=TRUE;
+ merged=true;
}
}
if(merged) {
@@ -409,14 +409,14 @@ CollationWeights::allocWeightsInShortRanges(int32_t n, int32_t minLength) {
/* sort the ranges by weight values */
UErrorCode errorCode=U_ZERO_ERROR;
uprv_sortArray(ranges, rangeCount, sizeof(WeightRange),
- compareRanges, NULL, FALSE, &errorCode);
+ compareRanges, nullptr, false, &errorCode);
/* ignore error code: we know that the internal sort function will not fail here */
}
- return TRUE;
+ return true;
}
n -= ranges[i].count; // still >0
}
- return FALSE;
+ return false;
}
UBool
@@ -433,7 +433,7 @@ CollationWeights::allocWeightsInMinLengthRanges(int32_t n, int32_t minLength) {
}
int32_t nextCountBytes = countBytes(minLength + 1);
- if(n > count * nextCountBytes) { return FALSE; }
+ if(n > count * nextCountBytes) { return false; }
// Use the minLength ranges. Merge them, and then split again as necessary.
uint32_t start = ranges[0].start;
@@ -485,7 +485,7 @@ CollationWeights::allocWeightsInMinLengthRanges(int32_t n, int32_t minLength) {
lengthenRange(ranges[1]);
rangeCount = 2;
}
- return TRUE;
+ return true;
}
/*
@@ -503,7 +503,7 @@ CollationWeights::allocWeights(uint32_t lowerLimit, uint32_t upperLimit, int32_t
#ifdef UCOL_DEBUG
printf("error: unable to get Weight ranges\n");
#endif
- return FALSE;
+ return false;
}
/* try until we find suitably large ranges */
@@ -518,7 +518,7 @@ CollationWeights::allocWeights(uint32_t lowerLimit, uint32_t upperLimit, int32_t
printf("error: the maximum number of %ld weights is insufficient for n=%ld\n",
minLengthCount, n);
#endif
- return FALSE;
+ return false;
}
if(allocWeightsInMinLengthRanges(n, minLength)) { break; }
@@ -541,7 +541,7 @@ CollationWeights::allocWeights(uint32_t lowerLimit, uint32_t upperLimit, int32_t
#endif
rangeIndex = 0;
- return TRUE;
+ return true;
}
uint32_t
diff --git a/contrib/libs/icu/i18n/coptccal.cpp b/contrib/libs/icu/i18n/coptccal.cpp
index 9c2b1ebbb7..a957f8f2c5 100644
--- a/contrib/libs/icu/i18n/coptccal.cpp
+++ b/contrib/libs/icu/i18n/coptccal.cpp
@@ -92,10 +92,28 @@ CopticCalendar::handleComputeFields(int32_t julianDay, UErrorCode &/*status*/)
internalSet(UCAL_ERA, era);
internalSet(UCAL_YEAR, year);
internalSet(UCAL_MONTH, month);
+ internalSet(UCAL_ORDINAL_MONTH, month);
internalSet(UCAL_DATE, day);
internalSet(UCAL_DAY_OF_YEAR, (30 * month) + day);
}
+constexpr uint32_t kCopticRelatedYearDiff = 284;
+
+int32_t CopticCalendar::getRelatedYear(UErrorCode &status) const
+{
+ int32_t year = get(UCAL_EXTENDED_YEAR, status);
+ if (U_FAILURE(status)) {
+ return 0;
+ }
+ return year + kCopticRelatedYearDiff;
+}
+
+void CopticCalendar::setRelatedYear(int32_t year)
+{
+ // set extended year
+ set(UCAL_EXTENDED_YEAR, year - kCopticRelatedYearDiff);
+}
+
/**
* The system maintains a static default century start date and Year. They are
* initialized the first time they are used. Once the system default century date
@@ -103,7 +121,7 @@ CopticCalendar::handleComputeFields(int32_t julianDay, UErrorCode &/*status*/)
*/
static UDate gSystemDefaultCenturyStart = DBL_MIN;
static int32_t gSystemDefaultCenturyStartYear = -1;
-static icu::UInitOnce gSystemDefaultCenturyInit = U_INITONCE_INITIALIZER;
+static icu::UInitOnce gSystemDefaultCenturyInit {};
static void U_CALLCONV initializeSystemDefaultCentury() {
diff --git a/contrib/libs/icu/i18n/coptccal.h b/contrib/libs/icu/i18n/coptccal.h
index 5c51af04ca..396127e8ad 100644
--- a/contrib/libs/icu/i18n/coptccal.h
+++ b/contrib/libs/icu/i18n/coptccal.h
@@ -154,6 +154,20 @@ public:
*/
const char * getType() const override;
+ /**
+ * @return The related Gregorian year; will be obtained by modifying the value
+ * obtained by get from UCAL_EXTENDED_YEAR field
+ * @internal
+ */
+ virtual int32_t getRelatedYear(UErrorCode &status) const override;
+
+ /**
+ * @param year The related Gregorian year to set; will be modified as necessary then
+ * set in UCAL_EXTENDED_YEAR field
+ * @internal
+ */
+ virtual void setRelatedYear(int32_t year) override;
+
protected:
//-------------------------------------------------------------------------
// Calendar framework
@@ -202,7 +216,7 @@ public:
* same class ID. Objects of other classes have different class IDs.
* @internal
*/
- virtual UClassID getDynamicClassID(void) const override;
+ virtual UClassID getDynamicClassID() const override;
/**
* Return the class ID for this class. This is useful only for comparing to a return
@@ -215,7 +229,7 @@ public:
* @return The class ID for all objects of this class.
* @internal
*/
- U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
+ U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
#if 0
// We do not want to introduce this API in ICU4C.
diff --git a/contrib/libs/icu/i18n/cpdtrans.cpp b/contrib/libs/icu/i18n/cpdtrans.cpp
index dc0217ba61..9b10364689 100644
--- a/contrib/libs/icu/i18n/cpdtrans.cpp
+++ b/contrib/libs/icu/i18n/cpdtrans.cpp
@@ -22,15 +22,15 @@
#include "cmemory.h"
// keep in sync with Transliterator
-//static const UChar ID_SEP = 0x002D; /*-*/
-static const UChar ID_DELIM = 0x003B; /*;*/
-static const UChar NEWLINE = 10;
+//static const char16_t ID_SEP = 0x002D; /*-*/
+static const char16_t ID_DELIM = 0x003B; /*;*/
+static const char16_t NEWLINE = 10;
-static const UChar COLON_COLON[] = {0x3A, 0x3A, 0}; //"::"
+static const char16_t COLON_COLON[] = {0x3A, 0x3A, 0}; //"::"
U_NAMESPACE_BEGIN
-const UChar CompoundTransliterator::PASS_STRING[] = { 0x0025, 0x0050, 0x0061, 0x0073, 0x0073, 0 }; // "%Pass"
+const char16_t CompoundTransliterator::PASS_STRING[] = { 0x0025, 0x0050, 0x0061, 0x0073, 0x0073, 0 }; // "%Pass"
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CompoundTransliterator)
@@ -73,7 +73,7 @@ CompoundTransliterator::CompoundTransliterator(const UnicodeString& id,
trans(0), numAnonymousRBTs(0) {
// TODO add code for parseError...currently unused, but
// later may be used by parsing code...
- init(id, direction, TRUE, status);
+ init(id, direction, true, status);
}
CompoundTransliterator::CompoundTransliterator(const UnicodeString& id,
@@ -83,7 +83,7 @@ CompoundTransliterator::CompoundTransliterator(const UnicodeString& id,
trans(0), numAnonymousRBTs(0) {
// TODO add code for parseError...currently unused, but
// later may be used by parsing code...
- init(id, UTRANS_FORWARD, TRUE, status);
+ init(id, UTRANS_FORWARD, true, status);
}
@@ -99,7 +99,7 @@ CompoundTransliterator::CompoundTransliterator(const UnicodeString& newID,
Transliterator(newID, adoptedFilter),
trans(0), numAnonymousRBTs(anonymousRBTs)
{
- init(list, UTRANS_FORWARD, FALSE, status);
+ init(list, UTRANS_FORWARD, false, status);
}
/**
@@ -110,12 +110,12 @@ CompoundTransliterator::CompoundTransliterator(const UnicodeString& newID,
CompoundTransliterator::CompoundTransliterator(UVector& list,
UParseError& /*parseError*/,
UErrorCode& status) :
- Transliterator(UnicodeString(), NULL),
+ Transliterator(UnicodeString(), nullptr),
trans(0), numAnonymousRBTs(0)
{
// TODO add code for parseError...currently unused, but
// later may be used by parsing code...
- init(list, UTRANS_FORWARD, FALSE, status);
+ init(list, UTRANS_FORWARD, false, status);
// assume caller will fixup ID
}
@@ -123,15 +123,15 @@ CompoundTransliterator::CompoundTransliterator(UVector& list,
int32_t anonymousRBTs,
UParseError& /*parseError*/,
UErrorCode& status) :
- Transliterator(UnicodeString(), NULL),
+ Transliterator(UnicodeString(), nullptr),
trans(0), numAnonymousRBTs(anonymousRBTs)
{
- init(list, UTRANS_FORWARD, FALSE, status);
+ init(list, UTRANS_FORWARD, false, status);
}
/**
* Finish constructing a transliterator: only to be called by
- * constructors. Before calling init(), set trans and filter to NULL.
+ * constructors. Before calling init(), set trans and filter to nullptr.
* @param id the id containing ';'-separated entries
* @param direction either FORWARD or REVERSE
* @param idSplitPoint the index into id at which the
@@ -139,8 +139,8 @@ CompoundTransliterator::CompoundTransliterator(UVector& list,
* -1 if there is none.
* @param adoptedSplitTransliterator a transliterator to be inserted
* before the entry at offset idSplitPoint in the id string. May be
- * NULL to insert no entry.
- * @param fixReverseID if TRUE, then reconstruct the ID of reverse
+ * nullptr to insert no entry.
+ * @param fixReverseID if true, then reconstruct the ID of reverse
* entries by calling getID() of component entries. Some constructors
* do not require this because they apply a facade ID anyway.
* @param status the error code indicating success or failure
@@ -156,7 +156,7 @@ void CompoundTransliterator::init(const UnicodeString& id,
}
UVector list(status);
- UnicodeSet* compoundFilter = NULL;
+ UnicodeSet* compoundFilter = nullptr;
UnicodeString regenID;
if (!TransliteratorIDParser::parseCompoundID(id, direction,
regenID, list, compoundFilter)) {
@@ -169,20 +169,20 @@ void CompoundTransliterator::init(const UnicodeString& id,
init(list, direction, fixReverseID, status);
- if (compoundFilter != NULL) {
+ if (compoundFilter != nullptr) {
adoptFilter(compoundFilter);
}
}
/**
* Finish constructing a transliterator: only to be called by
- * constructors. Before calling init(), set trans and filter to NULL.
+ * constructors. Before calling init(), set trans and filter to nullptr.
* @param list a vector of transliterator objects to be adopted. It
* should NOT be empty. The list should be in declared order. That
* is, it should be in the FORWARD order; if direction is REVERSE then
* the list order will be reversed.
* @param direction either FORWARD or REVERSE
- * @param fixReverseID if TRUE, then reconstruct the ID of reverse
+ * @param fixReverseID if true, then reconstruct the ID of reverse
* entries by calling getID() of component entries. Some constructors
* do not require this because they apply a facade ID anyway.
* @param status the error code indicating success or failure
@@ -197,7 +197,7 @@ void CompoundTransliterator::init(UVector& list,
if (U_SUCCESS(status)) {
count = list.size();
trans = (Transliterator **)uprv_malloc(count * sizeof(Transliterator *));
- /* test for NULL */
+ /* test for nullptr */
if (trans == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -265,7 +265,7 @@ CompoundTransliterator::~CompoundTransliterator() {
freeTransliterators();
}
-void CompoundTransliterator::freeTransliterators(void) {
+void CompoundTransliterator::freeTransliterators() {
if (trans != 0) {
for (int32_t i=0; i<count; ++i) {
delete trans[i];
@@ -285,25 +285,25 @@ CompoundTransliterator& CompoundTransliterator::operator=(
if (this == &t) { return *this; } // self-assignment: no-op
Transliterator::operator=(t);
int32_t i = 0;
- UBool failed = FALSE;
- if (trans != NULL) {
+ UBool failed = false;
+ if (trans != nullptr) {
for (i=0; i<count; ++i) {
delete trans[i];
trans[i] = 0;
}
}
if (t.count > count) {
- if (trans != NULL) {
+ if (trans != nullptr) {
uprv_free(trans);
}
trans = (Transliterator **)uprv_malloc(t.count * sizeof(Transliterator *));
}
count = t.count;
- if (trans != NULL) {
+ if (trans != nullptr) {
for (i=0; i<count; ++i) {
trans[i] = t.trans[i]->clone();
- if (trans[i] == NULL) {
- failed = TRUE;
+ if (trans[i] == nullptr) {
+ failed = true;
break;
}
}
@@ -314,7 +314,7 @@ CompoundTransliterator& CompoundTransliterator::operator=(
int32_t n;
for (n = i-1; n >= 0; n--) {
uprv_free(trans[n]);
- trans[n] = NULL;
+ trans[n] = nullptr;
}
}
numAnonymousRBTs = t.numAnonymousRBTs;
@@ -332,7 +332,7 @@ CompoundTransliterator* CompoundTransliterator::clone() const {
* Returns the number of transliterators in this chain.
* @return number of transliterators in this chain.
*/
-int32_t CompoundTransliterator::getCount(void) const {
+int32_t CompoundTransliterator::getCount() const {
return count;
}
@@ -348,15 +348,15 @@ const Transliterator& CompoundTransliterator::getTransliterator(int32_t index) c
void CompoundTransliterator::setTransliterators(Transliterator* const transliterators[],
int32_t transCount) {
Transliterator** a = (Transliterator **)uprv_malloc(transCount * sizeof(Transliterator *));
- if (a == NULL) {
+ if (a == nullptr) {
return;
}
int32_t i = 0;
- UBool failed = FALSE;
+ UBool failed = false;
for (i=0; i<transCount; ++i) {
a[i] = transliterators[i]->clone();
- if (a[i] == NULL) {
- failed = TRUE;
+ if (a[i] == nullptr) {
+ failed = true;
break;
}
}
@@ -364,7 +364,7 @@ void CompoundTransliterator::setTransliterators(Transliterator* const transliter
int32_t n;
for (n = i-1; n >= 0; n--) {
uprv_free(a[n]);
- a[n] = NULL;
+ a[n] = nullptr;
}
return;
}
@@ -385,7 +385,7 @@ void CompoundTransliterator::adoptTransliterators(Transliterator* adoptedTransli
/**
* Append c to buf, unless buf is empty or buf already ends in c.
*/
-static void _smartAppend(UnicodeString& buf, UChar c) {
+static void _smartAppend(UnicodeString& buf, char16_t c) {
if (buf.length() != 0 &&
buf.charAt(buf.length() - 1) != c) {
buf.append(c);
@@ -401,7 +401,7 @@ UnicodeString& CompoundTransliterator::toRules(UnicodeString& rulesSource,
// compoundRBTIndex >= 0. For the transliterator at compoundRBTIndex,
// we do call toRules() recursively.
rulesSource.truncate(0);
- if (numAnonymousRBTs >= 1 && getFilter() != NULL) {
+ if (numAnonymousRBTs >= 1 && getFilter() != nullptr) {
// If we are a compound RBT and if we have a global
// filter, then emit it at the top.
UnicodeString pat;
@@ -599,7 +599,7 @@ void CompoundTransliterator::handleTransliterate(Replaceable& text, UTransPositi
* Sets the length of the longest context required by this transliterator.
* This is <em>preceding</em> context.
*/
-void CompoundTransliterator::computeMaximumContextLength(void) {
+void CompoundTransliterator::computeMaximumContextLength() {
int32_t max = 0;
for (int32_t i=0; i<count; ++i) {
int32_t len = trans[i]->getMaximumContextLength();
diff --git a/contrib/libs/icu/i18n/cpdtrans.h b/contrib/libs/icu/i18n/cpdtrans.h
index af60cb827e..a27c617c95 100644
--- a/contrib/libs/icu/i18n/cpdtrans.h
+++ b/contrib/libs/icu/i18n/cpdtrans.h
@@ -70,7 +70,7 @@ public:
* @param id compound ID
* @param dir either UTRANS_FORWARD or UTRANS_REVERSE
* @param adoptedFilter a global filter for this compound transliterator
- * or NULL
+ * or nullptr
*/
CompoundTransliterator(const UnicodeString& id,
UTransDirection dir,
@@ -80,7 +80,7 @@ public:
/**
* Constructs a new compound transliterator in the FORWARD
- * direction with a NULL filter.
+ * direction with a nullptr filter.
*/
CompoundTransliterator(const UnicodeString& id,
UParseError& parseError,
@@ -104,7 +104,7 @@ public:
* Returns the number of transliterators in this chain.
* @return number of transliterators in this chain.
*/
- virtual int32_t getCount(void) const;
+ virtual int32_t getCount() const;
/**
* Returns the transliterator at the given index in this chain.
@@ -171,7 +171,7 @@ public:
static UClassID U_EXPORT2 getStaticClassID();
/* @internal */
- static const UChar PASS_STRING[];
+ static const char16_t PASS_STRING[];
private:
@@ -220,9 +220,9 @@ private:
UnicodeString joinIDs(Transliterator* const transliterators[],
int32_t transCount);
- void freeTransliterators(void);
+ void freeTransliterators();
- void computeMaximumContextLength(void);
+ void computeMaximumContextLength();
};
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/csdetect.cpp b/contrib/libs/icu/i18n/csdetect.cpp
index 84f0776542..16004f9f5d 100644
--- a/contrib/libs/icu/i18n/csdetect.cpp
+++ b/contrib/libs/icu/i18n/csdetect.cpp
@@ -46,27 +46,27 @@ struct CSRecognizerInfo : public UMemory {
U_NAMESPACE_END
-static icu::CSRecognizerInfo **fCSRecognizers = NULL;
-static icu::UInitOnce gCSRecognizersInitOnce = U_INITONCE_INITIALIZER;
+static icu::CSRecognizerInfo **fCSRecognizers = nullptr;
+static icu::UInitOnce gCSRecognizersInitOnce {};
static int32_t fCSRecognizers_size = 0;
U_CDECL_BEGIN
-static UBool U_CALLCONV csdet_cleanup(void)
+static UBool U_CALLCONV csdet_cleanup()
{
U_NAMESPACE_USE
- if (fCSRecognizers != NULL) {
+ if (fCSRecognizers != nullptr) {
for(int32_t r = 0; r < fCSRecognizers_size; r += 1) {
delete fCSRecognizers[r];
- fCSRecognizers[r] = NULL;
+ fCSRecognizers[r] = nullptr;
}
DELETE_ARRAY(fCSRecognizers);
- fCSRecognizers = NULL;
+ fCSRecognizers = nullptr;
fCSRecognizers_size = 0;
}
gCSRecognizersInitOnce.reset();
- return TRUE;
+ return true;
}
static int32_t U_CALLCONV
@@ -85,53 +85,53 @@ static void U_CALLCONV initRecognizers(UErrorCode &status) {
U_NAMESPACE_USE
ucln_i18n_registerCleanup(UCLN_I18N_CSDET, csdet_cleanup);
CSRecognizerInfo *tempArray[] = {
- new CSRecognizerInfo(new CharsetRecog_UTF8(), TRUE),
-
- new CSRecognizerInfo(new CharsetRecog_UTF_16_BE(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_UTF_16_LE(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_UTF_32_BE(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_UTF_32_LE(), TRUE),
-
- new CSRecognizerInfo(new CharsetRecog_8859_1(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_8859_2(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_8859_5_ru(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_8859_6_ar(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_8859_7_el(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_8859_8_I_he(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_8859_8_he(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_windows_1251(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_windows_1256(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_KOI8_R(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_8859_9_tr(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_sjis(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_gb_18030(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_euc_jp(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_euc_kr(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_big5(), TRUE),
-
- new CSRecognizerInfo(new CharsetRecog_2022JP(), TRUE),
+ new CSRecognizerInfo(new CharsetRecog_UTF8(), true),
+
+ new CSRecognizerInfo(new CharsetRecog_UTF_16_BE(), true),
+ new CSRecognizerInfo(new CharsetRecog_UTF_16_LE(), true),
+ new CSRecognizerInfo(new CharsetRecog_UTF_32_BE(), true),
+ new CSRecognizerInfo(new CharsetRecog_UTF_32_LE(), true),
+
+ new CSRecognizerInfo(new CharsetRecog_8859_1(), true),
+ new CSRecognizerInfo(new CharsetRecog_8859_2(), true),
+ new CSRecognizerInfo(new CharsetRecog_8859_5_ru(), true),
+ new CSRecognizerInfo(new CharsetRecog_8859_6_ar(), true),
+ new CSRecognizerInfo(new CharsetRecog_8859_7_el(), true),
+ new CSRecognizerInfo(new CharsetRecog_8859_8_I_he(), true),
+ new CSRecognizerInfo(new CharsetRecog_8859_8_he(), true),
+ new CSRecognizerInfo(new CharsetRecog_windows_1251(), true),
+ new CSRecognizerInfo(new CharsetRecog_windows_1256(), true),
+ new CSRecognizerInfo(new CharsetRecog_KOI8_R(), true),
+ new CSRecognizerInfo(new CharsetRecog_8859_9_tr(), true),
+ new CSRecognizerInfo(new CharsetRecog_sjis(), true),
+ new CSRecognizerInfo(new CharsetRecog_gb_18030(), true),
+ new CSRecognizerInfo(new CharsetRecog_euc_jp(), true),
+ new CSRecognizerInfo(new CharsetRecog_euc_kr(), true),
+ new CSRecognizerInfo(new CharsetRecog_big5(), true),
+
+ new CSRecognizerInfo(new CharsetRecog_2022JP(), true),
#if !UCONFIG_ONLY_HTML_CONVERSION
- new CSRecognizerInfo(new CharsetRecog_2022KR(), TRUE),
- new CSRecognizerInfo(new CharsetRecog_2022CN(), TRUE),
+ new CSRecognizerInfo(new CharsetRecog_2022KR(), true),
+ new CSRecognizerInfo(new CharsetRecog_2022CN(), true),
- new CSRecognizerInfo(new CharsetRecog_IBM424_he_rtl(), FALSE),
- new CSRecognizerInfo(new CharsetRecog_IBM424_he_ltr(), FALSE),
- new CSRecognizerInfo(new CharsetRecog_IBM420_ar_rtl(), FALSE),
- new CSRecognizerInfo(new CharsetRecog_IBM420_ar_ltr(), FALSE)
+ new CSRecognizerInfo(new CharsetRecog_IBM424_he_rtl(), false),
+ new CSRecognizerInfo(new CharsetRecog_IBM424_he_ltr(), false),
+ new CSRecognizerInfo(new CharsetRecog_IBM420_ar_rtl(), false),
+ new CSRecognizerInfo(new CharsetRecog_IBM420_ar_ltr(), false)
#endif
};
int32_t rCount = UPRV_LENGTHOF(tempArray);
fCSRecognizers = NEW_ARRAY(CSRecognizerInfo *, rCount);
- if (fCSRecognizers == NULL) {
+ if (fCSRecognizers == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
else {
fCSRecognizers_size = rCount;
for (int32_t r = 0; r < rCount; r += 1) {
fCSRecognizers[r] = tempArray[r];
- if (fCSRecognizers[r] == NULL) {
+ if (fCSRecognizers[r] == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
}
@@ -148,9 +148,9 @@ void CharsetDetector::setRecognizers(UErrorCode &status)
}
CharsetDetector::CharsetDetector(UErrorCode &status)
- : textIn(new InputText(status)), resultArray(NULL),
- resultCount(0), fStripTags(FALSE), fFreshTextSet(FALSE),
- fEnabledRecognizers(NULL)
+ : textIn(new InputText(status)), resultArray(nullptr),
+ resultCount(0), fStripTags(false), fFreshTextSet(false),
+ fEnabledRecognizers(nullptr)
{
if (U_FAILURE(status)) {
return;
@@ -164,7 +164,7 @@ CharsetDetector::CharsetDetector(UErrorCode &status)
resultArray = (CharsetMatch **)uprv_malloc(sizeof(CharsetMatch *)*fCSRecognizers_size);
- if (resultArray == NULL) {
+ if (resultArray == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -172,7 +172,7 @@ CharsetDetector::CharsetDetector(UErrorCode &status)
for(int32_t i = 0; i < fCSRecognizers_size; i += 1) {
resultArray[i] = new CharsetMatch();
- if (resultArray[i] == NULL) {
+ if (resultArray[i] == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
}
@@ -197,14 +197,14 @@ CharsetDetector::~CharsetDetector()
void CharsetDetector::setText(const char *in, int32_t len)
{
textIn->setText(in, len);
- fFreshTextSet = TRUE;
+ fFreshTextSet = true;
}
UBool CharsetDetector::setStripTagsFlag(UBool flag)
{
UBool temp = fStripTags;
fStripTags = flag;
- fFreshTextSet = TRUE;
+ fFreshTextSet = true;
return temp;
}
@@ -236,7 +236,7 @@ const CharsetMatch *CharsetDetector::detect(UErrorCode &status)
if(maxMatchesFound > 0) {
return resultArray[0];
} else {
- return NULL;
+ return nullptr;
}
}
@@ -245,7 +245,7 @@ const CharsetMatch * const *CharsetDetector::detectAll(int32_t &maxMatchesFound,
if(!textIn->isSet()) {
status = U_MISSING_RESOURCE_ERROR;// TODO: Need to set proper status code for input text not set
- return NULL;
+ return nullptr;
} else if (fFreshTextSet) {
CharsetRecognizer *csr;
int32_t i;
@@ -263,13 +263,18 @@ const CharsetMatch * const *CharsetDetector::detectAll(int32_t &maxMatchesFound,
}
if (resultCount > 1) {
- uprv_sortArray(resultArray, resultCount, sizeof resultArray[0], charsetMatchComparator, NULL, TRUE, &status);
+ uprv_sortArray(resultArray, resultCount, sizeof resultArray[0], charsetMatchComparator, nullptr, true, &status);
}
- fFreshTextSet = FALSE;
+ fFreshTextSet = false;
}
maxMatchesFound = resultCount;
+ if (maxMatchesFound == 0) {
+ status = U_INVALID_CHAR_FOUND;
+ return nullptr;
+ }
+
return resultArray;
}
@@ -280,7 +285,7 @@ void CharsetDetector::setDetectableCharset(const char *encoding, UBool enabled,
}
int32_t modIdx = -1;
- UBool isDefaultVal = FALSE;
+ UBool isDefaultVal = false;
for (int32_t i = 0; i < fCSRecognizers_size; i++) {
CSRecognizerInfo *csrinfo = fCSRecognizers[i];
if (uprv_strcmp(csrinfo->recognizer->getName(), encoding) == 0) {
@@ -295,10 +300,10 @@ void CharsetDetector::setDetectableCharset(const char *encoding, UBool enabled,
return;
}
- if (fEnabledRecognizers == NULL && !isDefaultVal) {
+ if (fEnabledRecognizers == nullptr && !isDefaultVal) {
// Create an array storing the non default setting
fEnabledRecognizers = NEW_ARRAY(UBool, fCSRecognizers_size);
- if (fEnabledRecognizers == NULL) {
+ if (fEnabledRecognizers == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -308,7 +313,7 @@ void CharsetDetector::setDetectableCharset(const char *encoding, UBool enabled,
}
}
- if (fEnabledRecognizers != NULL) {
+ if (fEnabledRecognizers != nullptr) {
fEnabledRecognizers[modIdx] = enabled;
}
}
@@ -337,7 +342,7 @@ typedef struct {
static void U_CALLCONV
enumClose(UEnumeration *en) {
- if(en->context != NULL) {
+ if(en->context != nullptr) {
DELETE_ARRAY(en->context);
}
@@ -354,7 +359,7 @@ enumCount(UEnumeration *en, UErrorCode *) {
// Otherwise, ucsdet_getDetectableCharsets - only enabled ones
int32_t count = 0;
UBool *enabledArray = ((Context *)en->context)->enabledRecognizers;
- if (enabledArray != NULL) {
+ if (enabledArray != nullptr) {
// custom set
for (int32_t i = 0; i < fCSRecognizers_size; i++) {
if (enabledArray[i]) {
@@ -374,7 +379,7 @@ enumCount(UEnumeration *en, UErrorCode *) {
static const char* U_CALLCONV
enumNext(UEnumeration *en, int32_t *resultLength, UErrorCode * /*status*/) {
- const char *currName = NULL;
+ const char *currName = nullptr;
if (((Context *)en->context)->currIndex < fCSRecognizers_size) {
if (((Context *)en->context)->all) {
@@ -384,9 +389,9 @@ enumNext(UEnumeration *en, int32_t *resultLength, UErrorCode * /*status*/) {
} else {
// ucsdet_getDetectableCharsets
UBool *enabledArray = ((Context *)en->context)->enabledRecognizers;
- if (enabledArray != NULL) {
+ if (enabledArray != nullptr) {
// custom set
- while (currName == NULL && ((Context *)en->context)->currIndex < fCSRecognizers_size) {
+ while (currName == nullptr && ((Context *)en->context)->currIndex < fCSRecognizers_size) {
if (enabledArray[((Context *)en->context)->currIndex]) {
currName = fCSRecognizers[((Context *)en->context)->currIndex]->recognizer->getName();
}
@@ -394,7 +399,7 @@ enumNext(UEnumeration *en, int32_t *resultLength, UErrorCode * /*status*/) {
}
} else {
// default set
- while (currName == NULL && ((Context *)en->context)->currIndex < fCSRecognizers_size) {
+ while (currName == nullptr && ((Context *)en->context)->currIndex < fCSRecognizers_size) {
if (fCSRecognizers[((Context *)en->context)->currIndex]->isDefaultEnabled) {
currName = fCSRecognizers[((Context *)en->context)->currIndex]->recognizer->getName();
}
@@ -404,8 +409,8 @@ enumNext(UEnumeration *en, int32_t *resultLength, UErrorCode * /*status*/) {
}
}
- if(resultLength != NULL) {
- *resultLength = currName == NULL ? 0 : (int32_t)uprv_strlen(currName);
+ if(resultLength != nullptr) {
+ *resultLength = currName == nullptr ? 0 : (int32_t)uprv_strlen(currName);
}
return currName;
@@ -418,8 +423,8 @@ enumReset(UEnumeration *en, UErrorCode *) {
}
static const UEnumeration gCSDetEnumeration = {
- NULL,
- NULL,
+ nullptr,
+ nullptr,
enumClose,
enumCount,
uenum_unextDefault,
@@ -442,19 +447,19 @@ UEnumeration * CharsetDetector::getAllDetectableCharsets(UErrorCode &status)
}
UEnumeration *en = NEW_ARRAY(UEnumeration, 1);
- if (en == NULL) {
+ if (en == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
memcpy(en, &gCSDetEnumeration, sizeof(UEnumeration));
en->context = (void*)NEW_ARRAY(Context, 1);
- if (en->context == NULL) {
+ if (en->context == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
DELETE_ARRAY(en);
return 0;
}
uprv_memset(en->context, 0, sizeof(Context));
- ((Context*)en->context)->all = TRUE;
+ ((Context*)en->context)->all = true;
return en;
}
@@ -465,19 +470,19 @@ UEnumeration * CharsetDetector::getDetectableCharsets(UErrorCode &status) const
}
UEnumeration *en = NEW_ARRAY(UEnumeration, 1);
- if (en == NULL) {
+ if (en == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
memcpy(en, &gCSDetEnumeration, sizeof(UEnumeration));
en->context = (void*)NEW_ARRAY(Context, 1);
- if (en->context == NULL) {
+ if (en->context == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
DELETE_ARRAY(en);
return 0;
}
uprv_memset(en->context, 0, sizeof(Context));
- ((Context*)en->context)->all = FALSE;
+ ((Context*)en->context)->all = false;
((Context*)en->context)->enabledRecognizers = fEnabledRecognizers;
return en;
}
diff --git a/contrib/libs/icu/i18n/csmatch.cpp b/contrib/libs/icu/i18n/csmatch.cpp
index 83bf531665..4c5f73b31b 100644
--- a/contrib/libs/icu/i18n/csmatch.cpp
+++ b/contrib/libs/icu/i18n/csmatch.cpp
@@ -21,7 +21,7 @@
U_NAMESPACE_BEGIN
CharsetMatch::CharsetMatch()
- : textIn(NULL), confidence(0), fCharsetName(NULL), fLang(NULL)
+ : textIn(nullptr), confidence(0), fCharsetName(nullptr), fLang(nullptr)
{
// nothing else to do.
}
@@ -33,11 +33,11 @@ void CharsetMatch::set(InputText *input, const CharsetRecognizer *cr, int32_t co
confidence = conf;
fCharsetName = csName;
fLang = lang;
- if (cr != NULL) {
- if (fCharsetName == NULL) {
+ if (cr != nullptr) {
+ if (fCharsetName == nullptr) {
fCharsetName = cr->getName();
}
- if (fLang == NULL) {
+ if (fLang == nullptr) {
fLang = cr->getLanguage();
}
}
@@ -58,7 +58,7 @@ int32_t CharsetMatch::getConfidence()const
return confidence;
}
-int32_t CharsetMatch::getUChars(UChar *buf, int32_t cap, UErrorCode *status) const
+int32_t CharsetMatch::getUChars(char16_t *buf, int32_t cap, UErrorCode *status) const
{
UConverter *conv = ucnv_open(getName(), status);
int32_t result = ucnv_toUChars(conv, buf, cap, (const char *) textIn->fRawInput, textIn->fRawLength, status);
diff --git a/contrib/libs/icu/i18n/csmatch.h b/contrib/libs/icu/i18n/csmatch.h
index fe379ceea7..c31da81863 100644
--- a/contrib/libs/icu/i18n/csmatch.h
+++ b/contrib/libs/icu/i18n/csmatch.h
@@ -44,14 +44,14 @@ class CharsetMatch : public UMemory
/**
* fully set the state of this CharsetMatch.
* Called by the CharsetRecognizers to record match results.
- * Default (NULL) parameters for names will be filled by calling the
+ * Default (nullptr) parameters for names will be filled by calling the
* corresponding getters on the recognizer.
*/
void set(InputText *input,
const CharsetRecognizer *cr,
int32_t conf,
- const char *csName=NULL,
- const char *lang=NULL);
+ const char *csName=nullptr,
+ const char *lang=nullptr);
/**
* Return the name of the charset for this Match
@@ -62,7 +62,7 @@ class CharsetMatch : public UMemory
int32_t getConfidence()const;
- int32_t getUChars(UChar *buf, int32_t cap, UErrorCode *status) const;
+ int32_t getUChars(char16_t *buf, int32_t cap, UErrorCode *status) const;
};
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/csrmbcs.cpp b/contrib/libs/icu/i18n/csrmbcs.cpp
index 4c5bdfa560..ec346b5fb3 100644
--- a/contrib/libs/icu/i18n/csrmbcs.cpp
+++ b/contrib/libs/icu/i18n/csrmbcs.cpp
@@ -115,7 +115,7 @@ static int32_t binarySearch(const uint16_t *array, int32_t len, uint16_t value)
}
IteratedChar::IteratedChar() :
-charValue(0), index(-1), nextIndex(0), error(FALSE), done(FALSE)
+charValue(0), index(-1), nextIndex(0), error(false), done(false)
{
// nothing else to do.
}
@@ -125,14 +125,14 @@ charValue(0), index(-1), nextIndex(0), error(FALSE), done(FALSE)
charValue = 0;
index = -1;
nextIndex = 0;
- error = FALSE;
- done = FALSE;
+ error = false;
+ done = false;
}*/
int32_t IteratedChar::nextByte(InputText *det)
{
if (nextIndex >= det->fRawLength) {
- done = TRUE;
+ done = true;
return -1;
}
@@ -146,7 +146,6 @@ CharsetRecog_mbcs::~CharsetRecog_mbcs()
}
int32_t CharsetRecog_mbcs::match_mbcs(InputText *det, const uint16_t commonChars[], int32_t commonCharsLen) const {
- int32_t singleByteCharCount = 0;
int32_t doubleByteCharCount = 0;
int32_t commonCharCount = 0;
int32_t badCharCount = 0;
@@ -160,9 +159,7 @@ int32_t CharsetRecog_mbcs::match_mbcs(InputText *det, const uint16_t commonChars
if (iter.error) {
badCharCount++;
} else {
- if (iter.charValue <= 0xFF) {
- singleByteCharCount++;
- } else {
+ if (iter.charValue > 0xFF) {
doubleByteCharCount++;
if (commonChars != 0) {
@@ -243,16 +240,16 @@ CharsetRecog_sjis::~CharsetRecog_sjis()
UBool CharsetRecog_sjis::nextChar(IteratedChar* it, InputText* det) const {
it->index = it->nextIndex;
- it->error = FALSE;
+ it->error = false;
int32_t firstByte = it->charValue = it->nextByte(det);
if (firstByte < 0) {
- return FALSE;
+ return false;
}
if (firstByte <= 0x7F || (firstByte > 0xA0 && firstByte <= 0xDF)) {
- return TRUE;
+ return true;
}
int32_t secondByte = it->nextByte(det);
@@ -263,10 +260,10 @@ UBool CharsetRecog_sjis::nextChar(IteratedChar* it, InputText* det) const {
if (! ((secondByte >= 0x40 && secondByte <= 0x7F) || (secondByte >= 0x80 && secondByte <= 0xFE))) {
// Illegal second byte value.
- it->error = TRUE;
+ it->error = true;
}
- return TRUE;
+ return true;
}
UBool CharsetRecog_sjis::match(InputText* det, CharsetMatch *results) const {
@@ -296,17 +293,17 @@ UBool CharsetRecog_euc::nextChar(IteratedChar* it, InputText* det) const {
int32_t thirdByte = 0;
it->index = it->nextIndex;
- it->error = FALSE;
+ it->error = false;
firstByte = it->charValue = it->nextByte(det);
if (firstByte < 0) {
// Ran off the end of the input data
- return FALSE;
+ return false;
}
if (firstByte <= 0x8D) {
// single byte char
- return TRUE;
+ return true;
}
secondByte = it->nextByte(det);
@@ -318,10 +315,10 @@ UBool CharsetRecog_euc::nextChar(IteratedChar* it, InputText* det) const {
if (firstByte >= 0xA1 && firstByte <= 0xFE) {
// Two byte Char
if (secondByte < 0xA1) {
- it->error = TRUE;
+ it->error = true;
}
- return TRUE;
+ return true;
}
if (firstByte == 0x8E) {
@@ -332,10 +329,10 @@ UBool CharsetRecog_euc::nextChar(IteratedChar* it, InputText* det) const {
// Treat it like EUC-JP. If the data really was EUC-TW, the following two
// bytes will look like a well formed 2 byte char.
if (secondByte < 0xA1) {
- it->error = TRUE;
+ it->error = true;
}
- return TRUE;
+ return true;
}
if (firstByte == 0x8F) {
@@ -346,11 +343,11 @@ UBool CharsetRecog_euc::nextChar(IteratedChar* it, InputText* det) const {
if (thirdByte < 0xa1) {
// Bad second byte or ran off the end of the input data with a non-ASCII first byte.
- it->error = TRUE;
+ it->error = true;
}
}
- return TRUE;
+ return true;
}
@@ -408,16 +405,16 @@ UBool CharsetRecog_big5::nextChar(IteratedChar* it, InputText* det) const
int32_t firstByte;
it->index = it->nextIndex;
- it->error = FALSE;
+ it->error = false;
firstByte = it->charValue = it->nextByte(det);
if (firstByte < 0) {
- return FALSE;
+ return false;
}
if (firstByte <= 0x7F || firstByte == 0xFF) {
// single byte character.
- return TRUE;
+ return true;
}
int32_t secondByte = it->nextByte(det);
@@ -427,10 +424,10 @@ UBool CharsetRecog_big5::nextChar(IteratedChar* it, InputText* det) const
// else we'll handle the error later.
if (secondByte < 0x40 || secondByte == 0x7F || secondByte == 0xFF) {
- it->error = TRUE;
+ it->error = true;
}
- return TRUE;
+ return true;
}
const char *CharsetRecog_big5::getName() const
@@ -462,17 +459,17 @@ UBool CharsetRecog_gb_18030::nextChar(IteratedChar* it, InputText* det) const {
int32_t fourthByte = 0;
it->index = it->nextIndex;
- it->error = FALSE;
+ it->error = false;
firstByte = it->charValue = it->nextByte(det);
if (firstByte < 0) {
// Ran off the end of the input data
- return FALSE;
+ return false;
}
if (firstByte <= 0x80) {
// single byte char
- return TRUE;
+ return true;
}
secondByte = it->nextByte(det);
@@ -484,7 +481,7 @@ UBool CharsetRecog_gb_18030::nextChar(IteratedChar* it, InputText* det) const {
if (firstByte >= 0x81 && firstByte <= 0xFE) {
// Two byte Char
if ((secondByte >= 0x40 && secondByte <= 0x7E) || (secondByte >=80 && secondByte <= 0xFE)) {
- return TRUE;
+ return true;
}
// Four byte char
@@ -497,16 +494,16 @@ UBool CharsetRecog_gb_18030::nextChar(IteratedChar* it, InputText* det) const {
if (fourthByte >= 0x30 && fourthByte <= 0x39) {
it->charValue = (it->charValue << 16) | (thirdByte << 8) | fourthByte;
- return TRUE;
+ return true;
}
}
}
// Something wasn't valid, or we ran out of data (-1).
- it->error = TRUE;
+ it->error = true;
}
- return TRUE;
+ return true;
}
const char *CharsetRecog_gb_18030::getName() const
diff --git a/contrib/libs/icu/i18n/csrsbcs.cpp b/contrib/libs/icu/i18n/csrsbcs.cpp
index 0b0d8967e7..92af9b5291 100644
--- a/contrib/libs/icu/i18n/csrsbcs.cpp
+++ b/contrib/libs/icu/i18n/csrsbcs.cpp
@@ -104,7 +104,7 @@ int32_t NGramParser::nextByte(InputText *det)
void NGramParser::parseCharacters(InputText *det)
{
int32_t b;
- bool ignoreSpace = FALSE;
+ bool ignoreSpace = false;
while ((b = nextByte(det)) >= 0) {
uint8_t mb = charMap[b];
@@ -211,7 +211,7 @@ int32_t NGramParser_IBM420::nextByte(InputText *det)
void NGramParser_IBM420::parseCharacters(InputText *det)
{
int32_t b;
- bool ignoreSpace = FALSE;
+ bool ignoreSpace = false;
while ((b = nextByte(det)) >= 0) {
uint8_t mb = charMap[b];
diff --git a/contrib/libs/icu/i18n/csrucode.cpp b/contrib/libs/icu/i18n/csrucode.cpp
index 480dae1400..a6e6f83f0f 100644
--- a/contrib/libs/icu/i18n/csrucode.cpp
+++ b/contrib/libs/icu/i18n/csrucode.cpp
@@ -37,7 +37,7 @@ const char *CharsetRecog_UTF_16_BE::getName() const
// NULs are a contra-indication, they will appear commonly if the actual encoding is UTF-32.
// NULs should be rare in actual text.
-static int32_t adjustConfidence(UChar codeUnit, int32_t confidence) {
+static int32_t adjustConfidence(char16_t codeUnit, int32_t confidence) {
if (codeUnit == 0) {
confidence -= 10;
} else if ((codeUnit >= 0x20 && codeUnit <= 0xff) || codeUnit == 0x0a) {
@@ -60,7 +60,7 @@ UBool CharsetRecog_UTF_16_BE::match(InputText* textIn, CharsetMatch *results) co
int32_t bytesToCheck = (length > 30) ? 30 : length;
for (int32_t charIndex=0; charIndex<bytesToCheck-1; charIndex+=2) {
- UChar codeUnit = (input[charIndex] << 8) | input[charIndex + 1];
+ char16_t codeUnit = (input[charIndex] << 8) | input[charIndex + 1];
if (charIndex == 0 && codeUnit == 0xFEFF) {
confidence = 100;
break;
@@ -95,7 +95,7 @@ UBool CharsetRecog_UTF_16_LE::match(InputText* textIn, CharsetMatch *results) co
int32_t bytesToCheck = (length > 30) ? 30 : length;
for (int32_t charIndex=0; charIndex<bytesToCheck-1; charIndex+=2) {
- UChar codeUnit = input[charIndex] | (input[charIndex + 1] << 8);
+ char16_t codeUnit = input[charIndex] | (input[charIndex + 1] << 8);
if (charIndex == 0 && codeUnit == 0xFEFF) {
confidence = 100; // UTF-16 BOM
if (length >= 4 && input[2] == 0 && input[3] == 0) {
@@ -126,11 +126,11 @@ UBool CharsetRecog_UTF_32::match(InputText* textIn, CharsetMatch *results) const
int32_t limit = (textIn->fRawLength / 4) * 4;
int32_t numValid = 0;
int32_t numInvalid = 0;
- bool hasBOM = FALSE;
+ bool hasBOM = false;
int32_t confidence = 0;
if (limit > 0 && getChar(input, 0) == 0x0000FEFFUL) {
- hasBOM = TRUE;
+ hasBOM = true;
}
for(int32_t i = 0; i < limit; i += 4) {
diff --git a/contrib/libs/icu/i18n/csrutf8.cpp b/contrib/libs/icu/i18n/csrutf8.cpp
index 3f16224ea6..f114f09722 100644
--- a/contrib/libs/icu/i18n/csrutf8.cpp
+++ b/contrib/libs/icu/i18n/csrutf8.cpp
@@ -27,7 +27,7 @@ const char *CharsetRecog_UTF8::getName() const
}
UBool CharsetRecog_UTF8::match(InputText* input, CharsetMatch *results) const {
- bool hasBOM = FALSE;
+ bool hasBOM = false;
int32_t numValid = 0;
int32_t numInvalid = 0;
const uint8_t *inputBytes = input->fRawInput;
@@ -37,7 +37,7 @@ UBool CharsetRecog_UTF8::match(InputText* input, CharsetMatch *results) const {
if (input->fRawLength >= 3 &&
inputBytes[0] == 0xEF && inputBytes[1] == 0xBB && inputBytes[2] == 0xBF) {
- hasBOM = TRUE;
+ hasBOM = true;
}
// Scan for multi-byte sequences
diff --git a/contrib/libs/icu/i18n/curramt.cpp b/contrib/libs/icu/i18n/curramt.cpp
index 6fd2ea2fda..43c3e9c151 100644
--- a/contrib/libs/icu/i18n/curramt.cpp
+++ b/contrib/libs/icu/i18n/curramt.cpp
@@ -44,7 +44,11 @@ CurrencyAmount* CurrencyAmount::clone() const {
CurrencyAmount::~CurrencyAmount() {
}
-
+
+const CurrencyUnit& CurrencyAmount::getCurrency() const {
+ return static_cast<const CurrencyUnit&>(getUnit());
+}
+
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyAmount)
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/currfmt.cpp b/contrib/libs/icu/i18n/currfmt.cpp
index 0ad0492ee7..b7dfc09c54 100644
--- a/contrib/libs/icu/i18n/currfmt.cpp
+++ b/contrib/libs/icu/i18n/currfmt.cpp
@@ -50,7 +50,7 @@ void CurrencyFormat::parseObject(const UnicodeString& source,
ParsePosition& pos) const
{
CurrencyAmount* currAmt = getCurrencyFormatInternal().parseCurrency(source, pos);
- if (currAmt != NULL) {
+ if (currAmt != nullptr) {
result.adoptObject(currAmt);
}
}
diff --git a/contrib/libs/icu/i18n/currpinf.cpp b/contrib/libs/icu/i18n/currpinf.cpp
index a2676ab5a1..7c5adaaf7c 100644
--- a/contrib/libs/icu/i18n/currpinf.cpp
+++ b/contrib/libs/icu/i18n/currpinf.cpp
@@ -29,7 +29,7 @@
U_NAMESPACE_BEGIN
-static const UChar gNumberPatternSeparator = 0x3B; // ;
+static const char16_t gNumberPatternSeparator = 0x3B; // ;
U_CDECL_BEGIN
@@ -50,11 +50,11 @@ U_CDECL_END
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyPluralInfo)
-static const UChar gDefaultCurrencyPluralPattern[] = {'0', '.', '#', '#', ' ', 0xA4, 0xA4, 0xA4, 0};
-static const UChar gTripleCurrencySign[] = {0xA4, 0xA4, 0xA4, 0};
-static const UChar gPluralCountOther[] = {0x6F, 0x74, 0x68, 0x65, 0x72, 0};
-static const UChar gPart0[] = {0x7B, 0x30, 0x7D, 0};
-static const UChar gPart1[] = {0x7B, 0x31, 0x7D, 0};
+static const char16_t gDefaultCurrencyPluralPattern[] = {'0', '.', '#', '#', ' ', 0xA4, 0xA4, 0xA4, 0};
+static const char16_t gTripleCurrencySign[] = {0xA4, 0xA4, 0xA4, 0};
+static const char16_t gPluralCountOther[] = {0x6F, 0x74, 0x68, 0x65, 0x72, 0};
+static const char16_t gPart0[] = {0x7B, 0x30, 0x7D, 0};
+static const char16_t gPart1[] = {0x7B, 0x31, 0x7D, 0};
static const char gNumberElementsTag[]="NumberElements";
static const char gLatnTag[]="latn";
@@ -190,7 +190,7 @@ CurrencyPluralInfo::getCurrencyPluralPattern(const UnicodeString& pluralCount,
// fall back to "other"
if (pluralCount.compare(gPluralCountOther, 5)) {
currencyPluralPattern =
- (UnicodeString*)fPluralCountToCurrencyUnitPattern->get(UnicodeString(TRUE, gPluralCountOther, 5));
+ (UnicodeString*)fPluralCountToCurrencyUnitPattern->get(UnicodeString(true, gPluralCountOther, 5));
}
if (currencyPluralPattern == nullptr) {
// no currencyUnitPatterns defined,
@@ -289,7 +289,7 @@ CurrencyPluralInfo::setupCurrencyPluralPattern(const Locale& loc, UErrorCode& st
ures_getByKeyWithFallback(numElements.getAlias(), ns->getName(), rb.getAlias(), &ec);
ures_getByKeyWithFallback(rb.getAlias(), gPatternsTag, rb.getAlias(), &ec);
int32_t ptnLen;
- const UChar* numberStylePattern = ures_getStringByKeyWithFallback(rb.getAlias(), gDecimalFormatTag, &ptnLen, &ec);
+ const char16_t* numberStylePattern = ures_getStringByKeyWithFallback(rb.getAlias(), gDecimalFormatTag, &ptnLen, &ec);
// Fall back to "latn" if num sys specific pattern isn't there.
if ( ec == U_MISSING_RESOURCE_ERROR && (uprv_strcmp(ns->getName(), gLatnTag) != 0)) {
ec = U_ZERO_ERROR;
@@ -298,7 +298,7 @@ CurrencyPluralInfo::setupCurrencyPluralPattern(const Locale& loc, UErrorCode& st
numberStylePattern = ures_getStringByKeyWithFallback(rb.getAlias(), gDecimalFormatTag, &ptnLen, &ec);
}
int32_t numberStylePatternLen = ptnLen;
- const UChar* negNumberStylePattern = nullptr;
+ const char16_t* negNumberStylePattern = nullptr;
int32_t negNumberStylePatternLen = 0;
// TODO: Java
// parse to check whether there is ";" separator in the numberStylePattern
@@ -335,7 +335,7 @@ CurrencyPluralInfo::setupCurrencyPluralPattern(const Locale& loc, UErrorCode& st
while (((pluralCount = keywords->next(nullptr, ec)) != nullptr) && U_SUCCESS(ec)) {
int32_t ptnLength;
UErrorCode err = U_ZERO_ERROR;
- const UChar* patternChars = ures_getStringByKeyWithFallback(currencyRes.getAlias(), pluralCount, &ptnLength, &err);
+ const char16_t* patternChars = ures_getStringByKeyWithFallback(currencyRes.getAlias(), pluralCount, &ptnLength, &err);
if (err == U_MEMORY_ALLOCATION_ERROR || patternChars == nullptr) {
ec = err;
break;
@@ -351,15 +351,15 @@ CurrencyPluralInfo::setupCurrencyPluralPattern(const Locale& loc, UErrorCode& st
pattern->extract(0, pattern->length(), result_1, "UTF-8");
std::cout << "pluralCount: " << pluralCount << "; pattern: " << result_1 << "\n";
#endif
- pattern->findAndReplace(UnicodeString(TRUE, gPart0, 3),
+ pattern->findAndReplace(UnicodeString(true, gPart0, 3),
UnicodeString(numberStylePattern, numberStylePatternLen));
- pattern->findAndReplace(UnicodeString(TRUE, gPart1, 3), UnicodeString(TRUE, gTripleCurrencySign, 3));
+ pattern->findAndReplace(UnicodeString(true, gPart1, 3), UnicodeString(true, gTripleCurrencySign, 3));
if (hasSeparator) {
UnicodeString negPattern(patternChars, ptnLength);
- negPattern.findAndReplace(UnicodeString(TRUE, gPart0, 3),
+ negPattern.findAndReplace(UnicodeString(true, gPart0, 3),
UnicodeString(negNumberStylePattern, negNumberStylePatternLen));
- negPattern.findAndReplace(UnicodeString(TRUE, gPart1, 3), UnicodeString(TRUE, gTripleCurrencySign, 3));
+ negPattern.findAndReplace(UnicodeString(true, gPart1, 3), UnicodeString(true, gTripleCurrencySign, 3));
pattern->append(gNumberPatternSeparator);
pattern->append(negPattern);
}
@@ -400,7 +400,7 @@ CurrencyPluralInfo::initHash(UErrorCode& status) {
if (U_FAILURE(status)) {
return nullptr;
}
- LocalPointer<Hashtable> hTable(new Hashtable(TRUE, status), status);
+ LocalPointer<Hashtable> hTable(new Hashtable(true, status), status);
if (U_FAILURE(status)) {
return nullptr;
}
diff --git a/contrib/libs/icu/i18n/currunit.cpp b/contrib/libs/icu/i18n/currunit.cpp
index 92bcf1268a..98f28365cf 100644
--- a/contrib/libs/icu/i18n/currunit.cpp
+++ b/contrib/libs/icu/i18n/currunit.cpp
@@ -48,7 +48,7 @@ CurrencyUnit::CurrencyUnit(ConstChar16Ptr _isoCode, UErrorCode& ec) {
isoCode[3] = 0;
}
if (useDefault) {
- uprv_memcpy(isoCode, kDefaultCurrency, sizeof(UChar) * 4);
+ uprv_memcpy(isoCode, kDefaultCurrency, sizeof(char16_t) * 4);
}
char simpleIsoCode[4];
u_UCharsToChars(isoCode, simpleIsoCode, 4);
diff --git a/contrib/libs/icu/i18n/dangical.cpp b/contrib/libs/icu/i18n/dangical.cpp
index 57fe80220b..2b340ee4b4 100644
--- a/contrib/libs/icu/i18n/dangical.cpp
+++ b/contrib/libs/icu/i18n/dangical.cpp
@@ -23,8 +23,8 @@
#include "unicode/tzrule.h"
// --- The cache --
-static icu::TimeZone *gDangiCalendarZoneAstroCalc = NULL;
-static icu::UInitOnce gDangiCalendarInitOnce = U_INITONCE_INITIALIZER;
+static icu::TimeZone *gDangiCalendarZoneAstroCalc = nullptr;
+static icu::UInitOnce gDangiCalendarInitOnce {};
/**
* The start year of the Korean traditional calendar (Dan-gi) is the inaugural
@@ -33,13 +33,13 @@ static icu::UInitOnce gDangiCalendarInitOnce = U_INITONCE_INITIALIZER;
static const int32_t DANGI_EPOCH_YEAR = -2332; // Gregorian year
U_CDECL_BEGIN
-static UBool calendar_dangi_cleanup(void) {
+static UBool calendar_dangi_cleanup() {
if (gDangiCalendarZoneAstroCalc) {
delete gDangiCalendarZoneAstroCalc;
- gDangiCalendarZoneAstroCalc = NULL;
+ gDangiCalendarZoneAstroCalc = nullptr;
}
gDangiCalendarInitOnce.reset();
- return TRUE;
+ return true;
}
U_CDECL_END
@@ -141,6 +141,23 @@ const TimeZone* DangiCalendar::getDangiCalZoneAstroCalc(UErrorCode &status) cons
return gDangiCalendarZoneAstroCalc;
}
+constexpr uint32_t kDangiRelatedYearDiff = -2333;
+
+int32_t DangiCalendar::getRelatedYear(UErrorCode &status) const
+{
+ int32_t year = get(UCAL_EXTENDED_YEAR, status);
+ if (U_FAILURE(status)) {
+ return 0;
+ }
+ return year + kDangiRelatedYearDiff;
+}
+
+void DangiCalendar::setRelatedYear(int32_t year)
+{
+ // set extended year
+ set(UCAL_EXTENDED_YEAR, year - kDangiRelatedYearDiff);
+}
+
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DangiCalendar)
diff --git a/contrib/libs/icu/i18n/dangical.h b/contrib/libs/icu/i18n/dangical.h
index 9d0437264e..3e5b0bb859 100644
--- a/contrib/libs/icu/i18n/dangical.h
+++ b/contrib/libs/icu/i18n/dangical.h
@@ -72,6 +72,20 @@ class DangiCalendar : public ChineseCalendar {
// Internal methods & astronomical calculations
//----------------------------------------------------------------------
+ /**
+ * @return The related Gregorian year; will be obtained by modifying the value
+ * obtained by get from UCAL_EXTENDED_YEAR field
+ * @internal
+ */
+ virtual int32_t getRelatedYear(UErrorCode &status) const override;
+
+ /**
+ * @param year The related Gregorian year to set; will be modified as necessary then
+ * set in UCAL_EXTENDED_YEAR field
+ * @internal
+ */
+ virtual void setRelatedYear(int32_t year) override;
+
private:
const TimeZone* getDangiCalZoneAstroCalc(UErrorCode &status) const;
@@ -83,7 +97,7 @@ class DangiCalendar : public ChineseCalendar {
* same class ID. Objects of other classes have different class IDs.
* @internal
*/
- virtual UClassID getDynamicClassID(void) const override;
+ virtual UClassID getDynamicClassID() const override;
/**
* Return the class ID for this class. This is useful only for comparing to a return
@@ -96,7 +110,7 @@ class DangiCalendar : public ChineseCalendar {
* @return The class ID for all objects of this class.
* @internal
*/
- U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
+ U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
/**
* return the calendar type, "dangi".
diff --git a/contrib/libs/icu/i18n/datefmt.cpp b/contrib/libs/icu/i18n/datefmt.cpp
index fed8f79aa0..029634e3dc 100644
--- a/contrib/libs/icu/i18n/datefmt.cpp
+++ b/contrib/libs/icu/i18n/datefmt.cpp
@@ -46,7 +46,7 @@
U_NAMESPACE_BEGIN
-class U_I18N_API DateFmtBestPattern : public SharedObject {
+class DateFmtBestPattern : public SharedObject {
public:
UnicodeString fPattern;
@@ -58,14 +58,14 @@ public:
DateFmtBestPattern::~DateFmtBestPattern() {
}
-template<> U_I18N_API
+template<>
const DateFmtBestPattern *LocaleCacheKey<DateFmtBestPattern>::createObject(
const void * /*creationContext*/, UErrorCode &status) const {
status = U_UNSUPPORTED_ERROR;
- return NULL;
+ return nullptr;
}
-class U_I18N_API DateFmtBestPatternKey : public LocaleCacheKey<DateFmtBestPattern> {
+class DateFmtBestPatternKey : public LocaleCacheKey<DateFmtBestPattern> {
private:
UnicodeString fSkeleton;
protected:
@@ -101,7 +101,7 @@ public:
LocalPointer<DateTimePatternGenerator> dtpg(
DateTimePatternGenerator::createInstance(fLoc, status));
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
LocalPointer<DateFmtBestPattern> pattern(
@@ -109,7 +109,7 @@ public:
dtpg->getBestPattern(fSkeleton, status)),
status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
DateFmtBestPattern *result = pattern.orphan();
result->addRef();
@@ -149,12 +149,12 @@ DateFormat& DateFormat::operator=(const DateFormat& other)
if(other.fCalendar) {
fCalendar = other.fCalendar->clone();
} else {
- fCalendar = NULL;
+ fCalendar = nullptr;
}
if(other.fNumberFormat) {
fNumberFormat = other.fNumberFormat->clone();
} else {
- fNumberFormat = NULL;
+ fNumberFormat = nullptr;
}
fBoolFlags = other.fBoolFlags;
fCapitalizationContext = other.fCapitalizationContext;
@@ -175,18 +175,17 @@ DateFormat::~DateFormat()
bool
DateFormat::operator==(const Format& other) const
{
- // This protected comparison operator should only be called by subclasses
- // which have confirmed that the other object being compared against is
- // an instance of a sublcass of DateFormat. THIS IS IMPORTANT.
-
+ if (this == &other) {
+ return true;
+ }
+ if (!(Format::operator==(other))) {
+ return false;
+ }
// Format::operator== guarantees that this cast is safe
DateFormat* fmt = (DateFormat*)&other;
-
- return (this == fmt) ||
- (Format::operator==(other) &&
- fCalendar&&(fCalendar->isEquivalentTo(*fmt->fCalendar)) &&
+ return fCalendar&&(fCalendar->isEquivalentTo(*fmt->fCalendar)) &&
(fNumberFormat && *fNumberFormat == *fmt->fNumberFormat) &&
- (fCapitalizationContext == fmt->fCapitalizationContext) );
+ (fCapitalizationContext == fmt->fCapitalizationContext);
}
//----------------------------------------------------------------------
@@ -277,10 +276,10 @@ DateFormat::format(Calendar& /* unused cal */,
UnicodeString&
DateFormat::format(UDate date, UnicodeString& appendTo, FieldPosition& fieldPosition) const {
- if (fCalendar != NULL) {
+ if (fCalendar != nullptr) {
// Use a clone of our calendar instance
Calendar* calClone = fCalendar->clone();
- if (calClone != NULL) {
+ if (calClone != nullptr) {
UErrorCode ec = U_ZERO_ERROR;
calClone->setTime(date, ec);
if (U_SUCCESS(ec)) {
@@ -297,9 +296,9 @@ DateFormat::format(UDate date, UnicodeString& appendTo, FieldPosition& fieldPosi
UnicodeString&
DateFormat::format(UDate date, UnicodeString& appendTo, FieldPositionIterator* posIter,
UErrorCode& status) const {
- if (fCalendar != NULL) {
+ if (fCalendar != nullptr) {
Calendar* calClone = fCalendar->clone();
- if (calClone != NULL) {
+ if (calClone != nullptr) {
calClone->setTime(date, status);
if (U_SUCCESS(status)) {
format(*calClone, appendTo, posIter, status);
@@ -328,9 +327,9 @@ DateFormat::parse(const UnicodeString& text,
ParsePosition& pos) const
{
UDate d = 0; // Error return UDate is 0 (the epoch)
- if (fCalendar != NULL) {
+ if (fCalendar != nullptr) {
Calendar* calClone = fCalendar->clone();
- if (calClone != NULL) {
+ if (calClone != nullptr) {
int32_t start = pos.getIndex();
calClone->clear();
parse(text, *calClone, pos);
@@ -434,7 +433,7 @@ DateFormat::getBestPattern(
return UnicodeString();
}
DateFmtBestPatternKey key(locale, skeleton, status);
- const DateFmtBestPattern *patternPtr = NULL;
+ const DateFmtBestPattern *patternPtr = nullptr;
cache->get(key, patternPtr, status);
if (U_FAILURE(status)) {
return UnicodeString();
@@ -452,20 +451,20 @@ DateFormat::createInstanceForSkeleton(
UErrorCode &status) {
LocalPointer<Calendar> calendar(calendarToAdopt);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
if (calendar.isNull()) {
status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
Locale localeWithCalendar = locale;
localeWithCalendar.setKeywordValue("calendar", calendar->getType(), status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
DateFormat *result = createInstanceForSkeleton(skeleton, localeWithCalendar, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
result->adoptCalendar(calendar.orphan());
return result;
@@ -477,14 +476,14 @@ DateFormat::createInstanceForSkeleton(
const Locale &locale,
UErrorCode &status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
LocalPointer<DateFormat> df(
new SimpleDateFormat(
getBestPattern(locale, skeleton, status),
locale, status),
status);
- return U_SUCCESS(status) ? df.orphan() : NULL;
+ return U_SUCCESS(status) ? df.orphan() : nullptr;
}
DateFormat* U_EXPORT2
@@ -568,7 +567,7 @@ void
DateFormat::setCalendar(const Calendar& newCalendar)
{
Calendar* newCalClone = newCalendar.clone();
- if (newCalClone != NULL) {
+ if (newCalClone != nullptr) {
adoptCalendar(newCalClone);
}
}
@@ -588,8 +587,8 @@ DateFormat::adoptNumberFormat(NumberFormat* newNumberFormat)
{
delete fNumberFormat;
fNumberFormat = newNumberFormat;
- newNumberFormat->setParseIntegerOnly(TRUE);
- newNumberFormat->setGroupingUsed(FALSE);
+ newNumberFormat->setParseIntegerOnly(true);
+ newNumberFormat->setGroupingUsed(false);
}
//----------------------------------------------------------------------
@@ -597,7 +596,7 @@ void
DateFormat::setNumberFormat(const NumberFormat& newNumberFormat)
{
NumberFormat* newNumFmtClone = newNumberFormat.clone();
- if (newNumFmtClone != NULL) {
+ if (newNumFmtClone != nullptr) {
adoptNumberFormat(newNumFmtClone);
}
}
@@ -615,7 +614,7 @@ DateFormat::getNumberFormat() const
void
DateFormat::adoptTimeZone(TimeZone* zone)
{
- if (fCalendar != NULL) {
+ if (fCalendar != nullptr) {
fCalendar->adoptTimeZone(zone);
}
}
@@ -624,7 +623,7 @@ DateFormat::adoptTimeZone(TimeZone* zone)
void
DateFormat::setTimeZone(const TimeZone& zone)
{
- if (fCalendar != NULL) {
+ if (fCalendar != nullptr) {
fCalendar->setTimeZone(zone);
}
}
@@ -634,7 +633,7 @@ DateFormat::setTimeZone(const TimeZone& zone)
const TimeZone&
DateFormat::getTimeZone() const
{
- if (fCalendar != NULL) {
+ if (fCalendar != nullptr) {
return fCalendar->getTimeZone();
}
// If calendar doesn't exists, create default timezone.
@@ -647,7 +646,7 @@ DateFormat::getTimeZone() const
void
DateFormat::setLenient(UBool lenient)
{
- if (fCalendar != NULL) {
+ if (fCalendar != nullptr) {
fCalendar->setLenient(lenient);
}
UErrorCode status = U_ZERO_ERROR;
@@ -660,8 +659,8 @@ DateFormat::setLenient(UBool lenient)
UBool
DateFormat::isLenient() const
{
- UBool lenient = TRUE;
- if (fCalendar != NULL) {
+ UBool lenient = true;
+ if (fCalendar != nullptr) {
lenient = fCalendar->isLenient();
}
UErrorCode status = U_ZERO_ERROR;
@@ -673,7 +672,7 @@ DateFormat::isLenient() const
void
DateFormat::setCalendarLenient(UBool lenient)
{
- if (fCalendar != NULL) {
+ if (fCalendar != nullptr) {
fCalendar->setLenient(lenient);
}
}
@@ -683,11 +682,11 @@ DateFormat::setCalendarLenient(UBool lenient)
UBool
DateFormat::isCalendarLenient() const
{
- if (fCalendar != NULL) {
+ if (fCalendar != nullptr) {
return fCalendar->isLenient();
}
// fCalendar is rarely null
- return FALSE;
+ return false;
}
diff --git a/contrib/libs/icu/i18n/dayperiodrules.cpp b/contrib/libs/icu/i18n/dayperiodrules.cpp
index efe92dd794..3d9ab5bfac 100644
--- a/contrib/libs/icu/i18n/dayperiodrules.cpp
+++ b/contrib/libs/icu/i18n/dayperiodrules.cpp
@@ -27,12 +27,12 @@ U_NAMESPACE_BEGIN
namespace {
struct DayPeriodRulesData : public UMemory {
- DayPeriodRulesData() : localeToRuleSetNumMap(NULL), rules(NULL), maxRuleSetNum(0) {}
+ DayPeriodRulesData() : localeToRuleSetNumMap(nullptr), rules(nullptr), maxRuleSetNum(0) {}
UHashtable *localeToRuleSetNumMap;
DayPeriodRules *rules;
int32_t maxRuleSetNum;
-} *data = NULL;
+} *data = nullptr;
enum CutoffType {
CUTOFF_TYPE_UNKNOWN = -1,
@@ -67,7 +67,7 @@ struct DayPeriodRulesDataSink : public ResourceSink {
} else if (uprv_strcmp(key, "rules") == 0) {
// Allocate one more than needed to skip [0]. See comment in parseSetNum().
data->rules = new DayPeriodRules[data->maxRuleSetNum + 1];
- if (data->rules == NULL) {
+ if (data->rules == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -196,9 +196,9 @@ struct DayPeriodRulesDataSink : public ResourceSink {
// AT cutoffs must be either midnight or noon.
if (cutoffs[startHour] & (1 << CUTOFF_TYPE_AT)) {
if (startHour == 0 && period == DayPeriodRules::DAYPERIOD_MIDNIGHT) {
- rule.fHasMidnight = TRUE;
+ rule.fHasMidnight = true;
} else if (startHour == 12 && period == DayPeriodRules::DAYPERIOD_NOON) {
- rule.fHasNoon = TRUE;
+ rule.fHasNoon = true;
} else {
errorCode = U_INVALID_FORMAT_ERROR; // Bad data.
return;
@@ -301,14 +301,14 @@ DayPeriodRulesCountSink::~DayPeriodRulesCountSink() {}
namespace {
-UInitOnce initOnce = U_INITONCE_INITIALIZER;
+UInitOnce initOnce {};
U_CFUNC UBool U_CALLCONV dayPeriodRulesCleanup() {
delete[] data->rules;
uhash_close(data->localeToRuleSetNumMap);
delete data;
- data = NULL;
- return TRUE;
+ data = nullptr;
+ return true;
}
} // namespace
@@ -319,8 +319,8 @@ void U_CALLCONV DayPeriodRules::load(UErrorCode &errorCode) {
}
data = new DayPeriodRulesData();
- data->localeToRuleSetNumMap = uhash_open(uhash_hashChars, uhash_compareChars, NULL, &errorCode);
- LocalUResourceBundlePointer rb_dayPeriods(ures_openDirect(NULL, "dayPeriods", &errorCode));
+ data->localeToRuleSetNumMap = uhash_open(uhash_hashChars, uhash_compareChars, nullptr, &errorCode);
+ LocalUResourceBundlePointer rb_dayPeriods(ures_openDirect(nullptr, "dayPeriods", &errorCode));
// Get the largest rule set number (so we allocate enough objects).
DayPeriodRulesCountSink countSink;
@@ -337,8 +337,8 @@ const DayPeriodRules *DayPeriodRules::getInstance(const Locale &locale, UErrorCo
umtx_initOnce(initOnce, DayPeriodRules::load, errorCode);
// If the entire day period rules data doesn't conform to spec (even if the part we want
- // does), return NULL.
- if(U_FAILURE(errorCode)) { return NULL; }
+ // does), return nullptr.
+ if(U_FAILURE(errorCode)) { return nullptr; }
const char *localeCode = locale.getBaseName();
char name[ULOC_FULLNAME_CAPACITY];
@@ -353,7 +353,7 @@ const DayPeriodRules *DayPeriodRules::getInstance(const Locale &locale, UErrorCo
}
} else {
errorCode = U_BUFFER_OVERFLOW_ERROR;
- return NULL;
+ return nullptr;
}
int32_t ruleSetNum = 0; // NB there is no rule set 0 and 0 is returned upon lookup failure.
@@ -375,13 +375,13 @@ const DayPeriodRules *DayPeriodRules::getInstance(const Locale &locale, UErrorCo
if (ruleSetNum <= 0 || data->rules[ruleSetNum].getDayPeriodForHour(0) == DAYPERIOD_UNKNOWN) {
// If day period for hour 0 is UNKNOWN then day period for all hours are UNKNOWN.
// Data doesn't exist even with fallback.
- return NULL;
+ return nullptr;
} else {
return &data->rules[ruleSetNum];
}
}
-DayPeriodRules::DayPeriodRules() : fHasMidnight(FALSE), fHasNoon(FALSE) {
+DayPeriodRules::DayPeriodRules() : fHasMidnight(false), fHasNoon(false) {
for (int32_t i = 0; i < 24; ++i) {
fDayPeriodForHour[i] = DayPeriodRules::DAYPERIOD_UNKNOWN;
}
@@ -504,10 +504,10 @@ void DayPeriodRules::add(int32_t startHour, int32_t limitHour, DayPeriod period)
UBool DayPeriodRules::allHoursAreSet() {
for (int32_t i = 0; i < 24; ++i) {
- if (fDayPeriodForHour[i] == DAYPERIOD_UNKNOWN) { return FALSE; }
+ if (fDayPeriodForHour[i] == DAYPERIOD_UNKNOWN) { return false; }
}
- return TRUE;
+ return true;
}
diff --git a/contrib/libs/icu/i18n/dcfmtsym.cpp b/contrib/libs/icu/i18n/dcfmtsym.cpp
index 4f5bae4e11..ac1f777399 100644
--- a/contrib/libs/icu/i18n/dcfmtsym.cpp
+++ b/contrib/libs/icu/i18n/dcfmtsym.cpp
@@ -59,38 +59,38 @@ static const char gLatn[] = "latn";
static const char gSymbols[] = "symbols";
static const char gNumberElementsLatnSymbols[] = "NumberElements/latn/symbols";
-static const UChar INTL_CURRENCY_SYMBOL_STR[] = {0xa4, 0xa4, 0};
+static const char16_t INTL_CURRENCY_SYMBOL_STR[] = {0xa4, 0xa4, 0};
// List of field names to be loaded from the data files.
// These are parallel with the enum ENumberFormatSymbol in unicode/dcfmtsym.h.
static const char *gNumberElementKeys[DecimalFormatSymbols::kFormatSymbolCount] = {
"decimal",
"group",
- NULL, /* #11897: the <list> symbol is NOT the pattern separator symbol */
+ nullptr, /* #11897: the <list> symbol is NOT the pattern separator symbol */
"percentSign",
- NULL, /* Native zero digit is deprecated from CLDR - get it from the numbering system */
- NULL, /* Pattern digit character is deprecated from CLDR - use # by default always */
+ nullptr, /* Native zero digit is deprecated from CLDR - get it from the numbering system */
+ nullptr, /* Pattern digit character is deprecated from CLDR - use # by default always */
"minusSign",
"plusSign",
- NULL, /* currency symbol - Wait until we know the currency before loading from CLDR */
- NULL, /* intl currency symbol - Wait until we know the currency before loading from CLDR */
+ nullptr, /* currency symbol - Wait until we know the currency before loading from CLDR */
+ nullptr, /* intl currency symbol - Wait until we know the currency before loading from CLDR */
"currencyDecimal",
"exponential",
"perMille",
- NULL, /* Escape padding character - not in CLDR */
+ nullptr, /* Escape padding character - not in CLDR */
"infinity",
"nan",
- NULL, /* Significant digit symbol - not in CLDR */
+ nullptr, /* Significant digit symbol - not in CLDR */
"currencyGroup",
- NULL, /* one digit - get it from the numbering system */
- NULL, /* two digit - get it from the numbering system */
- NULL, /* three digit - get it from the numbering system */
- NULL, /* four digit - get it from the numbering system */
- NULL, /* five digit - get it from the numbering system */
- NULL, /* six digit - get it from the numbering system */
- NULL, /* seven digit - get it from the numbering system */
- NULL, /* eight digit - get it from the numbering system */
- NULL, /* nine digit - get it from the numbering system */
+ nullptr, /* one digit - get it from the numbering system */
+ nullptr, /* two digit - get it from the numbering system */
+ nullptr, /* three digit - get it from the numbering system */
+ nullptr, /* four digit - get it from the numbering system */
+ nullptr, /* five digit - get it from the numbering system */
+ nullptr, /* six digit - get it from the numbering system */
+ nullptr, /* seven digit - get it from the numbering system */
+ nullptr, /* eight digit - get it from the numbering system */
+ nullptr, /* nine digit - get it from the numbering system */
"superscriptingExponent", /* Multiplication (x) symbol for exponents */
"approximatelySign" /* Approximately sign symbol */
};
@@ -99,34 +99,34 @@ static const char *gNumberElementKeys[DecimalFormatSymbols::kFormatSymbolCount]
// Initializes this with the decimal format symbols in the default locale.
DecimalFormatSymbols::DecimalFormatSymbols(UErrorCode& status)
- : UObject(), locale(), currPattern(NULL) {
- initialize(locale, status, TRUE);
+ : UObject(), locale() {
+ initialize(locale, status, true);
}
// -------------------------------------
// Initializes this with the decimal format symbols in the desired locale.
DecimalFormatSymbols::DecimalFormatSymbols(const Locale& loc, UErrorCode& status)
- : UObject(), locale(loc), currPattern(NULL) {
+ : UObject(), locale(loc) {
initialize(locale, status);
}
DecimalFormatSymbols::DecimalFormatSymbols(const Locale& loc, const NumberingSystem& ns, UErrorCode& status)
- : UObject(), locale(loc), currPattern(NULL) {
- initialize(locale, status, FALSE, &ns);
+ : UObject(), locale(loc) {
+ initialize(locale, status, false, &ns);
}
DecimalFormatSymbols::DecimalFormatSymbols()
- : UObject(), locale(Locale::getRoot()), currPattern(NULL) {
+ : UObject(), locale(Locale::getRoot()) {
*validLocale = *actualLocale = 0;
initialize();
}
DecimalFormatSymbols*
DecimalFormatSymbols::createWithLastResortData(UErrorCode& status) {
- if (U_FAILURE(status)) { return NULL; }
+ if (U_FAILURE(status)) { return nullptr; }
DecimalFormatSymbols* sym = new DecimalFormatSymbols();
- if (sym == NULL) {
+ if (sym == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
return sym;
@@ -169,6 +169,7 @@ DecimalFormatSymbols::operator=(const DecimalFormatSymbols& rhs)
fIsCustomIntlCurrencySymbol = rhs.fIsCustomIntlCurrencySymbol;
fCodePointZero = rhs.fCodePointZero;
currPattern = rhs.currPattern;
+ uprv_strcpy(nsName, rhs.nsName);
}
return *this;
}
@@ -227,7 +228,7 @@ struct DecFmtSymDataSink : public ResourceSink {
// Constructor/Destructor
DecFmtSymDataSink(DecimalFormatSymbols& _dfs) : dfs(_dfs) {
- uprv_memset(seenSymbol, FALSE, sizeof(seenSymbol));
+ uprv_memset(seenSymbol, false, sizeof(seenSymbol));
}
virtual ~DecFmtSymDataSink();
@@ -237,9 +238,9 @@ struct DecFmtSymDataSink : public ResourceSink {
if (U_FAILURE(errorCode)) { return; }
for (int32_t j = 0; symbolsTable.getKeyAndValue(j, key, value); ++j) {
for (int32_t i=0; i<DecimalFormatSymbols::kFormatSymbolCount; i++) {
- if (gNumberElementKeys[i] != NULL && uprv_strcmp(key, gNumberElementKeys[i]) == 0) {
+ if (gNumberElementKeys[i] != nullptr && uprv_strcmp(key, gNumberElementKeys[i]) == 0) {
if (!seenSymbol[i]) {
- seenSymbol[i] = TRUE;
+ seenSymbol[i] = true;
dfs.setSymbol(
(DecimalFormatSymbols::ENumberFormatSymbol) i,
value.getUnicodeString(errorCode));
@@ -255,10 +256,10 @@ struct DecFmtSymDataSink : public ResourceSink {
UBool seenAll() {
for (int32_t i=0; i<DecimalFormatSymbols::kFormatSymbolCount; i++) {
if (!seenSymbol[i]) {
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
// If monetary decimal or grouping were not explicitly set, then set them to be the
@@ -283,7 +284,7 @@ struct CurrencySpacingSink : public ResourceSink {
UBool hasAfterCurrency;
CurrencySpacingSink(DecimalFormatSymbols& _dfs)
- : dfs(_dfs), hasBeforeCurrency(FALSE), hasAfterCurrency(FALSE) {}
+ : dfs(_dfs), hasBeforeCurrency(false), hasAfterCurrency(false) {}
virtual ~CurrencySpacingSink();
virtual void put(const char *key, ResourceValue &value, UBool /*noFallback*/,
@@ -292,11 +293,11 @@ struct CurrencySpacingSink : public ResourceSink {
for (int32_t i = 0; spacingTypesTable.getKeyAndValue(i, key, value); ++i) {
UBool beforeCurrency;
if (uprv_strcmp(key, gBeforeCurrencyTag) == 0) {
- beforeCurrency = TRUE;
- hasBeforeCurrency = TRUE;
+ beforeCurrency = true;
+ hasBeforeCurrency = true;
} else if (uprv_strcmp(key, gAfterCurrencyTag) == 0) {
- beforeCurrency = FALSE;
- hasAfterCurrency = TRUE;
+ beforeCurrency = false;
+ hasAfterCurrency = true;
} else {
continue;
}
@@ -329,11 +330,13 @@ struct CurrencySpacingSink : public ResourceSink {
// both beforeCurrency and afterCurrency were found in CLDR.
static const char* defaults[] = { "[:letter:]", "[:digit:]", " " };
if (!hasBeforeCurrency || !hasAfterCurrency) {
- for (UBool beforeCurrency = 0; beforeCurrency <= TRUE; beforeCurrency++) {
- for (int32_t pattern = 0; pattern < UNUM_CURRENCY_SPACING_COUNT; pattern++) {
- dfs.setPatternForCurrencySpacing((UCurrencySpacing)pattern,
- beforeCurrency, UnicodeString(defaults[pattern], -1, US_INV));
- }
+ for (int32_t pattern = 0; pattern < UNUM_CURRENCY_SPACING_COUNT; pattern++) {
+ dfs.setPatternForCurrencySpacing((UCurrencySpacing)pattern,
+ false, UnicodeString(defaults[pattern], -1, US_INV));
+ }
+ for (int32_t pattern = 0; pattern < UNUM_CURRENCY_SPACING_COUNT; pattern++) {
+ dfs.setPatternForCurrencySpacing((UCurrencySpacing)pattern,
+ true, UnicodeString(defaults[pattern], -1, US_INV));
}
}
}
@@ -381,12 +384,13 @@ DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status,
} else {
nsName = gLatn;
}
+ uprv_strcpy(this->nsName, nsName);
// Open resource bundles
const char* locStr = loc.getName();
- LocalUResourceBundlePointer resource(ures_open(NULL, locStr, &status));
+ LocalUResourceBundlePointer resource(ures_open(nullptr, locStr, &status));
LocalUResourceBundlePointer numberElementsRes(
- ures_getByKeyWithFallback(resource.getAlias(), gNumberElements, NULL, &status));
+ ures_getByKeyWithFallback(resource.getAlias(), gNumberElements, nullptr, &status));
if (U_FAILURE(status)) {
if ( useLastResortData ) {
@@ -457,7 +461,7 @@ DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status,
// Get the default currency from the currency API.
UErrorCode internalStatus = U_ZERO_ERROR; // don't propagate failures out
- UChar curriso[4];
+ char16_t curriso[4];
UnicodeString tempStr;
int32_t currisoLength = ucurr_forLocale(locStr, curriso, UPRV_LENGTHOF(curriso), &internalStatus);
if (U_SUCCESS(internalStatus) && currisoLength == 3) {
@@ -481,44 +485,44 @@ DecimalFormatSymbols::initialize() {
* cannot initialize a static array with class constructors.
* markus 2000may25
*/
- fSymbols[kDecimalSeparatorSymbol] = (UChar)0x2e; // '.' decimal separator
+ fSymbols[kDecimalSeparatorSymbol] = (char16_t)0x2e; // '.' decimal separator
fSymbols[kGroupingSeparatorSymbol].remove(); // group (thousands) separator
- fSymbols[kPatternSeparatorSymbol] = (UChar)0x3b; // ';' pattern separator
- fSymbols[kPercentSymbol] = (UChar)0x25; // '%' percent sign
- fSymbols[kZeroDigitSymbol] = (UChar)0x30; // '0' native 0 digit
- fSymbols[kOneDigitSymbol] = (UChar)0x31; // '1' native 1 digit
- fSymbols[kTwoDigitSymbol] = (UChar)0x32; // '2' native 2 digit
- fSymbols[kThreeDigitSymbol] = (UChar)0x33; // '3' native 3 digit
- fSymbols[kFourDigitSymbol] = (UChar)0x34; // '4' native 4 digit
- fSymbols[kFiveDigitSymbol] = (UChar)0x35; // '5' native 5 digit
- fSymbols[kSixDigitSymbol] = (UChar)0x36; // '6' native 6 digit
- fSymbols[kSevenDigitSymbol] = (UChar)0x37; // '7' native 7 digit
- fSymbols[kEightDigitSymbol] = (UChar)0x38; // '8' native 8 digit
- fSymbols[kNineDigitSymbol] = (UChar)0x39; // '9' native 9 digit
- fSymbols[kDigitSymbol] = (UChar)0x23; // '#' pattern digit
- fSymbols[kPlusSignSymbol] = (UChar)0x002b; // '+' plus sign
- fSymbols[kMinusSignSymbol] = (UChar)0x2d; // '-' minus sign
- fSymbols[kCurrencySymbol] = (UChar)0xa4; // 'OX' currency symbol
- fSymbols[kIntlCurrencySymbol].setTo(TRUE, INTL_CURRENCY_SYMBOL_STR, 2);
- fSymbols[kMonetarySeparatorSymbol] = (UChar)0x2e; // '.' monetary decimal separator
- fSymbols[kExponentialSymbol] = (UChar)0x45; // 'E' exponential
- fSymbols[kPerMillSymbol] = (UChar)0x2030; // '%o' per mill
- fSymbols[kPadEscapeSymbol] = (UChar)0x2a; // '*' pad escape symbol
- fSymbols[kInfinitySymbol] = (UChar)0x221e; // 'oo' infinite
- fSymbols[kNaNSymbol] = (UChar)0xfffd; // SUB NaN
- fSymbols[kSignificantDigitSymbol] = (UChar)0x0040; // '@' significant digit
+ fSymbols[kPatternSeparatorSymbol] = (char16_t)0x3b; // ';' pattern separator
+ fSymbols[kPercentSymbol] = (char16_t)0x25; // '%' percent sign
+ fSymbols[kZeroDigitSymbol] = (char16_t)0x30; // '0' native 0 digit
+ fSymbols[kOneDigitSymbol] = (char16_t)0x31; // '1' native 1 digit
+ fSymbols[kTwoDigitSymbol] = (char16_t)0x32; // '2' native 2 digit
+ fSymbols[kThreeDigitSymbol] = (char16_t)0x33; // '3' native 3 digit
+ fSymbols[kFourDigitSymbol] = (char16_t)0x34; // '4' native 4 digit
+ fSymbols[kFiveDigitSymbol] = (char16_t)0x35; // '5' native 5 digit
+ fSymbols[kSixDigitSymbol] = (char16_t)0x36; // '6' native 6 digit
+ fSymbols[kSevenDigitSymbol] = (char16_t)0x37; // '7' native 7 digit
+ fSymbols[kEightDigitSymbol] = (char16_t)0x38; // '8' native 8 digit
+ fSymbols[kNineDigitSymbol] = (char16_t)0x39; // '9' native 9 digit
+ fSymbols[kDigitSymbol] = (char16_t)0x23; // '#' pattern digit
+ fSymbols[kPlusSignSymbol] = (char16_t)0x002b; // '+' plus sign
+ fSymbols[kMinusSignSymbol] = (char16_t)0x2d; // '-' minus sign
+ fSymbols[kCurrencySymbol] = (char16_t)0xa4; // 'OX' currency symbol
+ fSymbols[kIntlCurrencySymbol].setTo(true, INTL_CURRENCY_SYMBOL_STR, 2);
+ fSymbols[kMonetarySeparatorSymbol] = (char16_t)0x2e; // '.' monetary decimal separator
+ fSymbols[kExponentialSymbol] = (char16_t)0x45; // 'E' exponential
+ fSymbols[kPerMillSymbol] = (char16_t)0x2030; // '%o' per mill
+ fSymbols[kPadEscapeSymbol] = (char16_t)0x2a; // '*' pad escape symbol
+ fSymbols[kInfinitySymbol] = (char16_t)0x221e; // 'oo' infinite
+ fSymbols[kNaNSymbol] = (char16_t)0xfffd; // SUB NaN
+ fSymbols[kSignificantDigitSymbol] = (char16_t)0x0040; // '@' significant digit
fSymbols[kMonetaryGroupingSeparatorSymbol].remove(); //
- fSymbols[kExponentMultiplicationSymbol] = (UChar)0xd7; // 'x' multiplication symbol for exponents
+ fSymbols[kExponentMultiplicationSymbol] = (char16_t)0xd7; // 'x' multiplication symbol for exponents
fSymbols[kApproximatelySignSymbol] = u'~'; // '~' approximately sign
- fIsCustomCurrencySymbol = FALSE;
- fIsCustomIntlCurrencySymbol = FALSE;
+ fIsCustomCurrencySymbol = false;
+ fIsCustomIntlCurrencySymbol = false;
fCodePointZero = 0x30;
U_ASSERT(fCodePointZero == fSymbols[kZeroDigitSymbol].char32At(0));
currPattern = nullptr;
-
+ nsName[0] = 0;
}
-void DecimalFormatSymbols::setCurrency(const UChar* currency, UErrorCode& status) {
+void DecimalFormatSymbols::setCurrency(const char16_t* currency, UErrorCode& status) {
// TODO: If this method is made public:
// - Adopt ICU4J behavior of not allowing currency to be null.
// - Also verify that the length of currency is 3.
@@ -541,7 +545,7 @@ void DecimalFormatSymbols::setCurrency(const UChar* currency, UErrorCode& status
UErrorCode localStatus = U_ZERO_ERROR;
LocalUResourceBundlePointer rbTop(ures_open(U_ICUDATA_CURR, locale.getName(), &localStatus));
LocalUResourceBundlePointer rb(
- ures_getByKeyWithFallback(rbTop.getAlias(), "Currencies", NULL, &localStatus));
+ ures_getByKeyWithFallback(rbTop.getAlias(), "Currencies", nullptr, &localStatus));
ures_getByKeyWithFallback(rb.getAlias(), cc, rb.getAlias(), &localStatus);
if(U_SUCCESS(localStatus) && ures_getSize(rb.getAlias())>2) { // the length is 3 if more data is present
ures_getByIndex(rb.getAlias(), 2, rb.getAlias(), &localStatus);
@@ -555,7 +559,7 @@ void DecimalFormatSymbols::setCurrency(const UChar* currency, UErrorCode& status
if(U_SUCCESS(localStatus)){
fSymbols[kMonetaryGroupingSeparatorSymbol] = groupingSep;
fSymbols[kMonetarySeparatorSymbol] = decimalSep;
- //pattern.setTo(TRUE, currPattern, currPatternLen);
+ //pattern.setTo(true, currPattern, currPatternLen);
}
}
/* else An explicit currency was requested and is unknown or locale data is malformed. */
diff --git a/contrib/libs/icu/i18n/decContext.cpp b/contrib/libs/icu/i18n/decContext.cpp
index 421d65b43f..bdc5f22fe5 100644
--- a/contrib/libs/icu/i18n/decContext.cpp
+++ b/contrib/libs/icu/i18n/decContext.cpp
@@ -219,7 +219,7 @@ U_CAPI decContext * U_EXPORT2 uprv_decContextSetStatus(decContext *context, uIn
/* is raised if appropriate. */
/* */
/* returns the context structure, unless the string is equal to */
-/* DEC_Condition_MU or is not recognized. In these cases NULL is */
+/* DEC_Condition_MU or is not recognized. In these cases nullptr is */
/* returned. */
/* ------------------------------------------------------------------ */
U_CAPI decContext * U_EXPORT2 uprv_decContextSetStatusFromString(decContext *context,
@@ -256,7 +256,7 @@ U_CAPI decContext * U_EXPORT2 uprv_decContextSetStatusFromString(decContext *co
return uprv_decContextSetStatus(context, DEC_Underflow);
if (strcmp(string, DEC_Condition_ZE)==0)
return context;
- return NULL; /* Multiple status, or unknown */
+ return nullptr; /* Multiple status, or unknown */
} /* decContextSetStatusFromString */
/* ------------------------------------------------------------------ */
@@ -270,7 +270,7 @@ U_CAPI decContext * U_EXPORT2 uprv_decContextSetStatusFromString(decContext *co
/* raised. */
/* */
/* returns the context structure, unless the string is equal to */
-/* DEC_Condition_MU or is not recognized. In these cases NULL is */
+/* DEC_Condition_MU or is not recognized. In these cases nullptr is */
/* returned. */
/* ------------------------------------------------------------------ */
U_CAPI decContext * U_EXPORT2 uprv_decContextSetStatusFromStringQuiet(decContext *context,
@@ -307,7 +307,7 @@ U_CAPI decContext * U_EXPORT2 uprv_decContextSetStatusFromStringQuiet(decContex
return uprv_decContextSetStatusQuiet(context, DEC_Underflow);
if (strcmp(string, DEC_Condition_ZE)==0)
return context;
- return NULL; /* Multiple status, or unknown */
+ return nullptr; /* Multiple status, or unknown */
} /* decContextSetStatusFromStringQuiet */
/* ------------------------------------------------------------------ */
diff --git a/contrib/libs/icu/i18n/decContext.h b/contrib/libs/icu/i18n/decContext.h
index 59ab65e592..91c6739739 100644
--- a/contrib/libs/icu/i18n/decContext.h
+++ b/contrib/libs/icu/i18n/decContext.h
@@ -262,7 +262,6 @@
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 *);
diff --git a/contrib/libs/icu/i18n/decNumber.cpp b/contrib/libs/icu/i18n/decNumber.cpp
index 71477d8202..42da36dc4b 100644
--- a/contrib/libs/icu/i18n/decNumber.cpp
+++ b/contrib/libs/icu/i18n/decNumber.cpp
@@ -95,11 +95,11 @@
/* conversions are available in separate modules. */
/* */
/* 7. Normally, input operands are assumed to be valid. Set DECCHECK */
-/* to 1 for extended operand checking (including NULL operands). */
-/* Results are undefined if a badly-formed structure (or a NULL */
+/* to 1 for extended operand checking (including nullptr operands). */
+/* Results are undefined if a badly-formed structure (or a nullptr */
/* pointer to a structure) is provided, though with DECCHECK */
/* enabled the operator routines are protected against exceptions. */
-/* (Except if the result pointer is NULL, which is unrecoverable.) */
+/* (Except if the result pointer is nullptr, which is unrecoverable.) */
/* */
/* However, the routines will never cause exceptions if they are */
/* given well-formed operands, even if the value of the operands */
@@ -516,11 +516,11 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromString(decNumber *dn, const char
Unit *res; /* where result will be built */
Unit resbuff[SD2U(DECBUFFER+9)];/* local buffer in case need temporary */
/* [+9 allows for ln() constants] */
- Unit *allocres=NULL; /* -> allocated result, iff allocated */
+ Unit *allocres=nullptr; /* -> allocated result, iff allocated */
Int d=0; /* count of digits found in decimal part */
- const char *dotchar=NULL; /* where dot was found */
+ const char *dotchar=nullptr; /* where dot was found */
const char *cfirst=chars; /* -> first character of decimal part */
- const char *last=NULL; /* -> last digit of decimal part */
+ const char *last=nullptr; /* -> last digit of decimal part */
const char *c; /* work */
Unit *up; /* .. */
#if DECDPUN>1
@@ -541,7 +541,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromString(decNumber *dn, const char
d++; /* count of real digits */
continue; /* still in decimal part */
}
- if (*c=='.' && dotchar==NULL) { /* first '.' */
+ if (*c=='.' && dotchar==nullptr) { /* first '.' */
dotchar=c; /* record offset into decimal part */
if (c==cfirst) cfirst++; /* first digit must follow */
continue;}
@@ -558,7 +558,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromString(decNumber *dn, const char
break;
} /* c */
- if (last==NULL) { /* no digits yet */
+ if (last==nullptr) { /* no digits yet */
status=DEC_Conversion_syntax;/* assume the worst */
if (*c=='\0') break; /* and no more to come... */
#if DECSUBSET
@@ -566,7 +566,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromString(decNumber *dn, const char
if (!set->extended) break; /* hopeless */
#endif
/* Infinities and NaNs are possible, here */
- if (dotchar!=NULL) break; /* .. unless had a dot */
+ if (dotchar!=nullptr) break; /* .. unless had a dot */
uprv_decNumberZero(dn); /* be optimistic */
if (decBiStr(c, "infinity", "INFINITY")
|| decBiStr(c, "inf", "INF")) {
@@ -609,7 +609,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromString(decNumber *dn, const char
/* good; drop through to convert the integer to coefficient */
status=0; /* syntax is OK */
bits=dn->bits; /* for copy-back */
- } /* last==NULL */
+ } /* last==nullptr */
else if (*c!='\0') { /* more to process... */
/* had some digits; exponent is only valid sequence now */
@@ -667,7 +667,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromString(decNumber *dn, const char
} /* at least one leading 0 */
/* Handle decimal point... */
- if (dotchar!=NULL && dotchar<last) /* non-trailing '.' found? */
+ if (dotchar!=nullptr && dotchar<last) /* non-trailing '.' found? */
exponent -= static_cast<int32_t>(last-dotchar); /* adjust exponent */
/* [we can now ignore the .] */
@@ -679,7 +679,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromString(decNumber *dn, const char
res=resbuff; /* assume use local buffer */
if (needbytes>(Int)sizeof(resbuff)) { /* too big for local */
allocres=(Unit *)malloc(needbytes);
- if (allocres==NULL) {status|=DEC_Insufficient_storage; break;}
+ if (allocres==nullptr) {status|=DEC_Insufficient_storage; break;}
res=allocres;
}
}
@@ -736,7 +736,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFromString(decNumber *dn, const char
/* decNumberShow(dn); */
} while(0); /* [for break] */
- if (allocres!=NULL) free(allocres); /* drop any storage used */
+ if (allocres!=nullptr) free(allocres); /* drop any storage used */
if (status!=0) decStatus(dn, status, set);
return dn;
} /* decNumberFromString */
@@ -953,9 +953,9 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberCompareTotalMag(decNumber *res, const
uInt status=0; /* accumulator */
uInt needbytes; /* for space calculations */
decNumber bufa[D2N(DECBUFFER+1)];/* +1 in case DECBUFFER=0 */
- decNumber *allocbufa=NULL; /* -> allocated bufa, iff allocated */
+ decNumber *allocbufa=nullptr; /* -> allocated bufa, iff allocated */
decNumber bufb[D2N(DECBUFFER+1)];
- decNumber *allocbufb=NULL; /* -> allocated bufb, iff allocated */
+ decNumber *allocbufb=nullptr; /* -> allocated bufb, iff allocated */
decNumber *a, *b; /* temporary pointers */
#if DECCHECK
@@ -969,7 +969,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberCompareTotalMag(decNumber *res, const
needbytes=sizeof(decNumber)+(D2U(lhs->digits)-1)*sizeof(Unit);
if (needbytes>sizeof(bufa)) { /* need malloc space */
allocbufa=(decNumber *)malloc(needbytes);
- if (allocbufa==NULL) { /* hopeless -- abandon */
+ if (allocbufa==nullptr) { /* hopeless -- abandon */
status|=DEC_Insufficient_storage;
break;}
a=allocbufa; /* use the allocated space */
@@ -983,7 +983,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberCompareTotalMag(decNumber *res, const
needbytes=sizeof(decNumber)+(D2U(rhs->digits)-1)*sizeof(Unit);
if (needbytes>sizeof(bufb)) { /* need malloc space */
allocbufb=(decNumber *)malloc(needbytes);
- if (allocbufb==NULL) { /* hopeless -- abandon */
+ if (allocbufb==nullptr) { /* hopeless -- abandon */
status|=DEC_Insufficient_storage;
break;}
b=allocbufb; /* use the allocated space */
@@ -995,8 +995,8 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberCompareTotalMag(decNumber *res, const
decCompareOp(res, lhs, rhs, set, COMPTOTAL, &status);
} while(0); /* end protected */
- if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
- if (allocbufb!=NULL) free(allocbufb); /* .. */
+ if (allocbufa!=nullptr) free(allocbufa); /* drop any storage used */
+ if (allocbufb!=nullptr) free(allocbufb); /* .. */
if (status!=0) decStatus(res, status, set);
return res;
} /* decNumberCompareTotalMag */
@@ -1073,7 +1073,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberExp(decNumber *res, const decNumber *
decContext *set) {
uInt status=0; /* accumulator */
#if DECSUBSET
- decNumber *allocrhs=NULL; /* non-NULL if rounded rhs allocated */
+ decNumber *allocrhs=nullptr; /* non-nullptr if rounded rhs allocated */
#endif
#if DECCHECK
@@ -1090,7 +1090,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberExp(decNumber *res, const decNumber *
/* reduce operand and set lostDigits status, as needed */
if (rhs->digits>set->digits) {
allocrhs=decRoundOperand(rhs, set, &status);
- if (allocrhs==NULL) break;
+ if (allocrhs==nullptr) break;
rhs=allocrhs;
}
}
@@ -1099,7 +1099,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberExp(decNumber *res, const decNumber *
} while(0); /* end protected */
#if DECSUBSET
- if (allocrhs !=NULL) free(allocrhs); /* drop any storage used */
+ if (allocrhs !=nullptr) free(allocrhs); /* drop any storage used */
#endif
/* apply significant status */
if (status!=0) decStatus(res, status, set);
@@ -1132,7 +1132,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFMA(decNumber *res, const decNumber *
decContext dcmul; /* context for the multiplication */
uInt needbytes; /* for space calculations */
decNumber bufa[D2N(DECBUFFER*2+1)];
- decNumber *allocbufa=NULL; /* -> allocated bufa, iff allocated */
+ decNumber *allocbufa=nullptr; /* -> allocated bufa, iff allocated */
decNumber *acc; /* accumulator pointer */
decNumber dzero; /* work */
@@ -1162,7 +1162,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFMA(decNumber *res, const decNumber *
needbytes=sizeof(decNumber)+(D2U(dcmul.digits)-1)*sizeof(Unit);
if (needbytes>sizeof(bufa)) { /* need malloc space */
allocbufa=(decNumber *)malloc(needbytes);
- if (allocbufa==NULL) { /* hopeless -- abandon */
+ if (allocbufa==nullptr) { /* hopeless -- abandon */
status|=DEC_Insufficient_storage;
break;}
acc=allocbufa; /* use the allocated space */
@@ -1194,7 +1194,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberFMA(decNumber *res, const decNumber *
decAddOp(res, acc, fhs, set, 0, &status);
} while(0); /* end protected */
- if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
+ if (allocbufa!=nullptr) free(allocbufa); /* drop any storage used */
if (status!=0) decStatus(res, status, set);
#if DECCHECK
decCheckInexact(res, set);
@@ -1293,7 +1293,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberLn(decNumber *res, const decNumber *r
decContext *set) {
uInt status=0; /* accumulator */
#if DECSUBSET
- decNumber *allocrhs=NULL; /* non-NULL if rounded rhs allocated */
+ decNumber *allocrhs=nullptr; /* non-nullptr if rounded rhs allocated */
#endif
#if DECCHECK
@@ -1308,7 +1308,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberLn(decNumber *res, const decNumber *r
/* reduce operand and set lostDigits status, as needed */
if (rhs->digits>set->digits) {
allocrhs=decRoundOperand(rhs, set, &status);
- if (allocrhs==NULL) break;
+ if (allocrhs==nullptr) break;
rhs=allocrhs;
}
/* special check in subset for rhs=0 */
@@ -1321,7 +1321,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberLn(decNumber *res, const decNumber *r
} while(0); /* end protected */
#if DECSUBSET
- if (allocrhs !=NULL) free(allocrhs); /* drop any storage used */
+ if (allocrhs !=nullptr) free(allocrhs); /* drop any storage used */
#endif
/* apply significant status */
if (status!=0) decStatus(res, status, set);
@@ -1364,7 +1364,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberLogB(decNumber *res, const decNumber
#endif
/* NaNs as usual; Infinities return +Infinity; 0->oops */
- if (decNumberIsNaN(rhs)) decNaNs(res, rhs, NULL, set, &status);
+ if (decNumberIsNaN(rhs)) decNaNs(res, rhs, nullptr, set, &status);
else if (decNumberIsInfinite(rhs)) uprv_decNumberCopyAbs(res, rhs);
else if (decNumberIsZero(rhs)) {
uprv_decNumberZero(res); /* prepare for Infinity */
@@ -1425,15 +1425,15 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberLog10(decNumber *res, const decNumber
/* buffers for a and b working decimals */
/* (adjustment calculator, same size) */
decNumber bufa[D2N(DECBUFFER+2)];
- decNumber *allocbufa=NULL; /* -> allocated bufa, iff allocated */
+ decNumber *allocbufa=nullptr; /* -> allocated bufa, iff allocated */
decNumber *a=bufa; /* temporary a */
decNumber bufb[D2N(DECBUFFER+2)];
- decNumber *allocbufb=NULL; /* -> allocated bufb, iff allocated */
+ decNumber *allocbufb=nullptr; /* -> allocated bufb, iff allocated */
decNumber *b=bufb; /* temporary b */
decNumber bufw[D2N(10)]; /* working 2-10 digit number */
decNumber *w=bufw; /* .. */
#if DECSUBSET
- decNumber *allocrhs=NULL; /* non-NULL if rounded rhs allocated */
+ decNumber *allocrhs=nullptr; /* non-nullptr if rounded rhs allocated */
#endif
decContext aset; /* working context */
@@ -1450,7 +1450,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberLog10(decNumber *res, const decNumber
/* reduce operand and set lostDigits status, as needed */
if (rhs->digits>set->digits) {
allocrhs=decRoundOperand(rhs, set, &status);
- if (allocrhs==NULL) break;
+ if (allocrhs==nullptr) break;
rhs=allocrhs;
}
/* special check in subset for rhs=0 */
@@ -1495,7 +1495,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberLog10(decNumber *res, const decNumber
needbytes=sizeof(decNumber)+(D2U(p)-1)*sizeof(Unit);
if (needbytes>sizeof(bufa)) { /* need malloc space */
allocbufa=(decNumber *)malloc(needbytes);
- if (allocbufa==NULL) { /* hopeless -- abandon */
+ if (allocbufa==nullptr) { /* hopeless -- abandon */
status|=DEC_Insufficient_storage;
break;}
a=allocbufa; /* use the allocated space */
@@ -1518,7 +1518,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberLog10(decNumber *res, const decNumber
needbytes=sizeof(decNumber)+(D2U(p)-1)*sizeof(Unit);
if (needbytes>sizeof(bufb)) { /* need malloc space */
allocbufb=(decNumber *)malloc(needbytes);
- if (allocbufb==NULL) { /* hopeless -- abandon */
+ if (allocbufb==nullptr) { /* hopeless -- abandon */
status|=DEC_Insufficient_storage;
break;}
b=allocbufb; /* use the allocated space */
@@ -1538,10 +1538,10 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberLog10(decNumber *res, const decNumber
decDivideOp(res, a, b, &aset, DIVIDE, &status); /* into result */
} while(0); /* [for break] */
- if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
- if (allocbufb!=NULL) free(allocbufb); /* .. */
+ if (allocbufa!=nullptr) free(allocbufa); /* drop any storage used */
+ if (allocbufb!=nullptr) free(allocbufb); /* .. */
#if DECSUBSET
- if (allocrhs !=NULL) free(allocrhs); /* .. */
+ if (allocrhs !=nullptr) free(allocrhs); /* .. */
#endif
/* apply significant status */
if (status!=0) decStatus(res, status, set);
@@ -1974,11 +1974,11 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberMultiply(decNumber *res, const decNum
U_CAPI decNumber * U_EXPORT2 uprv_decNumberPower(decNumber *res, const decNumber *lhs,
const decNumber *rhs, decContext *set) {
#if DECSUBSET
- decNumber *alloclhs=NULL; /* non-NULL if rounded lhs allocated */
- decNumber *allocrhs=NULL; /* .., rhs */
+ decNumber *alloclhs=nullptr; /* non-nullptr if rounded lhs allocated */
+ decNumber *allocrhs=nullptr; /* .., rhs */
#endif
- decNumber *allocdac=NULL; /* -> allocated acc buffer, iff used */
- decNumber *allocinv=NULL; /* -> allocated 1/x buffer, iff used */
+ decNumber *allocdac=nullptr; /* -> allocated acc buffer, iff used */
+ decNumber *allocinv=nullptr; /* -> allocated 1/x buffer, iff used */
Int reqdigits=set->digits; /* requested DIGITS */
Int n; /* rhs in binary */
Flag rhsint=0; /* 1 if rhs is an integer */
@@ -2010,12 +2010,12 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberPower(decNumber *res, const decNumber
if (!set->extended) { /* reduce operands and set status, as needed */
if (lhs->digits>reqdigits) {
alloclhs=decRoundOperand(lhs, set, &status);
- if (alloclhs==NULL) break;
+ if (alloclhs==nullptr) break;
lhs=alloclhs;
}
if (rhs->digits>reqdigits) {
allocrhs=decRoundOperand(rhs, set, &status);
- if (allocrhs==NULL) break;
+ if (allocrhs==nullptr) break;
rhs=allocrhs;
}
}
@@ -2166,7 +2166,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberPower(decNumber *res, const decNumber
/* [needbytes also used below if 1/lhs needed] */
if (needbytes>sizeof(dacbuff)) {
allocdac=(decNumber *)malloc(needbytes);
- if (allocdac==NULL) { /* hopeless -- abandon */
+ if (allocdac==nullptr) { /* hopeless -- abandon */
status|=DEC_Insufficient_storage;
break;}
dac=allocdac; /* use the allocated space */
@@ -2213,7 +2213,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberPower(decNumber *res, const decNumber
/* now locate or allocate space for the inverted lhs */
if (needbytes>sizeof(invbuff)) {
allocinv=(decNumber *)malloc(needbytes);
- if (allocinv==NULL) { /* hopeless -- abandon */
+ if (allocinv==nullptr) { /* hopeless -- abandon */
status|=DEC_Insufficient_storage;
break;}
inv=allocinv; /* use the allocated space */
@@ -2285,11 +2285,11 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberPower(decNumber *res, const decNumber
#endif
} while(0); /* end protected */
- if (allocdac!=NULL) free(allocdac); /* drop any storage used */
- if (allocinv!=NULL) free(allocinv); /* .. */
+ if (allocdac!=nullptr) free(allocdac); /* drop any storage used */
+ if (allocinv!=nullptr) free(allocinv); /* .. */
#if DECSUBSET
- if (alloclhs!=NULL) free(alloclhs); /* .. */
- if (allocrhs!=NULL) free(allocrhs); /* .. */
+ if (alloclhs!=nullptr) free(alloclhs); /* .. */
+ if (allocrhs!=nullptr) free(allocrhs); /* .. */
#endif
if (status!=0) decStatus(res, status, set);
#if DECCHECK
@@ -2344,7 +2344,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberNormalize(decNumber *res, const decNu
U_CAPI decNumber * U_EXPORT2 uprv_decNumberReduce(decNumber *res, const decNumber *rhs,
decContext *set) {
#if DECSUBSET
- decNumber *allocrhs=NULL; /* non-NULL if rounded rhs allocated */
+ decNumber *allocrhs=nullptr; /* non-nullptr if rounded rhs allocated */
#endif
uInt status=0; /* as usual */
Int residue=0; /* as usual */
@@ -2360,7 +2360,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberReduce(decNumber *res, const decNumbe
/* reduce operand and set lostDigits status, as needed */
if (rhs->digits>set->digits) {
allocrhs=decRoundOperand(rhs, set, &status);
- if (allocrhs==NULL) break;
+ if (allocrhs==nullptr) break;
rhs=allocrhs;
}
}
@@ -2369,7 +2369,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberReduce(decNumber *res, const decNumbe
/* Infinities copy through; NaNs need usual treatment */
if (decNumberIsNaN(rhs)) {
- decNaNs(res, rhs, NULL, set, &status);
+ decNaNs(res, rhs, nullptr, set, &status);
break;
}
@@ -2381,7 +2381,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberReduce(decNumber *res, const decNumbe
} while(0); /* end protected */
#if DECSUBSET
- if (allocrhs !=NULL) free(allocrhs); /* .. */
+ if (allocrhs !=nullptr) free(allocrhs); /* .. */
#endif
if (status!=0) decStatus(res, status, set);/* then report status */
return res;
@@ -2845,7 +2845,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberSquareRoot(decNumber *res, const decN
Int dropped; /* .. */
#if DECSUBSET
- decNumber *allocrhs=NULL; /* non-NULL if rounded rhs allocated */
+ decNumber *allocrhs=nullptr; /* non-nullptr if rounded rhs allocated */
#endif
/* buffer for f [needs +1 in case DECBUFFER 0] */
decNumber buff[D2N(DECBUFFER+1)];
@@ -2853,9 +2853,9 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberSquareRoot(decNumber *res, const decN
decNumber bufa[D2N(DECBUFFER+2)];
/* buffer for temporary, b [must be same size as a] */
decNumber bufb[D2N(DECBUFFER+2)];
- decNumber *allocbuff=NULL; /* -> allocated buff, iff allocated */
- decNumber *allocbufa=NULL; /* -> allocated bufa, iff allocated */
- decNumber *allocbufb=NULL; /* -> allocated bufb, iff allocated */
+ decNumber *allocbuff=nullptr; /* -> allocated buff, iff allocated */
+ decNumber *allocbufa=nullptr; /* -> allocated bufa, iff allocated */
+ decNumber *allocbufb=nullptr; /* -> allocated bufb, iff allocated */
decNumber *f=buff; /* reduced fraction */
decNumber *a=bufa; /* approximation to result */
decNumber *b=bufb; /* intermediate result */
@@ -2873,7 +2873,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberSquareRoot(decNumber *res, const decN
/* reduce operand and set lostDigits status, as needed */
if (rhs->digits>set->digits) {
allocrhs=decRoundOperand(rhs, set, &status);
- if (allocrhs==NULL) break;
+ if (allocrhs==nullptr) break;
/* [Note: 'f' allocation below could reuse this buffer if */
/* used, but as this is rare they are kept separate for clarity.] */
rhs=allocrhs;
@@ -2888,7 +2888,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberSquareRoot(decNumber *res, const decN
if (decNumberIsNegative(rhs)) status|=DEC_Invalid_operation;
else uprv_decNumberCopy(res, rhs); /* +Infinity */
}
- else decNaNs(res, rhs, NULL, set, &status); /* a NaN */
+ else decNaNs(res, rhs, nullptr, set, &status); /* a NaN */
break;
}
@@ -2926,7 +2926,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberSquareRoot(decNumber *res, const decN
needbytes=sizeof(decNumber)+(D2U(rhs->digits)-1)*sizeof(Unit);
if (needbytes>(Int)sizeof(buff)) {
allocbuff=(decNumber *)malloc(needbytes);
- if (allocbuff==NULL) { /* hopeless -- abandon */
+ if (allocbuff==nullptr) { /* hopeless -- abandon */
status|=DEC_Insufficient_storage;
break;}
f=allocbuff; /* use the allocated space */
@@ -2936,7 +2936,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberSquareRoot(decNumber *res, const decN
if (needbytes>(Int)sizeof(bufa)) { /* [same applies to b] */
allocbufa=(decNumber *)malloc(needbytes);
allocbufb=(decNumber *)malloc(needbytes);
- if (allocbufa==NULL || allocbufb==NULL) { /* hopeless */
+ if (allocbufa==nullptr || allocbufb==nullptr) { /* hopeless */
status|=DEC_Insufficient_storage;
break;}
a=allocbufa; /* use the allocated spaces */
@@ -3147,11 +3147,11 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberSquareRoot(decNumber *res, const decN
uprv_decNumberCopy(res, a); /* a is now the result */
} while(0); /* end protected */
- if (allocbuff!=NULL) free(allocbuff); /* drop any storage used */
- if (allocbufa!=NULL) free(allocbufa); /* .. */
- if (allocbufb!=NULL) free(allocbufb); /* .. */
+ if (allocbuff!=nullptr) free(allocbuff); /* drop any storage used */
+ if (allocbufa!=nullptr) free(allocbufa); /* .. */
+ if (allocbufb!=nullptr) free(allocbufb); /* .. */
#if DECSUBSET
- if (allocrhs !=NULL) free(allocrhs); /* .. */
+ if (allocrhs !=nullptr) free(allocrhs); /* .. */
#endif
if (status!=0) decStatus(res, status, set);/* then report status */
#if DECCHECK
@@ -3221,7 +3221,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberToIntegralExact(decNumber *res, const
/* handle infinities and NaNs */
if (SPECIALARG) {
if (decNumberIsInfinite(rhs)) uprv_decNumberCopy(res, rhs); /* an Infinity */
- else decNaNs(res, rhs, NULL, set, &status); /* a NaN */
+ else decNaNs(res, rhs, nullptr, set, &status); /* a NaN */
}
else { /* finite */
/* have a finite number; no error possible (res must be big enough) */
@@ -3385,7 +3385,7 @@ const char *uprv_decNumberClassToString(enum decClass eclass) {
U_CAPI decNumber * U_EXPORT2 uprv_decNumberCopy(decNumber *dest, const decNumber *src) {
#if DECCHECK
- if (src==NULL) return uprv_decNumberZero(dest);
+ if (src==nullptr) return uprv_decNumberZero(dest);
#endif
if (dest==src) return dest; /* no copy required */
@@ -3605,7 +3605,7 @@ U_CAPI decNumber * U_EXPORT2 uprv_decNumberTrim(decNumber *dn) {
/* */
/* No error is possible. */
/* ------------------------------------------------------------------ */
-const char * uprv_decNumberVersion(void) {
+const char * uprv_decNumberVersion() {
return DECVERSION;
} /* decNumberVersion */
@@ -3837,8 +3837,8 @@ static decNumber * decAddOp(decNumber *res, const decNumber *lhs,
const decNumber *rhs, decContext *set,
uByte negate, uInt *status) {
#if DECSUBSET
- decNumber *alloclhs=NULL; /* non-NULL if rounded lhs allocated */
- decNumber *allocrhs=NULL; /* .., rhs */
+ decNumber *alloclhs=nullptr; /* non-nullptr if rounded lhs allocated */
+ decNumber *allocrhs=nullptr; /* .., rhs */
#endif
Int rhsshift; /* working shift (in Units) */
Int maxdigits; /* longest logical length */
@@ -3850,7 +3850,7 @@ static decNumber * decAddOp(decNumber *res, const decNumber *lhs,
Unit accbuff[SD2U(DECBUFFER*2+20)]; /* local buffer [*2+20 reduces many */
/* allocations when called from */
/* other operations, notable exp] */
- Unit *allocacc=NULL; /* -> allocated acc buffer, iff allocated */
+ Unit *allocacc=nullptr; /* -> allocated acc buffer, iff allocated */
Int reqdigits=set->digits; /* local copy; requested DIGITS */
Int padding; /* work */
@@ -3864,12 +3864,12 @@ static decNumber * decAddOp(decNumber *res, const decNumber *lhs,
/* reduce operands and set lostDigits status, as needed */
if (lhs->digits>reqdigits) {
alloclhs=decRoundOperand(lhs, set, status);
- if (alloclhs==NULL) break;
+ if (alloclhs==nullptr) break;
lhs=alloclhs;
}
if (rhs->digits>reqdigits) {
allocrhs=decRoundOperand(rhs, set, status);
- if (allocrhs==NULL) break;
+ if (allocrhs==nullptr) break;
rhs=allocrhs;
}
}
@@ -4075,7 +4075,7 @@ static decNumber * decAddOp(decNumber *res, const decNumber *lhs,
if (need*sizeof(Unit)>sizeof(accbuff)) {
/* printf("malloc add %ld %ld\n", need, sizeof(accbuff)); */
allocacc=(Unit *)malloc(need*sizeof(Unit));
- if (allocacc==NULL) { /* hopeless -- abandon */
+ if (allocacc==nullptr) { /* hopeless -- abandon */
*status|=DEC_Insufficient_storage;
break;}
acc=allocacc;
@@ -4171,10 +4171,10 @@ static decNumber * decAddOp(decNumber *res, const decNumber *lhs,
}
} while(0); /* end protected */
- if (allocacc!=NULL) free(allocacc); /* drop any storage used */
+ if (allocacc!=nullptr) free(allocacc); /* drop any storage used */
#if DECSUBSET
- if (allocrhs!=NULL) free(allocrhs); /* .. */
- if (alloclhs!=NULL) free(alloclhs); /* .. */
+ if (allocrhs!=nullptr) free(allocrhs); /* .. */
+ if (alloclhs!=nullptr) free(alloclhs); /* .. */
#endif
return res;
} /* decAddOp */
@@ -4253,12 +4253,12 @@ static decNumber * decDivideOp(decNumber *res,
const decNumber *lhs, const decNumber *rhs,
decContext *set, Flag op, uInt *status) {
#if DECSUBSET
- decNumber *alloclhs=NULL; /* non-NULL if rounded lhs allocated */
- decNumber *allocrhs=NULL; /* .., rhs */
+ decNumber *alloclhs=nullptr; /* non-nullptr if rounded lhs allocated */
+ decNumber *allocrhs=nullptr; /* .., rhs */
#endif
Unit accbuff[SD2U(DECBUFFER+DECDPUN+10)]; /* local buffer */
Unit *acc=accbuff; /* -> accumulator array for result */
- Unit *allocacc=NULL; /* -> allocated buffer, iff allocated */
+ Unit *allocacc=nullptr; /* -> allocated buffer, iff allocated */
Unit *accnext; /* -> where next digit will go */
Int acclength; /* length of acc needed [Units] */
Int accunits; /* count of units accumulated */
@@ -4266,7 +4266,7 @@ static decNumber * decDivideOp(decNumber *res,
Unit varbuff[SD2U(DECBUFFER*2+DECDPUN)]; /* buffer for var1 */
Unit *var1=varbuff; /* -> var1 array for long subtraction */
- Unit *varalloc=NULL; /* -> allocated buffer, iff used */
+ Unit *varalloc=nullptr; /* -> allocated buffer, iff used */
Unit *msu1; /* -> msu of var1 */
const Unit *var2; /* -> var2 array */
@@ -4303,12 +4303,12 @@ static decNumber * decDivideOp(decNumber *res,
/* reduce operands and set lostDigits status, as needed */
if (lhs->digits>reqdigits) {
alloclhs=decRoundOperand(lhs, set, status);
- if (alloclhs==NULL) break;
+ if (alloclhs==nullptr) break;
lhs=alloclhs;
}
if (rhs->digits>reqdigits) {
allocrhs=decRoundOperand(rhs, set, status);
- if (allocrhs==NULL) break;
+ if (allocrhs==nullptr) break;
rhs=allocrhs;
}
}
@@ -4440,7 +4440,7 @@ static decNumber * decDivideOp(decNumber *res,
if (acclength*sizeof(Unit)>sizeof(accbuff)) {
/* printf("malloc dvacc %ld units\n", acclength); */
allocacc=(Unit *)malloc(acclength*sizeof(Unit));
- if (allocacc==NULL) { /* hopeless -- abandon */
+ if (allocacc==nullptr) { /* hopeless -- abandon */
*status|=DEC_Insufficient_storage;
break;}
acc=allocacc; /* use the allocated space */
@@ -4465,7 +4465,7 @@ static decNumber * decDivideOp(decNumber *res,
if ((var1units+1)*sizeof(Unit)>sizeof(varbuff)) {
/* printf("malloc dvvar %ld units\n", var1units+1); */
varalloc=(Unit *)malloc((var1units+1)*sizeof(Unit));
- if (varalloc==NULL) { /* hopeless -- abandon */
+ if (varalloc==nullptr) { /* hopeless -- abandon */
*status|=DEC_Insufficient_storage;
break;}
var1=varalloc; /* use the allocated space */
@@ -4823,11 +4823,11 @@ static decNumber * decDivideOp(decNumber *res,
#endif
} while(0); /* end protected */
- if (varalloc!=NULL) free(varalloc); /* drop any storage used */
- if (allocacc!=NULL) free(allocacc); /* .. */
+ if (varalloc!=nullptr) free(varalloc); /* drop any storage used */
+ if (allocacc!=nullptr) free(allocacc); /* .. */
#if DECSUBSET
- if (allocrhs!=NULL) free(allocrhs); /* .. */
- if (alloclhs!=NULL) free(alloclhs); /* .. */
+ if (allocrhs!=nullptr) free(allocrhs); /* .. */
+ if (alloclhs!=nullptr) free(alloclhs); /* .. */
#endif
return res;
} /* decDivideOp */
@@ -4878,7 +4878,7 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
uByte bits; /* result sign */
Unit *acc; /* -> accumulator Unit array */
Int needbytes; /* size calculator */
- void *allocacc=NULL; /* -> allocated accumulator, iff allocated */
+ void *allocacc=nullptr; /* -> allocated accumulator, iff allocated */
Unit accbuff[SD2U(DECBUFFER*4+1)]; /* buffer (+1 for DECBUFFER==0, */
/* *4 for calls from other operations) */
const Unit *mer, *mermsup; /* work */
@@ -4902,10 +4902,10 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
/* lazy carry evaluation */
uInt zlhibuff[(DECBUFFER*2+1)/8+1]; /* buffer (+1 for DECBUFFER==0) */
uInt *zlhi=zlhibuff; /* -> lhs array */
- uInt *alloclhi=NULL; /* -> allocated buffer, iff allocated */
+ uInt *alloclhi=nullptr; /* -> allocated buffer, iff allocated */
uInt zrhibuff[(DECBUFFER*2+1)/8+1]; /* buffer (+1 for DECBUFFER==0) */
uInt *zrhi=zrhibuff; /* -> rhs array */
- uInt *allocrhi=NULL; /* -> allocated buffer, iff allocated */
+ uInt *allocrhi=nullptr; /* -> allocated buffer, iff allocated */
uLong zaccbuff[(DECBUFFER*2+1)/4+2]; /* buffer (+1 for DECBUFFER==0) */
/* [allocacc is shared for both paths, as only one will run] */
uLong *zacc=zaccbuff; /* -> accumulator array for exact result */
@@ -4926,8 +4926,8 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
#endif
#if DECSUBSET
- decNumber *alloclhs=NULL; /* -> allocated buffer, iff allocated */
- decNumber *allocrhs=NULL; /* -> allocated buffer, iff allocated */
+ decNumber *alloclhs=nullptr; /* -> allocated buffer, iff allocated */
+ decNumber *allocrhs=nullptr; /* -> allocated buffer, iff allocated */
#endif
#if DECCHECK
@@ -4967,12 +4967,12 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
/* reduce operands and set lostDigits status, as needed */
if (lhs->digits>set->digits) {
alloclhs=decRoundOperand(lhs, set, status);
- if (alloclhs==NULL) break;
+ if (alloclhs==nullptr) break;
lhs=alloclhs;
}
if (rhs->digits>set->digits) {
allocrhs=decRoundOperand(rhs, set, status);
- if (allocrhs==NULL) break;
+ if (allocrhs==nullptr) break;
rhs=allocrhs;
}
}
@@ -5018,7 +5018,7 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
if (needbytes>(Int)sizeof(zaccbuff)) {
allocacc=(uLong *)malloc(needbytes);
zacc=(uLong *)allocacc;}
- if (zlhi==NULL||zrhi==NULL||zacc==NULL) {
+ if (zlhi==nullptr||zrhi==nullptr||zacc==nullptr) {
*status|=DEC_Insufficient_storage;
break;}
@@ -5113,7 +5113,7 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
needbytes=(D2U(lhs->digits)+D2U(rhs->digits))*sizeof(Unit);
if (needbytes>(Int)sizeof(accbuff)) {
allocacc=(Unit *)malloc(needbytes);
- if (allocacc==NULL) {*status|=DEC_Insufficient_storage; break;}
+ if (allocacc==nullptr) {*status|=DEC_Insufficient_storage; break;}
acc=(Unit *)allocacc; /* use the allocated space */
}
@@ -5172,14 +5172,14 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
decFinish(res, set, &residue, status); /* final cleanup */
} while(0); /* end protected */
- if (allocacc!=NULL) free(allocacc); /* drop any storage used */
+ if (allocacc!=nullptr) free(allocacc); /* drop any storage used */
#if DECSUBSET
- if (allocrhs!=NULL) free(allocrhs); /* .. */
- if (alloclhs!=NULL) free(alloclhs); /* .. */
+ if (allocrhs!=nullptr) free(allocrhs); /* .. */
+ if (alloclhs!=nullptr) free(alloclhs); /* .. */
#endif
#if FASTMUL
- if (allocrhi!=NULL) free(allocrhi); /* .. */
- if (alloclhi!=NULL) free(alloclhi); /* .. */
+ if (allocrhi!=nullptr) free(allocrhi); /* .. */
+ if (alloclhi!=nullptr) free(alloclhi); /* .. */
#endif
return res;
} /* decMultiplyOp */
@@ -5278,7 +5278,7 @@ decNumber * decExpOp(decNumber *res, const decNumber *rhs,
/* is treated like other buffers, using DECBUFFER, +1 in case */
/* DECBUFFER is 0 */
decNumber bufr[D2N(DECBUFFER*2+1)];
- decNumber *allocrhs=NULL; /* non-NULL if rhs buffer allocated */
+ decNumber *allocrhs=nullptr; /* non-nullptr if rhs buffer allocated */
/* the working precision will be no more than set->digits+8+1 */
/* so for on-stack buffers DECBUFFER+9 is used, +1 in case DECBUFFER */
@@ -5286,11 +5286,11 @@ decNumber * decExpOp(decNumber *res, const decNumber *rhs,
/* buffer for t, term (working precision plus) */
decNumber buft[D2N(DECBUFFER*2+9+1)];
- decNumber *allocbuft=NULL; /* -> allocated buft, iff allocated */
+ decNumber *allocbuft=nullptr; /* -> allocated buft, iff allocated */
decNumber *t=buft; /* term */
/* buffer for a, accumulator (working precision * 2), at least 9 */
decNumber bufa[D2N(DECBUFFER*4+18+1)];
- decNumber *allocbufa=NULL; /* -> allocated bufa, iff allocated */
+ decNumber *allocbufa=nullptr; /* -> allocated bufa, iff allocated */
decNumber *a=bufa; /* accumulator */
/* decNumber for the divisor term; this needs at most 9 digits */
/* and so can be fixed size [16 so can use standard context] */
@@ -5310,7 +5310,7 @@ decNumber * decExpOp(decNumber *res, const decNumber *rhs,
uprv_decNumberZero(res);
else uprv_decNumberCopy(res, rhs); /* +Infinity -> self */
}
- else decNaNs(res, rhs, NULL, set, status); /* a NaN */
+ else decNaNs(res, rhs, nullptr, set, status); /* a NaN */
break;}
if (ISZERO(rhs)) { /* zeros -> exact 1 */
@@ -5400,7 +5400,7 @@ decNumber * decExpOp(decNumber *res, const decNumber *rhs,
needbytes=sizeof(decNumber)+(D2U(rhs->digits)-1)*sizeof(Unit);
if (needbytes>sizeof(bufr)) { /* need malloc space */
allocrhs=(decNumber *)malloc(needbytes);
- if (allocrhs==NULL) { /* hopeless -- abandon */
+ if (allocrhs==nullptr) { /* hopeless -- abandon */
*status|=DEC_Insufficient_storage;
break;}
newrhs=allocrhs; /* use the allocated space */
@@ -5432,7 +5432,7 @@ decNumber * decExpOp(decNumber *res, const decNumber *rhs,
needbytes=sizeof(decNumber)+(D2U(p*2)-1)*sizeof(Unit);
if (needbytes>sizeof(bufa)) { /* need malloc space */
allocbufa=(decNumber *)malloc(needbytes);
- if (allocbufa==NULL) { /* hopeless -- abandon */
+ if (allocbufa==nullptr) { /* hopeless -- abandon */
*status|=DEC_Insufficient_storage;
break;}
a=allocbufa; /* use the allocated space */
@@ -5444,7 +5444,7 @@ decNumber * decExpOp(decNumber *res, const decNumber *rhs,
needbytes=sizeof(decNumber)+(D2U(p+2)-1)*sizeof(Unit);
if (needbytes>sizeof(buft)) { /* need malloc space */
allocbuft=(decNumber *)malloc(needbytes);
- if (allocbuft==NULL) { /* hopeless -- abandon */
+ if (allocbuft==nullptr) { /* hopeless -- abandon */
*status|=DEC_Insufficient_storage;
break;}
t=allocbuft; /* use the allocated space */
@@ -5528,9 +5528,9 @@ decNumber * decExpOp(decNumber *res, const decNumber *rhs,
decFinish(res, set, &residue, status); /* cleanup/set flags */
} while(0); /* end protected */
- if (allocrhs !=NULL) free(allocrhs); /* drop any storage used */
- if (allocbufa!=NULL) free(allocbufa); /* .. */
- if (allocbuft!=NULL) free(allocbuft); /* .. */
+ if (allocrhs !=nullptr) free(allocrhs); /* drop any storage used */
+ if (allocbufa!=nullptr) free(allocbufa); /* .. */
+ if (allocbuft!=nullptr) free(allocbuft); /* .. */
/* [status is handled by caller] */
return res;
} /* decExpOp */
@@ -5640,10 +5640,10 @@ decNumber * decLnOp(decNumber *res, const decNumber *rhs,
/* buffers for a (accumulator, typically precision+2) and b */
/* (adjustment calculator, same size) */
decNumber bufa[D2N(DECBUFFER+12)];
- decNumber *allocbufa=NULL; /* -> allocated bufa, iff allocated */
+ decNumber *allocbufa=nullptr; /* -> allocated bufa, iff allocated */
decNumber *a=bufa; /* accumulator/work */
decNumber bufb[D2N(DECBUFFER*2+2)];
- decNumber *allocbufb=NULL; /* -> allocated bufa, iff allocated */
+ decNumber *allocbufb=nullptr; /* -> allocated bufa, iff allocated */
decNumber *b=bufb; /* adjustment/work */
decNumber numone; /* constant 1 */
@@ -5662,7 +5662,7 @@ decNumber * decLnOp(decNumber *res, const decNumber *rhs,
*status|=DEC_Invalid_operation;
else uprv_decNumberCopy(res, rhs); /* +Infinity -> self */
}
- else decNaNs(res, rhs, NULL, set, status); /* a NaN */
+ else decNaNs(res, rhs, nullptr, set, status); /* a NaN */
break;}
if (ISZERO(rhs)) { /* +/- zeros -> -Infinity */
@@ -5713,7 +5713,7 @@ decNumber * decLnOp(decNumber *res, const decNumber *rhs,
needbytes=sizeof(decNumber)+(D2U(MAXI(p,16))-1)*sizeof(Unit);
if (needbytes>sizeof(bufa)) { /* need malloc space */
allocbufa=(decNumber *)malloc(needbytes);
- if (allocbufa==NULL) { /* hopeless -- abandon */
+ if (allocbufa==nullptr) { /* hopeless -- abandon */
*status|=DEC_Insufficient_storage;
break;}
a=allocbufa; /* use the allocated space */
@@ -5722,7 +5722,7 @@ decNumber * decLnOp(decNumber *res, const decNumber *rhs,
needbytes=sizeof(decNumber)+(D2U(MAXI(pp,16))-1)*sizeof(Unit);
if (needbytes>sizeof(bufb)) { /* need malloc space */
allocbufb=(decNumber *)malloc(needbytes);
- if (allocbufb==NULL) { /* hopeless -- abandon */
+ if (allocbufb==nullptr) { /* hopeless -- abandon */
*status|=DEC_Insufficient_storage;
break;}
b=allocbufb; /* use the allocated space */
@@ -5843,8 +5843,8 @@ decNumber * decLnOp(decNumber *res, const decNumber *rhs,
decFinish(res, set, &residue, status); /* cleanup/set flags */
} while(0); /* end protected */
- if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
- if (allocbufb!=NULL) free(allocbufb); /* .. */
+ if (allocbufa!=nullptr) free(allocbufa); /* drop any storage used */
+ if (allocbufb!=nullptr) free(allocbufb); /* .. */
/* [status is handled by caller] */
return res;
} /* decLnOp */
@@ -5878,8 +5878,8 @@ static decNumber * decQuantizeOp(decNumber *res, const decNumber *lhs,
const decNumber *rhs, decContext *set,
Flag quant, uInt *status) {
#if DECSUBSET
- decNumber *alloclhs=NULL; /* non-NULL if rounded lhs allocated */
- decNumber *allocrhs=NULL; /* .., rhs */
+ decNumber *alloclhs=nullptr; /* non-nullptr if rounded lhs allocated */
+ decNumber *allocrhs=nullptr; /* .., rhs */
#endif
const decNumber *inrhs=rhs; /* save original rhs */
Int reqdigits=set->digits; /* requested DIGITS */
@@ -5897,12 +5897,12 @@ static decNumber * decQuantizeOp(decNumber *res, const decNumber *lhs,
/* reduce operands and set lostDigits status, as needed */
if (lhs->digits>reqdigits) {
alloclhs=decRoundOperand(lhs, set, status);
- if (alloclhs==NULL) break;
+ if (alloclhs==nullptr) break;
lhs=alloclhs;
}
if (rhs->digits>reqdigits) { /* [this only checks lostDigits] */
allocrhs=decRoundOperand(rhs, set, status);
- if (allocrhs==NULL) break;
+ if (allocrhs==nullptr) break;
rhs=allocrhs;
}
}
@@ -6011,8 +6011,8 @@ static decNumber * decQuantizeOp(decNumber *res, const decNumber *lhs,
} while(0); /* end protected */
#if DECSUBSET
- if (allocrhs!=NULL) free(allocrhs); /* drop any storage used */
- if (alloclhs!=NULL) free(alloclhs); /* .. */
+ if (allocrhs!=nullptr) free(allocrhs); /* drop any storage used */
+ if (alloclhs!=nullptr) free(alloclhs); /* .. */
#endif
return res;
} /* decQuantizeOp */
@@ -6051,8 +6051,8 @@ static decNumber * decCompareOp(decNumber *res, const decNumber *lhs,
const decNumber *rhs, decContext *set,
Flag op, uInt *status) {
#if DECSUBSET
- decNumber *alloclhs=NULL; /* non-NULL if rounded lhs allocated */
- decNumber *allocrhs=NULL; /* .., rhs */
+ decNumber *alloclhs=nullptr; /* non-nullptr if rounded lhs allocated */
+ decNumber *allocrhs=nullptr; /* .., rhs */
#endif
Int result=0; /* default result value */
uByte merged; /* work */
@@ -6067,12 +6067,12 @@ static decNumber * decCompareOp(decNumber *res, const decNumber *lhs,
/* reduce operands and set lostDigits status, as needed */
if (lhs->digits>set->digits) {
alloclhs=decRoundOperand(lhs, set, status);
- if (alloclhs==NULL) {result=BADINT; break;}
+ if (alloclhs==nullptr) {result=BADINT; break;}
lhs=alloclhs;
}
if (rhs->digits>set->digits) {
allocrhs=decRoundOperand(rhs, set, status);
- if (allocrhs==NULL) {result=BADINT; break;}
+ if (allocrhs==nullptr) {result=BADINT; break;}
rhs=allocrhs;
}
}
@@ -6194,8 +6194,8 @@ static decNumber * decCompareOp(decNumber *res, const decNumber *lhs,
}
}
#if DECSUBSET
- if (allocrhs!=NULL) free(allocrhs); /* free any storage used */
- if (alloclhs!=NULL) free(alloclhs); /* .. */
+ if (allocrhs!=nullptr) free(allocrhs); /* free any storage used */
+ if (alloclhs!=nullptr) free(alloclhs); /* .. */
#endif
return res;
} /* decCompareOp */
@@ -6280,7 +6280,7 @@ static Int decUnitCompare(const Unit *a, Int alength,
const Unit *b, Int blength, Int exp) {
Unit *acc; /* accumulator for result */
Unit accbuff[SD2U(DECBUFFER*2+1)]; /* local buffer */
- Unit *allocacc=NULL; /* -> allocated acc buffer, iff allocated */
+ Unit *allocacc=nullptr; /* -> allocated acc buffer, iff allocated */
Int accunits, need; /* units in use or needed for acc */
const Unit *l, *r, *u; /* work */
Int expunits, exprem, result; /* .. */
@@ -6312,7 +6312,7 @@ static Int decUnitCompare(const Unit *a, Int alength,
acc=accbuff; /* assume use local buffer */
if (need*sizeof(Unit)>sizeof(accbuff)) {
allocacc=(Unit *)malloc(need*sizeof(Unit));
- if (allocacc==NULL) return BADINT; /* hopeless -- abandon */
+ if (allocacc==nullptr) return BADINT; /* hopeless -- abandon */
acc=allocacc;
}
/* Calculate units and remainder from exponent. */
@@ -6329,7 +6329,7 @@ static Int decUnitCompare(const Unit *a, Int alength,
result=(*u==0 ? 0 : +1);
}
/* clean up and return the result */
- if (allocacc!=NULL) free(allocacc); /* drop any storage used */
+ if (allocacc!=nullptr) free(allocacc); /* drop any storage used */
return result;
} /* decUnitCompare */
@@ -6847,7 +6847,7 @@ static Int decShiftToLeast(Unit *uar, Int units, Int shift) {
/* Instead, return an allocated decNumber, rounded as required. */
/* It is the caller's responsibility to free the allocated storage. */
/* */
-/* If no storage is available then the result cannot be used, so NULL */
+/* If no storage is available then the result cannot be used, so nullptr */
/* is returned. */
/* ------------------------------------------------------------------ */
static decNumber *decRoundOperand(const decNumber *dn, decContext *set,
@@ -6860,9 +6860,9 @@ static decNumber *decRoundOperand(const decNumber *dn, decContext *set,
/* length specified by the context */
res=(decNumber *)malloc(sizeof(decNumber)
+(D2U(set->digits)-1)*sizeof(Unit));
- if (res==NULL) {
+ if (res==nullptr) {
*status|=DEC_Insufficient_storage;
- return NULL;
+ return nullptr;
}
decCopyFit(res, dn, set, &residue, &newstatus);
decApplyRound(res, set, residue, &newstatus);
@@ -7725,7 +7725,7 @@ static Flag decBiStr(const char *targ, const char *str1, const char *str2) {
/* */
/* res is the result number */
/* lhs is the first operand */
-/* rhs is the second operand, or NULL if none */
+/* rhs is the second operand, or nullptr if none */
/* context is used to limit payload length */
/* status contains the current status */
/* returns res in case convenient */
@@ -7741,7 +7741,7 @@ static decNumber * decNaNs(decNumber *res, const decNumber *lhs,
/* and status updated if need be */
if (lhs->bits & DECSNAN)
*status|=DEC_Invalid_operation | DEC_sNaN;
- else if (rhs==NULL);
+ else if (rhs==nullptr);
else if (rhs->bits & DECSNAN) {
lhs=rhs;
*status|=DEC_Invalid_operation | DEC_sNaN;
@@ -7862,8 +7862,8 @@ void uprv_decNumberShow(const decNumber *dn) {
uInt u, d; /* .. */
Int cut; /* .. */
char isign='+'; /* main sign */
- if (dn==NULL) {
- printf("NULL\n");
+ if (dn==nullptr) {
+ printf("nullptr\n");
return;}
if (decNumberIsNegative(dn)) isign='-';
printf(" >> %c ", isign);
@@ -7944,22 +7944,22 @@ static void decDumpAr(char name, const Unit *ar, Int len) {
/* ------------------------------------------------------------------ */
/* decCheckOperands -- check operand(s) to a routine */
/* res is the result structure (not checked; it will be set to */
-/* quiet NaN if error found (and it is not NULL)) */
+/* quiet NaN if error found (and it is not nullptr)) */
/* lhs is the first operand (may be DECUNRESU) */
/* rhs is the second (may be DECUNUSED) */
/* set is the context (may be DECUNCONT) */
/* returns 0 if both operands, and the context are clean, or 1 */
/* otherwise (in which case the context will show an error, */
-/* unless NULL). Note that res is not cleaned; caller should */
-/* handle this so res=NULL case is safe. */
+/* unless nullptr). Note that res is not cleaned; caller should */
+/* handle this so res=nullptr case is safe. */
/* The caller is expected to abandon immediately if 1 is returned. */
/* ------------------------------------------------------------------ */
static Flag decCheckOperands(decNumber *res, const decNumber *lhs,
const decNumber *rhs, decContext *set) {
Flag bad=0;
- if (set==NULL) { /* oops; hopeless */
+ if (set==nullptr) { /* oops; hopeless */
#if DECTRACE || DECVERB
- printf("Reference to context is NULL.\n");
+ printf("Reference to context is nullptr.\n");
#endif
bad=1;
return 1;}
@@ -7972,11 +7972,11 @@ static Flag decCheckOperands(decNumber *res, const decNumber *lhs,
#endif
}
else {
- if (res==NULL) {
+ if (res==nullptr) {
bad=1;
#if DECTRACE
- /* this one not DECVERB as standard tests include NULL */
- printf("Reference to result is NULL.\n");
+ /* this one not DECVERB as standard tests include nullptr */
+ printf("Reference to result is nullptr.\n");
#endif
}
if (!bad && lhs!=DECUNUSED) bad=(decCheckNumber(lhs));
@@ -7984,7 +7984,7 @@ static Flag decCheckOperands(decNumber *res, const decNumber *lhs,
}
if (bad) {
if (set!=DECUNCONT) uprv_decContextSetStatus(set, DEC_Invalid_operation);
- if (res!=DECUNRESU && res!=NULL) {
+ if (res!=DECUNRESU && res!=nullptr) {
uprv_decNumberZero(res);
res->bits=DECNAN; /* qNaN */
}
@@ -8006,10 +8006,10 @@ static Flag decCheckNumber(const decNumber *dn) {
Int ae, d, digits; /* .. */
Int emin, emax; /* .. */
- if (dn==NULL) { /* hopeless */
+ if (dn==nullptr) { /* hopeless */
#if DECTRACE
- /* this one not DECVERB as standard tests include NULL */
- printf("Reference to decNumber is NULL.\n");
+ /* this one not DECVERB as standard tests include nullptr */
+ printf("Reference to decNumber is nullptr.\n");
#endif
return 1;}
@@ -8114,7 +8114,7 @@ static void decCheckInexact(const decNumber *dn, decContext *set) {
}
#else
/* next is a noop for quiet compiler */
- if (dn!=NULL && dn->digits==0) set->status|=DEC_Invalid_operation;
+ if (dn!=nullptr && dn->digits==0) set->status|=DEC_Invalid_operation;
#endif
return;
} /* decCheckInexact */
@@ -8144,7 +8144,7 @@ static void *decMalloc(size_t n) {
uInt uiwork; /* for macros */
alloc=malloc(size); /* -> allocated storage */
- if (alloc==NULL) return NULL; /* out of strorage */
+ if (alloc==nullptr) return nullptr; /* out of strorage */
b0=(uByte *)alloc; /* as bytes */
decAllocBytes+=n; /* account for storage */
UBFROMUI(alloc, n); /* save n */
@@ -8171,7 +8171,7 @@ static void decFree(void *alloc) {
uByte *b, *b0; /* work */
uInt uiwork; /* for macros */
- if (alloc==NULL) return; /* allowed; it's a nop */
+ if (alloc==nullptr) return; /* allowed; it's a nop */
b0=(uByte *)alloc; /* as bytes */
b0-=8; /* -> true start of storage */
n=UBTOUI(b0); /* lift length */
diff --git a/contrib/libs/icu/i18n/decNumber.h b/contrib/libs/icu/i18n/decNumber.h
index ddcc50e2ef..4a1eb364e1 100644
--- a/contrib/libs/icu/i18n/decNumber.h
+++ b/contrib/libs/icu/i18n/decNumber.h
@@ -174,7 +174,7 @@
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 const char * U_EXPORT2 uprv_decNumberVersion();
U_CAPI decNumber * U_EXPORT2 uprv_decNumberZero(decNumber *);
/* Functions for testing decNumbers (normality depends on context) */
diff --git a/contrib/libs/icu/i18n/decimfmt.cpp b/contrib/libs/icu/i18n/decimfmt.cpp
index bca3336679..75906991d7 100644
--- a/contrib/libs/icu/i18n/decimfmt.cpp
+++ b/contrib/libs/icu/i18n/decimfmt.cpp
@@ -790,7 +790,7 @@ CurrencyAmount* DecimalFormat::parseCurrency(const UnicodeString& text, ParsePos
}
}
-const DecimalFormatSymbols* DecimalFormat::getDecimalFormatSymbols(void) const {
+const DecimalFormatSymbols* DecimalFormat::getDecimalFormatSymbols() const {
if (fields == nullptr) {
return nullptr;
}
@@ -803,7 +803,7 @@ const DecimalFormatSymbols* DecimalFormat::getDecimalFormatSymbols(void) const {
void DecimalFormat::adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt) {
if (symbolsToAdopt == nullptr) {
- return; // do not allow caller to set fields->symbols to NULL
+ return; // do not allow caller to set fields->symbols to nullptr
}
// we must take ownership of symbolsToAdopt, even in a failure case.
LocalPointer<DecimalFormatSymbols> dfs(symbolsToAdopt);
@@ -831,7 +831,7 @@ void DecimalFormat::setDecimalFormatSymbols(const DecimalFormatSymbols& symbols)
touchNoError();
}
-const CurrencyPluralInfo* DecimalFormat::getCurrencyPluralInfo(void) const {
+const CurrencyPluralInfo* DecimalFormat::getCurrencyPluralInfo() const {
if (fields == nullptr) {
return nullptr;
}
@@ -957,7 +957,7 @@ void DecimalFormat::setSignAlwaysShown(UBool value) {
touchNoError();
}
-int32_t DecimalFormat::getMultiplier(void) const {
+int32_t DecimalFormat::getMultiplier() const {
const DecimalFormatProperties *dfp;
// Not much we can do to report an error.
if (fields == nullptr) {
@@ -1021,7 +1021,7 @@ void DecimalFormat::setMultiplierScale(int32_t newValue) {
touchNoError();
}
-double DecimalFormat::getRoundingIncrement(void) const {
+double DecimalFormat::getRoundingIncrement() const {
// Not much we can do to report an error.
if (fields == nullptr) {
// Fallback to using the default instance of DecimalFormatProperties.
@@ -1037,7 +1037,7 @@ void DecimalFormat::setRoundingIncrement(double newValue) {
touchNoError();
}
-ERoundingMode DecimalFormat::getRoundingMode(void) const {
+ERoundingMode DecimalFormat::getRoundingMode() const {
// Not much we can do to report an error.
if (fields == nullptr) {
// Fallback to using the default instance of DecimalFormatProperties.
@@ -1047,7 +1047,7 @@ ERoundingMode DecimalFormat::getRoundingMode(void) const {
return static_cast<ERoundingMode>(fields->exportedProperties.roundingMode.getNoError());
}
-void DecimalFormat::setRoundingMode(ERoundingMode roundingMode) {
+void DecimalFormat::setRoundingMode(ERoundingMode roundingMode) UPRV_NO_SANITIZE_UNDEFINED {
if (fields == nullptr) { return; }
auto uRoundingMode = static_cast<UNumberFormatRoundingMode>(roundingMode);
if (!fields->properties.roundingMode.isNull() && uRoundingMode == fields->properties.roundingMode.getNoError()) {
@@ -1058,7 +1058,7 @@ void DecimalFormat::setRoundingMode(ERoundingMode roundingMode) {
touchNoError();
}
-int32_t DecimalFormat::getFormatWidth(void) const {
+int32_t DecimalFormat::getFormatWidth() const {
// Not much we can do to report an error.
if (fields == nullptr) {
// Fallback to using the default instance of DecimalFormatProperties.
@@ -1094,7 +1094,7 @@ void DecimalFormat::setPadCharacter(const UnicodeString& padChar) {
touchNoError();
}
-EPadPosition DecimalFormat::getPadPosition(void) const {
+EPadPosition DecimalFormat::getPadPosition() const {
if (fields == nullptr || fields->properties.padPosition.isNull()) {
return EPadPosition::kPadBeforePrefix;
} else {
@@ -1113,7 +1113,7 @@ void DecimalFormat::setPadPosition(EPadPosition padPos) {
touchNoError();
}
-UBool DecimalFormat::isScientificNotation(void) const {
+UBool DecimalFormat::isScientificNotation() const {
// Not much we can do to report an error.
if (fields == nullptr) {
// Fallback to using the default instance of DecimalFormatProperties.
@@ -1134,7 +1134,7 @@ void DecimalFormat::setScientificNotation(UBool useScientific) {
touchNoError();
}
-int8_t DecimalFormat::getMinimumExponentDigits(void) const {
+int8_t DecimalFormat::getMinimumExponentDigits() const {
// Not much we can do to report an error.
if (fields == nullptr) {
// Fallback to using the default instance of DecimalFormatProperties.
@@ -1150,7 +1150,7 @@ void DecimalFormat::setMinimumExponentDigits(int8_t minExpDig) {
touchNoError();
}
-UBool DecimalFormat::isExponentSignAlwaysShown(void) const {
+UBool DecimalFormat::isExponentSignAlwaysShown() const {
// Not much we can do to report an error.
if (fields == nullptr) {
// Fallback to using the default instance of DecimalFormatProperties.
@@ -1166,7 +1166,7 @@ void DecimalFormat::setExponentSignAlwaysShown(UBool expSignAlways) {
touchNoError();
}
-int32_t DecimalFormat::getGroupingSize(void) const {
+int32_t DecimalFormat::getGroupingSize() const {
int32_t groupingSize;
// Not much we can do to report an error.
if (fields == nullptr) {
@@ -1188,7 +1188,7 @@ void DecimalFormat::setGroupingSize(int32_t newValue) {
touchNoError();
}
-int32_t DecimalFormat::getSecondaryGroupingSize(void) const {
+int32_t DecimalFormat::getSecondaryGroupingSize() const {
int32_t grouping2;
// Not much we can do to report an error.
if (fields == nullptr) {
@@ -1226,7 +1226,7 @@ void DecimalFormat::setMinimumGroupingDigits(int32_t newValue) {
touchNoError();
}
-UBool DecimalFormat::isDecimalSeparatorAlwaysShown(void) const {
+UBool DecimalFormat::isDecimalSeparatorAlwaysShown() const {
// Not much we can do to report an error.
if (fields == nullptr) {
// Fallback to using the default instance of DecimalFormatProperties.
@@ -1242,7 +1242,7 @@ void DecimalFormat::setDecimalSeparatorAlwaysShown(UBool newValue) {
touchNoError();
}
-UBool DecimalFormat::isDecimalPatternMatchRequired(void) const {
+UBool DecimalFormat::isDecimalPatternMatchRequired() const {
// Not much we can do to report an error.
if (fields == nullptr) {
// Fallback to using the default instance of DecimalFormatProperties.
diff --git a/contrib/libs/icu/i18n/displayoptions.cpp b/contrib/libs/icu/i18n/displayoptions.cpp
new file mode 100644
index 0000000000..bb49e6033f
--- /dev/null
+++ b/contrib/libs/icu/i18n/displayoptions.cpp
@@ -0,0 +1,167 @@
+// © 2022 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 "unicode/displayoptions.h"
+#include "unicode/udisplayoptions.h"
+#include "cstring.h"
+
+U_NAMESPACE_BEGIN
+
+DisplayOptions::Builder DisplayOptions::builder() { return DisplayOptions::Builder(); }
+
+DisplayOptions::Builder DisplayOptions::copyToBuilder() const { return Builder(*this); }
+
+DisplayOptions::DisplayOptions(const Builder &builder) {
+ grammaticalCase = builder.grammaticalCase;
+ nounClass = builder.nounClass;
+ pluralCategory = builder.pluralCategory;
+ capitalization = builder.capitalization;
+ nameStyle = builder.nameStyle;
+ displayLength = builder.displayLength;
+ substituteHandling = builder.substituteHandling;
+}
+
+DisplayOptions::Builder::Builder() {
+ // Sets default values.
+ grammaticalCase = UDISPOPT_GRAMMATICAL_CASE_UNDEFINED;
+ nounClass = UDISPOPT_NOUN_CLASS_UNDEFINED;
+ pluralCategory = UDISPOPT_PLURAL_CATEGORY_UNDEFINED;
+ capitalization = UDISPOPT_CAPITALIZATION_UNDEFINED;
+ nameStyle = UDISPOPT_NAME_STYLE_UNDEFINED;
+ displayLength = UDISPOPT_DISPLAY_LENGTH_UNDEFINED;
+ substituteHandling = UDISPOPT_SUBSTITUTE_HANDLING_UNDEFINED;
+}
+
+DisplayOptions::Builder::Builder(const DisplayOptions &displayOptions) {
+ grammaticalCase = displayOptions.grammaticalCase;
+ nounClass = displayOptions.nounClass;
+ pluralCategory = displayOptions.pluralCategory;
+ capitalization = displayOptions.capitalization;
+ nameStyle = displayOptions.nameStyle;
+ displayLength = displayOptions.displayLength;
+ substituteHandling = displayOptions.substituteHandling;
+}
+
+U_NAMESPACE_END
+
+// C API ------------------------------------------------------------------- ***
+
+U_NAMESPACE_USE
+
+namespace {
+
+const char *grammaticalCaseIds[] = {
+ "undefined", // 0
+ "ablative", // 1
+ "accusative", // 2
+ "comitative", // 3
+ "dative", // 4
+ "ergative", // 5
+ "genitive", // 6
+ "instrumental", // 7
+ "locative", // 8
+ "locative_copulative", // 9
+ "nominative", // 10
+ "oblique", // 11
+ "prepositional", // 12
+ "sociative", // 13
+ "vocative", // 14
+};
+
+} // namespace
+
+U_CAPI const char * U_EXPORT2
+udispopt_getGrammaticalCaseIdentifier(UDisplayOptionsGrammaticalCase grammaticalCase) {
+ if (grammaticalCase >= 0 && grammaticalCase < UPRV_LENGTHOF(grammaticalCaseIds)) {
+ return grammaticalCaseIds[grammaticalCase];
+ }
+
+ return grammaticalCaseIds[0];
+}
+
+U_CAPI UDisplayOptionsGrammaticalCase U_EXPORT2
+udispopt_fromGrammaticalCaseIdentifier(const char *identifier) {
+ for (int32_t i = 0; i < UPRV_LENGTHOF(grammaticalCaseIds); i++) {
+ if (uprv_strcmp(identifier, grammaticalCaseIds[i]) == 0) {
+ return static_cast<UDisplayOptionsGrammaticalCase>(i);
+ }
+ }
+
+ return UDISPOPT_GRAMMATICAL_CASE_UNDEFINED;
+}
+
+namespace {
+
+const char *pluralCategoryIds[] = {
+ "undefined", // 0
+ "zero", // 1
+ "one", // 2
+ "two", // 3
+ "few", // 4
+ "many", // 5
+ "other", // 6
+};
+
+} // namespace
+
+U_CAPI const char * U_EXPORT2
+udispopt_getPluralCategoryIdentifier(UDisplayOptionsPluralCategory pluralCategory) {
+ if (pluralCategory >= 0 && pluralCategory < UPRV_LENGTHOF(pluralCategoryIds)) {
+ return pluralCategoryIds[pluralCategory];
+ }
+
+ return pluralCategoryIds[0];
+}
+
+U_CAPI UDisplayOptionsPluralCategory U_EXPORT2
+udispopt_fromPluralCategoryIdentifier(const char *identifier) {
+ for (int32_t i = 0; i < UPRV_LENGTHOF(pluralCategoryIds); i++) {
+ if (uprv_strcmp(identifier, pluralCategoryIds[i]) == 0) {
+ return static_cast<UDisplayOptionsPluralCategory>(i);
+ }
+ }
+
+ return UDISPOPT_PLURAL_CATEGORY_UNDEFINED;
+}
+
+namespace {
+
+const char *nounClassIds[] = {
+ "undefined", // 0
+ "other", // 1
+ "neuter", // 2
+ "feminine", // 3
+ "masculine", // 4
+ "animate", // 5
+ "inanimate", // 6
+ "personal", // 7
+ "common", // 8
+};
+
+} // namespace
+
+U_CAPI const char * U_EXPORT2
+udispopt_getNounClassIdentifier(UDisplayOptionsNounClass nounClass) {
+ if (nounClass >= 0 && nounClass < UPRV_LENGTHOF(nounClassIds)) {
+ return nounClassIds[nounClass];
+ }
+
+ return nounClassIds[0];
+}
+
+U_CAPI UDisplayOptionsNounClass U_EXPORT2
+udispopt_fromNounClassIdentifier(const char *identifier) {
+ for (int32_t i = 0; i < UPRV_LENGTHOF(nounClassIds); i++) {
+ if (uprv_strcmp(identifier, nounClassIds[i]) == 0) {
+ return static_cast<UDisplayOptionsNounClass>(i);
+ }
+ }
+
+ return UDISPOPT_NOUN_CLASS_UNDEFINED;
+}
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/contrib/libs/icu/i18n/double-conversion-bignum.cpp b/contrib/libs/icu/i18n/double-conversion-bignum.cpp
index 996d75c9f6..d2b701a21d 100644
--- a/contrib/libs/icu/i18n/double-conversion-bignum.cpp
+++ b/contrib/libs/icu/i18n/double-conversion-bignum.cpp
@@ -150,7 +150,7 @@ void Bignum::AssignHexString(Vector<const char> value) {
DOUBLE_CONVERSION_ASSERT(sizeof(uint64_t) * 8 >= kBigitSize + 4); // TODO: static_assert
// Accumulates converted hex digits until at least kBigitSize bits.
// Works with non-factor-of-four kBigitSizes.
- uint64_t tmp = 0; // Accumulates converted hex digits until at least
+ uint64_t tmp = 0;
for (int cnt = 0; !value.is_empty(); value.pop_back()) {
tmp |= (HexCharValue(value.last()) << cnt);
if ((cnt += 4) >= kBigitSize) {
@@ -160,7 +160,8 @@ void Bignum::AssignHexString(Vector<const char> value) {
}
}
if (tmp > 0) {
- RawBigit(used_bigits_++) = tmp;
+ DOUBLE_CONVERSION_ASSERT(tmp <= kBigitMask);
+ RawBigit(used_bigits_++) = static_cast<Bignum::Chunk>(tmp & kBigitMask);
}
Clamp();
}
@@ -217,7 +218,7 @@ void Bignum::AddBignum(const Bignum& other) {
carry = sum >> kBigitSize;
++bigit_pos;
}
- used_bigits_ = (std::max)(bigit_pos, static_cast<int>(used_bigits_));
+ used_bigits_ = static_cast<int16_t>(std::max(bigit_pos, static_cast<int>(used_bigits_)));
DOUBLE_CONVERSION_ASSERT(IsClamped());
}
@@ -253,7 +254,7 @@ void Bignum::ShiftLeft(const int shift_amount) {
if (used_bigits_ == 0) {
return;
}
- exponent_ += (shift_amount / kBigitSize);
+ exponent_ += static_cast<int16_t>(shift_amount / kBigitSize);
const int local_shift = shift_amount % kBigitSize;
EnsureCapacity(used_bigits_ + 1);
BigitsShiftLeft(local_shift);
@@ -431,7 +432,7 @@ void Bignum::Square() {
DOUBLE_CONVERSION_ASSERT(accumulator == 0);
// Don't forget to update the used_digits and the exponent.
- used_bigits_ = product_length;
+ used_bigits_ = static_cast<int16_t>(product_length);
exponent_ *= 2;
Clamp();
}
@@ -752,8 +753,8 @@ void Bignum::Align(const Bignum& other) {
for (int i = 0; i < zero_bigits; ++i) {
RawBigit(i) = 0;
}
- used_bigits_ += zero_bigits;
- exponent_ -= zero_bigits;
+ used_bigits_ += static_cast<int16_t>(zero_bigits);
+ exponent_ -= static_cast<int16_t>(zero_bigits);
DOUBLE_CONVERSION_ASSERT(used_bigits_ >= 0);
DOUBLE_CONVERSION_ASSERT(exponent_ >= 0);
diff --git a/contrib/libs/icu/i18n/double-conversion-double-to-string.cpp b/contrib/libs/icu/i18n/double-conversion-double-to-string.cpp
index 90ba436060..5ee6d2b8e8 100644
--- a/contrib/libs/icu/i18n/double-conversion-double-to-string.cpp
+++ b/contrib/libs/icu/i18n/double-conversion-double-to-string.cpp
@@ -71,7 +71,7 @@ bool DoubleToStringConverter::HandleSpecialValues(
StringBuilder* result_builder) const {
Double double_inspect(value);
if (double_inspect.IsInfinite()) {
- if (infinity_symbol_ == NULL) return false;
+ if (infinity_symbol_ == DOUBLE_CONVERSION_NULLPTR) return false;
if (value < 0) {
result_builder->AddCharacter('-');
}
@@ -79,7 +79,7 @@ bool DoubleToStringConverter::HandleSpecialValues(
return true;
}
if (double_inspect.IsNan()) {
- if (nan_symbol_ == NULL) return false;
+ if (nan_symbol_ == DOUBLE_CONVERSION_NULLPTR) return false;
result_builder->AddString(nan_symbol_);
return true;
}
diff --git a/contrib/libs/icu/i18n/double-conversion-double-to-string.h b/contrib/libs/icu/i18n/double-conversion-double-to-string.h
index 1fae2e8771..9940052c64 100644
--- a/contrib/libs/icu/i18n/double-conversion-double-to-string.h
+++ b/contrib/libs/icu/i18n/double-conversion-double-to-string.h
@@ -114,7 +114,7 @@ class DoubleToStringConverter {
// preserved.
//
// Infinity symbol and nan_symbol provide the string representation for these
- // special values. If the string is NULL and the special value is encountered
+ // special values. If the string is nullptr and the special value is encountered
// then the conversion functions return false.
//
// The exponent_character is used in exponential representations. It is
@@ -429,7 +429,7 @@ class DoubleToStringConverter {
// If the value is a special value (NaN or Infinity) constructs the
// corresponding string using the configured infinity/nan-symbol.
- // If either of them is NULL or the value is not special then the
+ // If either of them is nullptr or the value is not special then the
// function returns false.
bool HandleSpecialValues(double value, StringBuilder* result_builder) const;
// Constructs an exponential representation (i.e. 1.234e56).
diff --git a/contrib/libs/icu/i18n/double-conversion-ieee.h b/contrib/libs/icu/i18n/double-conversion-ieee.h
index 31c35867de..2940acb169 100644
--- a/contrib/libs/icu/i18n/double-conversion-ieee.h
+++ b/contrib/libs/icu/i18n/double-conversion-ieee.h
@@ -164,11 +164,19 @@ class Double {
}
bool IsQuietNan() const {
+#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
+ return IsNan() && ((AsUint64() & kQuietNanBit) == 0);
+#else
return IsNan() && ((AsUint64() & kQuietNanBit) != 0);
+#endif
}
bool IsSignalingNan() const {
+#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
+ return IsNan() && ((AsUint64() & kQuietNanBit) != 0);
+#else
return IsNan() && ((AsUint64() & kQuietNanBit) == 0);
+#endif
}
@@ -250,7 +258,12 @@ class Double {
private:
static const int kDenormalExponent = -kExponentBias + 1;
static const uint64_t kInfinity = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF00000, 00000000);
+#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
+ static const uint64_t kNaN = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF7FFFF, FFFFFFFF);
+#else
static const uint64_t kNaN = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF80000, 00000000);
+#endif
+
const uint64_t d64_;
@@ -350,11 +363,19 @@ class Single {
}
bool IsQuietNan() const {
+#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
+ return IsNan() && ((AsUint32() & kQuietNanBit) == 0);
+#else
return IsNan() && ((AsUint32() & kQuietNanBit) != 0);
+#endif
}
bool IsSignalingNan() const {
+#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
+ return IsNan() && ((AsUint32() & kQuietNanBit) != 0);
+#else
return IsNan() && ((AsUint32() & kQuietNanBit) == 0);
+#endif
}
@@ -424,7 +445,11 @@ class Single {
static const int kDenormalExponent = -kExponentBias + 1;
static const int kMaxExponent = 0xFF - kExponentBias;
static const uint32_t kInfinity = 0x7F800000;
+#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
+ static const uint32_t kNaN = 0x7FBFFFFF;
+#else
static const uint32_t kNaN = 0x7FC00000;
+#endif
const uint32_t d32_;
diff --git a/contrib/libs/icu/i18n/double-conversion-string-to-double.cpp b/contrib/libs/icu/i18n/double-conversion-string-to-double.cpp
index c72bb26277..727fff24e1 100644
--- a/contrib/libs/icu/i18n/double-conversion-string-to-double.cpp
+++ b/contrib/libs/icu/i18n/double-conversion-string-to-double.cpp
@@ -495,7 +495,7 @@ double StringToDoubleConverter::StringToIeee(
current = next_non_space;
}
- if (infinity_symbol_ != NULL) {
+ if (infinity_symbol_ != DOUBLE_CONVERSION_NULLPTR) {
if (ConsumeFirstCharacter(*current, infinity_symbol_, allow_case_insensitivity)) {
if (!ConsumeSubString(&current, end, infinity_symbol_, allow_case_insensitivity)) {
return junk_string_value_;
@@ -513,7 +513,7 @@ double StringToDoubleConverter::StringToIeee(
}
}
- if (nan_symbol_ != NULL) {
+ if (nan_symbol_ != DOUBLE_CONVERSION_NULLPTR) {
if (ConsumeFirstCharacter(*current, nan_symbol_, allow_case_insensitivity)) {
if (!ConsumeSubString(&current, end, nan_symbol_, allow_case_insensitivity)) {
return junk_string_value_;
diff --git a/contrib/libs/icu/i18n/double-conversion-string-to-double.h b/contrib/libs/icu/i18n/double-conversion-string-to-double.h
index 9f6f530711..1d4e3dddde 100644
--- a/contrib/libs/icu/i18n/double-conversion-string-to-double.h
+++ b/contrib/libs/icu/i18n/double-conversion-string-to-double.h
@@ -158,8 +158,8 @@ class StringToDoubleConverter {
// flags = ALLOW_OCTAL | ALLOW_LEADING_SPACES,
// empty_string_value = 0.0,
// junk_string_value = NaN,
- // infinity_symbol = NULL,
- // nan_symbol = NULL:
+ // infinity_symbol = nullptr,
+ // nan_symbol = nullptr:
// StringToDouble("0x1234") -> NaN // junk_string_value.
// StringToDouble("01234") -> 668.0.
// StringToDouble("") -> 0.0 // empty_string_value.
diff --git a/contrib/libs/icu/i18n/double-conversion-utils.h b/contrib/libs/icu/i18n/double-conversion-utils.h
index 7f23e0a825..303668f931 100644
--- a/contrib/libs/icu/i18n/double-conversion-utils.h
+++ b/contrib/libs/icu/i18n/double-conversion-utils.h
@@ -37,18 +37,36 @@
#ifndef DOUBLE_CONVERSION_UTILS_H_
#define DOUBLE_CONVERSION_UTILS_H_
+// Use DOUBLE_CONVERSION_NON_PREFIXED_MACROS to get unprefixed macros as was
+// the case in double-conversion releases prior to 3.1.6
+
#include <cstdlib>
#include <cstring>
+// For pre-C++11 compatibility
+#if __cplusplus >= 201103L
+#define DOUBLE_CONVERSION_NULLPTR nullptr
+#else
+#define DOUBLE_CONVERSION_NULLPTR NULL
+#endif
+
// ICU PATCH: Use U_ASSERT instead of <assert.h>
#include "uassert.h"
#ifndef DOUBLE_CONVERSION_ASSERT
#define DOUBLE_CONVERSION_ASSERT(condition) \
U_ASSERT(condition)
#endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(ASSERT)
+#define ASSERT DOUBLE_CONVERSION_ASSERT
+#endif
+
#ifndef DOUBLE_CONVERSION_UNIMPLEMENTED
#define DOUBLE_CONVERSION_UNIMPLEMENTED() (abort())
#endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(UNIMPLEMENTED)
+#define UNIMPLEMENTED DOUBLE_CONVERSION_UNIMPLEMENTED
+#endif
+
#ifndef DOUBLE_CONVERSION_NO_RETURN
#ifdef _MSC_VER
#define DOUBLE_CONVERSION_NO_RETURN __declspec(noreturn)
@@ -56,6 +74,10 @@
#define DOUBLE_CONVERSION_NO_RETURN __attribute__((noreturn))
#endif
#endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(NO_RETURN)
+#define NO_RETURN DOUBLE_CONVERSION_NO_RETURN
+#endif
+
#ifndef DOUBLE_CONVERSION_UNREACHABLE
#ifdef _MSC_VER
void DOUBLE_CONVERSION_NO_RETURN abort_noreturn();
@@ -65,6 +87,9 @@ inline void abort_noreturn() { abort(); }
#define DOUBLE_CONVERSION_UNREACHABLE() (abort())
#endif
#endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(UNREACHABLE)
+#define UNREACHABLE DOUBLE_CONVERSION_UNREACHABLE
+#endif
// Not all compilers support __has_attribute and combining a check for both
// ifdef and __has_attribute on the same preprocessor line isn't portable.
@@ -81,12 +106,18 @@ inline void abort_noreturn() { abort(); }
#define DOUBLE_CONVERSION_UNUSED
#endif
#endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(UNUSED)
+#define UNUSED DOUBLE_CONVERSION_UNUSED
+#endif
#if DOUBLE_CONVERSION_HAS_ATTRIBUTE(uninitialized)
#define DOUBLE_CONVERSION_STACK_UNINITIALIZED __attribute__((uninitialized))
#else
#define DOUBLE_CONVERSION_STACK_UNINITIALIZED
#endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(STACK_UNINITIALIZED)
+#define STACK_UNINITIALIZED DOUBLE_CONVERSION_STACK_UNINITIALIZED
+#endif
// Double operations detection based on target architecture.
// Linux uses a 80bit wide floating point stack on x86. This induces double
@@ -127,7 +158,7 @@ int main(int argc, char** argv) {
defined(_MIPS_ARCH_MIPS32R2) || defined(__ARMEB__) ||\
defined(__AARCH64EL__) || defined(__aarch64__) || defined(__AARCH64EB__) || \
defined(__riscv) || defined(__e2k__) || \
- defined(__or1k__) || defined(__arc__) || \
+ defined(__or1k__) || defined(__arc__) || defined(__ARC64__) || \
defined(__microblaze__) || defined(__XTENSA__) || \
defined(__EMSCRIPTEN__) || defined(__wasm32__)
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
@@ -144,6 +175,9 @@ int main(int argc, char** argv) {
#else
#error Target architecture was not detected as supported by Double-Conversion.
#endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(CORRECT_DOUBLE_OPERATIONS)
+#define CORRECT_DOUBLE_OPERATIONS DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS
+#endif
#if defined(_WIN32) && !defined(__MINGW32__)
@@ -169,7 +203,9 @@ typedef uint16_t uc16;
// Usage: instead of writing 0x1234567890123456
// write DOUBLE_CONVERSION_UINT64_2PART_C(0x12345678,90123456);
#define DOUBLE_CONVERSION_UINT64_2PART_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u))
-
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(UINT64_2PART_C)
+#define UINT64_2PART_C DOUBLE_CONVERSION_UINT64_2PART_C
+#endif
// The expression DOUBLE_CONVERSION_ARRAY_SIZE(a) is a compile-time constant of type
// size_t which represents the number of elements of the given
@@ -180,6 +216,9 @@ typedef uint16_t uc16;
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
#endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(ARRAY_SIZE)
+#define ARRAY_SIZE DOUBLE_CONVERSION_ARRAY_SIZE
+#endif
// A macro to disallow the evil copy constructor and operator= functions
// This should be used in the private: declarations for a class
@@ -188,6 +227,9 @@ typedef uint16_t uc16;
TypeName(const TypeName&); \
void operator=(const TypeName&)
#endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(DC_DISALLOW_COPY_AND_ASSIGN)
+#define DC_DISALLOW_COPY_AND_ASSIGN DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN
+#endif
// A macro to disallow all the implicit constructors, namely the
// default constructor, copy constructor and operator= functions.
@@ -200,6 +242,9 @@ typedef uint16_t uc16;
TypeName(); \
DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(TypeName)
#endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(DC_DISALLOW_IMPLICIT_CONSTRUCTORS)
+#define DC_DISALLOW_IMPLICIT_CONSTRUCTORS DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS
+#endif
// ICU PATCH: Wrap in ICU namespace
U_NAMESPACE_BEGIN
@@ -216,9 +261,9 @@ inline int StrLength(const char* string) {
template <typename T>
class Vector {
public:
- Vector() : start_(NULL), length_(0) {}
+ Vector() : start_(DOUBLE_CONVERSION_NULLPTR), length_(0) {}
Vector(T* data, int len) : start_(data), length_(len) {
- DOUBLE_CONVERSION_ASSERT(len == 0 || (len > 0 && data != NULL));
+ DOUBLE_CONVERSION_ASSERT(len == 0 || (len > 0 && data != DOUBLE_CONVERSION_NULLPTR));
}
// Returns a vector using the same backing storage as this one,
@@ -301,7 +346,7 @@ class StringBuilder {
void AddSubstring(const char* s, int n) {
DOUBLE_CONVERSION_ASSERT(!is_finalized() && position_ + n < buffer_.length());
DOUBLE_CONVERSION_ASSERT(static_cast<size_t>(n) <= strlen(s));
- memmove(&buffer_[position_], s, n);
+ memmove(&buffer_[position_], s, static_cast<size_t>(n));
position_ += n;
}
diff --git a/contrib/libs/icu/i18n/dt_impl.h b/contrib/libs/icu/i18n/dt_impl.h
index a4058c6924..a21b68ce1e 100644
--- a/contrib/libs/icu/i18n/dt_impl.h
+++ b/contrib/libs/icu/i18n/dt_impl.h
@@ -25,66 +25,66 @@
#include "unicode/unistr.h"
-#define QUOTE ((UChar)0x0027)
-#define LOW_LINE ((UChar)0x005F)
-#define COLON ((UChar)0x003A)
-#define LEFT_CURLY_BRACKET ((UChar)0x007B)
-#define RIGHT_CURLY_BRACKET ((UChar)0x007D)
-#define SPACE ((UChar)0x0020)
-#define EN_DASH ((UChar)0x2013)
-#define SOLIDUS ((UChar)0x002F)
-#define PERCENT ((UChar)0x0025)
+#define QUOTE ((char16_t)0x0027)
+#define LOW_LINE ((char16_t)0x005F)
+#define COLON ((char16_t)0x003A)
+#define LEFT_CURLY_BRACKET ((char16_t)0x007B)
+#define RIGHT_CURLY_BRACKET ((char16_t)0x007D)
+#define SPACE ((char16_t)0x0020)
+#define EN_DASH ((char16_t)0x2013)
+#define SOLIDUS ((char16_t)0x002F)
+#define PERCENT ((char16_t)0x0025)
-#define DIGIT_ZERO ((UChar)0x0030)
-#define DIGIT_ONE ((UChar)0x0031)
+#define DIGIT_ZERO ((char16_t)0x0030)
+#define DIGIT_ONE ((char16_t)0x0031)
-#define LOW_A ((UChar)0x0061)
-#define LOW_B ((UChar)0x0062)
-#define LOW_C ((UChar)0x0063)
-#define LOW_D ((UChar)0x0064)
-#define LOW_E ((UChar)0x0065)
-#define LOW_F ((UChar)0x0066)
-#define LOW_G ((UChar)0x0067)
-#define LOW_H ((UChar)0x0068)
-#define LOW_I ((UChar)0x0069)
-#define LOW_J ((UChar)0x006a)
-#define LOW_K ((UChar)0x006B)
-#define LOW_L ((UChar)0x006C)
-#define LOW_M ((UChar)0x006D)
-#define LOW_N ((UChar)0x006E)
-#define LOW_O ((UChar)0x006F)
-#define LOW_P ((UChar)0x0070)
-#define LOW_Q ((UChar)0x0071)
-#define LOW_R ((UChar)0x0072)
-#define LOW_S ((UChar)0x0073)
-#define LOW_T ((UChar)0x0074)
-#define LOW_U ((UChar)0x0075)
-#define LOW_V ((UChar)0x0076)
-#define LOW_W ((UChar)0x0077)
-#define LOW_Y ((UChar)0x0079)
-#define LOW_Z ((UChar)0x007A)
+#define LOW_A ((char16_t)0x0061)
+#define LOW_B ((char16_t)0x0062)
+#define LOW_C ((char16_t)0x0063)
+#define LOW_D ((char16_t)0x0064)
+#define LOW_E ((char16_t)0x0065)
+#define LOW_F ((char16_t)0x0066)
+#define LOW_G ((char16_t)0x0067)
+#define LOW_H ((char16_t)0x0068)
+#define LOW_I ((char16_t)0x0069)
+#define LOW_J ((char16_t)0x006a)
+#define LOW_K ((char16_t)0x006B)
+#define LOW_L ((char16_t)0x006C)
+#define LOW_M ((char16_t)0x006D)
+#define LOW_N ((char16_t)0x006E)
+#define LOW_O ((char16_t)0x006F)
+#define LOW_P ((char16_t)0x0070)
+#define LOW_Q ((char16_t)0x0071)
+#define LOW_R ((char16_t)0x0072)
+#define LOW_S ((char16_t)0x0073)
+#define LOW_T ((char16_t)0x0074)
+#define LOW_U ((char16_t)0x0075)
+#define LOW_V ((char16_t)0x0076)
+#define LOW_W ((char16_t)0x0077)
+#define LOW_Y ((char16_t)0x0079)
+#define LOW_Z ((char16_t)0x007A)
-#define CAP_A ((UChar)0x0041)
-#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_H ((UChar)0x0048)
-#define CAP_K ((UChar)0x004B)
-#define CAP_L ((UChar)0x004C)
-#define CAP_M ((UChar)0x004D)
-#define CAP_N ((UChar)0x004E)
-#define CAP_O ((UChar)0x004F)
-#define CAP_P ((UChar)0x0050)
-#define CAP_Q ((UChar)0x0051)
-#define CAP_S ((UChar)0x0053)
-#define CAP_T ((UChar)0x0054)
-#define CAP_U ((UChar)0x0055)
-#define CAP_V ((UChar)0x0056)
-#define CAP_W ((UChar)0x0057)
-#define CAP_Y ((UChar)0x0059)
-#define CAP_Z ((UChar)0x005A)
+#define CAP_A ((char16_t)0x0041)
+#define CAP_C ((char16_t)0x0043)
+#define CAP_D ((char16_t)0x0044)
+#define CAP_E ((char16_t)0x0045)
+#define CAP_F ((char16_t)0x0046)
+#define CAP_G ((char16_t)0x0047)
+#define CAP_H ((char16_t)0x0048)
+#define CAP_K ((char16_t)0x004B)
+#define CAP_L ((char16_t)0x004C)
+#define CAP_M ((char16_t)0x004D)
+#define CAP_N ((char16_t)0x004E)
+#define CAP_O ((char16_t)0x004F)
+#define CAP_P ((char16_t)0x0050)
+#define CAP_Q ((char16_t)0x0051)
+#define CAP_S ((char16_t)0x0053)
+#define CAP_T ((char16_t)0x0054)
+#define CAP_U ((char16_t)0x0055)
+#define CAP_V ((char16_t)0x0056)
+#define CAP_W ((char16_t)0x0057)
+#define CAP_Y ((char16_t)0x0059)
+#define CAP_Z ((char16_t)0x005A)
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/contrib/libs/icu/i18n/dtfmtsym.cpp b/contrib/libs/icu/i18n/dtfmtsym.cpp
index ab5f2b612c..943f6e21d2 100644
--- a/contrib/libs/icu/i18n/dtfmtsym.cpp
+++ b/contrib/libs/icu/i18n/dtfmtsym.cpp
@@ -70,7 +70,7 @@
* Unlocalized date-time pattern characters. For example: 'y', 'd', etc. All
* locales use the same these unlocalized pattern characters.
*/
-static const UChar gPatternChars[] = {
+static const char16_t gPatternChars[] = {
// if UDAT_HAS_PATTERN_CHAR_FOR_TIME_SEPARATOR:
// GyMdkHmsSEDFwWahKzYeugAZvcLQqVUOXxrbB:
// else:
@@ -91,7 +91,7 @@ static const UChar gPatternChars[] = {
// files. They aren't designed for actual use, just for backup.
// These are the month names and abbreviations of last resort.
-static const UChar gLastResortMonthNames[13][3] =
+static const char16_t gLastResortMonthNames[13][3] =
{
{0x0030, 0x0031, 0x0000}, /* "01" */
{0x0030, 0x0032, 0x0000}, /* "02" */
@@ -109,7 +109,7 @@ static const UChar gLastResortMonthNames[13][3] =
};
// These are the weekday names and abbreviations of last resort.
-static const UChar gLastResortDayNames[8][2] =
+static const char16_t gLastResortDayNames[8][2] =
{
{0x0030, 0x0000}, /* "0" */
{0x0031, 0x0000}, /* "1" */
@@ -122,7 +122,7 @@ static const UChar gLastResortDayNames[8][2] =
};
// These are the quarter names and abbreviations of last resort.
-static const UChar gLastResortQuarters[4][2] =
+static const char16_t gLastResortQuarters[4][2] =
{
{0x0031, 0x0000}, /* "1" */
{0x0032, 0x0000}, /* "2" */
@@ -131,13 +131,13 @@ static const UChar gLastResortQuarters[4][2] =
};
// These are the am/pm and BC/AD markers of last resort.
-static const UChar gLastResortAmPmMarkers[2][3] =
+static const char16_t gLastResortAmPmMarkers[2][3] =
{
{0x0041, 0x004D, 0x0000}, /* "AM" */
{0x0050, 0x004D, 0x0000} /* "PM" */
};
-static const UChar gLastResortEras[2][3] =
+static const char16_t gLastResortEras[2][3] =
{
{0x0042, 0x0043, 0x0000}, /* "BC" */
{0x0041, 0x0044, 0x0000} /* "AD" */
@@ -179,17 +179,17 @@ const SharedDateFormatSymbols *
char type[256];
Calendar::getCalendarTypeFromLocale(fLoc, type, UPRV_LENGTHOF(type), status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
SharedDateFormatSymbols *shared
= new SharedDateFormatSymbols(fLoc, type, status);
- if (shared == NULL) {
+ if (shared == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
if (U_FAILURE(status)) {
delete shared;
- return NULL;
+ return nullptr;
}
shared->addRef();
return shared;
@@ -248,16 +248,16 @@ static inline UnicodeString* newUnicodeStringArray(size_t count) {
DateFormatSymbols * U_EXPORT2
DateFormatSymbols::createForLocale(
const Locale& locale, UErrorCode &status) {
- const SharedDateFormatSymbols *shared = NULL;
+ const SharedDateFormatSymbols *shared = nullptr;
UnifiedCache::getByLocale(locale, shared, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
DateFormatSymbols *result = new DateFormatSymbols(shared->get());
shared->removeRef();
- if (result == NULL) {
+ if (result == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
return result;
}
@@ -266,13 +266,13 @@ DateFormatSymbols::DateFormatSymbols(const Locale& locale,
UErrorCode& status)
: UObject()
{
- initializeData(locale, NULL, status);
+ initializeData(locale, nullptr, status);
}
DateFormatSymbols::DateFormatSymbols(UErrorCode& status)
: UObject()
{
- initializeData(Locale::getDefault(), NULL, status, TRUE);
+ initializeData(Locale::getDefault(), nullptr, status, true);
}
@@ -287,7 +287,7 @@ DateFormatSymbols::DateFormatSymbols(const Locale& locale,
DateFormatSymbols::DateFormatSymbols(const char *type, UErrorCode& status)
: UObject()
{
- initializeData(Locale::getDefault(), type, status, TRUE);
+ initializeData(Locale::getDefault(), type, status, true);
}
DateFormatSymbols::DateFormatSymbols(const DateFormatSymbols& other)
@@ -314,9 +314,17 @@ DateFormatSymbols::assignArray(UnicodeString*& dstArray,
// only from a locale bundle or set via the cloning API,
// *and* for as long as all the strings are in *private* fields, preventing
// a subclass from creating these strings in an "unsafe" way (with respect to fastCopyFrom()).
+ if(srcArray == nullptr) {
+ // Do not attempt to copy bogus input (which will crash).
+ // Note that this assignArray method already had the potential to return a null dstArray;
+ // see handling below for "if(dstArray != nullptr)".
+ dstCount = 0;
+ dstArray = nullptr;
+ return;
+ }
dstCount = srcCount;
dstArray = newUnicodeStringArray(srcCount);
- if(dstArray != NULL) {
+ if(dstArray != nullptr) {
int32_t i;
for(i=0; i<srcCount; ++i) {
dstArray[i].fastCopyFrom(srcArray[i]);
@@ -333,15 +341,15 @@ void
DateFormatSymbols::createZoneStrings(const UnicodeString *const * otherStrings)
{
int32_t row, col;
- UBool failed = FALSE;
+ UBool failed = false;
fZoneStrings = (UnicodeString **)uprv_malloc(fZoneStringsRowCount * sizeof(UnicodeString *));
- if (fZoneStrings != NULL) {
+ if (fZoneStrings != nullptr) {
for (row=0; row<fZoneStringsRowCount; ++row)
{
fZoneStrings[row] = newUnicodeStringArray(fZoneStringsColCount);
- if (fZoneStrings[row] == NULL) {
- failed = TRUE;
+ if (fZoneStrings[row] == nullptr) {
+ failed = true;
break;
}
for (col=0; col<fZoneStringsColCount; ++col) {
@@ -356,7 +364,7 @@ DateFormatSymbols::createZoneStrings(const UnicodeString *const * otherStrings)
delete[] fZoneStrings[i];
}
uprv_free(fZoneStrings);
- fZoneStrings = NULL;
+ fZoneStrings = nullptr;
}
}
@@ -408,38 +416,38 @@ DateFormatSymbols::copyData(const DateFormatSymbols& other) {
other.fStandaloneNarrowDayPeriods, other.fStandaloneNarrowDayPeriodsCount);
assignArray(fStandaloneAbbreviatedDayPeriods, fStandaloneAbbreviatedDayPeriodsCount,
other.fStandaloneAbbreviatedDayPeriods, other.fStandaloneAbbreviatedDayPeriodsCount);
- if (other.fLeapMonthPatterns != NULL) {
+ if (other.fLeapMonthPatterns != nullptr) {
assignArray(fLeapMonthPatterns, fLeapMonthPatternsCount, other.fLeapMonthPatterns, other.fLeapMonthPatternsCount);
} else {
- fLeapMonthPatterns = NULL;
+ fLeapMonthPatterns = nullptr;
fLeapMonthPatternsCount = 0;
}
- if (other.fShortYearNames != NULL) {
+ if (other.fShortYearNames != nullptr) {
assignArray(fShortYearNames, fShortYearNamesCount, other.fShortYearNames, other.fShortYearNamesCount);
} else {
- fShortYearNames = NULL;
+ fShortYearNames = nullptr;
fShortYearNamesCount = 0;
}
- if (other.fShortZodiacNames != NULL) {
+ if (other.fShortZodiacNames != nullptr) {
assignArray(fShortZodiacNames, fShortZodiacNamesCount, other.fShortZodiacNames, other.fShortZodiacNamesCount);
} else {
- fShortZodiacNames = NULL;
+ fShortZodiacNames = nullptr;
fShortZodiacNamesCount = 0;
}
- if (other.fZoneStrings != NULL) {
+ if (other.fZoneStrings != nullptr) {
fZoneStringsColCount = other.fZoneStringsColCount;
fZoneStringsRowCount = other.fZoneStringsRowCount;
createZoneStrings((const UnicodeString**)other.fZoneStrings);
} else {
- fZoneStrings = NULL;
+ fZoneStrings = nullptr;
fZoneStringsColCount = 0;
fZoneStringsRowCount = 0;
}
fZSFLocale = other.fZSFLocale;
// Other zone strings data is created on demand
- fLocaleZoneStrings = NULL;
+ fLocaleZoneStrings = nullptr;
// fastCopyFrom() - see assignArray comments
fLocalPatternChars.fastCopyFrom(other.fLocalPatternChars);
@@ -519,8 +527,8 @@ void DateFormatSymbols::disposeZoneStrings()
uprv_free(fLocaleZoneStrings);
}
- fZoneStrings = NULL;
- fLocaleZoneStrings = NULL;
+ fZoneStrings = nullptr;
+ fLocaleZoneStrings = nullptr;
fZoneStringsRowCount = 0;
fZoneStringsColCount = 0;
}
@@ -530,13 +538,13 @@ DateFormatSymbols::arrayCompare(const UnicodeString* array1,
const UnicodeString* array2,
int32_t count)
{
- if (array1 == array2) return TRUE;
+ if (array1 == array2) return true;
while (count>0)
{
--count;
- if (array1[count] != array2[count]) return FALSE;
+ if (array1[count] != array2[count]) return false;
}
- return TRUE;
+ return true;
}
bool
@@ -623,11 +631,11 @@ DateFormatSymbols::operator==(const DateFormatSymbols& other) const
fStandaloneWideDayPeriodsCount))
{
// Compare the contents of fZoneStrings
- if (fZoneStrings == NULL && other.fZoneStrings == NULL) {
+ if (fZoneStrings == nullptr && other.fZoneStrings == nullptr) {
if (fZSFLocale == other.fZSFLocale) {
return true;
}
- } else if (fZoneStrings != NULL && other.fZoneStrings != NULL) {
+ } else if (fZoneStrings != nullptr && other.fZoneStrings != nullptr) {
if (fZoneStringsRowCount == other.fZoneStringsRowCount
&& fZoneStringsColCount == other.fZoneStringsColCount) {
bool cmpres = true;
@@ -683,7 +691,7 @@ DateFormatSymbols::getShortMonths(int32_t &count) const
const UnicodeString*
DateFormatSymbols::getMonths(int32_t &count, DtContextType context, DtWidthType width ) const
{
- UnicodeString *returnValue = NULL;
+ UnicodeString *returnValue = nullptr;
switch (context) {
case FORMAT :
@@ -747,7 +755,7 @@ DateFormatSymbols::getShortWeekdays(int32_t &count) const
const UnicodeString*
DateFormatSymbols::getWeekdays(int32_t &count, DtContextType context, DtWidthType width) const
{
- UnicodeString *returnValue = NULL;
+ UnicodeString *returnValue = nullptr;
switch (context) {
case FORMAT :
switch(width) {
@@ -802,7 +810,7 @@ DateFormatSymbols::getWeekdays(int32_t &count, DtContextType context, DtWidthTyp
const UnicodeString*
DateFormatSymbols::getQuarters(int32_t &count, DtContextType context, DtWidthType width ) const
{
- UnicodeString *returnValue = NULL;
+ UnicodeString *returnValue = nullptr;
switch (context) {
case FORMAT :
@@ -1250,12 +1258,12 @@ DateFormatSymbols::setTimeSeparatorString(const UnicodeString& newTimeSeparator)
const UnicodeString**
DateFormatSymbols::getZoneStrings(int32_t& rowCount, int32_t& columnCount) const
{
- const UnicodeString **result = NULL;
+ const UnicodeString **result = nullptr;
static UMutex LOCK;
umtx_lock(&LOCK);
- if (fZoneStrings == NULL) {
- if (fLocaleZoneStrings == NULL) {
+ if (fZoneStrings == nullptr) {
+ if (fLocaleZoneStrings == nullptr) {
((DateFormatSymbols*)this)->initZoneStringsArray();
}
result = (const UnicodeString**)fLocaleZoneStrings;
@@ -1274,16 +1282,16 @@ DateFormatSymbols::getZoneStrings(int32_t& rowCount, int32_t& columnCount) const
// This code must be called within a synchronized block
void
-DateFormatSymbols::initZoneStringsArray(void) {
- if (fZoneStrings != NULL || fLocaleZoneStrings != NULL) {
+DateFormatSymbols::initZoneStringsArray() {
+ if (fZoneStrings != nullptr || fLocaleZoneStrings != nullptr) {
return;
}
UErrorCode status = U_ZERO_ERROR;
- StringEnumeration *tzids = NULL;
- UnicodeString ** zarray = NULL;
- TimeZoneNames *tzNames = NULL;
+ StringEnumeration *tzids = nullptr;
+ UnicodeString ** zarray = nullptr;
+ TimeZoneNames *tzNames = nullptr;
int32_t rows = 0;
static const UTimeZoneNameType TYPES[] = {
@@ -1294,7 +1302,7 @@ DateFormatSymbols::initZoneStringsArray(void) {
do { // dummy do-while
- tzids = TimeZone::createTimeZoneIDEnumeration(ZONE_SET, NULL, NULL, status);
+ tzids = TimeZone::createTimeZoneIDEnumeration(ZONE_SET, nullptr, nullptr, status);
rows = tzids->count(status);
if (U_FAILURE(status)) {
break;
@@ -1303,7 +1311,7 @@ DateFormatSymbols::initZoneStringsArray(void) {
// Allocate array
int32_t size = rows * sizeof(UnicodeString*);
zarray = (UnicodeString**)uprv_malloc(size);
- if (zarray == NULL) {
+ if (zarray == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
}
@@ -1324,7 +1332,7 @@ DateFormatSymbols::initZoneStringsArray(void) {
}
zarray[i] = new UnicodeString[5];
- if (zarray[i] == NULL) {
+ if (zarray[i] == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
}
@@ -1334,7 +1342,7 @@ DateFormatSymbols::initZoneStringsArray(void) {
i++;
}
- } while (FALSE);
+ } while (false);
if (U_FAILURE(status)) {
if (zarray) {
@@ -1344,7 +1352,7 @@ DateFormatSymbols::initZoneStringsArray(void) {
}
}
uprv_free(zarray);
- zarray = NULL;
+ zarray = nullptr;
}
}
@@ -1376,15 +1384,15 @@ DateFormatSymbols::setZoneStrings(const UnicodeString* const *strings, int32_t r
//------------------------------------------------------
const char16_t * U_EXPORT2
-DateFormatSymbols::getPatternUChars(void)
+DateFormatSymbols::getPatternUChars()
{
return gPatternChars;
}
UDateFormatField U_EXPORT2
-DateFormatSymbols::getPatternCharIndex(UChar c) {
- const UChar *p = u_strchr(gPatternChars, c);
- if (p == NULL) {
+DateFormatSymbols::getPatternCharIndex(char16_t c) {
+ const char16_t *p = u_strchr(gPatternChars, c);
+ if (p == nullptr) {
return UDAT_FIELD_COUNT;
} else {
return static_cast<UDateFormatField>(p - gPatternChars);
@@ -1422,14 +1430,14 @@ static const uint64_t kNumericFieldsForCount12 =
UBool U_EXPORT2
DateFormatSymbols::isNumericField(UDateFormatField f, int32_t count) {
if (f == UDAT_FIELD_COUNT) {
- return FALSE;
+ return false;
}
uint64_t flag = ((uint64_t)1 << f);
return ((kNumericFieldsAlways & flag) != 0 || ((kNumericFieldsForCount12 & flag) != 0 && count < 3));
}
UBool U_EXPORT2
-DateFormatSymbols::isNumericPatternChar(UChar c, int32_t count) {
+DateFormatSymbols::isNumericPatternChar(char16_t c, int32_t count) {
return isNumericField(getPatternCharIndex(c), count);
}
@@ -1455,35 +1463,35 @@ DateFormatSymbols::setLocalPatternChars(const UnicodeString& newLocalPatternChar
namespace {
// Constants declarations
-static const UChar kCalendarAliasPrefixUChar[] = {
+static const char16_t kCalendarAliasPrefixUChar[] = {
SOLIDUS, CAP_L, CAP_O, CAP_C, CAP_A, CAP_L, CAP_E, SOLIDUS,
LOW_C, LOW_A, LOW_L, LOW_E, LOW_N, LOW_D, LOW_A, LOW_R, SOLIDUS
};
-static const UChar kGregorianTagUChar[] = {
+static const char16_t kGregorianTagUChar[] = {
LOW_G, LOW_R, LOW_E, LOW_G, LOW_O, LOW_R, LOW_I, LOW_A, LOW_N
};
-static const UChar kVariantTagUChar[] = {
+static const char16_t kVariantTagUChar[] = {
PERCENT, LOW_V, LOW_A, LOW_R, LOW_I, LOW_A, LOW_N, LOW_T
};
-static const UChar kLeapTagUChar[] = {
+static const char16_t kLeapTagUChar[] = {
LOW_L, LOW_E, LOW_A, LOW_P
};
-static const UChar kCyclicNameSetsTagUChar[] = {
+static const char16_t kCyclicNameSetsTagUChar[] = {
LOW_C, LOW_Y, LOW_C, LOW_L, LOW_I, LOW_C, CAP_N, LOW_A, LOW_M, LOW_E, CAP_S, LOW_E, LOW_T, LOW_S
};
-static const UChar kYearsTagUChar[] = {
+static const char16_t kYearsTagUChar[] = {
SOLIDUS, LOW_Y, LOW_E, LOW_A, LOW_R, LOW_S
};
-static const UChar kZodiacsUChar[] = {
+static const char16_t kZodiacsUChar[] = {
SOLIDUS, LOW_Z, LOW_O, LOW_D, LOW_I, LOW_A, LOW_C, LOW_S
};
-static const UChar kDayPartsTagUChar[] = {
+static const char16_t kDayPartsTagUChar[] = {
SOLIDUS, LOW_D, LOW_A, LOW_Y, CAP_P, LOW_A, LOW_R, LOW_T, LOW_S
};
-static const UChar kFormatTagUChar[] = {
+static const char16_t kFormatTagUChar[] = {
SOLIDUS, LOW_F, LOW_O, LOW_R, LOW_M, LOW_A, LOW_T
};
-static const UChar kAbbrTagUChar[] = {
+static const char16_t kAbbrTagUChar[] = {
SOLIDUS, LOW_A, LOW_B, LOW_B, LOW_R, LOW_E, LOW_V, LOW_I, LOW_A, LOW_T, LOW_E, LOW_D
};
@@ -1524,18 +1532,18 @@ struct CalendarDataSink : public ResourceSink {
// Initializes CalendarDataSink with default values
CalendarDataSink(UErrorCode& status)
- : arrays(FALSE, status), arraySizes(FALSE, status), maps(FALSE, status),
+ : arrays(false, status), arraySizes(false, status), maps(false, status),
mapRefs(),
aliasPathPairs(uprv_deleteUObject, uhash_compareUnicodeString, status),
currentCalendarType(), nextCalendarType(),
- resourcesToVisit(NULL), aliasRelativePath() {
+ resourcesToVisit(nullptr), aliasRelativePath() {
if (U_FAILURE(status)) { return; }
}
virtual ~CalendarDataSink();
// Configure the CalendarSink to visit all the resources
void visitAllResources() {
- resourcesToVisit.adoptInstead(NULL);
+ resourcesToVisit.adoptInstead(nullptr);
}
// Actions to be done before enumerating
@@ -1550,7 +1558,7 @@ struct CalendarDataSink : public ResourceSink {
U_ASSERT(!currentCalendarType.isEmpty());
// Stores the resources to visit on the next calendar.
- LocalPointer<UVector> resourcesToVisitNext(NULL);
+ LocalPointer<UVector> resourcesToVisitNext(nullptr);
ResourceTable calendarData = value.getTable(errorCode);
if (U_FAILURE(errorCode)) { return; }
@@ -1574,26 +1582,20 @@ struct CalendarDataSink : public ResourceSink {
errorCode);
if (U_FAILURE(errorCode)) { return; }
}
- LocalPointer<UnicodeString> aliasRelativePathCopy(new UnicodeString(aliasRelativePath), errorCode);
- resourcesToVisitNext->addElementX(aliasRelativePathCopy.getAlias(), errorCode);
+ LocalPointer<UnicodeString> aliasRelativePathCopy(aliasRelativePath.clone(), errorCode);
+ resourcesToVisitNext->adoptElement(aliasRelativePathCopy.orphan(), errorCode);
if (U_FAILURE(errorCode)) { return; }
- // Only release ownership after resourcesToVisitNext takes it (no error happened):
- aliasRelativePathCopy.orphan();
continue;
} else if (aliasType == SAME_CALENDAR) {
// Register same-calendar alias
- if (arrays.get(aliasRelativePath) == NULL && maps.get(aliasRelativePath) == NULL) {
- LocalPointer<UnicodeString> aliasRelativePathCopy(new UnicodeString(aliasRelativePath), errorCode);
- aliasPathPairs.addElementX(aliasRelativePathCopy.getAlias(), errorCode);
+ if (arrays.get(aliasRelativePath) == nullptr && maps.get(aliasRelativePath) == nullptr) {
+ LocalPointer<UnicodeString> aliasRelativePathCopy(aliasRelativePath.clone(), errorCode);
+ aliasPathPairs.adoptElement(aliasRelativePathCopy.orphan(), errorCode);
if (U_FAILURE(errorCode)) { return; }
- // Only release ownership after aliasPathPairs takes it (no error happened):
- aliasRelativePathCopy.orphan();
- LocalPointer<UnicodeString> keyUStringCopy(new UnicodeString(keyUString), errorCode);
- aliasPathPairs.addElementX(keyUStringCopy.getAlias(), errorCode);
+ LocalPointer<UnicodeString> keyUStringCopy(keyUString.clone(), errorCode);
+ aliasPathPairs.adoptElement(keyUStringCopy.orphan(), errorCode);
if (U_FAILURE(errorCode)) { return; }
- // Only release ownership after aliasPathPairs takes it (no error happened):
- keyUStringCopy.orphan();
}
continue;
}
@@ -1607,7 +1609,7 @@ struct CalendarDataSink : public ResourceSink {
if (uprv_strcmp(key, gAmPmMarkersTag) == 0
|| uprv_strcmp(key, gAmPmMarkersAbbrTag) == 0
|| uprv_strcmp(key, gAmPmMarkersNarrowTag) == 0) {
- if (arrays.get(keyUString) == NULL) {
+ if (arrays.get(keyUString) == nullptr) {
ResourceArray resourceArray = value.getArray(errorCode);
int32_t arraySize = resourceArray.getSize();
LocalArray<UnicodeString> stringArray(new UnicodeString[arraySize], errorCode);
@@ -1636,9 +1638,9 @@ struct CalendarDataSink : public ResourceSink {
UnicodeString *alias = (UnicodeString*)aliasPathPairs[i];
UnicodeString *aliasArray;
Hashtable *aliasMap;
- if ((aliasArray = (UnicodeString*)arrays.get(*alias)) != NULL) {
+ if ((aliasArray = (UnicodeString*)arrays.get(*alias)) != nullptr) {
UnicodeString *path = (UnicodeString*)aliasPathPairs[i + 1];
- if (arrays.get(*path) == NULL) {
+ if (arrays.get(*path) == nullptr) {
// Clone the array
int32_t aliasArraySize = arraySizes.geti(*alias);
LocalArray<UnicodeString> aliasArrayCopy(new UnicodeString[aliasArraySize], errorCode);
@@ -1650,9 +1652,9 @@ struct CalendarDataSink : public ResourceSink {
}
if (U_FAILURE(errorCode)) { return; }
mod = true;
- } else if ((aliasMap = (Hashtable*)maps.get(*alias)) != NULL) {
+ } else if ((aliasMap = (Hashtable*)maps.get(*alias)) != nullptr) {
UnicodeString *path = (UnicodeString*)aliasPathPairs[i + 1];
- if (maps.get(*path) == NULL) {
+ if (maps.get(*path) == nullptr) {
maps.put(*path, aliasMap, errorCode);
}
if (U_FAILURE(errorCode)) { return; }
@@ -1680,7 +1682,7 @@ struct CalendarDataSink : public ResourceSink {
ResourceTable table = value.getTable(errorCode);
if (U_FAILURE(errorCode)) return;
- Hashtable* stringMap = NULL;
+ Hashtable* stringMap = nullptr;
// Iterate over all the elements of the table and add them to the map
for (int i = 0; table.getKeyAndValue(i, key, value); i++) {
@@ -1696,8 +1698,8 @@ struct CalendarDataSink : public ResourceSink {
// We are on a leaf, store the map elements into the stringMap
if (i == 0) {
// mapRefs will keep ownership of 'stringMap':
- stringMap = mapRefs.create(FALSE, errorCode);
- if (stringMap == NULL) {
+ stringMap = mapRefs.create(false, errorCode);
+ if (stringMap == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -1705,16 +1707,16 @@ struct CalendarDataSink : public ResourceSink {
if (U_FAILURE(errorCode)) { return; }
stringMap->setValueDeleter(uprv_deleteUObject);
}
- U_ASSERT(stringMap != NULL);
+ U_ASSERT(stringMap != nullptr);
int32_t valueStringSize;
- const UChar *valueString = value.getString(valueStringSize, errorCode);
+ const char16_t *valueString = value.getString(valueStringSize, errorCode);
if (U_FAILURE(errorCode)) { return; }
- LocalPointer<UnicodeString> valueUString(new UnicodeString(TRUE, valueString, valueStringSize), errorCode);
+ LocalPointer<UnicodeString> valueUString(new UnicodeString(true, valueString, valueStringSize), errorCode);
stringMap->put(keyUString, valueUString.orphan(), errorCode);
if (U_FAILURE(errorCode)) { return; }
continue;
}
- U_ASSERT(stringMap == NULL);
+ U_ASSERT(stringMap == nullptr);
// Store the current path's length and append the current key to the path.
int32_t pathLength = path.length();
@@ -1723,7 +1725,7 @@ struct CalendarDataSink : public ResourceSink {
// In cyclicNameSets ignore everything but years/format/abbreviated
// and zodiacs/format/abbreviated
if (path.startsWith(kCyclicNameSetsTagUChar, UPRV_LENGTHOF(kCyclicNameSetsTagUChar))) {
- UBool skip = TRUE;
+ UBool skip = true;
int32_t startIndex = UPRV_LENGTHOF(kCyclicNameSetsTagUChar);
int32_t length = 0;
if (startIndex == path.length()
@@ -1738,7 +1740,7 @@ struct CalendarDataSink : public ResourceSink {
length = 0;
if (startIndex == path.length()
|| path.compare(startIndex, (length = UPRV_LENGTHOF(kAbbrTagUChar)), kAbbrTagUChar, 0, UPRV_LENGTHOF(kAbbrTagUChar)) == 0) {
- skip = FALSE;
+ skip = false;
}
}
}
@@ -1750,7 +1752,7 @@ struct CalendarDataSink : public ResourceSink {
}
// == Handle aliases ==
- if (arrays.get(path) != NULL || maps.get(path) != NULL) {
+ if (arrays.get(path) != nullptr || maps.get(path) != nullptr) {
// Drop the latest key on the path and continue
path.retainBetween(0, pathLength);
continue;
@@ -1760,16 +1762,12 @@ struct CalendarDataSink : public ResourceSink {
if (U_FAILURE(errorCode)) { return; }
if (aliasType == SAME_CALENDAR) {
// Store the alias path and the current path on aliasPathPairs
- LocalPointer<UnicodeString> aliasRelativePathCopy(new UnicodeString(aliasRelativePath), errorCode);
- aliasPathPairs.addElementX(aliasRelativePathCopy.getAlias(), errorCode);
+ LocalPointer<UnicodeString> aliasRelativePathCopy(aliasRelativePath.clone(), errorCode);
+ aliasPathPairs.adoptElement(aliasRelativePathCopy.orphan(), errorCode);
if (U_FAILURE(errorCode)) { return; }
- // Only release ownership after aliasPathPairs takes it (no error happened):
- aliasRelativePathCopy.orphan();
- LocalPointer<UnicodeString> pathCopy(new UnicodeString(path), errorCode);
- aliasPathPairs.addElementX(pathCopy.getAlias(), errorCode);
+ LocalPointer<UnicodeString> pathCopy(path.clone(), errorCode);
+ aliasPathPairs.adoptElement(pathCopy.orphan(), errorCode);
if (U_FAILURE(errorCode)) { return; }
- // Only release ownership after aliasPathPairs takes it (no error happened):
- pathCopy.orphan();
// Drop the latest key on the path and continue
path.retainBetween(0, pathLength);
@@ -1805,7 +1803,7 @@ struct CalendarDataSink : public ResourceSink {
if (value.getType() == URES_ALIAS) {
int32_t aliasPathSize;
- const UChar* aliasPathUChar = value.getAliasString(aliasPathSize, errorCode);
+ const char16_t* aliasPathUChar = value.getAliasString(aliasPathSize, errorCode);
if (U_FAILURE(errorCode)) { return NONE; }
UnicodeString aliasPath(aliasPathUChar, aliasPathSize);
const int32_t aliasPrefixLength = UPRV_LENGTHOF(kCalendarAliasPrefixUChar);
@@ -1856,7 +1854,7 @@ CalendarDataSink::~CalendarDataSink() {
//------------------------------------------------------
static void
-initField(UnicodeString **field, int32_t& length, const UChar *data, LastResortSize numStr, LastResortSize strLen, UErrorCode &status) {
+initField(UnicodeString **field, int32_t& length, const char16_t *data, LastResortSize numStr, LastResortSize strLen, UErrorCode &status) {
if (U_SUCCESS(status)) {
length = numStr;
*field = newUnicodeStringArray((size_t)numStr);
@@ -1864,7 +1862,7 @@ initField(UnicodeString **field, int32_t& length, const UChar *data, LastResortS
for(int32_t i = 0; i<length; i++) {
// readonly aliases - all "data" strings are constant
// -1 as length for variable-length strings (gLastResortDayNames[0] is empty)
- (*(field)+i)->setTo(TRUE, data+(i*((int32_t)strLen)), -1);
+ (*(field)+i)->setTo(true, data+(i*((int32_t)strLen)), -1);
}
}
else {
@@ -1880,7 +1878,7 @@ initField(UnicodeString **field, int32_t& length, CalendarDataSink &sink, CharSt
UnicodeString keyUString(key.data(), -1, US_INV);
UnicodeString* array = static_cast<UnicodeString*>(sink.arrays.get(keyUString));
- if (array != NULL) {
+ if (array != nullptr) {
length = sink.arraySizes.geti(keyUString);
*field = array;
// DateFormatSymbols takes ownership of the array:
@@ -1898,11 +1896,11 @@ initField(UnicodeString **field, int32_t& length, CalendarDataSink &sink, CharSt
UnicodeString keyUString(key.data(), -1, US_INV);
UnicodeString* array = static_cast<UnicodeString*>(sink.arrays.get(keyUString));
- if (array != NULL) {
+ if (array != nullptr) {
int32_t arrayLength = sink.arraySizes.geti(keyUString);
length = arrayLength + arrayOffset;
*field = new UnicodeString[length];
- if (*field == NULL) {
+ if (*field == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -1920,10 +1918,10 @@ initLeapMonthPattern(UnicodeString *field, int32_t index, CalendarDataSink &sink
if (U_SUCCESS(status)) {
UnicodeString pathUString(path.data(), -1, US_INV);
Hashtable *leapMonthTable = static_cast<Hashtable*>(sink.maps.get(pathUString));
- if (leapMonthTable != NULL) {
- UnicodeString leapLabel(FALSE, kLeapTagUChar, UPRV_LENGTHOF(kLeapTagUChar));
+ if (leapMonthTable != nullptr) {
+ UnicodeString leapLabel(false, kLeapTagUChar, UPRV_LENGTHOF(kLeapTagUChar));
UnicodeString *leapMonthPattern = static_cast<UnicodeString*>(leapMonthTable->get(leapLabel));
- if (leapMonthPattern != NULL) {
+ if (leapMonthPattern != nullptr) {
field[index].fastCopyFrom(*leapMonthPattern);
} else {
field[index].setToBogus();
@@ -1966,7 +1964,7 @@ typedef struct {
} ContextUsageTypeNameToEnumValue;
static const ContextUsageTypeNameToEnumValue contextUsageTypeMap[] = {
- // Entries must be sorted by usageTypeName; entry with NULL name terminates list.
+ // Entries must be sorted by usageTypeName; entry with nullptr name terminates list.
{ "day-format-except-narrow", DateFormatSymbols::kCapContextUsageDayFormat },
{ "day-narrow", DateFormatSymbols::kCapContextUsageDayNarrow },
{ "day-standalone-except-narrow", DateFormatSymbols::kCapContextUsageDayStandalone },
@@ -1980,7 +1978,7 @@ static const ContextUsageTypeNameToEnumValue contextUsageTypeMap[] = {
{ "month-standalone-except-narrow", DateFormatSymbols::kCapContextUsageMonthStandalone },
{ "zone-long", DateFormatSymbols::kCapContextUsageZoneLong },
{ "zone-short", DateFormatSymbols::kCapContextUsageZoneShort },
- { NULL, (DateFormatSymbols::ECapitalizationContextUsageType)0 },
+ { nullptr, (DateFormatSymbols::ECapitalizationContextUsageType)0 },
};
// Resource keys to look up localized strings for day periods.
@@ -1992,23 +1990,23 @@ static const char *dayPeriodKeys[] = {"midnight", "noon",
UnicodeString* loadDayPeriodStrings(CalendarDataSink &sink, CharString &path,
int32_t &stringCount, UErrorCode &status) {
- if (U_FAILURE(status)) { return NULL; }
+ if (U_FAILURE(status)) { return nullptr; }
UnicodeString pathUString(path.data(), -1, US_INV);
Hashtable* map = static_cast<Hashtable*>(sink.maps.get(pathUString));
stringCount = UPRV_LENGTHOF(dayPeriodKeys);
UnicodeString *strings = new UnicodeString[stringCount];
- if (strings == NULL) {
+ if (strings == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
- if (map != NULL) {
+ if (map != nullptr) {
for (int32_t i = 0; i < stringCount; ++i) {
UnicodeString dayPeriodKey(dayPeriodKeys[i], -1, US_INV);
UnicodeString *dayPeriod = static_cast<UnicodeString*>(map->get(dayPeriodKey));
- if (dayPeriod != NULL) {
+ if (dayPeriod != nullptr) {
strings[i].fastCopyFrom(*dayPeriod);
} else {
strings[i].setToBogus();
@@ -2027,79 +2025,79 @@ void
DateFormatSymbols::initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData)
{
int32_t len = 0;
- /* In case something goes wrong, initialize all of the data to NULL. */
- fEras = NULL;
+ /* In case something goes wrong, initialize all of the data to nullptr. */
+ fEras = nullptr;
fErasCount = 0;
- fEraNames = NULL;
+ fEraNames = nullptr;
fEraNamesCount = 0;
- fNarrowEras = NULL;
+ fNarrowEras = nullptr;
fNarrowErasCount = 0;
- fMonths = NULL;
+ fMonths = nullptr;
fMonthsCount=0;
- fShortMonths = NULL;
+ fShortMonths = nullptr;
fShortMonthsCount=0;
- fNarrowMonths = NULL;
+ fNarrowMonths = nullptr;
fNarrowMonthsCount=0;
- fStandaloneMonths = NULL;
+ fStandaloneMonths = nullptr;
fStandaloneMonthsCount=0;
- fStandaloneShortMonths = NULL;
+ fStandaloneShortMonths = nullptr;
fStandaloneShortMonthsCount=0;
- fStandaloneNarrowMonths = NULL;
+ fStandaloneNarrowMonths = nullptr;
fStandaloneNarrowMonthsCount=0;
- fWeekdays = NULL;
+ fWeekdays = nullptr;
fWeekdaysCount=0;
- fShortWeekdays = NULL;
+ fShortWeekdays = nullptr;
fShortWeekdaysCount=0;
- fShorterWeekdays = NULL;
+ fShorterWeekdays = nullptr;
fShorterWeekdaysCount=0;
- fNarrowWeekdays = NULL;
+ fNarrowWeekdays = nullptr;
fNarrowWeekdaysCount=0;
- fStandaloneWeekdays = NULL;
+ fStandaloneWeekdays = nullptr;
fStandaloneWeekdaysCount=0;
- fStandaloneShortWeekdays = NULL;
+ fStandaloneShortWeekdays = nullptr;
fStandaloneShortWeekdaysCount=0;
- fStandaloneShorterWeekdays = NULL;
+ fStandaloneShorterWeekdays = nullptr;
fStandaloneShorterWeekdaysCount=0;
- fStandaloneNarrowWeekdays = NULL;
+ fStandaloneNarrowWeekdays = nullptr;
fStandaloneNarrowWeekdaysCount=0;
- fAmPms = NULL;
+ fAmPms = nullptr;
fAmPmsCount=0;
- fNarrowAmPms = NULL;
+ fNarrowAmPms = nullptr;
fNarrowAmPmsCount=0;
fTimeSeparator.setToBogus();
- fQuarters = NULL;
+ fQuarters = nullptr;
fQuartersCount = 0;
- fShortQuarters = NULL;
+ fShortQuarters = nullptr;
fShortQuartersCount = 0;
- fNarrowQuarters = NULL;
+ fNarrowQuarters = nullptr;
fNarrowQuartersCount = 0;
- fStandaloneQuarters = NULL;
+ fStandaloneQuarters = nullptr;
fStandaloneQuartersCount = 0;
- fStandaloneShortQuarters = NULL;
+ fStandaloneShortQuarters = nullptr;
fStandaloneShortQuartersCount = 0;
- fStandaloneNarrowQuarters = NULL;
+ fStandaloneNarrowQuarters = nullptr;
fStandaloneNarrowQuartersCount = 0;
- fLeapMonthPatterns = NULL;
+ fLeapMonthPatterns = nullptr;
fLeapMonthPatternsCount = 0;
- fShortYearNames = NULL;
+ fShortYearNames = nullptr;
fShortYearNamesCount = 0;
- fShortZodiacNames = NULL;
+ fShortZodiacNames = nullptr;
fShortZodiacNamesCount = 0;
fZoneStringsRowCount = 0;
fZoneStringsColCount = 0;
- fZoneStrings = NULL;
- fLocaleZoneStrings = NULL;
- fAbbreviatedDayPeriods = NULL;
+ fZoneStrings = nullptr;
+ fLocaleZoneStrings = nullptr;
+ fAbbreviatedDayPeriods = nullptr;
fAbbreviatedDayPeriodsCount = 0;
- fWideDayPeriods = NULL;
+ fWideDayPeriods = nullptr;
fWideDayPeriodsCount = 0;
- fNarrowDayPeriods = NULL;
+ fNarrowDayPeriods = nullptr;
fNarrowDayPeriodsCount = 0;
- fStandaloneAbbreviatedDayPeriods = NULL;
+ fStandaloneAbbreviatedDayPeriods = nullptr;
fStandaloneAbbreviatedDayPeriodsCount = 0;
- fStandaloneWideDayPeriods = NULL;
+ fStandaloneWideDayPeriods = nullptr;
fStandaloneWideDayPeriodsCount = 0;
- fStandaloneNarrowDayPeriods = NULL;
+ fStandaloneNarrowDayPeriods = nullptr;
fStandaloneNarrowDayPeriodsCount = 0;
uprv_memset(fCapitalization, 0, sizeof(fCapitalization));
@@ -2113,13 +2111,13 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
// Create a CalendarDataSink to process this data and the resource bundles
CalendarDataSink calendarSink(status);
- UResourceBundle *rb = ures_open(NULL, locale.getBaseName(), &status);
- UResourceBundle *cb = ures_getByKey(rb, gCalendarTag, NULL, &status);
+ UResourceBundle *rb = ures_open(nullptr, locale.getBaseName(), &status);
+ UResourceBundle *cb = ures_getByKey(rb, gCalendarTag, nullptr, &status);
if (U_FAILURE(status)) return;
// Iterate over the resource bundle data following the fallbacks through different calendar types
- UnicodeString calendarType((type != NULL && *type != '\0')? type : gGregorianTag, -1, US_INV);
+ UnicodeString calendarType((type != nullptr && *type != '\0')? type : gGregorianTag, -1, US_INV);
while (!calendarType.isBogus()) {
CharString calendarTypeBuffer;
calendarTypeBuffer.appendInvariantChars(calendarType, status);
@@ -2128,11 +2126,11 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
// Enumerate this calendar type. If the calendar is not found fallback to gregorian
UErrorCode oldStatus = status;
- UResourceBundle *ctb = ures_getByKeyWithFallback(cb, calendarTypeCArray, NULL, &status);
+ UResourceBundle *ctb = ures_getByKeyWithFallback(cb, calendarTypeCArray, nullptr, &status);
if (status == U_MISSING_RESOURCE_ERROR) {
ures_close(ctb);
if (uprv_strcmp(calendarTypeCArray, gGregorianTag) != 0) {
- calendarType.setTo(FALSE, kGregorianTagUChar, UPRV_LENGTHOF(kGregorianTagUChar));
+ calendarType.setTo(false, kGregorianTagUChar, UPRV_LENGTHOF(kGregorianTagUChar));
calendarSink.visitAllResources();
status = oldStatus;
continue;
@@ -2155,7 +2153,7 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
// Gregorian is always the last fallback
if (calendarType.isBogus()) {
- calendarType.setTo(FALSE, kGregorianTagUChar, UPRV_LENGTHOF(kGregorianTagUChar));
+ calendarType.setTo(false, kGregorianTagUChar, UPRV_LENGTHOF(kGregorianTagUChar));
calendarSink.visitAllResources();
}
}
@@ -2200,7 +2198,7 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
fLeapMonthPatternsCount = kMonthPatternsCount;
} else {
delete[] fLeapMonthPatterns;
- fLeapMonthPatterns = NULL;
+ fLeapMonthPatterns = nullptr;
}
}
@@ -2213,23 +2211,23 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
// Load context transforms and capitalization
tempStatus = U_ZERO_ERROR;
- UResourceBundle *localeBundle = ures_open(NULL, locale.getName(), &tempStatus);
+ UResourceBundle *localeBundle = ures_open(nullptr, locale.getName(), &tempStatus);
if (U_SUCCESS(tempStatus)) {
- UResourceBundle *contextTransforms = ures_getByKeyWithFallback(localeBundle, gContextTransformsTag, NULL, &tempStatus);
+ UResourceBundle *contextTransforms = ures_getByKeyWithFallback(localeBundle, gContextTransformsTag, nullptr, &tempStatus);
if (U_SUCCESS(tempStatus)) {
UResourceBundle *contextTransformUsage;
- while ( (contextTransformUsage = ures_getNextResource(contextTransforms, NULL, &tempStatus)) != NULL ) {
+ while ( (contextTransformUsage = ures_getNextResource(contextTransforms, nullptr, &tempStatus)) != nullptr ) {
const int32_t * intVector = ures_getIntVector(contextTransformUsage, &len, &status);
- if (U_SUCCESS(tempStatus) && intVector != NULL && len >= 2) {
+ if (U_SUCCESS(tempStatus) && intVector != nullptr && len >= 2) {
const char* usageType = ures_getKey(contextTransformUsage);
- if (usageType != NULL) {
+ if (usageType != nullptr) {
const ContextUsageTypeNameToEnumValue * typeMapPtr = contextUsageTypeMap;
int32_t compResult = 0;
// linear search; list is short and we cannot be sure that bsearch is available
- while ( typeMapPtr->usageTypeName != NULL && (compResult = uprv_strcmp(usageType, typeMapPtr->usageTypeName)) > 0 ) {
+ while ( typeMapPtr->usageTypeName != nullptr && (compResult = uprv_strcmp(usageType, typeMapPtr->usageTypeName)) > 0 ) {
++typeMapPtr;
}
- if (typeMapPtr->usageTypeName != NULL && compResult == 0) {
+ if (typeMapPtr->usageTypeName != nullptr && compResult == 0) {
fCapitalization[typeMapPtr->usageTypeEnumValue][0] = static_cast<UBool>(intVector[0]);
fCapitalization[typeMapPtr->usageTypeEnumValue][1] = static_cast<UBool>(intVector[1]);
}
@@ -2245,15 +2243,15 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
const LocalPointer<NumberingSystem> numberingSystem(
NumberingSystem::createInstance(locale, tempStatus), tempStatus);
if (U_SUCCESS(tempStatus)) {
- // These functions all fail gracefully if passed NULL pointers and
+ // These functions all fail gracefully if passed nullptr pointers and
// do nothing unless U_SUCCESS(tempStatus), so it's only necessary
// to check for errors once after all calls are made.
const LocalUResourceBundlePointer numberElementsData(ures_getByKeyWithFallback(
- localeBundle, gNumberElementsTag, NULL, &tempStatus));
+ localeBundle, gNumberElementsTag, nullptr, &tempStatus));
const LocalUResourceBundlePointer nsNameData(ures_getByKeyWithFallback(
- numberElementsData.getAlias(), numberingSystem->getName(), NULL, &tempStatus));
+ numberElementsData.getAlias(), numberingSystem->getName(), nullptr, &tempStatus));
const LocalUResourceBundlePointer symbolsData(ures_getByKeyWithFallback(
- nsNameData.getAlias(), gSymbolsTag, NULL, &tempStatus));
+ nsNameData.getAlias(), gSymbolsTag, nullptr, &tempStatus));
fTimeSeparator = ures_getUnicodeStringByKey(
symbolsData.getAlias(), gTimeSeparatorTag, &tempStatus);
if (U_FAILURE(tempStatus)) {
@@ -2269,24 +2267,48 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
}
// Load day periods
+ fAbbreviatedDayPeriods = loadDayPeriodStrings(calendarSink,
+ buildResourcePath(path, gDayPeriodTag, gNamesFormatTag, gNamesAbbrTag, status),
+ fAbbreviatedDayPeriodsCount, status);
+
fWideDayPeriods = loadDayPeriodStrings(calendarSink,
buildResourcePath(path, gDayPeriodTag, gNamesFormatTag, gNamesWideTag, status),
fWideDayPeriodsCount, status);
fNarrowDayPeriods = loadDayPeriodStrings(calendarSink,
buildResourcePath(path, gDayPeriodTag, gNamesFormatTag, gNamesNarrowTag, status),
fNarrowDayPeriodsCount, status);
- fAbbreviatedDayPeriods = loadDayPeriodStrings(calendarSink,
- buildResourcePath(path, gDayPeriodTag, gNamesFormatTag, gNamesAbbrTag, status),
- fAbbreviatedDayPeriodsCount, status);
+
+ fStandaloneAbbreviatedDayPeriods = loadDayPeriodStrings(calendarSink,
+ buildResourcePath(path, gDayPeriodTag, gNamesStandaloneTag, gNamesAbbrTag, status),
+ fStandaloneAbbreviatedDayPeriodsCount, status);
+
fStandaloneWideDayPeriods = loadDayPeriodStrings(calendarSink,
buildResourcePath(path, gDayPeriodTag, gNamesStandaloneTag, gNamesWideTag, status),
fStandaloneWideDayPeriodsCount, status);
fStandaloneNarrowDayPeriods = loadDayPeriodStrings(calendarSink,
buildResourcePath(path, gDayPeriodTag, gNamesStandaloneTag, gNamesNarrowTag, status),
fStandaloneNarrowDayPeriodsCount, status);
- fStandaloneAbbreviatedDayPeriods = loadDayPeriodStrings(calendarSink,
- buildResourcePath(path, gDayPeriodTag, gNamesStandaloneTag, gNamesAbbrTag, status),
- fStandaloneAbbreviatedDayPeriodsCount, status);
+
+ // Fill in for missing/bogus items (dayPeriods are a map so single items might be missing)
+ if (U_SUCCESS(status)) {
+ for (int32_t dpidx = 0; dpidx < fAbbreviatedDayPeriodsCount; ++dpidx) {
+ if (dpidx < fWideDayPeriodsCount && fWideDayPeriods != nullptr && fWideDayPeriods[dpidx].isBogus()) {
+ fWideDayPeriods[dpidx].fastCopyFrom(fAbbreviatedDayPeriods[dpidx]);
+ }
+ if (dpidx < fNarrowDayPeriodsCount && fNarrowDayPeriods != nullptr && fNarrowDayPeriods[dpidx].isBogus()) {
+ fNarrowDayPeriods[dpidx].fastCopyFrom(fAbbreviatedDayPeriods[dpidx]);
+ }
+ if (dpidx < fStandaloneAbbreviatedDayPeriodsCount && fStandaloneAbbreviatedDayPeriods != nullptr && fStandaloneAbbreviatedDayPeriods[dpidx].isBogus()) {
+ fStandaloneAbbreviatedDayPeriods[dpidx].fastCopyFrom(fAbbreviatedDayPeriods[dpidx]);
+ }
+ if (dpidx < fStandaloneWideDayPeriodsCount && fStandaloneWideDayPeriods != nullptr && fStandaloneWideDayPeriods[dpidx].isBogus()) {
+ fStandaloneWideDayPeriods[dpidx].fastCopyFrom(fStandaloneAbbreviatedDayPeriods[dpidx]);
+ }
+ if (dpidx < fStandaloneNarrowDayPeriodsCount && fStandaloneNarrowDayPeriods != nullptr && fStandaloneNarrowDayPeriods[dpidx].isBogus()) {
+ fStandaloneNarrowDayPeriods[dpidx].fastCopyFrom(fStandaloneAbbreviatedDayPeriods[dpidx]);
+ }
+ }
+ }
U_LOCALE_BASED(locBased, *this);
// if we make it to here, the resource data is cool, and we can get everything out
@@ -2362,12 +2384,20 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
initField(&fNarrowAmPms, fNarrowAmPmsCount, calendarSink,
buildResourcePath(path, gAmPmMarkersAbbrTag, status), status);
}
+ if(status == U_MISSING_RESOURCE_ERROR) {
+ status = U_ZERO_ERROR;
+ assignArray(fNarrowAmPms, fNarrowAmPmsCount, fAmPms, fAmPmsCount);
+ }
// Load quarters
initField(&fQuarters, fQuartersCount, calendarSink,
buildResourcePath(path, gQuartersTag, gNamesFormatTag, gNamesWideTag, status), status);
initField(&fShortQuarters, fShortQuartersCount, calendarSink,
buildResourcePath(path, gQuartersTag, gNamesFormatTag, gNamesAbbrTag, status), status);
+ if(status == U_MISSING_RESOURCE_ERROR) {
+ status = U_ZERO_ERROR;
+ assignArray(fShortQuarters, fShortQuartersCount, fQuarters, fQuartersCount);
+ }
initField(&fStandaloneQuarters, fStandaloneQuartersCount, calendarSink,
buildResourcePath(path, gQuartersTag, gNamesStandaloneTag, gNamesWideTag, status), status);
@@ -2396,14 +2426,14 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
/*
// fastCopyFrom()/setTo() - see assignArray comments
resStr = ures_getStringByKey(fResourceBundle, gLocalPatternCharsTag, &len, &status);
- fLocalPatternChars.setTo(TRUE, resStr, len);
+ fLocalPatternChars.setTo(true, resStr, len);
// If the locale data does not include new pattern chars, use the defaults
// TODO: Consider making this an error, since this may add conflicting characters.
if (len < PATTERN_CHARS_LEN) {
- fLocalPatternChars.append(UnicodeString(TRUE, &gPatternChars[len], PATTERN_CHARS_LEN-len));
+ fLocalPatternChars.append(UnicodeString(true, &gPatternChars[len], PATTERN_CHARS_LEN-len));
}
*/
- fLocalPatternChars.setTo(TRUE, gPatternChars, PATTERN_CHARS_LEN);
+ fLocalPatternChars.setTo(true, gPatternChars, PATTERN_CHARS_LEN);
// Format wide weekdays -> fWeekdays
// {sfb} fixed to handle 1-based weekdays
@@ -2479,32 +2509,32 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
status = U_USING_FALLBACK_WARNING;
//TODO(fabalbon): make sure we are storing las resort data for all fields in here.
- initField(&fEras, fErasCount, (const UChar *)gLastResortEras, kEraNum, kEraLen, status);
- initField(&fEraNames, fEraNamesCount, (const UChar *)gLastResortEras, kEraNum, kEraLen, status);
- initField(&fNarrowEras, fNarrowErasCount, (const UChar *)gLastResortEras, kEraNum, kEraLen, status);
- initField(&fMonths, fMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
- initField(&fShortMonths, fShortMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
- initField(&fNarrowMonths, fNarrowMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
- initField(&fStandaloneMonths, fStandaloneMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
- initField(&fStandaloneShortMonths, fStandaloneShortMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
- initField(&fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
- initField(&fWeekdays, fWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fShortWeekdays, fShortWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fShorterWeekdays, fShorterWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fNarrowWeekdays, fNarrowWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fStandaloneWeekdays, fStandaloneWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fStandaloneShortWeekdays, fStandaloneShortWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fStandaloneShorterWeekdays, fStandaloneShorterWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fStandaloneNarrowWeekdays, fStandaloneNarrowWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
- initField(&fAmPms, fAmPmsCount, (const UChar *)gLastResortAmPmMarkers, kAmPmNum, kAmPmLen, status);
- initField(&fNarrowAmPms, fNarrowAmPmsCount, (const UChar *)gLastResortAmPmMarkers, kAmPmNum, kAmPmLen, status);
- initField(&fQuarters, fQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
- initField(&fShortQuarters, fShortQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
- initField(&fNarrowQuarters, fNarrowQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
- initField(&fStandaloneQuarters, fStandaloneQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
- initField(&fStandaloneShortQuarters, fStandaloneShortQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
- initField(&fStandaloneNarrowQuarters, fStandaloneNarrowQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
- fLocalPatternChars.setTo(TRUE, gPatternChars, PATTERN_CHARS_LEN);
+ initField(&fEras, fErasCount, (const char16_t *)gLastResortEras, kEraNum, kEraLen, status);
+ initField(&fEraNames, fEraNamesCount, (const char16_t *)gLastResortEras, kEraNum, kEraLen, status);
+ initField(&fNarrowEras, fNarrowErasCount, (const char16_t *)gLastResortEras, kEraNum, kEraLen, status);
+ initField(&fMonths, fMonthsCount, (const char16_t *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
+ initField(&fShortMonths, fShortMonthsCount, (const char16_t *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
+ initField(&fNarrowMonths, fNarrowMonthsCount, (const char16_t *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
+ initField(&fStandaloneMonths, fStandaloneMonthsCount, (const char16_t *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
+ initField(&fStandaloneShortMonths, fStandaloneShortMonthsCount, (const char16_t *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
+ initField(&fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount, (const char16_t *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
+ initField(&fWeekdays, fWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fShortWeekdays, fShortWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fShorterWeekdays, fShorterWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fNarrowWeekdays, fNarrowWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fStandaloneWeekdays, fStandaloneWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fStandaloneShortWeekdays, fStandaloneShortWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fStandaloneShorterWeekdays, fStandaloneShorterWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fStandaloneNarrowWeekdays, fStandaloneNarrowWeekdaysCount, (const char16_t *)gLastResortDayNames, kDayNum, kDayLen, status);
+ initField(&fAmPms, fAmPmsCount, (const char16_t *)gLastResortAmPmMarkers, kAmPmNum, kAmPmLen, status);
+ initField(&fNarrowAmPms, fNarrowAmPmsCount, (const char16_t *)gLastResortAmPmMarkers, kAmPmNum, kAmPmLen, status);
+ initField(&fQuarters, fQuartersCount, (const char16_t *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
+ initField(&fShortQuarters, fShortQuartersCount, (const char16_t *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
+ initField(&fNarrowQuarters, fNarrowQuartersCount, (const char16_t *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
+ initField(&fStandaloneQuarters, fStandaloneQuartersCount, (const char16_t *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
+ initField(&fStandaloneShortQuarters, fStandaloneShortQuartersCount, (const char16_t *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
+ initField(&fStandaloneNarrowQuarters, fStandaloneNarrowQuartersCount, (const char16_t *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
+ fLocalPatternChars.setTo(true, gPatternChars, PATTERN_CHARS_LEN);
}
}
diff --git a/contrib/libs/icu/i18n/dtitv_impl.h b/contrib/libs/icu/i18n/dtitv_impl.h
index 6fc16bb3e0..2cc7764817 100644
--- a/contrib/libs/icu/i18n/dtitv_impl.h
+++ b/contrib/libs/icu/i18n/dtitv_impl.h
@@ -25,65 +25,65 @@
#include "unicode/unistr.h"
-#define QUOTE ((UChar)0x0027)
-#define LOW_LINE ((UChar)0x005F)
-#define COLON ((UChar)0x003A)
-#define LEFT_CURLY_BRACKET ((UChar)0x007B)
-#define RIGHT_CURLY_BRACKET ((UChar)0x007D)
-#define SPACE ((UChar)0x0020)
-#define EN_DASH ((UChar)0x2013)
-#define SOLIDUS ((UChar)0x002F)
+#define QUOTE ((char16_t)0x0027)
+#define LOW_LINE ((char16_t)0x005F)
+#define COLON ((char16_t)0x003A)
+#define LEFT_CURLY_BRACKET ((char16_t)0x007B)
+#define RIGHT_CURLY_BRACKET ((char16_t)0x007D)
+#define SPACE ((char16_t)0x0020)
+#define EN_DASH ((char16_t)0x2013)
+#define SOLIDUS ((char16_t)0x002F)
-#define DIGIT_ZERO ((UChar)0x0030)
-#define DIGIT_ONE ((UChar)0x0031)
+#define DIGIT_ZERO ((char16_t)0x0030)
+#define DIGIT_ONE ((char16_t)0x0031)
-#define LOW_A ((UChar)0x0061)
-#define LOW_B ((UChar)0x0062)
-#define LOW_C ((UChar)0x0063)
-#define LOW_D ((UChar)0x0064)
-#define LOW_E ((UChar)0x0065)
-#define LOW_F ((UChar)0x0066)
-#define LOW_G ((UChar)0x0067)
-#define LOW_H ((UChar)0x0068)
-#define LOW_I ((UChar)0x0069)
-#define LOW_J ((UChar)0x006a)
-#define LOW_K ((UChar)0x006B)
-#define LOW_L ((UChar)0x006C)
-#define LOW_M ((UChar)0x006D)
-#define LOW_N ((UChar)0x006E)
-#define LOW_O ((UChar)0x006F)
-#define LOW_P ((UChar)0x0070)
-#define LOW_Q ((UChar)0x0071)
-#define LOW_R ((UChar)0x0072)
-#define LOW_S ((UChar)0x0073)
-#define LOW_T ((UChar)0x0074)
-#define LOW_U ((UChar)0x0075)
-#define LOW_V ((UChar)0x0076)
-#define LOW_W ((UChar)0x0077)
-#define LOW_Y ((UChar)0x0079)
-#define LOW_Z ((UChar)0x007A)
+#define LOW_A ((char16_t)0x0061)
+#define LOW_B ((char16_t)0x0062)
+#define LOW_C ((char16_t)0x0063)
+#define LOW_D ((char16_t)0x0064)
+#define LOW_E ((char16_t)0x0065)
+#define LOW_F ((char16_t)0x0066)
+#define LOW_G ((char16_t)0x0067)
+#define LOW_H ((char16_t)0x0068)
+#define LOW_I ((char16_t)0x0069)
+#define LOW_J ((char16_t)0x006a)
+#define LOW_K ((char16_t)0x006B)
+#define LOW_L ((char16_t)0x006C)
+#define LOW_M ((char16_t)0x006D)
+#define LOW_N ((char16_t)0x006E)
+#define LOW_O ((char16_t)0x006F)
+#define LOW_P ((char16_t)0x0070)
+#define LOW_Q ((char16_t)0x0071)
+#define LOW_R ((char16_t)0x0072)
+#define LOW_S ((char16_t)0x0073)
+#define LOW_T ((char16_t)0x0074)
+#define LOW_U ((char16_t)0x0075)
+#define LOW_V ((char16_t)0x0076)
+#define LOW_W ((char16_t)0x0077)
+#define LOW_Y ((char16_t)0x0079)
+#define LOW_Z ((char16_t)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)
-#define CAP_M ((UChar)0x004D)
-#define CAP_O ((UChar)0x004F)
-#define CAP_Q ((UChar)0x0051)
-#define CAP_S ((UChar)0x0053)
-#define CAP_T ((UChar)0x0054)
-#define CAP_U ((UChar)0x0055)
-#define CAP_V ((UChar)0x0056)
-#define CAP_W ((UChar)0x0057)
-#define CAP_Y ((UChar)0x0059)
-#define CAP_Z ((UChar)0x005A)
+#define CAP_A ((char16_t)0x0041)
+#define CAP_B ((char16_t)0x0042)
+#define CAP_C ((char16_t)0x0043)
+#define CAP_D ((char16_t)0x0044)
+#define CAP_E ((char16_t)0x0045)
+#define CAP_F ((char16_t)0x0046)
+#define CAP_G ((char16_t)0x0047)
+#define CAP_J ((char16_t)0x004A)
+#define CAP_H ((char16_t)0x0048)
+#define CAP_K ((char16_t)0x004B)
+#define CAP_L ((char16_t)0x004C)
+#define CAP_M ((char16_t)0x004D)
+#define CAP_O ((char16_t)0x004F)
+#define CAP_Q ((char16_t)0x0051)
+#define CAP_S ((char16_t)0x0053)
+#define CAP_T ((char16_t)0x0054)
+#define CAP_U ((char16_t)0x0055)
+#define CAP_V ((char16_t)0x0056)
+#define CAP_W ((char16_t)0x0057)
+#define CAP_Y ((char16_t)0x0059)
+#define CAP_Z ((char16_t)0x005A)
//#define MINIMUM_SUPPORTED_CALENDAR_FIELD UCAL_MINUTE
diff --git a/contrib/libs/icu/i18n/dtitvfmt.cpp b/contrib/libs/icu/i18n/dtitvfmt.cpp
index 298fb62be0..6087014668 100644
--- a/contrib/libs/icu/i18n/dtitvfmt.cpp
+++ b/contrib/libs/icu/i18n/dtitvfmt.cpp
@@ -44,7 +44,7 @@ U_NAMESPACE_BEGIN
#endif
-static const UChar gDateFormatSkeleton[][11] = {
+static const char16_t gDateFormatSkeleton[][11] = {
//yMMMMEEEEd
{LOW_Y, CAP_M, CAP_M, CAP_M, CAP_M, CAP_E, CAP_E, CAP_E, CAP_E, LOW_D, 0},
//yMMMMd
@@ -61,10 +61,10 @@ static const char gDateTimePatternsTag[] = "DateTimePatterns";
// latestFirst:
-static const UChar gLaterFirstPrefix[] = {LOW_L, LOW_A, LOW_T, LOW_E, LOW_S,LOW_T, CAP_F, LOW_I, LOW_R, LOW_S, LOW_T, COLON};
+static const char16_t gLaterFirstPrefix[] = {LOW_L, LOW_A, LOW_T, LOW_E, LOW_S,LOW_T, CAP_F, LOW_I, LOW_R, LOW_S, LOW_T, COLON};
// earliestFirst:
-static const UChar gEarlierFirstPrefix[] = {LOW_E, LOW_A, LOW_R, LOW_L, LOW_I, LOW_E, LOW_S, LOW_T, CAP_F, LOW_I, LOW_R, LOW_S, LOW_T, COLON};
+static const char16_t gEarlierFirstPrefix[] = {LOW_E, LOW_A, LOW_R, LOW_L, LOW_I, LOW_E, LOW_S, LOW_T, CAP_F, LOW_I, LOW_R, LOW_S, LOW_T, COLON};
class FormattedDateIntervalData : public FormattedValueFieldPositionIteratorImpl {
@@ -104,7 +104,7 @@ DateIntervalFormat::createInstance(const UnicodeString& skeleton,
UnicodeString pat;
((SimpleDateFormat*)dtfmt)->toPattern(pat);
pat.extract(0, pat.length(), result_1, "UTF-8");
- sprintf(mesg, "skeleton: %s; pattern: %s\n", result, result_1);
+ snprintf(mesg, sizeof(mesg), "skeleton: %s; pattern: %s\n", result, result_1);
PRINTMESG(mesg)
#endif
@@ -298,7 +298,7 @@ DateIntervalFormat::format(const DateInterval* dtInterval,
}
FieldPositionOnlyHandler handler(fieldPosition);
- handler.setAcceptFirstOnly(TRUE);
+ handler.setAcceptFirstOnly(true);
int8_t ignore;
Mutex lock(&gFormatterMutex);
@@ -351,7 +351,7 @@ DateIntervalFormat::format(Calendar& fromCalendar,
FieldPosition& pos,
UErrorCode& status) const {
FieldPositionOnlyHandler handler(pos);
- handler.setAcceptFirstOnly(TRUE);
+ handler.setAcceptFirstOnly(true);
int8_t ignore;
Mutex lock(&gFormatterMutex);
@@ -761,7 +761,7 @@ DateIntervalFormat::initializePattern(UErrorCode& status) {
char result_1[1000];
char mesg[2000];
fSkeleton.extract(0, fSkeleton.length(), result, "UTF-8");
- sprintf(mesg, "in getBestSkeleton: fSkeleton: %s; \n", result);
+ snprintf(mesg, sizeof(mesg), "in getBestSkeleton: fSkeleton: %s; \n", result);
PRINTMESG(mesg)
#endif
// fSkeleton is already set by createDateIntervalInstance()
@@ -808,7 +808,7 @@ DateIntervalFormat::initializePattern(UErrorCode& status) {
char result_1[1000];
char mesg[2000];
fSkeleton.extract(0, fSkeleton.length(), result, "UTF-8");
- sprintf(mesg, "in getBestSkeleton: fSkeleton: %s; \n", result);
+ snprintf(mesg, sizeof(mesg), "in getBestSkeleton: fSkeleton: %s; \n", result);
PRINTMESG(mesg)
#endif
@@ -827,7 +827,7 @@ DateIntervalFormat::initializePattern(UErrorCode& status) {
dateTimePatternsRes.getAlias(), &status);
int32_t dateTimeFormatLength;
- const UChar* dateTimeFormat = ures_getStringByIndex(
+ const char16_t* dateTimeFormat = ures_getStringByIndex(
dateTimePatternsRes.getAlias(),
(int32_t)DateFormat::kDateTime,
&dateTimeFormatLength, &status);
@@ -964,19 +964,28 @@ UnicodeString
DateIntervalFormat::normalizeHourMetacharacters(const UnicodeString& skeleton) const {
UnicodeString result = skeleton;
- UChar hourMetachar = u'\0';
- int32_t metacharStart = 0;
- int32_t metacharCount = 0;
+ char16_t hourMetachar = u'\0';
+ char16_t dayPeriodChar = u'\0';
+ int32_t hourFieldStart = 0;
+ int32_t hourFieldLength = 0;
+ int32_t dayPeriodStart = 0;
+ int32_t dayPeriodLength = 0;
for (int32_t i = 0; i < result.length(); i++) {
- UChar c = result[i];
- if (c == LOW_J || c == CAP_J || c == CAP_C) {
+ char16_t c = result[i];
+ if (c == LOW_J || c == CAP_J || c == CAP_C || c == LOW_H || c == CAP_H || c == LOW_K || c == CAP_K) {
if (hourMetachar == u'\0') {
hourMetachar = c;
- metacharStart = i;
+ hourFieldStart = i;
}
- ++metacharCount;
+ ++hourFieldLength;
+ } else if (c == LOW_A || c == LOW_B || c == CAP_B) {
+ if (dayPeriodChar == u'\0') {
+ dayPeriodChar = c;
+ dayPeriodStart = i;
+ }
+ ++dayPeriodLength;
} else {
- if (hourMetachar != u'\0') {
+ if (hourMetachar != u'\0' && dayPeriodChar != u'\0') {
break;
}
}
@@ -984,8 +993,7 @@ DateIntervalFormat::normalizeHourMetacharacters(const UnicodeString& skeleton) c
if (hourMetachar != u'\0') {
UErrorCode err = U_ZERO_ERROR;
- UChar hourChar = CAP_H;
- UChar dayPeriodChar = LOW_A;
+ char16_t hourChar = CAP_H;
UnicodeString convertedPattern = DateFormat::getBestPattern(fLocale, UnicodeString(hourMetachar), err);
if (U_SUCCESS(err)) {
@@ -1012,34 +1020,32 @@ DateIntervalFormat::normalizeHourMetacharacters(const UnicodeString& skeleton) c
dayPeriodChar = LOW_B;
} else if (convertedPattern.indexOf(CAP_B) != -1) {
dayPeriodChar = CAP_B;
+ } else if (dayPeriodChar == u'\0') {
+ dayPeriodChar = LOW_A;
}
}
- 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;
+ UnicodeString hourAndDayPeriod(hourChar);
+ if (hourChar != CAP_H && hourChar != LOW_K) {
+ int32_t newDayPeriodLength = 0;
+ if (dayPeriodLength >= 5 || hourFieldLength >= 5) {
+ newDayPeriodLength = 5;
+ } else if (dayPeriodLength >= 3 || hourFieldLength >= 3) {
+ newDayPeriodLength = 3;
+ } else {
+ newDayPeriodLength = 1;
}
- result.replace(metacharStart, metacharCount, hourAndDayPeriod);
+ for (int32_t i = 0; i < newDayPeriodLength; i++) {
+ hourAndDayPeriod.append(dayPeriodChar);
+ }
+ }
+ result.replace(hourFieldStart, hourFieldLength, hourAndDayPeriod);
+ if (dayPeriodStart > hourFieldStart) {
+ // before deleting the original day period field, adjust its position in case
+ // we just changed the size of the hour field (and new day period field)
+ dayPeriodStart += hourAndDayPeriod.length() - hourFieldLength;
}
+ result.remove(dayPeriodStart, dayPeriodLength);
}
return result;
}
@@ -1060,11 +1066,11 @@ DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton,
int32_t mCount = 0;
int32_t vCount = 0;
int32_t zCount = 0;
- UChar hourChar = u'\0';
+ char16_t hourChar = u'\0';
int32_t i;
for (i = 0; i < skeleton.length(); ++i) {
- UChar ch = skeleton[i];
+ char16_t ch = skeleton[i];
switch ( ch ) {
case CAP_E:
dateSkeleton.append(ch);
@@ -1201,8 +1207,8 @@ DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton,
* @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.
* @stable ICU 4.0
*/
UBool
@@ -1414,8 +1420,8 @@ DateIntervalFormat::setIntervalPattern(UCalendarDateFields field,
* @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.
* @stable ICU 4.0
*/
UBool
@@ -1457,7 +1463,7 @@ DateIntervalFormat::setIntervalPattern(UCalendarDateFields field,
// need to look for it from skeleton 'yMMMd',
// if found, adjust field width in interval pattern from
// "MMM" to "MMMM".
- UChar fieldLetter = fgCalendarFieldToPatternLetter[field];
+ char16_t fieldLetter = fgCalendarFieldToPatternLetter[field];
if ( extendedSkeleton ) {
*extendedSkeleton = *skeleton;
*extendedBestSkeleton = *bestSkeleton;
@@ -1489,10 +1495,10 @@ DateIntervalFormat::setIntervalPattern(UCalendarDateFields field,
setIntervalPattern(field, pattern);
}
if ( extendedSkeleton && !extendedSkeleton->isEmpty() ) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
@@ -1500,7 +1506,7 @@ DateIntervalFormat::setIntervalPattern(UCalendarDateFields field,
int32_t U_EXPORT2
DateIntervalFormat::splitPatternInto2Part(const UnicodeString& intervalPattern) {
UBool inQuote = false;
- UChar prevCh = 0;
+ char16_t prevCh = 0;
int32_t count = 0;
/* repeatedPattern used to record whether a pattern has already seen.
@@ -1528,13 +1534,13 @@ DateIntervalFormat::splitPatternInto2Part(const UnicodeString& intervalPattern)
int32_t i;
UBool foundRepetition = false;
for (i = 0; i < intervalPattern.length(); ++i) {
- UChar ch = intervalPattern.charAt(i);
+ char16_t ch = intervalPattern.charAt(i);
if (ch != prevCh && count > 0) {
// check the repeativeness of pattern letter
UBool repeated = patternRepeated[(int)(prevCh - PATTERN_CHAR_BASE)];
- if ( repeated == FALSE ) {
- patternRepeated[prevCh - PATTERN_CHAR_BASE] = TRUE;
+ if ( repeated == false ) {
+ patternRepeated[prevCh - PATTERN_CHAR_BASE] = true;
} else {
foundRepetition = true;
break;
@@ -1562,8 +1568,8 @@ DateIntervalFormat::splitPatternInto2Part(const UnicodeString& intervalPattern)
// "dd MM" ( no repetition ),
// "d-d"(last char repeated ), and
// "d-d MM" ( repetition found )
- if ( count > 0 && foundRepetition == FALSE ) {
- if ( patternRepeated[(int)(prevCh - PATTERN_CHAR_BASE)] == FALSE ) {
+ if ( count > 0 && foundRepetition == false ) {
+ if ( patternRepeated[(int)(prevCh - PATTERN_CHAR_BASE)] == false ) {
count = 0;
}
}
@@ -1676,8 +1682,8 @@ UBool U_EXPORT2
DateIntervalFormat::fieldExistsInSkeleton(UCalendarDateFields field,
const UnicodeString& skeleton)
{
- const UChar fieldChar = fgCalendarFieldToPatternLetter[field];
- return ( (skeleton.indexOf(fieldChar) == -1)?FALSE:TRUE ) ;
+ const char16_t fieldChar = fgCalendarFieldToPatternLetter[field];
+ return ( (skeleton.indexOf(fieldChar) == -1)?false:true ) ;
}
@@ -1719,7 +1725,13 @@ DateIntervalFormat::adjustFieldWidth(const UnicodeString& inputSkeleton,
DateIntervalInfo::parseSkeleton(inputSkeleton, inputSkeletonFieldWidth);
DateIntervalInfo::parseSkeleton(bestMatchSkeleton, bestMatchSkeletonFieldWidth);
if (suppressDayPeriodField) {
+ // remove the 'a' and any NBSP/NNBSP on one side of it
+ findReplaceInPattern(adjustedPtn, UnicodeString(u"\u00A0a",-1), UnicodeString());
+ findReplaceInPattern(adjustedPtn, UnicodeString(u"\u202Fa",-1), UnicodeString());
+ findReplaceInPattern(adjustedPtn, UnicodeString(u"a\u00A0",-1), UnicodeString());
+ findReplaceInPattern(adjustedPtn, UnicodeString(u"a\u202F",-1), UnicodeString());
findReplaceInPattern(adjustedPtn, UnicodeString(LOW_A), UnicodeString());
+ // adjust interior double spaces, remove exterior whitespace
findReplaceInPattern(adjustedPtn, UnicodeString(" "), UnicodeString(" "));
adjustedPtn.trim();
}
@@ -1745,17 +1757,17 @@ DateIntervalFormat::adjustFieldWidth(const UnicodeString& inputSkeleton,
}
UBool inQuote = false;
- UChar prevCh = 0;
+ char16_t prevCh = 0;
int32_t count = 0;
// loop through the pattern string character by character
int32_t adjustedPtnLength = adjustedPtn.length();
int32_t i;
for (i = 0; i < adjustedPtnLength; ++i) {
- UChar ch = adjustedPtn.charAt(i);
+ char16_t ch = adjustedPtn.charAt(i);
if (ch != prevCh && count > 0) {
// check the repeativeness of pattern letter
- UChar skeletonChar = prevCh;
+ char16_t skeletonChar = prevCh;
if ( skeletonChar == CAP_L ) {
// there is no "L" (always be "M") in skeleton,
// but there is "L" in pattern.
@@ -1794,7 +1806,7 @@ DateIntervalFormat::adjustFieldWidth(const UnicodeString& inputSkeleton,
if ( count > 0 ) {
// last item
// check the repeativeness of pattern letter
- UChar skeletonChar = prevCh;
+ char16_t skeletonChar = prevCh;
if ( skeletonChar == CAP_L ) {
// there is no "L" (always be "M") in skeleton,
// but there is "L" in pattern.
@@ -1877,7 +1889,7 @@ DateIntervalFormat::concatSingleDate2TimeInterval(UnicodeString& format,
-const UChar
+const char16_t
DateIntervalFormat::fgCalendarFieldToPatternLetter[] =
{
/*GyM*/ CAP_G, LOW_Y, CAP_M,
diff --git a/contrib/libs/icu/i18n/dtitvinf.cpp b/contrib/libs/icu/i18n/dtitvinf.cpp
index 6052894b58..3733d04518 100644
--- a/contrib/libs/icu/i18n/dtitvinf.cpp
+++ b/contrib/libs/icu/i18n/dtitvinf.cpp
@@ -55,12 +55,12 @@ static const char gIntervalDateTimePatternTag[]="intervalFormats";
static const char gFallbackPatternTag[]="fallback";
// {0}
-static const UChar gFirstPattern[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET};
+static const char16_t gFirstPattern[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET};
// {1}
-static const UChar gSecondPattern[] = {LEFT_CURLY_BRACKET, DIGIT_ONE, RIGHT_CURLY_BRACKET};
+static const char16_t gSecondPattern[] = {LEFT_CURLY_BRACKET, DIGIT_ONE, RIGHT_CURLY_BRACKET};
// default fall-back
-static const UChar gDefaultFallbackPattern[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, EN_DASH, SPACE, LEFT_CURLY_BRACKET, DIGIT_ONE, RIGHT_CURLY_BRACKET, 0};
+static const char16_t gDefaultFallbackPattern[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, EN_DASH, SPACE, LEFT_CURLY_BRACKET, DIGIT_ONE, RIGHT_CURLY_BRACKET, 0};
DateIntervalInfo::DateIntervalInfo(UErrorCode& status)
: fFallbackIntervalPattern(gDefaultFallbackPattern),
@@ -218,10 +218,10 @@ DateIntervalInfo::getFallbackIntervalPattern(UnicodeString& result) const {
static const int32_t PATH_PREFIX_LENGTH = 17;
-static const UChar PATH_PREFIX[] = {SOLIDUS, CAP_L, CAP_O, CAP_C, CAP_A, CAP_L, CAP_E, SOLIDUS,
+static const char16_t PATH_PREFIX[] = {SOLIDUS, CAP_L, CAP_O, CAP_C, CAP_A, CAP_L, CAP_E, SOLIDUS,
LOW_C, LOW_A, LOW_L, LOW_E, LOW_N, LOW_D, LOW_A, LOW_R, SOLIDUS};
static const int32_t PATH_SUFFIX_LENGTH = 16;
-static const UChar PATH_SUFFIX[] = {SOLIDUS, LOW_I, LOW_N, LOW_T, LOW_E, LOW_R, LOW_V, LOW_A,
+static const char16_t PATH_SUFFIX[] = {SOLIDUS, LOW_I, LOW_N, LOW_T, LOW_E, LOW_R, LOW_V, LOW_A,
LOW_L, CAP_F, LOW_O, LOW_R, LOW_M, LOW_A, LOW_T, LOW_S};
/**
@@ -401,7 +401,7 @@ DateIntervalInfo::initializeData(const Locale& locale, UErrorCode& status)
char localeWithCalendarKey[ULOC_LOCALE_IDENTIFIER_CAPACITY];
// obtain a locale that always has the calendar key value that should be used
(void)ures_getFunctionalEquivalent(localeWithCalendarKey, ULOC_LOCALE_IDENTIFIER_CAPACITY, nullptr,
- "calendar", "calendar", locName, nullptr, FALSE, &status);
+ "calendar", "calendar", locName, nullptr, false, &status);
localeWithCalendarKey[ULOC_LOCALE_IDENTIFIER_CAPACITY-1] = 0; // ensure null termination
// now get the calendar key value from that locale
int32_t calendarTypeLen = uloc_getKeywordValue(localeWithCalendarKey, "calendar", calendarType,
@@ -424,7 +424,7 @@ DateIntervalInfo::initializeData(const Locale& locale, UErrorCode& status)
UResourceBundle *calTypeBundle, *itvDtPtnResource;
// Get the fallback pattern
- const UChar* resStr = nullptr;
+ const char16_t* resStr = nullptr;
int32_t resStrLen = 0;
calTypeBundle = ures_getByKeyWithFallback(calBundle, calendarTypeToUse, nullptr, &status);
itvDtPtnResource = ures_getByKeyWithFallback(calTypeBundle,
@@ -437,7 +437,7 @@ DateIntervalInfo::initializeData(const Locale& locale, UErrorCode& status)
}
if ( U_SUCCESS(status) && (resStr != nullptr)) {
- UnicodeString pattern = UnicodeString(TRUE, resStr, resStrLen);
+ UnicodeString pattern = UnicodeString(true, resStr, resStrLen);
setFallbackIntervalPattern(pattern, status);
}
ures_close(itvDtPtnResource);
@@ -449,7 +449,7 @@ DateIntervalInfo::initializeData(const Locale& locale, UErrorCode& status)
const UnicodeString &calendarTypeToUseUString = sink.getNextCalendarType();
// Already loaded calendar types
- Hashtable loadedCalendarTypes(FALSE, status);
+ Hashtable loadedCalendarTypes(false, status);
if (U_SUCCESS(status)) {
while (!calendarTypeToUseUString.isBogus()) {
@@ -504,7 +504,7 @@ DateIntervalInfo::setIntervalPatternInternally(const UnicodeString& skeleton,
}
patternsOfOneSkeleton[index] = intervalPattern;
- if ( emptyHash == TRUE ) {
+ if ( emptyHash ) {
fIntervalPatterns->put(skeleton, patternsOfOneSkeleton, status);
}
}
@@ -547,7 +547,7 @@ DateIntervalInfo::getBestSkeleton(const UnicodeString& skeleton,
char result_1[1000];
char mesg[2000];
skeleton.extract(0, skeleton.length(), result, "UTF-8");
- sprintf(mesg, "in getBestSkeleton: skeleton: %s; \n", result);
+ snprintf(mesg, sizeof(mesg), "in getBestSkeleton: skeleton: %s; \n", result);
PRINTMESG(mesg)
#endif
@@ -616,7 +616,7 @@ DateIntervalInfo::getBestSkeleton(const UnicodeString& skeleton,
UnicodeString* newSkeleton = (UnicodeString*)keyTok.pointer;
#ifdef DTITVINF_DEBUG
skeleton->extract(0, skeleton->length(), result, "UTF-8");
- sprintf(mesg, "available skeletons: skeleton: %s; \n", result);
+ snprintf(mesg, sizeof(mesg), "available skeletons: skeleton: %s; \n", result);
PRINTMESG(mesg)
#endif
@@ -738,7 +738,7 @@ U_CDECL_BEGIN
*
* @param val1 one value in comparison
* @param val2 the other value in comparison
- * @return TRUE if 2 values are the same, FALSE otherwise
+ * @return true if 2 values are the same, false otherwise
*/
static UBool U_CALLCONV dtitvinfHashTableValueComparator(UHashTok val1, UHashTok val2);
@@ -746,9 +746,9 @@ static UBool
U_CALLCONV dtitvinfHashTableValueComparator(UHashTok val1, UHashTok val2) {
const UnicodeString* pattern1 = (UnicodeString*)val1.pointer;
const UnicodeString* pattern2 = (UnicodeString*)val2.pointer;
- UBool ret = TRUE;
+ UBool ret = true;
int8_t i;
- for ( i = 0; i < DateIntervalInfo::kMaxIntervalPatternIndex && ret == TRUE; ++i ) {
+ for ( i = 0; i < DateIntervalInfo::kMaxIntervalPatternIndex && ret ; ++i ) {
ret = (pattern1[i] == pattern2[i]);
}
return ret;
@@ -763,7 +763,7 @@ DateIntervalInfo::initHash(UErrorCode& status) {
return nullptr;
}
Hashtable* hTable;
- if ( (hTable = new Hashtable(FALSE, status)) == nullptr ) {
+ if ( (hTable = new Hashtable(false, status)) == nullptr ) {
status = U_MEMORY_ALLOCATION_ERROR;
return nullptr;
}
diff --git a/contrib/libs/icu/i18n/dtptngen.cpp b/contrib/libs/icu/i18n/dtptngen.cpp
index 6aee1750f9..1f74540fbd 100644
--- a/contrib/libs/icu/i18n/dtptngen.cpp
+++ b/contrib/libs/icu/i18n/dtptngen.cpp
@@ -58,7 +58,7 @@
#include "uarrsort.h"
struct UResAEntry {
- UChar *key;
+ char16_t *key;
UResourceBundle *item;
};
@@ -97,10 +97,10 @@ static void ures_a_open(UResourceBundleAIterator *aiter, UResourceBundle *bund,
aiter->entries[i].item = ures_getByIndex(aiter->bund, i, nullptr, status);
const char *akey = ures_getKey(aiter->entries[i].item);
int32_t len = uprv_strlen(akey)+1;
- aiter->entries[i].key = (UChar*)uprv_malloc(len*sizeof(UChar));
+ aiter->entries[i].key = (char16_t*)uprv_malloc(len*sizeof(char16_t));
u_charsToUChars(akey, aiter->entries[i].key, len);
}
- uprv_sortArray(aiter->entries, aiter->num, sizeof(UResAEntry), ures_a_codepointSort, nullptr, TRUE, status);
+ uprv_sortArray(aiter->entries, aiter->num, sizeof(UResAEntry), ures_a_codepointSort, nullptr, true, status);
#endif
}
@@ -113,13 +113,13 @@ static void ures_a_close(UResourceBundleAIterator *aiter) {
#endif
}
-static const UChar *ures_a_getNextString(UResourceBundleAIterator *aiter, int32_t *len, const char **key, UErrorCode *err) {
+static const char16_t *ures_a_getNextString(UResourceBundleAIterator *aiter, int32_t *len, const char **key, UErrorCode *err) {
#if !defined(U_SORT_ASCII_BUNDLE_ITERATOR)
return ures_getNextString(aiter->bund, len, key, err);
#else
if(U_FAILURE(*err)) return nullptr;
UResourceBundle *item = aiter->entries[aiter->cursor].item;
- const UChar* ret = ures_getString(item, len, err);
+ const char16_t* ret = ures_getString(item, len, err);
*key = ures_getKey(item);
aiter->cursor++;
return ret;
@@ -135,7 +135,7 @@ U_NAMESPACE_BEGIN
// *****************************************************************************
// class DateTimePatternGenerator
// *****************************************************************************
-static const UChar Canonical_Items[] = {
+static const char16_t Canonical_Items[] = {
// GyQMwWEDFdaHmsSv
CAP_G, LOW_Y, CAP_Q, CAP_M, LOW_W, CAP_W, CAP_E,
CAP_D, CAP_F, LOW_D, LOW_A, // The UDATPG_x_FIELD constants and these fields have a different order than in ICU4J
@@ -273,18 +273,17 @@ static const char* const CLDR_FIELD_WIDTH[] = { // [UDATPG_WIDTH_COUNT]
"", "-short", "-narrow"
};
-// TODO(ticket:13619): remove when definition uncommented in dtptngen.h.
-static const int32_t UDATPG_WIDTH_COUNT = UDATPG_NARROW + 1;
static constexpr UDateTimePGDisplayWidth UDATPG_WIDTH_APPENDITEM = UDATPG_WIDE;
static constexpr int32_t UDATPG_FIELD_KEY_MAX = 24; // max length of CLDR field tag (type + width)
// For appendItems
-static const UChar UDATPG_ItemFormat[]= {0x7B, 0x30, 0x7D, 0x20, 0x251C, 0x7B, 0x32, 0x7D, 0x3A,
+static const char16_t UDATPG_ItemFormat[]= {0x7B, 0x30, 0x7D, 0x20, 0x251C, 0x7B, 0x32, 0x7D, 0x3A,
0x20, 0x7B, 0x31, 0x7D, 0x2524, 0}; // {0} \u251C{2}: {1}\u2524
-//static const UChar repeatedPatterns[6]={CAP_G, CAP_E, LOW_Z, LOW_V, CAP_Q, 0}; // "GEzvQ"
+//static const char16_t repeatedPatterns[6]={CAP_G, CAP_E, LOW_Z, LOW_V, CAP_Q, 0}; // "GEzvQ"
static const char DT_DateTimePatternsTag[]="DateTimePatterns";
+static const char DT_DateAtTimePatternsTag[]="DateTimePatterns%atTime";
static const char DT_DateTimeCalendarTag[]="calendar";
static const char DT_DateTimeGregorianTag[]="gregorian";
static const char DT_DateTimeAppendItemsTag[]="appendItems";
@@ -393,10 +392,13 @@ DateTimePatternGenerator::operator=(const DateTimePatternGenerator& other) {
*fp = *(other.fp);
dtMatcher->copyFrom(other.dtMatcher->skeleton);
*distanceInfo = *(other.distanceInfo);
- dateTimeFormat = other.dateTimeFormat;
+ for (int32_t style = UDAT_FULL; style <= UDAT_SHORT; style++) {
+ dateTimeFormat[style] = other.dateTimeFormat[style];
+ }
decimal = other.decimal;
- // NUL-terminate for the C API.
- dateTimeFormat.getTerminatedBuffer();
+ for (int32_t style = UDAT_FULL; style <= UDAT_SHORT; style++) {
+ dateTimeFormat[style].getTerminatedBuffer(); // NUL-terminate for the C API.
+ }
decimal.getTerminatedBuffer();
delete skipMatcher;
if ( other.skipMatcher == nullptr ) {
@@ -430,7 +432,12 @@ DateTimePatternGenerator::operator==(const DateTimePatternGenerator& other) cons
return true;
}
if ((pLocale==other.pLocale) && (patternMap->equals(*other.patternMap)) &&
- (dateTimeFormat==other.dateTimeFormat) && (decimal==other.decimal)) {
+ (decimal==other.decimal)) {
+ for (int32_t style = UDAT_FULL; style <= UDAT_SHORT; style++) {
+ if (dateTimeFormat[style] != other.dateTimeFormat[style]) {
+ return false;
+ }
+ }
for ( int32_t i=0 ; i<UDATPG_FIELD_COUNT; ++i ) {
if (appendItemFormats[i] != other.appendItemFormats[i]) {
return false;
@@ -467,7 +474,7 @@ DateTimePatternGenerator::~DateTimePatternGenerator() {
namespace {
-UInitOnce initOnce = U_INITONCE_INITIALIZER;
+UInitOnce initOnce {};
UHashtable *localeToAllowedHourFormatsMap = nullptr;
// Value deleter for hashmap.
@@ -478,7 +485,7 @@ U_CFUNC void U_CALLCONV deleteAllowedHourFormats(void *ptr) {
// Close hashmap at cleanup.
U_CFUNC UBool U_CALLCONV allowedHourFormatsCleanup() {
uhash_close(localeToAllowedHourFormatsMap);
- return TRUE;
+ return true;
}
enum AllowedHourFormat{
@@ -649,6 +656,17 @@ void DateTimePatternGenerator::getAllowedHourFormats(const Locale &locale, UErro
const char *language = locale.getLanguage();
const char *country = locale.getCountry();
+
+ char regionOverride[8];
+ int32_t regionOverrideLength = locale.getKeywordValue("rg", regionOverride, sizeof(regionOverride), status);
+ if (U_SUCCESS(status) && regionOverrideLength > 0) {
+ country = regionOverride;
+ if (regionOverrideLength > 2) {
+ // chop off any subdivision codes that may have been included
+ regionOverride[2] = '\0';
+ }
+ }
+
Locale maxLocale; // must be here for correct lifetime
if (*language == '\0' || *country == '\0') {
maxLocale = locale;
@@ -802,7 +820,7 @@ DateTimePatternGenerator::addICUPatterns(const Locale& locale, UErrorCode& statu
SimpleDateFormat* sdf;
if (df != nullptr && (sdf = dynamic_cast<SimpleDateFormat*>(df)) != nullptr) {
sdf->toPattern(dfPattern);
- addPattern(dfPattern, FALSE, conflictingString, status);
+ addPattern(dfPattern, false, conflictingString, status);
}
// TODO Maybe we should return an error when the date format isn't simple.
delete df;
@@ -811,7 +829,7 @@ DateTimePatternGenerator::addICUPatterns(const Locale& locale, UErrorCode& statu
df = DateFormat::createTimeInstance(style, locale);
if (df != nullptr && (sdf = dynamic_cast<SimpleDateFormat*>(df)) != nullptr) {
sdf->toPattern(dfPattern);
- addPattern(dfPattern, FALSE, conflictingString, status);
+ addPattern(dfPattern, false, conflictingString, status);
// TODO: C++ and Java are inconsistent (see #12568).
// C++ uses MEDIUM, but Java uses SHORT.
@@ -831,7 +849,7 @@ DateTimePatternGenerator::hackTimes(const UnicodeString& hackPattern, UErrorCode
fp->set(hackPattern);
UnicodeString mmss;
- UBool gotMm=FALSE;
+ UBool gotMm=false;
for (int32_t i=0; i<fp->itemNumber; ++i) {
UnicodeString field = fp->items[i];
if ( fp->isQuoteLiteral(field) ) {
@@ -846,9 +864,9 @@ DateTimePatternGenerator::hackTimes(const UnicodeString& hackPattern, UErrorCode
mmss+=field;
}
else {
- UChar ch=field.charAt(0);
+ char16_t ch=field.charAt(0);
if (ch==LOW_M) {
- gotMm=TRUE;
+ gotMm=true;
mmss+=field;
}
else {
@@ -857,7 +875,7 @@ DateTimePatternGenerator::hackTimes(const UnicodeString& hackPattern, UErrorCode
break;
}
mmss+= field;
- addPattern(mmss, FALSE, conflictingString, status);
+ addPattern(mmss, false, conflictingString, status);
break;
}
else {
@@ -888,7 +906,7 @@ DateTimePatternGenerator::getCalendarTypeToUse(const Locale& locale, CharString&
"calendar",
locale.getName(),
nullptr,
- FALSE,
+ false,
&localStatus);
localeWithCalendarKey[ULOC_LOCALE_IDENTIFIER_CAPACITY-1] = 0; // ensure null termination
// now get the calendar key value from that locale
@@ -943,7 +961,7 @@ struct DateTimePatternGenerator::AppendItemFormatsSink : public ResourceSink {
}
void fillInMissing() {
- UnicodeString defaultItemFormat(TRUE, UDATPG_ItemFormat, UPRV_LENGTHOF(UDATPG_ItemFormat)-1); // Read-only alias.
+ UnicodeString defaultItemFormat(true, UDATPG_ItemFormat, UPRV_LENGTHOF(UDATPG_ItemFormat)-1); // Read-only alias.
for (int32_t i = 0; i < UDATPG_FIELD_COUNT; i++) {
UDateTimePatternField field = (UDateTimePatternField)i;
if (dtpg.getAppendItemFormat(field).isEmpty()) {
@@ -983,11 +1001,11 @@ struct DateTimePatternGenerator::AppendItemNamesSink : public ResourceSink {
U_ASSERT(i < 20);
if (i < 10) {
// F0, F1, ..., F9
- valueStr += (UChar)(i+0x30);
+ valueStr += (char16_t)(i+0x30);
} else {
// F10, F11, ...
- valueStr += (UChar)0x31;
- valueStr += (UChar)(i-10 + 0x30);
+ valueStr += (char16_t)0x31;
+ valueStr += (char16_t)(i-10 + 0x30);
}
// NUL-terminate for the C API.
valueStr.getTerminatedBuffer();
@@ -1087,7 +1105,7 @@ DateTimePatternGenerator::initHashtable(UErrorCode& err) {
if (fAvailableFormatKeyHash!=nullptr) {
return;
}
- LocalPointer<Hashtable> hash(new Hashtable(FALSE, err), err);
+ LocalPointer<Hashtable> hash(new Hashtable(false, err), err);
if (U_SUCCESS(err)) {
fAvailableFormatKeyHash = hash.orphan();
}
@@ -1199,7 +1217,21 @@ DateTimePatternGenerator::getBestPattern(const UnicodeString& patternForm, UDate
}
resultPattern.remove();
status = U_ZERO_ERROR;
- dtFormat=getDateTimeFormat();
+ // determine which dateTimeFormat to use
+ PtnSkeleton* reqSkeleton = dtMatcher->getSkeletonPtr();
+ UDateFormatStyle style = UDAT_SHORT;
+ int32_t monthFieldLen = reqSkeleton->baseOriginal.getFieldLength(UDATPG_MONTH_FIELD);
+ if (monthFieldLen == 4) {
+ if (reqSkeleton->baseOriginal.getFieldLength(UDATPG_WEEKDAY_FIELD) > 0) {
+ style = UDAT_FULL;
+ } else {
+ style = UDAT_LONG;
+ }
+ } else if (monthFieldLen == 3) {
+ style = UDAT_MEDIUM;
+ }
+ // and now use it to compose date and time
+ dtFormat=getDateTimeFormat(style, status);
SimpleFormatter(dtFormat, 2, 2, status).format(timePattern, datePattern, resultPattern, status);
return resultPattern;
}
@@ -1215,10 +1247,10 @@ UnicodeString
DateTimePatternGenerator::mapSkeletonMetacharacters(const UnicodeString& patternForm, int32_t* flags, UErrorCode& status) {
UnicodeString patternFormMapped;
patternFormMapped.remove();
- UBool inQuoted = FALSE;
+ UBool inQuoted = false;
int32_t patPos, patLen = patternForm.length();
for (patPos = 0; patPos < patLen; patPos++) {
- UChar patChr = patternForm.charAt(patPos);
+ char16_t patChr = patternForm.charAt(patPos);
if (patChr == SINGLE_QUOTE) {
inQuoted = !inQuoted;
} else if (!inQuoted) {
@@ -1236,8 +1268,8 @@ DateTimePatternGenerator::mapSkeletonMetacharacters(const UnicodeString& pattern
}
int32_t hourLen = 1 + (extraLen & 1);
int32_t dayPeriodLen = (extraLen < 2)? 1: 3 + (extraLen >> 1);
- UChar hourChar = LOW_H;
- UChar dayPeriodChar = LOW_A;
+ char16_t hourChar = LOW_H;
+ char16_t dayPeriodChar = LOW_A;
if (patChr == LOW_J) {
hourChar = fDefaultHourFormatChar;
} else {
@@ -1327,7 +1359,7 @@ DateTimePatternGenerator::addCanonicalItems(UErrorCode& status) {
for (int32_t i=0; i<UDATPG_FIELD_COUNT; i++) {
if (Canonical_Items[i] > 0) {
- addPattern(UnicodeString(Canonical_Items[i]), FALSE, conflictingPattern, status);
+ addPattern(UnicodeString(Canonical_Items[i]), false, conflictingPattern, status);
}
if (U_FAILURE(status)) { return; }
}
@@ -1335,56 +1367,119 @@ DateTimePatternGenerator::addCanonicalItems(UErrorCode& status) {
void
DateTimePatternGenerator::setDateTimeFormat(const UnicodeString& dtFormat) {
- dateTimeFormat = dtFormat;
- // NUL-terminate for the C API.
- dateTimeFormat.getTerminatedBuffer();
+ UErrorCode status = U_ZERO_ERROR;
+ for (int32_t style = UDAT_FULL; style <= UDAT_SHORT; style++) {
+ setDateTimeFormat((UDateFormatStyle)style, dtFormat, status);
+ }
}
const UnicodeString&
DateTimePatternGenerator::getDateTimeFormat() const {
- return dateTimeFormat;
+ UErrorCode status = U_ZERO_ERROR;
+ return getDateTimeFormat(UDAT_MEDIUM, status);
+}
+
+void
+DateTimePatternGenerator::setDateTimeFormat(UDateFormatStyle style, const UnicodeString& dtFormat, UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
+ if (style < UDAT_FULL || style > UDAT_SHORT) {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return;
+ }
+ dateTimeFormat[style] = dtFormat;
+ // Note for the following: getTerminatedBuffer() can re-allocate the UnicodeString
+ // buffer so we do this here before clients request a const ref to the UnicodeString
+ // or its buffer.
+ dateTimeFormat[style].getTerminatedBuffer(); // NUL-terminate for the C API.
+}
+
+const UnicodeString&
+DateTimePatternGenerator::getDateTimeFormat(UDateFormatStyle style, UErrorCode& status) const {
+ static const UnicodeString emptyString = UNICODE_STRING_SIMPLE("");
+ if (U_FAILURE(status)) {
+ return emptyString;
+ }
+ if (style < UDAT_FULL || style > UDAT_SHORT) {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return emptyString;
+ }
+ return dateTimeFormat[style];
}
+static const int32_t cTypeBufMax = 32;
+
void
DateTimePatternGenerator::setDateTimeFromCalendar(const Locale& locale, UErrorCode& status) {
if (U_FAILURE(status)) { return; }
- const UChar *resStr;
+ const char16_t *resStr;
int32_t resStrLen = 0;
- LocalPointer<Calendar> fCalendar(Calendar::createInstance(locale, status), status);
- if (U_FAILURE(status)) { return; }
-
LocalUResourceBundlePointer calData(ures_open(nullptr, locale.getBaseName(), &status));
if (U_FAILURE(status)) { return; }
ures_getByKey(calData.getAlias(), DT_DateTimeCalendarTag, calData.getAlias(), &status);
if (U_FAILURE(status)) { return; }
- LocalUResourceBundlePointer dateTimePatterns;
- if (fCalendar->getType() != nullptr && *fCalendar->getType() != '\0'
- && uprv_strcmp(fCalendar->getType(), DT_DateTimeGregorianTag) != 0) {
- dateTimePatterns.adoptInstead(ures_getByKeyWithFallback(calData.getAlias(), fCalendar->getType(),
- nullptr, &status));
- ures_getByKeyWithFallback(dateTimePatterns.getAlias(), DT_DateTimePatternsTag,
- dateTimePatterns.getAlias(), &status);
+ char cType[cTypeBufMax + 1];
+ Calendar::getCalendarTypeFromLocale(locale, cType, cTypeBufMax, status);
+ cType[cTypeBufMax] = 0;
+ if (U_FAILURE(status) || cType[0] == 0) {
+ status = U_ZERO_ERROR;
+ uprv_strcpy(cType, DT_DateTimeGregorianTag);
}
+ UBool cTypeIsGregorian = (uprv_strcmp(cType, DT_DateTimeGregorianTag) == 0);
+ // Currently, for compatibility with pre-CLDR-42 data, we default to the "atTime"
+ // combining patterns. Depending on guidance in CLDR 42 spec and on DisplayOptions,
+ // we may change this.
+ LocalUResourceBundlePointer specificCalBundle;
+ LocalUResourceBundlePointer dateTimePatterns;
+ int32_t dateTimeOffset = 0; // initially for DateTimePatterns%atTime
+ if (!cTypeIsGregorian) {
+ specificCalBundle.adoptInstead(ures_getByKeyWithFallback(calData.getAlias(), cType,
+ nullptr, &status));
+ dateTimePatterns.adoptInstead(ures_getByKeyWithFallback(specificCalBundle.getAlias(), DT_DateAtTimePatternsTag, // the %atTime variant, 4 entries
+ nullptr, &status));
+ }
if (dateTimePatterns.isNull() || status == U_MISSING_RESOURCE_ERROR) {
status = U_ZERO_ERROR;
- dateTimePatterns.adoptInstead(ures_getByKeyWithFallback(calData.getAlias(), DT_DateTimeGregorianTag,
- dateTimePatterns.orphan(), &status));
- ures_getByKeyWithFallback(dateTimePatterns.getAlias(), DT_DateTimePatternsTag,
- dateTimePatterns.getAlias(), &status);
+ specificCalBundle.adoptInstead(ures_getByKeyWithFallback(calData.getAlias(), DT_DateTimeGregorianTag,
+ nullptr, &status));
+ dateTimePatterns.adoptInstead(ures_getByKeyWithFallback(specificCalBundle.getAlias(), DT_DateAtTimePatternsTag, // the %atTime variant, 4 entries
+ nullptr, &status));
}
- if (U_FAILURE(status)) { return; }
-
- if (ures_getSize(dateTimePatterns.getAlias()) <= DateFormat::kDateTime)
- {
+ if (U_SUCCESS(status) && (ures_getSize(dateTimePatterns.getAlias()) < 4)) {
status = U_INVALID_FORMAT_ERROR;
- return;
}
- resStr = ures_getStringByIndex(dateTimePatterns.getAlias(), (int32_t)DateFormat::kDateTime, &resStrLen, &status);
- setDateTimeFormat(UnicodeString(TRUE, resStr, resStrLen));
+ if (status == U_MISSING_RESOURCE_ERROR) {
+ // Try again with standard variant
+ status = U_ZERO_ERROR;
+ dateTimePatterns.orphan();
+ dateTimeOffset = (int32_t)DateFormat::kDateTimeOffset;
+ if (!cTypeIsGregorian) {
+ specificCalBundle.adoptInstead(ures_getByKeyWithFallback(calData.getAlias(), cType,
+ nullptr, &status));
+ dateTimePatterns.adoptInstead(ures_getByKeyWithFallback(specificCalBundle.getAlias(), DT_DateTimePatternsTag, // the standard variant, 13 entries
+ nullptr, &status));
+ }
+ if (dateTimePatterns.isNull() || status == U_MISSING_RESOURCE_ERROR) {
+ status = U_ZERO_ERROR;
+ specificCalBundle.adoptInstead(ures_getByKeyWithFallback(calData.getAlias(), DT_DateTimeGregorianTag,
+ nullptr, &status));
+ dateTimePatterns.adoptInstead(ures_getByKeyWithFallback(specificCalBundle.getAlias(), DT_DateTimePatternsTag, // the standard variant, 13 entries
+ nullptr, &status));
+ }
+ if (U_SUCCESS(status) && (ures_getSize(dateTimePatterns.getAlias()) <= DateFormat::kDateTimeOffset + DateFormat::kShort)) {
+ status = U_INVALID_FORMAT_ERROR;
+ }
+ }
+ if (U_FAILURE(status)) { return; }
+ for (int32_t style = UDAT_FULL; style <= UDAT_SHORT; style++) {
+ resStr = ures_getStringByIndex(dateTimePatterns.getAlias(), dateTimeOffset + style, &resStrLen, &status);
+ setDateTimeFormat((UDateFormatStyle)style, UnicodeString(true, resStr, resStrLen), status);
+ }
}
void
@@ -1624,7 +1719,7 @@ DateTimePatternGenerator::adjustFieldTypes(const UnicodeString& pattern,
// a) The length of the field in the skeleton (skelFieldLen) is equal to reqFieldLen.
// b) The pattern field is numeric and the skeleton field is not, or vice versa.
- UChar reqFieldChar = dtMatcher->skeleton.original.getFieldChar(typeValue);
+ char16_t reqFieldChar = dtMatcher->skeleton.original.getFieldChar(typeValue);
int32_t reqFieldLen = dtMatcher->skeleton.original.getFieldLength(typeValue);
if (reqFieldChar == CAP_E && reqFieldLen < 3)
reqFieldLen = 3; // 1-3 for E are equivalent to 3 for c,e
@@ -1646,7 +1741,7 @@ DateTimePatternGenerator::adjustFieldTypes(const UnicodeString& pattern,
adjFieldLen = field.length();
}
}
- UChar c = (typeValue!= UDATPG_HOUR_FIELD
+ char16_t c = (typeValue!= UDATPG_HOUR_FIELD
&& typeValue!= UDATPG_MONTH_FIELD
&& typeValue!= UDATPG_WEEKDAY_FIELD
&& (typeValue!= UDATPG_YEAR_FIELD || reqFieldChar==CAP_Y))
@@ -1891,14 +1986,14 @@ DateTimePatternGenerator::getRedundants(UErrorCode& status) {
UBool
DateTimePatternGenerator::isCanonicalItem(const UnicodeString& item) const {
if ( item.length() != 1 ) {
- return FALSE;
+ return false;
}
for (int32_t i=0; i<UDATPG_FIELD_COUNT; ++i) {
if (item.charAt(0)==Canonical_Items[i]) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
@@ -1911,7 +2006,7 @@ PatternMap::PatternMap() {
for (int32_t i=0; i < MAX_PATTERN_ENTRIES; ++i ) {
boot[i] = nullptr;
}
- isDupAllowed = TRUE;
+ isDupAllowed = true;
}
void
@@ -1956,7 +2051,7 @@ PatternMap::copyFrom(const PatternMap& other, UErrorCode& status) {
}
PtnElem*
-PatternMap::getHeader(UChar baseChar) const {
+PatternMap::getHeader(char16_t baseChar) const {
PtnElem* curElem;
if ( (baseChar >= CAP_A) && (baseChar <= CAP_Z) ) {
@@ -1988,7 +2083,7 @@ PatternMap::add(const UnicodeString& basePattern,
const UnicodeString& value,// mapped pattern value
UBool skeletonWasSpecified,
UErrorCode &status) {
- UChar baseChar = basePattern.charAt(0);
+ char16_t baseChar = basePattern.charAt(0);
PtnElem *curElem, *baseElem;
status = U_ZERO_ERROR;
@@ -2082,10 +2177,10 @@ PatternMap::getPatternFromBasePattern(const UnicodeString& basePattern, UBool& s
// Find the pattern from the given skeleton.
-// At least when this is called from getBestRaw & addPattern (in which case specifiedSkeletonPtr is non-NULL),
+// At least when this is called from getBestRaw & addPattern (in which case specifiedSkeletonPtr is non-nullptr),
// the comparison should be based on skeleton.original (which is unique and tied to the distance measurement in bestRaw)
// and not skeleton.baseOriginal (which is not unique); otherwise we may pick a different skeleton than the one with the
-// optimum distance value in getBestRaw. When this is called from public getRedundants (specifiedSkeletonPtr is NULL),
+// optimum distance value in getBestRaw. When this is called from public getRedundants (specifiedSkeletonPtr is nullptr),
// for now it will continue to compare based on baseOriginal so as not to change the behavior unnecessarily.
const UnicodeString *
PatternMap::getPatternFromSkeleton(const PtnSkeleton& skeleton, const PtnSkeleton** specifiedSkeletonPtr) const { // key to search for
@@ -2096,7 +2191,7 @@ PatternMap::getPatternFromSkeleton(const PtnSkeleton& skeleton, const PtnSkeleto
}
// find boot entry
- UChar baseChar = skeleton.getFirstChar();
+ char16_t baseChar = skeleton.getFirstChar();
if ((curElem=getHeader(baseChar))==nullptr) {
return nullptr; // no match
}
@@ -2123,14 +2218,14 @@ PatternMap::getPatternFromSkeleton(const PtnSkeleton& skeleton, const PtnSkeleto
UBool
PatternMap::equals(const PatternMap& other) const {
if ( this==&other ) {
- return TRUE;
+ return true;
}
for (int32_t bootIndex = 0; bootIndex < MAX_PATTERN_ENTRIES; ++bootIndex) {
if (boot[bootIndex] == other.boot[bootIndex]) {
continue;
}
if ((boot[bootIndex] == nullptr) || (other.boot[bootIndex] == nullptr)) {
- return FALSE;
+ return false;
}
PtnElem *otherElem = other.boot[bootIndex];
PtnElem *myElem = boot[bootIndex];
@@ -2139,25 +2234,25 @@ PatternMap::equals(const PatternMap& other) const {
break;
}
if ((otherElem == nullptr) || (myElem == nullptr)) {
- return FALSE;
+ return false;
}
if ( (myElem->basePattern != otherElem->basePattern) ||
(myElem->pattern != otherElem->pattern) ) {
- return FALSE;
+ return false;
}
if ((myElem->skeleton.getAlias() != otherElem->skeleton.getAlias()) &&
!myElem->skeleton->equals(*(otherElem->skeleton))) {
- return FALSE;
+ return false;
}
myElem = myElem->next.getAlias();
otherElem = otherElem->next.getAlias();
}
}
- return TRUE;
+ return true;
}
// find any key existing in the mapping table already.
-// return TRUE if there is an existing key, otherwise return FALSE.
+// return true if there is an existing key, otherwise return false.
PtnElem*
PatternMap::getDuplicateElem(
const UnicodeString &basePattern,
@@ -2173,10 +2268,10 @@ PatternMap::getDuplicateElem(
}
do {
if ( basePattern.compare(curElem->basePattern)==0 ) {
- UBool isEqual = TRUE;
+ UBool isEqual = true;
for (int32_t i = 0; i < UDATPG_FIELD_COUNT; ++i) {
if (curElem->skeleton->type[i] != skeleton.type[i] ) {
- isEqual = FALSE;
+ isEqual = false;
break;
}
}
@@ -2192,7 +2287,7 @@ PatternMap::getDuplicateElem(
} // PatternMap::getDuplicateElem
-DateTimeMatcher::DateTimeMatcher(void) {
+DateTimeMatcher::DateTimeMatcher() {
}
DateTimeMatcher::~DateTimeMatcher() {}
@@ -2221,7 +2316,7 @@ DateTimeMatcher::set(const UnicodeString& pattern, FormatParser* fp, PtnSkeleton
}
skeletonResult.original.clear();
skeletonResult.baseOriginal.clear();
- skeletonResult.addedDefaultDayPeriod = FALSE;
+ skeletonResult.addedDefaultDayPeriod = false;
fp->set(pattern);
for (i=0; i < fp->itemNumber; i++) {
@@ -2240,7 +2335,7 @@ DateTimeMatcher::set(const UnicodeString& pattern, FormatParser* fp, PtnSkeleton
const dtTypeElem *row = &dtTypes[canonicalIndex];
int32_t field = row->field;
skeletonResult.original.populate(field, value);
- UChar repeatChar = row->patternChar;
+ char16_t repeatChar = row->patternChar;
int32_t repeatCount = row->minLen;
skeletonResult.baseOriginal.populate(field, repeatChar, repeatCount);
int16_t subField = row->type;
@@ -2289,7 +2384,7 @@ DateTimeMatcher::set(const UnicodeString& pattern, FormatParser* fp, PtnSkeleton
skeletonResult.original.populate(UDATPG_DAYPERIOD_FIELD, dtTypes[i].patternChar, dtTypes[i].minLen);
skeletonResult.baseOriginal.populate(UDATPG_DAYPERIOD_FIELD, dtTypes[i].patternChar, dtTypes[i].minLen);
skeletonResult.type[UDATPG_DAYPERIOD_FIELD] = dtTypes[i].type;
- skeletonResult.addedDefaultDayPeriod = TRUE;
+ skeletonResult.addedDefaultDayPeriod = true;
break;
}
}
@@ -2357,7 +2452,7 @@ DateTimeMatcher::copyFrom() {
UBool
DateTimeMatcher::equals(const DateTimeMatcher* other) const {
- if (other==nullptr) { return FALSE; }
+ if (other==nullptr) { return false; }
return skeleton.original == other->skeleton.original;
}
@@ -2398,7 +2493,7 @@ FormatParser::setTokens(const UnicodeString& pattern, int32_t startPos, int32_t
}
// check the current char is between A-Z or a-z
do {
- UChar c=pattern.charAt(curLoc);
+ char16_t c=pattern.charAt(curLoc);
if ( (c>=CAP_A && c<=CAP_Z) || (c>=LOW_A && c<=LOW_Z) ) {
curLoc++;
}
@@ -2442,7 +2537,7 @@ FormatParser::getCanonicalIndex(const UnicodeString& s, UBool strict) {
if (len == 0) {
return -1;
}
- UChar ch = s.charAt(0);
+ char16_t ch = s.charAt(0);
// Verify that all are the same character.
for (int32_t l = 1; l < len; l++) {
@@ -2510,16 +2605,16 @@ FormatParser::getQuoteLiteral(UnicodeString& quote, int32_t *itemIndex) {
UBool
FormatParser::isPatternSeparator(const UnicodeString& field) const {
for (int32_t i=0; i<field.length(); ++i ) {
- UChar c= field.charAt(i);
+ char16_t c= field.charAt(i);
if ( (c==SINGLE_QUOTE) || (c==BACKSLASH) || (c==SPACE) || (c==COLON) ||
(c==QUOTATION_MARK) || (c==COMMA) || (c==HYPHEN) ||(items[i].charAt(0)==DOT) ) {
continue;
}
else {
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
DistanceInfo::~DistanceInfo() {}
@@ -2561,12 +2656,12 @@ PatternMapIterator::hasNext() const {
PtnElem *curPtr = nodePtr;
if (patternMap==nullptr) {
- return FALSE;
+ return false;
}
while ( headIndex < MAX_PATTERN_ENTRIES ) {
if ( curPtr != nullptr ) {
if ( curPtr->next != nullptr ) {
- return TRUE;
+ return true;
}
else {
headIndex++;
@@ -2576,7 +2671,7 @@ PatternMapIterator::hasNext() const {
}
else {
if ( patternMap->boot[headIndex] != nullptr ) {
- return TRUE;
+ return true;
}
else {
headIndex++;
@@ -2584,7 +2679,7 @@ PatternMapIterator::hasNext() const {
}
}
}
- return FALSE;
+ return false;
}
DateTimeMatcher&
@@ -2642,7 +2737,7 @@ void SkeletonFields::clearField(int32_t field) {
lengths[field] = 0;
}
-UChar SkeletonFields::getFieldChar(int32_t field) const {
+char16_t SkeletonFields::getFieldChar(int32_t field) const {
return chars[field];
}
@@ -2654,7 +2749,7 @@ void SkeletonFields::populate(int32_t field, const UnicodeString& value) {
populate(field, value.charAt(0), value.length());
}
-void SkeletonFields::populate(int32_t field, UChar ch, int32_t length) {
+void SkeletonFields::populate(int32_t field, char16_t ch, int32_t length) {
chars[field] = (int8_t) ch;
lengths[field] = (int8_t) length;
}
@@ -2671,7 +2766,7 @@ UnicodeString& SkeletonFields::appendTo(UnicodeString& string) const {
}
UnicodeString& SkeletonFields::appendFieldTo(int32_t field, UnicodeString& string) const {
- UChar ch(chars[field]);
+ char16_t ch(chars[field]);
int32_t length = (int32_t) lengths[field];
for (int32_t i=0; i<length; i++) {
@@ -2680,7 +2775,7 @@ UnicodeString& SkeletonFields::appendFieldTo(int32_t field, UnicodeString& strin
return string;
}
-UChar SkeletonFields::getFirstChar() const {
+char16_t SkeletonFields::getFirstChar() const {
for (int32_t i = 0; i < UDATPG_FIELD_COUNT; ++i) {
if (lengths[i] != 0) {
return chars[i];
@@ -2691,7 +2786,7 @@ UChar SkeletonFields::getFirstChar() const {
PtnSkeleton::PtnSkeleton()
- : addedDefaultDayPeriod(FALSE) {
+ : addedDefaultDayPeriod(false) {
}
PtnSkeleton::PtnSkeleton(const PtnSkeleton& other) {
@@ -2744,7 +2839,7 @@ PtnSkeleton::getBaseSkeleton() const {
return result;
}
-UChar
+char16_t
PtnSkeleton::getFirstChar() const {
return baseOriginal.getFirstChar();
}
@@ -2788,16 +2883,17 @@ DTSkeletonEnumeration::DTSkeletonEnumeration(PatternMap& patternMap, dtStrEnum t
break;
}
if ( !isCanonicalItem(s) ) {
- LocalPointer<UnicodeString> newElem(new UnicodeString(s), status);
+ LocalPointer<UnicodeString> newElem(s.clone(), status);
if (U_FAILURE(status)) {
return;
}
- fSkeletons->addElementX(newElem.getAlias(), status);
+ fSkeletons->addElement(newElem.getAlias(), status);
if (U_FAILURE(status)) {
fSkeletons.adoptInstead(nullptr);
return;
}
- newElem.orphan(); // fSkeletons vector now owns the UnicodeString.
+ newElem.orphan(); // fSkeletons vector now owns the UnicodeString (although it
+ // does not use a deleter function to manage the ownership).
}
curElem = curElem->next.getAlias();
}
@@ -2828,14 +2924,14 @@ DTSkeletonEnumeration::count(UErrorCode& /*status*/) const {
UBool
DTSkeletonEnumeration::isCanonicalItem(const UnicodeString& item) {
if ( item.length() != 1 ) {
- return FALSE;
+ return false;
}
for (int32_t i=0; i<UDATPG_FIELD_COUNT; ++i) {
if (item.charAt(0)==Canonical_Items[i]) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
DTSkeletonEnumeration::~DTSkeletonEnumeration() {
@@ -2865,12 +2961,13 @@ DTRedundantEnumeration::add(const UnicodeString& pattern, UErrorCode& status) {
if (U_FAILURE(status)) {
return;
}
- fPatterns->addElementX(newElem.getAlias(), status);
+ fPatterns->addElement(newElem.getAlias(), status);
if (U_FAILURE(status)) {
fPatterns.adoptInstead(nullptr);
return;
}
- newElem.orphan(); // fPatterns now owns the string.
+ newElem.orphan(); // fPatterns now owns the string, although a UVector
+ // deleter function is not used to manage that ownership.
}
const UnicodeString*
@@ -2894,14 +2991,14 @@ DTRedundantEnumeration::count(UErrorCode& /*status*/) const {
UBool
DTRedundantEnumeration::isCanonicalItem(const UnicodeString& item) const {
if ( item.length() != 1 ) {
- return FALSE;
+ return false;
}
for (int32_t i=0; i<UDATPG_FIELD_COUNT; ++i) {
if (item.charAt(0)==Canonical_Items[i]) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
DTRedundantEnumeration::~DTRedundantEnumeration() {
diff --git a/contrib/libs/icu/i18n/dtptngen_impl.h b/contrib/libs/icu/i18n/dtptngen_impl.h
index 5caae11654..74fe925b2f 100644
--- a/contrib/libs/icu/i18n/dtptngen_impl.h
+++ b/contrib/libs/icu/i18n/dtptngen_impl.h
@@ -32,66 +32,66 @@
#define EXTRA_FIELD 0x10000
#define MISSING_FIELD 0x1000
#define MAX_STRING_ENUMERATION 200
-#define SINGLE_QUOTE ((UChar)0x0027)
-#define FORWARDSLASH ((UChar)0x002F)
-#define BACKSLASH ((UChar)0x005C)
-#define SPACE ((UChar)0x0020)
-#define QUOTATION_MARK ((UChar)0x0022)
-#define ASTERISK ((UChar)0x002A)
-#define PLUSSITN ((UChar)0x002B)
-#define COMMA ((UChar)0x002C)
-#define HYPHEN ((UChar)0x002D)
-#define DOT ((UChar)0x002E)
-#define COLON ((UChar)0x003A)
-#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_H ((UChar)0x0048)
-#define CAP_J ((UChar)0x004A)
-#define CAP_K ((UChar)0x004B)
-#define CAP_L ((UChar)0x004C)
-#define CAP_M ((UChar)0x004D)
-#define CAP_O ((UChar)0x004F)
-#define CAP_Q ((UChar)0x0051)
-#define CAP_S ((UChar)0x0053)
-#define CAP_T ((UChar)0x0054)
-#define CAP_U ((UChar)0x0055)
-#define CAP_V ((UChar)0x0056)
-#define CAP_W ((UChar)0x0057)
-#define CAP_X ((UChar)0x0058)
-#define CAP_Y ((UChar)0x0059)
-#define CAP_Z ((UChar)0x005A)
-#define LOWLINE ((UChar)0x005F)
-#define LOW_A ((UChar)0x0061)
-#define LOW_B ((UChar)0x0062)
-#define LOW_C ((UChar)0x0063)
-#define LOW_D ((UChar)0x0064)
-#define LOW_E ((UChar)0x0065)
-#define LOW_F ((UChar)0x0066)
-#define LOW_G ((UChar)0x0067)
-#define LOW_H ((UChar)0x0068)
-#define LOW_I ((UChar)0x0069)
-#define LOW_J ((UChar)0x006A)
-#define LOW_K ((UChar)0x006B)
-#define LOW_L ((UChar)0x006C)
-#define LOW_M ((UChar)0x006D)
-#define LOW_N ((UChar)0x006E)
-#define LOW_O ((UChar)0x006F)
-#define LOW_P ((UChar)0x0070)
-#define LOW_Q ((UChar)0x0071)
-#define LOW_R ((UChar)0x0072)
-#define LOW_S ((UChar)0x0073)
-#define LOW_T ((UChar)0x0074)
-#define LOW_U ((UChar)0x0075)
-#define LOW_V ((UChar)0x0076)
-#define LOW_W ((UChar)0x0077)
-#define LOW_X ((UChar)0x0078)
-#define LOW_Y ((UChar)0x0079)
-#define LOW_Z ((UChar)0x007A)
+#define SINGLE_QUOTE ((char16_t)0x0027)
+#define FORWARDSLASH ((char16_t)0x002F)
+#define BACKSLASH ((char16_t)0x005C)
+#define SPACE ((char16_t)0x0020)
+#define QUOTATION_MARK ((char16_t)0x0022)
+#define ASTERISK ((char16_t)0x002A)
+#define PLUSSITN ((char16_t)0x002B)
+#define COMMA ((char16_t)0x002C)
+#define HYPHEN ((char16_t)0x002D)
+#define DOT ((char16_t)0x002E)
+#define COLON ((char16_t)0x003A)
+#define CAP_A ((char16_t)0x0041)
+#define CAP_B ((char16_t)0x0042)
+#define CAP_C ((char16_t)0x0043)
+#define CAP_D ((char16_t)0x0044)
+#define CAP_E ((char16_t)0x0045)
+#define CAP_F ((char16_t)0x0046)
+#define CAP_G ((char16_t)0x0047)
+#define CAP_H ((char16_t)0x0048)
+#define CAP_J ((char16_t)0x004A)
+#define CAP_K ((char16_t)0x004B)
+#define CAP_L ((char16_t)0x004C)
+#define CAP_M ((char16_t)0x004D)
+#define CAP_O ((char16_t)0x004F)
+#define CAP_Q ((char16_t)0x0051)
+#define CAP_S ((char16_t)0x0053)
+#define CAP_T ((char16_t)0x0054)
+#define CAP_U ((char16_t)0x0055)
+#define CAP_V ((char16_t)0x0056)
+#define CAP_W ((char16_t)0x0057)
+#define CAP_X ((char16_t)0x0058)
+#define CAP_Y ((char16_t)0x0059)
+#define CAP_Z ((char16_t)0x005A)
+#define LOWLINE ((char16_t)0x005F)
+#define LOW_A ((char16_t)0x0061)
+#define LOW_B ((char16_t)0x0062)
+#define LOW_C ((char16_t)0x0063)
+#define LOW_D ((char16_t)0x0064)
+#define LOW_E ((char16_t)0x0065)
+#define LOW_F ((char16_t)0x0066)
+#define LOW_G ((char16_t)0x0067)
+#define LOW_H ((char16_t)0x0068)
+#define LOW_I ((char16_t)0x0069)
+#define LOW_J ((char16_t)0x006A)
+#define LOW_K ((char16_t)0x006B)
+#define LOW_L ((char16_t)0x006C)
+#define LOW_M ((char16_t)0x006D)
+#define LOW_N ((char16_t)0x006E)
+#define LOW_O ((char16_t)0x006F)
+#define LOW_P ((char16_t)0x0070)
+#define LOW_Q ((char16_t)0x0071)
+#define LOW_R ((char16_t)0x0072)
+#define LOW_S ((char16_t)0x0073)
+#define LOW_T ((char16_t)0x0074)
+#define LOW_U ((char16_t)0x0075)
+#define LOW_V ((char16_t)0x0076)
+#define LOW_W ((char16_t)0x0077)
+#define LOW_X ((char16_t)0x0078)
+#define LOW_Y ((char16_t)0x0079)
+#define LOW_Z ((char16_t)0x007A)
#define DT_NARROW -0x101
#define DT_SHORTER -0x102
#define DT_SHORT -0x103
@@ -111,7 +111,7 @@ typedef enum dtStrEnum {
}dtStrEnum;
typedef struct dtTypeElem {
- UChar patternChar;
+ char16_t patternChar;
UDateTimePatternField field;
int16_t type;
int16_t minLen;
@@ -126,14 +126,14 @@ public:
void clear();
void copyFrom(const SkeletonFields& other);
void clearField(int32_t field);
- UChar getFieldChar(int32_t field) const;
+ char16_t getFieldChar(int32_t field) const;
int32_t getFieldLength(int32_t field) const;
void populate(int32_t field, const UnicodeString& value);
- void populate(int32_t field, UChar repeatChar, int32_t repeatCount);
+ void populate(int32_t field, char16_t repeatChar, int32_t repeatCount);
UBool isFieldEmpty(int32_t field) const;
UnicodeString& appendTo(UnicodeString& string) const;
UnicodeString& appendFieldTo(int32_t field, UnicodeString& string) const;
- UChar getFirstChar() const;
+ char16_t getFirstChar() const;
inline bool operator==(const SkeletonFields& other) const;
inline bool operator!=(const SkeletonFields& other) const;
@@ -165,7 +165,7 @@ public:
UBool equals(const PtnSkeleton& other) const;
UnicodeString getSkeleton() const;
UnicodeString getBaseSkeleton() const;
- UChar getFirstChar() const;
+ char16_t getFirstChar() const;
// TODO: Why is this virtual, as well as the other destructors in this file? We don't want
// vtables when we don't use class objects polymorphically.
@@ -252,7 +252,7 @@ public:
const UnicodeString* getPatternFromBasePattern(const UnicodeString& basePattern, UBool& skeletonWasSpecified) const;
const UnicodeString* getPatternFromSkeleton(const PtnSkeleton& skeleton, const PtnSkeleton** specifiedSkeletonPtr = 0) const;
void copyFrom(const PatternMap& other, UErrorCode& status);
- PtnElem* getHeader(UChar baseChar) const;
+ PtnElem* getHeader(char16_t baseChar) const;
UBool equals(const PatternMap& other) const;
private:
UBool isDupAllowed;
@@ -278,8 +278,8 @@ class DTSkeletonEnumeration : public StringEnumeration {
public:
DTSkeletonEnumeration(PatternMap& patternMap, dtStrEnum type, UErrorCode& status);
virtual ~DTSkeletonEnumeration();
- static UClassID U_EXPORT2 getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID U_EXPORT2 getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
virtual const UnicodeString* snext(UErrorCode& status) override;
virtual void reset(UErrorCode& status) override;
virtual int32_t count(UErrorCode& status) const override;
@@ -293,8 +293,8 @@ class DTRedundantEnumeration : public StringEnumeration {
public:
DTRedundantEnumeration();
virtual ~DTRedundantEnumeration();
- static UClassID U_EXPORT2 getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID U_EXPORT2 getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
virtual const UnicodeString* snext(UErrorCode& status) override;
virtual void reset(UErrorCode& status) override;
virtual int32_t count(UErrorCode& status) const override;
diff --git a/contrib/libs/icu/i18n/dtrule.cpp b/contrib/libs/icu/i18n/dtrule.cpp
index 63949b63aa..7322cbfdad 100644
--- a/contrib/libs/icu/i18n/dtrule.cpp
+++ b/contrib/libs/icu/i18n/dtrule.cpp
@@ -100,37 +100,37 @@ DateTimeRule::operator!=(const DateTimeRule& that) const {
}
DateTimeRule::DateRuleType
-DateTimeRule::getDateRuleType(void) const {
+DateTimeRule::getDateRuleType() const {
return fDateRuleType;
}
DateTimeRule::TimeRuleType
-DateTimeRule::getTimeRuleType(void) const {
+DateTimeRule::getTimeRuleType() const {
return fTimeRuleType;
}
int32_t
-DateTimeRule::getRuleMonth(void) const {
+DateTimeRule::getRuleMonth() const {
return fMonth;
}
int32_t
-DateTimeRule::getRuleDayOfMonth(void) const {
+DateTimeRule::getRuleDayOfMonth() const {
return fDayOfMonth;
}
int32_t
-DateTimeRule::getRuleDayOfWeek(void) const {
+DateTimeRule::getRuleDayOfWeek() const {
return fDayOfWeek;
}
int32_t
-DateTimeRule::getRuleWeekInMonth(void) const {
+DateTimeRule::getRuleWeekInMonth() const {
return fWeekInMonth;
}
int32_t
-DateTimeRule::getRuleMillisInDay(void) const {
+DateTimeRule::getRuleMillisInDay() const {
return fMillisInDay;
}
diff --git a/contrib/libs/icu/i18n/erarules.cpp b/contrib/libs/icu/i18n/erarules.cpp
index e375740bd6..65405bb84a 100644
--- a/contrib/libs/icu/i18n/erarules.cpp
+++ b/contrib/libs/icu/i18n/erarules.cpp
@@ -31,8 +31,8 @@ static const int32_t DAY_MASK = 0x000000FF;
static const int32_t MAX_INT32 = 0x7FFFFFFF;
static const int32_t MIN_INT32 = 0xFFFFFFFF;
-static const UChar VAL_FALSE[] = {0x66, 0x61, 0x6c, 0x73, 0x65}; // "false"
-static const UChar VAL_FALSE_LEN = 5;
+static const char16_t VAL_FALSE[] = {0x66, 0x61, 0x6c, 0x73, 0x65}; // "false"
+static const char16_t VAL_FALSE_LEN = 5;
static UBool isSet(int startDate) {
return startDate != 0;
@@ -54,7 +54,7 @@ static UBool isValidRuleStartDate(int32_t year, int32_t month, int32_t day) {
* @return an encoded date.
*/
static int32_t encodeDate(int32_t year, int32_t month, int32_t day) {
- return year << 16 | month << 8 | day;
+ return (int32_t)((uint32_t)year << 16) | month << 8 | day;
}
static void decodeDate(int32_t encodedDate, int32_t (&fields)[3]) {
@@ -156,8 +156,8 @@ EraRules* EraRules::createInstance(const char *calType, UBool includeTentativeEr
return nullptr;
}
- UBool hasName = TRUE;
- UBool hasEnd = TRUE;
+ UBool hasName = true;
+ UBool hasEnd = true;
int32_t len;
while (ures_hasNext(eraRuleRes.getAlias())) {
LocalUResourceBundlePointer res(ures_getNextResource(eraRuleRes.getAlias(), nullptr, &status));
@@ -176,12 +176,12 @@ EraRules* EraRules::createInstance(const char *calType, UBool includeTentativeEr
}
startDates[eraIdx] = encodeDate(fields[0], fields[1], fields[2]);
} else if (uprv_strcmp(key, "named") == 0) {
- const UChar *val = ures_getString(res.getAlias(), &len, &status);
+ const char16_t *val = ures_getString(res.getAlias(), &len, &status);
if (u_strncmp(val, VAL_FALSE, VAL_FALSE_LEN) == 0) {
- hasName = FALSE;
+ hasName = false;
}
} else if (uprv_strcmp(key, "end") == 0) {
- hasEnd = TRUE;
+ hasEnd = true;
}
}
@@ -300,7 +300,7 @@ void EraRules::initCurrentEra() {
// If we failed to create the default time zone, we are in a bad state and don't
// really have many options. Carry on using UTC millis as a fallback.
if (zone != nullptr) {
- zone->getOffset(localMillis, FALSE, rawOffset, dstOffset, ec);
+ zone->getOffset(localMillis, false, rawOffset, dstOffset, ec);
delete zone;
localMillis += (rawOffset + dstOffset);
}
diff --git a/contrib/libs/icu/i18n/esctrn.cpp b/contrib/libs/icu/i18n/esctrn.cpp
index ba0e4c2c7b..24fa6f58e4 100644
--- a/contrib/libs/icu/i18n/esctrn.cpp
+++ b/contrib/libs/icu/i18n/esctrn.cpp
@@ -20,14 +20,14 @@
U_NAMESPACE_BEGIN
-static const UChar UNIPRE[] = {85,43,0}; // "U+"
-static const UChar BS_u[] = {92,117,0}; // "\\u"
-static const UChar BS_U[] = {92,85,0}; // "\\U"
-static const UChar XMLPRE[] = {38,35,120,0}; // "&#x"
-static const UChar XML10PRE[] = {38,35,0}; // "&#"
-static const UChar PERLPRE[] = {92,120,123,0}; // "\\x{"
-static const UChar SEMI[] = {59,0}; // ";"
-static const UChar RBRACE[] = {125,0}; // "}"
+static const char16_t UNIPRE[] = {85,43,0}; // "U+"
+static const char16_t BS_u[] = {92,117,0}; // "\\u"
+static const char16_t BS_U[] = {92,85,0}; // "\\U"
+static const char16_t XMLPRE[] = {38,35,120,0}; // "&#x"
+static const char16_t XML10PRE[] = {38,35,0}; // "&#"
+static const char16_t PERLPRE[] = {92,120,123,0}; // "\\x{"
+static const char16_t SEMI[] = {59,0}; // ";"
+static const char16_t RBRACE[] = {125,0}; // "}"
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(EscapeTransliterator)
@@ -36,28 +36,28 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(EscapeTransliterator)
*/
static Transliterator* _createEscUnicode(const UnicodeString& ID, Transliterator::Token /*context*/) {
// Unicode: "U+10FFFF" hex, min=4, max=6
- return new EscapeTransliterator(ID, UnicodeString(TRUE, UNIPRE, 2), UnicodeString(), 16, 4, TRUE, NULL);
+ return new EscapeTransliterator(ID, UnicodeString(true, UNIPRE, 2), UnicodeString(), 16, 4, true, nullptr);
}
static Transliterator* _createEscJava(const UnicodeString& ID, Transliterator::Token /*context*/) {
// Java: "\\uFFFF" hex, min=4, max=4
- return new EscapeTransliterator(ID, UnicodeString(TRUE, BS_u, 2), UnicodeString(), 16, 4, FALSE, NULL);
+ return new EscapeTransliterator(ID, UnicodeString(true, BS_u, 2), UnicodeString(), 16, 4, false, nullptr);
}
static Transliterator* _createEscC(const UnicodeString& ID, Transliterator::Token /*context*/) {
// C: "\\uFFFF" hex, min=4, max=4; \\U0010FFFF hex, min=8, max=8
- return new EscapeTransliterator(ID, UnicodeString(TRUE, BS_u, 2), UnicodeString(), 16, 4, TRUE,
- new EscapeTransliterator(UnicodeString(), UnicodeString(TRUE, BS_U, 2), UnicodeString(), 16, 8, TRUE, NULL));
+ return new EscapeTransliterator(ID, UnicodeString(true, BS_u, 2), UnicodeString(), 16, 4, true,
+ new EscapeTransliterator(UnicodeString(), UnicodeString(true, BS_U, 2), UnicodeString(), 16, 8, true, nullptr));
}
static Transliterator* _createEscXML(const UnicodeString& ID, Transliterator::Token /*context*/) {
// XML: "&#x10FFFF;" hex, min=1, max=6
- return new EscapeTransliterator(ID, UnicodeString(TRUE, XMLPRE, 3), UnicodeString(SEMI[0]), 16, 1, TRUE, NULL);
+ return new EscapeTransliterator(ID, UnicodeString(true, XMLPRE, 3), UnicodeString(SEMI[0]), 16, 1, true, nullptr);
}
static Transliterator* _createEscXML10(const UnicodeString& ID, Transliterator::Token /*context*/) {
// XML10: "&1114111;" dec, min=1, max=7 (not really "Any-Hex")
- return new EscapeTransliterator(ID, UnicodeString(TRUE, XML10PRE, 2), UnicodeString(SEMI[0]), 10, 1, TRUE, NULL);
+ return new EscapeTransliterator(ID, UnicodeString(true, XML10PRE, 2), UnicodeString(SEMI[0]), 10, 1, true, nullptr);
}
static Transliterator* _createEscPerl(const UnicodeString& ID, Transliterator::Token /*context*/) {
// Perl: "\\x{263A}" hex, min=1, max=6
- return new EscapeTransliterator(ID, UnicodeString(TRUE, PERLPRE, 3), UnicodeString(RBRACE[0]), 16, 1, TRUE, NULL);
+ return new EscapeTransliterator(ID, UnicodeString(true, PERLPRE, 3), UnicodeString(RBRACE[0]), 16, 1, true, nullptr);
}
/**
@@ -91,7 +91,7 @@ EscapeTransliterator::EscapeTransliterator(const UnicodeString& newID,
int32_t _radix, int32_t _minDigits,
UBool _grokSupplementals,
EscapeTransliterator* adoptedSupplementalHandler) :
- Transliterator(newID, NULL)
+ Transliterator(newID, nullptr)
{
this->prefix = _prefix;
this->suffix = _suffix;
@@ -112,7 +112,7 @@ EscapeTransliterator::EscapeTransliterator(const EscapeTransliterator& o) :
minDigits(o.minDigits),
grokSupplementals(o.grokSupplementals) {
supplementalHandler = (o.supplementalHandler != 0) ?
- new EscapeTransliterator(*o.supplementalHandler) : NULL;
+ new EscapeTransliterator(*o.supplementalHandler) : nullptr;
}
EscapeTransliterator::~EscapeTransliterator() {
@@ -139,24 +139,24 @@ void EscapeTransliterator::handleTransliterate(Replaceable& text,
UnicodeString buf(prefix);
int32_t prefixLen = prefix.length();
- UBool redoPrefix = FALSE;
+ UBool redoPrefix = false;
while (start < limit) {
int32_t c = grokSupplementals ? text.char32At(start) : text.charAt(start);
int32_t charLen = grokSupplementals ? U16_LENGTH(c) : 1;
- if ((c & 0xFFFF0000) != 0 && supplementalHandler != NULL) {
+ if ((c & 0xFFFF0000) != 0 && supplementalHandler != nullptr) {
buf.truncate(0);
buf.append(supplementalHandler->prefix);
ICU_Utility::appendNumber(buf, c, supplementalHandler->radix,
supplementalHandler->minDigits);
buf.append(supplementalHandler->suffix);
- redoPrefix = TRUE;
+ redoPrefix = true;
} else {
if (redoPrefix) {
buf.truncate(0);
buf.append(prefix);
- redoPrefix = FALSE;
+ redoPrefix = false;
} else {
buf.truncate(prefixLen);
}
diff --git a/contrib/libs/icu/i18n/ethpccal.cpp b/contrib/libs/icu/i18n/ethpccal.cpp
index 7c7c0ba37b..be4010843a 100644
--- a/contrib/libs/icu/i18n/ethpccal.cpp
+++ b/contrib/libs/icu/i18n/ethpccal.cpp
@@ -19,6 +19,7 @@
U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(EthiopicCalendar)
+UOBJECT_DEFINE_RTTI_IMPLEMENTATION(EthiopicAmeteAlemCalendar)
//static const int32_t JD_EPOCH_OFFSET_AMETE_ALEM = -285019;
static const int32_t JD_EPOCH_OFFSET_AMETE_MIHRET = 1723856;
@@ -29,16 +30,8 @@ static const int32_t AMETE_MIHRET_DELTA = 5500; // 5501 - 1 (Amete Alem 5501 = A
//-------------------------------------------------------------------------
EthiopicCalendar::EthiopicCalendar(const Locale& aLocale,
- UErrorCode& success,
- EEraType type /*= AMETE_MIHRET_ERA*/)
-: CECalendar(aLocale, success),
- eraType(type)
-{
-}
-
-EthiopicCalendar::EthiopicCalendar(const EthiopicCalendar& other)
-: CECalendar(other),
- eraType(other.eraType)
+ UErrorCode& success)
+: CECalendar(aLocale, success)
{
}
@@ -55,24 +48,9 @@ EthiopicCalendar::clone() const
const char *
EthiopicCalendar::getType() const
{
- if (isAmeteAlemEra()) {
- return "ethiopic-amete-alem";
- }
return "ethiopic";
}
-void
-EthiopicCalendar::setAmeteAlemEra(UBool onOff)
-{
- eraType = onOff ? AMETE_ALEM_ERA : AMETE_MIHRET_ERA;
-}
-
-UBool
-EthiopicCalendar::isAmeteAlemEra() const
-{
- return (eraType == AMETE_ALEM_ERA);
-}
-
//-------------------------------------------------------------------------
// Calendar framework
//-------------------------------------------------------------------------
@@ -82,58 +60,46 @@ EthiopicCalendar::handleGetExtendedYear()
{
// Ethiopic calendar uses EXTENDED_YEAR aligned to
// Amelete Hihret year always.
- int32_t eyear;
if (newerField(UCAL_EXTENDED_YEAR, UCAL_YEAR) == UCAL_EXTENDED_YEAR) {
- eyear = internalGet(UCAL_EXTENDED_YEAR, 1); // Default to year 1
- } else if (isAmeteAlemEra()) {
- eyear = internalGet(UCAL_YEAR, 1 + AMETE_MIHRET_DELTA)
- - AMETE_MIHRET_DELTA; // Default to year 1 of Amelete Mihret
- } else {
- // The year defaults to the epoch start, the era to AMETE_MIHRET
- int32_t era = internalGet(UCAL_ERA, AMETE_MIHRET);
- if (era == AMETE_MIHRET) {
- eyear = internalGet(UCAL_YEAR, 1); // Default to year 1
- } else {
- eyear = internalGet(UCAL_YEAR, 1) - AMETE_MIHRET_DELTA;
- }
+ return internalGet(UCAL_EXTENDED_YEAR, 1); // Default to year 1
+ }
+ // The year defaults to the epoch start, the era to AMETE_MIHRET
+ if (internalGet(UCAL_ERA, AMETE_MIHRET) == AMETE_MIHRET) {
+ return internalGet(UCAL_YEAR, 1); // Default to year 1
}
- return eyear;
+ return internalGet(UCAL_YEAR, 1) - AMETE_MIHRET_DELTA;
}
void
EthiopicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &/*status*/)
{
- int32_t eyear, month, day, era, year;
+ int32_t eyear, month, day;
jdToCE(julianDay, getJDEpochOffset(), eyear, month, day);
- if (isAmeteAlemEra()) {
- era = AMETE_ALEM;
- year = eyear + AMETE_MIHRET_DELTA;
- } else {
- if (eyear > 0) {
- era = AMETE_MIHRET;
- year = eyear;
- } else {
- era = AMETE_ALEM;
- year = eyear + AMETE_MIHRET_DELTA;
- }
- }
-
internalSet(UCAL_EXTENDED_YEAR, eyear);
- internalSet(UCAL_ERA, era);
- internalSet(UCAL_YEAR, year);
+ internalSet(UCAL_ERA, (eyear > 0) ? AMETE_MIHRET : AMETE_ALEM);
+ internalSet(UCAL_YEAR, (eyear > 0) ? eyear : (eyear + AMETE_MIHRET_DELTA));
internalSet(UCAL_MONTH, month);
+ internalSet(UCAL_ORDINAL_MONTH, month);
internalSet(UCAL_DATE, day);
internalSet(UCAL_DAY_OF_YEAR, (30 * month) + day);
}
-int32_t
-EthiopicCalendar::handleGetLimit(UCalendarDateFields field, ELimitType limitType) const
+constexpr uint32_t kEthiopicRelatedYearDiff = 8;
+
+int32_t EthiopicCalendar::getRelatedYear(UErrorCode &status) const
{
- if (isAmeteAlemEra() && field == UCAL_ERA) {
- return 0; // Only one era in this mode, era is always 0
+ int32_t year = get(UCAL_EXTENDED_YEAR, status);
+ if (U_FAILURE(status)) {
+ return 0;
}
- return CECalendar::handleGetLimit(field, limitType);
+ return year + kEthiopicRelatedYearDiff;
+}
+
+void EthiopicCalendar::setRelatedYear(int32_t year)
+{
+ // set extended year
+ set(UCAL_EXTENDED_YEAR, year - kEthiopicRelatedYearDiff);
}
/**
@@ -143,7 +109,7 @@ EthiopicCalendar::handleGetLimit(UCalendarDateFields field, ELimitType limitType
*/
static UDate gSystemDefaultCenturyStart = DBL_MIN;
static int32_t gSystemDefaultCenturyStartYear = -1;
-static icu::UInitOnce gSystemDefaultCenturyInit = U_INITONCE_INITIALIZER;
+static icu::UInitOnce gSystemDefaultCenturyInit {};
static void U_CALLCONV initializeSystemDefaultCentury()
{
@@ -173,9 +139,6 @@ EthiopicCalendar::defaultCenturyStartYear() const
{
// lazy-evaluate systemDefaultCenturyStartYear
umtx_initOnce(gSystemDefaultCenturyInit, &initializeSystemDefaultCentury);
- if (isAmeteAlemEra()) {
- return gSystemDefaultCenturyStartYear + AMETE_MIHRET_DELTA;
- }
return gSystemDefaultCenturyStartYear;
}
@@ -202,6 +165,95 @@ EthiopicCalendar::ethiopicToJD(int32_t year, int32_t month, int32_t date)
}
#endif
+//-------------------------------------------------------------------------
+// Constructors...
+//-------------------------------------------------------------------------
+
+EthiopicAmeteAlemCalendar::EthiopicAmeteAlemCalendar(const Locale& aLocale,
+ UErrorCode& success)
+: EthiopicCalendar(aLocale, success)
+{
+}
+
+EthiopicAmeteAlemCalendar::~EthiopicAmeteAlemCalendar()
+{
+}
+
+EthiopicAmeteAlemCalendar*
+EthiopicAmeteAlemCalendar::clone() const
+{
+ return new EthiopicAmeteAlemCalendar(*this);
+}
+
+//-------------------------------------------------------------------------
+// Calendar framework
+//-------------------------------------------------------------------------
+
+const char *
+EthiopicAmeteAlemCalendar::getType() const
+{
+ return "ethiopic-amete-alem";
+}
+
+int32_t
+EthiopicAmeteAlemCalendar::handleGetExtendedYear()
+{
+ // Ethiopic calendar uses EXTENDED_YEAR aligned to
+ // Amelete Hihret year always.
+ if (newerField(UCAL_EXTENDED_YEAR, UCAL_YEAR) == UCAL_EXTENDED_YEAR) {
+ return internalGet(UCAL_EXTENDED_YEAR, 1); // Default to year 1
+ }
+ return internalGet(UCAL_YEAR, 1 + AMETE_MIHRET_DELTA)
+ - AMETE_MIHRET_DELTA; // Default to year 1 of Amelete Mihret
+}
+
+void
+EthiopicAmeteAlemCalendar::handleComputeFields(int32_t julianDay, UErrorCode &/*status*/)
+{
+ int32_t eyear, month, day;
+ jdToCE(julianDay, getJDEpochOffset(), eyear, month, day);
+
+ internalSet(UCAL_EXTENDED_YEAR, eyear);
+ internalSet(UCAL_ERA, AMETE_ALEM);
+ internalSet(UCAL_YEAR, eyear + AMETE_MIHRET_DELTA);
+ internalSet(UCAL_MONTH, month);
+ internalSet(UCAL_ORDINAL_MONTH, month);
+ internalSet(UCAL_DATE, day);
+ internalSet(UCAL_DAY_OF_YEAR, (30 * month) + day);
+}
+
+int32_t
+EthiopicAmeteAlemCalendar::handleGetLimit(UCalendarDateFields field, ELimitType limitType) const
+{
+ if (field == UCAL_ERA) {
+ return 0; // Only one era in this mode, era is always 0
+ }
+ return EthiopicCalendar::handleGetLimit(field, limitType);
+}
+
+constexpr uint32_t kEthiopicAmeteAlemRelatedYearDiff = -5492;
+
+int32_t EthiopicAmeteAlemCalendar::getRelatedYear(UErrorCode &status) const
+{
+ int32_t year = get(UCAL_EXTENDED_YEAR, status);
+ if (U_FAILURE(status)) {
+ return 0;
+ }
+ return year + kEthiopicAmeteAlemRelatedYearDiff;
+}
+
+void EthiopicAmeteAlemCalendar::setRelatedYear(int32_t year)
+{
+ // set extended year
+ set(UCAL_EXTENDED_YEAR, year - kEthiopicAmeteAlemRelatedYearDiff);
+}
+
+int32_t
+EthiopicAmeteAlemCalendar::defaultCenturyStartYear() const
+{
+ return EthiopicCalendar::defaultCenturyStartYear() + AMETE_MIHRET_DELTA;
+}
+
U_NAMESPACE_END
#endif
diff --git a/contrib/libs/icu/i18n/ethpccal.h b/contrib/libs/icu/i18n/ethpccal.h
index 0cc5b6c535..1a5cd4f41a 100644
--- a/contrib/libs/icu/i18n/ethpccal.h
+++ b/contrib/libs/icu/i18n/ethpccal.h
@@ -27,15 +27,6 @@ class EthiopicCalendar : public CECalendar {
public:
/**
- * Calendar type - use Amete Alem era for all the time or not
- * @internal
- */
- enum EEraType {
- AMETE_MIHRET_ERA,
- AMETE_ALEM_ERA
- };
-
- /**
* Useful constants for EthiopicCalendar.
* @internal
*/
@@ -122,13 +113,13 @@ public:
* only use Amete Alem for all the time.
* @internal
*/
- EthiopicCalendar(const Locale& aLocale, UErrorCode& success, EEraType type = AMETE_MIHRET_ERA);
+ EthiopicCalendar(const Locale& aLocale, UErrorCode& success);
/**
* Copy Constructor
* @internal
*/
- EthiopicCalendar(const EthiopicCalendar& other);
+ EthiopicCalendar(const EthiopicCalendar& other) = default;
/**
* Destructor.
@@ -144,25 +135,25 @@ public:
virtual EthiopicCalendar* clone() const override;
/**
- * return the calendar type, "ethiopic"
+ * Return the calendar type, "ethiopic"
* @return calendar type
* @internal
*/
virtual const char * getType() const override;
/**
- * Set Alem or Mihret era.
- * @param onOff Set Amete Alem era if true, otherwise set Amete Mihret era.
+ * @return The related Gregorian year; will be obtained by modifying the value
+ * obtained by get from UCAL_EXTENDED_YEAR field
* @internal
*/
- void setAmeteAlemEra (UBool onOff);
+ virtual int32_t getRelatedYear(UErrorCode &status) const override;
/**
- * Return true if this calendar is set to the Amete Alem era.
- * @return true if set to the Amete Alem era.
+ * @param year The related Gregorian year to set; will be modified as necessary then
+ * set in UCAL_EXTENDED_YEAR field
* @internal
*/
- UBool isAmeteAlemEra() const;
+ virtual void setRelatedYear(int32_t year) override;
protected:
//-------------------------------------------------------------------------
@@ -171,6 +162,11 @@ protected:
/**
* Return the extended year defined by the current fields.
+ * This calendar uses both AMETE_ALEM and AMETE_MIHRET.
+ *
+ * EXTENDED_YEAR ERA YEAR
+ * 0 AMETE_ALEM 5500
+ * 1 AMETE_MIHRET 1
* @internal
*/
virtual int32_t handleGetExtendedYear() override;
@@ -182,12 +178,6 @@ protected:
virtual void handleComputeFields(int32_t julianDay, UErrorCode &status) override;
/**
- * Calculate the limit for a specified type of limit and field
- * @internal
- */
- virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const override;
-
- /**
* Returns the date of the start of the default century
* @return start of century - in milliseconds since epoch, 1970
* @internal
@@ -206,18 +196,6 @@ protected:
*/
virtual int32_t getJDEpochOffset() const override;
-private:
- /**
- * When eraType is AMETE_ALEM_ERA, then this calendar use only AMETE_ALEM
- * for the era. Otherwise (default), this calendar uses both AMETE_ALEM
- * and AMETE_MIHRET.
- *
- * EXTENDED_YEAR AMETE_ALEM_ERA AMETE_MIHRET_ERA
- * 0 Amete Alem 5500 Amete Alem 5500
- * 1 Amete Mihret 1 Amete Alem 5501
- */
- EEraType eraType;
-
public:
/**
* Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
@@ -229,7 +207,7 @@ public:
* same class ID. Objects of other classes have different class IDs.
* @internal
*/
- virtual UClassID getDynamicClassID(void) const override;
+ virtual UClassID getDynamicClassID() const override;
/**
* Return the class ID for this class. This is useful only for comparing to a return
@@ -242,7 +220,7 @@ public:
* @return The class ID for all objects of this class.
* @internal
*/
- U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
+ U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
#if 0
// We do not want to introduce this API in ICU4C.
@@ -266,6 +244,123 @@ public:
#endif
};
+/**
+ * Implement the Ethiopic Amete Alem calendar system.
+ * @internal
+ */
+class EthiopicAmeteAlemCalendar : public EthiopicCalendar {
+
+public:
+ /**
+ * Constructs a EthiopicAmeteAlemCalendar based on the current time in the default time zone
+ * with the given locale.
+ *
+ * @param aLocale The given locale.
+ * @param success Indicates the status of EthiopicCalendar object construction.
+ * Returns U_ZERO_ERROR if constructed successfully.
+ * @internal
+ */
+ EthiopicAmeteAlemCalendar(const Locale& aLocale, UErrorCode& success);
+
+ /**
+ * Copy Constructor
+ * @internal
+ */
+ EthiopicAmeteAlemCalendar(const EthiopicAmeteAlemCalendar& other) = default;
+
+ /**
+ * Destructor.
+ * @internal
+ */
+ virtual ~EthiopicAmeteAlemCalendar();
+
+ /**
+ * Create and return a polymorphic copy of this calendar.
+ * @return return a polymorphic copy of this calendar.
+ * @internal
+ */
+ virtual EthiopicAmeteAlemCalendar* clone() const override;
+
+ /**
+ * Return the calendar type, "ethiopic-amete-alem"
+ * @return calendar type
+ * @internal
+ */
+ virtual const char * getType() const override;
+
+ /**
+ * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
+ * override. This method is to implement a simple version of RTTI, since not all C++
+ * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
+ * this method.
+ *
+ * @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.
+ * @internal
+ */
+ virtual UClassID getDynamicClassID() const override;
+
+ /**
+ * Return the class ID for this class. This is useful only for comparing to a return
+ * value from getDynamicClassID(). For example:
+ *
+ * Base* polymorphic_pointer = createPolymorphicObject();
+ * if (polymorphic_pointer->getDynamicClassID() ==
+ * Derived::getStaticClassID()) ...
+ *
+ * @return The class ID for all objects of this class.
+ * @internal
+ */
+ U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
+
+ /**
+ * @return The related Gregorian year; will be obtained by modifying the value
+ * obtained by get from UCAL_EXTENDED_YEAR field
+ * @internal
+ */
+ virtual int32_t getRelatedYear(UErrorCode &status) const override;
+
+ /**
+ * @param year The related Gregorian year to set; will be modified as necessary then
+ * set in UCAL_EXTENDED_YEAR field
+ * @internal
+ */
+ virtual void setRelatedYear(int32_t year) override;
+
+protected:
+ //-------------------------------------------------------------------------
+ // Calendar framework
+ //-------------------------------------------------------------------------
+
+ /**
+ * Return the extended year defined by the current fields.
+ * This calendar use only AMETE_ALEM for the era.
+ *
+ * EXTENDED_YEAR ERA YEAR
+ * 0 AMETE_ALEM 5500
+ * 1 AMETE_ALEM 5501
+ * @internal
+ */
+ virtual int32_t handleGetExtendedYear() override;
+
+ /**
+ * Compute fields from the JD
+ * @internal
+ */
+ virtual void handleComputeFields(int32_t julianDay, UErrorCode &status) override;
+
+ /**
+ * Calculate the limit for a specified type of limit and field
+ * @internal
+ */
+ virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const override;
+ /**
+ * Returns the year in which the default century begins
+ * @internal
+ */
+ virtual int32_t defaultCenturyStartYear() const override;
+};
+
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif /* ETHPCCAL_H */
diff --git a/contrib/libs/icu/i18n/fmtable.cpp b/contrib/libs/icu/i18n/fmtable.cpp
index 7a9a81ded5..618868c0a2 100644
--- a/contrib/libs/icu/i18n/fmtable.cpp
+++ b/contrib/libs/icu/i18n/fmtable.cpp
@@ -53,7 +53,7 @@ using number::impl::DecimalQuantity;
// NOTE: These inlines assume that all fObjects are in fact instances
// of the Measure class, which is true as of 3.0. [alan]
-// Return TRUE if *a == *b.
+// Return true if *a == *b.
static inline UBool objectEquals(const UObject* a, const UObject* b) {
// LATER: return *a == *b;
return *((const Measure*) a) == *((const Measure*) b);
@@ -65,9 +65,9 @@ static inline UObject* objectClone(const UObject* a) {
return ((const Measure*) a)->clone();
}
-// Return TRUE if *a is an instance of Measure.
+// Return true if *a is an instance of Measure.
static inline UBool instanceOfMeasure(const UObject* a) {
- return dynamic_cast<const Measure*>(a) != NULL;
+ return dynamic_cast<const Measure*>(a) != nullptr;
}
/**
@@ -79,7 +79,7 @@ static inline UBool instanceOfMeasure(const UObject* a) {
*/
static Formattable* createArrayCopy(const Formattable* array, int32_t count) {
Formattable *result = new Formattable[count];
- if (result != NULL) {
+ if (result != nullptr) {
for (int32_t i=0; i<count; ++i)
result[i] = array[i]; // Don't memcpy!
}
@@ -104,8 +104,8 @@ static void setError(UErrorCode& ec, UErrorCode err) {
void Formattable::init() {
fValue.fInt64 = 0;
fType = kLong;
- fDecimalStr = NULL;
- fDecimalQuantity = NULL;
+ fDecimalStr = nullptr;
+ fDecimalQuantity = nullptr;
fBogus.setToBogus();
}
@@ -259,14 +259,14 @@ Formattable::operator=(const Formattable& source)
}
UErrorCode status = U_ZERO_ERROR;
- if (source.fDecimalQuantity != NULL) {
+ if (source.fDecimalQuantity != nullptr) {
fDecimalQuantity = new DecimalQuantity(*source.fDecimalQuantity);
}
- if (source.fDecimalStr != NULL) {
+ if (source.fDecimalStr != nullptr) {
fDecimalStr = new CharString(*source.fDecimalStr, status);
if (U_FAILURE(status)) {
delete fDecimalStr;
- fDecimalStr = NULL;
+ fDecimalStr = nullptr;
}
}
}
@@ -315,7 +315,7 @@ Formattable::operator==(const Formattable& that) const
}
break;
case kObject:
- if (fValue.fObject == NULL || that.fValue.fObject == NULL) {
+ if (fValue.fObject == nullptr || that.fValue.fObject == nullptr) {
equal = false;
} else {
equal = objectEquals(fValue.fObject, that.fValue.fObject);
@@ -357,10 +357,10 @@ void Formattable::dispose()
fValue.fInt64 = 0;
delete fDecimalStr;
- fDecimalStr = NULL;
+ fDecimalStr = nullptr;
delete fDecimalQuantity;
- fDecimalQuantity = NULL;
+ fDecimalQuantity = nullptr;
}
Formattable *
@@ -382,9 +382,9 @@ Formattable::isNumeric() const {
case kDouble:
case kLong:
case kInt64:
- return TRUE;
+ return true;
default:
- return FALSE;
+ return false;
}
}
@@ -421,7 +421,7 @@ Formattable::getLong(UErrorCode& status) const
return (int32_t)fValue.fDouble; // loses fraction
}
case Formattable::kObject:
- if (fValue.fObject == NULL) {
+ if (fValue.fObject == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
@@ -462,7 +462,7 @@ Formattable::getInt64(UErrorCode& status) const
} else if (fValue.fDouble < (double)U_INT64_MIN) {
status = U_INVALID_FORMAT_ERROR;
return U_INT64_MIN;
- } else if (fabs(fValue.fDouble) > U_DOUBLE_MAX_EXACT_INT && fDecimalQuantity != NULL) {
+ } else if (fabs(fValue.fDouble) > U_DOUBLE_MAX_EXACT_INT && fDecimalQuantity != nullptr) {
if (fDecimalQuantity->fitsInLong(true)) {
return fDecimalQuantity->toLong();
} else {
@@ -474,7 +474,7 @@ Formattable::getInt64(UErrorCode& status) const
return (int64_t)fValue.fDouble;
}
case Formattable::kObject:
- if (fValue.fObject == NULL) {
+ if (fValue.fObject == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
@@ -504,7 +504,7 @@ Formattable::getDouble(UErrorCode& status) const
case Formattable::kDouble:
return fValue.fDouble;
case Formattable::kObject:
- if (fValue.fObject == NULL) {
+ if (fValue.fObject == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
@@ -522,7 +522,7 @@ Formattable::getDouble(UErrorCode& status) const
const UObject*
Formattable::getObject() const {
- return (fType == kObject) ? fValue.fObject : NULL;
+ return (fType == kObject) ? fValue.fObject : nullptr;
}
// -------------------------------------
@@ -630,7 +630,7 @@ Formattable::getString(UnicodeString& result, UErrorCode& status) const
setError(status, U_INVALID_FORMAT_ERROR);
result.setToBogus();
} else {
- if (fValue.fString == NULL) {
+ if (fValue.fString == nullptr) {
setError(status, U_MEMORY_ALLOCATION_ERROR);
} else {
result = *fValue.fString;
@@ -647,7 +647,7 @@ Formattable::getString(UErrorCode& status) const
setError(status, U_INVALID_FORMAT_ERROR);
return *getBogus();
}
- if (fValue.fString == NULL) {
+ if (fValue.fString == nullptr) {
setError(status, U_MEMORY_ALLOCATION_ERROR);
return *getBogus();
}
@@ -662,7 +662,7 @@ Formattable::getString(UErrorCode& status)
setError(status, U_INVALID_FORMAT_ERROR);
return *getBogus();
}
- if (fValue.fString == NULL) {
+ if (fValue.fString == nullptr) {
setError(status, U_MEMORY_ALLOCATION_ERROR);
return *getBogus();
}
@@ -676,7 +676,7 @@ Formattable::getArray(int32_t& count, UErrorCode& status) const
if (fType != kArray) {
setError(status, U_INVALID_FORMAT_ERROR);
count = 0;
- return NULL;
+ return nullptr;
}
count = fValue.fArrayAndCount.fCount;
return fValue.fArrayAndCount.fArray;
@@ -697,12 +697,12 @@ StringPiece Formattable::getDecimalNumber(UErrorCode &status) {
if (U_FAILURE(status)) {
return "";
}
- if (fDecimalStr != NULL) {
+ if (fDecimalStr != nullptr) {
return fDecimalStr->toStringPiece();
}
CharString *decimalStr = internalGetCharString(status);
- if(decimalStr == NULL) {
+ if(decimalStr == nullptr) {
return ""; // getDecimalNumber returns "" for error cases
} else {
return decimalStr->toStringPiece();
@@ -710,8 +710,8 @@ StringPiece Formattable::getDecimalNumber(UErrorCode &status) {
}
CharString *Formattable::internalGetCharString(UErrorCode &status) {
- if(fDecimalStr == NULL) {
- if (fDecimalQuantity == NULL) {
+ if(fDecimalStr == nullptr) {
+ if (fDecimalQuantity == nullptr) {
// No decimal number for the formattable yet. Which means the value was
// set directly by the user as an int, int64 or double. If the value came
// from parsing, or from the user setting a decimal number, fDecimalNum
@@ -725,9 +725,9 @@ CharString *Formattable::internalGetCharString(UErrorCode &status) {
}
fDecimalStr = new CharString();
- if (fDecimalStr == NULL) {
+ if (fDecimalStr == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
// Older ICUs called uprv_decNumberToString here, which is not exactly the same as
// DecimalQuantity::toScientificString(). The biggest difference is that uprv_decNumberToString does
@@ -775,11 +775,11 @@ Formattable::populateDecimalQuantity(number::impl::DecimalQuantity& output, UErr
// ---------------------------------------
void
Formattable::adoptDecimalQuantity(DecimalQuantity *dq) {
- if (fDecimalQuantity != NULL) {
+ if (fDecimalQuantity != nullptr) {
delete fDecimalQuantity;
}
fDecimalQuantity = dq;
- if (dq == NULL) { // allow adoptDigitList(NULL) to clear
+ if (dq == nullptr) { // allow adoptDigitList(nullptr) to clear
return;
}
@@ -898,11 +898,11 @@ U_NAMESPACE_USE
U_CAPI UFormattable* U_EXPORT2
ufmt_open(UErrorCode *status) {
if( U_FAILURE(*status) ) {
- return NULL;
+ return nullptr;
}
UFormattable *fmt = (new Formattable())->toUFormattable();
- if( fmt == NULL ) {
+ if( fmt == nullptr ) {
*status = U_MEMORY_ALLOCATION_ERROR;
}
return fmt;
@@ -958,7 +958,7 @@ ufmt_getObject(const UFormattable *fmt, UErrorCode *status) {
const Formattable *obj = Formattable::fromUFormattable(fmt);
const void *ret = obj->getObject();
- if( ret==NULL &&
+ if( ret==nullptr &&
(obj->getType() != Formattable::kObject) &&
U_SUCCESS( *status )) {
*status = U_INVALID_FORMAT_ERROR;
@@ -966,7 +966,7 @@ ufmt_getObject(const UFormattable *fmt, UErrorCode *status) {
return ret;
}
-U_CAPI const UChar* U_EXPORT2
+U_CAPI const char16_t* U_EXPORT2
ufmt_getUChars(UFormattable *fmt, int32_t *len, UErrorCode *status) {
Formattable *obj = Formattable::fromUFormattable(fmt);
@@ -975,12 +975,12 @@ ufmt_getUChars(UFormattable *fmt, int32_t *len, UErrorCode *status) {
if( U_SUCCESS(*status) ){
*status = U_INVALID_FORMAT_ERROR;
}
- return NULL;
+ return nullptr;
}
// This should return a valid string
UnicodeString &str = obj->getString(*status);
- if( U_SUCCESS(*status) && len != NULL ) {
+ if( U_SUCCESS(*status) && len != nullptr ) {
*len = str.length();
}
return str.getTerminatedBuffer();
@@ -1001,10 +1001,10 @@ ufmt_getArrayItemByIndex(UFormattable* fmt, int32_t n, UErrorCode *status) {
int32_t count;
(void)obj->getArray(count, *status);
if(U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
} else if(n<0 || n>=count) {
setError(*status, U_INDEX_OUTOFBOUNDS_ERROR);
- return NULL;
+ return nullptr;
} else {
return (*obj)[n].toUFormattable(); // returns non-const Formattable
}
@@ -1020,11 +1020,11 @@ ufmt_getDecNumChars(UFormattable *fmt, int32_t *len, UErrorCode *status) {
if(U_FAILURE(*status)) {
return "";
}
- if(charString == NULL) {
+ if(charString == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
return "";
} else {
- if(len!=NULL) {
+ if(len!=nullptr) {
*len = charString->length();
}
return charString->data();
diff --git a/contrib/libs/icu/i18n/formatted_string_builder.cpp b/contrib/libs/icu/i18n/formatted_string_builder.cpp
index 734078644b..8dbf954af9 100644
--- a/contrib/libs/icu/i18n/formatted_string_builder.cpp
+++ b/contrib/libs/icu/i18n/formatted_string_builder.cpp
@@ -6,6 +6,7 @@
#if !UCONFIG_NO_FORMATTING
#include "formatted_string_builder.h"
+#include "putilimp.h"
#include "unicode/ustring.h"
#include "unicode/utf16.h"
#include "unicode/unum.h" // for UNumberFormatFields literals
@@ -197,6 +198,9 @@ FormattedStringBuilder::splice(int32_t startThis, int32_t endThis, const Unicod
int32_t thisLength = endThis - startThis;
int32_t otherLength = endOther - startOther;
int32_t count = otherLength - thisLength;
+ if (U_FAILURE(status)) {
+ return count;
+ }
int32_t position;
if (count > 0) {
// Overall, chars need to be added.
@@ -221,6 +225,9 @@ int32_t FormattedStringBuilder::append(const FormattedStringBuilder &other, UErr
int32_t
FormattedStringBuilder::insert(int32_t index, const FormattedStringBuilder &other, UErrorCode &status) {
+ if (U_FAILURE(status)) {
+ return 0;
+ }
if (this == &other) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
@@ -255,12 +262,18 @@ int32_t FormattedStringBuilder::prepareForInsert(int32_t index, int32_t count, U
U_ASSERT(index >= 0);
U_ASSERT(index <= fLength);
U_ASSERT(count >= 0);
+ U_ASSERT(fZero >= 0);
+ U_ASSERT(fLength >= 0);
+ U_ASSERT(getCapacity() - fZero >= fLength);
+ if (U_FAILURE(status)) {
+ return count;
+ }
if (index == 0 && fZero - count >= 0) {
// Append to start
fZero -= count;
fLength += count;
return fZero;
- } else if (index == fLength && fZero + fLength + count < getCapacity()) {
+ } else if (index == fLength && count <= getCapacity() - fZero - fLength) {
// Append to end
fLength += count;
return fZero + fLength - count;
@@ -275,18 +288,26 @@ int32_t FormattedStringBuilder::prepareForInsertHelper(int32_t index, int32_t co
int32_t oldZero = fZero;
char16_t *oldChars = getCharPtr();
Field *oldFields = getFieldPtr();
- if (fLength + count > oldCapacity) {
- if ((fLength + count) > INT32_MAX / 2) {
- // If we continue, then newCapacity will overflow int32_t in the next line.
+ int32_t newLength;
+ if (uprv_add32_overflow(fLength, count, &newLength)) {
+ status = U_INPUT_TOO_LONG_ERROR;
+ return -1;
+ }
+ int32_t newZero;
+ if (newLength > oldCapacity) {
+ if (newLength > INT32_MAX / 2) {
+ // We do not support more than 1G char16_t in this code because
+ // dealing with >2G *bytes* can cause subtle bugs.
status = U_INPUT_TOO_LONG_ERROR;
return -1;
}
- int32_t newCapacity = (fLength + count) * 2;
- int32_t newZero = newCapacity / 2 - (fLength + count) / 2;
+ // Keep newCapacity also to at most 1G char16_t.
+ int32_t newCapacity = newLength * 2;
+ newZero = (newCapacity - newLength) / 2;
// C++ note: malloc appears in two places: here and in the assignment operator.
- auto newChars = static_cast<char16_t *> (uprv_malloc(sizeof(char16_t) * newCapacity));
- auto newFields = static_cast<Field *>(uprv_malloc(sizeof(Field) * newCapacity));
+ auto newChars = static_cast<char16_t *> (uprv_malloc(sizeof(char16_t) * static_cast<size_t>(newCapacity)));
+ auto newFields = static_cast<Field *>(uprv_malloc(sizeof(Field) * static_cast<size_t>(newCapacity)));
if (newChars == nullptr || newFields == nullptr) {
uprv_free(newChars);
uprv_free(newFields);
@@ -315,10 +336,8 @@ int32_t FormattedStringBuilder::prepareForInsertHelper(int32_t index, int32_t co
fChars.heap.capacity = newCapacity;
fFields.heap.ptr = newFields;
fFields.heap.capacity = newCapacity;
- fZero = newZero;
- fLength += count;
} else {
- int32_t newZero = oldCapacity / 2 - (fLength + count) / 2;
+ newZero = (oldCapacity - newLength) / 2;
// C++ note: memmove is required because src and dest may overlap.
// First copy the entire string to the location of the prefix, and then move the suffix
@@ -331,18 +350,20 @@ int32_t FormattedStringBuilder::prepareForInsertHelper(int32_t index, int32_t co
uprv_memmove2(oldFields + newZero + index + count,
oldFields + newZero + index,
sizeof(Field) * (fLength - index));
-
- fZero = newZero;
- fLength += count;
}
- U_ASSERT((fZero + index) >= 0);
+ fZero = newZero;
+ fLength = newLength;
return fZero + index;
}
int32_t FormattedStringBuilder::remove(int32_t index, int32_t count) {
- // TODO: Reset the heap here? (If the string after removal can fit on stack?)
+ U_ASSERT(0 <= index);
+ U_ASSERT(index <= fLength);
+ U_ASSERT(count <= (fLength - index));
+ U_ASSERT(index <= getCapacity() - fZero);
+
int32_t position = index + fZero;
- U_ASSERT(position >= 0);
+ // TODO: Reset the heap here? (If the string after removal can fit on stack?)
uprv_memmove2(getCharPtr() + position,
getCharPtr() + position + count,
sizeof(char16_t) * (fLength - index - count));
@@ -359,7 +380,7 @@ UnicodeString FormattedStringBuilder::toUnicodeString() const {
const UnicodeString FormattedStringBuilder::toTempUnicodeString() const {
// Readonly-alias constructor:
- return UnicodeString(FALSE, getCharPtr() + fZero, fLength);
+ return UnicodeString(false, getCharPtr() + fZero, fLength);
}
UnicodeString FormattedStringBuilder::toDebugString() const {
diff --git a/contrib/libs/icu/i18n/formatted_string_builder.h b/contrib/libs/icu/i18n/formatted_string_builder.h
index 92bcf07d78..32e0900ae2 100644
--- a/contrib/libs/icu/i18n/formatted_string_builder.h
+++ b/contrib/libs/icu/i18n/formatted_string_builder.h
@@ -218,7 +218,9 @@ class U_I18N_API FormattedStringBuilder : public UMemory {
};
static_assert(
- std::is_pod<FormattedStringBuilder::Field>::value,
+ // std::is_pod<> is deprecated.
+ std::is_standard_layout<FormattedStringBuilder::Field>::value &&
+ std::is_trivial<FormattedStringBuilder::Field>::value,
"Field should be a POD type for efficient initialization");
constexpr FormattedStringBuilder::Field::Field(uint8_t category, uint8_t field)
diff --git a/contrib/libs/icu/i18n/formattedval_impl.h b/contrib/libs/icu/i18n/formattedval_impl.h
index 2b9a3970d2..e19392c5b9 100644
--- a/contrib/libs/icu/i18n/formattedval_impl.h
+++ b/contrib/libs/icu/i18n/formattedval_impl.h
@@ -83,10 +83,10 @@ public:
// Implementation of FormattedValue (const):
- UnicodeString toString(UErrorCode& status) const U_OVERRIDE;
- UnicodeString toTempString(UErrorCode& status) const U_OVERRIDE;
- Appendable& appendTo(Appendable& appendable, UErrorCode& status) const U_OVERRIDE;
- UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE;
+ UnicodeString toString(UErrorCode& status) const override;
+ UnicodeString toTempString(UErrorCode& status) const override;
+ Appendable& appendTo(Appendable& appendable, UErrorCode& status) const override;
+ UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const override;
// Additional methods used during construction phase only (non-const):
@@ -153,12 +153,15 @@ public:
virtual ~FormattedValueStringBuilderImpl();
+ FormattedValueStringBuilderImpl(FormattedValueStringBuilderImpl&&) = default;
+ FormattedValueStringBuilderImpl& operator=(FormattedValueStringBuilderImpl&&) = default;
+
// Implementation of FormattedValue (const):
- UnicodeString toString(UErrorCode& status) const U_OVERRIDE;
- UnicodeString toTempString(UErrorCode& status) const U_OVERRIDE;
- Appendable& appendTo(Appendable& appendable, UErrorCode& status) const U_OVERRIDE;
- UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE;
+ UnicodeString toString(UErrorCode& status) const override;
+ UnicodeString toTempString(UErrorCode& status) const override;
+ Appendable& appendTo(Appendable& appendable, UErrorCode& status) const override;
+ UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const override;
// Additional helper functions:
UBool nextFieldPosition(FieldPosition& fp, UErrorCode& status) const;
@@ -219,7 +222,7 @@ struct UFormattedValueImpl : public UMemory, public UFormattedValueApiHelper {
/** Implementation of the methods from U_FORMATTED_VALUE_SUBCLASS_AUTO. */
#define UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(Name) \
- Name::Name(Name&& src) U_NOEXCEPT \
+ Name::Name(Name&& src) noexcept \
: fData(src.fData), fErrorCode(src.fErrorCode) { \
src.fData = nullptr; \
src.fErrorCode = U_INVALID_STATE_ERROR; \
@@ -228,7 +231,7 @@ struct UFormattedValueImpl : public UMemory, public UFormattedValueApiHelper {
delete fData; \
fData = nullptr; \
} \
- Name& Name::operator=(Name&& src) U_NOEXCEPT { \
+ Name& Name::operator=(Name&& src) noexcept { \
delete fData; \
fData = src.fData; \
src.fData = nullptr; \
diff --git a/contrib/libs/icu/i18n/formattedval_iterimpl.cpp b/contrib/libs/icu/i18n/formattedval_iterimpl.cpp
index 75328fae88..ec770e2191 100644
--- a/contrib/libs/icu/i18n/formattedval_iterimpl.cpp
+++ b/contrib/libs/icu/i18n/formattedval_iterimpl.cpp
@@ -32,7 +32,7 @@ UnicodeString FormattedValueFieldPositionIteratorImpl::toTempString(
UErrorCode&) const {
// The alias must point to memory owned by this object;
// fastCopyFrom doesn't do this when using a stack buffer.
- return UnicodeString(TRUE, fString.getBuffer(), fString.length());
+ return UnicodeString(true, fString.getBuffer(), fString.length());
}
Appendable& FormattedValueFieldPositionIteratorImpl::appendTo(
diff --git a/contrib/libs/icu/i18n/formattedval_sbimpl.cpp b/contrib/libs/icu/i18n/formattedval_sbimpl.cpp
index 70ffacac4b..72197cdd8c 100644
--- a/contrib/libs/icu/i18n/formattedval_sbimpl.cpp
+++ b/contrib/libs/icu/i18n/formattedval_sbimpl.cpp
@@ -230,6 +230,11 @@ bool FormattedValueStringBuilderImpl::nextPositionImpl(ConstrainedFieldPosition&
if (si + 1 < spanIndicesCount) {
nextSpanStart = spanIndices[si + 1].start;
}
+ if (length == 0) {
+ // ICU-21871: Don't return fields on empty spans
+ i--;
+ continue;
+ }
if (cfpos.matchesField(spanCategory, spanValue)) {
fieldStart = i - fString.fZero;
int32_t end = fieldStart + length;
diff --git a/contrib/libs/icu/i18n/formattedvalue.cpp b/contrib/libs/icu/i18n/formattedvalue.cpp
index 1030661f22..aacd6ac70e 100644
--- a/contrib/libs/icu/i18n/formattedvalue.cpp
+++ b/contrib/libs/icu/i18n/formattedvalue.cpp
@@ -43,7 +43,7 @@ void ConstrainedFieldPosition::setInt64IterationContext(int64_t context) {
UBool ConstrainedFieldPosition::matchesField(int32_t category, int32_t field) const {
switch (fConstraint) {
case UCFPOS_CONSTRAINT_NONE:
- return TRUE;
+ return true;
case UCFPOS_CONSTRAINT_CATEGORY:
return fCategory == category;
case UCFPOS_CONSTRAINT_FIELD:
@@ -193,7 +193,7 @@ ucfpos_close(UConstrainedFieldPosition* ptr) {
}
-U_CAPI const UChar* U_EXPORT2
+U_CAPI const char16_t* U_EXPORT2
ufmtval_getString(
const UFormattedValue* ufmtval,
int32_t* pLength,
@@ -223,7 +223,7 @@ ufmtval_nextPosition(
const auto* fmtval = UFormattedValueApiHelper::validate(ufmtval, *ec);
auto* cfpos = UConstrainedFieldPositionImpl::validate(ucfpos, *ec);
if (U_FAILURE(*ec)) {
- return FALSE;
+ return false;
}
return fmtval->fFormattedValue->nextPosition(cfpos->fImpl, *ec);
}
diff --git a/contrib/libs/icu/i18n/fphdlimp.cpp b/contrib/libs/icu/i18n/fphdlimp.cpp
index f51bf4bae7..e170dc4b99 100644
--- a/contrib/libs/icu/i18n/fphdlimp.cpp
+++ b/contrib/libs/icu/i18n/fphdlimp.cpp
@@ -39,7 +39,7 @@ FieldPositionOnlyHandler::~FieldPositionOnlyHandler() {
void
FieldPositionOnlyHandler::addAttribute(int32_t id, int32_t start, int32_t limit) {
if (pos.getField() == id && (!acceptFirstOnly || !seenFirst)) {
- seenFirst = TRUE;
+ seenFirst = true;
pos.setBeginIndex(start + fShift);
pos.setEndIndex(limit + fShift);
}
@@ -54,7 +54,7 @@ FieldPositionOnlyHandler::shiftLast(int32_t delta) {
}
UBool
-FieldPositionOnlyHandler::isRecording(void) const {
+FieldPositionOnlyHandler::isRecording() const {
return pos.getField() != FieldPosition::DONT_CARE;
}
@@ -67,7 +67,7 @@ void FieldPositionOnlyHandler::setAcceptFirstOnly(UBool acceptFirstOnly) {
FieldPositionIteratorHandler::FieldPositionIteratorHandler(FieldPositionIterator* posIter,
UErrorCode& _status)
- : iter(posIter), vec(NULL), status(_status), fCategory(UFIELD_CATEGORY_UNDEFINED) {
+ : iter(posIter), vec(nullptr), status(_status), fCategory(UFIELD_CATEGORY_UNDEFINED) {
if (iter && U_SUCCESS(status)) {
vec = new UVector32(status);
}
@@ -85,7 +85,7 @@ FieldPositionIteratorHandler::~FieldPositionIteratorHandler() {
iter->setData(vec, status);
}
// if iter is null, we never allocated vec, so no need to free it
- vec = NULL;
+ vec = nullptr;
}
void
@@ -116,7 +116,7 @@ FieldPositionIteratorHandler::shiftLast(int32_t delta) {
}
UBool
-FieldPositionIteratorHandler::isRecording(void) const {
+FieldPositionIteratorHandler::isRecording() const {
return U_SUCCESS(status);
}
diff --git a/contrib/libs/icu/i18n/fphdlimp.h b/contrib/libs/icu/i18n/fphdlimp.h
index 4fb0c7b6fe..ad09c6c903 100644
--- a/contrib/libs/icu/i18n/fphdlimp.h
+++ b/contrib/libs/icu/i18n/fphdlimp.h
@@ -31,7 +31,7 @@ class U_I18N_API FieldPositionHandler: public UMemory {
virtual ~FieldPositionHandler();
virtual void addAttribute(int32_t id, int32_t start, int32_t limit) = 0;
virtual void shiftLast(int32_t delta) = 0;
- virtual UBool isRecording(void) const = 0;
+ virtual UBool isRecording() const = 0;
void setShift(int32_t delta);
};
@@ -48,9 +48,9 @@ class FieldPositionOnlyHandler : public FieldPositionHandler {
FieldPositionOnlyHandler(FieldPosition& pos);
virtual ~FieldPositionOnlyHandler();
- void addAttribute(int32_t id, int32_t start, int32_t limit) U_OVERRIDE;
- void shiftLast(int32_t delta) U_OVERRIDE;
- UBool isRecording(void) const U_OVERRIDE;
+ void addAttribute(int32_t id, int32_t start, int32_t limit) override;
+ void shiftLast(int32_t delta) override;
+ UBool isRecording() const override;
/**
* Enable this option to lock in the FieldPosition value after seeing the
@@ -65,7 +65,7 @@ class FieldPositionOnlyHandler : public FieldPositionHandler {
// exported as U_I18N_API for tests
class U_I18N_API FieldPositionIteratorHandler : public FieldPositionHandler {
- FieldPositionIterator* iter; // can be NULL
+ FieldPositionIterator* iter; // can be nullptr
UVector32* vec;
UErrorCode status;
UFieldCategory fCategory;
@@ -74,10 +74,10 @@ class U_I18N_API FieldPositionIteratorHandler : public FieldPositionHandler {
// to be destroyed before status goes out of scope. Easiest thing is to
// allocate us on the stack in the same (or narrower) scope as status has.
// This attempts to encourage that by blocking heap allocation.
- static void* U_EXPORT2 operator new(size_t) U_NOEXCEPT = delete;
- static void* U_EXPORT2 operator new[](size_t) U_NOEXCEPT = delete;
+ static void* U_EXPORT2 operator new(size_t) noexcept = delete;
+ static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
#if U_HAVE_PLACEMENT_NEW
- static void* U_EXPORT2 operator new(size_t, void*) U_NOEXCEPT = delete;
+ static void* U_EXPORT2 operator new(size_t, void*) noexcept = delete;
#endif
public:
@@ -86,9 +86,9 @@ class U_I18N_API FieldPositionIteratorHandler : public FieldPositionHandler {
FieldPositionIteratorHandler(UVector32* vec, UErrorCode& status);
~FieldPositionIteratorHandler();
- void addAttribute(int32_t id, int32_t start, int32_t limit) U_OVERRIDE;
- void shiftLast(int32_t delta) U_OVERRIDE;
- UBool isRecording(void) const U_OVERRIDE;
+ void addAttribute(int32_t id, int32_t start, int32_t limit) override;
+ void shiftLast(int32_t delta) override;
+ UBool isRecording() const override;
/** Copies a failed error code into _status. */
inline void getError(UErrorCode& _status) {
diff --git a/contrib/libs/icu/i18n/fpositer.cpp b/contrib/libs/icu/i18n/fpositer.cpp
index 096896d7b3..68f1edcc17 100644
--- a/contrib/libs/icu/i18n/fpositer.cpp
+++ b/contrib/libs/icu/i18n/fpositer.cpp
@@ -22,16 +22,16 @@ U_NAMESPACE_BEGIN
FieldPositionIterator::~FieldPositionIterator() {
delete data;
- data = NULL;
+ data = nullptr;
pos = -1;
}
FieldPositionIterator::FieldPositionIterator()
- : data(NULL), pos(-1) {
+ : data(nullptr), pos(-1) {
}
FieldPositionIterator::FieldPositionIterator(const FieldPositionIterator &rhs)
- : UObject(rhs), data(NULL), pos(rhs.pos) {
+ : UObject(rhs), data(nullptr), pos(rhs.pos) {
if (rhs.data) {
UErrorCode status = U_ZERO_ERROR;
@@ -39,7 +39,7 @@ FieldPositionIterator::FieldPositionIterator(const FieldPositionIterator &rhs)
data->assign(*rhs.data, status);
if (status != U_ZERO_ERROR) {
delete data;
- data = NULL;
+ data = nullptr;
pos = -1;
}
}
@@ -53,7 +53,7 @@ bool FieldPositionIterator::operator==(const FieldPositionIterator &rhs) const {
return false;
}
if (!data) {
- return rhs.data == NULL;
+ return rhs.data == nullptr;
}
return rhs.data ? data->operator==(*rhs.data) : false;
}
@@ -64,7 +64,7 @@ void FieldPositionIterator::setData(UVector32 *adopt, UErrorCode& status) {
if (adopt) {
if (adopt->size() == 0) {
delete adopt;
- adopt = NULL;
+ adopt = nullptr;
} else if ((adopt->size() % 4) != 0) {
status = U_ILLEGAL_ARGUMENT_ERROR;
} else {
@@ -87,12 +87,12 @@ void FieldPositionIterator::setData(UVector32 *adopt, UErrorCode& status) {
delete data;
data = adopt;
- pos = adopt == NULL ? -1 : 0;
+ pos = adopt == nullptr ? -1 : 0;
}
UBool FieldPositionIterator::next(FieldPosition& fp) {
if (pos == -1) {
- return FALSE;
+ return false;
}
// Ignore the first element of the tetrad: used for field category
@@ -105,7 +105,7 @@ UBool FieldPositionIterator::next(FieldPosition& fp) {
pos = -1;
}
- return TRUE;
+ return true;
}
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/funcrepl.cpp b/contrib/libs/icu/i18n/funcrepl.cpp
index 7dd54ed8d2..f093a1e437 100644
--- a/contrib/libs/icu/i18n/funcrepl.cpp
+++ b/contrib/libs/icu/i18n/funcrepl.cpp
@@ -18,9 +18,9 @@
#include "unicode/uniset.h"
#include "funcrepl.h"
-static const UChar AMPERSAND = 38; // '&'
-static const UChar OPEN[] = {40,32,0}; // "( "
-static const UChar CLOSE[] = {32,41,0}; // " )"
+static const char16_t AMPERSAND = 38; // '&'
+static const char16_t OPEN[] = {40,32,0}; // "( "
+static const char16_t CLOSE[] = {32,41,0}; // " )"
U_NAMESPACE_BEGIN
diff --git a/contrib/libs/icu/i18n/gender.cpp b/contrib/libs/icu/i18n/gender.cpp
index dc5def6ad3..97d161de32 100644
--- a/contrib/libs/icu/i18n/gender.cpp
+++ b/contrib/libs/icu/i18n/gender.cpp
@@ -31,13 +31,13 @@
#include "umutex.h"
#include "uhash.h"
-static UHashtable* gGenderInfoCache = NULL;
+static UHashtable* gGenderInfoCache = nullptr;
static const char* gNeutralStr = "neutral";
static const char* gMailTaintsStr = "maleTaints";
static const char* gMixedNeutralStr = "mixedNeutral";
-static icu::GenderInfo* gObjs = NULL;
-static icu::UInitOnce gGenderInitOnce = U_INITONCE_INITIALIZER;
+static icu::GenderInfo* gObjs = nullptr;
+static icu::UInitOnce gGenderInitOnce {};
enum GenderStyle {
NEUTRAL,
@@ -48,14 +48,14 @@ enum GenderStyle {
U_CDECL_BEGIN
-static UBool U_CALLCONV gender_cleanup(void) {
- if (gGenderInfoCache != NULL) {
+static UBool U_CALLCONV gender_cleanup() {
+ if (gGenderInfoCache != nullptr) {
uhash_close(gGenderInfoCache);
- gGenderInfoCache = NULL;
+ gGenderInfoCache = nullptr;
delete [] gObjs;
}
gGenderInitOnce.reset();
- return TRUE;
+ return true;
}
U_CDECL_END
@@ -64,19 +64,19 @@ U_NAMESPACE_BEGIN
void U_CALLCONV GenderInfo_initCache(UErrorCode &status) {
ucln_i18n_registerCleanup(UCLN_I18N_GENDERINFO, gender_cleanup);
- U_ASSERT(gGenderInfoCache == NULL);
+ U_ASSERT(gGenderInfoCache == nullptr);
if (U_FAILURE(status)) {
return;
}
gObjs = new GenderInfo[GENDER_STYLE_LENGTH];
- if (gObjs == NULL) {
+ if (gObjs == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
for (int i = 0; i < GENDER_STYLE_LENGTH; i++) {
gObjs[i]._style = i;
}
- gGenderInfoCache = uhash_open(uhash_hashChars, uhash_compareChars, NULL, &status);
+ gGenderInfoCache = uhash_open(uhash_hashChars, uhash_compareChars, nullptr, &status);
if (U_FAILURE(status)) {
delete [] gObjs;
return;
@@ -95,11 +95,11 @@ const GenderInfo* GenderInfo::getInstance(const Locale& locale, UErrorCode& stat
// Make sure our cache exists.
umtx_initOnce(gGenderInitOnce, &GenderInfo_initCache, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
static UMutex gGenderMetaLock;
- const GenderInfo* result = NULL;
+ const GenderInfo* result = nullptr;
const char* key = locale.getName();
{
Mutex lock(&gGenderMetaLock);
@@ -112,7 +112,7 @@ const GenderInfo* GenderInfo::getInstance(const Locale& locale, UErrorCode& stat
// On cache miss, try to create GenderInfo from CLDR data
result = loadInstance(locale, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
// Try to put our GenderInfo object in cache. If there is a race condition,
@@ -125,7 +125,7 @@ const GenderInfo* GenderInfo::getInstance(const Locale& locale, UErrorCode& stat
} else {
uhash_put(gGenderInfoCache, uprv_strdup(key), (void*) result, &status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
}
}
@@ -134,30 +134,30 @@ const GenderInfo* GenderInfo::getInstance(const Locale& locale, UErrorCode& stat
const GenderInfo* GenderInfo::loadInstance(const Locale& locale, UErrorCode& status) {
LocalUResourceBundlePointer rb(
- ures_openDirect(NULL, "genderList", &status));
+ ures_openDirect(nullptr, "genderList", &status));
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
- LocalUResourceBundlePointer locRes(ures_getByKey(rb.getAlias(), "genderList", NULL, &status));
+ LocalUResourceBundlePointer locRes(ures_getByKey(rb.getAlias(), "genderList", nullptr, &status));
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
int32_t resLen = 0;
const char* curLocaleName = locale.getName();
UErrorCode key_status = U_ZERO_ERROR;
- const UChar* s = ures_getStringByKey(locRes.getAlias(), curLocaleName, &resLen, &key_status);
- if (s == NULL) {
+ const char16_t* s = ures_getStringByKey(locRes.getAlias(), curLocaleName, &resLen, &key_status);
+ if (s == nullptr) {
key_status = U_ZERO_ERROR;
char parentLocaleName[ULOC_FULLNAME_CAPACITY];
uprv_strcpy(parentLocaleName, curLocaleName);
- while (s == NULL && uloc_getParent(parentLocaleName, parentLocaleName, ULOC_FULLNAME_CAPACITY, &key_status) > 0) {
+ while (s == nullptr && uloc_getParent(parentLocaleName, parentLocaleName, ULOC_FULLNAME_CAPACITY, &key_status) > 0) {
key_status = U_ZERO_ERROR;
resLen = 0;
s = ures_getStringByKey(locRes.getAlias(), parentLocaleName, &resLen, &key_status);
key_status = U_ZERO_ERROR;
}
}
- if (s == NULL) {
+ if (s == nullptr) {
return &gObjs[NEUTRAL];
}
char type_str[256] = "";
@@ -184,8 +184,8 @@ UGender GenderInfo::getListGender(const UGender* genders, int32_t length, UError
if (length == 1) {
return genders[0];
}
- UBool has_female = FALSE;
- UBool has_male = FALSE;
+ UBool has_female = false;
+ UBool has_male = false;
switch (_style) {
case NEUTRAL:
return UGENDER_OTHER;
@@ -199,13 +199,13 @@ UGender GenderInfo::getListGender(const UGender* genders, int32_t length, UError
if (has_male) {
return UGENDER_OTHER;
}
- has_female = TRUE;
+ has_female = true;
break;
case UGENDER_MALE:
if (has_female) {
return UGENDER_OTHER;
}
- has_male = TRUE;
+ has_male = true;
break;
default:
break;
diff --git a/contrib/libs/icu/i18n/gregocal.cpp b/contrib/libs/icu/i18n/gregocal.cpp
index 31d36300ae..5fd71d496c 100644
--- a/contrib/libs/icu/i18n/gregocal.cpp
+++ b/contrib/libs/icu/i18n/gregocal.cpp
@@ -101,6 +101,7 @@ static const int32_t kGregorianCalendarLimits[UCAL_FIELD_COUNT][4] = {
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // JULIAN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // MILLISECONDS_IN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // IS_LEAP_MONTH
+ { 0, 0, 11, 11}, // ORDINAL_MONTH
};
/*
@@ -155,7 +156,7 @@ GregorianCalendar::GregorianCalendar(UErrorCode& status)
: Calendar(status),
fGregorianCutover(kPapalCutover),
fCutoverJulianDay(kCutoverJulianDay), fNormalizedGregorianCutover(fGregorianCutover), fGregorianCutoverYear(1582),
-fIsGregorian(TRUE), fInvertGregorian(FALSE)
+fIsGregorian(true), fInvertGregorian(false)
{
setTimeInMillis(getNow(), status);
}
@@ -166,7 +167,7 @@ GregorianCalendar::GregorianCalendar(TimeZone* zone, UErrorCode& status)
: Calendar(zone, Locale::getDefault(), status),
fGregorianCutover(kPapalCutover),
fCutoverJulianDay(kCutoverJulianDay), fNormalizedGregorianCutover(fGregorianCutover), fGregorianCutoverYear(1582),
-fIsGregorian(TRUE), fInvertGregorian(FALSE)
+fIsGregorian(true), fInvertGregorian(false)
{
setTimeInMillis(getNow(), status);
}
@@ -177,7 +178,7 @@ GregorianCalendar::GregorianCalendar(const TimeZone& zone, UErrorCode& status)
: Calendar(zone, Locale::getDefault(), status),
fGregorianCutover(kPapalCutover),
fCutoverJulianDay(kCutoverJulianDay), fNormalizedGregorianCutover(fGregorianCutover), fGregorianCutoverYear(1582),
-fIsGregorian(TRUE), fInvertGregorian(FALSE)
+fIsGregorian(true), fInvertGregorian(false)
{
setTimeInMillis(getNow(), status);
}
@@ -188,7 +189,7 @@ GregorianCalendar::GregorianCalendar(const Locale& aLocale, UErrorCode& status)
: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, status),
fGregorianCutover(kPapalCutover),
fCutoverJulianDay(kCutoverJulianDay), fNormalizedGregorianCutover(fGregorianCutover), fGregorianCutoverYear(1582),
-fIsGregorian(TRUE), fInvertGregorian(FALSE)
+fIsGregorian(true), fInvertGregorian(false)
{
setTimeInMillis(getNow(), status);
}
@@ -200,7 +201,7 @@ GregorianCalendar::GregorianCalendar(TimeZone* zone, const Locale& aLocale,
: Calendar(zone, aLocale, status),
fGregorianCutover(kPapalCutover),
fCutoverJulianDay(kCutoverJulianDay), fNormalizedGregorianCutover(fGregorianCutover), fGregorianCutoverYear(1582),
- fIsGregorian(TRUE), fInvertGregorian(FALSE)
+ fIsGregorian(true), fInvertGregorian(false)
{
setTimeInMillis(getNow(), status);
}
@@ -212,7 +213,7 @@ GregorianCalendar::GregorianCalendar(const TimeZone& zone, const Locale& aLocale
: Calendar(zone, aLocale, status),
fGregorianCutover(kPapalCutover),
fCutoverJulianDay(kCutoverJulianDay), fNormalizedGregorianCutover(fGregorianCutover), fGregorianCutoverYear(1582),
- fIsGregorian(TRUE), fInvertGregorian(FALSE)
+ fIsGregorian(true), fInvertGregorian(false)
{
setTimeInMillis(getNow(), status);
}
@@ -224,7 +225,7 @@ GregorianCalendar::GregorianCalendar(int32_t year, int32_t month, int32_t date,
: Calendar(TimeZone::createDefault(), Locale::getDefault(), status),
fGregorianCutover(kPapalCutover),
fCutoverJulianDay(kCutoverJulianDay), fNormalizedGregorianCutover(fGregorianCutover), fGregorianCutoverYear(1582),
- fIsGregorian(TRUE), fInvertGregorian(FALSE)
+ fIsGregorian(true), fInvertGregorian(false)
{
set(UCAL_ERA, AD);
set(UCAL_YEAR, year);
@@ -239,7 +240,7 @@ GregorianCalendar::GregorianCalendar(int32_t year, int32_t month, int32_t date,
: Calendar(TimeZone::createDefault(), Locale::getDefault(), status),
fGregorianCutover(kPapalCutover),
fCutoverJulianDay(kCutoverJulianDay), fNormalizedGregorianCutover(fGregorianCutover), fGregorianCutoverYear(1582),
- fIsGregorian(TRUE), fInvertGregorian(FALSE)
+ fIsGregorian(true), fInvertGregorian(false)
{
set(UCAL_ERA, AD);
set(UCAL_YEAR, year);
@@ -257,7 +258,7 @@ GregorianCalendar::GregorianCalendar(int32_t year, int32_t month, int32_t date,
: Calendar(TimeZone::createDefault(), Locale::getDefault(), status),
fGregorianCutover(kPapalCutover),
fCutoverJulianDay(kCutoverJulianDay), fNormalizedGregorianCutover(fGregorianCutover), fGregorianCutoverYear(1582),
- fIsGregorian(TRUE), fInvertGregorian(FALSE)
+ fIsGregorian(true), fInvertGregorian(false)
{
set(UCAL_ERA, AD);
set(UCAL_YEAR, year);
@@ -349,7 +350,7 @@ GregorianCalendar::setGregorianChange(UDate date, UErrorCode& status)
// Normalize the year so BC values are represented as 0 and negative
// values.
GregorianCalendar *cal = new GregorianCalendar(getTimeZone(), status);
- /* test for NULL */
+ /* test for nullptr */
if (cal == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -388,7 +389,7 @@ void GregorianCalendar::handleComputeFields(int32_t julianDay, UErrorCode& statu
// The Julian epoch day (not the same as Julian Day)
// is zero on Saturday December 30, 0 (Gregorian).
int32_t julianEpochDay = julianDay - (kJan1_1JulianDay - 2);
- eyear = (int32_t) ClockMath::floorDivide((4.0*julianEpochDay) + 1464.0, (int32_t) 1461, unusedRemainder);
+ eyear = (int32_t) ClockMath::floorDivide((4.0*julianEpochDay) + 1464.0, (int32_t) 1461, &unusedRemainder);
// Compute the Julian calendar day number for January 1, eyear
int32_t january1 = 365*(eyear-1) + ClockMath::floorDivide(eyear-1, (int32_t)4);
@@ -435,6 +436,7 @@ void GregorianCalendar::handleComputeFields(int32_t julianDay, UErrorCode& statu
}
internalSet(UCAL_MONTH, month);
+ internalSet(UCAL_ORDINAL_MONTH, month);
internalSet(UCAL_DAY_OF_MONTH, dayOfMonth);
internalSet(UCAL_DAY_OF_YEAR, dayOfYear);
internalSet(UCAL_EXTENDED_YEAR, eyear);
@@ -472,27 +474,27 @@ GregorianCalendar::isLeapYear(int32_t year) const
int32_t GregorianCalendar::handleComputeJulianDay(UCalendarDateFields bestField)
{
- fInvertGregorian = FALSE;
+ fInvertGregorian = false;
int32_t jd = Calendar::handleComputeJulianDay(bestField);
if((bestField == UCAL_WEEK_OF_YEAR) && // if we are doing WOY calculations, we are counting relative to Jan 1 *julian*
(internalGet(UCAL_EXTENDED_YEAR)==fGregorianCutoverYear) &&
jd >= fCutoverJulianDay) {
- fInvertGregorian = TRUE; // So that the Julian Jan 1 will be used in handleComputeMonthStart
+ fInvertGregorian = true; // So that the Julian Jan 1 will be used in handleComputeMonthStart
return Calendar::handleComputeJulianDay(bestField);
}
// The following check handles portions of the cutover year BEFORE the
// cutover itself happens.
- //if ((fIsGregorian==TRUE) != (jd >= fCutoverJulianDay)) { /* cutoverJulianDay)) { */
- if ((fIsGregorian==TRUE) != (jd >= fCutoverJulianDay)) { /* cutoverJulianDay)) { */
+ //if ((fIsGregorian==true) != (jd >= fCutoverJulianDay)) { /* cutoverJulianDay)) { */
+ if ((fIsGregorian) != (jd >= fCutoverJulianDay)) { /* cutoverJulianDay)) { */
#if defined (U_DEBUG_CAL)
fprintf(stderr, "%s:%d: jd [invert] %d\n",
__FILE__, __LINE__, jd);
#endif
- fInvertGregorian = TRUE;
+ fInvertGregorian = true;
jd = Calendar::handleComputeJulianDay(bestField);
#if defined (U_DEBUG_CAL)
fprintf(stderr, "%s:%d: fIsGregorian %s, fInvertGregorian %s - ",
@@ -537,7 +539,7 @@ int32_t GregorianCalendar::handleComputeMonthStart(int32_t eyear, int32_t month,
// If the month is out of range, adjust it into range, and
// modify the extended year value accordingly.
if (month < 0 || month > 11) {
- eyear += ClockMath::floorDivide(month, 12, month);
+ eyear += ClockMath::floorDivide(month, 12, &month);
}
UBool isLeap = eyear%4 == 0;
@@ -580,7 +582,7 @@ int32_t GregorianCalendar::handleGetMonthLength(int32_t extendedYear, int32_t mo
// If the month is out of range, adjust it into range, and
// modify the extended year value accordingly.
if (month < 0 || month > 11) {
- extendedYear += ClockMath::floorDivide(month, 12, month);
+ extendedYear += ClockMath::floorDivide(month, 12, &month);
}
return isLeapYear(extendedYear) ? kLeapMonthLength[month] : kMonthLength[month];
@@ -633,7 +635,7 @@ GregorianCalendar::yearLength() const
void
GregorianCalendar::pinDayOfMonth()
{
- int32_t monthLen = monthLength(internalGet(UCAL_MONTH));
+ int32_t monthLen = monthLength(internalGetMonth());
int32_t dom = internalGet(UCAL_DATE);
if(dom > monthLen)
set(UCAL_DATE, monthLen);
@@ -651,7 +653,7 @@ GregorianCalendar::validateFields() const
field != UCAL_DAY_OF_YEAR &&
isSet((UCalendarDateFields)field) &&
! boundsCheck(internalGet((UCalendarDateFields)field), (UCalendarDateFields)field))
- return FALSE;
+ return false;
}
// Values differ in Least-Maximum and Maximum should be handled
@@ -659,15 +661,15 @@ GregorianCalendar::validateFields() const
if (isSet(UCAL_DATE)) {
int32_t date = internalGet(UCAL_DATE);
if (date < getMinimum(UCAL_DATE) ||
- date > monthLength(internalGet(UCAL_MONTH))) {
- return FALSE;
+ date > monthLength(internalGetMonth())) {
+ return false;
}
}
if (isSet(UCAL_DAY_OF_YEAR)) {
int32_t days = internalGet(UCAL_DAY_OF_YEAR);
if (days < 1 || days > yearLength()) {
- return FALSE;
+ return false;
}
}
@@ -675,10 +677,10 @@ GregorianCalendar::validateFields() const
// We've checked against minimum and maximum above already.
if (isSet(UCAL_DAY_OF_WEEK_IN_MONTH) &&
0 == internalGet(UCAL_DAY_OF_WEEK_IN_MONTH)) {
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
// -------------------------------------
@@ -821,14 +823,13 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status) {
}
void
-GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& status)
-{
+GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) UPRV_NO_SANITIZE_UNDEFINED {
if((amount == 0) || U_FAILURE(status)) {
return;
}
// J81 processing. (gregorian cutover)
- UBool inCutoverMonth = FALSE;
+ UBool inCutoverMonth = false;
int32_t cMonthLen=0; // 'c' for cutover; in days
int32_t cDayOfMonth=0; // no discontinuity: [0, cMonthLen)
double cMonthStart=0.0; // in ms
@@ -839,7 +840,7 @@ GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& s
case UCAL_DAY_OF_MONTH:
case UCAL_WEEK_OF_MONTH:
{
- int32_t max = monthLength(internalGet(UCAL_MONTH));
+ int32_t max = monthLength(internalGetMonth());
UDate t = internalGetTime();
// We subtract 1 from the DAY_OF_MONTH to make it zero-based, and an
// additional 10 if we are after the cutover. Thus the monthStart
@@ -849,7 +850,7 @@ GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& s
// A month containing the cutover is 10 days shorter.
if ((cMonthStart < fGregorianCutover) &&
(cMonthStart + (cMonthLen=(max-10))*kOneDay >= fGregorianCutover)) {
- inCutoverMonth = TRUE;
+ inCutoverMonth = true;
}
}
break;
@@ -872,7 +873,7 @@ GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& s
// may be one year before or after the calendar year.
int32_t isoYear = get(UCAL_YEAR_WOY, status);
int32_t isoDoy = internalGet(UCAL_DAY_OF_YEAR);
- if (internalGet(UCAL_MONTH) == UCAL_JANUARY) {
+ if (internalGetMonth() == UCAL_JANUARY) {
if (woy >= 52) {
isoDoy += handleGetYearLength(isoYear);
}
@@ -1145,7 +1146,7 @@ int32_t GregorianCalendar::getActualMaximum(UCalendarDateFields field, UErrorCod
return 0;
}
- cal->setLenient(TRUE);
+ cal->setLenient(true);
int32_t era = cal->get(UCAL_ERA, status);
UDate d = cal->getTime(status);
@@ -1237,20 +1238,6 @@ int32_t GregorianCalendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy,
// -------------------------------------
-UBool
-GregorianCalendar::inDaylightTime(UErrorCode& status) const
-{
- if (U_FAILURE(status) || !getTimeZone().useDaylightTime())
- return FALSE;
-
- // Force an update of the state of the Calendar.
- ((GregorianCalendar*)this)->complete(status); // cast away const
-
- return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : FALSE);
-}
-
-// -------------------------------------
-
/**
* Return the ERA. We need a special method for this because the
* default ERA is AD, but a zero (unset) ERA is BC.
@@ -1274,12 +1261,12 @@ GregorianCalendar::getType() const {
*/
static UDate gSystemDefaultCenturyStart = DBL_MIN;
static int32_t gSystemDefaultCenturyStartYear = -1;
-static icu::UInitOnce gSystemDefaultCenturyInit = U_INITONCE_INITIALIZER;
+static icu::UInitOnce gSystemDefaultCenturyInit {};
UBool GregorianCalendar::haveDefaultCentury() const
{
- return TRUE;
+ return true;
}
static void U_CALLCONV
diff --git a/contrib/libs/icu/i18n/gregoimp.cpp b/contrib/libs/icu/i18n/gregoimp.cpp
index 537aa19d8a..31b5aeed83 100644
--- a/contrib/libs/icu/i18n/gregoimp.cpp
+++ b/contrib/libs/icu/i18n/gregoimp.cpp
@@ -33,28 +33,35 @@ int64_t ClockMath::floorDivide(int64_t numerator, int64_t denominator) {
}
int32_t ClockMath::floorDivide(double numerator, int32_t denominator,
- int32_t& remainder) {
- double quotient;
- quotient = uprv_floor(numerator / denominator);
- remainder = (int32_t) (numerator - (quotient * denominator));
+ int32_t* remainder) {
+ // For an integer n and representable ⌊x/n⌋, ⌊RN(x/n)⌋=⌊x/n⌋, where RN is
+ // rounding to nearest.
+ double quotient = uprv_floor(numerator / denominator);
+ if (remainder != nullptr) {
+ // For doubles x and n, where n is an integer and ⌊x+n⌋ < 2³¹, the
+ // expression `(int32_t) (x + n)` evaluated with rounding to nearest
+ // differs from ⌊x+n⌋ if 0 < ⌈x⌉−x ≪ x+n, as `x + n` is rounded up to
+ // n+⌈x⌉ = ⌊x+n⌋ + 1. Rewriting it as ⌊x⌋+n makes the addition exact.
+ *remainder = (int32_t) (uprv_floor(numerator) - (quotient * denominator));
+ }
return (int32_t) quotient;
}
double ClockMath::floorDivide(double dividend, double divisor,
- double& remainder) {
+ double* remainder) {
// Only designed to work for positive divisors
U_ASSERT(divisor > 0);
double quotient = floorDivide(dividend, divisor);
- remainder = dividend - (quotient * divisor);
+ double r = dividend - (quotient * divisor);
// N.B. For certain large dividends, on certain platforms, there
// is a bug such that the quotient is off by one. If you doubt
// this to be true, set a breakpoint below and run cintltst.
- if (remainder < 0 || remainder >= divisor) {
+ if (r < 0 || r >= divisor) {
// E.g. 6.7317038241449352e+022 / 86400000.0 is wrong on my
// machine (too high by one). 4.1792057231752762e+024 /
// 86400000.0 is wrong the other way (too low).
double q = quotient;
- quotient += (remainder < 0) ? -1 : +1;
+ quotient += (r < 0) ? -1 : +1;
if (q == quotient) {
// For quotients > ~2^53, we won't be able to add or
// subtract one, since the LSB of the mantissa will be >
@@ -65,12 +72,15 @@ double ClockMath::floorDivide(double dividend, double divisor,
// values give back an approximate answer rather than
// crashing. For example, UDate values above a ~10^25
// might all have a time of midnight.
- remainder = 0;
+ r = 0;
} else {
- remainder = dividend - (quotient * divisor);
+ r = dividend - (quotient * divisor);
}
}
- U_ASSERT(0 <= remainder && remainder < divisor);
+ U_ASSERT(0 <= r && r < divisor);
+ if (remainder != nullptr) {
+ *remainder = r;
+ }
return quotient;
}
@@ -106,10 +116,10 @@ void Grego::dayToFields(double day, int32_t& year, int32_t& month,
// representation. We use 400-year, 100-year, and 4-year cycles.
// For example, the 4-year cycle has 4 years + 1 leap day; giving
// 1461 == 365*4 + 1 days.
- int32_t n400 = ClockMath::floorDivide(day, 146097, doy); // 400-year cycle length
- int32_t n100 = ClockMath::floorDivide(doy, 36524, doy); // 100-year cycle length
- int32_t n4 = ClockMath::floorDivide(doy, 1461, doy); // 4-year cycle length
- int32_t n1 = ClockMath::floorDivide(doy, 365, doy);
+ int32_t n400 = ClockMath::floorDivide(day, 146097, &doy); // 400-year cycle length
+ int32_t n100 = ClockMath::floorDivide(doy, 36524, &doy); // 100-year cycle length
+ int32_t n4 = ClockMath::floorDivide(doy, 1461, &doy); // 4-year cycle length
+ int32_t n1 = ClockMath::floorDivide(doy, 365, &doy);
year = 400*n400 + 100*n100 + 4*n4 + n1;
if (n100 == 4 || n1 == 4) {
doy = 365; // Dec 31 at end of 4- or 400-year cycle
@@ -137,14 +147,14 @@ void Grego::dayToFields(double day, int32_t& year, int32_t& month,
void Grego::timeToFields(UDate time, int32_t& year, int32_t& month,
int32_t& dom, int32_t& dow, int32_t& doy, int32_t& mid) {
double millisInDay;
- double day = ClockMath::floorDivide((double)time, (double)U_MILLIS_PER_DAY, millisInDay);
+ double day = ClockMath::floorDivide((double)time, (double)U_MILLIS_PER_DAY, &millisInDay);
mid = (int32_t)millisInDay;
dayToFields(day, year, month, dom, dow, doy);
}
int32_t Grego::dayOfWeek(double day) {
int32_t dow;
- ClockMath::floorDivide(day + UCAL_THURSDAY, 7, dow);
+ ClockMath::floorDivide(day + int{UCAL_THURSDAY}, 7, &dow);
return (dow == 0) ? UCAL_SATURDAY : dow;
}
diff --git a/contrib/libs/icu/i18n/gregoimp.h b/contrib/libs/icu/i18n/gregoimp.h
index b1a5bc22c2..d65d6a4f88 100644
--- a/contrib/libs/icu/i18n/gregoimp.h
+++ b/contrib/libs/icu/i18n/gregoimp.h
@@ -78,7 +78,7 @@ class ClockMath {
* @return the floor of the quotient
*/
static int32_t floorDivide(double numerator, int32_t denominator,
- int32_t& remainder);
+ int32_t* remainder);
/**
* For a positive divisor, return the quotient and remainder
@@ -91,7 +91,7 @@ class ClockMath {
* Calling with a divisor <= 0 is disallowed.
*/
static double floorDivide(double dividend, double divisor,
- double& remainder);
+ double* remainder);
};
// Useful millisecond constants
diff --git a/contrib/libs/icu/i18n/hebrwcal.cpp b/contrib/libs/icu/i18n/hebrwcal.cpp
index 4d8e59cef9..efd0d8fd4a 100644
--- a/contrib/libs/icu/i18n/hebrwcal.cpp
+++ b/contrib/libs/icu/i18n/hebrwcal.cpp
@@ -20,10 +20,11 @@
#if !UCONFIG_NO_FORMATTING
#include "cmemory.h"
+#include "cstring.h"
#include "umutex.h"
#include <float.h>
-#include "gregoimp.h" // Math
-#include "astro.h" // CalendarAstronomer
+#include "gregoimp.h" // ClockMath
+#include "astro.h" // CalendarCache
#include "uhash.h"
#include "ucln_in.h"
@@ -63,6 +64,7 @@ static const int32_t LIMITS[UCAL_FIELD_COUNT][4] = {
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // JULIAN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // MILLISECONDS_IN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // IS_LEAP_MONTH
+ { 0, 0, 11, 12}, // ORDINAL_MONTH
};
/**
@@ -134,13 +136,13 @@ static const int16_t LEAP_MONTH_START[][3] = {
{ 383, 384, 385 }, // Elul
};
-static icu::CalendarCache *gCache = NULL;
+static icu::CalendarCache *gCache = nullptr;
U_CDECL_BEGIN
-static UBool calendar_hebrew_cleanup(void) {
+static UBool calendar_hebrew_cleanup() {
delete gCache;
- gCache = NULL;
- return TRUE;
+ gCache = nullptr;
+ return true;
}
U_CDECL_END
@@ -217,7 +219,8 @@ void HebrewCalendar::add(UCalendarDateFields field, int32_t amount, UErrorCode&
return;
}
switch (field) {
- case UCAL_MONTH:
+ case UCAL_MONTH:
+ case UCAL_ORDINAL_MONTH:
{
// We can't just do a set(MONTH, get(MONTH) + amount). The
// reason is ADAR_1. Suppose amount is +2 and we land in
@@ -239,7 +242,7 @@ void HebrewCalendar::add(UCalendarDateFields field, int32_t amount, UErrorCode&
}
month -= ELUL+1;
++year;
- acrossAdar1 = TRUE;
+ acrossAdar1 = true;
}
} else {
acrossAdar1 = (month > ADAR_1); // started after ADAR_1?
@@ -253,7 +256,7 @@ void HebrewCalendar::add(UCalendarDateFields field, int32_t amount, UErrorCode&
}
month += ELUL+1;
--year;
- acrossAdar1 = TRUE;
+ acrossAdar1 = true;
}
}
set(UCAL_MONTH, month);
@@ -315,6 +318,7 @@ void HebrewCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode&
}
switch (field) {
case UCAL_MONTH:
+ case UCAL_ORDINAL_MONTH:
{
int32_t month = get(UCAL_MONTH, status);
int32_t year = get(UCAL_YEAR, status);
@@ -534,7 +538,8 @@ int32_t HebrewCalendar::handleGetYearLength(int32_t eyear) const {
}
void HebrewCalendar::validateField(UCalendarDateFields field, UErrorCode &status) {
- if (field == UCAL_MONTH && !isLeapYear(handleGetExtendedYear()) && internalGet(UCAL_MONTH) == ADAR_1) {
+ if ((field == UCAL_MONTH || field == UCAL_ORDINAL_MONTH)
+ && !isLeapYear(handleGetExtendedYear()) && internalGetMonth() == ADAR_1) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@@ -607,6 +612,11 @@ void HebrewCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status)
internalSet(UCAL_ERA, 0);
internalSet(UCAL_YEAR, year);
internalSet(UCAL_EXTENDED_YEAR, year);
+ int32_t ordinal_month = month;
+ if (!isLeap && ordinal_month > ADAR_1) {
+ ordinal_month--;
+ }
+ internalSet(UCAL_ORDINAL_MONTH, ordinal_month);
internalSet(UCAL_MONTH, month);
internalSet(UCAL_DAY_OF_MONTH, dayOfMonth);
internalSet(UCAL_DAY_OF_YEAR, dayOfYear);
@@ -666,17 +676,21 @@ int32_t HebrewCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, UB
return (int) (day + 347997);
}
-UBool
-HebrewCalendar::inDaylightTime(UErrorCode& status) const
-{
- // copied from GregorianCalendar
- if (U_FAILURE(status) || !getTimeZone().useDaylightTime())
- return FALSE;
+constexpr uint32_t kHebrewRelatedYearDiff = -3760;
- // Force an update of the state of the Calendar.
- ((HebrewCalendar*)this)->complete(status); // cast away const
+int32_t HebrewCalendar::getRelatedYear(UErrorCode &status) const
+{
+ int32_t year = get(UCAL_EXTENDED_YEAR, status);
+ if (U_FAILURE(status)) {
+ return 0;
+ }
+ return year + kHebrewRelatedYearDiff;
+}
- return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : FALSE);
+void HebrewCalendar::setRelatedYear(int32_t year)
+{
+ // set extended year
+ set(UCAL_EXTENDED_YEAR, year - kHebrewRelatedYearDiff);
}
/**
@@ -686,11 +700,11 @@ HebrewCalendar::inDaylightTime(UErrorCode& status) const
*/
static UDate gSystemDefaultCenturyStart = DBL_MIN;
static int32_t gSystemDefaultCenturyStartYear = -1;
-static icu::UInitOnce gSystemDefaultCenturyInit = U_INITONCE_INITIALIZER;
+static icu::UInitOnce gSystemDefaultCenturyInit {};
UBool HebrewCalendar::haveDefaultCentury() const
{
- return TRUE;
+ return true;
}
static void U_CALLCONV initializeSystemDefaultCentury()
@@ -724,6 +738,49 @@ int32_t HebrewCalendar::defaultCenturyStartYear() const {
return gSystemDefaultCenturyStartYear;
}
+bool HebrewCalendar::inTemporalLeapYear(UErrorCode& status) const {
+ if (U_FAILURE(status)) return false;
+ int32_t eyear = get(UCAL_EXTENDED_YEAR, status);
+ if (U_FAILURE(status)) return false;
+ return isLeapYear(eyear);
+}
+
+static const char * const gTemporalMonthCodesForHebrew[] = {
+ "M01", "M02", "M03", "M04", "M05", "M05L", "M06",
+ "M07", "M08", "M09", "M10", "M11", "M12", nullptr
+};
+
+const char* HebrewCalendar::getTemporalMonthCode(UErrorCode& status) const {
+ int32_t month = get(UCAL_MONTH, status);
+ if (U_FAILURE(status)) return nullptr;
+ return gTemporalMonthCodesForHebrew[month];
+}
+
+void HebrewCalendar::setTemporalMonthCode(const char* code, UErrorCode& status )
+{
+ if (U_FAILURE(status)) return;
+ int32_t len = static_cast<int32_t>(uprv_strlen(code));
+ if (len == 3 || len == 4) {
+ for (int m = 0; gTemporalMonthCodesForHebrew[m] != nullptr; m++) {
+ if (uprv_strcmp(code, gTemporalMonthCodesForHebrew[m]) == 0) {
+ set(UCAL_MONTH, m);
+ return;
+ }
+ }
+ }
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+}
+
+int32_t HebrewCalendar::internalGetMonth() const {
+ if (resolveFields(kMonthPrecedence) == UCAL_ORDINAL_MONTH) {
+ int32_t ordinalMonth = internalGet(UCAL_ORDINAL_MONTH);
+ HebrewCalendar *nonConstThis = (HebrewCalendar*)this; // cast away const
+
+ int32_t year = nonConstThis->handleGetExtendedYear();
+ return ordinalMonth + ((isLeapYear(year) && (ordinalMonth > ADAR_1)) ? 1: 0);
+ }
+ return Calendar::internalGetMonth();
+}
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(HebrewCalendar)
diff --git a/contrib/libs/icu/i18n/hebrwcal.h b/contrib/libs/icu/i18n/hebrwcal.h
index ae4401832d..829a642211 100644
--- a/contrib/libs/icu/i18n/hebrwcal.h
+++ b/contrib/libs/icu/i18n/hebrwcal.h
@@ -88,7 +88,7 @@ public:
* Useful constants for HebrewCalendar.
* @internal
*/
- enum EEras {
+ enum Month {
/**
* Constant for Tishri, the 1st month of the Hebrew year.
*/
@@ -181,13 +181,6 @@ public:
HebrewCalendar(const HebrewCalendar& source);
/**
- * Default assignment operator
- * @param right the object to be copied.
- * @internal
- */
- HebrewCalendar& operator=(const HebrewCalendar& right);
-
- /**
* Create and return a polymorphic copy of this calendar.
* @return return a polymorphic copy of this calendar.
* @internal
@@ -205,7 +198,7 @@ public:
* same class ID. Objects of other classes have different class IDs.
* @internal
*/
- virtual UClassID getDynamicClassID(void) const override;
+ virtual UClassID getDynamicClassID() const override;
/**
* Return the class ID for this class. This is useful only for comparing to a return
@@ -218,7 +211,7 @@ public:
* @return The class ID for all objects of this class.
* @internal
*/
- static UClassID U_EXPORT2 getStaticClassID(void);
+ static UClassID U_EXPORT2 getStaticClassID();
/**
* return the calendar type, "hebrew".
@@ -280,6 +273,20 @@ public:
*/
static UBool isLeapYear(int32_t year) ;
+ /**
+ * @return The related Gregorian year; will be obtained by modifying the value
+ * obtained by get from UCAL_EXTENDED_YEAR field
+ * @internal
+ */
+ virtual int32_t getRelatedYear(UErrorCode &status) const override;
+
+ /**
+ * @param year The related Gregorian year to set; will be modified as necessary then
+ * set in UCAL_EXTENDED_YEAR field
+ * @internal
+ */
+ virtual void setRelatedYear(int32_t year) override;
+
protected:
/**
@@ -373,18 +380,6 @@ public:
virtual void validateField(UCalendarDateFields field, UErrorCode &status) override;
protected:
-
- /**
- * (Overrides Calendar) Return true if the current date for this Calendar is in
- * Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
- *
- * @param status Fill-in parameter which receives the status of this operation.
- * @return True if the current date for this Calendar is in Daylight Savings Time,
- * false, otherwise.
- * @internal
- */
- virtual UBool inDaylightTime(UErrorCode& status) const override;
-
/**
* Returns true because the Hebrew Calendar does have a default century
* @internal
@@ -404,6 +399,51 @@ public:
*/
virtual int32_t defaultCenturyStartYear() const override;
+ public:
+ /**
+ * Returns true if the date is in a leap year.
+ *
+ * @param status ICU Error Code
+ * @return True if the date in the fields is in a Temporal proposal
+ * defined leap year. False otherwise.
+ */
+ virtual bool inTemporalLeapYear(UErrorCode& status) const override;
+
+ /**
+ * Gets The Temporal monthCode value corresponding to the month for the date.
+ * The value is a string identifier that starts with the literal grapheme
+ * "M" followed by two graphemes representing the zero-padded month number
+ * of the current month in a normal (non-leap) year and suffixed by an
+ * optional literal grapheme "L" if this is a leap month in a lunisolar
+ * calendar. For the Hebrew calendar, the values are "M01" .. "M12" for
+ * non-leap year, and "M01" .. "M05", "M05L", "M06" .. "M12" for leap year.
+ *
+ * @param status ICU Error Code
+ * @return One of 13 possible strings in {"M01".. "M05", "M05L",
+ * "M06" .. "M12"}.
+ * @draft ICU 73
+ */
+ virtual const char* getTemporalMonthCode(UErrorCode& status) const override;
+
+ /**
+ * Sets The Temporal monthCode which is a string identifier that starts
+ * with the literal grapheme "M" followed by two graphemes representing
+ * the zero-padded month number of the current month in a normal
+ * (non-leap) year and suffixed by an optional literal grapheme "L" if this
+ * is a leap month in a lunisolar calendar. For Hebrew calendar, the values
+ * are "M01" .. "M12" for non-leap years, and "M01" .. "M05", "M05L", "M06"
+ * .. "M12" for leap year.
+ *
+ * @param temporalMonth The value to be set for temporal monthCode.
+ * @param status ICU Error Code
+ *
+ * @draft ICU 73
+ */
+ virtual void setTemporalMonthCode(const char* code, UErrorCode& status ) override;
+
+ protected:
+ virtual int32_t internalGetMonth() const override;
+
private: // Calendar-specific implementation
/**
* Finds the day # of the first day in the given Hebrew year.
diff --git a/contrib/libs/icu/i18n/indiancal.cpp b/contrib/libs/icu/i18n/indiancal.cpp
index 7bba7f5092..29c2749f48 100644
--- a/contrib/libs/icu/i18n/indiancal.cpp
+++ b/contrib/libs/icu/i18n/indiancal.cpp
@@ -16,7 +16,6 @@
#include "mutex.h"
#include <float.h>
#include "gregoimp.h" // Math
-#include "astro.h" // CalendarAstronomer
#include "uhash.h"
// Debugging
@@ -81,6 +80,7 @@ static const int32_t LIMITS[UCAL_FIELD_COUNT][4] = {
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // JULIAN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // MILLISECONDS_IN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // IS_LEAP_MONTH
+ { 0, 0, 11, 11}, // ORDINAL_MONTH
};
static const int32_t INDIAN_ERA_START = 78;
@@ -110,7 +110,7 @@ static UBool isGregorianLeap(int32_t year)
*/
int32_t IndianCalendar::handleGetMonthLength(int32_t eyear, int32_t month) const {
if (month < 0 || month > 11) {
- eyear += ClockMath::floorDivide(month, 12, month);
+ eyear += ClockMath::floorDivide(month, 12, &month);
}
if (isGregorianLeap(eyear + INDIAN_ERA_START) && month == 0) {
@@ -210,7 +210,7 @@ int32_t IndianCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, UB
// If the month is out of range, adjust it into range, and adjust the extended year accordingly
if (month < 0 || month > 11) {
- eyear += (int32_t)ClockMath::floorDivide(month, 12, month);
+ eyear += (int32_t)ClockMath::floorDivide(month, 12, &month);
}
if(month == 12){
@@ -294,24 +294,27 @@ void IndianCalendar::handleComputeFields(int32_t julianDay, UErrorCode& /* stat
internalSet(UCAL_EXTENDED_YEAR, IndianYear);
internalSet(UCAL_YEAR, IndianYear);
internalSet(UCAL_MONTH, IndianMonth);
+ internalSet(UCAL_ORDINAL_MONTH, IndianMonth);
internalSet(UCAL_DAY_OF_MONTH, IndianDayOfMonth);
internalSet(UCAL_DAY_OF_YEAR, yday + 1); // yday is 0-based
}
-UBool
-IndianCalendar::inDaylightTime(UErrorCode& status) const
+constexpr uint32_t kIndianRelatedYearDiff = 79;
+
+int32_t IndianCalendar::getRelatedYear(UErrorCode &status) const
{
- // copied from GregorianCalendar
- if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) {
- return FALSE;
+ int32_t year = get(UCAL_EXTENDED_YEAR, status);
+ if (U_FAILURE(status)) {
+ return 0;
}
-
- // Force an update of the state of the Calendar.
- ((IndianCalendar*)this)->complete(status); // cast away const
-
- return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : FALSE);
+ return year + kIndianRelatedYearDiff;
}
+void IndianCalendar::setRelatedYear(int32_t year)
+{
+ // set extended year
+ set(UCAL_EXTENDED_YEAR, year - kIndianRelatedYearDiff);
+}
/**
* The system maintains a static default century start date and Year. They are
@@ -320,12 +323,12 @@ IndianCalendar::inDaylightTime(UErrorCode& status) const
*/
static UDate gSystemDefaultCenturyStart = DBL_MIN;
static int32_t gSystemDefaultCenturyStartYear = -1;
-static icu::UInitOnce gSystemDefaultCenturyInit = U_INITONCE_INITIALIZER;
+static icu::UInitOnce gSystemDefaultCenturyInit {};
UBool IndianCalendar::haveDefaultCentury() const
{
- return TRUE;
+ return true;
}
static void U_CALLCONV
diff --git a/contrib/libs/icu/i18n/indiancal.h b/contrib/libs/icu/i18n/indiancal.h
index 029515cf54..5ef9113a85 100644
--- a/contrib/libs/icu/i18n/indiancal.h
+++ b/contrib/libs/icu/i18n/indiancal.h
@@ -261,7 +261,7 @@ public:
* same class ID. Objects of other classes have different class IDs.
* @internal
*/
- virtual UClassID getDynamicClassID(void) const override;
+ virtual UClassID getDynamicClassID() const override;
/**
* Return the class ID for this class. This is useful only for comparing to a return
@@ -274,7 +274,7 @@ public:
* @return The class ID for all objects of this class.
* @internal
*/
- static UClassID U_EXPORT2 getStaticClassID(void);
+ static UClassID U_EXPORT2 getStaticClassID();
/**
* return the calendar type, "indian".
@@ -284,24 +284,26 @@ public:
*/
virtual const char * getType() const override;
-private:
- IndianCalendar(); // default constructor not implemented
-
- // Default century.
-protected:
+ /**
+ * @return The related Gregorian year; will be obtained by modifying the value
+ * obtained by get from UCAL_EXTENDED_YEAR field
+ * @internal
+ */
+ virtual int32_t getRelatedYear(UErrorCode &status) const override;
/**
- * (Overrides Calendar) Return true if the current date for this Calendar is in
- * Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
- *
- * @param status Fill-in parameter which receives the status of this operation.
- * @return True if the current date for this Calendar is in Daylight Savings Time,
- * false, otherwise.
+ * @param year The related Gregorian year to set; will be modified as necessary then
+ * set in UCAL_EXTENDED_YEAR field
* @internal
*/
- virtual UBool inDaylightTime(UErrorCode& status) const override;
+ virtual void setRelatedYear(int32_t year) override;
+
+private:
+ IndianCalendar() = delete; // default constructor not implemented
+ // Default century.
+protected:
/**
* Returns true because the Indian Calendar does have a default century
* @internal
diff --git a/contrib/libs/icu/i18n/inputext.cpp b/contrib/libs/icu/i18n/inputext.cpp
index fa4939e8f4..bce9862c0f 100644
--- a/contrib/libs/icu/i18n/inputext.cpp
+++ b/contrib/libs/icu/i18n/inputext.cpp
@@ -34,7 +34,7 @@ InputText::InputText(UErrorCode &status)
fRawInput(0),
fRawLength(0)
{
- if (fInputBytes == NULL || fByteStats == NULL) {
+ if (fInputBytes == nullptr || fByteStats == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
}
@@ -49,7 +49,7 @@ InputText::~InputText()
void InputText::setText(const char *in, int32_t len)
{
fInputLen = 0;
- fC1Bytes = FALSE;
+ fC1Bytes = false;
fRawInput = (const uint8_t *) in;
fRawLength = len == -1? (int32_t)uprv_strlen(in) : len;
}
@@ -70,7 +70,7 @@ void InputText::setDeclaredEncoding(const char* encoding, int32_t len)
UBool InputText::isSet() const
{
- return fRawInput != NULL;
+ return fRawInput != nullptr;
}
/**
@@ -83,7 +83,7 @@ void InputText::MungeInput(UBool fStripTags) {
int srci = 0;
int dsti = 0;
uint8_t b;
- bool inMarkup = FALSE;
+ bool inMarkup = false;
int32_t openTags = 0;
int32_t badTags = 0;
@@ -103,7 +103,7 @@ void InputText::MungeInput(UBool fStripTags) {
badTags += 1;
}
- inMarkup = TRUE;
+ inMarkup = true;
openTags += 1;
}
@@ -112,7 +112,7 @@ void InputText::MungeInput(UBool fStripTags) {
}
if (b == (uint8_t)0x3E) { /* Check for the ASCII '>' */
- inMarkup = FALSE;
+ inMarkup = false;
}
}
@@ -153,7 +153,7 @@ void InputText::MungeInput(UBool fStripTags) {
for (int32_t i = 0x80; i <= 0x9F; i += 1) {
if (fByteStats[i] != 0) {
- fC1Bytes = TRUE;
+ fC1Bytes = true;
break;
}
}
diff --git a/contrib/libs/icu/i18n/islamcal.cpp b/contrib/libs/icu/i18n/islamcal.cpp
index de37e6b939..c21530a736 100644
--- a/contrib/libs/icu/i18n/islamcal.cpp
+++ b/contrib/libs/icu/i18n/islamcal.cpp
@@ -54,20 +54,20 @@ static void debug_islamcal_msg(const char *pat, ...)
// --- The cache --
// cache of months
-static icu::CalendarCache *gMonthCache = NULL;
-static icu::CalendarAstronomer *gIslamicCalendarAstro = NULL;
+static icu::CalendarCache *gMonthCache = nullptr;
+static icu::CalendarAstronomer *gIslamicCalendarAstro = nullptr;
U_CDECL_BEGIN
-static UBool calendar_islamic_cleanup(void) {
+static UBool calendar_islamic_cleanup() {
if (gMonthCache) {
delete gMonthCache;
- gMonthCache = NULL;
+ gMonthCache = nullptr;
}
if (gIslamicCalendarAstro) {
delete gIslamicCalendarAstro;
- gIslamicCalendarAstro = NULL;
+ gIslamicCalendarAstro = nullptr;
}
- return TRUE;
+ return true;
}
U_CDECL_END
@@ -206,67 +206,22 @@ int32_t getUmalqura_MonthLength(int32_t y, int32_t m) {
//-------------------------------------------------------------------------
const char *IslamicCalendar::getType() const {
- const char *sType = NULL;
-
- switch (cType) {
- case CIVIL:
- sType = "islamic-civil";
- break;
- case ASTRONOMICAL:
- sType = "islamic";
- break;
- case TBLA:
- sType = "islamic-tbla";
- break;
- case UMALQURA:
- sType = "islamic-umalqura";
- break;
- default:
- UPRV_UNREACHABLE_EXIT; // out of range
- }
- return sType;
+ return "islamic";
}
IslamicCalendar* IslamicCalendar::clone() const {
return new IslamicCalendar(*this);
}
-IslamicCalendar::IslamicCalendar(const Locale& aLocale, UErrorCode& success, ECalculationType type)
-: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success),
-cType(type)
+IslamicCalendar::IslamicCalendar(const Locale& aLocale, UErrorCode& success)
+: Calendar(TimeZone::forLocaleOrDefault(aLocale), aLocale, success)
{
setTimeInMillis(getNow(), success); // Call this again now that the vtable is set up properly.
}
-IslamicCalendar::IslamicCalendar(const IslamicCalendar& other) : Calendar(other), cType(other.cType) {
-}
-
IslamicCalendar::~IslamicCalendar()
{
}
-
-void IslamicCalendar::setCalculationType(ECalculationType type, UErrorCode &status)
-{
- if (cType != type) {
- // The fields of the calendar will become invalid, because the calendar
- // rules are different
- UDate m = getTimeInMillis(status);
- cType = type;
- clear();
- setTimeInMillis(m, status);
- }
-}
-
-/**
-* Returns <code>true</code> if this object is using the fixed-cycle civil
-* calendar, or <code>false</code> if using the religious, astronomical
-* calendar.
-* @draft ICU 2.4
-*/
-UBool IslamicCalendar::isCivil() {
- return (cType == CIVIL);
-}
-
//-------------------------------------------------------------------------
// Minimum / Maximum access functions
//-------------------------------------------------------------------------
@@ -304,6 +259,7 @@ static const int32_t LIMITS[UCAL_FIELD_COUNT][4] = {
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // JULIAN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // MILLISECONDS_IN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // IS_LEAP_MONTH
+ { 0, 0, 11, 11}, // ORDINAL_MONTH
};
/**
@@ -365,19 +321,7 @@ UBool IslamicCalendar::civilLeapYear(int32_t year)
* from the Hijri epoch, origin 0.
*/
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*(int64_t)year),(int64_t)30);
- } else if(cType==ASTRONOMICAL){
- return trueMonthStart(12*(year-1));
- } else {
- year -= UMALQURA_YEAR_START;
- // rounded least-squares fit of the dates previously calculated from UMALQURA_MONTHLENGTH iteration
- int32_t yrStartLinearEstimate = (int32_t)((354.36720 * (double)year) + 460322.05 + 0.5);
- // need a slight correction to some
- return yrStartLinearEstimate + umAlQuraYrStartEstimateFix[year];
- }
+ return trueMonthStart(12*(year-1));
}
/**
@@ -388,19 +332,7 @@ int32_t IslamicCalendar::yearStart(int32_t year) const{
* @param month The hijri month, 0-based (assumed to be in range 0..11)
*/
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*(int64_t)year),(int64_t)30);
- } else if(cType==ASTRONOMICAL){
- return trueMonthStart(12*(year-1) + month);
- } else {
- int32_t ms = yearStart(year);
- for(int i=0; i< month; i++){
- ms+= handleGetMonthLength(year, i);
- }
- return ms;
- }
+ return trueMonthStart(12*(year-1) + month);
}
/**
@@ -473,9 +405,9 @@ double IslamicCalendar::moonAge(UDate time, UErrorCode &status)
static UMutex astroLock; // pod bay door lock
umtx_lock(&astroLock);
- if(gIslamicCalendarAstro == NULL) {
+ if(gIslamicCalendarAstro == nullptr) {
gIslamicCalendarAstro = new CalendarAstronomer();
- if (gIslamicCalendarAstro == NULL) {
+ if (gIslamicCalendarAstro == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return age;
}
@@ -506,22 +438,8 @@ double IslamicCalendar::moonAge(UDate time, UErrorCode &status)
* @draft ICU 2.4
*/
int32_t IslamicCalendar::handleGetMonthLength(int32_t extendedYear, int32_t month) const {
-
- int32_t length = 0;
-
- if (cType == CIVIL || cType == TBLA ||
- (cType == UMALQURA && (extendedYear<UMALQURA_YEAR_START || extendedYear>UMALQURA_YEAR_END)) ) {
- length = 29 + (month+1) % 2;
- if (month == DHU_AL_HIJJAH && civilLeapYear(extendedYear)) {
- length++;
- }
- } else if(cType == ASTRONOMICAL){
- month = 12*(extendedYear-1) + month;
- length = trueMonthStart(month+1) - trueMonthStart(month) ;
- } else {
- length = getUmalqura_MonthLength(extendedYear - UMALQURA_YEAR_START, month);
- }
- return length;
+ month = 12*(extendedYear-1) + month;
+ return trueMonthStart(month+1) - trueMonthStart(month) ;
}
/**
@@ -529,19 +447,8 @@ int32_t IslamicCalendar::handleGetMonthLength(int32_t extendedYear, int32_t mont
* @draft ICU 2.4
*/
int32_t IslamicCalendar::handleGetYearLength(int32_t extendedYear) const {
- if (cType == CIVIL || cType == TBLA ||
- (cType == UMALQURA && (extendedYear<UMALQURA_YEAR_START || extendedYear>UMALQURA_YEAR_END)) ) {
- return 354 + (civilLeapYear(extendedYear) ? 1 : 0);
- } else if(cType == ASTRONOMICAL){
- int32_t month = 12*(extendedYear-1);
- return (trueMonthStart(month + 12) - trueMonthStart(month));
- } else {
- int len = 0;
- for(int i=0; i<12; i++) {
- len += handleGetMonthLength(extendedYear, i);
- }
- return len;
- }
+ int32_t month = 12*(extendedYear-1);
+ return (trueMonthStart(month + 12) - trueMonthStart(month));
}
//-------------------------------------------------------------------------
@@ -567,8 +474,8 @@ int32_t IslamicCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, U
eyear += (month / 12) - 1;
month = (month % 12) + 11;
}
- return monthStart(eyear, month) + ((cType == TBLA)? ASTRONOMICAL_EPOC: CIVIL_EPOC) - 1;
-}
+ return monthStart(eyear, month) + getEpoc() - 1;
+}
//-------------------------------------------------------------------------
// Functions for converting from milliseconds to field values
@@ -604,105 +511,97 @@ int32_t IslamicCalendar::handleGetExtendedYear() {
* @draft ICU 2.4
*/
void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) {
- int32_t year, month, dayOfMonth, dayOfYear;
- int32_t startDate;
- int32_t days = julianDay - CIVIL_EPOC;
+ if (U_FAILURE(status)) return;
+ int32_t days = julianDay - getEpoc();
- if (cType == CIVIL || cType == TBLA) {
- if(cType == TBLA) {
- days = julianDay - ASTRONOMICAL_EPOC;
- }
- // Use the civil calendar approximation, which is just arithmetic
- year = (int32_t)ClockMath::floorDivide(30 * (int64_t)days + 10646, (int64_t)10631);
- month = (int32_t)uprv_ceil((days - 29 - yearStart(year)) / 29.5 );
- month = month<11?month:11;
- startDate = monthStart(year, month);
- } else if(cType == ASTRONOMICAL){
- // Guess at the number of elapsed full months since the epoch
- int32_t months = (int32_t)uprv_floor((double)days / CalendarAstronomer::SYNODIC_MONTH);
+ // Guess at the number of elapsed full months since the epoch
+ int32_t month = (int32_t)uprv_floor((double)days / CalendarAstronomer::SYNODIC_MONTH);
- startDate = (int32_t)uprv_floor(months * CalendarAstronomer::SYNODIC_MONTH);
+ int32_t startDate = (int32_t)uprv_floor(month * CalendarAstronomer::SYNODIC_MONTH);
- double age = moonAge(internalGetTime(), status);
- if (U_FAILURE(status)) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return;
- }
- if ( days - startDate >= 25 && age > 0) {
- // If we're near the end of the month, assume next month and search backwards
- months++;
- }
-
- // Find out the last time that the new moon was actually visible at this longitude
- // This returns midnight the night that the moon was visible at sunset.
- while ((startDate = trueMonthStart(months)) > days) {
- // If it was after the date in question, back up a month and try again
- months--;
- }
+ double age = moonAge(internalGetTime(), status);
+ if (U_FAILURE(status)) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ if ( days - startDate >= 25 && age > 0) {
+ // If we're near the end of the month, assume next month and search backwards
+ month++;
+ }
- 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 = (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);
- }else{
- int y =UMALQURA_YEAR_START-1, m =0;
- long d = 1;
- while(d > 0){
- y++;
- d = days - yearStart(y) +1;
- if(d == handleGetYearLength(y)){
- m=11;
- break;
- }else if(d < handleGetYearLength(y) ){
- int monthLen = handleGetMonthLength(y, m);
- m=0;
- while(d > monthLen){
- d -= monthLen;
- m++;
- monthLen = handleGetMonthLength(y, m);
- }
- break;
- }
- }
- year = y;
- month = m;
- }
- } else { // invalid 'civil'
- UPRV_UNREACHABLE_EXIT; // should not get here, out of range
+ // Find out the last time that the new moon was actually visible at this longitude
+ // This returns midnight the night that the moon was visible at sunset.
+ while ((startDate = trueMonthStart(month)) > days) {
+ // If it was after the date in question, back up a month and try again
+ month--;
}
- dayOfMonth = (days - monthStart(year, month)) + 1;
+ int32_t year = month >= 0 ? ((month / 12) + 1) : ((month + 1 ) / 12);
+ month = ((month % 12) + 12 ) % 12;
+ int32_t dayOfMonth = (days - monthStart(year, month)) + 1;
// Now figure out the day of the year.
- dayOfYear = (days - monthStart(year, 0)) + 1;
-
+ int32_t dayOfYear = (days - monthStart(year, 0)) + 1;
internalSet(UCAL_ERA, 0);
internalSet(UCAL_YEAR, year);
internalSet(UCAL_EXTENDED_YEAR, year);
internalSet(UCAL_MONTH, month);
+ internalSet(UCAL_ORDINAL_MONTH, month);
internalSet(UCAL_DAY_OF_MONTH, dayOfMonth);
- internalSet(UCAL_DAY_OF_YEAR, dayOfYear);
-}
+ internalSet(UCAL_DAY_OF_YEAR, dayOfYear);
+}
+
+int32_t IslamicCalendar::getEpoc() const {
+ return CIVIL_EPOC;
+}
-UBool
-IslamicCalendar::inDaylightTime(UErrorCode& status) const
+static int32_t gregoYearFromIslamicStart(int32_t year) {
+ // ad hoc conversion, improve under #10752
+ // rough est for now, ok for grego 1846-2138,
+ // otherwise occasionally wrong (for 3% of years)
+ int cycle, offset, shift = 0;
+ if (year >= 1397) {
+ cycle = (year - 1397) / 67;
+ offset = (year - 1397) % 67;
+ shift = 2*cycle + ((offset >= 33)? 1: 0);
+ } else {
+ cycle = (year - 1396) / 67 - 1;
+ offset = -(year - 1396) % 67;
+ shift = 2*cycle + ((offset <= 33)? 1: 0);
+ }
+ return year + 579 - shift;
+}
+
+int32_t IslamicCalendar::getRelatedYear(UErrorCode &status) const
{
- // copied from GregorianCalendar
- if (U_FAILURE(status) || !getTimeZone().useDaylightTime())
- return FALSE;
+ int32_t year = get(UCAL_EXTENDED_YEAR, status);
+ if (U_FAILURE(status)) {
+ return 0;
+ }
+ return gregoYearFromIslamicStart(year);
+}
- // Force an update of the state of the Calendar.
- ((IslamicCalendar*)this)->complete(status); // cast away const
+static int32_t firstIslamicStartYearFromGrego(int32_t year) {
+ // ad hoc conversion, improve under #10752
+ // rough est for now, ok for grego 1846-2138,
+ // otherwise occasionally wrong (for 3% of years)
+ int cycle, offset, shift = 0;
+ if (year >= 1977) {
+ cycle = (year - 1977) / 65;
+ offset = (year - 1977) % 65;
+ shift = 2*cycle + ((offset >= 32)? 1: 0);
+ } else {
+ cycle = (year - 1976) / 65 - 1;
+ offset = -(year - 1976) % 65;
+ shift = 2*cycle + ((offset <= 32)? 1: 0);
+ }
+ return year - 579 + shift;
+}
- return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : FALSE);
+void IslamicCalendar::setRelatedYear(int32_t year)
+{
+ set(UCAL_EXTENDED_YEAR, firstIslamicStartYearFromGrego(year));
}
/**
@@ -712,12 +611,12 @@ IslamicCalendar::inDaylightTime(UErrorCode& status) const
*/
static UDate gSystemDefaultCenturyStart = DBL_MIN;
static int32_t gSystemDefaultCenturyStartYear = -1;
-static icu::UInitOnce gSystemDefaultCenturyInit = U_INITONCE_INITIALIZER;
+static icu::UInitOnce gSystemDefaultCenturyInit {};
UBool IslamicCalendar::haveDefaultCentury() const
{
- return TRUE;
+ return true;
}
UDate IslamicCalendar::defaultCenturyStart() const
@@ -734,6 +633,14 @@ int32_t IslamicCalendar::defaultCenturyStartYear() const
return gSystemDefaultCenturyStartYear;
}
+bool
+IslamicCalendar::inTemporalLeapYear(UErrorCode &status) const
+{
+ int32_t days = getActualMaximum(UCAL_DAY_OF_YEAR, status);
+ if (U_FAILURE(status)) return false;
+ return days == 355;
+}
+
U_CFUNC void U_CALLCONV
IslamicCalendar::initializeSystemDefaultCentury()
@@ -754,9 +661,317 @@ IslamicCalendar::initializeSystemDefaultCentury()
// out.
}
+/*****************************************************************************
+ * IslamicCivilCalendar
+ *****************************************************************************/
+IslamicCivilCalendar::IslamicCivilCalendar(const Locale& aLocale, UErrorCode& success)
+ : IslamicCalendar(aLocale, success)
+{
+}
+
+IslamicCivilCalendar::~IslamicCivilCalendar()
+{
+}
+
+const char *IslamicCivilCalendar::getType() const {
+ return "islamic-civil";
+}
+
+IslamicCivilCalendar* IslamicCivilCalendar::clone() const {
+ return new IslamicCivilCalendar(*this);
+}
+
+/**
+* Return the day # on which the given year starts. Days are counted
+* from the Hijri epoch, origin 0.
+*/
+int32_t IslamicCivilCalendar::yearStart(int32_t year) const{
+ return static_cast<int32_t>(
+ (year-1)*354 + ClockMath::floorDivide((3+11*static_cast<int64_t>(year)),
+ static_cast<int64_t>(30)));
+}
+
+/**
+* Return the day # on which the given month starts. Days are counted
+* from the Hijri epoch, origin 0.
+*
+* @param year The hijri year
+* @param month The hijri month, 0-based (assumed to be in range 0..11)
+*/
+int32_t IslamicCivilCalendar::monthStart(int32_t year, int32_t month) const {
+ // This does not handle months out of the range 0..11
+ return static_cast<int32_t>(
+ uprv_ceil(29.5*month) + (year-1)*354 +
+ static_cast<int32_t>(ClockMath::floorDivide(
+ 3+11*static_cast<int64_t>(year),
+ static_cast<int64_t>(30))));
+}
+
+/**
+* Return the length (in days) of the given month.
+*
+* @param year The hijri year
+* @param year The hijri month, 0-based
+* @draft ICU 2.4
+*/
+int32_t IslamicCivilCalendar::handleGetMonthLength(int32_t extendedYear, int32_t month) const {
+ int32_t length = 29 + (month+1) % 2;
+ if (month == DHU_AL_HIJJAH && civilLeapYear(extendedYear)) {
+ length++;
+ }
+ return length;
+}
+
+/**
+* Return the number of days in the given Islamic year
+* @draft ICU 2.4
+*/
+int32_t IslamicCivilCalendar::handleGetYearLength(int32_t extendedYear) const {
+ return 354 + (civilLeapYear(extendedYear) ? 1 : 0);
+}
+
+/**
+* Override Calendar to compute several fields specific to the Islamic
+* calendar system. These are:
+*
+* <ul><li>ERA
+* <li>YEAR
+* <li>MONTH
+* <li>DAY_OF_MONTH
+* <li>DAY_OF_YEAR
+* <li>EXTENDED_YEAR</ul>
+*
+* The DAY_OF_WEEK and DOW_LOCAL fields are already set when this
+* method is called. The getGregorianXxx() methods return Gregorian
+* calendar equivalents for the given Julian day.
+* @draft ICU 2.4
+*/
+void IslamicCivilCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) {
+ if (U_FAILURE(status)) return;
+ int32_t days = julianDay - getEpoc();
+
+ // Use the civil calendar approximation, which is just arithmetic
+ int32_t year = static_cast<int32_t>(
+ ClockMath::floorDivide(30 * static_cast<int64_t>(days) + 10646,
+ static_cast<int64_t>(10631)));
+ int32_t month = static_cast<int32_t>(
+ uprv_ceil((days - 29 - yearStart(year)) / 29.5 ));
+ month = month<11?month:11;
+
+ int32_t dayOfMonth = (days - monthStart(year, month)) + 1;
+
+ // Now figure out the day of the year.
+ int32_t dayOfYear = (days - monthStart(year, 0)) + 1;
+
+ internalSet(UCAL_ERA, 0);
+ internalSet(UCAL_YEAR, year);
+ internalSet(UCAL_EXTENDED_YEAR, year);
+ internalSet(UCAL_MONTH, month);
+ internalSet(UCAL_ORDINAL_MONTH, month);
+ internalSet(UCAL_DAY_OF_MONTH, dayOfMonth);
+ internalSet(UCAL_DAY_OF_YEAR, dayOfYear);
+}
+/*****************************************************************************
+ * IslamicTBLACalendar
+ *****************************************************************************/
+IslamicTBLACalendar::IslamicTBLACalendar(const Locale& aLocale, UErrorCode& success)
+ : IslamicCivilCalendar(aLocale, success)
+{
+}
+
+IslamicTBLACalendar::~IslamicTBLACalendar()
+{
+}
+
+const char *IslamicTBLACalendar::getType() const {
+ return "islamic-tbla";
+}
+
+IslamicTBLACalendar* IslamicTBLACalendar::clone() const {
+ return new IslamicTBLACalendar(*this);
+}
+
+int32_t IslamicTBLACalendar::getEpoc() const {
+ return ASTRONOMICAL_EPOC;
+}
+
+/*****************************************************************************
+ * IslamicUmalquraCalendar
+ *****************************************************************************/
+IslamicUmalquraCalendar::IslamicUmalquraCalendar(const Locale& aLocale, UErrorCode& success)
+ : IslamicCalendar(aLocale, success)
+{
+}
+
+IslamicUmalquraCalendar::~IslamicUmalquraCalendar()
+{
+}
+const char *IslamicUmalquraCalendar::getType() const {
+ return "islamic-umalqura";
+}
+
+IslamicUmalquraCalendar* IslamicUmalquraCalendar::clone() const {
+ return new IslamicUmalquraCalendar(*this);
+}
+
+/**
+* Return the day # on which the given year starts. Days are counted
+* from the Hijri epoch, origin 0.
+*/
+int32_t IslamicUmalquraCalendar::yearStart(int32_t year) const {
+ if (year < UMALQURA_YEAR_START || year > UMALQURA_YEAR_END) {
+ return static_cast<int32_t>(
+ (year-1)*354 + ClockMath::floorDivide((3+11*static_cast<int64_t>(year)),
+ static_cast<int64_t>(30)));
+ }
+ year -= UMALQURA_YEAR_START;
+ // rounded least-squares fit of the dates previously calculated from UMALQURA_MONTHLENGTH iteration
+ int32_t yrStartLinearEstimate = static_cast<int32_t>(
+ (354.36720 * (double)year) + 460322.05 + 0.5);
+ // need a slight correction to some
+ return yrStartLinearEstimate + umAlQuraYrStartEstimateFix[year];
+}
+
+/**
+* Return the day # on which the given month starts. Days are counted
+* from the Hijri epoch, origin 0.
+*
+* @param year The hijri year
+* @param month The hijri month, 0-based (assumed to be in range 0..11)
+*/
+int32_t IslamicUmalquraCalendar::monthStart(int32_t year, int32_t month) const {
+ int32_t ms = yearStart(year);
+ for(int i=0; i< month; i++){
+ ms+= handleGetMonthLength(year, i);
+ }
+ return ms;
+}
+
+/**
+* Return the length (in days) of the given month.
+*
+* @param year The hijri year
+* @param year The hijri month, 0-based
+*/
+int32_t IslamicUmalquraCalendar::handleGetMonthLength(int32_t extendedYear, int32_t month) const {
+ int32_t length = 0;
+ if (extendedYear<UMALQURA_YEAR_START || extendedYear>UMALQURA_YEAR_END) {
+ length = 29 + (month+1) % 2;
+ if (month == DHU_AL_HIJJAH && civilLeapYear(extendedYear)) {
+ length++;
+ }
+ return length;
+ }
+ return getUmalqura_MonthLength(extendedYear - UMALQURA_YEAR_START, month);
+}
+
+/**
+* Return the number of days in the given Islamic year
+* @draft ICU 2.4
+*/
+int32_t IslamicUmalquraCalendar::handleGetYearLength(int32_t extendedYear) const {
+ if (extendedYear<UMALQURA_YEAR_START || extendedYear>UMALQURA_YEAR_END) {
+ return 354 + (civilLeapYear(extendedYear) ? 1 : 0);
+ }
+ int len = 0;
+ for(int i=0; i<12; i++) {
+ len += handleGetMonthLength(extendedYear, i);
+ }
+ return len;
+}
+
+/**
+* Override Calendar to compute several fields specific to the Islamic
+* calendar system. These are:
+*
+* <ul><li>ERA
+* <li>YEAR
+* <li>MONTH
+* <li>DAY_OF_MONTH
+* <li>DAY_OF_YEAR
+* <li>EXTENDED_YEAR</ul>
+*
+* The DAY_OF_WEEK and DOW_LOCAL fields are already set when this
+* method is called. The getGregorianXxx() methods return Gregorian
+* calendar equivalents for the given Julian day.
+* @draft ICU 2.4
+*/
+void IslamicUmalquraCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) {
+ if (U_FAILURE(status)) return;
+ int32_t year, month, dayOfMonth, dayOfYear;
+ int32_t days = julianDay - getEpoc();
+
+ int32_t umalquraStartdays = yearStart(UMALQURA_YEAR_START) ;
+ if (days < umalquraStartdays) {
+ //Use Civil calculation
+ 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;
+ } else {
+ int y =UMALQURA_YEAR_START-1, m =0;
+ long d = 1;
+ while (d > 0) {
+ y++;
+ d = days - yearStart(y) +1;
+ if (d == handleGetYearLength(y)) {
+ m=11;
+ break;
+ }
+ if (d < handleGetYearLength(y)){
+ int monthLen = handleGetMonthLength(y, m);
+ m=0;
+ while(d > monthLen){
+ d -= monthLen;
+ m++;
+ monthLen = handleGetMonthLength(y, m);
+ }
+ break;
+ }
+ }
+ year = y;
+ month = m;
+ }
+
+ dayOfMonth = (days - monthStart(year, month)) + 1;
+
+ // Now figure out the day of the year.
+ dayOfYear = (days - monthStart(year, 0)) + 1;
+
+ internalSet(UCAL_ERA, 0);
+ internalSet(UCAL_YEAR, year);
+ internalSet(UCAL_EXTENDED_YEAR, year);
+ internalSet(UCAL_MONTH, month);
+ internalSet(UCAL_ORDINAL_MONTH, month);
+ internalSet(UCAL_DAY_OF_MONTH, dayOfMonth);
+ internalSet(UCAL_DAY_OF_YEAR, dayOfYear);
+}
+/*****************************************************************************
+ * IslamicRGSACalendar
+ *****************************************************************************/
+IslamicRGSACalendar::IslamicRGSACalendar(const Locale& aLocale, UErrorCode& success)
+ : IslamicCalendar(aLocale, success)
+{
+}
+
+IslamicRGSACalendar::~IslamicRGSACalendar()
+{
+}
+
+const char *IslamicRGSACalendar::getType() const {
+ return "islamic-rgsa";
+}
+
+IslamicRGSACalendar* IslamicRGSACalendar::clone() const {
+ return new IslamicRGSACalendar(*this);
+}
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IslamicCalendar)
+UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IslamicCivilCalendar)
+UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IslamicUmalquraCalendar)
+UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IslamicTBLACalendar)
+UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IslamicRGSACalendar)
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/islamcal.h b/contrib/libs/icu/i18n/islamcal.h
index a29b7daa08..8469269bcc 100644
--- a/contrib/libs/icu/i18n/islamcal.h
+++ b/contrib/libs/icu/i18n/islamcal.h
@@ -53,7 +53,8 @@ U_NAMESPACE_BEGIN
* every 30 years. This calendar is easily calculated and thus predictable in
* advance, so it is used as the civil calendar in a number of Arab countries.
* This is the default behavior of a newly-created <code>IslamicCalendar</code>
- * object.
+ * object. This calendar variant is implemented in the IslamicCivilCalendar
+ * class.
* <p>
* The Islamic <em>religious</em> calendar, however, is based on the <em>observation</em>
* of the crescent moon. It is thus affected by the position at which the
@@ -71,10 +72,6 @@ U_NAMESPACE_BEGIN
* calculations. At present, the approximations used in this class are fairly
* simplistic; they will be improved in later versions of the code.
* <p>
- * The {@link #setCivil setCivil} method determines
- * which approach is used to determine the start of a month. By default, the
- * fixed-cycle civil calendar is used. However, if <code>setCivil(false)</code>
- * is called, an approximation of the true lunar calendar will be used.
*
* @see GregorianCalendar
*
@@ -88,18 +85,6 @@ class U_I18N_API IslamicCalendar : public Calendar {
//-------------------------------------------------------------------------
// Constants...
//-------------------------------------------------------------------------
-
- /**
- * Calendar type - civil or religious or um alqura
- * @internal
- */
- enum ECalculationType {
- ASTRONOMICAL,
- CIVIL,
- UMALQURA,
- TBLA
- };
-
/**
* Constants for the months
* @internal
@@ -192,16 +177,15 @@ class U_I18N_API IslamicCalendar : public Calendar {
* @param aLocale The given locale.
* @param success Indicates the status of IslamicCalendar object construction.
* Returns U_ZERO_ERROR if constructed successfully.
- * @param type The Islamic calendar calculation type. The default value is CIVIL.
* @internal
*/
- IslamicCalendar(const Locale& aLocale, UErrorCode &success, ECalculationType type = CIVIL);
+ IslamicCalendar(const Locale& aLocale, UErrorCode &success);
/**
* Copy Constructor
* @internal
*/
- IslamicCalendar(const IslamicCalendar& other);
+ IslamicCalendar(const IslamicCalendar& other) = default;
/**
* Destructor.
@@ -209,40 +193,20 @@ class U_I18N_API IslamicCalendar : public Calendar {
*/
virtual ~IslamicCalendar();
- /**
- * Sets Islamic calendar calculation type used by this instance.
- *
- * @param type The calendar calculation type, <code>CIVIL</code> to use the civil
- * calendar, <code>ASTRONOMICAL</code> to use the astronomical calendar.
- * @internal
- */
- void setCalculationType(ECalculationType type, UErrorCode &status);
-
- /**
- * Returns <code>true</code> if this object is using the fixed-cycle civil
- * calendar, or <code>false</code> if using the religious, astronomical
- * calendar.
- * @internal
- */
- UBool isCivil();
-
-
- // TODO: copy c'tor, etc
-
// clone
virtual IslamicCalendar* clone() const override;
- private:
+ protected:
/**
* Determine whether a year is a leap year in the Islamic civil calendar
*/
static UBool civilLeapYear(int32_t year);
-
+
/**
* Return the day # on which the given year starts. Days are counted
* from the Hijri epoch, origin 0.
*/
- int32_t yearStart(int32_t year) const;
+ virtual int32_t yearStart(int32_t year) const;
/**
* Return the day # on which the given month starts. Days are counted
@@ -251,7 +215,7 @@ class U_I18N_API IslamicCalendar : public Calendar {
* @param year The hijri year
* @param year The hijri month, 0-based
*/
- int32_t monthStart(int32_t year, int32_t month) const;
+ virtual int32_t monthStart(int32_t year, int32_t month) const;
/**
* Find the day number on which a particular month of the true/lunar
@@ -263,6 +227,7 @@ class U_I18N_API IslamicCalendar : public Calendar {
*/
int32_t trueMonthStart(int32_t month) const;
+ private:
/**
* Return the "age" of the moon at the given time; this is the difference
* in ecliptic latitude between the moon and the sun. This method simply
@@ -274,17 +239,6 @@ class U_I18N_API IslamicCalendar : public Calendar {
*/
static double moonAge(UDate time, UErrorCode &status);
- //-------------------------------------------------------------------------
- // Internal data....
- //
-
- /**
- * <code>CIVIL</code> if this object uses the fixed-cycle Islamic civil calendar,
- * and <code>ASTRONOMICAL</code> if it approximates the true religious calendar using
- * astronomical calculations for the time of the new moon.
- */
- ECalculationType cType;
-
//----------------------------------------------------------------------
// Calendar framework
//----------------------------------------------------------------------
@@ -346,6 +300,12 @@ class U_I18N_API IslamicCalendar : public Calendar {
*/
virtual void handleComputeFields(int32_t julianDay, UErrorCode &status) override;
+ /**
+ * Return the epoc.
+ * @internal
+ */
+ virtual int32_t getEpoc() const;
+
// UObject stuff
public:
/**
@@ -353,7 +313,7 @@ class U_I18N_API IslamicCalendar : public Calendar {
* same class ID. Objects of other classes have different class IDs.
* @internal
*/
- virtual UClassID getDynamicClassID(void) const override;
+ virtual UClassID getDynamicClassID() const override;
/**
* Return the class ID for this class. This is useful only for comparing to a return
@@ -366,34 +326,44 @@ class U_I18N_API IslamicCalendar : public Calendar {
* @return The class ID for all objects of this class.
* @internal
*/
- /*U_I18N_API*/ static UClassID U_EXPORT2 getStaticClassID(void);
+ /*U_I18N_API*/ static UClassID U_EXPORT2 getStaticClassID();
/**
- * return the calendar type, "buddhist".
+ * return the calendar type, "islamic".
*
* @return calendar type
* @internal
*/
virtual const char * getType() const override;
- private:
- IslamicCalendar(); // default constructor not implemented
+ /**
+ * @return The related Gregorian year; will be obtained by modifying the value
+ * obtained by get from UCAL_EXTENDED_YEAR field
+ * @internal
+ */
+ virtual int32_t getRelatedYear(UErrorCode &status) const override;
- // Default century.
- protected:
+ /**
+ * @param year The related Gregorian year to set; will be modified as necessary then
+ * set in UCAL_EXTENDED_YEAR field
+ * @internal
+ */
+ virtual void setRelatedYear(int32_t year) override;
/**
- * (Overrides Calendar) Return true if the current date for this Calendar is in
- * Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
+ * Returns true if the date is in a leap year.
*
- * @param status Fill-in parameter which receives the status of this operation.
- * @return True if the current date for this Calendar is in Daylight Savings Time,
- * false, otherwise.
- * @internal
+ * @param status ICU Error Code
+ * @return True if the date in the fields is in a Temporal proposal
+ * defined leap year. False otherwise.
*/
- virtual UBool inDaylightTime(UErrorCode& status) const override;
+ virtual bool inTemporalLeapYear(UErrorCode &status) const override;
+ private:
+ IslamicCalendar() = delete; // default constructor not implemented
+ // Default century.
+ protected:
/**
* Returns true because the Islamic Calendar does have a default century
* @internal
@@ -419,13 +389,375 @@ class U_I18N_API IslamicCalendar : public Calendar {
* are considered to fall within so that its start date is 80 years
* before the current time.
*/
- static void U_CALLCONV initializeSystemDefaultCentury(void);
+ static void U_CALLCONV initializeSystemDefaultCentury();
};
-U_NAMESPACE_END
+/*
+ * IslamicCivilCalendar is one of the two main variants of the Islamic calendar.
+ * The <em>civil</em> calendar, which uses a fixed cycle of alternating 29-
+ * and 30-day months, with a leap day added to the last month of 11 out of
+ * every 30 years. This calendar is easily calculated and thus predictable in
+ * advance, so it is used as the civil calendar in a number of Arab countries.
+ * This calendar is referring as "Islamic calendar, tabular (intercalary years
+ * [2,5,7,10,13,16,18,21,24,26,29]- civil epoch" in CLDR.
+ */
+class U_I18N_API IslamicCivilCalendar : public IslamicCalendar {
+ public:
+ /**
+ * Constructs an IslamicCivilCalendar based on the current time in the default time zone
+ * with the given locale.
+ *
+ * @param aLocale The given locale.
+ * @param success Indicates the status of IslamicCivilCalendar object construction.
+ * Returns U_ZERO_ERROR if constructed successfully.
+ * @internal
+ */
+ IslamicCivilCalendar(const Locale& aLocale, UErrorCode &success);
-#endif
-#endif
+ /**
+ * Copy Constructor
+ * @internal
+ */
+ IslamicCivilCalendar(const IslamicCivilCalendar& other) = default;
+
+ /**
+ * Destructor.
+ * @internal
+ */
+ virtual ~IslamicCivilCalendar();
+
+ // clone
+ virtual IslamicCivilCalendar* clone() const override;
+
+ /**
+ * @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.
+ * @internal
+ */
+ virtual UClassID getDynamicClassID() const override;
+
+ /**
+ * Return the class ID for this class. This is useful only for comparing to a return
+ * value from getDynamicClassID(). For example:
+ *
+ * Base* polymorphic_pointer = createPolymorphicObject();
+ * if (polymorphic_pointer->getDynamicClassID() ==
+ * Derived::getStaticClassID()) ...
+ *
+ * @return The class ID for all objects of this class.
+ * @internal
+ */
+ static UClassID U_EXPORT2 getStaticClassID();
+
+ /**
+ * return the calendar type, "islamic-civil".
+ *
+ * @return calendar type
+ * @internal
+ */
+ virtual const char * getType() const override;
+
+ protected:
+ /**
+ * Return the day # on which the given year starts. Days are counted
+ * from the Hijri epoch, origin 0.
+ * @internal
+ */
+ virtual int32_t yearStart(int32_t year) const override;
+
+ /**
+ * Return the day # on which the given month starts. Days are counted
+ * from the Hijri epoch, origin 0.
+ *
+ * @param year The hijri year
+ * @param year The hijri month, 0-based
+ * @internal
+ */
+ virtual int32_t monthStart(int32_t year, int32_t month) const override;
+
+ /**
+ * Return the length (in days) of the given month.
+ *
+ * @param year The hijri year
+ * @param year The hijri month, 0-based
+ * @internal
+ */
+ virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const override;
+
+ /**
+ * Return the number of days in the given Islamic year
+ * @internal
+ */
+ virtual int32_t handleGetYearLength(int32_t extendedYear) const override;
+
+ /**
+ * Override Calendar to compute several fields specific to the Islamic
+ * calendar system. These are:
+ *
+ * <ul><li>ERA
+ * <li>YEAR
+ * <li>MONTH
+ * <li>DAY_OF_MONTH
+ * <li>DAY_OF_YEAR
+ * <li>EXTENDED_YEAR</ul>
+ *
+ * The DAY_OF_WEEK and DOW_LOCAL fields are already set when this
+ * method is called. The getGregorianXxx() methods return Gregorian
+ * calendar equivalents for the given Julian day.
+ * @internal
+ */
+ virtual void handleComputeFields(int32_t julianDay, UErrorCode &status) override;
+};
+
+/*
+ * IslamicTBLACalendar calendar.
+ * This is a subclass of IslamicCivilCalendar. The only differences in the
+ * calendar math is it uses different epoch.
+ * This calendar is referring as "Islamic calendar, tabular (intercalary years
+ * [2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch" in CLDR.
+ */
+class U_I18N_API IslamicTBLACalendar : public IslamicCivilCalendar {
+ public:
+ /**
+ * Constructs an IslamicTBLACalendar based on the current time in the default time zone
+ * with the given locale.
+ *
+ * @param aLocale The given locale.
+ * @param success Indicates the status of IslamicTBLACalendar object construction.
+ * Returns U_ZERO_ERROR if constructed successfully.
+ * @internal
+ */
+ IslamicTBLACalendar(const Locale& aLocale, UErrorCode &success);
+
+ /**
+ * Copy Constructor
+ * @internal
+ */
+ IslamicTBLACalendar(const IslamicTBLACalendar& other) = default;
+
+ /**
+ * Destructor.
+ * @internal
+ */
+ virtual ~IslamicTBLACalendar();
+
+ /**
+ * @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.
+ * @internal
+ */
+ virtual UClassID getDynamicClassID() const override;
+
+ /**
+ * Return the class ID for this class. This is useful only for comparing to a return
+ * value from getDynamicClassID(). For example:
+ *
+ * Base* polymorphic_pointer = createPolymorphicObject();
+ * if (polymorphic_pointer->getDynamicClassID() ==
+ * Derived::getStaticClassID()) ...
+ *
+ * @return The class ID for all objects of this class.
+ * @internal
+ */
+ static UClassID U_EXPORT2 getStaticClassID();
+
+ /**
+ * return the calendar type, "islamic-tbla".
+ *
+ * @return calendar type
+ * @internal
+ */
+ virtual const char * getType() const override;
+
+ // clone
+ virtual IslamicTBLACalendar* clone() const override;
+
+ protected:
+ /**
+ * Return the epoc.
+ * @internal
+ */
+ virtual int32_t getEpoc() const override;
+};
+
+/*
+ * IslamicUmalquraCalendar
+ * This calendar is referred as "Islamic calendar, Umm al-Qura" in CLDR.
+ */
+class U_I18N_API IslamicUmalquraCalendar : public IslamicCalendar {
+ public:
+ /**
+ * Constructs an IslamicUmalquraCalendar based on the current time in the default time zone
+ * with the given locale.
+ *
+ * @param aLocale The given locale.
+ * @param success Indicates the status of IslamicUmalquraCalendar object construction.
+ * Returns U_ZERO_ERROR if constructed successfully.
+ * @internal
+ */
+ IslamicUmalquraCalendar(const Locale& aLocale, UErrorCode &success);
+
+ /**
+ * Copy Constructor
+ * @internal
+ */
+ IslamicUmalquraCalendar(const IslamicUmalquraCalendar& other) = default;
+
+ /**
+ * Destructor.
+ * @internal
+ */
+ virtual ~IslamicUmalquraCalendar();
+
+ /**
+ * @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.
+ * @internal
+ */
+ virtual UClassID getDynamicClassID() const override;
+
+ /**
+ * Return the class ID for this class. This is useful only for comparing to a return
+ * value from getDynamicClassID(). For example:
+ *
+ * Base* polymorphic_pointer = createPolymorphicObject();
+ * if (polymorphic_pointer->getDynamicClassID() ==
+ * Derived::getStaticClassID()) ...
+ *
+ * @return The class ID for all objects of this class.
+ * @internal
+ */
+ static UClassID U_EXPORT2 getStaticClassID();
+
+ /**
+ * return the calendar type, "islamic-umalqura".
+ *
+ * @return calendar type
+ * @internal
+ */
+ virtual const char * getType() const override;
+
+ // clone
+ virtual IslamicUmalquraCalendar* clone() const override;
+
+ protected:
+ /**
+ * Return the day # on which the given year starts. Days are counted
+ * from the Hijri epoch, origin 0.
+ * @internal
+ */
+ virtual int32_t yearStart(int32_t year) const override;
+
+ /**
+ * Return the day # on which the given month starts. Days are counted
+ * from the Hijri epoch, origin 0.
+ *
+ * @param year The hijri year
+ * @param year The hijri month, 0-based
+ * @internal
+ */
+ virtual int32_t monthStart(int32_t year, int32_t month) const override;
+
+ /**
+ * Return the length (in days) of the given month.
+ *
+ * @param year The hijri year
+ * @param year The hijri month, 0-based
+ * @internal
+ */
+ virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const override;
+
+ /**
+ * Return the number of days in the given Islamic year
+ * @internal
+ */
+ virtual int32_t handleGetYearLength(int32_t extendedYear) const override;
+ /**
+ * Override Calendar to compute several fields specific to the Islamic
+ * calendar system. These are:
+ *
+ * <ul><li>ERA
+ * <li>YEAR
+ * <li>MONTH
+ * <li>DAY_OF_MONTH
+ * <li>DAY_OF_YEAR
+ * <li>EXTENDED_YEAR</ul>
+ *
+ * The DAY_OF_WEEK and DOW_LOCAL fields are already set when this
+ * method is called. The getGregorianXxx() methods return Gregorian
+ * calendar equivalents for the given Julian day.
+ * @internal
+ */
+ virtual void handleComputeFields(int32_t julianDay, UErrorCode &status) override;
+};
+/*
+ * IslamicRGSACalendar
+ * Islamic calendar, Saudi Arabia sighting. Since the calendar depends on the
+ * sighting, it is impossible to implement by algorithm ahead of time. It is
+ * currently identical to IslamicCalendar except the getType will return
+ * "islamic-rgsa".
+ */
+class U_I18N_API IslamicRGSACalendar : public IslamicCalendar {
+ public:
+ /**
+ * Constructs an IslamicRGSACalendar based on the current time in the default time zone
+ * with the given locale.
+ *
+ * @param aLocale The given locale.
+ * @param success Indicates the status of IslamicRGSACalendar object construction.
+ * Returns U_ZERO_ERROR if constructed successfully.
+ * @internal
+ */
+ IslamicRGSACalendar(const Locale& aLocale, UErrorCode &success);
+
+ /**
+ * Copy Constructor
+ * @internal
+ */
+ IslamicRGSACalendar(const IslamicRGSACalendar& other) = default;
+
+ /**
+ * Destructor.
+ * @internal
+ */
+ virtual ~IslamicRGSACalendar();
+
+ /**
+ * @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.
+ * @internal
+ */
+ virtual UClassID getDynamicClassID() const override;
+
+ /**
+ * Return the class ID for this class. This is useful only for comparing to a return
+ * value from getDynamicClassID(). For example:
+ *
+ * Base* polymorphic_pointer = createPolymorphicObject();
+ * if (polymorphic_pointer->getDynamicClassID() ==
+ * Derived::getStaticClassID()) ...
+ *
+ * @return The class ID for all objects of this class.
+ * @internal
+ */
+ static UClassID U_EXPORT2 getStaticClassID();
+
+ /**
+ * return the calendar type, "islamic-rgsa".
+ *
+ * @return calendar type
+ * @internal
+ */
+ virtual const char * getType() const override;
+
+ // clone
+ virtual IslamicRGSACalendar* clone() const override;
+};
+
+U_NAMESPACE_END
+
+#endif
+#endif
diff --git a/contrib/libs/icu/i18n/iso8601cal.cpp b/contrib/libs/icu/i18n/iso8601cal.cpp
new file mode 100644
index 0000000000..1bc81fac15
--- /dev/null
+++ b/contrib/libs/icu/i18n/iso8601cal.cpp
@@ -0,0 +1,37 @@
+// © 2022 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 "iso8601cal.h"
+#include "unicode/gregocal.h"
+
+U_NAMESPACE_BEGIN
+
+UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ISO8601Calendar)
+
+ISO8601Calendar::ISO8601Calendar(const Locale& aLocale, UErrorCode& success)
+: GregorianCalendar(aLocale, success)
+{
+ setFirstDayOfWeek(UCAL_MONDAY);
+ setMinimalDaysInFirstWeek(4);
+}
+
+ISO8601Calendar::~ISO8601Calendar()
+{
+}
+
+ISO8601Calendar* ISO8601Calendar::clone() const
+{
+ return new ISO8601Calendar(*this);
+}
+
+const char *ISO8601Calendar::getType() const
+{
+ return "iso8601";
+}
+
+U_NAMESPACE_END
+
+#endif
diff --git a/contrib/libs/icu/i18n/iso8601cal.h b/contrib/libs/icu/i18n/iso8601cal.h
new file mode 100644
index 0000000000..688fac3588
--- /dev/null
+++ b/contrib/libs/icu/i18n/iso8601cal.h
@@ -0,0 +1,102 @@
+// © 2022 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+#ifndef ISO8601CAL_H
+#define ISO8601CAL_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/calendar.h"
+#include "unicode/gregocal.h"
+#include "unicode/timezone.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * Concrete class which provides the ISO8601 calendar.
+ * <P>
+ * <code>ISO8601Calendar</code> is a subclass of <code>GregorianCalendar</code>
+ * that the first day of a week is Monday and the minimal days in the first
+ * week of a year or month is four days.
+ * <p>
+ * The ISO8601 calendar is identical to the Gregorian calendar in all respects
+ * except for the first day of week and the minimal days in the first week
+ * of a year.
+ * @internal
+ */
+class ISO8601Calendar : public GregorianCalendar {
+ public:
+ //-------------------------------------------------------------------------
+ // Constructors...
+ //-------------------------------------------------------------------------
+
+ /**
+ * Constructs a DangiCalendar based on the current time in the default time zone
+ * with the given locale.
+ *
+ * @param aLocale The given locale.
+ * @param success Indicates the status of ISO8601Calendar object construction.
+ * Returns U_ZERO_ERROR if constructed successfully.
+ * @internal
+ */
+ ISO8601Calendar(const Locale& aLocale, UErrorCode &success);
+
+ /**
+ * Copy Constructor
+ * @internal
+ */
+ ISO8601Calendar(const ISO8601Calendar& other) = default;
+
+ /**
+ * Destructor.
+ * @internal
+ */
+ virtual ~ISO8601Calendar();
+
+ /**
+ * Clone.
+ * @internal
+ */
+ virtual ISO8601Calendar* clone() const override;
+
+ // UObject stuff
+ public:
+ /**
+ * @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.
+ * @internal
+ */
+ virtual UClassID getDynamicClassID() const override;
+
+ /**
+ * Return the class ID for this class. This is useful only for comparing to a return
+ * value from getDynamicClassID(). For example:
+ *
+ * Base* polymorphic_pointer = createPolymorphicObject();
+ * if (polymorphic_pointer->getDynamicClassID() ==
+ * Derived::getStaticClassID()) ...
+ *
+ * @return The class ID for all objects of this class.
+ * @internal
+ */
+ U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
+
+ /**
+ * return the calendar type, "iso8601".
+ *
+ * @return calendar type
+ * @internal
+ */
+ virtual const char * getType() const override;
+
+
+ private:
+
+ ISO8601Calendar(); // default constructor not implemented
+};
+
+U_NAMESPACE_END
+
+#endif
+#endif
diff --git a/contrib/libs/icu/i18n/japancal.cpp b/contrib/libs/icu/i18n/japancal.cpp
index 75a248f406..fc18d6c0eb 100644
--- a/contrib/libs/icu/i18n/japancal.cpp
+++ b/contrib/libs/icu/i18n/japancal.cpp
@@ -39,18 +39,18 @@
#include "cstring.h"
static icu::EraRules * gJapaneseEraRules = nullptr;
-static icu::UInitOnce gJapaneseEraRulesInitOnce = U_INITONCE_INITIALIZER;
+static icu::UInitOnce gJapaneseEraRulesInitOnce {};
static int32_t gCurrentEra = 0;
U_CDECL_BEGIN
-static UBool japanese_calendar_cleanup(void) {
+static UBool japanese_calendar_cleanup() {
if (gJapaneseEraRules) {
delete gJapaneseEraRules;
gJapaneseEraRules = nullptr;
}
gCurrentEra = 0;
gJapaneseEraRulesInitOnce.reset();
- return TRUE;
+ return true;
}
U_CDECL_END
@@ -71,21 +71,21 @@ UBool JapaneseCalendar::enableTentativeEra() {
// 1. Environment variable ICU_ENABLE_TENTATIVE_ERA=true or false
- UBool includeTentativeEra = FALSE;
+ UBool includeTentativeEra = false;
#if U_PLATFORM_HAS_WINUWP_API == 1
// UWP doesn't allow access to getenv(), but we can call GetEnvironmentVariableW to do the same thing.
- UChar varName[26] = {};
+ char16_t varName[26] = {};
u_charsToUChars(TENTATIVE_ERA_VAR_NAME, varName, static_cast<int32_t>(uprv_strlen(TENTATIVE_ERA_VAR_NAME)));
WCHAR varValue[5] = {};
DWORD ret = GetEnvironmentVariableW(reinterpret_cast<WCHAR*>(varName), varValue, UPRV_LENGTHOF(varValue));
if ((ret == 4) && (_wcsicmp(varValue, L"true") == 0)) {
- includeTentativeEra = TRUE;
+ includeTentativeEra = true;
}
#else
char *envVarVal = getenv(TENTATIVE_ERA_VAR_NAME);
- if (envVarVal != NULL && uprv_stricmp(envVarVal, "true") == 0) {
- includeTentativeEra = TRUE;
+ if (envVarVal != nullptr && uprv_stricmp(envVarVal, "true") == 0) {
+ includeTentativeEra = true;
}
#endif
return includeTentativeEra;
@@ -219,7 +219,7 @@ void JapaneseCalendar::handleComputeFields(int32_t julianDay, UErrorCode& status
//Calendar::timeToFields(theTime, quick, status);
GregorianCalendar::handleComputeFields(julianDay, status);
int32_t year = internalGet(UCAL_EXTENDED_YEAR); // Gregorian year
- int32_t eraIdx = gJapaneseEraRules->getEraIndex(year, internalGet(UCAL_MONTH) + 1, internalGet(UCAL_DAY_OF_MONTH), status);
+ int32_t eraIdx = gJapaneseEraRules->getEraIndex(year, internalGetMonth() + 1, internalGet(UCAL_DAY_OF_MONTH), status);
internalSet(UCAL_ERA, eraIdx);
internalSet(UCAL_YEAR, year - gJapaneseEraRules->getStartYear(eraIdx, status) + 1);
@@ -230,7 +230,7 @@ Disable pivoting
*/
UBool JapaneseCalendar::haveDefaultCentury() const
{
- return FALSE;
+ return false;
}
UDate JapaneseCalendar::defaultCenturyStart() const
diff --git a/contrib/libs/icu/i18n/japancal.h b/contrib/libs/icu/i18n/japancal.h
index 8851344052..3ae4900a2c 100644
--- a/contrib/libs/icu/i18n/japancal.h
+++ b/contrib/libs/icu/i18n/japancal.h
@@ -70,14 +70,14 @@ public:
* Check environment variable.
* @internal
*/
- U_I18N_API static UBool U_EXPORT2 enableTentativeEra(void);
+ U_I18N_API static UBool U_EXPORT2 enableTentativeEra();
/**
* Useful constants for JapaneseCalendar.
* Exported for use by test code.
* @internal
*/
- U_I18N_API static uint32_t U_EXPORT2 getCurrentEra(void); // the current era
+ U_I18N_API static uint32_t U_EXPORT2 getCurrentEra(); // the current era
/**
* Constructs a JapaneseCalendar based on the current time in the default time zone
@@ -143,7 +143,7 @@ public:
* same class ID. Objects of other classes have different class IDs.
* @internal
*/
- virtual UClassID getDynamicClassID(void) const override;
+ virtual UClassID getDynamicClassID() const override;
/**
* Return the class ID for this class. This is useful only for comparing to a return
@@ -156,7 +156,7 @@ public:
* @return The class ID for all objects of this class.
* @internal
*/
- U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
+ U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
/**
* return the calendar type, "japanese".
diff --git a/contrib/libs/icu/i18n/listformatter.cpp b/contrib/libs/icu/i18n/listformatter.cpp
index 4142fa461d..3405b5de38 100644
--- a/contrib/libs/icu/i18n/listformatter.cpp
+++ b/contrib/libs/icu/i18n/listformatter.cpp
@@ -396,8 +396,8 @@ static const char* typeWidthToStyleString(UListFormatterType type, UListFormatte
return nullptr;
}
-static const UChar solidus = 0x2F;
-static const UChar aliasPrefix[] = { 0x6C,0x69,0x73,0x74,0x50,0x61,0x74,0x74,0x65,0x72,0x6E,0x2F }; // "listPattern/"
+static const char16_t solidus = 0x2F;
+static const char16_t aliasPrefix[] = { 0x6C,0x69,0x73,0x74,0x50,0x61,0x74,0x74,0x65,0x72,0x6E,0x2F }; // "listPattern/"
enum {
kAliasPrefixLen = UPRV_LENGTHOF(aliasPrefix),
kStyleLenMax = 24 // longest currently is 14
@@ -405,16 +405,9 @@ enum {
struct ListFormatter::ListPatternsSink : public ResourceSink {
UnicodeString two, start, middle, end;
-#if ((U_PLATFORM == U_PF_AIX) || (U_PLATFORM == U_PF_OS390)) && (U_CPLUSPLUS_VERSION < 11)
- char aliasedStyle[kStyleLenMax+1];
- ListPatternsSink() {
- uprv_memset(aliasedStyle, 0, kStyleLenMax+1);
- }
-#else
char aliasedStyle[kStyleLenMax+1] = {0};
ListPatternsSink() {}
-#endif
virtual ~ListPatternsSink();
void setAliasedStyle(UnicodeString alias) {
diff --git a/contrib/libs/icu/i18n/measfmt.cpp b/contrib/libs/icu/i18n/measfmt.cpp
index a9a56a3b58..da4e69b49b 100644
--- a/contrib/libs/icu/i18n/measfmt.cpp
+++ b/contrib/libs/icu/i18n/measfmt.cpp
@@ -181,12 +181,12 @@ static UBool getString(
UnicodeString &result,
UErrorCode &status) {
int32_t len = 0;
- const UChar *resStr = ures_getString(resource, &len, &status);
+ const char16_t *resStr = ures_getString(resource, &len, &status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
- result.setTo(TRUE, resStr, len);
- return TRUE;
+ result.setTo(true, resStr, len);
+ return true;
}
static UnicodeString loadNumericDateFormatterPattern(
@@ -204,7 +204,7 @@ static UnicodeString loadNumericDateFormatterPattern(
ures_getByKeyWithFallback(
resource,
chs.data(),
- NULL,
+ nullptr,
&status));
if (U_FAILURE(status)) {
return result;
@@ -212,7 +212,7 @@ static UnicodeString loadNumericDateFormatterPattern(
getString(patternBundle.getAlias(), result, status);
// Replace 'h' with 'H'
int32_t len = result.length();
- UChar *buffer = result.getBuffer(len);
+ char16_t *buffer = result.getBuffer(len);
for (int32_t i = 0; i < len; ++i) {
if (buffer[i] == 0x68) { // 'h'
buffer[i] = 0x48; // 'H'
@@ -226,7 +226,7 @@ static NumericDateFormatters *loadNumericDateFormatters(
const UResourceBundle *resource,
UErrorCode &status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
NumericDateFormatters *result = new NumericDateFormatters(
loadNumericDateFormatterPattern(resource, "hm", status),
@@ -234,12 +234,12 @@ static NumericDateFormatters *loadNumericDateFormatters(
loadNumericDateFormatterPattern(resource, "hms", status));
if (U_FAILURE(status)) {
delete result;
- return NULL;
+ return nullptr;
}
return result;
}
-template<> U_I18N_API
+template<>
const MeasureFormatCacheData *LocaleCacheKey<MeasureFormatCacheData>::createObject(
const void * /*unused*/, UErrorCode &status) const {
const char *localeId = fLoc.getName();
@@ -248,12 +248,12 @@ const MeasureFormatCacheData *LocaleCacheKey<MeasureFormatCacheData>::createObje
UNUM_CURRENCY_PLURAL, UNUM_CURRENCY_ISO, UNUM_CURRENCY};
LocalPointer<MeasureFormatCacheData> result(new MeasureFormatCacheData(), status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
result->adoptNumericDateFormatters(loadNumericDateFormatters(
unitsBundle.getAlias(), status));
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
for (int32_t i = 0; i < WIDTH_INDEX_COUNT; ++i) {
@@ -266,17 +266,17 @@ const MeasureFormatCacheData *LocaleCacheKey<MeasureFormatCacheData>::createObje
status = localStatus;
}
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
}
NumberFormat *inf = NumberFormat::createInstance(
localeId, UNUM_DECIMAL, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
inf->setMaximumFractionDigits(0);
DecimalFormat *decfmt = dynamic_cast<DecimalFormat *>(inf);
- if (decfmt != NULL) {
+ if (decfmt != nullptr) {
decfmt->setRoundingMode(DecimalFormat::kRoundDown);
}
result->adoptIntegerFormat(inf);
@@ -352,12 +352,12 @@ static int32_t toHMS(
MeasureFormat::MeasureFormat(
const Locale &locale, UMeasureFormatWidth w, UErrorCode &status)
- : cache(NULL),
- numberFormat(NULL),
- pluralRules(NULL),
+ : cache(nullptr),
+ numberFormat(nullptr),
+ pluralRules(nullptr),
fWidth(w),
- listFormatter(NULL) {
- initMeasureFormat(locale, w, NULL, status);
+ listFormatter(nullptr) {
+ initMeasureFormat(locale, w, nullptr, status);
}
MeasureFormat::MeasureFormat(
@@ -365,11 +365,11 @@ MeasureFormat::MeasureFormat(
UMeasureFormatWidth w,
NumberFormat *nfToAdopt,
UErrorCode &status)
- : cache(NULL),
- numberFormat(NULL),
- pluralRules(NULL),
+ : cache(nullptr),
+ numberFormat(nullptr),
+ pluralRules(nullptr),
fWidth(w),
- listFormatter(NULL) {
+ listFormatter(nullptr) {
initMeasureFormat(locale, w, nfToAdopt, status);
}
@@ -379,11 +379,11 @@ MeasureFormat::MeasureFormat(const MeasureFormat &other) :
numberFormat(other.numberFormat),
pluralRules(other.pluralRules),
fWidth(other.fWidth),
- listFormatter(NULL) {
+ listFormatter(nullptr) {
cache->addRef();
numberFormat->addRef();
pluralRules->addRef();
- if (other.listFormatter != NULL) {
+ if (other.listFormatter != nullptr) {
listFormatter = new ListFormatter(*other.listFormatter);
}
}
@@ -398,30 +398,30 @@ MeasureFormat &MeasureFormat::operator=(const MeasureFormat &other) {
SharedObject::copyPtr(other.pluralRules, pluralRules);
fWidth = other.fWidth;
delete listFormatter;
- if (other.listFormatter != NULL) {
+ if (other.listFormatter != nullptr) {
listFormatter = new ListFormatter(*other.listFormatter);
} else {
- listFormatter = NULL;
+ listFormatter = nullptr;
}
return *this;
}
MeasureFormat::MeasureFormat() :
- cache(NULL),
- numberFormat(NULL),
- pluralRules(NULL),
+ cache(nullptr),
+ numberFormat(nullptr),
+ pluralRules(nullptr),
fWidth(UMEASFMT_WIDTH_SHORT),
- listFormatter(NULL) {
+ listFormatter(nullptr) {
}
MeasureFormat::~MeasureFormat() {
- if (cache != NULL) {
+ if (cache != nullptr) {
cache->removeRef();
}
- if (numberFormat != NULL) {
+ if (numberFormat != nullptr) {
numberFormat->removeRef();
}
- if (pluralRules != NULL) {
+ if (pluralRules != nullptr) {
pluralRules->removeRef();
}
delete listFormatter;
@@ -476,7 +476,7 @@ UnicodeString &MeasureFormat::format(
if (obj.getType() == Formattable::kObject) {
const UObject* formatObj = obj.getObject();
const Measure* amount = dynamic_cast<const Measure*>(formatObj);
- if (amount != NULL) {
+ if (amount != nullptr) {
return formatMeasure(
*amount, **numberFormat, appendTo, pos, status);
}
@@ -547,7 +547,7 @@ UnicodeString &MeasureFormat::formatMeasures(
measures, measureCount, appendTo, pos, status);
}
UnicodeString *results = new UnicodeString[measureCount];
- if (results == NULL) {
+ if (results == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return appendTo;
}
@@ -635,7 +635,7 @@ void MeasureFormat::adoptNumberFormat(
return;
}
SharedNumberFormat *shared = new SharedNumberFormat(nf.getAlias());
- if (shared == NULL) {
+ if (shared == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -645,9 +645,9 @@ void MeasureFormat::adoptNumberFormat(
UBool MeasureFormat::setMeasureFormatLocale(const Locale &locale, UErrorCode &status) {
if (U_FAILURE(status) || locale == getLocale(status)) {
- return FALSE;
+ return false;
}
- initMeasureFormat(locale, fWidth, NULL, status);
+ initMeasureFormat(locale, fWidth, nullptr, status);
return U_SUCCESS(status);
}
@@ -683,7 +683,7 @@ UnicodeString &MeasureFormat::formatMeasure(
const Formattable& amtNumber = measure.getNumber();
const MeasureUnit& amtUnit = measure.getUnit();
if (isCurrency(amtUnit)) {
- UChar isoCode[4];
+ char16_t isoCode[4];
u_charsToUChars(amtUnit.getSubtype(), isoCode, 4);
return cache->getCurrencyFormat(fWidth)->format(
new CurrencyAmount(amtNumber, isoCode, status),
@@ -769,7 +769,7 @@ UnicodeString &MeasureFormat::formatNumeric(
FormattedStringBuilder fsb;
- UBool protect = FALSE;
+ UBool protect = false;
const int32_t patternLength = pattern.length();
for (int32_t i = 0; i < patternLength; i++) {
char16_t c = pattern[i];
diff --git a/contrib/libs/icu/i18n/measunit.cpp b/contrib/libs/icu/i18n/measunit.cpp
index 5ad3991974..47ae5bcf5d 100644
--- a/contrib/libs/icu/i18n/measunit.cpp
+++ b/contrib/libs/icu/i18n/measunit.cpp
@@ -43,24 +43,24 @@ static const int32_t gOffsets[] = {
17,
27,
31,
- 330,
- 341,
- 357,
- 361,
- 370,
+ 332,
+ 343,
+ 360,
+ 364,
373,
- 377,
- 385,
- 407,
- 411,
- 426,
- 427,
- 433,
- 443,
- 447,
+ 376,
+ 380,
+ 388,
+ 410,
+ 414,
+ 429,
+ 430,
+ 436,
+ 446,
451,
- 453,
- 487
+ 455,
+ 457,
+ 491
};
static const int32_t kCurrencyOffset = 5;
@@ -345,6 +345,7 @@ static const char * const gSubTypes[] = {
"SHP",
"SIT",
"SKK",
+ "SLE",
"SLL",
"SOS",
"SRD",
@@ -384,6 +385,7 @@ static const char * const gSubTypes[] = {
"UYW",
"UZS",
"VEB",
+ "VED",
"VEF",
"VES",
"VNC",
@@ -446,6 +448,7 @@ static const char * const gSubTypes[] = {
"month",
"month-person",
"nanosecond",
+ "quarter",
"second",
"week",
"week-person",
@@ -511,7 +514,6 @@ static const char * const gSubTypes[] = {
"grain",
"gram",
"kilogram",
- "metric-ton",
"microgram",
"milligram",
"ounce",
@@ -520,6 +522,7 @@ static const char * const gSubTypes[] = {
"solar-mass",
"stone",
"ton",
+ "tonne",
"",
"gigawatt",
"horsepower",
@@ -537,6 +540,7 @@ static const char * const gSubTypes[] = {
"millimeter-ofhg",
"pascal",
"pound-force-per-square-inch",
+ "beaufort",
"kilometer-per-hour",
"knot",
"meter-per-second",
@@ -1011,46 +1015,54 @@ MeasureUnit MeasureUnit::getNanosecond() {
return MeasureUnit(7, 10);
}
-MeasureUnit *MeasureUnit::createSecond(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createQuarter(UErrorCode &status) {
return MeasureUnit::create(7, 11, status);
}
-MeasureUnit MeasureUnit::getSecond() {
+MeasureUnit MeasureUnit::getQuarter() {
return MeasureUnit(7, 11);
}
-MeasureUnit *MeasureUnit::createWeek(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createSecond(UErrorCode &status) {
return MeasureUnit::create(7, 12, status);
}
-MeasureUnit MeasureUnit::getWeek() {
+MeasureUnit MeasureUnit::getSecond() {
return MeasureUnit(7, 12);
}
-MeasureUnit *MeasureUnit::createWeekPerson(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createWeek(UErrorCode &status) {
return MeasureUnit::create(7, 13, status);
}
-MeasureUnit MeasureUnit::getWeekPerson() {
+MeasureUnit MeasureUnit::getWeek() {
return MeasureUnit(7, 13);
}
-MeasureUnit *MeasureUnit::createYear(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createWeekPerson(UErrorCode &status) {
return MeasureUnit::create(7, 14, status);
}
-MeasureUnit MeasureUnit::getYear() {
+MeasureUnit MeasureUnit::getWeekPerson() {
return MeasureUnit(7, 14);
}
-MeasureUnit *MeasureUnit::createYearPerson(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createYear(UErrorCode &status) {
return MeasureUnit::create(7, 15, status);
}
-MeasureUnit MeasureUnit::getYearPerson() {
+MeasureUnit MeasureUnit::getYear() {
return MeasureUnit(7, 15);
}
+MeasureUnit *MeasureUnit::createYearPerson(UErrorCode &status) {
+ return MeasureUnit::create(7, 16, status);
+}
+
+MeasureUnit MeasureUnit::getYearPerson() {
+ return MeasureUnit(7, 16);
+}
+
MeasureUnit *MeasureUnit::createAmpere(UErrorCode &status) {
return MeasureUnit::create(8, 0, status);
}
@@ -1532,74 +1544,82 @@ MeasureUnit MeasureUnit::getKilogram() {
}
MeasureUnit *MeasureUnit::createMetricTon(UErrorCode &status) {
- return MeasureUnit::create(15, 6, status);
+ return MeasureUnit::create(15, 14, status);
}
MeasureUnit MeasureUnit::getMetricTon() {
- return MeasureUnit(15, 6);
+ return MeasureUnit(15, 14);
}
MeasureUnit *MeasureUnit::createMicrogram(UErrorCode &status) {
- return MeasureUnit::create(15, 7, status);
+ return MeasureUnit::create(15, 6, status);
}
MeasureUnit MeasureUnit::getMicrogram() {
- return MeasureUnit(15, 7);
+ return MeasureUnit(15, 6);
}
MeasureUnit *MeasureUnit::createMilligram(UErrorCode &status) {
- return MeasureUnit::create(15, 8, status);
+ return MeasureUnit::create(15, 7, status);
}
MeasureUnit MeasureUnit::getMilligram() {
- return MeasureUnit(15, 8);
+ return MeasureUnit(15, 7);
}
MeasureUnit *MeasureUnit::createOunce(UErrorCode &status) {
- return MeasureUnit::create(15, 9, status);
+ return MeasureUnit::create(15, 8, status);
}
MeasureUnit MeasureUnit::getOunce() {
- return MeasureUnit(15, 9);
+ return MeasureUnit(15, 8);
}
MeasureUnit *MeasureUnit::createOunceTroy(UErrorCode &status) {
- return MeasureUnit::create(15, 10, status);
+ return MeasureUnit::create(15, 9, status);
}
MeasureUnit MeasureUnit::getOunceTroy() {
- return MeasureUnit(15, 10);
+ return MeasureUnit(15, 9);
}
MeasureUnit *MeasureUnit::createPound(UErrorCode &status) {
- return MeasureUnit::create(15, 11, status);
+ return MeasureUnit::create(15, 10, status);
}
MeasureUnit MeasureUnit::getPound() {
- return MeasureUnit(15, 11);
+ return MeasureUnit(15, 10);
}
MeasureUnit *MeasureUnit::createSolarMass(UErrorCode &status) {
- return MeasureUnit::create(15, 12, status);
+ return MeasureUnit::create(15, 11, status);
}
MeasureUnit MeasureUnit::getSolarMass() {
- return MeasureUnit(15, 12);
+ return MeasureUnit(15, 11);
}
MeasureUnit *MeasureUnit::createStone(UErrorCode &status) {
- return MeasureUnit::create(15, 13, status);
+ return MeasureUnit::create(15, 12, status);
}
MeasureUnit MeasureUnit::getStone() {
- return MeasureUnit(15, 13);
+ return MeasureUnit(15, 12);
}
MeasureUnit *MeasureUnit::createTon(UErrorCode &status) {
- return MeasureUnit::create(15, 14, status);
+ return MeasureUnit::create(15, 13, status);
}
MeasureUnit MeasureUnit::getTon() {
+ return MeasureUnit(15, 13);
+}
+
+MeasureUnit *MeasureUnit::createTonne(UErrorCode &status) {
+ return MeasureUnit::create(15, 14, status);
+}
+
+MeasureUnit MeasureUnit::getTonne() {
return MeasureUnit(15, 14);
}
@@ -1731,38 +1751,46 @@ MeasureUnit MeasureUnit::getPoundPerSquareInch() {
return MeasureUnit(18, 9);
}
-MeasureUnit *MeasureUnit::createKilometerPerHour(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createBeaufort(UErrorCode &status) {
return MeasureUnit::create(19, 0, status);
}
-MeasureUnit MeasureUnit::getKilometerPerHour() {
+MeasureUnit MeasureUnit::getBeaufort() {
return MeasureUnit(19, 0);
}
-MeasureUnit *MeasureUnit::createKnot(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createKilometerPerHour(UErrorCode &status) {
return MeasureUnit::create(19, 1, status);
}
-MeasureUnit MeasureUnit::getKnot() {
+MeasureUnit MeasureUnit::getKilometerPerHour() {
return MeasureUnit(19, 1);
}
-MeasureUnit *MeasureUnit::createMeterPerSecond(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createKnot(UErrorCode &status) {
return MeasureUnit::create(19, 2, status);
}
-MeasureUnit MeasureUnit::getMeterPerSecond() {
+MeasureUnit MeasureUnit::getKnot() {
return MeasureUnit(19, 2);
}
-MeasureUnit *MeasureUnit::createMilePerHour(UErrorCode &status) {
+MeasureUnit *MeasureUnit::createMeterPerSecond(UErrorCode &status) {
return MeasureUnit::create(19, 3, status);
}
-MeasureUnit MeasureUnit::getMilePerHour() {
+MeasureUnit MeasureUnit::getMeterPerSecond() {
return MeasureUnit(19, 3);
}
+MeasureUnit *MeasureUnit::createMilePerHour(UErrorCode &status) {
+ return MeasureUnit::create(19, 4, status);
+}
+
+MeasureUnit MeasureUnit::getMilePerHour() {
+ return MeasureUnit(19, 4);
+}
+
MeasureUnit *MeasureUnit::createCelsius(UErrorCode &status) {
return MeasureUnit::create(20, 0, status);
}
@@ -2258,13 +2286,13 @@ StringEnumeration* MeasureUnit::getAvailableTypes(UErrorCode &errorCode) {
gTypes, UPRV_LENGTHOF(gTypes), &errorCode);
if (U_FAILURE(errorCode)) {
uenum_close(uenum);
- return NULL;
+ return nullptr;
}
StringEnumeration *result = new UStringEnumeration(uenum);
- if (result == NULL) {
+ if (result == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
uenum_close(uenum);
- return NULL;
+ return nullptr;
}
return result;
}
@@ -2290,10 +2318,10 @@ bool MeasureUnit::findBySubType(StringPiece subType, MeasureUnit* output) {
MeasureUnit *MeasureUnit::create(int typeId, int subTypeId, UErrorCode &status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
MeasureUnit *result = new MeasureUnit(typeId, subTypeId);
- if (result == NULL) {
+ if (result == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
return result;
diff --git a/contrib/libs/icu/i18n/measunit_extra.cpp b/contrib/libs/icu/i18n/measunit_extra.cpp
index 8281119007..295d6a8ce8 100644
--- a/contrib/libs/icu/i18n/measunit_extra.cpp
+++ b/contrib/libs/icu/i18n/measunit_extra.cpp
@@ -148,7 +148,7 @@ const struct UnitPrefixStrings {
* int32_t *unitCategories[ARR_SIZE];
* SimpleUnitIdentifiersSink identifierSink(gSerializedUnitCategoriesTrie, unitIdentifiers,
* unitCategories, ARR_SIZE, b, kTrieValueOffset);
- * LocalUResourceBundlePointer unitsBundle(ures_openDirect(NULL, "units", &status));
+ * LocalUResourceBundlePointer unitsBundle(ures_openDirect(nullptr, "units", &status));
* ures_getAllItemsWithFallback(unitsBundle.getAlias(), "convertUnits", identifierSink, status);
*/
class SimpleUnitIdentifiersSink : public icu::ResourceSink {
@@ -220,7 +220,7 @@ class SimpleUnitIdentifiersSink : public icu::ResourceSink {
break;
}
int32_t len;
- const UChar* uTarget = value.getString(len, status);
+ const char16_t* uTarget = value.getString(len, status);
CharString target;
target.appendInvariantChars(uTarget, len, status);
if (U_FAILURE(status)) { return; }
@@ -255,15 +255,15 @@ class SimpleUnitIdentifiersSink : public icu::ResourceSink {
*
* For example: "kilogram" -> "mass", "meter-per-second" -> "speed".
*
- * In C++ unitQuantity values are collected in order into a UChar* array, while
+ * In C++ unitQuantity values are collected in order into a char16_t* array, while
* unitQuantity keys are added added to a TrieBuilder, with associated values
- * being the index into the aforementioned UChar* array.
+ * being the index into the aforementioned char16_t* array.
*/
class CategoriesSink : public icu::ResourceSink {
public:
/**
* Constructor.
- * @param out Array of UChar* to which unitQuantity values will be saved.
+ * @param out Array of char16_t* to which unitQuantity values will be saved.
* The pointers returned not owned: they point directly at the resource
* strings in static memory.
* @param outSize The size of the `out` array.
@@ -271,7 +271,7 @@ class CategoriesSink : public icu::ResourceSink {
* each unitQuantity will be added, each with value being the offset
* into `out`.
*/
- explicit CategoriesSink(const UChar **out, int32_t &outSize, BytesTrieBuilder &trieBuilder)
+ explicit CategoriesSink(const char16_t **out, int32_t &outSize, BytesTrieBuilder &trieBuilder)
: outQuantitiesArray(out), outSize(outSize), trieBuilder(trieBuilder), outIndex(0) {}
void put(const char * /*key*/, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) override {
@@ -305,14 +305,14 @@ class CategoriesSink : public icu::ResourceSink {
}
private:
- const UChar **outQuantitiesArray;
+ const char16_t **outQuantitiesArray;
int32_t &outSize;
BytesTrieBuilder &trieBuilder;
int32_t outIndex;
};
-icu::UInitOnce gUnitExtrasInitOnce = U_INITONCE_INITIALIZER;
+icu::UInitOnce gUnitExtrasInitOnce {};
// Array of simple unit IDs.
//
@@ -327,11 +327,11 @@ int32_t *gSimpleUnitCategories = nullptr;
char *gSerializedUnitExtrasStemTrie = nullptr;
-// Array of UChar* pointing at the unit categories (aka "quantities", aka
+// Array of char16_t* pointing at the unit categories (aka "quantities", aka
// "types"), as found in the `unitQuantities` resource. The array memory itself
-// is owned by this pointer, but the individual UChar* in that array point at
+// is owned by this pointer, but the individual char16_t* in that array point at
// static memory.
-const UChar **gCategories = nullptr;
+const char16_t **gCategories = nullptr;
// Number of items in `gCategories`.
int32_t gCategoriesCount = 0;
// Serialized BytesTrie for mapping from base units to indices into gCategories.
@@ -349,7 +349,7 @@ UBool U_CALLCONV cleanupUnitExtras() {
uprv_free(gSimpleUnits);
gSimpleUnits = nullptr;
gUnitExtrasInitOnce.reset();
- return TRUE;
+ return true;
}
void U_CALLCONV initUnitExtras(UErrorCode& status) {
@@ -362,8 +362,8 @@ void U_CALLCONV initUnitExtras(UErrorCode& status) {
ures_getByKey(unitsBundle.getAlias(), CATEGORY_TABLE_NAME, nullptr, &status));
if (U_FAILURE(status)) { return; }
gCategoriesCount = unitQuantities.getAlias()->fSize;
- size_t quantitiesMallocSize = sizeof(UChar *) * gCategoriesCount;
- gCategories = static_cast<const UChar **>(uprv_malloc(quantitiesMallocSize));
+ size_t quantitiesMallocSize = sizeof(char16_t *) * gCategoriesCount;
+ gCategories = static_cast<const char16_t **>(uprv_malloc(quantitiesMallocSize));
if (gCategories == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -615,7 +615,7 @@ private:
// 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
- // identifier is invalid pending TODO(CLDR-13700).
+ // identifier is invalid pending TODO(CLDR-13701).
bool fAfterPer = false;
Parser() : fSource(""), fTrie(u"") {}
@@ -669,7 +669,7 @@ private:
* dimensionality.
*
* Returns an error if we parse both compound units and "-and-", since mixed
- * compound units are not yet supported - TODO(CLDR-13700).
+ * compound units are not yet supported - TODO(CLDR-13701).
*
* @param result Will be overwritten by the result, if status shows success.
* @param sawAnd If an "-and-" was parsed prior to finding the "single
@@ -718,7 +718,7 @@ private:
case COMPOUND_PART_PER:
if (sawAnd) {
// Mixed compound units not yet supported,
- // TODO(CLDR-13700).
+ // TODO(CLDR-13701).
status = kUnitIdentifierSyntaxError;
return result;
}
@@ -735,7 +735,7 @@ private:
case COMPOUND_PART_AND:
if (fAfterPer) {
// Can't start with "-and-", and mixed compound units
- // not yet supported, TODO(CLDR-13700).
+ // not yet supported, TODO(CLDR-13701).
status = kUnitIdentifierSyntaxError;
return result;
}
@@ -946,7 +946,7 @@ const char *SingleUnitImpl::getSimpleUnitID() const {
return gSimpleUnits[index];
}
-void SingleUnitImpl::appendNeutralIdentifier(CharString &result, UErrorCode &status) const {
+void SingleUnitImpl::appendNeutralIdentifier(CharString &result, UErrorCode &status) const UPRV_NO_SANITIZE_UNDEFINED {
int32_t absPower = std::abs(this->dimensionality);
U_ASSERT(absPower > 0); // "this function does not support the dimensionless single units";
@@ -1195,7 +1195,7 @@ UMeasurePrefix MeasureUnit::getPrefix(UErrorCode& status) const {
return SingleUnitImpl::forMeasureUnit(*this, status).unitPrefix;
}
-MeasureUnit MeasureUnit::withPrefix(UMeasurePrefix prefix, UErrorCode& status) const {
+MeasureUnit MeasureUnit::withPrefix(UMeasurePrefix prefix, UErrorCode& status) const UPRV_NO_SANITIZE_UNDEFINED {
SingleUnitImpl singleUnit = SingleUnitImpl::forMeasureUnit(*this, status);
singleUnit.unitPrefix = prefix;
return singleUnit.build(status);
diff --git a/contrib/libs/icu/i18n/measure.cpp b/contrib/libs/icu/i18n/measure.cpp
index b9c47fd401..cdbd995034 100644
--- a/contrib/libs/icu/i18n/measure.cpp
+++ b/contrib/libs/icu/i18n/measure.cpp
@@ -69,8 +69,8 @@ bool Measure::operator==(const UObject& other) const {
}
const Measure &m = static_cast<const Measure&>(other);
return number == m.number &&
- ((unit == NULL) == (m.unit == NULL)) &&
- (unit == NULL || *unit == *m.unit);
+ ((unit == nullptr) == (m.unit == nullptr)) &&
+ (unit == nullptr || *unit == *m.unit);
}
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/msgfmt.cpp b/contrib/libs/icu/i18n/msgfmt.cpp
index b8cb2e2ca5..29fb4b3a01 100644
--- a/contrib/libs/icu/i18n/msgfmt.cpp
+++ b/contrib/libs/icu/i18n/msgfmt.cpp
@@ -55,87 +55,87 @@
// class MessageFormat
// *****************************************************************************
-#define SINGLE_QUOTE ((UChar)0x0027)
-#define COMMA ((UChar)0x002C)
-#define LEFT_CURLY_BRACE ((UChar)0x007B)
-#define RIGHT_CURLY_BRACE ((UChar)0x007D)
+#define SINGLE_QUOTE ((char16_t)0x0027)
+#define COMMA ((char16_t)0x002C)
+#define LEFT_CURLY_BRACE ((char16_t)0x007B)
+#define RIGHT_CURLY_BRACE ((char16_t)0x007D)
//---------------------------------------
// static data
-static const UChar ID_NUMBER[] = {
+static const char16_t ID_NUMBER[] = {
0x6E, 0x75, 0x6D, 0x62, 0x65, 0x72, 0 /* "number" */
};
-static const UChar ID_DATE[] = {
+static const char16_t ID_DATE[] = {
0x64, 0x61, 0x74, 0x65, 0 /* "date" */
};
-static const UChar ID_TIME[] = {
+static const char16_t ID_TIME[] = {
0x74, 0x69, 0x6D, 0x65, 0 /* "time" */
};
-static const UChar ID_SPELLOUT[] = {
+static const char16_t ID_SPELLOUT[] = {
0x73, 0x70, 0x65, 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0 /* "spellout" */
};
-static const UChar ID_ORDINAL[] = {
+static const char16_t ID_ORDINAL[] = {
0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x6c, 0 /* "ordinal" */
};
-static const UChar ID_DURATION[] = {
+static const char16_t ID_DURATION[] = {
0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0 /* "duration" */
};
// MessageFormat Type List Number, Date, Time or Choice
-static const UChar * const TYPE_IDS[] = {
+static const char16_t * const TYPE_IDS[] = {
ID_NUMBER,
ID_DATE,
ID_TIME,
ID_SPELLOUT,
ID_ORDINAL,
ID_DURATION,
- NULL,
+ nullptr,
};
-static const UChar ID_EMPTY[] = {
+static const char16_t ID_EMPTY[] = {
0 /* empty string, used for default so that null can mark end of list */
};
-static const UChar ID_CURRENCY[] = {
+static const char16_t ID_CURRENCY[] = {
0x63, 0x75, 0x72, 0x72, 0x65, 0x6E, 0x63, 0x79, 0 /* "currency" */
};
-static const UChar ID_PERCENT[] = {
+static const char16_t ID_PERCENT[] = {
0x70, 0x65, 0x72, 0x63, 0x65, 0x6E, 0x74, 0 /* "percent" */
};
-static const UChar ID_INTEGER[] = {
+static const char16_t ID_INTEGER[] = {
0x69, 0x6E, 0x74, 0x65, 0x67, 0x65, 0x72, 0 /* "integer" */
};
// NumberFormat modifier list, default, currency, percent or integer
-static const UChar * const NUMBER_STYLE_IDS[] = {
+static const char16_t * const NUMBER_STYLE_IDS[] = {
ID_EMPTY,
ID_CURRENCY,
ID_PERCENT,
ID_INTEGER,
- NULL,
+ nullptr,
};
-static const UChar ID_SHORT[] = {
+static const char16_t ID_SHORT[] = {
0x73, 0x68, 0x6F, 0x72, 0x74, 0 /* "short" */
};
-static const UChar ID_MEDIUM[] = {
+static const char16_t ID_MEDIUM[] = {
0x6D, 0x65, 0x64, 0x69, 0x75, 0x6D, 0 /* "medium" */
};
-static const UChar ID_LONG[] = {
+static const char16_t ID_LONG[] = {
0x6C, 0x6F, 0x6E, 0x67, 0 /* "long" */
};
-static const UChar ID_FULL[] = {
+static const char16_t ID_FULL[] = {
0x66, 0x75, 0x6C, 0x6C, 0 /* "full" */
};
// DateFormat modifier list, default, short, medium, long or full
-static const UChar * const DATE_STYLE_IDS[] = {
+static const char16_t * const DATE_STYLE_IDS[] = {
ID_EMPTY,
ID_SHORT,
ID_MEDIUM,
ID_LONG,
ID_FULL,
- NULL,
+ nullptr,
};
static const icu::DateFormat::EStyle DATE_STYLES[] = {
@@ -148,11 +148,11 @@ static const icu::DateFormat::EStyle DATE_STYLES[] = {
static const int32_t DEFAULT_INITIAL_CAPACITY = 10;
-static const UChar NULL_STRING[] = {
+static const char16_t NULL_STRING[] = {
0x6E, 0x75, 0x6C, 0x6C, 0 // "null"
};
-static const UChar OTHER_STRING[] = {
+static const char16_t OTHER_STRING[] = {
0x6F, 0x74, 0x68, 0x65, 0x72, 0 // "other"
};
@@ -177,7 +177,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(FormatNameEnumeration)
* the given UnicodeString.
*/
static UnicodeString& itos(int32_t i, UnicodeString& appendTo) {
- UChar temp[16];
+ char16_t temp[16];
uprv_itou(temp,16,i,10,0); // 10 == radix
appendTo.append(temp, -1);
return appendTo;
@@ -194,7 +194,7 @@ public:
app.appendString(s.getBuffer(), s.length());
len += s.length();
}
- void append(const UChar* s, const int32_t sLength) {
+ void append(const char16_t* s, const int32_t sLength) {
app.appendString(s, sLength);
len += sLength;
}
@@ -234,16 +234,16 @@ MessageFormat::MessageFormat(const UnicodeString& pattern,
UErrorCode& success)
: fLocale(Locale::getDefault()), // Uses the default locale
msgPattern(success),
- formatAliases(NULL),
+ formatAliases(nullptr),
formatAliasesCapacity(0),
- argTypes(NULL),
+ argTypes(nullptr),
argTypeCount(0),
argTypeCapacity(0),
- hasArgTypeConflicts(FALSE),
- defaultNumberFormat(NULL),
- defaultDateFormat(NULL),
- cachedFormatters(NULL),
- customFormatArgStarts(NULL),
+ hasArgTypeConflicts(false),
+ defaultNumberFormat(nullptr),
+ defaultDateFormat(nullptr),
+ cachedFormatters(nullptr),
+ customFormatArgStarts(nullptr),
pluralProvider(*this, UPLURAL_TYPE_CARDINAL),
ordinalProvider(*this, UPLURAL_TYPE_ORDINAL)
{
@@ -256,16 +256,16 @@ MessageFormat::MessageFormat(const UnicodeString& pattern,
UErrorCode& success)
: fLocale(newLocale),
msgPattern(success),
- formatAliases(NULL),
+ formatAliases(nullptr),
formatAliasesCapacity(0),
- argTypes(NULL),
+ argTypes(nullptr),
argTypeCount(0),
argTypeCapacity(0),
- hasArgTypeConflicts(FALSE),
- defaultNumberFormat(NULL),
- defaultDateFormat(NULL),
- cachedFormatters(NULL),
- customFormatArgStarts(NULL),
+ hasArgTypeConflicts(false),
+ defaultNumberFormat(nullptr),
+ defaultDateFormat(nullptr),
+ cachedFormatters(nullptr),
+ customFormatArgStarts(nullptr),
pluralProvider(*this, UPLURAL_TYPE_CARDINAL),
ordinalProvider(*this, UPLURAL_TYPE_ORDINAL)
{
@@ -279,16 +279,16 @@ MessageFormat::MessageFormat(const UnicodeString& pattern,
UErrorCode& success)
: fLocale(newLocale),
msgPattern(success),
- formatAliases(NULL),
+ formatAliases(nullptr),
formatAliasesCapacity(0),
- argTypes(NULL),
+ argTypes(nullptr),
argTypeCount(0),
argTypeCapacity(0),
- hasArgTypeConflicts(FALSE),
- defaultNumberFormat(NULL),
- defaultDateFormat(NULL),
- cachedFormatters(NULL),
- customFormatArgStarts(NULL),
+ hasArgTypeConflicts(false),
+ defaultNumberFormat(nullptr),
+ defaultDateFormat(nullptr),
+ cachedFormatters(nullptr),
+ customFormatArgStarts(nullptr),
pluralProvider(*this, UPLURAL_TYPE_CARDINAL),
ordinalProvider(*this, UPLURAL_TYPE_ORDINAL)
{
@@ -301,20 +301,20 @@ MessageFormat::MessageFormat(const MessageFormat& that)
Format(that),
fLocale(that.fLocale),
msgPattern(that.msgPattern),
- formatAliases(NULL),
+ formatAliases(nullptr),
formatAliasesCapacity(0),
- argTypes(NULL),
+ argTypes(nullptr),
argTypeCount(0),
argTypeCapacity(0),
hasArgTypeConflicts(that.hasArgTypeConflicts),
- defaultNumberFormat(NULL),
- defaultDateFormat(NULL),
- cachedFormatters(NULL),
- customFormatArgStarts(NULL),
+ defaultNumberFormat(nullptr),
+ defaultDateFormat(nullptr),
+ cachedFormatters(nullptr),
+ customFormatArgStarts(nullptr),
pluralProvider(*this, UPLURAL_TYPE_CARDINAL),
ordinalProvider(*this, UPLURAL_TYPE_ORDINAL)
{
- // This will take care of creating the hash tables (since they are NULL).
+ // This will take care of creating the hash tables (since they are nullptr).
UErrorCode ec = U_ZERO_ERROR;
copyObjects(that, ec);
if (U_FAILURE(ec)) {
@@ -338,17 +338,17 @@ MessageFormat::~MessageFormat()
/**
* Allocate argTypes[] to at least the given capacity and return
- * TRUE if successful. If not, leave argTypes[] unchanged.
+ * true if successful. If not, leave argTypes[] unchanged.
*
- * If argTypes is NULL, allocate it. If it is not NULL, enlarge it
+ * If argTypes is nullptr, allocate it. If it is not nullptr, enlarge it
* if necessary to be at least as large as specified.
*/
UBool MessageFormat::allocateArgTypes(int32_t capacity, UErrorCode& status) {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (argTypeCapacity >= capacity) {
- return TRUE;
+ return true;
}
if (capacity < DEFAULT_INITIAL_CAPACITY) {
capacity = DEFAULT_INITIAL_CAPACITY;
@@ -357,13 +357,13 @@ UBool MessageFormat::allocateArgTypes(int32_t capacity, UErrorCode& status) {
}
Formattable::Type* a = (Formattable::Type*)
uprv_realloc(argTypes, sizeof(*argTypes) * capacity);
- if (a == NULL) {
+ if (a == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return FALSE;
+ return false;
}
argTypes = a;
argTypeCapacity = capacity;
- return TRUE;
+ return true;
}
// -------------------------------------
@@ -394,20 +394,20 @@ MessageFormat::operator==(const Format& rhs) const
{
if (this == &rhs) return true;
- MessageFormat& that = (MessageFormat&)rhs;
-
// Check class ID before checking MessageFormat members
- if (!Format::operator==(rhs) ||
- msgPattern != that.msgPattern ||
+ if (!Format::operator==(rhs)) return false;
+
+ const MessageFormat& that = static_cast<const MessageFormat&>(rhs);
+ if (msgPattern != that.msgPattern ||
fLocale != that.fLocale) {
return false;
}
// Compare hashtables.
- if ((customFormatArgStarts == NULL) != (that.customFormatArgStarts == NULL)) {
+ if ((customFormatArgStarts == nullptr) != (that.customFormatArgStarts == nullptr)) {
return false;
}
- if (customFormatArgStarts == NULL) {
+ if (customFormatArgStarts == nullptr) {
return true;
}
@@ -450,9 +450,9 @@ MessageFormat::setLocale(const Locale& theLocale)
{
if (fLocale != theLocale) {
delete defaultNumberFormat;
- defaultNumberFormat = NULL;
+ defaultNumberFormat = nullptr;
delete defaultDateFormat;
- defaultDateFormat = NULL;
+ defaultDateFormat = nullptr;
fLocale = theLocale;
setLocaleIDs(fLocale.getName(), fLocale.getName());
pluralProvider.reset();
@@ -500,11 +500,11 @@ MessageFormat::applyPattern(const UnicodeString& pattern,
void MessageFormat::resetPattern() {
msgPattern.clear();
uhash_close(cachedFormatters);
- cachedFormatters = NULL;
+ cachedFormatters = nullptr;
uhash_close(customFormatArgStarts);
- customFormatArgStarts = NULL;
+ customFormatArgStarts = nullptr;
argTypeCount = 0;
- hasArgTypeConflicts = FALSE;
+ hasArgTypeConflicts = false;
}
void
@@ -515,7 +515,8 @@ MessageFormat::applyPattern(const UnicodeString& pattern,
if (aposMode != msgPattern.getApostropheMode()) {
msgPattern.clearPatternAndSetApostropheMode(aposMode);
}
- applyPattern(pattern, *parseError, status);
+ UParseError tempParseError;
+ applyPattern(pattern, (parseError == nullptr) ? tempParseError : *parseError, status);
}
// -------------------------------------
@@ -523,7 +524,7 @@ MessageFormat::applyPattern(const UnicodeString& pattern,
UnicodeString&
MessageFormat::toPattern(UnicodeString& appendTo) const {
- if ((customFormatArgStarts != NULL && 0 != uhash_count(customFormatArgStarts)) ||
+ if ((customFormatArgStarts != nullptr && 0 != uhash_count(customFormatArgStarts)) ||
0 == msgPattern.countParts()
) {
appendTo.setToBogus();
@@ -554,7 +555,7 @@ void MessageFormat::setArgStartFormat(int32_t argStart,
delete formatter;
return;
}
- if (cachedFormatters == NULL) {
+ if (cachedFormatters == nullptr) {
cachedFormatters=uhash_open(uhash_hashLong, uhash_compareLong,
equalFormatsForHash, &status);
if (U_FAILURE(status)) {
@@ -563,7 +564,7 @@ void MessageFormat::setArgStartFormat(int32_t argStart,
}
uhash_setValueDeleter(cachedFormatters, uprv_deleteUObject);
}
- if (formatter == NULL) {
+ if (formatter == nullptr) {
formatter = new DummyFormat();
}
uhash_iput(cachedFormatters, argStart, formatter, &status);
@@ -583,23 +584,23 @@ void MessageFormat::setCustomArgStartFormat(int32_t argStart,
Format* formatter,
UErrorCode& status) {
setArgStartFormat(argStart, formatter, status);
- if (customFormatArgStarts == NULL) {
+ if (customFormatArgStarts == nullptr) {
customFormatArgStarts=uhash_open(uhash_hashLong, uhash_compareLong,
- NULL, &status);
+ nullptr, &status);
}
uhash_iputi(customFormatArgStarts, argStart, 1, &status);
}
Format* MessageFormat::getCachedFormatter(int32_t argumentNumber) const {
- if (cachedFormatters == NULL) {
- return NULL;
+ if (cachedFormatters == nullptr) {
+ return nullptr;
}
void* ptr = uhash_iget(cachedFormatters, argumentNumber);
- if (ptr != NULL && dynamic_cast<DummyFormat*>((Format*)ptr) == NULL) {
+ if (ptr != nullptr && dynamic_cast<DummyFormat*>((Format*)ptr) == nullptr) {
return (Format*) ptr;
} else {
- // Not cached, or a DummyFormat representing setFormat(NULL).
- return NULL;
+ // Not cached, or a DummyFormat representing setFormat(nullptr).
+ return nullptr;
}
}
@@ -609,14 +610,14 @@ Format* MessageFormat::getCachedFormatter(int32_t argumentNumber) const {
void
MessageFormat::adoptFormats(Format** newFormats,
int32_t count) {
- if (newFormats == NULL || count < 0) {
+ if (newFormats == nullptr || count < 0) {
return;
}
// Throw away any cached formatters.
- if (cachedFormatters != NULL) {
+ if (cachedFormatters != nullptr) {
uhash_removeAll(cachedFormatters);
}
- if (customFormatArgStarts != NULL) {
+ if (customFormatArgStarts != nullptr) {
uhash_removeAll(customFormatArgStarts);
}
@@ -642,14 +643,14 @@ MessageFormat::adoptFormats(Format** newFormats,
void
MessageFormat::setFormats(const Format** newFormats,
int32_t count) {
- if (newFormats == NULL || count < 0) {
+ if (newFormats == nullptr || count < 0) {
return;
}
// Throw away any cached formatters.
- if (cachedFormatters != NULL) {
+ if (cachedFormatters != nullptr) {
uhash_removeAll(cachedFormatters);
}
- if (customFormatArgStarts != NULL) {
+ if (customFormatArgStarts != nullptr) {
uhash_removeAll(customFormatArgStarts);
}
@@ -657,10 +658,10 @@ MessageFormat::setFormats(const Format** newFormats,
int32_t formatNumber = 0;
for (int32_t partIndex = 0;
formatNumber < count && U_SUCCESS(status) && (partIndex = nextTopLevelArgStart(partIndex)) >= 0;) {
- Format* newFormat = NULL;
- if (newFormats[formatNumber] != NULL) {
+ Format* newFormat = nullptr;
+ if (newFormats[formatNumber] != nullptr) {
newFormat = newFormats[formatNumber]->clone();
- if (newFormat == NULL) {
+ if (newFormat == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
}
@@ -715,11 +716,11 @@ MessageFormat::adoptFormat(const UnicodeString& formatName,
Format* f;
if (p.isValid()) {
f = p.orphan();
- } else if (formatToAdopt == NULL) {
- f = NULL;
+ } else if (formatToAdopt == nullptr) {
+ f = nullptr;
} else {
f = formatToAdopt->clone();
- if (f == NULL) {
+ if (f == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -757,19 +758,19 @@ MessageFormat::setFormat(int32_t n, const Format& newFormat) {
// Do nothing if the variable is not less than the array count.
Format *
MessageFormat::getFormat(const UnicodeString& formatName, UErrorCode& status) {
- if (U_FAILURE(status) || cachedFormatters == NULL) return NULL;
+ if (U_FAILURE(status) || cachedFormatters == nullptr) return nullptr;
int32_t argNumber = MessagePattern::validateArgumentName(formatName);
if (argNumber < UMSGPAT_ARG_NAME_NOT_NUMBER) {
status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
for (int32_t partIndex = 0; (partIndex = nextTopLevelArgStart(partIndex)) >= 0;) {
if (argNameMatches(partIndex + 1, formatName, argNumber)) {
return getCachedFormatter(partIndex);
}
}
- return NULL;
+ return nullptr;
}
// -------------------------------------
@@ -791,7 +792,7 @@ MessageFormat::setFormat(const UnicodeString& formatName,
) {
if (argNameMatches(partIndex + 1, formatName, argNumber)) {
Format* new_format = newFormat.clone();
- if (new_format == NULL) {
+ if (new_format == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -852,21 +853,23 @@ UnicodeString MessageFormat::getArgName(int32_t partIndex) {
StringEnumeration*
MessageFormat::getFormatNames(UErrorCode& status) {
- if (U_FAILURE(status)) return NULL;
+ if (U_FAILURE(status)) return nullptr;
- UVector *fFormatNames = new UVector(status);
+ LocalPointer<UVector> formatNames(new UVector(status), status);
if (U_FAILURE(status)) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
- fFormatNames->setDeleter(uprv_deleteUObject);
+ formatNames->setDeleter(uprv_deleteUObject);
for (int32_t partIndex = 0; (partIndex = nextTopLevelArgStart(partIndex)) >= 0;) {
- fFormatNames->addElementX(new UnicodeString(getArgName(partIndex + 1)), status);
+ LocalPointer<UnicodeString> name(getArgName(partIndex + 1).clone(), status);
+ formatNames->adoptElement(name.orphan(), status);
+ if (U_FAILURE(status)) return nullptr;
}
- StringEnumeration* nameEnumerator = new FormatNameEnumeration(fFormatNames, status);
- return nameEnumerator;
+ LocalPointer<StringEnumeration> nameEnumerator(
+ new FormatNameEnumeration(std::move(formatNames), status), status);
+ return U_SUCCESS(status) ? nameEnumerator.orphan() : nullptr;
}
// -------------------------------------
@@ -880,7 +883,7 @@ MessageFormat::format(const Formattable* source,
FieldPosition& ignore,
UErrorCode& success) const
{
- return format(source, NULL, cnt, appendTo, &ignore, success);
+ return format(source, nullptr, cnt, appendTo, &ignore, success);
}
// -------------------------------------
@@ -896,7 +899,7 @@ MessageFormat::format( const UnicodeString& pattern,
UErrorCode& success)
{
MessageFormat temp(pattern, success);
- return temp.format(arguments, NULL, cnt, appendTo, NULL, success);
+ return temp.format(arguments, nullptr, cnt, appendTo, nullptr, success);
}
// -------------------------------------
@@ -918,7 +921,7 @@ MessageFormat::format(const Formattable& source,
}
int32_t cnt;
const Formattable* tmpPtr = source.getArray(cnt);
- return format(tmpPtr, NULL, cnt, appendTo, &ignore, success);
+ return format(tmpPtr, nullptr, cnt, appendTo, &ignore, success);
}
UnicodeString&
@@ -927,7 +930,7 @@ MessageFormat::format(const UnicodeString* argumentNames,
int32_t count,
UnicodeString& appendTo,
UErrorCode& success) const {
- return format(arguments, argumentNames, count, appendTo, NULL, success);
+ return format(arguments, argumentNames, count, appendTo, nullptr, success);
}
// Does linear search to find the match for an ArgName.
@@ -939,7 +942,7 @@ const Formattable* MessageFormat::getArgFromListByName(const Formattable* argume
return arguments + i;
}
}
- return NULL;
+ return nullptr;
}
@@ -956,7 +959,7 @@ MessageFormat::format(const Formattable* arguments,
UnicodeStringAppendable usapp(appendTo);
AppendableWrapper app(usapp);
- format(0, NULL, arguments, argumentNames, cnt, app, pos, status);
+ format(0, nullptr, arguments, argumentNames, cnt, app, pos, status);
return appendTo;
}
@@ -971,7 +974,7 @@ public:
PluralSelectorContext(int32_t start, const UnicodeString &name,
const Formattable &num, double off, UErrorCode &errorCode)
: startIndex(start), argName(name), offset(off),
- numberArgIndex(-1), formatter(NULL), forReplaceNumber(FALSE) {
+ numberArgIndex(-1), formatter(nullptr), forReplaceNumber(false) {
// number needs to be set even when select() is not called.
// Keep it as a Number/Formattable:
// For format() methods, and to preserve information (e.g., BigDecimal).
@@ -994,14 +997,14 @@ public:
const Format *formatter;
/** formatted argument number - plural offset */
UnicodeString numberString;
- /** TRUE if number-offset was formatted with the stock number formatter */
+ /** true if number-offset was formatted with the stock number formatter */
UBool forReplaceNumber;
};
} // namespace
-// if argumentNames is NULL, this means arguments is a numeric array.
-// arguments can not be NULL.
+// if argumentNames is nullptr, this means arguments is a numeric array.
+// arguments can not be nullptr.
// We use const void *plNumber rather than const PluralSelectorContext *pluralNumber
// so that we need not declare the PluralSelectorContext in the public header file.
void MessageFormat::format(int32_t msgStart, const void *plNumber,
@@ -1046,31 +1049,31 @@ void MessageFormat::format(int32_t msgStart, const void *plNumber,
UMessagePatternArgType argType = part->getArgType();
part = &msgPattern.getPart(++i);
const Formattable* arg;
- UBool noArg = FALSE;
+ UBool noArg = false;
UnicodeString argName = msgPattern.getSubstring(*part);
- if (argumentNames == NULL) {
+ if (argumentNames == nullptr) {
int32_t argNumber = part->getValue(); // ARG_NUMBER
if (0 <= argNumber && argNumber < cnt) {
arg = arguments + argNumber;
} else {
- arg = NULL;
- noArg = TRUE;
+ arg = nullptr;
+ noArg = true;
}
} else {
arg = getArgFromListByName(arguments, argumentNames, cnt, argName);
- if (arg == NULL) {
- noArg = TRUE;
+ if (arg == nullptr) {
+ noArg = true;
}
}
++i;
int32_t prevDestLength = appendTo.length();
- const Format* formatter = NULL;
+ const Format* formatter = nullptr;
if (noArg) {
appendTo.append(
UnicodeString(LEFT_CURLY_BRACE).append(argName).append(RIGHT_CURLY_BRACE));
- } else if (arg == NULL) {
+ } else if (arg == nullptr) {
appendTo.append(NULL_STRING, 4);
- } else if(plNumber!=NULL &&
+ } else if(plNumber!=nullptr &&
static_cast<const PluralSelectorContext *>(plNumber)->numberArgIndex==(i-2)) {
const PluralSelectorContext &pluralNumber =
*static_cast<const PluralSelectorContext *>(plNumber);
@@ -1097,7 +1100,7 @@ void MessageFormat::format(int32_t msgStart, const void *plNumber,
(subMsgString.indexOf(SINGLE_QUOTE) >= 0 && !MessageImpl::jdkAposMode(msgPattern))
) {
MessageFormat subMsgFormat(subMsgString, fLocale, success);
- subMsgFormat.format(0, NULL, arguments, argumentNames, cnt, appendTo, ignore, success);
+ subMsgFormat.format(0, nullptr, arguments, argumentNames, cnt, appendTo, ignore, success);
} else {
appendTo.append(subMsgString);
}
@@ -1105,7 +1108,7 @@ void MessageFormat::format(int32_t msgStart, const void *plNumber,
appendTo.formatAndAppend(formatter, *arg, success);
}
} else if (argType == UMSGPAT_ARG_TYPE_NONE || (cachedFormatters && uhash_iget(cachedFormatters, i - 2))) {
- // We arrive here if getCachedFormatter returned NULL, but there was actually an element in the hash table.
+ // We arrive here if getCachedFormatter returned nullptr, but there was actually an element in the hash table.
// This can only happen if the hash table contained a DummyFormat, so the if statement above is a check
// for the hash table containing DummyFormat.
if (arg->isNumeric()) {
@@ -1126,7 +1129,7 @@ void MessageFormat::format(int32_t msgStart, const void *plNumber,
// because only this one converts non-double numeric types to double.
const double number = arg->getDouble(success);
int32_t subMsgStart = ChoiceFormat::findSubMessage(msgPattern, i, number);
- formatComplexSubMessage(subMsgStart, NULL, arguments, argumentNames,
+ formatComplexSubMessage(subMsgStart, nullptr, arguments, argumentNames,
cnt, appendTo, success);
} else if (UMSGPAT_ARG_TYPE_HAS_PLURAL_STYLE(argType)) {
if (!arg->isNumeric()) {
@@ -1145,7 +1148,7 @@ void MessageFormat::format(int32_t msgStart, const void *plNumber,
cnt, appendTo, success);
} else if (argType == UMSGPAT_ARG_TYPE_SELECT) {
int32_t subMsgStart = SelectFormat::findSubMessage(msgPattern, i, arg->getString(success), success);
- formatComplexSubMessage(subMsgStart, NULL, arguments, argumentNames,
+ formatComplexSubMessage(subMsgStart, nullptr, arguments, argumentNames,
cnt, appendTo, success);
} else {
// This should never happen.
@@ -1171,7 +1174,7 @@ void MessageFormat::formatComplexSubMessage(int32_t msgStart,
}
if (!MessageImpl::jdkAposMode(msgPattern)) {
- format(msgStart, plNumber, arguments, argumentNames, cnt, appendTo, NULL, success);
+ format(msgStart, plNumber, arguments, argumentNames, cnt, appendTo, nullptr, success);
return;
}
@@ -1216,8 +1219,8 @@ void MessageFormat::formatComplexSubMessage(int32_t msgStart,
if (sb.indexOf(LEFT_CURLY_BRACE) >= 0) {
UnicodeString emptyPattern; // gcc 3.3.3 fails with "UnicodeString()" as the first parameter.
MessageFormat subMsgFormat(emptyPattern, fLocale, success);
- subMsgFormat.applyPattern(sb, UMSGPAT_APOS_DOUBLE_REQUIRED, NULL, success);
- subMsgFormat.format(0, NULL, arguments, argumentNames, cnt, appendTo, NULL, success);
+ subMsgFormat.applyPattern(sb, UMSGPAT_APOS_DOUBLE_REQUIRED, nullptr, success);
+ subMsgFormat.format(0, nullptr, arguments, argumentNames, cnt, appendTo, nullptr, success);
} else {
appendTo.append(sb);
}
@@ -1246,12 +1249,12 @@ UnicodeString MessageFormat::getLiteralStringUntilNextArgument(int32_t from) con
FieldPosition* MessageFormat::updateMetaData(AppendableWrapper& /*dest*/, int32_t /*prevLength*/,
FieldPosition* /*fp*/, const Formattable* /*argId*/) const {
// Unlike in Java, there are no field attributes defined for MessageFormat. Do nothing.
- return NULL;
+ return nullptr;
/*
- if (fp != NULL && Field.ARGUMENT.equals(fp.getFieldAttribute())) {
+ if (fp != nullptr && Field.ARGUMENT.equals(fp.getFieldAttribute())) {
fp->setBeginIndex(prevLength);
fp->setEndIndex(dest.get_length());
- return NULL;
+ return nullptr;
}
return fp;
*/
@@ -1266,7 +1269,7 @@ MessageFormat::findOtherSubMessage(int32_t partIndex) const {
}
// Iterate over (ARG_SELECTOR [ARG_INT|ARG_DOUBLE] message) tuples
// until ARG_LIMIT or end of plural-only pattern.
- UnicodeString other(FALSE, OTHER_STRING, 5);
+ UnicodeString other(false, OTHER_STRING, 5);
do {
part=&msgPattern.getPart(partIndex++);
UMessagePatternPartType type=part->getType();
@@ -1323,14 +1326,14 @@ void MessageFormat::copyObjects(const MessageFormat& that, UErrorCode& ec) {
}
uprv_memcpy(argTypes, that.argTypes, argTypeCount * sizeof(argTypes[0]));
}
- if (cachedFormatters != NULL) {
+ if (cachedFormatters != nullptr) {
uhash_removeAll(cachedFormatters);
}
- if (customFormatArgStarts != NULL) {
+ if (customFormatArgStarts != nullptr) {
uhash_removeAll(customFormatArgStarts);
}
if (that.cachedFormatters) {
- if (cachedFormatters == NULL) {
+ if (cachedFormatters == nullptr) {
cachedFormatters=uhash_open(uhash_hashLong, uhash_compareLong,
equalFormatsForHash, &ec);
if (U_FAILURE(ec)) {
@@ -1353,9 +1356,9 @@ void MessageFormat::copyObjects(const MessageFormat& that, UErrorCode& ec) {
}
}
if (that.customFormatArgStarts) {
- if (customFormatArgStarts == NULL) {
+ if (customFormatArgStarts == nullptr) {
customFormatArgStarts=uhash_open(uhash_hashLong, uhash_compareLong,
- NULL, &ec);
+ nullptr, &ec);
}
const int32_t count = uhash_count(that.customFormatArgStarts);
int32_t pos, idx;
@@ -1376,13 +1379,13 @@ MessageFormat::parse(int32_t msgStart,
count = 0;
if (U_FAILURE(ec)) {
pos.setErrorIndex(pos.getIndex());
- return NULL;
+ return nullptr;
}
// parse() does not work with named arguments.
if (msgPattern.hasNamedArguments()) {
ec = U_ARGUMENT_TYPE_MISMATCH;
pos.setErrorIndex(pos.getIndex());
- return NULL;
+ return nullptr;
}
LocalArray<Formattable> resultArray(new Formattable[argTypeCount ? argTypeCount : 1]);
const UnicodeString& msgString=msgPattern.getPatternString();
@@ -1391,7 +1394,7 @@ MessageFormat::parse(int32_t msgStart,
ParsePosition tempStatus(0);
for(int32_t i=msgStart+1; ; ++i) {
- UBool haveArgResult = FALSE;
+ UBool haveArgResult = false;
const MessagePattern::Part* part=&msgPattern.getPart(i);
const UMessagePatternPartType type=part->getType();
int32_t index=part->getIndex();
@@ -1402,7 +1405,7 @@ MessageFormat::parse(int32_t msgStart,
prevIndex += len;
} else {
pos.setErrorIndex(sourceOffset);
- return NULL; // leave index as is to signal error
+ return nullptr; // leave index as is to signal error
}
if(type==UMSGPAT_PART_TYPE_MSG_LIMIT) {
// Things went well! Done.
@@ -1423,22 +1426,22 @@ MessageFormat::parse(int32_t msgStart,
int32_t argNumber = part->getValue(); // ARG_NUMBER
UnicodeString key;
++i;
- const Format* formatter = NULL;
+ const Format* formatter = nullptr;
Formattable& argResult = resultArray[argNumber];
- if(cachedFormatters!=NULL && (formatter = getCachedFormatter(i - 2))!=NULL) {
+ if(cachedFormatters!=nullptr && (formatter = getCachedFormatter(i - 2))!=nullptr) {
// Just parse using the formatter.
tempStatus.setIndex(sourceOffset);
formatter->parseObject(source, argResult, tempStatus);
if (tempStatus.getIndex() == sourceOffset) {
pos.setErrorIndex(sourceOffset);
- return NULL; // leave index as is to signal error
+ return nullptr; // leave index as is to signal error
}
sourceOffset = tempStatus.getIndex();
- haveArgResult = TRUE;
+ haveArgResult = true;
} else if(
argType==UMSGPAT_ARG_TYPE_NONE || (cachedFormatters && uhash_iget(cachedFormatters, i -2))) {
- // We arrive here if getCachedFormatter returned NULL, but there was actually an element in the hash table.
+ // We arrive here if getCachedFormatter returned nullptr, but there was actually an element in the hash table.
// This can only happen if the hash table contained a DummyFormat, so the if statement above is a check
// for the hash table containing DummyFormat.
@@ -1455,7 +1458,7 @@ MessageFormat::parse(int32_t msgStart,
}
if (next < 0) {
pos.setErrorIndex(sourceOffset);
- return NULL; // leave index as is to signal error
+ return nullptr; // leave index as is to signal error
} else {
UnicodeString strValue(source.tempSubString(sourceOffset, next - sourceOffset));
UnicodeString compValue;
@@ -1464,7 +1467,7 @@ MessageFormat::parse(int32_t msgStart,
compValue.append(RIGHT_CURLY_BRACE);
if (0 != strValue.compare(compValue)) {
argResult.setString(strValue);
- haveArgResult = TRUE;
+ haveArgResult = true;
}
sourceOffset = next;
}
@@ -1473,19 +1476,19 @@ MessageFormat::parse(int32_t msgStart,
double choiceResult = ChoiceFormat::parseArgument(msgPattern, i, source, tempStatus);
if (tempStatus.getIndex() == sourceOffset) {
pos.setErrorIndex(sourceOffset);
- return NULL; // leave index as is to signal error
+ return nullptr; // leave index as is to signal error
}
argResult.setDouble(choiceResult);
- haveArgResult = TRUE;
+ haveArgResult = true;
sourceOffset = tempStatus.getIndex();
} else if(UMSGPAT_ARG_TYPE_HAS_PLURAL_STYLE(argType) || argType==UMSGPAT_ARG_TYPE_SELECT) {
// Parsing not supported.
ec = U_UNSUPPORTED_ERROR;
- return NULL;
+ return nullptr;
} else {
// This should never happen.
ec = U_INTERNAL_PROGRAM_ERROR;
- return NULL;
+ return nullptr;
}
if (haveArgResult && count <= argNumber) {
count = argNumber + 1;
@@ -1519,7 +1522,7 @@ MessageFormat::parse(const UnicodeString& source,
{
if (msgPattern.hasNamedArguments()) {
success = U_ARGUMENT_TYPE_MISMATCH;
- return NULL;
+ return nullptr;
}
ParsePosition status(0);
// Calls the actual implementation method and starts
@@ -1528,7 +1531,7 @@ MessageFormat::parse(const UnicodeString& source,
if (status.getIndex() == 0) {
success = U_MESSAGE_PARSE_ERROR;
delete[] result;
- return NULL;
+ return nullptr;
}
return result;
}
@@ -1543,7 +1546,7 @@ MessageFormat::parseObject( const UnicodeString& source,
{
int32_t cnt = 0;
Formattable* tmpResult = parse(source, status, cnt);
- if (tmpResult != NULL)
+ if (tmpResult != nullptr)
result.adoptArray(tmpResult, cnt);
}
@@ -1552,10 +1555,10 @@ MessageFormat::autoQuoteApostrophe(const UnicodeString& pattern, UErrorCode& sta
UnicodeString result;
if (U_SUCCESS(status)) {
int32_t plen = pattern.length();
- const UChar* pat = pattern.getBuffer();
+ const char16_t* pat = pattern.getBuffer();
int32_t blen = plen * 2 + 1; // space for null termination, convenience
- UChar* buf = result.getBuffer(blen);
- if (buf == NULL) {
+ char16_t* buf = result.getBuffer(blen);
+ if (buf == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
int32_t len = umsg_autoQuoteApostrophe(pat, plen, buf, blen, &status);
@@ -1572,7 +1575,7 @@ MessageFormat::autoQuoteApostrophe(const UnicodeString& pattern, UErrorCode& sta
static Format* makeRBNF(URBNFRuleSetTag tag, const Locale& locale, const UnicodeString& defaultRuleSet, UErrorCode& ec) {
RuleBasedNumberFormat* fmt = new RuleBasedNumberFormat(tag, locale, ec);
- if (fmt == NULL) {
+ if (fmt == nullptr) {
ec = U_MEMORY_ALLOCATION_ERROR;
} else if (U_SUCCESS(ec) && defaultRuleSet.length() > 0) {
UErrorCode localStatus = U_ZERO_ERROR; // ignore unrecognized default rule set
@@ -1586,10 +1589,10 @@ void MessageFormat::cacheExplicitFormats(UErrorCode& status) {
return;
}
- if (cachedFormatters != NULL) {
+ if (cachedFormatters != nullptr) {
uhash_removeAll(cachedFormatters);
}
- if (customFormatArgStarts != NULL) {
+ if (customFormatArgStarts != nullptr) {
uhash_removeAll(customFormatArgStarts);
}
@@ -1620,7 +1623,7 @@ void MessageFormat::cacheExplicitFormats(UErrorCode& status) {
for (int32_t i = 0; i < argTypeCount; ++i) {
argTypes[i] = Formattable::kObject;
}
- hasArgTypeConflicts = FALSE;
+ hasArgTypeConflicts = false;
// This loop starts at part index 1 because we do need to examine
// ARG_START parts. (But we can ignore the MSG_START.)
@@ -1671,7 +1674,7 @@ void MessageFormat::cacheExplicitFormats(UErrorCode& status) {
}
if (argNumber != -1) {
if (argTypes[argNumber] != Formattable::kObject && argTypes[argNumber] != formattableType) {
- hasArgTypeConflicts = TRUE;
+ hasArgTypeConflicts = true;
}
argTypes[argNumber] = formattableType;
}
@@ -1682,9 +1685,9 @@ Format* MessageFormat::createAppropriateFormat(UnicodeString& type, UnicodeStrin
Formattable::Type& formattableType, UParseError& parseError,
UErrorCode& ec) {
if (U_FAILURE(ec)) {
- return NULL;
+ return nullptr;
}
- Format* fmt = NULL;
+ Format* fmt = nullptr;
int32_t typeID, styleID;
DateFormat::EStyle date_style;
int32_t firstNonSpace;
@@ -1745,9 +1748,9 @@ Format* MessageFormat::createAppropriateFormat(UnicodeString& type, UnicodeStrin
fmt = DateFormat::createTimeInstance(date_style, fLocale);
}
- if (styleID < 0 && fmt != NULL) {
+ if (styleID < 0 && fmt != nullptr) {
SimpleDateFormat* sdtfmt = dynamic_cast<SimpleDateFormat*>(fmt);
- if (sdtfmt != NULL) {
+ if (sdtfmt != nullptr) {
sdtfmt->applyPattern(style);
}
}
@@ -1779,15 +1782,15 @@ Format* MessageFormat::createAppropriateFormat(UnicodeString& type, UnicodeStrin
//-------------------------------------
// Finds the string, s, in the string array, list.
int32_t MessageFormat::findKeyword(const UnicodeString& s,
- const UChar * const *list)
+ const char16_t * const *list)
{
if (s.isEmpty()) {
return 0; // default
}
int32_t length = s.length();
- const UChar *ps = PatternProps::trimWhiteSpace(s.getBuffer(), length);
- UnicodeString buffer(FALSE, ps, length);
+ const char16_t *ps = PatternProps::trimWhiteSpace(s.getBuffer(), length);
+ UnicodeString buffer(false, ps, length);
// Trims the space characters and turns all characters
// in s to lower case.
buffer.toLower("");
@@ -1806,10 +1809,10 @@ NumberFormat*
MessageFormat::createIntegerFormat(const Locale& locale, UErrorCode& status) const {
NumberFormat *temp = NumberFormat::createInstance(locale, status);
DecimalFormat *temp2;
- if (temp != NULL && (temp2 = dynamic_cast<DecimalFormat*>(temp)) != NULL) {
+ if (temp != nullptr && (temp2 = dynamic_cast<DecimalFormat*>(temp)) != nullptr) {
temp2->setMaximumFractionDigits(0);
- temp2->setDecimalSeparatorAlwaysShown(FALSE);
- temp2->setParseIntegerOnly(TRUE);
+ temp2->setDecimalSeparatorAlwaysShown(false);
+ temp2->setParseIntegerOnly(true);
}
return temp;
@@ -1817,19 +1820,19 @@ MessageFormat::createIntegerFormat(const Locale& locale, UErrorCode& status) con
/**
* Return the default number format. Used to format a numeric
- * argument when subformats[i].format is NULL. Returns NULL
+ * argument when subformats[i].format is nullptr. Returns nullptr
* on failure.
*
* Semantically const but may modify *this.
*/
const NumberFormat* MessageFormat::getDefaultNumberFormat(UErrorCode& ec) const {
- if (defaultNumberFormat == NULL) {
+ if (defaultNumberFormat == nullptr) {
MessageFormat* t = (MessageFormat*) this;
t->defaultNumberFormat = NumberFormat::createInstance(fLocale, ec);
if (U_FAILURE(ec)) {
delete t->defaultNumberFormat;
- t->defaultNumberFormat = NULL;
- } else if (t->defaultNumberFormat == NULL) {
+ t->defaultNumberFormat = nullptr;
+ } else if (t->defaultNumberFormat == nullptr) {
ec = U_MEMORY_ALLOCATION_ERROR;
}
}
@@ -1838,16 +1841,16 @@ const NumberFormat* MessageFormat::getDefaultNumberFormat(UErrorCode& ec) const
/**
* Return the default date format. Used to format a date
- * argument when subformats[i].format is NULL. Returns NULL
+ * argument when subformats[i].format is nullptr. Returns nullptr
* on failure.
*
* Semantically const but may modify *this.
*/
const DateFormat* MessageFormat::getDefaultDateFormat(UErrorCode& ec) const {
- if (defaultDateFormat == NULL) {
+ if (defaultDateFormat == nullptr) {
MessageFormat* t = (MessageFormat*) this;
t->defaultDateFormat = DateFormat::createDateTimeInstance(DateFormat::kShort, DateFormat::kShort, fLocale);
- if (t->defaultDateFormat == NULL) {
+ if (t->defaultDateFormat == nullptr) {
ec = U_MEMORY_ALLOCATION_ERROR;
}
}
@@ -1912,9 +1915,9 @@ void MessageFormat::DummyFormat::parseObject(const UnicodeString&,
}
-FormatNameEnumeration::FormatNameEnumeration(UVector *fNameList, UErrorCode& /*status*/) {
+FormatNameEnumeration::FormatNameEnumeration(LocalPointer<UVector> nameList, UErrorCode& /*status*/) {
pos=0;
- fFormatNames = fNameList;
+ fFormatNames = std::move(nameList);
}
const UnicodeString*
@@ -1922,7 +1925,7 @@ FormatNameEnumeration::snext(UErrorCode& status) {
if (U_SUCCESS(status) && pos < fFormatNames->size()) {
return (const UnicodeString*)fFormatNames->elementAt(pos++);
}
- return NULL;
+ return nullptr;
}
void
@@ -1932,15 +1935,14 @@ FormatNameEnumeration::reset(UErrorCode& /*status*/) {
int32_t
FormatNameEnumeration::count(UErrorCode& /*status*/) const {
- return (fFormatNames==NULL) ? 0 : fFormatNames->size();
+ return (fFormatNames==nullptr) ? 0 : fFormatNames->size();
}
FormatNameEnumeration::~FormatNameEnumeration() {
- delete fFormatNames;
}
MessageFormat::PluralSelectorProvider::PluralSelectorProvider(const MessageFormat &mf, UPluralType t)
- : msgFormat(mf), rules(NULL), type(t) {
+ : msgFormat(mf), rules(nullptr), type(t) {
}
MessageFormat::PluralSelectorProvider::~PluralSelectorProvider() {
@@ -1950,13 +1952,13 @@ MessageFormat::PluralSelectorProvider::~PluralSelectorProvider() {
UnicodeString MessageFormat::PluralSelectorProvider::select(void *ctx, double number,
UErrorCode& ec) const {
if (U_FAILURE(ec)) {
- return UnicodeString(FALSE, OTHER_STRING, 5);
+ return UnicodeString(false, OTHER_STRING, 5);
}
MessageFormat::PluralSelectorProvider* t = const_cast<MessageFormat::PluralSelectorProvider*>(this);
- if(rules == NULL) {
+ if(rules == nullptr) {
t->rules = PluralRules::forLocale(msgFormat.fLocale, type, ec);
if (U_FAILURE(ec)) {
- return UnicodeString(FALSE, OTHER_STRING, 5);
+ return UnicodeString(false, OTHER_STRING, 5);
}
}
// Select a sub-message according to how the number is formatted,
@@ -1968,25 +1970,25 @@ UnicodeString MessageFormat::PluralSelectorProvider::select(void *ctx, double nu
PluralSelectorContext &context = *static_cast<PluralSelectorContext *>(ctx);
int32_t otherIndex = msgFormat.findOtherSubMessage(context.startIndex);
context.numberArgIndex = msgFormat.findFirstPluralNumberArg(otherIndex, context.argName);
- if(context.numberArgIndex > 0 && msgFormat.cachedFormatters != NULL) {
+ if(context.numberArgIndex > 0 && msgFormat.cachedFormatters != nullptr) {
context.formatter =
(const Format*)uhash_iget(msgFormat.cachedFormatters, context.numberArgIndex);
}
- if(context.formatter == NULL) {
+ if(context.formatter == nullptr) {
context.formatter = msgFormat.getDefaultNumberFormat(ec);
- context.forReplaceNumber = TRUE;
+ context.forReplaceNumber = true;
}
if (context.number.getDouble(ec) != number) {
ec = U_INTERNAL_PROGRAM_ERROR;
- return UnicodeString(FALSE, OTHER_STRING, 5);
+ return UnicodeString(false, OTHER_STRING, 5);
}
context.formatter->format(context.number, context.numberString, ec);
auto* decFmt = dynamic_cast<const DecimalFormat *>(context.formatter);
- if(decFmt != NULL) {
+ if(decFmt != nullptr) {
number::impl::DecimalQuantity dq;
decFmt->formatToDecimalQuantity(context.number, dq, ec);
if (U_FAILURE(ec)) {
- return UnicodeString(FALSE, OTHER_STRING, 5);
+ return UnicodeString(false, OTHER_STRING, 5);
}
return rules->select(dq);
} else {
@@ -1996,7 +1998,7 @@ UnicodeString MessageFormat::PluralSelectorProvider::select(void *ctx, double nu
void MessageFormat::PluralSelectorProvider::reset() {
delete rules;
- rules = NULL;
+ rules = nullptr;
}
diff --git a/contrib/libs/icu/i18n/msgfmt_impl.h b/contrib/libs/icu/i18n/msgfmt_impl.h
index 5798838913..84344a3a25 100644
--- a/contrib/libs/icu/i18n/msgfmt_impl.h
+++ b/contrib/libs/icu/i18n/msgfmt_impl.h
@@ -26,16 +26,16 @@ U_NAMESPACE_BEGIN
class FormatNameEnumeration : public StringEnumeration {
public:
- FormatNameEnumeration(UVector *fFormatNames, UErrorCode& status);
+ FormatNameEnumeration(LocalPointer<UVector> fFormatNames, UErrorCode& status);
virtual ~FormatNameEnumeration();
- static UClassID U_EXPORT2 getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID U_EXPORT2 getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
virtual const UnicodeString* snext(UErrorCode& status) override;
virtual void reset(UErrorCode& status) override;
virtual int32_t count(UErrorCode& status) const override;
private:
int32_t pos;
- UVector *fFormatNames;
+ LocalPointer<UVector> fFormatNames;
};
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/name2uni.cpp b/contrib/libs/icu/i18n/name2uni.cpp
index ffbbf152d3..2d26dba812 100644
--- a/contrib/libs/icu/i18n/name2uni.cpp
+++ b/contrib/libs/icu/i18n/name2uni.cpp
@@ -29,10 +29,10 @@ U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(NameUnicodeTransliterator)
-static const UChar OPEN[] = {92,78,126,123,126,0}; // "\N~{~"
-static const UChar OPEN_DELIM = 92; // '\\' first char of OPEN
-static const UChar CLOSE_DELIM = 125; // '}'
-static const UChar SPACE = 32; // ' '
+static const char16_t OPEN[] = {92,78,126,123,126,0}; // "\N~{~"
+static const char16_t OPEN_DELIM = 92; // '\\' first char of OPEN
+static const char16_t CLOSE_DELIM = 125; // '}'
+static const char16_t SPACE = 32; // ' '
U_CDECL_BEGIN
@@ -50,7 +50,7 @@ _set_addRange(USet *set, UChar32 start, UChar32 end) {
}
static void U_CALLCONV
-_set_addString(USet *set, const UChar *str, int32_t length) {
+_set_addString(USet *set, const char16_t *str, int32_t length) {
((UnicodeSet *)set)->add(UnicodeString((UBool)(length<0), str, length));
}*/
@@ -68,10 +68,10 @@ NameUnicodeTransliterator::NameUnicodeTransliterator(UnicodeFilter* adoptedFilte
USetAdder sa = {
(USet *)legalPtr, // USet* == UnicodeSet*
_set_add,
- NULL, // Don't need _set_addRange
- NULL, // Don't need _set_addString
- NULL, // Don't need remove()
- NULL
+ nullptr, // Don't need _set_addRange
+ nullptr, // Don't need _set_addString
+ nullptr, // Don't need remove()
+ nullptr
};
uprv_getCharNameCharacters(&sa);
}
@@ -111,7 +111,7 @@ void NameUnicodeTransliterator::handleTransliterate(Replaceable& text, UTransPos
UBool isIncremental) const {
// The failure mode, here and below, is to behave like Any-Null,
// if either there is no name data (max len == 0) or there is no
- // memory (malloc() => NULL).
+ // memory (malloc() => nullptr).
int32_t maxLen = uprv_getMaxCharNameLength();
if (maxLen == 0) {
@@ -122,12 +122,12 @@ void NameUnicodeTransliterator::handleTransliterate(Replaceable& text, UTransPos
// Accommodate the longest possible name
++maxLen; // allow for temporary trailing space
char* cbuf = (char*) uprv_malloc(maxLen);
- if (cbuf == NULL) {
+ if (cbuf == nullptr) {
offsets.start = offsets.limit;
return;
}
- UnicodeString openPat(TRUE, OPEN, -1);
+ UnicodeString openPat(true, OPEN, -1);
UnicodeString str, name;
int32_t cursor = offsets.start;
@@ -222,7 +222,7 @@ void NameUnicodeTransliterator::handleTransliterate(Replaceable& text, UTransPos
}
// Check if c is a legal char. We assume here that
- // legal.contains(OPEN_DELIM) is FALSE, so when we abort a
+ // legal.contains(OPEN_DELIM) is false, so when we abort a
// name, we don't have to go back to openPos+1.
if (legal.contains(c)) {
name.append(c);
diff --git a/contrib/libs/icu/i18n/nfrlist.h b/contrib/libs/icu/i18n/nfrlist.h
index 3eb1882b2f..1864d4d3bd 100644
--- a/contrib/libs/icu/i18n/nfrlist.h
+++ b/contrib/libs/icu/i18n/nfrlist.h
@@ -39,7 +39,7 @@ protected:
uint32_t fCapacity;
public:
NFRuleList(uint32_t capacity = 10)
- : fStuff(capacity ? (NFRule**)uprv_malloc(capacity * sizeof(NFRule*)) : NULL)
+ : fStuff(capacity ? (NFRule**)uprv_malloc(capacity * sizeof(NFRule*)) : nullptr)
, fCount(0)
, fCapacity(capacity) {}
~NFRuleList() {
@@ -50,10 +50,10 @@ public:
uprv_free(fStuff);
}
}
- NFRule* operator[](uint32_t index) const { return fStuff != NULL ? fStuff[index] : NULL; }
+ NFRule* operator[](uint32_t index) const { return fStuff != nullptr ? fStuff[index] : nullptr; }
NFRule* remove(uint32_t index) {
- if (fStuff == NULL) {
- return NULL;
+ if (fStuff == nullptr) {
+ return nullptr;
}
NFRule* result = fStuff[index];
fCount -= 1;
@@ -67,7 +67,7 @@ public:
fCapacity += 10;
fStuff = (NFRule**)uprv_realloc(fStuff, fCapacity * sizeof(NFRule*)); // assume success
}
- if (fStuff != NULL) {
+ if (fStuff != nullptr) {
fStuff[fCount++] = thing;
} else {
fCapacity = 0;
@@ -75,17 +75,17 @@ public:
}
}
uint32_t size() const { return fCount; }
- NFRule* last() const { return (fCount > 0 && fStuff != NULL) ? fStuff[fCount-1] : NULL; }
+ NFRule* last() const { return (fCount > 0 && fStuff != nullptr) ? fStuff[fCount-1] : nullptr; }
NFRule** release() {
- add(NULL); // ensure null termination
+ add(nullptr); // ensure null termination
NFRule** result = fStuff;
- fStuff = NULL;
+ fStuff = nullptr;
fCount = 0;
fCapacity = 0;
return result;
}
void deleteAll() {
- NFRule** tmp = NULL;
+ NFRule** tmp = nullptr;
int32_t size = fCount;
if (size > 0) {
tmp = release();
diff --git a/contrib/libs/icu/i18n/nfrs.cpp b/contrib/libs/icu/i18n/nfrs.cpp
index df04e33e04..1f4b9b9d29 100644
--- a/contrib/libs/icu/i18n/nfrs.cpp
+++ b/contrib/libs/icu/i18n/nfrs.cpp
@@ -118,17 +118,17 @@ util_lcm(int64_t x, int64_t y)
}
#endif
-static const UChar gPercent = 0x0025;
-static const UChar gColon = 0x003a;
-static const UChar gSemicolon = 0x003b;
-static const UChar gLineFeed = 0x000a;
+static const char16_t gPercent = 0x0025;
+static const char16_t gColon = 0x003a;
+static const char16_t gSemicolon = 0x003b;
+static const char16_t gLineFeed = 0x000a;
-static const UChar gPercentPercent[] =
+static const char16_t gPercentPercent[] =
{
0x25, 0x25, 0
}; /* "%%" */
-static const UChar gNoparse[] =
+static const char16_t gNoparse[] =
{
0x40, 0x6E, 0x6F, 0x70, 0x61, 0x72, 0x73, 0x65, 0
}; /* "@noparse" */
@@ -138,12 +138,12 @@ NFRuleSet::NFRuleSet(RuleBasedNumberFormat *_owner, UnicodeString* descriptions,
, rules(0)
, owner(_owner)
, fractionRules()
- , fIsFractionRuleSet(FALSE)
- , fIsPublic(FALSE)
- , fIsParseable(TRUE)
+ , fIsFractionRuleSet(false)
+ , fIsPublic(false)
+ , fIsParseable(true)
{
for (int32_t i = 0; i < NON_NUMERICAL_RULE_LENGTH; ++i) {
- nonNumericalRules[i] = NULL;
+ nonNumericalRules[i] = nullptr;
}
if (U_FAILURE(status)) {
@@ -185,7 +185,7 @@ NFRuleSet::NFRuleSet(RuleBasedNumberFormat *_owner, UnicodeString* descriptions,
fIsPublic = name.indexOf(gPercentPercent, 2, 0) != 0;
if ( name.endsWith(gNoparse,8) ) {
- fIsParseable = FALSE;
+ fIsParseable = false;
name.truncate(name.length()-8); // remove the @noparse from the name
}
@@ -273,13 +273,13 @@ void NFRuleSet::setNonNumericalRule(NFRule *rule) {
nonNumericalRules[NEGATIVE_RULE_INDEX] = rule;
}
else if (baseValue == NFRule::kImproperFractionRule) {
- setBestFractionRule(IMPROPER_FRACTION_RULE_INDEX, rule, TRUE);
+ setBestFractionRule(IMPROPER_FRACTION_RULE_INDEX, rule, true);
}
else if (baseValue == NFRule::kProperFractionRule) {
- setBestFractionRule(PROPER_FRACTION_RULE_INDEX, rule, TRUE);
+ setBestFractionRule(PROPER_FRACTION_RULE_INDEX, rule, true);
}
else if (baseValue == NFRule::kDefaultRule) {
- setBestFractionRule(DEFAULT_RULE_INDEX, rule, TRUE);
+ setBestFractionRule(DEFAULT_RULE_INDEX, rule, true);
}
else if (baseValue == NFRule::kInfinityRule) {
delete nonNumericalRules[INFINITY_RULE_INDEX];
@@ -303,7 +303,7 @@ void NFRuleSet::setBestFractionRule(int32_t originalIndex, NFRule *newRule, UBoo
fractionRules.add(newRule);
}
NFRule *bestResult = nonNumericalRules[originalIndex];
- if (bestResult == NULL) {
+ if (bestResult == nullptr) {
nonNumericalRules[originalIndex] = newRule;
}
else {
@@ -339,9 +339,9 @@ util_equalRules(const NFRule* rule1, const NFRule* rule2)
return *rule1 == *rule2;
}
} else if (!rule2) {
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
bool
@@ -380,7 +380,7 @@ NFRuleSet::setDecimalFormatSymbols(const DecimalFormatSymbols &newSymbols, UErro
for (uint32_t fIdx = 0; fIdx < fractionRules.size(); fIdx++) {
NFRule *fractionRule = fractionRules[fIdx];
if (nonNumericalRules[nonNumericalIdx]->getBaseValue() == fractionRule->getBaseValue()) {
- setBestFractionRule(nonNumericalIdx, fractionRule, FALSE);
+ setBestFractionRule(nonNumericalIdx, fractionRule, false);
}
}
}
@@ -535,7 +535,7 @@ NFRuleSet::findNormalRule(int64_t number) const
}
}
if (hi == 0) { // bad rule set, minimum base > 0
- return NULL; // want to throw exception here
+ return nullptr; // want to throw exception here
}
NFRule *result = rules[hi - 1];
@@ -547,7 +547,7 @@ NFRuleSet::findNormalRule(int64_t number) const
// return
if (result->shouldRollBack(number)) {
if (hi == 1) { // bad rule set, no prior rule to rollback to from this base
- return NULL;
+ return nullptr;
}
result = rules[hi - 2];
}
@@ -671,7 +671,7 @@ NFRuleSet::findFractionRuleSetRule(double number) const
static void dumpUS(FILE* f, const UnicodeString& us) {
int len = us.length();
char* buf = (char *)uprv_malloc((len+1)*sizeof(char)); //new char[len+1];
- if (buf != NULL) {
+ if (buf != nullptr) {
us.extract(0, len, buf);
buf[len] = 0;
fprintf(f, "%s", buf);
@@ -860,7 +860,7 @@ static const uint8_t asciiDigits[] = {
0x77u, 0x78u, 0x79u, 0x7au,
};
-static const UChar kUMinus = (UChar)0x002d;
+static const char16_t kUMinus = (char16_t)0x002d;
#ifdef RBNF_DEBUG
static const char kMinus = '-';
@@ -910,7 +910,7 @@ int64_t util64_atoi(const char* str, uint32_t radix)
return result;
}
-int64_t util64_utoi(const UChar* str, uint32_t radix)
+int64_t util64_utoi(const char16_t* str, uint32_t radix)
{
if (radix > 36) {
radix = 36;
@@ -925,7 +925,7 @@ int64_t util64_utoi(const UChar* str, uint32_t radix)
neg = 1;
}
int64_t result = 0;
- UChar c;
+ char16_t c;
uint8_t b;
while (((c = *str++) < 0x0080) && (b = digitInfo[c]) && ((b &= 0x7f) < radix)) {
result *= lradix;
@@ -983,7 +983,7 @@ uint32_t util64_toa(int64_t w, char* buf, uint32_t len, uint32_t radix, UBool ra
}
#endif
-uint32_t util64_tou(int64_t w, UChar* buf, uint32_t len, uint32_t radix, UBool raw)
+uint32_t util64_tou(int64_t w, char16_t* buf, uint32_t len, uint32_t radix, UBool raw)
{
if (radix > 36) {
radix = 36;
@@ -992,13 +992,13 @@ uint32_t util64_tou(int64_t w, UChar* buf, uint32_t len, uint32_t radix, UBool r
}
int64_t base = radix;
- UChar* p = buf;
+ char16_t* p = buf;
if (len && (w < 0) && (radix == 10) && !raw) {
w = -w;
*p++ = kUMinus;
--len;
} else if (len && (w == 0)) {
- *p++ = (UChar)raw ? 0 : asciiDigits[0];
+ *p++ = (char16_t)raw ? 0 : asciiDigits[0];
--len;
}
@@ -1006,7 +1006,7 @@ uint32_t util64_tou(int64_t w, UChar* buf, uint32_t len, uint32_t radix, UBool r
int64_t n = w / base;
int64_t m = n * base;
int32_t d = (int32_t)(w-m);
- *p++ = (UChar)(raw ? d : asciiDigits[d]);
+ *p++ = (char16_t)(raw ? d : asciiDigits[d]);
w = n;
--len;
}
@@ -1019,7 +1019,7 @@ uint32_t util64_tou(int64_t w, UChar* buf, uint32_t len, uint32_t radix, UBool r
++buf;
}
while (--p > buf) {
- UChar c = *p;
+ char16_t c = *p;
*p = *buf;
*buf = c;
++buf;
diff --git a/contrib/libs/icu/i18n/nfrs.h b/contrib/libs/icu/i18n/nfrs.h
index a6ad3a3bb7..a1beedda17 100644
--- a/contrib/libs/icu/i18n/nfrs.h
+++ b/contrib/libs/icu/i18n/nfrs.h
@@ -93,10 +93,10 @@ 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, char16_t* 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);
+int64_t util64_utoi(const char16_t* str, uint32_t radix = 10);
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/contrib/libs/icu/i18n/nfrule.cpp b/contrib/libs/icu/i18n/nfrule.cpp
index 4bb0785127..51bd4c974f 100644
--- a/contrib/libs/icu/i18n/nfrule.cpp
+++ b/contrib/libs/icu/i18n/nfrule.cpp
@@ -40,10 +40,10 @@ NFRule::NFRule(const RuleBasedNumberFormat* _rbnf, const UnicodeString &_ruleTex
, exponent(0)
, decimalPoint(0)
, fRuleText(_ruleText)
- , sub1(NULL)
- , sub2(NULL)
+ , sub1(nullptr)
+ , sub2(nullptr)
, formatter(_rbnf)
- , rulePatternFormat(NULL)
+ , rulePatternFormat(nullptr)
{
if (!fRuleText.isEmpty()) {
parseRuleDescriptor(fRuleText, status);
@@ -54,54 +54,54 @@ NFRule::~NFRule()
{
if (sub1 != sub2) {
delete sub2;
- sub2 = NULL;
+ sub2 = nullptr;
}
delete sub1;
- sub1 = NULL;
+ sub1 = nullptr;
delete rulePatternFormat;
- rulePatternFormat = NULL;
+ rulePatternFormat = nullptr;
}
-static const UChar gLeftBracket = 0x005b;
-static const UChar gRightBracket = 0x005d;
-static const UChar gColon = 0x003a;
-static const UChar gZero = 0x0030;
-static const UChar gNine = 0x0039;
-static const UChar gSpace = 0x0020;
-static const UChar gSlash = 0x002f;
-static const UChar gGreaterThan = 0x003e;
-static const UChar gLessThan = 0x003c;
-static const UChar gComma = 0x002c;
-static const UChar gDot = 0x002e;
-static const UChar gTick = 0x0027;
-//static const UChar gMinus = 0x002d;
-static const UChar gSemicolon = 0x003b;
-static const UChar gX = 0x0078;
-
-static const UChar gMinusX[] = {0x2D, 0x78, 0}; /* "-x" */
-static const UChar gInf[] = {0x49, 0x6E, 0x66, 0}; /* "Inf" */
-static const UChar gNaN[] = {0x4E, 0x61, 0x4E, 0}; /* "NaN" */
-
-static const UChar gDollarOpenParenthesis[] = {0x24, 0x28, 0}; /* "$(" */
-static const UChar gClosedParenthesisDollar[] = {0x29, 0x24, 0}; /* ")$" */
-
-static const UChar gLessLess[] = {0x3C, 0x3C, 0}; /* "<<" */
-static const UChar gLessPercent[] = {0x3C, 0x25, 0}; /* "<%" */
-static const UChar gLessHash[] = {0x3C, 0x23, 0}; /* "<#" */
-static const UChar gLessZero[] = {0x3C, 0x30, 0}; /* "<0" */
-static const UChar gGreaterGreater[] = {0x3E, 0x3E, 0}; /* ">>" */
-static const UChar gGreaterPercent[] = {0x3E, 0x25, 0}; /* ">%" */
-static const UChar gGreaterHash[] = {0x3E, 0x23, 0}; /* ">#" */
-static const UChar gGreaterZero[] = {0x3E, 0x30, 0}; /* ">0" */
-static const UChar gEqualPercent[] = {0x3D, 0x25, 0}; /* "=%" */
-static const UChar gEqualHash[] = {0x3D, 0x23, 0}; /* "=#" */
-static const UChar gEqualZero[] = {0x3D, 0x30, 0}; /* "=0" */
-static const UChar gGreaterGreaterGreater[] = {0x3E, 0x3E, 0x3E, 0}; /* ">>>" */
-
-static const UChar * const RULE_PREFIXES[] = {
+static const char16_t gLeftBracket = 0x005b;
+static const char16_t gRightBracket = 0x005d;
+static const char16_t gColon = 0x003a;
+static const char16_t gZero = 0x0030;
+static const char16_t gNine = 0x0039;
+static const char16_t gSpace = 0x0020;
+static const char16_t gSlash = 0x002f;
+static const char16_t gGreaterThan = 0x003e;
+static const char16_t gLessThan = 0x003c;
+static const char16_t gComma = 0x002c;
+static const char16_t gDot = 0x002e;
+static const char16_t gTick = 0x0027;
+//static const char16_t gMinus = 0x002d;
+static const char16_t gSemicolon = 0x003b;
+static const char16_t gX = 0x0078;
+
+static const char16_t gMinusX[] = {0x2D, 0x78, 0}; /* "-x" */
+static const char16_t gInf[] = {0x49, 0x6E, 0x66, 0}; /* "Inf" */
+static const char16_t gNaN[] = {0x4E, 0x61, 0x4E, 0}; /* "NaN" */
+
+static const char16_t gDollarOpenParenthesis[] = {0x24, 0x28, 0}; /* "$(" */
+static const char16_t gClosedParenthesisDollar[] = {0x29, 0x24, 0}; /* ")$" */
+
+static const char16_t gLessLess[] = {0x3C, 0x3C, 0}; /* "<<" */
+static const char16_t gLessPercent[] = {0x3C, 0x25, 0}; /* "<%" */
+static const char16_t gLessHash[] = {0x3C, 0x23, 0}; /* "<#" */
+static const char16_t gLessZero[] = {0x3C, 0x30, 0}; /* "<0" */
+static const char16_t gGreaterGreater[] = {0x3E, 0x3E, 0}; /* ">>" */
+static const char16_t gGreaterPercent[] = {0x3E, 0x25, 0}; /* ">%" */
+static const char16_t gGreaterHash[] = {0x3E, 0x23, 0}; /* ">#" */
+static const char16_t gGreaterZero[] = {0x3E, 0x30, 0}; /* ">0" */
+static const char16_t gEqualPercent[] = {0x3D, 0x25, 0}; /* "=%" */
+static const char16_t gEqualHash[] = {0x3D, 0x23, 0}; /* "=#" */
+static const char16_t gEqualZero[] = {0x3D, 0x30, 0}; /* "=0" */
+static const char16_t gGreaterGreaterGreater[] = {0x3E, 0x3E, 0x3E, 0}; /* ">>>" */
+
+static const char16_t * const RULE_PREFIXES[] = {
gLessLess, gLessPercent, gLessHash, gLessZero,
gGreaterGreater, gGreaterPercent,gGreaterHash, gGreaterZero,
- gEqualPercent, gEqualHash, gEqualZero, NULL
+ gEqualPercent, gEqualHash, gEqualZero, nullptr
};
void
@@ -117,7 +117,7 @@ NFRule::makeRules(UnicodeString& description,
// (this also strips the rule descriptor, if any, off the
// description string)
NFRule* rule1 = new NFRule(rbnf, description, status);
- /* test for NULL */
+ /* test for nullptr */
if (rule1 == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -144,7 +144,7 @@ NFRule::makeRules(UnicodeString& description,
else {
// if the description does contain a matched pair of brackets,
// then it's really shorthand for two rules (with one exception)
- NFRule* rule2 = NULL;
+ NFRule* rule2 = nullptr;
UnicodeString sbuf;
// we'll actually only split the rule into two rules if its
@@ -161,7 +161,7 @@ NFRule::makeRules(UnicodeString& description,
// increment the original rule's base value ("rule1" actually
// goes SECOND in the rule set's rule list)
rule2 = new NFRule(rbnf, UnicodeString(), status);
- /* test for NULL */
+ /* test for nullptr */
if (rule2 == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -217,7 +217,7 @@ NFRule::makeRules(UnicodeString& description,
// BEFORE rule1 in the list: in all cases, rule2 OMITS the
// material in the brackets and rule1 INCLUDES the material
// in the brackets)
- if (rule2 != NULL) {
+ if (rule2 != nullptr) {
if (rule2->baseValue >= kNoBase) {
rules.add(rule2);
}
@@ -270,8 +270,8 @@ NFRule::parseRuleDescriptor(UnicodeString& description, UErrorCode& status)
// for one of the special rules. If it does, set the base
// value to the correct identifier value
int descriptorLength = descriptor.length();
- UChar firstChar = descriptor.charAt(0);
- UChar lastChar = descriptor.charAt(descriptorLength - 1);
+ char16_t firstChar = descriptor.charAt(0);
+ char16_t lastChar = descriptor.charAt(descriptorLength - 1);
if (firstChar >= gZero && firstChar <= gNine && lastChar != gX) {
// if the rule descriptor begins with a digit, it's a descriptor
// for a normal rule
@@ -279,7 +279,7 @@ NFRule::parseRuleDescriptor(UnicodeString& description, UErrorCode& status)
// just build up the value as we encounter the digits.
int64_t val = 0;
p = 0;
- UChar c = gSpace;
+ char16_t c = gSpace;
// begin parsing the descriptor: copy digits
// into "tempValue", skip periods, commas, and spaces,
@@ -420,9 +420,9 @@ NFRule::extractSubstitutions(const NFRuleSet* ruleSet,
}
fRuleText = ruleText;
sub1 = extractSubstitution(ruleSet, predecessor, status);
- if (sub1 == NULL) {
+ if (sub1 == nullptr) {
// Small optimization. There is no need to create a redundant NullSubstitution.
- sub2 = NULL;
+ sub2 = nullptr;
}
else {
sub2 = extractSubstitution(ruleSet, predecessor, status);
@@ -469,7 +469,7 @@ NFRule::extractSubstitution(const NFRuleSet* ruleSet,
const NFRule* predecessor,
UErrorCode& status)
{
- NFSubstitution* result = NULL;
+ NFSubstitution* result = nullptr;
// search the rule's rule text for the first two characters of
// a substitution token
@@ -479,7 +479,7 @@ NFRule::extractSubstitution(const NFRuleSet* ruleSet,
// if we didn't find one, create a null substitution positioned
// at the end of the rule text
if (subStart == -1) {
- return NULL;
+ return nullptr;
}
// special-case the ">>>" token, since searching for the > at the
@@ -490,7 +490,7 @@ NFRule::extractSubstitution(const NFRuleSet* ruleSet,
// otherwise the substitution token ends with the same character
// it began with
} else {
- UChar c = fRuleText.charAt(subStart);
+ char16_t c = fRuleText.charAt(subStart);
subEnd = fRuleText.indexOf(c, subStart + 1);
// special case for '<%foo<<'
if (c == gLessThan && subEnd != -1 && subEnd < fRuleText.length() - 1 && fRuleText.charAt(subEnd+1) == c) {
@@ -506,7 +506,7 @@ NFRule::extractSubstitution(const NFRuleSet* ruleSet,
// unmatched token character), create a null substitution positioned
// at the end of the rule
if (subEnd == -1) {
- return NULL;
+ return nullptr;
}
// if we get here, we have a real substitution token (or at least
@@ -549,10 +549,10 @@ NFRule::setBaseValue(int64_t newBaseValue, UErrorCode& status)
// description didn't specify a base value. This means it
// has substitutions, and some substitutions hold on to copies
// of the rule's divisor. Fix their copies of the divisor.
- if (sub1 != NULL) {
+ if (sub1 != nullptr) {
sub1->setDivisor(radix, exponent, status);
}
- if (sub2 != NULL) {
+ if (sub2 != nullptr) {
sub2->setDivisor(radix, exponent, status);
}
@@ -621,9 +621,9 @@ util_equalSubstitutions(const NFSubstitution* sub1, const NFSubstitution* sub2)
return *sub1 == *sub2;
}
} else if (!sub2) {
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
/**
@@ -650,7 +650,7 @@ NFRule::operator==(const NFRule& rhs) const
*/
static void util_append64(UnicodeString& result, int64_t n)
{
- UChar buffer[256];
+ char16_t buffer[256];
int32_t len = util64_tou(n, buffer, sizeof(buffer));
UnicodeString temp(buffer, len);
result.append(temp);
@@ -690,7 +690,7 @@ NFRule::_appendRuleText(UnicodeString& result) const
// if the rule text begins with a space, write an apostrophe
// (whitespace after the rule descriptor is ignored; the
// apostrophe is used to make the whitespace significant)
- if (fRuleText.charAt(0) == gSpace && (sub1 == NULL || sub1->getPos() != 0)) {
+ if (fRuleText.charAt(0) == gSpace && (sub1 == nullptr || sub1->getPos() != 0)) {
result.append(gTick);
}
@@ -700,11 +700,11 @@ NFRule::_appendRuleText(UnicodeString& result) const
ruleTextCopy.setTo(fRuleText);
UnicodeString temp;
- if (sub2 != NULL) {
+ if (sub2 != nullptr) {
sub2->toString(temp);
ruleTextCopy.insert(sub2->getPos(), temp);
}
- if (sub1 != NULL) {
+ if (sub1 != nullptr) {
sub1->toString(temp);
ruleTextCopy.insert(sub1->getPos(), temp);
}
@@ -763,10 +763,10 @@ NFRule::doFormat(int64_t number, UnicodeString& toInsertInto, int32_t pos, int32
lengthOffset = fRuleText.length() - (toInsertInto.length() - initialLength);
}
- if (sub2 != NULL) {
+ if (sub2 != nullptr) {
sub2->doSubstitution(number, toInsertInto, pos - (sub2->getPos() > pluralRuleStart ? lengthOffset : 0), recursionCount, status);
}
- if (sub1 != NULL) {
+ if (sub1 != nullptr) {
sub1->doSubstitution(number, toInsertInto, pos - (sub1->getPos() > pluralRuleStart ? lengthOffset : 0), recursionCount, status);
}
}
@@ -817,10 +817,10 @@ NFRule::doFormat(double number, UnicodeString& toInsertInto, int32_t pos, int32_
lengthOffset = fRuleText.length() - (toInsertInto.length() - initialLength);
}
- if (sub2 != NULL) {
+ if (sub2 != nullptr) {
sub2->doSubstitution(number, toInsertInto, pos - (sub2->getPos() > pluralRuleStart ? lengthOffset : 0), recursionCount, status);
}
- if (sub1 != NULL) {
+ if (sub1 != nullptr) {
sub1->doSubstitution(number, toInsertInto, pos - (sub1->getPos() > pluralRuleStart ? lengthOffset : 0), recursionCount, status);
}
}
@@ -852,11 +852,11 @@ NFRule::shouldRollBack(int64_t number) const
// a modulus substitution, its base value isn't an even multiple
// of 100, and the value we're trying to format _is_ an even
// multiple of 100. This is called the "rollback rule."
- if ((sub1 != NULL && sub1->isModulusSubstitution()) || (sub2 != NULL && sub2->isModulusSubstitution())) {
+ if ((sub1 != nullptr && sub1->isModulusSubstitution()) || (sub2 != nullptr && sub2->isModulusSubstitution())) {
int64_t re = util64_pow(radix, exponent);
return (number % re) == 0 && (baseValue % re) != 0;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -887,7 +887,7 @@ NFRule::shouldRollBack(int64_t number) const
static void dumpUS(FILE* f, const UnicodeString& us) {
int len = us.length();
char* buf = (char *)uprv_malloc((len+1)*sizeof(char)); //new char[len+1];
- if (buf != NULL) {
+ if (buf != nullptr) {
us.extract(0, len, buf);
buf[len] = 0;
fprintf(f, "%s", buf);
@@ -908,8 +908,8 @@ NFRule::doParse(const UnicodeString& text,
ParsePosition pp;
UnicodeString workText(text);
- int32_t sub1Pos = sub1 != NULL ? sub1->getPos() : fRuleText.length();
- int32_t sub2Pos = sub2 != NULL ? sub2->getPos() : fRuleText.length();
+ int32_t sub1Pos = sub1 != nullptr ? sub1->getPos() : fRuleText.length();
+ int32_t sub2Pos = sub2 != nullptr ? sub2->getPos() : fRuleText.length();
// check to see whether the text before the first substitution
// matches the text at the beginning of the string being
@@ -943,19 +943,19 @@ NFRule::doParse(const UnicodeString& text,
// restored for ICU4C port
parsePosition.setErrorIndex(pp.getErrorIndex());
resVal.setLong(0);
- return TRUE;
+ return true;
}
if (baseValue == kInfinityRule) {
// If you match this, don't try to perform any calculations on it.
parsePosition.setIndex(pp.getIndex());
resVal.setDouble(uprv_getInfinity());
- return TRUE;
+ return true;
}
if (baseValue == kNaNRule) {
// If you match this, don't try to perform any calculations on it.
parsePosition.setIndex(pp.getIndex());
resVal.setDouble(uprv_getNaN());
- return TRUE;
+ return true;
}
// this is the fun part. The basic guts of the rule-matching
@@ -1010,7 +1010,7 @@ NFRule::doParse(const UnicodeString& text,
// null substitution), pp is now pointing at the first unmatched
// character. Take note of that, and try matchToDelimiter()
// on the input text again
- if (pp.getIndex() != 0 || sub1 == NULL) {
+ if (pp.getIndex() != 0 || sub1 == nullptr) {
start = pp.getIndex();
UnicodeString workText2;
@@ -1030,7 +1030,7 @@ NFRule::doParse(const UnicodeString& text,
// if we got a successful match on this second
// matchToDelimiter() call, update the high-water mark
// and result (if necessary)
- if (pp2.getIndex() != 0 || sub2 == NULL) {
+ if (pp2.getIndex() != 0 || sub2 == nullptr) {
if (prefixLength + pp.getIndex() + pp2.getIndex() > highWaterMark) {
highWaterMark = prefixLength + pp.getIndex() + pp2.getIndex();
result = partialResult;
@@ -1078,12 +1078,12 @@ NFRule::doParse(const UnicodeString& text,
// we have to account for it here. By definition, if the matching
// rule in a fraction rule set has no substitutions, its numerator
// is 1, and so the result is the reciprocal of its base value.
- if (isFractionRule && highWaterMark > 0 && sub1 == NULL) {
+ if (isFractionRule && highWaterMark > 0 && sub1 == nullptr) {
result = 1 / result;
}
resVal.setDouble(result);
- return TRUE; // ??? do we need to worry if it is a long or a double?
+ return true; // ??? do we need to worry if it is a long or a double?
}
/**
@@ -1191,7 +1191,7 @@ NFRule::matchToDelimiter(const UnicodeString& text,
if (subText.length() > 0) {
UBool success = sub->doParse(subText, tempPP, _baseValue, upperBound,
#if UCONFIG_NO_COLLATION
- FALSE,
+ false,
#else
formatter->isLenient(),
#endif
@@ -1235,7 +1235,7 @@ NFRule::matchToDelimiter(const UnicodeString& text,
// for "delimiter". Instead, just use "sub" to parse as much of
// "text" as possible.
}
- else if (sub == NULL) {
+ else if (sub == nullptr) {
return _baseValue;
}
else {
@@ -1245,7 +1245,7 @@ NFRule::matchToDelimiter(const UnicodeString& text,
// try to match the whole string against the substitution
UBool success = sub->doParse(text, tempPP, _baseValue, upperBound,
#if UCONFIG_NO_COLLATION
- FALSE,
+ false,
#else
formatter->isLenient(),
#endif
@@ -1309,7 +1309,7 @@ NFRule::prefixLength(const UnicodeString& str, const UnicodeString& prefix, UErr
// the CollationElementIterator protocol. Hopefully, this
// will change someday.)
const RuleBasedCollator* collator = formatter->getCollator();
- if (collator == NULL) {
+ if (collator == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
@@ -1579,7 +1579,7 @@ NFRule::allIgnorable(const UnicodeString& str, UErrorCode& status) const
{
// if the string is empty, we can just return true
if (str.length() == 0) {
- return TRUE;
+ return true;
}
#if !UCONFIG_NO_COLLATION
@@ -1588,16 +1588,16 @@ NFRule::allIgnorable(const UnicodeString& str, UErrorCode& status) const
// element is 0 (ignorable) at the primary level
if (formatter->isLenient()) {
const RuleBasedCollator* collator = formatter->getCollator();
- if (collator == NULL) {
+ if (collator == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return FALSE;
+ return false;
}
LocalPointer<CollationElementIterator> iter(collator->createCollationElementIterator(str));
// Memory allocation error check.
if (iter.isNull()) {
status = U_MEMORY_ALLOCATION_ERROR;
- return FALSE;
+ return false;
}
UErrorCode err = U_ZERO_ERROR;
@@ -1613,15 +1613,15 @@ NFRule::allIgnorable(const UnicodeString& str, UErrorCode& status) const
// if lenient parsing is turned off, there is no such thing as
// an ignorable character: return true only if the string is empty
- return FALSE;
+ return false;
}
void
NFRule::setDecimalFormatSymbols(const DecimalFormatSymbols& newSymbols, UErrorCode& status) {
- if (sub1 != NULL) {
+ if (sub1 != nullptr) {
sub1->setDecimalFormatSymbols(newSymbols, status);
}
- if (sub2 != NULL) {
+ if (sub2 != nullptr) {
sub2->setDecimalFormatSymbols(newSymbols, status);
}
}
diff --git a/contrib/libs/icu/i18n/nfrule.h b/contrib/libs/icu/i18n/nfrule.h
index 5e615e485c..fda74fabf2 100644
--- a/contrib/libs/icu/i18n/nfrule.h
+++ b/contrib/libs/icu/i18n/nfrule.h
@@ -63,7 +63,7 @@ public:
int64_t getBaseValue() const { return baseValue; }
void setBaseValue(int64_t value, UErrorCode& status);
- UChar getDecimalPoint() const { return decimalPoint; }
+ char16_t getDecimalPoint() const { return decimalPoint; }
int64_t getDivisor() const;
@@ -108,7 +108,7 @@ private:
int64_t baseValue;
int32_t radix;
int16_t exponent;
- UChar decimalPoint;
+ char16_t decimalPoint;
UnicodeString fRuleText;
NFSubstitution* sub1;
NFSubstitution* sub2;
diff --git a/contrib/libs/icu/i18n/nfsubs.cpp b/contrib/libs/icu/i18n/nfsubs.cpp
index 70ac18be46..4f3247ce50 100644
--- a/contrib/libs/icu/i18n/nfsubs.cpp
+++ b/contrib/libs/icu/i18n/nfsubs.cpp
@@ -25,23 +25,23 @@
#if U_HAVE_RBNF
-static const UChar gLessThan = 0x003c;
-static const UChar gEquals = 0x003d;
-static const UChar gGreaterThan = 0x003e;
-static const UChar gPercent = 0x0025;
-static const UChar gPound = 0x0023;
-static const UChar gZero = 0x0030;
-static const UChar gSpace = 0x0020;
-
-static const UChar gEqualsEquals[] =
+static const char16_t gLessThan = 0x003c;
+static const char16_t gEquals = 0x003d;
+static const char16_t gGreaterThan = 0x003e;
+static const char16_t gPercent = 0x0025;
+static const char16_t gPound = 0x0023;
+static const char16_t gZero = 0x0030;
+static const char16_t gSpace = 0x0020;
+
+static const char16_t gEqualsEquals[] =
{
0x3D, 0x3D, 0
}; /* "==" */
-static const UChar gGreaterGreaterGreaterThan[] =
+static const char16_t gGreaterGreaterGreaterThan[] =
{
0x3E, 0x3E, 0x3E, 0
}; /* ">>>" */
-static const UChar gGreaterGreaterThan[] =
+static const char16_t gGreaterGreaterThan[] =
{
0x3E, 0x3E, 0
}; /* ">>" */
@@ -62,11 +62,11 @@ public:
virtual double transformNumber(double number) const override { return number; }
virtual double composeRuleValue(double newRuleValue, double /*oldRuleValue*/) const override { return newRuleValue; }
virtual double calcUpperBound(double oldUpperBound) const override { return oldUpperBound; }
- virtual UChar tokenChar() const override { return (UChar)0x003d; } // '='
+ virtual char16_t tokenChar() const override { return (char16_t)0x003d; } // '='
public:
- static UClassID getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
};
SameValueSubstitution::~SameValueSubstitution() {}
@@ -116,11 +116,11 @@ public:
virtual double calcUpperBound(double /*oldUpperBound*/) const override { return static_cast<double>(divisor); }
- virtual UChar tokenChar() const override { return (UChar)0x003c; } // '<'
+ virtual char16_t tokenChar() const override { return (char16_t)0x003c; } // '<'
public:
- static UClassID getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
};
MultiplierSubstitution::~MultiplierSubstitution() {}
@@ -167,15 +167,15 @@ public:
virtual double calcUpperBound(double /*oldUpperBound*/) const override { return static_cast<double>(divisor); }
- virtual UBool isModulusSubstitution() const override { return TRUE; }
+ virtual UBool isModulusSubstitution() const override { return true; }
- virtual UChar tokenChar() const override { return (UChar)0x003e; } // '>'
+ virtual char16_t tokenChar() const override { return (char16_t)0x003e; } // '>'
virtual void toString(UnicodeString& result) const override;
public:
- static UClassID getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
};
ModulusSubstitution::~ModulusSubstitution() {}
@@ -193,11 +193,11 @@ public:
virtual double transformNumber(double number) const override { return uprv_floor(number); }
virtual double composeRuleValue(double newRuleValue, double oldRuleValue) const override { return newRuleValue + oldRuleValue; }
virtual double calcUpperBound(double /*oldUpperBound*/) const override { return DBL_MAX; }
- virtual UChar tokenChar() const override { return (UChar)0x003c; } // '<'
+ virtual char16_t tokenChar() const override { return (char16_t)0x003c; } // '<'
public:
- static UClassID getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
};
IntegralPartSubstitution::~IntegralPartSubstitution() {}
@@ -230,11 +230,11 @@ public:
virtual double composeRuleValue(double newRuleValue, double oldRuleValue) const override { return newRuleValue + oldRuleValue; }
virtual double calcUpperBound(double /*oldUpperBound*/) const override { return 0.0; }
- virtual UChar tokenChar() const override { return (UChar)0x003e; } // '>'
+ virtual char16_t tokenChar() const override { return (char16_t)0x003e; } // '>'
public:
- static UClassID getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
};
FractionalPartSubstitution::~FractionalPartSubstitution() {}
@@ -252,11 +252,11 @@ public:
virtual double transformNumber(double number) const override { return uprv_fabs(number); }
virtual double composeRuleValue(double newRuleValue, double /*oldRuleValue*/) const override { return -newRuleValue; }
virtual double calcUpperBound(double /*oldUpperBound*/) const override { return DBL_MAX; }
- virtual UChar tokenChar() const override { return (UChar)0x003e; } // '>'
+ virtual char16_t tokenChar() const override { return (char16_t)0x003e; } // '>'
public:
- static UClassID getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
};
AbsoluteValueSubstitution::~AbsoluteValueSubstitution() {}
@@ -302,13 +302,13 @@ public:
virtual double composeRuleValue(double newRuleValue, double oldRuleValue) const override { return newRuleValue / oldRuleValue; }
virtual double calcUpperBound(double /*oldUpperBound*/) const override { return denominator; }
- virtual UChar tokenChar() const override { return (UChar)0x003c; } // '<'
+ virtual char16_t tokenChar() const override { return (char16_t)0x003c; } // '<'
private:
- static const UChar LTLT[2];
+ static const char16_t LTLT[2];
public:
- static UClassID getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
};
NumeratorSubstitution::~NumeratorSubstitution() {}
@@ -324,7 +324,7 @@ NFSubstitution::makeSubstitution(int32_t pos,
{
// if the description is empty, return a NullSubstitution
if (description.length() == 0) {
- return NULL;
+ return nullptr;
}
switch (description.charAt(0)) {
@@ -335,7 +335,7 @@ NFSubstitution::makeSubstitution(int32_t pos,
if (rule->getBaseValue() == NFRule::kNegativeNumberRule) {
// throw new IllegalArgumentException("<< not allowed in negative-number rule");
status = U_PARSE_ERROR;
- return NULL;
+ return nullptr;
}
// if the rule is a fraction rule, return an
@@ -380,7 +380,7 @@ NFSubstitution::makeSubstitution(int32_t pos,
else if (ruleSet->isFractionRuleSet()) {
// throw new IllegalArgumentException(">> not allowed in fraction rule set");
status = U_PARSE_ERROR;
- return NULL;
+ return nullptr;
}
// otherwise, return a ModulusSubstitution
@@ -399,14 +399,14 @@ NFSubstitution::makeSubstitution(int32_t pos,
// throw new IllegalArgumentException("Illegal substitution character");
status = U_PARSE_ERROR;
}
- return NULL;
+ return nullptr;
}
NFSubstitution::NFSubstitution(int32_t _pos,
const NFRuleSet* _ruleSet,
const UnicodeString& description,
UErrorCode& status)
- : pos(_pos), ruleSet(NULL), numberFormat(NULL)
+ : pos(_pos), ruleSet(nullptr), numberFormat(nullptr)
{
// the description should begin and end with the same character.
// If it doesn't that's a syntax error. Otherwise,
@@ -448,7 +448,7 @@ NFSubstitution::NFSubstitution(int32_t _pos,
return;
}
DecimalFormat *tempNumberFormat = new DecimalFormat(workingDescription, *sym, status);
- /* test for NULL */
+ /* test for nullptr */
if (!tempNumberFormat) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -467,9 +467,9 @@ NFSubstitution::NFSubstitution(int32_t _pos,
// a number even when it's 0)
// this causes problems when >>> is used in a frationalPartSubstitution
- // this->ruleSet = NULL;
+ // this->ruleSet = nullptr;
this->ruleSet = _ruleSet;
- this->numberFormat = NULL;
+ this->numberFormat = nullptr;
}
else {
// and of the description is none of these things, it's a syntax error
@@ -482,7 +482,7 @@ NFSubstitution::NFSubstitution(int32_t _pos,
NFSubstitution::~NFSubstitution()
{
delete numberFormat;
- numberFormat = NULL;
+ numberFormat = nullptr;
}
/**
@@ -499,7 +499,7 @@ NFSubstitution::setDivisor(int32_t /*radix*/, int16_t /*exponent*/, UErrorCode&
void
NFSubstitution::setDecimalFormatSymbols(const DecimalFormatSymbols &newSymbols, UErrorCode& /*status*/) {
- if (numberFormat != NULL) {
+ if (numberFormat != nullptr) {
numberFormat->setDecimalFormatSymbols(newSymbols);
}
}
@@ -523,10 +523,10 @@ NFSubstitution::operator==(const NFSubstitution& rhs) const
// this should be called by subclasses before their own equality tests
return typeid(*this) == typeid(rhs)
&& pos == rhs.pos
- && (ruleSet == NULL) == (rhs.ruleSet == NULL)
+ && (ruleSet == nullptr) == (rhs.ruleSet == nullptr)
// && ruleSet == rhs.ruleSet causes circularity, other checks to make instead?
- && (numberFormat == NULL
- ? (rhs.numberFormat == NULL)
+ && (numberFormat == nullptr
+ ? (rhs.numberFormat == nullptr)
: (*numberFormat == *rhs.numberFormat));
}
@@ -547,9 +547,9 @@ NFSubstitution::toString(UnicodeString& text) const
text.append(tokenChar());
UnicodeString temp;
- if (ruleSet != NULL) {
+ if (ruleSet != nullptr) {
ruleSet->getName(temp);
- } else if (numberFormat != NULL) {
+ } else if (numberFormat != nullptr) {
numberFormat->toPattern(temp);
}
text.append(temp);
@@ -573,12 +573,12 @@ NFSubstitution::toString(UnicodeString& text) const
void
NFSubstitution::doSubstitution(int64_t number, UnicodeString& toInsertInto, int32_t _pos, int32_t recursionCount, UErrorCode& status) const
{
- if (ruleSet != NULL) {
+ if (ruleSet != nullptr) {
// Perform a transformation on the number that is dependent
// on the type of substitution this is, then just call its
// rule set's format() method to format the result
ruleSet->format(transformNumber(number), toInsertInto, _pos + this->pos, recursionCount, status);
- } else if (numberFormat != NULL) {
+ } else if (numberFormat != nullptr) {
if (number <= MAX_INT64_IN_DOUBLE) {
// or perform the transformation on the number (preserving
// the result's fractional part if the formatter it set
@@ -634,16 +634,16 @@ NFSubstitution::doSubstitution(double number, UnicodeString& toInsertInto, int32
// if the result is an integer, from here on out we work in integer
// space (saving time and memory and preserving accuracy)
- if (numberToFormat == uprv_floor(numberToFormat) && ruleSet != NULL) {
+ if (numberToFormat == uprv_floor(numberToFormat) && ruleSet != nullptr) {
ruleSet->format(util64_fromDouble(numberToFormat), toInsertInto, _pos + this->pos, recursionCount, status);
// if the result isn't an integer, then call either our rule set's
// format() method or our DecimalFormat's format() method to
// format the result
} else {
- if (ruleSet != NULL) {
+ if (ruleSet != nullptr) {
ruleSet->format(numberToFormat, toInsertInto, _pos + this->pos, recursionCount, status);
- } else if (numberFormat != NULL) {
+ } else if (numberFormat != nullptr) {
UnicodeString temp;
numberFormat->format(numberToFormat, temp);
toInsertInto.insert(_pos + this->pos, temp);
@@ -715,7 +715,7 @@ NFSubstitution::doParse(const UnicodeString& text,
// be false even when the formatter's lenient-parse mode is
// on), then also try parsing the text using a default-
// constructed NumberFormat
- if (ruleSet != NULL) {
+ if (ruleSet != nullptr) {
ruleSet->parse(text, parsePosition, upperBound, nonNumericalExecutedRuleMask, result);
if (lenientParse && !ruleSet->isFractionRuleSet() && parsePosition.getIndex() == 0) {
UErrorCode status = U_ZERO_ERROR;
@@ -727,7 +727,7 @@ NFSubstitution::doParse(const UnicodeString& text,
}
// ...or use our DecimalFormat to parse the text
- } else if (numberFormat != NULL) {
+ } else if (numberFormat != nullptr) {
numberFormat->parse(text, result, parsePosition);
}
@@ -763,11 +763,11 @@ NFSubstitution::doParse(const UnicodeString& text,
// the result.
tempResult = composeRuleValue(tempResult, baseValue);
result.setDouble(tempResult);
- return TRUE;
+ return true;
// if the parse was UNsuccessful, return 0
} else {
result.setLong(0);
- return FALSE;
+ return false;
}
}
@@ -779,7 +779,7 @@ NFSubstitution::doParse(const UnicodeString& text,
*/
UBool
NFSubstitution::isModulusSubstitution() const {
- return FALSE;
+ return false;
}
//===================================================================
@@ -834,7 +834,7 @@ ModulusSubstitution::ModulusSubstitution(int32_t _pos,
UErrorCode& status)
: NFSubstitution(_pos, _ruleSet, description, status)
, divisor(rule->getDivisor())
- , ruleToUse(NULL)
+ , ruleToUse(nullptr)
{
// the owning rule's divisor controls the behavior of this
// substitution: rather than keeping a backpointer to the rule,
@@ -882,7 +882,7 @@ ModulusSubstitution::doSubstitution(int64_t number, UnicodeString& toInsertInto,
// if this isn't a >>> substitution, just use the inherited version
// of this function (which uses either a rule set or a DecimalFormat
// to format its substitution value)
- if (ruleToUse == NULL) {
+ if (ruleToUse == nullptr) {
NFSubstitution::doSubstitution(number, toInsertInto, _pos, recursionCount, status);
// a >>> substitution goes straight to a particular rule to
@@ -907,7 +907,7 @@ ModulusSubstitution::doSubstitution(double number, UnicodeString& toInsertInto,
// if this isn't a >>> substitution, just use the inherited version
// of this function (which uses either a rule set or a DecimalFormat
// to format its substitution value)
- if (ruleToUse == NULL) {
+ if (ruleToUse == nullptr) {
NFSubstitution::doSubstitution(number, toInsertInto, _pos, recursionCount, status);
// a >>> substitution goes straight to a particular rule to
@@ -943,14 +943,14 @@ ModulusSubstitution::doParse(const UnicodeString& text,
{
// if this isn't a >>> substitution, we can just use the
// inherited parse() routine to do the parsing
- if (ruleToUse == NULL) {
+ if (ruleToUse == nullptr) {
return NFSubstitution::doParse(text, parsePosition, baseValue, upperBound, lenientParse, nonNumericalExecutedRuleMask, result);
// but if it IS a >>> substitution, we have to do it here: we
// use the specific rule's doParse() method, and then we have to
// do some of the other work of NFRuleSet.parse()
} else {
- ruleToUse->doParse(text, parsePosition, FALSE, upperBound, nonNumericalExecutedRuleMask, result);
+ ruleToUse->doParse(text, parsePosition, false, upperBound, nonNumericalExecutedRuleMask, result);
if (parsePosition.getIndex() != 0) {
UErrorCode status = U_ZERO_ERROR;
@@ -959,7 +959,7 @@ ModulusSubstitution::doParse(const UnicodeString& text,
result.setDouble(tempResult);
}
- return TRUE;
+ return true;
}
}
/**
@@ -976,7 +976,7 @@ ModulusSubstitution::toString(UnicodeString& text) const
// either the name of the rule set it uses, or the pattern of
// the DecimalFormat it uses
- if ( ruleToUse != NULL ) { // Must have been a >>> substitution.
+ if ( ruleToUse != nullptr ) { // Must have been a >>> substitution.
text.remove();
text.append(tokenChar());
text.append(tokenChar());
@@ -1007,17 +1007,17 @@ FractionalPartSubstitution::FractionalPartSubstitution(int32_t _pos,
const UnicodeString& description,
UErrorCode& status)
: NFSubstitution(_pos, _ruleSet, description, status)
- , byDigits(FALSE)
- , useSpaces(TRUE)
+ , byDigits(false)
+ , useSpaces(true)
{
// akk, ruleSet can change in superclass constructor
if (0 == description.compare(gGreaterGreaterThan, 2) ||
0 == description.compare(gGreaterGreaterGreaterThan, 3) ||
_ruleSet == getRuleSet()) {
- byDigits = TRUE;
+ byDigits = true;
if (0 == description.compare(gGreaterGreaterGreaterThan, 3)) {
- useSpaces = FALSE;
+ useSpaces = false;
}
} else {
// cast away const
@@ -1059,14 +1059,14 @@ FractionalPartSubstitution::doSubstitution(double number, UnicodeString& toInser
// // this flag keeps us from formatting trailing zeros. It starts
// // out false because we're pulling from the right, and switches
// // to true the first time we encounter a non-zero digit
- // UBool doZeros = FALSE;
+ // UBool doZeros = false;
// for (int32_t i = 0; i < kMaxDecimalDigits; i++) {
// int64_t digit = numberToFormat % 10;
// if (digit != 0 || doZeros) {
// if (doZeros && useSpaces) {
// toInsertInto.insert(_pos + getPos(), gSpace);
// }
- // doZeros = TRUE;
+ // doZeros = true;
// getRuleSet()->format(digit, toInsertInto, _pos + getPos());
// }
// numberToFormat /= 10;
@@ -1076,7 +1076,7 @@ FractionalPartSubstitution::doSubstitution(double number, UnicodeString& toInser
dl.setToDouble(number);
dl.roundToMagnitude(-20, UNUM_ROUND_HALFEVEN, status); // round to 20 fraction digits.
- UBool pad = FALSE;
+ UBool pad = false;
for (int32_t didx = dl.getLowerDisplayMagnitude(); didx<0; didx++) {
// Loop iterates over fraction digits, starting with the LSD.
// include both real digits from the number, and zeros
@@ -1084,7 +1084,7 @@ FractionalPartSubstitution::doSubstitution(double number, UnicodeString& toInser
if (pad && useSpaces) {
toInsertInto.insert(_pos + getPos(), gSpace);
} else {
- pad = TRUE;
+ pad = true;
}
int64_t digit = dl.getDigit(didx);
getRuleSet()->format(digit, toInsertInto, _pos + getPos(), recursionCount, status);
@@ -1146,7 +1146,7 @@ FractionalPartSubstitution::doParse(const UnicodeString& text,
DecimalQuantity dl;
int32_t totalDigits = 0;
- NumberFormat* fmt = NULL;
+ NumberFormat* fmt = nullptr;
while (workText.length() > 0 && workPos.getIndex() != 0) {
workPos.setIndex(0);
Formattable temp;
@@ -1163,7 +1163,7 @@ FractionalPartSubstitution::doParse(const UnicodeString& text,
fmt = NumberFormat::createInstance(status);
if (U_FAILURE(status)) {
delete fmt;
- fmt = NULL;
+ fmt = nullptr;
}
}
if (fmt) {
@@ -1191,7 +1191,7 @@ FractionalPartSubstitution::doParse(const UnicodeString& text,
result = dl.toDouble();
result = composeRuleValue(result, baseValue);
resVal.setDouble(result);
- return TRUE;
+ return true;
}
}
@@ -1224,7 +1224,7 @@ NumeratorSubstitution::doSubstitution(double number, UnicodeString& toInsertInto
int64_t longNF = util64_fromDouble(numberToFormat);
const NFRuleSet* aruleSet = getRuleSet();
- if (withZeros && aruleSet != NULL) {
+ if (withZeros && aruleSet != nullptr) {
// if there are leading zeros in the decimal expansion then emit them
int64_t nf =longNF;
int32_t len = toInsertInto.length();
@@ -1237,14 +1237,14 @@ NumeratorSubstitution::doSubstitution(double number, UnicodeString& toInsertInto
// if the result is an integer, from here on out we work in integer
// space (saving time and memory and preserving accuracy)
- if (numberToFormat == longNF && aruleSet != NULL) {
+ if (numberToFormat == longNF && aruleSet != nullptr) {
aruleSet->format(longNF, toInsertInto, apos + getPos(), recursionCount, status);
// if the result isn't an integer, then call either our rule set's
// format() method or our DecimalFormat's format() method to
// format the result
} else {
- if (aruleSet != NULL) {
+ if (aruleSet != nullptr) {
aruleSet->format(numberToFormat, toInsertInto, apos + getPos(), recursionCount, status);
} else {
UnicodeString temp;
@@ -1301,7 +1301,7 @@ NumeratorSubstitution::doParse(const UnicodeString& text,
}
// we've parsed off the zeros, now let's parse the rest from our current position
- NFSubstitution::doParse(workText, parsePosition, withZeros ? 1 : baseValue, upperBound, FALSE, nonNumericalExecutedRuleMask, result);
+ NFSubstitution::doParse(workText, parsePosition, withZeros ? 1 : baseValue, upperBound, false, nonNumericalExecutedRuleMask, result);
if (withZeros) {
// any base value will do in this case. is there a way to
@@ -1310,10 +1310,8 @@ NumeratorSubstitution::doParse(const UnicodeString& text,
// compute the 'effective' base and prescale the value down
int64_t n = result.getLong(status); // force conversion!
int64_t d = 1;
- int32_t pow = 0;
while (d <= n) {
d *= 10;
- ++pow;
}
// now add the zeros
while (zeroCount > 0) {
@@ -1324,7 +1322,7 @@ NumeratorSubstitution::doParse(const UnicodeString& text,
result.setDouble((double)n/(double)d);
}
- return TRUE;
+ return true;
}
bool
@@ -1336,7 +1334,7 @@ NumeratorSubstitution::operator==(const NFSubstitution& rhs) const
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(NumeratorSubstitution)
-const UChar NumeratorSubstitution::LTLT[] = { 0x003c, 0x003c };
+const char16_t NumeratorSubstitution::LTLT[] = { 0x003c, 0x003c };
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/nfsubs.h b/contrib/libs/icu/i18n/nfsubs.h
index 0abd98be09..d252f86499 100644
--- a/contrib/libs/icu/i18n/nfsubs.h
+++ b/contrib/libs/icu/i18n/nfsubs.h
@@ -234,7 +234,7 @@ public:
* substitutions of this type. Used by toString().
* @return This substitution's token character.
*/
- virtual UChar tokenChar() const = 0;
+ virtual char16_t tokenChar() const = 0;
/**
* Returns true if this is a modulus substitution. (We didn't do this
@@ -245,12 +245,12 @@ public:
virtual UBool isModulusSubstitution() const;
private:
- NFSubstitution(const NFSubstitution &other); // forbid copying of this class
- NFSubstitution &operator=(const NFSubstitution &other); // forbid copying of this class
+ NFSubstitution(const NFSubstitution &other) = delete; // forbid copying of this class
+ NFSubstitution &operator=(const NFSubstitution &other) = delete; // forbid copying of this class
public:
- static UClassID getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
};
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/nortrans.cpp b/contrib/libs/icu/i18n/nortrans.cpp
index 6a8d2c7419..d793433b3d 100644
--- a/contrib/libs/icu/i18n/nortrans.cpp
+++ b/contrib/libs/icu/i18n/nortrans.cpp
@@ -45,13 +45,13 @@ void NormalizationTransliterator::registerIDs() {
Transliterator::_registerFactory(UNICODE_STRING_SIMPLE("Any-FCC"),
_create, cstrToken("nfc\0\3"));
Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("NFC"),
- UNICODE_STRING_SIMPLE("NFD"), TRUE);
+ UNICODE_STRING_SIMPLE("NFD"), true);
Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("NFKC"),
- UNICODE_STRING_SIMPLE("NFKD"), TRUE);
+ UNICODE_STRING_SIMPLE("NFKD"), true);
Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("FCC"),
- UNICODE_STRING_SIMPLE("NFD"), FALSE);
+ UNICODE_STRING_SIMPLE("NFD"), false);
Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("FCD"),
- UNICODE_STRING_SIMPLE("FCD"), FALSE);
+ UNICODE_STRING_SIMPLE("FCD"), false);
}
/**
@@ -62,11 +62,11 @@ Transliterator* NormalizationTransliterator::_create(const UnicodeString& ID,
const char *name = (const char *)context.pointer;
UNormalization2Mode mode = (UNormalization2Mode)uprv_strchr(name, 0)[1];
UErrorCode errorCode = U_ZERO_ERROR;
- const Normalizer2 *norm2 = Normalizer2::getInstance(NULL, name, mode, errorCode);
+ const Normalizer2 *norm2 = Normalizer2::getInstance(nullptr, name, mode, errorCode);
if(U_SUCCESS(errorCode)) {
return new NormalizationTransliterator(ID, *norm2);
} else {
- return NULL;
+ return nullptr;
}
}
diff --git a/contrib/libs/icu/i18n/number_affixutils.cpp b/contrib/libs/icu/i18n/number_affixutils.cpp
index f9c154c885..5f5ff4c3a6 100644
--- a/contrib/libs/icu/i18n/number_affixutils.cpp
+++ b/contrib/libs/icu/i18n/number_affixutils.cpp
@@ -135,8 +135,7 @@ Field AffixUtils::getFieldForType(AffixPatternType type) {
case TYPE_PLUS_SIGN:
return {UFIELD_CATEGORY_NUMBER, UNUM_SIGN_FIELD};
case TYPE_APPROXIMATELY_SIGN:
- // TODO: Introduce a new field for the approximately sign?
- return {UFIELD_CATEGORY_NUMBER, UNUM_SIGN_FIELD};
+ return {UFIELD_CATEGORY_NUMBER, UNUM_APPROXIMATELY_SIGN_FIELD};
case TYPE_PERCENT:
return {UFIELD_CATEGORY_NUMBER, UNUM_PERCENT_FIELD};
case TYPE_PERMILLE:
diff --git a/contrib/libs/icu/i18n/number_asformat.h b/contrib/libs/icu/i18n/number_asformat.h
index 394b9a811f..f921b42942 100644
--- a/contrib/libs/icu/i18n/number_asformat.h
+++ b/contrib/libs/icu/i18n/number_asformat.h
@@ -34,37 +34,37 @@ class U_I18N_API LocalizedNumberFormatterAsFormat : public Format {
/**
* Destructor.
*/
- ~LocalizedNumberFormatterAsFormat() U_OVERRIDE;
+ ~LocalizedNumberFormatterAsFormat() override;
/**
* Equals operator.
*/
- bool operator==(const Format& other) const U_OVERRIDE;
+ bool operator==(const Format& other) const override;
/**
* Creates a copy of this object.
*/
- LocalizedNumberFormatterAsFormat* clone() const U_OVERRIDE;
+ LocalizedNumberFormatterAsFormat* clone() const override;
/**
* Formats a Number using the wrapped LocalizedNumberFormatter. The provided formattable must be a
* number type.
*/
UnicodeString& format(const Formattable& obj, UnicodeString& appendTo, FieldPosition& pos,
- UErrorCode& status) const U_OVERRIDE;
+ UErrorCode& status) const override;
/**
* Formats a Number using the wrapped LocalizedNumberFormatter. The provided formattable must be a
* number type.
*/
UnicodeString& format(const Formattable& obj, UnicodeString& appendTo, FieldPositionIterator* posIter,
- UErrorCode& status) const U_OVERRIDE;
+ UErrorCode& status) const override;
/**
* Not supported: sets an error index and returns.
*/
void parseObject(const UnicodeString& source, Formattable& result,
- ParsePosition& parse_pos) const U_OVERRIDE;
+ ParsePosition& parse_pos) const override;
/**
* Gets the LocalizedNumberFormatter that this wrapper class uses to format numbers.
@@ -86,7 +86,7 @@ class U_I18N_API LocalizedNumberFormatterAsFormat : public Format {
*/
const LocalizedNumberFormatter& getNumberFormatter() const;
- UClassID getDynamicClassID() const U_OVERRIDE;
+ UClassID getDynamicClassID() const override;
static UClassID U_EXPORT2 getStaticClassID();
private:
diff --git a/contrib/libs/icu/i18n/number_capi.cpp b/contrib/libs/icu/i18n/number_capi.cpp
index b87dbd93e5..abada9ad86 100644
--- a/contrib/libs/icu/i18n/number_capi.cpp
+++ b/contrib/libs/icu/i18n/number_capi.cpp
@@ -16,6 +16,8 @@
#include "number_decnum.h"
#include "unicode/numberformatter.h"
#include "unicode/unumberformatter.h"
+#include "unicode/simplenumberformatter.h"
+#include "unicode/usimplenumberformatter.h"
using namespace icu;
using namespace icu::number;
@@ -35,6 +37,24 @@ struct UNumberFormatterData : public UMemory,
LocalizedNumberFormatter fFormatter;
};
+/**
+ * Implementation class for USimpleNumber. Wraps a SimpleNumberFormatter.
+ */
+struct USimpleNumberData : public UMemory,
+ // Magic number as ASCII == "SNM" (SimpleNuMber)
+ public IcuCApiHelper<USimpleNumber, USimpleNumberData, 0x534E4D00> {
+ SimpleNumber fNumber;
+};
+
+/**
+ * Implementation class for USimpleNumberFormatter. Wraps a SimpleNumberFormatter.
+ */
+struct USimpleNumberFormatterData : public UMemory,
+ // Magic number as ASCII == "SNF" (SimpleNumberFormatter)
+ public IcuCApiHelper<USimpleNumberFormatter, USimpleNumberFormatterData, 0x534E4600> {
+ SimpleNumberFormatter fFormatter;
+};
+
struct UFormattedNumberImpl;
// Magic number as ASCII == "FDN" (FormatteDNumber)
@@ -46,6 +66,8 @@ struct UFormattedNumberImpl : public UFormattedValueImpl, public UFormattedNumbe
FormattedNumber fImpl;
UFormattedNumberData fData;
+
+ void setTo(FormattedNumber value);
};
UFormattedNumberImpl::UFormattedNumberImpl()
@@ -58,6 +80,10 @@ UFormattedNumberImpl::~UFormattedNumberImpl() {
fImpl.fData = nullptr;
}
+void UFormattedNumberImpl::setTo(FormattedNumber value) {
+ fData = std::move(*value.fData);
+}
+
}
}
U_NAMESPACE_END
@@ -82,7 +108,7 @@ const DecimalQuantity* icu::number::impl::validateUFormattedNumberToDecimalQuant
U_CAPI UNumberFormatter* U_EXPORT2
-unumf_openForSkeletonAndLocale(const UChar* skeleton, int32_t skeletonLen, const char* locale,
+unumf_openForSkeletonAndLocale(const char16_t* skeleton, int32_t skeletonLen, const char* locale,
UErrorCode* ec) {
auto* impl = new UNumberFormatterData();
if (impl == nullptr) {
@@ -96,7 +122,7 @@ unumf_openForSkeletonAndLocale(const UChar* skeleton, int32_t skeletonLen, const
}
U_CAPI UNumberFormatter* U_EXPORT2
-unumf_openForSkeletonAndLocaleWithError(const UChar* skeleton, int32_t skeletonLen, const char* locale,
+unumf_openForSkeletonAndLocaleWithError(const char16_t* skeleton, int32_t skeletonLen, const char* locale,
UParseError* perror, UErrorCode* ec) {
auto* impl = new UNumberFormatterData();
if (impl == nullptr) {
@@ -105,7 +131,8 @@ unumf_openForSkeletonAndLocaleWithError(const UChar* skeleton, int32_t skeletonL
}
// Readonly-alias constructor (first argument is whether we are NUL-terminated)
UnicodeString skeletonString(skeletonLen == -1, skeleton, skeletonLen);
- impl->fFormatter = NumberFormatter::forSkeleton(skeletonString, *perror, *ec).locale(locale);
+ UParseError tempParseError;
+ impl->fFormatter = NumberFormatter::forSkeleton(skeletonString, (perror == nullptr) ? tempParseError : *perror, *ec).locale(locale);
return impl->exportForC();
}
@@ -150,7 +177,7 @@ unumf_formatDecimal(const UNumberFormatter* uformatter, const char* value, int32
}
U_CAPI int32_t U_EXPORT2
-unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t bufferCapacity,
+unumf_resultToString(const UFormattedNumber* uresult, char16_t* buffer, int32_t bufferCapacity,
UErrorCode* ec) {
const auto* result = UFormattedNumberApiHelper::validate(uresult, *ec);
if (U_FAILURE(*ec)) { return 0; }
@@ -166,11 +193,11 @@ unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t buf
U_CAPI UBool U_EXPORT2
unumf_resultNextFieldPosition(const UFormattedNumber* uresult, UFieldPosition* ufpos, UErrorCode* ec) {
const auto* result = UFormattedNumberApiHelper::validate(uresult, *ec);
- if (U_FAILURE(*ec)) { return FALSE; }
+ if (U_FAILURE(*ec)) { return false; }
if (ufpos == nullptr) {
*ec = U_ILLEGAL_ARGUMENT_ERROR;
- return FALSE;
+ return false;
}
FieldPosition fp;
@@ -181,7 +208,7 @@ unumf_resultNextFieldPosition(const UFormattedNumber* uresult, UFieldPosition* u
ufpos->beginIndex = fp.getBeginIndex();
ufpos->endIndex = fp.getEndIndex();
// NOTE: MSVC sometimes complains when implicitly converting between bool and UBool
- return retval ? TRUE : FALSE;
+ return retval ? true : false;
}
U_CAPI void U_EXPORT2
@@ -225,6 +252,154 @@ unumf_close(UNumberFormatter* f) {
}
+///// SIMPLE NUMBER FORMATTER /////
+
+U_CAPI USimpleNumber* U_EXPORT2
+usnum_openForInt64(int64_t value, UErrorCode* ec) {
+ auto* number = new USimpleNumberData();
+ if (number == nullptr) {
+ *ec = U_MEMORY_ALLOCATION_ERROR;
+ return nullptr;
+ }
+ number->fNumber = SimpleNumber::forInt64(value, *ec);
+ return number->exportForC();
+}
+
+U_CAPI void U_EXPORT2
+usnum_setToInt64(USimpleNumber* unumber, int64_t value, UErrorCode* ec) {
+ auto* number = USimpleNumberData::validate(unumber, *ec);
+ if (U_FAILURE(*ec)) {
+ return;
+ }
+ number->fNumber = SimpleNumber::forInt64(value, *ec);
+}
+
+U_CAPI void U_EXPORT2
+usnum_multiplyByPowerOfTen(USimpleNumber* unumber, int32_t power, UErrorCode* ec) {
+ auto* number = USimpleNumberData::validate(unumber, *ec);
+ if (U_FAILURE(*ec)) {
+ return;
+ }
+ number->fNumber.multiplyByPowerOfTen(power, *ec);
+}
+
+U_CAPI void U_EXPORT2
+usnum_roundTo(USimpleNumber* unumber, int32_t position, UNumberFormatRoundingMode roundingMode, UErrorCode* ec) {
+ auto* number = USimpleNumberData::validate(unumber, *ec);
+ if (U_FAILURE(*ec)) {
+ return;
+ }
+ number->fNumber.roundTo(position, roundingMode, *ec);
+}
+
+U_CAPI void U_EXPORT2
+usnum_setMinimumIntegerDigits(USimpleNumber* unumber, int32_t minimumIntegerDigits, UErrorCode* ec) {
+ auto* number = USimpleNumberData::validate(unumber, *ec);
+ if (U_FAILURE(*ec)) {
+ return;
+ }
+ number->fNumber.setMinimumIntegerDigits(minimumIntegerDigits, *ec);
+}
+
+U_CAPI void U_EXPORT2
+usnum_setMinimumFractionDigits(USimpleNumber* unumber, int32_t minimumFractionDigits, UErrorCode* ec) {
+ auto* number = USimpleNumberData::validate(unumber, *ec);
+ if (U_FAILURE(*ec)) {
+ return;
+ }
+ number->fNumber.setMinimumFractionDigits(minimumFractionDigits, *ec);
+}
+
+U_CAPI void U_EXPORT2
+usnum_truncateStart(USimpleNumber* unumber, int32_t maximumIntegerDigits, UErrorCode* ec) {
+ auto* number = USimpleNumberData::validate(unumber, *ec);
+ if (U_FAILURE(*ec)) {
+ return;
+ }
+ number->fNumber.truncateStart(maximumIntegerDigits, *ec);
+}
+
+U_CAPI void U_EXPORT2
+usnum_setSign(USimpleNumber* unumber, USimpleNumberSign sign, UErrorCode* ec) {
+ auto* number = USimpleNumberData::validate(unumber, *ec);
+ if (U_FAILURE(*ec)) {
+ return;
+ }
+ number->fNumber.setSign(sign, *ec);
+}
+
+U_CAPI USimpleNumberFormatter* U_EXPORT2
+usnumf_openForLocale(const char* locale, UErrorCode* ec) {
+ auto* impl = new USimpleNumberFormatterData();
+ if (impl == nullptr) {
+ *ec = U_MEMORY_ALLOCATION_ERROR;
+ return nullptr;
+ }
+ impl->fFormatter = SimpleNumberFormatter::forLocale(locale, *ec);
+ return impl->exportForC();
+}
+
+U_CAPI USimpleNumberFormatter* U_EXPORT2
+usnumf_openForLocaleAndGroupingStrategy(
+ const char* locale, UNumberGroupingStrategy groupingStrategy, UErrorCode* ec) {
+ auto* impl = new USimpleNumberFormatterData();
+ if (impl == nullptr) {
+ *ec = U_MEMORY_ALLOCATION_ERROR;
+ return nullptr;
+ }
+ impl->fFormatter = SimpleNumberFormatter::forLocaleAndGroupingStrategy(locale, groupingStrategy, *ec);
+ return impl->exportForC();
+}
+
+U_CAPI void U_EXPORT2
+usnumf_format(
+ const USimpleNumberFormatter* uformatter,
+ USimpleNumber* unumber,
+ UFormattedNumber* uresult,
+ UErrorCode* ec) {
+ auto* formatter = USimpleNumberFormatterData::validate(uformatter, *ec);
+ auto* number = USimpleNumberData::validate(unumber, *ec);
+ auto* result = UFormattedNumberApiHelper::validate(uresult, *ec);
+ if (U_FAILURE(*ec)) {
+ return;
+ }
+ auto localResult = formatter->fFormatter.format(std::move(number->fNumber), *ec);
+ if (U_FAILURE(*ec)) {
+ return;
+ }
+ result->setTo(std::move(localResult));
+}
+
+U_CAPI void U_EXPORT2
+usnumf_formatInt64(
+ const USimpleNumberFormatter* uformatter,
+ int64_t value,
+ UFormattedNumber* uresult,
+ UErrorCode* ec) {
+ auto* formatter = USimpleNumberFormatterData::validate(uformatter, *ec);
+ auto* result = UFormattedNumberApiHelper::validate(uresult, *ec);
+ if (U_FAILURE(*ec)) {
+ return;
+ }
+ auto localResult = formatter->fFormatter.formatInt64(value, *ec);
+ result->setTo(std::move(localResult));
+}
+
+U_CAPI void U_EXPORT2
+usnum_close(USimpleNumber* unumber) {
+ UErrorCode localStatus = U_ZERO_ERROR;
+ const USimpleNumberData* impl = USimpleNumberData::validate(unumber, localStatus);
+ delete impl;
+}
+
+U_CAPI void U_EXPORT2
+usnumf_close(USimpleNumberFormatter* uformatter) {
+ UErrorCode localStatus = U_ZERO_ERROR;
+ const USimpleNumberFormatterData* impl = USimpleNumberFormatterData::validate(uformatter, localStatus);
+ delete impl;
+}
+
+
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/contrib/libs/icu/i18n/number_compact.cpp b/contrib/libs/icu/i18n/number_compact.cpp
index 62692f444d..2cfa65a031 100644
--- a/contrib/libs/icu/i18n/number_compact.cpp
+++ b/contrib/libs/icu/i18n/number_compact.cpp
@@ -22,7 +22,7 @@ namespace {
// A dummy object used when a "0" compact decimal entry is encountered. This is necessary
// in order to prevent falling back to root. Object equality ("==") is intended.
-const UChar *USE_FALLBACK = u"<USE FALLBACK>";
+const char16_t *USE_FALLBACK = u"<USE FALLBACK>";
/** Produces a string like "NumberElements/latn/patternsShort/decimalFormat". */
void getResourceBundleKey(const char *nsName, CompactStyle compactStyle, CompactType compactType,
@@ -38,7 +38,7 @@ int32_t getIndex(int32_t magnitude, StandardPlural::Form plural) {
return magnitude * StandardPlural::COUNT + plural;
}
-int32_t countZeros(const UChar *patternString, int32_t patternLength) {
+int32_t countZeros(const char16_t *patternString, int32_t patternLength) {
// NOTE: This strategy for computing the number of zeros is a hack for efficiency.
// It could break if there are any 0s that aren't part of the main pattern.
int32_t numZeros = 0;
@@ -104,7 +104,7 @@ int32_t CompactData::getMultiplier(int32_t magnitude) const {
return multipliers[magnitude];
}
-const UChar *CompactData::getPattern(
+const char16_t *CompactData::getPattern(
int32_t magnitude,
const PluralRules *rules,
const DecimalQuantity &dq) const {
@@ -114,7 +114,7 @@ const UChar *CompactData::getPattern(
if (magnitude > largestMagnitude) {
magnitude = largestMagnitude;
}
- const UChar *patternString = nullptr;
+ const char16_t *patternString = nullptr;
if (dq.hasIntegerValue()) {
int64_t i = dq.toLong(true);
if (i == 0) {
@@ -151,14 +151,14 @@ void CompactData::getUniquePatterns(UVector &output, UErrorCode &status) const {
// Insert pattern into the UVector if the UVector does not already contain the pattern.
// Search the UVector from the end since identical patterns are likely to be adjacent.
for (int32_t i = output.size() - 1; i >= 0; i--) {
- if (u_strcmp(pattern, static_cast<const UChar *>(output[i])) == 0) {
+ if (u_strcmp(pattern, static_cast<const char16_t *>(output[i])) == 0) {
goto continue_outer;
}
}
// The string was not found; add it to the UVector.
- // ANDY: This requires a const_cast. Why?
- output.addElementX(const_cast<UChar *>(pattern), status);
+ // Note: must cast off const from pattern to store it in a UVector, which expects (void *)
+ output.addElement(const_cast<char16_t *>(pattern), status);
continue_outer:
continue;
@@ -173,10 +173,14 @@ void CompactData::CompactDataSink::put(const char *key, ResourceValue &value, UB
for (int i3 = 0; powersOfTenTable.getKeyAndValue(i3, key, value); ++i3) {
// Assumes that the keys are always of the form "10000" where the magnitude is the
- // length of the key minus one. We expect magnitudes to be less than MAX_DIGITS.
+ // length of the key minus one. We only support magnitudes less than COMPACT_MAX_DIGITS;
+ // ignore entries that have greater magnitude.
auto magnitude = static_cast<int8_t> (strlen(key) - 1);
+ U_ASSERT(magnitude < COMPACT_MAX_DIGITS); // debug assert
+ if (magnitude >= COMPACT_MAX_DIGITS) { // skip in production
+ continue;
+ }
int8_t multiplier = data.multipliers[magnitude];
- U_ASSERT(magnitude < COMPACT_MAX_DIGITS);
// Iterate over the plural variants ("one", "other", etc)
ResourceTable pluralVariantsTable = value.getTable(status);
@@ -193,7 +197,7 @@ void CompactData::CompactDataSink::put(const char *key, ResourceValue &value, UB
// The value "0" means that we need to use the default pattern and not fall back
// to parent locales. Example locale where this is relevant: 'it'.
int32_t patternLength;
- const UChar *patternString = value.getString(patternLength, status);
+ const char16_t *patternString = value.getString(patternLength, status);
if (U_FAILURE(status)) { return; }
if (u_strcmp(patternString, u"0") == 0) {
patternString = USE_FALLBACK;
@@ -275,7 +279,7 @@ void CompactHandler::precomputeAllModifiers(MutablePatternModifier &buildReferen
}
for (int32_t i = 0; i < precomputedModsLength; i++) {
- auto patternString = static_cast<const UChar *>(allPatterns[i]);
+ auto patternString = static_cast<const char16_t *>(allPatterns[i]);
UnicodeString hello(patternString);
CompactModInfo &info = precomputedMods[i];
ParsedPatternInfo patternInfo;
@@ -306,7 +310,7 @@ void CompactHandler::processQuantity(DecimalQuantity &quantity, MicroProps &micr
magnitude -= multiplier;
}
- const UChar *patternString = data.getPattern(magnitude, rules, quantity);
+ const char16_t *patternString = data.getPattern(magnitude, rules, quantity);
if (patternString == nullptr) {
// Use the default (non-compact) modifier.
// No need to take any action.
diff --git a/contrib/libs/icu/i18n/number_compact.h b/contrib/libs/icu/i18n/number_compact.h
index 9802b9fb10..aee1df7452 100644
--- a/contrib/libs/icu/i18n/number_compact.h
+++ b/contrib/libs/icu/i18n/number_compact.h
@@ -17,7 +17,7 @@
U_NAMESPACE_BEGIN namespace number {
namespace impl {
-static const int32_t COMPACT_MAX_DIGITS = 15;
+static const int32_t COMPACT_MAX_DIGITS = 20;
class CompactData : public MultiplierProducer {
public:
@@ -26,9 +26,9 @@ class CompactData : public MultiplierProducer {
void populate(const Locale &locale, const char *nsName, CompactStyle compactStyle,
CompactType compactType, UErrorCode &status);
- int32_t getMultiplier(int32_t magnitude) const U_OVERRIDE;
+ int32_t getMultiplier(int32_t magnitude) const override;
- const UChar *getPattern(
+ const char16_t *getPattern(
int32_t magnitude,
const PluralRules *rules,
const DecimalQuantity &dq) const;
@@ -36,7 +36,7 @@ class CompactData : public MultiplierProducer {
void getUniquePatterns(UVector &output, UErrorCode &status) const;
private:
- const UChar *patterns[(COMPACT_MAX_DIGITS + 1) * StandardPlural::COUNT];
+ const char16_t *patterns[(COMPACT_MAX_DIGITS + 1) * StandardPlural::COUNT];
int8_t multipliers[COMPACT_MAX_DIGITS + 1];
int8_t largestMagnitude;
UBool isEmpty;
@@ -45,7 +45,7 @@ class CompactData : public MultiplierProducer {
public:
explicit CompactDataSink(CompactData &data) : data(data) {}
- void put(const char *key, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) U_OVERRIDE;
+ void put(const char *key, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) override;
private:
CompactData &data;
@@ -54,7 +54,7 @@ class CompactData : public MultiplierProducer {
struct CompactModInfo {
const ImmutablePatternModifier *mod;
- const UChar* patternString;
+ const char16_t* patternString;
};
class CompactHandler : public MicroPropsGenerator, public UMemory {
@@ -70,10 +70,10 @@ class CompactHandler : public MicroPropsGenerator, public UMemory {
const MicroPropsGenerator *parent,
UErrorCode &status);
- ~CompactHandler() U_OVERRIDE;
+ ~CompactHandler() override;
void
- processQuantity(DecimalQuantity &quantity, MicroProps &micros, UErrorCode &status) const U_OVERRIDE;
+ processQuantity(DecimalQuantity &quantity, MicroProps &micros, UErrorCode &status) const override;
private:
const PluralRules *rules;
diff --git a/contrib/libs/icu/i18n/number_currencysymbols.cpp b/contrib/libs/icu/i18n/number_currencysymbols.cpp
index da1812f49f..8d5127556b 100644
--- a/contrib/libs/icu/i18n/number_currencysymbols.cpp
+++ b/contrib/libs/icu/i18n/number_currencysymbols.cpp
@@ -108,6 +108,10 @@ UnicodeString CurrencySymbols::getPluralName(StandardPlural::Form plural, UError
}
}
+bool CurrencySymbols::hasEmptyCurrencySymbol() const {
+ return !fCurrencySymbol.isBogus() && fCurrencySymbol.isEmpty();
+}
+
CurrencyUnit
icu::number::impl::resolveCurrency(const DecimalFormatProperties& properties, const Locale& locale,
diff --git a/contrib/libs/icu/i18n/number_currencysymbols.h b/contrib/libs/icu/i18n/number_currencysymbols.h
index 7e38fdf828..c2223bd0f0 100644
--- a/contrib/libs/icu/i18n/number_currencysymbols.h
+++ b/contrib/libs/icu/i18n/number_currencysymbols.h
@@ -41,6 +41,8 @@ class U_I18N_API CurrencySymbols : public UMemory {
UnicodeString getPluralName(StandardPlural::Form plural, UErrorCode& status) const;
+ bool hasEmptyCurrencySymbol() const;
+
protected:
// Required fields:
CurrencyUnit fCurrency;
diff --git a/contrib/libs/icu/i18n/number_decimalquantity.cpp b/contrib/libs/icu/i18n/number_decimalquantity.cpp
index 6a2847b1c1..659465d087 100644
--- a/contrib/libs/icu/i18n/number_decimalquantity.cpp
+++ b/contrib/libs/icu/i18n/number_decimalquantity.cpp
@@ -89,7 +89,7 @@ DecimalQuantity::DecimalQuantity(const DecimalQuantity &other) {
*this = other;
}
-DecimalQuantity::DecimalQuantity(DecimalQuantity&& src) U_NOEXCEPT {
+DecimalQuantity::DecimalQuantity(DecimalQuantity&& src) noexcept {
*this = std::move(src);
}
@@ -102,7 +102,7 @@ DecimalQuantity &DecimalQuantity::operator=(const DecimalQuantity &other) {
return *this;
}
-DecimalQuantity& DecimalQuantity::operator=(DecimalQuantity&& src) U_NOEXCEPT {
+DecimalQuantity& DecimalQuantity::operator=(DecimalQuantity&& src) noexcept {
if (this == &src) {
return *this;
}
@@ -181,20 +181,22 @@ uint64_t DecimalQuantity::getPositionFingerprint() const {
return fingerprint;
}
-void DecimalQuantity::roundToIncrement(double roundingIncrement, RoundingMode roundingMode,
- UErrorCode& status) {
+void DecimalQuantity::roundToIncrement(
+ uint64_t increment,
+ digits_t magnitude,
+ RoundingMode roundingMode,
+ UErrorCode& status) {
// Do not call this method with an increment having only a 1 or a 5 digit!
// Use a more efficient call to either roundToMagnitude() or roundToNickel().
// Check a few popular rounding increments; a more thorough check is in Java.
- U_ASSERT(roundingIncrement != 0.01);
- U_ASSERT(roundingIncrement != 0.05);
- U_ASSERT(roundingIncrement != 0.1);
- U_ASSERT(roundingIncrement != 0.5);
- U_ASSERT(roundingIncrement != 1);
- U_ASSERT(roundingIncrement != 5);
+ U_ASSERT(increment != 1);
+ U_ASSERT(increment != 5);
+ DecimalQuantity incrementDQ;
+ incrementDQ.setToLong(increment);
+ incrementDQ.adjustMagnitude(magnitude);
DecNum incrementDN;
- incrementDN.setTo(roundingIncrement, status);
+ incrementDQ.toDecNum(incrementDN, status);
if (U_FAILURE(status)) { return; }
// Divide this DecimalQuantity by the increment, round, then multiply back.
@@ -254,6 +256,12 @@ bool DecimalQuantity::adjustMagnitude(int32_t delta) {
return false;
}
+int32_t DecimalQuantity::adjustToZeroScale() {
+ int32_t retval = scale;
+ scale = 0;
+ return retval;
+}
+
double DecimalQuantity::getPluralOperand(PluralOperand operand) const {
// If this assertion fails, you need to call roundToInfinity() or some other rounding method.
// See the comment at the top of this file explaining the "isApproximate" field.
@@ -549,6 +557,65 @@ void DecimalQuantity::_setToDecNum(const DecNum& decnum, UErrorCode& status) {
}
}
+DecimalQuantity DecimalQuantity::fromExponentString(UnicodeString num, UErrorCode& status) {
+ if (num.indexOf(u'e') >= 0 || num.indexOf(u'c') >= 0
+ || num.indexOf(u'E') >= 0 || num.indexOf(u'C') >= 0) {
+ int32_t ePos = num.lastIndexOf('e');
+ if (ePos < 0) {
+ ePos = num.lastIndexOf('c');
+ }
+ if (ePos < 0) {
+ ePos = num.lastIndexOf('E');
+ }
+ if (ePos < 0) {
+ ePos = num.lastIndexOf('C');
+ }
+ int32_t expNumPos = ePos + 1;
+ UnicodeString exponentStr = num.tempSubString(expNumPos, num.length() - expNumPos);
+
+ // parse exponentStr into exponent, but note that parseAsciiInteger doesn't handle the minus sign
+ bool isExpStrNeg = num[expNumPos] == u'-';
+ int32_t exponentParsePos = isExpStrNeg ? 1 : 0;
+ int32_t exponent = ICU_Utility::parseAsciiInteger(exponentStr, exponentParsePos);
+ exponent = isExpStrNeg ? -exponent : exponent;
+
+ // Compute the decNumber representation
+ UnicodeString fractionStr = num.tempSubString(0, ePos);
+ CharString fracCharStr = CharString();
+ fracCharStr.appendInvariantChars(fractionStr, status);
+ DecNum decnum;
+ decnum.setTo(fracCharStr.toStringPiece(), status);
+
+ // Clear and set this DecimalQuantity instance
+ DecimalQuantity dq;
+ dq.setToDecNum(decnum, status);
+ int32_t numFracDigit = getVisibleFractionCount(fractionStr);
+ dq.setMinFraction(numFracDigit);
+ dq.adjustExponent(exponent);
+
+ return dq;
+ } else {
+ DecimalQuantity dq;
+ int numFracDigit = getVisibleFractionCount(num);
+
+ CharString numCharStr = CharString();
+ numCharStr.appendInvariantChars(num, status);
+ dq.setToDecNumber(numCharStr.toStringPiece(), status);
+
+ dq.setMinFraction(numFracDigit);
+ return dq;
+ }
+}
+
+int32_t DecimalQuantity::getVisibleFractionCount(UnicodeString value) {
+ int decimalPos = value.indexOf('.') + 1;
+ if (decimalPos == 0) {
+ return 0;
+ } else {
+ return value.length() - decimalPos;
+ }
+}
+
int64_t DecimalQuantity::toLong(bool truncateIfOverflow) const {
// NOTE: Call sites should be guarded by fitsInLong(), like this:
// if (dq.fitsInLong()) { /* use dq.toLong() */ } else { /* use some fallback */ }
@@ -948,6 +1015,44 @@ UnicodeString DecimalQuantity::toPlainString() const {
return sb;
}
+
+UnicodeString DecimalQuantity::toExponentString() const {
+ U_ASSERT(!isApproximate);
+ UnicodeString sb;
+ if (isNegative()) {
+ sb.append(u'-');
+ }
+
+ int32_t upper = scale + precision - 1;
+ int32_t lower = scale;
+ if (upper < lReqPos - 1) {
+ upper = lReqPos - 1;
+ }
+ if (lower > rReqPos) {
+ lower = rReqPos;
+ }
+ int32_t p = upper;
+ if (p < 0) {
+ sb.append(u'0');
+ }
+ for (; p >= 0; p--) {
+ sb.append(u'0' + getDigitPos(p - scale));
+ }
+ if (lower < 0) {
+ sb.append(u'.');
+ }
+ for(; p >= lower; p--) {
+ sb.append(u'0' + getDigitPos(p - scale));
+ }
+
+ if (exponent != 0) {
+ sb.append(u'c');
+ ICU_Utility::appendNumber(sb, exponent);
+ }
+
+ return sb;
+}
+
UnicodeString DecimalQuantity::toScientificString() const {
U_ASSERT(!isApproximate);
UnicodeString result;
diff --git a/contrib/libs/icu/i18n/number_decimalquantity.h b/contrib/libs/icu/i18n/number_decimalquantity.h
index 107c09a96a..2211fe9c19 100644
--- a/contrib/libs/icu/i18n/number_decimalquantity.h
+++ b/contrib/libs/icu/i18n/number_decimalquantity.h
@@ -36,7 +36,7 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory {
DecimalQuantity(const DecimalQuantity &other);
/** Move constructor. */
- DecimalQuantity(DecimalQuantity &&src) U_NOEXCEPT;
+ DecimalQuantity(DecimalQuantity &&src) noexcept;
DecimalQuantity();
@@ -50,7 +50,7 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory {
DecimalQuantity &operator=(const DecimalQuantity &other);
/** Move assignment */
- DecimalQuantity &operator=(DecimalQuantity&& src) U_NOEXCEPT;
+ DecimalQuantity &operator=(DecimalQuantity&& src) noexcept;
/**
* Sets the minimum integer digits that this {@link DecimalQuantity} should generate.
@@ -81,11 +81,15 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory {
*
* <p>If rounding to a power of ten, use the more efficient {@link #roundToMagnitude} instead.
*
- * @param roundingIncrement The increment to which to round.
+ * @param increment The increment to which to round.
+ * @param magnitude The power of 10 to which to round.
* @param roundingMode The {@link RoundingMode} to use if rounding is necessary.
*/
- void roundToIncrement(double roundingIncrement, RoundingMode roundingMode,
- UErrorCode& status);
+ void roundToIncrement(
+ uint64_t increment,
+ digits_t magnitude,
+ RoundingMode roundingMode,
+ UErrorCode& status);
/** Removes all fraction digits. */
void truncate();
@@ -141,6 +145,13 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory {
bool adjustMagnitude(int32_t delta);
/**
+ * Scales the number such that the least significant nonzero digit is at magnitude 0.
+ *
+ * @return The previous magnitude of the least significant digit.
+ */
+ int32_t adjustToZeroScale();
+
+ /**
* @return The power of ten corresponding to the most significant nonzero digit.
* The number must not be zero.
*/
@@ -184,10 +195,10 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory {
Signum signum() const;
/** @return Whether the value represented by this {@link DecimalQuantity} is infinite. */
- bool isInfinite() const U_OVERRIDE;
+ bool isInfinite() const override;
/** @return Whether the value represented by this {@link DecimalQuantity} is not a number. */
- bool isNaN() const U_OVERRIDE;
+ bool isNaN() const override;
/**
* Note: this method incorporates the value of {@code exponent}
@@ -234,6 +245,9 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory {
/** Internal method if the caller already has a DecNum. */
DecimalQuantity &setToDecNum(const DecNum& n, UErrorCode& status);
+ /** Returns a DecimalQuantity after parsing the input string. */
+ static DecimalQuantity fromExponentString(UnicodeString n, UErrorCode& status);
+
/**
* Appends a digit, optionally with one or more leading zeros, to the end of the value represented
* by this DecimalQuantity.
@@ -253,9 +267,9 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory {
*/
void appendDigit(int8_t value, int32_t leadingZeros, bool appendAsInteger);
- double getPluralOperand(PluralOperand operand) const U_OVERRIDE;
+ double getPluralOperand(PluralOperand operand) const override;
- bool hasIntegerValue() const U_OVERRIDE;
+ bool hasIntegerValue() const override;
/**
* Gets the digit at the specified magnitude. For example, if the represented number is 12.3,
@@ -315,6 +329,10 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory {
/** Returns the string without exponential notation. Slightly slower than toScientificString(). */
UnicodeString toPlainString() const;
+ /** Returns the string using ASCII digits and using exponential notation for non-zero
+ exponents, following the UTS 35 specification for plural rule samples. */
+ UnicodeString toExponentString() const;
+
/** Visible for testing */
inline bool isUsingBytes() { return usingBytes; }
@@ -518,6 +536,8 @@ class U_I18N_API DecimalQuantity : public IFixedDecimal, public UMemory {
void _setToDecNum(const DecNum& dn, UErrorCode& status);
+ static int32_t getVisibleFractionCount(UnicodeString value);
+
void convertToAccurateDouble();
/** Ensure that a byte array of at least 40 digits is allocated. */
diff --git a/contrib/libs/icu/i18n/number_decimfmtprops.cpp b/contrib/libs/icu/i18n/number_decimfmtprops.cpp
index 7fa58bbc7a..6dbfc69ec8 100644
--- a/contrib/libs/icu/i18n/number_decimfmtprops.cpp
+++ b/contrib/libs/icu/i18n/number_decimfmtprops.cpp
@@ -18,7 +18,7 @@ namespace {
alignas(DecimalFormatProperties)
char kRawDefaultProperties[sizeof(DecimalFormatProperties)];
-icu::UInitOnce gDefaultPropertiesInitOnce = U_INITONCE_INITIALIZER;
+icu::UInitOnce gDefaultPropertiesInitOnce {};
void U_CALLCONV initDefaultProperties(UErrorCode&) {
// can't fail, uses placement new into statically allocated space.
diff --git a/contrib/libs/icu/i18n/number_fluent.cpp b/contrib/libs/icu/i18n/number_fluent.cpp
index fd486afb51..45d6b06c6d 100644
--- a/contrib/libs/icu/i18n/number_fluent.cpp
+++ b/contrib/libs/icu/i18n/number_fluent.cpp
@@ -288,6 +288,34 @@ Derived NumberFormatterSettings<Derived>::usage(const StringPiece usage)&& {
return move;
}
+template <typename Derived>
+Derived NumberFormatterSettings<Derived>::displayOptions(const DisplayOptions &displayOptions) const & {
+ Derived copy(*this);
+ // `displayCase` does not recognise the `undefined`
+ if (displayOptions.getGrammaticalCase() == UDISPOPT_GRAMMATICAL_CASE_UNDEFINED) {
+ copy.fMacros.unitDisplayCase.set(nullptr);
+ return copy;
+ }
+
+ copy.fMacros.unitDisplayCase.set(
+ udispopt_getGrammaticalCaseIdentifier(displayOptions.getGrammaticalCase()));
+ return copy;
+}
+
+template <typename Derived>
+Derived NumberFormatterSettings<Derived>::displayOptions(const DisplayOptions &displayOptions) && {
+ Derived move(std::move(*this));
+ // `displayCase` does not recognise the `undefined`
+ if (displayOptions.getGrammaticalCase() == UDISPOPT_GRAMMATICAL_CASE_UNDEFINED) {
+ move.fMacros.unitDisplayCase.set(nullptr);
+ return move;
+ }
+
+ move.fMacros.unitDisplayCase.set(
+ udispopt_getGrammaticalCaseIdentifier(displayOptions.getGrammaticalCase()));
+ return move;
+}
+
template<typename Derived>
Derived NumberFormatterSettings<Derived>::unitDisplayCase(const StringPiece unitDisplayCase) const& {
Derived copy(*this);
@@ -403,10 +431,10 @@ UnlocalizedNumberFormatter::UnlocalizedNumberFormatter(const NFS<UNF>& other)
}
// Make default copy constructor call the NumberFormatterSettings copy constructor.
-UnlocalizedNumberFormatter::UnlocalizedNumberFormatter(UNF&& src) U_NOEXCEPT
+UnlocalizedNumberFormatter::UnlocalizedNumberFormatter(UNF&& src) noexcept
: UNF(static_cast<NFS<UNF>&&>(src)) {}
-UnlocalizedNumberFormatter::UnlocalizedNumberFormatter(NFS<UNF>&& src) U_NOEXCEPT
+UnlocalizedNumberFormatter::UnlocalizedNumberFormatter(NFS<UNF>&& src) noexcept
: NFS<UNF>(std::move(src)) {
// No additional fields to assign
}
@@ -417,7 +445,7 @@ UnlocalizedNumberFormatter& UnlocalizedNumberFormatter::operator=(const UNF& oth
return *this;
}
-UnlocalizedNumberFormatter& UnlocalizedNumberFormatter::operator=(UNF&& src) U_NOEXCEPT {
+UnlocalizedNumberFormatter& UnlocalizedNumberFormatter::operator=(UNF&& src) noexcept {
NFS<UNF>::operator=(static_cast<NFS<UNF>&&>(src));
// No additional fields to assign
return *this;
@@ -433,10 +461,10 @@ LocalizedNumberFormatter::LocalizedNumberFormatter(const NFS<LNF>& other)
lnfCopyHelper(static_cast<const LNF&>(other), localStatus);
}
-LocalizedNumberFormatter::LocalizedNumberFormatter(LocalizedNumberFormatter&& src) U_NOEXCEPT
+LocalizedNumberFormatter::LocalizedNumberFormatter(LocalizedNumberFormatter&& src) noexcept
: LNF(static_cast<NFS<LNF>&&>(src)) {}
-LocalizedNumberFormatter::LocalizedNumberFormatter(NFS<LNF>&& src) U_NOEXCEPT
+LocalizedNumberFormatter::LocalizedNumberFormatter(NFS<LNF>&& src) noexcept
: NFS<LNF>(std::move(src)) {
lnfMoveHelper(std::move(static_cast<LNF&&>(src)));
}
@@ -449,7 +477,7 @@ LocalizedNumberFormatter& LocalizedNumberFormatter::operator=(const LNF& other)
return *this;
}
-LocalizedNumberFormatter& LocalizedNumberFormatter::operator=(LNF&& src) U_NOEXCEPT {
+LocalizedNumberFormatter& LocalizedNumberFormatter::operator=(LNF&& src) noexcept {
NFS<LNF>::operator=(static_cast<NFS<LNF>&&>(src));
lnfMoveHelper(std::move(src));
return *this;
diff --git a/contrib/libs/icu/i18n/number_formatimpl.cpp b/contrib/libs/icu/i18n/number_formatimpl.cpp
index 96e3e9e7c6..53bac49a55 100644
--- a/contrib/libs/icu/i18n/number_formatimpl.cpp
+++ b/contrib/libs/icu/i18n/number_formatimpl.cpp
@@ -36,7 +36,7 @@ int32_t NumberFormatterImpl::formatStatic(const MacroProps &macros, UFormattedNu
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);
+ int32_t length = writeNumber(micros.simple, inValue, outString, 0, status);
length += writeAffixes(micros, outString, 0, length, status);
results->outputUnit = std::move(micros.outputUnit);
results->gender = micros.gender;
@@ -61,7 +61,7 @@ int32_t NumberFormatterImpl::format(UFormattedNumberData *results, UErrorCode &s
MicroProps micros;
preProcess(inValue, micros, status);
if (U_FAILURE(status)) { return 0; }
- int32_t length = writeNumber(micros, inValue, outString, 0, status);
+ int32_t length = writeNumber(micros.simple, inValue, outString, 0, status);
length += writeAffixes(micros, outString, 0, length, status);
results->outputUnit = std::move(micros.outputUnit);
results->gender = micros.gender;
@@ -186,7 +186,7 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
// Resolve the symbols. Do this here because currency may need to customize them.
if (macros.symbols.isDecimalFormatSymbols()) {
- fMicros.symbols = macros.symbols.getDecimalFormatSymbols();
+ fMicros.simple.symbols = macros.symbols.getDecimalFormatSymbols();
} else {
LocalPointer<DecimalFormatSymbols> newSymbols(
new DecimalFormatSymbols(macros.locale, *ns, status), status);
@@ -199,15 +199,15 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
return nullptr;
}
}
- fMicros.symbols = newSymbols.getAlias();
+ fMicros.simple.symbols = newSymbols.getAlias();
fSymbols.adoptInstead(newSymbols.orphan());
}
// Load and parse the pattern string. It is used for grouping sizes and affixes only.
// If we are formatting currency, check for a currency-specific pattern.
const char16_t* pattern = nullptr;
- if (isCurrency && fMicros.symbols->getCurrencyPattern() != nullptr) {
- pattern = fMicros.symbols->getCurrencyPattern();
+ if (isCurrency && fMicros.simple.symbols->getCurrencyPattern() != nullptr) {
+ pattern = fMicros.simple.symbols->getCurrencyPattern();
}
if (pattern == nullptr) {
CldrPatternStyle patternStyle;
@@ -291,14 +291,14 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
// Grouping strategy
if (!macros.grouper.isBogus()) {
- fMicros.grouping = macros.grouper;
+ fMicros.simple.grouping = macros.grouper;
} else if (isCompactNotation) {
// Compact notation uses minGrouping by default since ICU 59
- fMicros.grouping = Grouper::forStrategy(UNUM_GROUPING_MIN2);
+ fMicros.simple.grouping = Grouper::forStrategy(UNUM_GROUPING_MIN2);
} else {
- fMicros.grouping = Grouper::forStrategy(UNUM_GROUPING_AUTO);
+ fMicros.simple.grouping = Grouper::forStrategy(UNUM_GROUPING_AUTO);
}
- fMicros.grouping.setLocaleData(*fPatternInfo, macros.locale);
+ fMicros.simple.grouping.setLocaleData(*fPatternInfo, macros.locale);
// Padding strategy
if (!macros.padder.isBogus()) {
@@ -323,17 +323,17 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
// Decimal mark display
if (macros.decimal != UNUM_DECIMAL_SEPARATOR_COUNT) {
- fMicros.decimal = macros.decimal;
+ fMicros.simple.decimal = macros.decimal;
} else {
- fMicros.decimal = UNUM_DECIMAL_SEPARATOR_AUTO;
+ fMicros.simple.decimal = UNUM_DECIMAL_SEPARATOR_AUTO;
}
// Use monetary separator symbols
- fMicros.useCurrency = isCurrency;
+ fMicros.simple.useCurrency = isCurrency;
// Inner modifier (scientific notation)
if (macros.notation.fType == Notation::NTN_SCIENTIFIC) {
- auto newScientificHandler = new ScientificHandler(&macros.notation, fMicros.symbols, chain);
+ auto newScientificHandler = new ScientificHandler(&macros.notation, fMicros.simple.symbols, chain);
if (newScientificHandler == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return nullptr;
@@ -353,20 +353,22 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
}
fPatternModifier.adoptInstead(patternModifier);
const AffixPatternProvider* affixProvider =
- macros.affixProvider != nullptr
+ macros.affixProvider != nullptr && (
+ // For more information on this condition, see ICU-22073
+ !isCompactNotation || isCurrency == macros.affixProvider->hasCurrencySign())
? macros.affixProvider
: static_cast<const AffixPatternProvider*>(fPatternInfo.getAlias());
patternModifier->setPatternInfo(affixProvider, kUndefinedField);
patternModifier->setPatternAttributes(fMicros.sign, isPermille, macros.approximately);
if (patternModifier->needsPlurals()) {
patternModifier->setSymbols(
- fMicros.symbols,
+ fMicros.simple.symbols,
currency,
unitWidth,
resolvePluralRules(macros.rules, macros.locale, status),
status);
} else {
- patternModifier->setSymbols(fMicros.symbols, currency, unitWidth, nullptr, status);
+ patternModifier->setSymbols(fMicros.simple.symbols, currency, unitWidth, nullptr, status);
}
if (safe) {
fImmutablePatternModifier.adoptInsteadAndCheckErrorCode(patternModifier->createImmutable(status),
@@ -378,7 +380,7 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
// currencyAsDecimal
if (affixProvider->currencyAsDecimal()) {
- fMicros.currencyAsDecimal = patternModifier->getCurrencySymbolForUnitWidth(status);
+ fMicros.simple.currencyAsDecimal = patternModifier->getCurrencySymbolForUnitWidth(status);
}
// Outer modifier (CLDR units and currency long names)
@@ -479,8 +481,10 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
}
const PluralRules*
-NumberFormatterImpl::resolvePluralRules(const PluralRules* rulesPtr, const Locale& locale,
- UErrorCode& status) {
+NumberFormatterImpl::resolvePluralRules(
+ const PluralRules* rulesPtr,
+ const Locale& locale,
+ UErrorCode& status) {
if (rulesPtr != nullptr) {
return rulesPtr;
}
@@ -491,8 +495,12 @@ NumberFormatterImpl::resolvePluralRules(const PluralRules* rulesPtr, const Local
return fRules.getAlias();
}
-int32_t NumberFormatterImpl::writeAffixes(const MicroProps& micros, FormattedStringBuilder& string,
- int32_t start, int32_t end, UErrorCode& status) {
+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);
@@ -506,9 +514,12 @@ int32_t NumberFormatterImpl::writeAffixes(const MicroProps& micros, FormattedStr
return length;
}
-int32_t NumberFormatterImpl::writeNumber(const MicroProps& micros, DecimalQuantity& quantity,
- FormattedStringBuilder& string, int32_t index,
- UErrorCode& status) {
+int32_t NumberFormatterImpl::writeNumber(
+ const SimpleMicroProps& micros,
+ DecimalQuantity& quantity,
+ FormattedStringBuilder& string,
+ int32_t index,
+ UErrorCode& status) {
int32_t length = 0;
if (quantity.isInfinite()) {
length += string.insert(
@@ -526,7 +537,12 @@ int32_t NumberFormatterImpl::writeNumber(const MicroProps& micros, DecimalQuanti
} else {
// Add the integer digits
- length += writeIntegerDigits(micros, quantity, string, length + index, status);
+ length += writeIntegerDigits(
+ micros,
+ quantity,
+ string,
+ length + index,
+ status);
// Add the decimal point
if (quantity.getLowerDisplayMagnitude() < 0 || micros.decimal == UNUM_DECIMAL_SEPARATOR_ALWAYS) {
@@ -571,9 +587,12 @@ int32_t NumberFormatterImpl::writeNumber(const MicroProps& micros, DecimalQuanti
return length;
}
-int32_t NumberFormatterImpl::writeIntegerDigits(const MicroProps& micros, DecimalQuantity& quantity,
- FormattedStringBuilder& string, int32_t index,
- UErrorCode& status) {
+int32_t NumberFormatterImpl::writeIntegerDigits(
+ const SimpleMicroProps& micros,
+ DecimalQuantity& quantity,
+ FormattedStringBuilder& string,
+ int32_t index,
+ UErrorCode& status) {
int length = 0;
int integerCount = quantity.getUpperDisplayMagnitude() + 1;
for (int i = 0; i < integerCount; i++) {
@@ -603,9 +622,12 @@ int32_t NumberFormatterImpl::writeIntegerDigits(const MicroProps& micros, Decima
return length;
}
-int32_t NumberFormatterImpl::writeFractionDigits(const MicroProps& micros, DecimalQuantity& quantity,
- FormattedStringBuilder& string, int32_t index,
- UErrorCode& status) {
+int32_t NumberFormatterImpl::writeFractionDigits(
+ const SimpleMicroProps& micros,
+ DecimalQuantity& quantity,
+ FormattedStringBuilder& string,
+ int32_t index,
+ UErrorCode& status) {
int length = 0;
int fractionCount = -quantity.getLowerDisplayMagnitude();
for (int i = 0; i < fractionCount; i++) {
diff --git a/contrib/libs/icu/i18n/number_formatimpl.h b/contrib/libs/icu/i18n/number_formatimpl.h
index d7be1468b6..62d5321261 100644
--- a/contrib/libs/icu/i18n/number_formatimpl.h
+++ b/contrib/libs/icu/i18n/number_formatimpl.h
@@ -79,14 +79,22 @@ class NumberFormatterImpl : public UMemory {
* Synthesizes the output string from a MicroProps and DecimalQuantity.
* This method formats only the main number, not affixes.
*/
- static int32_t writeNumber(const MicroProps& micros, DecimalQuantity& quantity,
- FormattedStringBuilder& string, int32_t index, UErrorCode& status);
+ static int32_t writeNumber(
+ const SimpleMicroProps& micros,
+ DecimalQuantity& quantity,
+ FormattedStringBuilder& string,
+ int32_t index,
+ UErrorCode& status);
/**
* Adds the affixes. Intended to be called immediately after formatNumber.
*/
- static int32_t writeAffixes(const MicroProps& micros, FormattedStringBuilder& string, int32_t start,
- int32_t end, UErrorCode& status);
+ static int32_t writeAffixes(
+ const MicroProps& micros,
+ FormattedStringBuilder& string,
+ int32_t start,
+ int32_t end,
+ UErrorCode& status);
private:
// Head of the MicroPropsGenerator linked list. Subclasses' processQuantity
@@ -146,12 +154,20 @@ class NumberFormatterImpl : public UMemory {
macrosToMicroGenerator(const MacroProps &macros, bool safe, UErrorCode &status);
static int32_t
- writeIntegerDigits(const MicroProps &micros, DecimalQuantity &quantity, FormattedStringBuilder &string,
- int32_t index, UErrorCode &status);
+ writeIntegerDigits(
+ const SimpleMicroProps& micros,
+ DecimalQuantity &quantity,
+ FormattedStringBuilder &string,
+ int32_t index,
+ UErrorCode &status);
static int32_t
- writeFractionDigits(const MicroProps &micros, DecimalQuantity &quantity, FormattedStringBuilder &string,
- int32_t index, UErrorCode &status);
+ writeFractionDigits(
+ const SimpleMicroProps& micros,
+ DecimalQuantity &quantity,
+ FormattedStringBuilder &string,
+ int32_t index,
+ UErrorCode &status);
};
} // namespace impl
diff --git a/contrib/libs/icu/i18n/number_grouping.cpp b/contrib/libs/icu/i18n/number_grouping.cpp
index 9ba639e67e..54aeffee81 100644
--- a/contrib/libs/icu/i18n/number_grouping.cpp
+++ b/contrib/libs/icu/i18n/number_grouping.cpp
@@ -18,7 +18,7 @@ namespace {
int16_t getMinGroupingForLocale(const Locale& locale) {
// TODO: Cache this?
UErrorCode localStatus = U_ZERO_ERROR;
- LocalUResourceBundlePointer bundle(ures_open(NULL, locale.getName(), &localStatus));
+ LocalUResourceBundlePointer bundle(ures_open(nullptr, locale.getName(), &localStatus));
int32_t resultLen = 0;
const char16_t* result = ures_getStringByKeyWithFallback(
bundle.getAlias(),
diff --git a/contrib/libs/icu/i18n/number_longnames.cpp b/contrib/libs/icu/i18n/number_longnames.cpp
index 5a4cf6321c..96c6ca6bf8 100644
--- a/contrib/libs/icu/i18n/number_longnames.cpp
+++ b/contrib/libs/icu/i18n/number_longnames.cpp
@@ -151,7 +151,7 @@ enum PlaceholderPosition { PH_EMPTY, PH_NONE, PH_BEGINNING, PH_MIDDLE, PH_END };
void extractCorePattern(const UnicodeString &pattern,
UnicodeString &coreUnit,
PlaceholderPosition &placeholderPosition,
- UChar &joinerChar) {
+ char16_t &joinerChar) {
joinerChar = 0;
int32_t len = pattern.length();
if (pattern.startsWith(u"{0}", 3)) {
@@ -209,7 +209,7 @@ getGenderForBuiltin(const Locale &locale, const MeasureUnit &builtinUnit, UError
UErrorCode localStatus = status;
int32_t resultLen = 0;
- const UChar *result =
+ const char16_t *result =
ures_getStringByKeyWithFallback(unitsBundle.getAlias(), key.data(), &resultLen, &localStatus);
if (U_SUCCESS(localStatus)) {
status = localStatus;
@@ -258,7 +258,7 @@ class InflectedPluralSink : public ResourceSink {
}
// See ResourceSink::put().
- void put(const char *key, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) U_OVERRIDE {
+ void put(const char *key, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) override {
int32_t pluralIndex = getIndex(key, status);
if (U_FAILURE(status)) { return; }
if (!outArray[pluralIndex].isBogus()) {
@@ -384,7 +384,7 @@ class PluralTableSink : public ResourceSink {
}
}
- void put(const char *key, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) U_OVERRIDE {
+ void put(const char *key, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) override {
if (uprv_strcmp(key, "case") == 0) {
return;
}
@@ -431,13 +431,33 @@ void getMeasureData(const Locale &locale,
subKey.append(unit.getType(), status);
subKey.append("/", status);
+ // Check if unitSubType is an alias or not.
+ LocalUResourceBundlePointer aliasBundle(ures_open(U_ICUDATA_ALIAS, "metadata", &status));
+
+ UErrorCode aliasStatus = status;
+ StackUResourceBundle aliasFillIn;
+ CharString aliasKey;
+ aliasKey.append("alias/unit/", aliasStatus);
+ aliasKey.append(unit.getSubtype(), aliasStatus);
+ aliasKey.append("/replacement", aliasStatus);
+ ures_getByKeyWithFallback(aliasBundle.getAlias(), aliasKey.data(), aliasFillIn.getAlias(),
+ &aliasStatus);
+ CharString unitSubType;
+ if (!U_FAILURE(aliasStatus)) {
+ // This means the subType is an alias. Then, replace unitSubType with the replacement.
+ auto replacement = ures_getUnicodeString(aliasFillIn.getAlias(), &status);
+ unitSubType.appendInvariantChars(replacement, status);
+ } else {
+ unitSubType.append(unit.getSubtype(), status);
+ }
+
// Map duration-year-person, duration-week-person, etc. to duration-year, duration-week, ...
// TODO(ICU-20400): Get duration-*-person data properly with aliases.
- int32_t subtypeLen = static_cast<int32_t>(uprv_strlen(unit.getSubtype()));
- if (subtypeLen > 7 && uprv_strcmp(unit.getSubtype() + subtypeLen - 7, "-person") == 0) {
- subKey.append({unit.getSubtype(), subtypeLen - 7}, status);
+ int32_t subtypeLen = static_cast<int32_t>(uprv_strlen(unitSubType.data()));
+ if (subtypeLen > 7 && uprv_strcmp(unitSubType.data() + subtypeLen - 7, "-person") == 0) {
+ subKey.append({unitSubType.data(), subtypeLen - 7}, status);
} else {
- subKey.append({unit.getSubtype(), subtypeLen}, status);
+ subKey.append({unitSubType.data(), subtypeLen}, status);
}
if (width != UNUM_UNIT_WIDTH_FULL_NAME) {
@@ -540,7 +560,7 @@ UnicodeString getCompoundValue(StringPiece compoundKey,
UErrorCode localStatus = status;
int32_t len = 0;
- const UChar *ptr =
+ const char16_t *ptr =
ures_getStringByKeyWithFallback(unitsBundle.getAlias(), key.data(), &len, &localStatus);
if (U_FAILURE(localStatus) && width != UNUM_UNIT_WIDTH_SHORT) {
// Fall back to short, which contains more compound data
@@ -586,7 +606,7 @@ class DerivedComponents {
*/
DerivedComponents(const Locale &locale, const char *feature, const char *structure) {
StackUResourceBundle derivationsBundle, stackBundle;
- ures_openDirectFillIn(derivationsBundle.getAlias(), NULL, "grammaticalFeatures", &status);
+ ures_openDirectFillIn(derivationsBundle.getAlias(), nullptr, "grammaticalFeatures", &status);
ures_getByKey(derivationsBundle.getAlias(), "grammaticalData", derivationsBundle.getAlias(),
&status);
ures_getByKey(derivationsBundle.getAlias(), "derivations", derivationsBundle.getAlias(),
@@ -675,7 +695,7 @@ class DerivedComponents {
UnicodeString
getDeriveCompoundRule(Locale locale, const char *feature, const char *structure, UErrorCode &status) {
StackUResourceBundle derivationsBundle, stackBundle;
- ures_openDirectFillIn(derivationsBundle.getAlias(), NULL, "grammaticalFeatures", &status);
+ ures_openDirectFillIn(derivationsBundle.getAlias(), nullptr, "grammaticalFeatures", &status);
ures_getByKey(derivationsBundle.getAlias(), "grammaticalData", derivationsBundle.getAlias(),
&status);
ures_getByKey(derivationsBundle.getAlias(), "derivations", derivationsBundle.getAlias(), &status);
@@ -739,7 +759,7 @@ UnicodeString getDerivedGender(Locale locale,
////////////////////////
// TODO: promote this somewhere? It's based on patternprops.cpp' trimWhitespace
-const UChar *trimSpaceChars(const UChar *s, int32_t &length) {
+const char16_t *trimSpaceChars(const char16_t *s, int32_t &length) {
if (length <= 0 || (!u_isJavaSpaceChar(s[0]) && !u_isJavaSpaceChar(s[length - 1]))) {
return s;
}
@@ -1033,7 +1053,7 @@ void LongNameHandler::forArbitraryUnit(const Locale &loc,
}
UnicodeString denominatorPattern = denominatorFormatter.getTextWithNoArguments();
int32_t trimmedLen = denominatorPattern.length();
- const UChar *trimmed = trimSpaceChars(denominatorPattern.getBuffer(), trimmedLen);
+ const char16_t *trimmed = trimSpaceChars(denominatorPattern.getBuffer(), trimmedLen);
UnicodeString denominatorString(false, trimmed, trimmedLen);
// 9. If the denominatorString is empty, set result to
// [numeratorString], otherwise set result to format(perPattern,
@@ -1124,7 +1144,7 @@ void LongNameHandler::processPatternTimes(MeasureUnitImpl &&productUnit,
}
PlaceholderPosition globalPlaceholder[ARRAY_LENGTH];
- UChar globalJoinerChar = 0;
+ char16_t globalJoinerChar = 0;
// Numbered list items are from the algorithms at
// https://unicode.org/reports/tr35/tr35-general.html#compound-units:
//
@@ -1321,7 +1341,7 @@ void LongNameHandler::processPatternTimes(MeasureUnitImpl &&productUnit,
// 4.6. Extract(corePattern, coreUnit, placeholder, placeholderPosition) from that pattern.
UnicodeString coreUnit;
PlaceholderPosition placeholderPosition;
- UChar joinerChar;
+ char16_t joinerChar;
extractCorePattern(getWithPlural(singleUnitArray, plural, status), coreUnit,
placeholderPosition, joinerChar);
@@ -1509,7 +1529,7 @@ void LongNameHandler::multiSimpleFormatsToModifiers(const UnicodeString *leadFor
void LongNameHandler::processQuantity(DecimalQuantity &quantity, MicroProps &micros,
UErrorCode &status) const {
- if (parent != NULL) {
+ if (parent != nullptr) {
parent->processQuantity(quantity, micros, status);
}
StandardPlural::Form pluralForm = utils::getPluralSafe(micros.rounder, rules, quantity, status);
@@ -1549,7 +1569,7 @@ void MixedUnitLongNameHandler::forMeasureUnit(const Locale &loc,
for (int32_t i = 0; i < fillIn->fMixedUnitCount; i++) {
// Grab data for each of the components.
UnicodeString *unitData = &fillIn->fMixedUnitData[i * ARRAY_LENGTH];
- // TODO(CLDR-14502): check from the CLDR-14502 ticket whether this
+ // TODO(CLDR-14582): check from the CLDR-14582 ticket whether this
// propagation of unitDisplayCase is correct:
getMeasureData(loc, impl.singleUnits[i]->build(status), width, unitDisplayCase, unitData,
status);
@@ -1706,12 +1726,12 @@ LongNameMultiplexer *LongNameMultiplexer::forMeasureUnits(const Locale &loc,
result->fMeasureUnits[i] = unit;
if (unit.getComplexity(status) == UMEASURE_UNIT_MIXED) {
MixedUnitLongNameHandler *mlnh = result->fMixedUnitHandlers.createAndCheckErrorCode(status);
- MixedUnitLongNameHandler::forMeasureUnit(loc, unit, width, unitDisplayCase, rules, NULL,
+ MixedUnitLongNameHandler::forMeasureUnit(loc, unit, width, unitDisplayCase, rules, nullptr,
mlnh, status);
result->fHandlers[i] = mlnh;
} else {
LongNameHandler *lnh = result->fLongNameHandlers.createAndCheckErrorCode(status);
- LongNameHandler::forMeasureUnit(loc, unit, width, unitDisplayCase, rules, NULL, lnh, status);
+ LongNameHandler::forMeasureUnit(loc, unit, width, unitDisplayCase, rules, nullptr, lnh, status);
result->fHandlers[i] = lnh;
}
if (U_FAILURE(status)) {
diff --git a/contrib/libs/icu/i18n/number_longnames.h b/contrib/libs/icu/i18n/number_longnames.h
index 06949989d7..56d8c9b24e 100644
--- a/contrib/libs/icu/i18n/number_longnames.h
+++ b/contrib/libs/icu/i18n/number_longnames.h
@@ -71,9 +71,9 @@ class LongNameHandler : public MicroPropsGenerator, public ModifierStore, public
* on the plural form.
*/
void
- processQuantity(DecimalQuantity &quantity, MicroProps &micros, UErrorCode &status) const U_OVERRIDE;
+ processQuantity(DecimalQuantity &quantity, MicroProps &micros, UErrorCode &status) const override;
- const Modifier* getModifier(Signum signum, StandardPlural::Form plural) const U_OVERRIDE;
+ const Modifier* getModifier(Signum signum, StandardPlural::Form plural) const override;
private:
// A set of pre-computed modifiers, one for each plural form.
@@ -168,12 +168,12 @@ class MixedUnitLongNameHandler : public MicroPropsGenerator, public ModifierStor
* provided via `micros.mixedMeasures`.
*/
void processQuantity(DecimalQuantity &quantity, MicroProps &micros,
- UErrorCode &status) const U_OVERRIDE;
+ UErrorCode &status) const 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;
+ const Modifier *getModifier(Signum signum, StandardPlural::Form plural) const override;
private:
// Not owned
@@ -241,7 +241,7 @@ class LongNameMultiplexer : public MicroPropsGenerator, public UMemory {
// 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;
+ UErrorCode &status) const override;
private:
/**
diff --git a/contrib/libs/icu/i18n/number_mapper.cpp b/contrib/libs/icu/i18n/number_mapper.cpp
index 2d4d47a094..2f398d4a93 100644
--- a/contrib/libs/icu/i18n/number_mapper.cpp
+++ b/contrib/libs/icu/i18n/number_mapper.cpp
@@ -134,7 +134,8 @@ MacroProps NumberPropertyMapper::oldToNew(const DecimalFormatProperties& propert
if (PatternStringUtils::ignoreRoundingIncrement(roundingIncrement, maxFrac)) {
precision = Precision::constructFraction(minFrac, maxFrac);
} else {
- precision = Precision::constructIncrement(roundingIncrement, minFrac);
+ // Convert the double increment to an integer increment
+ precision = Precision::increment(roundingIncrement).withMinFraction(minFrac);
}
} else if (explicitMinMaxSig) {
minSig = minSig < 1 ? 1 : minSig > kMaxIntFracSig ? kMaxIntFracSig : minSig;
@@ -255,8 +256,6 @@ MacroProps NumberPropertyMapper::oldToNew(const DecimalFormatProperties& propert
} else {
macros.notation = Notation::compactShort();
}
- // Do not forward the affix provider.
- macros.affixProvider = nullptr;
}
/////////////////
@@ -293,9 +292,14 @@ MacroProps NumberPropertyMapper::oldToNew(const DecimalFormatProperties& propert
} else if (rounding_.fType == Precision::PrecisionType::RND_INCREMENT
|| rounding_.fType == Precision::PrecisionType::RND_INCREMENT_ONE
|| rounding_.fType == Precision::PrecisionType::RND_INCREMENT_FIVE) {
- increment_ = rounding_.fUnion.increment.fIncrement;
minFrac_ = rounding_.fUnion.increment.fMinFrac;
+ // If incrementRounding is used, maxFrac is set equal to minFrac
maxFrac_ = rounding_.fUnion.increment.fMinFrac;
+ // Convert the integer increment to a double
+ DecimalQuantity dq;
+ dq.setToLong(rounding_.fUnion.increment.fIncrement);
+ dq.adjustMagnitude(rounding_.fUnion.increment.fIncrementMagnitude);
+ increment_ = dq.toDouble();
} else if (rounding_.fType == Precision::PrecisionType::RND_SIGNIFICANT) {
minSig_ = rounding_.fUnion.fracSig.fMinSig;
maxSig_ = rounding_.fUnion.fracSig.fMaxSig;
diff --git a/contrib/libs/icu/i18n/number_mapper.h b/contrib/libs/icu/i18n/number_mapper.h
index 8879b7a94e..c01607e568 100644
--- a/contrib/libs/icu/i18n/number_mapper.h
+++ b/contrib/libs/icu/i18n/number_mapper.h
@@ -38,25 +38,25 @@ class PropertiesAffixPatternProvider : public AffixPatternProvider, public UMemo
// AffixPatternProvider Methods:
- char16_t charAt(int32_t flags, int32_t i) const U_OVERRIDE;
+ char16_t charAt(int32_t flags, int32_t i) const override;
- int32_t length(int32_t flags) const U_OVERRIDE;
+ int32_t length(int32_t flags) const override;
- UnicodeString getString(int32_t flags) const U_OVERRIDE;
+ UnicodeString getString(int32_t flags) const override;
- bool hasCurrencySign() const U_OVERRIDE;
+ bool hasCurrencySign() const override;
- bool positiveHasPlusSign() const U_OVERRIDE;
+ bool positiveHasPlusSign() const override;
- bool hasNegativeSubpattern() const U_OVERRIDE;
+ bool hasNegativeSubpattern() const override;
- bool negativeHasMinusSign() const U_OVERRIDE;
+ bool negativeHasMinusSign() const override;
- bool containsSymbolType(AffixPatternType, UErrorCode&) const U_OVERRIDE;
+ bool containsSymbolType(AffixPatternType, UErrorCode&) const override;
- bool hasBody() const U_OVERRIDE;
+ bool hasBody() const override;
- bool currencyAsDecimal() const U_OVERRIDE;
+ bool currencyAsDecimal() const override;
private:
UnicodeString posPrefix;
@@ -92,25 +92,25 @@ class CurrencyPluralInfoAffixProvider : public AffixPatternProvider, public UMem
// AffixPatternProvider Methods:
- char16_t charAt(int32_t flags, int32_t i) const U_OVERRIDE;
+ char16_t charAt(int32_t flags, int32_t i) const override;
- int32_t length(int32_t flags) const U_OVERRIDE;
+ int32_t length(int32_t flags) const override;
- UnicodeString getString(int32_t flags) const U_OVERRIDE;
+ UnicodeString getString(int32_t flags) const override;
- bool hasCurrencySign() const U_OVERRIDE;
+ bool hasCurrencySign() const override;
- bool positiveHasPlusSign() const U_OVERRIDE;
+ bool positiveHasPlusSign() const override;
- bool hasNegativeSubpattern() const U_OVERRIDE;
+ bool hasNegativeSubpattern() const override;
- bool negativeHasMinusSign() const U_OVERRIDE;
+ bool negativeHasMinusSign() const override;
- bool containsSymbolType(AffixPatternType, UErrorCode&) const U_OVERRIDE;
+ bool containsSymbolType(AffixPatternType, UErrorCode&) const override;
- bool hasBody() const U_OVERRIDE;
+ bool hasBody() const override;
- bool currencyAsDecimal() const U_OVERRIDE;
+ bool currencyAsDecimal() const override;
private:
PropertiesAffixPatternProvider affixesByPlural[StandardPlural::COUNT];
diff --git a/contrib/libs/icu/i18n/number_microprops.h b/contrib/libs/icu/i18n/number_microprops.h
index c34e7c17e9..18addaae08 100644
--- a/contrib/libs/icu/i18n/number_microprops.h
+++ b/contrib/libs/icu/i18n/number_microprops.h
@@ -67,33 +67,39 @@ class IntMeasures : public MaybeStackArray<int64_t, 2> {
UErrorCode status = U_ZERO_ERROR;
};
+struct SimpleMicroProps : public UMemory {
+ Grouper grouping;
+ bool useCurrency = false;
+ UNumberDecimalSeparatorDisplay decimal = UNUM_DECIMAL_SEPARATOR_AUTO;
+
+ // Currency symbol to be used as the decimal separator
+ UnicodeString currencyAsDecimal = ICU_Utility::makeBogusString();
+
+ // Note: This struct has no direct ownership of the following pointer.
+ const DecimalFormatSymbols* symbols = nullptr;
+};
+
/**
* 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 {
+ SimpleMicroProps simple;
// NOTE: All of these fields are properly initialized in NumberFormatterImpl.
RoundingImpl rounder;
- Grouper grouping;
Padder padding;
IntegerWidth integerWidth;
UNumberSignDisplay sign;
- UNumberDecimalSeparatorDisplay decimal;
- bool useCurrency;
char nsName[9];
- // Currency symbol to be used as the decimal separator
- UnicodeString currencyAsDecimal = ICU_Utility::makeBogusString();
-
// No ownership: must point at a string which will outlive MicroProps
// instances, e.g. a string with static storage duration, or just a string
// that will never be deallocated or modified.
const char *gender;
// 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):
@@ -162,7 +168,7 @@ struct MicroProps : public MicroPropsGenerator {
* not already `*this`, it will be overwritten with a copy of `*this`.
*/
void processQuantity(DecimalQuantity &quantity, MicroProps &micros,
- UErrorCode &status) const U_OVERRIDE {
+ UErrorCode &status) const override {
(void) quantity;
(void) status;
if (this == &micros) {
diff --git a/contrib/libs/icu/i18n/number_modifiers.cpp b/contrib/libs/icu/i18n/number_modifiers.cpp
index b74bfd06fc..0f6fdafb09 100644
--- a/contrib/libs/icu/i18n/number_modifiers.cpp
+++ b/contrib/libs/icu/i18n/number_modifiers.cpp
@@ -22,7 +22,7 @@ const int32_t ARG_NUM_LIMIT = 0x100;
// These are the default currency spacing UnicodeSets in CLDR.
// Pre-compute them for performance.
// The Java unit test testCurrencySpacingPatternStability() will start failing if these change in CLDR.
-icu::UInitOnce gDefaultCurrencySpacingInitOnce = U_INITONCE_INITIALIZER;
+icu::UInitOnce gDefaultCurrencySpacingInitOnce {};
UnicodeSet *UNISET_DIGIT = nullptr;
UnicodeSet *UNISET_NOTSZ = nullptr;
@@ -33,7 +33,7 @@ UBool U_CALLCONV cleanupDefaultCurrencySpacing() {
delete UNISET_NOTSZ;
UNISET_NOTSZ = nullptr;
gDefaultCurrencySpacingInitOnce.reset();
- return TRUE;
+ return true;
}
void U_CALLCONV initDefaultCurrencySpacing(UErrorCode &status) {
@@ -62,12 +62,21 @@ Modifier::Parameters::Parameters(
ModifierStore::~ModifierStore() = default;
-AdoptingModifierStore::~AdoptingModifierStore() {
+AdoptingSignumModifierStore::~AdoptingSignumModifierStore() {
for (const Modifier *mod : mods) {
delete mod;
}
}
+AdoptingSignumModifierStore&
+AdoptingSignumModifierStore::operator=(AdoptingSignumModifierStore&& other) noexcept {
+ for (size_t i=0; i<SIGNUM_COUNT; i++) {
+ this->mods[i] = other.mods[i];
+ other.mods[i] = nullptr;
+ }
+ return *this;
+}
+
int32_t ConstantAffixModifier::apply(FormattedStringBuilder &output, int leftIndex, int rightIndex,
UErrorCode &status) const {
diff --git a/contrib/libs/icu/i18n/number_modifiers.h b/contrib/libs/icu/i18n/number_modifiers.h
index 09af3f4881..da6956bcfb 100644
--- a/contrib/libs/icu/i18n/number_modifiers.h
+++ b/contrib/libs/icu/i18n/number_modifiers.h
@@ -29,19 +29,19 @@ class U_I18N_API ConstantAffixModifier : public Modifier, public UObject {
: fPrefix(prefix), fSuffix(suffix), fField(field), fStrong(strong) {}
int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex,
- UErrorCode &status) const U_OVERRIDE;
+ UErrorCode &status) const override;
- int32_t getPrefixLength() const U_OVERRIDE;
+ int32_t getPrefixLength() const override;
- int32_t getCodePointCount() const U_OVERRIDE;
+ int32_t getCodePointCount() const override;
- bool isStrong() const U_OVERRIDE;
+ bool isStrong() const override;
- bool containsField(Field field) const U_OVERRIDE;
+ bool containsField(Field field) const override;
- void getParameters(Parameters& output) const U_OVERRIDE;
+ void getParameters(Parameters& output) const override;
- bool semanticallyEquivalent(const Modifier& other) const U_OVERRIDE;
+ bool semanticallyEquivalent(const Modifier& other) const override;
private:
UnicodeString fPrefix;
@@ -65,19 +65,19 @@ class U_I18N_API SimpleModifier : public Modifier, public UMemory {
SimpleModifier();
int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex,
- UErrorCode &status) const U_OVERRIDE;
+ UErrorCode &status) const override;
- int32_t getPrefixLength() const U_OVERRIDE;
+ int32_t getPrefixLength() const override;
- int32_t getCodePointCount() const U_OVERRIDE;
+ int32_t getCodePointCount() const override;
- bool isStrong() const U_OVERRIDE;
+ bool isStrong() const override;
- bool containsField(Field field) const U_OVERRIDE;
+ bool containsField(Field field) const override;
- void getParameters(Parameters& output) const U_OVERRIDE;
+ void getParameters(Parameters& output) const override;
- bool semanticallyEquivalent(const Modifier& other) const U_OVERRIDE;
+ bool semanticallyEquivalent(const Modifier& other) const override;
/**
* TODO: This belongs in SimpleFormatterImpl. The only reason I haven't moved it there yet is because
@@ -158,19 +158,19 @@ class U_I18N_API ConstantMultiFieldModifier : public Modifier, public UMemory {
fStrong(strong) {}
int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex,
- UErrorCode &status) const U_OVERRIDE;
+ UErrorCode &status) const override;
- int32_t getPrefixLength() const U_OVERRIDE;
+ int32_t getPrefixLength() const override;
- int32_t getCodePointCount() const U_OVERRIDE;
+ int32_t getCodePointCount() const override;
- bool isStrong() const U_OVERRIDE;
+ bool isStrong() const override;
- bool containsField(Field field) const U_OVERRIDE;
+ bool containsField(Field field) const override;
- void getParameters(Parameters& output) const U_OVERRIDE;
+ void getParameters(Parameters& output) const override;
- bool semanticallyEquivalent(const Modifier& other) const U_OVERRIDE;
+ bool semanticallyEquivalent(const Modifier& other) const override;
protected:
// NOTE: In Java, these are stored as array pointers. In C++, the FormattedStringBuilder is stored by
@@ -195,7 +195,7 @@ class U_I18N_API CurrencySpacingEnabledModifier : public ConstantMultiFieldModif
UErrorCode &status);
int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex,
- UErrorCode &status) const U_OVERRIDE;
+ UErrorCode &status) const override;
/** Unsafe code path */
static int32_t
@@ -235,7 +235,7 @@ class U_I18N_API EmptyModifier : public Modifier, public UMemory {
explicit EmptyModifier(bool isStrong) : fStrong(isStrong) {}
int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex,
- UErrorCode &status) const U_OVERRIDE {
+ UErrorCode &status) const override {
(void)output;
(void)leftIndex;
(void)rightIndex;
@@ -243,28 +243,28 @@ class U_I18N_API EmptyModifier : public Modifier, public UMemory {
return 0;
}
- int32_t getPrefixLength() const U_OVERRIDE {
+ int32_t getPrefixLength() const override {
return 0;
}
- int32_t getCodePointCount() const U_OVERRIDE {
+ int32_t getCodePointCount() const override {
return 0;
}
- bool isStrong() const U_OVERRIDE {
+ bool isStrong() const override {
return fStrong;
}
- bool containsField(Field field) const U_OVERRIDE {
+ bool containsField(Field field) const override {
(void)field;
return false;
}
- void getParameters(Parameters& output) const U_OVERRIDE {
+ void getParameters(Parameters& output) const override {
output.obj = nullptr;
}
- bool semanticallyEquivalent(const Modifier& other) const U_OVERRIDE {
+ bool semanticallyEquivalent(const Modifier& other) const override {
return other.getCodePointCount() == 0;
}
@@ -272,13 +272,45 @@ class U_I18N_API EmptyModifier : public Modifier, public UMemory {
bool fStrong;
};
+/** An adopting Modifier store that varies by signum but not plural form. */
+class U_I18N_API AdoptingSignumModifierStore : public UMemory {
+ public:
+ virtual ~AdoptingSignumModifierStore();
+
+ AdoptingSignumModifierStore() = default;
+
+ // No copying!
+ AdoptingSignumModifierStore(const AdoptingSignumModifierStore &other) = delete;
+ AdoptingSignumModifierStore& operator=(const AdoptingSignumModifierStore& other) = delete;
+
+ // Moving is OK
+ AdoptingSignumModifierStore(AdoptingSignumModifierStore &&other) noexcept {
+ *this = std::move(other);
+ }
+ AdoptingSignumModifierStore& operator=(AdoptingSignumModifierStore&& other) noexcept;
+
+ /** Take ownership of the Modifier and slot it in at the given Signum. */
+ void adoptModifier(Signum signum, const Modifier* mod) {
+ U_ASSERT(mods[signum] == nullptr);
+ mods[signum] = mod;
+ }
+
+ inline const Modifier*& operator[](Signum signum) {
+ return mods[signum];
+ }
+ inline Modifier const* operator[](Signum signum) const {
+ return mods[signum];
+ }
+
+ private:
+ const Modifier* mods[SIGNUM_COUNT] = {};
+};
+
/**
* This implementation of ModifierStore adopts Modifier pointers.
*/
class U_I18N_API AdoptingModifierStore : public ModifierStore, public UMemory {
public:
- virtual ~AdoptingModifierStore();
-
static constexpr StandardPlural::Form DEFAULT_STANDARD_PLURAL = StandardPlural::OTHER;
AdoptingModifierStore() = default;
@@ -286,46 +318,36 @@ class U_I18N_API AdoptingModifierStore : public ModifierStore, public UMemory {
// No copying!
AdoptingModifierStore(const AdoptingModifierStore &other) = delete;
- /**
- * Sets the Modifier with the specified signum and plural form.
- */
- void adoptModifier(Signum signum, StandardPlural::Form plural, const Modifier *mod) {
- U_ASSERT(mods[getModIndex(signum, plural)] == nullptr);
- mods[getModIndex(signum, plural)] = mod;
+ // Moving is OK
+ AdoptingModifierStore(AdoptingModifierStore &&other) = default;
+
+ /** Sets the modifiers for a specific plural form. */
+ void adoptSignumModifierStore(StandardPlural::Form plural, AdoptingSignumModifierStore other) {
+ mods[plural] = std::move(other);
}
- /**
- * Sets the Modifier with the specified signum.
- * The modifier will apply to all plural forms.
- */
- void adoptModifierWithoutPlural(Signum signum, const Modifier *mod) {
- U_ASSERT(mods[getModIndex(signum, DEFAULT_STANDARD_PLURAL)] == nullptr);
- mods[getModIndex(signum, DEFAULT_STANDARD_PLURAL)] = mod;
+ /** Sets the modifiers for the default plural form. */
+ void adoptSignumModifierStoreNoPlural(AdoptingSignumModifierStore other) {
+ mods[DEFAULT_STANDARD_PLURAL] = std::move(other);
}
/** Returns a reference to the modifier; no ownership change. */
- const Modifier *getModifier(Signum signum, StandardPlural::Form plural) const U_OVERRIDE {
- const Modifier* modifier = mods[getModIndex(signum, plural)];
+ const Modifier *getModifier(Signum signum, StandardPlural::Form plural) const override {
+ const Modifier* modifier = mods[plural][signum];
if (modifier == nullptr && plural != DEFAULT_STANDARD_PLURAL) {
- modifier = mods[getModIndex(signum, DEFAULT_STANDARD_PLURAL)];
+ modifier = mods[DEFAULT_STANDARD_PLURAL][signum];
}
return modifier;
}
/** Returns a reference to the modifier; no ownership change. */
const Modifier *getModifierWithoutPlural(Signum signum) const {
- return mods[getModIndex(signum, DEFAULT_STANDARD_PLURAL)];
+ return mods[DEFAULT_STANDARD_PLURAL][signum];
}
private:
// NOTE: mods is zero-initialized (to nullptr)
- const Modifier *mods[4 * StandardPlural::COUNT] = {};
-
- inline static int32_t getModIndex(Signum signum, StandardPlural::Form plural) {
- U_ASSERT(signum >= 0 && signum < SIGNUM_COUNT);
- U_ASSERT(plural >= 0 && plural < StandardPlural::COUNT);
- return static_cast<int32_t>(plural) * SIGNUM_COUNT + signum;
- }
+ AdoptingSignumModifierStore mods[StandardPlural::COUNT] = {};
};
} // namespace impl
diff --git a/contrib/libs/icu/i18n/number_multiplier.cpp b/contrib/libs/icu/i18n/number_multiplier.cpp
index 58e1e441bd..dd5b3f8e06 100644
--- a/contrib/libs/icu/i18n/number_multiplier.cpp
+++ b/contrib/libs/icu/i18n/number_multiplier.cpp
@@ -58,13 +58,13 @@ Scale& Scale::operator=(const Scale& other) {
return *this;
}
-Scale::Scale(Scale&& src) U_NOEXCEPT
+Scale::Scale(Scale&& src) noexcept
: fMagnitude(src.fMagnitude), fArbitrary(src.fArbitrary), fError(src.fError) {
// Take ownership away from src if necessary
src.fArbitrary = nullptr;
}
-Scale& Scale::operator=(Scale&& src) U_NOEXCEPT {
+Scale& Scale::operator=(Scale&& src) noexcept {
fMagnitude = src.fMagnitude;
if (fArbitrary != nullptr) {
delete fArbitrary;
diff --git a/contrib/libs/icu/i18n/number_multiplier.h b/contrib/libs/icu/i18n/number_multiplier.h
index d8235dc601..c752935b78 100644
--- a/contrib/libs/icu/i18n/number_multiplier.h
+++ b/contrib/libs/icu/i18n/number_multiplier.h
@@ -25,7 +25,7 @@ class U_I18N_API MultiplierFormatHandler : public MicroPropsGenerator, public UM
void setAndChain(const Scale& multiplier, const MicroPropsGenerator* parent);
void processQuantity(DecimalQuantity& quantity, MicroProps& micros,
- UErrorCode& status) const U_OVERRIDE;
+ UErrorCode& status) const override;
private:
Scale fMultiplier;
diff --git a/contrib/libs/icu/i18n/number_output.cpp b/contrib/libs/icu/i18n/number_output.cpp
index 2c2c25eaed..729a2cd5e6 100644
--- a/contrib/libs/icu/i18n/number_output.cpp
+++ b/contrib/libs/icu/i18n/number_output.cpp
@@ -39,9 +39,10 @@ MeasureUnit FormattedNumber::getOutputUnit(UErrorCode& status) const {
return fData->outputUnit;
}
-const char *FormattedNumber::getGender(UErrorCode &status) const {
- UPRV_FORMATTED_VALUE_METHOD_GUARD("")
- return fData->gender;
+UDisplayOptionsNounClass FormattedNumber::getNounClass(UErrorCode &status) const {
+ UPRV_FORMATTED_VALUE_METHOD_GUARD(UDISPOPT_NOUN_CLASS_UNDEFINED);
+ const char *nounClass = fData->gender;
+ return udispopt_fromNounClassIdentifier(nounClass);
}
void FormattedNumber::getDecimalQuantity(impl::DecimalQuantity& output, UErrorCode& status) const {
diff --git a/contrib/libs/icu/i18n/number_patternmodifier.cpp b/contrib/libs/icu/i18n/number_patternmodifier.cpp
index b6543b262b..6f398c6acf 100644
--- a/contrib/libs/icu/i18n/number_patternmodifier.cpp
+++ b/contrib/libs/icu/i18n/number_patternmodifier.cpp
@@ -60,6 +60,21 @@ bool MutablePatternModifier::needsPlurals() const {
// Silently ignore any error codes.
}
+AdoptingSignumModifierStore MutablePatternModifier::createImmutableForPlural(StandardPlural::Form plural, UErrorCode& status) {
+ AdoptingSignumModifierStore pm;
+
+ setNumberProperties(SIGNUM_POS, plural);
+ pm.adoptModifier(SIGNUM_POS, createConstantModifier(status));
+ setNumberProperties(SIGNUM_NEG_ZERO, plural);
+ pm.adoptModifier(SIGNUM_NEG_ZERO, createConstantModifier(status));
+ setNumberProperties(SIGNUM_POS_ZERO, plural);
+ pm.adoptModifier(SIGNUM_POS_ZERO, createConstantModifier(status));
+ setNumberProperties(SIGNUM_NEG, plural);
+ pm.adoptModifier(SIGNUM_NEG, createConstantModifier(status));
+
+ return pm;
+}
+
ImmutablePatternModifier* MutablePatternModifier::createImmutable(UErrorCode& status) {
// TODO: Move StandardPlural VALUES to standardplural.h
static const StandardPlural::Form STANDARD_PLURAL_VALUES[] = {
@@ -79,14 +94,7 @@ ImmutablePatternModifier* MutablePatternModifier::createImmutable(UErrorCode& st
if (needsPlurals()) {
// Slower path when we require the plural keyword.
for (StandardPlural::Form plural : STANDARD_PLURAL_VALUES) {
- setNumberProperties(SIGNUM_POS, plural);
- pm->adoptModifier(SIGNUM_POS, plural, createConstantModifier(status));
- setNumberProperties(SIGNUM_NEG_ZERO, plural);
- pm->adoptModifier(SIGNUM_NEG_ZERO, plural, createConstantModifier(status));
- setNumberProperties(SIGNUM_POS_ZERO, plural);
- pm->adoptModifier(SIGNUM_POS_ZERO, plural, createConstantModifier(status));
- setNumberProperties(SIGNUM_NEG, plural);
- pm->adoptModifier(SIGNUM_NEG, plural, createConstantModifier(status));
+ pm->adoptSignumModifierStore(plural, createImmutableForPlural(plural, status));
}
if (U_FAILURE(status)) {
delete pm;
@@ -95,14 +103,7 @@ ImmutablePatternModifier* MutablePatternModifier::createImmutable(UErrorCode& st
return new ImmutablePatternModifier(pm, fRules); // adopts pm
} else {
// Faster path when plural keyword is not needed.
- setNumberProperties(SIGNUM_POS, StandardPlural::Form::COUNT);
- pm->adoptModifierWithoutPlural(SIGNUM_POS, createConstantModifier(status));
- setNumberProperties(SIGNUM_NEG_ZERO, StandardPlural::Form::COUNT);
- pm->adoptModifierWithoutPlural(SIGNUM_NEG_ZERO, createConstantModifier(status));
- setNumberProperties(SIGNUM_POS_ZERO, StandardPlural::Form::COUNT);
- pm->adoptModifierWithoutPlural(SIGNUM_POS_ZERO, createConstantModifier(status));
- setNumberProperties(SIGNUM_NEG, StandardPlural::Form::COUNT);
- pm->adoptModifierWithoutPlural(SIGNUM_NEG, createConstantModifier(status));
+ pm->adoptSignumModifierStoreNoPlural(createImmutableForPlural(StandardPlural::Form::COUNT, status));
if (U_FAILURE(status)) {
delete pm;
return nullptr;
@@ -284,6 +285,7 @@ void MutablePatternModifier::prepareAffix(bool isPrefix) {
fApproximately,
fPlural,
fPerMilleReplacesPercent,
+ false, // dropCurrencySymbols
currentAffix);
}
diff --git a/contrib/libs/icu/i18n/number_patternmodifier.h b/contrib/libs/icu/i18n/number_patternmodifier.h
index 4f825e1ed2..ee38c20c9c 100644
--- a/contrib/libs/icu/i18n/number_patternmodifier.h
+++ b/contrib/libs/icu/i18n/number_patternmodifier.h
@@ -42,9 +42,9 @@ class MutablePatternModifier;
// Exported as U_I18N_API because it is needed for the unit test PatternModifierTest
class U_I18N_API ImmutablePatternModifier : public MicroPropsGenerator, public UMemory {
public:
- ~ImmutablePatternModifier() U_OVERRIDE = default;
+ ~ImmutablePatternModifier() override = default;
- void processQuantity(DecimalQuantity&, MicroProps& micros, UErrorCode& status) const U_OVERRIDE;
+ void processQuantity(DecimalQuantity&, MicroProps& micros, UErrorCode& status) const override;
void applyToMicros(MicroProps& micros, const DecimalQuantity& quantity, UErrorCode& status) const;
@@ -89,7 +89,7 @@ class U_I18N_API MutablePatternModifier
public UMemory {
public:
- ~MutablePatternModifier() U_OVERRIDE = default;
+ ~MutablePatternModifier() override = default;
/**
* @param isStrong
@@ -156,6 +156,9 @@ class U_I18N_API MutablePatternModifier
*/
bool needsPlurals() const;
+ /** Creates a quantity-dependent Modifier for the specified plural form. */
+ AdoptingSignumModifierStore createImmutableForPlural(StandardPlural::Form plural, UErrorCode& status);
+
/**
* Creates a new quantity-dependent Modifier that behaves the same as the current instance, but which is immutable
* and can be saved for future use. The number properties in the current instance are mutated; all other properties
@@ -173,27 +176,27 @@ class U_I18N_API MutablePatternModifier
MicroPropsGenerator &addToChain(const MicroPropsGenerator *parent);
- void processQuantity(DecimalQuantity &, MicroProps &micros, UErrorCode &status) const U_OVERRIDE;
+ void processQuantity(DecimalQuantity &, MicroProps &micros, UErrorCode &status) const override;
int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex,
- UErrorCode &status) const U_OVERRIDE;
+ UErrorCode &status) const override;
- int32_t getPrefixLength() const U_OVERRIDE;
+ int32_t getPrefixLength() const override;
- int32_t getCodePointCount() const U_OVERRIDE;
+ int32_t getCodePointCount() const override;
- bool isStrong() const U_OVERRIDE;
+ bool isStrong() const override;
- bool containsField(Field field) const U_OVERRIDE;
+ bool containsField(Field field) const override;
- void getParameters(Parameters& output) const U_OVERRIDE;
+ void getParameters(Parameters& output) const override;
- bool semanticallyEquivalent(const Modifier& other) const U_OVERRIDE;
+ bool semanticallyEquivalent(const Modifier& other) const override;
/**
* Returns the string that substitutes a given symbol type in a pattern.
*/
- UnicodeString getSymbol(AffixPatternType type) const U_OVERRIDE;
+ UnicodeString getSymbol(AffixPatternType type) const override;
/**
* Returns the currency symbol for the unit width specified in setSymbols()
diff --git a/contrib/libs/icu/i18n/number_patternstring.cpp b/contrib/libs/icu/i18n/number_patternstring.cpp
index e819d39e96..aa082be5a8 100644
--- a/contrib/libs/icu/i18n/number_patternstring.cpp
+++ b/contrib/libs/icu/i18n/number_patternstring.cpp
@@ -750,7 +750,7 @@ UnicodeString PatternStringUtils::propertiesToPatternString(const DecimalFormatP
int32_t groupingLength = grouping1 + grouping2 + 1;
// Figure out the digits we need to put in the pattern.
- double roundingInterval = properties.roundingIncrement;
+ double increment = properties.roundingIncrement;
UnicodeString digitsString;
int32_t digitsStringScale = 0;
if (maxSig != uprv_min(dosMax, -1)) {
@@ -761,14 +761,14 @@ UnicodeString PatternStringUtils::propertiesToPatternString(const DecimalFormatP
while (digitsString.length() < maxSig) {
digitsString.append(u'#');
}
- } else if (roundingInterval != 0.0 && !ignoreRoundingIncrement(roundingInterval,maxFrac)) {
- // Rounding Interval.
- digitsStringScale = -roundingutils::doubleFractionLength(roundingInterval, nullptr);
- // TODO: Check for DoS here?
+ } else if (increment != 0.0 && !ignoreRoundingIncrement(increment,maxFrac)) {
+ // Rounding Increment.
DecimalQuantity incrementQuantity;
- incrementQuantity.setToDouble(roundingInterval);
+ incrementQuantity.setToDouble(increment);
+ incrementQuantity.roundToInfinity();
+ digitsStringScale = incrementQuantity.getLowerDisplayMagnitude();
incrementQuantity.adjustMagnitude(-digitsStringScale);
- incrementQuantity.roundToMagnitude(0, kDefaultMode, status);
+ incrementQuantity.setMinInteger(minInt - digitsStringScale);
UnicodeString str = incrementQuantity.toPlainString();
if (str.charAt(0) == u'-') {
// TODO: Unsupported operation exception or fail silently?
@@ -968,7 +968,7 @@ PatternStringUtils::convertLocalized(const UnicodeString& input, const DecimalFo
UnicodeString result;
int state = 0;
for (int offset = 0; offset < input.length(); offset++) {
- UChar ch = input.charAt(offset);
+ char16_t ch = input.charAt(offset);
// Handle a quote character (state shift)
if (ch == u'\'') {
@@ -1056,7 +1056,9 @@ void PatternStringUtils::patternInfoToStringBuilder(const AffixPatternProvider&
PatternSignType patternSignType,
bool approximately,
StandardPlural::Form plural,
- bool perMilleReplacesPercent, UnicodeString& output) {
+ bool perMilleReplacesPercent,
+ bool dropCurrencySymbols,
+ UnicodeString& output) {
// Should the output render '+' where '-' would normally appear in the pattern?
bool plusReplacesMinusSign = (patternSignType == PATTERN_SIGN_TYPE_POS_SIGN)
@@ -1130,6 +1132,9 @@ void PatternStringUtils::patternInfoToStringBuilder(const AffixPatternProvider&
if (perMilleReplacesPercent && candidate == u'%') {
candidate = u'‰';
}
+ if (dropCurrencySymbols && candidate == u'\u00A4') {
+ continue;
+ }
output.append(candidate);
}
}
diff --git a/contrib/libs/icu/i18n/number_patternstring.h b/contrib/libs/icu/i18n/number_patternstring.h
index 94afda3722..989d0d3464 100644
--- a/contrib/libs/icu/i18n/number_patternstring.h
+++ b/contrib/libs/icu/i18n/number_patternstring.h
@@ -80,32 +80,32 @@ struct U_I18N_API ParsedPatternInfo : public AffixPatternProvider, public UMemor
ParsedPatternInfo()
: state(this->pattern), currentSubpattern(nullptr) {}
- ~ParsedPatternInfo() U_OVERRIDE = default;
+ ~ParsedPatternInfo() override = default;
// Need to declare this explicitly because of the destructor
- ParsedPatternInfo& operator=(ParsedPatternInfo&& src) U_NOEXCEPT = default;
+ ParsedPatternInfo& operator=(ParsedPatternInfo&& src) noexcept = default;
static int32_t getLengthFromEndpoints(const Endpoints& endpoints);
- char16_t charAt(int32_t flags, int32_t index) const U_OVERRIDE;
+ char16_t charAt(int32_t flags, int32_t index) const override;
- int32_t length(int32_t flags) const U_OVERRIDE;
+ int32_t length(int32_t flags) const override;
- UnicodeString getString(int32_t flags) const U_OVERRIDE;
+ UnicodeString getString(int32_t flags) const override;
- bool positiveHasPlusSign() const U_OVERRIDE;
+ bool positiveHasPlusSign() const override;
- bool hasNegativeSubpattern() const U_OVERRIDE;
+ bool hasNegativeSubpattern() const override;
- bool negativeHasMinusSign() const U_OVERRIDE;
+ bool negativeHasMinusSign() const override;
- bool hasCurrencySign() const U_OVERRIDE;
+ bool hasCurrencySign() const override;
- bool containsSymbolType(AffixPatternType type, UErrorCode& status) const U_OVERRIDE;
+ bool containsSymbolType(AffixPatternType type, UErrorCode& status) const override;
- bool hasBody() const U_OVERRIDE;
+ bool hasBody() const override;
- bool currencyAsDecimal() const U_OVERRIDE;
+ bool currencyAsDecimal() const override;
private:
struct U_I18N_API ParserState {
@@ -115,7 +115,7 @@ struct U_I18N_API ParsedPatternInfo : public AffixPatternProvider, public UMemor
explicit ParserState(const UnicodeString& _pattern)
: pattern(_pattern) {}
- ParserState& operator=(ParserState&& src) U_NOEXCEPT {
+ ParserState& operator=(ParserState&& src) noexcept {
// Leave pattern reference alone; it will continue to point to the same place in memory,
// which gets overwritten by ParsedPatternInfo's implicit move assignment.
offset = src.offset;
@@ -317,7 +317,9 @@ class U_I18N_API PatternStringUtils {
static void patternInfoToStringBuilder(const AffixPatternProvider& patternInfo, bool isPrefix,
PatternSignType patternSignType,
bool approximately,
- StandardPlural::Form plural, bool perMilleReplacesPercent,
+ StandardPlural::Form plural,
+ bool perMilleReplacesPercent,
+ bool dropCurrencySymbols,
UnicodeString& output);
static PatternSignType resolveSignDisplay(UNumberSignDisplay signDisplay, Signum signum);
diff --git a/contrib/libs/icu/i18n/number_rounding.cpp b/contrib/libs/icu/i18n/number_rounding.cpp
index 877df63c8f..e6bb509ffd 100644
--- a/contrib/libs/icu/i18n/number_rounding.cpp
+++ b/contrib/libs/icu/i18n/number_rounding.cpp
@@ -28,7 +28,7 @@ using icu::StringSegment;
void number::impl::parseIncrementOption(const StringSegment &segment,
Precision &outPrecision,
UErrorCode &status) {
- // Need to do char <-> UChar conversion...
+ // Need to do char <-> char16_t conversion...
U_ASSERT(U_SUCCESS(status));
CharString buffer;
SKELETON_UCHAR_TO_CHAR(buffer, segment.toTempUnicodeString(), 0, segment.length(), status);
@@ -36,27 +36,24 @@ void number::impl::parseIncrementOption(const StringSegment &segment,
// Utilize DecimalQuantity/decNumber to parse this for us.
DecimalQuantity dq;
UErrorCode localStatus = U_ZERO_ERROR;
- DecNum decnum;
- decnum.setTo({buffer.data(), buffer.length()}, localStatus);
- dq.setToDecNum(decnum, localStatus);
- if (U_FAILURE(localStatus) || decnum.isSpecial()) {
+ dq.setToDecNumber({buffer.data(), buffer.length()}, localStatus);
+ if (U_FAILURE(localStatus) || dq.isNaN() || dq.isInfinite()) {
// 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);
+ // Now we break apart the number into a mantissa and exponent (magnitude).
+ int32_t magnitude = dq.adjustToZeroScale();
+ // setToDecNumber drops trailing zeros, so we search for the '.' manually.
+ for (int32_t i=0; i<buffer.length(); i++) {
+ if (buffer[i] == '.') {
+ int32_t newMagnitude = i - buffer.length() + 1;
+ dq.adjustMagnitude(magnitude - newMagnitude);
+ magnitude = newMagnitude;
+ break;
+ }
}
+ outPrecision = Precision::incrementExact(dq.toLong(), magnitude);
}
namespace {
@@ -94,34 +91,6 @@ int32_t getDisplayMagnitudeSignificant(const DecimalQuantity &value, int minSig)
MultiplierProducer::~MultiplierProducer() = default;
-digits_t roundingutils::doubleFractionLength(double input, int8_t* singleDigit) {
- char buffer[DoubleToStringConverter::kBase10MaximalLength + 1];
- bool sign; // unused; always positive
- int32_t length;
- int32_t point;
- DoubleToStringConverter::DoubleToAscii(
- input,
- DoubleToStringConverter::DtoaMode::SHORTEST,
- 0,
- buffer,
- sizeof(buffer),
- &sign,
- &length,
- &point
- );
-
- if (singleDigit == nullptr) {
- // no-op
- } else if (length == 1) {
- *singleDigit = buffer[0] - '0';
- } else {
- *singleDigit = -1;
- }
-
- return static_cast<digits_t>(length - point);
-}
-
-
Precision Precision::unlimited() {
return Precision(RND_NONE, {});
}
@@ -204,7 +173,19 @@ Precision Precision::trailingZeroDisplay(UNumberTrailingZeroDisplay trailingZero
IncrementPrecision Precision::increment(double roundingIncrement) {
if (roundingIncrement > 0.0) {
- return constructIncrement(roundingIncrement, 0);
+ DecimalQuantity dq;
+ dq.setToDouble(roundingIncrement);
+ dq.roundToInfinity();
+ int32_t magnitude = dq.adjustToZeroScale();
+ return constructIncrement(dq.toLong(), magnitude);
+ } else {
+ return {U_NUMBER_ARG_OUTOFBOUNDS_ERROR};
+ }
+}
+
+IncrementPrecision Precision::incrementExact(uint64_t mantissa, int16_t magnitude) {
+ if (mantissa > 0.0) {
+ return constructIncrement(mantissa, magnitude);
} else {
return {U_NUMBER_ARG_OUTOFBOUNDS_ERROR};
}
@@ -226,7 +207,8 @@ Precision FractionPrecision::withSignificantDigits(
*this,
minSignificantDigits,
maxSignificantDigits,
- priority);
+ priority,
+ false);
} else {
return {U_NUMBER_ARG_OUTOFBOUNDS_ERROR};
}
@@ -239,7 +221,8 @@ Precision FractionPrecision::withMinDigits(int32_t minSignificantDigits) const {
*this,
1,
minSignificantDigits,
- UNUM_ROUNDING_PRIORITY_RELAXED);
+ UNUM_ROUNDING_PRIORITY_RELAXED,
+ true);
} else {
return {U_NUMBER_ARG_OUTOFBOUNDS_ERROR};
}
@@ -251,7 +234,8 @@ Precision FractionPrecision::withMaxDigits(int32_t maxSignificantDigits) const {
return constructFractionSignificant(*this,
1,
maxSignificantDigits,
- UNUM_ROUNDING_PRIORITY_STRICT);
+ UNUM_ROUNDING_PRIORITY_STRICT,
+ true);
} else {
return {U_NUMBER_ARG_OUTOFBOUNDS_ERROR};
}
@@ -266,8 +250,8 @@ Precision Precision::withCurrency(const CurrencyUnit &currency, UErrorCode &stat
int32_t minMaxFrac = ucurr_getDefaultFractionDigitsForUsage(
isoCode, fUnion.currencyUsage, &status);
Precision retval = (increment != 0.0)
- ? static_cast<Precision>(constructIncrement(increment, minMaxFrac))
- : static_cast<Precision>(constructFraction(minMaxFrac, minMaxFrac));
+ ? Precision::increment(increment)
+ : static_cast<Precision>(Precision::fixedFraction(minMaxFrac));
retval.fTrailingZeroDisplay = fTrailingZeroDisplay;
return retval;
}
@@ -285,7 +269,9 @@ Precision CurrencyPrecision::withCurrency(const CurrencyUnit &currency) const {
Precision IncrementPrecision::withMinFraction(int32_t minFrac) const {
if (fType == RND_ERROR) { return *this; } // no-op in error state
if (minFrac >= 0 && minFrac <= kMaxIntFracSig) {
- return constructIncrement(fUnion.increment.fIncrement, minFrac);
+ IncrementPrecision copy = *this;
+ copy.fUnion.increment.fMinFrac = minFrac;
+ return copy;
} else {
return {U_NUMBER_ARG_OUTOFBOUNDS_ERROR};
}
@@ -318,35 +304,34 @@ Precision::constructFractionSignificant(
const FractionPrecision &base,
int32_t minSig,
int32_t maxSig,
- UNumberRoundingPriority priority) {
+ UNumberRoundingPriority priority,
+ bool retain) {
FractionSignificantSettings settings = base.fUnion.fracSig;
settings.fMinSig = static_cast<digits_t>(minSig);
settings.fMaxSig = static_cast<digits_t>(maxSig);
settings.fPriority = priority;
+ settings.fRetain = retain;
PrecisionUnion union_;
union_.fracSig = settings;
return {RND_FRACTION_SIGNIFICANT, union_};
}
-IncrementPrecision Precision::constructIncrement(double increment, int32_t minFrac) {
+IncrementPrecision Precision::constructIncrement(uint64_t increment, digits_t magnitude) {
IncrementSettings settings;
// Note: For number formatting, fIncrement is used for RND_INCREMENT but not
// RND_INCREMENT_ONE or RND_INCREMENT_FIVE. However, fIncrement is used in all
// three when constructing a skeleton.
settings.fIncrement = increment;
- settings.fMinFrac = static_cast<digits_t>(minFrac);
- // One of the few pre-computed quantities:
- // Note: it is possible for minFrac to be more than maxFrac... (misleading)
- int8_t singleDigit;
- settings.fMaxFrac = roundingutils::doubleFractionLength(increment, &singleDigit);
+ settings.fIncrementMagnitude = magnitude;
+ settings.fMinFrac = magnitude > 0 ? 0 : -magnitude;
PrecisionUnion union_;
union_.increment = settings;
- if (singleDigit == 1) {
+ if (increment == 1) {
// 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_};
- } else if (singleDigit == 5) {
+ } else if (increment == 5) {
return {RND_INCREMENT_FIVE, union_};
} else {
return {RND_INCREMENT, union_};
@@ -457,6 +442,23 @@ void RoundingImpl::apply(impl::DecimalQuantity &value, UErrorCode& status) const
break;
case Precision::RND_FRACTION_SIGNIFICANT: {
+ // From ECMA-402:
+ /*
+ Let sResult be ToRawPrecision(...).
+ Let fResult be ToRawFixed(...).
+ If intlObj.[[RoundingType]] is morePrecision, then
+ If sResult.[[RoundingMagnitude]] ≤ fResult.[[RoundingMagnitude]], then
+ Let result be sResult.
+ Else,
+ Let result be fResult.
+ Else,
+ Assert: intlObj.[[RoundingType]] is lessPrecision.
+ If sResult.[[RoundingMagnitude]] ≤ fResult.[[RoundingMagnitude]], then
+ Let result be fResult.
+ Else,
+ Let result be sResult.
+ */
+
int32_t roundingMag1 = getRoundingMagnitudeFraction(fPrecision.fUnion.fracSig.fMaxFrac);
int32_t roundingMag2 = getRoundingMagnitudeSignificant(value, fPrecision.fUnion.fracSig.fMaxSig);
int32_t roundingMag;
@@ -465,11 +467,35 @@ void RoundingImpl::apply(impl::DecimalQuantity &value, UErrorCode& status) const
} else {
roundingMag = uprv_max(roundingMag1, roundingMag2);
}
- value.roundToMagnitude(roundingMag, fRoundingMode, status);
+ if (!value.isZeroish()) {
+ int32_t upperMag = value.getMagnitude();
+ value.roundToMagnitude(roundingMag, fRoundingMode, status);
+ if (!value.isZeroish() && value.getMagnitude() != upperMag && roundingMag1 == roundingMag2) {
+ // roundingMag2 needs to be the magnitude after rounding
+ roundingMag2 += 1;
+ }
+ }
int32_t displayMag1 = getDisplayMagnitudeFraction(fPrecision.fUnion.fracSig.fMinFrac);
int32_t displayMag2 = getDisplayMagnitudeSignificant(value, fPrecision.fUnion.fracSig.fMinSig);
- int32_t displayMag = uprv_min(displayMag1, displayMag2);
+ int32_t displayMag;
+ if (fPrecision.fUnion.fracSig.fRetain) {
+ // withMinDigits + withMaxDigits
+ displayMag = uprv_min(displayMag1, displayMag2);
+ } else if (fPrecision.fUnion.fracSig.fPriority == UNUM_ROUNDING_PRIORITY_RELAXED) {
+ if (roundingMag2 <= roundingMag1) {
+ displayMag = displayMag2;
+ } else {
+ displayMag = displayMag1;
+ }
+ } else {
+ U_ASSERT(fPrecision.fUnion.fracSig.fPriority == UNUM_ROUNDING_PRIORITY_STRICT);
+ if (roundingMag2 <= roundingMag1) {
+ displayMag = displayMag1;
+ } else {
+ displayMag = displayMag2;
+ }
+ }
resolvedMinFraction = uprv_max(0, -displayMag);
break;
@@ -478,6 +504,7 @@ void RoundingImpl::apply(impl::DecimalQuantity &value, UErrorCode& status) const
case Precision::RND_INCREMENT:
value.roundToIncrement(
fPrecision.fUnion.increment.fIncrement,
+ fPrecision.fUnion.increment.fIncrementMagnitude,
fRoundingMode,
status);
resolvedMinFraction = fPrecision.fUnion.increment.fMinFrac;
@@ -485,7 +512,7 @@ void RoundingImpl::apply(impl::DecimalQuantity &value, UErrorCode& status) const
case Precision::RND_INCREMENT_ONE:
value.roundToMagnitude(
- -fPrecision.fUnion.increment.fMaxFrac,
+ fPrecision.fUnion.increment.fIncrementMagnitude,
fRoundingMode,
status);
resolvedMinFraction = fPrecision.fUnion.increment.fMinFrac;
@@ -493,7 +520,7 @@ void RoundingImpl::apply(impl::DecimalQuantity &value, UErrorCode& status) const
case Precision::RND_INCREMENT_FIVE:
value.roundToNickel(
- -fPrecision.fUnion.increment.fMaxFrac,
+ fPrecision.fUnion.increment.fIncrementMagnitude,
fRoundingMode,
status);
resolvedMinFraction = fPrecision.fUnion.increment.fMinFrac;
diff --git a/contrib/libs/icu/i18n/number_roundingutils.h b/contrib/libs/icu/i18n/number_roundingutils.h
index 06fadd29fd..6657127254 100644
--- a/contrib/libs/icu/i18n/number_roundingutils.h
+++ b/contrib/libs/icu/i18n/number_roundingutils.h
@@ -174,15 +174,6 @@ inline bool roundsAtMidpoint(int roundingMode) {
}
}
-/**
- * Computes the number of fraction digits in a double. Used for computing maxFrac for an increment.
- * Calls into the DoubleToStringConverter library to do so.
- *
- * @param singleDigit An output parameter; set to a number if that is the
- * only digit in the double, or -1 if there is more than one digit.
- */
-digits_t doubleFractionLength(double input, int8_t* singleDigit);
-
} // namespace roundingutils
diff --git a/contrib/libs/icu/i18n/number_scientific.h b/contrib/libs/icu/i18n/number_scientific.h
index a40a6e416d..22140a09af 100644
--- a/contrib/libs/icu/i18n/number_scientific.h
+++ b/contrib/libs/icu/i18n/number_scientific.h
@@ -22,19 +22,19 @@ class U_I18N_API ScientificModifier : public UMemory, public Modifier {
void set(int32_t exponent, const ScientificHandler *handler);
int32_t apply(FormattedStringBuilder &output, int32_t leftIndex, int32_t rightIndex,
- UErrorCode &status) const U_OVERRIDE;
+ UErrorCode &status) const override;
- int32_t getPrefixLength() const U_OVERRIDE;
+ int32_t getPrefixLength() const override;
- int32_t getCodePointCount() const U_OVERRIDE;
+ int32_t getCodePointCount() const override;
- bool isStrong() const U_OVERRIDE;
+ bool isStrong() const override;
- bool containsField(Field field) const U_OVERRIDE;
+ bool containsField(Field field) const override;
- void getParameters(Parameters& output) const U_OVERRIDE;
+ void getParameters(Parameters& output) const override;
- bool semanticallyEquivalent(const Modifier& other) const U_OVERRIDE;
+ bool semanticallyEquivalent(const Modifier& other) const override;
private:
int32_t fExponent;
@@ -47,9 +47,9 @@ class ScientificHandler : public UMemory, public MicroPropsGenerator, public Mul
const MicroPropsGenerator *parent);
void
- processQuantity(DecimalQuantity &quantity, MicroProps &micros, UErrorCode &status) const U_OVERRIDE;
+ processQuantity(DecimalQuantity &quantity, MicroProps &micros, UErrorCode &status) const override;
- int32_t getMultiplier(int32_t magnitude) const U_OVERRIDE;
+ int32_t getMultiplier(int32_t magnitude) const override;
private:
const Notation::ScientificSettings fSettings;
diff --git a/contrib/libs/icu/i18n/number_simple.cpp b/contrib/libs/icu/i18n/number_simple.cpp
new file mode 100644
index 0000000000..a2af6be42d
--- /dev/null
+++ b/contrib/libs/icu/i18n/number_simple.cpp
@@ -0,0 +1,255 @@
+// © 2017 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 "unicode/numberformatter.h"
+#include "unicode/simplenumberformatter.h"
+#include "number_formatimpl.h"
+#include "number_utils.h"
+#include "number_patternmodifier.h"
+#include "number_utypes.h"
+
+using namespace icu;
+using namespace icu::number;
+using namespace icu::number::impl;
+
+
+SimpleNumber
+SimpleNumber::forInt64(int64_t value, UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return SimpleNumber();
+ }
+ auto results = new UFormattedNumberData();
+ if (results == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return SimpleNumber();
+ }
+ results->quantity.setToLong(value);
+ return SimpleNumber(results, status);
+}
+
+SimpleNumber::SimpleNumber(UFormattedNumberData* data, UErrorCode& status) : fData(data) {
+ if (U_FAILURE(status)) {
+ return;
+ }
+ if (fData == nullptr) {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return;
+ }
+ if (fData->quantity.isNegative()) {
+ fSign = UNUM_SIMPLE_NUMBER_MINUS_SIGN;
+ } else {
+ fSign = UNUM_SIMPLE_NUMBER_NO_SIGN;
+ }
+}
+
+void SimpleNumber::cleanup() {
+ delete fData;
+ fData = nullptr;
+}
+
+void SimpleNumber::multiplyByPowerOfTen(int32_t power, UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
+ if (fData == nullptr) {
+ status = U_INVALID_STATE_ERROR;
+ return;
+ }
+ fData->quantity.adjustMagnitude(power);
+}
+
+void SimpleNumber::roundTo(int32_t position, UNumberFormatRoundingMode roundingMode, UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
+ if (fData == nullptr) {
+ status = U_INVALID_STATE_ERROR;
+ return;
+ }
+ fData->quantity.roundToMagnitude(position, roundingMode, status);
+}
+
+void SimpleNumber::setMinimumIntegerDigits(uint32_t position, UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
+ if (fData == nullptr) {
+ status = U_INVALID_STATE_ERROR;
+ return;
+ }
+ fData->quantity.setMinInteger(position);
+}
+
+void SimpleNumber::setMinimumFractionDigits(uint32_t position, UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
+ if (fData == nullptr) {
+ status = U_INVALID_STATE_ERROR;
+ return;
+ }
+ fData->quantity.setMinFraction(position);
+}
+
+void SimpleNumber::truncateStart(uint32_t position, UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
+ if (fData == nullptr) {
+ status = U_INVALID_STATE_ERROR;
+ return;
+ }
+ fData->quantity.applyMaxInteger(position);
+}
+
+void SimpleNumber::setSign(USimpleNumberSign sign, UErrorCode& status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
+ if (fData == nullptr) {
+ status = U_INVALID_STATE_ERROR;
+ return;
+ }
+ fSign = sign;
+}
+
+
+void SimpleNumberFormatter::cleanup() {
+ delete fOwnedSymbols;
+ delete fMicros;
+ delete fPatternModifier;
+ fOwnedSymbols = nullptr;
+ fMicros = nullptr;
+ fPatternModifier = nullptr;
+}
+
+SimpleNumberFormatter SimpleNumberFormatter::forLocale(const icu::Locale &locale, UErrorCode &status) {
+ return SimpleNumberFormatter::forLocaleAndGroupingStrategy(locale, UNUM_GROUPING_AUTO, status);
+}
+
+SimpleNumberFormatter SimpleNumberFormatter::forLocaleAndGroupingStrategy(
+ const icu::Locale &locale,
+ UNumberGroupingStrategy groupingStrategy,
+ UErrorCode &status) {
+ SimpleNumberFormatter retval;
+ retval.fOwnedSymbols = new DecimalFormatSymbols(locale, status);
+ if (U_FAILURE(status)) {
+ return retval;
+ }
+ if (retval.fOwnedSymbols == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return retval;
+ }
+ retval.initialize(locale, *retval.fOwnedSymbols, groupingStrategy, status);
+ return retval;
+}
+
+
+SimpleNumberFormatter SimpleNumberFormatter::forLocaleAndSymbolsAndGroupingStrategy(
+ const icu::Locale &locale,
+ const DecimalFormatSymbols &symbols,
+ UNumberGroupingStrategy groupingStrategy,
+ UErrorCode &status) {
+ SimpleNumberFormatter retval;
+ retval.initialize(locale, symbols, groupingStrategy, status);
+ return retval;
+}
+
+
+void SimpleNumberFormatter::initialize(
+ const icu::Locale &locale,
+ const DecimalFormatSymbols &symbols,
+ UNumberGroupingStrategy groupingStrategy,
+ UErrorCode &status) {
+ if (U_FAILURE(status)) {
+ return;
+ }
+
+ fMicros = new SimpleMicroProps();
+ if (fMicros == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
+ fMicros->symbols = &symbols;
+
+ auto pattern = utils::getPatternForStyle(
+ locale,
+ symbols.getNumberingSystemName(),
+ CLDR_PATTERN_STYLE_DECIMAL,
+ status);
+ if (U_FAILURE(status)) {
+ return;
+ }
+
+ ParsedPatternInfo patternInfo;
+ PatternParser::parseToPatternInfo(UnicodeString(pattern), patternInfo, status);
+ if (U_FAILURE(status)) {
+ return;
+ }
+
+ auto grouper = Grouper::forStrategy(groupingStrategy);
+ grouper.setLocaleData(patternInfo, locale);
+ fMicros->grouping = grouper;
+
+ MutablePatternModifier patternModifier(false);
+ patternModifier.setPatternInfo(&patternInfo, kUndefinedField);
+ patternModifier.setPatternAttributes(UNUM_SIGN_EXCEPT_ZERO, false, false);
+ patternModifier.setSymbols(fMicros->symbols, {}, UNUM_UNIT_WIDTH_SHORT, nullptr, status);
+
+ fPatternModifier = new AdoptingSignumModifierStore(patternModifier.createImmutableForPlural(StandardPlural::COUNT, status));
+
+ fGroupingStrategy = groupingStrategy;
+ return;
+}
+
+FormattedNumber SimpleNumberFormatter::format(SimpleNumber value, UErrorCode &status) const {
+ formatImpl(value.fData, value.fSign, status);
+
+ // Do not save the results object if we encountered a failure.
+ if (U_SUCCESS(status)) {
+ auto temp = value.fData;
+ value.fData = nullptr;
+ return FormattedNumber(temp);
+ } else {
+ return FormattedNumber(status);
+ }
+}
+
+void SimpleNumberFormatter::formatImpl(UFormattedNumberData* data, USimpleNumberSign sign, UErrorCode &status) const {
+ if (U_FAILURE(status)) {
+ return;
+ }
+ if (data == nullptr) {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return;
+ }
+ if (fPatternModifier == nullptr || fMicros == nullptr) {
+ status = U_INVALID_STATE_ERROR;
+ return;
+ }
+
+ Signum signum;
+ if (sign == UNUM_SIMPLE_NUMBER_MINUS_SIGN) {
+ signum = SIGNUM_NEG;
+ } else if (sign == UNUM_SIMPLE_NUMBER_PLUS_SIGN) {
+ signum = SIGNUM_POS;
+ } else {
+ signum = SIGNUM_POS_ZERO;
+ }
+
+ const Modifier* modifier = (*fPatternModifier)[signum];
+ auto length = NumberFormatterImpl::writeNumber(
+ *fMicros,
+ data->quantity,
+ data->getStringRef(),
+ 0,
+ status);
+ length += modifier->apply(data->getStringRef(), 0, length, status);
+ data->getStringRef().writeTerminator(status);
+}
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/contrib/libs/icu/i18n/number_skeletons.cpp b/contrib/libs/icu/i18n/number_skeletons.cpp
index de70c5cedf..ef3befbffa 100644
--- a/contrib/libs/icu/i18n/number_skeletons.cpp
+++ b/contrib/libs/icu/i18n/number_skeletons.cpp
@@ -33,7 +33,7 @@ using namespace icu::number::impl::skeleton;
namespace {
-icu::UInitOnce gNumberSkeletonsInitOnce = U_INITONCE_INITIALIZER;
+icu::UInitOnce gNumberSkeletonsInitOnce {};
char16_t* kSerializedStemTrie = nullptr;
@@ -41,7 +41,7 @@ UBool U_CALLCONV cleanupNumberSkeletons() {
uprv_free(kSerializedStemTrie);
kSerializedStemTrie = nullptr;
gNumberSkeletonsInitOnce.reset();
- return TRUE;
+ return true;
}
void U_CALLCONV initNumberSkeletons(UErrorCode& status) {
@@ -1022,7 +1022,7 @@ void blueprint_helpers::parseCurrencyOption(const StringSegment& segment, MacroP
status = U_NUMBER_SKELETON_SYNTAX_ERROR;
return;
}
- const UChar* currencyCode = segment.toTempUnicodeString().getBuffer();
+ const char16_t* currencyCode = segment.toTempUnicodeString().getBuffer();
UErrorCode localStatus = U_ZERO_ERROR;
CurrencyUnit currency(currencyCode, localStatus);
if (U_FAILURE(localStatus)) {
@@ -1057,7 +1057,7 @@ void blueprint_helpers::parseMeasureUnitOption(const StringSegment& segment, Mac
return;
}
- // Need to do char <-> UChar conversion...
+ // Need to do char <-> char16_t conversion...
CharString type;
SKELETON_UCHAR_TO_CHAR(type, stemString, 0, firstHyphen, status);
CharString subType;
@@ -1098,7 +1098,7 @@ void blueprint_helpers::parseMeasurePerUnitOption(const StringSegment& segment,
void blueprint_helpers::parseIdentifierUnitOption(const StringSegment& segment, MacroProps& macros,
UErrorCode& status) {
- // Need to do char <-> UChar conversion...
+ // Need to do char <-> char16_t conversion...
U_ASSERT(U_SUCCESS(status));
CharString buffer;
SKELETON_UCHAR_TO_CHAR(buffer, segment.toTempUnicodeString(), 0, segment.length(), status);
@@ -1114,7 +1114,7 @@ void blueprint_helpers::parseIdentifierUnitOption(const StringSegment& segment,
void blueprint_helpers::parseUnitUsageOption(const StringSegment &segment, MacroProps &macros,
UErrorCode &status) {
- // Need to do char <-> UChar conversion...
+ // Need to do char <-> char16_t conversion...
U_ASSERT(U_SUCCESS(status));
CharString buffer;
SKELETON_UCHAR_TO_CHAR(buffer, segment.toTempUnicodeString(), 0, segment.length(), status);
@@ -1344,8 +1344,9 @@ bool blueprint_helpers::parseFracSigOption(const StringSegment& segment, MacroPr
// @, @@, @@@
maxSig = minSig;
}
- UNumberRoundingPriority priority;
+ auto& oldPrecision = static_cast<const FractionPrecision&>(macros.precision);
if (offset < segment.length()) {
+ UNumberRoundingPriority priority;
if (maxSig == -1) {
// The wildcard character is not allowed with the priority annotation
status = U_NUMBER_SKELETON_SYNTAX_ERROR;
@@ -1367,22 +1368,19 @@ bool blueprint_helpers::parseFracSigOption(const StringSegment& segment, MacroPr
status = U_NUMBER_SKELETON_SYNTAX_ERROR;
return false;
}
+ macros.precision = oldPrecision.withSignificantDigits(minSig, maxSig, priority);
} else if (maxSig == -1) {
// withMinDigits
- maxSig = minSig;
- minSig = 1;
- priority = UNUM_ROUNDING_PRIORITY_RELAXED;
+ macros.precision = oldPrecision.withMinDigits(minSig);
} else if (minSig == 1) {
// withMaxDigits
- priority = UNUM_ROUNDING_PRIORITY_STRICT;
+ macros.precision = oldPrecision.withMaxDigits(maxSig);
} else {
// Digits options with both min and max sig require the priority option
status = U_NUMBER_SKELETON_SYNTAX_ERROR;
return false;
}
- auto& oldPrecision = static_cast<const FractionPrecision&>(macros.precision);
- macros.precision = oldPrecision.withSignificantDigits(minSig, maxSig, priority);
return true;
}
@@ -1399,12 +1397,16 @@ void blueprint_helpers::parseIncrementOption(const StringSegment &segment, Macro
number::impl::parseIncrementOption(segment, macros.precision, status);
}
-void blueprint_helpers::generateIncrementOption(double increment, int32_t minFrac, UnicodeString& sb,
- UErrorCode&) {
+void blueprint_helpers::generateIncrementOption(
+ uint32_t increment,
+ digits_t incrementMagnitude,
+ int32_t minFrac,
+ UnicodeString& sb,
+ UErrorCode&) {
// Utilize DecimalQuantity/double_conversion to format this for us.
DecimalQuantity dq;
- dq.setToDouble(increment);
- dq.roundToInfinity();
+ dq.setToLong(increment);
+ dq.adjustMagnitude(incrementMagnitude);
dq.setMinFraction(minFrac);
sb.append(dq.toPlainString());
}
@@ -1464,7 +1466,7 @@ void blueprint_helpers::generateIntegerWidthOption(int32_t minInt, int32_t maxIn
void blueprint_helpers::parseNumberingSystemOption(const StringSegment& segment, MacroProps& macros,
UErrorCode& status) {
- // Need to do char <-> UChar conversion...
+ // Need to do char <-> char16_t conversion...
U_ASSERT(U_SUCCESS(status));
CharString buffer;
SKELETON_UCHAR_TO_CHAR(buffer, segment.toTempUnicodeString(), 0, segment.length(), status);
@@ -1481,13 +1483,13 @@ void blueprint_helpers::parseNumberingSystemOption(const StringSegment& segment,
void blueprint_helpers::generateNumberingSystemOption(const NumberingSystem& ns, UnicodeString& sb,
UErrorCode&) {
- // Need to do char <-> UChar conversion...
+ // Need to do char <-> char16_t conversion...
sb.append(UnicodeString(ns.getName(), -1, US_INV));
}
void blueprint_helpers::parseScaleOption(const StringSegment& segment, MacroProps& macros,
UErrorCode& status) {
- // Need to do char <-> UChar conversion...
+ // Need to do char <-> char16_t conversion...
U_ASSERT(U_SUCCESS(status));
CharString buffer;
SKELETON_UCHAR_TO_CHAR(buffer, segment.toTempUnicodeString(), 0, segment.length(), status);
@@ -1617,11 +1619,21 @@ bool GeneratorHelpers::precision(const MacroProps& macros, UnicodeString& sb, UE
const Precision::FractionSignificantSettings& impl = macros.precision.fUnion.fracSig;
blueprint_helpers::generateFractionStem(impl.fMinFrac, impl.fMaxFrac, sb, status);
sb.append(u'/');
- blueprint_helpers::generateDigitsStem(impl.fMinSig, impl.fMaxSig, sb, status);
- if (impl.fPriority == UNUM_ROUNDING_PRIORITY_RELAXED) {
- sb.append(u'r');
+ if (impl.fRetain) {
+ if (impl.fPriority == UNUM_ROUNDING_PRIORITY_RELAXED) {
+ // withMinDigits
+ blueprint_helpers::generateDigitsStem(impl.fMaxSig, -1, sb, status);
+ } else {
+ // withMaxDigits
+ blueprint_helpers::generateDigitsStem(1, impl.fMaxSig, sb, status);
+ }
} else {
- sb.append(u's');
+ blueprint_helpers::generateDigitsStem(impl.fMinSig, impl.fMaxSig, sb, status);
+ if (impl.fPriority == UNUM_ROUNDING_PRIORITY_RELAXED) {
+ sb.append(u'r');
+ } else {
+ sb.append(u's');
+ }
}
} else if (macros.precision.fType == Precision::RND_INCREMENT
|| macros.precision.fType == Precision::RND_INCREMENT_ONE
@@ -1630,6 +1642,7 @@ bool GeneratorHelpers::precision(const MacroProps& macros, UnicodeString& sb, UE
sb.append(u"precision-increment/", -1);
blueprint_helpers::generateIncrementOption(
impl.fIncrement,
+ impl.fIncrementMagnitude,
impl.fMinFrac,
sb,
status);
diff --git a/contrib/libs/icu/i18n/number_skeletons.h b/contrib/libs/icu/i18n/number_skeletons.h
index be41f1b323..27f69cd48c 100644
--- a/contrib/libs/icu/i18n/number_skeletons.h
+++ b/contrib/libs/icu/i18n/number_skeletons.h
@@ -286,7 +286,7 @@ bool parseTrailingZeroOption(const StringSegment& segment, MacroProps& macros, U
void parseIncrementOption(const StringSegment& segment, MacroProps& macros, UErrorCode& status);
void
-generateIncrementOption(double increment, int32_t minFrac, UnicodeString& sb, UErrorCode& status);
+generateIncrementOption(uint32_t increment, digits_t incrementMagnitude, int32_t minFrac, UnicodeString& sb, UErrorCode& status);
void parseIntegerWidthOption(const StringSegment& segment, MacroProps& macros, UErrorCode& status);
diff --git a/contrib/libs/icu/i18n/number_symbolswrapper.cpp b/contrib/libs/icu/i18n/number_symbolswrapper.cpp
index ac3043d1ca..4742a69c1f 100644
--- a/contrib/libs/icu/i18n/number_symbolswrapper.cpp
+++ b/contrib/libs/icu/i18n/number_symbolswrapper.cpp
@@ -16,7 +16,7 @@ SymbolsWrapper::SymbolsWrapper(const SymbolsWrapper &other) {
doCopyFrom(other);
}
-SymbolsWrapper::SymbolsWrapper(SymbolsWrapper &&src) U_NOEXCEPT {
+SymbolsWrapper::SymbolsWrapper(SymbolsWrapper &&src) noexcept {
doMoveFrom(std::move(src));
}
@@ -29,7 +29,7 @@ SymbolsWrapper &SymbolsWrapper::operator=(const SymbolsWrapper &other) {
return *this;
}
-SymbolsWrapper &SymbolsWrapper::operator=(SymbolsWrapper &&src) U_NOEXCEPT {
+SymbolsWrapper &SymbolsWrapper::operator=(SymbolsWrapper &&src) noexcept {
if (this == &src) {
return *this;
}
diff --git a/contrib/libs/icu/i18n/number_usageprefs.cpp b/contrib/libs/icu/i18n/number_usageprefs.cpp
index 5d93d12cce..6f7fdaa9dc 100644
--- a/contrib/libs/icu/i18n/number_usageprefs.cpp
+++ b/contrib/libs/icu/i18n/number_usageprefs.cpp
@@ -60,7 +60,7 @@ StringProp &StringProp::operator=(const StringProp &other) {
}
// Move constructor
-StringProp::StringProp(StringProp &&src) U_NOEXCEPT : fValue(src.fValue),
+StringProp::StringProp(StringProp &&src) noexcept : fValue(src.fValue),
fLength(src.fLength),
fError(src.fError) {
// Take ownership away from src if necessary
@@ -68,7 +68,7 @@ StringProp::StringProp(StringProp &&src) U_NOEXCEPT : fValue(src.fValue),
}
// Move assignment operator
-StringProp &StringProp::operator=(StringProp &&src) U_NOEXCEPT {
+StringProp &StringProp::operator=(StringProp &&src) noexcept {
if (this == &src) {
return *this;
}
@@ -102,7 +102,9 @@ void StringProp::set(StringPiece value) {
fError = U_MEMORY_ALLOCATION_ERROR;
return;
}
- uprv_strncpy(fValue, value.data(), fLength);
+ if (fLength > 0) {
+ uprv_strncpy(fValue, value.data(), fLength);
+ }
fValue[fLength] = 0;
}
@@ -153,7 +155,7 @@ UsagePrefsHandler::UsagePrefsHandler(const Locale &locale,
const StringPiece usage,
const MicroPropsGenerator *parent,
UErrorCode &status)
- : fUnitsRouter(inputUnit, StringPiece(locale.getCountry()), usage, status),
+ : fUnitsRouter(inputUnit, locale, usage, status),
fParent(parent) {
}
diff --git a/contrib/libs/icu/i18n/number_usageprefs.h b/contrib/libs/icu/i18n/number_usageprefs.h
index 70547225a0..e90df99d39 100644
--- a/contrib/libs/icu/i18n/number_usageprefs.h
+++ b/contrib/libs/icu/i18n/number_usageprefs.h
@@ -44,7 +44,7 @@ class U_I18N_API UsagePrefsHandler : public MicroPropsGenerator, public UMemory
* micros.outputUnit.
*/
void processQuantity(DecimalQuantity &quantity, MicroProps &micros,
- UErrorCode &status) const U_OVERRIDE;
+ UErrorCode &status) const override;
/**
* Returns the list of possible output units, i.e. the full set of
@@ -111,7 +111,7 @@ class U_I18N_API UnitConversionHandler : public MicroPropsGenerator, public UMem
* Obtains the appropriate output values from the Unit Converter.
*/
void processQuantity(DecimalQuantity &quantity, MicroProps &micros,
- UErrorCode &status) const U_OVERRIDE;
+ UErrorCode &status) const override;
private:
MeasureUnit fOutputUnit;
LocalPointer<ComplexUnitsConverter> fUnitConverter;
diff --git a/contrib/libs/icu/i18n/number_utypes.h b/contrib/libs/icu/i18n/number_utypes.h
index 50c861787f..0c13040189 100644
--- a/contrib/libs/icu/i18n/number_utypes.h
+++ b/contrib/libs/icu/i18n/number_utypes.h
@@ -35,6 +35,9 @@ public:
UFormattedNumberData() : FormattedValueStringBuilderImpl(kUndefinedField) {}
virtual ~UFormattedNumberData();
+ UFormattedNumberData(UFormattedNumberData&&) = default;
+ UFormattedNumberData& operator=(UFormattedNumberData&&) = default;
+
// The formatted quantity.
DecimalQuantity quantity;
diff --git a/contrib/libs/icu/i18n/numfmt.cpp b/contrib/libs/icu/i18n/numfmt.cpp
index b8ce1c930f..74689e1363 100644
--- a/contrib/libs/icu/i18n/numfmt.cpp
+++ b/contrib/libs/icu/i18n/numfmt.cpp
@@ -74,32 +74,32 @@ static inline void debugout(UnicodeString s) {
// If no number pattern can be located for a locale, this is the last
// resort. The patterns are same as the ones in root locale.
-static const UChar gLastResortDecimalPat[] = {
+static const char16_t gLastResortDecimalPat[] = {
0x23, 0x2C, 0x23, 0x23, 0x30, 0x2E, 0x23, 0x23, 0x23, 0 /* "#,##0.###" */
};
-static const UChar gLastResortCurrencyPat[] = {
+static const char16_t gLastResortCurrencyPat[] = {
0xA4, 0xA0, 0x23, 0x2C, 0x23, 0x23, 0x30, 0x2E, 0x30, 0x30, 0 /* "\u00A4\u00A0#,##0.00" */
};
-static const UChar gLastResortPercentPat[] = {
+static const char16_t gLastResortPercentPat[] = {
0x23, 0x2C, 0x23, 0x23, 0x30, 0x25, 0 /* "#,##0%" */
};
-static const UChar gLastResortScientificPat[] = {
+static const char16_t gLastResortScientificPat[] = {
0x23, 0x45, 0x30, 0 /* "#E0" */
};
-static const UChar gLastResortIsoCurrencyPat[] = {
+static const char16_t gLastResortIsoCurrencyPat[] = {
0xA4, 0xA4, 0xA0, 0x23, 0x2C, 0x23, 0x23, 0x30, 0x2E, 0x30, 0x30, 0 /* "\u00A4\u00A4\u00A0#,##0.00" */
};
-static const UChar gLastResortPluralCurrencyPat[] = {
+static const char16_t gLastResortPluralCurrencyPat[] = {
0x23, 0x2C, 0x23, 0x23, 0x30, 0x2E, 0x23, 0x23, 0x23, 0x20, 0xA4, 0xA4, 0xA4, 0 /* "#,##0.### \u00A4\u00A4\u00A4*/
};
-static const UChar gLastResortAccountingCurrencyPat[] = {
+static const char16_t gLastResortAccountingCurrencyPat[] = {
0xA4, 0xA0, 0x23, 0x2C, 0x23, 0x23, 0x30, 0x2E, 0x30, 0x30, 0 /* "\u00A4\u00A0#,##0.00" */
};
-static const UChar gSingleCurrencySign[] = {0xA4, 0};
-static const UChar gDoubleCurrencySign[] = {0xA4, 0xA4, 0};
+static const char16_t gSingleCurrencySign[] = {0xA4, 0};
+static const char16_t gDoubleCurrencySign[] = {0xA4, 0xA4, 0};
-static const UChar gSlash = 0x2f;
+static const char16_t gSlash = 0x2f;
// If the maximum base 10 exponent were 4, then the largest number would
// be 99,999 which has 5 digits.
@@ -108,39 +108,39 @@ static const UChar gSlash = 0x2f;
const int32_t icu::NumberFormat::gDefaultMaxIntegerDigits = 2000000000;
const int32_t icu::NumberFormat::gDefaultMinIntegerDigits = 127;
-static const UChar * const gLastResortNumberPatterns[UNUM_FORMAT_STYLE_COUNT] = {
- NULL, // UNUM_PATTERN_DECIMAL
+static const char16_t * const gLastResortNumberPatterns[UNUM_FORMAT_STYLE_COUNT] = {
+ nullptr, // UNUM_PATTERN_DECIMAL
gLastResortDecimalPat, // UNUM_DECIMAL
gLastResortCurrencyPat, // UNUM_CURRENCY
gLastResortPercentPat, // UNUM_PERCENT
gLastResortScientificPat, // UNUM_SCIENTIFIC
- NULL, // UNUM_SPELLOUT
- NULL, // UNUM_ORDINAL
- NULL, // UNUM_DURATION
- NULL, // UNUM_NUMBERING_SYSTEM
- NULL, // UNUM_PATTERN_RULEBASED
+ nullptr, // UNUM_SPELLOUT
+ nullptr, // UNUM_ORDINAL
+ nullptr, // UNUM_DURATION
+ gLastResortDecimalPat, // UNUM_NUMBERING_SYSTEM
+ nullptr, // UNUM_PATTERN_RULEBASED
gLastResortIsoCurrencyPat, // UNUM_CURRENCY_ISO
gLastResortPluralCurrencyPat, // UNUM_CURRENCY_PLURAL
gLastResortAccountingCurrencyPat, // UNUM_CURRENCY_ACCOUNTING
gLastResortCurrencyPat, // UNUM_CASH_CURRENCY
- NULL, // UNUM_DECIMAL_COMPACT_SHORT
- NULL, // UNUM_DECIMAL_COMPACT_LONG
+ nullptr, // UNUM_DECIMAL_COMPACT_SHORT
+ nullptr, // UNUM_DECIMAL_COMPACT_LONG
gLastResortCurrencyPat, // UNUM_CURRENCY_STANDARD
};
// Keys used for accessing resource bundles
static const icu::number::impl::CldrPatternStyle gFormatCldrStyles[UNUM_FORMAT_STYLE_COUNT] = {
- /* NULL */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_PATTERN_DECIMAL
+ /* nullptr */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_PATTERN_DECIMAL
icu::number::impl::CLDR_PATTERN_STYLE_DECIMAL, // UNUM_DECIMAL
icu::number::impl::CLDR_PATTERN_STYLE_CURRENCY, // UNUM_CURRENCY
icu::number::impl::CLDR_PATTERN_STYLE_PERCENT, // UNUM_PERCENT
icu::number::impl::CLDR_PATTERN_STYLE_SCIENTIFIC, // UNUM_SCIENTIFIC
- /* NULL */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_SPELLOUT
- /* NULL */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_ORDINAL
- /* NULL */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_DURATION
- /* NULL */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_NUMBERING_SYSTEM
- /* NULL */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_PATTERN_RULEBASED
+ /* nullptr */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_SPELLOUT
+ /* nullptr */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_ORDINAL
+ /* nullptr */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_DURATION
+ /* nullptr */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_NUMBERING_SYSTEM
+ /* nullptr */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_PATTERN_RULEBASED
// For UNUM_CURRENCY_ISO and UNUM_CURRENCY_PLURAL,
// the pattern is the same as the pattern of UNUM_CURRENCY
// except for replacing the single currency sign with
@@ -149,18 +149,18 @@ static const icu::number::impl::CldrPatternStyle gFormatCldrStyles[UNUM_FORMAT_S
icu::number::impl::CLDR_PATTERN_STYLE_CURRENCY, // UNUM_CURRENCY_PLURAL
icu::number::impl::CLDR_PATTERN_STYLE_ACCOUNTING, // UNUM_CURRENCY_ACCOUNTING
icu::number::impl::CLDR_PATTERN_STYLE_CURRENCY, // UNUM_CASH_CURRENCY
- /* NULL */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_DECIMAL_COMPACT_SHORT
- /* NULL */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_DECIMAL_COMPACT_LONG
+ /* nullptr */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_DECIMAL_COMPACT_SHORT
+ /* nullptr */ icu::number::impl::CLDR_PATTERN_STYLE_COUNT, // UNUM_DECIMAL_COMPACT_LONG
icu::number::impl::CLDR_PATTERN_STYLE_CURRENCY, // UNUM_CURRENCY_STANDARD
};
// Static hashtable cache of NumberingSystem objects used by NumberFormat
-static UHashtable * NumberingSystem_cache = NULL;
-static icu::UInitOnce gNSCacheInitOnce = U_INITONCE_INITIALIZER;
+static UHashtable * NumberingSystem_cache = nullptr;
+static icu::UInitOnce gNSCacheInitOnce {};
#if !UCONFIG_NO_SERVICE
-static icu::ICULocaleService* gService = NULL;
-static icu::UInitOnce gServiceInitOnce = U_INITONCE_INITIALIZER;
+static icu::ICULocaleService* gService = nullptr;
+static icu::UInitOnce gServiceInitOnce {};
#endif
/**
@@ -172,21 +172,21 @@ deleteNumberingSystem(void *obj) {
delete (icu::NumberingSystem *)obj;
}
-static UBool U_CALLCONV numfmt_cleanup(void) {
+static UBool U_CALLCONV numfmt_cleanup() {
#if !UCONFIG_NO_SERVICE
gServiceInitOnce.reset();
if (gService) {
delete gService;
- gService = NULL;
+ gService = nullptr;
}
#endif
gNSCacheInitOnce.reset();
if (NumberingSystem_cache) {
// delete NumberingSystem_cache;
uhash_close(NumberingSystem_cache);
- NumberingSystem_cache = NULL;
+ NumberingSystem_cache = nullptr;
}
- return TRUE;
+ return true;
}
U_CDECL_END
@@ -210,7 +210,7 @@ SimpleNumberFormatFactory::SimpleNumberFormatFactory(const Locale& locale, UBool
SimpleNumberFormatFactory::~SimpleNumberFormatFactory() {}
-UBool SimpleNumberFormatFactory::visible(void) const {
+UBool SimpleNumberFormatFactory::visible() const {
return _visible;
}
@@ -222,20 +222,20 @@ SimpleNumberFormatFactory::getSupportedIDs(int32_t &count, UErrorCode& status) c
return &_id;
}
count = 0;
- return NULL;
+ return nullptr;
}
#endif /* #if !UCONFIG_NO_SERVICE */
// -------------------------------------
// default constructor
NumberFormat::NumberFormat()
-: fGroupingUsed(TRUE),
+: fGroupingUsed(true),
fMaxIntegerDigits(gDefaultMaxIntegerDigits),
fMinIntegerDigits(1),
fMaxFractionDigits(3), // invariant, >= minFractionDigits
fMinFractionDigits(0),
- fParseIntegerOnly(FALSE),
- fLenient(FALSE),
+ fParseIntegerOnly(false),
+ fLenient(false),
fCapitalizationContext(UDISPCTX_CAPITALIZATION_NONE)
{
fCurrency[0] = 0;
@@ -294,39 +294,39 @@ NumberFormat::operator==(const Format& that) const
#ifdef FMT_DEBUG
// This code makes it easy to determine why two format objects that should
// be equal aren't.
- UBool first = TRUE;
+ UBool first = true;
if (!Format::operator==(that)) {
- if (first) { printf("[ "); first = FALSE; } else { printf(", "); }
+ if (first) { printf("[ "); first = false; } else { printf(", "); }
debug("Format::!=");
}
if (!(fMaxIntegerDigits == other->fMaxIntegerDigits &&
fMinIntegerDigits == other->fMinIntegerDigits)) {
- if (first) { printf("[ "); first = FALSE; } else { printf(", "); }
+ if (first) { printf("[ "); first = false; } else { printf(", "); }
debug("Integer digits !=");
}
if (!(fMaxFractionDigits == other->fMaxFractionDigits &&
fMinFractionDigits == other->fMinFractionDigits)) {
- if (first) { printf("[ "); first = FALSE; } else { printf(", "); }
+ if (first) { printf("[ "); first = false; } else { printf(", "); }
debug("Fraction digits !=");
}
if (!(fGroupingUsed == other->fGroupingUsed)) {
- if (first) { printf("[ "); first = FALSE; } else { printf(", "); }
+ if (first) { printf("[ "); first = false; } else { printf(", "); }
debug("fGroupingUsed != ");
}
if (!(fParseIntegerOnly == other->fParseIntegerOnly)) {
- if (first) { printf("[ "); first = FALSE; } else { printf(", "); }
+ if (first) { printf("[ "); first = false; } else { printf(", "); }
debug("fParseIntegerOnly != ");
}
if (!(u_strcmp(fCurrency, other->fCurrency) == 0)) {
- if (first) { printf("[ "); first = FALSE; } else { printf(", "); }
+ if (first) { printf("[ "); first = false; } else { printf(", "); }
debug("fCurrency !=");
}
if (!(fLenient == other->fLenient)) {
- if (first) { printf("[ "); first = FALSE; } else { printf(", "); }
+ if (first) { printf("[ "); first = false; } else { printf(", "); }
debug("fLenient != ");
}
if (!(fCapitalizationContext == other->fCapitalizationContext)) {
- if (first) { printf("[ "); first = FALSE; } else { printf(", "); }
+ if (first) { printf("[ "); first = false; } else { printf(", "); }
debug("fCapitalizationContext != ");
}
if (!first) { printf(" ]"); }
@@ -474,45 +474,45 @@ NumberFormat::format(StringPiece decimalNum,
*/
class ArgExtractor {
const Formattable* num;
- UChar save[4];
+ char16_t save[4];
UBool fWasCurrency;
public:
ArgExtractor(const NumberFormat& nf, const Formattable& obj, UErrorCode& status);
~ArgExtractor();
- const Formattable* number(void) const;
- const UChar *iso(void) const;
- UBool wasCurrency(void) const;
+ const Formattable* number() const;
+ const char16_t *iso() const;
+ UBool wasCurrency() const;
};
inline const Formattable*
-ArgExtractor::number(void) const {
+ArgExtractor::number() const {
return num;
}
inline UBool
-ArgExtractor::wasCurrency(void) const {
+ArgExtractor::wasCurrency() const {
return fWasCurrency;
}
-inline const UChar *
-ArgExtractor::iso(void) const {
+inline const char16_t *
+ArgExtractor::iso() const {
return save;
}
ArgExtractor::ArgExtractor(const NumberFormat& /*nf*/, const Formattable& obj, UErrorCode& /*status*/)
- : num(&obj), fWasCurrency(FALSE) {
+ : num(&obj), fWasCurrency(false) {
- const UObject* o = obj.getObject(); // most commonly o==NULL
+ const UObject* o = obj.getObject(); // most commonly o==nullptr
const CurrencyAmount* amt;
- if (o != NULL && (amt = dynamic_cast<const CurrencyAmount*>(o)) != NULL) {
+ if (o != nullptr && (amt = dynamic_cast<const CurrencyAmount*>(o)) != nullptr) {
// getISOCurrency() returns a pointer to internal storage, so we
// copy it to retain it across the call to setCurrency().
- //const UChar* curr = amt->getISOCurrency();
+ //const char16_t* curr = amt->getISOCurrency();
u_strcpy(save, amt->getISOCurrency());
num = &amt->getNumber();
- fWasCurrency=TRUE;
+ fWasCurrency=true;
} else {
save[0]=0;
}
@@ -564,7 +564,7 @@ NumberFormat::format(const Formattable& obj,
ArgExtractor arg(*this, obj, status);
const Formattable *n = arg.number();
- const UChar *iso = arg.iso();
+ const char16_t *iso = arg.iso();
if(arg.wasCurrency() && u_strcmp(iso, getCurrency())) {
// trying to format a different currency.
@@ -575,7 +575,7 @@ NumberFormat::format(const Formattable& obj,
return cloneFmt->format(*n, appendTo, pos, status);
}
- if (n->isNumeric() && n->getDecimalQuantity() != NULL) {
+ if (n->isNumeric() && n->getDecimalQuantity() != nullptr) {
// Decimal Number. We will have a DigitList available if the value was
// set to a decimal number, or if the value originated with a parse.
//
@@ -619,7 +619,7 @@ NumberFormat::format(const Formattable& obj,
ArgExtractor arg(*this, obj, status);
const Formattable *n = arg.number();
- const UChar *iso = arg.iso();
+ const char16_t *iso = arg.iso();
if(arg.wasCurrency() && u_strcmp(iso, getCurrency())) {
// trying to format a different currency.
@@ -630,7 +630,7 @@ NumberFormat::format(const Formattable& obj,
return cloneFmt->format(*n, appendTo, posIter, status);
}
- if (n->isNumeric() && n->getDecimalQuantity() != NULL) {
+ if (n->isNumeric() && n->getDecimalQuantity() != nullptr) {
// Decimal Number
format(*n->getDecimalQuantity(), appendTo, posIter, status);
} else {
@@ -733,7 +733,7 @@ CurrencyAmount* NumberFormat::parseCurrency(const UnicodeString& text,
int32_t start = pos.getIndex();
parse(text, parseResult, pos);
if (pos.getIndex() != start) {
- UChar curr[4];
+ char16_t curr[4];
UErrorCode ec = U_ZERO_ERROR;
getEffectiveCurrency(curr, ec);
if (U_SUCCESS(ec)) {
@@ -745,7 +745,7 @@ CurrencyAmount* NumberFormat::parseCurrency(const UnicodeString& text,
}
}
}
- return NULL;
+ return nullptr;
}
// -------------------------------------
@@ -878,7 +878,7 @@ public:
NFFactory(NumberFormatFactory* delegate)
: LocaleKeyFactory(delegate->visible() ? VISIBLE : INVISIBLE)
, _delegate(delegate)
- , _ids(NULL)
+ , _ids(nullptr)
{
}
@@ -887,18 +887,19 @@ public:
virtual UObject* create(const ICUServiceKey& key, const ICUService* service, UErrorCode& status) const override
{
if (handlesKey(key, status)) {
- const LocaleKey& lkey = (const LocaleKey&)key;
+ const LocaleKey* lkey = dynamic_cast<const LocaleKey*>(&key);
+ U_ASSERT(lkey != nullptr);
Locale loc;
- lkey.canonicalLocale(loc);
- int32_t kind = lkey.kind();
+ lkey->canonicalLocale(loc);
+ int32_t kind = lkey->kind();
UObject* result = _delegate->createFormat(loc, (UNumberFormatStyle)kind);
- if (result == NULL) {
- result = service->getKey((ICUServiceKey&)key /* cast away const */, NULL, this, status);
+ if (result == nullptr) {
+ result = service->getKey(const_cast<ICUServiceKey&>(key) /* cast away const */, nullptr, this, status);
}
return result;
}
- return NULL;
+ return nullptr;
}
protected:
@@ -922,7 +923,7 @@ protected:
}
return _ids;
}
- return NULL;
+ return nullptr;
}
};
@@ -948,10 +949,11 @@ public:
}
virtual UObject* handleDefault(const ICUServiceKey& key, UnicodeString* /* actualID */, UErrorCode& status) const override {
- LocaleKey& lkey = (LocaleKey&)key;
- int32_t kind = lkey.kind();
+ const LocaleKey* lkey = dynamic_cast<const LocaleKey*>(&key);
+ U_ASSERT(lkey != nullptr);
+ int32_t kind = lkey->kind();
Locale loc;
- lkey.currentLocale(loc);
+ lkey->currentLocale(loc);
return NumberFormat::makeInstance(loc, (UNumberFormatStyle)kind, status);
}
@@ -965,20 +967,20 @@ ICUNumberFormatService::~ICUNumberFormatService() {}
// -------------------------------------
static void U_CALLCONV initNumberFormatService() {
- U_ASSERT(gService == NULL);
+ U_ASSERT(gService == nullptr);
ucln_i18n_registerCleanup(UCLN_I18N_NUMFMT, numfmt_cleanup);
gService = new ICUNumberFormatService();
}
static ICULocaleService*
-getNumberFormatService(void)
+getNumberFormatService()
{
umtx_initOnce(gServiceInitOnce, &initNumberFormatService);
return gService;
}
static UBool haveService() {
- return !gServiceInitOnce.isReset() && (getNumberFormatService() != NULL);
+ return !gServiceInitOnce.isReset() && (getNumberFormatService() != nullptr);
}
// -------------------------------------
@@ -993,12 +995,12 @@ NumberFormat::registerFactory(NumberFormatFactory* toAdopt, UErrorCode& status)
ICULocaleService *service = getNumberFormatService();
if (service) {
NFFactory *tempnnf = new NFFactory(toAdopt);
- if (tempnnf != NULL) {
+ if (tempnnf != nullptr) {
return service->registerFactory(tempnnf, status);
}
}
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
// -------------------------------------
@@ -1007,25 +1009,25 @@ UBool U_EXPORT2
NumberFormat::unregister(URegistryKey key, UErrorCode& status)
{
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (haveService()) {
return gService->unregister(key, status);
} else {
status = U_ILLEGAL_ARGUMENT_ERROR;
- return FALSE;
+ return false;
}
}
// -------------------------------------
StringEnumeration* U_EXPORT2
-NumberFormat::getAvailableLocales(void)
+NumberFormat::getAvailableLocales()
{
ICULocaleService *service = getNumberFormatService();
if (service) {
return service->getAvailableLocales();
}
- return NULL; // no way to return error condition
+ return nullptr; // no way to return error condition
}
#endif /* UCONFIG_NO_SERVICE */
// -------------------------------------
@@ -1057,11 +1059,11 @@ NumberFormat::createInstance(const Locale& loc, UNumberFormatStyle kind, UErrorC
}
const SharedNumberFormat *shared = createSharedInstance(loc, kind, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
NumberFormat *result = (*shared)->clone();
shared->removeRef();
- if (result == NULL) {
+ if (result == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
return result;
@@ -1177,7 +1179,7 @@ NumberFormat::setMinimumFractionDigits(int32_t newValue)
// -------------------------------------
-void NumberFormat::setCurrency(const UChar* theCurrency, UErrorCode& ec) {
+void NumberFormat::setCurrency(const char16_t* theCurrency, UErrorCode& ec) {
if (U_FAILURE(ec)) {
return;
}
@@ -1193,14 +1195,14 @@ const char16_t* NumberFormat::getCurrency() const {
return fCurrency;
}
-void NumberFormat::getEffectiveCurrency(UChar* result, UErrorCode& ec) const {
- const UChar* c = getCurrency();
+void NumberFormat::getEffectiveCurrency(char16_t* result, UErrorCode& ec) const {
+ const char16_t* c = getCurrency();
if (*c != 0) {
u_strncpy(result, c, 3);
result[3] = 0;
} else {
const char* loc = getLocaleID(ULOC_VALID_LOCALE, ec);
- if (loc == NULL) {
+ if (loc == nullptr) {
loc = uloc_getDefault();
}
ucurr_forLocale(loc, result, 4, &ec);
@@ -1239,16 +1241,16 @@ UDisplayContext NumberFormat::getContext(UDisplayContextType type, UErrorCode& s
// or percent) for the desired locale.
static void U_CALLCONV nscacheInit() {
- U_ASSERT(NumberingSystem_cache == NULL);
+ U_ASSERT(NumberingSystem_cache == nullptr);
ucln_i18n_registerCleanup(UCLN_I18N_NUMFMT, numfmt_cleanup);
UErrorCode status = U_ZERO_ERROR;
NumberingSystem_cache = uhash_open(uhash_hashLong,
uhash_compareLong,
- NULL,
+ nullptr,
&status);
if (U_FAILURE(status)) {
// Number Format code will run with no cache if creation fails.
- NumberingSystem_cache = NULL;
+ NumberingSystem_cache = nullptr;
return;
}
uhash_setValueDeleter(NumberingSystem_cache, deleteNumberingSystem);
@@ -1261,13 +1263,13 @@ const SharedNumberFormat *LocaleCacheKey<SharedNumberFormat>::createObject(
NumberFormat *nf = NumberFormat::internalCreateInstance(
localeId, UNUM_DECIMAL, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
SharedNumberFormat *result = new SharedNumberFormat(nf);
- if (result == NULL) {
+ if (result == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
delete nf;
- return NULL;
+ return nullptr;
}
result->addRef();
return result;
@@ -1276,20 +1278,20 @@ const SharedNumberFormat *LocaleCacheKey<SharedNumberFormat>::createObject(
const SharedNumberFormat* U_EXPORT2
NumberFormat::createSharedInstance(const Locale& loc, UNumberFormatStyle kind, UErrorCode& status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
if (kind != UNUM_DECIMAL) {
status = U_UNSUPPORTED_ERROR;
- return NULL;
+ return nullptr;
}
- const SharedNumberFormat *result = NULL;
+ const SharedNumberFormat *result = nullptr;
UnifiedCache::getByLocale(loc, result, status);
return result;
}
UBool
NumberFormat::isStyleSupported(UNumberFormatStyle style) {
- return gLastResortNumberPatterns[style] != NULL;
+ return gLastResortNumberPatterns[style] != nullptr;
}
NumberFormat*
@@ -1304,11 +1306,19 @@ NumberFormat::makeInstance(const Locale& desiredLocale,
UNumberFormatStyle style,
UBool mustBeDecimalFormat,
UErrorCode& status) {
- if (U_FAILURE(status)) return NULL;
+ if (U_FAILURE(status)) return nullptr;
if (style < 0 || style >= UNUM_FORMAT_STYLE_COUNT) {
status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
+ }
+
+ // For the purposes of general number formatting, UNUM_NUMBERING_SYSTEM should behave the same
+ // was as UNUM_DECIMAL. In both cases, you get either a DecimalFormat or a RuleBasedNumberFormat
+ // depending on the locale's numbering system (either the default one for the locale or a specific
+ // one specified by using the "@numbers=" or "-u-nu-" parameter in the locale ID.
+ if (style == UNUM_NUMBERING_SYSTEM) {
+ style = UNUM_DECIMAL;
}
// Some styles are not supported. This is a result of merging
@@ -1319,7 +1329,7 @@ NumberFormat::makeInstance(const Locale& desiredLocale,
// because this method does not take a pattern string.
if (!isStyleSupported(style)) {
status = U_UNSUPPORTED_ERROR;
- return NULL;
+ return nullptr;
}
#if U_PLATFORM_USES_ONLY_WIN32_API
@@ -1329,11 +1339,11 @@ NumberFormat::makeInstance(const Locale& desiredLocale,
// if the locale has "@compat=host", create a host-specific NumberFormat
if (U_SUCCESS(status) && count > 0 && uprv_strcmp(buffer, "host") == 0) {
- UBool curr = TRUE;
+ UBool curr = true;
switch (style) {
case UNUM_DECIMAL:
- curr = FALSE;
+ curr = false;
// fall-through
U_FALLTHROUGH;
@@ -1361,15 +1371,15 @@ NumberFormat::makeInstance(const Locale& desiredLocale,
// Get cached numbering system
LocalPointer<NumberingSystem> ownedNs;
- NumberingSystem *ns = NULL;
- if (NumberingSystem_cache != NULL) {
+ NumberingSystem *ns = nullptr;
+ if (NumberingSystem_cache != nullptr) {
// TODO: Bad hash key usage, see ticket #8504.
int32_t hashKey = desiredLocale.hashCode();
static UMutex nscacheMutex;
Mutex lock(&nscacheMutex);
ns = (NumberingSystem *)uhash_iget(NumberingSystem_cache, hashKey);
- if (ns == NULL) {
+ if (ns == nullptr) {
ns = NumberingSystem::createInstance(desiredLocale,status);
uhash_iput(NumberingSystem_cache, hashKey, (void*)ns, &status);
}
@@ -1380,25 +1390,25 @@ NumberFormat::makeInstance(const Locale& desiredLocale,
// check results of getting a numbering system
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
if (mustBeDecimalFormat && ns->isAlgorithmic()) {
status = U_UNSUPPORTED_ERROR;
- return NULL;
+ return nullptr;
}
LocalPointer<DecimalFormatSymbols> symbolsToAdopt;
UnicodeString pattern;
- LocalUResourceBundlePointer ownedResource(ures_open(NULL, desiredLocale.getName(), &status));
+ LocalUResourceBundlePointer ownedResource(ures_open(nullptr, desiredLocale.getName(), &status));
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
else {
// Loads the decimal symbols of the desired locale.
symbolsToAdopt.adoptInsteadAndCheckErrorCode(new DecimalFormatSymbols(desiredLocale, status), status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
// Load the pattern from data using the common library function
@@ -1407,15 +1417,15 @@ NumberFormat::makeInstance(const Locale& desiredLocale,
ns->getName(),
gFormatCldrStyles[style],
status);
- pattern = UnicodeString(TRUE, patternPtr, -1);
+ pattern = UnicodeString(true, patternPtr, -1);
}
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
if(style==UNUM_CURRENCY || style == UNUM_CURRENCY_ISO || style == UNUM_CURRENCY_ACCOUNTING
|| style == UNUM_CASH_CURRENCY || style == UNUM_CURRENCY_STANDARD){
- const UChar* currPattern = symbolsToAdopt->getCurrencyPattern();
- if(currPattern!=NULL){
+ const char16_t* currPattern = symbolsToAdopt->getCurrencyPattern();
+ if(currPattern!=nullptr){
pattern.setTo(currPattern, u_strlen(currPattern));
}
}
@@ -1450,9 +1460,9 @@ NumberFormat::makeInstance(const Locale& desiredLocale,
}
RuleBasedNumberFormat *r = new RuleBasedNumberFormat(desiredRulesType,nsLoc,status);
- if (r == NULL) {
+ if (r == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
r->setDefaultRuleSet(nsRuleSetName,status);
f.adoptInstead(r);
@@ -1460,8 +1470,8 @@ NumberFormat::makeInstance(const Locale& desiredLocale,
// replace single currency sign in the pattern with double currency sign
// if the style is UNUM_CURRENCY_ISO
if (style == UNUM_CURRENCY_ISO) {
- pattern.findAndReplace(UnicodeString(TRUE, gSingleCurrencySign, 1),
- UnicodeString(TRUE, gDoubleCurrencySign, 2));
+ pattern.findAndReplace(UnicodeString(true, gSingleCurrencySign, 1),
+ UnicodeString(true, gDoubleCurrencySign, 2));
}
// "new DecimalFormat()" does not adopt the symbols argument if its memory allocation fails.
@@ -1496,7 +1506,7 @@ NumberFormat::makeInstance(const Locale& desiredLocale,
f->setLocaleIDs(ures_getLocaleByType(ownedResource.getAlias(), ULOC_VALID_LOCALE, &status),
ures_getLocaleByType(ownedResource.getAlias(), ULOC_ACTUAL_LOCALE, &status));
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
return f.orphan();
}
diff --git a/contrib/libs/icu/i18n/numparse_affixes.cpp b/contrib/libs/icu/i18n/numparse_affixes.cpp
index 1414006598..ad3d48b473 100644
--- a/contrib/libs/icu/i18n/numparse_affixes.cpp
+++ b/contrib/libs/icu/i18n/numparse_affixes.cpp
@@ -169,6 +169,10 @@ NumberParseMatcher* AffixTokenMatcherWarehouse::nextCodePointMatcher(UChar32 cp,
return result;
}
+bool AffixTokenMatcherWarehouse::hasEmptyCurrencySymbol() const {
+ return fSetupData->currencySymbols.hasEmptyCurrencySymbol();
+}
+
CodePointMatcher::CodePointMatcher(UChar32 cp)
: fCp(cp) {}
@@ -280,8 +284,16 @@ void AffixMatcherWarehouse::createAffixMatchers(const AffixPatternProvider& patt
AffixPatternMatcher* posSuffix = nullptr;
// Pre-process the affix strings to resolve LDML rules like sign display.
- for (int8_t typeInt = 0; typeInt < PATTERN_SIGN_TYPE_COUNT; typeInt++) {
- auto type = static_cast<PatternSignType>(typeInt);
+ for (int8_t typeInt = 0; typeInt < PATTERN_SIGN_TYPE_COUNT * 2; typeInt++) {
+ auto type = static_cast<PatternSignType>(typeInt / 2);
+ bool dropCurrencySymbols = (typeInt % 2) == 1;
+
+ if (dropCurrencySymbols && !patternInfo.hasCurrencySign()) {
+ continue;
+ }
+ if (dropCurrencySymbols && !fTokenWarehouse->hasEmptyCurrencySymbol()) {
+ continue;
+ }
// Skip affixes in some cases
if (type == PATTERN_SIGN_TYPE_POS
@@ -297,7 +309,7 @@ void AffixMatcherWarehouse::createAffixMatchers(const AffixPatternProvider& patt
// TODO: Handle approximately sign?
bool hasPrefix = false;
PatternStringUtils::patternInfoToStringBuilder(
- patternInfo, true, type, false, StandardPlural::OTHER, false, sb);
+ patternInfo, true, type, false, StandardPlural::OTHER, false, dropCurrencySymbols, sb);
fAffixPatternMatchers[numAffixPatternMatchers] = AffixPatternMatcher::fromAffixPattern(
sb, *fTokenWarehouse, parseFlags, &hasPrefix, status);
AffixPatternMatcher* prefix = hasPrefix ? &fAffixPatternMatchers[numAffixPatternMatchers++]
@@ -307,7 +319,7 @@ void AffixMatcherWarehouse::createAffixMatchers(const AffixPatternProvider& patt
// TODO: Handle approximately sign?
bool hasSuffix = false;
PatternStringUtils::patternInfoToStringBuilder(
- patternInfo, false, type, false, StandardPlural::OTHER, false, sb);
+ patternInfo, false, type, false, StandardPlural::OTHER, false, dropCurrencySymbols, sb);
fAffixPatternMatchers[numAffixPatternMatchers] = AffixPatternMatcher::fromAffixPattern(
sb, *fTokenWarehouse, parseFlags, &hasSuffix, status);
AffixPatternMatcher* suffix = hasSuffix ? &fAffixPatternMatchers[numAffixPatternMatchers++]
diff --git a/contrib/libs/icu/i18n/numparse_affixes.h b/contrib/libs/icu/i18n/numparse_affixes.h
index a82b731ab5..81b633c262 100644
--- a/contrib/libs/icu/i18n/numparse_affixes.h
+++ b/contrib/libs/icu/i18n/numparse_affixes.h
@@ -53,7 +53,7 @@ class U_I18N_API CodePointMatcher : public NumberParseMatcher, public UMemory {
// Note: These need to be outside of the numparse::impl 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<numparse::impl::CodePointMatcher*, 8>;
-template class U_I18N_API MaybeStackArray<UChar, 4>;
+template class U_I18N_API MaybeStackArray<char16_t, 4>;
template class U_I18N_API MemoryPool<numparse::impl::CodePointMatcher, 8>;
template class U_I18N_API numparse::impl::CompactUnicodeString<4>;
#endif
@@ -101,6 +101,8 @@ class U_I18N_API AffixTokenMatcherWarehouse : public UMemory {
NumberParseMatcher* nextCodePointMatcher(UChar32 cp, UErrorCode& status);
+ bool hasEmptyCurrencySymbol() const;
+
private:
// NOTE: The following field may be unsafe to access after construction is done!
const AffixTokenMatcherSetupData* fSetupData;
@@ -204,10 +206,12 @@ class AffixMatcherWarehouse {
UErrorCode& status);
private:
- // 9 is the limit: positive, zero, and negative, each with prefix, suffix, and prefix+suffix
- AffixMatcher fAffixMatchers[9];
- // 6 is the limit: positive, zero, and negative, a prefix and a suffix for each
- AffixPatternMatcher fAffixPatternMatchers[6];
+ // 18 is the limit: positive, zero, and negative, each with prefix, suffix, and prefix+suffix,
+ // and doubled since there may be an empty currency symbol
+ AffixMatcher fAffixMatchers[18];
+ // 6 is the limit: positive, zero, and negative, a prefix and a suffix for each,
+ // and doubled since there may be an empty currency symbol
+ AffixPatternMatcher fAffixPatternMatchers[12];
// Reference to the warehouse for tokens used by the AffixPatternMatchers
AffixTokenMatcherWarehouse* fTokenWarehouse;
diff --git a/contrib/libs/icu/i18n/numparse_currency.h b/contrib/libs/icu/i18n/numparse_currency.h
index a94943312f..4e99334a31 100644
--- a/contrib/libs/icu/i18n/numparse_currency.h
+++ b/contrib/libs/icu/i18n/numparse_currency.h
@@ -44,7 +44,7 @@ class U_I18N_API CombinedCurrencyMatcher : public NumberParseMatcher, public UMe
UnicodeString toString() const override;
private:
- UChar fCurrencyCode[4];
+ char16_t fCurrencyCode[4];
UnicodeString fCurrency1;
UnicodeString fCurrency2;
diff --git a/contrib/libs/icu/i18n/numparse_types.h b/contrib/libs/icu/i18n/numparse_types.h
index 623f0e80f1..8e881793fd 100644
--- a/contrib/libs/icu/i18n/numparse_types.h
+++ b/contrib/libs/icu/i18n/numparse_types.h
@@ -67,7 +67,7 @@ class CompactUnicodeString {
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());
+ uprv_memcpy(fBuffer.getAlias(), text.getBuffer(), sizeof(char16_t) * text.length());
fBuffer[text.length()] = 0;
}
@@ -81,7 +81,7 @@ class CompactUnicodeString {
}
private:
- MaybeStackArray<UChar, stackCapacity> fBuffer;
+ MaybeStackArray<char16_t, stackCapacity> fBuffer;
};
@@ -125,7 +125,7 @@ class U_I18N_API ParsedNumber {
/**
* The currency that got consumed.
*/
- UChar currencyCode[4];
+ char16_t currencyCode[4];
ParsedNumber();
diff --git a/contrib/libs/icu/i18n/numparse_utils.h b/contrib/libs/icu/i18n/numparse_utils.h
index 162954bae0..8fda4f4369 100644
--- a/contrib/libs/icu/i18n/numparse_utils.h
+++ b/contrib/libs/icu/i18n/numparse_utils.h
@@ -28,8 +28,8 @@ inline static void putLeadCodePoint(const UnicodeString& input, UnicodeSet* outp
}
}
-inline static void copyCurrencyCode(UChar* dest, const UChar* src) {
- uprv_memcpy(dest, src, sizeof(UChar) * 3);
+inline static void copyCurrencyCode(char16_t* dest, const char16_t* src) {
+ uprv_memcpy(dest, src, sizeof(char16_t) * 3);
dest[3] = 0;
}
diff --git a/contrib/libs/icu/i18n/numparse_validators.h b/contrib/libs/icu/i18n/numparse_validators.h
index 5d43b779d0..9bb4b482b5 100644
--- a/contrib/libs/icu/i18n/numparse_validators.h
+++ b/contrib/libs/icu/i18n/numparse_validators.h
@@ -16,33 +16,33 @@ namespace impl {
class ValidationMatcher : public NumberParseMatcher {
public:
- bool match(StringSegment&, ParsedNumber&, UErrorCode&) const U_OVERRIDE {
+ bool match(StringSegment&, ParsedNumber&, UErrorCode&) const override {
// No-op
return false;
}
- bool smokeTest(const StringSegment&) const U_OVERRIDE {
+ bool smokeTest(const StringSegment&) const override {
// No-op
return false;
}
- void postProcess(ParsedNumber& result) const U_OVERRIDE = 0;
+ void postProcess(ParsedNumber& result) const override = 0;
};
class RequireAffixValidator : public ValidationMatcher, public UMemory {
public:
- void postProcess(ParsedNumber& result) const U_OVERRIDE;
+ void postProcess(ParsedNumber& result) const override;
- UnicodeString toString() const U_OVERRIDE;
+ UnicodeString toString() const override;
};
class RequireCurrencyValidator : public ValidationMatcher, public UMemory {
public:
- void postProcess(ParsedNumber& result) const U_OVERRIDE;
+ void postProcess(ParsedNumber& result) const override;
- UnicodeString toString() const U_OVERRIDE;
+ UnicodeString toString() const override;
};
@@ -52,9 +52,9 @@ class RequireDecimalSeparatorValidator : public ValidationMatcher, public UMemor
RequireDecimalSeparatorValidator(bool patternHasDecimalSeparator);
- void postProcess(ParsedNumber& result) const U_OVERRIDE;
+ void postProcess(ParsedNumber& result) const override;
- UnicodeString toString() const U_OVERRIDE;
+ UnicodeString toString() const override;
private:
bool fPatternHasDecimalSeparator;
@@ -63,9 +63,9 @@ class RequireDecimalSeparatorValidator : public ValidationMatcher, public UMemor
class RequireNumberValidator : public ValidationMatcher, public UMemory {
public:
- void postProcess(ParsedNumber& result) const U_OVERRIDE;
+ void postProcess(ParsedNumber& result) const override;
- UnicodeString toString() const U_OVERRIDE;
+ UnicodeString toString() const override;
};
@@ -78,9 +78,9 @@ class MultiplierParseHandler : public ValidationMatcher, public UMemory {
MultiplierParseHandler(::icu::number::Scale multiplier);
- void postProcess(ParsedNumber& result) const U_OVERRIDE;
+ void postProcess(ParsedNumber& result) const override;
- UnicodeString toString() const U_OVERRIDE;
+ UnicodeString toString() const override;
private:
::icu::number::Scale fMultiplier;
diff --git a/contrib/libs/icu/i18n/numrange_capi.cpp b/contrib/libs/icu/i18n/numrange_capi.cpp
index bd3a9ef5e8..9222969eb4 100644
--- a/contrib/libs/icu/i18n/numrange_capi.cpp
+++ b/contrib/libs/icu/i18n/numrange_capi.cpp
@@ -83,7 +83,7 @@ const UFormattedNumberRangeData* number::impl::validateUFormattedNumberRange(
U_CAPI UNumberRangeFormatter* U_EXPORT2
unumrf_openForSkeletonWithCollapseAndIdentityFallback(
- const UChar* skeleton,
+ const char16_t* skeleton,
int32_t skeletonLen,
UNumberRangeCollapse collapse,
UNumberRangeIdentityFallback identityFallback,
@@ -97,8 +97,9 @@ unumrf_openForSkeletonWithCollapseAndIdentityFallback(
}
// Readonly-alias constructor (first argument is whether we are NUL-terminated)
UnicodeString skeletonString(skeletonLen == -1, skeleton, skeletonLen);
+ UParseError tempParseError;
impl->fFormatter = NumberRangeFormatter::withLocale(locale)
- .numberFormatterBoth(NumberFormatter::forSkeleton(skeletonString, *perror, *ec))
+ .numberFormatterBoth(NumberFormatter::forSkeleton(skeletonString, (perror == nullptr) ? tempParseError : *perror, *ec))
.collapse(collapse)
.identityFallback(identityFallback);
return impl->exportForC();
diff --git a/contrib/libs/icu/i18n/numrange_fluent.cpp b/contrib/libs/icu/i18n/numrange_fluent.cpp
index f1060b3c21..0944f3024f 100644
--- a/contrib/libs/icu/i18n/numrange_fluent.cpp
+++ b/contrib/libs/icu/i18n/numrange_fluent.cpp
@@ -204,10 +204,10 @@ UnlocalizedNumberRangeFormatter::UnlocalizedNumberRangeFormatter(const NFS<UNF>&
}
// Make default copy constructor call the NumberRangeFormatterSettings copy constructor.
-UnlocalizedNumberRangeFormatter::UnlocalizedNumberRangeFormatter(UNF&& src) U_NOEXCEPT
+UnlocalizedNumberRangeFormatter::UnlocalizedNumberRangeFormatter(UNF&& src) noexcept
: UNF(static_cast<NFS<UNF>&&>(src)) {}
-UnlocalizedNumberRangeFormatter::UnlocalizedNumberRangeFormatter(NFS<UNF>&& src) U_NOEXCEPT
+UnlocalizedNumberRangeFormatter::UnlocalizedNumberRangeFormatter(NFS<UNF>&& src) noexcept
: NFS<UNF>(std::move(src)) {
// No additional fields to assign
}
@@ -218,7 +218,7 @@ UnlocalizedNumberRangeFormatter& UnlocalizedNumberRangeFormatter::operator=(cons
return *this;
}
-UnlocalizedNumberRangeFormatter& UnlocalizedNumberRangeFormatter::operator=(UNF&& src) U_NOEXCEPT {
+UnlocalizedNumberRangeFormatter& UnlocalizedNumberRangeFormatter::operator=(UNF&& src) noexcept {
NFS<UNF>::operator=(static_cast<NFS<UNF>&&>(src));
// No additional fields to assign
return *this;
@@ -233,10 +233,10 @@ LocalizedNumberRangeFormatter::LocalizedNumberRangeFormatter(const NFS<LNF>& oth
// No additional fields to assign
}
-LocalizedNumberRangeFormatter::LocalizedNumberRangeFormatter(LocalizedNumberRangeFormatter&& src) U_NOEXCEPT
+LocalizedNumberRangeFormatter::LocalizedNumberRangeFormatter(LocalizedNumberRangeFormatter&& src) noexcept
: LNF(static_cast<NFS<LNF>&&>(src)) {}
-LocalizedNumberRangeFormatter::LocalizedNumberRangeFormatter(NFS<LNF>&& src) U_NOEXCEPT
+LocalizedNumberRangeFormatter::LocalizedNumberRangeFormatter(NFS<LNF>&& src) noexcept
: NFS<LNF>(std::move(src)) {
// Steal the compiled formatter
LNF&& _src = static_cast<LNF&&>(src);
@@ -252,7 +252,7 @@ LocalizedNumberRangeFormatter& LocalizedNumberRangeFormatter::operator=(const LN
return *this;
}
-LocalizedNumberRangeFormatter& LocalizedNumberRangeFormatter::operator=(LNF&& src) U_NOEXCEPT {
+LocalizedNumberRangeFormatter& LocalizedNumberRangeFormatter::operator=(LNF&& src) noexcept {
NFS<LNF>::operator=(static_cast<NFS<LNF>&&>(src));
// Steal the compiled formatter
auto* stolen = src.fAtomicFormatter.exchange(nullptr);
@@ -354,6 +354,7 @@ LocalizedNumberRangeFormatter::getFormatter(UErrorCode& status) const {
// Try computing the formatter on our own
auto* temp = new NumberRangeFormatterImpl(fMacros, status);
if (U_FAILURE(status)) {
+ delete temp;
return nullptr;
}
if (temp == nullptr) {
diff --git a/contrib/libs/icu/i18n/numrange_impl.cpp b/contrib/libs/icu/i18n/numrange_impl.cpp
index 3c440c193c..002a8b2a21 100644
--- a/contrib/libs/icu/i18n/numrange_impl.cpp
+++ b/contrib/libs/icu/i18n/numrange_impl.cpp
@@ -38,7 +38,7 @@ class NumberRangeDataSink : public ResourceSink {
public:
NumberRangeDataSink(NumberRangeData& data) : fData(data) {}
- void put(const char* key, ResourceValue& value, UBool /*noFallback*/, UErrorCode& status) U_OVERRIDE {
+ void put(const char* key, ResourceValue& value, UBool /*noFallback*/, UErrorCode& status) override {
ResourceTable miscTable = value.getTable(status);
if (U_FAILURE(status)) { return; }
for (int i = 0; miscTable.getKeyAndValue(i, key, value); i++) {
@@ -92,7 +92,7 @@ class NumberRangeDataSink : public ResourceSink {
void getNumberRangeData(const char* localeName, const char* nsName, NumberRangeData& data, UErrorCode& status) {
if (U_FAILURE(status)) { return; }
- LocalUResourceBundlePointer rb(ures_open(NULL, localeName, &status));
+ LocalUResourceBundlePointer rb(ures_open(nullptr, localeName, &status));
if (U_FAILURE(status)) { return; }
NumberRangeDataSink sink(data);
@@ -130,7 +130,7 @@ NumberRangeFormatterImpl::NumberRangeFormatterImpl(const RangeMacroProps& macros
fApproximatelyFormatter(status) {
const char* nsName = formatterImpl1.getRawMicroProps().nsName;
- if (uprv_strcmp(nsName, formatterImpl2.getRawMicroProps().nsName) != 0) {
+ if (!fSameFormatters && uprv_strcmp(nsName, formatterImpl2.getRawMicroProps().nsName) != 0) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@@ -239,7 +239,7 @@ void NumberRangeFormatterImpl::formatSingleValue(UFormattedNumberRangeData& data
UErrorCode& status) const {
if (U_FAILURE(status)) { return; }
if (fSameFormatters) {
- int32_t length = NumberFormatterImpl::writeNumber(micros1, data.quantity1, data.getStringRef(), 0, status);
+ int32_t length = NumberFormatterImpl::writeNumber(micros1.simple, data.quantity1, data.getStringRef(), 0, status);
NumberFormatterImpl::writeAffixes(micros1, data.getStringRef(), 0, length, status);
} else {
formatRange(data, micros1, micros2, status);
@@ -256,7 +256,7 @@ void NumberRangeFormatterImpl::formatApproximately (UFormattedNumberRangeData& d
MicroProps microsAppx;
data.quantity1.resetExponent();
fApproximatelyFormatter.preProcess(data.quantity1, microsAppx, status);
- int32_t length = NumberFormatterImpl::writeNumber(microsAppx, data.quantity1, data.getStringRef(), 0, status);
+ int32_t length = NumberFormatterImpl::writeNumber(microsAppx.simple, data.quantity1, data.getStringRef(), 0, status);
length += microsAppx.modInner->apply(data.getStringRef(), 0, length, status);
length += microsAppx.modMiddle->apply(data.getStringRef(), 0, length, status);
microsAppx.modOuter->apply(data.getStringRef(), 0, length, status);
@@ -384,10 +384,10 @@ void NumberRangeFormatterImpl::formatRange(UFormattedNumberRangeData& data,
}
}
- length1 += NumberFormatterImpl::writeNumber(micros1, data.quantity1, string, UPRV_INDEX_0, status);
+ length1 += NumberFormatterImpl::writeNumber(micros1.simple, data.quantity1, string, UPRV_INDEX_0, status);
// ICU-21684: Write the second number to a temp string to avoid repeated insert operations
FormattedStringBuilder tempString;
- NumberFormatterImpl::writeNumber(micros2, data.quantity2, tempString, 0, status);
+ NumberFormatterImpl::writeNumber(micros2.simple, data.quantity2, tempString, 0, status);
length2 += string.insert(UPRV_INDEX_2, tempString, status);
// TODO: Support padding?
diff --git a/contrib/libs/icu/i18n/numsys.cpp b/contrib/libs/icu/i18n/numsys.cpp
index 44aaf8e2a5..0d5c43e4b2 100644
--- a/contrib/libs/icu/i18n/numsys.cpp
+++ b/contrib/libs/icu/i18n/numsys.cpp
@@ -61,7 +61,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(NumsysNameEnumeration)
NumberingSystem::NumberingSystem() {
radix = 10;
- algorithmic = FALSE;
+ algorithmic = false;
UnicodeString defaultDigits = DEFAULT_DIGITS;
desc.setTo(defaultDigits);
uprv_strcpy(name,gLatn);
@@ -116,8 +116,8 @@ NumberingSystem::createInstance(const Locale & inLocale, UErrorCode& status) {
return nullptr;
}
- UBool nsResolved = TRUE;
- UBool usingFallback = FALSE;
+ UBool nsResolved = true;
+ UBool usingFallback = false;
char buffer[ULOC_KEYWORDS_CAPACITY] = "";
int32_t count = inLocale.getKeywordValue("numbers", buffer, sizeof(buffer), status);
if (U_FAILURE(status) || status == U_STRING_NOT_TERMINATED_WARNING) {
@@ -130,11 +130,11 @@ NumberingSystem::createInstance(const Locale & inLocale, UErrorCode& status) {
buffer[count] = '\0'; // Make sure it is null terminated.
if ( !uprv_strcmp(buffer,gDefault) || !uprv_strcmp(buffer,gNative) ||
!uprv_strcmp(buffer,gTraditional) || !uprv_strcmp(buffer,gFinance)) {
- nsResolved = FALSE;
+ nsResolved = false;
}
} else {
uprv_strcpy(buffer, gDefault);
- nsResolved = FALSE;
+ nsResolved = false;
}
if (!nsResolved) { // Resolve the numbering system ( default, native, traditional or finance ) into a "real" numbering system
@@ -149,7 +149,7 @@ NumberingSystem::createInstance(const Locale & inLocale, UErrorCode& status) {
while (!nsResolved) {
localStatus = U_ZERO_ERROR;
count = 0;
- const UChar *nsName = ures_getStringByKeyWithFallback(numberElementsRes.getAlias(), buffer, &count, &localStatus);
+ const char16_t *nsName = ures_getStringByKeyWithFallback(numberElementsRes.getAlias(), buffer, &count, &localStatus);
// Don't stomp on the catastrophic failure of OOM.
if (localStatus == U_MEMORY_ALLOCATION_ERROR) {
status = U_MEMORY_ALLOCATION_ERROR;
@@ -158,7 +158,7 @@ NumberingSystem::createInstance(const Locale & inLocale, UErrorCode& status) {
if ( count > 0 && count < ULOC_KEYWORDS_CAPACITY ) { // numbering system found
u_UCharsToChars(nsName, buffer, count);
buffer[count] = '\0'; // Make sure it is null terminated.
- nsResolved = TRUE;
+ nsResolved = true;
}
if (!nsResolved) { // Fallback behavior per TR35 - traditional falls back to native, finance and native fall back to default
@@ -167,8 +167,8 @@ NumberingSystem::createInstance(const Locale & inLocale, UErrorCode& status) {
} else if (!uprv_strcmp(buffer,gTraditional)) {
uprv_strcpy(buffer,gNative);
} else { // If we get here we couldn't find even the default numbering system
- usingFallback = TRUE;
- nsResolved = TRUE;
+ usingFallback = true;
+ nsResolved = true;
}
}
}
@@ -271,7 +271,7 @@ UBool NumberingSystem::isAlgorithmic() const {
namespace {
UVector* gNumsysNames = nullptr;
-UInitOnce gNumSysInitOnce = U_INITONCE_INITIALIZER;
+UInitOnce gNumSysInitOnce {};
U_CFUNC UBool U_CALLCONV numSysCleanup() {
delete gNumsysNames;
@@ -313,12 +313,7 @@ U_CFUNC void initNumsysNames(UErrorCode &status) {
}
const char *nsName = ures_getKey(nsCurrent.getAlias());
LocalPointer<UnicodeString> newElem(new UnicodeString(nsName, -1, US_INV), status);
- if (U_SUCCESS(status)) {
- numsysNames->addElementX(newElem.getAlias(), status);
- if (U_SUCCESS(status)) {
- newElem.orphan(); // on success, the numsysNames vector owns newElem.
- }
- }
+ numsysNames->adoptElement(newElem.orphan(), status);
}
ures_close(numberingSystemsInfo);
diff --git a/contrib/libs/icu/i18n/numsys_impl.h b/contrib/libs/icu/i18n/numsys_impl.h
index e76e634dd2..42cf102a13 100644
--- a/contrib/libs/icu/i18n/numsys_impl.h
+++ b/contrib/libs/icu/i18n/numsys_impl.h
@@ -29,8 +29,8 @@ public:
NumsysNameEnumeration(UErrorCode& status);
virtual ~NumsysNameEnumeration();
- static UClassID U_EXPORT2 getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID U_EXPORT2 getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
virtual const UnicodeString* snext(UErrorCode& status) override;
virtual void reset(UErrorCode& status) override;
virtual int32_t count(UErrorCode& status) const override;
diff --git a/contrib/libs/icu/i18n/olsontz.cpp b/contrib/libs/icu/i18n/olsontz.cpp
index cae471a5a2..260e345d79 100644
--- a/contrib/libs/icu/i18n/olsontz.cpp
+++ b/contrib/libs/icu/i18n/olsontz.cpp
@@ -52,14 +52,14 @@ static void debug_tz_msg(const char *pat, ...)
#endif
static UBool arrayEqual(const void *a1, const void *a2, int32_t size) {
- if (a1 == NULL && a2 == NULL) {
- return TRUE;
+ if (a1 == nullptr && a2 == nullptr) {
+ return true;
}
- if ((a1 != NULL && a2 == NULL) || (a1 == NULL && a2 != NULL)) {
- return FALSE;
+ if ((a1 != nullptr && a2 == nullptr) || (a1 == nullptr && a2 != nullptr)) {
+ return false;
}
if (a1 == a2) {
- return TRUE;
+ return true;
}
return (uprv_memcmp(a1, a2, size) == 0);
@@ -87,7 +87,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(OlsonTimeZone)
* Default constructor. Creates a time zone with an empty ID and
* a fixed GMT offset of zero.
*/
-/*OlsonTimeZone::OlsonTimeZone() : finalYear(INT32_MAX), finalMillis(DBL_MAX), finalZone(0), transitionRulesInitialized(FALSE) {
+/*OlsonTimeZone::OlsonTimeZone() : finalYear(INT32_MAX), finalMillis(DBL_MAX), finalZone(0), transitionRulesInitialized(false) {
clearTransitionRules();
constructEmpty();
}*/
@@ -97,17 +97,17 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(OlsonTimeZone)
* constructor fails so the resultant object is well-behaved.
*/
void OlsonTimeZone::constructEmpty() {
- canonicalID = NULL;
+ canonicalID = nullptr;
transitionCountPre32 = transitionCount32 = transitionCountPost32 = 0;
- transitionTimesPre32 = transitionTimes32 = transitionTimesPost32 = NULL;
+ transitionTimesPre32 = transitionTimes32 = transitionTimesPost32 = nullptr;
- typeMapData = NULL;
+ typeMapData = nullptr;
typeCount = 1;
typeOffsets = ZEROS;
- finalZone = NULL;
+ finalZone = nullptr;
}
/**
@@ -121,11 +121,11 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top,
const UResourceBundle* res,
const UnicodeString& tzid,
UErrorCode& ec) :
- BasicTimeZone(tzid), finalZone(NULL)
+ BasicTimeZone(tzid), finalZone(nullptr)
{
clearTransitionRules();
U_DEBUG_TZ_MSG(("OlsonTimeZone(%s)\n", ures_getKey((UResourceBundle*)res)));
- if ((top == NULL || res == NULL) && U_SUCCESS(ec)) {
+ if ((top == nullptr || res == nullptr) && U_SUCCESS(ec)) {
ec = U_ILLEGAL_ARGUMENT_ERROR;
}
if (U_SUCCESS(ec)) {
@@ -142,7 +142,7 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top,
transitionCountPre32 = static_cast<int16_t>(len >> 1);
if (ec == U_MISSING_RESOURCE_ERROR) {
// No pre-32bit transitions
- transitionTimesPre32 = NULL;
+ transitionTimesPre32 = nullptr;
transitionCountPre32 = 0;
ec = U_ZERO_ERROR;
} else if (U_SUCCESS(ec) && (len < 0 || len > 0x7FFF || (len & 1) != 0) /* len must be even */) {
@@ -155,7 +155,7 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top,
transitionCount32 = static_cast<int16_t>(len);
if (ec == U_MISSING_RESOURCE_ERROR) {
// No 32bit transitions
- transitionTimes32 = NULL;
+ transitionTimes32 = nullptr;
transitionCount32 = 0;
ec = U_ZERO_ERROR;
} else if (U_SUCCESS(ec) && (len < 0 || len > 0x7FFF)) {
@@ -168,7 +168,7 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top,
transitionCountPost32 = static_cast<int16_t>(len >> 1);
if (ec == U_MISSING_RESOURCE_ERROR) {
// No pre-32bit transitions
- transitionTimesPost32 = NULL;
+ transitionTimesPost32 = nullptr;
transitionCountPost32 = 0;
ec = U_ZERO_ERROR;
} else if (U_SUCCESS(ec) && (len < 0 || len > 0x7FFF || (len & 1) != 0) /* len must be even */) {
@@ -184,7 +184,7 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top,
typeCount = (int16_t) len >> 1;
// Type map data must be of the same size as the transition count
- typeMapData = NULL;
+ typeMapData = nullptr;
if (transitionCount() > 0) {
ures_getByKey(res, kTYPEMAP, r.getAlias(), &ec);
typeMapData = ures_getBinary(r.getAlias(), &len, &ec);
@@ -198,14 +198,14 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top,
// Process final rule and data, if any
if (U_SUCCESS(ec)) {
- const UChar *ruleIdUStr = ures_getStringByKey(res, kFINALRULE, &len, &ec);
+ const char16_t *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);
+ UnicodeString ruleID(true, ruleIdUStr, len);
+ UResourceBundle *rule = TimeZone::loadRule(top, ruleID, nullptr, ec);
const int32_t *ruleData = ures_getIntVector(rule, &len, &ec);
if (U_SUCCESS(ec) && len == 11) {
UnicodeString emptyStr;
@@ -219,7 +219,7 @@ OlsonTimeZone::OlsonTimeZone(const UResourceBundle* top,
ruleData[8] * U_MILLIS_PER_SECOND,
(SimpleTimeZone::TimeMode) ruleData[9],
ruleData[10] * U_MILLIS_PER_SECOND, ec);
- if (finalZone == NULL) {
+ if (finalZone == nullptr) {
ec = U_MEMORY_ALLOCATION_ERROR;
} else {
finalStartYear = ruleYear;
@@ -373,7 +373,7 @@ int32_t OlsonTimeZone::getOffset(uint8_t era, int32_t year, int32_t month,
year = -year;
}
- if (finalZone != NULL && year >= finalStartYear) {
+ if (finalZone != nullptr && year >= finalStartYear) {
return finalZone->getOffset(era, year, month, dom, dow,
millis, monthLength, ec);
}
@@ -381,7 +381,7 @@ int32_t OlsonTimeZone::getOffset(uint8_t era, int32_t year, int32_t month,
// Compute local epoch millis from input fields
UDate date = (UDate)(Grego::fieldsToDay(year, month, dom) * U_MILLIS_PER_DAY + millis);
int32_t rawoff, dstoff;
- getHistoricalOffset(date, TRUE, kDaylight, kStandard, rawoff, dstoff);
+ getHistoricalOffset(date, true, kDaylight, kStandard, rawoff, dstoff);
return rawoff + dstoff;
}
@@ -393,7 +393,7 @@ void OlsonTimeZone::getOffset(UDate date, UBool local, int32_t& rawoff,
if (U_FAILURE(ec)) {
return;
}
- if (finalZone != NULL && date >= finalStartMillis) {
+ if (finalZone != nullptr && date >= finalStartMillis) {
finalZone->getOffset(date, local, rawoff, dstoff, ec);
} else {
getHistoricalOffset(date, local, kFormer, kLatter, rawoff, dstoff);
@@ -406,10 +406,10 @@ void OlsonTimeZone::getOffsetFromLocal(UDate date, UTimeZoneLocalOption nonExist
if (U_FAILURE(ec)) {
return;
}
- if (finalZone != NULL && date >= finalStartMillis) {
+ if (finalZone != nullptr && date >= finalStartMillis) {
finalZone->getOffsetFromLocal(date, nonExistingTimeOpt, duplicatedTimeOpt, rawoff, dstoff, ec);
} else {
- getHistoricalOffset(date, TRUE, nonExistingTimeOpt, duplicatedTimeOpt, rawoff, dstoff);
+ getHistoricalOffset(date, true, nonExistingTimeOpt, duplicatedTimeOpt, rawoff, dstoff);
}
}
@@ -430,8 +430,7 @@ void OlsonTimeZone::setRawOffset(int32_t /*offsetMillis*/) {
int32_t OlsonTimeZone::getRawOffset() const {
UErrorCode ec = U_ZERO_ERROR;
int32_t raw, dst;
- getOffset((double) uprv_getUTCtime() * U_MILLIS_PER_SECOND,
- FALSE, raw, dst, ec);
+ getOffset(uprv_getUTCtime(), false, raw, dst, ec);
return raw;
}
@@ -560,12 +559,12 @@ OlsonTimeZone::getHistoricalOffset(UDate date, UBool local,
UBool OlsonTimeZone::useDaylightTime() const {
// If DST was observed in 1942 (for example) but has never been
// observed from 1943 to the present, most clients will expect
- // this method to return FALSE. This method determines whether
+ // this method to return false. This method determines whether
// DST is in use in the current year (at any point in the year)
- // and returns TRUE if so.
+ // and returns true if so.
UDate current = uprv_getUTCtime();
- if (finalZone != NULL && current >= finalStartMillis) {
+ if (finalZone != nullptr && current >= finalStartMillis) {
return finalZone->useDaylightTime();
}
@@ -576,7 +575,7 @@ UBool OlsonTimeZone::useDaylightTime() const {
double start = Grego::fieldsToDay(year, 0, 1) * SECONDS_PER_DAY;
double limit = Grego::fieldsToDay(year+1, 0, 1) * SECONDS_PER_DAY;
- // Return TRUE if DST is observed at any time during the current
+ // Return true if DST is observed at any time during the current
// year.
for (int16_t i = 0; i < transitionCount(); ++i) {
double transition = (double)transitionTimeInSeconds(i);
@@ -585,14 +584,14 @@ UBool OlsonTimeZone::useDaylightTime() const {
}
if ((transition >= start && dstOffsetAt(i) != 0)
|| (transition > start && dstOffsetAt(i - 1) != 0)) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
int32_t
OlsonTimeZone::getDSTSavings() const{
- if (finalZone != NULL){
+ if (finalZone != nullptr){
return finalZone->getDSTSavings();
}
return TimeZone::getDSTSavings();
@@ -602,45 +601,45 @@ OlsonTimeZone::getDSTSavings() const{
*/
UBool OlsonTimeZone::inDaylightTime(UDate date, UErrorCode& ec) const {
int32_t raw, dst;
- getOffset(date, FALSE, raw, dst, ec);
+ getOffset(date, false, raw, dst, ec);
return dst != 0;
}
UBool
OlsonTimeZone::hasSameRules(const TimeZone &other) const {
if (this == &other) {
- return TRUE;
+ return true;
}
const OlsonTimeZone* z = dynamic_cast<const OlsonTimeZone*>(&other);
- if (z == NULL) {
- return FALSE;
+ if (z == nullptr) {
+ return false;
}
// [sic] pointer comparison: typeMapData points into
// memory-mapped or DLL space, so if two zones have the same
// pointer, they are equal.
if (typeMapData == z->typeMapData) {
- return TRUE;
+ return true;
}
// If the pointers are not equal, the zones may still
// be equal if their rules and transitions are equal
- if ((finalZone == NULL && z->finalZone != NULL)
- || (finalZone != NULL && z->finalZone == NULL)
- || (finalZone != NULL && z->finalZone != NULL && *finalZone != *z->finalZone)) {
- return FALSE;
+ if ((finalZone == nullptr && z->finalZone != nullptr)
+ || (finalZone != nullptr && z->finalZone == nullptr)
+ || (finalZone != nullptr && z->finalZone != nullptr && *finalZone != *z->finalZone)) {
+ return false;
}
- if (finalZone != NULL) {
+ if (finalZone != nullptr) {
if (finalStartYear != z->finalStartYear || finalStartMillis != z->finalStartMillis) {
- return FALSE;
+ return false;
}
}
if (typeCount != z->typeCount
|| transitionCountPre32 != z->transitionCountPre32
|| transitionCount32 != z->transitionCount32
|| transitionCountPost32 != z->transitionCountPost32) {
- return FALSE;
+ return false;
}
return
@@ -652,34 +651,34 @@ OlsonTimeZone::hasSameRules(const TimeZone &other) const {
}
void
-OlsonTimeZone::clearTransitionRules(void) {
- initialRule = NULL;
- firstTZTransition = NULL;
- firstFinalTZTransition = NULL;
- historicRules = NULL;
+OlsonTimeZone::clearTransitionRules() {
+ initialRule = nullptr;
+ firstTZTransition = nullptr;
+ firstFinalTZTransition = nullptr;
+ historicRules = nullptr;
historicRuleCount = 0;
- finalZoneWithStartYear = NULL;
+ finalZoneWithStartYear = nullptr;
firstTZTransitionIdx = 0;
transitionRulesInitOnce.reset();
}
void
-OlsonTimeZone::deleteTransitionRules(void) {
- if (initialRule != NULL) {
+OlsonTimeZone::deleteTransitionRules() {
+ if (initialRule != nullptr) {
delete initialRule;
}
- if (firstTZTransition != NULL) {
+ if (firstTZTransition != nullptr) {
delete firstTZTransition;
}
- if (firstFinalTZTransition != NULL) {
+ if (firstFinalTZTransition != nullptr) {
delete firstFinalTZTransition;
}
- if (finalZoneWithStartYear != NULL) {
+ if (finalZoneWithStartYear != nullptr) {
delete finalZoneWithStartYear;
}
- if (historicRules != NULL) {
+ if (historicRules != nullptr) {
for (int i = 0; i < historicRuleCount; i++) {
- if (historicRules[i] != NULL) {
+ if (historicRules[i] != nullptr) {
delete historicRules[i];
}
}
@@ -721,7 +720,7 @@ OlsonTimeZone::initTransitionRules(UErrorCode& status) {
dst = initialDstOffset() * U_MILLIS_PER_SECOND;
initialRule = new InitialTimeZoneRule((dst == 0 ? stdName : dstName), raw, dst);
// Check to make sure initialRule was created
- if (initialRule == NULL) {
+ if (initialRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -746,7 +745,7 @@ OlsonTimeZone::initTransitionRules(UErrorCode& status) {
} else {
// Build historic rule array
UDate* times = (UDate*)uprv_malloc(sizeof(UDate)*transCount); /* large enough to store all transition times */
- if (times == NULL) {
+ if (times == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -757,7 +756,7 @@ OlsonTimeZone::initTransitionRules(UErrorCode& status) {
for (transitionIdx = firstTZTransitionIdx; transitionIdx < transCount; transitionIdx++) {
if (typeIdx == (int16_t)typeMapData[transitionIdx]) {
UDate tt = (UDate)transitionTime(transitionIdx);
- if (finalZone == NULL || tt <= finalStartMillis) {
+ if (finalZone == nullptr || tt <= finalStartMillis) {
// Exclude transitions after finalMillis
times[nTimes++] = tt;
}
@@ -767,24 +766,24 @@ OlsonTimeZone::initTransitionRules(UErrorCode& status) {
// Create a TimeArrayTimeZoneRule
raw = typeOffsets[typeIdx << 1] * U_MILLIS_PER_SECOND;
dst = typeOffsets[(typeIdx << 1) + 1] * U_MILLIS_PER_SECOND;
- if (historicRules == NULL) {
+ if (historicRules == nullptr) {
historicRuleCount = typeCount;
historicRules = (TimeArrayTimeZoneRule**)uprv_malloc(sizeof(TimeArrayTimeZoneRule*)*historicRuleCount);
- if (historicRules == NULL) {
+ if (historicRules == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
uprv_free(times);
return;
}
for (int i = 0; i < historicRuleCount; i++) {
- // Initialize TimeArrayTimeZoneRule pointers as NULL
- historicRules[i] = NULL;
+ // Initialize TimeArrayTimeZoneRule pointers as nullptr
+ historicRules[i] = nullptr;
}
}
historicRules[typeIdx] = new TimeArrayTimeZoneRule((dst == 0 ? stdName : dstName),
raw, dst, times, nTimes, DateTimeRule::UTC_TIME);
// Check for memory allocation error
- if (historicRules[typeIdx] == NULL) {
+ if (historicRules[typeIdx] == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -798,17 +797,17 @@ OlsonTimeZone::initTransitionRules(UErrorCode& status) {
firstTZTransition = new TimeZoneTransition((UDate)transitionTime(firstTZTransitionIdx),
*initialRule, *historicRules[typeIdx]);
// Check to make sure firstTZTransition was created.
- if (firstTZTransition == NULL) {
+ if (firstTZTransition == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
}
}
}
- if (finalZone != NULL) {
+ if (finalZone != nullptr) {
// Get the first occurrence of final rule starts
UDate startTime = (UDate)finalStartMillis;
- TimeZoneRule *firstFinalRule = NULL;
+ TimeZoneRule *firstFinalRule = nullptr;
if (finalZone->useDaylightTime()) {
/*
@@ -820,7 +819,7 @@ OlsonTimeZone::initTransitionRules(UErrorCode& status) {
*/
finalZoneWithStartYear = finalZone->clone();
// Check to make sure finalZone was actually cloned.
- if (finalZoneWithStartYear == NULL) {
+ if (finalZoneWithStartYear == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -831,7 +830,7 @@ OlsonTimeZone::initTransitionRules(UErrorCode& status) {
finalZoneWithStartYear->getNextTransition(startTime, false, tzt);
firstFinalRule = tzt.getTo()->clone();
// Check to make sure firstFinalRule received proper clone.
- if (firstFinalRule == NULL) {
+ if (firstFinalRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -841,7 +840,7 @@ OlsonTimeZone::initTransitionRules(UErrorCode& status) {
// final rule with no transitions
finalZoneWithStartYear = finalZone->clone();
// Check to make sure finalZone was actually cloned.
- if (finalZoneWithStartYear == NULL) {
+ if (finalZoneWithStartYear == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -850,23 +849,23 @@ OlsonTimeZone::initTransitionRules(UErrorCode& status) {
firstFinalRule = new TimeArrayTimeZoneRule(tzid,
finalZone->getRawOffset(), 0, &startTime, 1, DateTimeRule::UTC_TIME);
// Check firstFinalRule was properly created.
- if (firstFinalRule == NULL) {
+ if (firstFinalRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
}
}
- TimeZoneRule *prevRule = NULL;
+ TimeZoneRule *prevRule = nullptr;
if (transCount > 0) {
prevRule = historicRules[typeMapData[transCount - 1]];
}
- if (prevRule == NULL) {
+ if (prevRule == nullptr) {
// No historic transitions, but only finalZone available
prevRule = initialRule;
}
firstFinalTZTransition = new TimeZoneTransition();
// Check to make sure firstFinalTZTransition was created before dereferencing
- if (firstFinalTZTransition == NULL) {
+ if (firstFinalTZTransition == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -882,24 +881,24 @@ OlsonTimeZone::getNextTransition(UDate base, UBool inclusive, TimeZoneTransition
UErrorCode status = U_ZERO_ERROR;
checkTransitionRules(status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
- if (finalZone != NULL) {
+ if (finalZone != nullptr) {
if (inclusive && base == firstFinalTZTransition->getTime()) {
result = *firstFinalTZTransition;
- return TRUE;
+ return true;
} else if (base >= firstFinalTZTransition->getTime()) {
if (finalZone->useDaylightTime()) {
//return finalZone->getNextTransition(base, inclusive, result);
return finalZoneWithStartYear->getNextTransition(base, inclusive, result);
} else {
// No more transitions
- return FALSE;
+ return false;
}
}
}
- if (historicRules != NULL) {
+ if (historicRules != nullptr) {
// Find a historical transition
int16_t transCount = transitionCount();
int16_t ttidx = transCount - 1;
@@ -910,15 +909,15 @@ OlsonTimeZone::getNextTransition(UDate base, UBool inclusive, TimeZoneTransition
}
}
if (ttidx == transCount - 1) {
- if (firstFinalTZTransition != NULL) {
+ if (firstFinalTZTransition != nullptr) {
result = *firstFinalTZTransition;
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
} else if (ttidx < firstTZTransitionIdx) {
result = *firstTZTransition;
- return TRUE;
+ return true;
} else {
// Create a TimeZoneTransition
TimeZoneRule *to = historicRules[typeMapData[ttidx + 1]];
@@ -936,10 +935,10 @@ OlsonTimeZone::getNextTransition(UDate base, UBool inclusive, TimeZoneTransition
result.setTime(startTime);
result.adoptFrom(from->clone());
result.adoptTo(to->clone());
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
UBool
@@ -947,25 +946,25 @@ OlsonTimeZone::getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransi
UErrorCode status = U_ZERO_ERROR;
checkTransitionRules(status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
- if (finalZone != NULL) {
+ if (finalZone != nullptr) {
if (inclusive && base == firstFinalTZTransition->getTime()) {
result = *firstFinalTZTransition;
- return TRUE;
+ return true;
} else if (base > firstFinalTZTransition->getTime()) {
if (finalZone->useDaylightTime()) {
//return finalZone->getPreviousTransition(base, inclusive, result);
return finalZoneWithStartYear->getPreviousTransition(base, inclusive, result);
} else {
result = *firstFinalTZTransition;
- return TRUE;
+ return true;
}
}
}
- if (historicRules != NULL) {
+ if (historicRules != nullptr) {
// Find a historical transition
int16_t ttidx = transitionCount() - 1;
for (; ttidx >= firstTZTransitionIdx; ttidx--) {
@@ -976,10 +975,10 @@ OlsonTimeZone::getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransi
}
if (ttidx < firstTZTransitionIdx) {
// No more transitions
- return FALSE;
+ return false;
} else if (ttidx == firstTZTransitionIdx) {
result = *firstTZTransition;
- return TRUE;
+ return true;
} else {
// Create a TimeZoneTransition
TimeZoneRule *to = historicRules[typeMapData[ttidx]];
@@ -997,10 +996,10 @@ OlsonTimeZone::getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransi
result.setTime(startTime);
result.adoptFrom(from->clone());
result.adoptTo(to->clone());
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
int32_t
@@ -1014,16 +1013,16 @@ OlsonTimeZone::countTransitionRules(UErrorCode& status) const {
}
int32_t count = 0;
- if (historicRules != NULL) {
+ if (historicRules != nullptr) {
// historicRules may contain null entries when original zoneinfo data
// includes non transition data.
for (int32_t i = 0; i < historicRuleCount; i++) {
- if (historicRules[i] != NULL) {
+ if (historicRules[i] != nullptr) {
count++;
}
}
}
- if (finalZone != NULL) {
+ if (finalZone != nullptr) {
if (finalZone->useDaylightTime()) {
count += 2;
} else {
@@ -1051,11 +1050,11 @@ OlsonTimeZone::getTimeZoneRules(const InitialTimeZoneRule*& initial,
// Transition rules
int32_t cnt = 0;
- if (historicRules != NULL && trscount > cnt) {
+ if (historicRules != nullptr && trscount > cnt) {
// historicRules may contain null entries when original zoneinfo data
// includes non transition data.
for (int32_t i = 0; i < historicRuleCount; i++) {
- if (historicRules[i] != NULL) {
+ if (historicRules[i] != nullptr) {
trsrules[cnt++] = historicRules[i];
if (cnt >= trscount) {
break;
@@ -1063,7 +1062,7 @@ OlsonTimeZone::getTimeZoneRules(const InitialTimeZoneRule*& initial,
}
}
}
- if (finalZoneWithStartYear != NULL && trscount > cnt) {
+ if (finalZoneWithStartYear != nullptr && trscount > cnt) {
const InitialTimeZoneRule *tmpini;
int32_t tmpcnt = trscount - cnt;
finalZoneWithStartYear->getTimeZoneRules(tmpini, &trsrules[cnt], tmpcnt, status);
diff --git a/contrib/libs/icu/i18n/olsontz.h b/contrib/libs/icu/i18n/olsontz.h
index 75d86781ed..9fe0d5dfed 100644
--- a/contrib/libs/icu/i18n/olsontz.h
+++ b/contrib/libs/icu/i18n/olsontz.h
@@ -263,7 +263,7 @@ class U_I18N_API OlsonTimeZone: public BasicTimeZone {
/**
* Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
* which represent time transitions for this time zone. On successful return,
- * the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
+ * the argument initial points to non-nullptr <code>InitialTimeZoneRule</code> and
* the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
* instances up to the size specified by trscount. The results are referencing the
* rule instance held by this time zone instance. Therefore, after this time zone
@@ -282,7 +282,7 @@ class U_I18N_API OlsonTimeZone: public BasicTimeZone {
* Internal API returning the canonical ID of this zone.
* This ID won't be affected by setID().
*/
- const UChar *getCanonicalID() const;
+ const char16_t *getCanonicalID() const;
private:
/**
@@ -328,20 +328,20 @@ private:
/**
* Time of each transition in seconds from 1970 epoch before 32bit second range (<= 1900).
* Each transition in this range is represented by a pair of int32_t.
- * Length is transitionCount int32_t's. NULL if no transitions in this range.
+ * Length is transitionCount int32_t's. nullptr if no transitions in this range.
*/
const int32_t *transitionTimesPre32; // alias into res; do not delete
/**
* Time of each transition in seconds from 1970 epoch in 32bit second range.
- * Length is transitionCount int32_t's. NULL if no transitions in this range.
+ * Length is transitionCount int32_t's. nullptr if no transitions in this range.
*/
const int32_t *transitionTimes32; // alias into res; do not delete
/**
* Time of each transition in seconds from 1970 epoch after 32bit second range (>= 2038).
* Each transition in this range is represented by a pair of int32_t.
- * Length is transitionCount int32_t's. NULL if no transitions in this range.
+ * Length is transitionCount int32_t's. nullptr if no transitions in this range.
*/
const int32_t *transitionTimesPost32; // alias into res; do not delete
@@ -360,14 +360,14 @@ private:
/**
* Type description data, consisting of transitionCount uint8_t
* type indices (from 0..typeCount-1).
- * Length is transitionCount int16_t's. NULL if no transitions.
+ * Length is transitionCount int16_t's. nullptr if no transitions.
*/
const uint8_t *typeMapData; // alias into res; do not delete
/**
* A SimpleTimeZone that governs the behavior for date >= finalMillis.
*/
- SimpleTimeZone *finalZone; // owned, may be NULL
+ SimpleTimeZone *finalZone; // owned, may be nullptr
/**
* For date >= finalMillis, the finalZone will be used.
@@ -382,11 +382,11 @@ private:
/*
* Canonical (CLDR) ID of this zone
*/
- const UChar *canonicalID;
+ const char16_t *canonicalID;
/* BasicTimeZone support */
- void clearTransitionRules(void);
- void deleteTransitionRules(void);
+ void clearTransitionRules();
+ void deleteTransitionRules();
void checkTransitionRules(UErrorCode& status) const;
public: // Internal, for access from plain C code
@@ -400,7 +400,7 @@ private:
TimeArrayTimeZoneRule **historicRules;
int16_t historicRuleCount;
SimpleTimeZone *finalZoneWithStartYear; // hack
- UInitOnce transitionRulesInitOnce = U_INITONCE_INITIALIZER;
+ UInitOnce transitionRulesInitOnce {};
};
inline int16_t
@@ -441,7 +441,7 @@ OlsonTimeZone::initialDstOffset() const {
return typeOffsets[1];
}
-inline const UChar*
+inline const char16_t*
OlsonTimeZone::getCanonicalID() const {
return canonicalID;
}
diff --git a/contrib/libs/icu/i18n/persncal.cpp b/contrib/libs/icu/i18n/persncal.cpp
index d30577f337..ab13f43434 100644
--- a/contrib/libs/icu/i18n/persncal.cpp
+++ b/contrib/libs/icu/i18n/persncal.cpp
@@ -58,6 +58,7 @@ static const int32_t kPersianCalendarLimits[UCAL_FIELD_COUNT][4] = {
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // JULIAN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // MILLISECONDS_IN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // IS_LEAP_MONTH
+ { 0, 0, 11, 11}, // ORDINAL_MONTH
};
U_NAMESPACE_BEGIN
@@ -110,7 +111,7 @@ int32_t PersianCalendar::handleGetLimit(UCalendarDateFields field, ELimitType li
UBool PersianCalendar::isLeapYear(int32_t year)
{
int32_t remainder;
- ClockMath::floorDivide(25 * year + 11, 33, remainder);
+ ClockMath::floorDivide(25 * year + 11, 33, &remainder);
return (remainder < 8);
}
@@ -119,7 +120,7 @@ UBool PersianCalendar::isLeapYear(int32_t year)
* from the Persian epoch, origin 0.
*/
int32_t PersianCalendar::yearStart(int32_t year) {
- return handleComputeMonthStart(year,0,FALSE);
+ return handleComputeMonthStart(year,0,false);
}
/**
@@ -130,7 +131,7 @@ int32_t PersianCalendar::yearStart(int32_t year) {
* @param year The Persian month, 0-based
*/
int32_t PersianCalendar::monthStart(int32_t year, int32_t month) const {
- return handleComputeMonthStart(year,month,TRUE);
+ return handleComputeMonthStart(year,month,true);
}
//----------------------------------------------------------------------
@@ -147,7 +148,7 @@ int32_t PersianCalendar::handleGetMonthLength(int32_t extendedYear, int32_t mont
// If the month is out of range, adjust it into range, and
// modify the extended year value accordingly.
if (month < 0 || month > 11) {
- extendedYear += ClockMath::floorDivide(month, 12, month);
+ extendedYear += ClockMath::floorDivide(month, 12, &month);
}
return isLeapYear(extendedYear) ? kPersianLeapMonthLength[month] : kPersianMonthLength[month];
@@ -169,7 +170,7 @@ int32_t PersianCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, U
// If the month is out of range, adjust it into range, and
// modify the extended year value accordingly.
if (month < 0 || month > 11) {
- eyear += ClockMath::floorDivide(month, 12, month);
+ eyear += ClockMath::floorDivide(month, 12, &month);
}
int32_t julianDay = PERSIAN_EPOCH - 1 + 365 * (eyear - 1) + ClockMath::floorDivide(8 * eyear + 21, 33);
@@ -229,32 +230,37 @@ void PersianCalendar::handleComputeFields(int32_t julianDay, UErrorCode &/*statu
internalSet(UCAL_YEAR, year);
internalSet(UCAL_EXTENDED_YEAR, year);
internalSet(UCAL_MONTH, month);
+ internalSet(UCAL_ORDINAL_MONTH, month);
internalSet(UCAL_DAY_OF_MONTH, dayOfMonth);
internalSet(UCAL_DAY_OF_YEAR, dayOfYear);
}
-UBool
-PersianCalendar::inDaylightTime(UErrorCode& status) const
-{
- // copied from GregorianCalendar
- if (U_FAILURE(status) || !getTimeZone().useDaylightTime())
- return FALSE;
+constexpr uint32_t kPersianRelatedYearDiff = 622;
- // Force an update of the state of the Calendar.
- ((PersianCalendar*)this)->complete(status); // cast away const
+int32_t PersianCalendar::getRelatedYear(UErrorCode &status) const
+{
+ int32_t year = get(UCAL_EXTENDED_YEAR, status);
+ if (U_FAILURE(status)) {
+ return 0;
+ }
+ return year + kPersianRelatedYearDiff;
+}
- return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : FALSE);
+void PersianCalendar::setRelatedYear(int32_t year)
+{
+ // set extended year
+ set(UCAL_EXTENDED_YEAR, year - kPersianRelatedYearDiff);
}
// default century
static UDate gSystemDefaultCenturyStart = DBL_MIN;
static int32_t gSystemDefaultCenturyStartYear = -1;
-static icu::UInitOnce gSystemDefaultCenturyInit = U_INITONCE_INITIALIZER;
+static icu::UInitOnce gSystemDefaultCenturyInit {};
UBool PersianCalendar::haveDefaultCentury() const
{
- return TRUE;
+ return true;
}
static void U_CALLCONV initializeSystemDefaultCentury() {
diff --git a/contrib/libs/icu/i18n/persncal.h b/contrib/libs/icu/i18n/persncal.h
index d0f2ee5ec2..b943321a54 100644
--- a/contrib/libs/icu/i18n/persncal.h
+++ b/contrib/libs/icu/i18n/persncal.h
@@ -255,7 +255,7 @@ class PersianCalendar : public Calendar {
* same class ID. Objects of other classes have different class IDs.
* @internal
*/
- virtual UClassID getDynamicClassID(void) const override;
+ virtual UClassID getDynamicClassID() const override;
/**
* Return the class ID for this class. This is useful only for comparing to a return
@@ -268,7 +268,7 @@ class PersianCalendar : public Calendar {
* @return The class ID for all objects of this class.
* @internal
*/
- U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
+ U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
/**
* return the calendar type, "persian".
@@ -278,22 +278,24 @@ class PersianCalendar : public Calendar {
*/
virtual const char * getType() const override;
- private:
- PersianCalendar(); // default constructor not implemented
-
- protected:
+ /**
+ * @return The related Gregorian year; will be obtained by modifying the value
+ * obtained by get from UCAL_EXTENDED_YEAR field
+ * @internal
+ */
+ virtual int32_t getRelatedYear(UErrorCode &status) const override;
/**
- * (Overrides Calendar) Return true if the current date for this Calendar is in
- * Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
- *
- * @param status Fill-in parameter which receives the status of this operation.
- * @return True if the current date for this Calendar is in Daylight Savings Time,
- * false, otherwise.
+ * @param year The related Gregorian year to set; will be modified as necessary then
+ * set in UCAL_EXTENDED_YEAR field
* @internal
*/
- virtual UBool inDaylightTime(UErrorCode& status) const override;
+ virtual void setRelatedYear(int32_t year) override;
+
+ private:
+ PersianCalendar(); // default constructor not implemented
+ protected:
/**
* Returns true because the Persian Calendar does have a default century
* @internal
diff --git a/contrib/libs/icu/i18n/pluralranges.cpp b/contrib/libs/icu/i18n/pluralranges.cpp
index da10e2117d..403836f627 100644
--- a/contrib/libs/icu/i18n/pluralranges.cpp
+++ b/contrib/libs/icu/i18n/pluralranges.cpp
@@ -26,7 +26,7 @@ class PluralRangesDataSink : public ResourceSink {
public:
PluralRangesDataSink(StandardPluralRanges& output) : fOutput(output) {}
- void put(const char* /*key*/, ResourceValue& value, UBool /*noFallback*/, UErrorCode& status) U_OVERRIDE {
+ void put(const char* /*key*/, ResourceValue& value, UBool /*noFallback*/, UErrorCode& status) override {
ResourceArray entriesArray = value.getArray(status);
if (U_FAILURE(status)) { return; }
fOutput.setCapacity(entriesArray.getSize(), status);
@@ -66,7 +66,7 @@ void getPluralRangesData(const Locale& locale, StandardPluralRanges& output, UEr
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);
+ const char16_t* set = ures_getStringByKeyWithFallback(rb.getAlias(), dataPath.data(), &setLen, &internalStatus);
if (U_FAILURE(internalStatus)) { return; }
dataPath.clear();
diff --git a/contrib/libs/icu/i18n/plurfmt.cpp b/contrib/libs/icu/i18n/plurfmt.cpp
index 65e275eeeb..33a539cd19 100644
--- a/contrib/libs/icu/i18n/plurfmt.cpp
+++ b/contrib/libs/icu/i18n/plurfmt.cpp
@@ -31,7 +31,7 @@ U_NAMESPACE_BEGIN
using number::impl::DecimalQuantity;
-static const UChar OTHER_STRING[] = {
+static const char16_t OTHER_STRING[] = {
0x6F, 0x74, 0x68, 0x65, 0x72, 0 // "other"
};
@@ -40,23 +40,23 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(PluralFormat)
PluralFormat::PluralFormat(UErrorCode& status)
: locale(Locale::getDefault()),
msgPattern(status),
- numberFormat(NULL),
+ numberFormat(nullptr),
offset(0) {
- init(NULL, UPLURAL_TYPE_CARDINAL, status);
+ init(nullptr, UPLURAL_TYPE_CARDINAL, status);
}
PluralFormat::PluralFormat(const Locale& loc, UErrorCode& status)
: locale(loc),
msgPattern(status),
- numberFormat(NULL),
+ numberFormat(nullptr),
offset(0) {
- init(NULL, UPLURAL_TYPE_CARDINAL, status);
+ init(nullptr, UPLURAL_TYPE_CARDINAL, status);
}
PluralFormat::PluralFormat(const PluralRules& rules, UErrorCode& status)
: locale(Locale::getDefault()),
msgPattern(status),
- numberFormat(NULL),
+ numberFormat(nullptr),
offset(0) {
init(&rules, UPLURAL_TYPE_COUNT, status);
}
@@ -66,7 +66,7 @@ PluralFormat::PluralFormat(const Locale& loc,
UErrorCode& status)
: locale(loc),
msgPattern(status),
- numberFormat(NULL),
+ numberFormat(nullptr),
offset(0) {
init(&rules, UPLURAL_TYPE_COUNT, status);
}
@@ -76,18 +76,18 @@ PluralFormat::PluralFormat(const Locale& loc,
UErrorCode& status)
: locale(loc),
msgPattern(status),
- numberFormat(NULL),
+ numberFormat(nullptr),
offset(0) {
- init(NULL, type, status);
+ init(nullptr, type, status);
}
PluralFormat::PluralFormat(const UnicodeString& pat,
UErrorCode& status)
: locale(Locale::getDefault()),
msgPattern(status),
- numberFormat(NULL),
+ numberFormat(nullptr),
offset(0) {
- init(NULL, UPLURAL_TYPE_CARDINAL, status);
+ init(nullptr, UPLURAL_TYPE_CARDINAL, status);
applyPattern(pat, status);
}
@@ -96,9 +96,9 @@ PluralFormat::PluralFormat(const Locale& loc,
UErrorCode& status)
: locale(loc),
msgPattern(status),
- numberFormat(NULL),
+ numberFormat(nullptr),
offset(0) {
- init(NULL, UPLURAL_TYPE_CARDINAL, status);
+ init(nullptr, UPLURAL_TYPE_CARDINAL, status);
applyPattern(pat, status);
}
@@ -107,7 +107,7 @@ PluralFormat::PluralFormat(const PluralRules& rules,
UErrorCode& status)
: locale(Locale::getDefault()),
msgPattern(status),
- numberFormat(NULL),
+ numberFormat(nullptr),
offset(0) {
init(&rules, UPLURAL_TYPE_COUNT, status);
applyPattern(pat, status);
@@ -119,7 +119,7 @@ PluralFormat::PluralFormat(const Locale& loc,
UErrorCode& status)
: locale(loc),
msgPattern(status),
- numberFormat(NULL),
+ numberFormat(nullptr),
offset(0) {
init(&rules, UPLURAL_TYPE_COUNT, status);
applyPattern(pat, status);
@@ -131,9 +131,9 @@ PluralFormat::PluralFormat(const Locale& loc,
UErrorCode& status)
: locale(loc),
msgPattern(status),
- numberFormat(NULL),
+ numberFormat(nullptr),
offset(0) {
- init(NULL, type, status);
+ init(nullptr, type, status);
applyPattern(pat, status);
}
@@ -141,7 +141,7 @@ PluralFormat::PluralFormat(const PluralFormat& other)
: Format(other),
locale(other.locale),
msgPattern(other.msgPattern),
- numberFormat(NULL),
+ numberFormat(nullptr),
offset(other.offset) {
copyObjects(other);
}
@@ -149,19 +149,19 @@ PluralFormat::PluralFormat(const PluralFormat& other)
void
PluralFormat::copyObjects(const PluralFormat& other) {
UErrorCode status = U_ZERO_ERROR;
- if (numberFormat != NULL) {
+ if (numberFormat != nullptr) {
delete numberFormat;
}
- if (pluralRulesWrapper.pluralRules != NULL) {
+ if (pluralRulesWrapper.pluralRules != nullptr) {
delete pluralRulesWrapper.pluralRules;
}
- if (other.numberFormat == NULL) {
+ if (other.numberFormat == nullptr) {
numberFormat = NumberFormat::createInstance(locale, status);
} else {
numberFormat = other.numberFormat->clone();
}
- if (other.pluralRulesWrapper.pluralRules == NULL) {
+ if (other.pluralRulesWrapper.pluralRules == nullptr) {
pluralRulesWrapper.pluralRules = PluralRules::forLocale(locale, status);
} else {
pluralRulesWrapper.pluralRules = other.pluralRulesWrapper.pluralRules->clone();
@@ -179,11 +179,11 @@ PluralFormat::init(const PluralRules* rules, UPluralType type, UErrorCode& statu
return;
}
- if (rules==NULL) {
+ if (rules==nullptr) {
pluralRulesWrapper.pluralRules = PluralRules::forLocale(locale, type, status);
} else {
pluralRulesWrapper.pluralRules = rules->clone();
- if (pluralRulesWrapper.pluralRules == NULL) {
+ if (pluralRulesWrapper.pluralRules == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -194,7 +194,7 @@ PluralFormat::init(const PluralRules* rules, UPluralType type, UErrorCode& statu
void
PluralFormat::applyPattern(const UnicodeString& newPattern, UErrorCode& status) {
- msgPattern.parsePluralStyle(newPattern, NULL, status);
+ msgPattern.parsePluralStyle(newPattern, nullptr, status);
if (U_FAILURE(status)) {
msgPattern.clear();
offset = 0;
@@ -343,9 +343,9 @@ PluralFormat::setLocale(const Locale& loc, UErrorCode& status) {
msgPattern.clear();
delete numberFormat;
offset = 0;
- numberFormat = NULL;
+ numberFormat = nullptr;
pluralRulesWrapper.reset();
- init(NULL, UPLURAL_TYPE_CARDINAL, status);
+ init(nullptr, UPLURAL_TYPE_CARDINAL, status);
}
void
@@ -354,7 +354,7 @@ PluralFormat::setNumberFormat(const NumberFormat* format, UErrorCode& status) {
return;
}
NumberFormat* nf = format->clone();
- if (nf != NULL) {
+ if (nf != nullptr) {
delete numberFormat;
numberFormat = nf;
} else {
@@ -393,10 +393,10 @@ PluralFormat::operator==(const Format& other) const {
return
locale == o.locale &&
msgPattern == o.msgPattern && // implies same offset
- (numberFormat == NULL) == (o.numberFormat == NULL) &&
- (numberFormat == NULL || *numberFormat == *o.numberFormat) &&
- (pluralRulesWrapper.pluralRules == NULL) == (o.pluralRulesWrapper.pluralRules == NULL) &&
- (pluralRulesWrapper.pluralRules == NULL ||
+ (numberFormat == nullptr) == (o.numberFormat == nullptr) &&
+ (numberFormat == nullptr || *numberFormat == *o.numberFormat) &&
+ (pluralRulesWrapper.pluralRules == nullptr) == (o.pluralRulesWrapper.pluralRules == nullptr) &&
+ (pluralRulesWrapper.pluralRules == nullptr ||
*pluralRulesWrapper.pluralRules == *o.pluralRulesWrapper.pluralRules);
}
@@ -434,11 +434,11 @@ int32_t PluralFormat::findSubMessage(const MessagePattern& pattern, int32_t part
// (In other words, we never call the selector if we match against an explicit value,
// or if the only non-explicit keyword is "other".)
UnicodeString keyword;
- UnicodeString other(FALSE, OTHER_STRING, 5);
+ UnicodeString other(false, OTHER_STRING, 5);
// When we find a match, we set msgStart>0 and also set this boolean to true
// to avoid matching the keyword again (duplicates are allowed)
// while we continue to look for an explicit-value match.
- UBool haveKeywordMatch=FALSE;
+ UBool haveKeywordMatch=false;
// msgStart is 0 until we find any appropriate sub-message.
// We remember the first "other" sub-message if we have not seen any
// appropriate sub-message before.
@@ -477,7 +477,7 @@ int32_t PluralFormat::findSubMessage(const MessagePattern& pattern, int32_t part
// This is the first "other" sub-message,
// and the selected keyword is also "other".
// Do not match "other" again.
- haveKeywordMatch=TRUE;
+ haveKeywordMatch=true;
}
}
} else {
@@ -486,7 +486,7 @@ int32_t PluralFormat::findSubMessage(const MessagePattern& pattern, int32_t part
if(msgStart!=0 && (0 == keyword.compare(other))) {
// We have already seen an "other" sub-message.
// Do not match "other" again.
- haveKeywordMatch=TRUE;
+ haveKeywordMatch=true;
// Skip keyword matching but do getLimitPartIndex().
}
}
@@ -494,7 +494,7 @@ int32_t PluralFormat::findSubMessage(const MessagePattern& pattern, int32_t part
// keyword matches
msgStart=partIndex;
// Do not match this keyword again.
- haveKeywordMatch=TRUE;
+ haveKeywordMatch=true;
}
}
}
@@ -548,7 +548,7 @@ void PluralFormat::parseType(const UnicodeString& source, const NFRule *rbnfLeni
}
UnicodeString currArg = pattern.tempSubString(partStart->getLimit(), partLimit->getIndex() - partStart->getLimit());
- if (rbnfLenientScanner != NULL) {
+ if (rbnfLenientScanner != nullptr) {
// Check if non-lenient rule finds the text before call lenient parsing
int32_t tempIndex = source.indexOf(currArg, startingAt);
if (tempIndex >= 0) {
@@ -595,7 +595,7 @@ UnicodeString PluralFormat::PluralSelectorAdapter::select(void *context, double
void PluralFormat::PluralSelectorAdapter::reset() {
delete pluralRules;
- pluralRules = NULL;
+ pluralRules = nullptr;
}
diff --git a/contrib/libs/icu/i18n/plurrule.cpp b/contrib/libs/icu/i18n/plurrule.cpp
index d1918c4698..9c37b09e25 100644
--- a/contrib/libs/icu/i18n/plurrule.cpp
+++ b/contrib/libs/icu/i18n/plurrule.cpp
@@ -26,6 +26,7 @@
#include "hash.h"
#include "locutil.h"
#include "mutex.h"
+#include "number_decnum.h"
#include "patternprops.h"
#include "plurrule_impl.h"
#include "putilimp.h"
@@ -45,26 +46,28 @@
U_NAMESPACE_BEGIN
using namespace icu::pluralimpl;
+using icu::number::impl::DecNum;
using icu::number::impl::DecimalQuantity;
-
-static const UChar PLURAL_KEYWORD_OTHER[]={LOW_O,LOW_T,LOW_H,LOW_E,LOW_R,0};
-static const UChar PLURAL_DEFAULT_RULE[]={LOW_O,LOW_T,LOW_H,LOW_E,LOW_R,COLON,SPACE,LOW_N,0};
-static const UChar PK_IN[]={LOW_I,LOW_N,0};
-static const UChar PK_NOT[]={LOW_N,LOW_O,LOW_T,0};
-static const UChar PK_IS[]={LOW_I,LOW_S,0};
-static const UChar PK_MOD[]={LOW_M,LOW_O,LOW_D,0};
-static const UChar PK_AND[]={LOW_A,LOW_N,LOW_D,0};
-static const UChar PK_OR[]={LOW_O,LOW_R,0};
-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_C[]={LOW_C,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};
-static const UChar PK_INTEGER[]={LOW_I,LOW_N,LOW_T,LOW_E,LOW_G,LOW_E,LOW_R,0};
+using icu::number::impl::RoundingMode;
+
+static const char16_t PLURAL_KEYWORD_OTHER[]={LOW_O,LOW_T,LOW_H,LOW_E,LOW_R,0};
+static const char16_t PLURAL_DEFAULT_RULE[]={LOW_O,LOW_T,LOW_H,LOW_E,LOW_R,COLON,SPACE,LOW_N,0};
+static const char16_t PK_IN[]={LOW_I,LOW_N,0};
+static const char16_t PK_NOT[]={LOW_N,LOW_O,LOW_T,0};
+static const char16_t PK_IS[]={LOW_I,LOW_S,0};
+static const char16_t PK_MOD[]={LOW_M,LOW_O,LOW_D,0};
+static const char16_t PK_AND[]={LOW_A,LOW_N,LOW_D,0};
+static const char16_t PK_OR[]={LOW_O,LOW_R,0};
+static const char16_t PK_VAR_N[]={LOW_N,0};
+static const char16_t PK_VAR_I[]={LOW_I,0};
+static const char16_t PK_VAR_F[]={LOW_F,0};
+static const char16_t PK_VAR_T[]={LOW_T,0};
+static const char16_t PK_VAR_E[]={LOW_E,0};
+static const char16_t PK_VAR_C[]={LOW_C,0};
+static const char16_t PK_VAR_V[]={LOW_V,0};
+static const char16_t PK_WITHIN[]={LOW_W,LOW_I,LOW_T,LOW_H,LOW_I,LOW_N,0};
+static const char16_t PK_DECIMAL[]={LOW_D,LOW_E,LOW_C,LOW_I,LOW_M,LOW_A,LOW_L,0};
+static const char16_t PK_INTEGER[]={LOW_I,LOW_N,LOW_T,LOW_E,LOW_G,LOW_E,LOW_R,0};
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(PluralRules)
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(PluralKeywordEnumeration)
@@ -176,7 +179,7 @@ PluralRules::createRules(const UnicodeString& description, UErrorCode& status) {
PluralRules* U_EXPORT2
PluralRules::createDefaultRules(UErrorCode& status) {
- return createRules(UnicodeString(TRUE, PLURAL_DEFAULT_RULE, -1), status);
+ return createRules(UnicodeString(true, PLURAL_DEFAULT_RULE, -1), status);
}
/******************************************************************************/
@@ -304,7 +307,7 @@ PluralRules::select(const number::FormattedNumber& number, UErrorCode& status) c
UnicodeString
PluralRules::select(const IFixedDecimal &number) const {
if (mRules == nullptr) {
- return UnicodeString(TRUE, PLURAL_DEFAULT_RULE, -1);
+ return UnicodeString(true, PLURAL_DEFAULT_RULE, -1);
}
else {
return mRules->select(number);
@@ -369,36 +372,18 @@ PluralRules::getAllKeywordValues(const UnicodeString & /* keyword */, double * /
return 0;
}
-
-static double scaleForInt(double d) {
- double scale = 1.0;
- while (d != floor(d)) {
- d = d * 10.0;
- scale = scale * 10.0;
- }
- return scale;
-}
-
-static const double powers10[7] = {1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0}; // powers of 10 for 0..6
-static double applyExponent(double source, int32_t exponent) {
- if (exponent >= 0 && exponent <= 6) {
- return source * powers10[exponent];
- }
- return source * pow(10.0, exponent);
-}
-
/**
- * 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.
+ * Helper method for the overrides of getSamples() for double and DecimalQuantity
+ * return value types. Provide only one of an allocated array of double or
+ * DecimalQuantity, and a nullptr for the other.
*/
static int32_t
getSamplesFromString(const UnicodeString &samples, double *destDbl,
- FixedDecimal* destFd, int32_t destCapacity,
+ DecimalQuantity* destDq, int32_t destCapacity,
UErrorCode& status) {
- if ((destDbl == nullptr && destFd == nullptr)
- || (destDbl != nullptr && destFd != nullptr)) {
+ if ((destDbl == nullptr && destDq == nullptr)
+ || (destDbl != nullptr && destDq != nullptr)) {
status = U_INTERNAL_PROGRAM_ERROR;
return 0;
}
@@ -420,58 +405,75 @@ getSamplesFromString(const UnicodeString &samples, double *destDbl,
// std::cout << "PluralRules::getSamples(), samplesRange = \"" << sampleRange.toUTF8String(ss) << "\"\n";
int32_t tildeIndex = sampleRange.indexOf(TILDE);
if (tildeIndex < 0) {
- FixedDecimal fixed(sampleRange, status);
+ DecimalQuantity dq = DecimalQuantity::fromExponentString(sampleRange, status);
if (isDouble) {
- double sampleValue = fixed.source;
- if (fixed.visibleDecimalDigitCount == 0 || sampleValue != floor(sampleValue)) {
- destDbl[sampleCount++] = applyExponent(sampleValue, fixed.exponent);
+ // See warning note below about lack of precision for floating point samples for numbers with
+ // trailing zeroes in the decimal fraction representation.
+ double dblValue = dq.toDouble();
+ if (!(dblValue == floor(dblValue) && dq.fractionCount() > 0)) {
+ destDbl[sampleCount++] = dblValue;
}
} else {
- destFd[sampleCount++] = fixed;
+ destDq[sampleCount++] = dq;
}
} else {
- FixedDecimal fixedLo(sampleRange.tempSubStringBetween(0, tildeIndex), status);
- FixedDecimal fixedHi(sampleRange.tempSubStringBetween(tildeIndex+1), status);
- double rangeLo = fixedLo.source;
- double rangeHi = fixedHi.source;
+ DecimalQuantity rangeLo =
+ DecimalQuantity::fromExponentString(sampleRange.tempSubStringBetween(0, tildeIndex), status);
+ DecimalQuantity rangeHi = DecimalQuantity::fromExponentString(sampleRange.tempSubStringBetween(tildeIndex+1), status);
if (U_FAILURE(status)) {
break;
}
- if (rangeHi < rangeLo) {
+ if (rangeHi.toDouble() < rangeLo.toDouble()) {
status = U_INVALID_FORMAT_ERROR;
break;
}
- // For ranges of samples with fraction decimal digits, scale the number up so that we
- // are adding one in the units place. Avoids roundoffs from repetitive adds of tenths.
+ DecimalQuantity incrementDq;
+ incrementDq.setToInt(1);
+ int32_t lowerDispMag = rangeLo.getLowerDisplayMagnitude();
+ int32_t exponent = rangeLo.getExponent();
+ int32_t incrementScale = lowerDispMag + exponent;
+ incrementDq.adjustMagnitude(incrementScale);
+ double incrementVal = incrementDq.toDouble(); // 10 ^ incrementScale
+
- double scale = scaleForInt(rangeLo);
- double t = scaleForInt(rangeHi);
- if (t > scale) {
- scale = t;
- }
- rangeLo *= scale;
- rangeHi *= scale;
- for (double n=rangeLo; n<=rangeHi; n+=1) {
- double sampleValue = n/scale;
+ DecimalQuantity dq(rangeLo);
+ double dblValue = dq.toDouble();
+ double end = rangeHi.toDouble();
+
+ while (dblValue <= end) {
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;
+ if (!(dblValue == floor(dblValue) && dq.fractionCount() > 0)) {
+ destDbl[sampleCount++] = dblValue;
}
} 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;
+ destDq[sampleCount++] = dq;
}
if (sampleCount >= destCapacity) {
break;
}
+
+ // Increment dq for next iteration
+
+ // Because DecNum and DecimalQuantity do not support
+ // add operations, we need to convert to/from double,
+ // despite precision lossiness for decimal fractions like 0.1.
+ dblValue += incrementVal;
+ DecNum newDqDecNum;
+ newDqDecNum.setTo(dblValue, status);
+ DecimalQuantity newDq;
+ newDq.setToDecNum(newDqDecNum, status);
+ newDq.setMinFraction(-lowerDispMag);
+ newDq.roundToMagnitude(lowerDispMag, RoundingMode::UNUM_ROUND_HALFEVEN, status);
+ newDq.adjustMagnitude(-exponent);
+ newDq.adjustExponent(exponent);
+ dblValue = newDq.toDouble();
+ dq = newDq;
}
}
sampleStartIdx = sampleEndIdx + 1;
@@ -505,7 +507,7 @@ PluralRules::getSamples(const UnicodeString &keyword, double *dest,
}
int32_t
-PluralRules::getSamples(const UnicodeString &keyword, FixedDecimal *dest,
+PluralRules::getSamples(const UnicodeString &keyword, DecimalQuantity *dest,
int32_t destCapacity, UErrorCode& status) {
if (U_FAILURE(status)) {
return 0;
@@ -552,7 +554,7 @@ PluralRules::isKeyword(const UnicodeString& keyword) const {
UnicodeString
PluralRules::getKeywordOther() const {
- return UnicodeString(TRUE, PLURAL_KEYWORD_OTHER, 5);
+ return UnicodeString(true, PLURAL_KEYWORD_OTHER, 5);
}
bool
@@ -639,11 +641,11 @@ PluralRuleParser::parse(const UnicodeString& ruleData, PluralRules *prules, UErr
break;
case tNot:
U_ASSERT(curAndConstraint != nullptr);
- curAndConstraint->negated=TRUE;
+ curAndConstraint->negated=true;
break;
case tNotEqual:
- curAndConstraint->negated=TRUE;
+ curAndConstraint->negated=true;
U_FALLTHROUGH;
case tIn:
case tWithin:
@@ -759,7 +761,7 @@ PluralRuleParser::parse(const UnicodeString& ruleData, PluralRules *prules, UErr
break;
}
if (type == tEllipsis) {
- currentChain->fIntegerSamplesUnbounded = TRUE;
+ currentChain->fIntegerSamplesUnbounded = true;
continue;
}
currentChain->fIntegerSamples.append(token);
@@ -773,7 +775,7 @@ PluralRuleParser::parse(const UnicodeString& ruleData, PluralRules *prules, UErr
break;
}
if (type == tEllipsis) {
- currentChain->fDecimalSamplesUnbounded = TRUE;
+ currentChain->fDecimalSamplesUnbounded = true;
continue;
}
currentChain->fDecimalSamples.append(token);
@@ -820,7 +822,7 @@ PluralRules::getRuleFromResource(const Locale& locale, UPluralType type, UErrorC
}
int32_t resLen=0;
const char *curLocaleName=locale.getBaseName();
- const UChar* s = ures_getStringByKey(locRes.getAlias(), curLocaleName, &resLen, &errCode);
+ const char16_t* s = ures_getStringByKey(locRes.getAlias(), curLocaleName, &resLen, &errCode);
if (s == nullptr) {
// Check parent locales.
@@ -917,10 +919,10 @@ AndConstraint::~AndConstraint() {
UBool
AndConstraint::isFulfilled(const IFixedDecimal &number) {
- UBool result = TRUE;
+ UBool result = true;
if (digitsType == none) {
// An empty AndConstraint, created by a rule with a keyword but no following expression.
- return TRUE;
+ return true;
}
PluralOperand operand = tokenTypeToPluralOperand(digitsType);
@@ -929,7 +931,7 @@ AndConstraint::isFulfilled(const IFixedDecimal &number) {
// May be non-integer (n option only)
do {
if (integerOnly && n != uprv_floor(n)) {
- result = FALSE;
+ result = false;
break;
}
@@ -941,14 +943,14 @@ AndConstraint::isFulfilled(const IFixedDecimal &number) {
n == value; // 'is' rule
break;
}
- result = FALSE; // 'in' or 'within' rule
+ result = false; // 'in' or 'within' rule
for (int32_t r=0; r<rangeList->size(); r+=2) {
if (rangeList->elementAti(r) <= n && n <= rangeList->elementAti(r+1)) {
- result = TRUE;
+ result = true;
break;
}
}
- } while (FALSE);
+ } while (false);
if (negated) {
result = !result;
@@ -1024,10 +1026,10 @@ OrConstraint::add(UErrorCode& status) {
UBool
OrConstraint::isFulfilled(const IFixedDecimal &number) {
OrConstraint* orRule=this;
- UBool result=FALSE;
+ UBool result=false;
while (orRule!=nullptr && !result) {
- result=TRUE;
+ result=true;
AndConstraint* andRule = orRule->childNode;
while (andRule!=nullptr && result) {
result = andRule->isFulfilled(number);
@@ -1084,7 +1086,7 @@ RuleChain::select(const IFixedDecimal &number) const {
}
}
}
- return UnicodeString(TRUE, PLURAL_KEYWORD_OTHER, 5);
+ return UnicodeString(true, PLURAL_KEYWORD_OTHER, 5);
}
static UnicodeString tokenString(tokenType tok) {
@@ -1112,7 +1114,7 @@ static UnicodeString tokenString(tokenType tok) {
void
RuleChain::dumpRules(UnicodeString& result) {
- UChar digitString[16];
+ char16_t digitString[16];
if ( ruleHeader != nullptr ) {
result += fKeyword;
@@ -1223,14 +1225,14 @@ RuleChain::getKeywords(int32_t capacityOfKeywords, UnicodeString* keywords, int3
UBool
RuleChain::isKeyword(const UnicodeString& keywordParam) const {
if ( fKeyword == keywordParam ) {
- return TRUE;
+ return true;
}
if ( fNext != nullptr ) {
return fNext->isKeyword(keywordParam);
}
else {
- return FALSE;
+ return false;
}
}
@@ -1376,7 +1378,7 @@ PluralRuleParser::getNextToken(UErrorCode &status)
return;
}
- UChar ch;
+ char16_t ch;
while (ruleIndex < ruleSrc->length()) {
ch = ruleSrc->charAt(ruleIndex);
type = charType(ch);
@@ -1457,7 +1459,7 @@ PluralRuleParser::getNextToken(UErrorCode &status)
}
tokenType
-PluralRuleParser::charType(UChar ch) {
+PluralRuleParser::charType(char16_t ch) {
if ((ch>=U_ZERO) && (ch<=U_NINE)) {
return tNumber;
}
@@ -1545,34 +1547,24 @@ PluralKeywordEnumeration::PluralKeywordEnumeration(RuleChain *header, UErrorCode
return;
}
fKeywordNames.setDeleter(uprv_deleteUObject);
- UBool addKeywordOther = TRUE;
+ UBool addKeywordOther = true;
RuleChain *node = header;
while (node != nullptr) {
- auto newElem = new UnicodeString(node->fKeyword);
- if (newElem == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return;
- }
- fKeywordNames.addElementX(newElem, status);
+ LocalPointer<UnicodeString> newElem(node->fKeyword.clone(), status);
+ fKeywordNames.adoptElement(newElem.orphan(), status);
if (U_FAILURE(status)) {
- delete newElem;
return;
}
if (0 == node->fKeyword.compare(PLURAL_KEYWORD_OTHER, 5)) {
- addKeywordOther = FALSE;
+ addKeywordOther = false;
}
node = node->fNext;
}
if (addKeywordOther) {
- auto newElem = new UnicodeString(PLURAL_KEYWORD_OTHER);
- if (newElem == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return;
- }
- fKeywordNames.addElementX(newElem, status);
+ LocalPointer<UnicodeString> newElem(new UnicodeString(PLURAL_KEYWORD_OTHER), status);
+ fKeywordNames.adoptElement(newElem.orphan(), status);
if (U_FAILURE(status)) {
- delete newElem;
return;
}
}
@@ -1628,7 +1620,7 @@ 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);
+ // long visiblePower = (int) Math.pow(10.0, v);
// if (decimalDigits > visiblePower) {
// throw new IllegalArgumentException();
// }
@@ -1761,7 +1753,7 @@ void FixedDecimal::init(double n, int32_t v, int64_t f, int32_t e, int32_t c) {
v = 0;
f = 0;
intValue = 0;
- _hasIntegerValue = FALSE;
+ _hasIntegerValue = false;
} else {
intValue = (int64_t)source;
_hasIntegerValue = (source == intValue);
@@ -1787,13 +1779,13 @@ void FixedDecimal::init(double n, int32_t v, int64_t f, int32_t e, int32_t c) {
// A single multiply of the original number works more reliably.
static int32_t p10[] = {1, 10, 100, 1000, 10000};
UBool FixedDecimal::quickInit(double n) {
- UBool success = FALSE;
+ UBool success = false;
n = fabs(n);
int32_t numFractionDigits;
for (numFractionDigits = 0; numFractionDigits <= 3; numFractionDigits++) {
double scaledN = n * p10[numFractionDigits];
if (scaledN == floor(scaledN)) {
- success = TRUE;
+ success = true;
break;
}
}
@@ -1816,9 +1808,9 @@ int32_t FixedDecimal::decimals(double n) {
}
}
- // Slow path, convert with sprintf, parse converted output.
+ // Slow path, convert with snprintf, parse converted output.
char buf[30] = {0};
- sprintf(buf, "%1.15e", n);
+ snprintf(buf, sizeof(buf), "%1.15e", n);
// formatted number looks like this: 1.234567890123457e-01
int exponent = atoi(buf+18);
int numFractionDigits = 15;
@@ -1881,7 +1873,7 @@ void FixedDecimal::adjustForMinFractionDigits(int32_t minFractionDigits) {
double FixedDecimal::getPluralOperand(PluralOperand operand) const {
switch(operand) {
- case PLURAL_OPERAND_N: return (exponent == 0 ? source : source * pow(10, exponent));
+ case PLURAL_OPERAND_N: return (exponent == 0 ? source : source * pow(10.0, exponent));
case PLURAL_OPERAND_I: return (double) longValue();
case PLURAL_OPERAND_F: return static_cast<double>(decimalDigits);
case PLURAL_OPERAND_T: return static_cast<double>(decimalDigitsWithoutTrailingZeros);
@@ -1932,14 +1924,14 @@ UnicodeString FixedDecimal::toString() const {
}
double FixedDecimal::doubleValue() const {
- return (isNegative ? -source : source) * pow(10, exponent);
+ return (isNegative ? -source : source) * pow(10.0, exponent);
}
int64_t FixedDecimal::longValue() const {
if (exponent == 0) {
return intValue;
} else {
- return (long) (pow(10, exponent) * intValue);
+ return (long) (pow(10.0, exponent) * intValue);
}
}
diff --git a/contrib/libs/icu/i18n/plurrule_impl.h b/contrib/libs/icu/i18n/plurrule_impl.h
index 7274da58f0..4de6d6460a 100644
--- a/contrib/libs/icu/i18n/plurrule_impl.h
+++ b/contrib/libs/icu/i18n/plurrule_impl.h
@@ -34,7 +34,7 @@
* 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))
+#define UPLRULES_NO_UNIQUE_VALUE_DECIMAL(ERROR_CODE) (DecimalQuantity::fromExponentString(u"-0.00123456777", ERROR_CODE))
class PluralRulesTest;
@@ -50,67 +50,67 @@ namespace pluralimpl {
// TODO: Remove this and replace with u"" literals. Was for EBCDIC compatibility.
-static const UChar DOT = ((UChar) 0x002E);
-static const UChar SINGLE_QUOTE = ((UChar) 0x0027);
-static const UChar SLASH = ((UChar) 0x002F);
-static const UChar BACKSLASH = ((UChar) 0x005C);
-static const UChar SPACE = ((UChar) 0x0020);
-static const UChar EXCLAMATION = ((UChar) 0x0021);
-static const UChar QUOTATION_MARK = ((UChar) 0x0022);
-static const UChar NUMBER_SIGN = ((UChar) 0x0023);
-static const UChar PERCENT_SIGN = ((UChar) 0x0025);
-static const UChar ASTERISK = ((UChar) 0x002A);
-static const UChar COMMA = ((UChar) 0x002C);
-static const UChar HYPHEN = ((UChar) 0x002D);
-static const UChar U_ZERO = ((UChar) 0x0030);
-static const UChar U_ONE = ((UChar) 0x0031);
-static const UChar U_TWO = ((UChar) 0x0032);
-static const UChar U_THREE = ((UChar) 0x0033);
-static const UChar U_FOUR = ((UChar) 0x0034);
-static const UChar U_FIVE = ((UChar) 0x0035);
-static const UChar U_SIX = ((UChar) 0x0036);
-static const UChar U_SEVEN = ((UChar) 0x0037);
-static const UChar U_EIGHT = ((UChar) 0x0038);
-static const UChar U_NINE = ((UChar) 0x0039);
-static const UChar COLON = ((UChar) 0x003A);
-static const UChar SEMI_COLON = ((UChar) 0x003B);
-static const UChar EQUALS = ((UChar) 0x003D);
-static const UChar AT = ((UChar) 0x0040);
-static const UChar CAP_A = ((UChar) 0x0041);
-static const UChar CAP_B = ((UChar) 0x0042);
-static const UChar CAP_R = ((UChar) 0x0052);
-static const UChar CAP_Z = ((UChar) 0x005A);
-static const UChar LOWLINE = ((UChar) 0x005F);
-static const UChar LEFTBRACE = ((UChar) 0x007B);
-static const UChar RIGHTBRACE = ((UChar) 0x007D);
-static const UChar TILDE = ((UChar) 0x007E);
-static const UChar ELLIPSIS = ((UChar) 0x2026);
-
-static const UChar LOW_A = ((UChar) 0x0061);
-static const UChar LOW_B = ((UChar) 0x0062);
-static const UChar LOW_C = ((UChar) 0x0063);
-static const UChar LOW_D = ((UChar) 0x0064);
-static const UChar LOW_E = ((UChar) 0x0065);
-static const UChar LOW_F = ((UChar) 0x0066);
-static const UChar LOW_G = ((UChar) 0x0067);
-static const UChar LOW_H = ((UChar) 0x0068);
-static const UChar LOW_I = ((UChar) 0x0069);
-static const UChar LOW_J = ((UChar) 0x006a);
-static const UChar LOW_K = ((UChar) 0x006B);
-static const UChar LOW_L = ((UChar) 0x006C);
-static const UChar LOW_M = ((UChar) 0x006D);
-static const UChar LOW_N = ((UChar) 0x006E);
-static const UChar LOW_O = ((UChar) 0x006F);
-static const UChar LOW_P = ((UChar) 0x0070);
-static const UChar LOW_Q = ((UChar) 0x0071);
-static const UChar LOW_R = ((UChar) 0x0072);
-static const UChar LOW_S = ((UChar) 0x0073);
-static const UChar LOW_T = ((UChar) 0x0074);
-static const UChar LOW_U = ((UChar) 0x0075);
-static const UChar LOW_V = ((UChar) 0x0076);
-static const UChar LOW_W = ((UChar) 0x0077);
-static const UChar LOW_Y = ((UChar) 0x0079);
-static const UChar LOW_Z = ((UChar) 0x007A);
+static const char16_t DOT = ((char16_t) 0x002E);
+static const char16_t SINGLE_QUOTE = ((char16_t) 0x0027);
+static const char16_t SLASH = ((char16_t) 0x002F);
+static const char16_t BACKSLASH = ((char16_t) 0x005C);
+static const char16_t SPACE = ((char16_t) 0x0020);
+static const char16_t EXCLAMATION = ((char16_t) 0x0021);
+static const char16_t QUOTATION_MARK = ((char16_t) 0x0022);
+static const char16_t NUMBER_SIGN = ((char16_t) 0x0023);
+static const char16_t PERCENT_SIGN = ((char16_t) 0x0025);
+static const char16_t ASTERISK = ((char16_t) 0x002A);
+static const char16_t COMMA = ((char16_t) 0x002C);
+static const char16_t HYPHEN = ((char16_t) 0x002D);
+static const char16_t U_ZERO = ((char16_t) 0x0030);
+static const char16_t U_ONE = ((char16_t) 0x0031);
+static const char16_t U_TWO = ((char16_t) 0x0032);
+static const char16_t U_THREE = ((char16_t) 0x0033);
+static const char16_t U_FOUR = ((char16_t) 0x0034);
+static const char16_t U_FIVE = ((char16_t) 0x0035);
+static const char16_t U_SIX = ((char16_t) 0x0036);
+static const char16_t U_SEVEN = ((char16_t) 0x0037);
+static const char16_t U_EIGHT = ((char16_t) 0x0038);
+static const char16_t U_NINE = ((char16_t) 0x0039);
+static const char16_t COLON = ((char16_t) 0x003A);
+static const char16_t SEMI_COLON = ((char16_t) 0x003B);
+static const char16_t EQUALS = ((char16_t) 0x003D);
+static const char16_t AT = ((char16_t) 0x0040);
+static const char16_t CAP_A = ((char16_t) 0x0041);
+static const char16_t CAP_B = ((char16_t) 0x0042);
+static const char16_t CAP_R = ((char16_t) 0x0052);
+static const char16_t CAP_Z = ((char16_t) 0x005A);
+static const char16_t LOWLINE = ((char16_t) 0x005F);
+static const char16_t LEFTBRACE = ((char16_t) 0x007B);
+static const char16_t RIGHTBRACE = ((char16_t) 0x007D);
+static const char16_t TILDE = ((char16_t) 0x007E);
+static const char16_t ELLIPSIS = ((char16_t) 0x2026);
+
+static const char16_t LOW_A = ((char16_t) 0x0061);
+static const char16_t LOW_B = ((char16_t) 0x0062);
+static const char16_t LOW_C = ((char16_t) 0x0063);
+static const char16_t LOW_D = ((char16_t) 0x0064);
+static const char16_t LOW_E = ((char16_t) 0x0065);
+static const char16_t LOW_F = ((char16_t) 0x0066);
+static const char16_t LOW_G = ((char16_t) 0x0067);
+static const char16_t LOW_H = ((char16_t) 0x0068);
+static const char16_t LOW_I = ((char16_t) 0x0069);
+static const char16_t LOW_J = ((char16_t) 0x006a);
+static const char16_t LOW_K = ((char16_t) 0x006B);
+static const char16_t LOW_L = ((char16_t) 0x006C);
+static const char16_t LOW_M = ((char16_t) 0x006D);
+static const char16_t LOW_N = ((char16_t) 0x006E);
+static const char16_t LOW_O = ((char16_t) 0x006F);
+static const char16_t LOW_P = ((char16_t) 0x0070);
+static const char16_t LOW_Q = ((char16_t) 0x0071);
+static const char16_t LOW_R = ((char16_t) 0x0072);
+static const char16_t LOW_S = ((char16_t) 0x0073);
+static const char16_t LOW_T = ((char16_t) 0x0074);
+static const char16_t LOW_U = ((char16_t) 0x0075);
+static const char16_t LOW_V = ((char16_t) 0x0076);
+static const char16_t LOW_W = ((char16_t) 0x0077);
+static const char16_t LOW_Y = ((char16_t) 0x0079);
+static const char16_t LOW_Z = ((char16_t) 0x007A);
}
@@ -164,7 +164,7 @@ public:
private:
static tokenType getKeyType(const UnicodeString& token, tokenType type);
- static tokenType charType(UChar ch);
+ static tokenType charType(char16_t ch);
static UBool isValidKeyword(const UnicodeString& token);
const UnicodeString *ruleSrc; // The rules string.
@@ -299,16 +299,16 @@ class U_I18N_API FixedDecimal: public IFixedDecimal, public UObject {
FixedDecimal(double n, int32_t);
explicit FixedDecimal(double n);
FixedDecimal();
- ~FixedDecimal() U_OVERRIDE;
+ ~FixedDecimal() override;
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;
- bool hasIntegerValue() const U_OVERRIDE;
+ double getPluralOperand(PluralOperand operand) const override;
+ bool isNaN() const override;
+ bool isInfinite() const override;
+ bool hasIntegerValue() const override;
bool isNanOrInfinity() const; // used in decimfmtimpl.cpp
@@ -410,8 +410,8 @@ class PluralKeywordEnumeration : public StringEnumeration {
public:
PluralKeywordEnumeration(RuleChain *header, UErrorCode& status);
virtual ~PluralKeywordEnumeration();
- static UClassID U_EXPORT2 getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID U_EXPORT2 getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
virtual const UnicodeString* snext(UErrorCode& status) override;
virtual void reset(UErrorCode& status) override;
virtual int32_t count(UErrorCode& status) const override;
diff --git a/contrib/libs/icu/i18n/quant.cpp b/contrib/libs/icu/i18n/quant.cpp
index ed33933387..4a45db1bf5 100644
--- a/contrib/libs/icu/i18n/quant.cpp
+++ b/contrib/libs/icu/i18n/quant.cpp
@@ -103,21 +103,21 @@ UnicodeString& Quantifier::toPattern(UnicodeString& result,
matcher->toMatcher()->toPattern(result, escapeUnprintable);
if (minCount == 0) {
if (maxCount == 1) {
- return result.append((UChar)63); /*?*/
+ return result.append((char16_t)63); /*?*/
} else if (maxCount == MAX) {
- return result.append((UChar)42); /***/
+ return result.append((char16_t)42); /***/
}
// else fall through
} else if (minCount == 1 && maxCount == MAX) {
- return result.append((UChar)43); /*+*/
+ return result.append((char16_t)43); /*+*/
}
- result.append((UChar)123); /*{*/
+ result.append((char16_t)123); /*{*/
ICU_Utility::appendNumber(result, minCount);
- result.append((UChar)44); /*,*/
+ result.append((char16_t)44); /*,*/
if (maxCount != MAX) {
ICU_Utility::appendNumber(result, maxCount);
}
- result.append((UChar)125); /*}*/
+ result.append((char16_t)125); /*}*/
return result;
}
diff --git a/contrib/libs/icu/i18n/quantityformatter.cpp b/contrib/libs/icu/i18n/quantityformatter.cpp
index 9c9aa99b67..0a1982e3d4 100644
--- a/contrib/libs/icu/i18n/quantityformatter.cpp
+++ b/contrib/libs/icu/i18n/quantityformatter.cpp
@@ -32,14 +32,14 @@ U_NAMESPACE_BEGIN
QuantityFormatter::QuantityFormatter() {
for (int32_t i = 0; i < UPRV_LENGTHOF(formatters); ++i) {
- formatters[i] = NULL;
+ formatters[i] = nullptr;
}
}
QuantityFormatter::QuantityFormatter(const QuantityFormatter &other) {
for (int32_t i = 0; i < UPRV_LENGTHOF(formatters); ++i) {
- if (other.formatters[i] == NULL) {
- formatters[i] = NULL;
+ if (other.formatters[i] == nullptr) {
+ formatters[i] = nullptr;
} else {
formatters[i] = new SimpleFormatter(*other.formatters[i]);
}
@@ -53,8 +53,8 @@ QuantityFormatter &QuantityFormatter::operator=(
}
for (int32_t i = 0; i < UPRV_LENGTHOF(formatters); ++i) {
delete formatters[i];
- if (other.formatters[i] == NULL) {
- formatters[i] = NULL;
+ if (other.formatters[i] == nullptr) {
+ formatters[i] = nullptr;
} else {
formatters[i] = new SimpleFormatter(*other.formatters[i]);
}
@@ -71,7 +71,7 @@ QuantityFormatter::~QuantityFormatter() {
void QuantityFormatter::reset() {
for (int32_t i = 0; i < UPRV_LENGTHOF(formatters); ++i) {
delete formatters[i];
- formatters[i] = NULL;
+ formatters[i] = nullptr;
}
}
@@ -81,26 +81,26 @@ UBool QuantityFormatter::addIfAbsent(
UErrorCode &status) {
int32_t pluralIndex = StandardPlural::indexFromString(variant, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
- if (formatters[pluralIndex] != NULL) {
- return TRUE;
+ if (formatters[pluralIndex] != nullptr) {
+ return true;
}
SimpleFormatter *newFmt = new SimpleFormatter(rawPattern, 0, 1, status);
- if (newFmt == NULL) {
+ if (newFmt == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return FALSE;
+ return false;
}
if (U_FAILURE(status)) {
delete newFmt;
- return FALSE;
+ return false;
}
formatters[pluralIndex] = newFmt;
- return TRUE;
+ return true;
}
UBool QuantityFormatter::isValid() const {
- return formatters[StandardPlural::OTHER] != NULL;
+ return formatters[StandardPlural::OTHER] != nullptr;
}
const SimpleFormatter *QuantityFormatter::getByVariant(
@@ -108,7 +108,7 @@ const SimpleFormatter *QuantityFormatter::getByVariant(
U_ASSERT(isValid());
int32_t pluralIndex = StandardPlural::indexOrOtherIndexFromString(variant);
const SimpleFormatter *pattern = formatters[pluralIndex];
- if (pattern == NULL) {
+ if (pattern == nullptr) {
pattern = formatters[StandardPlural::OTHER];
}
return pattern;
@@ -127,9 +127,9 @@ UnicodeString &QuantityFormatter::format(
return appendTo;
}
const SimpleFormatter *pattern = formatters[p];
- if (pattern == NULL) {
+ if (pattern == nullptr) {
pattern = formatters[StandardPlural::OTHER];
- if (pattern == NULL) {
+ if (pattern == nullptr) {
status = U_INVALID_STATE_ERROR;
return appendTo;
}
@@ -152,7 +152,7 @@ StandardPlural::Form QuantityFormatter::selectPlural(
}
UnicodeString pluralKeyword;
const DecimalFormat *decFmt = dynamic_cast<const DecimalFormat *>(&fmt);
- if (decFmt != NULL) {
+ if (decFmt != nullptr) {
number::impl::DecimalQuantity dq;
decFmt->formatToDecimalQuantity(number, dq, status);
if (U_FAILURE(status)) {
diff --git a/contrib/libs/icu/i18n/quantityformatter.h b/contrib/libs/icu/i18n/quantityformatter.h
index 841798cf88..ca0c0ee371 100644
--- a/contrib/libs/icu/i18n/quantityformatter.h
+++ b/contrib/libs/icu/i18n/quantityformatter.h
@@ -86,7 +86,7 @@ public:
/**
* Gets the pattern formatter that would be used for a particular variant.
* If isValid() returns true, this method is guaranteed to return a
- * non-NULL value.
+ * non-nullptr value.
*/
const SimpleFormatter *getByVariant(const char *variant) const;
diff --git a/contrib/libs/icu/i18n/rbnf.cpp b/contrib/libs/icu/i18n/rbnf.cpp
index 7f54fd7a33..06599b4fd1 100644
--- a/contrib/libs/icu/i18n/rbnf.cpp
+++ b/contrib/libs/icu/i18n/rbnf.cpp
@@ -45,19 +45,19 @@
#define U_ICUDATA_RBNF U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "rbnf"
-static const UChar gPercentPercent[] =
+static const char16_t gPercentPercent[] =
{
0x25, 0x25, 0
}; /* "%%" */
// All urbnf objects are created through openRules, so we init all of the
// Unicode string constants required by rbnf, nfrs, or nfr here.
-static const UChar gLenientParse[] =
+static const char16_t gLenientParse[] =
{
0x25, 0x25, 0x6C, 0x65, 0x6E, 0x69, 0x65, 0x6E, 0x74, 0x2D, 0x70, 0x61, 0x72, 0x73, 0x65, 0x3A, 0
}; /* "%%lenient-parse:" */
-static const UChar gSemiColon = 0x003B;
-static const UChar gSemiPercent[] =
+static const char16_t gSemiColon = 0x003B;
+static const char16_t gSemiPercent[] =
{
0x3B, 0x25, 0
}; /* ";%" */
@@ -87,48 +87,48 @@ protected:
public:
LocalizationInfo() : refcount(0) {}
- LocalizationInfo* ref(void) {
+ LocalizationInfo* ref() {
++refcount;
return this;
}
- LocalizationInfo* unref(void) {
+ LocalizationInfo* unref() {
if (refcount && --refcount == 0) {
delete this;
}
- return NULL;
+ return nullptr;
}
virtual bool operator==(const LocalizationInfo* rhs) const;
inline bool operator!=(const LocalizationInfo* rhs) const { return !operator==(rhs); }
- virtual int32_t getNumberOfRuleSets(void) const = 0;
- virtual const UChar* getRuleSetName(int32_t index) const = 0;
- virtual int32_t getNumberOfDisplayLocales(void) const = 0;
- virtual const UChar* getLocaleName(int32_t index) const = 0;
- virtual const UChar* getDisplayName(int32_t localeIndex, int32_t ruleIndex) const = 0;
+ virtual int32_t getNumberOfRuleSets() const = 0;
+ virtual const char16_t* getRuleSetName(int32_t index) const = 0;
+ virtual int32_t getNumberOfDisplayLocales() const = 0;
+ virtual const char16_t* getLocaleName(int32_t index) const = 0;
+ virtual const char16_t* getDisplayName(int32_t localeIndex, int32_t ruleIndex) const = 0;
- virtual int32_t indexForLocale(const UChar* locale) const;
- virtual int32_t indexForRuleSet(const UChar* ruleset) const;
+ virtual int32_t indexForLocale(const char16_t* locale) const;
+ virtual int32_t indexForRuleSet(const char16_t* ruleset) const;
// virtual UClassID getDynamicClassID() const = 0;
-// static UClassID getStaticClassID(void);
+// static UClassID getStaticClassID();
};
LocalizationInfo::~LocalizationInfo() {}
//UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(LocalizationInfo)
-// if both strings are NULL, this returns TRUE
+// if both strings are nullptr, this returns true
static UBool
-streq(const UChar* lhs, const UChar* rhs) {
+streq(const char16_t* lhs, const char16_t* rhs) {
if (rhs == lhs) {
- return TRUE;
+ return true;
}
if (lhs && rhs) {
return u_strcmp(lhs, rhs) == 0;
}
- return FALSE;
+ return false;
}
bool
@@ -148,7 +148,7 @@ LocalizationInfo::operator==(const LocalizationInfo* rhs) const {
int32_t dlc = getNumberOfDisplayLocales();
if (dlc == rhs->getNumberOfDisplayLocales()) {
for (int i = 0; i < dlc; ++i) {
- const UChar* locale = getLocaleName(i);
+ const char16_t* locale = getLocaleName(i);
int32_t ix = rhs->indexForLocale(locale);
// if no locale, ix is -1, getLocaleName returns null, so streq returns false
if (!streq(locale, rhs->getLocaleName(ix))) {
@@ -168,7 +168,7 @@ LocalizationInfo::operator==(const LocalizationInfo* rhs) const {
}
int32_t
-LocalizationInfo::indexForLocale(const UChar* locale) const {
+LocalizationInfo::indexForLocale(const char16_t* locale) const {
for (int i = 0; i < getNumberOfDisplayLocales(); ++i) {
if (streq(locale, getLocaleName(i))) {
return i;
@@ -178,7 +178,7 @@ LocalizationInfo::indexForLocale(const UChar* locale) const {
}
int32_t
-LocalizationInfo::indexForRuleSet(const UChar* ruleset) const {
+LocalizationInfo::indexForRuleSet(const char16_t* ruleset) const {
if (ruleset) {
for (int i = 0; i < getNumberOfRuleSets(); ++i) {
if (streq(ruleset, getRuleSetName(i))) {
@@ -198,9 +198,9 @@ class VArray {
int32_t size;
Fn_Deleter deleter;
public:
- VArray() : buf(NULL), cap(0), size(0), deleter(NULL) {}
+ VArray() : buf(nullptr), cap(0), size(0), deleter(nullptr) {}
- VArray(Fn_Deleter del) : buf(NULL), cap(0), size(0), deleter(del) {}
+ VArray(Fn_Deleter del) : buf(nullptr), cap(0), size(0), deleter(del) {}
~VArray() {
if (deleter) {
@@ -225,12 +225,12 @@ public:
} else {
cap += 256;
}
- if (buf == NULL) {
+ if (buf == nullptr) {
buf = (void**)uprv_malloc(cap * sizeof(void*));
} else {
buf = (void**)uprv_realloc(buf, cap * sizeof(void*));
}
- if (buf == NULL) {
+ if (buf == nullptr) {
// if we couldn't realloc, we leak the memory we've already allocated, but we're in deep trouble anyway
status = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -243,9 +243,9 @@ public:
}
}
- void** release(void) {
+ void** release() {
void** result = buf;
- buf = NULL;
+ buf = nullptr;
cap = 0;
size = 0;
return result;
@@ -255,14 +255,14 @@ public:
class LocDataParser;
class StringLocalizationInfo : public LocalizationInfo {
- UChar* info;
- UChar*** data;
+ char16_t* info;
+ char16_t*** data;
int32_t numRuleSets;
int32_t numLocales;
friend class LocDataParser;
- StringLocalizationInfo(UChar* i, UChar*** d, int32_t numRS, int32_t numLocs)
+ StringLocalizationInfo(char16_t* i, char16_t*** d, int32_t numRS, int32_t numLocs)
: info(i), data(d), numRuleSets(numRS), numLocales(numLocs)
{
}
@@ -271,14 +271,14 @@ public:
static StringLocalizationInfo* create(const UnicodeString& info, UParseError& perror, UErrorCode& status);
virtual ~StringLocalizationInfo();
- virtual int32_t getNumberOfRuleSets(void) const override { return numRuleSets; }
- virtual const UChar* getRuleSetName(int32_t index) const override;
- virtual int32_t getNumberOfDisplayLocales(void) const override { return numLocales; }
- virtual const UChar* getLocaleName(int32_t index) const override;
- virtual const UChar* getDisplayName(int32_t localeIndex, int32_t ruleIndex) const override;
+ virtual int32_t getNumberOfRuleSets() const override { return numRuleSets; }
+ virtual const char16_t* getRuleSetName(int32_t index) const override;
+ virtual int32_t getNumberOfDisplayLocales() const override { return numLocales; }
+ virtual const char16_t* getLocaleName(int32_t index) const override;
+ virtual const char16_t* getDisplayName(int32_t localeIndex, int32_t ruleIndex) const override;
// virtual UClassID getDynamicClassID() const;
-// static UClassID getStaticClassID(void);
+// static UClassID getStaticClassID();
private:
void init(UErrorCode& status) const;
@@ -298,48 +298,48 @@ enum {
* Utility for parsing a localization string and returning a StringLocalizationInfo*.
*/
class LocDataParser {
- UChar* data;
- const UChar* e;
- UChar* p;
- UChar ch;
+ char16_t* data;
+ const char16_t* e;
+ char16_t* p;
+ char16_t ch;
UParseError& pe;
UErrorCode& ec;
public:
LocDataParser(UParseError& parseError, UErrorCode& status)
- : data(NULL), e(NULL), p(NULL), ch(0xffff), pe(parseError), ec(status) {}
+ : data(nullptr), e(nullptr), p(nullptr), ch(0xffff), pe(parseError), ec(status) {}
~LocDataParser() {}
/*
* On a successful parse, return a StringLocalizationInfo*, otherwise delete locData, set perror and status,
- * and return NULL. The StringLocalizationInfo will adopt locData if it is created.
+ * and return nullptr. The StringLocalizationInfo will adopt locData if it is created.
*/
- StringLocalizationInfo* parse(UChar* data, int32_t len);
+ StringLocalizationInfo* parse(char16_t* data, int32_t len);
private:
- inline void inc(void) {
+ inline void inc() {
++p;
ch = 0xffff;
}
- inline UBool checkInc(UChar c) {
+ inline UBool checkInc(char16_t c) {
if (p < e && (ch == c || *p == c)) {
inc();
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
- inline UBool check(UChar c) {
+ inline UBool check(char16_t c) {
return p < e && (ch == c || *p == c);
}
- inline void skipWhitespace(void) {
+ inline void skipWhitespace() {
while (p < e && PatternProps::isWhiteSpace(ch != 0xffff ? ch : *p)) {
inc();
}
}
- inline UBool inList(UChar c, const UChar* list) const {
+ inline UBool inList(char16_t c, const char16_t* list) const {
if (*list == SPACE && PatternProps::isWhiteSpace(c)) {
- return TRUE;
+ return true;
}
while (*list && *list != c) {
++list;
@@ -348,36 +348,36 @@ private:
}
void parseError(const char* msg);
- StringLocalizationInfo* doParse(void);
+ StringLocalizationInfo* doParse();
- UChar** nextArray(int32_t& requiredLength);
- UChar* nextString(void);
+ char16_t** nextArray(int32_t& requiredLength);
+ char16_t* nextString();
};
#ifdef RBNF_DEBUG
#define ERROR(msg) UPRV_BLOCK_MACRO_BEGIN { \
parseError(msg); \
- return NULL; \
+ return nullptr; \
} UPRV_BLOCK_MACRO_END
#define EXPLANATION_ARG explanationArg
#else
#define ERROR(msg) UPRV_BLOCK_MACRO_BEGIN { \
- parseError(NULL); \
- return NULL; \
+ parseError(nullptr); \
+ return nullptr; \
} UPRV_BLOCK_MACRO_END
#define EXPLANATION_ARG
#endif
-static const UChar DQUOTE_STOPLIST[] = {
+static const char16_t DQUOTE_STOPLIST[] = {
QUOTE, 0
};
-static const UChar SQUOTE_STOPLIST[] = {
+static const char16_t SQUOTE_STOPLIST[] = {
TICK, 0
};
-static const UChar NOQUOTE_STOPLIST[] = {
+static const char16_t NOQUOTE_STOPLIST[] = {
SPACE, COMMA, CLOSE_ANGLE, OPEN_ANGLE, TICK, QUOTE, 0
};
@@ -387,10 +387,10 @@ DeleteFn(void* p) {
}
StringLocalizationInfo*
-LocDataParser::parse(UChar* _data, int32_t len) {
+LocDataParser::parse(char16_t* _data, int32_t len) {
if (U_FAILURE(ec)) {
if (_data) uprv_free(_data);
- return NULL;
+ return nullptr;
}
pe.line = 0;
@@ -398,15 +398,15 @@ LocDataParser::parse(UChar* _data, int32_t len) {
pe.postContext[0] = 0;
pe.preContext[0] = 0;
- if (_data == NULL) {
+ if (_data == nullptr) {
ec = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
if (len <= 0) {
ec = U_ILLEGAL_ARGUMENT_ERROR;
uprv_free(_data);
- return NULL;
+ return nullptr;
}
data = _data;
@@ -419,24 +419,24 @@ LocDataParser::parse(UChar* _data, int32_t len) {
StringLocalizationInfo*
-LocDataParser::doParse(void) {
+LocDataParser::doParse() {
skipWhitespace();
if (!checkInc(OPEN_ANGLE)) {
ERROR("Missing open angle");
} else {
VArray array(DeleteFn);
- UBool mightHaveNext = TRUE;
+ UBool mightHaveNext = true;
int32_t requiredLength = -1;
while (mightHaveNext) {
- mightHaveNext = FALSE;
- UChar** elem = nextArray(requiredLength);
+ mightHaveNext = false;
+ char16_t** elem = nextArray(requiredLength);
skipWhitespace();
UBool haveComma = check(COMMA);
if (elem) {
array.add(elem, ec);
if (haveComma) {
inc();
- mightHaveNext = TRUE;
+ mightHaveNext = true;
}
} else if (haveComma) {
ERROR("Unexpected character");
@@ -457,22 +457,22 @@ LocDataParser::doParse(void) {
ERROR("Extra text after close of localization data");
}
- array.add(NULL, ec);
+ array.add(nullptr, ec);
if (U_SUCCESS(ec)) {
- int32_t numLocs = array.length() - 2; // subtract first, NULL
- UChar*** result = (UChar***)array.release();
+ int32_t numLocs = array.length() - 2; // subtract first, nullptr
+ char16_t*** result = (char16_t***)array.release();
- return new StringLocalizationInfo(data, result, requiredLength-2, numLocs); // subtract first, NULL
+ return new StringLocalizationInfo(data, result, requiredLength-2, numLocs); // subtract first, nullptr
}
}
ERROR("Unknown error");
}
-UChar**
+char16_t**
LocDataParser::nextArray(int32_t& requiredLength) {
if (U_FAILURE(ec)) {
- return NULL;
+ return nullptr;
}
skipWhitespace();
@@ -481,17 +481,17 @@ LocDataParser::nextArray(int32_t& requiredLength) {
}
VArray array;
- UBool mightHaveNext = TRUE;
+ UBool mightHaveNext = true;
while (mightHaveNext) {
- mightHaveNext = FALSE;
- UChar* elem = nextString();
+ mightHaveNext = false;
+ char16_t* elem = nextString();
skipWhitespace();
UBool haveComma = check(COMMA);
if (elem) {
array.add(elem, ec);
if (haveComma) {
inc();
- mightHaveNext = TRUE;
+ mightHaveNext = true;
}
} else if (haveComma) {
ERROR("Unexpected comma");
@@ -506,7 +506,7 @@ LocDataParser::nextArray(int32_t& requiredLength) {
}
}
- array.add(NULL, ec);
+ array.add(nullptr, ec);
if (U_SUCCESS(ec)) {
if (requiredLength == -1) {
requiredLength = array.length() + 1;
@@ -515,19 +515,19 @@ LocDataParser::nextArray(int32_t& requiredLength) {
ERROR("Array not of required length");
}
- return (UChar**)array.release();
+ return (char16_t**)array.release();
}
ERROR("Unknown Error");
}
-UChar*
+char16_t*
LocDataParser::nextString() {
- UChar* result = NULL;
+ char16_t* result = nullptr;
skipWhitespace();
if (p < e) {
- const UChar* terminators;
- UChar c = *p;
+ const char16_t* terminators;
+ char16_t c = *p;
UBool haveQuote = c == QUOTE || c == TICK;
if (haveQuote) {
inc();
@@ -535,13 +535,13 @@ LocDataParser::nextString() {
} else {
terminators = NOQUOTE_STOPLIST;
}
- UChar* start = p;
+ char16_t* start = p;
while (p < e && !inList(*p, terminators)) ++p;
if (p == e) {
ERROR("Unexpected end of data");
}
- UChar x = *p;
+ char16_t x = *p;
if (p > start) {
ch = x;
*p = 0x0; // terminate by writing to data
@@ -569,17 +569,17 @@ void LocDataParser::parseError(const char* EXPLANATION_ARG)
return;
}
- const UChar* start = p - U_PARSE_CONTEXT_LEN - 1;
+ const char16_t* start = p - U_PARSE_CONTEXT_LEN - 1;
if (start < data) {
start = data;
}
- for (UChar* x = p; --x >= start;) {
+ for (char16_t* x = p; --x >= start;) {
if (!*x) {
start = x+1;
break;
}
}
- const UChar* limit = p + U_PARSE_CONTEXT_LEN - 1;
+ const char16_t* limit = p + U_PARSE_CONTEXT_LEN - 1;
if (limit > e) {
limit = e;
}
@@ -594,7 +594,7 @@ void LocDataParser::parseError(const char* EXPLANATION_ARG)
UnicodeString msg;
msg.append(start, p - start);
- msg.append((UChar)0x002f); /* SOLIDUS/SLASH */
+ msg.append((char16_t)0x002f); /* SOLIDUS/SLASH */
msg.append(p, limit-p);
msg.append(UNICODE_STRING_SIMPLE("'"));
@@ -610,9 +610,9 @@ void LocDataParser::parseError(const char* EXPLANATION_ARG)
#endif
uprv_free(data);
- data = NULL;
- p = NULL;
- e = NULL;
+ data = nullptr;
+ p = nullptr;
+ e = nullptr;
if (U_SUCCESS(ec)) {
ec = U_PARSE_ERROR;
@@ -624,18 +624,18 @@ void LocDataParser::parseError(const char* EXPLANATION_ARG)
StringLocalizationInfo*
StringLocalizationInfo::create(const UnicodeString& info, UParseError& perror, UErrorCode& status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
int32_t len = info.length();
if (len == 0) {
- return NULL; // no error;
+ return nullptr; // no error;
}
- UChar* p = (UChar*)uprv_malloc(len * sizeof(UChar));
+ char16_t* p = (char16_t*)uprv_malloc(len * sizeof(char16_t));
if (!p) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
info.extract(p, len, status);
if (!U_FAILURE(status)) {
@@ -647,7 +647,7 @@ StringLocalizationInfo::create(const UnicodeString& info, UParseError& perror, U
}
StringLocalizationInfo::~StringLocalizationInfo() {
- for (UChar*** p = (UChar***)data; *p; ++p) {
+ for (char16_t*** p = (char16_t***)data; *p; ++p) {
// remaining data is simply pointer into our unicode string data.
if (*p) uprv_free(*p);
}
@@ -656,29 +656,29 @@ StringLocalizationInfo::~StringLocalizationInfo() {
}
-const UChar*
+const char16_t*
StringLocalizationInfo::getRuleSetName(int32_t index) const {
if (index >= 0 && index < getNumberOfRuleSets()) {
return data[0][index];
}
- return NULL;
+ return nullptr;
}
-const UChar*
+const char16_t*
StringLocalizationInfo::getLocaleName(int32_t index) const {
if (index >= 0 && index < getNumberOfDisplayLocales()) {
return data[index+1][0];
}
- return NULL;
+ return nullptr;
}
-const UChar*
+const char16_t*
StringLocalizationInfo::getDisplayName(int32_t localeIndex, int32_t ruleIndex) const {
if (localeIndex >= 0 && localeIndex < getNumberOfDisplayLocales() &&
ruleIndex >= 0 && ruleIndex < getNumberOfRuleSets()) {
return data[localeIndex+1][ruleIndex+1];
}
- return NULL;
+ return nullptr;
}
// ----------
@@ -686,23 +686,23 @@ StringLocalizationInfo::getDisplayName(int32_t localeIndex, int32_t ruleIndex) c
RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description,
const UnicodeString& locs,
const Locale& alocale, UParseError& perror, UErrorCode& status)
- : fRuleSets(NULL)
- , ruleSetDescriptions(NULL)
+ : fRuleSets(nullptr)
+ , ruleSetDescriptions(nullptr)
, numRuleSets(0)
- , defaultRuleSet(NULL)
+ , defaultRuleSet(nullptr)
, locale(alocale)
- , collator(NULL)
- , decimalFormatSymbols(NULL)
- , defaultInfinityRule(NULL)
- , defaultNaNRule(NULL)
+ , collator(nullptr)
+ , decimalFormatSymbols(nullptr)
+ , defaultInfinityRule(nullptr)
+ , defaultNaNRule(nullptr)
, fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
- , lenient(FALSE)
- , lenientParseRules(NULL)
- , localizations(NULL)
- , capitalizationInfoSet(FALSE)
- , capitalizationForUIListMenu(FALSE)
- , capitalizationForStandAlone(FALSE)
- , capitalizationBrkIter(NULL)
+ , lenient(false)
+ , lenientParseRules(nullptr)
+ , localizations(nullptr)
+ , capitalizationInfoSet(false)
+ , capitalizationForUIListMenu(false)
+ , capitalizationForStandAlone(false)
+ , capitalizationBrkIter(nullptr)
{
LocalizationInfo* locinfo = StringLocalizationInfo::create(locs, perror, status);
init(description, locinfo, perror, status);
@@ -711,23 +711,23 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description,
RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description,
const UnicodeString& locs,
UParseError& perror, UErrorCode& status)
- : fRuleSets(NULL)
- , ruleSetDescriptions(NULL)
+ : fRuleSets(nullptr)
+ , ruleSetDescriptions(nullptr)
, numRuleSets(0)
- , defaultRuleSet(NULL)
+ , defaultRuleSet(nullptr)
, locale(Locale::getDefault())
- , collator(NULL)
- , decimalFormatSymbols(NULL)
- , defaultInfinityRule(NULL)
- , defaultNaNRule(NULL)
+ , collator(nullptr)
+ , decimalFormatSymbols(nullptr)
+ , defaultInfinityRule(nullptr)
+ , defaultNaNRule(nullptr)
, fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
- , lenient(FALSE)
- , lenientParseRules(NULL)
- , localizations(NULL)
- , capitalizationInfoSet(FALSE)
- , capitalizationForUIListMenu(FALSE)
- , capitalizationForStandAlone(FALSE)
- , capitalizationBrkIter(NULL)
+ , lenient(false)
+ , lenientParseRules(nullptr)
+ , localizations(nullptr)
+ , capitalizationInfoSet(false)
+ , capitalizationForUIListMenu(false)
+ , capitalizationForStandAlone(false)
+ , capitalizationBrkIter(nullptr)
{
LocalizationInfo* locinfo = StringLocalizationInfo::create(locs, perror, status);
init(description, locinfo, perror, status);
@@ -736,23 +736,23 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description,
RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description,
LocalizationInfo* info,
const Locale& alocale, UParseError& perror, UErrorCode& status)
- : fRuleSets(NULL)
- , ruleSetDescriptions(NULL)
+ : fRuleSets(nullptr)
+ , ruleSetDescriptions(nullptr)
, numRuleSets(0)
- , defaultRuleSet(NULL)
+ , defaultRuleSet(nullptr)
, locale(alocale)
- , collator(NULL)
- , decimalFormatSymbols(NULL)
- , defaultInfinityRule(NULL)
- , defaultNaNRule(NULL)
+ , collator(nullptr)
+ , decimalFormatSymbols(nullptr)
+ , defaultInfinityRule(nullptr)
+ , defaultNaNRule(nullptr)
, fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
- , lenient(FALSE)
- , lenientParseRules(NULL)
- , localizations(NULL)
- , capitalizationInfoSet(FALSE)
- , capitalizationForUIListMenu(FALSE)
- , capitalizationForStandAlone(FALSE)
- , capitalizationBrkIter(NULL)
+ , lenient(false)
+ , lenientParseRules(nullptr)
+ , localizations(nullptr)
+ , capitalizationInfoSet(false)
+ , capitalizationForUIListMenu(false)
+ , capitalizationForStandAlone(false)
+ , capitalizationBrkIter(nullptr)
{
init(description, info, perror, status);
}
@@ -760,70 +760,70 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description,
RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description,
UParseError& perror,
UErrorCode& status)
- : fRuleSets(NULL)
- , ruleSetDescriptions(NULL)
+ : fRuleSets(nullptr)
+ , ruleSetDescriptions(nullptr)
, numRuleSets(0)
- , defaultRuleSet(NULL)
+ , defaultRuleSet(nullptr)
, locale(Locale::getDefault())
- , collator(NULL)
- , decimalFormatSymbols(NULL)
- , defaultInfinityRule(NULL)
- , defaultNaNRule(NULL)
+ , collator(nullptr)
+ , decimalFormatSymbols(nullptr)
+ , defaultInfinityRule(nullptr)
+ , defaultNaNRule(nullptr)
, fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
- , lenient(FALSE)
- , lenientParseRules(NULL)
- , localizations(NULL)
- , capitalizationInfoSet(FALSE)
- , capitalizationForUIListMenu(FALSE)
- , capitalizationForStandAlone(FALSE)
- , capitalizationBrkIter(NULL)
+ , lenient(false)
+ , lenientParseRules(nullptr)
+ , localizations(nullptr)
+ , capitalizationInfoSet(false)
+ , capitalizationForUIListMenu(false)
+ , capitalizationForStandAlone(false)
+ , capitalizationBrkIter(nullptr)
{
- init(description, NULL, perror, status);
+ init(description, nullptr, perror, status);
}
RuleBasedNumberFormat::RuleBasedNumberFormat(const UnicodeString& description,
const Locale& aLocale,
UParseError& perror,
UErrorCode& status)
- : fRuleSets(NULL)
- , ruleSetDescriptions(NULL)
+ : fRuleSets(nullptr)
+ , ruleSetDescriptions(nullptr)
, numRuleSets(0)
- , defaultRuleSet(NULL)
+ , defaultRuleSet(nullptr)
, locale(aLocale)
- , collator(NULL)
- , decimalFormatSymbols(NULL)
- , defaultInfinityRule(NULL)
- , defaultNaNRule(NULL)
+ , collator(nullptr)
+ , decimalFormatSymbols(nullptr)
+ , defaultInfinityRule(nullptr)
+ , defaultNaNRule(nullptr)
, fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
- , lenient(FALSE)
- , lenientParseRules(NULL)
- , localizations(NULL)
- , capitalizationInfoSet(FALSE)
- , capitalizationForUIListMenu(FALSE)
- , capitalizationForStandAlone(FALSE)
- , capitalizationBrkIter(NULL)
+ , lenient(false)
+ , lenientParseRules(nullptr)
+ , localizations(nullptr)
+ , capitalizationInfoSet(false)
+ , capitalizationForUIListMenu(false)
+ , capitalizationForStandAlone(false)
+ , capitalizationBrkIter(nullptr)
{
- init(description, NULL, perror, status);
+ init(description, nullptr, perror, status);
}
RuleBasedNumberFormat::RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale& alocale, UErrorCode& status)
- : fRuleSets(NULL)
- , ruleSetDescriptions(NULL)
+ : fRuleSets(nullptr)
+ , ruleSetDescriptions(nullptr)
, numRuleSets(0)
- , defaultRuleSet(NULL)
+ , defaultRuleSet(nullptr)
, locale(alocale)
- , collator(NULL)
- , decimalFormatSymbols(NULL)
- , defaultInfinityRule(NULL)
- , defaultNaNRule(NULL)
+ , collator(nullptr)
+ , decimalFormatSymbols(nullptr)
+ , defaultInfinityRule(nullptr)
+ , defaultNaNRule(nullptr)
, fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
- , lenient(FALSE)
- , lenientParseRules(NULL)
- , localizations(NULL)
- , capitalizationInfoSet(FALSE)
- , capitalizationForUIListMenu(FALSE)
- , capitalizationForStandAlone(FALSE)
- , capitalizationBrkIter(NULL)
+ , lenient(false)
+ , lenientParseRules(nullptr)
+ , localizations(nullptr)
+ , capitalizationInfoSet(false)
+ , capitalizationForUIListMenu(false)
+ , capitalizationForStandAlone(false)
+ , capitalizationBrkIter(nullptr)
{
if (U_FAILURE(status)) {
return;
@@ -840,18 +840,18 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale&
}
// TODO: read localization info from resource
- LocalizationInfo* locinfo = NULL;
+ LocalizationInfo* locinfo = nullptr;
UResourceBundle* nfrb = ures_open(U_ICUDATA_RBNF, locale.getName(), &status);
if (U_SUCCESS(status)) {
setLocaleIDs(ures_getLocaleByType(nfrb, ULOC_VALID_LOCALE, &status),
ures_getLocaleByType(nfrb, ULOC_ACTUAL_LOCALE, &status));
- UResourceBundle* rbnfRules = ures_getByKeyWithFallback(nfrb, rules_tag, NULL, &status);
+ UResourceBundle* rbnfRules = ures_getByKeyWithFallback(nfrb, rules_tag, nullptr, &status);
if (U_FAILURE(status)) {
ures_close(nfrb);
}
- UResourceBundle* ruleSets = ures_getByKeyWithFallback(rbnfRules, fmt_tag, NULL, &status);
+ UResourceBundle* ruleSets = ures_getByKeyWithFallback(rbnfRules, fmt_tag, nullptr, &status);
if (U_FAILURE(status)) {
ures_close(rbnfRules);
ures_close(nfrb);
@@ -860,7 +860,7 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale&
UnicodeString desc;
while (ures_hasNext(ruleSets)) {
- desc.append(ures_getNextUnicodeString(ruleSets,NULL,&status));
+ desc.append(ures_getNextUnicodeString(ruleSets,nullptr,&status));
}
UParseError perror;
@@ -874,23 +874,23 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale&
RuleBasedNumberFormat::RuleBasedNumberFormat(const RuleBasedNumberFormat& rhs)
: NumberFormat(rhs)
- , fRuleSets(NULL)
- , ruleSetDescriptions(NULL)
+ , fRuleSets(nullptr)
+ , ruleSetDescriptions(nullptr)
, numRuleSets(0)
- , defaultRuleSet(NULL)
+ , defaultRuleSet(nullptr)
, locale(rhs.locale)
- , collator(NULL)
- , decimalFormatSymbols(NULL)
- , defaultInfinityRule(NULL)
- , defaultNaNRule(NULL)
+ , collator(nullptr)
+ , decimalFormatSymbols(nullptr)
+ , defaultInfinityRule(nullptr)
+ , defaultNaNRule(nullptr)
, fRoundingMode(DecimalFormat::ERoundingMode::kRoundUnnecessary)
- , lenient(FALSE)
- , lenientParseRules(NULL)
- , localizations(NULL)
- , capitalizationInfoSet(FALSE)
- , capitalizationForUIListMenu(FALSE)
- , capitalizationForStandAlone(FALSE)
- , capitalizationBrkIter(NULL)
+ , lenient(false)
+ , lenientParseRules(nullptr)
+ , localizations(nullptr)
+ , capitalizationInfoSet(false)
+ , capitalizationForUIListMenu(false)
+ , capitalizationForStandAlone(false)
+ , capitalizationBrkIter(nullptr)
{
this->operator=(rhs);
}
@@ -911,7 +911,7 @@ RuleBasedNumberFormat::operator=(const RuleBasedNumberFormat& rhs)
UParseError perror;
setDecimalFormatSymbols(*rhs.getDecimalFormatSymbols());
- init(rhs.originalDescription, rhs.localizations ? rhs.localizations->ref() : NULL, perror, status);
+ init(rhs.originalDescription, rhs.localizations ? rhs.localizations->ref() : nullptr, perror, status);
setDefaultRuleSet(rhs.getDefaultRuleSetName(), status);
setRoundingMode(rhs.getRoundingMode());
@@ -919,7 +919,7 @@ RuleBasedNumberFormat::operator=(const RuleBasedNumberFormat& rhs)
capitalizationForUIListMenu = rhs.capitalizationForUIListMenu;
capitalizationForStandAlone = rhs.capitalizationForStandAlone;
#if !UCONFIG_NO_BREAK_ITERATION
- capitalizationBrkIter = (rhs.capitalizationBrkIter!=NULL)? rhs.capitalizationBrkIter->clone(): NULL;
+ capitalizationBrkIter = (rhs.capitalizationBrkIter!=nullptr)? rhs.capitalizationBrkIter->clone(): nullptr;
#endif
return *this;
@@ -944,30 +944,30 @@ RuleBasedNumberFormat::operator==(const Format& other) const
}
if (typeid(*this) == typeid(other)) {
- const RuleBasedNumberFormat& rhs = (const RuleBasedNumberFormat&)other;
+ const RuleBasedNumberFormat& rhs = static_cast<const RuleBasedNumberFormat&>(other);
// test for capitalization info equality is adequately handled
// by the NumberFormat test for fCapitalizationContext equality;
// the info here is just derived from that.
if (locale == rhs.locale &&
lenient == rhs.lenient &&
- (localizations == NULL
- ? rhs.localizations == NULL
- : (rhs.localizations == NULL
+ (localizations == nullptr
+ ? rhs.localizations == nullptr
+ : (rhs.localizations == nullptr
? false
: *localizations == rhs.localizations))) {
NFRuleSet** p = fRuleSets;
NFRuleSet** q = rhs.fRuleSets;
- if (p == NULL) {
- return q == NULL;
- } else if (q == NULL) {
+ if (p == nullptr) {
+ return q == nullptr;
+ } else if (q == nullptr) {
return false;
}
while (*p && *q && (**p == **q)) {
++p;
++q;
}
- return *q == NULL && *p == NULL;
+ return *q == nullptr && *p == nullptr;
}
}
@@ -978,7 +978,7 @@ UnicodeString
RuleBasedNumberFormat::getRules() const
{
UnicodeString result;
- if (fRuleSets != NULL) {
+ if (fRuleSets != nullptr) {
for (NFRuleSet** p = fRuleSets; *p; ++p) {
(*p)->appendRules(result);
}
@@ -990,7 +990,7 @@ UnicodeString
RuleBasedNumberFormat::getRuleSetName(int32_t index) const
{
if (localizations) {
- UnicodeString string(TRUE, localizations->getRuleSetName(index), (int32_t)-1);
+ UnicodeString string(true, localizations->getRuleSetName(index), (int32_t)-1);
return string;
}
else if (fRuleSets) {
@@ -1027,7 +1027,7 @@ RuleBasedNumberFormat::getNumberOfRuleSetNames() const
}
int32_t
-RuleBasedNumberFormat::getNumberOfRuleSetDisplayNameLocales(void) const {
+RuleBasedNumberFormat::getNumberOfRuleSetDisplayNameLocales() const {
if (localizations) {
return localizations->getNumberOfDisplayLocales();
}
@@ -1040,13 +1040,13 @@ RuleBasedNumberFormat::getRuleSetDisplayNameLocale(int32_t index, UErrorCode& st
return Locale("");
}
if (localizations && index >= 0 && index < localizations->getNumberOfDisplayLocales()) {
- UnicodeString name(TRUE, localizations->getLocaleName(index), -1);
+ UnicodeString name(true, localizations->getLocaleName(index), -1);
char buffer[64];
int32_t cap = name.length() + 1;
char* bp = buffer;
if (cap > 64) {
bp = (char *)uprv_malloc(cap);
- if (bp == NULL) {
+ if (bp == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return Locale("");
}
@@ -1068,12 +1068,12 @@ RuleBasedNumberFormat::getRuleSetDisplayName(int32_t index, const Locale& locale
if (localizations && index >= 0 && index < localizations->getNumberOfRuleSets()) {
UnicodeString localeName(localeParam.getBaseName(), -1, UnicodeString::kInvariant);
int32_t len = localeName.length();
- UChar* localeStr = localeName.getBuffer(len + 1);
+ char16_t* localeStr = localeName.getBuffer(len + 1);
while (len >= 0) {
localeStr[len] = 0;
int32_t ix = localizations->indexForLocale(localeStr);
if (ix >= 0) {
- UnicodeString name(TRUE, localizations->getDisplayName(ix, index), -1);
+ UnicodeString name(true, localizations->getDisplayName(ix, index), -1);
return name;
}
@@ -1081,7 +1081,7 @@ RuleBasedNumberFormat::getRuleSetDisplayName(int32_t index, const Locale& locale
do { --len;} while (len > 0 && localeStr[len] != 0x005f); // underscore
while (len > 0 && localeStr[len-1] == 0x005F) --len;
}
- UnicodeString name(TRUE, localizations->getRuleSetName(index), -1);
+ UnicodeString name(true, localizations->getRuleSetName(index), -1);
return name;
}
UnicodeString bogus;
@@ -1113,7 +1113,7 @@ RuleBasedNumberFormat::findRuleSet(const UnicodeString& name, UErrorCode& status
}
status = U_ILLEGAL_ARGUMENT_ERROR;
}
- return NULL;
+ return nullptr;
}
UnicodeString&
@@ -1326,7 +1326,7 @@ RuleBasedNumberFormat::adjustForCapitalizationContext(int32_t startPos,
if (capitalizationContext != UDISPCTX_CAPITALIZATION_NONE && startPos == 0 && currentResult.length() > 0) {
// capitalize currentResult according to context
UChar32 ch = currentResult.char32At(0);
- if (u_islower(ch) && U_SUCCESS(status) && capitalizationBrkIter != NULL &&
+ if (u_islower(ch) && U_SUCCESS(status) && capitalizationBrkIter != nullptr &&
( capitalizationContext == UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE ||
(capitalizationContext == UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU && capitalizationForUIListMenu) ||
(capitalizationContext == UDISPCTX_CAPITALIZATION_FOR_STANDALONE && capitalizationForStandAlone)) ) {
@@ -1402,7 +1402,7 @@ RuleBasedNumberFormat::setLenient(UBool enabled)
lenient = enabled;
if (!enabled && collator) {
delete collator;
- collator = NULL;
+ collator = nullptr;
}
}
@@ -1413,7 +1413,7 @@ RuleBasedNumberFormat::setDefaultRuleSet(const UnicodeString& ruleSetName, UErro
if (U_SUCCESS(status)) {
if (ruleSetName.isEmpty()) {
if (localizations) {
- UnicodeString name(TRUE, localizations->getRuleSetName(0), -1);
+ UnicodeString name(true, localizations->getRuleSetName(0), -1);
defaultRuleSet = findRuleSet(name, status);
} else {
initDefaultRuleSet();
@@ -1422,7 +1422,7 @@ RuleBasedNumberFormat::setDefaultRuleSet(const UnicodeString& ruleSetName, UErro
status = U_ILLEGAL_ARGUMENT_ERROR;
} else {
NFRuleSet* result = findRuleSet(ruleSetName, status);
- if (result != NULL) {
+ if (result != nullptr) {
defaultRuleSet = result;
}
}
@@ -1443,7 +1443,7 @@ RuleBasedNumberFormat::getDefaultRuleSetName() const {
void
RuleBasedNumberFormat::initDefaultRuleSet()
{
- defaultRuleSet = NULL;
+ defaultRuleSet = nullptr;
if (!fRuleSets) {
return;
}
@@ -1480,7 +1480,7 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali
{
// TODO: implement UParseError
uprv_memset(&pErr, 0, sizeof(UParseError));
- // Note: this can leave ruleSets == NULL, so remaining code should check
+ // Note: this can leave ruleSets == nullptr, so remaining code should check
if (U_FAILURE(status)) {
return;
}
@@ -1492,7 +1492,7 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali
return;
}
- this->localizations = localizationInfos == NULL ? NULL : localizationInfos->ref();
+ this->localizations = localizationInfos == nullptr ? nullptr : localizationInfos->ref();
UnicodeString description(rules);
if (!description.length()) {
@@ -1533,7 +1533,7 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali
// copy out the lenient-parse rules and delete them
// from the description
lenientParseRules = new UnicodeString();
- /* test for NULL */
+ /* test for nullptr */
if (lenientParseRules == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -1556,14 +1556,14 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali
// our rule list is an array of the appropriate size
fRuleSets = (NFRuleSet **)uprv_malloc((numRuleSets + 1) * sizeof(NFRuleSet *));
- /* test for NULL */
+ /* test for nullptr */
if (fRuleSets == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
for (int i = 0; i <= numRuleSets; ++i) {
- fRuleSets[i] = NULL;
+ fRuleSets[i] = nullptr;
}
// divide up the descriptions into individual rule-set descriptions
@@ -1636,9 +1636,9 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, LocalizationInfo* locali
// confirm the names, if any aren't in the rules, that's an error
// it is ok if the rules contain public rule sets that are not in this list
for (int32_t i = 0; i < localizationInfos->getNumberOfRuleSets(); ++i) {
- UnicodeString name(TRUE, localizationInfos->getRuleSetName(i), -1);
+ UnicodeString name(true, localizationInfos->getRuleSetName(i), -1);
NFRuleSet* rs = findRuleSet(name, status);
- if (rs == NULL) {
+ if (rs == nullptr) {
break; // error
}
if (i == 0) {
@@ -1661,17 +1661,17 @@ RuleBasedNumberFormat::setContext(UDisplayContext value, UErrorCode& status)
if (!capitalizationInfoSet &&
(value==UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU || value==UDISPCTX_CAPITALIZATION_FOR_STANDALONE)) {
initCapitalizationContextInfo(locale);
- capitalizationInfoSet = TRUE;
+ capitalizationInfoSet = true;
}
#if !UCONFIG_NO_BREAK_ITERATION
- if ( capitalizationBrkIter == NULL && (value==UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE ||
+ if ( capitalizationBrkIter == nullptr && (value==UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE ||
(value==UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU && capitalizationForUIListMenu) ||
(value==UDISPCTX_CAPITALIZATION_FOR_STANDALONE && capitalizationForStandAlone)) ) {
status = U_ZERO_ERROR;
capitalizationBrkIter = BreakIterator::createSentenceInstance(locale, status);
if (U_FAILURE(status)) {
delete capitalizationBrkIter;
- capitalizationBrkIter = NULL;
+ capitalizationBrkIter = nullptr;
}
}
#endif
@@ -1682,15 +1682,15 @@ void
RuleBasedNumberFormat::initCapitalizationContextInfo(const Locale& thelocale)
{
#if !UCONFIG_NO_BREAK_ITERATION
- const char * localeID = (thelocale != NULL)? thelocale.getBaseName(): NULL;
+ const char * localeID = (thelocale != nullptr)? thelocale.getBaseName(): nullptr;
UErrorCode status = U_ZERO_ERROR;
- UResourceBundle *rb = ures_open(NULL, localeID, &status);
+ UResourceBundle *rb = ures_open(nullptr, localeID, &status);
rb = ures_getByKeyWithFallback(rb, "contextTransforms", rb, &status);
rb = ures_getByKeyWithFallback(rb, "number-spellout", rb, &status);
- if (U_SUCCESS(status) && rb != NULL) {
+ if (U_SUCCESS(status) && rb != nullptr) {
int32_t len = 0;
const int32_t * intVector = ures_getIntVector(rb, &len, &status);
- if (U_SUCCESS(status) && intVector != NULL && len >= 2) {
+ if (U_SUCCESS(status) && intVector != nullptr && len >= 2) {
capitalizationForUIListMenu = static_cast<UBool>(intVector[0]);
capitalizationForStandAlone = static_cast<UBool>(intVector[1]);
}
@@ -1748,34 +1748,34 @@ RuleBasedNumberFormat::dispose()
delete *p;
}
uprv_free(fRuleSets);
- fRuleSets = NULL;
+ fRuleSets = nullptr;
}
if (ruleSetDescriptions) {
delete [] ruleSetDescriptions;
- ruleSetDescriptions = NULL;
+ ruleSetDescriptions = nullptr;
}
#if !UCONFIG_NO_COLLATION
delete collator;
#endif
- collator = NULL;
+ collator = nullptr;
delete decimalFormatSymbols;
- decimalFormatSymbols = NULL;
+ decimalFormatSymbols = nullptr;
delete defaultInfinityRule;
- defaultInfinityRule = NULL;
+ defaultInfinityRule = nullptr;
delete defaultNaNRule;
- defaultNaNRule = NULL;
+ defaultNaNRule = nullptr;
delete lenientParseRules;
- lenientParseRules = NULL;
+ lenientParseRules = nullptr;
#if !UCONFIG_NO_BREAK_ITERATION
delete capitalizationBrkIter;
- capitalizationBrkIter = NULL;
+ capitalizationBrkIter = nullptr;
#endif
if (localizations) {
@@ -1799,11 +1799,11 @@ RuleBasedNumberFormat::getCollator() const
{
#if !UCONFIG_NO_COLLATION
if (!fRuleSets) {
- return NULL;
+ return nullptr;
}
// lazy-evaluate the collator
- if (collator == NULL && lenient) {
+ if (collator == nullptr && lenient) {
// create a default collator based on the formatter's locale,
// then pull out that collator's rules, append any additional
// rules specified in the description, and create a _new_
@@ -1813,18 +1813,18 @@ RuleBasedNumberFormat::getCollator() const
Collator* temp = Collator::createInstance(locale, status);
RuleBasedCollator* newCollator;
- if (U_SUCCESS(status) && (newCollator = dynamic_cast<RuleBasedCollator*>(temp)) != NULL) {
+ if (U_SUCCESS(status) && (newCollator = dynamic_cast<RuleBasedCollator*>(temp)) != nullptr) {
if (lenientParseRules) {
UnicodeString rules(newCollator->getRules());
rules.append(*lenientParseRules);
newCollator = new RuleBasedCollator(rules, status);
// Exit if newCollator could not be created.
- if (newCollator == NULL) {
- return NULL;
+ if (newCollator == nullptr) {
+ return nullptr;
}
} else {
- temp = NULL;
+ temp = nullptr;
}
if (U_SUCCESS(status)) {
newCollator->setAttribute(UCOL_DECOMPOSITION_MODE, UCOL_ON, status);
@@ -1875,7 +1875,7 @@ RuleBasedNumberFormat::initializeDefaultInfinityRule(UErrorCode &status)
if (U_FAILURE(status)) {
return nullptr;
}
- if (defaultInfinityRule == NULL) {
+ if (defaultInfinityRule == nullptr) {
UnicodeString rule(UNICODE_STRING_SIMPLE("Inf: "));
rule.append(getDecimalFormatSymbols()->getSymbol(DecimalFormatSymbols::kInfinitySymbol));
LocalPointer<NFRule> temp(new NFRule(this, rule, status), status);
@@ -1919,11 +1919,11 @@ RuleBasedNumberFormat::getDefaultNaNRule() const
void
RuleBasedNumberFormat::adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt)
{
- if (symbolsToAdopt == NULL) {
- return; // do not allow caller to set decimalFormatSymbols to NULL
+ if (symbolsToAdopt == nullptr) {
+ return; // do not allow caller to set decimalFormatSymbols to nullptr
}
- if (decimalFormatSymbols != NULL) {
+ if (decimalFormatSymbols != nullptr) {
delete decimalFormatSymbols;
}
@@ -1934,11 +1934,11 @@ RuleBasedNumberFormat::adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsTo
UErrorCode status = U_ZERO_ERROR;
delete defaultInfinityRule;
- defaultInfinityRule = NULL;
+ defaultInfinityRule = nullptr;
initializeDefaultInfinityRule(status); // Reset with the new DecimalFormatSymbols
delete defaultNaNRule;
- defaultNaNRule = NULL;
+ defaultNaNRule = nullptr;
initializeDefaultNaNRule(status); // Reset with the new DecimalFormatSymbols
if (fRuleSets) {
diff --git a/contrib/libs/icu/i18n/rbt.cpp b/contrib/libs/icu/i18n/rbt.cpp
index 1de53e6071..2176e89fdd 100644
--- a/contrib/libs/icu/i18n/rbt.cpp
+++ b/contrib/libs/icu/i18n/rbt.cpp
@@ -27,14 +27,14 @@ U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RuleBasedTransliterator)
-static Replaceable *gLockedText = NULL;
+static Replaceable *gLockedText = nullptr;
void RuleBasedTransliterator::_construct(const UnicodeString& rules,
UTransDirection direction,
UParseError& parseError,
UErrorCode& status) {
fData = 0;
- isDataOwned = TRUE;
+ isDataOwned = true;
if (U_FAILURE(status)) {
return;
}
@@ -46,7 +46,7 @@ void RuleBasedTransliterator::_construct(const UnicodeString& rules,
}
if (parser.idBlockVector.size() != 0 ||
- parser.compoundFilter != NULL ||
+ parser.compoundFilter != nullptr ||
parser.dataVector.size() == 0) {
status = U_INVALID_RBT_SYNTAX; // ::ID blocks disallowed in RBT
return;
@@ -143,7 +143,7 @@ RuleBasedTransliterator::RuleBasedTransliterator(const UnicodeString& id,
UnicodeFilter* adoptedFilter) :
Transliterator(id, adoptedFilter),
fData((TransliterationRuleData*)theData), // cast away const
- isDataOwned(FALSE) {
+ isDataOwned(false) {
setMaximumContextLength(fData->ruleSet.getMaximumContextLength());
}
@@ -241,7 +241,7 @@ RuleBasedTransliterator::handleTransliterate(Replaceable& text, UTransPosition&
// Double-locking must be prevented in these cases.
//
- UBool lockedMutexAtThisLevel = FALSE;
+ UBool lockedMutexAtThisLevel = false;
// Test whether this request is operating on the same text string as
// some other transliteration that is still in progress and holding the
@@ -263,11 +263,11 @@ RuleBasedTransliterator::handleTransliterate(Replaceable& text, UTransPosition&
umtx_lock(&transliteratorDataMutex); // Contention, longish waits possible here.
Mutex m;
gLockedText = &text;
- lockedMutexAtThisLevel = TRUE;
+ lockedMutexAtThisLevel = true;
}
// Check to make sure we don't dereference a null pointer.
- if (fData != NULL) {
+ if (fData != nullptr) {
while (index.start < index.limit &&
loopCount <= loopLimit &&
fData->ruleSet.transliterate(text, index, isIncremental)) {
@@ -277,7 +277,7 @@ RuleBasedTransliterator::handleTransliterate(Replaceable& text, UTransPosition&
if (lockedMutexAtThisLevel) {
{
Mutex m;
- gLockedText = NULL;
+ gLockedText = nullptr;
}
umtx_unlock(&transliteratorDataMutex);
}
@@ -292,14 +292,14 @@ UnicodeString& RuleBasedTransliterator::toRules(UnicodeString& rulesSource,
* Implement Transliterator framework
*/
void RuleBasedTransliterator::handleGetSourceSet(UnicodeSet& result) const {
- fData->ruleSet.getSourceTargetSet(result, FALSE);
+ fData->ruleSet.getSourceTargetSet(result, false);
}
/**
* Override Transliterator framework
*/
UnicodeSet& RuleBasedTransliterator::getTargetSet(UnicodeSet& result) const {
- return fData->ruleSet.getSourceTargetSet(result, TRUE);
+ return fData->ruleSet.getSourceTargetSet(result, true);
}
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/rbt.h b/contrib/libs/icu/i18n/rbt.h
index 8a43c90d46..59fa286a45 100644
--- a/contrib/libs/icu/i18n/rbt.h
+++ b/contrib/libs/icu/i18n/rbt.h
@@ -193,7 +193,7 @@ public:
* @return The class ID for all objects of this class.
* @internal Use transliterator factory methods instead since this class will be removed in that release.
*/
- U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
+ U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
/**
* Returns a unique class ID <b>polymorphically</b>. This method
@@ -205,7 +205,7 @@ public:
* class have the same class ID. Objects of other classes have
* different class IDs.
*/
- virtual UClassID getDynamicClassID(void) const override;
+ virtual UClassID getDynamicClassID() const override;
private:
diff --git a/contrib/libs/icu/i18n/rbt_data.cpp b/contrib/libs/icu/i18n/rbt_data.cpp
index f3985fc768..f4212848cb 100644
--- a/contrib/libs/icu/i18n/rbt_data.cpp
+++ b/contrib/libs/icu/i18n/rbt_data.cpp
@@ -25,7 +25,7 @@ U_NAMESPACE_BEGIN
TransliterationRuleData::TransliterationRuleData(UErrorCode& status)
: UMemory(), ruleSet(status), variableNames(status),
- variables(0), variablesAreOwned(TRUE)
+ variables(0), variablesAreOwned(true)
{
if (U_FAILURE(status)) {
return;
@@ -37,7 +37,7 @@ TransliterationRuleData::TransliterationRuleData(UErrorCode& status)
TransliterationRuleData::TransliterationRuleData(const TransliterationRuleData& other) :
UMemory(other), ruleSet(other.ruleSet),
- variablesAreOwned(TRUE),
+ variablesAreOwned(true),
variablesBase(other.variablesBase),
variablesLength(other.variablesLength)
{
@@ -50,7 +50,7 @@ TransliterationRuleData::TransliterationRuleData(const TransliterationRuleData&
UnicodeString* value =
new UnicodeString(*(const UnicodeString*)e->value.pointer);
// Exit out if value could not be created.
- if (value == NULL) {
+ if (value == nullptr) {
return;
}
variableNames.put(*(UnicodeString*)e->key.pointer, value, status);
@@ -59,14 +59,14 @@ TransliterationRuleData::TransliterationRuleData(const TransliterationRuleData&
variables = 0;
if (other.variables != 0) {
variables = (UnicodeFunctor **)uprv_malloc(variablesLength * sizeof(UnicodeFunctor *));
- /* test for NULL */
+ /* test for nullptr */
if (variables == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
for (i=0; i<variablesLength; ++i) {
variables[i] = other.variables[i]->clone();
- if (variables[i] == NULL) {
+ if (variables[i] == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
}
@@ -78,7 +78,7 @@ TransliterationRuleData::TransliterationRuleData(const TransliterationRuleData&
delete variables[n];
}
uprv_free(variables);
- variables = NULL;
+ variables = nullptr;
return;
}
diff --git a/contrib/libs/icu/i18n/rbt_data.h b/contrib/libs/icu/i18n/rbt_data.h
index 52a961dde0..43cbb4795b 100644
--- a/contrib/libs/icu/i18n/rbt_data.h
+++ b/contrib/libs/icu/i18n/rbt_data.h
@@ -67,7 +67,7 @@ public:
Hashtable variableNames;
/**
- * Map category variable (UChar) to set (UnicodeFunctor).
+ * Map category variable (char16_t) to set (UnicodeFunctor).
* Variables that correspond to a set of characters are mapped
* from variable name to a stand-in character in data.variableNames.
* The stand-in then serves as a key in this hash to lookup the
@@ -91,7 +91,7 @@ public:
* variablesBase through variablesBase +
* variablesLength - 1 represent UnicodeFunctor objects.
*/
- UChar variablesBase;
+ char16_t variablesBase;
/**
* The length of variables.
@@ -118,7 +118,7 @@ public:
/**
* Given a stand-in character, return the UnicodeFunctor that it
- * represents, or NULL if it doesn't represent anything.
+ * represents, or nullptr if it doesn't represent anything.
* @param standIn the given stand-in character.
* @return the UnicodeFunctor that 'standIn' represents
*/
@@ -126,7 +126,7 @@ public:
/**
* Given a stand-in character, return the UnicodeMatcher that it
- * represents, or NULL if it doesn't represent anything or if it
+ * represents, or nullptr if it doesn't represent anything or if it
* represents something that is not a matcher.
* @param standIn the given stand-in character.
* @return return the UnicodeMatcher that 'standIn' represents
@@ -135,7 +135,7 @@ public:
/**
* Given a stand-in character, return the UnicodeReplacer that it
- * represents, or NULL if it doesn't represent anything or if it
+ * represents, or nullptr if it doesn't represent anything or if it
* represents something that is not a replacer.
* @param standIn the given stand-in character.
* @return return the UnicodeReplacer that 'standIn' represents
diff --git a/contrib/libs/icu/i18n/rbt_pars.cpp b/contrib/libs/icu/i18n/rbt_pars.cpp
index 2f207a8deb..10482d5edb 100644
--- a/contrib/libs/icu/i18n/rbt_pars.cpp
+++ b/contrib/libs/icu/i18n/rbt_pars.cpp
@@ -43,66 +43,66 @@
#include "putilimp.h"
// Operators
-#define VARIABLE_DEF_OP ((UChar)0x003D) /*=*/
-#define FORWARD_RULE_OP ((UChar)0x003E) /*>*/
-#define REVERSE_RULE_OP ((UChar)0x003C) /*<*/
-#define FWDREV_RULE_OP ((UChar)0x007E) /*~*/ // internal rep of <> op
+#define VARIABLE_DEF_OP ((char16_t)0x003D) /*=*/
+#define FORWARD_RULE_OP ((char16_t)0x003E) /*>*/
+#define REVERSE_RULE_OP ((char16_t)0x003C) /*<*/
+#define FWDREV_RULE_OP ((char16_t)0x007E) /*~*/ // internal rep of <> op
// Other special characters
-#define QUOTE ((UChar)0x0027) /*'*/
-#define ESCAPE ((UChar)0x005C) /*\*/
-#define END_OF_RULE ((UChar)0x003B) /*;*/
-#define RULE_COMMENT_CHAR ((UChar)0x0023) /*#*/
-
-#define SEGMENT_OPEN ((UChar)0x0028) /*(*/
-#define SEGMENT_CLOSE ((UChar)0x0029) /*)*/
-#define CONTEXT_ANTE ((UChar)0x007B) /*{*/
-#define CONTEXT_POST ((UChar)0x007D) /*}*/
-#define CURSOR_POS ((UChar)0x007C) /*|*/
-#define CURSOR_OFFSET ((UChar)0x0040) /*@*/
-#define ANCHOR_START ((UChar)0x005E) /*^*/
-#define KLEENE_STAR ((UChar)0x002A) /***/
-#define ONE_OR_MORE ((UChar)0x002B) /*+*/
-#define ZERO_OR_ONE ((UChar)0x003F) /*?*/
-
-#define DOT ((UChar)46) /*.*/
-
-static const UChar DOT_SET[] = { // "[^[:Zp:][:Zl:]\r\n$]";
+#define QUOTE ((char16_t)0x0027) /*'*/
+#define ESCAPE ((char16_t)0x005C) /*\*/
+#define END_OF_RULE ((char16_t)0x003B) /*;*/
+#define RULE_COMMENT_CHAR ((char16_t)0x0023) /*#*/
+
+#define SEGMENT_OPEN ((char16_t)0x0028) /*(*/
+#define SEGMENT_CLOSE ((char16_t)0x0029) /*)*/
+#define CONTEXT_ANTE ((char16_t)0x007B) /*{*/
+#define CONTEXT_POST ((char16_t)0x007D) /*}*/
+#define CURSOR_POS ((char16_t)0x007C) /*|*/
+#define CURSOR_OFFSET ((char16_t)0x0040) /*@*/
+#define ANCHOR_START ((char16_t)0x005E) /*^*/
+#define KLEENE_STAR ((char16_t)0x002A) /***/
+#define ONE_OR_MORE ((char16_t)0x002B) /*+*/
+#define ZERO_OR_ONE ((char16_t)0x003F) /*?*/
+
+#define DOT ((char16_t)46) /*.*/
+
+static const char16_t DOT_SET[] = { // "[^[:Zp:][:Zl:]\r\n$]";
91, 94, 91, 58, 90, 112, 58, 93, 91, 58, 90,
108, 58, 93, 92, 114, 92, 110, 36, 93, 0
};
// A function is denoted &Source-Target/Variant(text)
-#define FUNCTION ((UChar)38) /*&*/
+#define FUNCTION ((char16_t)38) /*&*/
// Aliases for some of the syntax characters. These are provided so
// transliteration rules can be expressed in XML without clashing with
// XML syntax characters '<', '>', and '&'.
-#define ALT_REVERSE_RULE_OP ((UChar)0x2190) // Left Arrow
-#define ALT_FORWARD_RULE_OP ((UChar)0x2192) // Right Arrow
-#define ALT_FWDREV_RULE_OP ((UChar)0x2194) // Left Right Arrow
-#define ALT_FUNCTION ((UChar)0x2206) // Increment (~Greek Capital Delta)
+#define ALT_REVERSE_RULE_OP ((char16_t)0x2190) // Left Arrow
+#define ALT_FORWARD_RULE_OP ((char16_t)0x2192) // Right Arrow
+#define ALT_FWDREV_RULE_OP ((char16_t)0x2194) // Left Right Arrow
+#define ALT_FUNCTION ((char16_t)0x2206) // Increment (~Greek Capital Delta)
// Special characters disallowed at the top level
-static const UChar ILLEGAL_TOP[] = {41,0}; // ")"
+static const char16_t ILLEGAL_TOP[] = {41,0}; // ")"
// Special characters disallowed within a segment
-static const UChar ILLEGAL_SEG[] = {123,125,124,64,0}; // "{}|@"
+static const char16_t ILLEGAL_SEG[] = {123,125,124,64,0}; // "{}|@"
// Special characters disallowed within a function argument
-static const UChar ILLEGAL_FUNC[] = {94,40,46,42,43,63,123,125,124,64,0}; // "^(.*+?{}|@"
+static const char16_t ILLEGAL_FUNC[] = {94,40,46,42,43,63,123,125,124,64,0}; // "^(.*+?{}|@"
// By definition, the ANCHOR_END special character is a
// trailing SymbolTable.SYMBOL_REF character.
// private static final char ANCHOR_END = '$';
-static const UChar gOPERATORS[] = { // "=><"
+static const char16_t gOPERATORS[] = { // "=><"
VARIABLE_DEF_OP, FORWARD_RULE_OP, REVERSE_RULE_OP,
ALT_FORWARD_RULE_OP, ALT_REVERSE_RULE_OP, ALT_FWDREV_RULE_OP,
0
};
-static const UChar HALF_ENDERS[] = { // "=><;"
+static const char16_t HALF_ENDERS[] = { // "=><;"
VARIABLE_DEF_OP, FORWARD_RULE_OP, REVERSE_RULE_OP,
ALT_FORWARD_RULE_OP, ALT_REVERSE_RULE_OP, ALT_FWDREV_RULE_OP,
END_OF_RULE,
@@ -111,15 +111,15 @@ static const UChar HALF_ENDERS[] = { // "=><;"
// These are also used in Transliterator::toRules()
static const int32_t ID_TOKEN_LEN = 2;
-static const UChar ID_TOKEN[] = { 0x3A, 0x3A }; // ':', ':'
+static const char16_t ID_TOKEN[] = { 0x3A, 0x3A }; // ':', ':'
/*
commented out until we do real ::BEGIN/::END functionality
static const int32_t BEGIN_TOKEN_LEN = 5;
-static const UChar BEGIN_TOKEN[] = { 0x42, 0x45, 0x47, 0x49, 0x4e }; // 'BEGIN'
+static const char16_t BEGIN_TOKEN[] = { 0x42, 0x45, 0x47, 0x49, 0x4e }; // 'BEGIN'
static const int32_t END_TOKEN_LEN = 3;
-static const UChar END_TOKEN[] = { 0x45, 0x4e, 0x44 }; // 'END'
+static const char16_t END_TOKEN[] = { 0x45, 0x4e, 0x44 }; // 'END'
*/
U_NAMESPACE_BEGIN
@@ -191,7 +191,7 @@ const UnicodeString* ParseData::lookup(const UnicodeString& name) const {
const UnicodeFunctor* ParseData::lookupMatcher(UChar32 ch) const {
// Note that we cannot use data.lookupSet() because the
// set array has not been constructed yet.
- const UnicodeFunctor* set = NULL;
+ const UnicodeFunctor* set = nullptr;
int32_t i = ch - data->variablesBase;
if (i >= 0 && i < variablesVector->size()) {
int32_t j = ch - data->variablesBase;
@@ -211,7 +211,7 @@ UnicodeString ParseData::parseReference(const UnicodeString& text,
int32_t i = start;
UnicodeString result;
while (i < limit) {
- UChar c = text.charAt(i);
+ char16_t c = text.charAt(i);
if ((i==start && !u_isIDStart(c)) || !u_isIDPart(c)) {
break;
}
@@ -231,9 +231,9 @@ UBool ParseData::isMatcher(UChar32 ch) {
int32_t i = ch - data->variablesBase;
if (i >= 0 && i < variablesVector->size()) {
UnicodeFunctor *f = (UnicodeFunctor*) variablesVector->elementAt(i);
- return f != NULL && f->toMatcher() != NULL;
+ return f != nullptr && f->toMatcher() != nullptr;
}
- return TRUE;
+ return true;
}
/**
@@ -246,9 +246,9 @@ UBool ParseData::isReplacer(UChar32 ch) {
int i = ch - data->variablesBase;
if (i >= 0 && i < variablesVector->size()) {
UnicodeFunctor *f = (UnicodeFunctor*) variablesVector->elementAt(i);
- return f != NULL && f->toReplacer() != NULL;
+ return f != nullptr && f->toReplacer() != nullptr;
}
- return TRUE;
+ return true;
}
//----------------------------------------------------------------------
@@ -348,7 +348,7 @@ RuleHalf::RuleHalf(TransliteratorParser& p) :
post = -1;
cursorOffset = 0;
cursorOffsetPos = 0;
- anchorStart = anchorEnd = FALSE;
+ anchorStart = anchorEnd = false;
nextSegmentNumber = 1;
}
@@ -364,7 +364,7 @@ RuleHalf::~RuleHalf() {
int32_t RuleHalf::parse(const UnicodeString& rule, int32_t pos, int32_t limit, UErrorCode& status) {
int32_t start = pos;
text.truncate(0);
- pos = parseSection(rule, pos, limit, text, UnicodeString(TRUE, ILLEGAL_TOP, -1), FALSE, status);
+ pos = parseSection(rule, pos, limit, text, UnicodeString(true, ILLEGAL_TOP, -1), false, status);
if (cursorOffset > 0 && cursor != cursorOffsetPos) {
return syntaxError(U_MISPLACED_CURSOR_OFFSET, rule, start, status);
@@ -403,7 +403,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l
int32_t start = pos;
ParsePosition pp;
UnicodeString scratch;
- UBool done = FALSE;
+ UBool done = false;
int32_t quoteStart = -1; // Most recent 'single quoted string'
int32_t quoteLimit = -1;
int32_t varStart = -1; // Most recent $variableReference
@@ -413,14 +413,14 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l
while (pos < limit && !done) {
// Since all syntax characters are in the BMP, fetching
// 16-bit code units suffices here.
- UChar c = rule.charAt(pos++);
+ char16_t c = rule.charAt(pos++);
if (PatternProps::isWhiteSpace(c)) {
// Ignore whitespace. Note that this is not Unicode
// spaces, but Java spaces -- a subset, representing
// whitespace likely to be seen in code.
continue;
}
- if (u_strchr(HALF_ENDERS, c) != NULL) {
+ if (u_strchr(HALF_ENDERS, c) != nullptr) {
if (isSegment) {
// Unclosed segment
return syntaxError(U_UNCLOSED_SEGMENT, rule, start, status);
@@ -511,7 +511,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l
//------------------------------------------------------
case ANCHOR_START:
if (buf.length() == 0 && !anchorStart) {
- anchorStart = TRUE;
+ anchorStart = true;
} else {
return syntaxError(U_MISPLACED_ANCHOR_START,
rule, start, status);
@@ -529,7 +529,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l
int32_t segmentNumber = nextSegmentNumber++; // 1-based
// Parse the segment
- pos = parseSection(rule, pos, limit, buf, UnicodeString(TRUE, ILLEGAL_SEG, -1), TRUE, status);
+ pos = parseSection(rule, pos, limit, buf, UnicodeString(true, ILLEGAL_SEG, -1), true, status);
// After parsing a segment, the relevant characters are
// in buf, starting at offset bufSegStart. Extract them
@@ -538,7 +538,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l
StringMatcher* m =
new StringMatcher(buf, bufSegStart, buf.length(),
segmentNumber, *parser.curData);
- if (m == NULL) {
+ if (m == nullptr) {
return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
}
@@ -555,14 +555,14 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l
TransliteratorIDParser::SingleID* single =
TransliteratorIDParser::parseFilterID(rule, iref);
// The next character MUST be a segment open
- if (single == NULL ||
+ if (single == nullptr ||
!ICU_Utility::parseChar(rule, iref, SEGMENT_OPEN)) {
return syntaxError(U_INVALID_FUNCTION, rule, start, status);
}
Transliterator *t = single->createInstance();
delete single;
- if (t == NULL) {
+ if (t == nullptr) {
return syntaxError(U_INVALID_FUNCTION, rule, start, status);
}
@@ -571,7 +571,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l
int32_t bufSegStart = buf.length();
// Parse the segment
- pos = parseSection(rule, iref, limit, buf, UnicodeString(TRUE, ILLEGAL_FUNC, -1), TRUE, status);
+ pos = parseSection(rule, iref, limit, buf, UnicodeString(true, ILLEGAL_FUNC, -1), true, status);
// After parsing a segment, the relevant characters are
// in buf, starting at offset bufSegStart.
@@ -579,7 +579,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l
buf.extractBetween(bufSegStart, buf.length(), output);
FunctionReplacer *r =
new FunctionReplacer(t, new StringReplacer(output, parser.curData));
- if (r == NULL) {
+ if (r == nullptr) {
return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
}
@@ -598,7 +598,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l
if (pos == limit) {
// A variable ref character at the end acts as
// an anchor to the context limit, as in perl.
- anchorEnd = TRUE;
+ anchorEnd = true;
break;
}
// Parse "$1" "$2" .. "$9" .. (no upper limit)
@@ -621,7 +621,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l
// end anchor then. If this also doesn't work
// (if we see a following character) then signal
// an error.
- anchorEnd = TRUE;
+ anchorEnd = true;
break;
}
pos = pp.getIndex();
@@ -673,7 +673,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l
UnicodeFunctor *m =
new StringMatcher(buf, qstart, qlimit, 0, *parser.curData);
- if (m == NULL) {
+ if (m == nullptr) {
return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
}
int32_t min = 0;
@@ -690,7 +690,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l
// do nothing -- min, max already set
}
m = new Quantifier(m, min, max);
- if (m == NULL) {
+ if (m == nullptr) {
return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
}
buf.truncate(qstart);
@@ -704,7 +704,7 @@ int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t l
case SEGMENT_CLOSE:
// assert(isSegment);
// We're done parsing a segment.
- done = TRUE;
+ done = true;
break;
//------------------------------------------------------
@@ -786,7 +786,7 @@ void RuleHalf::removeContext() {
text.removeBetween(0, ante);
}
ante = post = -1;
- anchorStart = anchorEnd = FALSE;
+ anchorStart = anchorEnd = false;
}
/**
@@ -798,10 +798,10 @@ UBool RuleHalf::isValidOutput(TransliteratorParser& transParser) {
UChar32 c = text.char32At(i);
i += U16_LENGTH(c);
if (!transParser.parseData->isReplacer(c)) {
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
/**
@@ -813,10 +813,10 @@ UBool RuleHalf::isValidInput(TransliteratorParser& transParser) {
UChar32 c = text.char32At(i);
i += U16_LENGTH(c);
if (!transParser.parseData->isMatcher(c)) {
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
//----------------------------------------------------------------------
@@ -833,9 +833,9 @@ variablesVector(statusReturn),
segmentObjects(statusReturn)
{
idBlockVector.setDeleter(uprv_deleteUObject);
- curData = NULL;
- compoundFilter = NULL;
- parseData = NULL;
+ curData = nullptr;
+ compoundFilter = nullptr;
+ parseData = nullptr;
variableNames.setValueDeleter(uprv_deleteUObject);
}
@@ -867,7 +867,7 @@ TransliteratorParser::parse(const UnicodeString& rules,
*/
UnicodeSet* TransliteratorParser::orphanCompoundFilter() {
UnicodeSet* f = compoundFilter;
- compoundFilter = NULL;
+ compoundFilter = nullptr;
return f;
}
@@ -891,7 +891,7 @@ void TransliteratorParser::parseRules(const UnicodeString& rule,
uprv_memset(&parseError, 0, sizeof(parseError));
parseError.line = parseError.offset = -1;
- UBool parsingIDs = TRUE;
+ UBool parsingIDs = true;
int32_t ruleCount = 0;
while (!dataVector.isEmpty()) {
@@ -902,26 +902,26 @@ void TransliteratorParser::parseRules(const UnicodeString& rule,
}
idBlockVector.removeAllElements();
- curData = NULL;
+ curData = nullptr;
direction = theDirection;
ruleCount = 0;
delete compoundFilter;
- compoundFilter = NULL;
+ compoundFilter = nullptr;
while (!variablesVector.isEmpty()) {
delete (UnicodeFunctor*)variablesVector.orphanElementAt(0);
}
variableNames.removeAll();
parseData = new ParseData(0, &variablesVector, &variableNames);
- if (parseData == NULL) {
+ if (parseData == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
- dotStandIn = (UChar) -1;
+ dotStandIn = (char16_t) -1;
- UnicodeString *tempstr = NULL; // used for memory allocation error checking
+ UnicodeString *tempstr = nullptr; // used for memory allocation error checking
UnicodeString str; // scratch
UnicodeString idBlockResult;
int32_t pos = 0;
@@ -932,18 +932,18 @@ void TransliteratorParser::parseRules(const UnicodeString& rule,
// and it is the offset to the _start_ of the compound filter
// pattern. Otherwise it is the offset to the _limit_ of the
// compound filter pattern within idBlockResult.
- compoundFilter = NULL;
+ compoundFilter = nullptr;
int32_t compoundFilterOffset = -1;
while (pos < limit && U_SUCCESS(status)) {
- UChar c = rule.charAt(pos++);
+ char16_t c = rule.charAt(pos++);
if (PatternProps::isWhiteSpace(c)) {
// Ignore leading whitespace.
continue;
}
// Skip lines starting with the comment character
if (c == RULE_COMMENT_CHAR) {
- pos = rule.indexOf((UChar)0x000A /*\n*/, pos) + 1;
+ pos = rule.indexOf((char16_t)0x000A /*\n*/, pos) + 1;
if (pos == 0) {
break; // No "\n" found; rest of rule is a comment
}
@@ -974,7 +974,7 @@ void TransliteratorParser::parseRules(const UnicodeString& rule,
int32_t p = pos;
if (!parsingIDs) {
- if (curData != NULL) {
+ if (curData != nullptr) {
U_ASSERT(!dataVector.hasDeleter());
if (direction == UTRANS_FORWARD)
dataVector.addElement(curData, status);
@@ -983,9 +983,9 @@ void TransliteratorParser::parseRules(const UnicodeString& rule,
if (U_FAILURE(status)) {
delete curData;
}
- curData = NULL;
+ curData = nullptr;
}
- parsingIDs = TRUE;
+ parsingIDs = true;
}
TransliteratorIDParser::SingleID* id =
@@ -1003,12 +1003,12 @@ void TransliteratorParser::parseRules(const UnicodeString& rule,
} else {
// Couldn't parse an ID. Try to parse a global filter
int32_t withParens = -1;
- UnicodeSet* f = TransliteratorIDParser::parseGlobalFilter(rule, p, direction, withParens, NULL);
- if (f != NULL) {
+ UnicodeSet* f = TransliteratorIDParser::parseGlobalFilter(rule, p, direction, withParens, nullptr);
+ if (f != nullptr) {
if (ICU_Utility::parseChar(rule, p, END_OF_RULE)
&& (direction == UTRANS_FORWARD) == (withParens == 0))
{
- if (compoundFilter != NULL) {
+ if (compoundFilter != nullptr) {
// Multiple compound filters
syntaxError(U_MULTIPLE_COMPOUND_FILTERS, rule, pos, status);
delete f;
@@ -1030,8 +1030,8 @@ void TransliteratorParser::parseRules(const UnicodeString& rule,
} else {
if (parsingIDs) {
tempstr = new UnicodeString(idBlockResult);
- // NULL pointer check
- if (tempstr == NULL) {
+ // nullptr pointer check
+ if (tempstr == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -1044,10 +1044,10 @@ void TransliteratorParser::parseRules(const UnicodeString& rule,
return;
}
idBlockResult.remove();
- parsingIDs = FALSE;
+ parsingIDs = false;
curData = new TransliterationRuleData(status);
- // NULL pointer check
- if (curData == NULL) {
+ // nullptr pointer check
+ if (curData == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -1075,8 +1075,8 @@ void TransliteratorParser::parseRules(const UnicodeString& rule,
if (parsingIDs && idBlockResult.length() > 0) {
tempstr = new UnicodeString(idBlockResult);
- // NULL pointer check
- if (tempstr == NULL) {
+ // nullptr pointer check
+ if (tempstr == nullptr) {
// TODO: Testing, forcing this path, shows many memory leaks. ICU-21701
// intltest translit/TransliteratorTest/TestInstantiation
status = U_MEMORY_ALLOCATION_ERROR;
@@ -1090,7 +1090,7 @@ void TransliteratorParser::parseRules(const UnicodeString& rule,
return;
}
}
- else if (!parsingIDs && curData != NULL) {
+ else if (!parsingIDs && curData != nullptr) {
if (direction == UTRANS_FORWARD) {
dataVector.addElement(curData, status);
} else {
@@ -1112,8 +1112,8 @@ void TransliteratorParser::parseRules(const UnicodeString& rule,
data->variables = 0;
} else {
data->variables = (UnicodeFunctor**)uprv_malloc(data->variablesLength * sizeof(UnicodeFunctor*));
- // NULL pointer check
- if (data->variables == NULL) {
+ // nullptr pointer check
+ if (data->variables == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -1128,9 +1128,9 @@ void TransliteratorParser::parseRules(const UnicodeString& rule,
data->variableNames.removeAll();
int32_t p = UHASH_FIRST;
const UHashElement* he = variableNames.nextElement(p);
- while (he != NULL) {
+ while (he != nullptr) {
UnicodeString* tempus = ((UnicodeString*)(he->value.pointer))->clone();
- if (tempus == NULL) {
+ if (tempus == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -1142,7 +1142,7 @@ void TransliteratorParser::parseRules(const UnicodeString& rule,
variablesVector.removeAllElements(); // keeps them from getting deleted when we succeed
// Index the rules
- if (compoundFilter != NULL) {
+ if (compoundFilter != nullptr) {
if ((direction == UTRANS_FORWARD && compoundFilterOffset != 1) ||
(direction == UTRANS_REVERSE && compoundFilterOffset != ruleCount)) {
status = U_MISPLACED_COMPOUND_FILTER;
@@ -1168,16 +1168,16 @@ void TransliteratorParser::setVariableRange(int32_t start, int32_t end, UErrorCo
return;
}
- curData->variablesBase = (UChar) start;
+ curData->variablesBase = (char16_t) start;
if (dataVector.size() == 0) {
- variableNext = (UChar) start;
- variableLimit = (UChar) (end + 1);
+ variableNext = (char16_t) start;
+ variableLimit = (char16_t) (end + 1);
}
}
/**
* Assert that the given character is NOT within the variable range.
- * If it is, return FALSE. This is necessary to ensure that the
+ * If it is, return false. This is necessary to ensure that the
* variable range does not overlap characters used in a rule.
*/
UBool TransliteratorParser::checkVariableRange(UChar32 ch) const {
@@ -1200,15 +1200,15 @@ void TransliteratorParser::pragmaNormalizeRules(UNormalizationMode /*mode*/) {
//TODO Finish
}
-static const UChar PRAGMA_USE[] = {0x75,0x73,0x65,0x20,0}; // "use "
+static const char16_t PRAGMA_USE[] = {0x75,0x73,0x65,0x20,0}; // "use "
-static const UChar PRAGMA_VARIABLE_RANGE[] = {0x7E,0x76,0x61,0x72,0x69,0x61,0x62,0x6C,0x65,0x20,0x72,0x61,0x6E,0x67,0x65,0x20,0x23,0x20,0x23,0x7E,0x3B,0}; // "~variable range # #~;"
+static const char16_t PRAGMA_VARIABLE_RANGE[] = {0x7E,0x76,0x61,0x72,0x69,0x61,0x62,0x6C,0x65,0x20,0x72,0x61,0x6E,0x67,0x65,0x20,0x23,0x20,0x23,0x7E,0x3B,0}; // "~variable range # #~;"
-static const UChar PRAGMA_MAXIMUM_BACKUP[] = {0x7E,0x6D,0x61,0x78,0x69,0x6D,0x75,0x6D,0x20,0x62,0x61,0x63,0x6B,0x75,0x70,0x20,0x23,0x7E,0x3B,0}; // "~maximum backup #~;"
+static const char16_t PRAGMA_MAXIMUM_BACKUP[] = {0x7E,0x6D,0x61,0x78,0x69,0x6D,0x75,0x6D,0x20,0x62,0x61,0x63,0x6B,0x75,0x70,0x20,0x23,0x7E,0x3B,0}; // "~maximum backup #~;"
-static const UChar PRAGMA_NFD_RULES[] = {0x7E,0x6E,0x66,0x64,0x20,0x72,0x75,0x6C,0x65,0x73,0x7E,0x3B,0}; // "~nfd rules~;"
+static const char16_t PRAGMA_NFD_RULES[] = {0x7E,0x6E,0x66,0x64,0x20,0x72,0x75,0x6C,0x65,0x73,0x7E,0x3B,0}; // "~nfd rules~;"
-static const UChar PRAGMA_NFC_RULES[] = {0x7E,0x6E,0x66,0x63,0x20,0x72,0x75,0x6C,0x65,0x73,0x7E,0x3B,0}; // "~nfc rules~;"
+static const char16_t PRAGMA_NFC_RULES[] = {0x7E,0x6E,0x66,0x63,0x20,0x72,0x75,0x6C,0x65,0x73,0x7E,0x3B,0}; // "~nfc rules~;"
/**
* Return true if the given rule looks like a pragma.
@@ -1218,7 +1218,7 @@ static const UChar PRAGMA_NFC_RULES[] = {0x7E,0x6E,0x66,0x63,0x20,0x72,0x75,0x6C
*/
UBool TransliteratorParser::resemblesPragma(const UnicodeString& rule, int32_t pos, int32_t limit) {
// Must start with /use\s/i
- return ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_USE, 4), NULL) >= 0;
+ return ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(true, PRAGMA_USE, 4), nullptr) >= 0;
}
/**
@@ -1243,25 +1243,25 @@ int32_t TransliteratorParser::parsePragma(const UnicodeString& rule, int32_t pos
// use maximum backup 16;
// use nfd rules;
// use nfc rules;
- int p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_VARIABLE_RANGE, -1), array);
+ int p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(true, PRAGMA_VARIABLE_RANGE, -1), array);
if (p >= 0) {
setVariableRange(array[0], array[1], status);
return p;
}
- p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_MAXIMUM_BACKUP, -1), array);
+ p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(true, PRAGMA_MAXIMUM_BACKUP, -1), array);
if (p >= 0) {
pragmaMaximumBackup(array[0]);
return p;
}
- p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_NFD_RULES, -1), NULL);
+ p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(true, PRAGMA_NFD_RULES, -1), nullptr);
if (p >= 0) {
pragmaNormalizeRules(UNORM_NFD);
return p;
}
- p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_NFC_RULES, -1), NULL);
+ p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(true, PRAGMA_NFC_RULES, -1), nullptr);
if (p >= 0) {
pragmaNormalizeRules(UNORM_NFC);
return p;
@@ -1287,7 +1287,7 @@ int32_t TransliteratorParser::parsePragma(const UnicodeString& rule, int32_t pos
int32_t TransliteratorParser::parseRule(const UnicodeString& rule, int32_t pos, int32_t limit, UErrorCode& status) {
// Locate the left side, operator, and right side
int32_t start = pos;
- UChar op = 0;
+ char16_t op = 0;
int32_t i;
// Set up segments data
@@ -1305,7 +1305,7 @@ int32_t TransliteratorParser::parseRule(const UnicodeString& rule, int32_t pos,
return start;
}
- if (pos == limit || u_strchr(gOPERATORS, (op = rule.charAt(--pos))) == NULL) {
+ if (pos == limit || u_strchr(gOPERATORS, (op = rule.charAt(--pos))) == nullptr) {
return syntaxError(U_MISSING_OPERATOR, rule, start, status);
}
++pos;
@@ -1366,8 +1366,8 @@ int32_t TransliteratorParser::parseRule(const UnicodeString& rule, int32_t pos,
}
// We allow anything on the right, including an empty string.
UnicodeString* value = new UnicodeString(right->text);
- // NULL pointer check
- if (value == NULL) {
+ // nullptr pointer check
+ if (value == nullptr) {
return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
}
variableNames.put(undefinedVariableName, value, status);
@@ -1393,7 +1393,7 @@ int32_t TransliteratorParser::parseRule(const UnicodeString& rule, int32_t pos,
}
}
for (i=0; i<segmentObjects.size(); ++i) {
- if (segmentObjects.elementAt(i) == NULL) {
+ if (segmentObjects.elementAt(i) == nullptr) {
syntaxError(U_INTERNAL_TRANSLITERATOR_ERROR, rule, start, status); // will never happen
}
}
@@ -1451,11 +1451,11 @@ int32_t TransliteratorParser::parseRule(const UnicodeString& rule, int32_t pos,
}
// Flatten segment objects vector to an array
- UnicodeFunctor** segmentsArray = NULL;
+ UnicodeFunctor** segmentsArray = nullptr;
if (segmentObjects.size() > 0) {
segmentsArray = (UnicodeFunctor **)uprv_malloc(segmentObjects.size() * sizeof(UnicodeFunctor *));
// Null pointer check
- if (segmentsArray == NULL) {
+ if (segmentsArray == nullptr) {
return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
}
segmentObjects.toArray((void**) segmentsArray);
@@ -1469,7 +1469,7 @@ int32_t TransliteratorParser::parseRule(const UnicodeString& rule, int32_t pos,
curData,
status);
//Null pointer check
- if (temptr == NULL) {
+ if (temptr == nullptr) {
uprv_free(segmentsArray);
return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
}
@@ -1522,14 +1522,14 @@ int32_t TransliteratorParser::syntaxError(UErrorCode parseErrorCode,
* Parse a UnicodeSet out, store it, and return the stand-in character
* used to represent it.
*/
-UChar TransliteratorParser::parseSet(const UnicodeString& rule,
+char16_t TransliteratorParser::parseSet(const UnicodeString& rule,
ParsePosition& pos,
UErrorCode& status) {
UnicodeSet* set = new UnicodeSet(rule, pos, USET_IGNORE_SPACE, parseData, status);
// Null pointer check
- if (set == NULL) {
+ if (set == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return (UChar)0x0000; // Return empty character with error.
+ return (char16_t)0x0000; // Return empty character with error.
}
set->compact();
return generateStandInFor(set, status);
@@ -1539,14 +1539,14 @@ UChar TransliteratorParser::parseSet(const UnicodeString& rule,
* Generate and return a stand-in for a new UnicodeFunctor. Store
* the matcher (adopt it).
*/
-UChar TransliteratorParser::generateStandInFor(UnicodeFunctor* adopted, UErrorCode& status) {
+char16_t TransliteratorParser::generateStandInFor(UnicodeFunctor* adopted, UErrorCode& status) {
// assert(obj != null);
// Look up previous stand-in, if any. This is a short list
// (typical n is 0, 1, or 2); linear search is optimal.
for (int32_t i=0; i<variablesVector.size(); ++i) {
if (variablesVector.elementAt(i) == adopted) { // [sic] pointer comparison
- return (UChar) (curData->variablesBase + i);
+ return (char16_t) (curData->variablesBase + i);
}
}
@@ -1566,13 +1566,13 @@ UChar TransliteratorParser::generateStandInFor(UnicodeFunctor* adopted, UErrorCo
/**
* Return the standin for segment seg (1-based).
*/
-UChar TransliteratorParser::getSegmentStandin(int32_t seg, UErrorCode& status) {
+char16_t TransliteratorParser::getSegmentStandin(int32_t seg, UErrorCode& status) {
// Special character used to indicate an empty spot
- UChar empty = curData->variablesBase - 1;
+ char16_t empty = curData->variablesBase - 1;
while (segmentStandins.length() < seg) {
segmentStandins.append(empty);
}
- UChar c = segmentStandins.charAt(seg-1);
+ char16_t c = segmentStandins.charAt(seg-1);
if (c == empty) {
if (variableNext >= variableLimit) {
status = U_VARIABLE_RANGE_EXHAUSTED;
@@ -1582,7 +1582,7 @@ UChar TransliteratorParser::getSegmentStandin(int32_t seg, UErrorCode& status) {
// 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);
+ variablesVector.addElement((void*) nullptr, status);
segmentStandins.setCharAt(seg-1, c);
}
return c;
@@ -1603,8 +1603,8 @@ void TransliteratorParser::setSegmentObject(int32_t seg, StringMatcher* adopted,
return;
}
int32_t index = getSegmentStandin(seg, status) - curData->variablesBase;
- if (segmentObjects.elementAt(seg-1) != NULL ||
- variablesVector.elementAt(index) != NULL) {
+ if (segmentObjects.elementAt(seg-1) != nullptr ||
+ variablesVector.elementAt(index) != nullptr) {
// should never happen
if (U_SUCCESS(status)) {status = U_INTERNAL_TRANSLITERATOR_ERROR;}
return;
@@ -1618,13 +1618,13 @@ void TransliteratorParser::setSegmentObject(int32_t seg, StringMatcher* adopted,
* Return the stand-in for the dot set. It is allocated the first
* time and reused thereafter.
*/
-UChar TransliteratorParser::getDotStandIn(UErrorCode& status) {
- if (dotStandIn == (UChar) -1) {
- UnicodeSet* tempus = new UnicodeSet(UnicodeString(TRUE, DOT_SET, -1), status);
+char16_t TransliteratorParser::getDotStandIn(UErrorCode& status) {
+ if (dotStandIn == (char16_t) -1) {
+ UnicodeSet* tempus = new UnicodeSet(UnicodeString(true, DOT_SET, -1), status);
// Null pointer check.
- if (tempus == NULL) {
+ if (tempus == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return (UChar)0x0000;
+ return (char16_t)0x0000;
}
dotStandIn = generateStandInFor(tempus, status);
}
@@ -1639,7 +1639,7 @@ void TransliteratorParser::appendVariableDef(const UnicodeString& name,
UnicodeString& buf,
UErrorCode& status) {
const UnicodeString* s = (const UnicodeString*) variableNames.get(name);
- if (s == NULL) {
+ if (s == nullptr) {
// We allow one undefined variable so that variable definition
// statements work. For the first undefined variable we return
// the special placeholder variableLimit-1, and save the variable
@@ -1651,7 +1651,7 @@ void TransliteratorParser::appendVariableDef(const UnicodeString& name,
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
- buf.append((UChar) --variableLimit);
+ buf.append((char16_t) --variableLimit);
} else {
//throw new IllegalArgumentException("Undefined variable $"
// + name);
@@ -1673,15 +1673,15 @@ void TransliteratorParser::appendVariableDef(const UnicodeString& name,
U_NAMESPACE_END
U_CAPI int32_t
-utrans_stripRules(const UChar *source, int32_t sourceLen, UChar *target, UErrorCode *status) {
+utrans_stripRules(const char16_t *source, int32_t sourceLen, char16_t *target, UErrorCode *status) {
U_NAMESPACE_USE
- //const UChar *sourceStart = source;
- const UChar *targetStart = target;
- const UChar *sourceLimit = source+sourceLen;
- UChar *targetLimit = target+sourceLen;
+ //const char16_t *sourceStart = source;
+ const char16_t *targetStart = target;
+ const char16_t *sourceLimit = source+sourceLen;
+ char16_t *targetLimit = target+sourceLen;
UChar32 c = 0;
- UBool quoted = FALSE;
+ UBool quoted = false;
int32_t index;
uprv_memset(target, 0, sourceLen*U_SIZEOF_UCHAR);
@@ -1748,7 +1748,7 @@ utrans_stripRules(const UChar *source, int32_t sourceLen, UChar *target, UErrorC
/* ignore spaces carriage returns, and all leading spaces on the next line.
* and line feed unless in the form \uXXXX
*/
- quoted = FALSE;
+ quoted = false;
while (source < sourceLimit) {
c = *(source);
if (c != CR && c != LF && c != 0x0020) {
@@ -1759,7 +1759,7 @@ utrans_stripRules(const UChar *source, int32_t sourceLen, UChar *target, UErrorC
continue;
}
- /* Append UChar * after dissembling if c > 0xffff*/
+ /* Append char16_t * after dissembling if c > 0xffff*/
index=0;
U16_APPEND_UNSAFE(target, index, c);
target+=index;
diff --git a/contrib/libs/icu/i18n/rbt_pars.h b/contrib/libs/icu/i18n/rbt_pars.h
index d1a4cd6997..11cf50e756 100644
--- a/contrib/libs/icu/i18n/rbt_pars.h
+++ b/contrib/libs/icu/i18n/rbt_pars.h
@@ -107,14 +107,14 @@ class TransliteratorParser : public UMemory {
* <code>variableLimit</code>. At any point during parsing, available
* variables are <code>variableNext..variableLimit-1</code>.
*/
- UChar variableNext;
+ char16_t variableNext;
/**
* The last available stand-in for variables. This is discovered
* dynamically. At any point during parsing, available variables are
* <code>variableNext..variableLimit-1</code>.
*/
- UChar variableLimit;
+ char16_t variableLimit;
/**
* When we encounter an undefined variable, we do not immediately signal
@@ -130,7 +130,7 @@ class TransliteratorParser : public UMemory {
* patterns. This is allocated the first time it is needed, and
* reused thereafter.
*/
- UChar dotStandIn;
+ char16_t dotStandIn;
public:
@@ -272,9 +272,9 @@ private:
* @param pos the position in pattern at which to start parsing.
* @return the stand-in character used to represent it.
*/
- UChar parseSet(const UnicodeString& rule,
- ParsePosition& pos,
- UErrorCode& status);
+ char16_t parseSet(const UnicodeString& rule,
+ ParsePosition& pos,
+ UErrorCode& status);
/**
* Generate and return a stand-in for a new UnicodeFunctor. Store
@@ -282,14 +282,14 @@ private:
* @param adopted the UnicodeFunctor to be adopted.
* @return a stand-in for a new UnicodeFunctor.
*/
- UChar generateStandInFor(UnicodeFunctor* adopted, UErrorCode& status);
+ char16_t generateStandInFor(UnicodeFunctor* adopted, UErrorCode& status);
/**
* Return the standin for segment seg (1-based).
* @param seg the given segment.
* @return the standIn character for the given segment.
*/
- UChar getSegmentStandin(int32_t seg, UErrorCode& status);
+ char16_t getSegmentStandin(int32_t seg, UErrorCode& status);
/**
* Set the object for segment seg (1-based).
@@ -303,7 +303,7 @@ private:
* time and reused thereafter.
* @return the stand-in for the dot set.
*/
- UChar getDotStandIn(UErrorCode& status);
+ char16_t getDotStandIn(UErrorCode& status);
/**
* Append the value of the given variable name to the given
diff --git a/contrib/libs/icu/i18n/rbt_rule.cpp b/contrib/libs/icu/i18n/rbt_rule.cpp
index 6cc5325c46..da8e4eaa1f 100644
--- a/contrib/libs/icu/i18n/rbt_rule.cpp
+++ b/contrib/libs/icu/i18n/rbt_rule.cpp
@@ -26,7 +26,7 @@
#include "util.h"
#include "putilimp.h"
-static const UChar FORWARD_OP[] = {32,62,32,0}; // " > "
+static const char16_t FORWARD_OP[] = {32,62,32,0}; // " > "
U_NAMESPACE_BEGIN
@@ -50,9 +50,9 @@ U_NAMESPACE_BEGIN
* 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
*/
TransliterationRule::TransliterationRule(const UnicodeString& input,
@@ -116,22 +116,22 @@ TransliterationRule::TransliterationRule(const UnicodeString& input,
flags |= ANCHOR_END;
}
- anteContext = NULL;
+ anteContext = nullptr;
if (anteContextLength > 0) {
anteContext = new StringMatcher(pattern, 0, anteContextLength,
- FALSE, *data);
- /* test for NULL */
+ false, *data);
+ /* test for nullptr */
if (anteContext == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
}
- key = NULL;
+ key = nullptr;
if (keyLength > 0) {
key = new StringMatcher(pattern, anteContextLength, anteContextLength + keyLength,
- FALSE, *data);
- /* test for NULL */
+ false, *data);
+ /* test for nullptr */
if (key == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -139,11 +139,11 @@ TransliterationRule::TransliterationRule(const UnicodeString& input,
}
int32_t postContextLength = pattern.length() - keyLength - anteContextLength;
- postContext = NULL;
+ postContext = nullptr;
if (postContextLength > 0) {
postContext = new StringMatcher(pattern, anteContextLength + keyLength, pattern.length(),
- FALSE, *data);
- /* test for NULL */
+ false, *data);
+ /* test for nullptr */
if (postContext == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -151,7 +151,7 @@ TransliterationRule::TransliterationRule(const UnicodeString& input,
}
this->output = new StringReplacer(outputStr, cursorPosition + cursorOffset, data);
- /* test for NULL */
+ /* test for nullptr */
if (this->output == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -163,29 +163,29 @@ TransliterationRule::TransliterationRule(const UnicodeString& input,
*/
TransliterationRule::TransliterationRule(TransliterationRule& other) :
UMemory(other),
- anteContext(NULL),
- key(NULL),
- postContext(NULL),
+ anteContext(nullptr),
+ key(nullptr),
+ postContext(nullptr),
pattern(other.pattern),
anteContextLength(other.anteContextLength),
keyLength(other.keyLength),
flags(other.flags),
data(other.data) {
- segments = NULL;
+ segments = nullptr;
segmentsCount = 0;
if (other.segmentsCount > 0) {
segments = (UnicodeFunctor **)uprv_malloc(other.segmentsCount * sizeof(UnicodeFunctor *));
uprv_memcpy(segments, other.segments, (size_t)other.segmentsCount*sizeof(segments[0]));
}
- if (other.anteContext != NULL) {
+ if (other.anteContext != nullptr) {
anteContext = other.anteContext->clone();
}
- if (other.key != NULL) {
+ if (other.key != nullptr) {
key = other.key->clone();
}
- if (other.postContext != NULL) {
+ if (other.postContext != nullptr) {
postContext = other.postContext->clone();
}
output = other.output->clone();
@@ -208,7 +208,7 @@ TransliterationRule::~TransliterationRule() {
* needed to make repeated incremental transliteration with
* anchors work.
*/
-int32_t TransliterationRule::getContextLength(void) const {
+int32_t TransliterationRule::getContextLength() const {
return anteContextLength + ((flags & ANCHOR_START) ? 1 : 0);
}
@@ -225,7 +225,7 @@ int16_t TransliterationRule::getIndexValue() const {
return -1;
}
UChar32 c = pattern.char32At(anteContextLength);
- return (int16_t)(data->lookupMatcher(c) == NULL ? (c & 0xFF) : -1);
+ return (int16_t)(data->lookupMatcher(c) == nullptr ? (c & 0xFF) : -1);
}
/**
@@ -241,8 +241,8 @@ int16_t TransliterationRule::getIndexValue() const {
UBool TransliterationRule::matchesIndexValue(uint8_t v) const {
// Delegate to the key, or if there is none, to the postContext.
// If there is neither then we match any key; return true.
- UnicodeMatcher *m = (key != NULL) ? key : postContext;
- return (m != NULL) ? m->matchesIndexValue(v) : TRUE;
+ UnicodeMatcher *m = (key != nullptr) ? key : postContext;
+ return (m != nullptr) ? m->matchesIndexValue(v) : true;
}
/**
@@ -343,11 +343,11 @@ static inline int32_t posAfter(const Replaceable& str, int32_t pos) {
*
* @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 TransliterationRule::matchAndReplace(Replaceable& text,
UTransPosition& pos,
@@ -361,7 +361,7 @@ UMatchDegree TransliterationRule::matchAndReplace(Replaceable& text,
// ============================ MATCH ===========================
// Reset segment match data
- if (segments != NULL) {
+ if (segments != nullptr) {
for (int32_t i=0; i<segmentsCount; ++i) {
((StringMatcher*) segments[i])->resetMatch();
}
@@ -391,8 +391,8 @@ UMatchDegree TransliterationRule::matchAndReplace(Replaceable& text,
// Start reverse match at char before pos.start
oText = posBefore(text, pos.start);
- if (anteContext != NULL) {
- match = anteContext->matches(text, oText, anteLimit, FALSE);
+ if (anteContext != nullptr) {
+ match = anteContext->matches(text, oText, anteLimit, false);
if (match != U_MATCH) {
return U_MISMATCH;
}
@@ -410,7 +410,7 @@ UMatchDegree TransliterationRule::matchAndReplace(Replaceable& text,
oText = pos.start;
- if (key != NULL) {
+ if (key != nullptr) {
match = key->matches(text, oText, pos.limit, incremental);
if (match != U_MATCH) {
return match;
@@ -419,7 +419,7 @@ UMatchDegree TransliterationRule::matchAndReplace(Replaceable& text,
keyLimit = oText;
- if (postContext != NULL) {
+ if (postContext != nullptr) {
if (incremental && keyLimit == pos.limit) {
// The key matches just before pos.limit, and there is
// a postContext. Since we are in incremental mode,
@@ -477,51 +477,51 @@ UnicodeString& TransliterationRule::toRule(UnicodeString& rule,
// Do not emit the braces '{' '}' around the pattern if there
// is neither anteContext nor postContext.
UBool emitBraces =
- (anteContext != NULL) || (postContext != NULL);
+ (anteContext != nullptr) || (postContext != nullptr);
// Emit start anchor
if ((flags & ANCHOR_START) != 0) {
- rule.append((UChar)94/*^*/);
+ rule.append((char16_t)94/*^*/);
}
// Emit the input pattern
ICU_Utility::appendToRule(rule, anteContext, escapeUnprintable, quoteBuf);
if (emitBraces) {
- ICU_Utility::appendToRule(rule, (UChar) 0x007B /*{*/, TRUE, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, (char16_t) 0x007B /*{*/, true, escapeUnprintable, quoteBuf);
}
ICU_Utility::appendToRule(rule, key, escapeUnprintable, quoteBuf);
if (emitBraces) {
- ICU_Utility::appendToRule(rule, (UChar) 0x007D /*}*/, TRUE, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, (char16_t) 0x007D /*}*/, true, escapeUnprintable, quoteBuf);
}
ICU_Utility::appendToRule(rule, postContext, escapeUnprintable, quoteBuf);
// Emit end anchor
if ((flags & ANCHOR_END) != 0) {
- rule.append((UChar)36/*$*/);
+ rule.append((char16_t)36/*$*/);
}
- ICU_Utility::appendToRule(rule, UnicodeString(TRUE, FORWARD_OP, 3), TRUE, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, UnicodeString(true, FORWARD_OP, 3), true, escapeUnprintable, quoteBuf);
// Emit the output pattern
ICU_Utility::appendToRule(rule, output->toReplacer()->toReplacerPattern(str, escapeUnprintable),
- TRUE, escapeUnprintable, quoteBuf);
+ true, escapeUnprintable, quoteBuf);
- ICU_Utility::appendToRule(rule, (UChar) 0x003B /*;*/, TRUE, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, (char16_t) 0x003B /*;*/, true, escapeUnprintable, quoteBuf);
return rule;
}
void TransliterationRule::setData(const TransliterationRuleData* d) {
data = d;
- if (anteContext != NULL) anteContext->setData(d);
- if (postContext != NULL) postContext->setData(d);
- if (key != NULL) key->setData(d);
- // assert(output != NULL);
+ if (anteContext != nullptr) anteContext->setData(d);
+ if (postContext != nullptr) postContext->setData(d);
+ if (key != nullptr) key->setData(d);
+ // assert(output != nullptr);
output->setData(d);
// Don't have to do segments since they are in the context or key
}
@@ -536,7 +536,7 @@ void TransliterationRule::addSourceSetTo(UnicodeSet& toUnionTo) const {
UChar32 ch = pattern.char32At(i);
i += U16_LENGTH(ch);
const UnicodeMatcher* matcher = data->lookupMatcher(ch);
- if (matcher == NULL) {
+ if (matcher == nullptr) {
toUnionTo.add(ch);
} else {
matcher->addMatchSetTo(toUnionTo);
diff --git a/contrib/libs/icu/i18n/rbt_rule.h b/contrib/libs/icu/i18n/rbt_rule.h
index b927f5d6c0..c6f5151d4c 100644
--- a/contrib/libs/icu/i18n/rbt_rule.h
+++ b/contrib/libs/icu/i18n/rbt_rule.h
@@ -108,7 +108,7 @@ private:
UnicodeFunctor** segments;
/**
- * The number of elements in segments[] or zero if segments is NULL.
+ * The number of elements in segments[] or zero if segments is nullptr.
*/
int32_t segmentsCount;
@@ -217,7 +217,7 @@ public:
* anchors work.
* @return the preceding context length.
*/
- virtual int32_t getContextLength(void) const;
+ virtual int32_t getContextLength() const;
/**
* Internal method. Returns 8-bit index value for this rule.
diff --git a/contrib/libs/icu/i18n/rbt_set.cpp b/contrib/libs/icu/i18n/rbt_set.cpp
index abc4413c2c..c0a2ccd868 100644
--- a/contrib/libs/icu/i18n/rbt_set.cpp
+++ b/contrib/libs/icu/i18n/rbt_set.cpp
@@ -61,9 +61,9 @@ static UnicodeString& _formatInput(UnicodeString &appendTo,
input.extractBetween(pos.start, pos.limit, c);
input.extractBetween(pos.limit, pos.contextLimit, d);
input.extractBetween(pos.contextLimit, input.length(), e);
- appendTo.append(a).append((UChar)123/*{*/).append(b).
- append((UChar)124/*|*/).append(c).append((UChar)124/*|*/).append(d).
- append((UChar)125/*}*/).append(e);
+ appendTo.append(a).append((char16_t)123/*{*/).append(b).
+ append((char16_t)124/*|*/).append(c).append((char16_t)124/*|*/).append(d).
+ append((char16_t)125/*}*/).append(e);
} else {
appendTo.append("INVALID UTransPosition");
//appendTo.append((UnicodeString)"INVALID UTransPosition {cs=" +
@@ -78,7 +78,7 @@ static UnicodeString& _formatInput(UnicodeString &appendTo,
UnicodeString& _appendHex(uint32_t number,
int32_t digits,
UnicodeString& target) {
- static const UChar digitString[] = {
+ static const char16_t digitString[] = {
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0
};
@@ -114,8 +114,8 @@ inline void _debugOut(const char* msg, TransliterationRule* rule,
UnicodeString buf(msg, "");
if (rule) {
UnicodeString r;
- rule->toRule(r, TRUE);
- buf.append((UChar)32).append(r);
+ rule->toRule(r, true);
+ buf.append((char16_t)32).append(r);
}
buf.append(UnicodeString(" => ", ""));
UnicodeString* text = (UnicodeString*)&theText;
@@ -145,14 +145,14 @@ static void maskingError(const icu::TransliterationRule& rule1,
parseError.line = parseError.offset = -1;
// for pre-context
- rule1.toRule(r, FALSE);
+ rule1.toRule(r, false);
len = uprv_min(r.length(), U_PARSE_CONTEXT_LEN-1);
r.extract(0, len, parseError.preContext);
parseError.preContext[len] = 0;
//for post-context
r.truncate(0);
- rule2.toRule(r, FALSE);
+ rule2.toRule(r, false);
len = uprv_min(r.length(), U_PARSE_CONTEXT_LEN-1);
r.extract(0, len, parseError.postContext);
parseError.postContext[len] = 0;
@@ -163,16 +163,13 @@ U_NAMESPACE_BEGIN
/**
* Construct a new empty rule set.
*/
-TransliterationRuleSet::TransliterationRuleSet(UErrorCode& status) : UMemory() {
- ruleVector = new UVector(&_deleteRule, NULL, status);
+TransliterationRuleSet::TransliterationRuleSet(UErrorCode& status) :
+ UMemory(), ruleVector(nullptr), rules(nullptr), index {}, maxContextLength(0) {
+ LocalPointer<UVector> lpRuleVector(new UVector(_deleteRule, nullptr, status), status);
if (U_FAILURE(status)) {
return;
}
- if (ruleVector == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
- }
- rules = NULL;
- maxContextLength = 0;
+ ruleVector = lpRuleVector.orphan();
}
/**
@@ -180,27 +177,24 @@ TransliterationRuleSet::TransliterationRuleSet(UErrorCode& status) : UMemory() {
*/
TransliterationRuleSet::TransliterationRuleSet(const TransliterationRuleSet& other) :
UMemory(other),
- ruleVector(0),
- rules(0),
+ ruleVector(nullptr),
+ rules(nullptr),
maxContextLength(other.maxContextLength) {
int32_t i, len;
uprv_memcpy(index, other.index, sizeof(index));
UErrorCode status = U_ZERO_ERROR;
- ruleVector = new UVector(&_deleteRule, NULL, status);
- if (other.ruleVector != 0 && ruleVector != 0 && U_SUCCESS(status)) {
+ LocalPointer<UVector> lpRuleVector(new UVector(_deleteRule, nullptr, status), status);
+ if (U_FAILURE(status)) {
+ return;
+ }
+ ruleVector = lpRuleVector.orphan();
+ if (other.ruleVector != nullptr && U_SUCCESS(status)) {
len = other.ruleVector->size();
for (i=0; i<len && U_SUCCESS(status); ++i) {
- TransliterationRule *tempTranslitRule = new TransliterationRule(*(TransliterationRule*)other.ruleVector->elementAt(i));
- // Null pointer test
- if (tempTranslitRule == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
- break;
- }
- ruleVector->addElementX(tempTranslitRule, status);
- if (U_FAILURE(status)) {
- break;
- }
+ LocalPointer<TransliterationRule> tempTranslitRule(
+ new TransliterationRule(*(TransliterationRule*)other.ruleVector->elementAt(i)), status);
+ ruleVector->adoptElement(tempTranslitRule.orphan(), status);
}
}
if (other.rules != 0 && U_SUCCESS(status)) {
@@ -231,7 +225,7 @@ void TransliterationRuleSet::setData(const TransliterationRuleData* d) {
* Return the maximum context length.
* @return the length of the longest preceding context.
*/
-int32_t TransliterationRuleSet::getMaximumContextLength(void) const {
+int32_t TransliterationRuleSet::getMaximumContextLength() const {
return maxContextLength;
}
@@ -247,11 +241,11 @@ int32_t TransliterationRuleSet::getMaximumContextLength(void) const {
*/
void TransliterationRuleSet::addRule(TransliterationRule* adoptedRule,
UErrorCode& status) {
+ LocalPointer<TransliterationRule> lpAdoptedRule(adoptedRule);
+ ruleVector->adoptElement(lpAdoptedRule.orphan(), status);
if (U_FAILURE(status)) {
- delete adoptedRule;
return;
}
- ruleVector->addElementX(adoptedRule, status);
int32_t len;
if ((len = adoptedRule->getContextLength()) > maxContextLength) {
@@ -302,7 +296,7 @@ void TransliterationRuleSet::freeze(UParseError& parseError,UErrorCode& status)
* Be careful not to call malloc(0).
*/
int16_t* indexValue = (int16_t*) uprv_malloc( sizeof(int16_t) * (n > 0 ? n : 1) );
- /* test for NULL */
+ /* test for nullptr */
if (indexValue == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -316,7 +310,7 @@ void TransliterationRuleSet::freeze(UParseError& parseError,UErrorCode& status)
for (j=0; j<n; ++j) {
if (indexValue[j] >= 0) {
if (indexValue[j] == x) {
- v.addElementX(ruleVector->elementAt(j), status);
+ v.addElement(ruleVector->elementAt(j), status);
}
} else {
// If the indexValue is < 0, then the first key character is
@@ -325,13 +319,16 @@ void TransliterationRuleSet::freeze(UParseError& parseError,UErrorCode& status)
// rarely, so we seldom treat this code path.
TransliterationRule* r = (TransliterationRule*) ruleVector->elementAt(j);
if (r->matchesIndexValue((uint8_t)x)) {
- v.addElementX(r, status);
+ v.addElement(r, status);
}
}
}
}
uprv_free(indexValue);
index[256] = v.size();
+ if (U_FAILURE(status)) {
+ return;
+ }
/* Freeze things into an array.
*/
@@ -339,11 +336,11 @@ void TransliterationRuleSet::freeze(UParseError& parseError,UErrorCode& status)
/* You can't do malloc(0)! */
if (v.size() == 0) {
- rules = NULL;
+ rules = nullptr;
return;
}
rules = (TransliterationRule **)uprv_malloc(v.size() * sizeof(TransliterationRule *));
- /* test for NULL */
+ /* test for nullptr */
if (rules == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -390,14 +387,14 @@ void TransliterationRuleSet::freeze(UParseError& parseError,UErrorCode& status)
/**
* 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 pos the position indices, which will be updated
- * @param incremental if TRUE, assume new text may be inserted
- * at index.limit, and return FALSE if there is a partial match.
- * @return TRUE unless a U_PARTIAL_MATCH has been obtained,
+ * @param incremental if true, assume new text may be inserted
+ * at index.limit, and return false if there is a partial match.
+ * @return true unless a U_PARTIAL_MATCH has been obtained,
* indicating that transliteration should stop until more text
* arrives.
*/
@@ -410,18 +407,18 @@ UBool TransliterationRuleSet::transliterate(Replaceable& text,
switch (m) {
case U_MATCH:
_debugOut("match", rules[i], text, pos);
- return TRUE;
+ return true;
case U_PARTIAL_MATCH:
_debugOut("partial match", rules[i], text, pos);
- return FALSE;
+ return false;
default: /* Ram: added default to make GCC happy */
break;
}
}
// No match or partial match from any rule
pos.start += U16_LENGTH(text.char32At(pos.start));
- _debugOut("no match", NULL, text, pos);
- return TRUE;
+ _debugOut("no match", nullptr, text, pos);
+ return true;
}
/**
@@ -434,7 +431,7 @@ UnicodeString& TransliterationRuleSet::toRules(UnicodeString& ruleSource,
ruleSource.truncate(0);
for (i=0; i<count; ++i) {
if (i != 0) {
- ruleSource.append((UChar) 0x000A /*\n*/);
+ ruleSource.append((char16_t) 0x000A /*\n*/);
}
TransliterationRule *r =
(TransliterationRule*) ruleVector->elementAt(i);
diff --git a/contrib/libs/icu/i18n/rbt_set.h b/contrib/libs/icu/i18n/rbt_set.h
index 3a2890e8ec..fb436ff67e 100644
--- a/contrib/libs/icu/i18n/rbt_set.h
+++ b/contrib/libs/icu/i18n/rbt_set.h
@@ -92,7 +92,7 @@ public:
* Return the maximum context length.
* @return the length of the longest preceding context.
*/
- virtual int32_t getMaximumContextLength(void) const;
+ virtual int32_t getMaximumContextLength() const;
/**
* Add a rule to this set. Rules are added in order, and order is
diff --git a/contrib/libs/icu/i18n/rbtz.cpp b/contrib/libs/icu/i18n/rbtz.cpp
index 495d8310d0..e4d71436c5 100644
--- a/contrib/libs/icu/i18n/rbtz.cpp
+++ b/contrib/libs/icu/i18n/rbtz.cpp
@@ -39,35 +39,35 @@ deleteTransition(void* obj) {
U_CDECL_END
static UBool compareRules(UVector* rules1, UVector* rules2) {
- if (rules1 == NULL && rules2 == NULL) {
- return TRUE;
- } else if (rules1 == NULL || rules2 == NULL) {
- return FALSE;
+ if (rules1 == nullptr && rules2 == nullptr) {
+ return true;
+ } else if (rules1 == nullptr || rules2 == nullptr) {
+ return false;
}
int32_t size = rules1->size();
if (size != rules2->size()) {
- return FALSE;
+ return false;
}
for (int32_t i = 0; i < size; i++) {
TimeZoneRule *r1 = (TimeZoneRule*)rules1->elementAt(i);
TimeZoneRule *r2 = (TimeZoneRule*)rules2->elementAt(i);
if (*r1 != *r2) {
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RuleBasedTimeZone)
RuleBasedTimeZone::RuleBasedTimeZone(const UnicodeString& id, InitialTimeZoneRule* initialRule)
-: BasicTimeZone(id), fInitialRule(initialRule), fHistoricRules(NULL), fFinalRules(NULL),
- fHistoricTransitions(NULL), fUpToDate(FALSE) {
+: BasicTimeZone(id), fInitialRule(initialRule), fHistoricRules(nullptr), fFinalRules(nullptr),
+ fHistoricTransitions(nullptr), fUpToDate(false) {
}
RuleBasedTimeZone::RuleBasedTimeZone(const RuleBasedTimeZone& source)
: BasicTimeZone(source), fInitialRule(source.fInitialRule->clone()),
- fHistoricTransitions(NULL), fUpToDate(FALSE) {
+ fHistoricTransitions(nullptr), fUpToDate(false) {
fHistoricRules = copyRules(source.fHistoricRules);
fFinalRules = copyRules(source.fFinalRules);
if (source.fUpToDate) {
@@ -90,7 +90,7 @@ RuleBasedTimeZone::operator=(const RuleBasedTimeZone& right) {
fHistoricRules = copyRules(right.fHistoricRules);
fFinalRules = copyRules(right.fFinalRules);
deleteTransitions();
- fUpToDate = FALSE;
+ fUpToDate = false;
}
return *this;
}
@@ -152,7 +152,7 @@ RuleBasedTimeZone::addTransitionRule(TimeZoneRule* rule, UErrorCode& status) {
fHistoricRules->adoptElement(lpRule.orphan(), status);
}
// Mark dirty, so transitions are recalculated at next complete() call
- fUpToDate = FALSE;
+ fUpToDate = false;
}
@@ -180,35 +180,35 @@ RuleBasedTimeZone::complete(UErrorCode& status) {
}
// Make sure either no final rules or a pair of AnnualTimeZoneRules
// are available.
- if (fFinalRules != NULL && fFinalRules->size() != 2) {
+ if (fFinalRules != nullptr && fFinalRules->size() != 2) {
status = U_INVALID_STATE_ERROR;
return;
}
// Create a TimezoneTransition and add to the list
- if (fHistoricRules != NULL || fFinalRules != NULL) {
+ if (fHistoricRules != nullptr || fFinalRules != nullptr) {
TimeZoneRule *curRule = fInitialRule;
UDate lastTransitionTime = MIN_MILLIS;
// Build the transition array which represents historical time zone
// transitions.
- if (fHistoricRules != NULL && fHistoricRules->size() > 0) {
+ if (fHistoricRules != nullptr && fHistoricRules->size() > 0) {
int32_t i;
int32_t historicCount = fHistoricRules->size();
LocalMemory<bool> done((bool *)uprv_malloc(sizeof(bool) * historicCount));
- if (done == NULL) {
+ if (done == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
goto cleanup;
}
for (i = 0; i < historicCount; i++) {
done[i] = false;
}
- while (TRUE) {
+ while (true) {
int32_t curStdOffset = curRule->getRawOffset();
int32_t curDstSavings = curRule->getDSTSavings();
UDate nextTransitionTime = MAX_MILLIS;
- TimeZoneRule *nextRule = NULL;
- TimeZoneRule *r = NULL;
+ TimeZoneRule *nextRule = nullptr;
+ TimeZoneRule *r = nullptr;
UBool avail;
UDate tt;
UnicodeString curName, name;
@@ -237,12 +237,12 @@ RuleBasedTimeZone::complete(UErrorCode& status) {
}
}
- if (nextRule == NULL) {
+ if (nextRule == nullptr) {
// Check if all historic rules are done
- UBool bDoneAll = TRUE;
+ UBool bDoneAll = true;
for (int32_t j = 0; j < historicCount; j++) {
if (!done[j]) {
- bDoneAll = FALSE;
+ bDoneAll = false;
break;
}
}
@@ -251,7 +251,7 @@ RuleBasedTimeZone::complete(UErrorCode& status) {
}
}
- if (fFinalRules != NULL) {
+ if (fFinalRules != nullptr) {
// Check if one of final rules has earlier transition date
for (i = 0; i < 2 /* fFinalRules->size() */; i++) {
TimeZoneRule *fr = (TimeZoneRule*)fFinalRules->elementAt(i);
@@ -269,12 +269,12 @@ RuleBasedTimeZone::complete(UErrorCode& status) {
}
}
- if (nextRule == NULL) {
+ if (nextRule == nullptr) {
// Nothing more
break;
}
- if (fHistoricTransitions == NULL) {
+ if (fHistoricTransitions == nullptr) {
LocalPointer<UVector> lpHistoricTransitions(
new UVector(deleteTransition, nullptr, status), status);
if (U_FAILURE(status)) {
@@ -297,8 +297,8 @@ RuleBasedTimeZone::complete(UErrorCode& status) {
curRule = nextRule;
}
}
- if (fFinalRules != NULL) {
- if (fHistoricTransitions == NULL) {
+ if (fFinalRules != nullptr) {
+ if (fHistoricTransitions == nullptr) {
LocalPointer<UVector> lpHistoricTransitions(
new UVector(deleteTransition, nullptr, status), status);
if (U_FAILURE(status)) {
@@ -344,12 +344,12 @@ RuleBasedTimeZone::complete(UErrorCode& status) {
}
}
}
- fUpToDate = TRUE;
+ fUpToDate = true;
return;
cleanup:
deleteTransitions();
- fUpToDate = FALSE;
+ fUpToDate = false;
}
RuleBasedTimeZone*
@@ -386,7 +386,7 @@ RuleBasedTimeZone::getOffset(uint8_t era, int32_t year, int32_t month, int32_t d
}
int32_t rawOffset, dstOffset;
UDate time = (UDate)Grego::fieldsToDay(year, month, day) * U_MILLIS_PER_DAY + millis;
- getOffsetInternal(time, TRUE, kDaylight, kStandard, rawOffset, dstOffset, status);
+ getOffsetInternal(time, true, kDaylight, kStandard, rawOffset, dstOffset, status);
if (U_FAILURE(status)) {
return 0;
}
@@ -402,7 +402,7 @@ RuleBasedTimeZone::getOffset(UDate date, UBool local, int32_t& rawOffset,
void RuleBasedTimeZone::getOffsetFromLocal(UDate date, UTimeZoneLocalOption nonExistingTimeOpt,
UTimeZoneLocalOption duplicatedTimeOpt,
int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) const {
- getOffsetInternal(date, TRUE, nonExistingTimeOpt, duplicatedTimeOpt, rawOffset, dstOffset, status);
+ getOffsetInternal(date, true, nonExistingTimeOpt, duplicatedTimeOpt, rawOffset, dstOffset, status);
}
@@ -427,8 +427,8 @@ RuleBasedTimeZone::getOffsetInternal(UDate date, UBool local,
status = U_INVALID_STATE_ERROR;
return;
}
- const TimeZoneRule *rule = NULL;
- if (fHistoricTransitions == NULL) {
+ const TimeZoneRule *rule = nullptr;
+ if (fHistoricTransitions == nullptr) {
rule = fInitialRule;
} else {
UDate tstart = getTransitionTime((Transition*)fHistoricTransitions->elementAt(0),
@@ -440,10 +440,10 @@ RuleBasedTimeZone::getOffsetInternal(UDate date, UBool local,
UDate tend = getTransitionTime((Transition*)fHistoricTransitions->elementAt(idx),
local, NonExistingTimeOpt, DuplicatedTimeOpt);
if (date > tend) {
- if (fFinalRules != NULL) {
+ if (fFinalRules != nullptr) {
rule = findRuleInFinal(date, local, NonExistingTimeOpt, DuplicatedTimeOpt);
}
- if (rule == NULL) {
+ if (rule == nullptr) {
// no final rules or the given time is before the first transition
// specified by the final rules -> use the last rule
rule = ((Transition*)fHistoricTransitions->elementAt(idx))->to;
@@ -461,7 +461,7 @@ RuleBasedTimeZone::getOffsetInternal(UDate date, UBool local,
}
}
}
- if (rule != NULL) {
+ if (rule != nullptr) {
rawOffset = rule->getRawOffset();
dstOffset = rule->getDSTSavings();
}
@@ -474,68 +474,67 @@ RuleBasedTimeZone::setRawOffset(int32_t /*offsetMillis*/) {
}
int32_t
-RuleBasedTimeZone::getRawOffset(void) const {
+RuleBasedTimeZone::getRawOffset() const {
// Note: This implementation returns standard GMT offset
// as of current time.
UErrorCode status = U_ZERO_ERROR;
int32_t raw, dst;
- getOffset(uprv_getUTCtime() * U_MILLIS_PER_SECOND,
- FALSE, raw, dst, status);
+ getOffset(uprv_getUTCtime(), false, raw, dst, status);
return raw;
}
UBool
-RuleBasedTimeZone::useDaylightTime(void) const {
+RuleBasedTimeZone::useDaylightTime() const {
// Note: This implementation returns true when
// daylight saving time is used as of now or
// after the next transition.
UErrorCode status = U_ZERO_ERROR;
- UDate now = uprv_getUTCtime() * U_MILLIS_PER_SECOND;
+ UDate now = uprv_getUTCtime();
int32_t raw, dst;
- getOffset(now, FALSE, raw, dst, status);
+ getOffset(now, false, raw, dst, status);
if (dst != 0) {
- return TRUE;
+ return true;
}
// If DST is not used now, check if DST is used after the next transition
UDate time;
TimeZoneRule *from, *to;
- UBool avail = findNext(now, FALSE, time, from, to);
+ UBool avail = findNext(now, false, time, from, to);
if (avail && to->getDSTSavings() != 0) {
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
UBool
RuleBasedTimeZone::inDaylightTime(UDate date, UErrorCode& status) const {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
int32_t raw, dst;
- getOffset(date, FALSE, raw, dst, status);
+ getOffset(date, false, raw, dst, status);
if (dst != 0) {
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
UBool
RuleBasedTimeZone::hasSameRules(const TimeZone& other) const {
if (this == &other) {
- return TRUE;
+ return true;
}
if (typeid(*this) != typeid(other)) {
- return FALSE;
+ return false;
}
- const RuleBasedTimeZone& that = (const RuleBasedTimeZone&)other;
+ const RuleBasedTimeZone& that = static_cast<const RuleBasedTimeZone&>(other);
if (*fInitialRule != *(that.fInitialRule)) {
- return FALSE;
+ return false;
}
if (compareRules(fHistoricRules, that.fHistoricRules)
&& compareRules(fFinalRules, that.fFinalRules)) {
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
UBool
@@ -543,18 +542,18 @@ RuleBasedTimeZone::getNextTransition(UDate base, UBool inclusive, TimeZoneTransi
UErrorCode status = U_ZERO_ERROR;
completeConst(status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
UDate transitionTime;
TimeZoneRule *fromRule, *toRule;
UBool found = findNext(base, inclusive, transitionTime, fromRule, toRule);
if (found) {
result.setTime(transitionTime);
- result.setFrom((const TimeZoneRule&)*fromRule);
- result.setTo((const TimeZoneRule&)*toRule);
- return TRUE;
+ result.setFrom(*fromRule);
+ result.setTo(*toRule);
+ return true;
}
- return FALSE;
+ return false;
}
UBool
@@ -562,27 +561,27 @@ RuleBasedTimeZone::getPreviousTransition(UDate base, UBool inclusive, TimeZoneTr
UErrorCode status = U_ZERO_ERROR;
completeConst(status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
UDate transitionTime;
TimeZoneRule *fromRule, *toRule;
UBool found = findPrev(base, inclusive, transitionTime, fromRule, toRule);
if (found) {
result.setTime(transitionTime);
- result.setFrom((const TimeZoneRule&)*fromRule);
- result.setTo((const TimeZoneRule&)*toRule);
- return TRUE;
+ result.setFrom(*fromRule);
+ result.setTo(*toRule);
+ return true;
}
- return FALSE;
+ return false;
}
int32_t
RuleBasedTimeZone::countTransitionRules(UErrorCode& /*status*/) const {
int32_t count = 0;
- if (fHistoricRules != NULL) {
+ if (fHistoricRules != nullptr) {
count += fHistoricRules->size();
}
- if (fFinalRules != NULL) {
+ if (fFinalRules != nullptr) {
count += fFinalRules->size();
}
return count;
@@ -602,14 +601,14 @@ RuleBasedTimeZone::getTimeZoneRules(const InitialTimeZoneRule*& initial,
// Transition rules
int32_t cnt = 0;
int32_t idx;
- if (fHistoricRules != NULL && cnt < trscount) {
+ if (fHistoricRules != nullptr && cnt < trscount) {
int32_t historicCount = fHistoricRules->size();
idx = 0;
while (cnt < trscount && idx < historicCount) {
trsrules[cnt++] = (const TimeZoneRule*)fHistoricRules->elementAt(idx++);
}
}
- if (fFinalRules != NULL && cnt < trscount) {
+ if (fFinalRules != nullptr && cnt < trscount) {
int32_t finalCount = fFinalRules->size();
idx = 0;
while (cnt < trscount && idx < finalCount) {
@@ -621,25 +620,25 @@ RuleBasedTimeZone::getTimeZoneRules(const InitialTimeZoneRule*& initial,
}
void
-RuleBasedTimeZone::deleteRules(void) {
+RuleBasedTimeZone::deleteRules() {
delete fInitialRule;
- fInitialRule = NULL;
- if (fHistoricRules != NULL) {
+ fInitialRule = nullptr;
+ if (fHistoricRules != nullptr) {
delete fHistoricRules;
- fHistoricRules = NULL;
+ fHistoricRules = nullptr;
}
- if (fFinalRules != NULL) {
+ if (fFinalRules != nullptr) {
delete fFinalRules;
- fFinalRules = NULL;
+ fFinalRules = nullptr;
}
}
void
-RuleBasedTimeZone::deleteTransitions(void) {
- if (fHistoricTransitions != NULL) {
+RuleBasedTimeZone::deleteTransitions() {
+ if (fHistoricTransitions != nullptr) {
delete fHistoricTransitions;
}
- fHistoricTransitions = NULL;
+ fHistoricTransitions = nullptr;
}
UVector*
@@ -667,14 +666,14 @@ RuleBasedTimeZone::copyRules(UVector* source) {
TimeZoneRule*
RuleBasedTimeZone::findRuleInFinal(UDate date, UBool local,
int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt) const {
- if (fFinalRules == NULL) {
- return NULL;
+ if (fFinalRules == nullptr) {
+ return nullptr;
}
AnnualTimeZoneRule* fr0 = (AnnualTimeZoneRule*)fFinalRules->elementAt(0);
AnnualTimeZoneRule* fr1 = (AnnualTimeZoneRule*)fFinalRules->elementAt(1);
- if (fr0 == NULL || fr1 == NULL) {
- return NULL;
+ if (fr0 == nullptr || fr1 == nullptr) {
+ return nullptr;
}
UDate start0, start1;
@@ -688,7 +687,7 @@ RuleBasedTimeZone::findRuleInFinal(UDate date, UBool local,
NonExistingTimeOpt, DuplicatedTimeOpt);
base -= localDelta;
}
- UBool avail0 = fr0->getPreviousStart(base, fr1->getRawOffset(), fr1->getDSTSavings(), TRUE, start0);
+ UBool avail0 = fr0->getPreviousStart(base, fr1->getRawOffset(), fr1->getDSTSavings(), true, start0);
base = date;
if (local) {
@@ -697,7 +696,7 @@ RuleBasedTimeZone::findRuleInFinal(UDate date, UBool local,
NonExistingTimeOpt, DuplicatedTimeOpt);
base -= localDelta;
}
- UBool avail1 = fr1->getPreviousStart(base, fr0->getRawOffset(), fr0->getDSTSavings(), TRUE, start1);
+ UBool avail1 = fr1->getPreviousStart(base, fr0->getRawOffset(), fr0->getDSTSavings(), true, start1);
if (!avail0 || !avail1) {
if (avail0) {
@@ -706,7 +705,7 @@ RuleBasedTimeZone::findRuleInFinal(UDate date, UBool local,
return fr1;
}
// Both rules take effect after the given time
- return NULL;
+ return nullptr;
}
return (start0 > start1) ? fr0 : fr1;
@@ -715,35 +714,35 @@ RuleBasedTimeZone::findRuleInFinal(UDate date, UBool local,
UBool
RuleBasedTimeZone::findNext(UDate base, UBool inclusive, UDate& transitionTime,
TimeZoneRule*& fromRule, TimeZoneRule*& toRule) const {
- if (fHistoricTransitions == NULL) {
- return FALSE;
+ if (fHistoricTransitions == nullptr) {
+ return false;
}
- UBool isFinal = FALSE;
- UBool found = FALSE;
+ UBool isFinal = false;
+ UBool found = false;
Transition result;
Transition *tzt = (Transition*)fHistoricTransitions->elementAt(0);
UDate tt = tzt->time;
if (tt > base || (inclusive && tt == base)) {
result = *tzt;
- found = TRUE;
+ found = true;
} else {
int32_t idx = fHistoricTransitions->size() - 1;
tzt = (Transition*)fHistoricTransitions->elementAt(idx);
tt = tzt->time;
if (inclusive && tt == base) {
result = *tzt;
- found = TRUE;
+ found = true;
} else if (tt <= base) {
- if (fFinalRules != NULL) {
+ if (fFinalRules != nullptr) {
// Find a transion time with finalRules
TimeZoneRule *r0 = (TimeZoneRule*)fFinalRules->elementAt(0);
TimeZoneRule *r1 = (TimeZoneRule*)fFinalRules->elementAt(1);
UDate start0, start1;
UBool avail0 = r0->getNextStart(base, r1->getRawOffset(), r1->getDSTSavings(), inclusive, start0);
UBool avail1 = r1->getNextStart(base, r0->getRawOffset(), r0->getDSTSavings(), inclusive, start1);
- // avail0/avail1 should be always TRUE
+ // avail0/avail1 should be always true
if (!avail0 && !avail1) {
- return FALSE;
+ return false;
}
if (!avail1 || start0 < start1) {
result.time = start0;
@@ -754,8 +753,8 @@ RuleBasedTimeZone::findNext(UDate base, UBool inclusive, UDate& transitionTime,
result.from = r0;
result.to = r1;
}
- isFinal = TRUE;
- found = TRUE;
+ isFinal = true;
+ found = true;
}
} else {
// Find a transition within the historic transitions
@@ -773,7 +772,7 @@ RuleBasedTimeZone::findNext(UDate base, UBool inclusive, UDate& transitionTime,
result.time = prev->time;
result.from = prev->from;
result.to = prev->to;
- found = TRUE;
+ found = true;
}
}
if (found) {
@@ -781,52 +780,52 @@ RuleBasedTimeZone::findNext(UDate base, UBool inclusive, UDate& transitionTime,
if (result.from->getRawOffset() == result.to->getRawOffset()
&& result.from->getDSTSavings() == result.to->getDSTSavings()) {
if (isFinal) {
- return FALSE;
+ return false;
} else {
// No offset changes. Try next one if not final
- return findNext(result.time, FALSE /* always exclusive */,
+ return findNext(result.time, false /* always exclusive */,
transitionTime, fromRule, toRule);
}
}
transitionTime = result.time;
fromRule = result.from;
toRule = result.to;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
UBool
RuleBasedTimeZone::findPrev(UDate base, UBool inclusive, UDate& transitionTime,
TimeZoneRule*& fromRule, TimeZoneRule*& toRule) const {
- if (fHistoricTransitions == NULL) {
- return FALSE;
+ if (fHistoricTransitions == nullptr) {
+ return false;
}
- UBool found = FALSE;
+ UBool found = false;
Transition result;
Transition *tzt = (Transition*)fHistoricTransitions->elementAt(0);
UDate tt = tzt->time;
if (inclusive && tt == base) {
result = *tzt;
- found = TRUE;
+ found = true;
} else if (tt < base) {
int32_t idx = fHistoricTransitions->size() - 1;
tzt = (Transition*)fHistoricTransitions->elementAt(idx);
tt = tzt->time;
if (inclusive && tt == base) {
result = *tzt;
- found = TRUE;
+ found = true;
} else if (tt < base) {
- if (fFinalRules != NULL) {
+ if (fFinalRules != nullptr) {
// Find a transion time with finalRules
TimeZoneRule *r0 = (TimeZoneRule*)fFinalRules->elementAt(0);
TimeZoneRule *r1 = (TimeZoneRule*)fFinalRules->elementAt(1);
UDate start0, start1;
UBool avail0 = r0->getPreviousStart(base, r1->getRawOffset(), r1->getDSTSavings(), inclusive, start0);
UBool avail1 = r1->getPreviousStart(base, r0->getRawOffset(), r0->getDSTSavings(), inclusive, start1);
- // avail0/avail1 should be always TRUE
+ // avail0/avail1 should be always true
if (!avail0 && !avail1) {
- return FALSE;
+ return false;
}
if (!avail1 || start0 > start1) {
result.time = start0;
@@ -840,7 +839,7 @@ RuleBasedTimeZone::findPrev(UDate base, UBool inclusive, UDate& transitionTime,
} else {
result = *tzt;
}
- found = TRUE;
+ found = true;
} else {
// Find a transition within the historic transitions
idx--;
@@ -853,7 +852,7 @@ RuleBasedTimeZone::findPrev(UDate base, UBool inclusive, UDate& transitionTime,
idx--;
}
result = *tzt;
- found = TRUE;
+ found = true;
}
}
if (found) {
@@ -861,15 +860,15 @@ RuleBasedTimeZone::findPrev(UDate base, UBool inclusive, UDate& transitionTime,
if (result.from->getRawOffset() == result.to->getRawOffset()
&& result.from->getDSTSavings() == result.to->getDSTSavings()) {
// No offset changes. Try next one if not final
- return findPrev(result.time, FALSE /* always exclusive */,
+ return findPrev(result.time, false /* always exclusive */,
transitionTime, fromRule, toRule);
}
transitionTime = result.time;
fromRule = result.from;
toRule = result.to;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
UDate
diff --git a/contrib/libs/icu/i18n/regexcmp.cpp b/contrib/libs/icu/i18n/regexcmp.cpp
index 89cb658425..0a0d095ca4 100644
--- a/contrib/libs/icu/i18n/regexcmp.cpp
+++ b/contrib/libs/icu/i18n/regexcmp.cpp
@@ -66,14 +66,14 @@ RegexCompile::RegexCompile(RegexPattern *rxp, UErrorCode &status) :
fPeekChar = -1;
fLineNum = 1;
fCharNum = 0;
- fQuoteMode = FALSE;
- fInBackslashQuote = FALSE;
+ fQuoteMode = false;
+ fInBackslashQuote = false;
fModeFlags = fRXPat->fFlags | 0x80000000;
- fEOLComments = TRUE;
+ fEOLComments = true;
fMatchOpenParen = -1;
fMatchCloseParen = -1;
- fCaptureName = NULL;
+ fCaptureName = nullptr;
fLastSetLiteral = U_SENTINEL;
if (U_SUCCESS(status) && U_FAILURE(rxp->fDeferredStatus)) {
@@ -81,8 +81,8 @@ RegexCompile::RegexCompile(RegexPattern *rxp, UErrorCode &status) :
}
}
-static const UChar chAmp = 0x26; // '&'
-static const UChar chDash = 0x2d; // '-'
+static const char16_t chAmp = 0x26; // '&'
+static const char16_t chDash = 0x2d; // '-'
//------------------------------------------------------------------------------
@@ -91,7 +91,7 @@ static const UChar chDash = 0x2d; // '-'
//
//------------------------------------------------------------------------------
RegexCompile::~RegexCompile() {
- delete fCaptureName; // Normally will be NULL, but can exist if pattern
+ delete fCaptureName; // Normally will be nullptr, but can exist if pattern
// compilation stops with a syntax error.
}
@@ -141,10 +141,10 @@ void RegexCompile::compile(
}
// There should be no pattern stuff in the RegexPattern object. They can not be reused.
- U_ASSERT(fRXPat->fPattern == NULL || utext_nativeLength(fRXPat->fPattern) == 0);
+ U_ASSERT(fRXPat->fPattern == nullptr || utext_nativeLength(fRXPat->fPattern) == 0);
// Prepare the RegexPattern object to receive the compiled pattern.
- fRXPat->fPattern = utext_clone(fRXPat->fPattern, pat, FALSE, TRUE, fStatus);
+ fRXPat->fPattern = utext_clone(fRXPat->fPattern, pat, false, true, fStatus);
if (U_FAILURE(*fStatus)) {
return;
}
@@ -156,7 +156,7 @@ void RegexCompile::compile(
// UREGEX_LITERAL force entire pattern to be treated as a literal string.
if (fModeFlags & UREGEX_LITERAL) {
- fQuoteMode = TRUE;
+ fQuoteMode = true;
}
nextChar(fC); // Fetch the first char from the pattern string.
@@ -193,7 +193,7 @@ void RegexCompile::compile(
for (;;) { // loop through table rows belonging to this state, looking for one
// that matches the current input char.
REGEX_SCAN_DEBUG_PRINTF(("."));
- if (tableEl->fCharClass < 127 && fC.fQuoted == FALSE && tableEl->fCharClass == fC.fChar) {
+ if (tableEl->fCharClass < 127 && fC.fQuoted == false && tableEl->fCharClass == fC.fChar) {
// Table row specified an individual character, not a set, and
// the input character is not quoted, and
// the input character matched it.
@@ -213,7 +213,7 @@ void RegexCompile::compile(
}
if (tableEl->fCharClass >= 128 && tableEl->fCharClass < 240 && // Table specs a char class &&
- fC.fQuoted == FALSE && // char is not escaped &&
+ fC.fQuoted == false && // char is not escaped &&
fC.fChar != (UChar32)-1) { // char is not EOF
U_ASSERT(tableEl->fCharClass <= 137);
if (RegexStaticSets::gStaticSets->fRuleSets[tableEl->fCharClass-128].contains(fC.fChar)) {
@@ -232,7 +232,7 @@ void RegexCompile::compile(
// We've found the row of the state table that matches the current input
// character from the rules string.
// Perform any action specified by this row in the state table.
- if (doParseActions(tableEl->fAction) == FALSE) {
+ if (doParseActions(tableEl->fAction) == false) {
// Break out of the state machine loop if the
// the action signalled some kind of error, or
// the action was to exit, occurs on normal end-of-rules-input.
@@ -317,7 +317,7 @@ void RegexCompile::compile(
int32_t numSets = fRXPat->fSets->size();
fRXPat->fSets8 = new Regex8BitSet[numSets];
// Null pointer check.
- if (fRXPat->fSets8 == NULL) {
+ if (fRXPat->fSets8 == nullptr) {
e = *fStatus = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -345,7 +345,7 @@ void RegexCompile::compile(
//------------------------------------------------------------------------------
UBool RegexCompile::doParseActions(int32_t action)
{
- UBool returnVal = TRUE;
+ UBool returnVal = true;
switch ((Regex_PatternParseAction)action) {
@@ -386,7 +386,7 @@ UBool RegexCompile::doParseActions(int32_t action)
appendOp(URX_END, 0);
// Terminate the pattern compilation state machine.
- returnVal = FALSE;
+ returnVal = false;
break;
@@ -395,7 +395,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// Scanning a '|', as in (A|B)
{
// Generate code for any pending literals preceding the '|'
- fixLiterals(FALSE);
+ fixLiterals(false);
// Insert a SAVE operation at the start of the pattern section preceding
// this OR at this level. This SAVE will branch the match forward
@@ -430,7 +430,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// Scanning (?<letter.
// The first letter of the name will come through again under doConinueNamedCapture.
fCaptureName = new UnicodeString();
- if (fCaptureName == NULL) {
+ if (fCaptureName == nullptr) {
error(U_MEMORY_ALLOCATION_ERROR);
}
break;
@@ -481,7 +481,7 @@ UBool RegexCompile::doParseActions(int32_t action)
fRXPat->fGroupMap->addElement(varsLoc, *fStatus);
// If this is a named capture group, add the name->group number mapping.
- if (fCaptureName != NULL) {
+ if (fCaptureName != nullptr) {
if (!fRXPat->initNamedCaptureMap()) {
if (U_SUCCESS(*fStatus)) {
error(fRXPat->fDeferredStatus);
@@ -490,7 +490,7 @@ UBool RegexCompile::doParseActions(int32_t action)
}
int32_t groupNumber = fRXPat->fGroupMap->size();
int32_t previousMapping = uhash_puti(fRXPat->fNamedCaptureMap, fCaptureName, groupNumber, fStatus);
- fCaptureName = NULL; // hash table takes ownership of the name (key) string.
+ fCaptureName = nullptr; // hash table takes ownership of the name (key) string.
if (previousMapping > 0 && U_SUCCESS(*fStatus)) {
error(U_REGEX_INVALID_CAPTURE_GROUP_NAME);
}
@@ -788,7 +788,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// 2. LOOP_SR_I set number (assuming repeated item is a set ref)
// 3. LOOP_C stack location
{
- int32_t topLoc = blockTopLoc(FALSE); // location of item #1
+ int32_t topLoc = blockTopLoc(false); // location of item #1
int32_t frameLoc;
// Check for simple constructs, which may get special optimized code.
@@ -850,7 +850,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// 2. state-save 1
// 3. ...
{
- int32_t topLoc = blockTopLoc(FALSE);
+ int32_t topLoc = blockTopLoc(false);
appendOp(URX_STATE_SAVE, topLoc);
}
break;
@@ -864,7 +864,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// 3. ...
// Insert the state save into the compiled pattern, and we're done.
{
- int32_t saveStateLoc = blockTopLoc(TRUE);
+ int32_t saveStateLoc = blockTopLoc(true);
int32_t saveStateOp = buildOp(URX_STATE_SAVE, fRXPat->fCompiledPat->size());
fRXPat->fCompiledPat->setElementAt(saveStateOp, saveStateLoc);
}
@@ -881,7 +881,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// This code is less than ideal, with two jmps instead of one, because we can only
// insert one instruction at the top of the block being iterated.
{
- int32_t jmp1_loc = blockTopLoc(TRUE);
+ int32_t jmp1_loc = blockTopLoc(true);
int32_t jmp2_loc = fRXPat->fCompiledPat->size();
int32_t jmp1_op = buildOp(URX_JMP, jmp2_loc+1);
@@ -919,7 +919,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// 5. ...
{
// location of item #1, the STATE_SAVE
- int32_t topLoc = blockTopLoc(FALSE);
+ int32_t topLoc = blockTopLoc(false);
int32_t dataLoc = -1;
// Check for simple *, where the construct being repeated
@@ -958,7 +958,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// Emit general case code for this *
// The optimizations did not apply.
- int32_t saveStateLoc = blockTopLoc(TRUE);
+ int32_t saveStateLoc = blockTopLoc(true);
int32_t jmpOp = buildOp(URX_JMP_SAV, saveStateLoc+1);
// Check for minimum match length of zero, which requires
@@ -993,7 +993,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// 3. STATE_SAVE 2
// 4 ...
{
- int32_t jmpLoc = blockTopLoc(TRUE); // loc 1.
+ int32_t jmpLoc = blockTopLoc(true); // loc 1.
int32_t saveLoc = fRXPat->fCompiledPat->size(); // loc 3.
int32_t jmpOp = buildOp(URX_JMP, saveLoc);
fRXPat->fCompiledPat->setElementAt(jmpOp, jmpLoc);
@@ -1048,7 +1048,7 @@ UBool RegexCompile::doParseActions(int32_t action)
case doInterval:
// Finished scanning a normal {lower,upper} interval. Generate the code for it.
- if (compileInlineInterval() == FALSE) {
+ if (compileInlineInterval() == false) {
compileInterval(URX_CTR_INIT, URX_CTR_LOOP);
}
break;
@@ -1060,7 +1060,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// (Can not reserve a slot in the compiled pattern at this time, because
// compileInterval needs to reserve also, and blockTopLoc can only reserve
// once per block.)
- int32_t topLoc = blockTopLoc(FALSE);
+ int32_t topLoc = blockTopLoc(false);
// Produce normal looping code.
compileInterval(URX_CTR_INIT, URX_CTR_LOOP);
@@ -1116,7 +1116,7 @@ UBool RegexCompile::doParseActions(int32_t action)
case doDotAny:
// scanned a ".", match any single character.
{
- fixLiterals(FALSE);
+ fixLiterals(false);
if (fModeFlags & UREGEX_DOTALL) {
appendOp(URX_DOTANY_ALL, 0);
} else if (fModeFlags & UREGEX_UNIX_LINES) {
@@ -1129,7 +1129,7 @@ UBool RegexCompile::doParseActions(int32_t action)
case doCaret:
{
- fixLiterals(FALSE);
+ fixLiterals(false);
if ( (fModeFlags & UREGEX_MULTILINE) == 0 && (fModeFlags & UREGEX_UNIX_LINES) == 0) {
appendOp(URX_CARET, 0);
} else if ((fModeFlags & UREGEX_MULTILINE) != 0 && (fModeFlags & UREGEX_UNIX_LINES) == 0) {
@@ -1144,7 +1144,7 @@ UBool RegexCompile::doParseActions(int32_t action)
case doDollar:
{
- fixLiterals(FALSE);
+ fixLiterals(false);
if ( (fModeFlags & UREGEX_MULTILINE) == 0 && (fModeFlags & UREGEX_UNIX_LINES) == 0) {
appendOp(URX_DOLLAR, 0);
} else if ((fModeFlags & UREGEX_MULTILINE) != 0 && (fModeFlags & UREGEX_UNIX_LINES) == 0) {
@@ -1158,7 +1158,7 @@ UBool RegexCompile::doParseActions(int32_t action)
break;
case doBackslashA:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_CARET, 0);
break;
@@ -1169,7 +1169,7 @@ UBool RegexCompile::doParseActions(int32_t action)
error(U_UNSUPPORTED_ERROR);
}
#endif
- fixLiterals(FALSE);
+ fixLiterals(false);
int32_t op = (fModeFlags & UREGEX_UWORD)? URX_BACKSLASH_BU : URX_BACKSLASH_B;
appendOp(op, 1);
}
@@ -1182,69 +1182,69 @@ UBool RegexCompile::doParseActions(int32_t action)
error(U_UNSUPPORTED_ERROR);
}
#endif
- fixLiterals(FALSE);
+ fixLiterals(false);
int32_t op = (fModeFlags & UREGEX_UWORD)? URX_BACKSLASH_BU : URX_BACKSLASH_B;
appendOp(op, 0);
}
break;
case doBackslashD:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_BACKSLASH_D, 1);
break;
case doBackslashd:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_BACKSLASH_D, 0);
break;
case doBackslashG:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_BACKSLASH_G, 0);
break;
case doBackslashH:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_BACKSLASH_H, 1);
break;
case doBackslashh:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_BACKSLASH_H, 0);
break;
case doBackslashR:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_BACKSLASH_R, 0);
break;
case doBackslashS:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_STAT_SETREF_N, URX_ISSPACE_SET);
break;
case doBackslashs:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_STATIC_SETREF, URX_ISSPACE_SET);
break;
case doBackslashV:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_BACKSLASH_V, 1);
break;
case doBackslashv:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_BACKSLASH_V, 0);
break;
case doBackslashW:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_STAT_SETREF_N, URX_ISWORD_SET);
break;
case doBackslashw:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_STATIC_SETREF, URX_ISWORD_SET);
break;
@@ -1253,17 +1253,17 @@ UBool RegexCompile::doParseActions(int32_t action)
// Grapheme Cluster Boundary requires ICU break iteration.
error(U_UNSUPPORTED_ERROR);
#endif
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_BACKSLASH_X, 0);
break;
case doBackslashZ:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_DOLLAR, 0);
break;
case doBackslashz:
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_BACKSLASH_Z, 0);
break;
@@ -1272,13 +1272,13 @@ UBool RegexCompile::doParseActions(int32_t action)
break;
case doExit:
- fixLiterals(FALSE);
- returnVal = FALSE;
+ fixLiterals(false);
+ returnVal = false;
break;
case doProperty:
{
- fixLiterals(FALSE);
+ fixLiterals(false);
UnicodeSet *theSet = scanProp();
compileSet(theSet);
}
@@ -1310,7 +1310,7 @@ UBool RegexCompile::doParseActions(int32_t action)
break;
}
c = peekCharLL();
- if (RegexStaticSets::gStaticSets->fRuleDigitsAlias->contains(c) == FALSE) {
+ if (RegexStaticSets::gStaticSets->fRuleDigitsAlias->contains(c) == false) {
break;
}
nextCharLL();
@@ -1323,7 +1323,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// of compilation, it will be changed to the variable's location.
U_ASSERT(groupNum > 0); // Shouldn't happen. '\0' begins an octal escape sequence,
// and shouldn't enter this code path at all.
- fixLiterals(FALSE);
+ fixLiterals(false);
if (fModeFlags & UREGEX_CASE_INSENSITIVE) {
appendOp(URX_BACKREF_I, groupNum);
} else {
@@ -1333,9 +1333,9 @@ UBool RegexCompile::doParseActions(int32_t action)
break;
case doBeginNamedBackRef:
- U_ASSERT(fCaptureName == NULL);
+ U_ASSERT(fCaptureName == nullptr);
fCaptureName = new UnicodeString;
- if (fCaptureName == NULL) {
+ if (fCaptureName == nullptr) {
error(U_MEMORY_ALLOCATION_ERROR);
}
break;
@@ -1356,7 +1356,7 @@ UBool RegexCompile::doParseActions(int32_t action)
} else {
// Given the number, handle identically to a \n numbered back reference.
// See comments above, under doBackRef
- fixLiterals(FALSE);
+ fixLiterals(false);
if (fModeFlags & UREGEX_CASE_INSENSITIVE) {
appendOp(URX_BACKREF_I, groupNumber);
} else {
@@ -1364,7 +1364,7 @@ UBool RegexCompile::doParseActions(int32_t action)
}
}
delete fCaptureName;
- fCaptureName = NULL;
+ fCaptureName = nullptr;
break;
}
@@ -1383,7 +1383,7 @@ UBool RegexCompile::doParseActions(int32_t action)
//
{
// Emit the STO_SP
- int32_t topLoc = blockTopLoc(TRUE);
+ int32_t topLoc = blockTopLoc(true);
int32_t stoLoc = allocateData(1); // Reserve the data location for storing save stack ptr.
int32_t op = buildOp(URX_STO_SP, stoLoc);
fRXPat->fCompiledPat->setElementAt(op, topLoc);
@@ -1411,7 +1411,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// TODO: do something to cut back the state stack each time through the loop.
{
// Reserve two slots at the top of the block.
- int32_t topLoc = blockTopLoc(TRUE);
+ int32_t topLoc = blockTopLoc(true);
insertOp(topLoc);
// emit STO_SP loc
@@ -1443,7 +1443,7 @@ UBool RegexCompile::doParseActions(int32_t action)
//
{
// Reserve two slots at the top of the block.
- int32_t topLoc = blockTopLoc(TRUE);
+ int32_t topLoc = blockTopLoc(true);
insertOp(topLoc);
// Emit the STO_SP
@@ -1464,7 +1464,7 @@ UBool RegexCompile::doParseActions(int32_t action)
case doBeginMatchMode:
fNewModeFlags = fModeFlags;
- fSetModeFlag = TRUE;
+ fSetModeFlag = true;
break;
case doMatchMode: // (?i) and similar
@@ -1478,7 +1478,7 @@ UBool RegexCompile::doParseActions(int32_t action)
case 0x75: /* 'u' */ bit = 0; /* Unicode casing */ break;
case 0x77: /* 'w' */ bit = UREGEX_UWORD; break;
case 0x78: /* 'x' */ bit = UREGEX_COMMENTS; break;
- case 0x2d: /* '-' */ fSetModeFlag = FALSE; break;
+ case 0x2d: /* '-' */ fSetModeFlag = false; break;
default:
UPRV_UNREACHABLE_EXIT; // Should never happen. Other chars are filtered out
// by the scanner.
@@ -1513,7 +1513,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// - NOP, which may later be replaced by a save-state if there
// is an '|' alternation within the parens.
{
- fixLiterals(FALSE);
+ fixLiterals(false);
appendOp(URX_NOP, 0);
appendOp(URX_NOP, 0);
@@ -1539,7 +1539,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// We have just scanned a '(?'. We now need to prevent the character scanner from
// treating a '#' as a to-the-end-of-line comment.
// (This Perl compatibility just gets uglier and uglier to do...)
- fEOLComments = FALSE;
+ fEOLComments = false;
break;
@@ -1652,7 +1652,7 @@ UBool RegexCompile::doParseActions(int32_t action)
case doSetBegin:
{
- fixLiterals(FALSE);
+ fixLiterals(false);
LocalPointer<UnicodeSet> lpSet(new UnicodeSet(), *fStatus);
fSetStack.push(lpSet.orphan(), *fStatus);
fSetOpStack.push(setStart, *fStatus);
@@ -1820,7 +1820,7 @@ UBool RegexCompile::doParseActions(int32_t action)
case doSetPosixProp:
{
UnicodeSet *s = scanPosixProp();
- if (s != NULL) {
+ if (s != nullptr) {
UnicodeSet *tos = (UnicodeSet *)fSetStack.peek();
tos->addAll(*s);
delete s;
@@ -1832,7 +1832,7 @@ UBool RegexCompile::doParseActions(int32_t action)
// Scanned a \p \P within [brackets].
{
UnicodeSet *s = scanProp();
- if (s != NULL) {
+ if (s != nullptr) {
UnicodeSet *tos = (UnicodeSet *)fSetStack.peek();
tos->addAll(*s);
delete s;
@@ -1862,7 +1862,7 @@ UBool RegexCompile::doParseActions(int32_t action)
}
if (U_FAILURE(*fStatus)) {
- returnVal = FALSE;
+ returnVal = false;
}
return returnVal;
@@ -1913,12 +1913,12 @@ void RegexCompile::fixLiterals(UBool split) {
if (split) {
fLiteralChars.truncate(indexOfLastCodePoint);
- fixLiterals(FALSE); // Recursive call, emit code to match the first part of the string.
+ fixLiterals(false); // Recursive call, emit code to match the first part of the string.
// Note that the truncated literal string may be empty, in which case
// nothing will be emitted.
literalChar(lastCodePoint); // Re-add the last code point as if it were a new literal.
- fixLiterals(FALSE); // Second recursive call, code for the final code point.
+ fixLiterals(false); // Second recursive call, code for the final code point.
return;
}
@@ -2130,15 +2130,15 @@ int32_t RegexCompile::allocateStackData(int32_t size) {
// is reserved for this purpose. .* or similar don't
// and a slot needs to be added.
//
-// parameter reserveLoc : TRUE - ensure that there is space to add an opcode
+// parameter reserveLoc : true - ensure that there is space to add an opcode
// at the returned location.
-// FALSE - just return the address,
+// false - just return the address,
// do not reserve a location there.
//
//------------------------------------------------------------------------------
int32_t RegexCompile::blockTopLoc(UBool reserveLoc) {
int32_t theLoc;
- fixLiterals(TRUE); // Emit code for any pending literals.
+ fixLiterals(true); // Emit code for any pending literals.
// If last item was a string, emit separate op for the its last char.
if (fRXPat->fCompiledPat->size() == fMatchCloseParen)
{
@@ -2189,7 +2189,7 @@ void RegexCompile::handleCloseParen() {
}
// Emit code for any pending literals.
- fixLiterals(FALSE);
+ fixLiterals(false);
// Fixup any operations within the just-closed parenthesized group
// that need to reference the end of the (block).
@@ -2390,7 +2390,7 @@ void RegexCompile::handleCloseParen() {
//------------------------------------------------------------------------------
void RegexCompile::compileSet(UnicodeSet *theSet)
{
- if (theSet == NULL) {
+ if (theSet == nullptr) {
return;
}
// Remove any strings from the set.
@@ -2459,7 +2459,7 @@ void RegexCompile::compileInterval(int32_t InitOp, int32_t LoopOp)
{
// The CTR_INIT op at the top of the block with the {n,m} quantifier takes
// four slots in the compiled code. Reserve them.
- int32_t topOfBlock = blockTopLoc(TRUE);
+ int32_t topOfBlock = blockTopLoc(true);
insertOp(topOfBlock);
insertOp(topOfBlock);
insertOp(topOfBlock);
@@ -2507,10 +2507,10 @@ UBool RegexCompile::compileInlineInterval() {
if (fIntervalUpper > 10 || fIntervalUpper < fIntervalLow) {
// Too big to inline. Fail, which will cause looping code to be generated.
// (Upper < Lower picks up unbounded upper and errors, both.)
- return FALSE;
+ return false;
}
- int32_t topOfBlock = blockTopLoc(FALSE);
+ int32_t topOfBlock = blockTopLoc(false);
if (fIntervalUpper == 0) {
// Pathological case. Attempt no matches, as if the block doesn't exist.
// Discard the generated code for the block.
@@ -2522,7 +2522,7 @@ UBool RegexCompile::compileInlineInterval() {
if (fMatchCloseParen >= topOfBlock) {
fMatchCloseParen = -1;
}
- return TRUE;
+ return true;
}
if (topOfBlock != fRXPat->fCompiledPat->size()-1 && fIntervalUpper != 1) {
@@ -2530,7 +2530,7 @@ UBool RegexCompile::compileInlineInterval() {
// more complex block. Do it as a loop, not inlines.
// Note that things "repeated" a max of once are handled as inline, because
// the one copy of the code already generated is just fine.
- return FALSE;
+ return false;
}
// Pick up the opcode that is to be repeated
@@ -2560,7 +2560,7 @@ UBool RegexCompile::compileInlineInterval() {
}
appendOp(op);
}
- return TRUE;
+ return true;
}
@@ -2620,7 +2620,7 @@ void RegexCompile::findCaseInsensitiveStarters(UChar32 c, UnicodeSet *starterCh
0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2,
0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x1, 0x1, 0x1, 0};
- static const UChar RECaseFixData[] = {
+ static const char16_t RECaseFixData[] = {
0x1e9a, 0xfb00, 0xfb01, 0xfb02, 0xfb03, 0xfb04, 0x1e96, 0x130, 0x1f0, 0xdf,
0x1e9e, 0xfb05, 0xfb06, 0x1e97, 0x1e98, 0x1e99, 0x149, 0x1fb4, 0x1fc4, 0x1fb3,
0x1fb6, 0x1fb7, 0x1fbc, 0x1fc3, 0x1fc6, 0x1fc7, 0x1fcc, 0x390, 0x1fd2, 0x1fd3,
@@ -2701,7 +2701,7 @@ void RegexCompile::matchStartType() {
int32_t currentLen = 0; // Minimum length of a match to this point (loc) in the pattern
int32_t numInitialStrings = 0; // Number of strings encountered that could match at start.
- UBool atStart = TRUE; // True if no part of the pattern yet encountered
+ UBool atStart = true; // True if no part of the pattern yet encountered
// could have advanced the position in a match.
// (Maximum match length so far == 0)
@@ -2777,7 +2777,7 @@ void RegexCompile::matchStartType() {
numInitialStrings += 2;
}
currentLen = safeIncrement(currentLen, 1);
- atStart = FALSE;
+ atStart = false;
break;
@@ -2790,7 +2790,7 @@ void RegexCompile::matchStartType() {
numInitialStrings += 2;
}
currentLen = safeIncrement(currentLen, 1);
- atStart = FALSE;
+ atStart = false;
break;
case URX_LOOP_SR_I:
@@ -2803,7 +2803,7 @@ void RegexCompile::matchStartType() {
fRXPat->fInitialChars->addAll(*s);
numInitialStrings += 2;
}
- atStart = FALSE;
+ atStart = false;
break;
case URX_LOOP_DOT_I:
@@ -2814,7 +2814,7 @@ void RegexCompile::matchStartType() {
fRXPat->fInitialChars->complement();
numInitialStrings += 2;
}
- atStart = FALSE;
+ atStart = false;
break;
@@ -2827,7 +2827,7 @@ void RegexCompile::matchStartType() {
numInitialStrings += 2;
}
currentLen = safeIncrement(currentLen, 1);
- atStart = FALSE;
+ atStart = false;
break;
@@ -2841,7 +2841,7 @@ void RegexCompile::matchStartType() {
numInitialStrings += 2;
}
currentLen = safeIncrement(currentLen, 1);
- atStart = FALSE;
+ atStart = false;
break;
@@ -2858,7 +2858,7 @@ void RegexCompile::matchStartType() {
numInitialStrings += 2;
}
currentLen = safeIncrement(currentLen, 1);
- atStart = FALSE;
+ atStart = false;
break;
@@ -2875,7 +2875,7 @@ void RegexCompile::matchStartType() {
numInitialStrings += 2;
}
currentLen = safeIncrement(currentLen, 1);
- atStart = FALSE;
+ atStart = false;
break;
@@ -2894,7 +2894,7 @@ void RegexCompile::matchStartType() {
numInitialStrings += 2;
}
currentLen = safeIncrement(currentLen, 1);
- atStart = FALSE;
+ atStart = false;
break;
@@ -2918,7 +2918,7 @@ void RegexCompile::matchStartType() {
numInitialStrings += 2;
}
currentLen = safeIncrement(currentLen, 1);
- atStart = FALSE;
+ atStart = false;
break;
@@ -2934,7 +2934,7 @@ void RegexCompile::matchStartType() {
numInitialStrings += 2;
}
currentLen = safeIncrement(currentLen, 1);
- atStart = FALSE;
+ atStart = false;
break;
@@ -2957,21 +2957,21 @@ void RegexCompile::matchStartType() {
}
}
}
- atStart = FALSE;
+ atStart = false;
break;
case URX_JMP_SAV:
case URX_JMP_SAV_X:
// Combo of state save to the next loc, + jmp backwards.
// Net effect on min. length computation is nothing.
- atStart = FALSE;
+ atStart = false;
break;
case URX_BACKTRACK:
// Fails are kind of like a branch, except that the min length was
// propagated already, by the state save.
currentLen = forwardedLength.elementAti(loc+1);
- atStart = FALSE;
+ atStart = false;
break;
@@ -2986,7 +2986,7 @@ void RegexCompile::matchStartType() {
}
}
}
- atStart = FALSE;
+ atStart = false;
break;
@@ -3014,7 +3014,7 @@ void RegexCompile::matchStartType() {
}
currentLen = safeIncrement(currentLen, stringLen);
- atStart = FALSE;
+ atStart = false;
}
break;
@@ -3039,7 +3039,7 @@ void RegexCompile::matchStartType() {
numInitialStrings += 2; // Matching on an initial string not possible.
}
currentLen = safeIncrement(currentLen, stringLen);
- atStart = FALSE;
+ atStart = false;
}
break;
@@ -3067,7 +3067,7 @@ void RegexCompile::matchStartType() {
}
loc+=3; // Skips over operands of CTR_INIT
}
- atStart = FALSE;
+ atStart = false;
break;
@@ -3075,13 +3075,13 @@ void RegexCompile::matchStartType() {
case URX_CTR_LOOP_NG:
// Loop ops.
// The jump is conditional, backwards only.
- atStart = FALSE;
+ atStart = false;
break;
case URX_LOOP_C:
// More loop ops. These state-save to themselves.
// don't change the minimum match
- atStart = FALSE;
+ atStart = false;
break;
@@ -3177,7 +3177,7 @@ void RegexCompile::matchStartType() {
fRXPat->fStartType = START_CHAR;
fRXPat->fInitialChar = fRXPat->fInitialChars->charAt(0);
U_ASSERT(fRXPat->fInitialChar != (UChar32)-1);
- } else if (fRXPat->fInitialChars->contains((UChar32)0, (UChar32)0x10ffff) == FALSE &&
+ } else if (fRXPat->fInitialChars->contains((UChar32)0, (UChar32)0x10ffff) == false &&
fRXPat->fMinMatchLen > 0) {
// Matches start with a set of character smaller than the set of all chars.
fRXPat->fStartType = START_SET;
@@ -3834,7 +3834,7 @@ void RegexCompile::stripNOPs() {
fRXPat->fCompiledPat->setElementAt(op, dst);
dst++;
- fRXPat->fNeedsAltInput = TRUE;
+ fRXPat->fNeedsAltInput = true;
break;
}
case URX_RESERVED_OP:
@@ -3944,25 +3944,25 @@ void RegexCompile::error(UErrorCode e) {
// Numeric because there is no portable way to enter them as literals.
// (Think EBCDIC).
//
-static const UChar chCR = 0x0d; // New lines, for terminating comments.
-static const UChar chLF = 0x0a; // Line Feed
-static const UChar chPound = 0x23; // '#', introduces a comment.
-static const UChar chDigit0 = 0x30; // '0'
-static const UChar chDigit7 = 0x37; // '9'
-static const UChar chColon = 0x3A; // ':'
-static const UChar chE = 0x45; // 'E'
-static const UChar chQ = 0x51; // 'Q'
-//static const UChar chN = 0x4E; // 'N'
-static const UChar chP = 0x50; // 'P'
-static const UChar chBackSlash = 0x5c; // '\' introduces a char escape
-//static const UChar chLBracket = 0x5b; // '['
-static const UChar chRBracket = 0x5d; // ']'
-static const UChar chUp = 0x5e; // '^'
-static const UChar chLowerP = 0x70;
-static const UChar chLBrace = 0x7b; // '{'
-static const UChar chRBrace = 0x7d; // '}'
-static const UChar chNEL = 0x85; // NEL newline variant
-static const UChar chLS = 0x2028; // Unicode Line Separator
+static const char16_t chCR = 0x0d; // New lines, for terminating comments.
+static const char16_t chLF = 0x0a; // Line Feed
+static const char16_t chPound = 0x23; // '#', introduces a comment.
+static const char16_t chDigit0 = 0x30; // '0'
+static const char16_t chDigit7 = 0x37; // '9'
+static const char16_t chColon = 0x3A; // ':'
+static const char16_t chE = 0x45; // 'E'
+static const char16_t chQ = 0x51; // 'Q'
+//static const char16_t chN = 0x4E; // 'N'
+static const char16_t chP = 0x50; // 'P'
+static const char16_t chBackSlash = 0x5c; // '\' introduces a char escape
+//static const char16_t chLBracket = 0x5b; // '['
+static const char16_t chRBracket = 0x5d; // ']'
+static const char16_t chUp = 0x5e; // '^'
+static const char16_t chLowerP = 0x70;
+static const char16_t chLBrace = 0x7b; // '{'
+static const char16_t chRBrace = 0x7d; // '}'
+static const char16_t chNEL = 0x85; // NEL newline variant
+static const char16_t chLS = 0x2028; // Unicode Line Separator
//------------------------------------------------------------------------------
@@ -4032,13 +4032,13 @@ void RegexCompile::nextChar(RegexPatternChar &c) {
tailRecursion:
fScanIndex = UTEXT_GETNATIVEINDEX(fRXPat->fPattern);
c.fChar = nextCharLL();
- c.fQuoted = FALSE;
+ c.fQuoted = false;
if (fQuoteMode) {
- c.fQuoted = TRUE;
+ c.fQuoted = true;
if ((c.fChar==chBackSlash && peekCharLL()==chE && ((fModeFlags & UREGEX_LITERAL) == 0)) ||
c.fChar == (UChar32)-1) {
- fQuoteMode = FALSE; // Exit quote mode,
+ fQuoteMode = false; // Exit quote mode,
nextCharLL(); // discard the E
// nextChar(c); // recurse to get the real next char
goto tailRecursion; // Note: fuzz testing produced testcases that
@@ -4050,7 +4050,7 @@ void RegexCompile::nextChar(RegexPatternChar &c) {
// Don't check for any further escapes, just return it as-is.
// Don't set c.fQuoted, because that would prevent the state machine from
// dispatching on the character.
- fInBackslashQuote = FALSE;
+ fInBackslashQuote = false;
}
else
{
@@ -4065,7 +4065,7 @@ void RegexCompile::nextChar(RegexPatternChar &c) {
if (c.fChar == (UChar32)-1) {
break; // End of Input
}
- if (c.fChar == chPound && fEOLComments == TRUE) {
+ if (c.fChar == chPound && fEOLComments) {
// Start of a comment. Consume the rest of it, until EOF or a new line
for (;;) {
c.fChar = nextCharLL();
@@ -4079,7 +4079,7 @@ void RegexCompile::nextChar(RegexPatternChar &c) {
}
}
// TODO: check what Java & Perl do with non-ASCII white spaces. Ticket 6061.
- if (PatternProps::isWhiteSpace(c.fChar) == FALSE) {
+ if (PatternProps::isWhiteSpace(c.fChar) == false) {
break;
}
c.fChar = nextCharLL();
@@ -4098,7 +4098,7 @@ void RegexCompile::nextChar(RegexPatternChar &c) {
// Return the single equivalent character.
//
nextCharLL(); // get & discard the peeked char.
- c.fQuoted = TRUE;
+ c.fQuoted = true;
if (UTEXT_FULL_TEXT_IN_CHUNK(fRXPat->fPattern, fPatternLength)) {
int32_t endIndex = (int32_t)pos;
@@ -4155,11 +4155,11 @@ void RegexCompile::nextChar(RegexPatternChar &c) {
c.fChar >>= 3;
}
}
- c.fQuoted = TRUE;
+ c.fQuoted = true;
}
else if (peekCharLL() == chQ) {
// "\Q" enter quote mode, which will continue until "\E"
- fQuoteMode = TRUE;
+ fQuoteMode = true;
nextCharLL(); // discard the 'Q'.
// nextChar(c); // recurse to get the real next char.
goto tailRecursion; // Note: fuzz testing produced test cases that
@@ -4170,7 +4170,7 @@ void RegexCompile::nextChar(RegexPatternChar &c) {
// We are in a '\' escape that will be handled by the state table scanner.
// Just return the backslash, but remember that the following char is to
// be taken literally.
- fInBackslashQuote = TRUE;
+ fInBackslashQuote = true;
}
}
}
@@ -4178,7 +4178,7 @@ void RegexCompile::nextChar(RegexPatternChar &c) {
// re-enable # to end-of-line comments, in case they were disabled.
// They are disabled by the parser upon seeing '(?', but this lasts for
// the fetching of the next character only.
- fEOLComments = TRUE;
+ fEOLComments = true;
// putc(c.fChar, stdout);
}
@@ -4249,14 +4249,14 @@ UChar32 RegexCompile::scanNamedChar() {
// the scan position should be just after the '}'
//
// Return a UnicodeSet, constructed from the \P pattern,
-// or NULL if the pattern is invalid.
+// or nullptr if the pattern is invalid.
//
//------------------------------------------------------------------------------
UnicodeSet *RegexCompile::scanProp() {
- UnicodeSet *uset = NULL;
+ UnicodeSet *uset = nullptr;
if (U_FAILURE(*fStatus)) {
- return NULL;
+ return nullptr;
}
(void)chLowerP; // Suppress compiler unused variable warning.
U_ASSERT(fC.fChar == chLowerP || fC.fChar == chP);
@@ -4266,7 +4266,7 @@ UnicodeSet *RegexCompile::scanProp() {
nextChar(fC);
if (fC.fChar != chLBrace) {
error(U_REGEX_PROPERTY_SYNTAX);
- return NULL;
+ return nullptr;
}
for (;;) {
nextChar(fC);
@@ -4276,7 +4276,7 @@ UnicodeSet *RegexCompile::scanProp() {
if (fC.fChar == -1) {
// Hit the end of the input string without finding the closing '}'
error(U_REGEX_PROPERTY_SYNTAX);
- return NULL;
+ return nullptr;
}
propertyName.append(fC.fChar);
}
@@ -4294,7 +4294,7 @@ UnicodeSet *RegexCompile::scanProp() {
// the scan position must be on the closing ']'
//
// Return a UnicodeSet constructed from the pattern,
-// or NULL if this is not a valid POSIX-style set expression.
+// or nullptr if this is not a valid POSIX-style set expression.
// If not a property expression, restore the initial scan position
// (to the opening ':')
//
@@ -4305,10 +4305,10 @@ UnicodeSet *RegexCompile::scanProp() {
//
//------------------------------------------------------------------------------
UnicodeSet *RegexCompile::scanPosixProp() {
- UnicodeSet *uset = NULL;
+ UnicodeSet *uset = nullptr;
if (U_FAILURE(*fStatus)) {
- return NULL;
+ return nullptr;
}
U_ASSERT(fC.fChar == chColon);
@@ -4331,17 +4331,17 @@ UnicodeSet *RegexCompile::scanPosixProp() {
// ending on the second closing ].
UnicodeString propName;
- UBool negated = FALSE;
+ UBool negated = false;
// Check for and consume the '^' in a negated POSIX property, e.g. [:^Letter:]
nextChar(fC);
if (fC.fChar == chUp) {
- negated = TRUE;
+ negated = true;
nextChar(fC);
}
// Scan for the closing ":]", collecting the property name along the way.
- UBool sawPropSetTerminator = FALSE;
+ UBool sawPropSetTerminator = false;
for (;;) {
propName.append(fC.fChar);
nextChar(fC);
@@ -4352,7 +4352,7 @@ UnicodeSet *RegexCompile::scanPosixProp() {
if (fC.fChar == chColon) {
nextChar(fC);
if (fC.fChar == chRBracket) {
- sawPropSetTerminator = TRUE;
+ sawPropSetTerminator = true;
}
break;
}
@@ -4412,7 +4412,7 @@ UnicodeSet *RegexCompile::createSetForProperty(const UnicodeString &propName, UB
if (fModeFlags & UREGEX_CASE_INSENSITIVE) {
usetFlags |= USET_CASE_INSENSITIVE;
}
- set.adoptInsteadAndCheckErrorCode(new UnicodeSet(setExpr, usetFlags, NULL, status), status);
+ set.adoptInsteadAndCheckErrorCode(new UnicodeSet(setExpr, usetFlags, nullptr, status), status);
if (U_SUCCESS(status) || status == U_MEMORY_ALLOCATION_ERROR) {
break;
}
@@ -4610,16 +4610,16 @@ UnicodeSet *RegexCompile::createSetForProperty(const UnicodeString &propName, UB
// in the expression.
//
void RegexCompile::setEval(int32_t nextOp) {
- UnicodeSet *rightOperand = NULL;
- UnicodeSet *leftOperand = NULL;
+ UnicodeSet *rightOperand = nullptr;
+ UnicodeSet *leftOperand = nullptr;
for (;;) {
- U_ASSERT(fSetOpStack.empty()==FALSE);
+ U_ASSERT(fSetOpStack.empty()==false);
int32_t pendingSetOperation = fSetOpStack.peeki();
if ((pendingSetOperation&0xffff0000) < (nextOp&0xffff0000)) {
break;
}
fSetOpStack.popi();
- U_ASSERT(fSetStack.empty() == FALSE);
+ U_ASSERT(fSetStack.empty() == false);
rightOperand = (UnicodeSet *)fSetStack.peek();
// ICU 70 adds emoji properties of strings, but createSetForProperty() removes all strings
// (see comments there).
diff --git a/contrib/libs/icu/i18n/regexcmp.h b/contrib/libs/icu/i18n/regexcmp.h
index 9e1aa170f0..81ac9e5178 100644
--- a/contrib/libs/icu/i18n/regexcmp.h
+++ b/contrib/libs/icu/i18n/regexcmp.h
@@ -37,7 +37,6 @@ U_NAMESPACE_BEGIN
// class RegexCompile Contains the regular expression compiler.
//
//--------------------------------------------------------------------------------
-struct RegexTableEl;
class RegexPattern;
@@ -65,9 +64,6 @@ public:
void nextChar(RegexPatternChar &c); // Get the next char from the input stream.
- static void cleanup(); // Memory cleanup
-
-
// Categories of parentheses in pattern.
// The category is saved in the compile-time parentheses stack frame, and
@@ -154,12 +150,6 @@ private:
RegexPatternChar fC; // Current char for parse state machine
// processing.
- //
- // Data for the state machine that parses the regular expression.
- //
- RegexTableEl **fStateTable; // State Transition Table for regex Rule
- // parsing. index by p[state][char-class]
-
uint16_t fStack[kStackSize]; // State stack, holds state pushes
int32_t fStackPtr; // and pops as specified in the state
// transition rules.
@@ -211,10 +201,6 @@ private:
// -1 for the upper interval value means none
// was specified (unlimited occurrences.)
- int64_t fNameStartPos; // Starting position of a \N{NAME} name in a
- // pattern, valid while remainder of name is
- // scanned.
-
UStack fSetStack; // Stack of UnicodeSets, used while evaluating
// (at compile time) set expressions within
// the pattern.
diff --git a/contrib/libs/icu/i18n/regexcst.h b/contrib/libs/icu/i18n/regexcst.h
index d44c2aec2b..a475b6b363 100644
--- a/contrib/libs/icu/i18n/regexcst.h
+++ b/contrib/libs/icu/i18n/regexcst.h
@@ -149,213 +149,213 @@ struct RegexTableEl {
};
static const struct RegexTableEl gRuleParseStateTable[] = {
- {doNOP, 0, 0, 0, TRUE}
- , {doPatStart, 255, 2,0, FALSE} // 1 start
- , {doLiteralChar, 254, 14,0, TRUE} // 2 term
- , {doLiteralChar, 130, 14,0, TRUE} // 3
- , {doSetBegin, 91 /* [ */, 123, 205, TRUE} // 4
- , {doNOP, 40 /* ( */, 27,0, TRUE} // 5
- , {doDotAny, 46 /* . */, 14,0, TRUE} // 6
- , {doCaret, 94 /* ^ */, 14,0, TRUE} // 7
- , {doDollar, 36 /* $ */, 14,0, TRUE} // 8
- , {doNOP, 92 /* \ */, 89,0, TRUE} // 9
- , {doOrOperator, 124 /* | */, 2,0, TRUE} // 10
- , {doCloseParen, 41 /* ) */, 255,0, TRUE} // 11
- , {doPatFinish, 253, 2,0, FALSE} // 12
- , {doRuleError, 255, 206,0, FALSE} // 13
- , {doNOP, 42 /* * */, 68,0, TRUE} // 14 expr-quant
- , {doNOP, 43 /* + */, 71,0, TRUE} // 15
- , {doNOP, 63 /* ? */, 74,0, TRUE} // 16
- , {doIntervalInit, 123 /* { */, 77,0, TRUE} // 17
- , {doNOP, 40 /* ( */, 23,0, TRUE} // 18
- , {doNOP, 255, 20,0, FALSE} // 19
- , {doOrOperator, 124 /* | */, 2,0, TRUE} // 20 expr-cont
- , {doCloseParen, 41 /* ) */, 255,0, TRUE} // 21
- , {doNOP, 255, 2,0, FALSE} // 22
- , {doSuppressComments, 63 /* ? */, 25,0, TRUE} // 23 open-paren-quant
- , {doNOP, 255, 27,0, FALSE} // 24
- , {doNOP, 35 /* # */, 50, 14, TRUE} // 25 open-paren-quant2
- , {doNOP, 255, 29,0, FALSE} // 26
- , {doSuppressComments, 63 /* ? */, 29,0, TRUE} // 27 open-paren
- , {doOpenCaptureParen, 255, 2, 14, FALSE} // 28
- , {doOpenNonCaptureParen, 58 /* : */, 2, 14, TRUE} // 29 open-paren-extended
- , {doOpenAtomicParen, 62 /* > */, 2, 14, TRUE} // 30
- , {doOpenLookAhead, 61 /* = */, 2, 20, TRUE} // 31
- , {doOpenLookAheadNeg, 33 /* ! */, 2, 20, TRUE} // 32
- , {doNOP, 60 /* < */, 46,0, TRUE} // 33
- , {doNOP, 35 /* # */, 50, 2, TRUE} // 34
- , {doBeginMatchMode, 105 /* i */, 53,0, FALSE} // 35
- , {doBeginMatchMode, 100 /* d */, 53,0, FALSE} // 36
- , {doBeginMatchMode, 109 /* m */, 53,0, FALSE} // 37
- , {doBeginMatchMode, 115 /* s */, 53,0, FALSE} // 38
- , {doBeginMatchMode, 117 /* u */, 53,0, FALSE} // 39
- , {doBeginMatchMode, 119 /* w */, 53,0, FALSE} // 40
- , {doBeginMatchMode, 120 /* x */, 53,0, FALSE} // 41
- , {doBeginMatchMode, 45 /* - */, 53,0, FALSE} // 42
- , {doConditionalExpr, 40 /* ( */, 206,0, TRUE} // 43
- , {doPerlInline, 123 /* { */, 206,0, TRUE} // 44
- , {doBadOpenParenType, 255, 206,0, FALSE} // 45
- , {doOpenLookBehind, 61 /* = */, 2, 20, TRUE} // 46 open-paren-lookbehind
- , {doOpenLookBehindNeg, 33 /* ! */, 2, 20, TRUE} // 47
- , {doBeginNamedCapture, 129, 64,0, FALSE} // 48
- , {doBadOpenParenType, 255, 206,0, FALSE} // 49
- , {doNOP, 41 /* ) */, 255,0, TRUE} // 50 paren-comment
- , {doMismatchedParenErr, 253, 206,0, FALSE} // 51
- , {doNOP, 255, 50,0, TRUE} // 52
- , {doMatchMode, 105 /* i */, 53,0, TRUE} // 53 paren-flag
- , {doMatchMode, 100 /* d */, 53,0, TRUE} // 54
- , {doMatchMode, 109 /* m */, 53,0, TRUE} // 55
- , {doMatchMode, 115 /* s */, 53,0, TRUE} // 56
- , {doMatchMode, 117 /* u */, 53,0, TRUE} // 57
- , {doMatchMode, 119 /* w */, 53,0, TRUE} // 58
- , {doMatchMode, 120 /* x */, 53,0, TRUE} // 59
- , {doMatchMode, 45 /* - */, 53,0, TRUE} // 60
- , {doSetMatchMode, 41 /* ) */, 2,0, TRUE} // 61
- , {doMatchModeParen, 58 /* : */, 2, 14, TRUE} // 62
- , {doBadModeFlag, 255, 206,0, FALSE} // 63
- , {doContinueNamedCapture, 129, 64,0, TRUE} // 64 named-capture
- , {doContinueNamedCapture, 128, 64,0, TRUE} // 65
- , {doOpenCaptureParen, 62 /* > */, 2, 14, TRUE} // 66
- , {doBadNamedCapture, 255, 206,0, FALSE} // 67
- , {doNGStar, 63 /* ? */, 20,0, TRUE} // 68 quant-star
- , {doPossessiveStar, 43 /* + */, 20,0, TRUE} // 69
- , {doStar, 255, 20,0, FALSE} // 70
- , {doNGPlus, 63 /* ? */, 20,0, TRUE} // 71 quant-plus
- , {doPossessivePlus, 43 /* + */, 20,0, TRUE} // 72
- , {doPlus, 255, 20,0, FALSE} // 73
- , {doNGOpt, 63 /* ? */, 20,0, TRUE} // 74 quant-opt
- , {doPossessiveOpt, 43 /* + */, 20,0, TRUE} // 75
- , {doOpt, 255, 20,0, FALSE} // 76
- , {doNOP, 128, 79,0, FALSE} // 77 interval-open
- , {doIntervalError, 255, 206,0, FALSE} // 78
- , {doIntevalLowerDigit, 128, 79,0, TRUE} // 79 interval-lower
- , {doNOP, 44 /* , */, 83,0, TRUE} // 80
- , {doIntervalSame, 125 /* } */, 86,0, TRUE} // 81
- , {doIntervalError, 255, 206,0, FALSE} // 82
- , {doIntervalUpperDigit, 128, 83,0, TRUE} // 83 interval-upper
- , {doNOP, 125 /* } */, 86,0, TRUE} // 84
- , {doIntervalError, 255, 206,0, FALSE} // 85
- , {doNGInterval, 63 /* ? */, 20,0, TRUE} // 86 interval-type
- , {doPossessiveInterval, 43 /* + */, 20,0, TRUE} // 87
- , {doInterval, 255, 20,0, FALSE} // 88
- , {doBackslashA, 65 /* A */, 2,0, TRUE} // 89 backslash
- , {doBackslashB, 66 /* B */, 2,0, TRUE} // 90
- , {doBackslashb, 98 /* b */, 2,0, TRUE} // 91
- , {doBackslashd, 100 /* d */, 14,0, TRUE} // 92
- , {doBackslashD, 68 /* D */, 14,0, TRUE} // 93
- , {doBackslashG, 71 /* G */, 2,0, TRUE} // 94
- , {doBackslashh, 104 /* h */, 14,0, TRUE} // 95
- , {doBackslashH, 72 /* H */, 14,0, TRUE} // 96
- , {doNOP, 107 /* k */, 115,0, TRUE} // 97
- , {doNamedChar, 78 /* N */, 14,0, FALSE} // 98
- , {doProperty, 112 /* p */, 14,0, FALSE} // 99
- , {doProperty, 80 /* P */, 14,0, FALSE} // 100
- , {doBackslashR, 82 /* R */, 14,0, TRUE} // 101
- , {doEnterQuoteMode, 81 /* Q */, 2,0, TRUE} // 102
- , {doBackslashS, 83 /* S */, 14,0, TRUE} // 103
- , {doBackslashs, 115 /* s */, 14,0, TRUE} // 104
- , {doBackslashv, 118 /* v */, 14,0, TRUE} // 105
- , {doBackslashV, 86 /* V */, 14,0, TRUE} // 106
- , {doBackslashW, 87 /* W */, 14,0, TRUE} // 107
- , {doBackslashw, 119 /* w */, 14,0, TRUE} // 108
- , {doBackslashX, 88 /* X */, 14,0, TRUE} // 109
- , {doBackslashZ, 90 /* Z */, 2,0, TRUE} // 110
- , {doBackslashz, 122 /* z */, 2,0, TRUE} // 111
- , {doBackRef, 128, 14,0, TRUE} // 112
- , {doEscapeError, 253, 206,0, FALSE} // 113
- , {doEscapedLiteralChar, 255, 14,0, TRUE} // 114
- , {doBeginNamedBackRef, 60 /* < */, 117,0, TRUE} // 115 named-backref
- , {doBadNamedCapture, 255, 206,0, FALSE} // 116
- , {doContinueNamedBackRef, 129, 119,0, TRUE} // 117 named-backref-2
- , {doBadNamedCapture, 255, 206,0, FALSE} // 118
- , {doContinueNamedBackRef, 129, 119,0, TRUE} // 119 named-backref-3
- , {doContinueNamedBackRef, 128, 119,0, TRUE} // 120
- , {doCompleteNamedBackRef, 62 /* > */, 14,0, TRUE} // 121
- , {doBadNamedCapture, 255, 206,0, FALSE} // 122
- , {doSetNegate, 94 /* ^ */, 126,0, TRUE} // 123 set-open
- , {doSetPosixProp, 58 /* : */, 128,0, FALSE} // 124
- , {doNOP, 255, 126,0, FALSE} // 125
- , {doSetLiteral, 93 /* ] */, 141,0, TRUE} // 126 set-open2
- , {doNOP, 255, 131,0, FALSE} // 127
- , {doSetEnd, 93 /* ] */, 255,0, TRUE} // 128 set-posix
- , {doNOP, 58 /* : */, 131,0, FALSE} // 129
- , {doRuleError, 255, 206,0, FALSE} // 130
- , {doSetEnd, 93 /* ] */, 255,0, TRUE} // 131 set-start
- , {doSetBeginUnion, 91 /* [ */, 123, 148, TRUE} // 132
- , {doNOP, 92 /* \ */, 191,0, TRUE} // 133
- , {doNOP, 45 /* - */, 137,0, TRUE} // 134
- , {doNOP, 38 /* & */, 139,0, TRUE} // 135
- , {doSetLiteral, 255, 141,0, TRUE} // 136
- , {doRuleError, 45 /* - */, 206,0, FALSE} // 137 set-start-dash
- , {doSetAddDash, 255, 141,0, FALSE} // 138
- , {doRuleError, 38 /* & */, 206,0, FALSE} // 139 set-start-amp
- , {doSetAddAmp, 255, 141,0, FALSE} // 140
- , {doSetEnd, 93 /* ] */, 255,0, TRUE} // 141 set-after-lit
- , {doSetBeginUnion, 91 /* [ */, 123, 148, TRUE} // 142
- , {doNOP, 45 /* - */, 178,0, TRUE} // 143
- , {doNOP, 38 /* & */, 169,0, TRUE} // 144
- , {doNOP, 92 /* \ */, 191,0, TRUE} // 145
- , {doSetNoCloseError, 253, 206,0, FALSE} // 146
- , {doSetLiteral, 255, 141,0, TRUE} // 147
- , {doSetEnd, 93 /* ] */, 255,0, TRUE} // 148 set-after-set
- , {doSetBeginUnion, 91 /* [ */, 123, 148, TRUE} // 149
- , {doNOP, 45 /* - */, 171,0, TRUE} // 150
- , {doNOP, 38 /* & */, 166,0, TRUE} // 151
- , {doNOP, 92 /* \ */, 191,0, TRUE} // 152
- , {doSetNoCloseError, 253, 206,0, FALSE} // 153
- , {doSetLiteral, 255, 141,0, TRUE} // 154
- , {doSetEnd, 93 /* ] */, 255,0, TRUE} // 155 set-after-range
- , {doSetBeginUnion, 91 /* [ */, 123, 148, TRUE} // 156
- , {doNOP, 45 /* - */, 174,0, TRUE} // 157
- , {doNOP, 38 /* & */, 176,0, TRUE} // 158
- , {doNOP, 92 /* \ */, 191,0, TRUE} // 159
- , {doSetNoCloseError, 253, 206,0, FALSE} // 160
- , {doSetLiteral, 255, 141,0, TRUE} // 161
- , {doSetBeginUnion, 91 /* [ */, 123, 148, TRUE} // 162 set-after-op
- , {doSetOpError, 93 /* ] */, 206,0, FALSE} // 163
- , {doNOP, 92 /* \ */, 191,0, TRUE} // 164
- , {doSetLiteral, 255, 141,0, TRUE} // 165
- , {doSetBeginIntersection1, 91 /* [ */, 123, 148, TRUE} // 166 set-set-amp
- , {doSetIntersection2, 38 /* & */, 162,0, TRUE} // 167
- , {doSetAddAmp, 255, 141,0, FALSE} // 168
- , {doSetIntersection2, 38 /* & */, 162,0, TRUE} // 169 set-lit-amp
- , {doSetAddAmp, 255, 141,0, FALSE} // 170
- , {doSetBeginDifference1, 91 /* [ */, 123, 148, TRUE} // 171 set-set-dash
- , {doSetDifference2, 45 /* - */, 162,0, TRUE} // 172
- , {doSetAddDash, 255, 141,0, FALSE} // 173
- , {doSetDifference2, 45 /* - */, 162,0, TRUE} // 174 set-range-dash
- , {doSetAddDash, 255, 141,0, FALSE} // 175
- , {doSetIntersection2, 38 /* & */, 162,0, TRUE} // 176 set-range-amp
- , {doSetAddAmp, 255, 141,0, FALSE} // 177
- , {doSetDifference2, 45 /* - */, 162,0, TRUE} // 178 set-lit-dash
- , {doSetAddDash, 91 /* [ */, 141,0, FALSE} // 179
- , {doSetAddDash, 93 /* ] */, 141,0, FALSE} // 180
- , {doNOP, 92 /* \ */, 183,0, TRUE} // 181
- , {doSetRange, 255, 155,0, TRUE} // 182
- , {doSetOpError, 115 /* s */, 206,0, FALSE} // 183 set-lit-dash-escape
- , {doSetOpError, 83 /* S */, 206,0, FALSE} // 184
- , {doSetOpError, 119 /* w */, 206,0, FALSE} // 185
- , {doSetOpError, 87 /* W */, 206,0, FALSE} // 186
- , {doSetOpError, 100 /* d */, 206,0, FALSE} // 187
- , {doSetOpError, 68 /* D */, 206,0, FALSE} // 188
- , {doSetNamedRange, 78 /* N */, 155,0, FALSE} // 189
- , {doSetRange, 255, 155,0, TRUE} // 190
- , {doSetProp, 112 /* p */, 148,0, FALSE} // 191 set-escape
- , {doSetProp, 80 /* P */, 148,0, FALSE} // 192
- , {doSetNamedChar, 78 /* N */, 141,0, FALSE} // 193
- , {doSetBackslash_s, 115 /* s */, 155,0, TRUE} // 194
- , {doSetBackslash_S, 83 /* S */, 155,0, TRUE} // 195
- , {doSetBackslash_w, 119 /* w */, 155,0, TRUE} // 196
- , {doSetBackslash_W, 87 /* W */, 155,0, TRUE} // 197
- , {doSetBackslash_d, 100 /* d */, 155,0, TRUE} // 198
- , {doSetBackslash_D, 68 /* D */, 155,0, TRUE} // 199
- , {doSetBackslash_h, 104 /* h */, 155,0, TRUE} // 200
- , {doSetBackslash_H, 72 /* H */, 155,0, TRUE} // 201
- , {doSetBackslash_v, 118 /* v */, 155,0, TRUE} // 202
- , {doSetBackslash_V, 86 /* V */, 155,0, TRUE} // 203
- , {doSetLiteralEscaped, 255, 141,0, TRUE} // 204
- , {doSetFinish, 255, 14,0, FALSE} // 205 set-finish
- , {doExit, 255, 206,0, TRUE} // 206 errorDeath
+ {doNOP, 0, 0, 0, true}
+ , {doPatStart, 255, 2,0, false} // 1 start
+ , {doLiteralChar, 254, 14,0, true} // 2 term
+ , {doLiteralChar, 130, 14,0, true} // 3
+ , {doSetBegin, 91 /* [ */, 123, 205, true} // 4
+ , {doNOP, 40 /* ( */, 27,0, true} // 5
+ , {doDotAny, 46 /* . */, 14,0, true} // 6
+ , {doCaret, 94 /* ^ */, 14,0, true} // 7
+ , {doDollar, 36 /* $ */, 14,0, true} // 8
+ , {doNOP, 92 /* \ */, 89,0, true} // 9
+ , {doOrOperator, 124 /* | */, 2,0, true} // 10
+ , {doCloseParen, 41 /* ) */, 255,0, true} // 11
+ , {doPatFinish, 253, 2,0, false} // 12
+ , {doRuleError, 255, 206,0, false} // 13
+ , {doNOP, 42 /* * */, 68,0, true} // 14 expr-quant
+ , {doNOP, 43 /* + */, 71,0, true} // 15
+ , {doNOP, 63 /* ? */, 74,0, true} // 16
+ , {doIntervalInit, 123 /* { */, 77,0, true} // 17
+ , {doNOP, 40 /* ( */, 23,0, true} // 18
+ , {doNOP, 255, 20,0, false} // 19
+ , {doOrOperator, 124 /* | */, 2,0, true} // 20 expr-cont
+ , {doCloseParen, 41 /* ) */, 255,0, true} // 21
+ , {doNOP, 255, 2,0, false} // 22
+ , {doSuppressComments, 63 /* ? */, 25,0, true} // 23 open-paren-quant
+ , {doNOP, 255, 27,0, false} // 24
+ , {doNOP, 35 /* # */, 50, 14, true} // 25 open-paren-quant2
+ , {doNOP, 255, 29,0, false} // 26
+ , {doSuppressComments, 63 /* ? */, 29,0, true} // 27 open-paren
+ , {doOpenCaptureParen, 255, 2, 14, false} // 28
+ , {doOpenNonCaptureParen, 58 /* : */, 2, 14, true} // 29 open-paren-extended
+ , {doOpenAtomicParen, 62 /* > */, 2, 14, true} // 30
+ , {doOpenLookAhead, 61 /* = */, 2, 20, true} // 31
+ , {doOpenLookAheadNeg, 33 /* ! */, 2, 20, true} // 32
+ , {doNOP, 60 /* < */, 46,0, true} // 33
+ , {doNOP, 35 /* # */, 50, 2, true} // 34
+ , {doBeginMatchMode, 105 /* i */, 53,0, false} // 35
+ , {doBeginMatchMode, 100 /* d */, 53,0, false} // 36
+ , {doBeginMatchMode, 109 /* m */, 53,0, false} // 37
+ , {doBeginMatchMode, 115 /* s */, 53,0, false} // 38
+ , {doBeginMatchMode, 117 /* u */, 53,0, false} // 39
+ , {doBeginMatchMode, 119 /* w */, 53,0, false} // 40
+ , {doBeginMatchMode, 120 /* x */, 53,0, false} // 41
+ , {doBeginMatchMode, 45 /* - */, 53,0, false} // 42
+ , {doConditionalExpr, 40 /* ( */, 206,0, true} // 43
+ , {doPerlInline, 123 /* { */, 206,0, true} // 44
+ , {doBadOpenParenType, 255, 206,0, false} // 45
+ , {doOpenLookBehind, 61 /* = */, 2, 20, true} // 46 open-paren-lookbehind
+ , {doOpenLookBehindNeg, 33 /* ! */, 2, 20, true} // 47
+ , {doBeginNamedCapture, 129, 64,0, false} // 48
+ , {doBadOpenParenType, 255, 206,0, false} // 49
+ , {doNOP, 41 /* ) */, 255,0, true} // 50 paren-comment
+ , {doMismatchedParenErr, 253, 206,0, false} // 51
+ , {doNOP, 255, 50,0, true} // 52
+ , {doMatchMode, 105 /* i */, 53,0, true} // 53 paren-flag
+ , {doMatchMode, 100 /* d */, 53,0, true} // 54
+ , {doMatchMode, 109 /* m */, 53,0, true} // 55
+ , {doMatchMode, 115 /* s */, 53,0, true} // 56
+ , {doMatchMode, 117 /* u */, 53,0, true} // 57
+ , {doMatchMode, 119 /* w */, 53,0, true} // 58
+ , {doMatchMode, 120 /* x */, 53,0, true} // 59
+ , {doMatchMode, 45 /* - */, 53,0, true} // 60
+ , {doSetMatchMode, 41 /* ) */, 2,0, true} // 61
+ , {doMatchModeParen, 58 /* : */, 2, 14, true} // 62
+ , {doBadModeFlag, 255, 206,0, false} // 63
+ , {doContinueNamedCapture, 129, 64,0, true} // 64 named-capture
+ , {doContinueNamedCapture, 128, 64,0, true} // 65
+ , {doOpenCaptureParen, 62 /* > */, 2, 14, true} // 66
+ , {doBadNamedCapture, 255, 206,0, false} // 67
+ , {doNGStar, 63 /* ? */, 20,0, true} // 68 quant-star
+ , {doPossessiveStar, 43 /* + */, 20,0, true} // 69
+ , {doStar, 255, 20,0, false} // 70
+ , {doNGPlus, 63 /* ? */, 20,0, true} // 71 quant-plus
+ , {doPossessivePlus, 43 /* + */, 20,0, true} // 72
+ , {doPlus, 255, 20,0, false} // 73
+ , {doNGOpt, 63 /* ? */, 20,0, true} // 74 quant-opt
+ , {doPossessiveOpt, 43 /* + */, 20,0, true} // 75
+ , {doOpt, 255, 20,0, false} // 76
+ , {doNOP, 128, 79,0, false} // 77 interval-open
+ , {doIntervalError, 255, 206,0, false} // 78
+ , {doIntevalLowerDigit, 128, 79,0, true} // 79 interval-lower
+ , {doNOP, 44 /* , */, 83,0, true} // 80
+ , {doIntervalSame, 125 /* } */, 86,0, true} // 81
+ , {doIntervalError, 255, 206,0, false} // 82
+ , {doIntervalUpperDigit, 128, 83,0, true} // 83 interval-upper
+ , {doNOP, 125 /* } */, 86,0, true} // 84
+ , {doIntervalError, 255, 206,0, false} // 85
+ , {doNGInterval, 63 /* ? */, 20,0, true} // 86 interval-type
+ , {doPossessiveInterval, 43 /* + */, 20,0, true} // 87
+ , {doInterval, 255, 20,0, false} // 88
+ , {doBackslashA, 65 /* A */, 2,0, true} // 89 backslash
+ , {doBackslashB, 66 /* B */, 2,0, true} // 90
+ , {doBackslashb, 98 /* b */, 2,0, true} // 91
+ , {doBackslashd, 100 /* d */, 14,0, true} // 92
+ , {doBackslashD, 68 /* D */, 14,0, true} // 93
+ , {doBackslashG, 71 /* G */, 2,0, true} // 94
+ , {doBackslashh, 104 /* h */, 14,0, true} // 95
+ , {doBackslashH, 72 /* H */, 14,0, true} // 96
+ , {doNOP, 107 /* k */, 115,0, true} // 97
+ , {doNamedChar, 78 /* N */, 14,0, false} // 98
+ , {doProperty, 112 /* p */, 14,0, false} // 99
+ , {doProperty, 80 /* P */, 14,0, false} // 100
+ , {doBackslashR, 82 /* R */, 14,0, true} // 101
+ , {doEnterQuoteMode, 81 /* Q */, 2,0, true} // 102
+ , {doBackslashS, 83 /* S */, 14,0, true} // 103
+ , {doBackslashs, 115 /* s */, 14,0, true} // 104
+ , {doBackslashv, 118 /* v */, 14,0, true} // 105
+ , {doBackslashV, 86 /* V */, 14,0, true} // 106
+ , {doBackslashW, 87 /* W */, 14,0, true} // 107
+ , {doBackslashw, 119 /* w */, 14,0, true} // 108
+ , {doBackslashX, 88 /* X */, 14,0, true} // 109
+ , {doBackslashZ, 90 /* Z */, 2,0, true} // 110
+ , {doBackslashz, 122 /* z */, 2,0, true} // 111
+ , {doBackRef, 128, 14,0, true} // 112
+ , {doEscapeError, 253, 206,0, false} // 113
+ , {doEscapedLiteralChar, 255, 14,0, true} // 114
+ , {doBeginNamedBackRef, 60 /* < */, 117,0, true} // 115 named-backref
+ , {doBadNamedCapture, 255, 206,0, false} // 116
+ , {doContinueNamedBackRef, 129, 119,0, true} // 117 named-backref-2
+ , {doBadNamedCapture, 255, 206,0, false} // 118
+ , {doContinueNamedBackRef, 129, 119,0, true} // 119 named-backref-3
+ , {doContinueNamedBackRef, 128, 119,0, true} // 120
+ , {doCompleteNamedBackRef, 62 /* > */, 14,0, true} // 121
+ , {doBadNamedCapture, 255, 206,0, false} // 122
+ , {doSetNegate, 94 /* ^ */, 126,0, true} // 123 set-open
+ , {doSetPosixProp, 58 /* : */, 128,0, false} // 124
+ , {doNOP, 255, 126,0, false} // 125
+ , {doSetLiteral, 93 /* ] */, 141,0, true} // 126 set-open2
+ , {doNOP, 255, 131,0, false} // 127
+ , {doSetEnd, 93 /* ] */, 255,0, true} // 128 set-posix
+ , {doNOP, 58 /* : */, 131,0, false} // 129
+ , {doRuleError, 255, 206,0, false} // 130
+ , {doSetEnd, 93 /* ] */, 255,0, true} // 131 set-start
+ , {doSetBeginUnion, 91 /* [ */, 123, 148, true} // 132
+ , {doNOP, 92 /* \ */, 191,0, true} // 133
+ , {doNOP, 45 /* - */, 137,0, true} // 134
+ , {doNOP, 38 /* & */, 139,0, true} // 135
+ , {doSetLiteral, 255, 141,0, true} // 136
+ , {doRuleError, 45 /* - */, 206,0, false} // 137 set-start-dash
+ , {doSetAddDash, 255, 141,0, false} // 138
+ , {doRuleError, 38 /* & */, 206,0, false} // 139 set-start-amp
+ , {doSetAddAmp, 255, 141,0, false} // 140
+ , {doSetEnd, 93 /* ] */, 255,0, true} // 141 set-after-lit
+ , {doSetBeginUnion, 91 /* [ */, 123, 148, true} // 142
+ , {doNOP, 45 /* - */, 178,0, true} // 143
+ , {doNOP, 38 /* & */, 169,0, true} // 144
+ , {doNOP, 92 /* \ */, 191,0, true} // 145
+ , {doSetNoCloseError, 253, 206,0, false} // 146
+ , {doSetLiteral, 255, 141,0, true} // 147
+ , {doSetEnd, 93 /* ] */, 255,0, true} // 148 set-after-set
+ , {doSetBeginUnion, 91 /* [ */, 123, 148, true} // 149
+ , {doNOP, 45 /* - */, 171,0, true} // 150
+ , {doNOP, 38 /* & */, 166,0, true} // 151
+ , {doNOP, 92 /* \ */, 191,0, true} // 152
+ , {doSetNoCloseError, 253, 206,0, false} // 153
+ , {doSetLiteral, 255, 141,0, true} // 154
+ , {doSetEnd, 93 /* ] */, 255,0, true} // 155 set-after-range
+ , {doSetBeginUnion, 91 /* [ */, 123, 148, true} // 156
+ , {doNOP, 45 /* - */, 174,0, true} // 157
+ , {doNOP, 38 /* & */, 176,0, true} // 158
+ , {doNOP, 92 /* \ */, 191,0, true} // 159
+ , {doSetNoCloseError, 253, 206,0, false} // 160
+ , {doSetLiteral, 255, 141,0, true} // 161
+ , {doSetBeginUnion, 91 /* [ */, 123, 148, true} // 162 set-after-op
+ , {doSetOpError, 93 /* ] */, 206,0, false} // 163
+ , {doNOP, 92 /* \ */, 191,0, true} // 164
+ , {doSetLiteral, 255, 141,0, true} // 165
+ , {doSetBeginIntersection1, 91 /* [ */, 123, 148, true} // 166 set-set-amp
+ , {doSetIntersection2, 38 /* & */, 162,0, true} // 167
+ , {doSetAddAmp, 255, 141,0, false} // 168
+ , {doSetIntersection2, 38 /* & */, 162,0, true} // 169 set-lit-amp
+ , {doSetAddAmp, 255, 141,0, false} // 170
+ , {doSetBeginDifference1, 91 /* [ */, 123, 148, true} // 171 set-set-dash
+ , {doSetDifference2, 45 /* - */, 162,0, true} // 172
+ , {doSetAddDash, 255, 141,0, false} // 173
+ , {doSetDifference2, 45 /* - */, 162,0, true} // 174 set-range-dash
+ , {doSetAddDash, 255, 141,0, false} // 175
+ , {doSetIntersection2, 38 /* & */, 162,0, true} // 176 set-range-amp
+ , {doSetAddAmp, 255, 141,0, false} // 177
+ , {doSetDifference2, 45 /* - */, 162,0, true} // 178 set-lit-dash
+ , {doSetAddDash, 91 /* [ */, 141,0, false} // 179
+ , {doSetAddDash, 93 /* ] */, 141,0, false} // 180
+ , {doNOP, 92 /* \ */, 183,0, true} // 181
+ , {doSetRange, 255, 155,0, true} // 182
+ , {doSetOpError, 115 /* s */, 206,0, false} // 183 set-lit-dash-escape
+ , {doSetOpError, 83 /* S */, 206,0, false} // 184
+ , {doSetOpError, 119 /* w */, 206,0, false} // 185
+ , {doSetOpError, 87 /* W */, 206,0, false} // 186
+ , {doSetOpError, 100 /* d */, 206,0, false} // 187
+ , {doSetOpError, 68 /* D */, 206,0, false} // 188
+ , {doSetNamedRange, 78 /* N */, 155,0, false} // 189
+ , {doSetRange, 255, 155,0, true} // 190
+ , {doSetProp, 112 /* p */, 148,0, false} // 191 set-escape
+ , {doSetProp, 80 /* P */, 148,0, false} // 192
+ , {doSetNamedChar, 78 /* N */, 141,0, false} // 193
+ , {doSetBackslash_s, 115 /* s */, 155,0, true} // 194
+ , {doSetBackslash_S, 83 /* S */, 155,0, true} // 195
+ , {doSetBackslash_w, 119 /* w */, 155,0, true} // 196
+ , {doSetBackslash_W, 87 /* W */, 155,0, true} // 197
+ , {doSetBackslash_d, 100 /* d */, 155,0, true} // 198
+ , {doSetBackslash_D, 68 /* D */, 155,0, true} // 199
+ , {doSetBackslash_h, 104 /* h */, 155,0, true} // 200
+ , {doSetBackslash_H, 72 /* H */, 155,0, true} // 201
+ , {doSetBackslash_v, 118 /* v */, 155,0, true} // 202
+ , {doSetBackslash_V, 86 /* V */, 155,0, true} // 203
+ , {doSetLiteralEscaped, 255, 141,0, true} // 204
+ , {doSetFinish, 255, 14,0, false} // 205 set-finish
+ , {doExit, 255, 206,0, true} // 206 errorDeath
};
static const char * const RegexStateNames[] = { 0,
"start",
diff --git a/contrib/libs/icu/i18n/regeximp.cpp b/contrib/libs/icu/i18n/regeximp.cpp
index d555669625..86e238c0f7 100644
--- a/contrib/libs/icu/i18n/regeximp.cpp
+++ b/contrib/libs/icu/i18n/regeximp.cpp
@@ -19,7 +19,7 @@
U_NAMESPACE_BEGIN
CaseFoldingUTextIterator::CaseFoldingUTextIterator(UText &text) :
- fUText(text), fFoldChars(NULL), fFoldLength(0) {
+ fUText(text), fFoldChars(nullptr), fFoldLength(0) {
}
CaseFoldingUTextIterator::~CaseFoldingUTextIterator() {}
@@ -27,7 +27,7 @@ CaseFoldingUTextIterator::~CaseFoldingUTextIterator() {}
UChar32 CaseFoldingUTextIterator::next() {
UChar32 foldedC;
UChar32 originalC;
- if (fFoldChars == NULL) {
+ if (fFoldChars == nullptr) {
// We are not in a string folding of an earlier character.
// Start handling the next char from the input UText.
originalC = UTEXT_NEXT32(&fUText);
@@ -42,7 +42,7 @@ UChar32 CaseFoldingUTextIterator::next() {
fFoldLength = ~fFoldLength;
}
foldedC = (UChar32)fFoldLength;
- fFoldChars = NULL;
+ fFoldChars = nullptr;
return foldedC;
}
// String foldings fall through here.
@@ -51,20 +51,20 @@ UChar32 CaseFoldingUTextIterator::next() {
U16_NEXT(fFoldChars, fFoldIndex, fFoldLength, foldedC);
if (fFoldIndex >= fFoldLength) {
- fFoldChars = NULL;
+ fFoldChars = nullptr;
}
return foldedC;
}
UBool CaseFoldingUTextIterator::inExpansion() {
- return fFoldChars != NULL;
+ return fFoldChars != nullptr;
}
-CaseFoldingUCharIterator::CaseFoldingUCharIterator(const UChar *chars, int64_t start, int64_t limit) :
- fChars(chars), fIndex(start), fLimit(limit), fFoldChars(NULL), fFoldLength(0) {
+CaseFoldingUCharIterator::CaseFoldingUCharIterator(const char16_t *chars, int64_t start, int64_t limit) :
+ fChars(chars), fIndex(start), fLimit(limit), fFoldChars(nullptr), fFoldLength(0) {
}
@@ -74,7 +74,7 @@ CaseFoldingUCharIterator::~CaseFoldingUCharIterator() {}
UChar32 CaseFoldingUCharIterator::next() {
UChar32 foldedC;
UChar32 originalC;
- if (fFoldChars == NULL) {
+ if (fFoldChars == nullptr) {
// We are not in a string folding of an earlier character.
// Start handling the next char from the input UText.
if (fIndex >= fLimit) {
@@ -90,7 +90,7 @@ UChar32 CaseFoldingUCharIterator::next() {
fFoldLength = ~fFoldLength;
}
foldedC = (UChar32)fFoldLength;
- fFoldChars = NULL;
+ fFoldChars = nullptr;
return foldedC;
}
// String foldings fall through here.
@@ -99,14 +99,14 @@ UChar32 CaseFoldingUCharIterator::next() {
U16_NEXT(fFoldChars, fFoldIndex, fFoldLength, foldedC);
if (fFoldIndex >= fFoldLength) {
- fFoldChars = NULL;
+ fFoldChars = nullptr;
}
return foldedC;
}
UBool CaseFoldingUCharIterator::inExpansion() {
- return fFoldChars != NULL;
+ return fFoldChars != nullptr;
}
int64_t CaseFoldingUCharIterator::getIndex() {
diff --git a/contrib/libs/icu/i18n/regeximp.h b/contrib/libs/icu/i18n/regeximp.h
index bb0e1e838d..446cd90747 100644
--- a/contrib/libs/icu/i18n/regeximp.h
+++ b/contrib/libs/icu/i18n/regeximp.h
@@ -343,7 +343,7 @@ inline void Regex8BitSet::add(UChar32 c) {
}
inline void Regex8BitSet::init(const UnicodeSet *s) {
- if (s != NULL) {
+ if (s != nullptr) {
for (int32_t i=0; i<=255; i++) {
if (s->contains(i)) {
this->add(i);
@@ -374,21 +374,21 @@ class CaseFoldingUTextIterator: public UMemory {
// folding of the same code point from the original UText.
private:
UText &fUText;
- const UChar *fFoldChars;
+ const char16_t *fFoldChars;
int32_t fFoldLength;
int32_t fFoldIndex;
};
-// Case folded UChar * string iterator.
-// Wraps a UChar *, provides a case-folded enumeration over its contents.
+// Case folded char16_t * string iterator.
+// Wraps a char16_t *, provides a case-folded enumeration over its contents.
// Used in implementing case insensitive matching constructs.
// Implementation in rematch.cpp
class CaseFoldingUCharIterator: public UMemory {
public:
- CaseFoldingUCharIterator(const UChar *chars, int64_t start, int64_t limit);
+ CaseFoldingUCharIterator(const char16_t *chars, int64_t start, int64_t limit);
~CaseFoldingUCharIterator();
UChar32 next(); // Next case folded character
@@ -400,10 +400,10 @@ class CaseFoldingUCharIterator: public UMemory {
int64_t getIndex(); // Return the current input buffer index.
private:
- const UChar *fChars;
+ const char16_t *fChars;
int64_t fIndex;
int64_t fLimit;
- const UChar *fFoldChars;
+ const char16_t *fFoldChars;
int32_t fFoldLength;
int32_t fFoldIndex;
diff --git a/contrib/libs/icu/i18n/regexst.cpp b/contrib/libs/icu/i18n/regexst.cpp
index 97e417ab5a..9103230544 100644
--- a/contrib/libs/icu/i18n/regexst.cpp
+++ b/contrib/libs/icu/i18n/regexst.cpp
@@ -69,7 +69,7 @@ constexpr char16_t const *gGC_LVTPattern = u"[\\p{Hangul_Syllable_Type=LVT}]
RegexStaticSets *RegexStaticSets::gStaticSets = nullptr;
-UInitOnce gStaticSetsInitOnce = U_INITONCE_INITIALIZER;
+UInitOnce gStaticSetsInitOnce {};
RegexStaticSets::RegexStaticSets(UErrorCode *status) {
@@ -77,13 +77,13 @@ RegexStaticSets::RegexStaticSets(UErrorCode *status) {
fUnescapeCharSet.addAll(UnicodeString(true, gUnescapeChars, -1)).freeze();
fPropSets[URX_ISWORD_SET].applyPattern(UnicodeString(true, gIsWordPattern, -1), *status).freeze();
fPropSets[URX_ISSPACE_SET].applyPattern(UnicodeString(true, gIsSpacePattern, -1), *status).freeze();
- fPropSets[URX_GC_EXTEND].applyPattern(UnicodeString(TRUE, gGC_ExtendPattern, -1), *status).freeze();
- fPropSets[URX_GC_CONTROL].applyPattern(UnicodeString(TRUE, gGC_ControlPattern, -1), *status).freeze();
- fPropSets[URX_GC_L].applyPattern(UnicodeString(TRUE, gGC_LPattern, -1), *status).freeze();
- fPropSets[URX_GC_V].applyPattern(UnicodeString(TRUE, gGC_VPattern, -1), *status).freeze();
- fPropSets[URX_GC_T].applyPattern(UnicodeString(TRUE, gGC_TPattern, -1), *status).freeze();
- fPropSets[URX_GC_LV].applyPattern(UnicodeString(TRUE, gGC_LVPattern, -1), *status).freeze();
- fPropSets[URX_GC_LVT].applyPattern(UnicodeString(TRUE, gGC_LVTPattern, -1), *status).freeze();
+ fPropSets[URX_GC_EXTEND].applyPattern(UnicodeString(true, gGC_ExtendPattern, -1), *status).freeze();
+ fPropSets[URX_GC_CONTROL].applyPattern(UnicodeString(true, gGC_ControlPattern, -1), *status).freeze();
+ fPropSets[URX_GC_L].applyPattern(UnicodeString(true, gGC_LPattern, -1), *status).freeze();
+ fPropSets[URX_GC_V].applyPattern(UnicodeString(true, gGC_VPattern, -1), *status).freeze();
+ fPropSets[URX_GC_T].applyPattern(UnicodeString(true, gGC_TPattern, -1), *status).freeze();
+ fPropSets[URX_GC_LV].applyPattern(UnicodeString(true, gGC_LVPattern, -1), *status).freeze();
+ fPropSets[URX_GC_LVT].applyPattern(UnicodeString(true, gGC_LVTPattern, -1), *status).freeze();
//
@@ -143,11 +143,11 @@ RegexStaticSets::~RegexStaticSets() {
U_CDECL_BEGIN
static UBool U_CALLCONV
-regex_cleanup(void) {
+regex_cleanup() {
delete RegexStaticSets::gStaticSets;
RegexStaticSets::gStaticSets = nullptr;
gStaticSetsInitOnce.reset();
- return TRUE;
+ return true;
}
static void U_CALLCONV initStaticSets(UErrorCode &status) {
diff --git a/contrib/libs/icu/i18n/regextxt.cpp b/contrib/libs/icu/i18n/regextxt.cpp
index 41bb4a944b..32d8a5c5f8 100644
--- a/contrib/libs/icu/i18n/regextxt.cpp
+++ b/contrib/libs/icu/i18n/regextxt.cpp
@@ -16,7 +16,7 @@
U_NAMESPACE_BEGIN
-U_CFUNC UChar U_CALLCONV
+U_CFUNC char16_t U_CALLCONV
uregex_utext_unescape_charAt(int32_t offset, void *ct) {
struct URegexUTextUnescapeCharContext *context = (struct URegexUTextUnescapeCharContext *)ct;
UChar32 c;
@@ -34,15 +34,15 @@ uregex_utext_unescape_charAt(int32_t offset, void *ct) {
// !!!: Doesn't handle characters outside BMP
if (U_IS_BMP(c)) {
- return (UChar)c;
+ return (char16_t)c;
} else {
return 0;
}
}
-U_CFUNC UChar U_CALLCONV
+U_CFUNC char16_t U_CALLCONV
uregex_ucstr_unescape_charAt(int32_t offset, void *context) {
- return ((UChar *)context)[offset];
+ return ((char16_t *)context)[offset];
}
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/region.cpp b/contrib/libs/icu/i18n/region.cpp
index 2e013708bb..26440b6593 100644
--- a/contrib/libs/icu/i18n/region.cpp
+++ b/contrib/libs/icu/i18n/region.cpp
@@ -39,37 +39,32 @@
U_CDECL_BEGIN
-static void U_CALLCONV
-deleteRegion(void *obj) {
- delete (icu::Region *)obj;
-}
-
/**
* Cleanup callback func
*/
-static UBool U_CALLCONV region_cleanup(void)
+static UBool U_CALLCONV region_cleanup()
{
icu::Region::cleanupRegionData();
- return TRUE;
+ return true;
}
U_CDECL_END
U_NAMESPACE_BEGIN
-static UInitOnce gRegionDataInitOnce = U_INITONCE_INITIALIZER;
+static UInitOnce gRegionDataInitOnce {};
static UVector* availableRegions[URGN_LIMIT];
-static UHashtable *regionAliases = NULL;
-static UHashtable *regionIDMap = NULL;
-static UHashtable *numericCodeMap = NULL;
-static UVector *allRegions = NULL;
+static UHashtable *regionAliases = nullptr;
+static UHashtable *regionIDMap = nullptr;
+static UHashtable *numericCodeMap = nullptr;
+static UVector *allRegions = nullptr;
-static const UChar UNKNOWN_REGION_ID [] = { 0x5A, 0x5A, 0 }; /* "ZZ" */
-static const UChar OUTLYING_OCEANIA_REGION_ID [] = { 0x51, 0x4F, 0 }; /* "QO" */
-static const UChar WORLD_ID [] = { 0x30, 0x30, 0x31, 0 }; /* "001" */
-static const UChar RANGE_MARKER = 0x7E; /* '~' */
+static const char16_t UNKNOWN_REGION_ID [] = { 0x5A, 0x5A, 0 }; /* "ZZ" */
+static const char16_t OUTLYING_OCEANIA_REGION_ID [] = { 0x51, 0x4F, 0 }; /* "QO" */
+static const char16_t WORLD_ID [] = { 0x30, 0x30, 0x31, 0 }; /* "001" */
+static const char16_t RANGE_MARKER = 0x7E; /* '~' */
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RegionNameEnumeration)
@@ -84,86 +79,92 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RegionNameEnumeration)
void U_CALLCONV Region::loadRegionData(UErrorCode &status) {
// Construct service objs first
- LocalUHashtablePointer newRegionIDMap(uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, NULL, &status));
- LocalUHashtablePointer newNumericCodeMap(uhash_open(uhash_hashLong,uhash_compareLong,NULL,&status));
- LocalUHashtablePointer newRegionAliases(uhash_open(uhash_hashUnicodeString,uhash_compareUnicodeString,NULL,&status));
+ LocalUHashtablePointer newRegionIDMap(uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, nullptr, &status));
+ LocalUHashtablePointer newNumericCodeMap(uhash_open(uhash_hashLong,uhash_compareLong,nullptr,&status));
+ LocalUHashtablePointer newRegionAliases(uhash_open(uhash_hashUnicodeString,uhash_compareUnicodeString,nullptr,&status));
LocalPointer<UVector> continents(new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status), status);
LocalPointer<UVector> groupings(new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status), status);
- allRegions = new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status);
+ LocalPointer<UVector> lpAllRegions(new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status), status);
+ allRegions = lpAllRegions.orphan();
- LocalUResourceBundlePointer metadata(ures_openDirect(NULL,"metadata",&status));
- LocalUResourceBundlePointer metadataAlias(ures_getByKey(metadata.getAlias(),"alias",NULL,&status));
- LocalUResourceBundlePointer territoryAlias(ures_getByKey(metadataAlias.getAlias(),"territory",NULL,&status));
+ LocalUResourceBundlePointer metadata(ures_openDirect(nullptr,"metadata",&status));
+ LocalUResourceBundlePointer metadataAlias(ures_getByKey(metadata.getAlias(),"alias",nullptr,&status));
+ LocalUResourceBundlePointer territoryAlias(ures_getByKey(metadataAlias.getAlias(),"territory",nullptr,&status));
- LocalUResourceBundlePointer supplementalData(ures_openDirect(NULL,"supplementalData",&status));
- LocalUResourceBundlePointer codeMappings(ures_getByKey(supplementalData.getAlias(),"codeMappings",NULL,&status));
+ LocalUResourceBundlePointer supplementalData(ures_openDirect(nullptr,"supplementalData",&status));
+ LocalUResourceBundlePointer codeMappings(ures_getByKey(supplementalData.getAlias(),"codeMappings",nullptr,&status));
- LocalUResourceBundlePointer idValidity(ures_getByKey(supplementalData.getAlias(),"idValidity",NULL,&status));
- LocalUResourceBundlePointer regionList(ures_getByKey(idValidity.getAlias(),"region",NULL,&status));
- LocalUResourceBundlePointer regionRegular(ures_getByKey(regionList.getAlias(),"regular",NULL,&status));
- LocalUResourceBundlePointer regionMacro(ures_getByKey(regionList.getAlias(),"macroregion",NULL,&status));
- LocalUResourceBundlePointer regionUnknown(ures_getByKey(regionList.getAlias(),"unknown",NULL,&status));
+ LocalUResourceBundlePointer idValidity(ures_getByKey(supplementalData.getAlias(),"idValidity",nullptr,&status));
+ LocalUResourceBundlePointer regionList(ures_getByKey(idValidity.getAlias(),"region",nullptr,&status));
+ LocalUResourceBundlePointer regionRegular(ures_getByKey(regionList.getAlias(),"regular",nullptr,&status));
+ LocalUResourceBundlePointer regionMacro(ures_getByKey(regionList.getAlias(),"macroregion",nullptr,&status));
+ LocalUResourceBundlePointer regionUnknown(ures_getByKey(regionList.getAlias(),"unknown",nullptr,&status));
- LocalUResourceBundlePointer territoryContainment(ures_getByKey(supplementalData.getAlias(),"territoryContainment",NULL,&status));
- LocalUResourceBundlePointer worldContainment(ures_getByKey(territoryContainment.getAlias(),"001",NULL,&status));
- LocalUResourceBundlePointer groupingContainment(ures_getByKey(territoryContainment.getAlias(),"grouping",NULL,&status));
+ LocalUResourceBundlePointer territoryContainment(ures_getByKey(supplementalData.getAlias(),"territoryContainment",nullptr,&status));
+ LocalUResourceBundlePointer worldContainment(ures_getByKey(territoryContainment.getAlias(),"001",nullptr,&status));
+ LocalUResourceBundlePointer groupingContainment(ures_getByKey(territoryContainment.getAlias(),"grouping",nullptr,&status));
+ ucln_i18n_registerCleanup(UCLN_I18N_REGION, region_cleanup);
if (U_FAILURE(status)) {
return;
}
// now, initialize
- uhash_setValueDeleter(newRegionIDMap.getAlias(), deleteRegion); // regionIDMap owns objs
- uhash_setKeyDeleter(newRegionAliases.getAlias(), uprv_deleteUObject); // regionAliases owns the string keys
+ uhash_setValueDeleter(newRegionIDMap.getAlias(), uprv_deleteUObject); // regionIDMap owns objs
+ uhash_setKeyDeleter(newRegionAliases.getAlias(), uprv_deleteUObject); // regionAliases owns the string keys
- while ( ures_hasNext(regionRegular.getAlias()) ) {
- UnicodeString regionName = ures_getNextUnicodeString(regionRegular.getAlias(),NULL,&status);
+ while (U_SUCCESS(status) && ures_hasNext(regionRegular.getAlias())) {
+ UnicodeString regionName = ures_getNextUnicodeString(regionRegular.getAlias(),nullptr,&status);
int32_t rangeMarkerLocation = regionName.indexOf(RANGE_MARKER);
- UChar buf[6];
+ char16_t buf[6];
regionName.extract(buf,6,status);
if ( rangeMarkerLocation > 0 ) {
- UChar endRange = regionName.charAt(rangeMarkerLocation+1);
+ char16_t endRange = regionName.charAt(rangeMarkerLocation+1);
buf[rangeMarkerLocation] = 0;
- while ( buf[rangeMarkerLocation-1] <= endRange ) {
+ while (U_SUCCESS(status) && buf[rangeMarkerLocation-1] <= endRange) {
LocalPointer<UnicodeString> newRegion(new UnicodeString(buf), status);
- allRegions->addElementX(newRegion.orphan(),status);
+ allRegions->adoptElement(newRegion.orphan(), status);
buf[rangeMarkerLocation-1]++;
}
} else {
LocalPointer<UnicodeString> newRegion(new UnicodeString(regionName), status);
- allRegions->addElementX(newRegion.orphan(),status);
+ allRegions->adoptElement(newRegion.orphan(), status);
}
}
- while ( ures_hasNext(regionMacro.getAlias()) ) {
- UnicodeString regionName = ures_getNextUnicodeString(regionMacro.getAlias(),NULL,&status);
+ while (U_SUCCESS(status) && ures_hasNext(regionMacro.getAlias())) {
+ UnicodeString regionName = ures_getNextUnicodeString(regionMacro.getAlias(),nullptr,&status);
int32_t rangeMarkerLocation = regionName.indexOf(RANGE_MARKER);
- UChar buf[6];
+ char16_t buf[6];
regionName.extract(buf,6,status);
if ( rangeMarkerLocation > 0 ) {
- UChar endRange = regionName.charAt(rangeMarkerLocation+1);
+ char16_t endRange = regionName.charAt(rangeMarkerLocation+1);
buf[rangeMarkerLocation] = 0;
- while ( buf[rangeMarkerLocation-1] <= endRange ) {
+ while ( buf[rangeMarkerLocation-1] <= endRange && U_SUCCESS(status)) {
LocalPointer<UnicodeString> newRegion(new UnicodeString(buf), status);
- allRegions->addElementX(newRegion.orphan(),status);
+ allRegions->adoptElement(newRegion.orphan(),status);
buf[rangeMarkerLocation-1]++;
}
} else {
LocalPointer<UnicodeString> newRegion(new UnicodeString(regionName), status);
- allRegions->addElementX(newRegion.orphan(),status);
+ allRegions->adoptElement(newRegion.orphan(),status);
}
}
- while ( ures_hasNext(regionUnknown.getAlias()) ) {
- LocalPointer<UnicodeString> regionName (new UnicodeString(ures_getNextUnicodeString(regionUnknown.getAlias(),NULL,&status),status));
- allRegions->addElementX(regionName.orphan(),status);
+ while (U_SUCCESS(status) && ures_hasNext(regionUnknown.getAlias())) {
+ LocalPointer<UnicodeString> regionName (
+ new UnicodeString(ures_getNextUnicodeString(regionUnknown.getAlias(), nullptr, &status), status));
+ allRegions->adoptElement(regionName.orphan(),status);
}
- while ( ures_hasNext(worldContainment.getAlias()) ) {
- UnicodeString *continentName = new UnicodeString(ures_getNextUnicodeString(worldContainment.getAlias(),NULL,&status));
- continents->addElementX(continentName,status);
+ while (U_SUCCESS(status) && ures_hasNext(worldContainment.getAlias())) {
+ UnicodeString *continentName = new UnicodeString(ures_getNextUnicodeString(worldContainment.getAlias(),nullptr,&status));
+ continents->adoptElement(continentName,status);
+ }
+ if (U_FAILURE(status)) {
+ return;
}
for ( int32_t i = 0 ; i < allRegions->size() ; i++ ) {
@@ -191,22 +192,32 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) {
}
UResourceBundle *groupingBundle = nullptr;
- while ( ures_hasNext(groupingContainment.getAlias()) ) {
+ while (U_SUCCESS(status) && ures_hasNext(groupingContainment.getAlias())) {
groupingBundle = ures_getNextResource(groupingContainment.getAlias(), groupingBundle, &status);
if (U_FAILURE(status)) {
break;
}
UnicodeString *groupingName = new UnicodeString(ures_getKey(groupingBundle), -1, US_INV);
- groupings->addElementX(groupingName,status);
- Region *grouping = (Region *) uhash_get(newRegionIDMap.getAlias(),groupingName);
- if (grouping != NULL) {
- for (int32_t i = 0; i < ures_getSize(groupingBundle); i++) {
+ LocalPointer<UnicodeString> lpGroupingName(groupingName, status);
+ groupings->adoptElement(lpGroupingName.orphan(), status);
+ if (U_FAILURE(status)) {
+ break;
+ }
+ Region *grouping = (Region *) uhash_get(newRegionIDMap.getAlias(), groupingName);
+ if (grouping != nullptr) {
+ for (int32_t i = 0; i < ures_getSize(groupingBundle) && U_SUCCESS(status); i++) {
UnicodeString child = ures_getUnicodeStringByIndex(groupingBundle, i, &status);
if (U_SUCCESS(status)) {
- if (grouping->containedRegions == NULL) {
- grouping->containedRegions = new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status);
+ if (grouping->containedRegions == nullptr) {
+ LocalPointer<UVector> lpContainedRegions(
+ new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status), status);
+ grouping->containedRegions = lpContainedRegions.orphan();
+ if (U_FAILURE(status)) {
+ break;
+ }
}
- grouping->containedRegions->addElementX(new UnicodeString(child), status);
+ LocalPointer<UnicodeString> lpChildCopy(new UnicodeString(child), status);
+ grouping->containedRegions->adoptElement(lpChildCopy.orphan(), status);
}
}
}
@@ -214,20 +225,20 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) {
ures_close(groupingBundle);
// Process the territory aliases
- while ( ures_hasNext(territoryAlias.getAlias()) ) {
- LocalUResourceBundlePointer res(ures_getNextResource(territoryAlias.getAlias(),NULL,&status));
+ while (U_SUCCESS(status) && ures_hasNext(territoryAlias.getAlias())) {
+ LocalUResourceBundlePointer res(ures_getNextResource(territoryAlias.getAlias(),nullptr,&status));
const char *aliasFrom = ures_getKey(res.getAlias());
LocalPointer<UnicodeString> aliasFromStr(new UnicodeString(aliasFrom, -1, US_INV), status);
UnicodeString aliasTo = ures_getUnicodeStringByKey(res.getAlias(),"replacement",&status);
- res.adoptInstead(NULL);
+ res.adoptInstead(nullptr);
const Region *aliasToRegion = (Region *) uhash_get(newRegionIDMap.getAlias(),&aliasTo);
Region *aliasFromRegion = (Region *)uhash_get(newRegionIDMap.getAlias(),aliasFromStr.getAlias());
- if ( aliasToRegion != NULL && aliasFromRegion == NULL ) { // This is just an alias from some string to a region
+ if ( aliasToRegion != nullptr && aliasFromRegion == nullptr ) { // 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 primary codes list - so need to create a deprecated region for it.
+ if ( aliasFromRegion == nullptr ) { // 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();
@@ -259,7 +270,7 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) {
}
UnicodeString currentRegion;
//currentRegion.remove(); TODO: was already 0 length?
- for (int32_t i = 0 ; i < aliasTo.length() ; i++ ) {
+ for (int32_t i = 0 ; i < aliasTo.length() && U_SUCCESS(status); i++ ) {
if ( aliasTo.charAt(i) != 0x0020 ) {
currentRegion.append(aliasTo.charAt(i));
}
@@ -267,7 +278,7 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) {
Region *target = (Region *)uhash_get(newRegionIDMap.getAlias(),(void *)&currentRegion);
if (target) {
LocalPointer<UnicodeString> preferredValue(new UnicodeString(target->idStr), status);
- aliasFromRegion->preferredValues->addElementX((void *)preferredValue.orphan(),status); // may add null if err
+ aliasFromRegion->preferredValues->adoptElement(preferredValue.orphan(),status); // may add null if err
}
currentRegion.remove();
}
@@ -276,9 +287,9 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) {
}
// Process the code mappings - This will allow us to assign numeric codes to most of the territories.
- while ( ures_hasNext(codeMappings.getAlias()) ) {
- UResourceBundle *mapping = ures_getNextResource(codeMappings.getAlias(),NULL,&status);
- if ( ures_getType(mapping) == URES_ARRAY && ures_getSize(mapping) == 3) {
+ while (U_SUCCESS(status) && ures_hasNext(codeMappings.getAlias())) {
+ UResourceBundle *mapping = ures_getNextResource(codeMappings.getAlias(),nullptr,&status);
+ if (U_SUCCESS(status) && ures_getType(mapping) == URES_ARRAY && ures_getSize(mapping) == 3) {
UnicodeString codeMappingID = ures_getUnicodeStringByIndex(mapping,0,&status);
UnicodeString codeMappingNumber = ures_getUnicodeStringByIndex(mapping,1,&status);
UnicodeString codeMapping3Letter = ures_getUnicodeStringByIndex(mapping,2,&status);
@@ -337,7 +348,7 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) {
// Load territory containment info from the supplemental data.
while ( ures_hasNext(territoryContainment.getAlias()) ) {
- LocalUResourceBundlePointer mapping(ures_getNextResource(territoryContainment.getAlias(),NULL,&status));
+ LocalUResourceBundlePointer mapping(ures_getNextResource(territoryContainment.getAlias(),nullptr,&status));
if( U_FAILURE(status) ) {
return; // error out
}
@@ -352,19 +363,27 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) {
for ( int j = 0 ; j < ures_getSize(mapping.getAlias()); j++ ) {
UnicodeString child = ures_getUnicodeStringByIndex(mapping.getAlias(),j,&status);
Region *childRegion = (Region *) uhash_get(newRegionIDMap.getAlias(),(void *)&child);
- if ( parentRegion != NULL && childRegion != NULL ) {
+ if ( parentRegion != nullptr && childRegion != nullptr ) {
// Add the child region to the set of regions contained by the parent
- if (parentRegion->containedRegions == NULL) {
- parentRegion->containedRegions = new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status);
+ if (parentRegion->containedRegions == nullptr) {
+ LocalPointer<UVector> lpContainedRegions(
+ new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status), status);
+ parentRegion->containedRegions = lpContainedRegions.orphan();
+ if (U_FAILURE(status)) {
+ return;
+ }
}
LocalPointer<UnicodeString> childStr(new UnicodeString(), status);
- if( U_FAILURE(status) ) {
+ if (U_FAILURE(status)) {
return; // error out
}
childStr->fastCopyFrom(childRegion->idStr);
- parentRegion->containedRegions->addElementX((void *)childStr.orphan(),status);
+ parentRegion->containedRegions->adoptElement(childStr.orphan(),status);
+ if (U_FAILURE(status)) {
+ return;
+ }
// Set the parent region to be the containing region of the child.
// Regions of type GROUPING can't be set as the parent, since another region
@@ -380,7 +399,7 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) {
int32_t pos = UHASH_FIRST;
while ( const UHashElement* element = uhash_nextElement(newRegionIDMap.getAlias(),&pos)) {
Region *ar = (Region *)element->value.pointer;
- if ( availableRegions[ar->fType] == NULL ) {
+ if ( availableRegions[ar->fType] == nullptr ) {
LocalPointer<UVector> newAr(new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status), status);
availableRegions[ar->fType] = newAr.orphan();
}
@@ -388,10 +407,9 @@ void U_CALLCONV Region::loadRegionData(UErrorCode &status) {
if( U_FAILURE(status) ) {
return; // error out
}
- availableRegions[ar->fType]->addElementX((void *)arString.orphan(),status);
+ availableRegions[ar->fType]->adoptElement(arString.orphan(), status);
}
- ucln_i18n_registerCleanup(UCLN_I18N_REGION, region_cleanup);
// copy hashtables
numericCodeMap = newNumericCodeMap.orphan();
regionIDMap = newRegionIDMap.orphan();
@@ -402,6 +420,7 @@ void Region::cleanupRegionData() {
for (int32_t i = 0 ; i < URGN_LIMIT ; i++ ) {
if ( availableRegions[i] ) {
delete availableRegions[i];
+ availableRegions[i] = nullptr;
}
}
@@ -417,12 +436,11 @@ void Region::cleanupRegionData() {
uhash_close(regionIDMap);
}
if (allRegions) {
- allRegions->removeAllElements(); // Don't need the temporary list anymore.
delete allRegions;
- allRegions = NULL;
+ allRegions = nullptr;
}
- regionAliases = numericCodeMap = regionIDMap = NULL;
+ regionAliases = numericCodeMap = regionIDMap = nullptr;
gRegionDataInitOnce.reset();
}
@@ -430,9 +448,9 @@ void Region::cleanupRegionData() {
Region::Region ()
: code(-1),
fType(URGN_UNKNOWN),
- containingRegion(NULL),
- containedRegions(NULL),
- preferredValues(NULL) {
+ containingRegion(nullptr),
+ containedRegions(nullptr),
+ preferredValues(nullptr) {
id[0] = 0;
}
@@ -467,19 +485,19 @@ Region::operator!=(const Region &that) const {
* Returns a pointer to a Region using the given region code. The region code can be either 2-letter ISO code,
* 3-letter ISO code, UNM.49 numeric code, or other valid Unicode Region Code as defined by the LDML specification.
* The identifier will be canonicalized internally using the supplemental metadata as defined in the CLDR.
- * If the region code is NULL or not recognized, the appropriate error code will be set ( U_ILLEGAL_ARGUMENT_ERROR )
+ * If the region code is nullptr or not recognized, the appropriate error code will be set ( U_ILLEGAL_ARGUMENT_ERROR )
*/
const Region* U_EXPORT2
Region::getInstance(const char *region_code, UErrorCode &status) {
umtx_initOnce(gRegionDataInitOnce, &loadRegionData, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
if ( !region_code ) {
status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
UnicodeString regionCodeString = UnicodeString(region_code, -1, US_INV);
@@ -491,7 +509,7 @@ Region::getInstance(const char *region_code, UErrorCode &status) {
if ( !r ) { // Unknown region code
status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
if ( r->fType == URGN_DEPRECATED && r->preferredValues->size() == 1) {
@@ -515,7 +533,7 @@ Region::getInstance (int32_t code, UErrorCode &status) {
umtx_initOnce(gRegionDataInitOnce, &loadRegionData, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
Region *r = (Region *)uhash_iget(numericCodeMap,code);
@@ -527,12 +545,12 @@ Region::getInstance (int32_t code, UErrorCode &status) {
}
if( U_FAILURE(status) ) {
- return NULL;
+ return nullptr;
}
if ( !r ) {
status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
if ( r->fType == URGN_DEPRECATED && r->preferredValues->size() == 1) {
@@ -554,13 +572,13 @@ StringEnumeration* U_EXPORT2
Region::getAvailable(URegionType type, UErrorCode &status) {
umtx_initOnce(gRegionDataInitOnce, &loadRegionData, status); // returns immediately if U_FAILURE(status)
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
return new RegionNameEnumeration(availableRegions[type],status);
}
/**
- * Returns a pointer to the region that contains this region. Returns NULL if this region is code "001" (World)
+ * Returns a pointer to the region that contains this region. Returns nullptr if this region is code "001" (World)
* or "ZZ" (Unknown region). For example, calling this method with region "IT" (Italy) returns the
* region "039" (Southern Europe).
*/
@@ -573,17 +591,17 @@ Region::getContainingRegion() const {
/**
* Return a pointer to the region that geographically contains this region and matches the given type,
- * moving multiple steps up the containment chain if necessary. Returns NULL if no containing region can be found
+ * moving multiple steps up the containment chain if necessary. Returns nullptr if no containing region can be found
* that matches the given type. Note: The URegionTypes = "URGN_GROUPING", "URGN_DEPRECATED", or "URGN_UNKNOWN"
- * are not appropriate for use in this API. NULL will be returned in this case. For example, calling this method
+ * are not appropriate for use in this API. nullptr will be returned in this case. For example, calling this method
* with region "IT" (Italy) for type "URGN_CONTINENT" returns the region "150" ( Europe ).
*/
const Region*
Region::getContainingRegion(URegionType type) const {
UErrorCode status = U_ZERO_ERROR;
umtx_initOnce(gRegionDataInitOnce, &loadRegionData, status);
- if ( containingRegion == NULL ) {
- return NULL;
+ if ( containingRegion == nullptr ) {
+ return nullptr;
}
return ( containingRegion->fType == type)? containingRegion: containingRegion->getContainingRegion(type);
@@ -592,7 +610,7 @@ Region::getContainingRegion(URegionType type) const {
/**
* Return an enumeration over the IDs of all the regions that are immediate children of this region in the
* region hierarchy. These returned regions could be either macro regions, territories, or a mixture of the two,
- * depending on the containment data as defined in CLDR. This API may return NULL if this region doesn't have
+ * depending on the containment data as defined in CLDR. This API may return nullptr if this region doesn't have
* any sub-regions. For example, calling this method with region "150" (Europe) returns an enumeration containing
* the various sub regions of Europe - "039" (Southern Europe) - "151" (Eastern Europe) - "154" (Northern Europe)
* and "155" (Western Europe).
@@ -601,7 +619,7 @@ StringEnumeration*
Region::getContainedRegions(UErrorCode &status) const {
umtx_initOnce(gRegionDataInitOnce, &loadRegionData, status); // returns immediately if U_FAILURE(status)
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
return new RegionNameEnumeration(containedRegions,status);
}
@@ -615,33 +633,30 @@ Region::getContainedRegions(UErrorCode &status) const {
StringEnumeration*
Region::getContainedRegions( URegionType type, UErrorCode &status ) const {
umtx_initOnce(gRegionDataInitOnce, &loadRegionData, status); // returns immediately if U_FAILURE(status)
+
+ UVector result(nullptr, uhash_compareChars, status);
+ LocalPointer<StringEnumeration> cr(getContainedRegions(status), status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
- UVector *result = new UVector(NULL, uhash_compareChars, status);
-
- StringEnumeration *cr = getContainedRegions(status);
-
- for ( int32_t i = 0 ; i < cr->count(status) ; i++ ) {
- const char *regionId = cr->next(NULL,status);
- const Region *r = Region::getInstance(regionId,status);
+ const char *regionId;
+ while((regionId = cr->next(nullptr, status)) != nullptr && U_SUCCESS(status)) {
+ const Region *r = Region::getInstance(regionId, status);
if ( r->getType() == type) {
- result->addElementX((void *)&r->idStr,status);
+ result.addElement(const_cast<UnicodeString *>(&r->idStr), status);
} else {
- StringEnumeration *children = r->getContainedRegions(type, status);
- for ( int32_t j = 0 ; j < children->count(status) ; j++ ) {
- const char *id2 = children->next(NULL,status);
+ LocalPointer<StringEnumeration> children(r->getContainedRegions(type, status));
+ const char *id2;
+ while(U_SUCCESS(status) && ((id2 = children->next(nullptr, status)) != nullptr)) {
const Region *r2 = Region::getInstance(id2,status);
- result->addElementX((void *)&r2->idStr,status);
+ result.addElement(const_cast<UnicodeString *>(&r2->idStr), status);
}
- delete children;
}
}
- delete cr;
- StringEnumeration* resultEnumeration = new RegionNameEnumeration(result,status);
- delete result;
- return resultEnumeration;
+ LocalPointer<StringEnumeration> resultEnumeration(
+ new RegionNameEnumeration(&result, status), status);
+ return U_SUCCESS(status) ? resultEnumeration.orphan() : nullptr;
}
/**
@@ -653,33 +668,33 @@ Region::contains(const Region &other) const {
umtx_initOnce(gRegionDataInitOnce, &loadRegionData, status);
if (!containedRegions) {
- return FALSE;
+ return false;
}
if (containedRegions->contains((void *)&other.idStr)) {
- return TRUE;
+ return true;
} else {
for ( int32_t i = 0 ; i < containedRegions->size() ; i++ ) {
UnicodeString *crStr = (UnicodeString *)containedRegions->elementAt(i);
Region *cr = (Region *) uhash_get(regionIDMap,(void *)crStr);
if ( cr && cr->contains(other) ) {
- return TRUE;
+ return true;
}
}
}
- return FALSE;
+ return false;
}
/**
* For deprecated regions, return an enumeration over the IDs of the regions that are the preferred replacement
- * regions for this region. Returns NULL for a non-deprecated region. For example, calling this method with region
+ * regions for this region. Returns nullptr for a non-deprecated region. For example, calling this method with region
* "SU" (Soviet Union) would return a list of the regions containing "RU" (Russia), "AM" (Armenia), "AZ" (Azerbaijan), etc...
*/
StringEnumeration*
Region::getPreferredValues(UErrorCode &status) const {
umtx_initOnce(gRegionDataInitOnce, &loadRegionData, status); // returns immediately if U_FAILURE(status)
if (U_FAILURE(status) || fType != URGN_DEPRECATED) {
- return NULL;
+ return nullptr;
}
return new RegionNameEnumeration(preferredValues,status);
}
@@ -706,28 +721,31 @@ Region::getType() const {
return fType;
}
-RegionNameEnumeration::RegionNameEnumeration(UVector *fNameList, UErrorCode& status) {
- pos=0;
- if (fNameList && U_SUCCESS(status)) {
- fRegionNames = new UVector(uprv_deleteUObject, uhash_compareUnicodeString, fNameList->size(),status);
- for ( int32_t i = 0 ; i < fNameList->size() ; i++ ) {
- UnicodeString* this_region_name = (UnicodeString *)fNameList->elementAt(i);
- UnicodeString* new_region_name = new UnicodeString(*this_region_name);
- fRegionNames->addElementX((void *)new_region_name,status);
+RegionNameEnumeration::RegionNameEnumeration(UVector *nameList, UErrorCode& status) :
+ pos(0), fRegionNames(nullptr) {
+ // TODO: https://unicode-org.atlassian.net/browse/ICU-21829
+ // Is all of the copying going on here really necessary?
+ if (nameList && U_SUCCESS(status)) {
+ LocalPointer<UVector> regionNames(
+ new UVector(uprv_deleteUObject, uhash_compareUnicodeString, nameList->size(), status), status);
+ for ( int32_t i = 0 ; U_SUCCESS(status) && i < nameList->size() ; i++ ) {
+ UnicodeString* this_region_name = (UnicodeString *)nameList->elementAt(i);
+ LocalPointer<UnicodeString> new_region_name(new UnicodeString(*this_region_name), status);
+ regionNames->adoptElement(new_region_name.orphan(), status);
+ }
+ if (U_SUCCESS(status)) {
+ fRegionNames = regionNames.orphan();
}
- }
- else {
- fRegionNames = NULL;
}
}
const UnicodeString*
RegionNameEnumeration::snext(UErrorCode& status) {
- if (U_FAILURE(status) || (fRegionNames==NULL)) {
- return NULL;
+ if (U_FAILURE(status) || (fRegionNames==nullptr)) {
+ return nullptr;
}
const UnicodeString* nextStr = (const UnicodeString *)fRegionNames->elementAt(pos);
- if (nextStr!=NULL) {
+ if (nextStr!=nullptr) {
pos++;
}
return nextStr;
@@ -740,7 +758,7 @@ RegionNameEnumeration::reset(UErrorCode& /*status*/) {
int32_t
RegionNameEnumeration::count(UErrorCode& /*status*/) const {
- return (fRegionNames==NULL) ? 0 : fRegionNames->size();
+ return (fRegionNames==nullptr) ? 0 : fRegionNames->size();
}
RegionNameEnumeration::~RegionNameEnumeration() {
diff --git a/contrib/libs/icu/i18n/region_impl.h b/contrib/libs/icu/i18n/region_impl.h
index 62acaa4511..edabc6d0fe 100644
--- a/contrib/libs/icu/i18n/region_impl.h
+++ b/contrib/libs/icu/i18n/region_impl.h
@@ -26,10 +26,14 @@ U_NAMESPACE_BEGIN
class RegionNameEnumeration : public StringEnumeration {
public:
- RegionNameEnumeration(UVector *fNameList, UErrorCode& status);
+ /**
+ * Construct an string enumeration over the supplied name list.
+ * Makes a copy of the supplied input name list; does not retain a reference to the original.
+ */
+ RegionNameEnumeration(UVector *nameList, UErrorCode& status);
virtual ~RegionNameEnumeration();
- static UClassID U_EXPORT2 getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID U_EXPORT2 getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
virtual const UnicodeString* snext(UErrorCode& status) override;
virtual void reset(UErrorCode& status) override;
virtual int32_t count(UErrorCode& status) const override;
diff --git a/contrib/libs/icu/i18n/reldatefmt.cpp b/contrib/libs/icu/i18n/reldatefmt.cpp
index 6ef5160798..24d22a4b4b 100644
--- a/contrib/libs/icu/i18n/reldatefmt.cpp
+++ b/contrib/libs/icu/i18n/reldatefmt.cpp
@@ -16,6 +16,8 @@
#include <cmath>
#include <functional>
+#include "unicode/calendar.h"
+#include "unicode/datefmt.h"
#include "unicode/dtfmtsym.h"
#include "unicode/ucasemap.h"
#include "unicode/ureldatefmt.h"
@@ -184,35 +186,19 @@ const UnicodeString& RelativeDateTimeCacheData::getAbsoluteUnitString(
return nullptr; // No formatter found.
}
-static UBool getStringWithFallback(
- const UResourceBundle *resource,
- const char *key,
- UnicodeString &result,
- UErrorCode &status) {
- int32_t len = 0;
- const UChar *resStr = ures_getStringByKeyWithFallback(
- resource, key, &len, &status);
- if (U_FAILURE(status)) {
- return FALSE;
- }
- result.setTo(TRUE, resStr, len);
- return TRUE;
-}
-
-
static UBool getStringByIndex(
const UResourceBundle *resource,
int32_t idx,
UnicodeString &result,
UErrorCode &status) {
int32_t len = 0;
- const UChar *resStr = ures_getStringByIndex(
+ const char16_t *resStr = ures_getStringByIndex(
resource, idx, &len, &status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
- result.setTo(TRUE, resStr, len);
- return TRUE;
+ result.setTo(true, resStr, len);
+ return true;
}
namespace {
@@ -386,8 +372,8 @@ struct RelDateTimeFmtDataSink : public ResourceSink {
// Utility functions
static UDateRelativeDateTimeFormatterStyle styleFromAliasUnicodeString(UnicodeString s) {
- static const UChar narrow[7] = {0x002D, 0x006E, 0x0061, 0x0072, 0x0072, 0x006F, 0x0077};
- static const UChar sshort[6] = {0x002D, 0x0073, 0x0068, 0x006F, 0x0072, 0x0074,};
+ static const char16_t narrow[7] = {0x002D, 0x006E, 0x0061, 0x0072, 0x0072, 0x006F, 0x0077};
+ static const char16_t sshort[6] = {0x002D, 0x0073, 0x0068, 0x006F, 0x0072, 0x0074,};
if (s.endsWith(narrow, 7)) {
return UDAT_STYLE_NARROW;
}
@@ -661,39 +647,61 @@ static UBool loadUnitData(
return U_SUCCESS(status);
}
+static const int32_t cTypeBufMax = 32;
+
static UBool getDateTimePattern(
+ Locale locale,
const UResourceBundle *resource,
UnicodeString &result,
UErrorCode &status) {
- UnicodeString defaultCalendarName;
- if (!getStringWithFallback(
- resource,
- "calendar/default",
- defaultCalendarName,
- status)) {
- return FALSE;
+ if (U_FAILURE(status)) {
+ return false;
+ }
+ char cType[cTypeBufMax + 1];
+ Calendar::getCalendarTypeFromLocale(locale, cType, cTypeBufMax, status);
+ cType[cTypeBufMax] = 0;
+ if (U_FAILURE(status) || cType[0] == 0) {
+ status = U_ZERO_ERROR;
+ uprv_strcpy(cType, "gregorian");
}
+
+ LocalUResourceBundlePointer topLevel;
+ int32_t dateTimeFormatOffset = DateFormat::kMedium;
CharString pathBuffer;
+ // Currently, for compatibility with pre-CLDR-42 data, we default to the "atTime"
+ // combining patterns. Depending on guidance in CLDR 42 spec and on DisplayOptions,
+ // we may change this.
pathBuffer.append("calendar/", status)
- .appendInvariantChars(defaultCalendarName, status)
- .append("/DateTimePatterns", status);
- LocalUResourceBundlePointer topLevel(
+ .append(cType, status)
+ .append("/DateTimePatterns%atTime", status);
+ topLevel.adoptInstead(
ures_getByKeyWithFallback(
resource, pathBuffer.data(), nullptr, &status));
+ if (U_FAILURE(status) || ures_getSize(topLevel.getAlias()) < 4) {
+ // Fall back to standard combining patterns
+ status = U_ZERO_ERROR;
+ dateTimeFormatOffset = DateFormat::kDateTime;
+ pathBuffer.clear();
+ pathBuffer.append("calendar/", status)
+ .append(cType, status)
+ .append("/DateTimePatterns", status);
+ topLevel.adoptInstead(
+ ures_getByKeyWithFallback(
+ resource, pathBuffer.data(), nullptr, &status));
+ }
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
- int32_t size = ures_getSize(topLevel.getAlias());
- if (size <= 8) {
+ if (dateTimeFormatOffset == DateFormat::kDateTime && ures_getSize(topLevel.getAlias()) <= DateFormat::kDateTime) {
// Oops, size is too small to access the index that we want, fallback
// to a hard-coded value.
result = UNICODE_STRING_SIMPLE("{1} {0}");
- return TRUE;
+ return true;
}
- return getStringByIndex(topLevel.getAlias(), 8, result, status);
+ return getStringByIndex(topLevel.getAlias(), dateTimeFormatOffset, result, status);
}
-template<> U_I18N_API
+template<>
const RelativeDateTimeCacheData *LocaleCacheKey<RelativeDateTimeCacheData>::createObject(const void * /*unused*/, UErrorCode &status) const {
const char *localeId = fLoc.getName();
LocalUResourceBundlePointer topLevel(ures_open(nullptr, localeId, &status));
@@ -714,7 +722,7 @@ const RelativeDateTimeCacheData *LocaleCacheKey<RelativeDateTimeCacheData>::crea
return nullptr;
}
UnicodeString dateTimePattern;
- if (!getDateTimePattern(topLevel.getAlias(), dateTimePattern, status)) {
+ if (!getDateTimePattern(fLoc, topLevel.getAlias(), dateTimePattern, status)) {
return nullptr;
}
result->adoptCombinedDateAndTime(
@@ -1204,9 +1212,9 @@ UBool RelativeDateTimeFormatter::checkNoAdjustForContext(UErrorCode& status) con
// casing. The code could be written and tested if there is demand.
if (fOptBreakIterator != nullptr) {
status = U_UNSUPPORTED_ERROR;
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
void RelativeDateTimeFormatter::init(
@@ -1302,7 +1310,7 @@ U_CAPI int32_t U_EXPORT2
ureldatefmt_formatNumeric( const URelativeDateTimeFormatter* reldatefmt,
double offset,
URelativeDateTimeUnit unit,
- UChar* result,
+ char16_t* result,
int32_t resultCapacity,
UErrorCode* status)
{
@@ -1345,7 +1353,7 @@ U_CAPI int32_t U_EXPORT2
ureldatefmt_format( const URelativeDateTimeFormatter* reldatefmt,
double offset,
URelativeDateTimeUnit unit,
- UChar* result,
+ char16_t* result,
int32_t resultCapacity,
UErrorCode* status)
{
@@ -1386,11 +1394,11 @@ ureldatefmt_formatToResult(
U_CAPI int32_t U_EXPORT2
ureldatefmt_combineDateAndTime( const URelativeDateTimeFormatter* reldatefmt,
- const UChar * relativeDateString,
+ const char16_t * relativeDateString,
int32_t relativeDateStringLen,
- const UChar * timeString,
+ const char16_t * timeString,
int32_t timeStringLen,
- UChar* result,
+ char16_t* result,
int32_t resultCapacity,
UErrorCode* status )
{
diff --git a/contrib/libs/icu/i18n/reldtfmt.cpp b/contrib/libs/icu/i18n/reldtfmt.cpp
index 5fdef1c0d6..0c836a0b79 100644
--- a/contrib/libs/icu/i18n/reldtfmt.cpp
+++ b/contrib/libs/icu/i18n/reldtfmt.cpp
@@ -34,26 +34,26 @@ U_NAMESPACE_BEGIN
struct URelativeString {
int32_t offset; /** offset of this item, such as, the relative date **/
int32_t len; /** length of the string **/
- const UChar* string; /** string, or NULL if not set **/
+ const char16_t* string; /** string, or nullptr if not set **/
};
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RelativeDateFormat)
RelativeDateFormat::RelativeDateFormat(const RelativeDateFormat& other) :
- DateFormat(other), fDateTimeFormatter(NULL), fDatePattern(other.fDatePattern),
- fTimePattern(other.fTimePattern), fCombinedFormat(NULL),
+ DateFormat(other), fDateTimeFormatter(nullptr), fDatePattern(other.fDatePattern),
+ fTimePattern(other.fTimePattern), fCombinedFormat(nullptr),
fDateStyle(other.fDateStyle), fLocale(other.fLocale),
- fDatesLen(other.fDatesLen), fDates(NULL),
+ fDatesLen(other.fDatesLen), fDates(nullptr),
fCombinedHasDateAtStart(other.fCombinedHasDateAtStart),
fCapitalizationInfoSet(other.fCapitalizationInfoSet),
fCapitalizationOfRelativeUnitsForUIListMenu(other.fCapitalizationOfRelativeUnitsForUIListMenu),
fCapitalizationOfRelativeUnitsForStandAlone(other.fCapitalizationOfRelativeUnitsForStandAlone),
- fCapitalizationBrkIter(NULL)
+ fCapitalizationBrkIter(nullptr)
{
- if(other.fDateTimeFormatter != NULL) {
+ if(other.fDateTimeFormatter != nullptr) {
fDateTimeFormatter = other.fDateTimeFormatter->clone();
}
- if(other.fCombinedFormat != NULL) {
+ if(other.fCombinedFormat != nullptr) {
fCombinedFormat = new SimpleFormatter(*other.fCombinedFormat);
}
if (fDatesLen > 0) {
@@ -61,7 +61,7 @@ RelativeDateFormat::RelativeDateFormat(const RelativeDateFormat& other) :
uprv_memcpy(fDates, other.fDates, sizeof(fDates[0])*(size_t)fDatesLen);
}
#if !UCONFIG_NO_BREAK_ITERATION
- if (other.fCapitalizationBrkIter != NULL) {
+ if (other.fCapitalizationBrkIter != nullptr) {
fCapitalizationBrkIter = (other.fCapitalizationBrkIter)->clone();
}
#endif
@@ -69,11 +69,11 @@ RelativeDateFormat::RelativeDateFormat(const RelativeDateFormat& other) :
RelativeDateFormat::RelativeDateFormat( UDateFormatStyle timeStyle, UDateFormatStyle dateStyle,
const Locale& locale, UErrorCode& status) :
- DateFormat(), fDateTimeFormatter(NULL), fDatePattern(), fTimePattern(), fCombinedFormat(NULL),
- fDateStyle(dateStyle), fLocale(locale), fDatesLen(0), fDates(NULL),
- fCombinedHasDateAtStart(FALSE), fCapitalizationInfoSet(FALSE),
- fCapitalizationOfRelativeUnitsForUIListMenu(FALSE), fCapitalizationOfRelativeUnitsForStandAlone(FALSE),
- fCapitalizationBrkIter(NULL)
+ DateFormat(), fDateTimeFormatter(nullptr), fDatePattern(), fTimePattern(), fCombinedFormat(nullptr),
+ fDateStyle(dateStyle), fLocale(locale), fDatesLen(0), fDates(nullptr),
+ fCombinedHasDateAtStart(false), fCapitalizationInfoSet(false),
+ fCapitalizationOfRelativeUnitsForUIListMenu(false), fCapitalizationOfRelativeUnitsForStandAlone(false),
+ fCapitalizationBrkIter(nullptr)
{
if(U_FAILURE(status) ) {
return;
@@ -91,7 +91,7 @@ RelativeDateFormat::RelativeDateFormat( UDateFormatStyle timeStyle, UDateFormatS
if (baseDateStyle != UDAT_NONE) {
df = createDateInstance((EStyle)baseDateStyle, locale);
fDateTimeFormatter=dynamic_cast<SimpleDateFormat *>(df);
- if (fDateTimeFormatter == NULL) {
+ if (fDateTimeFormatter == nullptr) {
status = U_UNSUPPORTED_ERROR;
return;
}
@@ -99,7 +99,7 @@ RelativeDateFormat::RelativeDateFormat( UDateFormatStyle timeStyle, UDateFormatS
if (timeStyle != UDAT_NONE) {
df = createTimeInstance((EStyle)timeStyle, locale);
SimpleDateFormat *sdf = dynamic_cast<SimpleDateFormat *>(df);
- if (sdf != NULL) {
+ if (sdf != nullptr) {
sdf->toPattern(fTimePattern);
delete sdf;
}
@@ -108,7 +108,7 @@ RelativeDateFormat::RelativeDateFormat( UDateFormatStyle timeStyle, UDateFormatS
// does not matter whether timeStyle is UDAT_NONE, we need something for fDateTimeFormatter
df = createTimeInstance((EStyle)timeStyle, locale);
fDateTimeFormatter=dynamic_cast<SimpleDateFormat *>(df);
- if (fDateTimeFormatter == NULL) {
+ if (fDateTimeFormatter == nullptr) {
status = U_UNSUPPORTED_ERROR;
delete df;
return;
@@ -117,7 +117,7 @@ RelativeDateFormat::RelativeDateFormat( UDateFormatStyle timeStyle, UDateFormatS
}
// Initialize the parent fCalendar, so that parse() works correctly.
- initializeCalendar(NULL, locale, status);
+ initializeCalendar(nullptr, locale, status);
loadDates(status);
}
@@ -149,7 +149,7 @@ bool RelativeDateFormat::operator==(const Format& other) const {
return false;
}
-static const UChar APOSTROPHE = (UChar)0x0027;
+static const char16_t APOSTROPHE = (char16_t)0x0027;
UnicodeString& RelativeDateFormat::format( Calendar& cal,
UnicodeString& appendTo,
@@ -164,17 +164,17 @@ UnicodeString& RelativeDateFormat::format( Calendar& cal,
// look up string
int32_t len = 0;
- const UChar *theString = getStringForDay(dayDiff, len, status);
- if(U_SUCCESS(status) && (theString!=NULL)) {
+ const char16_t *theString = getStringForDay(dayDiff, len, status);
+ if(U_SUCCESS(status) && (theString!=nullptr)) {
// found a relative string
relativeDayString.setTo(theString, len);
}
if ( relativeDayString.length() > 0 && !fDatePattern.isEmpty() &&
- (fTimePattern.isEmpty() || fCombinedFormat == NULL || fCombinedHasDateAtStart)) {
+ (fTimePattern.isEmpty() || fCombinedFormat == nullptr || fCombinedHasDateAtStart)) {
#if !UCONFIG_NO_BREAK_ITERATION
// capitalize relativeDayString according to context for relative, set formatter no context
- if ( u_islower(relativeDayString.char32At(0)) && fCapitalizationBrkIter!= NULL &&
+ if ( u_islower(relativeDayString.char32At(0)) && fCapitalizationBrkIter!= nullptr &&
( capitalizationContext==UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE ||
(capitalizationContext==UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU && fCapitalizationOfRelativeUnitsForUIListMenu) ||
(capitalizationContext==UDISPCTX_CAPITALIZATION_FOR_STANDALONE && fCapitalizationOfRelativeUnitsForStandAlone) ) ) {
@@ -191,7 +191,7 @@ UnicodeString& RelativeDateFormat::format( Calendar& cal,
if (fDatePattern.isEmpty()) {
fDateTimeFormatter->applyPattern(fTimePattern);
fDateTimeFormatter->format(cal,appendTo,pos);
- } else if (fTimePattern.isEmpty() || fCombinedFormat == NULL) {
+ } else if (fTimePattern.isEmpty() || fCombinedFormat == nullptr) {
if (relativeDayString.length() > 0) {
appendTo.append(relativeDayString);
} else {
@@ -243,16 +243,16 @@ void RelativeDateFormat::parse( const UnicodeString& text,
// no date pattern, try parsing as time
fDateTimeFormatter->applyPattern(fTimePattern);
fDateTimeFormatter->parse(text,cal,pos);
- } else if (fTimePattern.isEmpty() || fCombinedFormat == NULL) {
+ } else if (fTimePattern.isEmpty() || fCombinedFormat == nullptr) {
// no time pattern or way to combine, try parsing as date
// first check whether text matches a relativeDayString
- UBool matchedRelative = FALSE;
+ UBool matchedRelative = false;
for (int n=0; n < fDatesLen && !matchedRelative; n++) {
- if (fDates[n].string != NULL &&
+ if (fDates[n].string != nullptr &&
text.compare(startIndex, fDates[n].len, fDates[n].string) == 0) {
// it matched, handle the relative day string
UErrorCode status = U_ZERO_ERROR;
- matchedRelative = TRUE;
+ matchedRelative = true;
// Set the calendar to now+offset
cal.setTime(Calendar::getNow(),status);
@@ -280,7 +280,7 @@ void RelativeDateFormat::parse( const UnicodeString& text,
UErrorCode status = U_ZERO_ERROR;
for (int n=0; n < fDatesLen; n++) {
int32_t relativeStringOffset;
- if (fDates[n].string != NULL &&
+ if (fDates[n].string != nullptr &&
(relativeStringOffset = modifiedText.indexOf(fDates[n].string, fDates[n].len, startIndex)) >= startIndex) {
// it matched, replace the relative date with a real one for parsing
UnicodeString dateString;
@@ -347,20 +347,20 @@ RelativeDateFormat::parse(const UnicodeString& text, UErrorCode& status) const
}
-const UChar *RelativeDateFormat::getStringForDay(int32_t day, int32_t &len, UErrorCode &status) const {
+const char16_t *RelativeDateFormat::getStringForDay(int32_t day, int32_t &len, UErrorCode &status) const {
if(U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
// Is it inside the resource bundle's range?
int n = day + UDAT_DIRECTION_THIS;
if (n >= 0 && n < fDatesLen) {
- if (fDates[n].offset == day && fDates[n].string != NULL) {
+ if (fDates[n].offset == day && fDates[n].string != nullptr) {
len = fDates[n].len;
return fDates[n].string;
}
}
- return NULL; // not found.
+ return nullptr; // not found.
}
UnicodeString&
@@ -370,7 +370,7 @@ RelativeDateFormat::toPattern(UnicodeString& result, UErrorCode& status) const
result.remove();
if (fDatePattern.isEmpty()) {
result.setTo(fTimePattern);
- } else if (fTimePattern.isEmpty() || fCombinedFormat == NULL) {
+ } else if (fTimePattern.isEmpty() || fCombinedFormat == nullptr) {
result.setTo(fDatePattern);
} else {
fCombinedFormat->format(fTimePattern, fDatePattern, result, status);
@@ -424,17 +424,17 @@ RelativeDateFormat::setContext(UDisplayContext value, UErrorCode& status)
if (!fCapitalizationInfoSet &&
(value==UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU || value==UDISPCTX_CAPITALIZATION_FOR_STANDALONE)) {
initCapitalizationContextInfo(fLocale);
- fCapitalizationInfoSet = TRUE;
+ fCapitalizationInfoSet = true;
}
#if !UCONFIG_NO_BREAK_ITERATION
- if ( fCapitalizationBrkIter == NULL && (value==UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE ||
+ if ( fCapitalizationBrkIter == nullptr && (value==UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE ||
(value==UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU && fCapitalizationOfRelativeUnitsForUIListMenu) ||
(value==UDISPCTX_CAPITALIZATION_FOR_STANDALONE && fCapitalizationOfRelativeUnitsForStandAlone)) ) {
status = U_ZERO_ERROR;
fCapitalizationBrkIter = BreakIterator::createSentenceInstance(fLocale, status);
if (U_FAILURE(status)) {
delete fCapitalizationBrkIter;
- fCapitalizationBrkIter = NULL;
+ fCapitalizationBrkIter = nullptr;
}
}
#endif
@@ -445,17 +445,17 @@ void
RelativeDateFormat::initCapitalizationContextInfo(const Locale& thelocale)
{
#if !UCONFIG_NO_BREAK_ITERATION
- const char * localeID = (thelocale != NULL)? thelocale.getBaseName(): NULL;
+ const char * localeID = (thelocale != nullptr)? thelocale.getBaseName(): nullptr;
UErrorCode status = U_ZERO_ERROR;
- LocalUResourceBundlePointer rb(ures_open(NULL, localeID, &status));
+ LocalUResourceBundlePointer rb(ures_open(nullptr, localeID, &status));
ures_getByKeyWithFallback(rb.getAlias(),
"contextTransforms/relative",
rb.getAlias(), &status);
- if (U_SUCCESS(status) && rb != NULL) {
+ if (U_SUCCESS(status) && rb != nullptr) {
int32_t len = 0;
const int32_t * intVector = ures_getIntVector(rb.getAlias(),
&len, &status);
- if (U_SUCCESS(status) && intVector != NULL && len >= 2) {
+ if (U_SUCCESS(status) && intVector != nullptr && len >= 2) {
fCapitalizationOfRelativeUnitsForUIListMenu = static_cast<UBool>(intVector[0]);
fCapitalizationOfRelativeUnitsForStandAlone = static_cast<UBool>(intVector[1]);
}
@@ -477,7 +477,7 @@ struct RelDateFmtDataSink : public ResourceSink {
RelDateFmtDataSink(URelativeString* fDates, int32_t len) : fDatesPtr(fDates), fDatesLen(len) {
for (int32_t i = 0; i < fDatesLen; ++i) {
fDatesPtr[i].offset = 0;
- fDatesPtr[i].string = NULL;
+ fDatesPtr[i].string = nullptr;
fDatesPtr[i].len = -1;
}
}
@@ -495,7 +495,7 @@ struct RelDateFmtDataSink : public ResourceSink {
// Put in the proper spot, but don't override existing data.
n = offset + UDAT_DIRECTION_THIS; // Converts to index in UDAT_R
- if (n < fDatesLen && fDatesPtr[n].string == NULL) {
+ if (n < fDatesLen && fDatesPtr[n].string == nullptr) {
// Not found and n is an empty slot.
fDatesPtr[n].offset = offset;
fDatesPtr[n].string = value.getString(len, errorCode);
@@ -512,15 +512,15 @@ RelDateFmtDataSink::~RelDateFmtDataSink() {}
} // Namespace
-static const UChar patItem1[] = {0x7B,0x31,0x7D}; // "{1}"
+static const char16_t patItem1[] = {0x7B,0x31,0x7D}; // "{1}"
static const int32_t patItem1Len = 3;
void RelativeDateFormat::loadDates(UErrorCode &status) {
- UResourceBundle *rb = ures_open(NULL, fLocale.getBaseName(), &status);
+ UResourceBundle *rb = ures_open(nullptr, fLocale.getBaseName(), &status);
LocalUResourceBundlePointer dateTimePatterns(
ures_getByKeyWithFallback(rb,
"calendar/gregorian/DateTimePatterns",
- (UResourceBundle*)NULL, &status));
+ (UResourceBundle*)nullptr, &status));
if(U_SUCCESS(status)) {
int32_t patternsSize = ures_getSize(dateTimePatterns.getAlias());
if (patternsSize > kDateTime) {
@@ -534,11 +534,11 @@ void RelativeDateFormat::loadDates(UErrorCode &status) {
}
}
- const UChar *resStr = ures_getStringByIndex(dateTimePatterns.getAlias(), glueIndex, &resStrLen, &status);
+ const char16_t *resStr = ures_getStringByIndex(dateTimePatterns.getAlias(), glueIndex, &resStrLen, &status);
if (U_SUCCESS(status) && resStrLen >= patItem1Len && u_strncmp(resStr,patItem1,patItem1Len)==0) {
- fCombinedHasDateAtStart = TRUE;
+ fCombinedHasDateAtStart = true;
}
- fCombinedFormat = new SimpleFormatter(UnicodeString(TRUE, resStr, resStrLen), 2, 2, status);
+ fCombinedFormat = new SimpleFormatter(UnicodeString(true, resStr, resStrLen), 2, 2, status);
}
}
@@ -567,7 +567,7 @@ RelativeDateFormat::initializeCalendar(TimeZone* adoptZone, const Locale& locale
if(!U_FAILURE(status)) {
fCalendar = Calendar::createInstance(adoptZone?adoptZone:TimeZone::createDefault(), locale, status);
}
- if (U_SUCCESS(status) && fCalendar == NULL) {
+ if (U_SUCCESS(status) && fCalendar == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
return fCalendar;
diff --git a/contrib/libs/icu/i18n/reldtfmt.h b/contrib/libs/icu/i18n/reldtfmt.h
index 98b333a02b..3af43d49ca 100644
--- a/contrib/libs/icu/i18n/reldtfmt.h
+++ b/contrib/libs/icu/i18n/reldtfmt.h
@@ -233,7 +233,7 @@ public:
* with this date-time formatter.
* @internal ICU 4.8
*/
- virtual const DateFormatSymbols* getDateFormatSymbols(void) const;
+ virtual const DateFormatSymbols* getDateFormatSymbols() const;
/**
* Set a particular UDisplayContext value in the formatter, such as
@@ -273,9 +273,9 @@ private:
* Get the string at a specific offset.
* @param day day offset ( -1, 0, 1, etc.. )
* @param len on output, length of string.
- * @return the string, or NULL if none at that location.
+ * @return the string, or nullptr if none at that location.
*/
- const UChar *getStringForDay(int32_t day, int32_t &len, UErrorCode &status) const;
+ const char16_t *getStringForDay(int32_t day, int32_t &len, UErrorCode &status) const;
/**
* Load the Date string array
@@ -294,7 +294,7 @@ private:
/**
* initializes fCalendar from parameters. Returns fCalendar as a convenience.
- * @param adoptZone Zone to be adopted, or NULL for TimeZone::createDefault().
+ * @param adoptZone Zone to be adopted, or nullptr for TimeZone::createDefault().
* @param locale Locale of the calendar
* @param status Error code
* @return the newly constructed fCalendar
@@ -314,7 +314,7 @@ public:
* @return The class ID for all objects of this class.
* @internal ICU 3.8
*/
- U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
+ U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
/**
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
@@ -327,7 +327,7 @@ public:
* other classes have different class IDs.
* @internal ICU 3.8
*/
- virtual UClassID getDynamicClassID(void) const override;
+ virtual UClassID getDynamicClassID() const override;
};
diff --git a/contrib/libs/icu/i18n/rematch.cpp b/contrib/libs/icu/i18n/rematch.cpp
index 7d6eaeed8b..7a39afbf7b 100644
--- a/contrib/libs/icu/i18n/rematch.cpp
+++ b/contrib/libs/icu/i18n/rematch.cpp
@@ -73,7 +73,7 @@ RegexMatcher::RegexMatcher(const RegexPattern *pat) {
if (U_FAILURE(fDeferredStatus)) {
return;
}
- if (pat==NULL) {
+ if (pat==nullptr) {
fDeferredStatus = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@@ -98,7 +98,7 @@ RegexMatcher::RegexMatcher(const UnicodeString &regexp, const UnicodeString &inp
init2(&inputText, status);
utext_close(&inputText);
- fInputUniStrMaybeMutable = TRUE;
+ fInputUniStrMaybeMutable = true;
}
@@ -157,12 +157,12 @@ RegexMatcher::~RegexMatcher() {
delete fStack;
if (fData != fSmallData) {
uprv_free(fData);
- fData = NULL;
+ fData = nullptr;
}
if (fPatternOwned) {
delete fPatternOwned;
- fPatternOwned = NULL;
- fPattern = NULL;
+ fPatternOwned = nullptr;
+ fPattern = nullptr;
}
if (fInput) {
@@ -189,8 +189,8 @@ RegexMatcher::~RegexMatcher() {
// to run safely.
//
void RegexMatcher::init(UErrorCode &status) {
- fPattern = NULL;
- fPatternOwned = NULL;
+ fPattern = nullptr;
+ fPatternOwned = nullptr;
fFrameSize = 0;
fRegionStart = 0;
fRegionLimit = 0;
@@ -200,37 +200,37 @@ void RegexMatcher::init(UErrorCode &status) {
fLookLimit = 0;
fActiveStart = 0;
fActiveLimit = 0;
- fTransparentBounds = FALSE;
- fAnchoringBounds = TRUE;
- fMatch = FALSE;
+ fTransparentBounds = false;
+ fAnchoringBounds = true;
+ fMatch = false;
fMatchStart = 0;
fMatchEnd = 0;
fLastMatchEnd = -1;
fAppendPosition = 0;
- fHitEnd = FALSE;
- fRequireEnd = FALSE;
- fStack = NULL;
- fFrame = NULL;
+ fHitEnd = false;
+ fRequireEnd = false;
+ fStack = nullptr;
+ fFrame = nullptr;
fTimeLimit = 0;
fTime = 0;
fTickCounter = 0;
fStackLimit = DEFAULT_BACKTRACK_STACK_CAPACITY;
- fCallbackFn = NULL;
- fCallbackContext = NULL;
- fFindProgressCallbackFn = NULL;
- fFindProgressCallbackContext = NULL;
- fTraceDebug = FALSE;
+ fCallbackFn = nullptr;
+ fCallbackContext = nullptr;
+ fFindProgressCallbackFn = nullptr;
+ fFindProgressCallbackContext = nullptr;
+ fTraceDebug = false;
fDeferredStatus = status;
fData = fSmallData;
- fWordBreakItr = NULL;
- fGCBreakItr = NULL;
+ fWordBreakItr = nullptr;
+ fGCBreakItr = nullptr;
- fStack = NULL;
- fInputText = NULL;
- fAltInputText = NULL;
- fInput = NULL;
+ fStack = nullptr;
+ fInputText = nullptr;
+ fAltInputText = nullptr;
+ fInput = nullptr;
fInputLength = 0;
- fInputUniStrMaybeMutable = FALSE;
+ fInputUniStrMaybeMutable = false;
}
//
@@ -245,14 +245,14 @@ void RegexMatcher::init2(UText *input, UErrorCode &status) {
if (fPattern->fDataSize > UPRV_LENGTHOF(fSmallData)) {
fData = (int64_t *)uprv_malloc(fPattern->fDataSize * sizeof(int64_t));
- if (fData == NULL) {
+ if (fData == nullptr) {
status = fDeferredStatus = U_MEMORY_ALLOCATION_ERROR;
return;
}
}
fStack = new UVector64(status);
- if (fStack == NULL) {
+ if (fStack == nullptr) {
status = fDeferredStatus = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -266,10 +266,10 @@ void RegexMatcher::init2(UText *input, UErrorCode &status) {
}
-static const UChar BACKSLASH = 0x5c;
-static const UChar DOLLARSIGN = 0x24;
-static const UChar LEFTBRACKET = 0x7b;
-static const UChar RIGHTBRACKET = 0x7d;
+static const char16_t BACKSLASH = 0x5c;
+static const char16_t DOLLARSIGN = 0x24;
+static const char16_t LEFTBRACKET = 0x7b;
+static const char16_t RIGHTBRACKET = 0x7d;
//--------------------------------------------------------------------------------
//
@@ -309,7 +309,7 @@ RegexMatcher &RegexMatcher::appendReplacement(UText *dest,
status = fDeferredStatus;
return *this;
}
- if (fMatch == FALSE) {
+ if (fMatch == false) {
status = U_REGEX_INVALID_STATE;
return *this;
}
@@ -326,10 +326,10 @@ RegexMatcher &RegexMatcher::appendReplacement(UText *dest,
len16 = (int32_t)(fMatchStart-fAppendPosition);
} else {
UErrorCode lengthStatus = U_ZERO_ERROR;
- len16 = utext_extract(fInputText, fAppendPosition, fMatchStart, NULL, 0, &lengthStatus);
+ len16 = utext_extract(fInputText, fAppendPosition, fMatchStart, nullptr, 0, &lengthStatus);
}
- UChar *inputChars = (UChar *)uprv_malloc(sizeof(UChar)*(len16+1));
- if (inputChars == NULL) {
+ char16_t *inputChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(len16+1));
+ if (inputChars == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return *this;
}
@@ -364,10 +364,10 @@ RegexMatcher &RegexMatcher::appendReplacement(UText *dest,
UChar32 escapedChar = u_unescapeAt(uregex_utext_unescape_charAt, &offset, INT32_MAX, &context);
if (escapedChar != (UChar32)0xFFFFFFFF) {
if (U_IS_BMP(escapedChar)) {
- UChar c16 = (UChar)escapedChar;
+ char16_t c16 = (char16_t)escapedChar;
destLen += utext_replace(dest, destLen, destLen, &c16, 1, &status);
} else {
- UChar surrogate[2];
+ char16_t surrogate[2];
surrogate[0] = U16_LEAD(escapedChar);
surrogate[1] = U16_TRAIL(escapedChar);
if (U_SUCCESS(status)) {
@@ -386,10 +386,10 @@ RegexMatcher &RegexMatcher::appendReplacement(UText *dest,
(void)UTEXT_NEXT32(replacement);
// Plain backslash escape. Just put out the escaped character.
if (U_IS_BMP(c)) {
- UChar c16 = (UChar)c;
+ char16_t c16 = (char16_t)c;
destLen += utext_replace(dest, destLen, destLen, &c16, 1, &status);
} else {
- UChar surrogate[2];
+ char16_t surrogate[2];
surrogate[0] = U16_LEAD(c);
surrogate[1] = U16_TRAIL(c);
if (U_SUCCESS(status)) {
@@ -400,10 +400,10 @@ RegexMatcher &RegexMatcher::appendReplacement(UText *dest,
} else if (c != DOLLARSIGN) {
// Normal char, not a $. Copy it out without further checks.
if (U_IS_BMP(c)) {
- UChar c16 = (UChar)c;
+ char16_t c16 = (char16_t)c;
destLen += utext_replace(dest, destLen, destLen, &c16, 1, &status);
} else {
- UChar surrogate[2];
+ char16_t surrogate[2];
surrogate[0] = U16_LEAD(c);
surrogate[1] = U16_TRAIL(c);
if (U_SUCCESS(status)) {
@@ -449,7 +449,7 @@ RegexMatcher &RegexMatcher::appendReplacement(UText *dest,
if (nextChar == U_SENTINEL) {
break;
}
- if (u_isdigit(nextChar) == FALSE) {
+ if (u_isdigit(nextChar) == false) {
break;
}
int32_t nextDigitVal = u_charDigitValue(nextChar);
@@ -524,12 +524,12 @@ UText *RegexMatcher::appendTail(UText *dest, UErrorCode &status) {
if (UTEXT_USES_U16(fInputText)) {
len16 = (int32_t)(fInputLength-fAppendPosition);
} else {
- len16 = utext_extract(fInputText, fAppendPosition, fInputLength, NULL, 0, &status);
+ len16 = utext_extract(fInputText, fAppendPosition, fInputLength, nullptr, 0, &status);
status = U_ZERO_ERROR; // buffer overflow
}
- UChar *inputChars = (UChar *)uprv_malloc(sizeof(UChar)*(len16));
- if (inputChars == NULL) {
+ char16_t *inputChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(len16));
+ if (inputChars == nullptr) {
fDeferredStatus = U_MEMORY_ALLOCATION_ERROR;
} else {
utext_extract(fInputText, fAppendPosition, fInputLength, inputChars, len16, &status); // unterminated
@@ -561,7 +561,7 @@ int64_t RegexMatcher::end64(int32_t group, UErrorCode &err) const {
if (U_FAILURE(err)) {
return -1;
}
- if (fMatch == FALSE) {
+ if (fMatch == false) {
err = U_REGEX_INVALID_STATE;
return -1;
}
@@ -594,16 +594,16 @@ int32_t RegexMatcher::end(int32_t group, UErrorCode &err) const {
// string from the find() function, and calls the user progress callback
// function if there is one installed.
//
-// Return: TRUE if the find operation is to be terminated.
-// FALSE if the find operation is to continue running.
+// Return: true if the find operation is to be terminated.
+// false if the find operation is to continue running.
//
//--------------------------------------------------------------------------------
UBool RegexMatcher::findProgressInterrupt(int64_t pos, UErrorCode &status) {
if (fFindProgressCallbackFn && !(*fFindProgressCallbackFn)(fFindProgressCallbackContext, pos)) {
status = U_REGEX_STOPPED_BY_CALLER;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//--------------------------------------------------------------------------------
@@ -613,7 +613,7 @@ UBool RegexMatcher::findProgressInterrupt(int64_t pos, UErrorCode &status) {
//--------------------------------------------------------------------------------
UBool RegexMatcher::find() {
if (U_FAILURE(fDeferredStatus)) {
- return FALSE;
+ return false;
}
UErrorCode status = U_ZERO_ERROR;
UBool result = find(status);
@@ -630,11 +630,11 @@ UBool RegexMatcher::find(UErrorCode &status) {
// matcher has been reset.)
//
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (U_FAILURE(fDeferredStatus)) {
status = fDeferredStatus;
- return FALSE;
+ return false;
}
if (UTEXT_FULL_TEXT_IN_CHUNK(fInputText, fInputLength)) {
@@ -654,9 +654,9 @@ UBool RegexMatcher::find(UErrorCode &status) {
// Previous match had zero length. Move start position up one position
// to avoid sending find() into a loop on zero-length matches.
if (startPos >= fActiveLimit) {
- fMatch = FALSE;
- fHitEnd = TRUE;
- return FALSE;
+ fMatch = false;
+ fHitEnd = true;
+ return false;
}
UTEXT_SETNATIVEINDEX(fInputText, startPos);
(void)UTEXT_NEXT32(fInputText);
@@ -667,8 +667,8 @@ UBool RegexMatcher::find(UErrorCode &status) {
// A previous find() failed to match. Don't try again.
// (without this test, a pattern with a zero-length match
// could match again at the end of an input string.)
- fHitEnd = TRUE;
- return FALSE;
+ fHitEnd = true;
+ return false;
}
}
@@ -681,9 +681,9 @@ UBool RegexMatcher::find(UErrorCode &status) {
if (UTEXT_USES_U16(fInputText)) {
testStartLimit = fActiveLimit - fPattern->fMinMatchLen;
if (startPos > testStartLimit) {
- fMatch = FALSE;
- fHitEnd = TRUE;
- return FALSE;
+ fMatch = false;
+ fHitEnd = true;
+ return false;
}
} else {
// We don't know exactly how long the minimum match length is in native characters.
@@ -699,16 +699,16 @@ UBool RegexMatcher::find(UErrorCode &status) {
// No optimization was found.
// Try a match at each input position.
for (;;) {
- MatchAt(startPos, FALSE, status);
+ MatchAt(startPos, false, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (fMatch) {
- return TRUE;
+ return true;
}
if (startPos >= testStartLimit) {
- fHitEnd = TRUE;
- return FALSE;
+ fHitEnd = true;
+ return false;
}
UTEXT_SETNATIVEINDEX(fInputText, startPos);
(void)UTEXT_NEXT32(fInputText);
@@ -717,7 +717,7 @@ UBool RegexMatcher::find(UErrorCode &status) {
// match at the end of a string, so we must make sure that the loop
// runs with startPos == testStartLimit the last time through.
if (findProgressInterrupt(startPos, status))
- return FALSE;
+ return false;
}
UPRV_UNREACHABLE_EXIT;
@@ -725,12 +725,12 @@ UBool RegexMatcher::find(UErrorCode &status) {
// Matches are only possible at the start of the input string
// (pattern begins with ^ or \A)
if (startPos > fActiveStart) {
- fMatch = FALSE;
- return FALSE;
+ fMatch = false;
+ return false;
}
- MatchAt(startPos, FALSE, status);
+ MatchAt(startPos, false, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
return fMatch;
@@ -749,22 +749,22 @@ UBool RegexMatcher::find(UErrorCode &status) {
// and handle end of text in the following block.
if (c >= 0 && ((c<256 && fPattern->fInitialChars8->contains(c)) ||
(c>=256 && fPattern->fInitialChars->contains(c)))) {
- MatchAt(pos, FALSE, status);
+ MatchAt(pos, false, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (fMatch) {
- return TRUE;
+ return true;
}
UTEXT_SETNATIVEINDEX(fInputText, pos);
}
if (startPos > testStartLimit) {
- fMatch = FALSE;
- fHitEnd = TRUE;
- return FALSE;
+ fMatch = false;
+ fHitEnd = true;
+ return false;
}
if (findProgressInterrupt(startPos, status))
- return FALSE;
+ return false;
}
}
UPRV_UNREACHABLE_EXIT;
@@ -781,22 +781,22 @@ UBool RegexMatcher::find(UErrorCode &status) {
c = UTEXT_NEXT32(fInputText);
startPos = UTEXT_GETNATIVEINDEX(fInputText);
if (c == theChar) {
- MatchAt(pos, FALSE, status);
+ MatchAt(pos, false, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (fMatch) {
- return TRUE;
+ return true;
}
UTEXT_SETNATIVEINDEX(fInputText, startPos);
}
if (startPos > testStartLimit) {
- fMatch = FALSE;
- fHitEnd = TRUE;
- return FALSE;
+ fMatch = false;
+ fHitEnd = true;
+ return false;
}
if (findProgressInterrupt(startPos, status))
- return FALSE;
+ return false;
}
}
UPRV_UNREACHABLE_EXIT;
@@ -805,12 +805,12 @@ UBool RegexMatcher::find(UErrorCode &status) {
{
UChar32 ch;
if (startPos == fAnchorStart) {
- MatchAt(startPos, FALSE, status);
+ MatchAt(startPos, false, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (fMatch) {
- return TRUE;
+ return true;
}
UTEXT_SETNATIVEINDEX(fInputText, startPos);
ch = UTEXT_NEXT32(fInputText);
@@ -824,19 +824,19 @@ UBool RegexMatcher::find(UErrorCode &status) {
if (fPattern->fFlags & UREGEX_UNIX_LINES) {
for (;;) {
if (ch == 0x0a) {
- MatchAt(startPos, FALSE, status);
+ MatchAt(startPos, false, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (fMatch) {
- return TRUE;
+ return true;
}
UTEXT_SETNATIVEINDEX(fInputText, startPos);
}
if (startPos >= testStartLimit) {
- fMatch = FALSE;
- fHitEnd = TRUE;
- return FALSE;
+ fMatch = false;
+ fHitEnd = true;
+ return false;
}
ch = UTEXT_NEXT32(fInputText);
startPos = UTEXT_GETNATIVEINDEX(fInputText);
@@ -844,7 +844,7 @@ UBool RegexMatcher::find(UErrorCode &status) {
// match at the end of a string, so we must make sure that the loop
// runs with startPos == testStartLimit the last time through.
if (findProgressInterrupt(startPos, status))
- return FALSE;
+ return false;
}
} else {
for (;;) {
@@ -853,19 +853,19 @@ UBool RegexMatcher::find(UErrorCode &status) {
(void)UTEXT_NEXT32(fInputText);
startPos = UTEXT_GETNATIVEINDEX(fInputText);
}
- MatchAt(startPos, FALSE, status);
+ MatchAt(startPos, false, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (fMatch) {
- return TRUE;
+ return true;
}
UTEXT_SETNATIVEINDEX(fInputText, startPos);
}
if (startPos >= testStartLimit) {
- fMatch = FALSE;
- fHitEnd = TRUE;
- return FALSE;
+ fMatch = false;
+ fHitEnd = true;
+ return false;
}
ch = UTEXT_NEXT32(fInputText);
startPos = UTEXT_GETNATIVEINDEX(fInputText);
@@ -873,7 +873,7 @@ UBool RegexMatcher::find(UErrorCode &status) {
// match at the end of a string, so we must make sure that the loop
// runs with startPos == testStartLimit the last time through.
if (findProgressInterrupt(startPos, status))
- return FALSE;
+ return false;
}
}
}
@@ -884,7 +884,7 @@ UBool RegexMatcher::find(UErrorCode &status) {
// we have reports of this in production code, don't use UPRV_UNREACHABLE_EXIT.
// See ICU-21669.
status = U_INTERNAL_PROGRAM_ERROR;
- return FALSE;
+ return false;
}
UPRV_UNREACHABLE_EXIT;
@@ -894,23 +894,23 @@ UBool RegexMatcher::find(UErrorCode &status) {
UBool RegexMatcher::find(int64_t start, UErrorCode &status) {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (U_FAILURE(fDeferredStatus)) {
status = fDeferredStatus;
- return FALSE;
+ return false;
}
this->reset(); // Note: Reset() is specified by Java Matcher documentation.
// This will reset the region to be the full input length.
if (start < 0) {
status = U_INDEX_OUTOFBOUNDS_ERROR;
- return FALSE;
+ return false;
}
int64_t nativeStart = start;
if (nativeStart < fActiveStart || nativeStart > fActiveLimit) {
status = U_INDEX_OUTOFBOUNDS_ERROR;
- return FALSE;
+ return false;
}
fMatchEnd = nativeStart;
return find(status);
@@ -933,7 +933,7 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
startPos = (int32_t)fActiveStart;
}
- const UChar *inputBuf = fInputText->chunkContents;
+ const char16_t *inputBuf = fInputText->chunkContents;
if (fMatch) {
// Save the position of any previous successful match.
@@ -943,9 +943,9 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
// Previous match had zero length. Move start position up one position
// to avoid sending find() into a loop on zero-length matches.
if (startPos >= fActiveLimit) {
- fMatch = FALSE;
- fHitEnd = TRUE;
- return FALSE;
+ fMatch = false;
+ fHitEnd = true;
+ return false;
}
U16_FWD_1(inputBuf, startPos, fInputLength);
}
@@ -954,8 +954,8 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
// A previous find() failed to match. Don't try again.
// (without this test, a pattern with a zero-length match
// could match again at the end of an input string.)
- fHitEnd = TRUE;
- return FALSE;
+ fHitEnd = true;
+ return false;
}
}
@@ -967,9 +967,9 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
// Note: a match can begin at inputBuf + testLen; it is an inclusive limit.
int32_t testLen = (int32_t)(fActiveLimit - fPattern->fMinMatchLen);
if (startPos > testLen) {
- fMatch = FALSE;
- fHitEnd = TRUE;
- return FALSE;
+ fMatch = false;
+ fHitEnd = true;
+ return false;
}
UChar32 c;
@@ -980,23 +980,23 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
// No optimization was found.
// Try a match at each input position.
for (;;) {
- MatchChunkAt(startPos, FALSE, status);
+ MatchChunkAt(startPos, false, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (fMatch) {
- return TRUE;
+ return true;
}
if (startPos >= testLen) {
- fHitEnd = TRUE;
- return FALSE;
+ fHitEnd = true;
+ return false;
}
U16_FWD_1(inputBuf, startPos, fActiveLimit);
// Note that it's perfectly OK for a pattern to have a zero-length
// match at the end of a string, so we must make sure that the loop
// runs with startPos == testLen the last time through.
if (findProgressInterrupt(startPos, status))
- return FALSE;
+ return false;
}
UPRV_UNREACHABLE_EXIT;
@@ -1004,12 +1004,12 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
// Matches are only possible at the start of the input string
// (pattern begins with ^ or \A)
if (startPos > fActiveStart) {
- fMatch = FALSE;
- return FALSE;
+ fMatch = false;
+ return false;
}
- MatchChunkAt(startPos, FALSE, status);
+ MatchChunkAt(startPos, false, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
return fMatch;
@@ -1023,21 +1023,21 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
U16_NEXT(inputBuf, startPos, fActiveLimit, c); // like c = inputBuf[startPos++];
if ((c<256 && fPattern->fInitialChars8->contains(c)) ||
(c>=256 && fPattern->fInitialChars->contains(c))) {
- MatchChunkAt(pos, FALSE, status);
+ MatchChunkAt(pos, false, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (fMatch) {
- return TRUE;
+ return true;
}
}
if (startPos > testLen) {
- fMatch = FALSE;
- fHitEnd = TRUE;
- return FALSE;
+ fMatch = false;
+ fHitEnd = true;
+ return false;
}
if (findProgressInterrupt(startPos, status))
- return FALSE;
+ return false;
}
}
UPRV_UNREACHABLE_EXIT;
@@ -1052,21 +1052,21 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
int32_t pos = startPos;
U16_NEXT(inputBuf, startPos, fActiveLimit, c); // like c = inputBuf[startPos++];
if (c == theChar) {
- MatchChunkAt(pos, FALSE, status);
+ MatchChunkAt(pos, false, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (fMatch) {
- return TRUE;
+ return true;
}
}
if (startPos > testLen) {
- fMatch = FALSE;
- fHitEnd = TRUE;
- return FALSE;
+ fMatch = false;
+ fHitEnd = true;
+ return false;
}
if (findProgressInterrupt(startPos, status))
- return FALSE;
+ return false;
}
}
UPRV_UNREACHABLE_EXIT;
@@ -1075,12 +1075,12 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
{
UChar32 ch;
if (startPos == fAnchorStart) {
- MatchChunkAt(startPos, FALSE, status);
+ MatchChunkAt(startPos, false, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (fMatch) {
- return TRUE;
+ return true;
}
U16_FWD_1(inputBuf, startPos, fActiveLimit);
}
@@ -1089,25 +1089,25 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
for (;;) {
ch = inputBuf[startPos-1];
if (ch == 0x0a) {
- MatchChunkAt(startPos, FALSE, status);
+ MatchChunkAt(startPos, false, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (fMatch) {
- return TRUE;
+ return true;
}
}
if (startPos >= testLen) {
- fMatch = FALSE;
- fHitEnd = TRUE;
- return FALSE;
+ fMatch = false;
+ fHitEnd = true;
+ return false;
}
U16_FWD_1(inputBuf, startPos, fActiveLimit);
// Note that it's perfectly OK for a pattern to have a zero-length
// match at the end of a string, so we must make sure that the loop
// runs with startPos == testLen the last time through.
if (findProgressInterrupt(startPos, status))
- return FALSE;
+ return false;
}
} else {
for (;;) {
@@ -1116,25 +1116,25 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
if (ch == 0x0d && startPos < fActiveLimit && inputBuf[startPos] == 0x0a) {
startPos++;
}
- MatchChunkAt(startPos, FALSE, status);
+ MatchChunkAt(startPos, false, status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (fMatch) {
- return TRUE;
+ return true;
}
}
if (startPos >= testLen) {
- fMatch = FALSE;
- fHitEnd = TRUE;
- return FALSE;
+ fMatch = false;
+ fHitEnd = true;
+ return false;
}
U16_FWD_1(inputBuf, startPos, fActiveLimit);
// Note that it's perfectly OK for a pattern to have a zero-length
// match at the end of a string, so we must make sure that the loop
// runs with startPos == testLen the last time through.
if (findProgressInterrupt(startPos, status))
- return FALSE;
+ return false;
}
}
}
@@ -1145,7 +1145,7 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
// we have reports of this in production code, don't use UPRV_UNREACHABLE_EXIT.
// See ICU-21669.
status = U_INTERNAL_PROGRAM_ERROR;
- return FALSE;
+ return false;
}
UPRV_UNREACHABLE_EXIT;
@@ -1175,7 +1175,7 @@ UText *RegexMatcher::group(int32_t groupNum, UText *dest, int64_t &group_len, UE
}
if (U_FAILURE(fDeferredStatus)) {
status = fDeferredStatus;
- } else if (fMatch == FALSE) {
+ } else if (fMatch == false) {
status = U_REGEX_INVALID_STATE;
} else if (groupNum < 0 || groupNum > fPattern->fGroupMap->size()) {
status = U_INDEX_OUTOFBOUNDS_ERROR;
@@ -1199,12 +1199,12 @@ UText *RegexMatcher::group(int32_t groupNum, UText *dest, int64_t &group_len, UE
if (s < 0) {
// A capture group wasn't part of the match
- return utext_clone(dest, fInputText, FALSE, TRUE, &status);
+ return utext_clone(dest, fInputText, false, true, &status);
}
U_ASSERT(s <= e);
group_len = e - s;
- dest = utext_clone(dest, fInputText, FALSE, TRUE, &status);
+ dest = utext_clone(dest, fInputText, false, true, &status);
if (dest)
UTEXT_SETNATIVEINDEX(dest, s);
return dest;
@@ -1220,14 +1220,14 @@ UnicodeString RegexMatcher::group(int32_t groupNum, UErrorCode &status) const {
// Get the group length using a utext_extract preflight.
// UText is actually pretty efficient at this when underlying encoding is UTF-16.
- int32_t length = utext_extract(fInputText, groupStart, groupEnd, NULL, 0, &status);
+ int32_t length = utext_extract(fInputText, groupStart, groupEnd, nullptr, 0, &status);
if (status != U_BUFFER_OVERFLOW_ERROR) {
return result;
}
status = U_ZERO_ERROR;
- UChar *buf = result.getBuffer(length);
- if (buf == NULL) {
+ char16_t *buf = result.getBuffer(length);
+ if (buf == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
int32_t extractLength = utext_extract(fInputText, groupStart, groupEnd, buf, length, &status);
@@ -1255,13 +1255,13 @@ int64_t RegexMatcher::appendGroup(int32_t groupNum, UText *dest, UErrorCode &sta
}
int64_t destLen = utext_nativeLength(dest);
- if (fMatch == FALSE) {
+ if (fMatch == false) {
status = U_REGEX_INVALID_STATE;
- return utext_replace(dest, destLen, destLen, NULL, 0, &status);
+ return utext_replace(dest, destLen, destLen, nullptr, 0, &status);
}
if (groupNum < 0 || groupNum > fPattern->fGroupMap->size()) {
status = U_INDEX_OUTOFBOUNDS_ERROR;
- return utext_replace(dest, destLen, destLen, NULL, 0, &status);
+ return utext_replace(dest, destLen, destLen, nullptr, 0, &status);
}
int64_t s, e;
@@ -1278,7 +1278,7 @@ int64_t RegexMatcher::appendGroup(int32_t groupNum, UText *dest, UErrorCode &sta
if (s < 0) {
// A capture group wasn't part of the match
- return utext_replace(dest, destLen, destLen, NULL, 0, &status);
+ return utext_replace(dest, destLen, destLen, nullptr, 0, &status);
}
U_ASSERT(s <= e);
@@ -1292,10 +1292,10 @@ int64_t RegexMatcher::appendGroup(int32_t groupNum, UText *dest, UErrorCode &sta
len16 = (int32_t)(e-s);
} else {
UErrorCode lengthStatus = U_ZERO_ERROR;
- len16 = utext_extract(fInputText, s, e, NULL, 0, &lengthStatus);
+ len16 = utext_extract(fInputText, s, e, nullptr, 0, &lengthStatus);
}
- UChar *groupChars = (UChar *)uprv_malloc(sizeof(UChar)*(len16+1));
- if (groupChars == NULL) {
+ char16_t *groupChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(len16+1));
+ if (groupChars == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
@@ -1361,12 +1361,12 @@ const UnicodeString &RegexMatcher::input() const {
if (UTEXT_USES_U16(fInputText)) {
len16 = (int32_t)fInputLength;
} else {
- len16 = utext_extract(fInputText, 0, fInputLength, NULL, 0, &status);
+ len16 = utext_extract(fInputText, 0, fInputLength, nullptr, 0, &status);
status = U_ZERO_ERROR; // overflow, length status
}
UnicodeString *result = new UnicodeString(len16, 0, 0);
- UChar *inputChars = result->getBuffer(len16);
+ char16_t *inputChars = result->getBuffer(len16);
utext_extract(fInputText, 0, fInputLength, inputChars, len16, &status); // unterminated warning
result->releaseBuffer(len16);
@@ -1409,10 +1409,10 @@ UText *RegexMatcher::getInput (UText *dest, UErrorCode &status) const {
input16Len = (int32_t)fInputLength;
} else {
UErrorCode lengthStatus = U_ZERO_ERROR;
- input16Len = utext_extract(fInputText, 0, fInputLength, NULL, 0, &lengthStatus); // buffer overflow error
+ input16Len = utext_extract(fInputText, 0, fInputLength, nullptr, 0, &lengthStatus); // buffer overflow error
}
- UChar *inputChars = (UChar *)uprv_malloc(sizeof(UChar)*(input16Len));
- if (inputChars == NULL) {
+ char16_t *inputChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(input16Len));
+ if (inputChars == nullptr) {
return dest;
}
@@ -1425,14 +1425,14 @@ UText *RegexMatcher::getInput (UText *dest, UErrorCode &status) const {
}
return dest;
} else {
- return utext_clone(NULL, fInputText, FALSE, TRUE, &status);
+ return utext_clone(nullptr, fInputText, false, true, &status);
}
}
static UBool compat_SyncMutableUTextContents(UText *ut);
static UBool compat_SyncMutableUTextContents(UText *ut) {
- UBool retVal = FALSE;
+ UBool retVal = false;
// In the following test, we're really only interested in whether the UText should switch
// between heap and stack allocation. If length hasn't changed, we won't, so the chunkContents
@@ -1450,7 +1450,7 @@ static UBool compat_SyncMutableUTextContents(UText *ut) {
ut->chunkLength = newLength;
ut->chunkNativeLimit = newLength;
ut->nativeIndexingLimit = newLength;
- retVal = TRUE;
+ retVal = true;
}
return retVal;
@@ -1463,11 +1463,11 @@ static UBool compat_SyncMutableUTextContents(UText *ut) {
//--------------------------------------------------------------------------------
UBool RegexMatcher::lookingAt(UErrorCode &status) {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (U_FAILURE(fDeferredStatus)) {
status = fDeferredStatus;
- return FALSE;
+ return false;
}
if (fInputUniStrMaybeMutable) {
@@ -1480,9 +1480,9 @@ UBool RegexMatcher::lookingAt(UErrorCode &status) {
resetPreserveRegion();
}
if (UTEXT_FULL_TEXT_IN_CHUNK(fInputText, fInputLength)) {
- MatchChunkAt((int32_t)fActiveStart, FALSE, status);
+ MatchChunkAt((int32_t)fActiveStart, false, status);
} else {
- MatchAt(fActiveStart, FALSE, status);
+ MatchAt(fActiveStart, false, status);
}
return fMatch;
}
@@ -1490,17 +1490,17 @@ UBool RegexMatcher::lookingAt(UErrorCode &status) {
UBool RegexMatcher::lookingAt(int64_t start, UErrorCode &status) {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (U_FAILURE(fDeferredStatus)) {
status = fDeferredStatus;
- return FALSE;
+ return false;
}
reset();
if (start < 0) {
status = U_INDEX_OUTOFBOUNDS_ERROR;
- return FALSE;
+ return false;
}
if (fInputUniStrMaybeMutable) {
@@ -1514,13 +1514,13 @@ UBool RegexMatcher::lookingAt(int64_t start, UErrorCode &status) {
nativeStart = start;
if (nativeStart < fActiveStart || nativeStart > fActiveLimit) {
status = U_INDEX_OUTOFBOUNDS_ERROR;
- return FALSE;
+ return false;
}
if (UTEXT_FULL_TEXT_IN_CHUNK(fInputText, fInputLength)) {
- MatchChunkAt((int32_t)nativeStart, FALSE, status);
+ MatchChunkAt((int32_t)nativeStart, false, status);
} else {
- MatchAt(nativeStart, FALSE, status);
+ MatchAt(nativeStart, false, status);
}
return fMatch;
}
@@ -1534,11 +1534,11 @@ UBool RegexMatcher::lookingAt(int64_t start, UErrorCode &status) {
//--------------------------------------------------------------------------------
UBool RegexMatcher::matches(UErrorCode &status) {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (U_FAILURE(fDeferredStatus)) {
status = fDeferredStatus;
- return FALSE;
+ return false;
}
if (fInputUniStrMaybeMutable) {
@@ -1552,9 +1552,9 @@ UBool RegexMatcher::matches(UErrorCode &status) {
}
if (UTEXT_FULL_TEXT_IN_CHUNK(fInputText, fInputLength)) {
- MatchChunkAt((int32_t)fActiveStart, TRUE, status);
+ MatchChunkAt((int32_t)fActiveStart, true, status);
} else {
- MatchAt(fActiveStart, TRUE, status);
+ MatchAt(fActiveStart, true, status);
}
return fMatch;
}
@@ -1562,17 +1562,17 @@ UBool RegexMatcher::matches(UErrorCode &status) {
UBool RegexMatcher::matches(int64_t start, UErrorCode &status) {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (U_FAILURE(fDeferredStatus)) {
status = fDeferredStatus;
- return FALSE;
+ return false;
}
reset();
if (start < 0) {
status = U_INDEX_OUTOFBOUNDS_ERROR;
- return FALSE;
+ return false;
}
if (fInputUniStrMaybeMutable) {
@@ -1586,13 +1586,13 @@ UBool RegexMatcher::matches(int64_t start, UErrorCode &status) {
nativeStart = start;
if (nativeStart < fActiveStart || nativeStart > fActiveLimit) {
status = U_INDEX_OUTOFBOUNDS_ERROR;
- return FALSE;
+ return false;
}
if (UTEXT_FULL_TEXT_IN_CHUNK(fInputText, fInputLength)) {
- MatchChunkAt((int32_t)nativeStart, TRUE, status);
+ MatchChunkAt((int32_t)nativeStart, true, status);
} else {
- MatchAt(nativeStart, TRUE, status);
+ MatchAt(nativeStart, true, status);
}
return fMatch;
}
@@ -1726,12 +1726,12 @@ UText *RegexMatcher::replaceAll(UText *replacement, UText *dest, UErrorCode &sta
return dest;
}
- if (dest == NULL) {
+ if (dest == nullptr) {
UnicodeString emptyString;
UText empty = UTEXT_INITIALIZER;
utext_openUnicodeString(&empty, &emptyString, &status);
- dest = utext_clone(NULL, &empty, TRUE, FALSE, &status);
+ dest = utext_clone(nullptr, &empty, true, false, &status);
utext_close(&empty);
}
@@ -1788,12 +1788,12 @@ UText *RegexMatcher::replaceFirst(UText *replacement, UText *dest, UErrorCode &s
return getInput(dest, status);
}
- if (dest == NULL) {
+ if (dest == nullptr) {
UnicodeString emptyString;
UText empty = UTEXT_INITIALIZER;
utext_openUnicodeString(&empty, &emptyString, &status);
- dest = utext_clone(NULL, &empty, TRUE, FALSE, &status);
+ dest = utext_clone(nullptr, &empty, true, false, &status);
utext_close(&empty);
}
@@ -1839,9 +1839,9 @@ void RegexMatcher::resetPreserveRegion() {
fMatchEnd = 0;
fLastMatchEnd = -1;
fAppendPosition = 0;
- fMatch = FALSE;
- fHitEnd = FALSE;
- fRequireEnd = FALSE;
+ fMatch = false;
+ fHitEnd = false;
+ fRequireEnd = false;
fTime = 0;
fTickCounter = TIMER_INITIAL_VALUE;
//resetStack(); // more expensive than it looks...
@@ -1851,7 +1851,7 @@ void RegexMatcher::resetPreserveRegion() {
RegexMatcher &RegexMatcher::reset(const UnicodeString &input) {
fInputText = utext_openConstUnicodeString(fInputText, &input, &fDeferredStatus);
if (fPattern->fNeedsAltInput) {
- fAltInputText = utext_clone(fAltInputText, fInputText, FALSE, TRUE, &fDeferredStatus);
+ fAltInputText = utext_clone(fAltInputText, fInputText, false, true, &fDeferredStatus);
}
if (U_FAILURE(fDeferredStatus)) {
return *this;
@@ -1860,11 +1860,11 @@ RegexMatcher &RegexMatcher::reset(const UnicodeString &input) {
reset();
delete fInput;
- fInput = NULL;
+ fInput = nullptr;
// Do the following for any UnicodeString.
// This is for compatibility for those clients who modify the input string "live" during regex operations.
- fInputUniStrMaybeMutable = TRUE;
+ fInputUniStrMaybeMutable = true;
#if UCONFIG_NO_BREAK_ITERATION==0
if (fWordBreakItr) {
@@ -1881,15 +1881,15 @@ RegexMatcher &RegexMatcher::reset(const UnicodeString &input) {
RegexMatcher &RegexMatcher::reset(UText *input) {
if (fInputText != input) {
- fInputText = utext_clone(fInputText, input, FALSE, TRUE, &fDeferredStatus);
- if (fPattern->fNeedsAltInput) fAltInputText = utext_clone(fAltInputText, fInputText, FALSE, TRUE, &fDeferredStatus);
+ fInputText = utext_clone(fInputText, input, false, true, &fDeferredStatus);
+ if (fPattern->fNeedsAltInput) fAltInputText = utext_clone(fAltInputText, fInputText, false, true, &fDeferredStatus);
if (U_FAILURE(fDeferredStatus)) {
return *this;
}
fInputLength = utext_nativeLength(fInputText);
delete fInput;
- fInput = NULL;
+ fInput = nullptr;
#if UCONFIG_NO_BREAK_ITERATION==0
if (fWordBreakItr) {
@@ -1901,12 +1901,12 @@ RegexMatcher &RegexMatcher::reset(UText *input) {
#endif
}
reset();
- fInputUniStrMaybeMutable = FALSE;
+ fInputUniStrMaybeMutable = false;
return *this;
}
-/*RegexMatcher &RegexMatcher::reset(const UChar *) {
+/*RegexMatcher &RegexMatcher::reset(const char16_t *) {
fDeferredStatus = U_INTERNAL_PROGRAM_ERROR;
return *this;
}*/
@@ -1935,7 +1935,7 @@ RegexMatcher &RegexMatcher::refreshInputText(UText *input, UErrorCode &status) {
if (U_FAILURE(status)) {
return *this;
}
- if (input == NULL) {
+ if (input == nullptr) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return *this;
}
@@ -1945,15 +1945,15 @@ RegexMatcher &RegexMatcher::refreshInputText(UText *input, UErrorCode &status) {
}
int64_t pos = utext_getNativeIndex(fInputText);
// Shallow read-only clone of the new UText into the existing input UText
- fInputText = utext_clone(fInputText, input, FALSE, TRUE, &status);
+ fInputText = utext_clone(fInputText, input, false, true, &status);
if (U_FAILURE(status)) {
return *this;
}
utext_setNativeIndex(fInputText, pos);
- if (fAltInputText != NULL) {
+ if (fAltInputText != nullptr) {
pos = utext_getNativeIndex(fAltInputText);
- fAltInputText = utext_clone(fAltInputText, input, FALSE, TRUE, &status);
+ fAltInputText = utext_clone(fAltInputText, input, false, true, &status);
if (U_FAILURE(status)) {
return *this;
}
@@ -1980,7 +1980,7 @@ void RegexMatcher::setTrace(UBool state) {
*
* @param src The source UText
* @param dest The destination UText. Must be writable.
- * May be NULL, in which case a new UText will be allocated.
+ * May be nullptr, in which case a new UText will be allocated.
* @param start Start index of source substring.
* @param limit Limit index of source substring.
* @param status An error code.
@@ -1991,21 +1991,21 @@ static UText *utext_extract_replace(UText *src, UText *dest, int64_t start, int6
}
if (start == limit) {
if (dest) {
- utext_replace(dest, 0, utext_nativeLength(dest), NULL, 0, status);
+ utext_replace(dest, 0, utext_nativeLength(dest), nullptr, 0, status);
return dest;
} else {
- return utext_openUChars(NULL, NULL, 0, status);
+ return utext_openUChars(nullptr, nullptr, 0, status);
}
}
- int32_t length = utext_extract(src, start, limit, NULL, 0, status);
+ int32_t length = utext_extract(src, start, limit, nullptr, 0, status);
if (*status != U_BUFFER_OVERFLOW_ERROR && U_FAILURE(*status)) {
return dest;
}
*status = U_ZERO_ERROR;
- MaybeStackArray<UChar, 40> buffer;
+ MaybeStackArray<char16_t, 40> buffer;
if (length >= buffer.getCapacity()) {
- UChar *newBuf = buffer.resize(length+1); // Leave space for terminating Nul.
- if (newBuf == NULL) {
+ char16_t *newBuf = buffer.resize(length+1); // Leave space for terminating Nul.
+ if (newBuf == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
}
}
@@ -2018,18 +2018,18 @@ static UText *utext_extract_replace(UText *src, UText *dest, int64_t start, int6
// Caller did not provide a preexisting UText.
// Open a new one, and have it adopt the text buffer storage.
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
int32_t ownedLength = 0;
- UChar *ownedBuf = buffer.orphanOrClone(length+1, ownedLength);
- if (ownedBuf == NULL) {
+ char16_t *ownedBuf = buffer.orphanOrClone(length+1, ownedLength);
+ if (ownedBuf == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
- UText *result = utext_openUChars(NULL, ownedBuf, length, status);
+ UText *result = utext_openUChars(nullptr, ownedBuf, length, status);
if (U_FAILURE(*status)) {
uprv_free(ownedBuf);
- return NULL;
+ return nullptr;
}
result->providerProperties |= (1 << UTEXT_PROVIDER_OWNS_TEXT);
return result;
@@ -2053,13 +2053,13 @@ int32_t RegexMatcher::split(const UnicodeString &input,
}
UText **destText = (UText **)uprv_malloc(sizeof(UText*)*destCapacity);
- if (destText == NULL) {
+ if (destText == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
int32_t i;
for (i = 0; i < destCapacity; i++) {
- destText[i] = utext_openUnicodeString(NULL, &dest[i], &status);
+ destText[i] = utext_openUnicodeString(nullptr, &dest[i], &status);
}
int32_t fieldCount = split(&inputText, destText, destCapacity, status);
@@ -2126,15 +2126,15 @@ int32_t RegexMatcher::split(UText *input,
UText remainingText = UTEXT_INITIALIZER;
utext_openUChars(&remainingText, input->chunkContents+nextOutputStringStart,
fActiveLimit-nextOutputStringStart, &status);
- dest[i] = utext_clone(NULL, &remainingText, TRUE, FALSE, &status);
+ dest[i] = utext_clone(nullptr, &remainingText, true, false, &status);
utext_close(&remainingText);
}
} else {
UErrorCode lengthStatus = U_ZERO_ERROR;
int32_t remaining16Length =
- utext_extract(input, nextOutputStringStart, fActiveLimit, NULL, 0, &lengthStatus);
- UChar *remainingChars = (UChar *)uprv_malloc(sizeof(UChar)*(remaining16Length+1));
- if (remainingChars == NULL) {
+ utext_extract(input, nextOutputStringStart, fActiveLimit, nullptr, 0, &lengthStatus);
+ char16_t *remainingChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(remaining16Length+1));
+ if (remainingChars == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
}
@@ -2145,7 +2145,7 @@ int32_t RegexMatcher::split(UText *input,
} else {
UText remainingText = UTEXT_INITIALIZER;
utext_openUChars(&remainingText, remainingChars, remaining16Length, &status);
- dest[i] = utext_clone(NULL, &remainingText, TRUE, FALSE, &status);
+ dest[i] = utext_clone(nullptr, &remainingText, true, false, &status);
utext_close(&remainingText);
}
@@ -2166,14 +2166,14 @@ int32_t RegexMatcher::split(UText *input,
UText remainingText = UTEXT_INITIALIZER;
utext_openUChars(&remainingText, input->chunkContents+nextOutputStringStart,
fMatchStart-nextOutputStringStart, &status);
- dest[i] = utext_clone(NULL, &remainingText, TRUE, FALSE, &status);
+ dest[i] = utext_clone(nullptr, &remainingText, true, false, &status);
utext_close(&remainingText);
}
} else {
UErrorCode lengthStatus = U_ZERO_ERROR;
- int32_t remaining16Length = utext_extract(input, nextOutputStringStart, fMatchStart, NULL, 0, &lengthStatus);
- UChar *remainingChars = (UChar *)uprv_malloc(sizeof(UChar)*(remaining16Length+1));
- if (remainingChars == NULL) {
+ int32_t remaining16Length = utext_extract(input, nextOutputStringStart, fMatchStart, nullptr, 0, &lengthStatus);
+ char16_t *remainingChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(remaining16Length+1));
+ if (remainingChars == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
}
@@ -2183,7 +2183,7 @@ int32_t RegexMatcher::split(UText *input,
} else {
UText remainingText = UTEXT_INITIALIZER;
utext_openUChars(&remainingText, remainingChars, remaining16Length, &status);
- dest[i] = utext_clone(NULL, &remainingText, TRUE, FALSE, &status);
+ dest[i] = utext_clone(nullptr, &remainingText, true, false, &status);
utext_close(&remainingText);
}
@@ -2212,10 +2212,10 @@ int32_t RegexMatcher::split(UText *input,
// the delimiter at the end of input.
if (i+1 < destCapacity) {
++i;
- if (dest[i] == NULL) {
- dest[i] = utext_openUChars(NULL, NULL, 0, &status);
+ if (dest[i] == nullptr) {
+ dest[i] = utext_openUChars(nullptr, nullptr, 0, &status);
} else {
- static const UChar emptyString[] = {(UChar)0};
+ static const char16_t emptyString[] = {(char16_t)0};
utext_replace(dest[i], 0, utext_nativeLength(dest[i]), emptyString, 0, &status);
}
}
@@ -2236,14 +2236,14 @@ int32_t RegexMatcher::split(UText *input,
UText remainingText = UTEXT_INITIALIZER;
utext_openUChars(&remainingText, input->chunkContents+nextOutputStringStart,
fActiveLimit-nextOutputStringStart, &status);
- dest[i] = utext_clone(NULL, &remainingText, TRUE, FALSE, &status);
+ dest[i] = utext_clone(nullptr, &remainingText, true, false, &status);
utext_close(&remainingText);
}
} else {
UErrorCode lengthStatus = U_ZERO_ERROR;
- int32_t remaining16Length = utext_extract(input, nextOutputStringStart, fActiveLimit, NULL, 0, &lengthStatus);
- UChar *remainingChars = (UChar *)uprv_malloc(sizeof(UChar)*(remaining16Length+1));
- if (remainingChars == NULL) {
+ int32_t remaining16Length = utext_extract(input, nextOutputStringStart, fActiveLimit, nullptr, 0, &lengthStatus);
+ char16_t *remainingChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(remaining16Length+1));
+ if (remainingChars == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
}
@@ -2254,7 +2254,7 @@ int32_t RegexMatcher::split(UText *input,
} else {
UText remainingText = UTEXT_INITIALIZER;
utext_openUChars(&remainingText, remainingChars, remaining16Length, &status);
- dest[i] = utext_clone(NULL, &remainingText, TRUE, FALSE, &status);
+ dest[i] = utext_clone(nullptr, &remainingText, true, false, &status);
utext_close(&remainingText);
}
@@ -2297,7 +2297,7 @@ int64_t RegexMatcher::start64(int32_t group, UErrorCode &status) const {
status = fDeferredStatus;
return -1;
}
- if (fMatch == FALSE) {
+ if (fMatch == false) {
status = U_REGEX_INVALID_STATE;
return -1;
}
@@ -2516,7 +2516,7 @@ REStackFrame *RegexMatcher::resetStack() {
REStackFrame *iFrame = (REStackFrame *)fStack->reserveBlock(fPattern->fFrameSize, fDeferredStatus);
if(U_FAILURE(fDeferredStatus)) {
- return NULL;
+ return nullptr;
}
int32_t i;
@@ -2534,7 +2534,7 @@ REStackFrame *RegexMatcher::resetStack() {
// in perl, "xab..cd..", \b is true at positions 0,3,5,7
// For us,
// If the current char is a combining mark,
-// \b is FALSE.
+// \b is false.
// Else Scan backwards to the first non-combining char.
// We are at a boundary if the this char and the original chars are
// opposite in membership in \w set
@@ -2545,11 +2545,11 @@ REStackFrame *RegexMatcher::resetStack() {
//
//--------------------------------------------------------------------------------
UBool RegexMatcher::isWordBoundary(int64_t pos) {
- UBool isBoundary = FALSE;
- UBool cIsWord = FALSE;
+ UBool isBoundary = false;
+ UBool cIsWord = false;
if (pos >= fLookLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
} else {
// Determine whether char c at current position is a member of the word set of chars.
// If we're off the end of the string, behave as though we're not at a word char.
@@ -2557,14 +2557,14 @@ UBool RegexMatcher::isWordBoundary(int64_t pos) {
UChar32 c = UTEXT_CURRENT32(fInputText);
if (u_hasBinaryProperty(c, UCHAR_GRAPHEME_EXTEND) || u_charType(c) == U_FORMAT_CHAR) {
// Current char is a combining one. Not a boundary.
- return FALSE;
+ return false;
}
cIsWord = RegexStaticSets::gStaticSets->fPropSets[URX_ISWORD_SET].contains(c);
}
// Back up until we come to a non-combining char, determine whether
// that char is a word char.
- UBool prevCIsWord = FALSE;
+ UBool prevCIsWord = false;
for (;;) {
if (UTEXT_GETNATIVEINDEX(fInputText) <= fLookStart) {
break;
@@ -2581,13 +2581,13 @@ UBool RegexMatcher::isWordBoundary(int64_t pos) {
}
UBool RegexMatcher::isChunkWordBoundary(int32_t pos) {
- UBool isBoundary = FALSE;
- UBool cIsWord = FALSE;
+ UBool isBoundary = false;
+ UBool cIsWord = false;
- const UChar *inputBuf = fInputText->chunkContents;
+ const char16_t *inputBuf = fInputText->chunkContents;
if (pos >= fLookLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
} else {
// Determine whether char c at current position is a member of the word set of chars.
// If we're off the end of the string, behave as though we're not at a word char.
@@ -2595,14 +2595,14 @@ UBool RegexMatcher::isChunkWordBoundary(int32_t pos) {
U16_GET(inputBuf, fLookStart, pos, fLookLimit, c);
if (u_hasBinaryProperty(c, UCHAR_GRAPHEME_EXTEND) || u_charType(c) == U_FORMAT_CHAR) {
// Current char is a combining one. Not a boundary.
- return FALSE;
+ return false;
}
cIsWord = RegexStaticSets::gStaticSets->fPropSets[URX_ISWORD_SET].contains(c);
}
// Back up until we come to a non-combining char, determine whether
// that char is a word char.
- UBool prevCIsWord = FALSE;
+ UBool prevCIsWord = false;
for (;;) {
if (pos <= fLookStart) {
break;
@@ -2629,7 +2629,7 @@ UBool RegexMatcher::isChunkWordBoundary(int32_t pos) {
//
//--------------------------------------------------------------------------------
UBool RegexMatcher::isUWordBoundary(int64_t pos, UErrorCode &status) {
- UBool returnVal = FALSE;
+ UBool returnVal = false;
#if UCONFIG_NO_BREAK_ITERATION==0
// Note: this point will never be reached if break iteration is configured out.
@@ -2639,7 +2639,7 @@ UBool RegexMatcher::isUWordBoundary(int64_t pos, UErrorCode &status) {
if (fWordBreakItr == nullptr) {
fWordBreakItr = BreakIterator::createWordInstance(Locale::getEnglish(), status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
fWordBreakItr->setText(fInputText, status);
}
@@ -2647,8 +2647,8 @@ UBool RegexMatcher::isUWordBoundary(int64_t pos, UErrorCode &status) {
// Note: zero width boundary tests like \b see through transparent region bounds,
// which is why fLookLimit is used here, rather than fActiveLimit.
if (pos >= fLookLimit) {
- fHitEnd = TRUE;
- returnVal = TRUE; // With Unicode word rules, only positions within the interior of "real"
+ fHitEnd = true;
+ returnVal = true; // With Unicode word rules, only positions within the interior of "real"
// words are not boundaries. All non-word chars stand by themselves,
// with word boundaries on both sides.
} else {
@@ -2696,8 +2696,8 @@ int64_t RegexMatcher::followingGCBoundary(int64_t pos, UErrorCode &status) {
void RegexMatcher::IncrementTime(UErrorCode &status) {
fTickCounter = TIMER_INITIAL_VALUE;
fTime++;
- if (fCallbackFn != NULL) {
- if ((*fCallbackFn)(fCallbackContext, fTime) == FALSE) {
+ if (fCallbackFn != nullptr) {
+ if ((*fCallbackFn)(fCallbackContext, fTime) == false) {
status = U_REGEX_STOPPED_BY_CALLER;
return;
}
@@ -2787,7 +2787,7 @@ UnicodeString StringFromUText(UText *ut) {
//
//--------------------------------------------------------------------------------
void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
- UBool isMatch = FALSE; // True if the we have a match.
+ UBool isMatch = false; // True if the we have a match.
int64_t backSearchIndex = U_INT64_MAX; // used after greedy single-character matches for searching backwards
@@ -2811,7 +2811,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
//
int64_t *pat = fPattern->fCompiledPat->getBuffer();
- const UChar *litText = fPattern->fLiteralText.getBuffer();
+ const char16_t *litText = fPattern->fLiteralText.getBuffer();
UVector *fSets = fPattern->fSets;
fFrameSize = fPattern->fFrameSize;
@@ -2872,7 +2872,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
break;
}
} else {
- fHitEnd = TRUE;
+ fHitEnd = true;
}
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
@@ -2892,22 +2892,22 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
U_ASSERT(opType == URX_STRING_LEN);
U_ASSERT(stringLen >= 2);
- const UChar *patternString = litText+stringStartIdx;
+ const char16_t *patternString = litText+stringStartIdx;
int32_t patternStringIndex = 0;
UTEXT_SETNATIVEINDEX(fInputText, fp->fInputIdx);
UChar32 inputChar;
UChar32 patternChar;
- UBool success = TRUE;
+ UBool success = true;
while (patternStringIndex < stringLen) {
if (UTEXT_GETNATIVEINDEX(fInputText) >= fActiveLimit) {
- success = FALSE;
- fHitEnd = TRUE;
+ success = false;
+ fHitEnd = true;
break;
}
inputChar = UTEXT_NEXT32(fInputText);
U16_NEXT(patternString, patternStringIndex, stringLen, patternChar);
if (patternChar != inputChar) {
- success = FALSE;
+ success = false;
break;
}
}
@@ -2934,7 +2934,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
- isMatch = TRUE;
+ isMatch = true;
goto breakFromLoop;
// Start and End Capture stack frame variables are laid out out like this:
@@ -2962,8 +2962,8 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
{
if (fp->fInputIdx >= fAnchorLimit) {
// We really are at the end of input. Success.
- fHitEnd = TRUE;
- fRequireEnd = TRUE;
+ fHitEnd = true;
+ fRequireEnd = true;
break;
}
@@ -2977,8 +2977,8 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
// If not in the middle of a CR/LF sequence
if ( !(c==0x0a && fp->fInputIdx>fAnchorStart && ((void)UTEXT_PREVIOUS32(fInputText), UTEXT_PREVIOUS32(fInputText))==0x0d)) {
// At new-line at end of input. Success
- fHitEnd = TRUE;
- fRequireEnd = TRUE;
+ fHitEnd = true;
+ fRequireEnd = true;
break;
}
@@ -2986,8 +2986,8 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
} else {
UChar32 nextC = UTEXT_NEXT32(fInputText);
if (c == 0x0d && nextC == 0x0a && UTEXT_GETNATIVEINDEX(fInputText) >= fAnchorLimit) {
- fHitEnd = TRUE;
- fRequireEnd = TRUE;
+ fHitEnd = true;
+ fRequireEnd = true;
break; // At CR/LF at end of input. Success
}
}
@@ -3000,16 +3000,16 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
case URX_DOLLAR_D: // $, test for End of Line, in UNIX_LINES mode.
if (fp->fInputIdx >= fAnchorLimit) {
// Off the end of input. Success.
- fHitEnd = TRUE;
- fRequireEnd = TRUE;
+ fHitEnd = true;
+ fRequireEnd = true;
break;
} else {
UTEXT_SETNATIVEINDEX(fInputText, fp->fInputIdx);
UChar32 c = UTEXT_NEXT32(fInputText);
// Either at the last character of input, or off the end.
if (c == 0x0a && UTEXT_GETNATIVEINDEX(fInputText) == fAnchorLimit) {
- fHitEnd = TRUE;
- fRequireEnd = TRUE;
+ fHitEnd = true;
+ fRequireEnd = true;
break;
}
}
@@ -3023,8 +3023,8 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
{
if (fp->fInputIdx >= fAnchorLimit) {
// We really are at the end of input. Success.
- fHitEnd = TRUE;
- fRequireEnd = TRUE;
+ fHitEnd = true;
+ fRequireEnd = true;
break;
}
// If we are positioned just before a new-line, succeed.
@@ -3049,8 +3049,8 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
{
if (fp->fInputIdx >= fAnchorLimit) {
// We really are at the end of input. Success.
- fHitEnd = TRUE;
- fRequireEnd = TRUE; // Java set requireEnd in this case, even though
+ fHitEnd = true;
+ fRequireEnd = true; // Java set requireEnd in this case, even though
break; // adding a new-line would not lose the match.
}
// If we are not positioned just before a new-line, the test fails; backtrack out.
@@ -3134,7 +3134,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
case URX_BACKSLASH_D: // Test for decimal digit
{
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -3155,7 +3155,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
case URX_BACKSLASH_G: // Test for position at end of previous match
- if (!((fMatch && fp->fInputIdx==fMatchEnd) || (fMatch==FALSE && fp->fInputIdx==fActiveStart))) {
+ if (!((fMatch && fp->fInputIdx==fMatchEnd) || (fMatch==false && fp->fInputIdx==fActiveStart))) {
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
}
break;
@@ -3164,7 +3164,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
case URX_BACKSLASH_H: // Test for \h, horizontal white space.
{
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -3185,7 +3185,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
case URX_BACKSLASH_R: // Test for \R, any line break sequence.
{
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -3206,7 +3206,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
case URX_BACKSLASH_V: // \v, any single line ending character.
{
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -3228,14 +3228,14 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
// Fail if at end of input
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
fp->fInputIdx = followingGCBoundary(fp->fInputIdx, status);
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp->fInputIdx = fActiveLimit;
}
break;
@@ -3245,8 +3245,8 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
if (fp->fInputIdx < fAnchorLimit) {
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
} else {
- fHitEnd = TRUE;
- fRequireEnd = TRUE;
+ fHitEnd = true;
+ fRequireEnd = true;
}
break;
@@ -3260,7 +3260,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
// 0: success if input char is in set.
// 1: success if input char is not in set.
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -3297,7 +3297,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
// Test input character for NOT being a member of one of
// the predefined sets (Word Characters, for example)
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -3309,13 +3309,13 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
UChar32 c = UTEXT_NEXT32(fInputText);
if (c < 256) {
Regex8BitSet &s8 = RegexStaticSets::gStaticSets->fPropSets8[opValue];
- if (s8.contains(c) == FALSE) {
+ if (s8.contains(c) == false) {
fp->fInputIdx = UTEXT_GETNATIVEINDEX(fInputText);
break;
}
} else {
const UnicodeSet &s = RegexStaticSets::gStaticSets->fPropSets[opValue];
- if (s.contains(c) == FALSE) {
+ if (s.contains(c) == false) {
fp->fInputIdx = UTEXT_GETNATIVEINDEX(fInputText);
break;
}
@@ -3328,7 +3328,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
case URX_SETREF:
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
} else {
@@ -3363,7 +3363,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
// . matches anything, but stops at end-of-line.
if (fp->fInputIdx >= fActiveLimit) {
// At end of input. Match failed. Backtrack out.
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -3387,7 +3387,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
// ., in dot-matches-all (including new lines) mode
if (fp->fInputIdx >= fActiveLimit) {
// At end of input. Match failed. Backtrack out.
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -3417,7 +3417,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
// UNIX_LINES mode, so 0x0a is the only recognized line ending.
if (fp->fInputIdx >= fActiveLimit) {
// At end of input. Match failed. Backtrack out.
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -3441,7 +3441,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
break;
case URX_FAIL:
- isMatch = FALSE;
+ isMatch = false;
goto breakFromLoop;
case URX_JMP_SAV:
@@ -3658,21 +3658,21 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
// match succeeds. Verified by testing: Perl matches succeed
// in this case, so we do too.
- UBool success = TRUE;
+ UBool success = true;
for (;;) {
if (utext_getNativeIndex(fAltInputText) >= groupEndIdx) {
- success = TRUE;
+ success = true;
break;
}
if (utext_getNativeIndex(fInputText) >= fActiveLimit) {
- success = FALSE;
- fHitEnd = TRUE;
+ success = false;
+ fHitEnd = true;
break;
}
UChar32 captureGroupChar = utext_next32(fAltInputText);
UChar32 inputChar = utext_next32(fInputText);
if (inputChar != captureGroupChar) {
- success = FALSE;
+ success = false;
break;
}
}
@@ -3707,21 +3707,21 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
// match succeeds. Verified by testing: Perl matches succeed
// in this case, so we do too.
- UBool success = TRUE;
+ UBool success = true;
for (;;) {
if (!captureGroupItr.inExpansion() && utext_getNativeIndex(fAltInputText) >= groupEndIdx) {
- success = TRUE;
+ success = true;
break;
}
if (!inputItr.inExpansion() && utext_getNativeIndex(fInputText) >= fActiveLimit) {
- success = FALSE;
- fHitEnd = TRUE;
+ success = false;
+ fHitEnd = true;
break;
}
UChar32 captureGroupChar = captureGroupItr.next();
UChar32 inputChar = inputItr.next();
if (inputChar != captureGroupChar) {
- success = FALSE;
+ success = false;
break;
}
}
@@ -3730,7 +3730,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
// We obtained a match by consuming part of a string obtained from
// case-folding a single code point of the input text.
// This does not count as an overall match.
- success = FALSE;
+ success = false;
}
if (success) {
@@ -3823,7 +3823,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
break;
}
} else {
- fHitEnd = TRUE;
+ fHitEnd = true;
}
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
@@ -3836,7 +3836,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
// offset to the string text, and one for the length.
// The compiled string has already been case folded.
{
- const UChar *patternString = litText + opValue;
+ const char16_t *patternString = litText + opValue;
int32_t patternStringIdx = 0;
op = (int32_t)pat[fp->fPatIdx];
@@ -3849,25 +3849,25 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
UChar32 cPattern;
UChar32 cText;
- UBool success = TRUE;
+ UBool success = true;
UTEXT_SETNATIVEINDEX(fInputText, fp->fInputIdx);
CaseFoldingUTextIterator inputIterator(*fInputText);
while (patternStringIdx < patternStringLen) {
if (!inputIterator.inExpansion() && UTEXT_GETNATIVEINDEX(fInputText) >= fActiveLimit) {
- success = FALSE;
- fHitEnd = TRUE;
+ success = false;
+ fHitEnd = true;
break;
}
U16_NEXT(patternString, patternStringIdx, patternStringLen, cPattern);
cText = inputIterator.next();
if (cText != cPattern) {
- success = FALSE;
+ success = false;
break;
}
}
if (inputIterator.inExpansion()) {
- success = FALSE;
+ success = false;
}
if (success) {
@@ -4099,16 +4099,16 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
UTEXT_SETNATIVEINDEX(fInputText, ix);
for (;;) {
if (ix >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
break;
}
UChar32 c = UTEXT_NEXT32(fInputText);
if (c<256) {
- if (s8->contains(c) == FALSE) {
+ if (s8->contains(c) == false) {
break;
}
} else {
- if (s->contains(c) == FALSE) {
+ if (s->contains(c) == false) {
break;
}
}
@@ -4152,7 +4152,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
if ((opValue & 1) == 1) {
// Dot-matches-All mode. Jump straight to the end of the string.
ix = fActiveLimit;
- fHitEnd = TRUE;
+ fHitEnd = true;
} else {
// NOT DOT ALL mode. Line endings do not match '.'
// Scan forward until a line ending or end of input.
@@ -4160,7 +4160,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
UTEXT_SETNATIVEINDEX(fInputText, ix);
for (;;) {
if (ix >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
break;
}
UChar32 c = UTEXT_NEXT32(fInputText);
@@ -4252,7 +4252,7 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
}
if (U_FAILURE(status)) {
- isMatch = FALSE;
+ isMatch = false;
break;
}
}
@@ -4295,7 +4295,7 @@ breakFromLoop:
//
//--------------------------------------------------------------------------------
void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &status) {
- UBool isMatch = FALSE; // True if the we have a match.
+ UBool isMatch = false; // True if the we have a match.
int32_t backSearchIndex = INT32_MAX; // used after greedy single-character matches for searching backwards
@@ -4319,10 +4319,10 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
//
int64_t *pat = fPattern->fCompiledPat->getBuffer();
- const UChar *litText = fPattern->fLiteralText.getBuffer();
+ const char16_t *litText = fPattern->fLiteralText.getBuffer();
UVector *fSets = fPattern->fSets;
- const UChar *inputBuf = fInputText->chunkContents;
+ const char16_t *inputBuf = fInputText->chunkContents;
fFrameSize = fPattern->fFrameSize;
REStackFrame *fp = resetStack();
@@ -4381,7 +4381,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
break;
}
} else {
- fHitEnd = TRUE;
+ fHitEnd = true;
}
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
@@ -4402,19 +4402,19 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
U_ASSERT(opType == URX_STRING_LEN);
U_ASSERT(stringLen >= 2);
- const UChar * pInp = inputBuf + fp->fInputIdx;
- const UChar * pInpLimit = inputBuf + fActiveLimit;
- const UChar * pPat = litText+stringStartIdx;
- const UChar * pEnd = pInp + stringLen;
- UBool success = TRUE;
+ const char16_t * pInp = inputBuf + fp->fInputIdx;
+ const char16_t * pInpLimit = inputBuf + fActiveLimit;
+ const char16_t * pPat = litText+stringStartIdx;
+ const char16_t * pEnd = pInp + stringLen;
+ UBool success = true;
while (pInp < pEnd) {
if (pInp >= pInpLimit) {
- fHitEnd = TRUE;
- success = FALSE;
+ fHitEnd = true;
+ success = false;
break;
}
if (*pInp++ != *pPat++) {
- success = FALSE;
+ success = false;
break;
}
}
@@ -4441,7 +4441,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
- isMatch = TRUE;
+ isMatch = true;
goto breakFromLoop;
// Start and End Capture stack frame variables are laid out out like this:
@@ -4474,8 +4474,8 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
}
if (fp->fInputIdx >= fAnchorLimit) {
// We really are at the end of input. Success.
- fHitEnd = TRUE;
- fRequireEnd = TRUE;
+ fHitEnd = true;
+ fRequireEnd = true;
break;
}
@@ -4488,15 +4488,15 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
if (isLineTerminator(c)) {
if ( !(c==0x0a && fp->fInputIdx>fAnchorStart && inputBuf[fp->fInputIdx-1]==0x0d)) {
// At new-line at end of input. Success
- fHitEnd = TRUE;
- fRequireEnd = TRUE;
+ fHitEnd = true;
+ fRequireEnd = true;
break;
}
}
} else if (fp->fInputIdx == fAnchorLimit-2 &&
inputBuf[fp->fInputIdx]==0x0d && inputBuf[fp->fInputIdx+1]==0x0a) {
- fHitEnd = TRUE;
- fRequireEnd = TRUE;
+ fHitEnd = true;
+ fRequireEnd = true;
break; // At CR/LF at end of input. Success
}
@@ -4511,14 +4511,14 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
if (fp->fInputIdx == fAnchorLimit-1) {
// At last char of input. Success if it's a new line.
if (inputBuf[fp->fInputIdx] == 0x0a) {
- fHitEnd = TRUE;
- fRequireEnd = TRUE;
+ fHitEnd = true;
+ fRequireEnd = true;
break;
}
} else {
// Off the end of input. Success.
- fHitEnd = TRUE;
- fRequireEnd = TRUE;
+ fHitEnd = true;
+ fRequireEnd = true;
break;
}
}
@@ -4532,8 +4532,8 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
{
if (fp->fInputIdx >= fAnchorLimit) {
// We really are at the end of input. Success.
- fHitEnd = TRUE;
- fRequireEnd = TRUE;
+ fHitEnd = true;
+ fRequireEnd = true;
break;
}
// If we are positioned just before a new-line, succeed.
@@ -4557,8 +4557,8 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
{
if (fp->fInputIdx >= fAnchorLimit) {
// We really are at the end of input. Success.
- fHitEnd = TRUE;
- fRequireEnd = TRUE; // Java set requireEnd in this case, even though
+ fHitEnd = true;
+ fRequireEnd = true; // Java set requireEnd in this case, even though
break; // adding a new-line would not lose the match.
}
// If we are not positioned just before a new-line, the test fails; backtrack out.
@@ -4585,7 +4585,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
}
// Check whether character just before the current pos is a new-line
// unless we are at the end of input
- UChar c = inputBuf[fp->fInputIdx - 1];
+ char16_t c = inputBuf[fp->fInputIdx - 1];
if ((fp->fInputIdx < fAnchorLimit) &&
isLineTerminator(c)) {
// It's a new-line. ^ is true. Success.
@@ -4607,7 +4607,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
}
// Check whether character just before the current pos is a new-line
U_ASSERT(fp->fInputIdx <= fAnchorLimit);
- UChar c = inputBuf[fp->fInputIdx - 1];
+ char16_t c = inputBuf[fp->fInputIdx - 1];
if (c != 0x0a) {
// Not at the start of a line. Back-track out.
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
@@ -4640,7 +4640,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
case URX_BACKSLASH_D: // Test for decimal digit
{
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -4658,7 +4658,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
case URX_BACKSLASH_G: // Test for position at end of previous match
- if (!((fMatch && fp->fInputIdx==fMatchEnd) || (fMatch==FALSE && fp->fInputIdx==fActiveStart))) {
+ if (!((fMatch && fp->fInputIdx==fMatchEnd) || (fMatch==false && fp->fInputIdx==fActiveStart))) {
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
}
break;
@@ -4667,7 +4667,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
case URX_BACKSLASH_H: // Test for \h, horizontal white space.
{
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -4686,7 +4686,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
case URX_BACKSLASH_R: // Test for \R, any line break sequence.
{
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -4695,7 +4695,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
if (isLineTerminator(c)) {
if (c == 0x0d && fp->fInputIdx < fActiveLimit) {
// Check for CR/LF sequence. Consume both together when found.
- UChar c2;
+ char16_t c2;
U16_NEXT(inputBuf, fp->fInputIdx, fActiveLimit, c2);
if (c2 != 0x0a) {
U16_PREV(inputBuf, 0, fp->fInputIdx, c2);
@@ -4711,7 +4711,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
case URX_BACKSLASH_V: // Any single code point line ending.
{
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -4731,14 +4731,14 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
// Fail if at end of input
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
fp->fInputIdx = followingGCBoundary(fp->fInputIdx, status);
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp->fInputIdx = fActiveLimit;
}
break;
@@ -4748,8 +4748,8 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
if (fp->fInputIdx < fAnchorLimit) {
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
} else {
- fHitEnd = TRUE;
- fRequireEnd = TRUE;
+ fHitEnd = true;
+ fRequireEnd = true;
}
break;
@@ -4763,7 +4763,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
// 0: success if input char is in set.
// 1: success if input char is not in set.
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -4797,7 +4797,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
// Test input character for NOT being a member of one of
// the predefined sets (Word Characters, for example)
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -4808,12 +4808,12 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
U16_NEXT(inputBuf, fp->fInputIdx, fActiveLimit, c);
if (c < 256) {
Regex8BitSet &s8 = RegexStaticSets::gStaticSets->fPropSets8[opValue];
- if (s8.contains(c) == FALSE) {
+ if (s8.contains(c) == false) {
break;
}
} else {
const UnicodeSet &s = RegexStaticSets::gStaticSets->fPropSets[opValue];
- if (s.contains(c) == FALSE) {
+ if (s.contains(c) == false) {
break;
}
}
@@ -4825,7 +4825,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
case URX_SETREF:
{
if (fp->fInputIdx >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -4860,7 +4860,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
// . matches anything, but stops at end-of-line.
if (fp->fInputIdx >= fActiveLimit) {
// At end of input. Match failed. Backtrack out.
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -4882,7 +4882,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
// . in dot-matches-all (including new lines) mode
if (fp->fInputIdx >= fActiveLimit) {
// At end of input. Match failed. Backtrack out.
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -4907,7 +4907,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
// UNIX_LINES mode, so 0x0a is the only recognized line ending.
if (fp->fInputIdx >= fActiveLimit) {
// At end of input. Match failed. Backtrack out.
- fHitEnd = TRUE;
+ fHitEnd = true;
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
}
@@ -4928,7 +4928,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
break;
case URX_FAIL:
- isMatch = FALSE;
+ isMatch = false;
goto breakFromLoop;
case URX_JMP_SAV:
@@ -5137,15 +5137,15 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
fp = (REStackFrame *)fStack->popFrame(fFrameSize); // FAIL, no match.
break;
}
- UBool success = TRUE;
+ UBool success = true;
for (int64_t groupIndex = groupStartIdx; groupIndex < groupEndIdx; ++groupIndex,++inputIndex) {
if (inputIndex >= fActiveLimit) {
- success = FALSE;
- fHitEnd = TRUE;
+ success = false;
+ fHitEnd = true;
break;
}
if (inputBuf[groupIndex] != inputBuf[inputIndex]) {
- success = FALSE;
+ success = false;
break;
}
}
@@ -5153,7 +5153,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
inputIndex < fActiveLimit && U16_IS_TRAIL(inputBuf[inputIndex])) {
// Capture group ended with an unpaired lead surrogate.
// Back reference is not permitted to match lead only of a surrogatge pair.
- success = FALSE;
+ success = false;
}
if (success) {
fp->fInputIdx = inputIndex;
@@ -5181,21 +5181,21 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
// match succeeds. Verified by testing: Perl matches succeed
// in this case, so we do too.
- UBool success = TRUE;
+ UBool success = true;
for (;;) {
UChar32 captureGroupChar = captureGroupItr.next();
if (captureGroupChar == U_SENTINEL) {
- success = TRUE;
+ success = true;
break;
}
UChar32 inputChar = inputItr.next();
if (inputChar == U_SENTINEL) {
- success = FALSE;
- fHitEnd = TRUE;
+ success = false;
+ fHitEnd = true;
break;
}
if (inputChar != captureGroupChar) {
- success = FALSE;
+ success = false;
break;
}
}
@@ -5204,7 +5204,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
// We obtained a match by consuming part of a string obtained from
// case-folding a single code point of the input text.
// This does not count as an overall match.
- success = FALSE;
+ success = false;
}
if (success) {
@@ -5291,7 +5291,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
break;
}
} else {
- fHitEnd = TRUE;
+ fHitEnd = true;
}
fp = (REStackFrame *)fStack->popFrame(fFrameSize);
break;
@@ -5302,7 +5302,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
// offset to the string text, and one for the length.
// The compiled string has already been case folded.
{
- const UChar *patternString = litText + opValue;
+ const char16_t *patternString = litText + opValue;
op = (int32_t)pat[fp->fPatIdx];
fp->fPatIdx++;
@@ -5313,22 +5313,22 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
UChar32 cText;
UChar32 cPattern;
- UBool success = TRUE;
+ UBool success = true;
int32_t patternStringIdx = 0;
CaseFoldingUCharIterator inputIterator(inputBuf, fp->fInputIdx, fActiveLimit);
while (patternStringIdx < patternStringLen) {
U16_NEXT(patternString, patternStringIdx, patternStringLen, cPattern);
cText = inputIterator.next();
if (cText != cPattern) {
- success = FALSE;
+ success = false;
if (cText == U_SENTINEL) {
- fHitEnd = TRUE;
+ fHitEnd = true;
}
break;
}
}
if (inputIterator.inExpansion()) {
- success = FALSE;
+ success = false;
}
if (success) {
@@ -5540,18 +5540,18 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
int32_t ix = (int32_t)fp->fInputIdx;
for (;;) {
if (ix >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
break;
}
UChar32 c;
U16_NEXT(inputBuf, ix, fActiveLimit, c);
if (c<256) {
- if (s8->contains(c) == FALSE) {
+ if (s8->contains(c) == false) {
U16_BACK_1(inputBuf, 0, ix);
break;
}
} else {
- if (s->contains(c) == FALSE) {
+ if (s->contains(c) == false) {
U16_BACK_1(inputBuf, 0, ix);
break;
}
@@ -5595,14 +5595,14 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
if ((opValue & 1) == 1) {
// Dot-matches-All mode. Jump straight to the end of the string.
ix = (int32_t)fActiveLimit;
- fHitEnd = TRUE;
+ fHitEnd = true;
} else {
// NOT DOT ALL mode. Line endings do not match '.'
// Scan forward until a line ending or end of input.
ix = (int32_t)fp->fInputIdx;
for (;;) {
if (ix >= fActiveLimit) {
- fHitEnd = TRUE;
+ fHitEnd = true;
break;
}
UChar32 c;
@@ -5694,7 +5694,7 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
}
if (U_FAILURE(status)) {
- isMatch = FALSE;
+ isMatch = false;
break;
}
}
diff --git a/contrib/libs/icu/i18n/remtrans.cpp b/contrib/libs/icu/i18n/remtrans.cpp
index 03b878575c..40af1845c7 100644
--- a/contrib/libs/icu/i18n/remtrans.cpp
+++ b/contrib/libs/icu/i18n/remtrans.cpp
@@ -17,7 +17,7 @@
#include "remtrans.h"
#include "unicode/unifilt.h"
-static const UChar CURR_ID[] = {65, 110, 121, 45, 0x52, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x00}; /* "Any-Remove" */
+static const char16_t CURR_ID[] = {65, 110, 121, 45, 0x52, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x00}; /* "Any-Remove" */
U_NAMESPACE_BEGIN
@@ -37,20 +37,20 @@ static Transliterator* RemoveTransliterator_create(const UnicodeString& /*ID*/,
*/
void RemoveTransliterator::registerIDs() {
- Transliterator::_registerFactory(UnicodeString(TRUE, ::CURR_ID, -1),
+ Transliterator::_registerFactory(UnicodeString(true, ::CURR_ID, -1),
RemoveTransliterator_create, integerToken(0));
Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("Remove"),
- UNICODE_STRING_SIMPLE("Null"), FALSE);
+ UNICODE_STRING_SIMPLE("Null"), false);
}
-RemoveTransliterator::RemoveTransliterator() : Transliterator(UnicodeString(TRUE, ::CURR_ID, -1), 0) {}
+RemoveTransliterator::RemoveTransliterator() : Transliterator(UnicodeString(true, ::CURR_ID, -1), 0) {}
RemoveTransliterator::~RemoveTransliterator() {}
RemoveTransliterator* RemoveTransliterator::clone() const {
RemoveTransliterator* result = new RemoveTransliterator();
- if (result != NULL && getFilter() != 0) {
+ if (result != nullptr && getFilter() != 0) {
result->adoptFilter(getFilter()->clone());
}
return result;
diff --git a/contrib/libs/icu/i18n/repattrn.cpp b/contrib/libs/icu/i18n/repattrn.cpp
index 8c94948d29..c0a88f70d9 100644
--- a/contrib/libs/icu/i18n/repattrn.cpp
+++ b/contrib/libs/icu/i18n/repattrn.cpp
@@ -77,15 +77,15 @@ RegexPattern &RegexPattern::operator = (const RegexPattern &other) {
return *this;
}
- if (other.fPatternString == NULL) {
- fPatternString = NULL;
- fPattern = utext_clone(fPattern, other.fPattern, FALSE, TRUE, &fDeferredStatus);
+ if (other.fPatternString == nullptr) {
+ fPatternString = nullptr;
+ fPattern = utext_clone(fPattern, other.fPattern, false, true, &fDeferredStatus);
} else {
fPatternString = new UnicodeString(*(other.fPatternString));
- if (fPatternString == NULL) {
+ if (fPatternString == nullptr) {
fDeferredStatus = U_MEMORY_ALLOCATION_ERROR;
} else {
- fPattern = utext_openConstUnicodeString(NULL, fPatternString, &fDeferredStatus);
+ fPattern = utext_openConstUnicodeString(nullptr, fPatternString, &fDeferredStatus);
}
}
if (U_FAILURE(fDeferredStatus)) {
@@ -117,7 +117,7 @@ RegexPattern &RegexPattern::operator = (const RegexPattern &other) {
int32_t i;
int32_t numSets = other.fSets->size();
fSets8 = new Regex8BitSet[numSets];
- if (fSets8 == NULL) {
+ if (fSets8 == nullptr) {
fDeferredStatus = U_MEMORY_ALLOCATION_ERROR;
return *this;
}
@@ -127,7 +127,7 @@ RegexPattern &RegexPattern::operator = (const RegexPattern &other) {
}
UnicodeSet *sourceSet = (UnicodeSet *)other.fSets->elementAt(i);
UnicodeSet *newSet = new UnicodeSet(*sourceSet);
- if (newSet == NULL) {
+ if (newSet == nullptr) {
fDeferredStatus = U_MEMORY_ALLOCATION_ERROR;
break;
}
@@ -145,7 +145,7 @@ RegexPattern &RegexPattern::operator = (const RegexPattern &other) {
const UnicodeString *name = (const UnicodeString *)hashEl->key.pointer;
UnicodeString *key = new UnicodeString(*name);
int32_t val = hashEl->value.integer;
- if (key == NULL) {
+ if (key == nullptr) {
fDeferredStatus = U_MEMORY_ALLOCATION_ERROR;
} else {
uhash_puti(fNamedCaptureMap, key, val, &fDeferredStatus);
@@ -166,24 +166,24 @@ void RegexPattern::init() {
fFlags = 0;
fCompiledPat = 0;
fLiteralText.remove();
- fSets = NULL;
- fSets8 = NULL;
+ fSets = nullptr;
+ fSets8 = nullptr;
fDeferredStatus = U_ZERO_ERROR;
fMinMatchLen = 0;
fFrameSize = 0;
fDataSize = 0;
- fGroupMap = NULL;
+ fGroupMap = nullptr;
fStartType = START_NO_INFO;
fInitialStringIdx = 0;
fInitialStringLen = 0;
- fInitialChars = NULL;
+ fInitialChars = nullptr;
fInitialChar = 0;
- fInitialChars8 = NULL;
- fNeedsAltInput = FALSE;
- fNamedCaptureMap = NULL;
+ fInitialChars8 = nullptr;
+ fNeedsAltInput = false;
+ fNamedCaptureMap = nullptr;
- fPattern = NULL; // will be set later
- fPatternString = NULL; // may be set later
+ fPattern = nullptr; // will be set later
+ fPatternString = nullptr; // may be set later
fCompiledPat = new UVector64(fDeferredStatus);
fGroupMap = new UVector32(fDeferredStatus);
fSets = new UVector(fDeferredStatus);
@@ -192,8 +192,8 @@ void RegexPattern::init() {
if (U_FAILURE(fDeferredStatus)) {
return;
}
- if (fCompiledPat == NULL || fGroupMap == NULL || fSets == NULL ||
- fInitialChars == NULL || fInitialChars8 == NULL) {
+ if (fCompiledPat == nullptr || fGroupMap == nullptr || fSets == nullptr ||
+ fInitialChars == nullptr || fInitialChars8 == nullptr) {
fDeferredStatus = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -228,36 +228,36 @@ bool RegexPattern::initNamedCaptureMap() {
//--------------------------------------------------------------------------
void RegexPattern::zap() {
delete fCompiledPat;
- fCompiledPat = NULL;
+ fCompiledPat = nullptr;
int i;
for (i=1; i<fSets->size(); i++) {
UnicodeSet *s;
s = (UnicodeSet *)fSets->elementAt(i);
- if (s != NULL) {
+ if (s != nullptr) {
delete s;
}
}
delete fSets;
- fSets = NULL;
+ fSets = nullptr;
delete[] fSets8;
- fSets8 = NULL;
+ fSets8 = nullptr;
delete fGroupMap;
- fGroupMap = NULL;
+ fGroupMap = nullptr;
delete fInitialChars;
- fInitialChars = NULL;
+ fInitialChars = nullptr;
delete fInitialChars8;
- fInitialChars8 = NULL;
- if (fPattern != NULL) {
+ fInitialChars8 = nullptr;
+ if (fPattern != nullptr) {
utext_close(fPattern);
- fPattern = NULL;
+ fPattern = nullptr;
}
- if (fPatternString != NULL) {
+ if (fPatternString != nullptr) {
delete fPatternString;
- fPatternString = NULL;
+ fPatternString = nullptr;
}
- if (fNamedCaptureMap != NULL) {
+ if (fNamedCaptureMap != nullptr) {
uhash_close(fNamedCaptureMap);
- fNamedCaptureMap = NULL;
+ fNamedCaptureMap = nullptr;
}
}
@@ -293,13 +293,13 @@ RegexPattern *RegexPattern::clone() const {
//--------------------------------------------------------------------------
bool RegexPattern::operator ==(const RegexPattern &other) const {
if (this->fFlags == other.fFlags && this->fDeferredStatus == other.fDeferredStatus) {
- if (this->fPatternString != NULL && other.fPatternString != NULL) {
+ if (this->fPatternString != nullptr && other.fPatternString != nullptr) {
return *(this->fPatternString) == *(other.fPatternString);
- } else if (this->fPattern == NULL) {
- if (other.fPattern == NULL) {
+ } else if (this->fPattern == nullptr) {
+ if (other.fPattern == nullptr) {
return true;
}
- } else if (other.fPattern != NULL) {
+ } else if (other.fPattern != nullptr) {
UTEXT_SETNATIVEINDEX(this->fPattern, 0);
UTEXT_SETNATIVEINDEX(other.fPattern, 0);
return utext_equals(this->fPattern, other.fPattern);
@@ -320,7 +320,7 @@ RegexPattern::compile(const UnicodeString &regex,
UErrorCode &status)
{
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
const uint32_t allFlags = UREGEX_CANON_EQ | UREGEX_CASE_INSENSITIVE | UREGEX_COMMENTS |
@@ -329,23 +329,23 @@ RegexPattern::compile(const UnicodeString &regex,
if ((flags & ~allFlags) != 0) {
status = U_REGEX_INVALID_FLAG;
- return NULL;
+ return nullptr;
}
if ((flags & UREGEX_CANON_EQ) != 0) {
status = U_REGEX_UNIMPLEMENTED;
- return NULL;
+ return nullptr;
}
RegexPattern *This = new RegexPattern;
- if (This == NULL) {
+ if (This == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
if (U_FAILURE(This->fDeferredStatus)) {
status = This->fDeferredStatus;
delete This;
- return NULL;
+ return nullptr;
}
This->fFlags = flags;
@@ -354,7 +354,7 @@ RegexPattern::compile(const UnicodeString &regex,
if (U_FAILURE(status)) {
delete This;
- This = NULL;
+ This = nullptr;
}
return This;
@@ -371,7 +371,7 @@ RegexPattern::compile(UText *regex,
UErrorCode &status)
{
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
const uint32_t allFlags = UREGEX_CANON_EQ | UREGEX_CASE_INSENSITIVE | UREGEX_COMMENTS |
@@ -380,23 +380,23 @@ RegexPattern::compile(UText *regex,
if ((flags & ~allFlags) != 0) {
status = U_REGEX_INVALID_FLAG;
- return NULL;
+ return nullptr;
}
if ((flags & UREGEX_CANON_EQ) != 0) {
status = U_REGEX_UNIMPLEMENTED;
- return NULL;
+ return nullptr;
}
RegexPattern *This = new RegexPattern;
- if (This == NULL) {
+ if (This == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
if (U_FAILURE(This->fDeferredStatus)) {
status = This->fDeferredStatus;
delete This;
- return NULL;
+ return nullptr;
}
This->fFlags = flags;
@@ -405,7 +405,7 @@ RegexPattern::compile(UText *regex,
if (U_FAILURE(status)) {
delete This;
- This = NULL;
+ This = nullptr;
}
return This;
@@ -479,7 +479,7 @@ uint32_t RegexPattern::flags() const {
RegexMatcher *RegexPattern::matcher(const UnicodeString &input,
UErrorCode &status) const {
RegexMatcher *retMatcher = matcher(status);
- if (retMatcher != NULL) {
+ if (retMatcher != nullptr) {
retMatcher->fDeferredStatus = status;
retMatcher->reset(input);
}
@@ -493,20 +493,20 @@ RegexMatcher *RegexPattern::matcher(const UnicodeString &input,
//
//---------------------------------------------------------------------
RegexMatcher *RegexPattern::matcher(UErrorCode &status) const {
- RegexMatcher *retMatcher = NULL;
+ RegexMatcher *retMatcher = nullptr;
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
if (U_FAILURE(fDeferredStatus)) {
status = fDeferredStatus;
- return NULL;
+ return nullptr;
}
retMatcher = new RegexMatcher(this);
- if (retMatcher == NULL) {
+ if (retMatcher == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
return retMatcher;
}
@@ -524,11 +524,11 @@ UBool U_EXPORT2 RegexPattern::matches(const UnicodeString &regex,
UParseError &pe,
UErrorCode &status) {
- if (U_FAILURE(status)) {return FALSE;}
+ if (U_FAILURE(status)) {return false;}
UBool retVal;
- RegexPattern *pat = NULL;
- RegexMatcher *matcher = NULL;
+ RegexPattern *pat = nullptr;
+ RegexMatcher *matcher = nullptr;
pat = RegexPattern::compile(regex, 0, pe, status);
matcher = pat->matcher(input, status);
@@ -548,11 +548,11 @@ UBool U_EXPORT2 RegexPattern::matches(UText *regex,
UParseError &pe,
UErrorCode &status) {
- if (U_FAILURE(status)) {return FALSE;}
+ if (U_FAILURE(status)) {return false;}
- UBool retVal = FALSE;
- RegexPattern *pat = NULL;
- RegexMatcher *matcher = NULL;
+ UBool retVal = false;
+ RegexPattern *pat = nullptr;
+ RegexMatcher *matcher = nullptr;
pat = RegexPattern::compile(regex, 0, pe, status);
matcher = pat->matcher(status);
@@ -576,18 +576,18 @@ UBool U_EXPORT2 RegexPattern::matches(UText *regex,
//
//---------------------------------------------------------------------
UnicodeString RegexPattern::pattern() const {
- if (fPatternString != NULL) {
+ if (fPatternString != nullptr) {
return *fPatternString;
- } else if (fPattern == NULL) {
+ } else if (fPattern == nullptr) {
return UnicodeString();
} else {
UErrorCode status = U_ZERO_ERROR;
int64_t nativeLen = utext_nativeLength(fPattern);
- int32_t len16 = utext_extract(fPattern, 0, nativeLen, NULL, 0, &status); // buffer overflow error
+ int32_t len16 = utext_extract(fPattern, 0, nativeLen, nullptr, 0, &status); // buffer overflow error
UnicodeString result;
status = U_ZERO_ERROR;
- UChar *resultChars = result.getBuffer(len16);
+ char16_t *resultChars = result.getBuffer(len16);
utext_extract(fPattern, 0, nativeLen, resultChars, len16, &status); // unterminated warning
result.releaseBuffer(len16);
@@ -604,10 +604,10 @@ UnicodeString RegexPattern::pattern() const {
//
//---------------------------------------------------------------------
UText *RegexPattern::patternText(UErrorCode &status) const {
- if (U_FAILURE(status)) {return NULL;}
+ if (U_FAILURE(status)) {return nullptr;}
status = U_ZERO_ERROR;
- if (fPattern != NULL) {
+ if (fPattern != nullptr) {
return fPattern;
} else {
RegexStaticSets::initGlobals(&status);
@@ -788,7 +788,7 @@ void RegexPattern::dumpOp(int32_t index) const {
{
UnicodeString s;
UnicodeSet *set = (UnicodeSet *)fSets->elementAt(val);
- set->toPattern(s, TRUE);
+ set->toPattern(s, true);
printf("%s", CStr(s)());
}
break;
@@ -802,7 +802,7 @@ void RegexPattern::dumpOp(int32_t index) const {
val &= ~URX_NEG_SET;
}
UnicodeSet &set = RegexStaticSets::gStaticSets->fPropSets[val];
- set.toPattern(s, TRUE);
+ set.toPattern(s, true);
printf("%s", CStr(s)());
}
break;
@@ -833,7 +833,7 @@ void RegexPattern::dumpPattern() const {
printf(" Initial match string: \"%s\"\n", CStr(initialString)());
} else if (fStartType == START_SET) {
UnicodeString s;
- fInitialChars->toPattern(s, TRUE);
+ fInitialChars->toPattern(s, true);
printf(" Match First Chars: %s\n", CStr(s)());
} else if (fStartType == START_CHAR) {
@@ -850,7 +850,7 @@ void RegexPattern::dumpPattern() const {
printf(" None\n");
} else {
int32_t pos = UHASH_FIRST;
- const UHashElement *el = NULL;
+ const UHashElement *el = nullptr;
while ((el = uhash_nextElement(fNamedCaptureMap, &pos))) {
const UnicodeString *name = (const UnicodeString *)el->key.pointer;
int32_t number = el->value.integer;
diff --git a/contrib/libs/icu/i18n/rulebasedcollator.cpp b/contrib/libs/icu/i18n/rulebasedcollator.cpp
index 5e5cc3db62..e9482628d9 100644
--- a/contrib/libs/icu/i18n/rulebasedcollator.cpp
+++ b/contrib/libs/icu/i18n/rulebasedcollator.cpp
@@ -74,7 +74,7 @@ FixedSortKeyByteSink::~FixedSortKeyByteSink() {}
void
FixedSortKeyByteSink::AppendBeyondCapacity(const char *bytes, int32_t /*n*/, int32_t length) {
- // buffer_ != NULL && bytes != NULL && n > 0 && appended_ > capacity_
+ // buffer_ != nullptr && bytes != nullptr && n > 0 && appended_ > capacity_
// Fill the buffer completely.
int32_t available = capacity_ - length;
if (available > 0) {
@@ -84,7 +84,7 @@ FixedSortKeyByteSink::AppendBeyondCapacity(const char *bytes, int32_t /*n*/, int
UBool
FixedSortKeyByteSink::Resize(int32_t /*appendCapacity*/, int32_t /*length*/) {
- return FALSE;
+ return false;
}
} // namespace
@@ -108,7 +108,7 @@ CollationKeyByteSink::~CollationKeyByteSink() {}
void
CollationKeyByteSink::AppendBeyondCapacity(const char *bytes, int32_t n, int32_t length) {
- // buffer_ != NULL && bytes != NULL && n > 0 && appended_ > capacity_
+ // buffer_ != nullptr && bytes != nullptr && n > 0 && appended_ > capacity_
if (Resize(n, length)) {
uprv_memcpy(buffer_ + length, bytes, n);
}
@@ -116,8 +116,8 @@ CollationKeyByteSink::AppendBeyondCapacity(const char *bytes, int32_t n, int32_t
UBool
CollationKeyByteSink::Resize(int32_t appendCapacity, int32_t length) {
- if (buffer_ == NULL) {
- return FALSE; // allocation failed before already
+ if (buffer_ == nullptr) {
+ return false; // allocation failed before already
}
int32_t newCapacity = 2 * capacity_;
int32_t altCapacity = length + 2 * appendCapacity;
@@ -128,13 +128,13 @@ CollationKeyByteSink::Resize(int32_t appendCapacity, int32_t length) {
newCapacity = 200;
}
uint8_t *newBuffer = key_.reallocate(newCapacity, length);
- if (newBuffer == NULL) {
+ if (newBuffer == nullptr) {
SetNotOk();
- return FALSE;
+ return false;
}
buffer_ = reinterpret_cast<char *>(newBuffer);
capacity_ = newCapacity;
- return TRUE;
+ return true;
}
RuleBasedCollator::RuleBasedCollator(const RuleBasedCollator &other)
@@ -152,15 +152,15 @@ RuleBasedCollator::RuleBasedCollator(const RuleBasedCollator &other)
RuleBasedCollator::RuleBasedCollator(const uint8_t *bin, int32_t length,
const RuleBasedCollator *base, UErrorCode &errorCode)
- : data(NULL),
- settings(NULL),
- tailoring(NULL),
- cacheEntry(NULL),
+ : data(nullptr),
+ settings(nullptr),
+ tailoring(nullptr),
+ cacheEntry(nullptr),
validLocale(""),
explicitlySetAttributes(0),
- actualLocaleIsSameAsValid(FALSE) {
+ actualLocaleIsSameAsValid(false) {
if(U_FAILURE(errorCode)) { return; }
- if(bin == NULL || length == 0 || base == NULL) {
+ if(bin == nullptr || length == 0 || base == nullptr) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@@ -188,7 +188,7 @@ RuleBasedCollator::RuleBasedCollator(const CollationCacheEntry *entry)
cacheEntry(entry),
validLocale(entry->validLocale),
explicitlySetAttributes(0),
- actualLocaleIsSameAsValid(FALSE) {
+ actualLocaleIsSameAsValid(false) {
settings->addRef();
cacheEntry->addRef();
}
@@ -204,9 +204,9 @@ RuleBasedCollator::adoptTailoring(CollationTailoring *t, UErrorCode &errorCode)
t->deleteIfZeroRefCount();
return;
}
- U_ASSERT(settings == NULL && data == NULL && tailoring == NULL && cacheEntry == NULL);
+ U_ASSERT(settings == nullptr && data == nullptr && tailoring == nullptr && cacheEntry == nullptr);
cacheEntry = new CollationCacheEntry(t->actualLocale, t);
- if(cacheEntry == NULL) {
+ if(cacheEntry == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
t->deleteIfZeroRefCount();
return;
@@ -217,7 +217,7 @@ RuleBasedCollator::adoptTailoring(CollationTailoring *t, UErrorCode &errorCode)
tailoring = t;
cacheEntry->addRef();
validLocale = t->actualLocale;
- actualLocaleIsSameAsValid = FALSE;
+ actualLocaleIsSameAsValid = false;
}
RuleBasedCollator *
@@ -246,8 +246,8 @@ RuleBasedCollator::operator==(const Collator& other) const {
const RuleBasedCollator &o = static_cast<const RuleBasedCollator &>(other);
if(*settings != *o.settings) { return false; }
if(data == o.data) { return true; }
- UBool thisIsRoot = data->base == NULL;
- UBool otherIsRoot = o.data->base == NULL;
+ UBool thisIsRoot = data->base == nullptr;
+ UBool otherIsRoot = o.data->base == nullptr;
U_ASSERT(!thisIsRoot || !otherIsRoot); // otherwise their data pointers should be ==
if(thisIsRoot != otherIsRoot) { return false; }
if((thisIsRoot || !tailoring->rules.isEmpty()) &&
@@ -274,7 +274,7 @@ RuleBasedCollator::operator==(const Collator& other) const {
int32_t
RuleBasedCollator::hashCode() const {
int32_t h = settings->hashCode();
- if(data->base == NULL) { return h; } // root collator
+ if(data->base == nullptr) { return h; } // root collator
// Do not rely on the rule string, see comments in operator==().
UErrorCode errorCode = U_ZERO_ERROR;
LocalPointer<UnicodeSet> set(getTailoredSet(errorCode));
@@ -290,10 +290,10 @@ void
RuleBasedCollator::setLocales(const Locale &requested, const Locale &valid,
const Locale &actual) {
if(actual == tailoring->actualLocale) {
- actualLocaleIsSameAsValid = FALSE;
+ actualLocaleIsSameAsValid = false;
} else {
U_ASSERT(actual == valid);
- actualLocaleIsSameAsValid = TRUE;
+ actualLocaleIsSameAsValid = true;
}
// Do not modify tailoring.actualLocale:
// We cannot be sure that that would be thread-safe.
@@ -321,7 +321,7 @@ RuleBasedCollator::getLocale(ULocDataLocaleType type, UErrorCode& errorCode) con
const char *
RuleBasedCollator::internalGetLocaleID(ULocDataLocaleType type, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) {
- return NULL;
+ return nullptr;
}
const Locale *result;
switch(type) {
@@ -334,9 +334,9 @@ RuleBasedCollator::internalGetLocaleID(ULocDataLocaleType type, UErrorCode &erro
case ULOC_REQUESTED_LOCALE:
default:
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
- if(result->isBogus()) { return NULL; }
+ if(result->isBogus()) { return nullptr; }
const char *id = result->getName();
return id[0] == 0 ? "root" : id;
}
@@ -366,17 +366,17 @@ RuleBasedCollator::getVersion(UVersionInfo version) const {
UnicodeSet *
RuleBasedCollator::getTailoredSet(UErrorCode &errorCode) const {
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
UnicodeSet *tailored = new UnicodeSet();
- if(tailored == NULL) {
+ if(tailored == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
- if(data->base != NULL) {
+ if(data->base != nullptr) {
TailoredSet(tailored).forData(data, errorCode);
if(U_FAILURE(errorCode)) {
delete tailored;
- return NULL;
+ return nullptr;
}
}
return tailored;
@@ -387,19 +387,19 @@ RuleBasedCollator::internalGetContractionsAndExpansions(
UnicodeSet *contractions, UnicodeSet *expansions,
UBool addPrefixes, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return; }
- if(contractions != NULL) {
+ if(contractions != nullptr) {
contractions->clear();
}
- if(expansions != NULL) {
+ if(expansions != nullptr) {
expansions->clear();
}
- ContractionsAndExpansions(contractions, expansions, NULL, addPrefixes).forData(data, errorCode);
+ ContractionsAndExpansions(contractions, expansions, nullptr, addPrefixes).forData(data, errorCode);
}
void
RuleBasedCollator::internalAddContractions(UChar32 c, UnicodeSet &set, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return; }
- ContractionsAndExpansions(&set, NULL, NULL, FALSE).forCodePoint(data, c, errorCode);
+ ContractionsAndExpansions(&set, nullptr, nullptr, false).forCodePoint(data, c, errorCode);
}
const CollationSettings &
@@ -457,7 +457,7 @@ RuleBasedCollator::setAttribute(UColAttribute attr, UColAttributeValue value,
}
}
CollationSettings *ownedSettings = SharedObject::copyOnWrite(settings);
- if(ownedSettings == NULL) {
+ if(ownedSettings == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -532,13 +532,14 @@ RuleBasedCollator::setMaxVariable(UColReorderCode group, UErrorCode &errorCode)
}
}
CollationSettings *ownedSettings = SharedObject::copyOnWrite(settings);
- if(ownedSettings == NULL) {
+ if(ownedSettings == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return *this;
}
if(group == UCOL_REORDER_CODE_DEFAULT) {
- group = (UColReorderCode)(UCOL_REORDER_CODE_FIRST + defaultSettings.getMaxVariable());
+ group = (UColReorderCode)(
+ UCOL_REORDER_CODE_FIRST + int32_t{defaultSettings.getMaxVariable()});
}
uint32_t varTop = data->getLastPrimaryForGroup(group);
U_ASSERT(varTop != 0);
@@ -556,7 +557,7 @@ RuleBasedCollator::setMaxVariable(UColReorderCode group, UErrorCode &errorCode)
UColReorderCode
RuleBasedCollator::getMaxVariable() const {
- return (UColReorderCode)(UCOL_REORDER_CODE_FIRST + settings->getMaxVariable());
+ return (UColReorderCode)(UCOL_REORDER_CODE_FIRST + int32_t{settings->getMaxVariable()});
}
uint32_t
@@ -565,9 +566,9 @@ RuleBasedCollator::getVariableTop(UErrorCode & /*errorCode*/) const {
}
uint32_t
-RuleBasedCollator::setVariableTop(const UChar *varTop, int32_t len, UErrorCode &errorCode) {
+RuleBasedCollator::setVariableTop(const char16_t *varTop, int32_t len, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return 0; }
- if(varTop == NULL && len !=0) {
+ if(varTop == nullptr && len !=0) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -616,7 +617,7 @@ RuleBasedCollator::setVariableTop(uint32_t varTop, UErrorCode &errorCode) {
varTop = v;
if(varTop != settings->variableTop) {
CollationSettings *ownedSettings = SharedObject::copyOnWrite(settings);
- if(ownedSettings == NULL) {
+ if(ownedSettings == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -638,7 +639,7 @@ int32_t
RuleBasedCollator::getReorderCodes(int32_t *dest, int32_t capacity,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return 0; }
- if(capacity < 0 || (dest == NULL && capacity > 0)) {
+ if(capacity < 0 || (dest == nullptr && capacity > 0)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -656,7 +657,7 @@ void
RuleBasedCollator::setReorderCodes(const int32_t *reorderCodes, int32_t length,
UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
- if(length < 0 || (reorderCodes == NULL && length > 0)) {
+ if(length < 0 || (reorderCodes == nullptr && length > 0)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@@ -671,7 +672,7 @@ RuleBasedCollator::setReorderCodes(const int32_t *reorderCodes, int32_t length,
if(length == 1 && reorderCodes[0] == UCOL_REORDER_CODE_DEFAULT) {
if(settings != &defaultSettings) {
CollationSettings *ownedSettings = SharedObject::copyOnWrite(settings);
- if(ownedSettings == NULL) {
+ if(ownedSettings == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -681,7 +682,7 @@ RuleBasedCollator::setReorderCodes(const int32_t *reorderCodes, int32_t length,
return;
}
CollationSettings *ownedSettings = SharedObject::copyOnWrite(settings);
- if(ownedSettings == NULL) {
+ if(ownedSettings == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -721,11 +722,11 @@ RuleBasedCollator::compare(const UnicodeString &left, const UnicodeString &right
}
UCollationResult
-RuleBasedCollator::compare(const UChar *left, int32_t leftLength,
- const UChar *right, int32_t rightLength,
+RuleBasedCollator::compare(const char16_t *left, int32_t leftLength,
+ const char16_t *right, int32_t rightLength,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return UCOL_EQUAL; }
- if((left == NULL && leftLength != 0) || (right == NULL && rightLength != 0)) {
+ if((left == nullptr && leftLength != 0) || (right == nullptr && rightLength != 0)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return UCOL_EQUAL;
}
@@ -745,7 +746,7 @@ RuleBasedCollator::compareUTF8(const StringPiece &left, const StringPiece &right
if(U_FAILURE(errorCode)) { return UCOL_EQUAL; }
const uint8_t *leftBytes = reinterpret_cast<const uint8_t *>(left.data());
const uint8_t *rightBytes = reinterpret_cast<const uint8_t *>(right.data());
- if((leftBytes == NULL && !left.empty()) || (rightBytes == NULL && !right.empty())) {
+ if((leftBytes == nullptr && !left.empty()) || (rightBytes == nullptr && !right.empty())) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return UCOL_EQUAL;
}
@@ -757,7 +758,7 @@ RuleBasedCollator::internalCompareUTF8(const char *left, int32_t leftLength,
const char *right, int32_t rightLength,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return UCOL_EQUAL; }
- if((left == NULL && leftLength != 0) || (right == NULL && rightLength != 0)) {
+ if((left == nullptr && leftLength != 0) || (right == nullptr && rightLength != 0)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return UCOL_EQUAL;
}
@@ -808,7 +809,7 @@ public:
UChar32 nextDecomposedCodePoint(const Normalizer2Impl &nfcImpl, UChar32 c) {
if(index >= 0) { return c; }
decomp = nfcImpl.getDecomposition(c, buffer, length);
- if(decomp == NULL) { return c; }
+ if(decomp == nullptr) { return c; }
index = 0;
U16_NEXT_UNSAFE(decomp, index, c);
return c;
@@ -820,24 +821,24 @@ protected:
*/
virtual UChar32 nextRawCodePoint() = 0;
private:
- const UChar *decomp;
- UChar buffer[4];
+ const char16_t *decomp;
+ char16_t buffer[4];
int32_t index;
int32_t length;
};
class UTF16NFDIterator : public NFDIterator {
public:
- UTF16NFDIterator(const UChar *text, const UChar *textLimit) : s(text), limit(textLimit) {}
+ UTF16NFDIterator(const char16_t *text, const char16_t *textLimit) : s(text), limit(textLimit) {}
protected:
virtual UChar32 nextRawCodePoint() override {
if(s == limit) { return U_SENTINEL; }
UChar32 c = *s++;
- if(limit == NULL && c == 0) {
- s = NULL;
+ if(limit == nullptr && c == 0) {
+ s = nullptr;
return U_SENTINEL;
}
- UChar trail;
+ char16_t trail;
if(U16_IS_LEAD(c) && s != limit && U16_IS_TRAIL(trail = *s)) {
++s;
c = U16_GET_SUPPLEMENTARY(c, trail);
@@ -845,18 +846,18 @@ protected:
return c;
}
- const UChar *s;
- const UChar *limit;
+ const char16_t *s;
+ const char16_t *limit;
};
class FCDUTF16NFDIterator : public UTF16NFDIterator {
public:
- FCDUTF16NFDIterator(const Normalizer2Impl &nfcImpl, const UChar *text, const UChar *textLimit)
- : UTF16NFDIterator(NULL, NULL) {
+ FCDUTF16NFDIterator(const Normalizer2Impl &nfcImpl, const char16_t *text, const char16_t *textLimit)
+ : UTF16NFDIterator(nullptr, nullptr) {
UErrorCode errorCode = U_ZERO_ERROR;
- const UChar *spanLimit = nfcImpl.makeFCD(text, textLimit, NULL, errorCode);
+ const char16_t *spanLimit = nfcImpl.makeFCD(text, textLimit, nullptr, errorCode);
if(U_FAILURE(errorCode)) { return; }
- if(spanLimit == textLimit || (textLimit == NULL && *spanLimit == 0)) {
+ if(spanLimit == textLimit || (textLimit == nullptr && *spanLimit == 0)) {
s = text;
limit = spanLimit;
} else {
@@ -897,7 +898,7 @@ protected:
class FCDUTF8NFDIterator : public NFDIterator {
public:
FCDUTF8NFDIterator(const CollationData *data, const uint8_t *text, int32_t textLength)
- : u8ci(data, FALSE, text, 0, textLength) {}
+ : u8ci(data, false, text, 0, textLength) {}
protected:
virtual UChar32 nextRawCodePoint() override {
UErrorCode errorCode = U_ZERO_ERROR;
@@ -921,7 +922,7 @@ private:
class FCDUIterNFDIterator : public NFDIterator {
public:
FCDUIterNFDIterator(const CollationData *data, UCharIterator &it, int32_t startIndex)
- : uici(data, FALSE, it, startIndex) {}
+ : uici(data, false, it, startIndex) {}
protected:
virtual UChar32 nextRawCodePoint() override {
UErrorCode errorCode = U_ZERO_ERROR;
@@ -965,8 +966,8 @@ UCollationResult compareNFDIter(const Normalizer2Impl &nfcImpl,
} // namespace
UCollationResult
-RuleBasedCollator::doCompare(const UChar *left, int32_t leftLength,
- const UChar *right, int32_t rightLength,
+RuleBasedCollator::doCompare(const char16_t *left, int32_t leftLength,
+ const char16_t *right, int32_t rightLength,
UErrorCode &errorCode) const {
// U_FAILURE(errorCode) checked by caller.
if(left == right && leftLength == rightLength) {
@@ -974,13 +975,13 @@ RuleBasedCollator::doCompare(const UChar *left, int32_t leftLength,
}
// Identical-prefix test.
- const UChar *leftLimit;
- const UChar *rightLimit;
+ const char16_t *leftLimit;
+ const char16_t *rightLimit;
int32_t equalPrefixLength = 0;
if(leftLength < 0) {
- leftLimit = NULL;
- rightLimit = NULL;
- UChar c;
+ leftLimit = nullptr;
+ rightLimit = nullptr;
+ char16_t c;
while((c = left[equalPrefixLength]) == right[equalPrefixLength]) {
if(c == 0) { return UCOL_EQUAL; }
++equalPrefixLength;
@@ -1121,7 +1122,7 @@ RuleBasedCollator::doCompare(const uint8_t *left, int32_t leftLength,
UBool numeric = settings->isNumeric();
if(equalPrefixLength > 0) {
- UBool unsafe = FALSE;
+ UBool unsafe = false;
if(equalPrefixLength != leftLength) {
int32_t i = equalPrefixLength;
UChar32 c;
@@ -1282,12 +1283,12 @@ RuleBasedCollator::getCollationKey(const UnicodeString &s, CollationKey &key,
}
CollationKey &
-RuleBasedCollator::getCollationKey(const UChar *s, int32_t length, CollationKey& key,
+RuleBasedCollator::getCollationKey(const char16_t *s, int32_t length, CollationKey& key,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) {
return key.setToBogus();
}
- if(s == NULL && length != 0) {
+ if(s == nullptr && length != 0) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return key.setToBogus();
}
@@ -1311,13 +1312,13 @@ RuleBasedCollator::getSortKey(const UnicodeString &s,
}
int32_t
-RuleBasedCollator::getSortKey(const UChar *s, int32_t length,
+RuleBasedCollator::getSortKey(const char16_t *s, int32_t length,
uint8_t *dest, int32_t capacity) const {
- if((s == NULL && length != 0) || capacity < 0 || (dest == NULL && capacity > 0)) {
+ if((s == nullptr && length != 0) || capacity < 0 || (dest == nullptr && capacity > 0)) {
return 0;
}
uint8_t noDest[1] = { 0 };
- if(dest == NULL) {
+ if(dest == nullptr) {
// Distinguish pure preflighting from an allocation error.
dest = noDest;
capacity = 0;
@@ -1329,22 +1330,22 @@ RuleBasedCollator::getSortKey(const UChar *s, int32_t length,
}
void
-RuleBasedCollator::writeSortKey(const UChar *s, int32_t length,
+RuleBasedCollator::writeSortKey(const char16_t *s, int32_t length,
SortKeyByteSink &sink, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return; }
- const UChar *limit = (length >= 0) ? s + length : NULL;
+ const char16_t *limit = (length >= 0) ? s + length : nullptr;
UBool numeric = settings->isNumeric();
CollationKeys::LevelCallback callback;
if(settings->dontCheckFCD()) {
UTF16CollationIterator iter(data, numeric, s, s, limit);
CollationKeys::writeSortKeyUpToQuaternary(iter, data->compressibleBytes, *settings,
sink, Collation::PRIMARY_LEVEL,
- callback, TRUE, errorCode);
+ callback, true, errorCode);
} else {
FCDUTF16CollationIterator iter(data, numeric, s, s, limit);
CollationKeys::writeSortKeyUpToQuaternary(iter, data->compressibleBytes, *settings,
sink, Collation::PRIMARY_LEVEL,
- callback, TRUE, errorCode);
+ callback, true, errorCode);
}
if(settings->getStrength() == UCOL_IDENTICAL) {
writeIdenticalLevel(s, limit, sink, errorCode);
@@ -1354,10 +1355,10 @@ RuleBasedCollator::writeSortKey(const UChar *s, int32_t length,
}
void
-RuleBasedCollator::writeIdenticalLevel(const UChar *s, const UChar *limit,
+RuleBasedCollator::writeIdenticalLevel(const char16_t *s, const char16_t *limit,
SortKeyByteSink &sink, UErrorCode &errorCode) const {
// NFD quick check
- const UChar *nfdQCYesLimit = data->nfcImpl.decompose(s, limit, NULL, errorCode);
+ const char16_t *nfdQCYesLimit = data->nfcImpl.decompose(s, limit, nullptr, errorCode);
if(U_FAILURE(errorCode)) { return; }
sink.Append(Collation::LEVEL_SEPARATOR_BYTE);
UChar32 prev = 0;
@@ -1366,7 +1367,7 @@ RuleBasedCollator::writeIdenticalLevel(const UChar *s, const UChar *limit,
}
// Is there non-NFD text?
int32_t destLengthEstimate;
- if(limit != NULL) {
+ if(limit != nullptr) {
if(nfdQCYesLimit == limit) { return; }
destLengthEstimate = (int32_t)(limit - nfdQCYesLimit);
} else {
@@ -1403,9 +1404,9 @@ public:
// Remember a level that will be at least partially written.
level = l;
levelCapacity = sink.GetRemainingCapacity();
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
Collation::Level getLevel() const { return level; }
@@ -1423,7 +1424,7 @@ int32_t
RuleBasedCollator::internalNextSortKeyPart(UCharIterator *iter, uint32_t state[2],
uint8_t *dest, int32_t count, UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return 0; }
- if(iter == NULL || state == NULL || count < 0 || (count > 0 && dest == NULL)) {
+ if(iter == nullptr || state == nullptr || count < 0 || (count > 0 && dest == nullptr)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -1440,11 +1441,11 @@ RuleBasedCollator::internalNextSortKeyPart(UCharIterator *iter, uint32_t state[2
if(settings->dontCheckFCD()) {
UIterCollationIterator ci(data, numeric, *iter);
CollationKeys::writeSortKeyUpToQuaternary(ci, data->compressibleBytes, *settings,
- sink, level, callback, FALSE, errorCode);
+ sink, level, callback, false, errorCode);
} else {
FCDUIterCollationIterator ci(data, numeric, *iter, 0);
CollationKeys::writeSortKeyUpToQuaternary(ci, data->compressibleBytes, *settings,
- sink, level, callback, FALSE, errorCode);
+ sink, level, callback, false, errorCode);
}
if(U_FAILURE(errorCode)) { return 0; }
if(sink.NumberOfBytesAppended() > count) {
@@ -1466,9 +1467,9 @@ RuleBasedCollator::internalNextSortKeyPart(UCharIterator *iter, uint32_t state[2
for(;;) {
UChar32 c = iter->next(iter);
if(c < 0) { break; }
- s.append((UChar)c);
+ s.append((char16_t)c);
}
- const UChar *sArray = s.getBuffer();
+ const char16_t *sArray = s.getBuffer();
writeIdenticalLevel(sArray, sArray + s.length(), sink, errorCode);
if(U_FAILURE(errorCode)) { return 0; }
if(sink.NumberOfBytesAppended() > count) {
@@ -1491,8 +1492,8 @@ void
RuleBasedCollator::internalGetCEs(const UnicodeString &str, UVector64 &ces,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return; }
- const UChar *s = str.getBuffer();
- const UChar *limit = s + str.length();
+ const char16_t *s = str.getBuffer();
+ const char16_t *limit = s + str.length();
UBool numeric = settings->isNumeric();
if(settings->dontCheckFCD()) {
UTF16CollationIterator iter(data, numeric, s, s, limit);
@@ -1541,18 +1542,18 @@ RuleBasedCollator::internalGetShortDefinitionString(const char *locale,
char *buffer, int32_t capacity,
UErrorCode &errorCode) const {
if(U_FAILURE(errorCode)) { return 0; }
- if(buffer == NULL ? capacity != 0 : capacity < 0) {
+ if(buffer == nullptr ? capacity != 0 : capacity < 0) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
- if(locale == NULL) {
+ if(locale == nullptr) {
locale = internalGetLocaleID(ULOC_VALID_LOCALE, errorCode);
}
char resultLocale[ULOC_FULLNAME_CAPACITY + 1];
int32_t length = ucol_getFunctionalEquivalent(resultLocale, ULOC_FULLNAME_CAPACITY,
"collation", locale,
- NULL, &errorCode);
+ nullptr, &errorCode);
if(U_FAILURE(errorCode)) { return 0; }
resultLocale[length] = 0;
@@ -1622,11 +1623,11 @@ RuleBasedCollator::initMaxExpansions(UErrorCode &errorCode) const {
CollationElementIterator *
RuleBasedCollator::createCollationElementIterator(const UnicodeString& source) const {
UErrorCode errorCode = U_ZERO_ERROR;
- if(!initMaxExpansions(errorCode)) { return NULL; }
+ if(!initMaxExpansions(errorCode)) { return nullptr; }
CollationElementIterator *cei = new CollationElementIterator(source, this, errorCode);
if(U_FAILURE(errorCode)) {
delete cei;
- return NULL;
+ return nullptr;
}
return cei;
}
@@ -1634,11 +1635,11 @@ RuleBasedCollator::createCollationElementIterator(const UnicodeString& source) c
CollationElementIterator *
RuleBasedCollator::createCollationElementIterator(const CharacterIterator& source) const {
UErrorCode errorCode = U_ZERO_ERROR;
- if(!initMaxExpansions(errorCode)) { return NULL; }
+ if(!initMaxExpansions(errorCode)) { return nullptr; }
CollationElementIterator *cei = new CollationElementIterator(source, this, errorCode);
if(U_FAILURE(errorCode)) {
delete cei;
- return NULL;
+ return nullptr;
}
return cei;
}
diff --git a/contrib/libs/icu/i18n/scientificnumberformatter.cpp b/contrib/libs/icu/i18n/scientificnumberformatter.cpp
index 6c2cb3aeed..8f9c19c384 100644
--- a/contrib/libs/icu/i18n/scientificnumberformatter.cpp
+++ b/contrib/libs/icu/i18n/scientificnumberformatter.cpp
@@ -20,7 +20,7 @@
U_NAMESPACE_BEGIN
-static const UChar kSuperscriptDigits[] = {
+static const char16_t kSuperscriptDigits[] = {
0x2070,
0xB9,
0xB2,
@@ -32,8 +32,8 @@ static const UChar kSuperscriptDigits[] = {
0x2078,
0x2079};
-static const UChar kSuperscriptPlusSign = 0x207A;
-static const UChar kSuperscriptMinusSign = 0x207B;
+static const char16_t kSuperscriptPlusSign = 0x207A;
+static const char16_t kSuperscriptMinusSign = 0x207B;
static UBool copyAsSuperscript(
const UnicodeString &s,
@@ -42,19 +42,19 @@ static UBool copyAsSuperscript(
UnicodeString &result,
UErrorCode &status) {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
for (int32_t i = beginIndex; i < endIndex;) {
UChar32 c = s.char32At(i);
int32_t digit = u_charDigitValue(c);
if (digit < 0) {
status = U_INVALID_CHAR_FOUND;
- return FALSE;
+ return false;
}
result.append(kSuperscriptDigits[digit]);
i += U16_LENGTH(c);
}
- return TRUE;
+ return true;
}
ScientificNumberFormatter *ScientificNumberFormatter::createSuperscriptInstance(
@@ -101,22 +101,22 @@ ScientificNumberFormatter *ScientificNumberFormatter::createInstance(
LocalPointer<DecimalFormat> fmt(fmtToAdopt);
LocalPointer<Style> style(styleToAdopt);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
ScientificNumberFormatter *result =
new ScientificNumberFormatter(
fmt.getAlias(),
style.getAlias(),
status);
- if (result == NULL) {
+ if (result == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
fmt.orphan();
style.orphan();
if (U_FAILURE(status)) {
delete result;
- return NULL;
+ return nullptr;
}
return result;
}
@@ -246,12 +246,12 @@ ScientificNumberFormatter::ScientificNumberFormatter(
if (U_FAILURE(status)) {
return;
}
- if (fDecimalFormat == NULL || fStyle == NULL) {
+ if (fDecimalFormat == nullptr || fStyle == nullptr) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
const DecimalFormatSymbols *sym = fDecimalFormat->getDecimalFormatSymbols();
- if (sym == NULL) {
+ if (sym == nullptr) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@@ -262,8 +262,8 @@ ScientificNumberFormatter::ScientificNumberFormatter(
const ScientificNumberFormatter &other)
: UObject(other),
fPreExponent(other.fPreExponent),
- fDecimalFormat(NULL),
- fStyle(NULL) {
+ fDecimalFormat(nullptr),
+ fStyle(nullptr) {
fDecimalFormat = static_cast<DecimalFormat *>(
other.fDecimalFormat->clone());
fStyle = other.fStyle->clone();
diff --git a/contrib/libs/icu/i18n/scriptset.cpp b/contrib/libs/icu/i18n/scriptset.cpp
index 6a1db8c01c..736a85cf8c 100644
--- a/contrib/libs/icu/i18n/scriptset.cpp
+++ b/contrib/libs/icu/i18n/scriptset.cpp
@@ -55,11 +55,11 @@ bool ScriptSet::operator == (const ScriptSet &other) const {
UBool ScriptSet::test(UScriptCode script, UErrorCode &status) const {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (script < 0 || (int32_t)script >= SCRIPT_LIMIT) {
status = U_ILLEGAL_ARGUMENT_ERROR;
- return FALSE;
+ return false;
}
uint32_t index = script / 32;
uint32_t bit = 1 << (script & 31);
@@ -188,19 +188,19 @@ int32_t ScriptSet::nextSetBit(int32_t fromIndex) const {
UBool ScriptSet::isEmpty() const {
for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
if (bits[i] != 0) {
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
UnicodeString &ScriptSet::displayScripts(UnicodeString &dest) const {
- UBool firstTime = TRUE;
+ UBool firstTime = true;
for (int32_t i = nextSetBit(0); i >= 0; i = nextSetBit(i + 1)) {
if (!firstTime) {
- dest.append((UChar)0x20);
+ dest.append((char16_t)0x20);
}
- firstTime = FALSE;
+ firstTime = false;
const char *scriptName = uscript_getShortName((UScriptCode(i)));
dest.append(UnicodeString(scriptName, -1, US_INV));
}
@@ -248,12 +248,12 @@ void ScriptSet::setScriptExtensions(UChar32 codePoint, UErrorCode& status) {
UErrorCode internalStatus = U_ZERO_ERROR;
int32_t script_count = -1;
- while (TRUE) {
+ while (true) {
script_count = uscript_getScriptExtensions(
codePoint, scripts.getAlias(), scripts.getCapacity(), &internalStatus);
if (internalStatus == U_BUFFER_OVERFLOW_ERROR) {
// Need to allocate more space
- if (scripts.resize(script_count) == NULL) {
+ if (scripts.resize(script_count) == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
diff --git a/contrib/libs/icu/i18n/scriptset.h b/contrib/libs/icu/i18n/scriptset.h
index 51980ab7b3..df5cfdc748 100644
--- a/contrib/libs/icu/i18n/scriptset.h
+++ b/contrib/libs/icu/i18n/scriptset.h
@@ -83,4 +83,7 @@ uhash_hashScriptSet(const UElement key);
U_CAPI void U_EXPORT2
uhash_deleteScriptSet(void *obj);
-#endif // __SCRIPTSET_H__
+U_CAPI UBool U_EXPORT2
+uhash_equalsScriptSet(const UElement key1, const UElement key2);
+
+#endif // __SCRIPTSET_H_
diff --git a/contrib/libs/icu/i18n/search.cpp b/contrib/libs/icu/i18n/search.cpp
index 9e559bcc71..ec5028ca81 100644
--- a/contrib/libs/icu/i18n/search.cpp
+++ b/contrib/libs/icu/i18n/search.cpp
@@ -40,7 +40,7 @@ SearchIterator::SearchIterator(const SearchIterator &other)
SearchIterator::~SearchIterator()
{
- if (m_search_ != NULL) {
+ if (m_search_ != nullptr) {
uprv_free(m_search_);
}
}
@@ -55,10 +55,10 @@ void SearchIterator::setAttribute(USearchAttribute attribute,
switch (attribute)
{
case USEARCH_OVERLAP :
- m_search_->isOverlap = (value == USEARCH_ON ? TRUE : FALSE);
+ m_search_->isOverlap = (value == USEARCH_ON ? true : false);
break;
case USEARCH_CANONICAL_MATCH :
- m_search_->isCanonicalMatch = (value == USEARCH_ON ? TRUE : FALSE);
+ m_search_->isCanonicalMatch = (value == USEARCH_ON ? true : false);
break;
case USEARCH_ELEMENT_COMPARISON :
if (value == USEARCH_PATTERN_BASE_WEIGHT_IS_WILDCARD || value == USEARCH_ANY_BASE_WEIGHT_IS_WILDCARD) {
@@ -81,10 +81,9 @@ USearchAttributeValue SearchIterator::getAttribute(
{
switch (attribute) {
case USEARCH_OVERLAP :
- return (m_search_->isOverlap == TRUE ? USEARCH_ON : USEARCH_OFF);
+ return (m_search_->isOverlap ? USEARCH_ON : USEARCH_OFF);
case USEARCH_CANONICAL_MATCH :
- return (m_search_->isCanonicalMatch == TRUE ? USEARCH_ON :
- USEARCH_OFF);
+ return (m_search_->isCanonicalMatch ? USEARCH_ON : USEARCH_OFF);
case USEARCH_ELEMENT_COMPARISON :
{
int16_t value = m_search_->elementComparisonType;
@@ -126,7 +125,7 @@ void SearchIterator::setBreakIterator(BreakIterator *breakiter,
{
if (U_SUCCESS(status)) {
#if 0
- m_search_->breakIter = NULL;
+ m_search_->breakIter = nullptr;
// the c++ breakiterator may not make use of ubreakiterator.
// so we'll have to keep track of it ourselves.
#else
@@ -144,7 +143,7 @@ void SearchIterator::setBreakIterator(BreakIterator *breakiter,
}
}
-const BreakIterator * SearchIterator::getBreakIterator(void) const
+const BreakIterator * SearchIterator::getBreakIterator() const
{
return m_breakiterator_;
}
@@ -171,7 +170,7 @@ void SearchIterator::setText(CharacterIterator &text, UErrorCode &status)
}
}
-const UnicodeString & SearchIterator::getText(void) const
+const UnicodeString & SearchIterator::getText() const
{
return m_text_;
}
@@ -191,8 +190,9 @@ bool SearchIterator::operator==(const SearchIterator &that) const
m_search_->matchedLength == that.m_search_->matchedLength &&
m_search_->textLength == that.m_search_->textLength &&
getOffset() == that.getOffset() &&
+ (m_search_->textLength == 0 ||
(uprv_memcmp(m_search_->text, that.m_search_->text,
- m_search_->textLength * sizeof(UChar)) == 0));
+ m_search_->textLength * sizeof(char16_t)) == 0)));
}
// public methods ----------------------------------------------------
@@ -241,8 +241,8 @@ int32_t SearchIterator::next(UErrorCode &status)
int32_t offset = getOffset();
int32_t matchindex = m_search_->matchedIndex;
int32_t matchlength = m_search_->matchedLength;
- m_search_->reset = FALSE;
- if (m_search_->isForwardSearching == TRUE) {
+ m_search_->reset = false;
+ if (m_search_->isForwardSearching) {
int32_t textlength = m_search_->textLength;
if (offset == textlength || matchindex == textlength ||
(matchindex != USEARCH_DONE &&
@@ -258,7 +258,7 @@ int32_t SearchIterator::next(UErrorCode &status)
// setOffset has been called or that previous ran off the text
// string. the iterator would have been set to offset 0 if a
// match is not found.
- m_search_->isForwardSearching = TRUE;
+ m_search_->isForwardSearching = true;
if (m_search_->matchedIndex != USEARCH_DONE) {
// there's no need to set the collation element iterator
// the next call to next will set the offset.
@@ -286,8 +286,8 @@ int32_t SearchIterator::previous(UErrorCode &status)
int32_t offset;
if (m_search_->reset) {
offset = m_search_->textLength;
- m_search_->isForwardSearching = FALSE;
- m_search_->reset = FALSE;
+ m_search_->isForwardSearching = false;
+ m_search_->reset = false;
setOffset(offset, status);
}
else {
@@ -295,13 +295,13 @@ int32_t SearchIterator::previous(UErrorCode &status)
}
int32_t matchindex = m_search_->matchedIndex;
- if (m_search_->isForwardSearching == TRUE) {
+ if (m_search_->isForwardSearching) {
// switching direction.
// if matchedIndex == USEARCH_DONE, it means that either a
// setOffset has been called or that next ran off the text
// string. the iterator would have been set to offset textLength if
// a match is not found.
- m_search_->isForwardSearching = FALSE;
+ m_search_->isForwardSearching = false;
if (matchindex != USEARCH_DONE) {
return matchindex;
}
@@ -333,11 +333,11 @@ void SearchIterator::reset()
UErrorCode status = U_ZERO_ERROR;
setMatchNotFound();
setOffset(0, status);
- m_search_->isOverlap = FALSE;
- m_search_->isCanonicalMatch = FALSE;
+ m_search_->isOverlap = false;
+ m_search_->isCanonicalMatch = false;
m_search_->elementComparisonType = 0;
- m_search_->isForwardSearching = TRUE;
- m_search_->reset = TRUE;
+ m_search_->isForwardSearching = true;
+ m_search_->reset = true;
}
// protected constructors and destructors -----------------------------
@@ -345,17 +345,17 @@ void SearchIterator::reset()
SearchIterator::SearchIterator()
{
m_search_ = (USearch *)uprv_malloc(sizeof(USearch));
- m_search_->breakIter = NULL;
- m_search_->isOverlap = FALSE;
- m_search_->isCanonicalMatch = FALSE;
+ m_search_->breakIter = nullptr;
+ m_search_->isOverlap = false;
+ m_search_->isCanonicalMatch = false;
m_search_->elementComparisonType = 0;
- m_search_->isForwardSearching = TRUE;
- m_search_->reset = TRUE;
+ m_search_->isForwardSearching = true;
+ m_search_->reset = true;
m_search_->matchedIndex = USEARCH_DONE;
m_search_->matchedLength = 0;
- m_search_->text = NULL;
+ m_search_->text = nullptr;
m_search_->textLength = 0;
- m_breakiterator_ = NULL;
+ m_breakiterator_ = nullptr;
}
SearchIterator::SearchIterator(const UnicodeString &text,
@@ -364,12 +364,12 @@ SearchIterator::SearchIterator(const UnicodeString &text,
m_text_(text)
{
m_search_ = (USearch *)uprv_malloc(sizeof(USearch));
- m_search_->breakIter = NULL;
- m_search_->isOverlap = FALSE;
- m_search_->isCanonicalMatch = FALSE;
+ m_search_->breakIter = nullptr;
+ m_search_->isOverlap = false;
+ m_search_->isCanonicalMatch = false;
m_search_->elementComparisonType = 0;
- m_search_->isForwardSearching = TRUE;
- m_search_->reset = TRUE;
+ m_search_->isForwardSearching = true;
+ m_search_->reset = true;
m_search_->matchedIndex = USEARCH_DONE;
m_search_->matchedLength = 0;
m_search_->text = m_text_.getBuffer();
@@ -381,12 +381,12 @@ SearchIterator::SearchIterator(CharacterIterator &text,
m_breakiterator_(breakiter)
{
m_search_ = (USearch *)uprv_malloc(sizeof(USearch));
- m_search_->breakIter = NULL;
- m_search_->isOverlap = FALSE;
- m_search_->isCanonicalMatch = FALSE;
+ m_search_->breakIter = nullptr;
+ m_search_->isOverlap = false;
+ m_search_->isCanonicalMatch = false;
m_search_->elementComparisonType = 0;
- m_search_->isForwardSearching = TRUE;
- m_search_->reset = TRUE;
+ m_search_->isForwardSearching = true;
+ m_search_->reset = true;
m_search_->matchedIndex = USEARCH_DONE;
m_search_->matchedLength = 0;
text.getText(m_text_);
diff --git a/contrib/libs/icu/i18n/selfmt.cpp b/contrib/libs/icu/i18n/selfmt.cpp
index bb18e84ef6..abe39bcb63 100644
--- a/contrib/libs/icu/i18n/selfmt.cpp
+++ b/contrib/libs/icu/i18n/selfmt.cpp
@@ -41,7 +41,7 @@ U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SelectFormat)
-static const UChar SELECT_KEYWORD_OTHER[] = {LOW_O, LOW_T, LOW_H, LOW_E, LOW_R, 0};
+static const char16_t SELECT_KEYWORD_OTHER[] = {LOW_O, LOW_T, LOW_H, LOW_E, LOW_R, 0};
SelectFormat::SelectFormat(const UnicodeString& pat,
UErrorCode& status) : msgPattern(status) {
@@ -61,7 +61,7 @@ SelectFormat::applyPattern(const UnicodeString& newPattern, UErrorCode& status)
return;
}
- msgPattern.parseSelectStyle(newPattern, NULL, status);
+ msgPattern.parseSelectStyle(newPattern, nullptr, status);
if (U_FAILURE(status)) {
msgPattern.clear();
}
@@ -129,7 +129,7 @@ int32_t SelectFormat::findSubMessage(const MessagePattern& pattern, int32_t part
if (U_FAILURE(ec)) {
return 0;
}
- UnicodeString other(FALSE, SELECT_KEYWORD_OTHER, 5);
+ UnicodeString other(false, SELECT_KEYWORD_OTHER, 5);
int32_t count = pattern.countParts();
int32_t msgStart=0;
// Iterate over (ARG_SELECTOR, message) pairs until ARG_LIMIT or end of select-only pattern.
@@ -172,7 +172,7 @@ SelectFormat::operator==(const Format& other) const {
if (!Format::operator==(other)) {
return false;
}
- const SelectFormat& o = (const SelectFormat&)other;
+ const SelectFormat& o = static_cast<const SelectFormat&>(other);
return msgPattern == o.msgPattern;
}
diff --git a/contrib/libs/icu/i18n/selfmtimpl.h b/contrib/libs/icu/i18n/selfmtimpl.h
index a36d1a5c34..6cf875efde 100644
--- a/contrib/libs/icu/i18n/selfmtimpl.h
+++ b/contrib/libs/icu/i18n/selfmtimpl.h
@@ -27,62 +27,62 @@
U_NAMESPACE_BEGIN
-#define DOT ((UChar)0x002E)
-#define SINGLE_QUOTE ((UChar)0x0027)
-#define SLASH ((UChar)0x002F)
-#define BACKSLASH ((UChar)0x005C)
-#define SPACE ((UChar)0x0020)
-#define TAB ((UChar)0x0009)
-#define QUOTATION_MARK ((UChar)0x0022)
-#define ASTERISK ((UChar)0x002A)
-#define COMMA ((UChar)0x002C)
-#define HYPHEN ((UChar)0x002D)
-#define U_ZERO ((UChar)0x0030)
-#define U_ONE ((UChar)0x0031)
-#define U_TWO ((UChar)0x0032)
-#define U_THREE ((UChar)0x0033)
-#define U_FOUR ((UChar)0x0034)
-#define U_FIVE ((UChar)0x0035)
-#define U_SIX ((UChar)0x0036)
-#define U_SEVEN ((UChar)0x0037)
-#define U_EIGHT ((UChar)0x0038)
-#define U_NINE ((UChar)0x0039)
-#define COLON ((UChar)0x003A)
-#define SEMI_COLON ((UChar)0x003B)
-#define CAP_A ((UChar)0x0041)
-#define CAP_B ((UChar)0x0042)
-#define CAP_R ((UChar)0x0052)
-#define CAP_Z ((UChar)0x005A)
-#define LOWLINE ((UChar)0x005F)
-#define LEFTBRACE ((UChar)0x007B)
-#define RIGHTBRACE ((UChar)0x007D)
+#define DOT ((char16_t)0x002E)
+#define SINGLE_QUOTE ((char16_t)0x0027)
+#define SLASH ((char16_t)0x002F)
+#define BACKSLASH ((char16_t)0x005C)
+#define SPACE ((char16_t)0x0020)
+#define TAB ((char16_t)0x0009)
+#define QUOTATION_MARK ((char16_t)0x0022)
+#define ASTERISK ((char16_t)0x002A)
+#define COMMA ((char16_t)0x002C)
+#define HYPHEN ((char16_t)0x002D)
+#define U_ZERO ((char16_t)0x0030)
+#define U_ONE ((char16_t)0x0031)
+#define U_TWO ((char16_t)0x0032)
+#define U_THREE ((char16_t)0x0033)
+#define U_FOUR ((char16_t)0x0034)
+#define U_FIVE ((char16_t)0x0035)
+#define U_SIX ((char16_t)0x0036)
+#define U_SEVEN ((char16_t)0x0037)
+#define U_EIGHT ((char16_t)0x0038)
+#define U_NINE ((char16_t)0x0039)
+#define COLON ((char16_t)0x003A)
+#define SEMI_COLON ((char16_t)0x003B)
+#define CAP_A ((char16_t)0x0041)
+#define CAP_B ((char16_t)0x0042)
+#define CAP_R ((char16_t)0x0052)
+#define CAP_Z ((char16_t)0x005A)
+#define LOWLINE ((char16_t)0x005F)
+#define LEFTBRACE ((char16_t)0x007B)
+#define RIGHTBRACE ((char16_t)0x007D)
-#define LOW_A ((UChar)0x0061)
-#define LOW_B ((UChar)0x0062)
-#define LOW_C ((UChar)0x0063)
-#define LOW_D ((UChar)0x0064)
-#define LOW_E ((UChar)0x0065)
-#define LOW_F ((UChar)0x0066)
-#define LOW_G ((UChar)0x0067)
-#define LOW_H ((UChar)0x0068)
-#define LOW_I ((UChar)0x0069)
-#define LOW_J ((UChar)0x006a)
-#define LOW_K ((UChar)0x006B)
-#define LOW_L ((UChar)0x006C)
-#define LOW_M ((UChar)0x006D)
-#define LOW_N ((UChar)0x006E)
-#define LOW_O ((UChar)0x006F)
-#define LOW_P ((UChar)0x0070)
-#define LOW_Q ((UChar)0x0071)
-#define LOW_R ((UChar)0x0072)
-#define LOW_S ((UChar)0x0073)
-#define LOW_T ((UChar)0x0074)
-#define LOW_U ((UChar)0x0075)
-#define LOW_V ((UChar)0x0076)
-#define LOW_W ((UChar)0x0077)
-#define LOW_X ((UChar)0x0078)
-#define LOW_Y ((UChar)0x0079)
-#define LOW_Z ((UChar)0x007A)
+#define LOW_A ((char16_t)0x0061)
+#define LOW_B ((char16_t)0x0062)
+#define LOW_C ((char16_t)0x0063)
+#define LOW_D ((char16_t)0x0064)
+#define LOW_E ((char16_t)0x0065)
+#define LOW_F ((char16_t)0x0066)
+#define LOW_G ((char16_t)0x0067)
+#define LOW_H ((char16_t)0x0068)
+#define LOW_I ((char16_t)0x0069)
+#define LOW_J ((char16_t)0x006a)
+#define LOW_K ((char16_t)0x006B)
+#define LOW_L ((char16_t)0x006C)
+#define LOW_M ((char16_t)0x006D)
+#define LOW_N ((char16_t)0x006E)
+#define LOW_O ((char16_t)0x006F)
+#define LOW_P ((char16_t)0x0070)
+#define LOW_Q ((char16_t)0x0071)
+#define LOW_R ((char16_t)0x0072)
+#define LOW_S ((char16_t)0x0073)
+#define LOW_T ((char16_t)0x0074)
+#define LOW_U ((char16_t)0x0075)
+#define LOW_V ((char16_t)0x0076)
+#define LOW_W ((char16_t)0x0077)
+#define LOW_X ((char16_t)0x0078)
+#define LOW_Y ((char16_t)0x0079)
+#define LOW_Z ((char16_t)0x007A)
class UnicodeSet;
diff --git a/contrib/libs/icu/i18n/sharedbreakiterator.h b/contrib/libs/icu/i18n/sharedbreakiterator.h
index b6d67bc8e8..76e959fda3 100644
--- a/contrib/libs/icu/i18n/sharedbreakiterator.h
+++ b/contrib/libs/icu/i18n/sharedbreakiterator.h
@@ -38,8 +38,8 @@ public:
BreakIterator &operator*() const { return *ptr; }
private:
BreakIterator *ptr;
- SharedBreakIterator(const SharedBreakIterator &);
- SharedBreakIterator &operator=(const SharedBreakIterator &);
+ SharedBreakIterator(const SharedBreakIterator &) = delete;
+ SharedBreakIterator &operator=(const SharedBreakIterator &) = delete;
};
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/sharedcalendar.h b/contrib/libs/icu/i18n/sharedcalendar.h
index 1526f92e88..60d1d5d487 100644
--- a/contrib/libs/icu/i18n/sharedcalendar.h
+++ b/contrib/libs/icu/i18n/sharedcalendar.h
@@ -13,6 +13,7 @@
#include "unicode/utypes.h"
#include "sharedobject.h"
+#include "unifiedcache.h"
U_NAMESPACE_BEGIN
@@ -27,10 +28,15 @@ public:
const Calendar &operator*() const { return *ptr; }
private:
Calendar *ptr;
- SharedCalendar(const SharedCalendar &);
- SharedCalendar &operator=(const SharedCalendar &);
+ SharedCalendar(const SharedCalendar &) = delete;
+ SharedCalendar &operator=(const SharedCalendar &) = delete;
};
+template<> U_I18N_API
+const SharedCalendar *LocaleCacheKey<SharedCalendar>::createObject(
+ const void * /*unusedCreationContext*/, UErrorCode &status) const;
+
+
U_NAMESPACE_END
#endif
diff --git a/contrib/libs/icu/i18n/shareddateformatsymbols.h b/contrib/libs/icu/i18n/shareddateformatsymbols.h
index 66a06ecae5..b51fad98b0 100644
--- a/contrib/libs/icu/i18n/shareddateformatsymbols.h
+++ b/contrib/libs/icu/i18n/shareddateformatsymbols.h
@@ -17,6 +17,7 @@
#include "sharedobject.h"
#include "unicode/dtfmtsym.h"
+#include "unifiedcache.h"
U_NAMESPACE_BEGIN
@@ -30,10 +31,15 @@ public:
const DateFormatSymbols &get() const { return dfs; }
private:
DateFormatSymbols dfs;
- SharedDateFormatSymbols(const SharedDateFormatSymbols &);
- SharedDateFormatSymbols &operator=(const SharedDateFormatSymbols &);
+ SharedDateFormatSymbols(const SharedDateFormatSymbols &) = delete;
+ SharedDateFormatSymbols &operator=(const SharedDateFormatSymbols &) = delete;
};
+template<> U_I18N_API
+const SharedDateFormatSymbols *
+ LocaleCacheKey<SharedDateFormatSymbols>::createObject(
+ const void * /*unusedContext*/, UErrorCode &status) const;
+
U_NAMESPACE_END
#endif /* !UCONFIG_NO_FORMATTING */
diff --git a/contrib/libs/icu/i18n/sharednumberformat.h b/contrib/libs/icu/i18n/sharednumberformat.h
index a7e105b5ac..bd914c0340 100644
--- a/contrib/libs/icu/i18n/sharednumberformat.h
+++ b/contrib/libs/icu/i18n/sharednumberformat.h
@@ -13,6 +13,7 @@
#include "unicode/utypes.h"
#include "sharedobject.h"
+#include "unifiedcache.h"
U_NAMESPACE_BEGIN
@@ -27,10 +28,14 @@ public:
const NumberFormat &operator*() const { return *ptr; }
private:
NumberFormat *ptr;
- SharedNumberFormat(const SharedNumberFormat &);
- SharedNumberFormat &operator=(const SharedNumberFormat &);
+ SharedNumberFormat(const SharedNumberFormat &) = delete;
+ SharedNumberFormat &operator=(const SharedNumberFormat &) = delete;
};
+template<> U_I18N_API
+const SharedNumberFormat *LocaleCacheKey<SharedNumberFormat>::createObject(
+ const void * /*unused*/, UErrorCode &status) const;
+
U_NAMESPACE_END
#endif
diff --git a/contrib/libs/icu/i18n/sharedpluralrules.h b/contrib/libs/icu/i18n/sharedpluralrules.h
index 28d8b25c14..11c82c5619 100644
--- a/contrib/libs/icu/i18n/sharedpluralrules.h
+++ b/contrib/libs/icu/i18n/sharedpluralrules.h
@@ -13,6 +13,7 @@
#include "unicode/utypes.h"
#include "sharedobject.h"
+#include "unifiedcache.h"
U_NAMESPACE_BEGIN
@@ -26,10 +27,14 @@ public:
const PluralRules &operator*() const { return *ptr; }
private:
PluralRules *ptr;
- SharedPluralRules(const SharedPluralRules &);
- SharedPluralRules &operator=(const SharedPluralRules &);
+ SharedPluralRules(const SharedPluralRules &) = delete;
+ SharedPluralRules &operator=(const SharedPluralRules &) =delete;
};
+template<> U_I18N_API
+const SharedPluralRules *LocaleCacheKey<SharedPluralRules>::createObject(
+ const void * /*unused*/, UErrorCode &status) const;
+
U_NAMESPACE_END
#endif
diff --git a/contrib/libs/icu/i18n/simpletz.cpp b/contrib/libs/icu/i18n/simpletz.cpp
index d9b0cd8e1e..8b21152f52 100644
--- a/contrib/libs/icu/i18n/simpletz.cpp
+++ b/contrib/libs/icu/i18n/simpletz.cpp
@@ -53,8 +53,8 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SimpleTimeZone)
// Gregorian calendar started.
const int8_t SimpleTimeZone::STATICMONTHLENGTH[] = {31,29,31,30,31,30,31,31,30,31,30,31};
-static const UChar DST_STR[] = {0x0028,0x0044,0x0053,0x0054,0x0029,0}; // "(DST)"
-static const UChar STD_STR[] = {0x0028,0x0053,0x0054,0x0044,0x0029,0}; // "(STD)"
+static const char16_t DST_STR[] = {0x0028,0x0044,0x0053,0x0054,0x0029,0}; // "(DST)"
+static const char16_t STD_STR[] = {0x0028,0x0053,0x0054,0x0044,0x0029,0}; // "(STD)"
// *****************************************************************************
@@ -76,7 +76,7 @@ SimpleTimeZone::SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID)
endTime(0),
startYear(0),
rawOffset(rawOffsetGMT),
- useDaylight(FALSE),
+ useDaylight(false),
startMode(DOM_MODE),
endMode(DOM_MODE),
dstSavings(U_MILLIS_PER_HOUR)
@@ -262,7 +262,7 @@ void
SimpleTimeZone::setStartYear(int32_t year)
{
startYear = year;
- transitionRulesInitialized = FALSE;
+ transitionRulesInitialized = false;
}
// -------------------------------------
@@ -316,7 +316,7 @@ SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t da
startTime = time;
startTimeMode = mode;
decodeStartRule(status);
- transitionRulesInitialized = FALSE;
+ transitionRulesInitialized = false;
}
// -------------------------------------
@@ -368,7 +368,7 @@ SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayO
endTime = time;
endTimeMode = mode;
decodeEndRule(status);
- transitionRulesInitialized = FALSE;
+ transitionRulesInitialized = false;
}
// -------------------------------------
@@ -518,9 +518,8 @@ SimpleTimeZone::getOffsetFromLocal(UDate date, UTimeZoneLocalOption nonExistingT
}
rawOffsetGMT = getRawOffset();
- int32_t year, month, dom, dow;
- double day = uprv_floor(date / U_MILLIS_PER_DAY);
- int32_t millis = (int32_t) (date - day * U_MILLIS_PER_DAY);
+ int32_t year, month, dom, dow, millis;
+ int32_t day = ClockMath::floorDivide(date, U_MILLIS_PER_DAY, &millis);
Grego::dayToFields(day, year, month, dom, dow);
@@ -532,25 +531,24 @@ SimpleTimeZone::getOffsetFromLocal(UDate date, UTimeZoneLocalOption nonExistingT
return;
}
- UBool recalc = FALSE;
+ UBool recalc = false;
// Now we need some adjustment
if (savingsDST > 0) {
if ((nonExistingTimeOpt & kStdDstMask) == kStandard
|| ((nonExistingTimeOpt & kStdDstMask) != kDaylight && (nonExistingTimeOpt & kFormerLatterMask) != kLatter)) {
date -= getDSTSavings();
- recalc = TRUE;
+ recalc = true;
}
} else {
if ((duplicatedTimeOpt & kStdDstMask) == kDaylight
|| ((duplicatedTimeOpt & kStdDstMask) != kStandard && (duplicatedTimeOpt & kFormerLatterMask) == kFormer)) {
date -= getDSTSavings();
- recalc = TRUE;
+ recalc = true;
}
}
if (recalc) {
- day = uprv_floor(date / U_MILLIS_PER_DAY);
- millis = (int32_t) (date - day * U_MILLIS_PER_DAY);
+ day = ClockMath::floorDivide(date, U_MILLIS_PER_DAY, &millis);
Grego::dayToFields(day, year, month, dom, dow);
savingsDST = getOffset(GregorianCalendar::AD, year, month, dom,
(uint8_t) dow, millis,
@@ -681,7 +679,7 @@ void
SimpleTimeZone::setRawOffset(int32_t offsetMillis)
{
rawOffset = offsetMillis;
- transitionRulesInitialized = FALSE;
+ transitionRulesInitialized = false;
}
// -------------------------------------
@@ -695,7 +693,7 @@ SimpleTimeZone::setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status)
else {
dstSavings = millisSavedDuringDST;
}
- transitionRulesInitialized = FALSE;
+ transitionRulesInitialized = false;
}
// -------------------------------------
@@ -725,12 +723,12 @@ UBool SimpleTimeZone::inDaylightTime(UDate date, UErrorCode& status) const
// This method is wasteful since it creates a new GregorianCalendar and
// deletes it each time it is called. However, this is a deprecated method
// and provided only for Java compatibility as of 8/6/97 [LIU].
- if (U_FAILURE(status)) return FALSE;
+ if (U_FAILURE(status)) return false;
GregorianCalendar *gc = new GregorianCalendar(*this, status);
- /* test for NULL */
+ /* test for nullptr */
if (gc == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
- return FALSE;
+ return false;
}
gc->setTime(date, status);
UBool result = gc->inDaylightTime(status);
@@ -748,8 +746,8 @@ UBool SimpleTimeZone::inDaylightTime(UDate date, UErrorCode& status) const
UBool
SimpleTimeZone::hasSameRules(const TimeZone& other) const
{
- if (this == &other) return TRUE;
- if (typeid(*this) != typeid(other)) return FALSE;
+ if (this == &other) return true;
+ if (typeid(*this) != typeid(other)) return false;
SimpleTimeZone *that = (SimpleTimeZone*)&other;
return rawOffset == that->rawOffset &&
useDaylight == that->useDaylight &&
@@ -872,7 +870,7 @@ SimpleTimeZone::decodeStartRule(UErrorCode& status)
{
if(U_FAILURE(status)) return;
- useDaylight = (UBool)((startDay != 0) && (endDay != 0) ? TRUE : FALSE);
+ useDaylight = (UBool)((startDay != 0) && (endDay != 0) ? true : false);
if (useDaylight && dstSavings == 0) {
dstSavings = U_MILLIS_PER_HOUR;
}
@@ -927,7 +925,7 @@ SimpleTimeZone::decodeEndRule(UErrorCode& status)
{
if(U_FAILURE(status)) return;
- useDaylight = (UBool)((startDay != 0) && (endDay != 0) ? TRUE : FALSE);
+ useDaylight = (UBool)((startDay != 0) && (endDay != 0) ? true : false);
if (useDaylight && dstSavings == 0) {
dstSavings = U_MILLIS_PER_HOUR;
}
@@ -975,13 +973,13 @@ SimpleTimeZone::decodeEndRule(UErrorCode& status)
UBool
SimpleTimeZone::getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const {
if (!useDaylight) {
- return FALSE;
+ return false;
}
UErrorCode status = U_ZERO_ERROR;
checkTransitionRules(status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
UDate firstTransitionTime = firstTransition->getTime();
@@ -993,74 +991,74 @@ SimpleTimeZone::getNextTransition(UDate base, UBool inclusive, TimeZoneTransitio
UBool dstAvail = dstRule->getNextStart(base, stdRule->getRawOffset(), stdRule->getDSTSavings(), inclusive, dstDate);
if (stdAvail && (!dstAvail || stdDate < dstDate)) {
result.setTime(stdDate);
- result.setFrom((const TimeZoneRule&)*dstRule);
- result.setTo((const TimeZoneRule&)*stdRule);
- return TRUE;
+ result.setFrom(*dstRule);
+ result.setTo(*stdRule);
+ return true;
}
if (dstAvail && (!stdAvail || dstDate < stdDate)) {
result.setTime(dstDate);
- result.setFrom((const TimeZoneRule&)*stdRule);
- result.setTo((const TimeZoneRule&)*dstRule);
- return TRUE;
+ result.setFrom(*stdRule);
+ result.setTo(*dstRule);
+ return true;
}
- return FALSE;
+ return false;
}
UBool
SimpleTimeZone::getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const {
if (!useDaylight) {
- return FALSE;
+ return false;
}
UErrorCode status = U_ZERO_ERROR;
checkTransitionRules(status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
UDate firstTransitionTime = firstTransition->getTime();
if (base < firstTransitionTime || (!inclusive && base == firstTransitionTime)) {
- return FALSE;
+ return false;
}
UDate stdDate, dstDate;
UBool stdAvail = stdRule->getPreviousStart(base, dstRule->getRawOffset(), dstRule->getDSTSavings(), inclusive, stdDate);
UBool dstAvail = dstRule->getPreviousStart(base, stdRule->getRawOffset(), stdRule->getDSTSavings(), inclusive, dstDate);
if (stdAvail && (!dstAvail || stdDate > dstDate)) {
result.setTime(stdDate);
- result.setFrom((const TimeZoneRule&)*dstRule);
- result.setTo((const TimeZoneRule&)*stdRule);
- return TRUE;
+ result.setFrom(*dstRule);
+ result.setTo(*stdRule);
+ return true;
}
if (dstAvail && (!stdAvail || dstDate > stdDate)) {
result.setTime(dstDate);
- result.setFrom((const TimeZoneRule&)*stdRule);
- result.setTo((const TimeZoneRule&)*dstRule);
- return TRUE;
+ result.setFrom(*stdRule);
+ result.setTo(*dstRule);
+ return true;
}
- return FALSE;
+ return false;
}
void
-SimpleTimeZone::clearTransitionRules(void) {
- initialRule = NULL;
- firstTransition = NULL;
- stdRule = NULL;
- dstRule = NULL;
- transitionRulesInitialized = FALSE;
+SimpleTimeZone::clearTransitionRules() {
+ initialRule = nullptr;
+ firstTransition = nullptr;
+ stdRule = nullptr;
+ dstRule = nullptr;
+ transitionRulesInitialized = false;
}
void
-SimpleTimeZone::deleteTransitionRules(void) {
- if (initialRule != NULL) {
+SimpleTimeZone::deleteTransitionRules() {
+ if (initialRule != nullptr) {
delete initialRule;
}
- if (firstTransition != NULL) {
+ if (firstTransition != nullptr) {
delete firstTransition;
}
- if (stdRule != NULL) {
+ if (stdRule != nullptr) {
delete stdRule;
}
- if (dstRule != NULL) {
+ if (dstRule != nullptr) {
delete dstRule;
}
clearTransitionRules();
@@ -1133,7 +1131,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
return;
}
// Check for Null pointer
- if (dtRule == NULL) {
+ if (dtRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -1142,7 +1140,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
dtRule, startYear, AnnualTimeZoneRule::MAX_YEAR);
// Check for Null pointer
- if (dstRule == NULL) {
+ if (dstRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -1170,7 +1168,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
}
// Check for Null pointer
- if (dtRule == NULL) {
+ if (dtRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -1180,7 +1178,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
dtRule, startYear, AnnualTimeZoneRule::MAX_YEAR);
//Check for Null pointer
- if (stdRule == NULL) {
+ if (stdRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -1192,7 +1190,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
// Create a TimeZoneRule for initial time
if (firstStdStart < firstDstStart) {
initialRule = new InitialTimeZoneRule(tzid+UnicodeString(DST_STR), getRawOffset(), dstRule->getDSTSavings());
- if (initialRule == NULL) {
+ if (initialRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -1200,14 +1198,14 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
firstTransition = new TimeZoneTransition(firstStdStart, *initialRule, *stdRule);
} else {
initialRule = new InitialTimeZoneRule(tzid+UnicodeString(STD_STR), getRawOffset(), 0);
- if (initialRule == NULL) {
+ if (initialRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
}
firstTransition = new TimeZoneTransition(firstDstStart, *initialRule, *dstRule);
}
- if (firstTransition == NULL) {
+ if (firstTransition == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -1217,14 +1215,14 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
// Create a TimeZoneRule for initial time
initialRule = new InitialTimeZoneRule(tzid, getRawOffset(), 0);
// Check for null pointer.
- if (initialRule == NULL) {
+ if (initialRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
}
}
- transitionRulesInitialized = TRUE;
+ transitionRulesInitialized = true;
}
int32_t
@@ -1246,7 +1244,7 @@ SimpleTimeZone::getTimeZoneRules(const InitialTimeZoneRule*& initial,
}
initial = initialRule;
int32_t cnt = 0;
- if (stdRule != NULL) {
+ if (stdRule != nullptr) {
if (cnt < trscount) {
trsrules[cnt++] = stdRule;
}
diff --git a/contrib/libs/icu/i18n/smpdtfmt.cpp b/contrib/libs/icu/i18n/smpdtfmt.cpp
index 91748d82f9..a87fb8d5e1 100644
--- a/contrib/libs/icu/i18n/smpdtfmt.cpp
+++ b/contrib/libs/icu/i18n/smpdtfmt.cpp
@@ -45,6 +45,7 @@
#include "unicode/ustring.h"
#include "unicode/basictz.h"
#include "unicode/simpleformatter.h"
+#include "unicode/simplenumberformatter.h"
#include "unicode/simpletz.h"
#include "unicode/rbtz.h"
#include "unicode/tzfmt.h"
@@ -94,16 +95,16 @@ U_NAMESPACE_BEGIN
// GMT-minutes. For instance, in France the time zone is GMT+60.
// Also accepted are GMT+H:MM or GMT-H:MM.
// Currently not being used
-//static const UChar gGmt[] = {0x0047, 0x004D, 0x0054, 0x0000}; // "GMT"
-//static const UChar gGmtPlus[] = {0x0047, 0x004D, 0x0054, 0x002B, 0x0000}; // "GMT+"
-//static const UChar gGmtMinus[] = {0x0047, 0x004D, 0x0054, 0x002D, 0x0000}; // "GMT-"
-//static const UChar gDefGmtPat[] = {0x0047, 0x004D, 0x0054, 0x007B, 0x0030, 0x007D, 0x0000}; /* GMT{0} */
-//static const UChar gDefGmtNegHmsPat[] = {0x002D, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0x0000}; /* -HH:mm:ss */
-//static const UChar gDefGmtNegHmPat[] = {0x002D, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x0000}; /* -HH:mm */
-//static const UChar gDefGmtPosHmsPat[] = {0x002B, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0x0000}; /* +HH:mm:ss */
-//static const UChar gDefGmtPosHmPat[] = {0x002B, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x0000}; /* +HH:mm */
-//static const UChar gUt[] = {0x0055, 0x0054, 0x0000}; // "UT"
-//static const UChar gUtc[] = {0x0055, 0x0054, 0x0043, 0x0000}; // "UT"
+//static const char16_t gGmt[] = {0x0047, 0x004D, 0x0054, 0x0000}; // "GMT"
+//static const char16_t gGmtPlus[] = {0x0047, 0x004D, 0x0054, 0x002B, 0x0000}; // "GMT+"
+//static const char16_t gGmtMinus[] = {0x0047, 0x004D, 0x0054, 0x002D, 0x0000}; // "GMT-"
+//static const char16_t gDefGmtPat[] = {0x0047, 0x004D, 0x0054, 0x007B, 0x0030, 0x007D, 0x0000}; /* GMT{0} */
+//static const char16_t gDefGmtNegHmsPat[] = {0x002D, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0x0000}; /* -HH:mm:ss */
+//static const char16_t gDefGmtNegHmPat[] = {0x002D, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x0000}; /* -HH:mm */
+//static const char16_t gDefGmtPosHmsPat[] = {0x002B, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0x0000}; /* +HH:mm:ss */
+//static const char16_t gDefGmtPosHmPat[] = {0x002B, 0x0048, 0x0048, 0x003A, 0x006D, 0x006D, 0x0000}; /* +HH:mm */
+//static const char16_t gUt[] = {0x0055, 0x0054, 0x0000}; // "UT"
+//static const char16_t gUtc[] = {0x0055, 0x0054, 0x0043, 0x0000}; // "UT"
typedef enum GmtPatSize {
kGmtLen = 3,
@@ -159,21 +160,21 @@ static const int8_t kTimeFieldsCount = 10;
// This is a pattern-of-last-resort used when we can't load a usable pattern out
// of a resource.
-static const UChar gDefaultPattern[] =
+static const char16_t gDefaultPattern[] =
{
- 0x79, 0x79, 0x79, 0x79, 0x4D, 0x4D, 0x64, 0x64, 0x20, 0x68, 0x68, 0x3A, 0x6D, 0x6D, 0x20, 0x61, 0
-}; /* "yyyyMMdd hh:mm a" */
+ 0x79, 0x4D, 0x4D, 0x64, 0x64, 0x20, 0x68, 0x68, 0x3A, 0x6D, 0x6D, 0x20, 0x61, 0
+}; /* "yMMdd hh:mm a" */
// This prefix is designed to NEVER MATCH real text, in order to
// suppress the parsing of negative numbers. Adjust as needed (if
// this becomes valid Unicode).
-static const UChar SUPPRESS_NEGATIVE_PREFIX[] = {0xAB00, 0};
+static const char16_t SUPPRESS_NEGATIVE_PREFIX[] = {0xAB00, 0};
/**
* These are the tags we expect to see in normal resource bundle files associated
* with a locale.
*/
-static const UChar QUOTE = 0x27; // Single quote
+static const char16_t QUOTE = 0x27; // Single quote
/*
* The field range check bias for each UDateFormatField.
@@ -244,7 +245,7 @@ static UMutex LOCK;
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SimpleDateFormat)
SimpleDateFormat::NSOverride::~NSOverride() {
- if (snf != NULL) {
+ if (snf != nullptr) {
snf->removeRef();
}
}
@@ -263,12 +264,12 @@ void SimpleDateFormat::NSOverride::free() {
// to modify it so that it doesn't use thousands separators, doesn't always
// show the decimal point, and recognizes integers only when parsing
static void fixNumberFormatForDates(NumberFormat &nf) {
- nf.setGroupingUsed(FALSE);
+ nf.setGroupingUsed(false);
DecimalFormat* decfmt = dynamic_cast<DecimalFormat*>(&nf);
- if (decfmt != NULL) {
- decfmt->setDecimalSeparatorAlwaysShown(FALSE);
+ if (decfmt != nullptr) {
+ decfmt->setDecimalSeparatorAlwaysShown(false);
}
- nf.setParseIntegerOnly(TRUE);
+ nf.setParseIntegerOnly(true);
nf.setMinimumFractionDigits(0); // To prevent "Jan 1.00, 1997.00"
}
@@ -276,7 +277,7 @@ static const SharedNumberFormat *createSharedNumberFormat(
NumberFormat *nfToAdopt) {
fixNumberFormatForDates(*nfToAdopt);
const SharedNumberFormat *result = new SharedNumberFormat(nfToAdopt);
- if (result == NULL) {
+ if (result == nullptr) {
delete nfToAdopt;
}
return result;
@@ -286,10 +287,10 @@ static const SharedNumberFormat *createSharedNumberFormat(
const Locale &loc, UErrorCode &status) {
NumberFormat *nf = NumberFormat::createInstance(loc, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
const SharedNumberFormat *result = createSharedNumberFormat(nf);
- if (result == NULL) {
+ if (result == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
return result;
@@ -298,11 +299,11 @@ static const SharedNumberFormat *createSharedNumberFormat(
static const SharedNumberFormat **allocSharedNumberFormatters() {
const SharedNumberFormat **result = (const SharedNumberFormat**)
uprv_malloc(UDAT_FIELD_COUNT * sizeof(const SharedNumberFormat*));
- if (result == NULL) {
- return NULL;
+ if (result == nullptr) {
+ return nullptr;
}
for (int32_t i = 0; i < UDAT_FIELD_COUNT; ++i) {
- result[i] = NULL;
+ result[i] = nullptr;
}
return result;
}
@@ -316,8 +317,8 @@ static void freeSharedNumberFormatters(const SharedNumberFormat ** list) {
const NumberFormat *SimpleDateFormat::getNumberFormatByIndex(
UDateFormatField index) const {
- if (fSharedNumberFormatters == NULL ||
- fSharedNumberFormatters[index] == NULL) {
+ if (fSharedNumberFormatters == nullptr ||
+ fSharedNumberFormatters[index] == nullptr) {
return fNumberFormat;
}
return &(**fSharedNumberFormatters[index]);
@@ -334,7 +335,7 @@ SimpleDateFormat::~SimpleDateFormat()
if (fTimeZoneFormat) {
delete fTimeZoneFormat;
}
- freeFastNumberFormatters();
+ delete fSimpleNumberFormatter;
#if !UCONFIG_NO_BREAK_ITERATION
delete fCapitalizationBrkIter;
@@ -344,11 +345,7 @@ SimpleDateFormat::~SimpleDateFormat()
//----------------------------------------------------------------------
SimpleDateFormat::SimpleDateFormat(UErrorCode& status)
- : fLocale(Locale::getDefault()),
- fSymbols(NULL),
- fTimeZoneFormat(NULL),
- fSharedNumberFormatters(NULL),
- fCapitalizationBrkIter(NULL)
+ : fLocale(Locale::getDefault())
{
initializeBooleanAttributes();
construct(kShort, (EStyle) (kShort + kDateOffset), fLocale, status);
@@ -360,16 +357,12 @@ SimpleDateFormat::SimpleDateFormat(UErrorCode& status)
SimpleDateFormat::SimpleDateFormat(const UnicodeString& pattern,
UErrorCode &status)
: fPattern(pattern),
- fLocale(Locale::getDefault()),
- fSymbols(NULL),
- fTimeZoneFormat(NULL),
- fSharedNumberFormatters(NULL),
- fCapitalizationBrkIter(NULL)
+ fLocale(Locale::getDefault())
{
fDateOverride.setToBogus();
fTimeOverride.setToBogus();
initializeBooleanAttributes();
- initializeCalendar(NULL,fLocale,status);
+ initializeCalendar(nullptr,fLocale,status);
fSymbols = DateFormatSymbols::createForLocale(fLocale, status);
initialize(fLocale, status);
initializeDefaultCentury();
@@ -381,16 +374,12 @@ SimpleDateFormat::SimpleDateFormat(const UnicodeString& pattern,
const UnicodeString& override,
UErrorCode &status)
: fPattern(pattern),
- fLocale(Locale::getDefault()),
- fSymbols(NULL),
- fTimeZoneFormat(NULL),
- fSharedNumberFormatters(NULL),
- fCapitalizationBrkIter(NULL)
+ fLocale(Locale::getDefault())
{
fDateOverride.setTo(override);
fTimeOverride.setToBogus();
initializeBooleanAttributes();
- initializeCalendar(NULL,fLocale,status);
+ initializeCalendar(nullptr,fLocale,status);
fSymbols = DateFormatSymbols::createForLocale(fLocale, status);
initialize(fLocale, status);
initializeDefaultCentury();
@@ -405,17 +394,14 @@ SimpleDateFormat::SimpleDateFormat(const UnicodeString& pattern,
const Locale& locale,
UErrorCode& status)
: fPattern(pattern),
- fLocale(locale),
- fTimeZoneFormat(NULL),
- fSharedNumberFormatters(NULL),
- fCapitalizationBrkIter(NULL)
+ fLocale(locale)
{
fDateOverride.setToBogus();
fTimeOverride.setToBogus();
initializeBooleanAttributes();
- initializeCalendar(NULL,fLocale,status);
+ initializeCalendar(nullptr,fLocale,status);
fSymbols = DateFormatSymbols::createForLocale(fLocale, status);
initialize(fLocale, status);
initializeDefaultCentury();
@@ -428,17 +414,14 @@ SimpleDateFormat::SimpleDateFormat(const UnicodeString& pattern,
const Locale& locale,
UErrorCode& status)
: fPattern(pattern),
- fLocale(locale),
- fTimeZoneFormat(NULL),
- fSharedNumberFormatters(NULL),
- fCapitalizationBrkIter(NULL)
+ fLocale(locale)
{
fDateOverride.setTo(override);
fTimeOverride.setToBogus();
initializeBooleanAttributes();
- initializeCalendar(NULL,fLocale,status);
+ initializeCalendar(nullptr,fLocale,status);
fSymbols = DateFormatSymbols::createForLocale(fLocale, status);
initialize(fLocale, status);
initializeDefaultCentury();
@@ -454,17 +437,14 @@ SimpleDateFormat::SimpleDateFormat(const UnicodeString& pattern,
UErrorCode& status)
: fPattern(pattern),
fLocale(Locale::getDefault()),
- fSymbols(symbolsToAdopt),
- fTimeZoneFormat(NULL),
- fSharedNumberFormatters(NULL),
- fCapitalizationBrkIter(NULL)
+ fSymbols(symbolsToAdopt)
{
fDateOverride.setToBogus();
fTimeOverride.setToBogus();
initializeBooleanAttributes();
- initializeCalendar(NULL,fLocale,status);
+ initializeCalendar(nullptr,fLocale,status);
initialize(fLocale, status);
initializeDefaultCentury();
}
@@ -476,17 +456,14 @@ SimpleDateFormat::SimpleDateFormat(const UnicodeString& pattern,
UErrorCode& status)
: fPattern(pattern),
fLocale(Locale::getDefault()),
- fSymbols(new DateFormatSymbols(symbols)),
- fTimeZoneFormat(NULL),
- fSharedNumberFormatters(NULL),
- fCapitalizationBrkIter(NULL)
+ fSymbols(new DateFormatSymbols(symbols))
{
fDateOverride.setToBogus();
fTimeOverride.setToBogus();
initializeBooleanAttributes();
- initializeCalendar(NULL, fLocale, status);
+ initializeCalendar(nullptr, fLocale, status);
initialize(fLocale, status);
initializeDefaultCentury();
}
@@ -498,11 +475,7 @@ SimpleDateFormat::SimpleDateFormat(EStyle timeStyle,
EStyle dateStyle,
const Locale& locale,
UErrorCode& status)
-: fLocale(locale),
- fSymbols(NULL),
- fTimeZoneFormat(NULL),
- fSharedNumberFormatters(NULL),
- fCapitalizationBrkIter(NULL)
+: fLocale(locale)
{
initializeBooleanAttributes();
construct(timeStyle, dateStyle, fLocale, status);
@@ -521,15 +494,11 @@ SimpleDateFormat::SimpleDateFormat(EStyle timeStyle,
SimpleDateFormat::SimpleDateFormat(const Locale& locale,
UErrorCode& status)
: fPattern(gDefaultPattern),
- fLocale(locale),
- fSymbols(NULL),
- fTimeZoneFormat(NULL),
- fSharedNumberFormatters(NULL),
- fCapitalizationBrkIter(NULL)
+ fLocale(locale)
{
if (U_FAILURE(status)) return;
initializeBooleanAttributes();
- initializeCalendar(NULL, fLocale, status);
+ initializeCalendar(nullptr, fLocale, status);
fSymbols = DateFormatSymbols::createForLocale(fLocale, status);
if (U_FAILURE(status))
{
@@ -537,7 +506,7 @@ SimpleDateFormat::SimpleDateFormat(const Locale& locale,
delete fSymbols;
// This constructor doesn't fail; it uses last resort data
fSymbols = new DateFormatSymbols(status);
- /* test for NULL */
+ /* test for nullptr */
if (fSymbols == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
@@ -557,11 +526,7 @@ SimpleDateFormat::SimpleDateFormat(const Locale& locale,
SimpleDateFormat::SimpleDateFormat(const SimpleDateFormat& other)
: DateFormat(other),
- fLocale(other.fLocale),
- fSymbols(NULL),
- fTimeZoneFormat(NULL),
- fSharedNumberFormatters(NULL),
- fCapitalizationBrkIter(NULL)
+ fLocale(other.fLocale)
{
initializeBooleanAttributes();
*this = other;
@@ -574,12 +539,18 @@ SimpleDateFormat& SimpleDateFormat::operator=(const SimpleDateFormat& other)
if (this == &other) {
return *this;
}
+
+ // fSimpleNumberFormatter references fNumberFormatter, delete it
+ // before we call the = operator which may invalidate fNumberFormatter
+ delete fSimpleNumberFormatter;
+ fSimpleNumberFormatter = nullptr;
+
DateFormat::operator=(other);
fDateOverride = other.fDateOverride;
fTimeOverride = other.fTimeOverride;
delete fSymbols;
- fSymbols = NULL;
+ fSymbols = nullptr;
if (other.fSymbols)
fSymbols = new DateFormatSymbols(*other.fSymbols);
@@ -595,7 +566,7 @@ SimpleDateFormat& SimpleDateFormat::operator=(const SimpleDateFormat& other)
fLocale = other.fLocale;
// TimeZoneFormat can now be set independently via setter.
- // If it is NULL, it will be lazily initialized from locale.
+ // If it is nullptr, it will be lazily initialized from locale.
delete fTimeZoneFormat;
fTimeZoneFormat = nullptr;
TimeZoneFormat *otherTZFormat;
@@ -621,16 +592,16 @@ SimpleDateFormat& SimpleDateFormat::operator=(const SimpleDateFormat& other)
}
#if !UCONFIG_NO_BREAK_ITERATION
- if (other.fCapitalizationBrkIter != NULL) {
+ if (other.fCapitalizationBrkIter != nullptr) {
fCapitalizationBrkIter = (other.fCapitalizationBrkIter)->clone();
}
#endif
- if (fSharedNumberFormatters != NULL) {
+ if (fSharedNumberFormatters != nullptr) {
freeSharedNumberFormatters(fSharedNumberFormatters);
- fSharedNumberFormatters = NULL;
+ fSharedNumberFormatters = nullptr;
}
- if (other.fSharedNumberFormatters != NULL) {
+ if (other.fSharedNumberFormatters != nullptr) {
fSharedNumberFormatters = allocSharedNumberFormatters();
if (fSharedNumberFormatters) {
for (int32_t i = 0; i < UDAT_FIELD_COUNT; ++i) {
@@ -642,9 +613,10 @@ SimpleDateFormat& SimpleDateFormat::operator=(const SimpleDateFormat& other)
}
UErrorCode localStatus = U_ZERO_ERROR;
- freeFastNumberFormatters();
- initFastNumberFormatters(localStatus);
-
+ // SimpleNumberFormatter does not have a copy constructor. Furthermore,
+ // it references data from an internal field, fNumberFormatter,
+ // so we must rematerialize that reference after copying over the number formatter.
+ initSimpleNumberFormatter(localStatus);
return *this;
}
@@ -667,8 +639,8 @@ SimpleDateFormat::operator==(const Format& other) const
// DateFormat::operator== guarantees following cast is safe
SimpleDateFormat* that = (SimpleDateFormat*)&other;
return (fPattern == that->fPattern &&
- fSymbols != NULL && // Check for pathological object
- that->fSymbols != NULL && // Check for pathological object
+ fSymbols != nullptr && // Check for pathological object
+ that->fSymbols != nullptr && // Check for pathological object
*fSymbols == *that->fSymbols &&
fHaveDefaultCentury == that->fHaveDefaultCentury &&
fDefaultCenturyStart == that->fDefaultCenturyStart);
@@ -677,7 +649,7 @@ SimpleDateFormat::operator==(const Format& other) const
}
//----------------------------------------------------------------------
-static const UChar* timeSkeletons[4] = {
+static const char16_t* timeSkeletons[4] = {
u"jmmsszzzz", // kFull
u"jmmssz", // kLong
u"jmmss", // kMedium
@@ -693,23 +665,23 @@ void SimpleDateFormat::construct(EStyle timeStyle,
if (U_FAILURE(status)) return;
// We will need the calendar to know what type of symbols to load.
- initializeCalendar(NULL, locale, status);
+ initializeCalendar(nullptr, locale, status);
if (U_FAILURE(status)) return;
// Load date time patterns directly from resources.
- const char* cType = fCalendar ? fCalendar->getType() : NULL;
- LocalUResourceBundlePointer bundle(ures_open(NULL, locale.getBaseName(), &status));
+ const char* cType = fCalendar ? fCalendar->getType() : nullptr;
+ LocalUResourceBundlePointer bundle(ures_open(nullptr, locale.getBaseName(), &status));
if (U_FAILURE(status)) return;
- UBool cTypeIsGregorian = TRUE;
+ UBool cTypeIsGregorian = true;
LocalUResourceBundlePointer dateTimePatterns;
- if (cType != NULL && uprv_strcmp(cType, "gregorian") != 0) {
+ if (cType != nullptr && uprv_strcmp(cType, "gregorian") != 0) {
CharString resourcePath("calendar/", status);
resourcePath.append(cType, status).append("/DateTimePatterns", status);
dateTimePatterns.adoptInstead(
ures_getByKeyWithFallback(bundle.getAlias(), resourcePath.data(),
- (UResourceBundle*)NULL, &status));
- cTypeIsGregorian = FALSE;
+ (UResourceBundle*)nullptr, &status));
+ cTypeIsGregorian = false;
}
// Check for "gregorian" fallback.
@@ -718,7 +690,7 @@ void SimpleDateFormat::construct(EStyle timeStyle,
dateTimePatterns.adoptInstead(
ures_getByKeyWithFallback(bundle.getAlias(),
"calendar/gregorian/DateTimePatterns",
- (UResourceBundle*)NULL, &status));
+ (UResourceBundle*)nullptr, &status));
}
if (U_FAILURE(status)) return;
@@ -736,13 +708,13 @@ void SimpleDateFormat::construct(EStyle timeStyle,
// create a symbols object from the locale
fSymbols = DateFormatSymbols::createForLocale(locale, status);
if (U_FAILURE(status)) return;
- /* test for NULL */
+ /* test for nullptr */
if (fSymbols == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
- const UChar *resStr,*ovrStr;
+ const char16_t *resStr,*ovrStr;
int32_t resStrLen,ovrStrLen = 0;
fDateOverride.setToBogus();
fTimeOverride.setToBogus();
@@ -776,7 +748,7 @@ void SimpleDateFormat::construct(EStyle timeStyle,
// region preferences anyway.
LocalPointer<DateTimePatternGenerator> dtpg(DateTimePatternGenerator::createInstanceNoStdPat(locale, useStatus));
if (U_SUCCESS(useStatus)) {
- UnicodeString timeSkeleton(TRUE, timeSkeletons[timeStyle], -1);
+ UnicodeString timeSkeleton(true, timeSkeletons[timeStyle], -1);
timePattern = dtpg->getBestPattern(timeSkeleton, useStatus);
}
}
@@ -792,7 +764,7 @@ void SimpleDateFormat::construct(EStyle timeStyle,
UnicodeString tempus1(timePattern);
if (tempus1.length() == 0) {
currentBundle.adoptInstead(
- ures_getByIndex(dateTimePatterns.getAlias(), (int32_t)timeStyle, NULL, &status));
+ ures_getByIndex(dateTimePatterns.getAlias(), (int32_t)timeStyle, nullptr, &status));
if (U_FAILURE(status)) {
status = U_INVALID_FORMAT_ERROR;
return;
@@ -805,7 +777,7 @@ void SimpleDateFormat::construct(EStyle timeStyle,
case URES_ARRAY: {
resStr = ures_getStringByIndex(currentBundle.getAlias(), 0, &resStrLen, &status);
ovrStr = ures_getStringByIndex(currentBundle.getAlias(), 1, &ovrStrLen, &status);
- fTimeOverride.setTo(TRUE, ovrStr, ovrStrLen);
+ fTimeOverride.setTo(true, ovrStr, ovrStrLen);
break;
}
default: {
@@ -814,11 +786,11 @@ void SimpleDateFormat::construct(EStyle timeStyle,
}
}
- tempus1.setTo(TRUE, resStr, resStrLen);
+ tempus1.setTo(true, resStr, resStrLen);
}
currentBundle.adoptInstead(
- ures_getByIndex(dateTimePatterns.getAlias(), (int32_t)dateStyle, NULL, &status));
+ ures_getByIndex(dateTimePatterns.getAlias(), (int32_t)dateStyle, nullptr, &status));
if (U_FAILURE(status)) {
status = U_INVALID_FORMAT_ERROR;
return;
@@ -831,7 +803,7 @@ void SimpleDateFormat::construct(EStyle timeStyle,
case URES_ARRAY: {
resStr = ures_getStringByIndex(currentBundle.getAlias(), 0, &resStrLen, &status);
ovrStr = ures_getStringByIndex(currentBundle.getAlias(), 1, &ovrStrLen, &status);
- fDateOverride.setTo(TRUE, ovrStr, ovrStrLen);
+ fDateOverride.setTo(true, ovrStr, ovrStrLen);
break;
}
default: {
@@ -840,17 +812,40 @@ void SimpleDateFormat::construct(EStyle timeStyle,
}
}
- UnicodeString tempus2(TRUE, resStr, resStrLen);
+ UnicodeString tempus2(true, resStr, resStrLen);
- int32_t glueIndex = kDateTime;
- int32_t patternsSize = ures_getSize(dateTimePatterns.getAlias());
- if (patternsSize >= (kDateTimeOffset + kShort + 1)) {
- // Get proper date time format
- glueIndex = (int32_t)(kDateTimeOffset + (dateStyle - kDateOffset));
+ // Currently, for compatibility with pre-CLDR-42 data, we default to the "atTime"
+ // combining patterns. Depending on guidance in CLDR 42 spec and on DisplayOptions,
+ // we may change this.
+ LocalUResourceBundlePointer dateAtTimePatterns;
+ if (!cTypeIsGregorian) {
+ CharString resourcePath("calendar/", status);
+ resourcePath.append(cType, status).append("/DateTimePatterns%atTime", status);
+ dateAtTimePatterns.adoptInstead(
+ ures_getByKeyWithFallback(bundle.getAlias(), resourcePath.data(),
+ nullptr, &status));
+ }
+ if (cTypeIsGregorian || status == U_MISSING_RESOURCE_ERROR) {
+ status = U_ZERO_ERROR;
+ dateAtTimePatterns.adoptInstead(
+ ures_getByKeyWithFallback(bundle.getAlias(),
+ "calendar/gregorian/DateTimePatterns%atTime",
+ nullptr, &status));
}
+ if (U_SUCCESS(status) && ures_getSize(dateAtTimePatterns.getAlias()) >= 4) {
+ resStr = ures_getStringByIndex(dateAtTimePatterns.getAlias(), dateStyle - kDateOffset, &resStrLen, &status);
+ } else {
+ status = U_ZERO_ERROR;
+ int32_t glueIndex = kDateTime;
+ int32_t patternsSize = ures_getSize(dateTimePatterns.getAlias());
+ if (patternsSize >= (kDateTimeOffset + kShort + 1)) {
+ // Get proper date time format
+ glueIndex = (int32_t)(kDateTimeOffset + (dateStyle - kDateOffset));
+ }
- resStr = ures_getStringByIndex(dateTimePatterns.getAlias(), glueIndex, &resStrLen, &status);
- SimpleFormatter(UnicodeString(TRUE, resStr, resStrLen), 2, 2, status).
+ resStr = ures_getStringByIndex(dateTimePatterns.getAlias(), glueIndex, &resStrLen, &status);
+ }
+ SimpleFormatter(UnicodeString(true, resStr, resStrLen), 2, 2, status).
format(tempus1, tempus2, fPattern, status);
}
// if the pattern includes just time data or just date date, load the appropriate
@@ -860,7 +855,7 @@ void SimpleDateFormat::construct(EStyle timeStyle,
fPattern.setTo(timePattern);
if (fPattern.length() == 0) {
currentBundle.adoptInstead(
- ures_getByIndex(dateTimePatterns.getAlias(), (int32_t)timeStyle, NULL, &status));
+ ures_getByIndex(dateTimePatterns.getAlias(), (int32_t)timeStyle, nullptr, &status));
if (U_FAILURE(status)) {
status = U_INVALID_FORMAT_ERROR;
return;
@@ -873,7 +868,7 @@ void SimpleDateFormat::construct(EStyle timeStyle,
case URES_ARRAY: {
resStr = ures_getStringByIndex(currentBundle.getAlias(), 0, &resStrLen, &status);
ovrStr = ures_getStringByIndex(currentBundle.getAlias(), 1, &ovrStrLen, &status);
- fDateOverride.setTo(TRUE, ovrStr, ovrStrLen);
+ fDateOverride.setTo(true, ovrStr, ovrStrLen);
break;
}
default: {
@@ -881,12 +876,12 @@ void SimpleDateFormat::construct(EStyle timeStyle,
return;
}
}
- fPattern.setTo(TRUE, resStr, resStrLen);
+ fPattern.setTo(true, resStr, resStrLen);
}
}
else if (dateStyle != kNone) {
currentBundle.adoptInstead(
- ures_getByIndex(dateTimePatterns.getAlias(), (int32_t)dateStyle, NULL, &status));
+ ures_getByIndex(dateTimePatterns.getAlias(), (int32_t)dateStyle, nullptr, &status));
if (U_FAILURE(status)) {
status = U_INVALID_FORMAT_ERROR;
return;
@@ -899,7 +894,7 @@ void SimpleDateFormat::construct(EStyle timeStyle,
case URES_ARRAY: {
resStr = ures_getStringByIndex(currentBundle.getAlias(), 0, &resStrLen, &status);
ovrStr = ures_getStringByIndex(currentBundle.getAlias(), 1, &ovrStrLen, &status);
- fDateOverride.setTo(TRUE, ovrStr, ovrStrLen);
+ fDateOverride.setTo(true, ovrStr, ovrStrLen);
break;
}
default: {
@@ -907,7 +902,7 @@ void SimpleDateFormat::construct(EStyle timeStyle,
return;
}
}
- fPattern.setTo(TRUE, resStr, resStrLen);
+ fPattern.setTo(true, resStr, resStrLen);
}
// and if it includes _neither_, that's an error
@@ -950,13 +945,13 @@ SimpleDateFormat::initialize(const Locale& locale,
// We don't need to check that the row count is >= 1, since all 2d arrays have at
// least one row
fNumberFormat = NumberFormat::createInstance(locale, status);
- if (fNumberFormat != NULL && U_SUCCESS(status))
+ if (fNumberFormat != nullptr && U_SUCCESS(status))
{
fixNumberFormatForDates(*fNumberFormat);
- //fNumberFormat->setLenient(TRUE); // Java uses a custom DateNumberFormat to format/parse
+ //fNumberFormat->setLenient(true); // Java uses a custom DateNumberFormat to format/parse
initNumberFormatters(locale, status);
- initFastNumberFormatters(status);
+ initSimpleNumberFormatter(status);
}
else if (U_SUCCESS(status))
@@ -1010,7 +1005,7 @@ void SimpleDateFormat::parseAmbiguousDatesAsAfter(UDate startDate, UErrorCode& s
fCalendar->setTime(startDate, status);
if(U_SUCCESS(status)) {
- fHaveDefaultCentury = TRUE;
+ fHaveDefaultCentury = true;
fDefaultCenturyStart = startDate;
fDefaultCenturyStartYear = fCalendar->get(UCAL_YEAR, status);
}
@@ -1046,13 +1041,13 @@ SimpleDateFormat::_format(Calendar& cal, UnicodeString& appendTo,
return appendTo;
}
Calendar* workCal = &cal;
- Calendar* calClone = NULL;
+ Calendar* calClone = nullptr;
if (&cal != fCalendar && uprv_strcmp(cal.getType(), fCalendar->getType()) != 0) {
// Different calendar type
// We use the time and time zone from the input calendar, but
// do not use the input calendar for field calculation.
calClone = fCalendar->clone();
- if (calClone != NULL) {
+ if (calClone != nullptr) {
UDate t = cal.getTime(status);
calClone->setTime(t, status);
calClone->setTimeZone(cal.getTimeZone());
@@ -1063,15 +1058,15 @@ SimpleDateFormat::_format(Calendar& cal, UnicodeString& appendTo,
}
}
- UBool inQuote = FALSE;
- UChar prevCh = 0;
+ UBool inQuote = false;
+ char16_t prevCh = 0;
int32_t count = 0;
int32_t fieldNum = 0;
UDisplayContext capitalizationContext = getContext(UDISPCTX_TYPE_CAPITALIZATION, status);
// loop through the pattern string character by character
for (int32_t i = 0; i < fPattern.length() && U_SUCCESS(status); ++i) {
- UChar ch = fPattern[i];
+ char16_t ch = fPattern[i];
// Use subFormat() to format a repeated pattern character
// when a different pattern or non-pattern character is seen
@@ -1084,7 +1079,7 @@ SimpleDateFormat::_format(Calendar& cal, UnicodeString& appendTo,
// Consecutive single quotes are a single quote literal,
// either outside of quotes or between quotes
if ((i+1) < fPattern.length() && fPattern[i+1] == QUOTE) {
- appendTo += (UChar)QUOTE;
+ appendTo += (char16_t)QUOTE;
++i;
} else {
inQuote = ! inQuote;
@@ -1108,7 +1103,7 @@ SimpleDateFormat::_format(Calendar& cal, UnicodeString& appendTo,
prevCh, handler, *workCal, status);
}
- if (calClone != NULL) {
+ if (calClone != nullptr) {
delete calClone;
}
@@ -1136,7 +1131,7 @@ SimpleDateFormat::fgCalendarFieldToLevel[] =
/*A?.*/ 40, 0, 0
};
-int32_t SimpleDateFormat::getLevelFromChar(UChar ch) {
+int32_t SimpleDateFormat::getLevelFromChar(char16_t ch) {
// Map date field LETTER into calendar field level.
// the larger the level, the smaller the field unit.
// NOTE: if new fields adds in, the table needs to update.
@@ -1166,48 +1161,48 @@ int32_t SimpleDateFormat::getLevelFromChar(UChar ch) {
return ch < UPRV_LENGTHOF(mapCharToLevel) ? mapCharToLevel[ch] : -1;
}
-UBool SimpleDateFormat::isSyntaxChar(UChar ch) {
+UBool SimpleDateFormat::isSyntaxChar(char16_t ch) {
static const UBool mapCharToIsSyntax[] = {
//
- FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
+ false, false, false, false, false, false, false, false,
//
- FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
+ false, false, false, false, false, false, false, false,
//
- FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
+ false, false, false, false, false, false, false, false,
//
- FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
+ false, false, false, false, false, false, false, false,
// ! " # $ % & '
- FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
+ false, false, false, false, false, false, false, false,
// ( ) * + , - . /
- FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
+ false, false, false, false, false, false, false, false,
// 0 1 2 3 4 5 6 7
- FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
+ false, false, false, false, false, false, false, false,
#if UDAT_HAS_PATTERN_CHAR_FOR_TIME_SEPARATOR
// 8 9 : ; < = > ?
- FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE,
+ false, false, true, false, false, false, false, false,
#else
// 8 9 : ; < = > ?
- FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
+ false, false, false, false, false, false, false, false,
#endif
// @ A B C D E F G
- FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
+ false, true, true, true, true, true, true, true,
// H I J K L M N O
- TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
+ true, true, true, true, true, true, true, true,
// P Q R S T U V W
- TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
+ true, true, true, true, true, true, true, true,
// X Y Z [ \ ] ^ _
- TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE,
+ true, true, true, false, false, false, false, false,
// ` a b c d e f g
- FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
+ false, true, true, true, true, true, true, true,
// h i j k l m n o
- TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
+ true, true, true, true, true, true, true, true,
// p q r s t u v w
- TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
+ true, true, true, true, true, true, true, true,
// x y z { | } ~
- TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE
+ true, true, true, false, false, false, false, false
};
- return ch < UPRV_LENGTHOF(mapCharToIsSyntax) ? mapCharToIsSyntax[ch] : FALSE;
+ return ch < UPRV_LENGTHOF(mapCharToIsSyntax) ? mapCharToIsSyntax[ch] : false;
}
// Map index into pattern character string to Calendar field number.
@@ -1291,7 +1286,7 @@ _appendSymbolWithMonthPattern(UnicodeString& dst, int32_t value, const UnicodeSt
const UnicodeString* monthPattern, UErrorCode& status) {
U_ASSERT(0 <= value && value < symbolsCount);
if (0 <= value && value < symbolsCount) {
- if (monthPattern == NULL) {
+ if (monthPattern == nullptr) {
dst += symbols[value];
} else {
SimpleFormatter(*monthPattern, 1, 1, status).format(symbols[value], dst, status);
@@ -1301,18 +1296,8 @@ _appendSymbolWithMonthPattern(UnicodeString& dst, int32_t value, const UnicodeSt
//----------------------------------------------------------------------
-static number::LocalizedNumberFormatter*
-createFastFormatter(const DecimalFormat* df, int32_t minInt, int32_t maxInt, UErrorCode& status) {
- const number::LocalizedNumberFormatter* lnfBase = df->toNumberFormatter(status);
- if (U_FAILURE(status)) {
- return nullptr;
- }
- return lnfBase->integerWidth(
- number::IntegerWidth::zeroFillTo(minInt).truncateAt(maxInt)
- ).clone().orphan();
-}
-
-void SimpleDateFormat::initFastNumberFormatters(UErrorCode& status) {
+void
+SimpleDateFormat::initSimpleNumberFormatter(UErrorCode &status) {
if (U_FAILURE(status)) {
return;
}
@@ -1320,27 +1305,20 @@ void SimpleDateFormat::initFastNumberFormatters(UErrorCode& status) {
if (df == nullptr) {
return;
}
- fFastNumberFormatters[SMPDTFMT_NF_1x10] = createFastFormatter(df, 1, 10, status);
- fFastNumberFormatters[SMPDTFMT_NF_2x10] = createFastFormatter(df, 2, 10, status);
- fFastNumberFormatters[SMPDTFMT_NF_3x10] = createFastFormatter(df, 3, 10, status);
- fFastNumberFormatters[SMPDTFMT_NF_4x10] = createFastFormatter(df, 4, 10, status);
- fFastNumberFormatters[SMPDTFMT_NF_2x2] = createFastFormatter(df, 2, 2, status);
-}
-
-void SimpleDateFormat::freeFastNumberFormatters() {
- delete fFastNumberFormatters[SMPDTFMT_NF_1x10];
- delete fFastNumberFormatters[SMPDTFMT_NF_2x10];
- delete fFastNumberFormatters[SMPDTFMT_NF_3x10];
- delete fFastNumberFormatters[SMPDTFMT_NF_4x10];
- delete fFastNumberFormatters[SMPDTFMT_NF_2x2];
- fFastNumberFormatters[SMPDTFMT_NF_1x10] = nullptr;
- fFastNumberFormatters[SMPDTFMT_NF_2x10] = nullptr;
- fFastNumberFormatters[SMPDTFMT_NF_3x10] = nullptr;
- fFastNumberFormatters[SMPDTFMT_NF_4x10] = nullptr;
- fFastNumberFormatters[SMPDTFMT_NF_2x2] = nullptr;
+ const DecimalFormatSymbols* syms = df->getDecimalFormatSymbols();
+ if (syms == nullptr) {
+ return;
+ }
+ fSimpleNumberFormatter = new number::SimpleNumberFormatter(
+ number::SimpleNumberFormatter::forLocaleAndSymbolsAndGroupingStrategy(
+ fLocale, *syms, UNUM_GROUPING_OFF, status
+ )
+ );
+ if (fSimpleNumberFormatter == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ }
}
-
void
SimpleDateFormat::initNumberFormatters(const Locale &locale,UErrorCode &status) {
if (U_FAILURE(status)) {
@@ -1350,9 +1328,9 @@ SimpleDateFormat::initNumberFormatters(const Locale &locale,UErrorCode &status)
return;
}
umtx_lock(&LOCK);
- if (fSharedNumberFormatters == NULL) {
+ if (fSharedNumberFormatters == nullptr) {
fSharedNumberFormatters = allocSharedNumberFormatters();
- if (fSharedNumberFormatters == NULL) {
+ if (fSharedNumberFormatters == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
}
@@ -1376,19 +1354,19 @@ SimpleDateFormat::processOverrideString(const Locale &locale, const UnicodeStrin
int32_t len;
UnicodeString nsName;
UnicodeString ovrField;
- UBool moreToProcess = TRUE;
- NSOverride *overrideList = NULL;
+ UBool moreToProcess = true;
+ NSOverride *overrideList = nullptr;
while (moreToProcess) {
- int32_t delimiterPosition = str.indexOf((UChar)ULOC_KEYWORD_ITEM_SEPARATOR_UNICODE,start);
+ int32_t delimiterPosition = str.indexOf((char16_t)ULOC_KEYWORD_ITEM_SEPARATOR_UNICODE,start);
if (delimiterPosition == -1) {
- moreToProcess = FALSE;
+ moreToProcess = false;
len = str.length() - start;
} else {
len = delimiterPosition - start;
}
UnicodeString currentString(str,start,len);
- int32_t equalSignPosition = currentString.indexOf((UChar)ULOC_KEYWORD_ASSIGN_UNICODE,0);
+ int32_t equalSignPosition = currentString.indexOf((char16_t)ULOC_KEYWORD_ASSIGN_UNICODE,0);
if (equalSignPosition == -1) { // Simple override string such as "hebrew"
nsName.setTo(currentString);
ovrField.setToBogus();
@@ -1400,12 +1378,12 @@ SimpleDateFormat::processOverrideString(const Locale &locale, const UnicodeStrin
int32_t nsNameHash = nsName.hashCode();
// See if the numbering system is in the override list, if not, then add it.
NSOverride *curr = overrideList;
- const SharedNumberFormat *snf = NULL;
- UBool found = FALSE;
+ const SharedNumberFormat *snf = nullptr;
+ UBool found = false;
while ( curr && !found ) {
if ( curr->hash == nsNameHash ) {
snf = curr->snf;
- found = TRUE;
+ found = true;
}
curr = curr->next;
}
@@ -1529,7 +1507,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
}
currentNumberFormat = getNumberFormatByIndex(patternCharIndex);
- if (currentNumberFormat == NULL) {
+ if (currentNumberFormat == nullptr) {
status = U_INTERNAL_PROGRAM_ERROR;
return;
}
@@ -1557,7 +1535,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
break;
case UDAT_YEAR_NAME_FIELD:
- if (fSymbols->fShortYearNames != NULL && value <= fSymbols->fShortYearNamesCount) {
+ if (fSymbols->fShortYearNames != nullptr && value <= fSymbols->fShortYearNamesCount) {
// the Calendar YEAR field runs 1 through 60 for cyclic years
_appendSymbol(appendTo, value - 1, fSymbols->fShortYearNames, fSymbols->fShortYearNamesCount);
break;
@@ -1598,43 +1576,43 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
value--; // Adjust the month number down 1 in Hebrew non-leap years, i.e. Adar is 6, not 7.
}
{
- int32_t isLeapMonth = (fSymbols->fLeapMonthPatterns != NULL && fSymbols->fLeapMonthPatternsCount >= DateFormatSymbols::kMonthPatternsCount)?
+ int32_t isLeapMonth = (fSymbols->fLeapMonthPatterns != nullptr && fSymbols->fLeapMonthPatternsCount >= DateFormatSymbols::kMonthPatternsCount)?
cal.get(UCAL_IS_LEAP_MONTH, status): 0;
// should consolidate the next section by using arrays of pointers & counts for the right symbols...
if (count == 5) {
if (patternCharIndex == UDAT_MONTH_FIELD) {
_appendSymbolWithMonthPattern(appendTo, value, fSymbols->fNarrowMonths, fSymbols->fNarrowMonthsCount,
- (isLeapMonth!=0)? &(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternFormatNarrow]): NULL, status);
+ (isLeapMonth!=0)? &(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternFormatNarrow]): nullptr, status);
} else {
_appendSymbolWithMonthPattern(appendTo, value, fSymbols->fStandaloneNarrowMonths, fSymbols->fStandaloneNarrowMonthsCount,
- (isLeapMonth!=0)? &(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternStandaloneNarrow]): NULL, status);
+ (isLeapMonth!=0)? &(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternStandaloneNarrow]): nullptr, status);
}
capContextUsageType = DateFormatSymbols::kCapContextUsageMonthNarrow;
} else if (count == 4) {
if (patternCharIndex == UDAT_MONTH_FIELD) {
_appendSymbolWithMonthPattern(appendTo, value, fSymbols->fMonths, fSymbols->fMonthsCount,
- (isLeapMonth!=0)? &(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternFormatWide]): NULL, status);
+ (isLeapMonth!=0)? &(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternFormatWide]): nullptr, status);
capContextUsageType = DateFormatSymbols::kCapContextUsageMonthFormat;
} else {
_appendSymbolWithMonthPattern(appendTo, value, fSymbols->fStandaloneMonths, fSymbols->fStandaloneMonthsCount,
- (isLeapMonth!=0)? &(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternStandaloneWide]): NULL, status);
+ (isLeapMonth!=0)? &(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternStandaloneWide]): nullptr, status);
capContextUsageType = DateFormatSymbols::kCapContextUsageMonthStandalone;
}
} else if (count == 3) {
if (patternCharIndex == UDAT_MONTH_FIELD) {
_appendSymbolWithMonthPattern(appendTo, value, fSymbols->fShortMonths, fSymbols->fShortMonthsCount,
- (isLeapMonth!=0)? &(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternFormatAbbrev]): NULL, status);
+ (isLeapMonth!=0)? &(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternFormatAbbrev]): nullptr, status);
capContextUsageType = DateFormatSymbols::kCapContextUsageMonthFormat;
} else {
_appendSymbolWithMonthPattern(appendTo, value, fSymbols->fStandaloneShortMonths, fSymbols->fStandaloneShortMonthsCount,
- (isLeapMonth!=0)? &(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternStandaloneAbbrev]): NULL, status);
+ (isLeapMonth!=0)? &(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternStandaloneAbbrev]): nullptr, status);
capContextUsageType = DateFormatSymbols::kCapContextUsageMonthStandalone;
}
} else {
UnicodeString monthNumber;
zeroPaddingNumber(currentNumberFormat,monthNumber, value + 1, count, maxIntCount);
_appendSymbolWithMonthPattern(appendTo, 0, &monthNumber, 1,
- (isLeapMonth!=0)? &(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternNumeric]): NULL, status);
+ (isLeapMonth!=0)? &(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternNumeric]): nullptr, status);
}
}
break;
@@ -1772,7 +1750,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
case UDAT_TIMEZONE_ISO_FIELD: // 'X'
case UDAT_TIMEZONE_ISO_LOCAL_FIELD: // 'x'
{
- UChar zsbuf[ZONE_NAME_U16_MAX];
+ char16_t zsbuf[ZONE_NAME_U16_MAX];
UnicodeString zoneString(zsbuf, 0, UPRV_LENGTHOF(zsbuf));
const TimeZone& tz = cal.getTimeZone();
UDate date = cal.getTime(status);
@@ -1911,7 +1889,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
case UDAT_AM_PM_MIDNIGHT_NOON_FIELD:
{
- const UnicodeString *toAppend = NULL;
+ const UnicodeString *toAppend = nullptr;
int32_t hour = cal.get(UCAL_HOUR_OF_DAY, status);
// Note: "midnight" can be ambiguous as to whether it refers to beginning of day or end of day.
@@ -1937,10 +1915,10 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
}
}
- // toAppend is NULL if time isn't exactly midnight or noon (as displayed).
+ // toAppend is nullptr if time isn't exactly midnight or noon (as displayed).
// toAppend is bogus if time is midnight or noon, but no localized string exists.
// In either case, fall back to am/pm.
- if (toAppend == NULL || toAppend->isBogus()) {
+ if (toAppend == nullptr || toAppend->isBogus()) {
// Reformat with identical arguments except ch, now changed to 'a'.
// We are passing a different fieldToOutput because we want to add
// 'b' to field position. This makes this fallback stable when
@@ -1963,7 +1941,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
// Data doesn't conform to spec, therefore loading failed.
break;
}
- if (ruleSet == NULL) {
+ if (ruleSet == nullptr) {
// Data doesn't exist for the locale we're looking for.
// Falling back to am/pm.
// We are passing a different fieldToOutput because we want to add
@@ -1997,7 +1975,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
// Rule set exists, therefore periodType can't be UNKNOWN.
// Get localized string.
U_ASSERT(periodType != DayPeriodRules::DAYPERIOD_UNKNOWN);
- UnicodeString *toAppend = NULL;
+ UnicodeString *toAppend = nullptr;
int32_t index;
// Note: "midnight" can be ambiguous as to whether it refers to beginning of day or end of day.
@@ -2020,7 +1998,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
// Midnight/Noon -> General Periods -> AM/PM.
// Midnight/Noon -> General Periods.
- if ((toAppend == NULL || toAppend->isBogus()) &&
+ if ((toAppend == nullptr || toAppend->isBogus()) &&
(periodType == DayPeriodRules::DAYPERIOD_MIDNIGHT ||
periodType == DayPeriodRules::DAYPERIOD_NOON)) {
periodType = ruleSet->getDayPeriodForHour(hour);
@@ -2060,12 +2038,12 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
}
#if !UCONFIG_NO_BREAK_ITERATION
// if first field, check to see whether we need to and are able to titlecase it
- if (fieldNum == 0 && fCapitalizationBrkIter != NULL && appendTo.length() > beginOffset &&
+ if (fieldNum == 0 && fCapitalizationBrkIter != nullptr && appendTo.length() > beginOffset &&
u_islower(appendTo.char32At(beginOffset))) {
- UBool titlecase = FALSE;
+ UBool titlecase = false;
switch (capitalizationContext) {
case UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE:
- titlecase = TRUE;
+ titlecase = true;
break;
case UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU:
titlecase = fSymbols->fCapitalization[capContextUsageType][0];
@@ -2074,7 +2052,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
titlecase = fSymbols->fCapitalization[capContextUsageType][1];
break;
default:
- // titlecase = FALSE;
+ // titlecase = false;
break;
}
if (titlecase) {
@@ -2093,6 +2071,11 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
//----------------------------------------------------------------------
void SimpleDateFormat::adoptNumberFormat(NumberFormat *formatToAdopt) {
+ // Null out the fast formatter, it references fNumberFormat which we're
+ // about to invalidate
+ delete fSimpleNumberFormatter;
+ fSimpleNumberFormatter = nullptr;
+
fixNumberFormatForDates(*formatToAdopt);
delete fNumberFormat;
fNumberFormat = formatToAdopt;
@@ -2101,13 +2084,12 @@ void SimpleDateFormat::adoptNumberFormat(NumberFormat *formatToAdopt) {
// (can't fail).
if (fSharedNumberFormatters) {
freeSharedNumberFormatters(fSharedNumberFormatters);
- fSharedNumberFormatters = NULL;
+ fSharedNumberFormatters = nullptr;
}
- // Also re-compute the fast formatters.
+ // Recompute fSimpleNumberFormatter if necessary
UErrorCode localStatus = U_ZERO_ERROR;
- freeFastNumberFormatters();
- initFastNumberFormatters(localStatus);
+ initSimpleNumberFormatter(localStatus);
}
void SimpleDateFormat::adoptNumberFormat(const UnicodeString& fields, NumberFormat *formatToAdopt, UErrorCode &status){
@@ -2118,20 +2100,20 @@ void SimpleDateFormat::adoptNumberFormat(const UnicodeString& fields, NumberForm
}
// We must ensure fSharedNumberFormatters is allocated.
- if (fSharedNumberFormatters == NULL) {
+ if (fSharedNumberFormatters == nullptr) {
fSharedNumberFormatters = allocSharedNumberFormatters();
- if (fSharedNumberFormatters == NULL) {
+ if (fSharedNumberFormatters == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
}
const SharedNumberFormat *newFormat = createSharedNumberFormat(fmt.orphan());
- if (newFormat == NULL) {
+ if (newFormat == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
for (int i=0; i<fields.length(); i++) {
- UChar field = fields.charAt(i);
+ char16_t field = fields.charAt(i);
// if the pattern character is unrecognized, signal an error and bail out
UDateFormatField patternCharIndex = DateFormatSymbols::getPatternCharIndex(field);
if (patternCharIndex == UDAT_FIELD_COUNT) {
@@ -2148,10 +2130,10 @@ void SimpleDateFormat::adoptNumberFormat(const UnicodeString& fields, NumberForm
}
const NumberFormat *
-SimpleDateFormat::getNumberFormatForField(UChar field) const {
+SimpleDateFormat::getNumberFormatForField(char16_t field) const {
UDateFormatField index = DateFormatSymbols::getPatternCharIndex(field);
if (index == UDAT_FIELD_COUNT) {
- return NULL;
+ return nullptr;
}
return getNumberFormatByIndex(index);
}
@@ -2163,36 +2145,19 @@ SimpleDateFormat::zeroPaddingNumber(
UnicodeString &appendTo,
int32_t value, int32_t minDigits, int32_t maxDigits) const
{
- const number::LocalizedNumberFormatter* fastFormatter = nullptr;
- // NOTE: This uses the heuristic that these five min/max int settings account for the vast majority
- // of SimpleDateFormat number formatting cases at the time of writing (ICU 62).
- if (currentNumberFormat == fNumberFormat) {
- if (maxDigits == 10) {
- if (minDigits == 1) {
- fastFormatter = fFastNumberFormatters[SMPDTFMT_NF_1x10];
- } else if (minDigits == 2) {
- fastFormatter = fFastNumberFormatters[SMPDTFMT_NF_2x10];
- } else if (minDigits == 3) {
- fastFormatter = fFastNumberFormatters[SMPDTFMT_NF_3x10];
- } else if (minDigits == 4) {
- fastFormatter = fFastNumberFormatters[SMPDTFMT_NF_4x10];
- }
- } else if (maxDigits == 2) {
- if (minDigits == 2) {
- fastFormatter = fFastNumberFormatters[SMPDTFMT_NF_2x2];
- }
- }
- }
- if (fastFormatter != nullptr) {
+
+ if (currentNumberFormat == fNumberFormat && fSimpleNumberFormatter) {
// Can use fast path
- number::impl::UFormattedNumberData result;
- result.quantity.setToInt(value);
UErrorCode localStatus = U_ZERO_ERROR;
- fastFormatter->formatImpl(&result, localStatus);
+ number::SimpleNumber number = number::SimpleNumber::forInt64(value, localStatus);
+ number.setMinimumIntegerDigits(minDigits, localStatus);
+ number.truncateStart(maxDigits, localStatus);
+
+ number::FormattedNumber result = fSimpleNumberFormatter->format(std::move(number), localStatus);
if (U_FAILURE(localStatus)) {
return;
}
- appendTo.append(result.getStringRef().toTempUnicodeString());
+ appendTo.append(result.toTempString(localStatus));
return;
}
@@ -2220,7 +2185,7 @@ SimpleDateFormat::zeroPaddingNumber(
* Return true if the given format character, occurring count
* times, represents a numeric field.
*/
-UBool SimpleDateFormat::isNumeric(UChar formatChar, int32_t count) {
+UBool SimpleDateFormat::isNumeric(char16_t formatChar, int32_t count) {
return DateFormatSymbols::isNumericPatternChar(formatChar, count);
}
@@ -2228,13 +2193,13 @@ UBool
SimpleDateFormat::isAtNumericField(const UnicodeString &pattern, int32_t patternOffset) {
if (patternOffset >= pattern.length()) {
// not at any field
- return FALSE;
+ return false;
}
- UChar ch = pattern.charAt(patternOffset);
+ char16_t ch = pattern.charAt(patternOffset);
UDateFormatField f = DateFormatSymbols::getPatternCharIndex(ch);
if (f == UDAT_FIELD_COUNT) {
// not at any field
- return FALSE;
+ return false;
}
int32_t i = patternOffset;
while (pattern.charAt(++i) == ch) {}
@@ -2245,13 +2210,13 @@ UBool
SimpleDateFormat::isAfterNonNumericField(const UnicodeString &pattern, int32_t patternOffset) {
if (patternOffset <= 0) {
// not after any field
- return FALSE;
+ return false;
}
- UChar ch = pattern.charAt(--patternOffset);
+ char16_t ch = pattern.charAt(--patternOffset);
UDateFormatField f = DateFormatSymbols::getPatternCharIndex(ch);
if (f == UDAT_FIELD_COUNT) {
// not after any field
- return FALSE;
+ return false;
}
int32_t i = patternOffset;
while (pattern.charAt(--i) == ch) {}
@@ -2273,7 +2238,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
// the hour to interpret time correctly.
int32_t dayPeriodInt = -1;
- UBool ambiguousYear[] = { FALSE };
+ UBool ambiguousYear[] = { false };
int32_t saveHebrewMonth = -1;
int32_t count = 0;
UTimeZoneFormatTimeType tzTimeType = UTZFMT_TIME_TYPE_UNKNOWN;
@@ -2286,18 +2251,18 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
int32_t abutPat = -1; // If >=0, we are in a run of abutting numeric fields
int32_t abutStart = 0;
int32_t abutPass = 0;
- UBool inQuote = FALSE;
+ UBool inQuote = false;
- MessageFormat * numericLeapMonthFormatter = NULL;
+ MessageFormat * numericLeapMonthFormatter = nullptr;
- Calendar* calClone = NULL;
+ Calendar* calClone = nullptr;
Calendar *workCal = &cal;
if (&cal != fCalendar && uprv_strcmp(cal.getType(), fCalendar->getType()) != 0) {
// Different calendar type
// We use the time/zone from the input calendar, but
// do not use the input calendar for field calculation.
calClone = fCalendar->clone();
- if (calClone != NULL) {
+ if (calClone != nullptr) {
calClone->setTime(cal.getTime(status),status);
if (U_FAILURE(status)) {
goto ExitParse;
@@ -2310,9 +2275,9 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
}
}
- if (fSymbols->fLeapMonthPatterns != NULL && fSymbols->fLeapMonthPatternsCount >= DateFormatSymbols::kMonthPatternsCount) {
+ if (fSymbols->fLeapMonthPatterns != nullptr && fSymbols->fLeapMonthPatternsCount >= DateFormatSymbols::kMonthPatternsCount) {
numericLeapMonthFormatter = new MessageFormat(fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternNumeric], fLocale, status);
- if (numericLeapMonthFormatter == NULL) {
+ if (numericLeapMonthFormatter == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
goto ExitParse;
} else if (U_FAILURE(status)) {
@@ -2321,7 +2286,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
}
for (int32_t i=0; i<fPattern.length(); ++i) {
- UChar ch = fPattern.charAt(i);
+ char16_t ch = fPattern.charAt(i);
// Handle alphabetic field characters.
if (!inQuote && isSyntaxChar(ch)) {
@@ -2370,7 +2335,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
}
pos = subParse(text, pos, ch, count,
- TRUE, FALSE, ambiguousYear, saveHebrewMonth, *workCal, i, numericLeapMonthFormatter, &tzTimeType);
+ true, false, ambiguousYear, saveHebrewMonth, *workCal, i, numericLeapMonthFormatter, &tzTimeType);
// If the parse fails anywhere in the run, back up to the
// start of the run and retry.
@@ -2385,7 +2350,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
// fields.
else if (ch != 0x6C) { // pattern char 'l' (SMALL LETTER L) just gets ignored
int32_t s = subParse(text, pos, ch, count,
- FALSE, TRUE, ambiguousYear, saveHebrewMonth, *workCal, i, numericLeapMonthFormatter, &tzTimeType, &dayPeriodInt);
+ false, true, ambiguousYear, saveHebrewMonth, *workCal, i, numericLeapMonthFormatter, &tzTimeType, &dayPeriodInt);
if (s == -pos-1) {
// era not present, in special cases allow this to continue
@@ -2394,7 +2359,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
if (i+1 < fPattern.length()) {
// move to next pattern character
- UChar c = fPattern.charAt(i+1);
+ char16_t c = fPattern.charAt(i+1);
// check for whitespace
if (PatternProps::isWhiteSpace(c)) {
@@ -2545,7 +2510,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
if (ambiguousYear[0]) {
copy = cal.clone();
// Check for failed cloning.
- if (copy == NULL) {
+ if (copy == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
goto ExitParse;
}
@@ -2561,17 +2526,17 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
if (tzTimeType != UTZFMT_TIME_TYPE_UNKNOWN) {
copy = cal.clone();
// Check for failed cloning.
- if (copy == NULL) {
+ if (copy == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
goto ExitParse;
}
const TimeZone & tz = cal.getTimeZone();
- BasicTimeZone *btz = NULL;
+ BasicTimeZone *btz = nullptr;
- if (dynamic_cast<const OlsonTimeZone *>(&tz) != NULL
- || dynamic_cast<const SimpleTimeZone *>(&tz) != NULL
- || dynamic_cast<const RuleBasedTimeZone *>(&tz) != NULL
- || dynamic_cast<const VTimeZone *>(&tz) != NULL) {
+ if (dynamic_cast<const OlsonTimeZone *>(&tz) != nullptr
+ || dynamic_cast<const SimpleTimeZone *>(&tz) != nullptr
+ || dynamic_cast<const RuleBasedTimeZone *>(&tz) != nullptr
+ || dynamic_cast<const VTimeZone *>(&tz) != nullptr) {
btz = (BasicTimeZone*)&tz;
}
@@ -2583,7 +2548,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
// Make sure parsed time zone type (Standard or Daylight)
// matches the rule used by the parsed time zone.
int32_t raw, dst;
- if (btz != NULL) {
+ if (btz != nullptr) {
if (tzTimeType == UTZFMT_TIME_TYPE_STANDARD) {
btz->getOffsetFromLocal(localMillis,
UCAL_TZ_LOCAL_STANDARD_FORMER, UCAL_TZ_LOCAL_STANDARD_LATTER, raw, dst, status);
@@ -2594,7 +2559,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
} else {
// No good way to resolve ambiguous time at transition,
// but following code work in most case.
- tz.getOffset(localMillis, TRUE, raw, dst, status);
+ tz.getOffset(localMillis, true, raw, dst, status);
}
// Now, compare the results with parsed type, either standard or daylight saving time
@@ -2606,7 +2571,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
}
} else { // tztype == TZTYPE_DST
if (dst == 0) {
- if (btz != NULL) {
+ if (btz != nullptr) {
// This implementation resolves daylight saving time offset
// closest rule after the given time.
UDate baseTime = localMillis + raw;
@@ -2617,7 +2582,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
// Search for DST rule after the given time
while (time < limit) {
- trsAvail = btz->getNextTransition(time, FALSE, trs);
+ trsAvail = btz->getNextTransition(time, false, trs);
if (!trsAvail) {
break;
}
@@ -2634,7 +2599,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
time = baseTime;
limit = baseTime - MAX_DAYLIGHT_DETECTION_RANGE;
while (time > limit) {
- trsAvail = btz->getPreviousTransition(time, TRUE, trs);
+ trsAvail = btz->getPreviousTransition(time, true, trs);
if (!trsAvail) {
break;
}
@@ -2671,10 +2636,10 @@ ExitParse:
cal.setTime(workCal->getTime(status), status);
}
- if (numericLeapMonthFormatter != NULL) {
+ if (numericLeapMonthFormatter != nullptr) {
delete numericLeapMonthFormatter;
}
- if (calClone != NULL) {
+ if (calClone != nullptr) {
delete calClone;
}
@@ -2759,13 +2724,13 @@ UBool SimpleDateFormat::matchLiterals(const UnicodeString &pattern,
UBool partialMatchLenient,
UBool oldLeniency)
{
- UBool inQuote = FALSE;
+ UBool inQuote = false;
UnicodeString literal;
int32_t i = patternOffset;
// scan pattern looking for contiguous literal characters
for ( ; i < pattern.length(); i += 1) {
- UChar ch = pattern.charAt(i);
+ char16_t ch = pattern.charAt(i);
if (!inQuote && isSyntaxChar(ch)) {
break;
@@ -2801,10 +2766,10 @@ UBool SimpleDateFormat::matchLiterals(const UnicodeString &pattern,
}
for (p = 0; p < literal.length() && t < text.length();) {
- UBool needWhitespace = FALSE;
+ UBool needWhitespace = false;
while (p < literal.length() && PatternProps::isWhiteSpace(literal.charAt(p))) {
- needWhitespace = TRUE;
+ needWhitespace = true;
p += 1;
}
@@ -2812,7 +2777,7 @@ UBool SimpleDateFormat::matchLiterals(const UnicodeString &pattern,
int32_t tStart = t;
while (t < text.length()) {
- UChar tch = text.charAt(t);
+ char16_t tch = text.charAt(t);
if (!u_isUWhiteSpace(tch) && !PatternProps::isWhiteSpace(tch)) {
break;
@@ -2827,7 +2792,7 @@ UBool SimpleDateFormat::matchLiterals(const UnicodeString &pattern,
if (!whitespaceLenient && t == tStart) {
// didn't find matching whitespace:
// an error in strict mode
- return FALSE;
+ return false;
}
// In strict mode, this run of whitespace
@@ -2849,7 +2814,7 @@ UBool SimpleDateFormat::matchLiterals(const UnicodeString &pattern,
}
// if it is actual whitespace and we're whitespace lenient it's OK
- UChar wsc = text.charAt(t);
+ char16_t wsc = text.charAt(t);
if(PatternProps::isWhiteSpace(wsc)) {
// Lenient mode and it's just whitespace we skip it
++t;
@@ -2861,7 +2826,7 @@ UBool SimpleDateFormat::matchLiterals(const UnicodeString &pattern,
break;
}
- return FALSE;
+ return false;
}
++p;
++t;
@@ -2873,16 +2838,16 @@ UBool SimpleDateFormat::matchLiterals(const UnicodeString &pattern,
if (p <= 0) {
// no match. Pretend it matched a run of whitespace
// and ignorables in the text.
- const UnicodeSet *ignorables = NULL;
+ const UnicodeSet *ignorables = nullptr;
UDateFormatField patternCharIndex = DateFormatSymbols::getPatternCharIndex(pattern.charAt(i));
if (patternCharIndex != UDAT_FIELD_COUNT) {
ignorables = SimpleDateFormatStaticSets::getIgnorables(patternCharIndex);
}
for (t = textOffset; t < text.length(); t += 1) {
- UChar ch = text.charAt(t);
+ char16_t ch = text.charAt(t);
- if (ignorables == NULL || !ignorables->contains(ch)) {
+ if (ignorables == nullptr || !ignorables->contains(ch)) {
break;
}
}
@@ -2892,7 +2857,50 @@ UBool SimpleDateFormat::matchLiterals(const UnicodeString &pattern,
patternOffset = i - 1;
textOffset = t;
- return TRUE;
+ return true;
+}
+
+//----------------------------------------------------------------------
+// check both wide and abbrev months.
+// Does not currently handle monthPattern.
+// UCalendarDateFields field = UCAL_MONTH
+
+int32_t SimpleDateFormat::matchAlphaMonthStrings(const UnicodeString& text,
+ int32_t start,
+ const UnicodeString* wideData,
+ const UnicodeString* shortData,
+ int32_t dataCount,
+ Calendar& cal) const
+{
+ int32_t i;
+ int32_t bestMatchLength = 0, bestMatch = -1;
+
+ for (i = 0; i < dataCount; ++i) {
+ int32_t matchLen = 0;
+ if ((matchLen = matchStringWithOptionalDot(text, start, wideData[i])) > bestMatchLength) {
+ bestMatch = i;
+ bestMatchLength = matchLen;
+ }
+ }
+ for (i = 0; i < dataCount; ++i) {
+ int32_t matchLen = 0;
+ if ((matchLen = matchStringWithOptionalDot(text, start, shortData[i])) > bestMatchLength) {
+ bestMatch = i;
+ bestMatchLength = matchLen;
+ }
+ }
+
+ if (bestMatch >= 0) {
+ // Adjustment for Hebrew Calendar month Adar II
+ if (!strcmp(cal.getType(),"hebrew") && bestMatch==13) {
+ cal.set(UCAL_MONTH,6);
+ } else {
+ cal.set(UCAL_MONTH, bestMatch);
+ }
+ return start + bestMatchLength;
+ }
+
+ return -start;
}
//----------------------------------------------------------------------
@@ -2914,6 +2922,8 @@ int32_t SimpleDateFormat::matchString(const UnicodeString& text,
// the same prefix (e.g., Cerven and Cervenec (June and July) in Czech).
// We keep track of the longest match, and return that. Note that this
// unfortunately requires us to test all array elements.
+ // But this does not really work for cases such as Chuvash in which
+ // May is "ҫу" and August is "ҫурла"/"ҫур.", hence matchAlphaMonthStrings.
int32_t bestMatchLength = 0, bestMatch = -1;
UnicodeString bestMatchName;
int32_t isLeapMonth = 0;
@@ -2925,7 +2935,7 @@ int32_t SimpleDateFormat::matchString(const UnicodeString& text,
bestMatchLength = matchLen;
}
- if (monthPattern != NULL) {
+ if (monthPattern != nullptr) {
UErrorCode status = U_ZERO_ERROR;
UnicodeString leapMonthName;
SimpleFormatter(*monthPattern, 1, 1, status).format(data[i], leapMonthName, status);
@@ -2950,7 +2960,7 @@ int32_t SimpleDateFormat::matchString(const UnicodeString& text,
}
cal.set(field, bestMatch);
}
- if (monthPattern != NULL) {
+ if (monthPattern != nullptr) {
cal.set(UCAL_IS_LEAP_MONTH, isLeapMonth);
}
}
@@ -2997,7 +3007,7 @@ SimpleDateFormat::set2DigitYearStart(UDate d, UErrorCode& status)
* Private member function that converts the parsed date strings into
* timeFields. Returns -start (for ParsePosition) if failed.
*/
-int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UChar ch, int32_t count,
+int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, char16_t ch, int32_t count,
UBool obeyCount, UBool allowNegative, UBool ambiguousYear[], int32_t& saveHebrewMonth, Calendar& cal,
int32_t patLoc, MessageFormat * numericLeapMonthFormatter, UTimeZoneFormatTimeType *tzTimeType,
int32_t *dayPeriod) const
@@ -3011,7 +3021,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
UDateFormatField patternCharIndex = DateFormatSymbols::getPatternCharIndex(ch);
const NumberFormat *currentNumberFormat;
UnicodeString temp;
- UBool gotNumber = FALSE;
+ UBool gotNumber = false;
#if defined (U_DEBUG_CAL)
//fprintf(stderr, "%s:%d - [%c] st=%d \n", __FILE__, __LINE__, (char) ch, start);
@@ -3022,13 +3032,13 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
}
currentNumberFormat = getNumberFormatByIndex(patternCharIndex);
- if (currentNumberFormat == NULL) {
+ if (currentNumberFormat == nullptr) {
return -start;
}
UCalendarDateFields field = fgPatternIndexToCalendarField[patternCharIndex]; // UCAL_FIELD_COUNT if irrelevant
UnicodeString hebr("hebr", 4, US_INV);
- if (numericLeapMonthFormatter != NULL) {
+ if (numericLeapMonthFormatter != nullptr) {
numericLeapMonthFormatter->setFormats((const Format **)&currentNumberFormat, 1);
}
UBool isChineseCalendar = (uprv_strcmp(cal.getType(),"chinese") == 0 || uprv_strcmp(cal.getType(),"dangi") == 0);
@@ -3072,12 +3082,12 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
// but that's going to be difficult.
const UnicodeString* src;
- UBool parsedNumericLeapMonth = FALSE;
- if (numericLeapMonthFormatter != NULL && (patternCharIndex == UDAT_MONTH_FIELD || patternCharIndex == UDAT_STANDALONE_MONTH_FIELD)) {
+ UBool parsedNumericLeapMonth = false;
+ if (numericLeapMonthFormatter != nullptr && (patternCharIndex == UDAT_MONTH_FIELD || patternCharIndex == UDAT_STANDALONE_MONTH_FIELD)) {
int32_t argCount;
Formattable * args = numericLeapMonthFormatter->parse(text, pos, argCount);
- if (args != NULL && argCount == 1 && pos.getIndex() > parseStart && args[0].isNumeric()) {
- parsedNumericLeapMonth = TRUE;
+ if (args != nullptr && argCount == 1 && pos.getIndex() > parseStart && args[0].isNumeric()) {
+ parsedNumericLeapMonth = true;
number.setLong(args[0].getLong());
cal.set(UCAL_IS_LEAP_MONTH, 1);
delete[] args;
@@ -3106,17 +3116,17 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
if (txtLoc > parseStart) {
value = number.getLong();
- gotNumber = TRUE;
+ gotNumber = true;
// suffix processing
if (value < 0 ) {
- txtLoc = checkIntSuffix(text, txtLoc, patLoc+1, TRUE);
+ txtLoc = checkIntSuffix(text, txtLoc, patLoc+1, true);
if (txtLoc != pos.getIndex()) {
value *= -1;
}
}
else {
- txtLoc = checkIntSuffix(text, txtLoc, patLoc+1, FALSE);
+ txtLoc = checkIntSuffix(text, txtLoc, patLoc+1, false);
}
if (!getBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, status)) {
@@ -3171,11 +3181,11 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
return pos.getIndex();
}
if (count == 5) {
- ps = matchString(text, start, UCAL_ERA, fSymbols->fNarrowEras, fSymbols->fNarrowErasCount, NULL, cal);
+ ps = matchString(text, start, UCAL_ERA, fSymbols->fNarrowEras, fSymbols->fNarrowErasCount, nullptr, cal);
} else if (count == 4) {
- ps = matchString(text, start, UCAL_ERA, fSymbols->fEraNames, fSymbols->fEraNamesCount, NULL, cal);
+ ps = matchString(text, start, UCAL_ERA, fSymbols->fEraNames, fSymbols->fEraNamesCount, nullptr, cal);
} else {
- ps = matchString(text, start, UCAL_ERA, fSymbols->fEras, fSymbols->fErasCount, NULL, cal);
+ ps = matchString(text, start, UCAL_ERA, fSymbols->fEras, fSymbols->fErasCount, nullptr, cal);
}
// check return position, if it equals -start, then matchString error
@@ -3249,8 +3259,8 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
return pos.getIndex();
case UDAT_YEAR_NAME_FIELD:
- if (fSymbols->fShortYearNames != NULL) {
- int32_t newStart = matchString(text, start, UCAL_YEAR, fSymbols->fShortYearNames, fSymbols->fShortYearNamesCount, NULL, cal);
+ if (fSymbols->fShortYearNames != nullptr) {
+ int32_t newStart = matchString(text, start, UCAL_YEAR, fSymbols->fShortYearNames, fSymbols->fShortYearNamesCount, nullptr, cal);
if (newStart > 0) {
return newStart;
}
@@ -3291,9 +3301,9 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
// count >= 3 // i.e., MMM/MMMM, LLL/LLLL
// Want to be able to parse both short and long forms.
// Try count == 4 first:
- UnicodeString * wideMonthPat = NULL;
- UnicodeString * shortMonthPat = NULL;
- if (fSymbols->fLeapMonthPatterns != NULL && fSymbols->fLeapMonthPatternsCount >= DateFormatSymbols::kMonthPatternsCount) {
+ UnicodeString * wideMonthPat = nullptr;
+ UnicodeString * shortMonthPat = nullptr;
+ if (fSymbols->fLeapMonthPatterns != nullptr && fSymbols->fLeapMonthPatternsCount >= DateFormatSymbols::kMonthPatternsCount) {
if (patternCharIndex==UDAT_MONTH_FIELD) {
wideMonthPat = &fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternFormatWide];
shortMonthPat = &fSymbols->fLeapMonthPatterns[DateFormatSymbols::kLeapMonthPatternFormatAbbrev];
@@ -3304,6 +3314,14 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
}
int32_t newStart = 0;
if (patternCharIndex==UDAT_MONTH_FIELD) {
+ if(getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status) && count>=3 && count <=4 &&
+ fSymbols->fLeapMonthPatterns==nullptr && fSymbols->fMonthsCount==fSymbols->fShortMonthsCount) {
+ // single function to check both wide and short, an experiment
+ newStart = matchAlphaMonthStrings(text, start, fSymbols->fMonths, fSymbols->fShortMonths, fSymbols->fMonthsCount, cal); // try MMMM,MMM
+ if (newStart > 0) {
+ return newStart;
+ }
+ }
if(getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status) || count == 4) {
newStart = matchString(text, start, UCAL_MONTH, fSymbols->fMonths, fSymbols->fMonthsCount, wideMonthPat, cal); // try MMMM
if (newStart > 0) {
@@ -3314,6 +3332,14 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
newStart = matchString(text, start, UCAL_MONTH, fSymbols->fShortMonths, fSymbols->fShortMonthsCount, shortMonthPat, cal); // try MMM
}
} else {
+ if(getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status) && count>=3 && count <=4 &&
+ fSymbols->fLeapMonthPatterns==nullptr && fSymbols->fStandaloneMonthsCount==fSymbols->fStandaloneShortMonthsCount) {
+ // single function to check both wide and short, an experiment
+ newStart = matchAlphaMonthStrings(text, start, fSymbols->fStandaloneMonths, fSymbols->fStandaloneShortMonths, fSymbols->fStandaloneMonthsCount, cal); // try MMMM,MMM
+ if (newStart > 0) {
+ return newStart;
+ }
+ }
if(getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status) || count == 4) {
newStart = matchString(text, start, UCAL_MONTH, fSymbols->fStandaloneMonths, fSymbols->fStandaloneMonthsCount, wideMonthPat, cal); // try LLLL
if (newStart > 0) {
@@ -3377,25 +3403,25 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
int32_t newStart = 0;
if(getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status) || count == 4) {
if ((newStart = matchString(text, start, UCAL_DAY_OF_WEEK,
- fSymbols->fWeekdays, fSymbols->fWeekdaysCount, NULL, cal)) > 0)
+ fSymbols->fWeekdays, fSymbols->fWeekdaysCount, nullptr, cal)) > 0)
return newStart;
}
// EEEE wide failed, now try EEE abbreviated
if(getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status) || count == 3) {
if ((newStart = matchString(text, start, UCAL_DAY_OF_WEEK,
- fSymbols->fShortWeekdays, fSymbols->fShortWeekdaysCount, NULL, cal)) > 0)
+ fSymbols->fShortWeekdays, fSymbols->fShortWeekdaysCount, nullptr, cal)) > 0)
return newStart;
}
// EEE abbreviated failed, now try EEEEEE short
if(getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status) || count == 6) {
if ((newStart = matchString(text, start, UCAL_DAY_OF_WEEK,
- fSymbols->fShorterWeekdays, fSymbols->fShorterWeekdaysCount, NULL, cal)) > 0)
+ fSymbols->fShorterWeekdays, fSymbols->fShorterWeekdaysCount, nullptr, cal)) > 0)
return newStart;
}
// EEEEEE short failed, now try EEEEE narrow
if(getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status) || count == 5) {
if ((newStart = matchString(text, start, UCAL_DAY_OF_WEEK,
- fSymbols->fNarrowWeekdays, fSymbols->fNarrowWeekdaysCount, NULL, cal)) > 0)
+ fSymbols->fNarrowWeekdays, fSymbols->fNarrowWeekdaysCount, nullptr, cal)) > 0)
return newStart;
}
if (!getBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, status) || patternCharIndex == UDAT_DAY_OF_WEEK_FIELD)
@@ -3417,17 +3443,17 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
int32_t newStart = 0;
if(getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status) || count == 4) {
if ((newStart = matchString(text, start, UCAL_DAY_OF_WEEK,
- fSymbols->fStandaloneWeekdays, fSymbols->fStandaloneWeekdaysCount, NULL, cal)) > 0)
+ fSymbols->fStandaloneWeekdays, fSymbols->fStandaloneWeekdaysCount, nullptr, cal)) > 0)
return newStart;
}
if(getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status) || count == 3) {
if ((newStart = matchString(text, start, UCAL_DAY_OF_WEEK,
- fSymbols->fStandaloneShortWeekdays, fSymbols->fStandaloneShortWeekdaysCount, NULL, cal)) > 0)
+ fSymbols->fStandaloneShortWeekdays, fSymbols->fStandaloneShortWeekdaysCount, nullptr, cal)) > 0)
return newStart;
}
if(getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status) || count == 6) {
if ((newStart = matchString(text, start, UCAL_DAY_OF_WEEK,
- fSymbols->fStandaloneShorterWeekdays, fSymbols->fStandaloneShorterWeekdaysCount, NULL, cal)) > 0)
+ fSymbols->fStandaloneShorterWeekdays, fSymbols->fStandaloneShorterWeekdaysCount, nullptr, cal)) > 0)
return newStart;
}
if (!getBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, status))
@@ -3442,13 +3468,13 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
int32_t newStart = 0;
// try wide/abbrev
if( getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status) || count < 5 ) {
- if ((newStart = matchString(text, start, UCAL_AM_PM, fSymbols->fAmPms, fSymbols->fAmPmsCount, NULL, cal)) > 0) {
+ if ((newStart = matchString(text, start, UCAL_AM_PM, fSymbols->fAmPms, fSymbols->fAmPmsCount, nullptr, cal)) > 0) {
return newStart;
}
}
// try narrow
if( getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status) || count >= 5 ) {
- if ((newStart = matchString(text, start, UCAL_AM_PM, fSymbols->fNarrowAmPms, fSymbols->fNarrowAmPmsCount, NULL, cal)) > 0) {
+ if ((newStart = matchString(text, start, UCAL_AM_PM, fSymbols->fNarrowAmPms, fSymbols->fNarrowAmPmsCount, nullptr, cal)) > 0) {
return newStart;
}
}
@@ -3547,7 +3573,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
const TimeZoneFormat *tzfmt = tzFormat(status);
if (U_SUCCESS(status)) {
TimeZone *tz = tzfmt->parse(style, text, pos, tzTimeType);
- if (tz != NULL) {
+ if (tz != nullptr) {
cal.adoptTimeZone(tz);
return pos.getIndex();
}
@@ -3562,7 +3588,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
const TimeZoneFormat *tzfmt = tzFormat(status);
if (U_SUCCESS(status)) {
TimeZone *tz = tzfmt->parse(style, text, pos, tzTimeType);
- if (tz != NULL) {
+ if (tz != nullptr) {
cal.adoptTimeZone(tz);
return pos.getIndex();
}
@@ -3575,7 +3601,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
const TimeZoneFormat *tzfmt = tzFormat(status);
if (U_SUCCESS(status)) {
TimeZone *tz = tzfmt->parse(style, text, pos, tzTimeType);
- if (tz != NULL) {
+ if (tz != nullptr) {
cal.adoptTimeZone(tz);
return pos.getIndex();
}
@@ -3602,7 +3628,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
const TimeZoneFormat *tzfmt = tzFormat(status);
if (U_SUCCESS(status)) {
TimeZone *tz = tzfmt->parse(style, text, pos, tzTimeType);
- if (tz != NULL) {
+ if (tz != nullptr) {
cal.adoptTimeZone(tz);
return pos.getIndex();
}
@@ -3615,7 +3641,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
const TimeZoneFormat *tzfmt = tzFormat(status);
if (U_SUCCESS(status)) {
TimeZone *tz = tzfmt->parse(style, text, pos, tzTimeType);
- if (tz != NULL) {
+ if (tz != nullptr) {
cal.adoptTimeZone(tz);
return pos.getIndex();
}
@@ -3645,7 +3671,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
const TimeZoneFormat *tzfmt = tzFormat(status);
if (U_SUCCESS(status)) {
TimeZone *tz = tzfmt->parse(style, text, pos, tzTimeType);
- if (tz != NULL) {
+ if (tz != nullptr) {
cal.adoptTimeZone(tz);
return pos.getIndex();
}
@@ -3675,7 +3701,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
const TimeZoneFormat *tzfmt = tzFormat(status);
if (U_SUCCESS(status)) {
TimeZone *tz = tzfmt->parse(style, text, pos, tzTimeType);
- if (tz != NULL) {
+ if (tz != nullptr) {
cal.adoptTimeZone(tz);
return pos.getIndex();
}
@@ -3686,8 +3712,8 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
// so we should not get here. Leave support in for future definition.
case UDAT_TIME_SEPARATOR_FIELD:
{
- static const UChar def_sep = DateFormatSymbols::DEFAULT_TIME_SEPARATOR;
- static const UChar alt_sep = DateFormatSymbols::ALTERNATE_TIME_SEPARATOR;
+ static const char16_t def_sep = DateFormatSymbols::DEFAULT_TIME_SEPARATOR;
+ static const char16_t alt_sep = DateFormatSymbols::ALTERNATE_TIME_SEPARATOR;
// Try matching a time separator.
int32_t count_sep = 1;
@@ -3704,12 +3730,12 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
data[count_sep++].setTo(alt_sep);
}
- return matchString(text, start, UCAL_FIELD_COUNT /* => nothing to set */, data, count_sep, NULL, cal);
+ return matchString(text, start, UCAL_FIELD_COUNT /* => nothing to set */, data, count_sep, nullptr, cal);
}
case UDAT_AM_PM_MIDNIGHT_NOON_FIELD:
{
- U_ASSERT(dayPeriod != NULL);
+ U_ASSERT(dayPeriod != nullptr);
int32_t ampmStart = subParse(text, start, 0x61, count,
obeyCount, allowNegative, ambiguousYear, saveHebrewMonth, cal,
patLoc, numericLeapMonthFormatter, tzTimeType);
@@ -3746,7 +3772,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
case UDAT_FLEXIBLE_DAY_PERIOD_FIELD:
{
- U_ASSERT(dayPeriod != NULL);
+ U_ASSERT(dayPeriod != nullptr);
int32_t newStart = 0;
if (getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status) || count == 3) {
@@ -3792,6 +3818,9 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
src = &text;
}
parseInt(*src, number, pos, allowNegative,currentNumberFormat);
+ if (obeyCount && !isLenient() && pos.getIndex() < start + count) {
+ return -start;
+ }
if (pos.getIndex() != parseStart) {
int32_t val = number.getLong();
@@ -3881,7 +3910,7 @@ void SimpleDateFormat::parseInt(const UnicodeString& text,
// Memory allocation error
return;
}
- df->setNegativePrefix(UnicodeString(TRUE, SUPPRESS_NEGATIVE_PREFIX, -1));
+ df->setNegativePrefix(UnicodeString(true, SUPPRESS_NEGATIVE_PREFIX, -1));
fmt = df.getAlias();
}
int32_t oldPos = pos.getIndex();
@@ -3936,16 +3965,16 @@ void SimpleDateFormat::translatePattern(const UnicodeString& originalPattern,
}
translatedPattern.remove();
- UBool inQuote = FALSE;
+ UBool inQuote = false;
for (int32_t i = 0; i < originalPattern.length(); ++i) {
- UChar c = originalPattern[i];
+ char16_t c = originalPattern[i];
if (inQuote) {
if (c == QUOTE) {
- inQuote = FALSE;
+ inQuote = false;
}
} else {
if (c == QUOTE) {
- inQuote = TRUE;
+ inQuote = true;
} else if (isSyntaxChar(c)) {
int32_t ci = from.indexOf(c);
if (ci == -1) {
@@ -4001,18 +4030,18 @@ SimpleDateFormat::applyPattern(const UnicodeString& pattern)
// use procedure from adoptNumberFormat to clear overrides
if (fSharedNumberFormatters) {
freeSharedNumberFormatters(fSharedNumberFormatters);
- fSharedNumberFormatters = NULL;
+ fSharedNumberFormatters = nullptr;
}
fDateOverride.setToBogus(); // record status
} else if (fDateOverride.isBogus() && fHasHanYearChar) {
// No current override (=> no Gannen numbering) but new pattern needs it;
// use procedures from initNUmberFormatters / adoptNumberFormat
umtx_lock(&LOCK);
- if (fSharedNumberFormatters == NULL) {
+ if (fSharedNumberFormatters == nullptr) {
fSharedNumberFormatters = allocSharedNumberFormatters();
}
umtx_unlock(&LOCK);
- if (fSharedNumberFormatters != NULL) {
+ if (fSharedNumberFormatters != nullptr) {
Locale ovrLoc(fLocale.getLanguage(),fLocale.getCountry(),fLocale.getVariant(),"numbers=jpanyear");
UErrorCode status = U_ZERO_ERROR;
const SharedNumberFormat *snf = createSharedNumberFormat(ovrLoc, status);
@@ -4067,7 +4096,7 @@ SimpleDateFormat::setDateFormatSymbols(const DateFormatSymbols& newFormatSymbols
//----------------------------------------------------------------------
const TimeZoneFormat*
-SimpleDateFormat::getTimeZoneFormat(void) const {
+SimpleDateFormat::getTimeZoneFormat() const {
// TimeZoneFormat initialization might fail when out of memory.
// If we always initialize TimeZoneFormat instance, we can return
// such status there. For now, this implementation lazily instantiates
@@ -4125,13 +4154,13 @@ SimpleDateFormat::setContext(UDisplayContext value, UErrorCode& status)
DateFormat::setContext(value, status);
#if !UCONFIG_NO_BREAK_ITERATION
if (U_SUCCESS(status)) {
- if ( fCapitalizationBrkIter == NULL && (value==UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE ||
+ if ( fCapitalizationBrkIter == nullptr && (value==UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE ||
value==UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU || value==UDISPCTX_CAPITALIZATION_FOR_STANDALONE) ) {
status = U_ZERO_ERROR;
fCapitalizationBrkIter = BreakIterator::createSentenceInstance(fLocale, status);
if (U_FAILURE(status)) {
delete fCapitalizationBrkIter;
- fCapitalizationBrkIter = NULL;
+ fCapitalizationBrkIter = nullptr;
}
}
}
@@ -4153,9 +4182,9 @@ SimpleDateFormat::isFieldUnitIgnored(const UnicodeString& pattern,
UCalendarDateFields field) {
int32_t fieldLevel = fgCalendarFieldToLevel[field];
int32_t level;
- UChar ch;
- UBool inQuote = FALSE;
- UChar prevCh = 0;
+ char16_t ch;
+ UBool inQuote = false;
+ char16_t prevCh = 0;
int32_t count = 0;
for (int32_t i = 0; i < pattern.length(); ++i) {
@@ -4164,7 +4193,7 @@ SimpleDateFormat::isFieldUnitIgnored(const UnicodeString& pattern,
level = getLevelFromChar(prevCh);
// the larger the level, the smaller the field unit.
if (fieldLevel <= level) {
- return FALSE;
+ return false;
}
count = 0;
}
@@ -4184,16 +4213,16 @@ SimpleDateFormat::isFieldUnitIgnored(const UnicodeString& pattern,
// last item
level = getLevelFromChar(prevCh);
if (fieldLevel <= level) {
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
//----------------------------------------------------------------------
const Locale&
-SimpleDateFormat::getSmpFmtLocale(void) const {
+SimpleDateFormat::getSmpFmtLocale() const {
return fLocale;
}
@@ -4219,7 +4248,7 @@ SimpleDateFormat::checkIntSuffix(const UnicodeString& text, int32_t start,
// get the suffix
DecimalFormat* decfmt = dynamic_cast<DecimalFormat*>(fNumberFormat);
- if (decfmt != NULL) {
+ if (decfmt != nullptr) {
if (isNegative) {
suf = decfmt->getNegativeSuffix(suf);
}
@@ -4271,10 +4300,10 @@ SimpleDateFormat::compareSimpleAffix(const UnicodeString& affix,
// U+0020 is UWhiteSpace. So we have to first do a direct
// match of the run of Pattern_White_Space in the pattern,
// then match any extra characters.
- UBool literalMatch = FALSE;
+ UBool literalMatch = false;
while (pos < input.length() &&
input.char32At(pos) == c) {
- literalMatch = TRUE;
+ literalMatch = true;
i += len;
pos += len;
if (i == affix.length()) {
@@ -4320,7 +4349,7 @@ SimpleDateFormat::compareSimpleAffix(const UnicodeString& affix,
int32_t
SimpleDateFormat::skipPatternWhiteSpace(const UnicodeString& text, int32_t pos) const {
- const UChar* s = text.getBuffer();
+ const char16_t* s = text.getBuffer();
return (int32_t)(PatternProps::skipWhiteSpace(s + pos, text.length() - pos) - s);
}
@@ -4352,26 +4381,26 @@ SimpleDateFormat::tzFormat(UErrorCode &status) const {
}
void SimpleDateFormat::parsePattern() {
- fHasMinute = FALSE;
- fHasSecond = FALSE;
- fHasHanYearChar = FALSE;
+ fHasMinute = false;
+ fHasSecond = false;
+ fHasHanYearChar = false;
int len = fPattern.length();
- UBool inQuote = FALSE;
+ UBool inQuote = false;
for (int32_t i = 0; i < len; ++i) {
- UChar ch = fPattern[i];
+ char16_t ch = fPattern[i];
if (ch == QUOTE) {
inQuote = !inQuote;
}
if (ch == 0x5E74) { // don't care whether this is inside quotes
- fHasHanYearChar = TRUE;
+ fHasHanYearChar = true;
}
if (!inQuote) {
if (ch == 0x6D) { // 0x6D == 'm'
- fHasMinute = TRUE;
+ fHasMinute = true;
}
if (ch == 0x73) { // 0x73 == 's'
- fHasSecond = TRUE;
+ fHasSecond = true;
}
}
}
diff --git a/contrib/libs/icu/i18n/smpdtfst.cpp b/contrib/libs/icu/i18n/smpdtfst.cpp
index db59a4b4ab..9f9166aceb 100644
--- a/contrib/libs/icu/i18n/smpdtfst.cpp
+++ b/contrib/libs/icu/i18n/smpdtfst.cpp
@@ -29,20 +29,20 @@
U_NAMESPACE_BEGIN
-SimpleDateFormatStaticSets *gStaticSets = NULL;
-UInitOnce gSimpleDateFormatStaticSetsInitOnce = U_INITONCE_INITIALIZER;
+SimpleDateFormatStaticSets *gStaticSets = nullptr;
+UInitOnce gSimpleDateFormatStaticSetsInitOnce {};
SimpleDateFormatStaticSets::SimpleDateFormatStaticSets(UErrorCode &status)
-: fDateIgnorables(NULL),
- fTimeIgnorables(NULL),
- fOtherIgnorables(NULL)
+: fDateIgnorables(nullptr),
+ fTimeIgnorables(nullptr),
+ fOtherIgnorables(nullptr)
{
fDateIgnorables = new UnicodeSet(UNICODE_STRING("[-,./[:whitespace:]]", 20), status);
fTimeIgnorables = new UnicodeSet(UNICODE_STRING("[-.:[:whitespace:]]", 19), status);
fOtherIgnorables = new UnicodeSet(UNICODE_STRING("[:whitespace:]", 14), status);
// Check for null pointers
- if (fDateIgnorables == NULL || fTimeIgnorables == NULL || fOtherIgnorables == NULL) {
+ if (fDateIgnorables == nullptr || fTimeIgnorables == nullptr || fOtherIgnorables == nullptr) {
goto ExitConstrDeleteAll;
}
@@ -54,18 +54,18 @@ SimpleDateFormatStaticSets::SimpleDateFormatStaticSets(UErrorCode &status)
return; // If we reached this point, everything is fine so just exit
ExitConstrDeleteAll: // Remove all sets and return error
- delete fDateIgnorables; fDateIgnorables = NULL;
- delete fTimeIgnorables; fTimeIgnorables = NULL;
- delete fOtherIgnorables; fOtherIgnorables = NULL;
+ delete fDateIgnorables; fDateIgnorables = nullptr;
+ delete fTimeIgnorables; fTimeIgnorables = nullptr;
+ delete fOtherIgnorables; fOtherIgnorables = nullptr;
status = U_MEMORY_ALLOCATION_ERROR;
}
SimpleDateFormatStaticSets::~SimpleDateFormatStaticSets() {
- delete fDateIgnorables; fDateIgnorables = NULL;
- delete fTimeIgnorables; fTimeIgnorables = NULL;
- delete fOtherIgnorables; fOtherIgnorables = NULL;
+ delete fDateIgnorables; fDateIgnorables = nullptr;
+ delete fTimeIgnorables; fTimeIgnorables = nullptr;
+ delete fOtherIgnorables; fOtherIgnorables = nullptr;
}
@@ -76,26 +76,26 @@ SimpleDateFormatStaticSets::~SimpleDateFormatStaticSets() {
//
//------------------------------------------------------------------------------
UBool
-SimpleDateFormatStaticSets::cleanup(void)
+SimpleDateFormatStaticSets::cleanup()
{
delete gStaticSets;
- gStaticSets = NULL;
+ gStaticSets = nullptr;
gSimpleDateFormatStaticSetsInitOnce.reset();
- return TRUE;
+ return true;
}
U_CDECL_BEGIN
static UBool U_CALLCONV
-smpdtfmt_cleanup(void)
+smpdtfmt_cleanup()
{
return SimpleDateFormatStaticSets::cleanup();
}
static void U_CALLCONV smpdtfmt_initSets(UErrorCode &status) {
ucln_i18n_registerCleanup(UCLN_I18N_SMPDTFMT, smpdtfmt_cleanup);
- U_ASSERT(gStaticSets == NULL);
+ U_ASSERT(gStaticSets == nullptr);
gStaticSets = new SimpleDateFormatStaticSets(status);
- if (gStaticSets == NULL) {
+ if (gStaticSets == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -108,7 +108,7 @@ UnicodeSet *SimpleDateFormatStaticSets::getIgnorables(UDateFormatField fieldInde
UErrorCode status = U_ZERO_ERROR;
umtx_initOnce(gSimpleDateFormatStaticSetsInitOnce, &smpdtfmt_initSets, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
switch (fieldIndex) {
diff --git a/contrib/libs/icu/i18n/sortkey.cpp b/contrib/libs/icu/i18n/sortkey.cpp
index 441d15d426..1fd066cc20 100644
--- a/contrib/libs/icu/i18n/sortkey.cpp
+++ b/contrib/libs/icu/i18n/sortkey.cpp
@@ -61,8 +61,8 @@ CollationKey::CollationKey(const uint8_t* newValues, int32_t count)
: UObject(), fFlagAndLength(count),
fHashCode(kInvalidHashCode)
{
- if (count < 0 || (newValues == NULL && count != 0) ||
- (count > getCapacity() && reallocate(count, 0) == NULL)) {
+ if (count < 0 || (newValues == nullptr && count != 0) ||
+ (count > getCapacity() && reallocate(count, 0) == nullptr)) {
setToBogus();
return;
}
@@ -83,7 +83,7 @@ CollationKey::CollationKey(const CollationKey& other)
}
int32_t length = fFlagAndLength;
- if (length > getCapacity() && reallocate(length, 0) == NULL) {
+ if (length > getCapacity() && reallocate(length, 0) == nullptr) {
setToBogus();
return;
}
@@ -100,7 +100,7 @@ CollationKey::~CollationKey()
uint8_t *CollationKey::reallocate(int32_t newCapacity, int32_t length) {
uint8_t *newBytes = static_cast<uint8_t *>(uprv_malloc(newCapacity));
- if(newBytes == NULL) { return NULL; }
+ if(newBytes == nullptr) { return nullptr; }
if(length > 0) {
uprv_memcpy(newBytes, getBytes(), length);
}
@@ -156,7 +156,7 @@ CollationKey::operator=(const CollationKey& other)
}
int32_t length = other.getLength();
- if (length > getCapacity() && reallocate(length, 0) == NULL) {
+ if (length > getCapacity() && reallocate(length, 0) == nullptr) {
return setToBogus();
}
if (length > 0) {
@@ -227,7 +227,7 @@ CollationKey::toByteArray(int32_t& count) const
{
uint8_t *result = (uint8_t*) uprv_malloc( sizeof(uint8_t) * fCount );
- if (result == NULL)
+ if (result == nullptr)
{
count = 0;
}
@@ -247,7 +247,7 @@ static int32_t
computeHashCode(const uint8_t *key, int32_t length) {
const char *s = reinterpret_cast<const char *>(key);
int32_t hash;
- if (s == NULL || length == 0) {
+ if (s == nullptr || length == 0) {
hash = kEmptyHashCode;
} else {
hash = ustr_hashCharsN(s, length);
diff --git a/contrib/libs/icu/i18n/standardplural.cpp b/contrib/libs/icu/i18n/standardplural.cpp
index 5a6069bf7d..9183e92550 100644
--- a/contrib/libs/icu/i18n/standardplural.cpp
+++ b/contrib/libs/icu/i18n/standardplural.cpp
@@ -84,14 +84,14 @@ int32_t StandardPlural::indexOrNegativeFromString(const char *keyword) {
return -1;
}
-static const UChar gZero[] = u"zero";
-static const UChar gOne[] = u"one";
-static const UChar gTwo[] = u"two";
-static const UChar gFew[] = u"few";
-static const UChar gMany[] = u"many";
-static const UChar gOther[] = u"other";
-static const UChar gEq0[] = u"=0";
-static const UChar gEq1[] = u"=1";
+static const char16_t gZero[] = u"zero";
+static const char16_t gOne[] = u"one";
+static const char16_t gTwo[] = u"two";
+static const char16_t gFew[] = u"few";
+static const char16_t gMany[] = u"many";
+static const char16_t gOther[] = u"other";
+static const char16_t gEq0[] = u"=0";
+static const char16_t gEq1[] = u"=1";
int32_t StandardPlural::indexOrNegativeFromString(const UnicodeString &keyword) {
switch (keyword.length()) {
diff --git a/contrib/libs/icu/i18n/string_segment.cpp b/contrib/libs/icu/i18n/string_segment.cpp
index 5d19ac57f5..2ddb738f4d 100644
--- a/contrib/libs/icu/i18n/string_segment.cpp
+++ b/contrib/libs/icu/i18n/string_segment.cpp
@@ -64,7 +64,7 @@ UnicodeString StringSegment::toUnicodeString() const {
const UnicodeString StringSegment::toTempUnicodeString() const {
// Use the readonly-aliasing constructor for efficiency.
- return UnicodeString(FALSE, fStr.getBuffer() + fStart, fEnd - fStart);
+ return UnicodeString(false, fStr.getBuffer() + fStart, fEnd - fStart);
}
UChar32 StringSegment::getCodePoint() const {
@@ -131,8 +131,8 @@ bool StringSegment::codePointsEqual(UChar32 cp1, UChar32 cp2, bool foldCase) {
if (!foldCase) {
return false;
}
- cp1 = u_foldCase(cp1, TRUE);
- cp2 = u_foldCase(cp2, TRUE);
+ cp1 = u_foldCase(cp1, true);
+ cp2 = u_foldCase(cp2, true);
return cp1 == cp2;
}
diff --git a/contrib/libs/icu/i18n/strmatch.cpp b/contrib/libs/icu/i18n/strmatch.cpp
index a20f7873fe..ff52eeacdc 100644
--- a/contrib/libs/icu/i18n/strmatch.cpp
+++ b/contrib/libs/icu/i18n/strmatch.cpp
@@ -96,7 +96,7 @@ UMatchDegree StringMatcher::matches(const Replaceable& text,
if (limit < cursor) {
// Match in the reverse direction
for (i=pattern.length()-1; i>=0; --i) {
- UChar keyChar = pattern.charAt(i);
+ char16_t keyChar = pattern.charAt(i);
UnicodeMatcher* subm = data->lookupMatcher(keyChar);
if (subm == 0) {
if (cursor > limit &&
@@ -127,11 +127,11 @@ UMatchDegree StringMatcher::matches(const Replaceable& text,
// without completing our match.
return U_PARTIAL_MATCH;
}
- UChar keyChar = pattern.charAt(i);
+ char16_t keyChar = pattern.charAt(i);
UnicodeMatcher* subm = data->lookupMatcher(keyChar);
if (subm == 0) {
// Don't need the cursor < limit check if
- // incremental is TRUE (because it's done above); do need
+ // incremental is true (because it's done above); do need
// it otherwise.
if (cursor < limit &&
keyChar == text.charAt(cursor)) {
@@ -165,24 +165,24 @@ UnicodeString& StringMatcher::toPattern(UnicodeString& result,
result.truncate(0);
UnicodeString str, quoteBuf;
if (segmentNumber > 0) {
- result.append((UChar)40); /*(*/
+ result.append((char16_t)40); /*(*/
}
for (int32_t i=0; i<pattern.length(); ++i) {
- UChar keyChar = pattern.charAt(i);
+ char16_t keyChar = pattern.charAt(i);
const UnicodeMatcher* m = data->lookupMatcher(keyChar);
if (m == 0) {
- ICU_Utility::appendToRule(result, keyChar, FALSE, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(result, keyChar, false, escapeUnprintable, quoteBuf);
} else {
ICU_Utility::appendToRule(result, m->toPattern(str, escapeUnprintable),
- TRUE, escapeUnprintable, quoteBuf);
+ true, escapeUnprintable, quoteBuf);
}
}
if (segmentNumber > 0) {
- result.append((UChar)41); /*)*/
+ result.append((char16_t)41); /*)*/
}
// Flush quoteBuf out to result
ICU_Utility::appendToRule(result, -1,
- TRUE, escapeUnprintable, quoteBuf);
+ true, escapeUnprintable, quoteBuf);
return result;
}
@@ -191,7 +191,7 @@ UnicodeString& StringMatcher::toPattern(UnicodeString& result,
*/
UBool StringMatcher::matchesIndexValue(uint8_t v) const {
if (pattern.length() == 0) {
- return TRUE;
+ return true;
}
UChar32 c = pattern.char32At(0);
const UnicodeMatcher *m = data->lookupMatcher(c);
@@ -206,7 +206,7 @@ void StringMatcher::addMatchSetTo(UnicodeSet& toUnionTo) const {
for (int32_t i=0; i<pattern.length(); i+=U16_LENGTH(ch)) {
ch = pattern.char32At(i);
const UnicodeMatcher* matcher = data->lookupMatcher(ch);
- if (matcher == NULL) {
+ if (matcher == nullptr) {
toUnionTo.add(ch);
} else {
matcher->addMatchSetTo(toUnionTo);
@@ -247,7 +247,7 @@ UnicodeString& StringMatcher::toReplacerPattern(UnicodeString& rule,
UBool /*escapeUnprintable*/) const {
// assert(segmentNumber > 0);
rule.truncate(0);
- rule.append((UChar)0x0024 /*$*/);
+ rule.append((char16_t)0x0024 /*$*/);
ICU_Utility::appendNumber(rule, segmentNumber, 10, 1);
return rule;
}
@@ -282,7 +282,7 @@ void StringMatcher::setData(const TransliterationRuleData* d) {
while (i<pattern.length()) {
UChar32 c = pattern.char32At(i);
UnicodeFunctor* f = data->lookup(c);
- if (f != NULL) {
+ if (f != nullptr) {
f->setData(data);
}
i += U16_LENGTH(c);
diff --git a/contrib/libs/icu/i18n/strrepl.cpp b/contrib/libs/icu/i18n/strrepl.cpp
index 9fafeb2659..2981553869 100644
--- a/contrib/libs/icu/i18n/strrepl.cpp
+++ b/contrib/libs/icu/i18n/strrepl.cpp
@@ -41,9 +41,9 @@ StringReplacer::StringReplacer(const UnicodeString& theOutput,
const TransliterationRuleData* theData) {
output = theOutput;
cursorPos = theCursorPos;
- hasCursor = TRUE;
+ hasCursor = true;
data = theData;
- isComplex = TRUE;
+ isComplex = true;
}
/**
@@ -59,9 +59,9 @@ StringReplacer::StringReplacer(const UnicodeString& theOutput,
const TransliterationRuleData* theData) {
output = theOutput;
cursorPos = 0;
- hasCursor = FALSE;
+ hasCursor = false;
data = theData;
- isComplex = TRUE;
+ isComplex = true;
}
/**
@@ -131,7 +131,7 @@ int32_t StringReplacer::replace(Replaceable& text,
*/
UnicodeString buf;
int32_t oOutput; // offset into 'output'
- isComplex = FALSE;
+ isComplex = false;
// The temporary buffer starts at tempStart, and extends
// to destLimit. The start of the buffer has a single
@@ -149,7 +149,7 @@ int32_t StringReplacer::replace(Replaceable& text,
text.copy(start-len, start, tempStart);
destStart += len;
} else {
- UnicodeString str((UChar) 0xFFFF);
+ UnicodeString str((char16_t) 0xFFFF);
text.handleReplaceBetween(tempStart, tempStart, str);
destStart++;
}
@@ -162,11 +162,11 @@ int32_t StringReplacer::replace(Replaceable& text,
}
UChar32 c = output.char32At(oOutput);
UnicodeReplacer* r = data->lookupReplacer(c);
- if (r == NULL) {
+ if (r == nullptr) {
// Accumulate straight (non-segment) text.
buf.append(c);
} else {
- isComplex = TRUE;
+ isComplex = true;
// Insert any accumulated straight text.
if (buf.length() > 0) {
@@ -249,27 +249,27 @@ UnicodeString& StringReplacer::toReplacerPattern(UnicodeString& rule,
// Handle a cursor preceding the output
if (hasCursor && cursor < 0) {
while (cursor++ < 0) {
- ICU_Utility::appendToRule(rule, (UChar)0x0040 /*@*/, TRUE, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, (char16_t)0x0040 /*@*/, true, escapeUnprintable, quoteBuf);
}
// Fall through and append '|' below
}
for (int32_t i=0; i<output.length(); ++i) {
if (hasCursor && i == cursor) {
- ICU_Utility::appendToRule(rule, (UChar)0x007C /*|*/, TRUE, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, (char16_t)0x007C /*|*/, true, escapeUnprintable, quoteBuf);
}
- UChar c = output.charAt(i); // Ok to use 16-bits here
+ char16_t c = output.charAt(i); // Ok to use 16-bits here
UnicodeReplacer* r = data->lookupReplacer(c);
- if (r == NULL) {
- ICU_Utility::appendToRule(rule, c, FALSE, escapeUnprintable, quoteBuf);
+ if (r == nullptr) {
+ ICU_Utility::appendToRule(rule, c, false, escapeUnprintable, quoteBuf);
} else {
UnicodeString buf;
r->toReplacerPattern(buf, escapeUnprintable);
- buf.insert(0, (UChar)0x20);
- buf.append((UChar)0x20);
+ buf.insert(0, (char16_t)0x20);
+ buf.append((char16_t)0x20);
ICU_Utility::appendToRule(rule, buf,
- TRUE, escapeUnprintable, quoteBuf);
+ true, escapeUnprintable, quoteBuf);
}
}
@@ -279,13 +279,13 @@ UnicodeString& StringReplacer::toReplacerPattern(UnicodeString& rule,
if (hasCursor && cursor > output.length()) {
cursor -= output.length();
while (cursor-- > 0) {
- ICU_Utility::appendToRule(rule, (UChar)0x0040 /*@*/, TRUE, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, (char16_t)0x0040 /*@*/, true, escapeUnprintable, quoteBuf);
}
- ICU_Utility::appendToRule(rule, (UChar)0x007C /*|*/, TRUE, escapeUnprintable, quoteBuf);
+ ICU_Utility::appendToRule(rule, (char16_t)0x007C /*|*/, true, escapeUnprintable, quoteBuf);
}
// Flush quoteBuf out to result
ICU_Utility::appendToRule(rule, -1,
- TRUE, escapeUnprintable, quoteBuf);
+ true, escapeUnprintable, quoteBuf);
return rule;
}
@@ -298,7 +298,7 @@ void StringReplacer::addReplacementSetTo(UnicodeSet& toUnionTo) const {
for (int32_t i=0; i<output.length(); i+=U16_LENGTH(ch)) {
ch = output.char32At(i);
UnicodeReplacer* r = data->lookupReplacer(ch);
- if (r == NULL) {
+ if (r == nullptr) {
toUnionTo.add(ch);
} else {
r->addReplacementSetTo(toUnionTo);
@@ -315,7 +315,7 @@ void StringReplacer::setData(const TransliterationRuleData* d) {
while (i<output.length()) {
UChar32 c = output.char32At(i);
UnicodeFunctor* f = data->lookup(c);
- if (f != NULL) {
+ if (f != nullptr) {
f->setData(data);
}
i += U16_LENGTH(c);
diff --git a/contrib/libs/icu/i18n/stsearch.cpp b/contrib/libs/icu/i18n/stsearch.cpp
index 1bade8fbd1..395ce1cdc1 100644
--- a/contrib/libs/icu/i18n/stsearch.cpp
+++ b/contrib/libs/icu/i18n/stsearch.cpp
@@ -32,7 +32,7 @@ StringSearch::StringSearch(const UnicodeString &pattern,
m_pattern_(pattern)
{
if (U_FAILURE(status)) {
- m_strsrch_ = NULL;
+ m_strsrch_ = nullptr;
return;
}
@@ -41,7 +41,7 @@ StringSearch::StringSearch(const UnicodeString &pattern,
locale.getName(), (UBreakIterator *)breakiter,
&status);
uprv_free(m_search_);
- m_search_ = NULL;
+ m_search_ = nullptr;
if (U_SUCCESS(status)) {
// m_search_ has been created by the base SearchIterator class
@@ -58,12 +58,12 @@ StringSearch::StringSearch(const UnicodeString &pattern,
m_pattern_(pattern)
{
if (U_FAILURE(status)) {
- m_strsrch_ = NULL;
+ m_strsrch_ = nullptr;
return;
}
- if (coll == NULL) {
+ if (coll == nullptr) {
status = U_ILLEGAL_ARGUMENT_ERROR;
- m_strsrch_ = NULL;
+ m_strsrch_ = nullptr;
return;
}
m_strsrch_ = usearch_openFromCollator(m_pattern_.getBuffer(),
@@ -73,7 +73,7 @@ StringSearch::StringSearch(const UnicodeString &pattern,
(UBreakIterator *)breakiter,
&status);
uprv_free(m_search_);
- m_search_ = NULL;
+ m_search_ = nullptr;
if (U_SUCCESS(status)) {
// m_search_ has been created by the base SearchIterator class
@@ -90,7 +90,7 @@ StringSearch::StringSearch(const UnicodeString &pattern,
m_pattern_(pattern)
{
if (U_FAILURE(status)) {
- m_strsrch_ = NULL;
+ m_strsrch_ = nullptr;
return;
}
m_strsrch_ = usearch_open(m_pattern_.getBuffer(), m_pattern_.length(),
@@ -98,7 +98,7 @@ StringSearch::StringSearch(const UnicodeString &pattern,
locale.getName(), (UBreakIterator *)breakiter,
&status);
uprv_free(m_search_);
- m_search_ = NULL;
+ m_search_ = nullptr;
if (U_SUCCESS(status)) {
// m_search_ has been created by the base SearchIterator class
@@ -115,12 +115,12 @@ StringSearch::StringSearch(const UnicodeString &pattern,
m_pattern_(pattern)
{
if (U_FAILURE(status)) {
- m_strsrch_ = NULL;
+ m_strsrch_ = nullptr;
return;
}
- if (coll == NULL) {
+ if (coll == nullptr) {
status = U_ILLEGAL_ARGUMENT_ERROR;
- m_strsrch_ = NULL;
+ m_strsrch_ = nullptr;
return;
}
m_strsrch_ = usearch_openFromCollator(m_pattern_.getBuffer(),
@@ -130,7 +130,7 @@ StringSearch::StringSearch(const UnicodeString &pattern,
(UBreakIterator *)breakiter,
&status);
uprv_free(m_search_);
- m_search_ = NULL;
+ m_search_ = nullptr;
if (U_SUCCESS(status)) {
// m_search_ has been created by the base SearchIterator class
@@ -146,11 +146,11 @@ StringSearch::StringSearch(const StringSearch &that) :
// Free m_search_ from the superclass
uprv_free(m_search_);
- m_search_ = NULL;
+ m_search_ = nullptr;
- if (that.m_strsrch_ == NULL) {
+ if (that.m_strsrch_ == nullptr) {
// This was not a good copy
- m_strsrch_ = NULL;
+ m_strsrch_ = nullptr;
}
else {
// Make a deep copy
@@ -170,9 +170,9 @@ StringSearch::StringSearch(const StringSearch &that) :
StringSearch::~StringSearch()
{
- if (m_strsrch_ != NULL) {
+ if (m_strsrch_ != nullptr) {
usearch_close(m_strsrch_);
- m_search_ = NULL;
+ m_search_ = nullptr;
}
}
@@ -196,9 +196,9 @@ StringSearch & StringSearch::operator=(const StringSearch &that)
m_text_.getBuffer(),
m_text_.length(),
that.m_strsrch_->collator,
- NULL, &status);
+ nullptr, &status);
// Check null pointer
- if (m_strsrch_ != NULL) {
+ if (m_strsrch_ != nullptr) {
m_search_ = m_strsrch_->search;
}
}
@@ -211,9 +211,10 @@ bool StringSearch::operator==(const SearchIterator &that) const
return true;
}
if (SearchIterator::operator ==(that)) {
- StringSearch &thatsrch = (StringSearch &)that;
- return (this->m_pattern_ == thatsrch.m_pattern_ &&
- this->m_strsrch_->collator == thatsrch.m_strsrch_->collator);
+ const StringSearch *thatsrch = dynamic_cast<const StringSearch *>(&that);
+ if (thatsrch == nullptr) return false;
+ return (this->m_pattern_ == thatsrch->m_pattern_ &&
+ this->m_strsrch_->collator == thatsrch->m_strsrch_->collator);
}
return false;
}
@@ -226,7 +227,7 @@ void StringSearch::setOffset(int32_t position, UErrorCode &status)
usearch_setOffset(m_strsrch_, position, &status);
}
-int32_t StringSearch::getOffset(void) const
+int32_t StringSearch::getOffset() const
{
return usearch_getOffset(m_strsrch_);
}
@@ -289,7 +290,7 @@ StringSearch * StringSearch::safeClone() const
getCollator(),
m_breakiterator_,
status);
- /* test for NULL */
+ /* test for nullptr */
if (result == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return 0;
@@ -298,7 +299,7 @@ StringSearch * StringSearch::safeClone() const
result->setMatchStart(m_strsrch_->search->matchedIndex);
result->setMatchLength(m_strsrch_->search->matchedLength);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
return result;
}
@@ -355,7 +356,7 @@ int32_t StringSearch::handleNext(int32_t position, UErrorCode &status)
if (U_FAILURE(status)) {
return USEARCH_DONE;
}
- if (m_breakiterator_ == NULL
+ if (m_breakiterator_ == nullptr
#if !UCONFIG_NO_BREAK_ITERATION
||
m_search_->matchedIndex == USEARCH_DONE ||
@@ -443,7 +444,7 @@ int32_t StringSearch::handlePrev(int32_t position, UErrorCode &status)
if (U_FAILURE(status)) {
return USEARCH_DONE;
}
- if (m_breakiterator_ == NULL
+ if (m_breakiterator_ == nullptr
#if !UCONFIG_NO_BREAK_ITERATION
||
m_search_->matchedIndex == USEARCH_DONE ||
diff --git a/contrib/libs/icu/i18n/taiwncal.cpp b/contrib/libs/icu/i18n/taiwncal.cpp
index 27352aa10c..48f0b99e18 100644
--- a/contrib/libs/icu/i18n/taiwncal.cpp
+++ b/contrib/libs/icu/i18n/taiwncal.cpp
@@ -140,11 +140,11 @@ void TaiwanCalendar::timeToFields(UDate theTime, UBool quick, UErrorCode& status
*/
static UDate gSystemDefaultCenturyStart = DBL_MIN;
static int32_t gSystemDefaultCenturyStartYear = -1;
-static icu::UInitOnce gSystemDefaultCenturyInit = U_INITONCE_INITIALIZER;
+static icu::UInitOnce gSystemDefaultCenturyInit {};
UBool TaiwanCalendar::haveDefaultCentury() const
{
- return TRUE;
+ return true;
}
static void U_CALLCONV initializeSystemDefaultCentury()
diff --git a/contrib/libs/icu/i18n/taiwncal.h b/contrib/libs/icu/i18n/taiwncal.h
index ab6b6aff09..b0a30f9108 100644
--- a/contrib/libs/icu/i18n/taiwncal.h
+++ b/contrib/libs/icu/i18n/taiwncal.h
@@ -104,7 +104,7 @@ public:
* same class ID. Objects of other classes have different class IDs.
* @internal
*/
- virtual UClassID getDynamicClassID(void) const override;
+ virtual UClassID getDynamicClassID() const override;
/**
* Return the class ID for this class. This is useful only for comparing to a return
@@ -117,7 +117,7 @@ public:
* @return The class ID for all objects of this class.
* @internal
*/
- U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
+ U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
/**
* return the calendar type, "Taiwan".
diff --git a/contrib/libs/icu/i18n/timezone.cpp b/contrib/libs/icu/i18n/timezone.cpp
index 8115a45e0a..75479267d7 100644
--- a/contrib/libs/icu/i18n/timezone.cpp
+++ b/contrib/libs/icu/i18n/timezone.cpp
@@ -105,15 +105,15 @@ static char gStrBuf[256];
// Static data and constants
-static const UChar WORLD[] = {0x30, 0x30, 0x31, 0x00}; /* "001" */
+static const char16_t WORLD[] = {0x30, 0x30, 0x31, 0x00}; /* "001" */
-static const UChar GMT_ID[] = {0x47, 0x4D, 0x54, 0x00}; /* "GMT" */
-static const UChar UNKNOWN_ZONE_ID[] = {0x45, 0x74, 0x63, 0x2F, 0x55, 0x6E, 0x6B, 0x6E, 0x6F, 0x77, 0x6E, 0x00}; /* "Etc/Unknown" */
+static const char16_t GMT_ID[] = {0x47, 0x4D, 0x54, 0x00}; /* "GMT" */
+static const char16_t UNKNOWN_ZONE_ID[] = {0x45, 0x74, 0x63, 0x2F, 0x55, 0x6E, 0x6B, 0x6E, 0x6F, 0x77, 0x6E, 0x00}; /* "Etc/Unknown" */
static const int32_t GMT_ID_LENGTH = 3;
static const int32_t UNKNOWN_ZONE_ID_LENGTH = 11;
-static icu::TimeZone* DEFAULT_ZONE = NULL;
-static icu::UInitOnce gDefaultZoneInitOnce = U_INITONCE_INITIALIZER;
+static icu::TimeZone* DEFAULT_ZONE = nullptr;
+static icu::UInitOnce gDefaultZoneInitOnce {};
alignas(icu::SimpleTimeZone)
static char gRawGMT[sizeof(icu::SimpleTimeZone)];
@@ -121,36 +121,36 @@ static char gRawGMT[sizeof(icu::SimpleTimeZone)];
alignas(icu::SimpleTimeZone)
static char gRawUNKNOWN[sizeof(icu::SimpleTimeZone)];
-static icu::UInitOnce gStaticZonesInitOnce = U_INITONCE_INITIALIZER;
-static UBool gStaticZonesInitialized = FALSE; // Whether the static zones are initialized and ready to use.
+static icu::UInitOnce gStaticZonesInitOnce {};
+static UBool gStaticZonesInitialized = false; // Whether the static zones are initialized and ready to use.
static char TZDATA_VERSION[16];
-static icu::UInitOnce gTZDataVersionInitOnce = U_INITONCE_INITIALIZER;
+static icu::UInitOnce gTZDataVersionInitOnce {};
-static int32_t* MAP_SYSTEM_ZONES = NULL;
-static int32_t* MAP_CANONICAL_SYSTEM_ZONES = NULL;
-static int32_t* MAP_CANONICAL_SYSTEM_LOCATION_ZONES = NULL;
+static int32_t* MAP_SYSTEM_ZONES = nullptr;
+static int32_t* MAP_CANONICAL_SYSTEM_ZONES = nullptr;
+static int32_t* MAP_CANONICAL_SYSTEM_LOCATION_ZONES = nullptr;
static int32_t LEN_SYSTEM_ZONES = 0;
static int32_t LEN_CANONICAL_SYSTEM_ZONES = 0;
static int32_t LEN_CANONICAL_SYSTEM_LOCATION_ZONES = 0;
-static icu::UInitOnce gSystemZonesInitOnce = U_INITONCE_INITIALIZER;
-static icu::UInitOnce gCanonicalZonesInitOnce = U_INITONCE_INITIALIZER;
-static icu::UInitOnce gCanonicalLocationZonesInitOnce = U_INITONCE_INITIALIZER;
+static icu::UInitOnce gSystemZonesInitOnce {};
+static icu::UInitOnce gCanonicalZonesInitOnce {};
+static icu::UInitOnce gCanonicalLocationZonesInitOnce {};
U_CDECL_BEGIN
-static UBool U_CALLCONV timeZone_cleanup(void)
+static UBool U_CALLCONV timeZone_cleanup()
{
U_NAMESPACE_USE
delete DEFAULT_ZONE;
- DEFAULT_ZONE = NULL;
+ DEFAULT_ZONE = nullptr;
gDefaultZoneInitOnce.reset();
if (gStaticZonesInitialized) {
reinterpret_cast<SimpleTimeZone*>(gRawGMT)->~SimpleTimeZone();
reinterpret_cast<SimpleTimeZone*>(gRawUNKNOWN)->~SimpleTimeZone();
- gStaticZonesInitialized = FALSE;
+ gStaticZonesInitialized = false;
gStaticZonesInitOnce.reset();
}
@@ -172,7 +172,7 @@ static UBool U_CALLCONV timeZone_cleanup(void)
MAP_CANONICAL_SYSTEM_LOCATION_ZONES = 0;
gCanonicalLocationZonesInitOnce.reset();
- return TRUE;
+ return true;
}
U_CDECL_END
@@ -181,7 +181,7 @@ U_NAMESPACE_BEGIN
static int32_t findInStringArray(UResourceBundle* array, const UnicodeString& id, UErrorCode &status)
{
UnicodeString copy;
- const UChar *u;
+ const char16_t *u;
int32_t len;
int32_t start = 0;
@@ -204,7 +204,7 @@ static int32_t findInStringArray(UResourceBundle* array, const UnicodeString& id
break;
}
U_DEBUG_TZ_MSG(("tz: compare to %s, %d .. [%d] .. %d\n", U_DEBUG_TZ_STR(u), start, mid, limit));
- copy.setTo(TRUE, u, len);
+ copy.setTo(true, u, len);
int r = id.compare(copy);
if(r==0) {
U_DEBUG_TZ_MSG(("fisa: found at %d\n", mid));
@@ -223,12 +223,12 @@ static int32_t findInStringArray(UResourceBundle* array, const UnicodeString& id
* Fetch a specific zone by name. Replaces the getByKey call.
* @param top Top timezone resource
* @param id Time zone ID
- * @param oldbundle Bundle for reuse (or NULL). see 'ures_open()'
+ * @param oldbundle Bundle for reuse (or nullptr). see 'ures_open()'
* @return the zone's bundle if found, or undefined if error. Reuses oldbundle.
*/
static UResourceBundle* getZoneByName(const UResourceBundle* top, const UnicodeString& id, UResourceBundle *oldbundle, UErrorCode& status) {
// load the Rules object
- UResourceBundle *tmp = ures_getByKey(top, kNAMES, NULL, &status);
+ UResourceBundle *tmp = ures_getByKey(top, kNAMES, nullptr, &status);
// search for the string
int32_t idx = findInStringArray(tmp, id, status);
@@ -237,7 +237,7 @@ static UResourceBundle* getZoneByName(const UResourceBundle* top, const UnicodeS
// not found
status = U_MISSING_RESOURCE_ERROR;
//ures_close(oldbundle);
- //oldbundle = NULL;
+ //oldbundle = nullptr;
} else {
U_DEBUG_TZ_MSG(("gzbn: oldbundle= size %d, type %d, %s\n", ures_getSize(tmp), ures_getType(tmp), u_errorName(status)));
tmp = ures_getByKey(top, kZONES, tmp, &status); // get Zones object from top
@@ -248,7 +248,7 @@ static UResourceBundle* getZoneByName(const UResourceBundle* top, const UnicodeS
ures_close(tmp);
if(U_FAILURE(status)) {
//ures_close(oldbundle);
- return NULL;
+ return nullptr;
} else {
return oldbundle;
}
@@ -291,7 +291,7 @@ static UResourceBundle* openOlsonResource(const UnicodeString& id,
if (ures_getType(&res) == URES_INT) {
int32_t deref = ures_getInt(&res, &ec) + 0;
U_DEBUG_TZ_MSG(("getInt: %s - type is %d\n", u_errorName(ec), ures_getType(&res)));
- UResourceBundle *ares = ures_getByKey(top, kZONES, NULL, &ec); // dereference Zones section
+ UResourceBundle *ares = ures_getByKey(top, kZONES, nullptr, &ec); // dereference Zones section
ures_getByIndex(ares, deref, &res, &ec);
ures_close(ares);
U_DEBUG_TZ_MSG(("alias to #%d (%s) - %s\n", deref, "??", u_errorName(ec)));
@@ -312,10 +312,10 @@ void U_CALLCONV initStaticTimeZones() {
ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONE, timeZone_cleanup);
// new can't fail below, as we use placement new into statically allocated space.
- new(gRawGMT) SimpleTimeZone(0, UnicodeString(TRUE, GMT_ID, GMT_ID_LENGTH));
- new(gRawUNKNOWN) SimpleTimeZone(0, UnicodeString(TRUE, UNKNOWN_ZONE_ID, UNKNOWN_ZONE_ID_LENGTH));
+ new(gRawGMT) SimpleTimeZone(0, UnicodeString(true, GMT_ID, GMT_ID_LENGTH));
+ new(gRawUNKNOWN) SimpleTimeZone(0, UnicodeString(true, UNKNOWN_ZONE_ID, UNKNOWN_ZONE_ID_LENGTH));
- gStaticZonesInitialized = TRUE;
+ gStaticZonesInitialized = true;
}
} // anonymous namespace
@@ -328,7 +328,7 @@ TimeZone::getUnknown()
}
const TimeZone* U_EXPORT2
-TimeZone::getGMT(void)
+TimeZone::getGMT()
{
umtx_initOnce(gStaticZonesInitOnce, &initStaticTimeZones);
return reinterpret_cast<SimpleTimeZone*>(gRawGMT);
@@ -389,7 +389,7 @@ namespace {
TimeZone*
createSystemTimeZone(const UnicodeString& id, UErrorCode& ec) {
if (U_FAILURE(ec)) {
- return NULL;
+ return nullptr;
}
TimeZone* z = 0;
StackUResourceBundle res;
@@ -398,7 +398,7 @@ createSystemTimeZone(const UnicodeString& id, UErrorCode& ec) {
U_DEBUG_TZ_MSG(("post-err=%s\n", u_errorName(ec)));
if (U_SUCCESS(ec)) {
z = new OlsonTimeZone(top, res.getAlias(), id, ec);
- if (z == NULL) {
+ if (z == nullptr) {
ec = U_MEMORY_ALLOCATION_ERROR;
U_DEBUG_TZ_MSG(("cstz: olson time zone failed to initialize - err %s\n", u_errorName(ec)));
}
@@ -407,7 +407,7 @@ createSystemTimeZone(const UnicodeString& id, UErrorCode& ec) {
if (U_FAILURE(ec)) {
U_DEBUG_TZ_MSG(("cstz: failed to create, err %s\n", u_errorName(ec)));
delete z;
- z = NULL;
+ z = nullptr;
}
return z;
}
@@ -433,16 +433,16 @@ TimeZone::createTimeZone(const UnicodeString& ID)
* all else fails, we return GMT, which is probably not what the
* user wants, but at least is a functioning TimeZone object.
*
- * We cannot return NULL, because that would break compatibility
+ * We cannot return nullptr, because that would break compatibility
* with the JDK.
*/
TimeZone* result = createSystemTimeZone(ID);
- if (result == NULL) {
+ if (result == nullptr) {
U_DEBUG_TZ_MSG(("failed to load system time zone with id - falling to custom"));
result = createCustomTimeZone(ID);
}
- if (result == NULL) {
+ if (result == nullptr) {
U_DEBUG_TZ_MSG(("failed to load time zone with id - falling to Etc/Unknown(GMT)"));
const TimeZone& unknown = getUnknown();
// Unknown zone uses statically allocated memory, so creation of it can never fail due to OOM.
@@ -460,7 +460,7 @@ TimeZone::detectHostTimeZone()
// which have platform specific implementations in putil.cpp
int32_t rawOffset = 0;
const char *hostID;
- UBool hostDetectionSucceeded = TRUE;
+ UBool hostDetectionSucceeded = true;
// First, try to create a system timezone, based
// on the string ID in tzname[0].
@@ -477,15 +477,15 @@ TimeZone::detectHostTimeZone()
// Invert sign because UNIX semantics are backwards
rawOffset = uprv_timezone() * -U_MILLIS_PER_SECOND;
- TimeZone* hostZone = NULL;
+ TimeZone* hostZone = nullptr;
UnicodeString hostStrID(hostID, -1, US_INV);
if (hostStrID.length() == 0) {
// The host time zone detection (or remapping) above has failed and
// we have no name at all. Fallback to using the Unknown zone.
- hostStrID = UnicodeString(TRUE, UNKNOWN_ZONE_ID, UNKNOWN_ZONE_ID_LENGTH);
- hostDetectionSucceeded = FALSE;
+ hostStrID = UnicodeString(true, UNKNOWN_ZONE_ID, UNKNOWN_ZONE_ID_LENGTH);
+ hostDetectionSucceeded = false;
}
hostZone = createSystemTimeZone(hostStrID);
@@ -496,18 +496,18 @@ TimeZone::detectHostTimeZone()
#endif
int32_t hostIDLen = hostStrID.length();
- if (hostZone != NULL && rawOffset != hostZone->getRawOffset()
+ if (hostZone != nullptr && rawOffset != hostZone->getRawOffset()
&& (3 <= hostIDLen && hostIDLen <= 4))
{
// Uh oh. This probably wasn't a good id.
// It was probably an ambiguous abbreviation
delete hostZone;
- hostZone = NULL;
+ hostZone = nullptr;
}
// Construct a fixed standard zone with the host's ID
// and raw offset.
- if (hostZone == NULL && hostDetectionSucceeded) {
+ if (hostZone == nullptr && hostDetectionSucceeded) {
hostZone = new SimpleTimeZone(rawOffset, hostStrID);
}
@@ -516,7 +516,7 @@ TimeZone::detectHostTimeZone()
// Note: This is extremely unlikely situation. If
// new SimpleTimeZone(...) above fails, the following
// code may also fail.
- if (hostZone == NULL) {
+ if (hostZone == nullptr) {
// Unknown zone uses static allocated memory, so it must always exist.
// However, clone() allocates memory and can fail.
hostZone = TimeZone::getUnknown().clone();
@@ -531,8 +531,8 @@ static UMutex gDefaultZoneMutex;
/**
* Initialize DEFAULT_ZONE from the system default time zone.
- * Upon return, DEFAULT_ZONE will not be NULL, unless operator new()
- * returns NULL.
+ * Upon return, DEFAULT_ZONE will not be nullptr, unless operator new()
+ * returns nullptr.
*/
static void U_CALLCONV initDefault()
{
@@ -541,7 +541,7 @@ static void U_CALLCONV initDefault()
Mutex lock(&gDefaultZoneMutex);
// If setDefault() has already been called we can skip getting the
// default zone information from the system.
- if (DEFAULT_ZONE != NULL) {
+ if (DEFAULT_ZONE != nullptr) {
return;
}
@@ -560,7 +560,7 @@ static void U_CALLCONV initDefault()
TimeZone *default_zone = TimeZone::detectHostTimeZone();
- U_ASSERT(DEFAULT_ZONE == NULL);
+ U_ASSERT(DEFAULT_ZONE == nullptr);
DEFAULT_ZONE = default_zone;
}
@@ -573,7 +573,7 @@ TimeZone::createDefault()
umtx_initOnce(gDefaultZoneInitOnce, initDefault);
{
Mutex lock(&gDefaultZoneMutex);
- return (DEFAULT_ZONE != NULL) ? DEFAULT_ZONE->clone() : NULL;
+ return (DEFAULT_ZONE != nullptr) ? DEFAULT_ZONE->clone() : nullptr;
}
}
@@ -600,7 +600,7 @@ TimeZone::forLocaleOrDefault(const Locale& locale)
void U_EXPORT2
TimeZone::adoptDefault(TimeZone* zone)
{
- if (zone != NULL)
+ if (zone != nullptr)
{
{
Mutex lock(&gDefaultZoneMutex);
@@ -630,7 +630,7 @@ static void U_CALLCONV initMap(USystemTimeZoneType type, UErrorCode& ec) {
if (U_SUCCESS(ec)) {
int32_t size = ures_getSize(res);
int32_t *m = (int32_t *)uprv_malloc(size * sizeof(int32_t));
- if (m == NULL) {
+ if (m == nullptr) {
ec = U_MEMORY_ALLOCATION_ERROR;
} else {
int32_t numEntries = 0;
@@ -655,7 +655,7 @@ static void U_CALLCONV initMap(USystemTimeZoneType type, UErrorCode& ec) {
}
}
if (type == UCAL_ZONE_TYPE_CANONICAL_LOCATION) {
- const UChar *region = TimeZone::getRegion(id, ec);
+ const char16_t *region = TimeZone::getRegion(id, ec);
if (U_FAILURE(ec)) {
break;
}
@@ -669,7 +669,7 @@ static void U_CALLCONV initMap(USystemTimeZoneType type, UErrorCode& ec) {
if (U_SUCCESS(ec)) {
int32_t *tmp = m;
m = (int32_t *)uprv_realloc(tmp, numEntries * sizeof(int32_t));
- if (m == NULL) {
+ if (m == nullptr) {
// realloc failed.. use the original one even it has unused
// area at the end
m = tmp;
@@ -677,17 +677,17 @@ static void U_CALLCONV initMap(USystemTimeZoneType type, UErrorCode& ec) {
switch(type) {
case UCAL_ZONE_TYPE_ANY:
- U_ASSERT(MAP_SYSTEM_ZONES == NULL);
+ U_ASSERT(MAP_SYSTEM_ZONES == nullptr);
MAP_SYSTEM_ZONES = m;
LEN_SYSTEM_ZONES = numEntries;
break;
case UCAL_ZONE_TYPE_CANONICAL:
- U_ASSERT(MAP_CANONICAL_SYSTEM_ZONES == NULL);
+ U_ASSERT(MAP_CANONICAL_SYSTEM_ZONES == nullptr);
MAP_CANONICAL_SYSTEM_ZONES = m;
LEN_CANONICAL_SYSTEM_ZONES = numEntries;
break;
case UCAL_ZONE_TYPE_CANONICAL_LOCATION:
- U_ASSERT(MAP_CANONICAL_SYSTEM_LOCATION_ZONES == NULL);
+ U_ASSERT(MAP_CANONICAL_SYSTEM_LOCATION_ZONES == nullptr);
MAP_CANONICAL_SYSTEM_LOCATION_ZONES = m;
LEN_CANONICAL_SYSTEM_LOCATION_ZONES = numEntries;
break;
@@ -716,12 +716,12 @@ void TimeZone::getOffset(UDate date, UBool local, int32_t& rawOffset,
date += rawOffset; // now in local standard millis
}
- // When local == TRUE, date might not be in local standard
+ // When local == true, date might not be in local standard
// millis. getOffset taking 7 parameters used here assume
// the given time in day is local standard time.
// At STD->DST transition, there is a range of time which
// does not exist. When 'date' is in this time range
- // (and local == TRUE), this method interprets the specified
+ // (and local == true), this method interprets the specified
// local time as DST. At DST->STD transition, there is a
// range of time which occurs twice. In this case, this
// method interprets the specified local time as STD.
@@ -729,9 +729,8 @@ void TimeZone::getOffset(UDate date, UBool local, int32_t& rawOffset,
// (with 7 args) twice when local == true and DST is
// detected in the initial call.
for (int32_t pass=0; ; ++pass) {
- int32_t year, month, dom, dow;
- double day = uprv_floor(date / U_MILLIS_PER_DAY);
- int32_t millis = (int32_t) (date - day * U_MILLIS_PER_DAY);
+ int32_t year, month, dom, dow, millis;
+ double day = ClockMath::floorDivide(date, U_MILLIS_PER_DAY, &millis);
Grego::dayToFields(day, year, month, dom, dow);
@@ -740,7 +739,7 @@ void TimeZone::getOffset(UDate date, UBool local, int32_t& rawOffset,
Grego::monthLength(year, month),
ec) - rawOffset;
- // Recompute if local==TRUE, dstOffset!=0.
+ // Recompute if local==true, dstOffset!=0.
if (pass!=0 || !local || dstOffset == 0) {
break;
}
@@ -757,7 +756,7 @@ class TZEnumeration : public StringEnumeration {
private:
// Map into to zones. Our results are zone[map[i]] for
- // i=0..len-1, where zone[i] is the i-th Olson zone. If map==NULL
+ // i=0..len-1, where zone[i] is the i-th Olson zone. If map==nullptr
// then our results are zone[i] for i=0..len-1. Len will be zero
// if the zone data could not be loaded.
int32_t* map;
@@ -767,13 +766,13 @@ private:
TZEnumeration(int32_t* mapData, int32_t mapLen, UBool adoptMapData) : pos(0) {
map = mapData;
- localMap = adoptMapData ? mapData : NULL;
+ localMap = adoptMapData ? mapData : nullptr;
len = mapLen;
}
UBool getID(int32_t i, UErrorCode& ec) {
int32_t idLen = 0;
- const UChar* id = NULL;
+ const char16_t* id = nullptr;
UResourceBundle *top = ures_openDirect(0, kZONEINFO, &ec);
top = ures_getByKey(top, kNAMES, top, &ec); // dereference Zones section
id = ures_getStringByIndex(top, i, &idLen, &ec);
@@ -781,7 +780,7 @@ private:
unistr.truncate(0);
}
else {
- unistr.fastCopyFrom(UnicodeString(TRUE, id, idLen));
+ unistr.fastCopyFrom(UnicodeString(true, id, idLen));
}
ures_close(top);
return U_SUCCESS(ec);
@@ -790,9 +789,9 @@ private:
static int32_t* getMap(USystemTimeZoneType type, int32_t& len, UErrorCode& ec) {
len = 0;
if (U_FAILURE(ec)) {
- return NULL;
+ return nullptr;
}
- int32_t* m = NULL;
+ int32_t* m = nullptr;
switch (type) {
case UCAL_ZONE_TYPE_ANY:
umtx_initOnce(gSystemZonesInitOnce, &initMap, type, ec);
@@ -811,7 +810,7 @@ private:
break;
default:
ec = U_ILLEGAL_ARGUMENT_ERROR;
- m = NULL;
+ m = nullptr;
len = 0;
break;
}
@@ -825,28 +824,28 @@ public:
static TZEnumeration* create(USystemTimeZoneType type, const char* region, const int32_t* rawOffset, UErrorCode& ec) {
if (U_FAILURE(ec)) {
- return NULL;
+ return nullptr;
}
int32_t baseLen;
int32_t *baseMap = getMap(type, baseLen, ec);
if (U_FAILURE(ec)) {
- return NULL;
+ return nullptr;
}
// If any additional conditions are available,
// create instance local map filtered by the conditions.
- int32_t *filteredMap = NULL;
+ int32_t *filteredMap = nullptr;
int32_t numEntries = 0;
- if (region != NULL || rawOffset != NULL) {
+ if (region != nullptr || rawOffset != nullptr) {
int32_t filteredMapSize = DEFAULT_FILTERED_MAP_SIZE;
filteredMap = (int32_t *)uprv_malloc(filteredMapSize * sizeof(int32_t));
- if (filteredMap == NULL) {
+ if (filteredMap == nullptr) {
ec = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
// Walk through the base map
@@ -858,7 +857,7 @@ public:
if (U_FAILURE(ec)) {
break;
}
- if (region != NULL) {
+ if (region != nullptr) {
// Filter by region
char tzregion[4]; // max 3 letters + null term
TimeZone::getRegion(id, tzregion, sizeof(tzregion), ec);
@@ -870,7 +869,7 @@ public:
continue;
}
}
- if (rawOffset != NULL) {
+ if (rawOffset != nullptr) {
// Filter by raw offset
// Note: This is VERY inefficient
TimeZone *z = createSystemTimeZone(id, ec);
@@ -888,7 +887,7 @@ public:
if (filteredMapSize <= numEntries) {
filteredMapSize += MAP_INCREMENT_SIZE;
int32_t *tmp = (int32_t *)uprv_realloc(filteredMap, filteredMapSize * sizeof(int32_t));
- if (tmp == NULL) {
+ if (tmp == nullptr) {
ec = U_MEMORY_ALLOCATION_ERROR;
break;
} else {
@@ -901,37 +900,37 @@ public:
if (U_FAILURE(ec)) {
uprv_free(filteredMap);
- filteredMap = NULL;
+ filteredMap = nullptr;
}
ures_close(res);
}
- TZEnumeration *result = NULL;
+ TZEnumeration *result = nullptr;
if (U_SUCCESS(ec)) {
// Finally, create a new enumeration instance
- if (filteredMap == NULL) {
- result = new TZEnumeration(baseMap, baseLen, FALSE);
+ if (filteredMap == nullptr) {
+ result = new TZEnumeration(baseMap, baseLen, false);
} else {
- result = new TZEnumeration(filteredMap, numEntries, TRUE);
- filteredMap = NULL;
+ result = new TZEnumeration(filteredMap, numEntries, true);
+ filteredMap = nullptr;
}
- if (result == NULL) {
+ if (result == nullptr) {
ec = U_MEMORY_ALLOCATION_ERROR;
}
}
- if (filteredMap != NULL) {
+ if (filteredMap != nullptr) {
uprv_free(filteredMap);
}
return result;
}
- TZEnumeration(const TZEnumeration &other) : StringEnumeration(), map(NULL), localMap(NULL), len(0), pos(0) {
- if (other.localMap != NULL) {
+ TZEnumeration(const TZEnumeration &other) : StringEnumeration(), map(nullptr), localMap(nullptr), len(0), pos(0) {
+ if (other.localMap != nullptr) {
localMap = (int32_t *)uprv_malloc(other.len * sizeof(int32_t));
- if (localMap != NULL) {
+ if (localMap != nullptr) {
len = other.len;
uprv_memcpy(localMap, other.localMap, len * sizeof(int32_t));
pos = other.pos;
@@ -939,11 +938,11 @@ public:
} else {
len = 0;
pos = 0;
- map = NULL;
+ map = nullptr;
}
} else {
map = other.map;
- localMap = NULL;
+ localMap = nullptr;
len = other.len;
pos = other.pos;
}
@@ -960,7 +959,7 @@ public:
}
virtual const UnicodeString* snext(UErrorCode& status) override {
- if (U_SUCCESS(status) && map != NULL && pos < len) {
+ if (U_SUCCESS(status) && map != nullptr && pos < len) {
getID(map[pos], status);
++pos;
return &unistr;
@@ -973,12 +972,12 @@ public:
}
public:
- static UClassID U_EXPORT2 getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID U_EXPORT2 getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
};
TZEnumeration::~TZEnumeration() {
- if (localMap != NULL) {
+ if (localMap != nullptr) {
uprv_free(localMap);
}
}
@@ -996,17 +995,17 @@ TimeZone::createTimeZoneIDEnumeration(
StringEnumeration* U_EXPORT2
TimeZone::createEnumeration(UErrorCode& status) {
- return TZEnumeration::create(UCAL_ZONE_TYPE_ANY, NULL, NULL, status);
+ return TZEnumeration::create(UCAL_ZONE_TYPE_ANY, nullptr, nullptr, status);
}
StringEnumeration* U_EXPORT2
TimeZone::createEnumerationForRawOffset(int32_t rawOffset, UErrorCode& status) {
- return TZEnumeration::create(UCAL_ZONE_TYPE_ANY, NULL, &rawOffset, status);
+ return TZEnumeration::create(UCAL_ZONE_TYPE_ANY, nullptr, &rawOffset, status);
}
StringEnumeration* U_EXPORT2
TimeZone::createEnumerationForRegion(const char* region, UErrorCode& status) {
- return TZEnumeration::create(UCAL_ZONE_TYPE_ANY, region, NULL, status);
+ return TZEnumeration::create(UCAL_ZONE_TYPE_ANY, region, nullptr, status);
}
//
@@ -1071,11 +1070,11 @@ TimeZone::getEquivalentID(const UnicodeString& id, int32_t index) {
}
}
if (zone >= 0) {
- UResourceBundle *ares = ures_getByKey(top, kNAMES, NULL, &ec); // dereference Zones section
+ UResourceBundle *ares = ures_getByKey(top, kNAMES, nullptr, &ec); // dereference Zones section
if (U_SUCCESS(ec)) {
int32_t idLen = 0;
- const UChar* id2 = ures_getStringByIndex(ares, zone, &idLen, &ec);
- result.fastCopyFrom(UnicodeString(TRUE, id2, idLen));
+ const char16_t* id2 = ures_getStringByIndex(ares, zone, &idLen, &ec);
+ result.fastCopyFrom(UnicodeString(true, id2, idLen));
U_DEBUG_TZ_MSG(("gei(%d) -> %d, len%d, %s\n", index, zone, result.length(), u_errorName(ec)));
}
ures_close(ares);
@@ -1093,18 +1092,18 @@ TimeZone::getEquivalentID(const UnicodeString& id, int32_t index) {
// These methods are used by ZoneMeta class only.
-const UChar*
+const char16_t*
TimeZone::findID(const UnicodeString& id) {
- const UChar *result = NULL;
+ const char16_t *result = nullptr;
UErrorCode ec = U_ZERO_ERROR;
- UResourceBundle *rb = ures_openDirect(NULL, kZONEINFO, &ec);
+ UResourceBundle *rb = ures_openDirect(nullptr, kZONEINFO, &ec);
// resolve zone index by name
- UResourceBundle *names = ures_getByKey(rb, kNAMES, NULL, &ec);
+ UResourceBundle *names = ures_getByKey(rb, kNAMES, nullptr, &ec);
int32_t idx = findInStringArray(names, id, ec);
- result = ures_getStringByIndex(names, idx, NULL, &ec);
+ result = ures_getStringByIndex(names, idx, nullptr, &ec);
if (U_FAILURE(ec)) {
- result = NULL;
+ result = nullptr;
}
ures_close(names);
ures_close(rb);
@@ -1112,16 +1111,16 @@ TimeZone::findID(const UnicodeString& id) {
}
-const UChar*
+const char16_t*
TimeZone::dereferOlsonLink(const UnicodeString& id) {
- const UChar *result = NULL;
+ const char16_t *result = nullptr;
UErrorCode ec = U_ZERO_ERROR;
- UResourceBundle *rb = ures_openDirect(NULL, kZONEINFO, &ec);
+ UResourceBundle *rb = ures_openDirect(nullptr, kZONEINFO, &ec);
// resolve zone index by name
- UResourceBundle *names = ures_getByKey(rb, kNAMES, NULL, &ec);
+ UResourceBundle *names = ures_getByKey(rb, kNAMES, nullptr, &ec);
int32_t idx = findInStringArray(names, id, ec);
- result = ures_getStringByIndex(names, idx, NULL, &ec);
+ result = ures_getStringByIndex(names, idx, nullptr, &ec);
// open the zone bundle by index
ures_getByKey(rb, kZONES, rb, &ec);
@@ -1131,7 +1130,7 @@ TimeZone::dereferOlsonLink(const UnicodeString& id) {
if (ures_getType(rb) == URES_INT) {
// this is a link - dereference the link
int32_t deref = ures_getInt(rb, &ec);
- const UChar* tmp = ures_getStringByIndex(names, deref, NULL, &ec);
+ const char16_t* tmp = ures_getStringByIndex(names, deref, nullptr, &ec);
if (U_SUCCESS(ec)) {
result = tmp;
}
@@ -1144,27 +1143,27 @@ TimeZone::dereferOlsonLink(const UnicodeString& id) {
return result;
}
-const UChar*
+const char16_t*
TimeZone::getRegion(const UnicodeString& id) {
UErrorCode status = U_ZERO_ERROR;
return getRegion(id, status);
}
-const UChar*
+const char16_t*
TimeZone::getRegion(const UnicodeString& id, UErrorCode& status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
- const UChar *result = NULL;
- UResourceBundle *rb = ures_openDirect(NULL, kZONEINFO, &status);
+ const char16_t *result = nullptr;
+ UResourceBundle *rb = ures_openDirect(nullptr, kZONEINFO, &status);
// resolve zone index by name
- UResourceBundle *res = ures_getByKey(rb, kNAMES, NULL, &status);
+ UResourceBundle *res = ures_getByKey(rb, kNAMES, nullptr, &status);
int32_t idx = findInStringArray(res, id, status);
// get region mapping
ures_getByKey(rb, kREGIONS, res, &status);
- const UChar *tmp = ures_getStringByIndex(res, idx, NULL, &status);
+ const char16_t *tmp = ures_getStringByIndex(res, idx, nullptr, &status);
if (U_SUCCESS(status)) {
result = tmp;
}
@@ -1186,13 +1185,13 @@ TimeZone::getRegion(const UnicodeString& id, char *region, int32_t capacity, UEr
return 0;
}
- const UChar *uregion = NULL;
+ const char16_t *uregion = nullptr;
// "Etc/Unknown" is not a system zone ID,
// but in the zone data
if (id.compare(UNKNOWN_ZONE_ID, UNKNOWN_ZONE_ID_LENGTH) != 0) {
uregion = getRegion(id);
}
- if (uregion == NULL) {
+ if (uregion == nullptr) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -1214,13 +1213,13 @@ TimeZone::getRegion(const UnicodeString& id, char *region, int32_t capacity, UEr
UnicodeString&
TimeZone::getDisplayName(UnicodeString& result) const
{
- return getDisplayName(FALSE,LONG,Locale::getDefault(), result);
+ return getDisplayName(false,LONG,Locale::getDefault(), result);
}
UnicodeString&
TimeZone::getDisplayName(const Locale& locale, UnicodeString& result) const
{
- return getDisplayName(FALSE, LONG, locale, result);
+ return getDisplayName(false, LONG, locale, result);
}
UnicodeString&
@@ -1288,7 +1287,7 @@ TimeZone::getDisplayName(UBool inDaylight, EDisplayType style, const Locale& loc
tzfmt->formatOffsetLocalizedGMT(offset, result, status);
break;
case SHORT_GMT:
- tzfmt->formatOffsetISO8601Basic(offset, FALSE, FALSE, FALSE, result, status);
+ tzfmt->formatOffsetISO8601Basic(offset, false, false, false, result, status);
break;
default:
UPRV_UNREACHABLE_EXIT;
@@ -1349,7 +1348,7 @@ TimeZone::createCustomTimeZone(const UnicodeString& id)
int32_t offset = sign * ((hour * 60 + min) * 60 + sec) * 1000;
return new SimpleTimeZone(offset, customID);
}
- return NULL;
+ return nullptr;
}
UnicodeString&
@@ -1388,17 +1387,17 @@ TimeZone::parseCustomID(const UnicodeString& id, int32_t& sign,
if (id[pos.getIndex()] == MINUS /*'-'*/) {
sign = -1;
} else if (id[pos.getIndex()] != PLUS /*'+'*/) {
- return FALSE;
+ return false;
}
pos.setIndex(pos.getIndex() + 1);
UErrorCode success = U_ZERO_ERROR;
numberFormat = NumberFormat::createInstance(success);
if(U_FAILURE(success)){
- return FALSE;
+ return false;
}
- numberFormat->setParseIntegerOnly(TRUE);
- //numberFormat->setLenient(TRUE); // TODO: May need to set this, depends on latest timezone parsing
+ numberFormat->setParseIntegerOnly(true);
+ //numberFormat->setLenient(true); // TODO: May need to set this, depends on latest timezone parsing
// Look for either hh:mm, hhmm, or hh
int32_t start = pos.getIndex();
@@ -1406,7 +1405,7 @@ TimeZone::parseCustomID(const UnicodeString& id, int32_t& sign,
numberFormat->parse(id, n, pos);
if (pos.getIndex() == start) {
delete numberFormat;
- return FALSE;
+ return false;
}
hour = n.getLong();
@@ -1414,7 +1413,7 @@ TimeZone::parseCustomID(const UnicodeString& id, int32_t& sign,
if (pos.getIndex() - start > 2
|| id[pos.getIndex()] != COLON) {
delete numberFormat;
- return FALSE;
+ return false;
}
// hh:mm
pos.setIndex(pos.getIndex() + 1);
@@ -1424,13 +1423,13 @@ TimeZone::parseCustomID(const UnicodeString& id, int32_t& sign,
if ((pos.getIndex() - oldPos) != 2) {
// must be 2 digits
delete numberFormat;
- return FALSE;
+ return false;
}
min = n.getLong();
if (pos.getIndex() < id.length()) {
if (id[pos.getIndex()] != COLON) {
delete numberFormat;
- return FALSE;
+ return false;
}
// [:ss]
pos.setIndex(pos.getIndex() + 1);
@@ -1440,7 +1439,7 @@ TimeZone::parseCustomID(const UnicodeString& id, int32_t& sign,
if (pos.getIndex() != id.length()
|| (pos.getIndex() - oldPos) != 2) {
delete numberFormat;
- return FALSE;
+ return false;
}
sec = n.getLong();
}
@@ -1458,7 +1457,7 @@ TimeZone::parseCustomID(const UnicodeString& id, int32_t& sign,
if (length <= 0 || 6 < length) {
// invalid length
delete numberFormat;
- return FALSE;
+ return false;
}
switch (length) {
case 1:
@@ -1482,11 +1481,11 @@ TimeZone::parseCustomID(const UnicodeString& id, int32_t& sign,
delete numberFormat;
if (hour > kMAX_CUSTOM_HOUR || min > kMAX_CUSTOM_MIN || sec > kMAX_CUSTOM_SEC) {
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
UnicodeString&
@@ -1496,33 +1495,33 @@ TimeZone::formatCustomID(int32_t hour, int32_t min, int32_t sec,
id.setTo(GMT_ID, GMT_ID_LENGTH);
if (hour | min | sec) {
if (negative) {
- id += (UChar)MINUS;
+ id += (char16_t)MINUS;
} else {
- id += (UChar)PLUS;
+ id += (char16_t)PLUS;
}
if (hour < 10) {
- id += (UChar)ZERO_DIGIT;
+ id += (char16_t)ZERO_DIGIT;
} else {
- id += (UChar)(ZERO_DIGIT + hour/10);
+ id += (char16_t)(ZERO_DIGIT + hour/10);
}
- id += (UChar)(ZERO_DIGIT + hour%10);
- id += (UChar)COLON;
+ id += (char16_t)(ZERO_DIGIT + hour%10);
+ id += (char16_t)COLON;
if (min < 10) {
- id += (UChar)ZERO_DIGIT;
+ id += (char16_t)ZERO_DIGIT;
} else {
- id += (UChar)(ZERO_DIGIT + min/10);
+ id += (char16_t)(ZERO_DIGIT + min/10);
}
- id += (UChar)(ZERO_DIGIT + min%10);
+ id += (char16_t)(ZERO_DIGIT + min%10);
if (sec) {
- id += (UChar)COLON;
+ id += (char16_t)COLON;
if (sec < 10) {
- id += (UChar)ZERO_DIGIT;
+ id += (char16_t)ZERO_DIGIT;
} else {
- id += (UChar)(ZERO_DIGIT + sec/10);
+ id += (char16_t)(ZERO_DIGIT + sec/10);
}
- id += (UChar)(ZERO_DIGIT + sec%10);
+ id += (char16_t)(ZERO_DIGIT + sec%10);
}
}
return id;
@@ -1540,8 +1539,8 @@ static void U_CALLCONV initTZDataVersion(UErrorCode &status) {
ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONE, timeZone_cleanup);
int32_t len = 0;
StackUResourceBundle bundle;
- ures_openDirectFillIn(bundle.getAlias(), NULL, kZONEINFO, &status);
- const UChar *tzver = ures_getStringByKey(bundle.getAlias(), kTZVERSION, &len, &status);
+ ures_openDirectFillIn(bundle.getAlias(), nullptr, kZONEINFO, &status);
+ const char16_t *tzver = ures_getStringByKey(bundle.getAlias(), kTZVERSION, &len, &status);
if (U_SUCCESS(status)) {
if (len >= (int32_t)sizeof(TZDATA_VERSION)) {
@@ -1562,7 +1561,7 @@ TimeZone::getTZDataVersion(UErrorCode& status)
UnicodeString&
TimeZone::getCanonicalID(const UnicodeString& id, UnicodeString& canonicalID, UErrorCode& status)
{
- UBool isSystemID = FALSE;
+ UBool isSystemID = false;
return getCanonicalID(id, canonicalID, isSystemID, status);
}
@@ -1571,18 +1570,18 @@ TimeZone::getCanonicalID(const UnicodeString& id, UnicodeString& canonicalID, UB
UErrorCode& status)
{
canonicalID.remove();
- isSystemID = FALSE;
+ isSystemID = false;
if (U_FAILURE(status)) {
return canonicalID;
}
if (id.compare(UNKNOWN_ZONE_ID, UNKNOWN_ZONE_ID_LENGTH) == 0) {
// special case - Etc/Unknown is a canonical ID, but not system ID
canonicalID.fastCopyFrom(id);
- isSystemID = FALSE;
+ isSystemID = false;
} else {
ZoneMeta::getCanonicalCLDRID(id, canonicalID, status);
if (U_SUCCESS(status)) {
- isSystemID = TRUE;
+ isSystemID = true;
} else {
// Not a system ID
status = U_ZERO_ERROR;
@@ -1601,7 +1600,7 @@ TimeZone::getWindowsID(const UnicodeString& id, UnicodeString& winid, UErrorCode
// canonicalize the input ID
UnicodeString canonicalID;
- UBool isSystemID = FALSE;
+ UBool isSystemID = false;
getCanonicalID(id, canonicalID, isSystemID, status);
if (U_FAILURE(status) || !isSystemID) {
@@ -1614,15 +1613,15 @@ TimeZone::getWindowsID(const UnicodeString& id, UnicodeString& winid, UErrorCode
return winid;
}
- UResourceBundle *mapTimezones = ures_openDirect(NULL, "windowsZones", &status);
+ UResourceBundle *mapTimezones = ures_openDirect(nullptr, "windowsZones", &status);
ures_getByKey(mapTimezones, "mapTimezones", mapTimezones, &status);
if (U_FAILURE(status)) {
return winid;
}
- UResourceBundle *winzone = NULL;
- UBool found = FALSE;
+ UResourceBundle *winzone = nullptr;
+ UBool found = false;
while (ures_hasNext(mapTimezones) && !found) {
winzone = ures_getNextResource(mapTimezones, winzone, &status);
if (U_FAILURE(status)) {
@@ -1631,7 +1630,7 @@ TimeZone::getWindowsID(const UnicodeString& id, UnicodeString& winid, UErrorCode
if (ures_getType(winzone) != URES_TABLE) {
continue;
}
- UResourceBundle *regionalData = NULL;
+ UResourceBundle *regionalData = nullptr;
while (ures_hasNext(winzone) && !found) {
regionalData = ures_getNextResource(winzone, regionalData, &status);
if (U_FAILURE(status)) {
@@ -1641,22 +1640,22 @@ TimeZone::getWindowsID(const UnicodeString& id, UnicodeString& winid, UErrorCode
continue;
}
int32_t len;
- const UChar *tzids = ures_getString(regionalData, &len, &status);
+ const char16_t *tzids = ures_getString(regionalData, &len, &status);
if (U_FAILURE(status)) {
break;
}
- const UChar *start = tzids;
- UBool hasNext = TRUE;
+ const char16_t *start = tzids;
+ UBool hasNext = true;
while (hasNext) {
- const UChar *end = u_strchr(start, (UChar)0x20);
- if (end == NULL) {
+ const char16_t *end = u_strchr(start, (char16_t)0x20);
+ if (end == nullptr) {
end = tzids + len;
- hasNext = FALSE;
+ hasNext = false;
}
if (canonicalID.compare(start, static_cast<int32_t>(end - start)) == 0) {
winid = UnicodeString(ures_getKey(winzone), -1 , US_INV);
- found = TRUE;
+ found = true;
break;
}
start = end + 1;
@@ -1679,7 +1678,7 @@ TimeZone::getIDForWindowsID(const UnicodeString& winid, const char* region, Unic
return id;
}
- UResourceBundle *zones = ures_openDirect(NULL, "windowsZones", &status);
+ UResourceBundle *zones = ures_openDirect(nullptr, "windowsZones", &status);
ures_getByKey(zones, "mapTimezones", zones, &status);
if (U_FAILURE(status)) {
ures_close(zones);
@@ -1703,21 +1702,21 @@ TimeZone::getIDForWindowsID(const UnicodeString& winid, const char* region, Unic
return id;
}
- const UChar *tzid = NULL;
+ const char16_t *tzid = nullptr;
int32_t len = 0;
- UBool gotID = FALSE;
+ UBool gotID = false;
if (region) {
- const UChar *tzids = ures_getStringByKey(zones, region, &len, &tmperr); // use tmperr, because
+ const char16_t *tzids = ures_getStringByKey(zones, region, &len, &tmperr); // use tmperr, because
// regional mapping is optional
if (U_SUCCESS(tmperr)) {
// first ID delimited by space is the default one
- const UChar *end = u_strchr(tzids, (UChar)0x20);
- if (end == NULL) {
+ const char16_t *end = u_strchr(tzids, (char16_t)0x20);
+ if (end == nullptr) {
id.setTo(tzids, -1);
} else {
id.setTo(tzids, static_cast<int32_t>(end - tzids));
}
- gotID = TRUE;
+ gotID = true;
}
}
diff --git a/contrib/libs/icu/i18n/titletrn.cpp b/contrib/libs/icu/i18n/titletrn.cpp
index 9c39b4676a..d3732893a7 100644
--- a/contrib/libs/icu/i18n/titletrn.cpp
+++ b/contrib/libs/icu/i18n/titletrn.cpp
@@ -28,7 +28,7 @@ U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TitlecaseTransliterator)
TitlecaseTransliterator::TitlecaseTransliterator() :
- CaseMapTransliterator(UNICODE_STRING("Any-Title", 9), NULL)
+ CaseMapTransliterator(UNICODE_STRING("Any-Title", 9), nullptr)
{
// Need to look back 2 characters in the case of "can't"
setMaximumContextLength(2);
@@ -87,7 +87,7 @@ void TitlecaseTransliterator::handleTransliterate(
// Our mode; we are either converting letter toTitle or
// toLower.
- UBool doTitle = TRUE;
+ UBool doTitle = true;
// Determine if there is a preceding context of cased case-ignorable*,
// in which case we want to start in toLower mode. If the
@@ -99,7 +99,7 @@ void TitlecaseTransliterator::handleTransliterate(
c = text.char32At(start);
type=ucase_getTypeOrIgnorable(c);
if(type>0) { // cased
- doTitle=FALSE;
+ doTitle=false;
break;
} else if(type==0) { // uncased but not ignorable
break;
@@ -117,7 +117,7 @@ void TitlecaseTransliterator::handleTransliterate(
csc.limit = offsets.contextLimit;
UnicodeString tmp;
- const UChar *s;
+ const char16_t *s;
int32_t textPos, delta, result;
for(textPos=offsets.start; textPos<offsets.limit;) {
@@ -146,7 +146,7 @@ void TitlecaseTransliterator::handleTransliterate(
// see UCASE_MAX_STRING_LENGTH
if(result<=UCASE_MAX_STRING_LENGTH) {
// string s[result]
- tmp.setTo(FALSE, s, result);
+ tmp.setTo(false, s, result);
delta=result-U16_LENGTH(c);
} else {
// single code point
diff --git a/contrib/libs/icu/i18n/tmunit.cpp b/contrib/libs/icu/i18n/tmunit.cpp
index 361aecb92e..ffa67eddeb 100644
--- a/contrib/libs/icu/i18n/tmunit.cpp
+++ b/contrib/libs/icu/i18n/tmunit.cpp
@@ -59,11 +59,11 @@ TimeUnit* U_EXPORT2
TimeUnit::createInstance(TimeUnit::UTimeUnitFields timeUnitField,
UErrorCode& status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
if (timeUnitField < 0 || timeUnitField >= UTIMEUNIT_FIELD_COUNT) {
status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
return new TimeUnit(timeUnitField);
}
diff --git a/contrib/libs/icu/i18n/tmutamt.cpp b/contrib/libs/icu/i18n/tmutamt.cpp
index 2753c29374..94fd8cfa97 100644
--- a/contrib/libs/icu/i18n/tmutamt.cpp
+++ b/contrib/libs/icu/i18n/tmutamt.cpp
@@ -63,7 +63,7 @@ TimeUnitAmount::~TimeUnitAmount() {
const TimeUnit&
TimeUnitAmount::getTimeUnit() const {
- return (const TimeUnit&) getUnit();
+ return static_cast<const TimeUnit&>(getUnit());
}
diff --git a/contrib/libs/icu/i18n/tmutfmt.cpp b/contrib/libs/icu/i18n/tmutfmt.cpp
index 057bb634eb..87b509ea35 100644
--- a/contrib/libs/icu/i18n/tmutfmt.cpp
+++ b/contrib/libs/icu/i18n/tmutfmt.cpp
@@ -24,24 +24,24 @@
#include "unicode/msgfmt.h"
#include "uassert.h"
-#define LEFT_CURLY_BRACKET ((UChar)0x007B)
-#define RIGHT_CURLY_BRACKET ((UChar)0x007D)
-#define SPACE ((UChar)0x0020)
-#define DIGIT_ZERO ((UChar)0x0030)
-#define LOW_S ((UChar)0x0073)
-#define LOW_M ((UChar)0x006D)
-#define LOW_I ((UChar)0x0069)
-#define LOW_N ((UChar)0x006E)
-#define LOW_H ((UChar)0x0068)
-#define LOW_W ((UChar)0x0077)
-#define LOW_D ((UChar)0x0064)
-#define LOW_Y ((UChar)0x0079)
-#define LOW_Z ((UChar)0x007A)
-#define LOW_E ((UChar)0x0065)
-#define LOW_R ((UChar)0x0072)
-#define LOW_O ((UChar)0x006F)
-#define LOW_N ((UChar)0x006E)
-#define LOW_T ((UChar)0x0074)
+#define LEFT_CURLY_BRACKET ((char16_t)0x007B)
+#define RIGHT_CURLY_BRACKET ((char16_t)0x007D)
+#define SPACE ((char16_t)0x0020)
+#define DIGIT_ZERO ((char16_t)0x0030)
+#define LOW_S ((char16_t)0x0073)
+#define LOW_M ((char16_t)0x006D)
+#define LOW_I ((char16_t)0x0069)
+#define LOW_N ((char16_t)0x006E)
+#define LOW_H ((char16_t)0x0068)
+#define LOW_W ((char16_t)0x0077)
+#define LOW_D ((char16_t)0x0064)
+#define LOW_Y ((char16_t)0x0079)
+#define LOW_Z ((char16_t)0x007A)
+#define LOW_E ((char16_t)0x0065)
+#define LOW_R ((char16_t)0x0072)
+#define LOW_O ((char16_t)0x006F)
+#define LOW_N ((char16_t)0x006E)
+#define LOW_T ((char16_t)0x0074)
//TODO: define in compile time
@@ -68,26 +68,26 @@ static const char gTimeUnitMinute[] = "minute";
static const char gTimeUnitSecond[] = "second";
static const char gPluralCountOther[] = "other";
-static const UChar DEFAULT_PATTERN_FOR_SECOND[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_S, 0};
-static const UChar DEFAULT_PATTERN_FOR_MINUTE[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_M, LOW_I, LOW_N, 0};
-static const UChar DEFAULT_PATTERN_FOR_HOUR[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_H, 0};
-static const UChar DEFAULT_PATTERN_FOR_WEEK[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_W, 0};
-static const UChar DEFAULT_PATTERN_FOR_DAY[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_D, 0};
-static const UChar DEFAULT_PATTERN_FOR_MONTH[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_M, 0};
-static const UChar DEFAULT_PATTERN_FOR_YEAR[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_Y, 0};
+static const char16_t DEFAULT_PATTERN_FOR_SECOND[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_S, 0};
+static const char16_t DEFAULT_PATTERN_FOR_MINUTE[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_M, LOW_I, LOW_N, 0};
+static const char16_t DEFAULT_PATTERN_FOR_HOUR[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_H, 0};
+static const char16_t DEFAULT_PATTERN_FOR_WEEK[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_W, 0};
+static const char16_t DEFAULT_PATTERN_FOR_DAY[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_D, 0};
+static const char16_t DEFAULT_PATTERN_FOR_MONTH[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_M, 0};
+static const char16_t DEFAULT_PATTERN_FOR_YEAR[] = {LEFT_CURLY_BRACKET, DIGIT_ZERO, RIGHT_CURLY_BRACKET, SPACE, LOW_Y, 0};
-static const UChar PLURAL_COUNT_ZERO[] = {LOW_Z, LOW_E, LOW_R, LOW_O, 0};
-static const UChar PLURAL_COUNT_ONE[] = {LOW_O, LOW_N, LOW_E, 0};
-static const UChar PLURAL_COUNT_TWO[] = {LOW_T, LOW_W, LOW_O, 0};
+static const char16_t PLURAL_COUNT_ZERO[] = {LOW_Z, LOW_E, LOW_R, LOW_O, 0};
+static const char16_t PLURAL_COUNT_ONE[] = {LOW_O, LOW_N, LOW_E, 0};
+static const char16_t PLURAL_COUNT_TWO[] = {LOW_T, LOW_W, LOW_O, 0};
TimeUnitFormat::TimeUnitFormat(UErrorCode& status) {
- initMeasureFormat(Locale::getDefault(), UMEASFMT_WIDTH_WIDE, NULL, status);
+ initMeasureFormat(Locale::getDefault(), UMEASFMT_WIDTH_WIDE, nullptr, status);
create(UTMUTFMT_FULL_STYLE, status);
}
TimeUnitFormat::TimeUnitFormat(const Locale& locale, UErrorCode& status) {
- initMeasureFormat(locale, UMEASFMT_WIDTH_WIDE, NULL, status);
+ initMeasureFormat(locale, UMEASFMT_WIDTH_WIDE, nullptr, status);
create(UTMUTFMT_FULL_STYLE, status);
}
@@ -95,13 +95,13 @@ TimeUnitFormat::TimeUnitFormat(const Locale& locale, UErrorCode& status) {
TimeUnitFormat::TimeUnitFormat(const Locale& locale, UTimeUnitFormatStyle style, UErrorCode& status) {
switch (style) {
case UTMUTFMT_FULL_STYLE:
- initMeasureFormat(locale, UMEASFMT_WIDTH_WIDE, NULL, status);
+ initMeasureFormat(locale, UMEASFMT_WIDTH_WIDE, nullptr, status);
break;
case UTMUTFMT_ABBREVIATED_STYLE:
- initMeasureFormat(locale, UMEASFMT_WIDTH_SHORT, NULL, status);
+ initMeasureFormat(locale, UMEASFMT_WIDTH_SHORT, nullptr, status);
break;
default:
- initMeasureFormat(locale, UMEASFMT_WIDTH_WIDE, NULL, status);
+ initMeasureFormat(locale, UMEASFMT_WIDTH_WIDE, nullptr, status);
break;
}
create(style, status);
@@ -120,7 +120,7 @@ TimeUnitFormat::TimeUnitFormat(const TimeUnitFormat& other)
copyHash(other.fTimeUnitToCountToPatterns[i], fTimeUnitToCountToPatterns[i], status);
} else {
delete fTimeUnitToCountToPatterns[i];
- fTimeUnitToCountToPatterns[i] = NULL;
+ fTimeUnitToCountToPatterns[i] = nullptr;
}
}
}
@@ -131,7 +131,7 @@ TimeUnitFormat::~TimeUnitFormat() {
i < TimeUnit::UTIMEUNIT_FIELD_COUNT;
i = (TimeUnit::UTimeUnitFields)(i+1)) {
deleteHash(fTimeUnitToCountToPatterns[i]);
- fTimeUnitToCountToPatterns[i] = NULL;
+ fTimeUnitToCountToPatterns[i] = nullptr;
}
}
@@ -152,7 +152,7 @@ TimeUnitFormat::operator=(const TimeUnitFormat& other) {
i < TimeUnit::UTIMEUNIT_FIELD_COUNT;
i = (TimeUnit::UTimeUnitFields)(i+1)) {
deleteHash(fTimeUnitToCountToPatterns[i]);
- fTimeUnitToCountToPatterns[i] = NULL;
+ fTimeUnitToCountToPatterns[i] = nullptr;
}
for (TimeUnit::UTimeUnitFields i = TimeUnit::UTIMEUNIT_YEAR;
i < TimeUnit::UTIMEUNIT_FIELD_COUNT;
@@ -163,7 +163,7 @@ TimeUnitFormat::operator=(const TimeUnitFormat& other) {
copyHash(other.fTimeUnitToCountToPatterns[i], fTimeUnitToCountToPatterns[i], status);
} else {
delete fTimeUnitToCountToPatterns[i];
- fTimeUnitToCountToPatterns[i] = NULL;
+ fTimeUnitToCountToPatterns[i] = nullptr;
}
}
fStyle = other.fStyle;
@@ -180,7 +180,7 @@ TimeUnitFormat::parseObject(const UnicodeString& source,
int32_t oldPos = pos.getIndex();
int32_t newPos = -1;
int32_t longestParseDistance = 0;
- UnicodeString* countOfLongestMatch = NULL;
+ UnicodeString* countOfLongestMatch = nullptr;
#ifdef TMUTFMT_DEBUG
char res[1000];
source.extract(0, source.length(), res, "UTF-8");
@@ -193,8 +193,8 @@ TimeUnitFormat::parseObject(const UnicodeString& source,
i = (TimeUnit::UTimeUnitFields)(i+1)) {
Hashtable* countToPatterns = fTimeUnitToCountToPatterns[i];
int32_t elemPos = UHASH_FIRST;
- const UHashElement* elem = NULL;
- while ((elem = countToPatterns->nextElement(elemPos)) != NULL){
+ const UHashElement* elem = nullptr;
+ while ((elem = countToPatterns->nextElement(elemPos)) != nullptr){
const UHashTok keyTok = elem->key;
UnicodeString* count = (UnicodeString*)keyTok.pointer;
#ifdef TMUTFMT_DEBUG
@@ -288,12 +288,12 @@ TimeUnitFormat::parseObject(const UnicodeString& source,
void
TimeUnitFormat::create(UTimeUnitFormatStyle style, UErrorCode& status) {
- // fTimeUnitToCountToPatterns[] must have its elements initialized to NULL first
+ // fTimeUnitToCountToPatterns[] must have its elements initialized to nullptr first
// before checking for failure status.
for (TimeUnit::UTimeUnitFields i = TimeUnit::UTIMEUNIT_YEAR;
i < TimeUnit::UTIMEUNIT_FIELD_COUNT;
i = (TimeUnit::UTimeUnitFields)(i+1)) {
- fTimeUnitToCountToPatterns[i] = NULL;
+ fTimeUnitToCountToPatterns[i] = nullptr;
}
if (U_FAILURE(status)) {
@@ -320,14 +320,14 @@ void
TimeUnitFormat::setup(UErrorCode& err) {
initDataMembers(err);
- UVector pluralCounts(0, uhash_compareUnicodeString, 6, err);
+ UVector pluralCounts(nullptr, uhash_compareUnicodeString, 6, err);
LocalPointer<StringEnumeration> keywords(getPluralRules().getKeywords(err), err);
if (U_FAILURE(err)) {
return;
}
UnicodeString* pluralCount;
- while ((pluralCount = const_cast<UnicodeString*>(keywords->snext(err))) != NULL) {
- pluralCounts.addElementX(pluralCount, err);
+ while ((pluralCount = const_cast<UnicodeString*>(keywords->snext(err))) != nullptr) {
+ pluralCounts.addElement(pluralCount, err);
}
readFromCurrentLocale(UTMUTFMT_FULL_STYLE, gUnitsTag, pluralCounts, err);
checkConsistency(UTMUTFMT_FULL_STYLE, gUnitsTag, err);
@@ -345,7 +345,7 @@ TimeUnitFormat::initDataMembers(UErrorCode& err){
i < TimeUnit::UTIMEUNIT_FIELD_COUNT;
i = (TimeUnit::UTimeUnitFields)(i+1)) {
deleteHash(fTimeUnitToCountToPatterns[i]);
- fTimeUnitToCountToPatterns[i] = NULL;
+ fTimeUnitToCountToPatterns[i] = nullptr;
}
}
@@ -358,7 +358,7 @@ struct TimeUnitFormatReadSink : public ResourceSink {
TimeUnitFormatReadSink(TimeUnitFormat *timeUnitFormatObj,
const UVector &pluralCounts, UTimeUnitFormatStyle style) :
timeUnitFormatObj(timeUnitFormatObj), pluralCounts(pluralCounts),
- style(style), beenHere(FALSE){}
+ style(style), beenHere(false){}
virtual ~TimeUnitFormatReadSink();
@@ -367,7 +367,7 @@ struct TimeUnitFormatReadSink : public ResourceSink {
if (beenHere) {
return;
} else {
- beenHere = TRUE;
+ beenHere = true;
}
ResourceTable units = value.getTable(errorCode);
@@ -375,7 +375,7 @@ struct TimeUnitFormatReadSink : public ResourceSink {
for (int32_t i = 0; units.getKeyAndValue(i, key, value); ++i) {
const char* timeUnitName = key;
- if (timeUnitName == NULL) {
+ if (timeUnitName == nullptr) {
continue;
}
@@ -400,7 +400,7 @@ struct TimeUnitFormatReadSink : public ResourceSink {
LocalPointer<Hashtable> localCountToPatterns;
Hashtable *countToPatterns =
timeUnitFormatObj->fTimeUnitToCountToPatterns[timeUnitField];
- if (countToPatterns == NULL) {
+ if (countToPatterns == nullptr) {
localCountToPatterns.adoptInsteadAndCheckErrorCode(
timeUnitFormatObj->initHash(errorCode), errorCode);
countToPatterns = localCountToPatterns.getAlias();
@@ -430,15 +430,15 @@ struct TimeUnitFormatReadSink : public ResourceSink {
}
MessageFormat** formatters =
(MessageFormat**)countToPatterns->get(pluralCountUniStr);
- if (formatters == NULL) {
+ if (formatters == nullptr) {
LocalMemory<MessageFormat *> localFormatters(
(MessageFormat **)uprv_malloc(UTMUTFMT_FORMAT_STYLE_COUNT*sizeof(MessageFormat*)));
if (localFormatters.isNull()) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
- localFormatters[UTMUTFMT_FULL_STYLE] = NULL;
- localFormatters[UTMUTFMT_ABBREVIATED_STYLE] = NULL;
+ localFormatters[UTMUTFMT_FULL_STYLE] = nullptr;
+ localFormatters[UTMUTFMT_ABBREVIATED_STYLE] = nullptr;
countToPatterns->put(pluralCountUniStr, localFormatters.getAlias(), errorCode);
if (U_FAILURE(errorCode)) {
return;
@@ -448,7 +448,7 @@ struct TimeUnitFormatReadSink : public ResourceSink {
formatters[style] = messageFormat.orphan();
}
- if (timeUnitFormatObj->fTimeUnitToCountToPatterns[timeUnitField] == NULL) {
+ if (timeUnitFormatObj->fTimeUnitToCountToPatterns[timeUnitField] == nullptr) {
timeUnitFormatObj->fTimeUnitToCountToPatterns[timeUnitField] = localCountToPatterns.orphan();
}
}
@@ -471,7 +471,7 @@ TimeUnitFormat::readFromCurrentLocale(UTimeUnitFormatStyle style, const char* ke
UErrorCode status = U_ZERO_ERROR;
LocalUResourceBundlePointer rb(ures_open(U_ICUDATA_UNIT, getLocaleID(status), &status));
- LocalUResourceBundlePointer unitsRes(ures_getByKey(rb.getAlias(), key, NULL, &status));
+ LocalUResourceBundlePointer unitsRes(ures_getByKey(rb.getAlias(), key, nullptr, &status));
ures_getByKey(unitsRes.getAlias(), "duration", unitsRes.getAlias(), &status);
if (U_FAILURE(status)) {
return;
@@ -507,19 +507,19 @@ TimeUnitFormat::checkConsistency(UTimeUnitFormatStyle style, const char* key, UE
LocalPointer<StringEnumeration> keywords(
getPluralRules().getKeywords(err), err);
const UnicodeString* pluralCount;
- while (U_SUCCESS(err) && (pluralCount = keywords->snext(err)) != NULL) {
+ while (U_SUCCESS(err) && (pluralCount = keywords->snext(err)) != nullptr) {
for (int32_t i = 0; i < TimeUnit::UTIMEUNIT_FIELD_COUNT; ++i) {
// for each time unit,
// get all the patterns for each plural rule in this locale.
Hashtable* countToPatterns = fTimeUnitToCountToPatterns[i];
- if ( countToPatterns == NULL ) {
+ if ( countToPatterns == nullptr ) {
fTimeUnitToCountToPatterns[i] = countToPatterns = initHash(err);
if (U_FAILURE(err)) {
return;
}
}
MessageFormat** formatters = (MessageFormat**)countToPatterns->get(*pluralCount);
- if( formatters == NULL || formatters[style] == NULL ) {
+ if( formatters == nullptr || formatters[style] == nullptr ) {
// look through parents
const char* localeName = getLocaleID(err);
CharString pluralCountChars;
@@ -559,31 +559,31 @@ TimeUnitFormat::searchInLocaleChain(UTimeUnitFormatStyle style, const char* key,
char parentLocale[ULOC_FULLNAME_CAPACITY];
uprv_strcpy(parentLocale, localeName);
int32_t locNameLen;
- U_ASSERT(countToPatterns != NULL);
+ U_ASSERT(countToPatterns != nullptr);
while ((locNameLen = uloc_getParent(parentLocale, parentLocale,
ULOC_FULLNAME_CAPACITY, &status)) >= 0){
// look for pattern for srcPluralCount in locale tree
LocalUResourceBundlePointer rb(ures_open(U_ICUDATA_UNIT, parentLocale, &status));
- LocalUResourceBundlePointer unitsRes(ures_getByKey(rb.getAlias(), key, NULL, &status));
+ LocalUResourceBundlePointer unitsRes(ures_getByKey(rb.getAlias(), key, nullptr, &status));
const char* timeUnitName = getTimeUnitName(srcTimeUnitField, status);
- LocalUResourceBundlePointer countsToPatternRB(ures_getByKey(unitsRes.getAlias(), timeUnitName, NULL, &status));
- const UChar* pattern;
+ LocalUResourceBundlePointer countsToPatternRB(ures_getByKey(unitsRes.getAlias(), timeUnitName, nullptr, &status));
+ const char16_t* pattern;
int32_t ptLength;
pattern = ures_getStringByKeyWithFallback(countsToPatternRB.getAlias(), searchPluralCount, &ptLength, &status);
if (U_SUCCESS(status)) {
//found
LocalPointer<MessageFormat> messageFormat(
- new MessageFormat(UnicodeString(TRUE, pattern, ptLength), getLocale(err), err), err);
+ new MessageFormat(UnicodeString(true, pattern, ptLength), getLocale(err), err), err);
if (U_FAILURE(err)) {
return;
}
MessageFormat** formatters = (MessageFormat**)countToPatterns->get(srcPluralCount);
- if (formatters == NULL) {
+ if (formatters == nullptr) {
LocalMemory<MessageFormat *> localFormatters(
(MessageFormat**)uprv_malloc(UTMUTFMT_FORMAT_STYLE_COUNT*sizeof(MessageFormat*)));
formatters = localFormatters.getAlias();
- localFormatters[UTMUTFMT_FULL_STYLE] = NULL;
- localFormatters[UTMUTFMT_ABBREVIATED_STYLE] = NULL;
+ localFormatters[UTMUTFMT_FULL_STYLE] = nullptr;
+ localFormatters[UTMUTFMT_ABBREVIATED_STYLE] = nullptr;
countToPatterns->put(srcPluralCount, localFormatters.orphan(), err);
if (U_FAILURE(err)) {
return;
@@ -615,7 +615,7 @@ TimeUnitFormat::searchInLocaleChain(UTimeUnitFormatStyle style, const char* key,
return;
}
MessageFormat** formatters = (MessageFormat**)countToPatterns->get(srcPluralCount);
- if (formatters != NULL && formatters[style] != NULL) {
+ if (formatters != nullptr && formatters[style] != nullptr) {
return;
}
}
@@ -625,7 +625,7 @@ TimeUnitFormat::searchInLocaleChain(UTimeUnitFormatStyle style, const char* key,
if ( uprv_strcmp(searchPluralCount, gPluralCountOther) == 0 ) {
// set default fall back the same as the resource in root
LocalPointer<MessageFormat> messageFormat;
- const UChar *pattern = NULL;
+ const char16_t *pattern = nullptr;
if ( srcTimeUnitField == TimeUnit::UTIMEUNIT_SECOND ) {
pattern = DEFAULT_PATTERN_FOR_SECOND;
} else if ( srcTimeUnitField == TimeUnit::UTIMEUNIT_MINUTE ) {
@@ -641,15 +641,15 @@ TimeUnitFormat::searchInLocaleChain(UTimeUnitFormatStyle style, const char* key,
} else if ( srcTimeUnitField == TimeUnit::UTIMEUNIT_YEAR ) {
pattern = DEFAULT_PATTERN_FOR_YEAR;
}
- if (pattern != NULL) {
+ if (pattern != nullptr) {
messageFormat.adoptInsteadAndCheckErrorCode(
- new MessageFormat(UnicodeString(TRUE, pattern, -1), getLocale(err), err), err);
+ new MessageFormat(UnicodeString(true, pattern, -1), getLocale(err), err), err);
}
if (U_FAILURE(err)) {
return;
}
MessageFormat** formatters = (MessageFormat**)countToPatterns->get(srcPluralCount);
- if (formatters == NULL) {
+ if (formatters == nullptr) {
LocalMemory<MessageFormat *> localFormatters (
(MessageFormat**)uprv_malloc(UTMUTFMT_FORMAT_STYLE_COUNT*sizeof(MessageFormat*)));
if (localFormatters.isNull()) {
@@ -657,8 +657,8 @@ TimeUnitFormat::searchInLocaleChain(UTimeUnitFormatStyle style, const char* key,
return;
}
formatters = localFormatters.getAlias();
- formatters[UTMUTFMT_FULL_STYLE] = NULL;
- formatters[UTMUTFMT_ABBREVIATED_STYLE] = NULL;
+ formatters[UTMUTFMT_FULL_STYLE] = nullptr;
+ formatters[UTMUTFMT_ABBREVIATED_STYLE] = nullptr;
countToPatterns->put(srcPluralCount, localFormatters.orphan(), err);
}
if (U_SUCCESS(err)) {
@@ -692,9 +692,9 @@ TimeUnitFormat::setNumberFormat(const NumberFormat& format, UErrorCode& status){
void
TimeUnitFormat::deleteHash(Hashtable* htable) {
int32_t pos = UHASH_FIRST;
- const UHashElement* element = NULL;
+ const UHashElement* element = nullptr;
if ( htable ) {
- while ( (element = htable->nextElement(pos)) != NULL ) {
+ while ( (element = htable->nextElement(pos)) != nullptr ) {
const UHashTok valueTok = element->value;
const MessageFormat** value = (const MessageFormat**)valueTok.pointer;
delete value[UTMUTFMT_FULL_STYLE];
@@ -713,9 +713,9 @@ TimeUnitFormat::copyHash(const Hashtable* source, Hashtable* target, UErrorCode&
return;
}
int32_t pos = UHASH_FIRST;
- const UHashElement* element = NULL;
+ const UHashElement* element = nullptr;
if ( source ) {
- while ( (element = source->nextElement(pos)) != NULL ) {
+ while ( (element = source->nextElement(pos)) != nullptr ) {
const UHashTok keyTok = element->key;
const UnicodeString* key = (UnicodeString*)keyTok.pointer;
const UHashTok valueTok = element->value;
@@ -742,7 +742,7 @@ U_CDECL_BEGIN
*
* @param val1 one value in comparison
* @param val2 the other value in comparison
- * @return TRUE if 2 values are the same, FALSE otherwise
+ * @return true if 2 values are the same, false otherwise
*/
static UBool U_CALLCONV tmutfmtHashTableValueComparator(UHashTok val1, UHashTok val2);
@@ -758,16 +758,16 @@ U_CDECL_END
Hashtable*
TimeUnitFormat::initHash(UErrorCode& status) {
if ( U_FAILURE(status) ) {
- return NULL;
+ return nullptr;
}
Hashtable* hTable;
- if ( (hTable = new Hashtable(TRUE, status)) == NULL ) {
+ if ( (hTable = new Hashtable(true, status)) == nullptr ) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
if ( U_FAILURE(status) ) {
delete hTable;
- return NULL;
+ return nullptr;
}
hTable->setValueComparator(tmutfmtHashTableValueComparator);
return hTable;
@@ -778,7 +778,7 @@ const char*
TimeUnitFormat::getTimeUnitName(TimeUnit::UTimeUnitFields unitField,
UErrorCode& status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
switch (unitField) {
case TimeUnit::UTIMEUNIT_YEAR:
@@ -797,7 +797,7 @@ TimeUnitFormat::getTimeUnitName(TimeUnit::UTimeUnitFields unitField,
return gTimeUnitSecond;
default:
status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
}
diff --git a/contrib/libs/icu/i18n/translit.cpp b/contrib/libs/icu/i18n/translit.cpp
index c7d6b51057..29d38b12c7 100644
--- a/contrib/libs/icu/i18n/translit.cpp
+++ b/contrib/libs/icu/i18n/translit.cpp
@@ -54,9 +54,9 @@
#include "cstring.h"
#include "uinvchar.h"
-static const UChar TARGET_SEP = 0x002D; /*-*/
-static const UChar ID_DELIM = 0x003B; /*;*/
-static const UChar VARIANT_SEP = 0x002F; // '/'
+static const char16_t TARGET_SEP = 0x002D; /*-*/
+static const char16_t ID_DELIM = 0x003B; /*;*/
+static const char16_t VARIANT_SEP = 0x002F; // '/'
/**
* Prefix for resource bundle key for the display name for a
@@ -107,7 +107,7 @@ U_NAMESPACE_BEGIN
UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(Transliterator)
/**
- * Return TRUE if the given UTransPosition is valid for text of
+ * Return true if the given UTransPosition is valid for text of
* the given length.
*/
static inline UBool positionIsValid(UTransPosition& index, int32_t len) {
@@ -122,7 +122,7 @@ static inline UBool positionIsValid(UTransPosition& index, int32_t len) {
* Default constructor.
* @param theID the string identifier for this transliterator
* @param theFilter the filter. Any character for which
- * <tt>filter.contains()</tt> returns <tt>FALSE</tt> will not be
+ * <tt>filter.contains()</tt> returns <tt>false</tt> will not be
* altered by this transliterator. If <tt>filter</tt> is
* <tt>null</tt> then no filtering is applied.
*/
@@ -132,7 +132,7 @@ Transliterator::Transliterator(const UnicodeString& theID,
maximumContextLength(0)
{
// NUL-terminate the ID string, which is a non-aliased copy.
- ID.append((UChar)0);
+ ID.append((char16_t)0);
ID.truncate(ID.length()-1);
}
@@ -153,7 +153,7 @@ Transliterator::Transliterator(const Transliterator& other) :
maximumContextLength(other.maximumContextLength)
{
// NUL-terminate the ID string, which is a non-aliased copy.
- ID.append((UChar)0);
+ ID.append((char16_t)0);
ID.truncate(ID.length()-1);
if (other.filter != 0) {
@@ -163,7 +163,7 @@ Transliterator::Transliterator(const Transliterator& other) :
}
Transliterator* Transliterator::clone() const {
- return NULL;
+ return nullptr;
}
/**
@@ -202,7 +202,7 @@ int32_t Transliterator::transliterate(Replaceable& text,
offsets.contextLimit = limit;
offsets.start = start;
offsets.limit = limit;
- filteredTransliterate(text, offsets, FALSE, TRUE);
+ filteredTransliterate(text, offsets, false, true);
return offsets.limit;
}
@@ -341,7 +341,7 @@ void Transliterator::finishTransliteration(Replaceable& text,
return;
}
- filteredTransliterate(text, index, FALSE, TRUE);
+ filteredTransliterate(text, index, false, true);
}
/**
@@ -380,7 +380,7 @@ void Transliterator::_transliterate(Replaceable& text,
return;
}
- filteredTransliterate(text, index, TRUE, TRUE);
+ filteredTransliterate(text, index, true, true);
#if 0
// TODO
@@ -440,7 +440,7 @@ void Transliterator::filteredTransliterate(Replaceable& text,
// This method processes text in two groupings:
//
// RUNS -- A run is a contiguous group of characters which are contained
- // in the filter for this transliterator (filter.contains(ch) == TRUE).
+ // in the filter for this transliterator (filter.contains(ch) == true).
// Text outside of runs may appear as context but it is not modified.
// The start and limit Position values are narrowed to each run.
//
@@ -474,7 +474,7 @@ void Transliterator::filteredTransliterate(Replaceable& text,
for (;;) {
- if (filter != NULL) {
+ if (filter != nullptr) {
// Narrow the range to be transliterated to the first segment
// of unfiltered characters at or after index.start.
@@ -503,10 +503,10 @@ void Transliterator::filteredTransliterate(Replaceable& text,
// Is this run incremental? If there is additional
// filtered text (if limit < globalLimit) then we pass in
- // an incremental value of FALSE to force the subclass to
+ // an incremental value of false to force the subclass to
// complete the transliteration for this run.
UBool isIncrementalRun =
- (index.limit < globalLimit ? FALSE : incremental);
+ (index.limit < globalLimit ? false : incremental);
int32_t delta;
@@ -585,7 +585,7 @@ void Transliterator::filteredTransliterate(Replaceable& text,
// return, start will be updated to point after the
// transliterated text, and limit and contextLimit will be
// adjusted for length changes.
- handleTransliterate(text, index, TRUE);
+ handleTransliterate(text, index, true);
delta = index.limit - passLimit; // change in length
@@ -666,7 +666,7 @@ void Transliterator::filteredTransliterate(Replaceable& text,
globalLimit += delta;
}
- if (filter == NULL || isIncrementalRun) {
+ if (filter == nullptr || isIncrementalRun) {
break;
}
@@ -682,7 +682,7 @@ void Transliterator::filteredTransliterate(Replaceable& text,
void Transliterator::filteredTransliterate(Replaceable& text,
UTransPosition& index,
UBool incremental) const {
- filteredTransliterate(text, index, incremental, FALSE);
+ filteredTransliterate(text, index, incremental, false);
}
/**
@@ -700,7 +700,7 @@ void Transliterator::setMaximumContextLength(int32_t maxContextLength) {
* @see #registerInstance
* @see #getAvailableIDs
*/
-const UnicodeString& Transliterator::getID(void) const {
+const UnicodeString& Transliterator::getID() const {
return ID;
}
@@ -834,19 +834,19 @@ UnicodeString& U_EXPORT2 Transliterator::getDisplayName(const UnicodeString& id,
* if this transliterator uses no filter. Caller musn't delete
* the result!
*/
-const UnicodeFilter* Transliterator::getFilter(void) const {
+const UnicodeFilter* Transliterator::getFilter() const {
return filter;
}
/**
* Returns the filter used by this transliterator, or
- * <tt>NULL</tt> if this transliterator uses no filter. The
+ * <tt>nullptr</tt> if this transliterator uses no filter. The
* caller must eventually delete the result. After this call,
- * this transliterator's filter is set to <tt>NULL</tt>.
+ * this transliterator's filter is set to <tt>nullptr</tt>.
*/
-UnicodeFilter* Transliterator::orphanFilter(void) {
+UnicodeFilter* Transliterator::orphanFilter() {
UnicodeFilter *result = filter;
- filter = NULL;
+ filter = nullptr;
return result;
}
@@ -921,7 +921,7 @@ Transliterator::createInstance(const UnicodeString& ID,
UnicodeString canonID;
UVector list(status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
UnicodeSet* globalFilter = nullptr;
@@ -930,17 +930,17 @@ Transliterator::createInstance(const UnicodeString& ID,
if (!TransliteratorIDParser::parseCompoundID(ID, dir, canonID, list, globalFilter)) {
status = U_INVALID_ID;
delete globalFilter;
- return NULL;
+ return nullptr;
}
LocalPointer<UnicodeSet> lpGlobalFilter(globalFilter);
TransliteratorIDParser::instantiateList(list, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
U_ASSERT(list.size() > 0);
- Transliterator* t = NULL;
+ Transliterator* t = nullptr;
if (list.size() > 1 || canonID.indexOf(ID_DELIM) >= 0) {
// [NOTE: If it's a compoundID, we instantiate a CompoundTransliterator even if it only
@@ -954,7 +954,7 @@ Transliterator::createInstance(const UnicodeString& ID,
t = (Transliterator*)list.elementAt(0);
}
// Check null pointer
- if (t != NULL) {
+ if (t != nullptr) {
t->setID(canonID);
if (lpGlobalFilter.isValid()) {
t->adoptFilter(lpGlobalFilter.orphan());
@@ -1029,12 +1029,12 @@ Transliterator* Transliterator::createBasicInstance(const UnicodeString& id,
if (U_FAILURE(ec)) {
delete t;
delete alias;
- t = NULL;
+ t = nullptr;
break;
}
}
- if (t != NULL && canon != NULL) {
+ if (t != nullptr && canon != nullptr) {
t->setID(*canon);
}
@@ -1056,7 +1056,7 @@ Transliterator::createFromRules(const UnicodeString& ID,
UParseError& parseError,
UErrorCode& status)
{
- Transliterator* t = NULL;
+ Transliterator* t = nullptr;
TransliteratorParser parser(status);
parser.parse(rules, dir, parseError, status);
@@ -1070,16 +1070,16 @@ Transliterator::createFromRules(const UnicodeString& ID,
t = new NullTransliterator();
}
else if (parser.idBlockVector.size() == 0 && parser.dataVector.size() == 1) {
- t = new RuleBasedTransliterator(ID, (TransliterationRuleData*)parser.dataVector.orphanElementAt(0), TRUE);
+ t = new RuleBasedTransliterator(ID, (TransliterationRuleData*)parser.dataVector.orphanElementAt(0), true);
}
else if (parser.idBlockVector.size() == 1 && parser.dataVector.size() == 0) {
// idBlock, no data -- this is an alias. The ID has
// been munged from reverse into forward mode, if
// necessary, so instantiate the ID in the forward
// direction.
- if (parser.compoundFilter != NULL) {
+ if (parser.compoundFilter != nullptr) {
UnicodeString filterPattern;
- parser.compoundFilter->toPattern(filterPattern, FALSE);
+ parser.compoundFilter->toPattern(filterPattern, false);
t = createInstance(filterPattern + UnicodeString(ID_DELIM)
+ *((UnicodeString*)parser.idBlockVector.elementAt(0)), UTRANS_FORWARD, parseError, status);
}
@@ -1087,7 +1087,7 @@ Transliterator::createFromRules(const UnicodeString& ID,
t = createInstance(*((UnicodeString*)parser.idBlockVector.elementAt(0)), UTRANS_FORWARD, parseError, status);
- if (t != NULL) {
+ if (t != nullptr) {
t->setID(ID);
}
}
@@ -1110,7 +1110,7 @@ Transliterator::createFromRules(const UnicodeString& ID,
delete temp;
return nullptr;
}
- if (temp != NULL && typeid(*temp) != typeid(NullTransliterator)) {
+ if (temp != nullptr && typeid(*temp) != typeid(NullTransliterator)) {
transliterators.addElement(temp, status);
if (U_FAILURE(status)) {
delete temp;
@@ -1125,9 +1125,9 @@ Transliterator::createFromRules(const UnicodeString& ID,
TransliterationRuleData* data = (TransliterationRuleData*)parser.dataVector.orphanElementAt(0);
// TODO: Should passNumber be turned into a decimal-string representation (1 -> "1")?
RuleBasedTransliterator* temprbt = new RuleBasedTransliterator(UnicodeString(CompoundTransliterator::PASS_STRING) + UnicodeString(passNumber++),
- data, TRUE);
- // Check if NULL before adding it to transliterators to avoid future usage of NULL pointer.
- if (temprbt == NULL) {
+ data, true);
+ // Check if nullptr before adding it to transliterators to avoid future usage of nullptr pointer.
+ if (temprbt == nullptr) {
if (U_SUCCESS(status)) {
status = U_MEMORY_ALLOCATION_ERROR;
}
@@ -1146,12 +1146,12 @@ Transliterator::createFromRules(const UnicodeString& ID,
t = new CompoundTransliterator(transliterators, passNumber - 1, parseError, status);
// Null pointer check
- if (t != NULL) {
+ if (t != nullptr) {
t->setID(ID);
t->adoptFilter(parser.orphanCompoundFilter());
}
}
- if (U_SUCCESS(status) && t == NULL) {
+ if (U_SUCCESS(status) && t == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
return t;
@@ -1182,7 +1182,7 @@ UnicodeString& Transliterator::toRules(UnicodeString& rulesSource,
int32_t Transliterator::countElements() const {
const CompoundTransliterator* ct = dynamic_cast<const CompoundTransliterator*>(this);
- return ct != NULL ? ct->getCount() : 0;
+ return ct != nullptr ? ct->getCount() : 0;
}
const Transliterator& Transliterator::getElement(int32_t index, UErrorCode& ec) const {
@@ -1190,7 +1190,7 @@ const Transliterator& Transliterator::getElement(int32_t index, UErrorCode& ec)
return *this;
}
const CompoundTransliterator* cpd = dynamic_cast<const CompoundTransliterator*>(this);
- int32_t n = (cpd == NULL) ? 1 : cpd->getCount();
+ int32_t n = (cpd == nullptr) ? 1 : cpd->getCount();
if (index < 0 || index >= n) {
ec = U_INDEX_OUTOFBOUNDS_ERROR;
return *this;
@@ -1201,18 +1201,18 @@ const Transliterator& Transliterator::getElement(int32_t index, UErrorCode& ec)
UnicodeSet& Transliterator::getSourceSet(UnicodeSet& result) const {
handleGetSourceSet(result);
- if (filter != NULL) {
+ if (filter != nullptr) {
UnicodeSet* filterSet = dynamic_cast<UnicodeSet*>(filter);
- UBool deleteFilterSet = FALSE;
+ UBool deleteFilterSet = false;
// Most, but not all filters will be UnicodeSets. Optimize for
// the high-runner case.
- if (filterSet == NULL) {
+ if (filterSet == nullptr) {
filterSet = new UnicodeSet();
// Check null pointer
- if (filterSet == NULL) {
+ if (filterSet == nullptr) {
return result;
}
- deleteFilterSet = TRUE;
+ deleteFilterSet = true;
filter->addMatchSetTo(*filterSet);
}
result.retainAll(*filterSet);
@@ -1248,7 +1248,7 @@ void Transliterator::_registerFactory(const UnicodeString& id,
Transliterator::Factory factory,
Transliterator::Token context) {
UErrorCode ec = U_ZERO_ERROR;
- registry->put(id, factory, context, TRUE, ec);
+ registry->put(id, factory, context, true, ec);
}
// To be called only by Transliterator subclasses that are called
@@ -1283,7 +1283,7 @@ void U_EXPORT2 Transliterator::registerInstance(Transliterator* adoptedPrototype
void Transliterator::_registerInstance(Transliterator* adoptedPrototype) {
UErrorCode ec = U_ZERO_ERROR;
- registry->put(adoptedPrototype, TRUE, ec);
+ registry->put(adoptedPrototype, true, ec);
}
void U_EXPORT2 Transliterator::registerAlias(const UnicodeString& aliasID,
@@ -1298,7 +1298,7 @@ void U_EXPORT2 Transliterator::registerAlias(const UnicodeString& aliasID,
void Transliterator::_registerAlias(const UnicodeString& aliasID,
const UnicodeString& realID) {
UErrorCode ec = U_ZERO_ERROR;
- registry->put(aliasID, realID, FALSE, TRUE, ec);
+ registry->put(aliasID, realID, false, true, ec);
}
/**
@@ -1323,7 +1323,7 @@ void U_EXPORT2 Transliterator::unregister(const UnicodeString& ID) {
* To retrieve the actual IDs, call getAvailableID(i) with
* i from 0 to countAvailableIDs() - 1.
*/
-int32_t U_EXPORT2 Transliterator::countAvailableIDs(void) {
+int32_t U_EXPORT2 Transliterator::countAvailableIDs() {
int32_t retVal = 0;
Mutex lock(&registryMutex);
UErrorCode ec = U_ZERO_ERROR;
@@ -1340,32 +1340,32 @@ int32_t U_EXPORT2 Transliterator::countAvailableIDs(void) {
* range, the result of getAvailableID(0) is returned.
*/
const UnicodeString& U_EXPORT2 Transliterator::getAvailableID(int32_t index) {
- const UnicodeString* result = NULL;
+ const UnicodeString* result = nullptr;
umtx_lock(&registryMutex);
UErrorCode ec = U_ZERO_ERROR;
if (HAVE_REGISTRY(ec)) {
result = &registry->getAvailableID(index);
}
umtx_unlock(&registryMutex);
- U_ASSERT(result != NULL); // fail if no registry
+ U_ASSERT(result != nullptr); // fail if no registry
return *result;
}
StringEnumeration* U_EXPORT2 Transliterator::getAvailableIDs(UErrorCode& ec) {
- if (U_FAILURE(ec)) return NULL;
- StringEnumeration* result = NULL;
+ if (U_FAILURE(ec)) return nullptr;
+ StringEnumeration* result = nullptr;
umtx_lock(&registryMutex);
if (HAVE_REGISTRY(ec)) {
result = registry->getAvailableIDs();
}
umtx_unlock(&registryMutex);
- if (result == NULL) {
+ if (result == nullptr) {
ec = U_INTERNAL_TRANSLITERATOR_ERROR;
}
return result;
}
-int32_t U_EXPORT2 Transliterator::countAvailableSources(void) {
+int32_t U_EXPORT2 Transliterator::countAvailableSources() {
Mutex lock(&registryMutex);
UErrorCode ec = U_ZERO_ERROR;
return HAVE_REGISTRY(ec) ? _countAvailableSources() : 0;
@@ -1417,7 +1417,7 @@ UnicodeString& U_EXPORT2 Transliterator::getAvailableVariant(int32_t index,
return result;
}
-int32_t Transliterator::_countAvailableSources(void) {
+int32_t Transliterator::_countAvailableSources() {
return registry->countAvailableSources();
}
@@ -1456,19 +1456,19 @@ UnicodeString& Transliterator::_getAvailableVariant(int32_t index,
* @deprecated the new architecture provides filtering at the top
* level. This method will be removed Dec 31 2001.
*/
-UChar Transliterator::filteredCharAt(const Replaceable& text, int32_t i) const {
- UChar c;
+char16_t Transliterator::filteredCharAt(const Replaceable& text, int32_t i) const {
+ char16_t c;
const UnicodeFilter* localFilter = getFilter();
return (localFilter == 0) ? text.charAt(i) :
- (localFilter->contains(c = text.charAt(i)) ? c : (UChar)0xFFFE);
+ (localFilter->contains(c = text.charAt(i)) ? c : (char16_t)0xFFFE);
}
#endif
/**
- * If the registry is initialized, return TRUE. If not, initialize it
- * and return TRUE. If the registry cannot be initialized, return
- * FALSE (rare).
+ * If the registry is initialized, return true. If not, initialize it
+ * and return true. If the registry cannot be initialized, return
+ * false (rare).
*
* IMPORTANT: Upon entry, registryMutex must be LOCKED. The entire
* initialization is done with the lock held. There is NO REASON to
@@ -1477,14 +1477,14 @@ UChar Transliterator::filteredCharAt(const Replaceable& text, int32_t i) const {
*/
UBool Transliterator::initializeRegistry(UErrorCode &status) {
if (registry != 0) {
- return TRUE;
+ return true;
}
registry = new TransliteratorRegistry(status);
if (registry == 0 || U_FAILURE(status)) {
delete registry;
registry = 0;
- return FALSE; // can't create registry, no recovery
+ return false; // can't create registry, no recovery
}
/* The following code parses the index table located in
@@ -1525,7 +1525,7 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) {
UErrorCode lstatus = U_ZERO_ERROR;
UResourceBundle *bundle, *transIDs, *colBund;
- bundle = ures_open(U_ICUDATA_TRANSLIT, NULL/*open default locale*/, &lstatus);
+ bundle = ures_open(U_ICUDATA_TRANSLIT, nullptr/*open default locale*/, &lstatus);
transIDs = ures_getByKey(bundle, RB_RULE_BASED_IDS, 0, &lstatus);
const UnicodeString T_PART = UNICODE_STRING_SIMPLE("-t-");
@@ -1534,7 +1534,7 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) {
delete registry;
registry = nullptr;
status = U_MEMORY_ALLOCATION_ERROR;
- return FALSE;
+ return false;
}
if (U_SUCCESS(lstatus)) {
maxRows = ures_getSize(transIDs);
@@ -1546,14 +1546,14 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) {
ures_close(colBund);
continue;
}
- UResourceBundle* res = ures_getNextResource(colBund, NULL, &lstatus);
+ UResourceBundle* res = ures_getNextResource(colBund, nullptr, &lstatus);
const char* typeStr = ures_getKey(res);
- UChar type;
+ char16_t type;
u_charsToUChars(typeStr, &type, 1);
if (U_SUCCESS(lstatus)) {
int32_t len = 0;
- const UChar *resString;
+ const char16_t *resString;
switch (type) {
case 0x66: // 'f'
case 0x69: // 'i'
@@ -1567,13 +1567,13 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) {
(ures_getUnicodeStringByKey(res, "direction", &lstatus).charAt(0) ==
0x0046 /*F*/) ?
UTRANS_FORWARD : UTRANS_REVERSE;
- registry->put(id, UnicodeString(TRUE, resString, len), dir, TRUE, visible, lstatus);
+ registry->put(id, UnicodeString(true, resString, len), dir, true, visible, lstatus);
}
break;
case 0x61: // 'a'
// 'alias'; row[2]=createInstance argument
resString = ures_getString(res, &len, &lstatus);
- registry->put(id, UnicodeString(TRUE, resString, len), TRUE, TRUE, lstatus);
+ registry->put(id, UnicodeString(true, resString, len), true, true, lstatus);
break;
}
}
@@ -1602,12 +1602,12 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) {
BreakTransliterator* tempBreakTranslit = new BreakTransliterator();
#endif
// Check for null pointers
- if (tempNullTranslit == NULL || tempLowercaseTranslit == NULL || tempUppercaseTranslit == NULL ||
- tempTitlecaseTranslit == NULL || tempUnicodeTranslit == NULL ||
+ if (tempNullTranslit == nullptr || tempLowercaseTranslit == nullptr || tempUppercaseTranslit == nullptr ||
+ tempTitlecaseTranslit == nullptr || tempUnicodeTranslit == nullptr ||
#if !UCONFIG_NO_BREAK_ITERATION
- tempBreakTranslit == NULL ||
+ tempBreakTranslit == nullptr ||
#endif
- tempNameUnicodeTranslit == NULL )
+ tempNameUnicodeTranslit == nullptr )
{
delete tempNullTranslit;
delete tempLowercaseTranslit;
@@ -1620,20 +1620,20 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) {
#endif
// Since there was an error, remove registry
delete registry;
- registry = NULL;
+ registry = nullptr;
status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
- registry->put(tempNullTranslit, TRUE, status);
- registry->put(tempLowercaseTranslit, TRUE, status);
- registry->put(tempUppercaseTranslit, TRUE, status);
- registry->put(tempTitlecaseTranslit, TRUE, status);
- registry->put(tempUnicodeTranslit, TRUE, status);
- registry->put(tempNameUnicodeTranslit, TRUE, status);
+ registry->put(tempNullTranslit, true, status);
+ registry->put(tempLowercaseTranslit, true, status);
+ registry->put(tempUppercaseTranslit, true, status);
+ registry->put(tempTitlecaseTranslit, true, status);
+ registry->put(tempUnicodeTranslit, true, status);
+ registry->put(tempNameUnicodeTranslit, true, status);
#if !UCONFIG_NO_BREAK_ITERATION
- registry->put(tempBreakTranslit, FALSE, status); // FALSE means invisible.
+ registry->put(tempBreakTranslit, false, status); // false means invisible.
#endif
RemoveTransliterator::registerIDs(); // Must be within mutex
@@ -1643,15 +1643,15 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) {
AnyTransliterator::registerIDs();
_registerSpecialInverse(UNICODE_STRING_SIMPLE("Null"),
- UNICODE_STRING_SIMPLE("Null"), FALSE);
+ UNICODE_STRING_SIMPLE("Null"), false);
_registerSpecialInverse(UNICODE_STRING_SIMPLE("Upper"),
- UNICODE_STRING_SIMPLE("Lower"), TRUE);
+ UNICODE_STRING_SIMPLE("Lower"), true);
_registerSpecialInverse(UNICODE_STRING_SIMPLE("Title"),
- UNICODE_STRING_SIMPLE("Lower"), FALSE);
+ UNICODE_STRING_SIMPLE("Lower"), false);
ucln_i18n_registerCleanup(UCLN_I18N_TRANSLITERATOR, utrans_transliterator_cleanup);
- return TRUE;
+ return true;
}
U_NAMESPACE_END
@@ -1663,14 +1663,14 @@ U_NAMESPACE_END
* necessarily invalidate any rule-based transliterators held by the
* user, because RBTs hold pointers to common data objects.
*/
-U_CFUNC UBool utrans_transliterator_cleanup(void) {
+U_CFUNC UBool utrans_transliterator_cleanup() {
U_NAMESPACE_USE
TransliteratorIDParser::cleanup();
if (registry) {
delete registry;
- registry = NULL;
+ registry = nullptr;
}
- return TRUE;
+ return true;
}
#endif /* #if !UCONFIG_NO_TRANSLITERATION */
diff --git a/contrib/libs/icu/i18n/transreg.cpp b/contrib/libs/icu/i18n/transreg.cpp
index 726ad56f0f..46c68eb74d 100644
--- a/contrib/libs/icu/i18n/transreg.cpp
+++ b/contrib/libs/icu/i18n/transreg.cpp
@@ -40,14 +40,14 @@
#include <stdio.h>
#endif
-// UChar constants
-static const UChar LOCALE_SEP = 95; // '_'
-//static const UChar ID_SEP = 0x002D; /*-*/
-//static const UChar VARIANT_SEP = 0x002F; // '/'
+// char16_t constants
+static const char16_t LOCALE_SEP = 95; // '_'
+//static const char16_t ID_SEP = 0x002D; /*-*/
+//static const char16_t VARIANT_SEP = 0x002F; // '/'
// String constants
-static const UChar ANY[] = { 0x41, 0x6E, 0x79, 0 }; // Any
-static const UChar LAT[] = { 0x4C, 0x61, 0x74, 0 }; // Lat
+static const char16_t ANY[] = { 0x41, 0x6E, 0x79, 0 }; // Any
+static const char16_t LAT[] = { 0x4C, 0x61, 0x74, 0 }; // Lat
// empty string
#define NO_VARIANT UnicodeString()
@@ -123,7 +123,7 @@ Transliterator* TransliteratorAlias::create(UParseError& pe,
if (U_FAILURE(ec)) {
return 0;
}
- Transliterator *t = NULL;
+ Transliterator *t = nullptr;
switch (type) {
case SIMPLE:
t = Transliterator::createInstance(aliasesOrRules, UTRANS_FORWARD, pe, ec);
@@ -141,22 +141,16 @@ Transliterator* TransliteratorAlias::create(UParseError& pe,
// to see whether there really are ID blocks at the beginning and end (by looking for U+FFFF, which
// marks the position where an anonymous transliterator goes) and adjust accordingly
int32_t anonymousRBTs = transes->size();
- int32_t transCount = anonymousRBTs * 2 + 1;
- if (!aliasesOrRules.isEmpty() && aliasesOrRules[0] == (UChar)(0xffff))
- --transCount;
- if (aliasesOrRules.length() >= 2 && aliasesOrRules[aliasesOrRules.length() - 1] == (UChar)(0xffff))
- --transCount;
- UnicodeString noIDBlock((UChar)(0xffff));
- noIDBlock += ((UChar)(0xffff));
+ UnicodeString noIDBlock((char16_t)(0xffff));
+ noIDBlock += ((char16_t)(0xffff));
int32_t pos = aliasesOrRules.indexOf(noIDBlock);
while (pos >= 0) {
- --transCount;
pos = aliasesOrRules.indexOf(noIDBlock, pos + 1);
}
UVector transliterators(uprv_deleteUObject, nullptr, ec);
UnicodeString idBlock;
- int32_t blockSeparatorPos = aliasesOrRules.indexOf((UChar)(0xffff));
+ int32_t blockSeparatorPos = aliasesOrRules.indexOf((char16_t)(0xffff));
while (blockSeparatorPos >= 0) {
aliasesOrRules.extract(0, blockSeparatorPos, idBlock);
aliasesOrRules.remove(0, blockSeparatorPos + 1);
@@ -164,7 +158,7 @@ Transliterator* TransliteratorAlias::create(UParseError& pe,
transliterators.adoptElement(Transliterator::createInstance(idBlock, UTRANS_FORWARD, pe, ec), ec);
if (!transes->isEmpty())
transliterators.adoptElement(transes->orphanElementAt(0), ec);
- blockSeparatorPos = aliasesOrRules.indexOf((UChar)(0xffff));
+ blockSeparatorPos = aliasesOrRules.indexOf((char16_t)(0xffff));
}
if (!aliasesOrRules.isEmpty())
transliterators.adoptElement(Transliterator::createInstance(aliasesOrRules, UTRANS_FORWARD, pe, ec), ec);
@@ -187,7 +181,7 @@ Transliterator* TransliteratorAlias::create(UParseError& pe,
}
break;
case RULES:
- UPRV_UNREACHABLE_EXIT; // don't call create() if isRuleBased() returns TRUE!
+ UPRV_UNREACHABLE_EXIT; // don't call create() if isRuleBased() returns true!
}
return t;
}
@@ -248,8 +242,8 @@ class TransliteratorSpec : public UMemory {
UnicodeString spec;
UnicodeString nextSpec;
UnicodeString scriptName;
- UBool isSpecLocale; // TRUE if spec is a locale
- UBool isNextLocale; // TRUE if nextSpec is a locale
+ UBool isSpecLocale; // true if spec is a locale
+ UBool isNextLocale; // true if nextSpec is a locale
ResourceBundle* res;
TransliteratorSpec(const TransliteratorSpec &other); // forbid copying of this class
@@ -265,7 +259,7 @@ TransliteratorSpec::TransliteratorSpec(const UnicodeString& theSpec)
LocaleUtility::initLocaleFromName(theSpec, topLoc);
if (!topLoc.isBogus()) {
res = new ResourceBundle(U_ICUDATA_TRANSLIT, topLoc, status);
- /* test for NULL */
+ /* test for nullptr */
if (res == 0) {
return;
}
@@ -319,7 +313,7 @@ void TransliteratorSpec::reset() {
}
void TransliteratorSpec::setupNext() {
- isNextLocale = FALSE;
+ isNextLocale = false;
if (isSpecLocale) {
nextSpec = spec;
int32_t i = nextSpec.lastIndexOf(LOCALE_SEP);
@@ -327,7 +321,7 @@ void TransliteratorSpec::setupNext() {
// to the scriptName.
if (i > 0) {
nextSpec.truncate(i);
- isNextLocale = TRUE;
+ isNextLocale = true;
} else {
nextSpec = scriptName; // scriptName may be empty
}
@@ -365,10 +359,10 @@ ResourceBundle& TransliteratorSpec::getBundle() const {
#ifdef DEBUG_MEM
// Vector of Entry pointers currently in use
-static UVector* DEBUG_entries = NULL;
+static UVector* DEBUG_entries = nullptr;
static void DEBUG_setup() {
- if (DEBUG_entries == NULL) {
+ if (DEBUG_entries == nullptr) {
UErrorCode ec = U_ZERO_ERROR;
DEBUG_entries = new UVector(ec);
}
@@ -410,7 +404,7 @@ static void DEBUG_delEntry(TransliteratorEntry* e) {
// Track object usage
static void DEBUG_useEntry(TransliteratorEntry* e) {
- if (e == NULL) return;
+ if (e == nullptr) return;
DEBUG_setup();
int i = DEBUG_findEntry(e);
if (i < 0) {
@@ -480,7 +474,7 @@ private:
TransliteratorEntry::TransliteratorEntry() {
u.prototype = 0;
- compoundFilter = NULL;
+ compoundFilter = nullptr;
entryType = NONE;
DEBUG_newEntry(this);
}
@@ -496,7 +490,7 @@ TransliteratorEntry::~TransliteratorEntry() {
// invalidates any RBTs that the user has instantiated.
delete u.data;
} else if (entryType == COMPOUND_RBT) {
- while (u.dataVector != NULL && !u.dataVector->isEmpty())
+ while (u.dataVector != nullptr && !u.dataVector->isEmpty())
delete (TransliterationRuleData*)u.dataVector->orphanElementAt(0);
delete u.dataVector;
}
@@ -534,8 +528,8 @@ U_CDECL_END
//----------------------------------------------------------------------
TransliteratorRegistry::TransliteratorRegistry(UErrorCode& status) :
- registry(TRUE, status),
- specDAG(TRUE, SPECDAG_INIT_SIZE, status),
+ registry(true, status),
+ specDAG(true, SPECDAG_INIT_SIZE, status),
variantList(VARIANT_LIST_INIT_SIZE, status),
availableIDs(AVAILABLE_IDS_INIT_SIZE, status)
{
@@ -543,7 +537,7 @@ TransliteratorRegistry::TransliteratorRegistry(UErrorCode& status) :
variantList.setDeleter(uprv_deleteUObject);
variantList.setComparer(uhash_compareCaselessUnicodeString);
UnicodeString *emptyString = new UnicodeString();
- if (emptyString != NULL) {
+ if (emptyString != nullptr) {
variantList.adoptElement(emptyString, status);
}
availableIDs.setDeleter(uprv_deleteUObject);
@@ -558,7 +552,7 @@ TransliteratorRegistry::~TransliteratorRegistry() {
Transliterator* TransliteratorRegistry::get(const UnicodeString& ID,
TransliteratorAlias*& aliasReturn,
UErrorCode& status) {
- U_ASSERT(aliasReturn == NULL);
+ U_ASSERT(aliasReturn == nullptr);
TransliteratorEntry *entry = find(ID);
return (entry == 0) ? 0
: instantiateEntry(ID, entry, aliasReturn, status);
@@ -568,7 +562,7 @@ Transliterator* TransliteratorRegistry::reget(const UnicodeString& ID,
TransliteratorParser& parser,
TransliteratorAlias*& aliasReturn,
UErrorCode& status) {
- U_ASSERT(aliasReturn == NULL);
+ U_ASSERT(aliasReturn == nullptr);
TransliteratorEntry *entry = find(ID);
if (entry == 0) {
@@ -580,7 +574,7 @@ Transliterator* TransliteratorRegistry::reget(const UnicodeString& ID,
// The usage model for the caller is that they will first call
// reg->get() inside the mutex, they'll get back an alias, they call
- // alias->isRuleBased(), and if they get TRUE, they call alias->parse()
+ // alias->isRuleBased(), and if they get true, they call alias->parse()
// outside the mutex, then reg->reget() inside the mutex again. A real
// mess, but it gets things working for ICU 3.0. [alan].
@@ -597,7 +591,7 @@ Transliterator* TransliteratorRegistry::reget(const UnicodeString& ID,
if (parser.idBlockVector.isEmpty() && parser.dataVector.isEmpty()) {
entry->u.data = 0;
entry->entryType = TransliteratorEntry::ALIAS;
- entry->stringArg = UNICODE_STRING_SIMPLE("Any-NULL");
+ entry->stringArg = UNICODE_STRING_SIMPLE("Any-nullptr");
}
else if (parser.idBlockVector.isEmpty() && parser.dataVector.size() == 1) {
entry->u.data = (TransliterationRuleData*)parser.dataVector.orphanElementAt(0);
@@ -632,7 +626,7 @@ Transliterator* TransliteratorRegistry::reget(const UnicodeString& ID,
if (U_FAILURE(status)) {
delete data;
}
- entry->stringArg += (UChar)0xffff; // use U+FFFF to mark position of RBTs in ID block
+ entry->stringArg += (char16_t)0xffff; // use U+FFFF to mark position of RBTs in ID block
}
}
}
@@ -648,7 +642,7 @@ void TransliteratorRegistry::put(Transliterator* adoptedProto,
UErrorCode& ec)
{
TransliteratorEntry *entry = new TransliteratorEntry();
- if (entry == NULL) {
+ if (entry == nullptr) {
ec = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -662,7 +656,7 @@ void TransliteratorRegistry::put(const UnicodeString& ID,
UBool visible,
UErrorCode& ec) {
TransliteratorEntry *entry = new TransliteratorEntry();
- if (entry == NULL) {
+ if (entry == nullptr) {
ec = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -677,14 +671,14 @@ void TransliteratorRegistry::put(const UnicodeString& ID,
UBool visible,
UErrorCode& ec) {
TransliteratorEntry *entry = new TransliteratorEntry();
- if (entry == NULL) {
+ if (entry == nullptr) {
ec = U_MEMORY_ALLOCATION_ERROR;
return;
}
entry->entryType = (dir == UTRANS_FORWARD) ? TransliteratorEntry::RULES_FORWARD
: TransliteratorEntry::RULES_REVERSE;
if (readonlyResourceAlias) {
- entry->stringArg.setTo(TRUE, resourceName.getBuffer(), -1);
+ entry->stringArg.setTo(true, resourceName.getBuffer(), -1);
}
else {
entry->stringArg = resourceName;
@@ -699,10 +693,10 @@ void TransliteratorRegistry::put(const UnicodeString& ID,
UErrorCode& /*ec*/) {
TransliteratorEntry *entry = new TransliteratorEntry();
// Null pointer check
- if (entry != NULL) {
+ if (entry != nullptr) {
entry->entryType = TransliteratorEntry::ALIAS;
if (readonlyAliasAlias) {
- entry->stringArg.setTo(TRUE, alias.getBuffer(), -1);
+ entry->stringArg.setTo(true, alias.getBuffer(), -1);
}
else {
entry->stringArg = alias;
@@ -733,7 +727,7 @@ void TransliteratorRegistry::remove(const UnicodeString& ID) {
* To retrieve the actual IDs, call getAvailableID(i) with
* i from 0 to countAvailableIDs() - 1.
*/
-int32_t TransliteratorRegistry::countAvailableIDs(void) const {
+int32_t TransliteratorRegistry::countAvailableIDs() const {
return availableIDs.size();
}
@@ -754,7 +748,7 @@ StringEnumeration* TransliteratorRegistry::getAvailableIDs() const {
return new Enumeration(*this);
}
-int32_t TransliteratorRegistry::countAvailableSources(void) const {
+int32_t TransliteratorRegistry::countAvailableSources() const {
return specDAG.count();
}
@@ -838,7 +832,7 @@ UnicodeString& TransliteratorRegistry::getAvailableVariant(int32_t index,
if (varMask & 1) {
if (varCount == index) {
UnicodeString *v = (UnicodeString*) variantList.elementAt(varListIndex);
- if (v != NULL) {
+ if (v != nullptr) {
result = *v;
return result;
}
@@ -879,7 +873,7 @@ const UnicodeString* TransliteratorRegistry::Enumeration::snext(UErrorCode& stat
// doing as long as there is some possibility of removing this code in favor
// of some new code based on Doug's service framework.
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
int32_t n = reg.availableIDs.size();
if (index > n) {
@@ -891,7 +885,7 @@ const UnicodeString* TransliteratorRegistry::Enumeration::snext(UErrorCode& stat
unistr = *(const UnicodeString*)reg.availableIDs[index++];
return &unistr;
} else {
- return NULL;
+ return nullptr;
}
}
@@ -916,7 +910,7 @@ void TransliteratorRegistry::registerEntry(const UnicodeString& source,
UnicodeString ID;
UnicodeString s(source);
if (s.length() == 0) {
- s.setTo(TRUE, ANY, 3);
+ s.setTo(true, ANY, 3);
}
TransliteratorIDParser::STVtoID(source, target, variant, ID);
registerEntry(ID, s, target, variant, adopted, visible);
@@ -954,7 +948,7 @@ void TransliteratorRegistry::registerEntry(const UnicodeString& ID,
if (!availableIDs.contains((void*) &ID)) {
UnicodeString *newID = ID.clone();
// Check to make sure newID was created.
- if (newID != NULL) {
+ if (newID != nullptr) {
// NUL-terminate the ID string
newID->getTerminatedBuffer();
availableIDs.adoptElement(newID, status);
@@ -984,8 +978,8 @@ void TransliteratorRegistry::registerSTV(const UnicodeString& source,
} else if (source.compare(LAT,3) == 0) {
size = LAT_TARGETS_INIT_SIZE;
}
- targets = new Hashtable(TRUE, size, status);
- if (U_FAILURE(status) || targets == NULL) {
+ targets = new Hashtable(true, size, status);
+ if (U_FAILURE(status) || targets == nullptr) {
return;
}
specDAG.put(source, targets, status);
@@ -997,7 +991,7 @@ void TransliteratorRegistry::registerSTV(const UnicodeString& source,
return;
}
UnicodeString *variantEntry = new UnicodeString(variant);
- if (variantEntry != NULL) {
+ if (variantEntry != nullptr) {
variantList.adoptElement(variantEntry, status);
if (U_SUCCESS(status)) {
variantListIndex = variantList.size() - 1;
@@ -1022,7 +1016,7 @@ void TransliteratorRegistry::removeSTV(const UnicodeString& source,
// assert(target.length() > 0);
UErrorCode status = U_ZERO_ERROR;
Hashtable *targets = (Hashtable*) specDAG.get(source);
- if (targets == NULL) {
+ if (targets == nullptr) {
return; // should never happen for valid s-t/v
}
uint32_t varMask = targets->geti(target);
@@ -1085,18 +1079,18 @@ TransliteratorEntry* TransliteratorRegistry::findInStaticStore(const Translitera
// If we found an entry, store it in the Hashtable for next
// time.
if (entry != 0) {
- registerEntry(src.getTop(), trg.getTop(), variant, entry, FALSE);
+ registerEntry(src.getTop(), trg.getTop(), variant, entry, false);
}
return entry;
}
// As of 2.0, resource bundle keys cannot contain '_'
-static const UChar TRANSLITERATE_TO[] = {84,114,97,110,115,108,105,116,101,114,97,116,101,84,111,0}; // "TransliterateTo"
+static const char16_t TRANSLITERATE_TO[] = {84,114,97,110,115,108,105,116,101,114,97,116,101,84,111,0}; // "TransliterateTo"
-static const UChar TRANSLITERATE_FROM[] = {84,114,97,110,115,108,105,116,101,114,97,116,101,70,114,111,109,0}; // "TransliterateFrom"
+static const char16_t TRANSLITERATE_FROM[] = {84,114,97,110,115,108,105,116,101,114,97,116,101,70,114,111,109,0}; // "TransliterateFrom"
-static const UChar TRANSLITERATE[] = {84,114,97,110,115,108,105,116,101,114,97,116,101,0}; // "Transliterate"
+static const char16_t TRANSLITERATE[] = {84,114,97,110,115,108,105,116,101,114,97,116,101,0}; // "Transliterate"
/**
* Attempt to find an entry in a single resource bundle. This is
@@ -1164,7 +1158,7 @@ TransliteratorEntry* TransliteratorRegistry::findInBundle(const TransliteratorSp
if (pass==2) {
// Failed
- return NULL;
+ return nullptr;
}
// We have succeeded in loading a string from the locale
@@ -1328,15 +1322,15 @@ Transliterator* TransliteratorRegistry::instantiateEntry(const UnicodeString& ID
{
UVector* rbts = new UVector(uprv_deleteUObject, nullptr, entry->u.dataVector->size(), status);
// Check for null pointer
- if (rbts == NULL) {
+ if (rbts == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
int32_t passNumber = 1;
for (int32_t i = 0; U_SUCCESS(status) && i < entry->u.dataVector->size(); i++) {
// TODO: Should passNumber be turned into a decimal-string representation (1 -> "1")?
Transliterator* tl = new RuleBasedTransliterator(UnicodeString(CompoundTransliterator::PASS_STRING) + UnicodeString(passNumber++),
- (TransliterationRuleData*)(entry->u.dataVector->elementAt(i)), FALSE);
+ (TransliterationRuleData*)(entry->u.dataVector->elementAt(i)), false);
if (tl == 0)
status = U_MEMORY_ALLOCATION_ERROR;
else
diff --git a/contrib/libs/icu/i18n/transreg.h b/contrib/libs/icu/i18n/transreg.h
index 686e62ae33..da9c2ee8b9 100644
--- a/contrib/libs/icu/i18n/transreg.h
+++ b/contrib/libs/icu/i18n/transreg.h
@@ -163,13 +163,13 @@ class TransliteratorRegistry : public UMemory {
* compound) attempt to instantiate it from the registry. Return
* 0 on failure.
*
- * Return a non-NULL aliasReturn value if the ID points to an alias.
+ * Return a non-nullptr aliasReturn value if the ID points to an alias.
* We cannot instantiate it ourselves because the alias may contain
* filters or compounds, which we do not understand. Caller should
- * make aliasReturn NULL before calling.
+ * make aliasReturn nullptr before calling.
* @param ID the given ID
* @param aliasReturn output param to receive TransliteratorAlias;
- * should be NULL on entry
+ * should be nullptr on entry
* @param parseError Struct to receive information on position
* of error if an error is encountered
* @param status Output param set to success/failure code.
@@ -191,7 +191,7 @@ class TransliteratorRegistry : public UMemory {
* from within the TransliteratorRegistry mutex.
*
* @param aliasReturn output param to receive TransliteratorAlias;
- * should be NULL on entry
+ * should be nullptr on entry
*/
Transliterator* reget(const UnicodeString& ID,
TransliteratorParser& parser,
@@ -268,7 +268,7 @@ class TransliteratorRegistry : public UMemory {
* @return the number of IDs currently registered with the system.
* @internal
*/
- int32_t countAvailableIDs(void) const;
+ int32_t countAvailableIDs() const;
/**
* == OBSOLETE - remove in ICU 3.4 ==
@@ -287,7 +287,7 @@ class TransliteratorRegistry : public UMemory {
* Return the number of registered source specifiers.
* @return the number of registered source specifiers.
*/
- int32_t countAvailableSources(void) const;
+ int32_t countAvailableSources() const;
/**
* Return a registered source specifier.
@@ -460,7 +460,7 @@ class TransliteratorRegistry : public UMemory {
U_NAMESPACE_END
-U_CFUNC UBool utrans_transliterator_cleanup(void);
+U_CFUNC UBool utrans_transliterator_cleanup();
#endif /* #if !UCONFIG_NO_TRANSLITERATION */
diff --git a/contrib/libs/icu/i18n/tridpars.cpp b/contrib/libs/icu/i18n/tridpars.cpp
index 0ca168e7a3..6c23a0dc90 100644
--- a/contrib/libs/icu/i18n/tridpars.cpp
+++ b/contrib/libs/icu/i18n/tridpars.cpp
@@ -31,21 +31,21 @@
U_NAMESPACE_BEGIN
-static const UChar ID_DELIM = 0x003B; // ;
-static const UChar TARGET_SEP = 0x002D; // -
-static const UChar VARIANT_SEP = 0x002F; // /
-static const UChar OPEN_REV = 0x0028; // (
-static const UChar CLOSE_REV = 0x0029; // )
+static const char16_t ID_DELIM = 0x003B; // ;
+static const char16_t TARGET_SEP = 0x002D; // -
+static const char16_t VARIANT_SEP = 0x002F; // /
+static const char16_t OPEN_REV = 0x0028; // (
+static const char16_t CLOSE_REV = 0x0029; // )
-//static const UChar EMPTY[] = {0}; // ""
-static const UChar ANY[] = {65,110,121,0}; // "Any"
-static const UChar ANY_NULL[] = {65,110,121,45,78,117,108,108,0}; // "Any-Null"
+//static const char16_t EMPTY[] = {0}; // ""
+static const char16_t ANY[] = {65,110,121,0}; // "Any"
+static const char16_t ANY_NULL[] = {65,110,121,45,78,117,108,108,0}; // "Any-Null"
static const int32_t FORWARD = UTRANS_FORWARD;
static const int32_t REVERSE = UTRANS_REVERSE;
-static Hashtable* SPECIAL_INVERSES = NULL;
-static UInitOnce gSpecialInversesInitOnce = U_INITONCE_INITIALIZER;
+static Hashtable* SPECIAL_INVERSES = nullptr;
+static UInitOnce gSpecialInversesInitOnce {};
/**
* The mutex controlling access to SPECIAL_INVERSES
@@ -77,11 +77,11 @@ TransliteratorIDParser::SingleID::SingleID(const UnicodeString& c, const Unicode
Transliterator* TransliteratorIDParser::SingleID::createInstance() {
Transliterator* t;
if (basicID.length() == 0) {
- t = createBasicInstance(UnicodeString(TRUE, ANY_NULL, 8), &canonID);
+ t = createBasicInstance(UnicodeString(true, ANY_NULL, 8), &canonID);
} else {
t = createBasicInstance(basicID, &canonID);
}
- if (t != NULL) {
+ if (t != nullptr) {
if (filter.length() != 0) {
UErrorCode ec = U_ZERO_ERROR;
UnicodeSet *set = new UnicodeSet(filter, ec);
@@ -106,7 +106,7 @@ Transliterator* TransliteratorIDParser::SingleID::createInstance() {
* the last character parsed.
* @param dir the direction. If the direction is REVERSE then the
* SingleID is constructed for the reverse direction.
- * @return a SingleID object or NULL
+ * @return a SingleID object or nullptr
*/
TransliteratorIDParser::SingleID*
TransliteratorIDParser::parseSingleID(const UnicodeString& id, int32_t& pos,
@@ -116,29 +116,29 @@ TransliteratorIDParser::parseSingleID(const UnicodeString& id, int32_t& pos,
// The ID will be of the form A, A(), A(B), or (B), where
// A and B are filter IDs.
- Specs* specsA = NULL;
- Specs* specsB = NULL;
- UBool sawParen = FALSE;
+ Specs* specsA = nullptr;
+ Specs* specsB = nullptr;
+ UBool sawParen = false;
// On the first pass, look for (B) or (). If this fails, then
// on the second pass, look for A, A(B), or A().
for (int32_t pass=1; pass<=2; ++pass) {
if (pass == 2) {
- specsA = parseFilterID(id, pos, TRUE);
- if (specsA == NULL) {
+ specsA = parseFilterID(id, pos, true);
+ if (specsA == nullptr) {
pos = start;
- return NULL;
+ return nullptr;
}
}
if (ICU_Utility::parseChar(id, pos, OPEN_REV)) {
- sawParen = TRUE;
+ sawParen = true;
if (!ICU_Utility::parseChar(id, pos, CLOSE_REV)) {
- specsB = parseFilterID(id, pos, TRUE);
+ specsB = parseFilterID(id, pos, true);
// Must close with a ')'
- if (specsB == NULL || !ICU_Utility::parseChar(id, pos, CLOSE_REV)) {
+ if (specsB == nullptr || !ICU_Utility::parseChar(id, pos, CLOSE_REV)) {
delete specsA;
pos = start;
- return NULL;
+ return nullptr;
}
}
break;
@@ -152,15 +152,15 @@ TransliteratorIDParser::parseSingleID(const UnicodeString& id, int32_t& pos,
SingleID* b = specsToID(specsB, FORWARD);
single = specsToID(specsA, FORWARD);
// Null pointers check
- if (b == NULL || single == NULL) {
+ if (b == nullptr || single == nullptr) {
delete b;
delete single;
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
single->canonID.append(OPEN_REV)
.append(b->canonID).append(CLOSE_REV);
- if (specsA != NULL) {
+ if (specsA != nullptr) {
single->filter = specsA->filter;
}
delete b;
@@ -168,33 +168,33 @@ TransliteratorIDParser::parseSingleID(const UnicodeString& id, int32_t& pos,
SingleID* a = specsToID(specsA, FORWARD);
single = specsToID(specsB, FORWARD);
// Check for null pointer.
- if (a == NULL || single == NULL) {
+ if (a == nullptr || single == nullptr) {
delete a;
delete single;
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
single->canonID.append(OPEN_REV)
.append(a->canonID).append(CLOSE_REV);
- if (specsB != NULL) {
+ if (specsB != nullptr) {
single->filter = specsB->filter;
}
delete a;
}
} else {
- // assert(specsA != NULL);
+ // assert(specsA != nullptr);
if (dir == FORWARD) {
single = specsToID(specsA, FORWARD);
} else {
single = specsToSpecialInverse(*specsA, status);
- if (single == NULL) {
+ if (single == nullptr) {
single = specsToID(specsA, REVERSE);
}
}
- // Check for NULL pointer
- if (single == NULL) {
+ // Check for nullptr pointer
+ if (single == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
single->filter = specsA->filter;
}
@@ -219,15 +219,15 @@ TransliteratorIDParser::parseFilterID(const UnicodeString& id, int32_t& pos) {
int32_t start = pos;
- Specs* specs = parseFilterID(id, pos, TRUE);
- if (specs == NULL) {
+ Specs* specs = parseFilterID(id, pos, true);
+ if (specs == nullptr) {
pos = start;
- return NULL;
+ return nullptr;
}
// Assemble return results
SingleID* single = specsToID(specs, FORWARD);
- if (single != NULL) {
+ if (single != nullptr) {
single->filter = specs->filter;
}
delete specs;
@@ -250,8 +250,8 @@ TransliteratorIDParser::parseFilterID(const UnicodeString& id, int32_t& pos) {
* added to the canonID, either at the end, if dir is FORWARD, or
* at the start, if dir is REVERSE. The pattern will be enclosed
* in parentheses if appropriate, and will be suffixed with an
- * ID_DELIM character. May be NULL.
- * @return a UnicodeSet object or NULL. A non-NULL results
+ * ID_DELIM character. May be nullptr.
+ * @return a UnicodeSet object or nullptr. A non-nullptr results
* indicates a successful parse, regardless of whether the filter
* applies to the given direction. The caller should discard it
* if withParens != (dir == REVERSE).
@@ -260,7 +260,7 @@ UnicodeSet* TransliteratorIDParser::parseGlobalFilter(const UnicodeString& id, i
int32_t dir,
int32_t& withParens,
UnicodeString* canonID) {
- UnicodeSet* filter = NULL;
+ UnicodeSet* filter = nullptr;
int32_t start = pos;
if (withParens == -1) {
@@ -268,17 +268,17 @@ UnicodeSet* TransliteratorIDParser::parseGlobalFilter(const UnicodeString& id, i
} else if (withParens == 1) {
if (!ICU_Utility::parseChar(id, pos, OPEN_REV)) {
pos = start;
- return NULL;
+ return nullptr;
}
}
- ICU_Utility::skipWhitespace(id, pos, TRUE);
+ ICU_Utility::skipWhitespace(id, pos, true);
if (UnicodeSet::resemblesPattern(id, pos)) {
ParsePosition ppos(pos);
UErrorCode ec = U_ZERO_ERROR;
- filter = new UnicodeSet(id, ppos, USET_IGNORE_SPACE, NULL, ec);
- /* test for NULL */
+ filter = new UnicodeSet(id, ppos, USET_IGNORE_SPACE, nullptr, ec);
+ /* test for nullptr */
if (filter == 0) {
pos = start;
return 0;
@@ -286,7 +286,7 @@ UnicodeSet* TransliteratorIDParser::parseGlobalFilter(const UnicodeString& id, i
if (U_FAILURE(ec)) {
delete filter;
pos = start;
- return NULL;
+ return nullptr;
}
UnicodeString pattern;
@@ -296,13 +296,13 @@ UnicodeSet* TransliteratorIDParser::parseGlobalFilter(const UnicodeString& id, i
if (withParens == 1 && !ICU_Utility::parseChar(id, pos, CLOSE_REV)) {
delete filter;
pos = start;
- return NULL;
+ return nullptr;
}
// In the forward direction, append the pattern to the
// canonID. In the reverse, insert it at zero, and invert
// the presence of parens ("A" <-> "(A)").
- if (canonID != NULL) {
+ if (canonID != nullptr) {
if (dir == FORWARD) {
if (withParens == 1) {
pattern.insert(0, OPEN_REV);
@@ -351,8 +351,8 @@ U_CDECL_END
* discarded.
* @param globalFilter OUTPUT parameter that receives a pointer to
* a newly created global filter for this ID in this direction, or
- * NULL if there is none.
- * @return TRUE if the parse succeeds, that is, if the entire
+ * nullptr if there is none.
+ * @return true if the parse succeeds, that is, if the entire
* id is consumed without syntax error.
*/
UBool TransliteratorIDParser::parseCompoundID(const UnicodeString& id, int32_t dir,
@@ -367,13 +367,13 @@ UBool TransliteratorIDParser::parseCompoundID(const UnicodeString& id, int32_t d
UObjectDeleter *save = list.setDeleter(_deleteSingleID);
UnicodeSet* filter;
- globalFilter = NULL;
+ globalFilter = nullptr;
canonID.truncate(0);
// Parse leading global filter, if any
withParens = 0; // parens disallowed
filter = parseGlobalFilter(id, pos, dir, withParens, &canonID);
- if (filter != NULL) {
+ if (filter != nullptr) {
if (!ICU_Utility::parseChar(id, pos, ID_DELIM)) {
// Not a global filter; backup and resume
canonID.truncate(0);
@@ -384,13 +384,13 @@ UBool TransliteratorIDParser::parseCompoundID(const UnicodeString& id, int32_t d
} else {
delete filter;
}
- filter = NULL;
+ filter = nullptr;
}
- UBool sawDelimiter = TRUE;
+ UBool sawDelimiter = true;
for (;;) {
SingleID* single = parseSingleID(id, pos, dir, ec);
- if (single == NULL) {
+ if (single == nullptr) {
break;
}
if (dir == FORWARD) {
@@ -402,7 +402,7 @@ UBool TransliteratorIDParser::parseCompoundID(const UnicodeString& id, int32_t d
goto FAIL;
}
if (!ICU_Utility::parseChar(id, pos, ID_DELIM)) {
- sawDelimiter = FALSE;
+ sawDelimiter = false;
break;
}
}
@@ -425,7 +425,7 @@ UBool TransliteratorIDParser::parseCompoundID(const UnicodeString& id, int32_t d
if (sawDelimiter) {
withParens = 1; // parens required
filter = parseGlobalFilter(id, pos, dir, withParens, &canonID);
- if (filter != NULL) {
+ if (filter != nullptr) {
// Don't require trailing ';', but parse it if present
ICU_Utility::parseChar(id, pos, ID_DELIM);
@@ -434,32 +434,32 @@ UBool TransliteratorIDParser::parseCompoundID(const UnicodeString& id, int32_t d
} else {
delete filter;
}
- filter = NULL;
+ filter = nullptr;
}
}
// Trailing unparsed text is a syntax error
- ICU_Utility::skipWhitespace(id, pos, TRUE);
+ ICU_Utility::skipWhitespace(id, pos, true);
if (pos != id.length()) {
goto FAIL;
}
list.setDeleter(save);
- return TRUE;
+ return true;
FAIL:
list.removeAllElements();
list.setDeleter(save);
delete globalFilter;
- globalFilter = NULL;
- return FALSE;
+ globalFilter = nullptr;
+ return false;
}
/**
* Convert the elements of the 'list' vector, which are SingleID
* objects, into actual Transliterator objects. In the course of
* this, some (or all) entries may be removed. If all entries
- * are removed, the NULL transliterator will be added.
+ * are removed, the nullptr transliterator will be added.
*
* Delete entries with empty basicIDs; these are generated by
* elements like "(A)" in the forward direction, or "A()" in
@@ -492,7 +492,7 @@ void TransliteratorIDParser::instantiateList(UVector& list,
SingleID* single = (SingleID*) list.elementAt(i);
if (single->basicID.length() != 0) {
t = single->createInstance();
- if (t == NULL) {
+ if (t == nullptr) {
ec = U_INVALID_ID;
goto RETURN;
}
@@ -503,10 +503,10 @@ void TransliteratorIDParser::instantiateList(UVector& list,
}
}
- // An empty list is equivalent to a NULL transliterator.
+ // An empty list is equivalent to a nullptr transliterator.
if (tlist.size() == 0) {
- t = createBasicInstance(UnicodeString(TRUE, ANY_NULL, 8), NULL);
- if (t == NULL) {
+ t = createBasicInstance(UnicodeString(true, ANY_NULL, 8), nullptr);
+ if (t == nullptr) {
// Should never happen
ec = U_INTERNAL_TRANSLITERATOR_ERROR;
}
@@ -541,8 +541,8 @@ void TransliteratorIDParser::instantiateList(UVector& list,
* @param id the id string, in any of several forms
* @return an array of 4 strings: source, target, variant, and
* isSourcePresent. If the source is not present, ANY will be
- * given as the source, and isSourcePresent will be NULL. Otherwise
- * isSourcePresent will be non-NULL. The target may be empty if the
+ * given as the source, and isSourcePresent will be nullptr. Otherwise
+ * isSourcePresent will be non-nullptr. The target may be empty if the
* id is not well-formed. The variant may be empty.
*/
void TransliteratorIDParser::IDtoSTV(const UnicodeString& id,
@@ -559,7 +559,7 @@ void TransliteratorIDParser::IDtoSTV(const UnicodeString& id,
if (var < 0) {
var = id.length();
}
- isSourcePresent = FALSE;
+ isSourcePresent = false;
if (sep < 0) {
// Form: T/V or T (or /V)
@@ -569,7 +569,7 @@ void TransliteratorIDParser::IDtoSTV(const UnicodeString& id,
// Form: S-T/V or S-T (or -T/V or -T)
if (sep > 0) {
id.extractBetween(0, sep, source);
- isSourcePresent = TRUE;
+ isSourcePresent = true;
}
id.extractBetween(++sep, var, target);
id.extractBetween(var, id.length(), variant);
@@ -577,7 +577,7 @@ void TransliteratorIDParser::IDtoSTV(const UnicodeString& id,
// Form: (S/V-T or /V-T)
if (var > 0) {
id.extractBetween(0, var, source);
- isSourcePresent = TRUE;
+ isSourcePresent = true;
}
id.extractBetween(var, sep++, variant);
id.extractBetween(sep, id.length(), target);
@@ -607,13 +607,13 @@ void TransliteratorIDParser::STVtoID(const UnicodeString& source,
}
// NUL-terminate the ID string for getTerminatedBuffer.
// This prevents valgrind and Purify warnings.
- id.append((UChar)0);
+ id.append((char16_t)0);
id.truncate(id.length()-1);
}
/**
* Register two targets as being inverses of one another. For
- * example, calling registerSpecialInverse("NFC", "NFD", TRUE) causes
+ * example, calling registerSpecialInverse("NFC", "NFD", true) causes
* Transliterator to form the following inverse relationships:
*
* <pre>NFC => NFD
@@ -640,7 +640,7 @@ void TransliteratorIDParser::STVtoID(const UnicodeString& source,
* @param target the target against which to register the inverse
* @param inverseTarget the inverse of target, that is
* Any-target.getInverse() => Any-inverseTarget
- * @param bidirectional if TRUE, register the reverse relation
+ * @param bidirectional if true, register the reverse relation
* as well, that is, Any-inverseTarget.getInverse() => Any-target
*/
void TransliteratorIDParser::registerSpecialInverse(const UnicodeString& target,
@@ -652,22 +652,22 @@ void TransliteratorIDParser::registerSpecialInverse(const UnicodeString& target,
return;
}
- // If target == inverseTarget then force bidirectional => FALSE
+ // If target == inverseTarget then force bidirectional => false
if (bidirectional && 0==target.caseCompare(inverseTarget, U_FOLD_CASE_DEFAULT)) {
- bidirectional = FALSE;
+ bidirectional = false;
}
Mutex lock(&LOCK);
UnicodeString *tempus = new UnicodeString(inverseTarget); // Used for null pointer check before usage.
- if (tempus == NULL) {
+ if (tempus == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
SPECIAL_INVERSES->put(target, tempus, status);
if (bidirectional) {
tempus = new UnicodeString(target);
- if (tempus == NULL) {
+ if (tempus == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -688,15 +688,15 @@ void TransliteratorIDParser::registerSpecialInverse(const UnicodeString& target,
* offset of the first character to parse in id. On output,
* pos is the offset after the last parsed character. If the
* parse failed, pos will be unchanged.
- * @param allowFilter2 if TRUE, a UnicodeSet pattern is allowed
+ * @param allowFilter2 if true, a UnicodeSet pattern is allowed
* at any location between specs or delimiters, and is returned
* as the fifth string in the array.
- * @return a Specs object, or NULL if the parse failed. If
+ * @return a Specs object, or nullptr if the parse failed. If
* neither source nor target was seen in the parsed id, then the
- * parse fails. If allowFilter is TRUE, then the parsed filter
+ * parse fails. If allowFilter is true, then the parsed filter
* pattern is returned in the Specs object, otherwise the returned
- * filter reference is NULL. If the parse fails for any reason
- * NULL is returned.
+ * filter reference is nullptr. If the parse fails for any reason
+ * nullptr is returned.
*/
TransliteratorIDParser::Specs*
TransliteratorIDParser::parseFilterID(const UnicodeString& id, int32_t& pos,
@@ -706,7 +706,7 @@ TransliteratorIDParser::parseFilterID(const UnicodeString& id, int32_t& pos,
UnicodeString target;
UnicodeString variant;
UnicodeString filter;
- UChar delimiter = 0;
+ char16_t delimiter = 0;
int32_t specCount = 0;
int32_t start = pos;
@@ -714,7 +714,7 @@ TransliteratorIDParser::parseFilterID(const UnicodeString& id, int32_t& pos,
// pass: a filter, a delimiter character (either '-' or '/'),
// or a spec (source, target, or variant).
for (;;) {
- ICU_Utility::skipWhitespace(id, pos, TRUE);
+ ICU_Utility::skipWhitespace(id, pos, true);
if (pos == id.length()) {
break;
}
@@ -725,10 +725,10 @@ TransliteratorIDParser::parseFilterID(const UnicodeString& id, int32_t& pos,
ParsePosition ppos(pos);
UErrorCode ec = U_ZERO_ERROR;
- UnicodeSet set(id, ppos, USET_IGNORE_SPACE, NULL, ec);
+ UnicodeSet set(id, ppos, USET_IGNORE_SPACE, nullptr, ec);
if (U_FAILURE(ec)) {
pos = start;
- return NULL;
+ return nullptr;
}
id.extractBetween(pos, ppos.getIndex(), filter);
pos = ppos.getIndex();
@@ -736,7 +736,7 @@ TransliteratorIDParser::parseFilterID(const UnicodeString& id, int32_t& pos,
}
if (delimiter == 0) {
- UChar c = id.charAt(pos);
+ char16_t c = id.charAt(pos);
if ((c == TARGET_SEP && target.length() == 0) ||
(c == VARIANT_SEP && variant.length() == 0)) {
delimiter = c;
@@ -788,14 +788,14 @@ TransliteratorIDParser::parseFilterID(const UnicodeString& id, int32_t& pos,
// Must have either source or target
if (source.length() == 0 && target.length() == 0) {
pos = start;
- return NULL;
+ return nullptr;
}
// Empty source or target defaults to ANY
- UBool sawSource = TRUE;
+ UBool sawSource = true;
if (source.length() == 0) {
source.setTo(ANY, 3);
- sawSource = FALSE;
+ sawSource = false;
}
if (target.length() == 0) {
target.setTo(ANY, 3);
@@ -808,15 +808,15 @@ TransliteratorIDParser::parseFilterID(const UnicodeString& id, int32_t& pos,
* Givens a Spec object, convert it to a SingleID object. The
* Spec object is a more unprocessed parse result. The SingleID
* object contains information about canonical and basic IDs.
- * @return a SingleID; never returns NULL. Returned object always
- * has 'filter' field of NULL.
+ * @return a SingleID; never returns nullptr. Returned object always
+ * has 'filter' field of nullptr.
*/
TransliteratorIDParser::SingleID*
TransliteratorIDParser::specsToID(const Specs* specs, int32_t dir) {
UnicodeString canonID;
UnicodeString basicID;
UnicodeString basicPrefix;
- if (specs != NULL) {
+ if (specs != nullptr) {
UnicodeString buf;
if (dir == FORWARD) {
if (specs->sawSource) {
@@ -845,18 +845,18 @@ TransliteratorIDParser::specsToID(const Specs* specs, int32_t dir) {
/**
* Given a Specs object, return a SingleID representing the
* special inverse of that ID. If there is no special inverse
- * then return NULL.
- * @return a SingleID or NULL. Returned object always has
- * 'filter' field of NULL.
+ * then return nullptr.
+ * @return a SingleID or nullptr. Returned object always has
+ * 'filter' field of nullptr.
*/
TransliteratorIDParser::SingleID*
TransliteratorIDParser::specsToSpecialInverse(const Specs& specs, UErrorCode &status) {
if (0!=specs.source.caseCompare(ANY, 3, U_FOLD_CASE_DEFAULT)) {
- return NULL;
+ return nullptr;
}
umtx_initOnce(gSpecialInversesInitOnce, init, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
UnicodeString* inverseTarget;
@@ -865,7 +865,7 @@ TransliteratorIDParser::specsToSpecialInverse(const Specs& specs, UErrorCode &st
inverseTarget = (UnicodeString*) SPECIAL_INVERSES->get(specs.target);
umtx_unlock(&LOCK);
- if (inverseTarget != NULL) {
+ if (inverseTarget != nullptr) {
// If the original ID contained "Any-" then make the
// special inverse "Any-Foo"; otherwise make it "Foo".
// So "Any-NFC" => "Any-NFD" but "NFC" => "NFD".
@@ -878,7 +878,7 @@ TransliteratorIDParser::specsToSpecialInverse(const Specs& specs, UErrorCode &st
}
buf.append(*inverseTarget);
- UnicodeString basicID(TRUE, ANY, 3);
+ UnicodeString basicID(true, ANY, 3);
basicID.append(TARGET_SEP).append(*inverseTarget);
if (specs.variant.length() != 0) {
@@ -887,7 +887,7 @@ TransliteratorIDParser::specsToSpecialInverse(const Specs& specs, UErrorCode &st
}
return new SingleID(buf, basicID);
}
- return NULL;
+ return nullptr;
}
/**
@@ -903,11 +903,11 @@ Transliterator* TransliteratorIDParser::createBasicInstance(const UnicodeString&
* Initialize static memory. Called through umtx_initOnce only.
*/
void U_CALLCONV TransliteratorIDParser::init(UErrorCode &status) {
- U_ASSERT(SPECIAL_INVERSES == NULL);
+ U_ASSERT(SPECIAL_INVERSES == nullptr);
ucln_i18n_registerCleanup(UCLN_I18N_TRANSLITERATOR, utrans_transliterator_cleanup);
- SPECIAL_INVERSES = new Hashtable(TRUE, status);
- if (SPECIAL_INVERSES == NULL) {
+ SPECIAL_INVERSES = new Hashtable(true, status);
+ if (SPECIAL_INVERSES == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -920,7 +920,7 @@ void U_CALLCONV TransliteratorIDParser::init(UErrorCode &status) {
void TransliteratorIDParser::cleanup() {
if (SPECIAL_INVERSES) {
delete SPECIAL_INVERSES;
- SPECIAL_INVERSES = NULL;
+ SPECIAL_INVERSES = nullptr;
}
gSpecialInversesInitOnce.reset();
}
diff --git a/contrib/libs/icu/i18n/tzfmt.cpp b/contrib/libs/icu/i18n/tzfmt.cpp
index ef3cfad80c..ed53438c41 100644
--- a/contrib/libs/icu/i18n/tzfmt.cpp
+++ b/contrib/libs/icu/i18n/tzfmt.cpp
@@ -70,35 +70,35 @@ static const char gGmtFormatTag[]= "gmtFormat";
static const char gGmtZeroFormatTag[] = "gmtZeroFormat";
static const char gHourFormatTag[]= "hourFormat";
-static const UChar TZID_GMT[] = {0x0045, 0x0074, 0x0063, 0x002F, 0x0047, 0x004D, 0x0054, 0}; // Etc/GMT
-static const UChar UNKNOWN_ZONE_ID[] = {
+static const char16_t TZID_GMT[] = {0x0045, 0x0074, 0x0063, 0x002F, 0x0047, 0x004D, 0x0054, 0}; // Etc/GMT
+static const char16_t UNKNOWN_ZONE_ID[] = {
0x0045, 0x0074, 0x0063, 0x002F, 0x0055, 0x006E, 0x006B, 0x006E, 0x006F, 0x0077, 0x006E, 0}; // Etc/Unknown
-static const UChar UNKNOWN_SHORT_ZONE_ID[] = {0x0075, 0x006E, 0x006B, 0}; // unk
-static const UChar UNKNOWN_LOCATION[] = {0x0055, 0x006E, 0x006B, 0x006E, 0x006F, 0x0077, 0x006E, 0}; // Unknown
-
-static const UChar DEFAULT_GMT_PATTERN[] = {0x0047, 0x004D, 0x0054, 0x007B, 0x0030, 0x007D, 0}; // GMT{0}
-//static const UChar DEFAULT_GMT_ZERO[] = {0x0047, 0x004D, 0x0054, 0}; // GMT
-static const UChar DEFAULT_GMT_POSITIVE_HM[] = {0x002B, 0x0048, 0x003A, 0x006D, 0x006D, 0}; // +H:mm
-static const UChar DEFAULT_GMT_POSITIVE_HMS[] = {0x002B, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0}; // +H:mm:ss
-static const UChar DEFAULT_GMT_NEGATIVE_HM[] = {0x002D, 0x0048, 0x003A, 0x006D, 0x006D, 0}; // -H:mm
-static const UChar DEFAULT_GMT_NEGATIVE_HMS[] = {0x002D, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0}; // -H:mm:ss
-static const UChar DEFAULT_GMT_POSITIVE_H[] = {0x002B, 0x0048, 0}; // +H
-static const UChar DEFAULT_GMT_NEGATIVE_H[] = {0x002D, 0x0048, 0}; // -H
+static const char16_t UNKNOWN_SHORT_ZONE_ID[] = {0x0075, 0x006E, 0x006B, 0}; // unk
+static const char16_t UNKNOWN_LOCATION[] = {0x0055, 0x006E, 0x006B, 0x006E, 0x006F, 0x0077, 0x006E, 0}; // Unknown
+
+static const char16_t DEFAULT_GMT_PATTERN[] = {0x0047, 0x004D, 0x0054, 0x007B, 0x0030, 0x007D, 0}; // GMT{0}
+//static const char16_t DEFAULT_GMT_ZERO[] = {0x0047, 0x004D, 0x0054, 0}; // GMT
+static const char16_t DEFAULT_GMT_POSITIVE_HM[] = {0x002B, 0x0048, 0x003A, 0x006D, 0x006D, 0}; // +H:mm
+static const char16_t DEFAULT_GMT_POSITIVE_HMS[] = {0x002B, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0}; // +H:mm:ss
+static const char16_t DEFAULT_GMT_NEGATIVE_HM[] = {0x002D, 0x0048, 0x003A, 0x006D, 0x006D, 0}; // -H:mm
+static const char16_t DEFAULT_GMT_NEGATIVE_HMS[] = {0x002D, 0x0048, 0x003A, 0x006D, 0x006D, 0x003A, 0x0073, 0x0073, 0}; // -H:mm:ss
+static const char16_t DEFAULT_GMT_POSITIVE_H[] = {0x002B, 0x0048, 0}; // +H
+static const char16_t DEFAULT_GMT_NEGATIVE_H[] = {0x002D, 0x0048, 0}; // -H
static const UChar32 DEFAULT_GMT_DIGITS[] = {
0x0030, 0x0031, 0x0032, 0x0033, 0x0034,
0x0035, 0x0036, 0x0037, 0x0038, 0x0039
};
-static const UChar DEFAULT_GMT_OFFSET_SEP = 0x003A; // ':'
+static const char16_t DEFAULT_GMT_OFFSET_SEP = 0x003A; // ':'
-static const UChar ARG0[] = {0x007B, 0x0030, 0x007D}; // "{0}"
+static const char16_t ARG0[] = {0x007B, 0x0030, 0x007D}; // "{0}"
static const int32_t ARG0_LEN = 3;
-static const UChar DEFAULT_GMT_OFFSET_MINUTE_PATTERN[] = {0x006D, 0x006D, 0}; // "mm"
-static const UChar DEFAULT_GMT_OFFSET_SECOND_PATTERN[] = {0x0073, 0x0073, 0}; // "ss"
+static const char16_t DEFAULT_GMT_OFFSET_MINUTE_PATTERN[] = {0x006D, 0x006D, 0}; // "mm"
+static const char16_t DEFAULT_GMT_OFFSET_SECOND_PATTERN[] = {0x0073, 0x0073, 0}; // "ss"
-static const UChar ALT_GMT_STRINGS[][4] = {
+static const char16_t ALT_GMT_STRINGS[][4] = {
{0x0047, 0x004D, 0x0054, 0}, // GMT
{0x0055, 0x0054, 0x0043, 0}, // UTC
{0x0055, 0x0054, 0, 0}, // UT
@@ -117,11 +117,11 @@ static const int32_t PARSE_GMT_OFFSET_TYPES[] = {
-1
};
-static const UChar SINGLEQUOTE = 0x0027;
-static const UChar PLUS = 0x002B;
-static const UChar MINUS = 0x002D;
-static const UChar ISO8601_UTC = 0x005A; // 'Z'
-static const UChar ISO8601_SEP = 0x003A; // ':'
+static const char16_t SINGLEQUOTE = 0x0027;
+static const char16_t PLUS = 0x002B;
+static const char16_t MINUS = 0x002D;
+static const char16_t ISO8601_UTC = 0x005A; // 'Z'
+static const char16_t ISO8601_SEP = 0x003A; // ':'
static const int32_t MILLIS_PER_HOUR = 60 * 60 * 1000;
static const int32_t MILLIS_PER_MINUTE = 60 * 1000;
@@ -144,11 +144,11 @@ static const int32_t ALL_GENERIC_NAME_TYPES = UTZGNM_LOCATION | UTZGNM_LONG | UT
#define MAX_OFFSET_DIGITS 6
// Time Zone ID/Short ID trie
-static TextTrieMap *gZoneIdTrie = NULL;
-static icu::UInitOnce gZoneIdTrieInitOnce = U_INITONCE_INITIALIZER;
+static TextTrieMap *gZoneIdTrie = nullptr;
+static icu::UInitOnce gZoneIdTrieInitOnce {};
-static TextTrieMap *gShortZoneIdTrie = NULL;
-static icu::UInitOnce gShortZoneIdTrieInitOnce = U_INITONCE_INITIALIZER;
+static TextTrieMap *gShortZoneIdTrie = nullptr;
+static icu::UInitOnce gShortZoneIdTrieInitOnce {};
static UMutex gLock;
@@ -156,21 +156,21 @@ U_CDECL_BEGIN
/**
* Cleanup callback func
*/
-static UBool U_CALLCONV tzfmt_cleanup(void)
+static UBool U_CALLCONV tzfmt_cleanup()
{
- if (gZoneIdTrie != NULL) {
+ if (gZoneIdTrie != nullptr) {
delete gZoneIdTrie;
}
- gZoneIdTrie = NULL;
+ gZoneIdTrie = nullptr;
gZoneIdTrieInitOnce.reset();
- if (gShortZoneIdTrie != NULL) {
+ if (gShortZoneIdTrie != nullptr) {
delete gShortZoneIdTrie;
}
- gShortZoneIdTrie = NULL;
+ gShortZoneIdTrie = nullptr;
gShortZoneIdTrieInitOnce.reset();
- return TRUE;
+ return true;
}
U_CDECL_END
@@ -194,14 +194,14 @@ public:
static GMTOffsetField* createText(const UnicodeString& text, UErrorCode& status);
static GMTOffsetField* createTimeField(FieldType type, uint8_t width, UErrorCode& status);
static UBool isValid(FieldType type, int32_t width);
- static FieldType getTypeByLetter(UChar ch);
+ static FieldType getTypeByLetter(char16_t ch);
FieldType getType() const;
uint8_t getWidth() const;
- const UChar* getPatternText(void) const;
+ const char16_t* getPatternText() const;
private:
- UChar* fText;
+ char16_t* fText;
FieldType fType;
uint8_t fWidth;
@@ -209,7 +209,7 @@ private:
};
GMTOffsetField::GMTOffsetField()
-: fText(NULL), fType(TEXT), fWidth(0) {
+: fText(nullptr), fType(TEXT), fWidth(0) {
}
GMTOffsetField::~GMTOffsetField() {
@@ -221,20 +221,20 @@ GMTOffsetField::~GMTOffsetField() {
GMTOffsetField*
GMTOffsetField::createText(const UnicodeString& text, UErrorCode& status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
GMTOffsetField* result = new GMTOffsetField();
- if (result == NULL) {
+ if (result == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
int32_t len = text.length();
- result->fText = (UChar*)uprv_malloc((len + 1) * sizeof(UChar));
- if (result->fText == NULL) {
+ result->fText = (char16_t*)uprv_malloc((len + 1) * sizeof(char16_t));
+ if (result->fText == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
delete result;
- return NULL;
+ return nullptr;
}
u_strncpy(result->fText, text.getBuffer(), len);
result->fText[len] = 0;
@@ -247,12 +247,12 @@ GMTOffsetField*
GMTOffsetField::createTimeField(FieldType type, uint8_t width, UErrorCode& status) {
U_ASSERT(type != TEXT);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
GMTOffsetField* result = new GMTOffsetField();
- if (result == NULL) {
+ if (result == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
result->fType = type;
@@ -276,7 +276,7 @@ GMTOffsetField::isValid(FieldType type, int32_t width) {
}
GMTOffsetField::FieldType
-GMTOffsetField::getTypeByLetter(UChar ch) {
+GMTOffsetField::getTypeByLetter(char16_t ch) {
if (ch == 0x0048 /* H */) {
return HOUR;
} else if (ch == 0x006D /* m */) {
@@ -297,8 +297,8 @@ GMTOffsetField::getWidth() const {
return fWidth;
}
-inline const UChar*
-GMTOffsetField::getPatternText(void) const {
+inline const char16_t*
+GMTOffsetField::getPatternText() const {
return fText;
}
@@ -317,11 +317,11 @@ U_CDECL_END
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeZoneFormat)
TimeZoneFormat::TimeZoneFormat(const Locale& locale, UErrorCode& status)
-: fLocale(locale), fTimeZoneNames(NULL), fTimeZoneGenericNames(NULL),
- fDefParseOptionFlags(0), fTZDBTimeZoneNames(NULL) {
+: fLocale(locale), fTimeZoneNames(nullptr), fTimeZoneGenericNames(nullptr),
+ fDefParseOptionFlags(0), fTZDBTimeZoneNames(nullptr) {
for (int32_t i = 0; i < UTZFMT_PAT_COUNT; i++) {
- fGMTOffsetPatternItems[i] = NULL;
+ fGMTOffsetPatternItems[i] = nullptr;
}
const char* region = fLocale.getCountry();
@@ -351,13 +351,13 @@ TimeZoneFormat::TimeZoneFormat(const Locale& locale, UErrorCode& status)
return;
}
- const UChar* gmtPattern = NULL;
- const UChar* hourFormats = NULL;
+ const char16_t* gmtPattern = nullptr;
+ const char16_t* hourFormats = nullptr;
UResourceBundle *zoneBundle = ures_open(U_ICUDATA_ZONE, locale.getName(), &status);
- UResourceBundle *zoneStringsArray = ures_getByKeyWithFallback(zoneBundle, gZoneStringsTag, NULL, &status);
+ UResourceBundle *zoneStringsArray = ures_getByKeyWithFallback(zoneBundle, gZoneStringsTag, nullptr, &status);
if (U_SUCCESS(status)) {
- const UChar* resStr;
+ const char16_t* resStr;
int32_t len;
resStr = ures_getStringByKeyWithFallback(zoneStringsArray, gGmtFormatTag, &len, &status);
if (len > 0) {
@@ -365,7 +365,7 @@ TimeZoneFormat::TimeZoneFormat(const Locale& locale, UErrorCode& status)
}
resStr = ures_getStringByKeyWithFallback(zoneStringsArray, gGmtZeroFormatTag, &len, &status);
if (len > 0) {
- fGMTZeroFormat.setTo(TRUE, resStr, len);
+ fGMTZeroFormat.setTo(true, resStr, len);
}
resStr = ures_getStringByKeyWithFallback(zoneStringsArray, gHourFormatTag, &len, &status);
if (len > 0) {
@@ -375,39 +375,39 @@ TimeZoneFormat::TimeZoneFormat(const Locale& locale, UErrorCode& status)
ures_close(zoneBundle);
}
- if (gmtPattern == NULL) {
+ if (gmtPattern == nullptr) {
gmtPattern = DEFAULT_GMT_PATTERN;
}
- initGMTPattern(UnicodeString(TRUE, gmtPattern, -1), status);
+ initGMTPattern(UnicodeString(true, gmtPattern, -1), status);
- UBool useDefaultOffsetPatterns = TRUE;
+ UBool useDefaultOffsetPatterns = true;
if (hourFormats) {
- UChar *sep = u_strchr(hourFormats, (UChar)0x003B /* ';' */);
- if (sep != NULL) {
+ char16_t *sep = u_strchr(hourFormats, (char16_t)0x003B /* ';' */);
+ if (sep != nullptr) {
UErrorCode tmpStatus = U_ZERO_ERROR;
- fGMTOffsetPatterns[UTZFMT_PAT_POSITIVE_HM].setTo(FALSE, hourFormats, (int32_t)(sep - hourFormats));
- fGMTOffsetPatterns[UTZFMT_PAT_NEGATIVE_HM].setTo(TRUE, sep + 1, -1);
+ fGMTOffsetPatterns[UTZFMT_PAT_POSITIVE_HM].setTo(false, hourFormats, (int32_t)(sep - hourFormats));
+ fGMTOffsetPatterns[UTZFMT_PAT_NEGATIVE_HM].setTo(true, sep + 1, -1);
expandOffsetPattern(fGMTOffsetPatterns[UTZFMT_PAT_POSITIVE_HM], fGMTOffsetPatterns[UTZFMT_PAT_POSITIVE_HMS], tmpStatus);
expandOffsetPattern(fGMTOffsetPatterns[UTZFMT_PAT_NEGATIVE_HM], fGMTOffsetPatterns[UTZFMT_PAT_NEGATIVE_HMS], tmpStatus);
truncateOffsetPattern(fGMTOffsetPatterns[UTZFMT_PAT_POSITIVE_HM], fGMTOffsetPatterns[UTZFMT_PAT_POSITIVE_H], tmpStatus);
truncateOffsetPattern(fGMTOffsetPatterns[UTZFMT_PAT_NEGATIVE_HM], fGMTOffsetPatterns[UTZFMT_PAT_NEGATIVE_H], tmpStatus);
if (U_SUCCESS(tmpStatus)) {
- useDefaultOffsetPatterns = FALSE;
+ useDefaultOffsetPatterns = false;
}
}
}
if (useDefaultOffsetPatterns) {
- fGMTOffsetPatterns[UTZFMT_PAT_POSITIVE_H].setTo(TRUE, DEFAULT_GMT_POSITIVE_H, -1);
- fGMTOffsetPatterns[UTZFMT_PAT_POSITIVE_HM].setTo(TRUE, DEFAULT_GMT_POSITIVE_HM, -1);
- fGMTOffsetPatterns[UTZFMT_PAT_POSITIVE_HMS].setTo(TRUE, DEFAULT_GMT_POSITIVE_HMS, -1);
- fGMTOffsetPatterns[UTZFMT_PAT_NEGATIVE_H].setTo(TRUE, DEFAULT_GMT_NEGATIVE_H, -1);
- fGMTOffsetPatterns[UTZFMT_PAT_NEGATIVE_HM].setTo(TRUE, DEFAULT_GMT_NEGATIVE_HM, -1);
- fGMTOffsetPatterns[UTZFMT_PAT_NEGATIVE_HMS].setTo(TRUE, DEFAULT_GMT_NEGATIVE_HMS, -1);
+ fGMTOffsetPatterns[UTZFMT_PAT_POSITIVE_H].setTo(true, DEFAULT_GMT_POSITIVE_H, -1);
+ fGMTOffsetPatterns[UTZFMT_PAT_POSITIVE_HM].setTo(true, DEFAULT_GMT_POSITIVE_HM, -1);
+ fGMTOffsetPatterns[UTZFMT_PAT_POSITIVE_HMS].setTo(true, DEFAULT_GMT_POSITIVE_HMS, -1);
+ fGMTOffsetPatterns[UTZFMT_PAT_NEGATIVE_H].setTo(true, DEFAULT_GMT_NEGATIVE_H, -1);
+ fGMTOffsetPatterns[UTZFMT_PAT_NEGATIVE_HM].setTo(true, DEFAULT_GMT_NEGATIVE_HM, -1);
+ fGMTOffsetPatterns[UTZFMT_PAT_NEGATIVE_HMS].setTo(true, DEFAULT_GMT_NEGATIVE_HMS, -1);
}
initGMTOffsetPatterns(status);
NumberingSystem* ns = NumberingSystem::createInstance(locale, status);
- UBool useDefDigits = TRUE;
+ UBool useDefDigits = true;
if (ns && !ns->isAlgorithmic()) {
UnicodeString digits = ns->getDescription();
useDefDigits = !toCodePoints(digits, fGMTOffsetDigits, 10);
@@ -419,11 +419,11 @@ TimeZoneFormat::TimeZoneFormat(const Locale& locale, UErrorCode& status)
}
TimeZoneFormat::TimeZoneFormat(const TimeZoneFormat& other)
-: Format(other), fTimeZoneNames(NULL), fTimeZoneGenericNames(NULL),
- fTZDBTimeZoneNames(NULL) {
+: Format(other), fTimeZoneNames(nullptr), fTimeZoneGenericNames(nullptr),
+ fTZDBTimeZoneNames(nullptr) {
for (int32_t i = 0; i < UTZFMT_PAT_COUNT; i++) {
- fGMTOffsetPatternItems[i] = NULL;
+ fGMTOffsetPatternItems[i] = nullptr;
}
*this = other;
}
@@ -446,9 +446,9 @@ TimeZoneFormat::operator=(const TimeZoneFormat& other) {
delete fTimeZoneNames;
delete fTimeZoneGenericNames;
- fTimeZoneGenericNames = NULL;
+ fTimeZoneGenericNames = nullptr;
delete fTZDBTimeZoneNames;
- fTZDBTimeZoneNames = NULL;
+ fTZDBTimeZoneNames = nullptr;
fLocale = other.fLocale;
uprv_memcpy(fTargetRegion, other.fTargetRegion, sizeof(fTargetRegion));
@@ -467,7 +467,7 @@ TimeZoneFormat::operator=(const TimeZoneFormat& other) {
for (int32_t i = 0; i < UTZFMT_PAT_COUNT; i++) {
fGMTOffsetPatterns[i] = other.fGMTOffsetPatterns[i];
delete fGMTOffsetPatternItems[i];
- fGMTOffsetPatternItems[i] = NULL;
+ fGMTOffsetPatternItems[i] = nullptr;
}
initGMTOffsetPatterns(status);
U_ASSERT(U_SUCCESS(status));
@@ -517,7 +517,7 @@ TimeZoneFormat::createInstance(const Locale& locale, UErrorCode& status) {
return tzfmt;
}
delete tzfmt;
- return NULL;
+ return nullptr;
}
// ------------------------------------------------------------------
@@ -550,7 +550,7 @@ TimeZoneFormat::setDefaultParseOptions(uint32_t flags) {
}
uint32_t
-TimeZoneFormat::getDefaultParseOptions(void) const {
+TimeZoneFormat::getDefaultParseOptions() const {
return fDefParseOptionFlags;
}
@@ -599,7 +599,7 @@ TimeZoneFormat::setGMTOffsetPattern(UTimeZoneFormatGMTOffsetPatternType type, co
}
UVector* patternItems = parseOffsetPattern(pattern, required, status);
- if (patternItems == NULL) {
+ if (patternItems == nullptr) {
return;
}
@@ -652,12 +652,12 @@ TimeZoneFormat::setGMTZeroFormat(const UnicodeString& gmtZeroFormat, UErrorCode&
UnicodeString&
TimeZoneFormat::format(UTimeZoneFormatStyle style, const TimeZone& tz, UDate date,
- UnicodeString& name, UTimeZoneFormatTimeType* timeType /* = NULL */) const {
+ UnicodeString& name, UTimeZoneFormatTimeType* timeType /* = nullptr */) const {
if (timeType) {
*timeType = UTZFMT_TIME_TYPE_UNKNOWN;
}
- UBool noOffsetFormatFallback = FALSE;
+ UBool noOffsetFormatFallback = false;
switch (style) {
case UTZFMT_STYLE_GENERIC_LOCATION:
@@ -678,22 +678,22 @@ TimeZoneFormat::format(UTimeZoneFormatStyle style, const TimeZone& tz, UDate dat
case UTZFMT_STYLE_ZONE_ID:
tz.getID(name);
- noOffsetFormatFallback = TRUE;
+ noOffsetFormatFallback = true;
break;
case UTZFMT_STYLE_ZONE_ID_SHORT:
{
- const UChar* shortID = ZoneMeta::getShortID(tz);
- if (shortID == NULL) {
+ const char16_t* shortID = ZoneMeta::getShortID(tz);
+ if (shortID == nullptr) {
shortID = UNKNOWN_SHORT_ZONE_ID;
}
name.setTo(shortID, -1);
}
- noOffsetFormatFallback = TRUE;
+ noOffsetFormatFallback = true;
break;
case UTZFMT_STYLE_EXEMPLAR_LOCATION:
formatExemplarLocation(tz, name);
- noOffsetFormatFallback = TRUE;
+ noOffsetFormatFallback = true;
break;
default:
@@ -704,7 +704,7 @@ TimeZoneFormat::format(UTimeZoneFormatStyle style, const TimeZone& tz, UDate dat
if (name.isEmpty() && !noOffsetFormatFallback) {
UErrorCode status = U_ZERO_ERROR;
int32_t rawOffset, dstOffset;
- tz.getOffset(date, FALSE, rawOffset, dstOffset, status);
+ tz.getOffset(date, false, rawOffset, dstOffset, status);
int32_t offset = rawOffset + dstOffset;
if (U_SUCCESS(status)) {
switch (style) {
@@ -722,43 +722,43 @@ TimeZoneFormat::format(UTimeZoneFormatStyle style, const TimeZone& tz, UDate dat
break;
case UTZFMT_STYLE_ISO_BASIC_SHORT:
- formatOffsetISO8601Basic(offset, TRUE, TRUE, TRUE, name, status);
+ formatOffsetISO8601Basic(offset, true, true, true, name, status);
break;
case UTZFMT_STYLE_ISO_BASIC_LOCAL_SHORT:
- formatOffsetISO8601Basic(offset, FALSE, TRUE, TRUE, name, status);
+ formatOffsetISO8601Basic(offset, false, true, true, name, status);
break;
case UTZFMT_STYLE_ISO_BASIC_FIXED:
- formatOffsetISO8601Basic(offset, TRUE, FALSE, TRUE, name, status);
+ formatOffsetISO8601Basic(offset, true, false, true, name, status);
break;
case UTZFMT_STYLE_ISO_BASIC_LOCAL_FIXED:
- formatOffsetISO8601Basic(offset, FALSE, FALSE, TRUE, name, status);
+ formatOffsetISO8601Basic(offset, false, false, true, name, status);
break;
case UTZFMT_STYLE_ISO_EXTENDED_FIXED:
- formatOffsetISO8601Extended(offset, TRUE, FALSE, TRUE, name, status);
+ formatOffsetISO8601Extended(offset, true, false, true, name, status);
break;
case UTZFMT_STYLE_ISO_EXTENDED_LOCAL_FIXED:
- formatOffsetISO8601Extended(offset, FALSE, FALSE, TRUE, name, status);
+ formatOffsetISO8601Extended(offset, false, false, true, name, status);
break;
case UTZFMT_STYLE_ISO_BASIC_FULL:
- formatOffsetISO8601Basic(offset, TRUE, FALSE, FALSE, name, status);
+ formatOffsetISO8601Basic(offset, true, false, false, name, status);
break;
case UTZFMT_STYLE_ISO_BASIC_LOCAL_FULL:
- formatOffsetISO8601Basic(offset, FALSE, FALSE, FALSE, name, status);
+ formatOffsetISO8601Basic(offset, false, false, false, name, status);
break;
case UTZFMT_STYLE_ISO_EXTENDED_FULL:
- formatOffsetISO8601Extended(offset, TRUE, FALSE, FALSE, name, status);
+ formatOffsetISO8601Extended(offset, true, false, false, name, status);
break;
case UTZFMT_STYLE_ISO_EXTENDED_LOCAL_FULL:
- formatOffsetISO8601Extended(offset, FALSE, FALSE, FALSE, name, status);
+ formatOffsetISO8601Extended(offset, false, false, false, name, status);
break;
default:
@@ -785,17 +785,17 @@ TimeZoneFormat::format(const Formattable& obj, UnicodeString& appendTo,
if (obj.getType() == Formattable::kObject) {
const UObject* formatObj = obj.getObject();
const TimeZone* tz = dynamic_cast<const TimeZone*>(formatObj);
- if (tz == NULL) {
+ if (tz == nullptr) {
const Calendar* cal = dynamic_cast<const Calendar*>(formatObj);
- if (cal != NULL) {
+ if (cal != nullptr) {
tz = &cal->getTimeZone();
date = cal->getTime(status);
}
}
- if (tz != NULL) {
+ if (tz != nullptr) {
int32_t rawOffset, dstOffset;
- tz->getOffset(date, FALSE, rawOffset, dstOffset, status);
- UChar buf[ZONE_NAME_U16_MAX];
+ tz->getOffset(date, false, rawOffset, dstOffset, status);
+ char16_t buf[ZONE_NAME_U16_MAX];
UnicodeString result(buf, 0, UPRV_LENGTHOF(buf));
formatOffsetLocalizedGMT(rawOffset + dstOffset, result, status);
if (U_SUCCESS(status)) {
@@ -812,13 +812,13 @@ TimeZoneFormat::format(const Formattable& obj, UnicodeString& appendTo,
TimeZone*
TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, ParsePosition& pos,
- UTimeZoneFormatTimeType* timeType /*= NULL*/) const {
+ UTimeZoneFormatTimeType* timeType /*= nullptr*/) const {
return parse(style, text, pos, getDefaultParseOptions(), timeType);
}
TimeZone*
TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, ParsePosition& pos,
- int32_t parseOptions, UTimeZoneFormatTimeType* timeType /* = NULL */) const {
+ int32_t parseOptions, UTimeZoneFormatTimeType* timeType /* = nullptr */) const {
if (timeType) {
*timeType = UTZFMT_TIME_TYPE_UNKNOWN;
}
@@ -841,7 +841,7 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
// Try localized GMT format first if necessary
if (fallbackLocalizedGMT || fallbackShortLocalizedGMT) {
- UBool hasDigitOffset = FALSE;
+ UBool hasDigitOffset = false;
offset = parseOffsetLocalizedGMT(text, tmpPos, fallbackShortLocalizedGMT, &hasDigitOffset);
if (tmpPos.getErrorIndex() == -1) {
// Even when the input text was successfully parsed as a localized GMT format text,
@@ -862,7 +862,7 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
}
UErrorCode status = U_ZERO_ERROR;
- UChar tzIDBuf[32];
+ char16_t tzIDBuf[32];
UnicodeString tzID(tzIDBuf, 0, UPRV_LENGTHOF(tzIDBuf));
UBool parseTZDBAbbrev = ((parseOptions & UTZFMT_PARSE_OPTION_TZ_DATABASE_ABBREVIATIONS) != 0);
@@ -931,8 +931,8 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
tmpPos.setErrorIndex(-1);
// Exclude the case of UTC Indicator "Z" here
- UBool hasDigitOffset = FALSE;
- offset = parseOffsetISO8601(text, tmpPos, FALSE, &hasDigitOffset);
+ UBool hasDigitOffset = false;
+ offset = parseOffsetISO8601(text, tmpPos, false, &hasDigitOffset);
if (tmpPos.getErrorIndex() == -1 && hasDigitOffset) {
pos.setIndex(tmpPos.getIndex());
return createTimeZoneForOffset(offset);
@@ -955,7 +955,7 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
LocalPointer<TimeZoneNames::MatchInfoCollection> specificMatches(fTimeZoneNames->find(text, startIdx, nameTypes, status));
if (U_FAILURE(status)) {
pos.setErrorIndex(startIdx);
- return NULL;
+ return nullptr;
}
if (!specificMatches.isNull()) {
int32_t matchIdx = -1;
@@ -988,7 +988,7 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
tzdbTimeZoneNames->find(text, startIdx, nameTypes, status));
if (U_FAILURE(status)) {
pos.setErrorIndex(startIdx);
- return NULL;
+ return nullptr;
}
if (!tzdbNameMatches.isNull()) {
int32_t matchIdx = -1;
@@ -1044,7 +1044,7 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
}
if (U_FAILURE(status)) {
pos.setErrorIndex(startIdx);
- return NULL;
+ return nullptr;
}
if (len > 0) {
// Found a match
@@ -1112,7 +1112,7 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
// Failed to parse the input text as the time zone format in the specified style.
// Check the longest match among other styles below.
- UChar parsedIDBuf[32];
+ char16_t parsedIDBuf[32];
UnicodeString parsedID(parsedIDBuf, 0, UPRV_LENGTHOF(parsedIDBuf));
UTimeZoneFormatTimeType parsedTimeType = UTZFMT_TIME_TYPE_UNKNOWN;
@@ -1125,8 +1125,8 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
tmpPos.setIndex(startIdx);
tmpPos.setErrorIndex(-1);
- UBool hasDigitOffset = FALSE;
- offset = parseOffsetISO8601(text, tmpPos, FALSE, &hasDigitOffset);
+ UBool hasDigitOffset = false;
+ offset = parseOffsetISO8601(text, tmpPos, false, &hasDigitOffset);
if (tmpPos.getErrorIndex() == -1) {
if (tmpPos.getIndex() == maxPos || hasDigitOffset) {
pos.setIndex(tmpPos.getIndex());
@@ -1151,8 +1151,8 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
tmpPos.setIndex(startIdx);
tmpPos.setErrorIndex(-1);
- UBool hasDigitOffset = FALSE;
- offset = parseOffsetLocalizedGMT(text, tmpPos, FALSE, &hasDigitOffset);
+ UBool hasDigitOffset = false;
+ offset = parseOffsetLocalizedGMT(text, tmpPos, false, &hasDigitOffset);
if (tmpPos.getErrorIndex() == -1) {
if (tmpPos.getIndex() == maxPos || hasDigitOffset) {
pos.setIndex(tmpPos.getIndex());
@@ -1173,8 +1173,8 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
tmpPos.setIndex(startIdx);
tmpPos.setErrorIndex(-1);
- UBool hasDigitOffset = FALSE;
- offset = parseOffsetLocalizedGMT(text, tmpPos, TRUE, &hasDigitOffset);
+ UBool hasDigitOffset = false;
+ offset = parseOffsetLocalizedGMT(text, tmpPos, true, &hasDigitOffset);
if (tmpPos.getErrorIndex() == -1) {
if (tmpPos.getIndex() == maxPos || hasDigitOffset) {
pos.setIndex(tmpPos.getIndex());
@@ -1205,7 +1205,7 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
LocalPointer<TimeZoneNames::MatchInfoCollection> specificMatches(fTimeZoneNames->find(text, startIdx, ALL_SIMPLE_NAME_TYPES, status));
if (U_FAILURE(status)) {
pos.setErrorIndex(startIdx);
- return NULL;
+ return nullptr;
}
int32_t specificMatchIdx = -1;
int32_t matchPos = -1;
@@ -1232,7 +1232,7 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
tzdbTimeZoneNames->find(text, startIdx, ALL_SIMPLE_NAME_TYPES, status));
if (U_FAILURE(status)) {
pos.setErrorIndex(startIdx);
- return NULL;
+ return nullptr;
}
int32_t tzdbNameMatchIdx = -1;
int32_t matchPos = -1;
@@ -1264,7 +1264,7 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
}
if (U_FAILURE(status)) {
pos.setErrorIndex(startIdx);
- return NULL;
+ return nullptr;
}
if (genMatchLen > 0 && parsedPos < startIdx + genMatchLen) {
@@ -1320,7 +1320,7 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
}
pos.setErrorIndex(startIdx);
- return NULL;
+ return nullptr;
}
void
@@ -1343,12 +1343,12 @@ TimeZoneFormat::formatGeneric(const TimeZone& tz, int32_t genType, UDate date, U
}
if (genType == UTZGNM_LOCATION) {
- const UChar* canonicalID = ZoneMeta::getCanonicalCLDRID(tz);
- if (canonicalID == NULL) {
+ const char16_t* canonicalID = ZoneMeta::getCanonicalCLDRID(tz);
+ if (canonicalID == nullptr) {
name.setToBogus();
return name;
}
- return gnames->getGenericLocationName(UnicodeString(TRUE, canonicalID, -1), name);
+ return gnames->getGenericLocationName(UnicodeString(true, canonicalID, -1), name);
}
return gnames->getDisplayName(tz, (UTimeZoneGenericNameType)genType, date, name);
}
@@ -1356,24 +1356,24 @@ TimeZoneFormat::formatGeneric(const TimeZone& tz, int32_t genType, UDate date, U
UnicodeString&
TimeZoneFormat::formatSpecific(const TimeZone& tz, UTimeZoneNameType stdType, UTimeZoneNameType dstType,
UDate date, UnicodeString& name, UTimeZoneFormatTimeType *timeType) const {
- if (fTimeZoneNames == NULL) {
+ if (fTimeZoneNames == nullptr) {
name.setToBogus();
return name;
}
UErrorCode status = U_ZERO_ERROR;
UBool isDaylight = tz.inDaylightTime(date, status);
- const UChar* canonicalID = ZoneMeta::getCanonicalCLDRID(tz);
+ const char16_t* canonicalID = ZoneMeta::getCanonicalCLDRID(tz);
- if (U_FAILURE(status) || canonicalID == NULL) {
+ if (U_FAILURE(status) || canonicalID == nullptr) {
name.setToBogus();
return name;
}
if (isDaylight) {
- fTimeZoneNames->getDisplayName(UnicodeString(TRUE, canonicalID, -1), dstType, date, name);
+ fTimeZoneNames->getDisplayName(UnicodeString(true, canonicalID, -1), dstType, date, name);
} else {
- fTimeZoneNames->getDisplayName(UnicodeString(TRUE, canonicalID, -1), stdType, date, name);
+ fTimeZoneNames->getDisplayName(UnicodeString(true, canonicalID, -1), stdType, date, name);
}
if (timeType && !name.isEmpty()) {
@@ -1385,11 +1385,11 @@ TimeZoneFormat::formatSpecific(const TimeZone& tz, UTimeZoneNameType stdType, UT
const TimeZoneGenericNames*
TimeZoneFormat::getTimeZoneGenericNames(UErrorCode& status) const {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
umtx_lock(&gLock);
- if (fTimeZoneGenericNames == NULL) {
+ if (fTimeZoneGenericNames == nullptr) {
TimeZoneFormat *nonConstThis = const_cast<TimeZoneFormat *>(this);
nonConstThis->fTimeZoneGenericNames = TimeZoneGenericNames::createInstance(fLocale, status);
}
@@ -1401,13 +1401,13 @@ TimeZoneFormat::getTimeZoneGenericNames(UErrorCode& status) const {
const TZDBTimeZoneNames*
TimeZoneFormat::getTZDBTimeZoneNames(UErrorCode& status) const {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
umtx_lock(&gLock);
- if (fTZDBTimeZoneNames == NULL) {
+ if (fTZDBTimeZoneNames == nullptr) {
TZDBTimeZoneNames *tzdbNames = new TZDBTimeZoneNames(fLocale);
- if (tzdbNames == NULL) {
+ if (tzdbNames == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
TimeZoneFormat *nonConstThis = const_cast<TimeZoneFormat *>(this);
@@ -1421,18 +1421,18 @@ TimeZoneFormat::getTZDBTimeZoneNames(UErrorCode& status) const {
UnicodeString&
TimeZoneFormat::formatExemplarLocation(const TimeZone& tz, UnicodeString& name) const {
- UChar locationBuf[ZONE_NAME_U16_MAX];
+ char16_t locationBuf[ZONE_NAME_U16_MAX];
UnicodeString location(locationBuf, 0, UPRV_LENGTHOF(locationBuf));
- const UChar* canonicalID = ZoneMeta::getCanonicalCLDRID(tz);
+ const char16_t* canonicalID = ZoneMeta::getCanonicalCLDRID(tz);
if (canonicalID) {
- fTimeZoneNames->getExemplarLocationName(UnicodeString(TRUE, canonicalID, -1), location);
+ fTimeZoneNames->getExemplarLocationName(UnicodeString(true, canonicalID, -1), location);
}
if (location.length() > 0) {
name.setTo(location);
} else {
// Use "unknown" location
- fTimeZoneNames->getExemplarLocationName(UnicodeString(TRUE, UNKNOWN_ZONE_ID, -1), location);
+ fTimeZoneNames->getExemplarLocationName(UnicodeString(true, UNKNOWN_ZONE_ID, -1), location);
if (location.length() > 0) {
name.setTo(location);
} else {
@@ -1450,38 +1450,38 @@ TimeZoneFormat::formatExemplarLocation(const TimeZone& tz, UnicodeString& name)
UnicodeString&
TimeZoneFormat::formatOffsetISO8601Basic(int32_t offset, UBool useUtcIndicator, UBool isShort, UBool ignoreSeconds,
UnicodeString& result, UErrorCode& status) const {
- return formatOffsetISO8601(offset, TRUE, useUtcIndicator, isShort, ignoreSeconds, result, status);
+ return formatOffsetISO8601(offset, true, useUtcIndicator, isShort, ignoreSeconds, result, status);
}
UnicodeString&
TimeZoneFormat::formatOffsetISO8601Extended(int32_t offset, UBool useUtcIndicator, UBool isShort, UBool ignoreSeconds,
UnicodeString& result, UErrorCode& status) const {
- return formatOffsetISO8601(offset, FALSE, useUtcIndicator, isShort, ignoreSeconds, result, status);
+ return formatOffsetISO8601(offset, false, useUtcIndicator, isShort, ignoreSeconds, result, status);
}
UnicodeString&
TimeZoneFormat::formatOffsetLocalizedGMT(int32_t offset, UnicodeString& result, UErrorCode& status) const {
- return formatOffsetLocalizedGMT(offset, FALSE, result, status);
+ return formatOffsetLocalizedGMT(offset, false, result, status);
}
UnicodeString&
TimeZoneFormat::formatOffsetShortLocalizedGMT(int32_t offset, UnicodeString& result, UErrorCode& status) const {
- return formatOffsetLocalizedGMT(offset, TRUE, result, status);
+ return formatOffsetLocalizedGMT(offset, true, result, status);
}
int32_t
TimeZoneFormat::parseOffsetISO8601(const UnicodeString& text, ParsePosition& pos) const {
- return parseOffsetISO8601(text, pos, FALSE);
+ return parseOffsetISO8601(text, pos, false);
}
int32_t
TimeZoneFormat::parseOffsetLocalizedGMT(const UnicodeString& text, ParsePosition& pos) const {
- return parseOffsetLocalizedGMT(text, pos, FALSE, NULL);
+ return parseOffsetLocalizedGMT(text, pos, false, nullptr);
}
int32_t
TimeZoneFormat::parseOffsetShortLocalizedGMT(const UnicodeString& text, ParsePosition& pos) const {
- return parseOffsetLocalizedGMT(text, pos, TRUE, NULL);
+ return parseOffsetLocalizedGMT(text, pos, true, nullptr);
}
// ------------------------------------------------------------------
@@ -1502,7 +1502,7 @@ TimeZoneFormat::formatOffsetISO8601(int32_t offset, UBool isBasic, UBool useUtcI
OffsetFields minFields = isShort ? FIELDS_H : FIELDS_HM;
OffsetFields maxFields = ignoreSeconds ? FIELDS_HM : FIELDS_HMS;
- UChar sep = isBasic ? 0 : ISO8601_SEP;
+ char16_t sep = isBasic ? 0 : ISO8601_SEP;
// Note: FIELDS_HMS as maxFields is a CLDR/ICU extension. ISO 8601 specification does
// not support seconds field.
@@ -1532,7 +1532,7 @@ TimeZoneFormat::formatOffsetISO8601(int32_t offset, UBool isBasic, UBool useUtcI
lastIdx--;
}
- UChar sign = PLUS;
+ char16_t sign = PLUS;
if (offset < 0) {
// if all output fields are 0s, do not use negative sign
for (int32_t idx = 0; idx <= lastIdx; idx++) {
@@ -1548,8 +1548,8 @@ TimeZoneFormat::formatOffsetISO8601(int32_t offset, UBool isBasic, UBool useUtcI
if (sep && idx != 0) {
result.append(sep);
}
- result.append((UChar)(0x0030 + fields[idx]/10));
- result.append((UChar)(0x0030 + fields[idx]%10));
+ result.append((char16_t)(0x0030 + fields[idx]/10));
+ result.append((char16_t)(0x0030 + fields[idx]%10));
}
return result;
@@ -1572,10 +1572,10 @@ TimeZoneFormat::formatOffsetLocalizedGMT(int32_t offset, UBool isShort, UnicodeS
return result;
}
- UBool positive = TRUE;
+ UBool positive = true;
if (offset < 0) {
offset = -offset;
- positive = FALSE;
+ positive = false;
}
int32_t offsetH = offset / MILLIS_PER_HOUR;
@@ -1586,7 +1586,7 @@ TimeZoneFormat::formatOffsetLocalizedGMT(int32_t offset, UBool isShort, UnicodeS
U_ASSERT(offsetH <= MAX_OFFSET_HOUR && offsetM <= MAX_OFFSET_MINUTE && offsetS <= MAX_OFFSET_SECOND);
- const UVector* offsetPatternItems = NULL;
+ const UVector* offsetPatternItems = nullptr;
if (positive) {
if (offsetS != 0) {
offsetPatternItems = fGMTOffsetPatternItems[UTZFMT_PAT_POSITIVE_HMS];
@@ -1605,7 +1605,7 @@ TimeZoneFormat::formatOffsetLocalizedGMT(int32_t offset, UBool isShort, UnicodeS
}
}
- U_ASSERT(offsetPatternItems != NULL);
+ U_ASSERT(offsetPatternItems != nullptr);
// Building the GMT format string
result.setTo(fGMTPatternPrefix);
@@ -1638,9 +1638,9 @@ TimeZoneFormat::formatOffsetLocalizedGMT(int32_t offset, UBool isShort, UnicodeS
}
int32_t
-TimeZoneFormat::parseOffsetISO8601(const UnicodeString& text, ParsePosition& pos, UBool extendedOnly, UBool* hasDigitOffset /* = NULL */) const {
+TimeZoneFormat::parseOffsetISO8601(const UnicodeString& text, ParsePosition& pos, UBool extendedOnly, UBool* hasDigitOffset /* = nullptr */) const {
if (hasDigitOffset) {
- *hasDigitOffset = FALSE;
+ *hasDigitOffset = false;
}
int32_t start = pos.getIndex();
if (start >= text.length()) {
@@ -1648,8 +1648,8 @@ TimeZoneFormat::parseOffsetISO8601(const UnicodeString& text, ParsePosition& pos
return 0;
}
- UChar firstChar = text.charAt(start);
- if (firstChar == ISO8601_UTC || firstChar == (UChar)(ISO8601_UTC + 0x20)) {
+ char16_t firstChar = text.charAt(start);
+ if (firstChar == ISO8601_UTC || firstChar == (char16_t)(ISO8601_UTC + 0x20)) {
// "Z" (or "z") - indicates UTC
pos.setIndex(start + 1);
return 0;
@@ -1672,7 +1672,7 @@ TimeZoneFormat::parseOffsetISO8601(const UnicodeString& text, ParsePosition& pos
// as basic format. For example, "0230" can be parsed as offset 2:00 (only first digits are valid for
// extended format), but it can be parsed as offset 2:30 with basic format. We use longer result.
ParsePosition posBasic(start + 1);
- int32_t tmpOffset = parseAbuttingAsciiOffsetFields(text, posBasic, FIELDS_H, FIELDS_HMS, FALSE);
+ int32_t tmpOffset = parseAbuttingAsciiOffsetFields(text, posBasic, FIELDS_H, FIELDS_HMS, false);
if (posBasic.getErrorIndex() == -1 && posBasic.getIndex() > posOffset.getIndex()) {
offset = tmpOffset;
posOffset.setIndex(posBasic.getIndex());
@@ -1686,7 +1686,7 @@ TimeZoneFormat::parseOffsetISO8601(const UnicodeString& text, ParsePosition& pos
pos.setIndex(posOffset.getIndex());
if (hasDigitOffset) {
- *hasDigitOffset = TRUE;
+ *hasDigitOffset = true;
}
return sign * offset;
}
@@ -1698,7 +1698,7 @@ TimeZoneFormat::parseOffsetLocalizedGMT(const UnicodeString& text, ParsePosition
int32_t parsedLength = 0;
if (hasDigitOffset) {
- *hasDigitOffset = FALSE;
+ *hasDigitOffset = false;
}
offset = parseOffsetLocalizedGMTPattern(text, start, isShort, parsedLength);
@@ -1715,7 +1715,7 @@ TimeZoneFormat::parseOffsetLocalizedGMT(const UnicodeString& text, ParsePosition
if (parsedLength > 0) {
if (hasDigitOffset) {
- *hasDigitOffset = TRUE;
+ *hasDigitOffset = true;
}
pos.setIndex(start + parsedLength);
return offset;
@@ -1725,7 +1725,7 @@ TimeZoneFormat::parseOffsetLocalizedGMT(const UnicodeString& text, ParsePosition
offset = parseOffsetDefaultLocalizedGMT(text, start, parsedLength);
if (parsedLength > 0) {
if (hasDigitOffset) {
- *hasDigitOffset = TRUE;
+ *hasDigitOffset = true;
}
pos.setIndex(start + parsedLength);
return offset;
@@ -1739,7 +1739,7 @@ TimeZoneFormat::parseOffsetLocalizedGMT(const UnicodeString& text, ParsePosition
// Check if this is a default GMT zero format
for (int32_t i = 0; ALT_GMT_STRINGS[i][0] != 0; i++) {
- const UChar* defGMTZero = ALT_GMT_STRINGS[i];
+ const char16_t* defGMTZero = ALT_GMT_STRINGS[i];
int32_t defGMTZeroLen = u_strlen(defGMTZero);
if (text.caseCompare(start, defGMTZeroLen, defGMTZero, 0) == 0) {
pos.setIndex(start + defGMTZeroLen);
@@ -1756,7 +1756,7 @@ int32_t
TimeZoneFormat::parseOffsetLocalizedGMTPattern(const UnicodeString& text, int32_t start, UBool /*isShort*/, int32_t& parsedLen) const {
int32_t idx = start;
int32_t offset = 0;
- UBool parsed = FALSE;
+ UBool parsed = false;
do {
// Prefix part
@@ -1768,7 +1768,7 @@ TimeZoneFormat::parseOffsetLocalizedGMTPattern(const UnicodeString& text, int32_
idx += len;
// Offset part
- offset = parseOffsetFields(text, idx, FALSE, len);
+ offset = parseOffsetFields(text, idx, false, len);
if (len == 0) {
// offset field match failed
break;
@@ -1781,8 +1781,8 @@ TimeZoneFormat::parseOffsetLocalizedGMTPattern(const UnicodeString& text, int32_
break;
}
idx += len;
- parsed = TRUE;
- } while (FALSE);
+ parsed = true;
+ } while (false);
parsedLen = parsed ? idx - start : 0;
return offset;
@@ -1802,9 +1802,9 @@ TimeZoneFormat::parseOffsetFields(const UnicodeString& text, int32_t start, UBoo
for (int32_t patidx = 0; PARSE_GMT_OFFSET_TYPES[patidx] >= 0; patidx++) {
int32_t gmtPatType = PARSE_GMT_OFFSET_TYPES[patidx];
UVector* items = fGMTOffsetPatternItems[gmtPatType];
- U_ASSERT(items != NULL);
+ U_ASSERT(items != nullptr);
- outLen = parseOffsetFieldsWithPattern(text, start, items, FALSE, offsetH, offsetM, offsetS);
+ outLen = parseOffsetFieldsWithPattern(text, start, items, false, offsetH, offsetM, offsetS);
if (outLen > 0) {
sign = (gmtPatType == UTZFMT_PAT_POSITIVE_H || gmtPatType == UTZFMT_PAT_POSITIVE_HM || gmtPatType == UTZFMT_PAT_POSITIVE_HMS) ?
1 : -1;
@@ -1826,10 +1826,10 @@ TimeZoneFormat::parseOffsetFields(const UnicodeString& text, int32_t start, UBoo
for (int32_t patidx = 0; PARSE_GMT_OFFSET_TYPES[patidx] >= 0; patidx++) {
int32_t gmtPatType = PARSE_GMT_OFFSET_TYPES[patidx];
UVector* items = fGMTOffsetPatternItems[gmtPatType];
- U_ASSERT(items != NULL);
+ U_ASSERT(items != nullptr);
// forcing parse to use single hour digit
- tmpLen = parseOffsetFieldsWithPattern(text, start, items, TRUE, tmpH, tmpM, tmpS);
+ tmpLen = parseOffsetFieldsWithPattern(text, start, items, true, tmpH, tmpM, tmpS);
if (tmpLen > 0) {
tmpSign = (gmtPatType == UTZFMT_PAT_POSITIVE_H || gmtPatType == UTZFMT_PAT_POSITIVE_HM || gmtPatType == UTZFMT_PAT_POSITIVE_HMS) ?
1 : -1;
@@ -1857,7 +1857,7 @@ TimeZoneFormat::parseOffsetFields(const UnicodeString& text, int32_t start, UBoo
int32_t
TimeZoneFormat::parseOffsetFieldsWithPattern(const UnicodeString& text, int32_t start,
UVector* patternItems, UBool forceSingleHourDigit, int32_t& hour, int32_t& min, int32_t& sec) const {
- UBool failed = FALSE;
+ UBool failed = false;
int32_t offsetH, offsetM, offsetS;
offsetH = offsetM = offsetS = 0;
int32_t idx = start;
@@ -1867,7 +1867,7 @@ TimeZoneFormat::parseOffsetFieldsWithPattern(const UnicodeString& text, int32_t
const GMTOffsetField* field = (const GMTOffsetField*)patternItems->elementAt(i);
GMTOffsetField::FieldType fieldType = field->getType();
if (fieldType == GMTOffsetField::TEXT) {
- const UChar* patStr = field->getPatternText();
+ const char16_t* patStr = field->getPatternText();
len = u_strlen(patStr);
if (i == 0) {
// When TimeZoneFormat parse() is called from SimpleDateFormat,
@@ -1891,7 +1891,7 @@ TimeZoneFormat::parseOffsetFieldsWithPattern(const UnicodeString& text, int32_t
}
}
if (text.caseCompare(idx, len, patStr, 0) != 0) {
- failed = TRUE;
+ failed = true;
break;
}
idx += len;
@@ -1906,7 +1906,7 @@ TimeZoneFormat::parseOffsetFieldsWithPattern(const UnicodeString& text, int32_t
}
if (len == 0) {
- failed = TRUE;
+ failed = true;
break;
}
idx += len;
@@ -2004,7 +2004,7 @@ TimeZoneFormat::parseOffsetDefaultLocalizedGMT(const UnicodeString& text, int st
int32_t gmtLen = 0;
for (int32_t i = 0; ALT_GMT_STRINGS[i][0] != 0; i++) {
- const UChar* gmt = ALT_GMT_STRINGS[i];
+ const char16_t* gmt = ALT_GMT_STRINGS[i];
int32_t len = u_strlen(gmt);
if (text.caseCompare(start, len, gmt, 0) == 0) {
gmtLen = len;
@@ -2023,7 +2023,7 @@ TimeZoneFormat::parseOffsetDefaultLocalizedGMT(const UnicodeString& text, int st
// parse sign
int32_t sign = 1;
- UChar c = text.charAt(idx);
+ char16_t c = text.charAt(idx);
if (c == PLUS) {
sign = 1;
} else if (c == MINUS) {
@@ -2062,7 +2062,7 @@ TimeZoneFormat::parseOffsetDefaultLocalizedGMT(const UnicodeString& text, int st
}
int32_t
-TimeZoneFormat::parseDefaultOffsetFields(const UnicodeString& text, int32_t start, UChar separator, int32_t& parsedLen) const {
+TimeZoneFormat::parseDefaultOffsetFields(const UnicodeString& text, int32_t start, char16_t separator, int32_t& parsedLen) const {
int32_t max = text.length();
int32_t idx = start;
int32_t len = 0;
@@ -2092,7 +2092,7 @@ TimeZoneFormat::parseDefaultOffsetFields(const UnicodeString& text, int32_t star
idx += (1 + len);
}
}
- } while (FALSE);
+ } while (false);
if (idx == start) {
return 0;
@@ -2165,11 +2165,11 @@ TimeZoneFormat::parseSingleLocalizedDigit(const UnicodeString& text, int32_t sta
}
UnicodeString&
-TimeZoneFormat::formatOffsetWithAsciiDigits(int32_t offset, UChar sep, OffsetFields minFields, OffsetFields maxFields, UnicodeString& result) {
+TimeZoneFormat::formatOffsetWithAsciiDigits(int32_t offset, char16_t sep, OffsetFields minFields, OffsetFields maxFields, UnicodeString& result) {
U_ASSERT(maxFields >= minFields);
U_ASSERT(offset > -MAX_OFFSET && offset < MAX_OFFSET);
- UChar sign = PLUS;
+ char16_t sign = PLUS;
if (offset < 0) {
sign = MINUS;
offset = -offset;
@@ -2199,8 +2199,8 @@ TimeZoneFormat::formatOffsetWithAsciiDigits(int32_t offset, UChar sep, OffsetFie
if (sep && idx != 0) {
result.append(sep);
}
- result.append((UChar)(0x0030 + fields[idx]/10));
- result.append((UChar)(0x0030 + fields[idx]%10));
+ result.append((char16_t)(0x0030 + fields[idx]/10));
+ result.append((char16_t)(0x0030 + fields[idx]%10));
}
return result;
@@ -2219,7 +2219,7 @@ TimeZoneFormat::parseAbuttingAsciiOffsetFields(const UnicodeString& text, ParseP
int32_t numDigits = 0;
int32_t idx = start;
while (numDigits < maxDigits && idx < text.length()) {
- UChar uch = text.charAt(idx);
+ char16_t uch = text.charAt(idx);
int32_t digit = DIGIT_VAL(uch);
if (digit < 0) {
break;
@@ -2240,7 +2240,7 @@ TimeZoneFormat::parseAbuttingAsciiOffsetFields(const UnicodeString& text, ParseP
}
int32_t hour = 0, min = 0, sec = 0;
- UBool bParsed = FALSE;
+ UBool bParsed = false;
while (numDigits >= minDigits) {
switch (numDigits) {
case 1: //H
@@ -2289,12 +2289,12 @@ TimeZoneFormat::parseAbuttingAsciiOffsetFields(const UnicodeString& text, ParseP
}
int32_t
-TimeZoneFormat::parseAsciiOffsetFields(const UnicodeString& text, ParsePosition& pos, UChar sep, OffsetFields minFields, OffsetFields maxFields) {
+TimeZoneFormat::parseAsciiOffsetFields(const UnicodeString& text, ParsePosition& pos, char16_t sep, OffsetFields minFields, OffsetFields maxFields) {
int32_t start = pos.getIndex();
int32_t fieldVal[] = {0, 0, 0};
int32_t fieldLen[] = {0, -1, -1};
for (int32_t idx = start, fieldIdx = 0; idx < text.length() && fieldIdx <= maxFields; idx++) {
- UChar c = text.charAt(idx);
+ char16_t c = text.charAt(idx);
if (c == sep) {
if (fieldIdx == 0) {
if (fieldLen[0] == 0) {
@@ -2409,20 +2409,20 @@ TimeZoneFormat::unquote(const UnicodeString& pattern, UnicodeString& result) {
return result;
}
result.remove();
- UBool isPrevQuote = FALSE;
- UBool inQuote = FALSE;
+ UBool isPrevQuote = false;
+ UBool inQuote = false;
for (int32_t i = 0; i < pattern.length(); i++) {
- UChar c = pattern.charAt(i);
+ char16_t c = pattern.charAt(i);
if (c == SINGLEQUOTE) {
if (isPrevQuote) {
result.append(c);
- isPrevQuote = FALSE;
+ isPrevQuote = false;
} else {
- isPrevQuote = TRUE;
+ isPrevQuote = true;
}
inQuote = !inQuote;
} else {
- isPrevQuote = FALSE;
+ isPrevQuote = false;
result.append(c);
}
}
@@ -2432,34 +2432,34 @@ TimeZoneFormat::unquote(const UnicodeString& pattern, UnicodeString& result) {
UVector*
TimeZoneFormat::parseOffsetPattern(const UnicodeString& pattern, OffsetFields required, UErrorCode& status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
- UVector* result = new UVector(deleteGMTOffsetField, NULL, status);
- if (result == NULL) {
+ UVector* result = new UVector(deleteGMTOffsetField, nullptr, status);
+ if (result == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
int32_t checkBits = 0;
- UBool isPrevQuote = FALSE;
- UBool inQuote = FALSE;
- UChar textBuf[32];
+ UBool isPrevQuote = false;
+ UBool inQuote = false;
+ char16_t textBuf[32];
UnicodeString text(textBuf, 0, UPRV_LENGTHOF(textBuf));
GMTOffsetField::FieldType itemType = GMTOffsetField::TEXT;
int32_t itemLength = 1;
for (int32_t i = 0; i < pattern.length(); i++) {
- UChar ch = pattern.charAt(i);
+ char16_t ch = pattern.charAt(i);
if (ch == SINGLEQUOTE) {
if (isPrevQuote) {
text.append(SINGLEQUOTE);
- isPrevQuote = FALSE;
+ isPrevQuote = false;
} else {
- isPrevQuote = TRUE;
+ isPrevQuote = true;
if (itemType != GMTOffsetField::TEXT) {
if (GMTOffsetField::isValid(itemType, itemLength)) {
GMTOffsetField* fld = GMTOffsetField::createTimeField(itemType, static_cast<uint8_t>(itemLength), status);
- result->addElementX(fld, status);
+ result->adoptElement(fld, status);
if (U_FAILURE(status)) {
break;
}
@@ -2472,7 +2472,7 @@ TimeZoneFormat::parseOffsetPattern(const UnicodeString& pattern, OffsetFields re
}
inQuote = !inQuote;
} else {
- isPrevQuote = FALSE;
+ isPrevQuote = false;
if (inQuote) {
text.append(ch);
} else {
@@ -2485,7 +2485,7 @@ TimeZoneFormat::parseOffsetPattern(const UnicodeString& pattern, OffsetFields re
if (itemType == GMTOffsetField::TEXT) {
if (text.length() > 0) {
GMTOffsetField* textfld = GMTOffsetField::createText(text, status);
- result->addElementX(textfld, status);
+ result->adoptElement(textfld, status);
if (U_FAILURE(status)) {
break;
}
@@ -2494,7 +2494,7 @@ TimeZoneFormat::parseOffsetPattern(const UnicodeString& pattern, OffsetFields re
} else {
if (GMTOffsetField::isValid(itemType, itemLength)) {
GMTOffsetField* fld = GMTOffsetField::createTimeField(itemType, static_cast<uint8_t>(itemLength), status);
- result->addElementX(fld, status);
+ result->adoptElement(fld, status);
if (U_FAILURE(status)) {
break;
}
@@ -2512,7 +2512,7 @@ TimeZoneFormat::parseOffsetPattern(const UnicodeString& pattern, OffsetFields re
if (itemType != GMTOffsetField::TEXT) {
if (GMTOffsetField::isValid(itemType, itemLength)) {
GMTOffsetField* fld = GMTOffsetField::createTimeField(itemType, static_cast<uint8_t>(itemLength), status);
- result->addElementX(fld, status);
+ result->adoptElement(fld, status);
if (U_FAILURE(status)) {
break;
}
@@ -2532,12 +2532,12 @@ TimeZoneFormat::parseOffsetPattern(const UnicodeString& pattern, OffsetFields re
if (itemType == GMTOffsetField::TEXT) {
if (text.length() > 0) {
GMTOffsetField* tfld = GMTOffsetField::createText(text, status);
- result->addElementX(tfld, status);
+ result->adoptElement(tfld, status);
}
} else {
if (GMTOffsetField::isValid(itemType, itemLength)) {
GMTOffsetField* fld = GMTOffsetField::createTimeField(itemType, static_cast<uint8_t>(itemLength), status);
- result->addElementX(fld, status);
+ result->adoptElement(fld, status);
} else {
status = U_ILLEGAL_ARGUMENT_ERROR;
}
@@ -2566,7 +2566,7 @@ TimeZoneFormat::parseOffsetPattern(const UnicodeString& pattern, OffsetFields re
// error
delete result;
- return NULL;
+ return nullptr;
}
UnicodeString&
@@ -2585,7 +2585,7 @@ TimeZoneFormat::expandOffsetPattern(const UnicodeString& offsetHM, UnicodeString
}
UnicodeString sep;
- int32_t idx_H = offsetHM.tempSubString(0, idx_mm).lastIndexOf((UChar)0x0048 /* H */);
+ int32_t idx_H = offsetHM.tempSubString(0, idx_mm).lastIndexOf((char16_t)0x0048 /* H */);
if (idx_H >= 0) {
sep = offsetHM.tempSubString(idx_H + 1, idx_mm - (idx_H + 1));
}
@@ -2610,12 +2610,12 @@ TimeZoneFormat::truncateOffsetPattern(const UnicodeString& offsetHM, UnicodeStri
status = U_ILLEGAL_ARGUMENT_ERROR;
return result;
}
- UChar HH[] = {0x0048, 0x0048};
+ char16_t HH[] = {0x0048, 0x0048};
int32_t idx_HH = offsetHM.tempSubString(0, idx_mm).lastIndexOf(HH, 2, 0);
if (idx_HH >= 0) {
return result.setTo(offsetHM.tempSubString(0, idx_HH + 2));
}
- int32_t idx_H = offsetHM.tempSubString(0, idx_mm).lastIndexOf((UChar)0x0048, 0);
+ int32_t idx_H = offsetHM.tempSubString(0, idx_mm).lastIndexOf((char16_t)0x0048, 0);
if (idx_H >= 0) {
return result.setTo(offsetHM.tempSubString(0, idx_H + 1));
}
@@ -2642,24 +2642,27 @@ TimeZoneFormat::initGMTOffsetPatterns(UErrorCode& status) {
break;
}
}
+ if (U_FAILURE(status)) {
+ return;
+ }
checkAbuttingHoursAndMinutes();
}
void
TimeZoneFormat::checkAbuttingHoursAndMinutes() {
- fAbuttingOffsetHoursAndMinutes= FALSE;
+ fAbuttingOffsetHoursAndMinutes= false;
for (int32_t type = 0; type < UTZFMT_PAT_COUNT; type++) {
- UBool afterH = FALSE;
+ UBool afterH = false;
UVector *items = fGMTOffsetPatternItems[type];
for (int32_t i = 0; i < items->size(); i++) {
const GMTOffsetField* item = (GMTOffsetField*)items->elementAt(i);
GMTOffsetField::FieldType fieldType = item->getType();
if (fieldType != GMTOffsetField::TEXT) {
if (afterH) {
- fAbuttingOffsetHoursAndMinutes = TRUE;
+ fAbuttingOffsetHoursAndMinutes = true;
break;
} else if (fieldType == GMTOffsetField::HOUR) {
- afterH = TRUE;
+ afterH = true;
}
} else if (afterH) {
break;
@@ -2675,7 +2678,7 @@ UBool
TimeZoneFormat::toCodePoints(const UnicodeString& str, UChar32* codeArray, int32_t size) {
int32_t count = str.countChar32();
if (count != size) {
- return FALSE;
+ return false;
}
for (int32_t idx = 0, start = 0; idx < size; idx++) {
@@ -2683,14 +2686,14 @@ TimeZoneFormat::toCodePoints(const UnicodeString& str, UChar32* codeArray, int32
start = str.moveIndex32(start, 1);
}
- return TRUE;
+ return true;
}
TimeZone*
TimeZoneFormat::createTimeZoneForOffset(int32_t offset) const {
if (offset == 0) {
// when offset is 0, we should use "Etc/GMT"
- return TimeZone::createTimeZone(UnicodeString(TRUE, TZID_GMT, -1));
+ return TimeZone::createTimeZone(UnicodeString(true, TZID_GMT, -1));
}
return ZoneMeta::createCustomTimeZone(offset);
}
@@ -2714,7 +2717,7 @@ TimeZoneFormat::getTimeType(UTimeZoneNameType nameType) {
UnicodeString&
TimeZoneFormat::getTimeZoneID(const TimeZoneNames::MatchInfoCollection* matches, int32_t idx, UnicodeString& tzID) const {
if (!matches->getTimeZoneIDAt(idx, tzID)) {
- UChar mzIDBuf[32];
+ char16_t mzIDBuf[32];
UnicodeString mzID(mzIDBuf, 0, UPRV_LENGTHOF(mzIDBuf));
if (matches->getMetaZoneIDAt(idx, mzID)) {
fTimeZoneNames->getReferenceZoneID(mzID, fTargetRegion, tzID);
@@ -2730,15 +2733,15 @@ public:
virtual ~ZoneIdMatchHandler();
UBool handleMatch(int32_t matchLength, const CharacterNode *node, UErrorCode &status) override;
- const UChar* getID();
+ const char16_t* getID();
int32_t getMatchLen();
private:
int32_t fLen;
- const UChar* fID;
+ const char16_t* fID;
};
ZoneIdMatchHandler::ZoneIdMatchHandler()
-: fLen(0), fID(NULL) {
+: fLen(0), fID(nullptr) {
}
ZoneIdMatchHandler::~ZoneIdMatchHandler() {
@@ -2747,21 +2750,21 @@ ZoneIdMatchHandler::~ZoneIdMatchHandler() {
UBool
ZoneIdMatchHandler::handleMatch(int32_t matchLength, const CharacterNode *node, UErrorCode &status) {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (node->hasValues()) {
- const UChar* id = (const UChar*)node->getValue(0);
- if (id != NULL) {
+ const char16_t* id = (const char16_t*)node->getValue(0);
+ if (id != nullptr) {
if (fLen < matchLength) {
fID = id;
fLen = matchLength;
}
}
}
- return TRUE;
+ return true;
}
-const UChar*
+const char16_t*
ZoneIdMatchHandler::getID() {
return fID;
}
@@ -2773,20 +2776,20 @@ ZoneIdMatchHandler::getMatchLen() {
static void U_CALLCONV initZoneIdTrie(UErrorCode &status) {
- U_ASSERT(gZoneIdTrie == NULL);
+ U_ASSERT(gZoneIdTrie == nullptr);
ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONEFORMAT, tzfmt_cleanup);
- gZoneIdTrie = new TextTrieMap(TRUE, NULL); // No deleter, because values are pooled by ZoneMeta
- if (gZoneIdTrie == NULL) {
+ gZoneIdTrie = new TextTrieMap(true, nullptr); // No deleter, because values are pooled by ZoneMeta
+ if (gZoneIdTrie == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
StringEnumeration *tzenum = TimeZone::createEnumeration(status);
if (U_SUCCESS(status)) {
const UnicodeString *id;
- while ((id = tzenum->snext(status)) != NULL) {
- const UChar* uid = ZoneMeta::findTimeZoneID(*id);
+ while ((id = tzenum->snext(status)) != nullptr) {
+ const char16_t* uid = ZoneMeta::findTimeZoneID(*id);
if (uid) {
- gZoneIdTrie->put(uid, const_cast<UChar *>(uid), status);
+ gZoneIdTrie->put(uid, const_cast<char16_t *>(uid), status);
}
}
delete tzenum;
@@ -2822,20 +2825,20 @@ TimeZoneFormat::parseZoneID(const UnicodeString& text, ParsePosition& pos, Unico
}
static void U_CALLCONV initShortZoneIdTrie(UErrorCode &status) {
- U_ASSERT(gShortZoneIdTrie == NULL);
+ U_ASSERT(gShortZoneIdTrie == nullptr);
ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONEFORMAT, tzfmt_cleanup);
- StringEnumeration *tzenum = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL, NULL, NULL, status);
+ StringEnumeration *tzenum = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL, nullptr, nullptr, status);
if (U_SUCCESS(status)) {
- gShortZoneIdTrie = new TextTrieMap(TRUE, NULL); // No deleter, because values are pooled by ZoneMeta
- if (gShortZoneIdTrie == NULL) {
+ gShortZoneIdTrie = new TextTrieMap(true, nullptr); // No deleter, because values are pooled by ZoneMeta
+ if (gShortZoneIdTrie == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
const UnicodeString *id;
- while ((id = tzenum->snext(status)) != NULL) {
- const UChar* uID = ZoneMeta::findTimeZoneID(*id);
- const UChar* shortID = ZoneMeta::getShortID(*id);
+ while ((id = tzenum->snext(status)) != nullptr) {
+ const char16_t* uID = ZoneMeta::findTimeZoneID(*id);
+ const char16_t* shortID = ZoneMeta::getShortID(*id);
if (shortID && uID) {
- gShortZoneIdTrie->put(shortID, const_cast<UChar *>(uID), status);
+ gShortZoneIdTrie->put(shortID, const_cast<char16_t *>(uID), status);
}
}
}
diff --git a/contrib/libs/icu/i18n/tzgnames.cpp b/contrib/libs/icu/i18n/tzgnames.cpp
index ed5f42d7bc..d55b0fd2ae 100644
--- a/contrib/libs/icu/i18n/tzgnames.cpp
+++ b/contrib/libs/icu/i18n/tzgnames.cpp
@@ -46,10 +46,10 @@ static const char gZoneStrings[] = "zoneStrings";
static const char gRegionFormatTag[] = "regionFormat";
static const char gFallbackFormatTag[] = "fallbackFormat";
-static const UChar gEmpty[] = {0x00};
+static const char16_t gEmpty[] = {0x00};
-static const UChar gDefRegionPattern[] = {0x7B, 0x30, 0x7D, 0x00}; // "{0}"
-static const UChar gDefFallbackPattern[] = {0x7B, 0x31, 0x7D, 0x20, 0x28, 0x7B, 0x30, 0x7D, 0x29, 0x00}; // "{1} ({0})"
+static const char16_t gDefRegionPattern[] = {0x7B, 0x30, 0x7D, 0x00}; // "{0}"
+static const char16_t gDefFallbackPattern[] = {0x7B, 0x31, 0x7D, 0x20, 0x28, 0x7B, 0x30, 0x7D, 0x29, 0x00}; // "{1} ({0})"
static const double kDstCheckRange = (double)184*U_MILLIS_PER_DAY;
@@ -58,8 +58,8 @@ static const double kDstCheckRange = (double)184*U_MILLIS_PER_DAY;
U_CDECL_BEGIN
typedef struct PartialLocationKey {
- const UChar* tzID;
- const UChar* mzID;
+ const char16_t* tzID;
+ const char16_t* mzID;
UBool isLong;
} PartialLocationKey;
@@ -71,10 +71,10 @@ hashPartialLocationKey(const UHashTok key) {
// <tzID>&<mzID>#[L|S]
PartialLocationKey *p = (PartialLocationKey *)key.pointer;
UnicodeString str(p->tzID);
- str.append((UChar)0x26)
+ str.append((char16_t)0x26)
.append(p->mzID, -1)
- .append((UChar)0x23)
- .append((UChar)(p->isLong ? 0x4C : 0x53));
+ .append((char16_t)0x23)
+ .append((char16_t)(p->isLong ? 0x4C : 0x53));
return str.hashCode();
}
@@ -87,10 +87,10 @@ comparePartialLocationKey(const UHashTok key1, const UHashTok key2) {
PartialLocationKey *p2 = (PartialLocationKey *)key2.pointer;
if (p1 == p2) {
- return TRUE;
+ return true;
}
- if (p1 == NULL || p2 == NULL) {
- return FALSE;
+ if (p1 == nullptr || p2 == nullptr) {
+ return false;
}
// We just check identity of tzID/mzID
return (p1->tzID == p2->tzID && p1->mzID == p2->mzID && p1->isLong == p2->isLong);
@@ -109,7 +109,7 @@ deleteGNameInfo(void *obj) {
*/
typedef struct GNameInfo {
UTimeZoneGenericNameType type;
- const UChar* tzID;
+ const char16_t* tzID;
} ZNameInfo;
/**
@@ -145,14 +145,14 @@ TimeZoneGenericNameMatchInfo::TimeZoneGenericNameMatchInfo(UVector* matches)
}
TimeZoneGenericNameMatchInfo::~TimeZoneGenericNameMatchInfo() {
- if (fMatches != NULL) {
+ if (fMatches != nullptr) {
delete fMatches;
}
}
int32_t
TimeZoneGenericNameMatchInfo::size() const {
- if (fMatches == NULL) {
+ if (fMatches == nullptr) {
return 0;
}
return fMatches->size();
@@ -161,7 +161,7 @@ TimeZoneGenericNameMatchInfo::size() const {
UTimeZoneGenericNameType
TimeZoneGenericNameMatchInfo::getGenericNameType(int32_t index) const {
GMatchInfo *minfo = (GMatchInfo *)fMatches->elementAt(index);
- if (minfo != NULL) {
+ if (minfo != nullptr) {
return static_cast<UTimeZoneGenericNameType>(minfo->gnameInfo->type);
}
return UTZGNM_UNKNOWN;
@@ -170,7 +170,7 @@ TimeZoneGenericNameMatchInfo::getGenericNameType(int32_t index) const {
int32_t
TimeZoneGenericNameMatchInfo::getMatchLength(int32_t index) const {
ZMatchInfo *minfo = (ZMatchInfo *)fMatches->elementAt(index);
- if (minfo != NULL) {
+ if (minfo != nullptr) {
return minfo->matchLength;
}
return -1;
@@ -179,8 +179,8 @@ TimeZoneGenericNameMatchInfo::getMatchLength(int32_t index) const {
UnicodeString&
TimeZoneGenericNameMatchInfo::getTimeZoneID(int32_t index, UnicodeString& tzID) const {
GMatchInfo *minfo = (GMatchInfo *)fMatches->elementAt(index);
- if (minfo != NULL && minfo->gnameInfo->tzID != NULL) {
- tzID.setTo(TRUE, minfo->gnameInfo->tzID, -1);
+ if (minfo != nullptr && minfo->gnameInfo->tzID != nullptr) {
+ tzID.setTo(true, minfo->gnameInfo->tzID, -1);
} else {
tzID.setToBogus();
}
@@ -205,11 +205,11 @@ private:
};
GNameSearchHandler::GNameSearchHandler(uint32_t types)
-: fTypes(types), fResults(NULL), fMaxMatchLen(0) {
+: fTypes(types), fResults(nullptr), fMaxMatchLen(0) {
}
GNameSearchHandler::~GNameSearchHandler() {
- if (fResults != NULL) {
+ if (fResults != nullptr) {
delete fResults;
}
}
@@ -217,47 +217,44 @@ GNameSearchHandler::~GNameSearchHandler() {
UBool
GNameSearchHandler::handleMatch(int32_t matchLength, const CharacterNode *node, UErrorCode &status) {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (node->hasValues()) {
int32_t valuesCount = node->countValues();
for (int32_t i = 0; i < valuesCount; i++) {
GNameInfo *nameinfo = (ZNameInfo *)node->getValue(i);
- if (nameinfo == NULL) {
+ if (nameinfo == nullptr) {
break;
}
if ((nameinfo->type & fTypes) != 0) {
// matches a requested type
- if (fResults == NULL) {
- fResults = new UVector(uprv_free, NULL, status);
- if (fResults == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
+ if (fResults == nullptr) {
+ LocalPointer<UVector> lpResults(new UVector(uprv_free, nullptr, status), status);
+ if (U_FAILURE(status)) {
+ return false;
}
+ fResults = lpResults.orphan();
}
- if (U_SUCCESS(status)) {
- U_ASSERT(fResults != NULL);
- GMatchInfo *gmatch = (GMatchInfo *)uprv_malloc(sizeof(GMatchInfo));
- if (gmatch == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
- } else {
- // add the match to the vector
- gmatch->gnameInfo = nameinfo;
- gmatch->matchLength = matchLength;
- gmatch->timeType = UTZFMT_TIME_TYPE_UNKNOWN;
- fResults->addElementX(gmatch, status);
- if (U_FAILURE(status)) {
- uprv_free(gmatch);
- } else {
- if (matchLength > fMaxMatchLen) {
- fMaxMatchLen = matchLength;
- }
- }
- }
+ GMatchInfo *gmatch = (GMatchInfo *)uprv_malloc(sizeof(GMatchInfo));
+ if (gmatch == nullptr) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return false;
+ }
+ // add the match to the vector
+ gmatch->gnameInfo = nameinfo;
+ gmatch->matchLength = matchLength;
+ gmatch->timeType = UTZFMT_TIME_TYPE_UNKNOWN;
+ fResults->adoptElement(gmatch, status);
+ if (U_FAILURE(status)) {
+ return false;
+ }
+ if (matchLength > fMaxMatchLen) {
+ fMaxMatchLen = matchLength;
}
}
}
}
- return TRUE;
+ return true;
}
UVector*
@@ -267,7 +264,7 @@ GNameSearchHandler::getMatches(int32_t& maxMatchLen) {
maxMatchLen = fMaxMatchLen;
// reset
- fResults = NULL;
+ fResults = nullptr;
fMaxMatchLen = 0;
return results;
}
@@ -309,7 +306,7 @@ private:
void loadStrings(const UnicodeString& tzCanonicalID);
- const UChar* getGenericLocationName(const UnicodeString& tzCanonicalID);
+ const char16_t* getGenericLocationName(const UnicodeString& tzCanonicalID);
UnicodeString& formatGenericNonLocationName(const TimeZone& tz, UTimeZoneGenericNameType type,
UDate date, UnicodeString& name) const;
@@ -318,7 +315,7 @@ private:
const UnicodeString& mzID, UBool isLong, const UnicodeString& mzDisplayName,
UnicodeString& name) const;
- const UChar* getPartialLocationName(const UnicodeString& tzCanonicalID,
+ const char16_t* getPartialLocationName(const UnicodeString& tzCanonicalID,
const UnicodeString& mzID, UBool isLong, const UnicodeString& mzDisplayName);
TimeZoneGenericNameMatchInfo* findLocal(const UnicodeString& text, int32_t start, uint32_t types, UErrorCode& status) const;
@@ -336,13 +333,13 @@ private:
// ---------------------------------------------------
TZGNCore::TZGNCore(const Locale& locale, UErrorCode& status)
: fLocale(locale),
- fTimeZoneNames(NULL),
- fLocationNamesMap(NULL),
- fPartialLocationNamesMap(NULL),
- fLocaleDisplayNames(NULL),
+ fTimeZoneNames(nullptr),
+ fLocationNamesMap(nullptr),
+ fPartialLocationNamesMap(nullptr),
+ fLocaleDisplayNames(nullptr),
fStringPool(status),
- fGNamesTrie(TRUE, deleteGNameInfo),
- fGNamesTrieFullyLoaded(FALSE) {
+ fGNamesTrie(true, deleteGNameInfo),
+ fGNamesTrieFullyLoaded(false) {
initialize(locale, status);
}
@@ -363,20 +360,20 @@ TZGNCore::initialize(const Locale& locale, UErrorCode& status) {
}
// Initialize format patterns
- UnicodeString rpat(TRUE, gDefRegionPattern, -1);
- UnicodeString fpat(TRUE, gDefFallbackPattern, -1);
+ UnicodeString rpat(true, gDefRegionPattern, -1);
+ UnicodeString fpat(true, gDefFallbackPattern, -1);
UErrorCode tmpsts = U_ZERO_ERROR; // OK with fallback warning..
UResourceBundle *zoneStrings = ures_open(U_ICUDATA_ZONE, locale.getName(), &tmpsts);
zoneStrings = ures_getByKeyWithFallback(zoneStrings, gZoneStrings, zoneStrings, &tmpsts);
if (U_SUCCESS(tmpsts)) {
- const UChar *regionPattern = ures_getStringByKeyWithFallback(zoneStrings, gRegionFormatTag, NULL, &tmpsts);
+ const char16_t *regionPattern = ures_getStringByKeyWithFallback(zoneStrings, gRegionFormatTag, nullptr, &tmpsts);
if (U_SUCCESS(tmpsts) && u_strlen(regionPattern) > 0) {
rpat.setTo(regionPattern, -1);
}
tmpsts = U_ZERO_ERROR;
- const UChar *fallbackPattern = ures_getStringByKeyWithFallback(zoneStrings, gFallbackFormatTag, NULL, &tmpsts);
+ const char16_t *fallbackPattern = ures_getStringByKeyWithFallback(zoneStrings, gFallbackFormatTag, nullptr, &tmpsts);
if (U_SUCCESS(tmpsts) && u_strlen(fallbackPattern) > 0) {
fpat.setTo(fallbackPattern, -1);
}
@@ -394,13 +391,13 @@ TZGNCore::initialize(const Locale& locale, UErrorCode& status) {
fLocaleDisplayNames = LocaleDisplayNames::createInstance(locale);
// hash table for names - no key/value deleters
- fLocationNamesMap = uhash_open(uhash_hashUChars, uhash_compareUChars, NULL, &status);
+ fLocationNamesMap = uhash_open(uhash_hashUChars, uhash_compareUChars, nullptr, &status);
if (U_FAILURE(status)) {
cleanup();
return;
}
- fPartialLocationNamesMap = uhash_open(hashPartialLocationKey, comparePartialLocationKey, NULL, &status);
+ fPartialLocationNamesMap = uhash_open(hashPartialLocationKey, comparePartialLocationKey, nullptr, &status);
if (U_FAILURE(status)) {
cleanup();
return;
@@ -433,19 +430,19 @@ TZGNCore::initialize(const Locale& locale, UErrorCode& status) {
// preload generic names for the default zone
TimeZone *tz = TimeZone::createDefault();
- const UChar *tzID = ZoneMeta::getCanonicalCLDRID(*tz);
- if (tzID != NULL) {
- loadStrings(UnicodeString(TRUE, tzID, -1));
+ const char16_t *tzID = ZoneMeta::getCanonicalCLDRID(*tz);
+ if (tzID != nullptr) {
+ loadStrings(UnicodeString(true, tzID, -1));
}
delete tz;
}
void
TZGNCore::cleanup() {
- if (fLocaleDisplayNames != NULL) {
+ if (fLocaleDisplayNames != nullptr) {
delete fLocaleDisplayNames;
}
- if (fTimeZoneNames != NULL) {
+ if (fTimeZoneNames != nullptr) {
delete fTimeZoneNames;
}
@@ -460,9 +457,9 @@ TZGNCore::getDisplayName(const TimeZone& tz, UTimeZoneGenericNameType type, UDat
switch (type) {
case UTZGNM_LOCATION:
{
- const UChar* tzCanonicalID = ZoneMeta::getCanonicalCLDRID(tz);
- if (tzCanonicalID != NULL) {
- getGenericLocationName(UnicodeString(TRUE, tzCanonicalID, -1), name);
+ const char16_t* tzCanonicalID = ZoneMeta::getCanonicalCLDRID(tz);
+ if (tzCanonicalID != nullptr) {
+ getGenericLocationName(UnicodeString(true, tzCanonicalID, -1), name);
}
}
break;
@@ -470,9 +467,9 @@ TZGNCore::getDisplayName(const TimeZone& tz, UTimeZoneGenericNameType type, UDat
case UTZGNM_SHORT:
formatGenericNonLocationName(tz, type, date, name);
if (name.isEmpty()) {
- const UChar* tzCanonicalID = ZoneMeta::getCanonicalCLDRID(tz);
- if (tzCanonicalID != NULL) {
- getGenericLocationName(UnicodeString(TRUE, tzCanonicalID, -1), name);
+ const char16_t* tzCanonicalID = ZoneMeta::getCanonicalCLDRID(tz);
+ if (tzCanonicalID != nullptr) {
+ getGenericLocationName(UnicodeString(true, tzCanonicalID, -1), name);
}
}
break;
@@ -489,7 +486,7 @@ TZGNCore::getGenericLocationName(const UnicodeString& tzCanonicalID, UnicodeStri
return name;
}
- const UChar *locname = NULL;
+ const char16_t *locname = nullptr;
TZGNCore *nonConstThis = const_cast<TZGNCore *>(this);
umtx_lock(&gLock);
{
@@ -497,7 +494,7 @@ TZGNCore::getGenericLocationName(const UnicodeString& tzCanonicalID, UnicodeStri
}
umtx_unlock(&gLock);
- if (locname == NULL) {
+ if (locname == nullptr) {
name.setToBogus();
} else {
name.setTo(locname, u_strlen(locname));
@@ -509,25 +506,25 @@ TZGNCore::getGenericLocationName(const UnicodeString& tzCanonicalID, UnicodeStri
/*
* This method updates the cache and must be called with a lock
*/
-const UChar*
+const char16_t*
TZGNCore::getGenericLocationName(const UnicodeString& tzCanonicalID) {
U_ASSERT(!tzCanonicalID.isEmpty());
if (tzCanonicalID.length() > ZID_KEY_MAX) {
- return NULL;
+ return nullptr;
}
UErrorCode status = U_ZERO_ERROR;
- UChar tzIDKey[ZID_KEY_MAX + 1];
+ char16_t tzIDKey[ZID_KEY_MAX + 1];
int32_t tzIDKeyLen = tzCanonicalID.extract(tzIDKey, ZID_KEY_MAX + 1, status);
U_ASSERT(status == U_ZERO_ERROR); // already checked length above
tzIDKey[tzIDKeyLen] = 0;
- const UChar *locname = (const UChar *)uhash_get(fLocationNamesMap, tzIDKey);
+ const char16_t *locname = (const char16_t *)uhash_get(fLocationNamesMap, tzIDKey);
- if (locname != NULL) {
+ if (locname != nullptr) {
// gEmpty indicate the name is not available
if (locname == gEmpty) {
- return NULL;
+ return nullptr;
}
return locname;
}
@@ -535,7 +532,7 @@ TZGNCore::getGenericLocationName(const UnicodeString& tzCanonicalID) {
// Construct location name
UnicodeString name;
UnicodeString usCountryCode;
- UBool isPrimary = FALSE;
+ UBool isPrimary = false;
ZoneMeta::getCanonicalCountry(tzCanonicalID, usCountryCode, &isPrimary);
@@ -562,26 +559,26 @@ TZGNCore::getGenericLocationName(const UnicodeString& tzCanonicalID) {
fRegionFormat.format(city, name, status);
}
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
}
- locname = name.isEmpty() ? NULL : fStringPool.get(name, status);
+ locname = name.isEmpty() ? nullptr : fStringPool.get(name, status);
if (U_SUCCESS(status)) {
// Cache the result
- const UChar* cacheID = ZoneMeta::findTimeZoneID(tzCanonicalID);
- U_ASSERT(cacheID != NULL);
- if (locname == NULL) {
+ const char16_t* cacheID = ZoneMeta::findTimeZoneID(tzCanonicalID);
+ U_ASSERT(cacheID != nullptr);
+ if (locname == nullptr) {
// gEmpty to indicate - no location name available
uhash_put(fLocationNamesMap, (void *)cacheID, (void *)gEmpty, &status);
} else {
uhash_put(fLocationNamesMap, (void *)cacheID, (void *)locname, &status);
if (U_FAILURE(status)) {
- locname = NULL;
+ locname = nullptr;
} else {
// put the name info into the trie
GNameInfo *nameinfo = (ZNameInfo *)uprv_malloc(sizeof(GNameInfo));
- if (nameinfo != NULL) {
+ if (nameinfo != nullptr) {
nameinfo->type = UTZGNM_LOCATION;
nameinfo->tzID = cacheID;
fGNamesTrie.put(locname, nameinfo, status);
@@ -598,12 +595,12 @@ TZGNCore::formatGenericNonLocationName(const TimeZone& tz, UTimeZoneGenericNameT
U_ASSERT(type == UTZGNM_LONG || type == UTZGNM_SHORT);
name.setToBogus();
- const UChar* uID = ZoneMeta::getCanonicalCLDRID(tz);
- if (uID == NULL) {
+ const char16_t* uID = ZoneMeta::getCanonicalCLDRID(tz);
+ if (uID == nullptr) {
return name;
}
- UnicodeString tzID(TRUE, uID, -1);
+ UnicodeString tzID(true, uID, -1);
// Try to get a name from time zone first
UTimeZoneNameType nameType = (type == UTZGNM_LONG) ? UTZNM_LONG_GENERIC : UTZNM_SHORT_GENERIC;
@@ -614,59 +611,59 @@ TZGNCore::formatGenericNonLocationName(const TimeZone& tz, UTimeZoneGenericNameT
}
// Try meta zone
- UChar mzIDBuf[32];
+ char16_t mzIDBuf[32];
UnicodeString mzID(mzIDBuf, 0, UPRV_LENGTHOF(mzIDBuf));
fTimeZoneNames->getMetaZoneID(tzID, date, mzID);
if (!mzID.isEmpty()) {
UErrorCode status = U_ZERO_ERROR;
- UBool useStandard = FALSE;
+ UBool useStandard = false;
int32_t raw, sav;
- UChar tmpNameBuf[ZONE_NAME_U16_MAX];
+ char16_t tmpNameBuf[ZONE_NAME_U16_MAX];
- tz.getOffset(date, FALSE, raw, sav, status);
+ tz.getOffset(date, false, raw, sav, status);
if (U_FAILURE(status)) {
return name;
}
if (sav == 0) {
- useStandard = TRUE;
+ useStandard = true;
TimeZone *tmptz = tz.clone();
// Check if the zone actually uses daylight saving time around the time
- BasicTimeZone *btz = NULL;
- if (dynamic_cast<OlsonTimeZone *>(tmptz) != NULL
- || dynamic_cast<SimpleTimeZone *>(tmptz) != NULL
- || dynamic_cast<RuleBasedTimeZone *>(tmptz) != NULL
- || dynamic_cast<VTimeZone *>(tmptz) != NULL) {
+ BasicTimeZone *btz = nullptr;
+ if (dynamic_cast<OlsonTimeZone *>(tmptz) != nullptr
+ || dynamic_cast<SimpleTimeZone *>(tmptz) != nullptr
+ || dynamic_cast<RuleBasedTimeZone *>(tmptz) != nullptr
+ || dynamic_cast<VTimeZone *>(tmptz) != nullptr) {
btz = (BasicTimeZone*)tmptz;
}
- if (btz != NULL) {
+ if (btz != nullptr) {
TimeZoneTransition before;
- UBool beforTrs = btz->getPreviousTransition(date, TRUE, before);
+ UBool beforTrs = btz->getPreviousTransition(date, true, before);
if (beforTrs
&& (date - before.getTime() < kDstCheckRange)
&& before.getFrom()->getDSTSavings() != 0) {
- useStandard = FALSE;
+ useStandard = false;
} else {
TimeZoneTransition after;
- UBool afterTrs = btz->getNextTransition(date, FALSE, after);
+ UBool afterTrs = btz->getNextTransition(date, false, after);
if (afterTrs
&& (after.getTime() - date < kDstCheckRange)
&& after.getTo()->getDSTSavings() != 0) {
- useStandard = FALSE;
+ useStandard = false;
}
}
} else {
// If not BasicTimeZone... only if the instance is not an ICU's implementation.
// We may get a wrong answer in edge case, but it should practically work OK.
- tmptz->getOffset(date - kDstCheckRange, FALSE, raw, sav, status);
+ tmptz->getOffset(date - kDstCheckRange, false, raw, sav, status);
if (sav != 0) {
- useStandard = FALSE;
+ useStandard = false;
} else {
- tmptz->getOffset(date + kDstCheckRange, FALSE, raw, sav, status);
+ tmptz->getOffset(date + kDstCheckRange, false, raw, sav, status);
if (sav != 0){
- useStandard = FALSE;
+ useStandard = false;
}
}
if (U_FAILURE(status)) {
@@ -689,7 +686,7 @@ TZGNCore::formatGenericNonLocationName(const TimeZone& tz, UTimeZoneGenericNameT
// for some meta zones in some locales. This looks like a data bugs.
// For now, we check if the standard name is different from its generic
// name below.
- UChar genNameBuf[ZONE_NAME_U16_MAX];
+ char16_t genNameBuf[ZONE_NAME_U16_MAX];
UnicodeString mzGenericName(genNameBuf, 0, UPRV_LENGTHOF(genNameBuf));
fTimeZoneNames->getMetaZoneDisplayName(mzID, nameType, mzGenericName);
if (stdName.caseCompare(mzGenericName, 0) == 0) {
@@ -705,7 +702,7 @@ TZGNCore::formatGenericNonLocationName(const TimeZone& tz, UTimeZoneGenericNameT
// Check if we need to use a partial location format.
// This check is done by comparing offset with the meta zone's
// golden zone at the given date.
- UChar idBuf[32];
+ char16_t idBuf[32];
UnicodeString goldenID(idBuf, 0, UPRV_LENGTHOF(idBuf));
fTimeZoneNames->getReferenceZoneID(mzID, fTargetRegion, goldenID);
if (!goldenID.isEmpty() && goldenID != tzID) {
@@ -716,7 +713,7 @@ TZGNCore::formatGenericNonLocationName(const TimeZone& tz, UTimeZoneGenericNameT
// With getOffset(date, false, offsets1),
// you may get incorrect results because of time overlap at DST->STD
// transition.
- goldenZone->getOffset(date + raw + sav, TRUE, raw1, sav1, status);
+ goldenZone->getOffset(date + raw + sav, true, raw1, sav1, status);
delete goldenZone;
if (U_SUCCESS(status)) {
if (raw != raw1 || sav != sav1) {
@@ -744,7 +741,7 @@ TZGNCore::getPartialLocationName(const UnicodeString& tzCanonicalID,
return name;
}
- const UChar *uplname = NULL;
+ const char16_t *uplname = nullptr;
TZGNCore *nonConstThis = const_cast<TZGNCore *>(this);
umtx_lock(&gLock);
{
@@ -752,10 +749,10 @@ TZGNCore::getPartialLocationName(const UnicodeString& tzCanonicalID,
}
umtx_unlock(&gLock);
- if (uplname == NULL) {
+ if (uplname == nullptr) {
name.setToBogus();
} else {
- name.setTo(TRUE, uplname, -1);
+ name.setTo(true, uplname, -1);
}
return name;
}
@@ -763,7 +760,7 @@ TZGNCore::getPartialLocationName(const UnicodeString& tzCanonicalID,
/*
* This method updates the cache and must be called with a lock
*/
-const UChar*
+const char16_t*
TZGNCore::getPartialLocationName(const UnicodeString& tzCanonicalID,
const UnicodeString& mzID, UBool isLong, const UnicodeString& mzDisplayName) {
U_ASSERT(!tzCanonicalID.isEmpty());
@@ -774,10 +771,10 @@ TZGNCore::getPartialLocationName(const UnicodeString& tzCanonicalID,
key.tzID = ZoneMeta::findTimeZoneID(tzCanonicalID);
key.mzID = ZoneMeta::findMetaZoneID(mzID);
key.isLong = isLong;
- U_ASSERT(key.tzID != NULL && key.mzID != NULL);
+ U_ASSERT(key.tzID != nullptr && key.mzID != nullptr);
- const UChar* uplname = (const UChar*)uhash_get(fPartialLocationNamesMap, (void *)&key);
- if (uplname != NULL) {
+ const char16_t* uplname = (const char16_t*)uhash_get(fPartialLocationNamesMap, (void *)&key);
+ if (uplname != nullptr) {
return uplname;
}
@@ -813,14 +810,14 @@ TZGNCore::getPartialLocationName(const UnicodeString& tzCanonicalID,
UnicodeString name;
fFallbackFormat.format(location, mzDisplayName, name, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
uplname = fStringPool.get(name, status);
if (U_SUCCESS(status)) {
// Add the name to cache
PartialLocationKey* cacheKey = (PartialLocationKey *)uprv_malloc(sizeof(PartialLocationKey));
- if (cacheKey != NULL) {
+ if (cacheKey != nullptr) {
cacheKey->tzID = key.tzID;
cacheKey->mzID = key.mzID;
cacheKey->isLong = key.isLong;
@@ -830,7 +827,7 @@ TZGNCore::getPartialLocationName(const UnicodeString& tzCanonicalID,
} else {
// put the name to the local trie as well
GNameInfo *nameinfo = (ZNameInfo *)uprv_malloc(sizeof(GNameInfo));
- if (nameinfo != NULL) {
+ if (nameinfo != nullptr) {
nameinfo->type = isLong ? UTZGNM_LONG : UTZGNM_SHORT;
nameinfo->tzID = key.tzID;
fGNamesTrie.put(uplname, nameinfo, status);
@@ -862,7 +859,7 @@ TZGNCore::loadStrings(const UnicodeString& tzCanonicalID) {
};
StringEnumeration *mzIDs = fTimeZoneNames->getAvailableMetaZoneIDs(tzCanonicalID, status);
- while ((mzID = mzIDs->snext(status)) != NULL) {
+ while ((mzID = mzIDs->snext(status)) != nullptr) {
if (U_FAILURE(status)) {
break;
}
@@ -881,7 +878,7 @@ TZGNCore::loadStrings(const UnicodeString& tzCanonicalID) {
}
}
}
- if (mzIDs != NULL) {
+ if (mzIDs != nullptr) {
delete mzIDs;
}
}
@@ -905,10 +902,10 @@ TZGNCore::findBestMatch(const UnicodeString& text, int32_t start, uint32_t types
int32_t bestMatchLen = 0;
UTimeZoneFormatTimeType bestMatchTimeType = UTZFMT_TIME_TYPE_UNKNOWN;
UnicodeString bestMatchTzID;
- // UBool isLongStandard = FALSE; // workaround - see the comments below
- UBool isStandard = FALSE; // TODO: Temporary hack (on hack) for short standard name/location name conflict (found in zh_Hant), should be removed after CLDR 21m1 integration
+ // UBool isLongStandard = false; // workaround - see the comments below
+ UBool isStandard = false; // TODO: Temporary hack (on hack) for short standard name/location name conflict (found in zh_Hant), should be removed after CLDR 21m1 integration
- if (tznamesMatches != NULL) {
+ if (tznamesMatches != nullptr) {
UnicodeString mzID;
for (int32_t i = 0; i < tznamesMatches->size(); i++) {
int32_t len = tznamesMatches->getMatchLengthAt(i);
@@ -926,9 +923,9 @@ TZGNCore::findBestMatch(const UnicodeString& text, int32_t start, uint32_t types
}
switch (nameType) {
case UTZNM_LONG_STANDARD:
- // isLongStandard = TRUE;
+ // isLongStandard = true;
case UTZNM_SHORT_STANDARD: // this one is never used for generic, but just in case
- isStandard = TRUE; // TODO: Remove this later, see the comments above.
+ isStandard = true; // TODO: Remove this later, see the comments above.
bestMatchTimeType = UTZFMT_TIME_TYPE_STANDARD;
break;
case UTZNM_LONG_DAYLIGHT:
@@ -982,7 +979,7 @@ TZGNCore::findBestMatch(const UnicodeString& text, int32_t start, uint32_t types
if (U_FAILURE(status)) {
return 0;
}
- if (localMatches != NULL) {
+ if (localMatches != nullptr) {
for (int32_t i = 0; i < localMatches->size(); i++) {
int32_t len = localMatches->getMatchLength(i);
@@ -1020,25 +1017,25 @@ TZGNCore::findLocal(const UnicodeString& text, int32_t start, uint32_t types, UE
umtx_unlock(&gLock);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
- TimeZoneGenericNameMatchInfo *gmatchInfo = NULL;
+ TimeZoneGenericNameMatchInfo *gmatchInfo = nullptr;
int32_t maxLen = 0;
UVector *results = handler.getMatches(maxLen);
- if (results != NULL && ((maxLen == (text.length() - start)) || fGNamesTrieFullyLoaded)) {
+ if (results != nullptr && ((maxLen == (text.length() - start)) || fGNamesTrieFullyLoaded)) {
// perfect match
gmatchInfo = new TimeZoneGenericNameMatchInfo(results);
- if (gmatchInfo == NULL) {
+ if (gmatchInfo == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
delete results;
- return NULL;
+ return nullptr;
}
return gmatchInfo;
}
- if (results != NULL) {
+ if (results != nullptr) {
delete results;
}
@@ -1047,29 +1044,29 @@ TZGNCore::findLocal(const UnicodeString& text, int32_t start, uint32_t types, UE
umtx_lock(&gLock);
{
if (!fGNamesTrieFullyLoaded) {
- StringEnumeration *tzIDs = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL, NULL, NULL, status);
+ StringEnumeration *tzIDs = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL, nullptr, nullptr, status);
if (U_SUCCESS(status)) {
const UnicodeString *tzID;
- while ((tzID = tzIDs->snext(status)) != NULL) {
+ while ((tzID = tzIDs->snext(status)) != nullptr) {
if (U_FAILURE(status)) {
break;
}
nonConstThis->loadStrings(*tzID);
}
}
- if (tzIDs != NULL) {
+ if (tzIDs != nullptr) {
delete tzIDs;
}
if (U_SUCCESS(status)) {
- nonConstThis->fGNamesTrieFullyLoaded = TRUE;
+ nonConstThis->fGNamesTrieFullyLoaded = true;
}
}
}
umtx_unlock(&gLock);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
umtx_lock(&gLock);
@@ -1080,12 +1077,12 @@ TZGNCore::findLocal(const UnicodeString& text, int32_t start, uint32_t types, UE
umtx_unlock(&gLock);
results = handler.getMatches(maxLen);
- if (results != NULL && maxLen > 0) {
+ if (results != nullptr && maxLen > 0) {
gmatchInfo = new TimeZoneGenericNameMatchInfo(results);
- if (gmatchInfo == NULL) {
+ if (gmatchInfo == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
delete results;
- return NULL;
+ return nullptr;
}
}
@@ -1108,7 +1105,7 @@ TZGNCore::findTimeZoneNames(const UnicodeString& text, int32_t start, uint32_t t
return fTimeZoneNames->find(text, start, nameTypes, status);
}
- return NULL;
+ return nullptr;
}
typedef struct TZGNCoreRef {
@@ -1119,8 +1116,8 @@ typedef struct TZGNCoreRef {
// TZGNCore object cache handling
static UMutex gTZGNLock;
-static UHashtable *gTZGNCoreCache = NULL;
-static UBool gTZGNCoreCacheInitialized = FALSE;
+static UHashtable *gTZGNCoreCache = nullptr;
+static UBool gTZGNCoreCacheInitialized = false;
// Access count - incremented every time up to SWEEP_INTERVAL,
// then reset to 0
@@ -1139,14 +1136,14 @@ U_CDECL_BEGIN
/**
* Cleanup callback func
*/
-static UBool U_CALLCONV tzgnCore_cleanup(void)
+static UBool U_CALLCONV tzgnCore_cleanup()
{
- if (gTZGNCoreCache != NULL) {
+ if (gTZGNCoreCache != nullptr) {
uhash_close(gTZGNCoreCache);
- gTZGNCoreCache = NULL;
+ gTZGNCoreCache = nullptr;
}
- gTZGNCoreCacheInitialized = FALSE;
- return TRUE;
+ gTZGNCoreCacheInitialized = false;
+ return true;
}
/**
@@ -1170,7 +1167,7 @@ static void sweepCache() {
const UHashElement* elem;
double now = (double)uprv_getUTCtime();
- while ((elem = uhash_nextElement(gTZGNCoreCache, &pos)) != NULL) {
+ while ((elem = uhash_nextElement(gTZGNCoreCache, &pos)) != nullptr) {
TZGNCoreRef *entry = (TZGNCoreRef *)elem->value.pointer;
if (entry->refCount <= 0 && (now - entry->lastAccess) > CACHE_EXPIRATION) {
// delete this entry
@@ -1196,46 +1193,46 @@ TimeZoneGenericNames::~TimeZoneGenericNames() {
TimeZoneGenericNames*
TimeZoneGenericNames::createInstance(const Locale& locale, UErrorCode& status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
TimeZoneGenericNames* instance = new TimeZoneGenericNames();
- if (instance == NULL) {
+ if (instance == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
- TZGNCoreRef *cacheEntry = NULL;
+ TZGNCoreRef *cacheEntry = nullptr;
{
Mutex lock(&gTZGNLock);
if (!gTZGNCoreCacheInitialized) {
// Create empty hashtable
- gTZGNCoreCache = uhash_open(uhash_hashChars, uhash_compareChars, NULL, &status);
+ gTZGNCoreCache = uhash_open(uhash_hashChars, uhash_compareChars, nullptr, &status);
if (U_SUCCESS(status)) {
uhash_setKeyDeleter(gTZGNCoreCache, uprv_free);
uhash_setValueDeleter(gTZGNCoreCache, deleteTZGNCoreRef);
- gTZGNCoreCacheInitialized = TRUE;
+ gTZGNCoreCacheInitialized = true;
ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONEGENERICNAMES, tzgnCore_cleanup);
}
}
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
// Check the cache, if not available, create new one and cache
const char *key = locale.getName();
cacheEntry = (TZGNCoreRef *)uhash_get(gTZGNCoreCache, key);
- if (cacheEntry == NULL) {
- TZGNCore *tzgnCore = NULL;
- char *newKey = NULL;
+ if (cacheEntry == nullptr) {
+ TZGNCore *tzgnCore = nullptr;
+ char *newKey = nullptr;
tzgnCore = new TZGNCore(locale, status);
- if (tzgnCore == NULL) {
+ if (tzgnCore == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
if (U_SUCCESS(status)) {
newKey = (char *)uprv_malloc(uprv_strlen(key) + 1);
- if (newKey == NULL) {
+ if (newKey == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
uprv_strcpy(newKey, key);
@@ -1243,7 +1240,7 @@ TimeZoneGenericNames::createInstance(const Locale& locale, UErrorCode& status) {
}
if (U_SUCCESS(status)) {
cacheEntry = (TZGNCoreRef *)uprv_malloc(sizeof(TZGNCoreRef));
- if (cacheEntry == NULL) {
+ if (cacheEntry == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
cacheEntry->obj = tzgnCore;
@@ -1254,16 +1251,16 @@ TimeZoneGenericNames::createInstance(const Locale& locale, UErrorCode& status) {
}
}
if (U_FAILURE(status)) {
- if (tzgnCore != NULL) {
+ if (tzgnCore != nullptr) {
delete tzgnCore;
}
- if (newKey != NULL) {
+ if (newKey != nullptr) {
uprv_free(newKey);
}
- if (cacheEntry != NULL) {
+ if (cacheEntry != nullptr) {
uprv_free(cacheEntry);
}
- cacheEntry = NULL;
+ cacheEntry = nullptr;
}
} else {
// Update the reference count
@@ -1278,9 +1275,9 @@ TimeZoneGenericNames::createInstance(const Locale& locale, UErrorCode& status) {
}
} // End of mutex locked block
- if (cacheEntry == NULL) {
+ if (cacheEntry == nullptr) {
delete instance;
- return NULL;
+ return nullptr;
}
instance->fRef = cacheEntry;
diff --git a/contrib/libs/icu/i18n/tznames.cpp b/contrib/libs/icu/i18n/tznames.cpp
index 5c504d01cb..900499fd40 100644
--- a/contrib/libs/icu/i18n/tznames.cpp
+++ b/contrib/libs/icu/i18n/tznames.cpp
@@ -30,8 +30,8 @@ U_NAMESPACE_BEGIN
// TimeZoneNames object cache handling
static UMutex gTimeZoneNamesLock;
-static UHashtable *gTimeZoneNamesCache = NULL;
-static UBool gTimeZoneNamesCacheInitialized = FALSE;
+static UHashtable *gTimeZoneNamesCache = nullptr;
+static UBool gTimeZoneNamesCacheInitialized = false;
// Access count - incremented every time up to SWEEP_INTERVAL,
// then reset to 0
@@ -56,14 +56,14 @@ U_CDECL_BEGIN
/**
* Cleanup callback func
*/
-static UBool U_CALLCONV timeZoneNames_cleanup(void)
+static UBool U_CALLCONV timeZoneNames_cleanup()
{
- if (gTimeZoneNamesCache != NULL) {
+ if (gTimeZoneNamesCache != nullptr) {
uhash_close(gTimeZoneNamesCache);
- gTimeZoneNamesCache = NULL;
+ gTimeZoneNamesCache = nullptr;
}
- gTimeZoneNamesCacheInitialized = FALSE;
- return TRUE;
+ gTimeZoneNamesCacheInitialized = false;
+ return true;
}
/**
@@ -135,11 +135,11 @@ TimeZoneNamesDelegate::TimeZoneNamesDelegate(const Locale& locale, UErrorCode& s
Mutex lock(&gTimeZoneNamesLock);
if (!gTimeZoneNamesCacheInitialized) {
// Create empty hashtable if it is not already initialized.
- gTimeZoneNamesCache = uhash_open(uhash_hashChars, uhash_compareChars, NULL, &status);
+ gTimeZoneNamesCache = uhash_open(uhash_hashChars, uhash_compareChars, nullptr, &status);
if (U_SUCCESS(status)) {
uhash_setKeyDeleter(gTimeZoneNamesCache, uprv_free);
uhash_setValueDeleter(gTimeZoneNamesCache, deleteTimeZoneNamesCacheEntry);
- gTimeZoneNamesCacheInitialized = TRUE;
+ gTimeZoneNamesCacheInitialized = true;
ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONENAMES, timeZoneNames_cleanup);
}
}
@@ -149,21 +149,21 @@ TimeZoneNamesDelegate::TimeZoneNamesDelegate(const Locale& locale, UErrorCode& s
}
// Check the cache, if not available, create new one and cache
- TimeZoneNamesCacheEntry *cacheEntry = NULL;
+ TimeZoneNamesCacheEntry *cacheEntry = nullptr;
const char *key = locale.getName();
cacheEntry = (TimeZoneNamesCacheEntry *)uhash_get(gTimeZoneNamesCache, key);
- if (cacheEntry == NULL) {
- TimeZoneNames *tznames = NULL;
- char *newKey = NULL;
+ if (cacheEntry == nullptr) {
+ TimeZoneNames *tznames = nullptr;
+ char *newKey = nullptr;
tznames = new TimeZoneNamesImpl(locale, status);
- if (tznames == NULL) {
+ if (tznames == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
if (U_SUCCESS(status)) {
newKey = (char *)uprv_malloc(uprv_strlen(key) + 1);
- if (newKey == NULL) {
+ if (newKey == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
uprv_strcpy(newKey, key);
@@ -171,7 +171,7 @@ TimeZoneNamesDelegate::TimeZoneNamesDelegate(const Locale& locale, UErrorCode& s
}
if (U_SUCCESS(status)) {
cacheEntry = (TimeZoneNamesCacheEntry *)uprv_malloc(sizeof(TimeZoneNamesCacheEntry));
- if (cacheEntry == NULL) {
+ if (cacheEntry == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
cacheEntry->names = tznames;
@@ -182,16 +182,16 @@ TimeZoneNamesDelegate::TimeZoneNamesDelegate(const Locale& locale, UErrorCode& s
}
}
if (U_FAILURE(status)) {
- if (tznames != NULL) {
+ if (tznames != nullptr) {
delete tznames;
}
- if (newKey != NULL) {
+ if (newKey != nullptr) {
uprv_free(newKey);
}
- if (cacheEntry != NULL) {
+ if (cacheEntry != nullptr) {
uprv_free(cacheEntry);
}
- cacheEntry = NULL;
+ cacheEntry = nullptr;
}
} else {
// Update the reference count
@@ -236,7 +236,7 @@ TimeZoneNamesDelegate::operator==(const TimeZoneNames& other) const {
TimeZoneNamesDelegate*
TimeZoneNamesDelegate::clone() const {
TimeZoneNamesDelegate* other = new TimeZoneNamesDelegate();
- if (other != NULL) {
+ if (other != nullptr) {
umtx_lock(&gTimeZoneNamesLock);
{
// Just increment the reference count
@@ -306,10 +306,10 @@ TimeZoneNames::~TimeZoneNames() {
TimeZoneNames*
TimeZoneNames::createInstance(const Locale& locale, UErrorCode& status) {
- TimeZoneNames *instance = NULL;
+ TimeZoneNames *instance = nullptr;
if (U_SUCCESS(status)) {
instance = new TimeZoneNamesDelegate(locale, status);
- if (instance == NULL && U_SUCCESS(status)) {
+ if (instance == nullptr && U_SUCCESS(status)) {
status = U_MEMORY_ALLOCATION_ERROR;
}
}
@@ -318,10 +318,10 @@ TimeZoneNames::createInstance(const Locale& locale, UErrorCode& status) {
TimeZoneNames*
TimeZoneNames::createTZDBInstance(const Locale& locale, UErrorCode& status) {
- TimeZoneNames *instance = NULL;
+ TimeZoneNames *instance = nullptr;
if (U_SUCCESS(status)) {
instance = new TZDBTimeZoneNames(locale);
- if (instance == NULL && U_SUCCESS(status)) {
+ if (instance == nullptr && U_SUCCESS(status)) {
status = U_MEMORY_ALLOCATION_ERROR;
}
}
@@ -337,7 +337,7 @@ UnicodeString&
TimeZoneNames::getDisplayName(const UnicodeString& tzID, UTimeZoneNameType type, UDate date, UnicodeString& name) const {
getTimeZoneDisplayName(tzID, type, name);
if (name.isEmpty()) {
- UChar mzIDBuf[32];
+ char16_t mzIDBuf[32];
UnicodeString mzID(mzIDBuf, 0, UPRV_LENGTHOF(mzIDBuf));
getMetaZoneID(tzID, date, mzID);
getMetaZoneDisplayName(mzID, type, name);
@@ -378,12 +378,12 @@ struct MatchInfo : UMemory {
MatchInfo(UTimeZoneNameType nameType, int32_t matchLength, const UnicodeString* tzID, const UnicodeString* mzID) {
this->nameType = nameType;
this->matchLength = matchLength;
- if (tzID != NULL) {
+ if (tzID != nullptr) {
this->id.setTo(*tzID);
- this->isTZID = TRUE;
+ this->isTZID = true;
} else {
this->id.setTo(*mzID);
- this->isTZID = FALSE;
+ this->isTZID = false;
}
}
};
@@ -399,11 +399,11 @@ U_CDECL_END
// MatchInfoCollection class
// ---------------------------------------------------
TimeZoneNames::MatchInfoCollection::MatchInfoCollection()
-: fMatches(NULL) {
+: fMatches(nullptr) {
}
TimeZoneNames::MatchInfoCollection::~MatchInfoCollection() {
- if (fMatches != NULL) {
+ if (fMatches != nullptr) {
delete fMatches;
}
}
@@ -414,15 +414,12 @@ TimeZoneNames::MatchInfoCollection::addZone(UTimeZoneNameType nameType, int32_t
if (U_FAILURE(status)) {
return;
}
- MatchInfo* matchInfo = new MatchInfo(nameType, matchLength, &tzID, NULL);
- if (matchInfo == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return;
- }
- matches(status)->addElementX(matchInfo, status);
+ LocalPointer <MatchInfo> matchInfo(new MatchInfo(nameType, matchLength, &tzID, nullptr), status);
+ UVector *matchesVec = matches(status);
if (U_FAILURE(status)) {
- delete matchInfo;
+ return;
}
+ matchesVec->adoptElement(matchInfo.orphan(), status);
}
void
@@ -431,20 +428,17 @@ TimeZoneNames::MatchInfoCollection::addMetaZone(UTimeZoneNameType nameType, int3
if (U_FAILURE(status)) {
return;
}
- MatchInfo* matchInfo = new MatchInfo(nameType, matchLength, NULL, &mzID);
- if (matchInfo == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return;
- }
- matches(status)->addElementX(matchInfo, status);
+ LocalPointer<MatchInfo> matchInfo(new MatchInfo(nameType, matchLength, nullptr, &mzID), status);
+ UVector *matchesVec = matches(status);
if (U_FAILURE(status)) {
- delete matchInfo;
+ return;
}
+ matchesVec->adoptElement(matchInfo.orphan(), status);
}
int32_t
TimeZoneNames::MatchInfoCollection::size() const {
- if (fMatches == NULL) {
+ if (fMatches == nullptr) {
return 0;
}
return fMatches->size();
@@ -474,9 +468,9 @@ TimeZoneNames::MatchInfoCollection::getTimeZoneIDAt(int32_t idx, UnicodeString&
const MatchInfo* match = (const MatchInfo*)fMatches->elementAt(idx);
if (match && match->isTZID) {
tzID.setTo(match->id);
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
UBool
@@ -485,25 +479,25 @@ TimeZoneNames::MatchInfoCollection::getMetaZoneIDAt(int32_t idx, UnicodeString&
const MatchInfo* match = (const MatchInfo*)fMatches->elementAt(idx);
if (match && !match->isTZID) {
mzID.setTo(match->id);
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
UVector*
TimeZoneNames::MatchInfoCollection::matches(UErrorCode& status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
- if (fMatches != NULL) {
+ if (fMatches != nullptr) {
return fMatches;
}
- fMatches = new UVector(deleteMatchInfo, NULL, status);
- if (fMatches == NULL) {
+ fMatches = new UVector(deleteMatchInfo, nullptr, status);
+ if (fMatches == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
} else if (U_FAILURE(status)) {
delete fMatches;
- fMatches = NULL;
+ fMatches = nullptr;
}
return fMatches;
}
diff --git a/contrib/libs/icu/i18n/tznames_impl.cpp b/contrib/libs/icu/i18n/tznames_impl.cpp
index d450b74564..8e52fd90a6 100644
--- a/contrib/libs/icu/i18n/tznames_impl.cpp
+++ b/contrib/libs/icu/i18n/tznames_impl.cpp
@@ -46,7 +46,7 @@ static const char gMZPrefix[] = "meta:";
static const char EMPTY[] = "<empty>"; // place holder for empty ZNames
static const char DUMMY_LOADER[] = "<dummy>"; // place holder for dummy ZNamesLoader
-static const UChar NO_NAME[] = { 0 }; // for empty no-fallback time zone names
+static const char16_t NO_NAME[] = { 0 }; // for empty no-fallback time zone names
// stuff for TZDBTimeZoneNames
static const char* TZDBNAMES_KEYS[] = {"ss", "sd"};
@@ -54,11 +54,11 @@ static const int32_t TZDBNAMES_KEYS_SIZE = UPRV_LENGTHOF(TZDBNAMES_KEYS);
static UMutex gDataMutex;
-static UHashtable* gTZDBNamesMap = NULL;
-static icu::UInitOnce gTZDBNamesMapInitOnce = U_INITONCE_INITIALIZER;
+static UHashtable* gTZDBNamesMap = nullptr;
+static icu::UInitOnce gTZDBNamesMapInitOnce {};
-static TextTrieMap* gTZDBNamesTrie = NULL;
-static icu::UInitOnce gTZDBNamesTrieInitOnce = U_INITONCE_INITIALIZER;
+static TextTrieMap* gTZDBNamesTrie = nullptr;
+static icu::UInitOnce gTZDBNamesTrieInitOnce {};
// The order in which strings are stored may be different than the order in the public enum.
enum UTimeZoneNameTypeIndex {
@@ -72,23 +72,23 @@ enum UTimeZoneNameTypeIndex {
UTZNM_INDEX_SHORT_DAYLIGHT,
UTZNM_INDEX_COUNT
};
-static const UChar* const EMPTY_NAMES[UTZNM_INDEX_COUNT] = {0,0,0,0,0,0,0};
+static const char16_t* const EMPTY_NAMES[UTZNM_INDEX_COUNT] = {0,0,0,0,0,0,0};
U_CDECL_BEGIN
-static UBool U_CALLCONV tzdbTimeZoneNames_cleanup(void) {
- if (gTZDBNamesMap != NULL) {
+static UBool U_CALLCONV tzdbTimeZoneNames_cleanup() {
+ if (gTZDBNamesMap != nullptr) {
uhash_close(gTZDBNamesMap);
- gTZDBNamesMap = NULL;
+ gTZDBNamesMap = nullptr;
}
gTZDBNamesMapInitOnce.reset();
- if (gTZDBNamesTrie != NULL) {
+ if (gTZDBNamesTrie != nullptr) {
delete gTZDBNamesTrie;
- gTZDBNamesTrie = NULL;
+ gTZDBNamesTrie = nullptr;
}
gTZDBNamesTrieInitOnce.reset();
- return TRUE;
+ return true;
}
U_CDECL_END
@@ -97,8 +97,8 @@ U_CDECL_END
*/
struct ZNameInfo {
UTimeZoneNameType type;
- const UChar* tzID;
- const UChar* mzID;
+ const char16_t* tzID;
+ const char16_t* mzID;
};
/**
@@ -122,7 +122,7 @@ void CharacterNode::clear() {
}
void CharacterNode::deleteValues(UObjectDeleter *valueDeleter) {
- if (fValues == NULL) {
+ if (fValues == nullptr) {
// Do nothing.
} else if (!fHasValuesVector) {
if (valueDeleter) {
@@ -141,26 +141,36 @@ CharacterNode::addValue(void *value, UObjectDeleter *valueDeleter, UErrorCode &s
}
return;
}
- if (fValues == NULL) {
+ if (fValues == nullptr) {
fValues = value;
} else {
// At least one value already.
if (!fHasValuesVector) {
// There is only one value so far, and not in a vector yet.
// Create a vector and add the old value.
- UVector *values = new UVector(valueDeleter, NULL, DEFAULT_CHARACTERNODE_CAPACITY, status);
+ LocalPointer<UVector> values(
+ new UVector(valueDeleter, nullptr, DEFAULT_CHARACTERNODE_CAPACITY, status), status);
if (U_FAILURE(status)) {
if (valueDeleter) {
valueDeleter(value);
}
return;
}
- values->addElementX(fValues, status);
- fValues = values;
- fHasValuesVector = TRUE;
+ if (values->hasDeleter()) {
+ values->adoptElement(fValues, status);
+ } else {
+ values->addElement(fValues, status);
+ }
+ fValues = values.orphan();
+ fHasValuesVector = true;
}
// Add the new value.
- ((UVector *)fValues)->addElementX(value, status);
+ UVector *values = (UVector *)fValues;
+ if (values->hasDeleter()) {
+ values->adoptElement(value, status);
+ } else {
+ values->addElement(value, status);
+ }
}
}
@@ -174,8 +184,8 @@ TextTrieMapSearchResultHandler::~TextTrieMapSearchResultHandler(){
// TextTrieMap class implementation
// ---------------------------------------------------
TextTrieMap::TextTrieMap(UBool ignoreCase, UObjectDeleter *valueDeleter)
-: fIgnoreCase(ignoreCase), fNodes(NULL), fNodesCapacity(0), fNodesCount(0),
- fLazyContents(NULL), fIsEmpty(TRUE), fValueDeleter(valueDeleter) {
+: fIgnoreCase(ignoreCase), fNodes(nullptr), fNodesCapacity(0), fNodesCount(0),
+ fLazyContents(nullptr), fIsEmpty(true), fValueDeleter(valueDeleter) {
}
TextTrieMap::~TextTrieMap() {
@@ -184,7 +194,7 @@ TextTrieMap::~TextTrieMap() {
fNodes[index].deleteValues(fValueDeleter);
}
uprv_free(fNodes);
- if (fLazyContents != NULL) {
+ if (fLazyContents != nullptr) {
for (int32_t i=0; i<fLazyContents->size(); i+=2) {
if (fValueDeleter) {
fValueDeleter(fLazyContents->elementAt(i+1));
@@ -209,20 +219,18 @@ int32_t TextTrieMap::isEmpty() const {
//
void
TextTrieMap::put(const UnicodeString &key, void *value, ZNStringPool &sp, UErrorCode &status) {
- const UChar *s = sp.get(key, status);
+ const char16_t *s = sp.get(key, status);
put(s, value, status);
}
// This method is designed for a persistent key, such as string key stored in
// resource bundle.
void
-TextTrieMap::put(const UChar *key, void *value, UErrorCode &status) {
- fIsEmpty = FALSE;
- if (fLazyContents == NULL) {
- fLazyContents = new UVector(status);
- if (fLazyContents == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
- }
+TextTrieMap::put(const char16_t *key, void *value, UErrorCode &status) {
+ fIsEmpty = false;
+ if (fLazyContents == nullptr) {
+ LocalPointer<UVector> lpLazyContents(new UVector(status), status);
+ fLazyContents = lpLazyContents.orphan();
}
if (U_FAILURE(status)) {
if (fValueDeleter) {
@@ -230,10 +238,10 @@ TextTrieMap::put(const UChar *key, void *value, UErrorCode &status) {
}
return;
}
- U_ASSERT(fLazyContents != NULL);
+ U_ASSERT(fLazyContents != nullptr);
- UChar *s = const_cast<UChar *>(key);
- fLazyContents->addElementX(s, status);
+ char16_t *s = const_cast<char16_t *>(key);
+ fLazyContents->addElement(s, status);
if (U_FAILURE(status)) {
if (fValueDeleter) {
fValueDeleter((void*) key);
@@ -241,15 +249,15 @@ TextTrieMap::put(const UChar *key, void *value, UErrorCode &status) {
return;
}
- fLazyContents->addElementX(value, status);
+ fLazyContents->addElement(value, status);
}
void
TextTrieMap::putImpl(const UnicodeString &key, void *value, UErrorCode &status) {
- if (fNodes == NULL) {
+ if (fNodes == nullptr) {
fNodesCapacity = 512;
fNodes = (CharacterNode *)uprv_malloc(fNodesCapacity * sizeof(CharacterNode));
- if (fNodes == NULL) {
+ if (fNodes == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -258,7 +266,7 @@ TextTrieMap::putImpl(const UnicodeString &key, void *value, UErrorCode &status)
}
UnicodeString foldedKey;
- const UChar *keyBuffer;
+ const char16_t *keyBuffer;
int32_t keyLength;
if (fIgnoreCase) {
// Ok to use fastCopyFrom() because we discard the copy when we return.
@@ -281,34 +289,34 @@ TextTrieMap::putImpl(const UnicodeString &key, void *value, UErrorCode &status)
UBool
TextTrieMap::growNodes() {
if (fNodesCapacity == 0xffff) {
- return FALSE; // We use 16-bit node indexes.
+ return false; // We use 16-bit node indexes.
}
int32_t newCapacity = fNodesCapacity + 1000;
if (newCapacity > 0xffff) {
newCapacity = 0xffff;
}
CharacterNode *newNodes = (CharacterNode *)uprv_malloc(newCapacity * sizeof(CharacterNode));
- if (newNodes == NULL) {
- return FALSE;
+ if (newNodes == nullptr) {
+ return false;
}
uprv_memcpy(newNodes, fNodes, fNodesCount * sizeof(CharacterNode));
uprv_free(fNodes);
fNodes = newNodes;
fNodesCapacity = newCapacity;
- return TRUE;
+ return true;
}
CharacterNode*
-TextTrieMap::addChildNode(CharacterNode *parent, UChar c, UErrorCode &status) {
+TextTrieMap::addChildNode(CharacterNode *parent, char16_t c, UErrorCode &status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
// Linear search of the sorted list of children.
uint16_t prevIndex = 0;
uint16_t nodeIndex = parent->fFirstChild;
while (nodeIndex > 0) {
CharacterNode *current = fNodes + nodeIndex;
- UChar childCharacter = current->fCharacter;
+ char16_t childCharacter = current->fCharacter;
if (childCharacter == c) {
return current;
} else if (childCharacter > c) {
@@ -323,7 +331,7 @@ TextTrieMap::addChildNode(CharacterNode *parent, UChar c, UErrorCode &status) {
int32_t parentIndex = (int32_t)(parent - fNodes);
if (!growNodes()) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
parent = fNodes + parentIndex;
}
@@ -343,12 +351,12 @@ TextTrieMap::addChildNode(CharacterNode *parent, UChar c, UErrorCode &status) {
}
CharacterNode*
-TextTrieMap::getChildNode(CharacterNode *parent, UChar c) const {
+TextTrieMap::getChildNode(CharacterNode *parent, char16_t c) const {
// Linear search of the sorted list of children.
uint16_t nodeIndex = parent->fFirstChild;
while (nodeIndex > 0) {
CharacterNode *current = fNodes + nodeIndex;
- UChar childCharacter = current->fCharacter;
+ char16_t childCharacter = current->fCharacter;
if (childCharacter == c) {
return current;
} else if (childCharacter > c) {
@@ -356,7 +364,7 @@ TextTrieMap::getChildNode(CharacterNode *parent, UChar c) const {
}
nodeIndex = current->fNextSibling;
}
- return NULL;
+ return nullptr;
}
@@ -365,15 +373,15 @@ TextTrieMap::getChildNode(CharacterNode *parent, UChar c) const {
// needed for parsing operations, which are less common than formatting,
// and the Trie is big, which is why its creation is deferred until first use.
void TextTrieMap::buildTrie(UErrorCode &status) {
- if (fLazyContents != NULL) {
+ if (fLazyContents != nullptr) {
for (int32_t i=0; i<fLazyContents->size(); i+=2) {
- const UChar *key = (UChar *)fLazyContents->elementAt(i);
+ const char16_t *key = (char16_t *)fLazyContents->elementAt(i);
void *val = fLazyContents->elementAt(i+1);
- UnicodeString keyString(TRUE, key, -1); // Aliasing UnicodeString constructor.
+ UnicodeString keyString(true, key, -1); // Aliasing UnicodeString constructor.
putImpl(keyString, val, status);
}
delete fLazyContents;
- fLazyContents = NULL;
+ fLazyContents = nullptr;
}
}
@@ -391,12 +399,12 @@ TextTrieMap::search(const UnicodeString &text, int32_t start,
static UMutex TextTrieMutex;
Mutex lock(&TextTrieMutex);
- if (fLazyContents != NULL) {
+ if (fLazyContents != nullptr) {
TextTrieMap *nonConstThis = const_cast<TextTrieMap *>(this);
nonConstThis->buildTrie(status);
}
}
- if (fNodes == NULL) {
+ if (fNodes == nullptr) {
return;
}
search(fNodes, text, start, start, handler, status);
@@ -426,18 +434,18 @@ TextTrieMap::search(CharacterNode *node, const UnicodeString &text, int32_t star
tmp.foldCase();
int32_t tmpidx = 0;
while (tmpidx < tmp.length()) {
- UChar c = tmp.charAt(tmpidx++);
+ char16_t c = tmp.charAt(tmpidx++);
node = getChildNode(node, c);
- if (node == NULL) {
+ if (node == nullptr) {
break;
}
}
} else {
// here we just get the next UTF16 code unit
- UChar c = text.charAt(index++);
+ char16_t c = text.charAt(index++);
node = getChildNode(node, c);
}
- if (node != NULL) {
+ if (node != nullptr) {
search(node, text, start, index, handler, status);
}
}
@@ -449,23 +457,23 @@ static const int32_t POOL_CHUNK_SIZE = 2000;
struct ZNStringPoolChunk: public UMemory {
ZNStringPoolChunk *fNext; // Ptr to next pool chunk
int32_t fLimit; // Index to start of unused area at end of fStrings
- UChar fStrings[POOL_CHUNK_SIZE]; // Strings array
+ char16_t fStrings[POOL_CHUNK_SIZE]; // Strings array
ZNStringPoolChunk();
};
ZNStringPoolChunk::ZNStringPoolChunk() {
- fNext = NULL;
+ fNext = nullptr;
fLimit = 0;
}
ZNStringPool::ZNStringPool(UErrorCode &status) {
- fChunks = NULL;
- fHash = NULL;
+ fChunks = nullptr;
+ fHash = nullptr;
if (U_FAILURE(status)) {
return;
}
fChunks = new ZNStringPoolChunk;
- if (fChunks == NULL) {
+ if (fChunks == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -480,28 +488,28 @@ ZNStringPool::ZNStringPool(UErrorCode &status) {
}
ZNStringPool::~ZNStringPool() {
- if (fHash != NULL) {
+ if (fHash != nullptr) {
uhash_close(fHash);
- fHash = NULL;
+ fHash = nullptr;
}
- while (fChunks != NULL) {
+ while (fChunks != nullptr) {
ZNStringPoolChunk *nextChunk = fChunks->fNext;
delete fChunks;
fChunks = nextChunk;
}
}
-static const UChar EmptyString = 0;
+static const char16_t EmptyString = 0;
-const UChar *ZNStringPool::get(const UChar *s, UErrorCode &status) {
- const UChar *pooledString;
+const char16_t *ZNStringPool::get(const char16_t *s, UErrorCode &status) {
+ const char16_t *pooledString;
if (U_FAILURE(status)) {
return &EmptyString;
}
- pooledString = static_cast<UChar *>(uhash_get(fHash, s));
- if (pooledString != NULL) {
+ pooledString = static_cast<char16_t *>(uhash_get(fHash, s));
+ if (pooledString != nullptr) {
return pooledString;
}
@@ -515,14 +523,14 @@ const UChar *ZNStringPool::get(const UChar *s, UErrorCode &status) {
}
ZNStringPoolChunk *oldChunk = fChunks;
fChunks = new ZNStringPoolChunk;
- if (fChunks == NULL) {
+ if (fChunks == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return &EmptyString;
}
fChunks->fNext = oldChunk;
}
- UChar *destString = &fChunks->fStrings[fChunks->fLimit];
+ char16_t *destString = &fChunks->fStrings[fChunks->fLimit];
u_strcpy(destString, s);
fChunks->fLimit += (length + 1);
uhash_put(fHash, destString, destString, &status);
@@ -535,15 +543,15 @@ const UChar *ZNStringPool::get(const UChar *s, UErrorCode &status) {
// into the pool's storage. Used for strings from resource bundles,
// which will persist for the life of the zone string formatter, and
// therefore can be used directly without copying.
-const UChar *ZNStringPool::adopt(const UChar * s, UErrorCode &status) {
- const UChar *pooledString;
+const char16_t *ZNStringPool::adopt(const char16_t * s, UErrorCode &status) {
+ const char16_t *pooledString;
if (U_FAILURE(status)) {
return &EmptyString;
}
- if (s != NULL) {
- pooledString = static_cast<UChar *>(uhash_get(fHash, s));
- if (pooledString == NULL) {
- UChar *ncs = const_cast<UChar *>(s);
+ if (s != nullptr) {
+ pooledString = static_cast<char16_t *>(uhash_get(fHash, s));
+ if (pooledString == nullptr) {
+ char16_t *ncs = const_cast<char16_t *>(s);
uhash_put(fHash, ncs, ncs, &status);
}
}
@@ -551,7 +559,7 @@ const UChar *ZNStringPool::adopt(const UChar * s, UErrorCode &status) {
}
-const UChar *ZNStringPool::get(const UnicodeString &s, UErrorCode &status) {
+const char16_t *ZNStringPool::get(const UnicodeString &s, UErrorCode &status) {
UnicodeString &nonConstStr = const_cast<UnicodeString &>(s);
return this->get(nonConstStr.getTerminatedBuffer(), status);
}
@@ -565,7 +573,7 @@ const UChar *ZNStringPool::get(const UnicodeString &s, UErrorCode &status) {
*/
void ZNStringPool::freeze() {
uhash_close(fHash);
- fHash = NULL;
+ fHash = nullptr;
}
@@ -601,38 +609,38 @@ private:
}
}
- const UChar* fNames[UTZNM_INDEX_COUNT];
+ const char16_t* fNames[UTZNM_INDEX_COUNT];
UBool fDidAddIntoTrie;
// Whether we own the location string, if computed rather than loaded from a bundle.
// A meta zone names instance never has an exemplar location string.
UBool fOwnsLocationName;
- ZNames(const UChar* names[], const UChar* locationName)
- : fDidAddIntoTrie(FALSE) {
+ ZNames(const char16_t* names[], const char16_t* locationName)
+ : fDidAddIntoTrie(false) {
uprv_memcpy(fNames, names, sizeof(fNames));
- if (locationName != NULL) {
- fOwnsLocationName = TRUE;
+ if (locationName != nullptr) {
+ fOwnsLocationName = true;
fNames[UTZNM_INDEX_EXEMPLAR_LOCATION] = locationName;
} else {
- fOwnsLocationName = FALSE;
+ fOwnsLocationName = false;
}
}
public:
~ZNames() {
if (fOwnsLocationName) {
- const UChar* locationName = fNames[UTZNM_INDEX_EXEMPLAR_LOCATION];
- U_ASSERT(locationName != NULL);
+ const char16_t* locationName = fNames[UTZNM_INDEX_EXEMPLAR_LOCATION];
+ U_ASSERT(locationName != nullptr);
uprv_free((void*) locationName);
}
}
private:
- static void* createMetaZoneAndPutInCache(UHashtable* cache, const UChar* names[],
+ static void* createMetaZoneAndPutInCache(UHashtable* cache, const char16_t* names[],
const UnicodeString& mzID, UErrorCode& status) {
- if (U_FAILURE(status)) { return NULL; }
- U_ASSERT(names != NULL);
+ if (U_FAILURE(status)) { return nullptr; }
+ U_ASSERT(names != nullptr);
// Use the persistent ID as the resource key, so we can
// avoid duplications.
@@ -642,35 +650,35 @@ private:
if (uprv_memcmp(names, EMPTY_NAMES, sizeof(EMPTY_NAMES)) == 0) {
value = (void*) EMPTY;
} else {
- value = (void*) (new ZNames(names, NULL));
- if (value == NULL) {
+ value = (void*) (new ZNames(names, nullptr));
+ if (value == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
}
uhash_put(cache, key, value, &status);
return value;
}
- static void* createTimeZoneAndPutInCache(UHashtable* cache, const UChar* names[],
+ static void* createTimeZoneAndPutInCache(UHashtable* cache, const char16_t* names[],
const UnicodeString& tzID, UErrorCode& status) {
- if (U_FAILURE(status)) { return NULL; }
- U_ASSERT(names != NULL);
+ if (U_FAILURE(status)) { return nullptr; }
+ U_ASSERT(names != nullptr);
// If necessary, compute the location name from the time zone name.
- UChar* locationName = NULL;
- if (names[UTZNM_INDEX_EXEMPLAR_LOCATION] == NULL) {
+ char16_t* locationName = nullptr;
+ if (names[UTZNM_INDEX_EXEMPLAR_LOCATION] == nullptr) {
UnicodeString locationNameUniStr;
TimeZoneNamesImpl::getDefaultExemplarLocationName(tzID, locationNameUniStr);
// Copy the computed location name to the heap
if (locationNameUniStr.length() > 0) {
- const UChar* buff = locationNameUniStr.getTerminatedBuffer();
- int32_t len = sizeof(UChar) * (locationNameUniStr.length() + 1);
- locationName = (UChar*) uprv_malloc(len);
- if (locationName == NULL) {
+ const char16_t* buff = locationNameUniStr.getTerminatedBuffer();
+ int32_t len = sizeof(char16_t) * (locationNameUniStr.length() + 1);
+ locationName = (char16_t*) uprv_malloc(len);
+ if (locationName == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
uprv_memcpy(locationName, buff, len);
}
@@ -681,37 +689,37 @@ private:
// TODO: Is there a more efficient way, like intern() in Java?
void* key = (void*) ZoneMeta::findTimeZoneID(tzID);
void* value = (void*) (new ZNames(names, locationName));
- if (value == NULL) {
+ if (value == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
uhash_put(cache, key, value, &status);
return value;
}
- const UChar* getName(UTimeZoneNameType type) const {
+ const char16_t* getName(UTimeZoneNameType type) const {
UTimeZoneNameTypeIndex index = getTZNameTypeIndex(type);
- return index >= 0 ? fNames[index] : NULL;
+ return index >= 0 ? fNames[index] : nullptr;
}
- void addAsMetaZoneIntoTrie(const UChar* mzID, TextTrieMap& trie, UErrorCode& status) {
- addNamesIntoTrie(mzID, NULL, trie, status);
+ void addAsMetaZoneIntoTrie(const char16_t* mzID, TextTrieMap& trie, UErrorCode& status) {
+ addNamesIntoTrie(mzID, nullptr, trie, status);
}
- void addAsTimeZoneIntoTrie(const UChar* tzID, TextTrieMap& trie, UErrorCode& status) {
- addNamesIntoTrie(NULL, tzID, trie, status);
+ void addAsTimeZoneIntoTrie(const char16_t* tzID, TextTrieMap& trie, UErrorCode& status) {
+ addNamesIntoTrie(nullptr, tzID, trie, status);
}
- void addNamesIntoTrie(const UChar* mzID, const UChar* tzID, TextTrieMap& trie,
+ void addNamesIntoTrie(const char16_t* mzID, const char16_t* tzID, TextTrieMap& trie,
UErrorCode& status) {
if (U_FAILURE(status)) { return; }
if (fDidAddIntoTrie) { return; }
- fDidAddIntoTrie = TRUE;
+ fDidAddIntoTrie = true;
for (int32_t i = 0; i < UTZNM_INDEX_COUNT; i++) {
- const UChar* name = fNames[i];
- if (name != NULL) {
+ const char16_t* name = fNames[i];
+ if (name != nullptr) {
ZNameInfo *nameinfo = (ZNameInfo *)uprv_malloc(sizeof(ZNameInfo));
- if (nameinfo == NULL) {
+ if (nameinfo == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -731,7 +739,7 @@ public:
};
struct ZNames::ZNamesLoader : public ResourceSink {
- const UChar *names[UTZNM_INDEX_COUNT];
+ const char16_t *names[UTZNM_INDEX_COUNT];
ZNamesLoader() {
clear();
@@ -756,8 +764,8 @@ struct ZNames::ZNamesLoader : public ResourceSink {
// Replace "/" with ":".
UnicodeString uKey(tzID);
for (int32_t i = 0; i < uKey.length(); i++) {
- if (uKey.charAt(i) == (UChar)0x2F) {
- uKey.setCharAt(i, (UChar)0x3A);
+ if (uKey.charAt(i) == (char16_t)0x2F) {
+ uKey.setCharAt(i, (char16_t)0x3A);
}
}
@@ -768,8 +776,8 @@ struct ZNames::ZNamesLoader : public ResourceSink {
}
void loadNames(const UResourceBundle* zoneStrings, const char* key, UErrorCode& errorCode) {
- U_ASSERT(zoneStrings != NULL);
- U_ASSERT(key != NULL);
+ U_ASSERT(zoneStrings != nullptr);
+ U_ASSERT(key != nullptr);
U_ASSERT(key[0] != '\0');
UErrorCode localStatus = U_ZERO_ERROR;
@@ -785,11 +793,11 @@ struct ZNames::ZNamesLoader : public ResourceSink {
void setNameIfEmpty(const char* key, const ResourceValue* value, UErrorCode& errorCode) {
UTimeZoneNameTypeIndex type = nameTypeFromKey(key);
if (type == UTZNM_INDEX_UNKNOWN) { return; }
- if (names[type] == NULL) {
+ if (names[type] == nullptr) {
int32_t length;
// 'NO_NAME' indicates internally that this field should remain empty. It will be
- // replaced by 'NULL' in getNames()
- names[type] = (value == NULL) ? NO_NAME : value->getString(length, errorCode);
+ // replaced by 'nullptr' in getNames()
+ names[type] = (value == nullptr) ? NO_NAME : value->getString(length, errorCode);
}
}
@@ -799,7 +807,7 @@ struct ZNames::ZNamesLoader : public ResourceSink {
if (U_FAILURE(errorCode)) { return; }
for (int32_t i = 0; namesTable.getKeyAndValue(i, key, value); ++i) {
if (value.isNoInheritanceMarker()) {
- setNameIfEmpty(key, NULL, errorCode);
+ setNameIfEmpty(key, nullptr, errorCode);
} else {
setNameIfEmpty(key, &value, errorCode);
}
@@ -833,11 +841,11 @@ struct ZNames::ZNamesLoader : public ResourceSink {
* This is different than Java, where the array will no longer be modified and null
* may be returned.
*/
- const UChar** getNames() {
- // Remove 'NO_NAME' references in the array and replace with 'NULL'
+ const char16_t** getNames() {
+ // Remove 'NO_NAME' references in the array and replace with 'nullptr'
for (int32_t i = 0; i < UTZNM_INDEX_COUNT; ++i) {
if (names[i] == NO_NAME) {
- names[i] = NULL;
+ names[i] = nullptr;
}
}
return names;
@@ -854,10 +862,10 @@ class MetaZoneIDsEnumeration : public StringEnumeration {
public:
MetaZoneIDsEnumeration();
MetaZoneIDsEnumeration(const UVector& mzIDs);
- MetaZoneIDsEnumeration(UVector* mzIDs);
+ MetaZoneIDsEnumeration(LocalPointer<UVector> mzIDs);
virtual ~MetaZoneIDsEnumeration();
- static UClassID U_EXPORT2 getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID U_EXPORT2 getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
virtual const UnicodeString* snext(UErrorCode& status) override;
virtual void reset(UErrorCode& status) override;
virtual int32_t count(UErrorCode& status) const override;
@@ -865,22 +873,23 @@ private:
int32_t fLen;
int32_t fPos;
const UVector* fMetaZoneIDs;
- UVector *fLocalVector;
+ LocalPointer<UVector> fLocalVector;
};
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(MetaZoneIDsEnumeration)
MetaZoneIDsEnumeration::MetaZoneIDsEnumeration()
-: fLen(0), fPos(0), fMetaZoneIDs(NULL), fLocalVector(NULL) {
+: fLen(0), fPos(0), fMetaZoneIDs(nullptr), fLocalVector(nullptr) {
}
MetaZoneIDsEnumeration::MetaZoneIDsEnumeration(const UVector& mzIDs)
-: fPos(0), fMetaZoneIDs(&mzIDs), fLocalVector(NULL) {
+: fPos(0), fMetaZoneIDs(&mzIDs), fLocalVector(nullptr) {
fLen = fMetaZoneIDs->size();
}
-MetaZoneIDsEnumeration::MetaZoneIDsEnumeration(UVector *mzIDs)
-: fLen(0), fPos(0), fMetaZoneIDs(mzIDs), fLocalVector(mzIDs) {
+MetaZoneIDsEnumeration::MetaZoneIDsEnumeration(LocalPointer<UVector> mzIDs)
+: fLen(0), fPos(0), fMetaZoneIDs(nullptr), fLocalVector(std::move(mzIDs)) {
+ fMetaZoneIDs = fLocalVector.getAlias();
if (fMetaZoneIDs) {
fLen = fMetaZoneIDs->size();
}
@@ -888,11 +897,11 @@ MetaZoneIDsEnumeration::MetaZoneIDsEnumeration(UVector *mzIDs)
const UnicodeString*
MetaZoneIDsEnumeration::snext(UErrorCode& status) {
- if (U_SUCCESS(status) && fMetaZoneIDs != NULL && fPos < fLen) {
- unistr.setTo((const UChar*)fMetaZoneIDs->elementAt(fPos++), -1);
+ if (U_SUCCESS(status) && fMetaZoneIDs != nullptr && fPos < fLen) {
+ unistr.setTo((const char16_t*)fMetaZoneIDs->elementAt(fPos++), -1);
return &unistr;
}
- return NULL;
+ return nullptr;
}
void
@@ -906,9 +915,6 @@ MetaZoneIDsEnumeration::count(UErrorCode& /*status*/) const {
}
MetaZoneIDsEnumeration::~MetaZoneIDsEnumeration() {
- if (fLocalVector) {
- delete fLocalVector;
- }
}
@@ -930,11 +936,11 @@ private:
};
ZNameSearchHandler::ZNameSearchHandler(uint32_t types)
-: fTypes(types), fMaxMatchLen(0), fResults(NULL) {
+: fTypes(types), fMaxMatchLen(0), fResults(nullptr) {
}
ZNameSearchHandler::~ZNameSearchHandler() {
- if (fResults != NULL) {
+ if (fResults != nullptr) {
delete fResults;
}
}
@@ -942,25 +948,25 @@ ZNameSearchHandler::~ZNameSearchHandler() {
UBool
ZNameSearchHandler::handleMatch(int32_t matchLength, const CharacterNode *node, UErrorCode &status) {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
if (node->hasValues()) {
int32_t valuesCount = node->countValues();
for (int32_t i = 0; i < valuesCount; i++) {
ZNameInfo *nameinfo = (ZNameInfo *)node->getValue(i);
- if (nameinfo == NULL) {
+ if (nameinfo == nullptr) {
continue;
}
if ((nameinfo->type & fTypes) != 0) {
// matches a requested type
- if (fResults == NULL) {
+ if (fResults == nullptr) {
fResults = new TimeZoneNames::MatchInfoCollection();
- if (fResults == NULL) {
+ if (fResults == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
}
if (U_SUCCESS(status)) {
- U_ASSERT(fResults != NULL);
+ U_ASSERT(fResults != nullptr);
if (nameinfo->tzID) {
fResults->addZone(nameinfo->type, matchLength, UnicodeString(nameinfo->tzID, -1), status);
} else {
@@ -974,7 +980,7 @@ ZNameSearchHandler::handleMatch(int32_t matchLength, const CharacterNode *node,
}
}
}
- return TRUE;
+ return true;
}
TimeZoneNames::MatchInfoCollection*
@@ -984,7 +990,7 @@ ZNameSearchHandler::getMatches(int32_t& maxMatchLen) {
maxMatchLen = fMaxMatchLen;
// reset
- fResults = NULL;
+ fResults = nullptr;
fMaxMatchLen = 0;
return results;
}
@@ -1019,12 +1025,12 @@ U_CDECL_END
TimeZoneNamesImpl::TimeZoneNamesImpl(const Locale& locale, UErrorCode& status)
: fLocale(locale),
- fZoneStrings(NULL),
- fTZNamesMap(NULL),
- fMZNamesMap(NULL),
- fNamesTrieFullyLoaded(FALSE),
- fNamesFullyLoaded(FALSE),
- fNamesTrie(TRUE, deleteZNameInfo) {
+ fZoneStrings(nullptr),
+ fTZNamesMap(nullptr),
+ fMZNamesMap(nullptr),
+ fNamesTrieFullyLoaded(false),
+ fNamesFullyLoaded(false),
+ fNamesTrie(true, deleteZNameInfo) {
initialize(locale, status);
}
@@ -1045,8 +1051,8 @@ TimeZoneNamesImpl::initialize(const Locale& locale, UErrorCode& status) {
}
// Initialize hashtables holding time zone/meta zone names
- fMZNamesMap = uhash_open(uhash_hashUChars, uhash_compareUChars, NULL, &status);
- fTZNamesMap = uhash_open(uhash_hashUChars, uhash_compareUChars, NULL, &status);
+ fMZNamesMap = uhash_open(uhash_hashUChars, uhash_compareUChars, nullptr, &status);
+ fTZNamesMap = uhash_open(uhash_hashUChars, uhash_compareUChars, nullptr, &status);
if (U_FAILURE(status)) {
cleanup();
return;
@@ -1058,8 +1064,8 @@ TimeZoneNamesImpl::initialize(const Locale& locale, UErrorCode& status) {
// preload zone strings for the default zone
TimeZone *tz = TimeZone::createDefault();
- const UChar *tzID = ZoneMeta::getCanonicalCLDRID(*tz);
- if (tzID != NULL) {
+ const char16_t *tzID = ZoneMeta::getCanonicalCLDRID(*tz);
+ if (tzID != nullptr) {
loadStrings(UnicodeString(tzID), status);
}
delete tz;
@@ -1079,7 +1085,7 @@ TimeZoneNamesImpl::loadStrings(const UnicodeString& tzCanonicalID, UErrorCode& s
U_ASSERT(!mzIDs.isNull());
const UnicodeString *mzID;
- while (((mzID = mzIDs->snext(status)) != NULL) && U_SUCCESS(status)) {
+ while (((mzID = mzIDs->snext(status)) != nullptr) && U_SUCCESS(status)) {
loadMetaZoneNames(*mzID, status);
}
}
@@ -1090,17 +1096,17 @@ TimeZoneNamesImpl::~TimeZoneNamesImpl() {
void
TimeZoneNamesImpl::cleanup() {
- if (fZoneStrings != NULL) {
+ if (fZoneStrings != nullptr) {
ures_close(fZoneStrings);
- fZoneStrings = NULL;
+ fZoneStrings = nullptr;
}
- if (fMZNamesMap != NULL) {
+ if (fMZNamesMap != nullptr) {
uhash_close(fMZNamesMap);
- fMZNamesMap = NULL;
+ fMZNamesMap = nullptr;
}
- if (fTZNamesMap != NULL) {
+ if (fTZNamesMap != nullptr) {
uhash_close(fTZNamesMap);
- fTZNamesMap = NULL;
+ fTZNamesMap = nullptr;
}
}
@@ -1128,10 +1134,10 @@ TimeZoneNamesImpl::getAvailableMetaZoneIDs(UErrorCode& status) const {
StringEnumeration*
TimeZoneNamesImpl::_getAvailableMetaZoneIDs(UErrorCode& status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
const UVector* mzIDs = ZoneMeta::getAvailableMetazoneIDs();
- if (mzIDs == NULL) {
+ if (mzIDs == nullptr) {
return new MetaZoneIDsEnumeration();
}
return new MetaZoneIDsEnumeration(*mzIDs);
@@ -1146,35 +1152,30 @@ TimeZoneNamesImpl::getAvailableMetaZoneIDs(const UnicodeString& tzID, UErrorCode
StringEnumeration*
TimeZoneNamesImpl::_getAvailableMetaZoneIDs(const UnicodeString& tzID, UErrorCode& status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
const UVector* mappings = ZoneMeta::getMetazoneMappings(tzID);
- if (mappings == NULL) {
+ if (mappings == nullptr) {
return new MetaZoneIDsEnumeration();
}
- MetaZoneIDsEnumeration *senum = NULL;
- UVector* mzIDs = new UVector(NULL, uhash_compareUChars, status);
- if (mzIDs == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
- }
+ LocalPointer<MetaZoneIDsEnumeration> senum;
+ LocalPointer<UVector> mzIDs(new UVector(nullptr, uhash_compareUChars, status), status);
if (U_SUCCESS(status)) {
- U_ASSERT(mzIDs != NULL);
+ U_ASSERT(mzIDs.isValid());
for (int32_t i = 0; U_SUCCESS(status) && i < mappings->size(); i++) {
OlsonToMetaMappingEntry *map = (OlsonToMetaMappingEntry *)mappings->elementAt(i);
- const UChar *mzID = map->mzid;
+ const char16_t *mzID = map->mzid;
if (!mzIDs->contains((void *)mzID)) {
- mzIDs->addElementX((void *)mzID, status);
+ mzIDs->addElement((void *)mzID, status);
}
}
if (U_SUCCESS(status)) {
- senum = new MetaZoneIDsEnumeration(mzIDs);
- } else {
- delete mzIDs;
+ senum.adoptInsteadAndCheckErrorCode(new MetaZoneIDsEnumeration(std::move(mzIDs)), status);
}
}
- return senum;
+ return U_SUCCESS(status) ? senum.orphan() : nullptr;
}
UnicodeString&
@@ -1210,7 +1211,7 @@ TimeZoneNamesImpl::getMetaZoneDisplayName(const UnicodeString& mzID,
return name;
}
- ZNames *znames = NULL;
+ ZNames *znames = nullptr;
TimeZoneNamesImpl *nonConstThis = const_cast<TimeZoneNamesImpl *>(this);
{
@@ -1220,10 +1221,10 @@ TimeZoneNamesImpl::getMetaZoneDisplayName(const UnicodeString& mzID,
if (U_FAILURE(status)) { return name; }
}
- if (znames != NULL) {
- const UChar* s = znames->getName(type);
- if (s != NULL) {
- name.setTo(TRUE, s, -1);
+ if (znames != nullptr) {
+ const char16_t* s = znames->getName(type);
+ if (s != nullptr) {
+ name.setTo(true, s, -1);
}
}
return name;
@@ -1236,7 +1237,7 @@ TimeZoneNamesImpl::getTimeZoneDisplayName(const UnicodeString& tzID, UTimeZoneNa
return name;
}
- ZNames *tznames = NULL;
+ ZNames *tznames = nullptr;
TimeZoneNamesImpl *nonConstThis = const_cast<TimeZoneNamesImpl *>(this);
{
@@ -1246,10 +1247,10 @@ TimeZoneNamesImpl::getTimeZoneDisplayName(const UnicodeString& tzID, UTimeZoneNa
if (U_FAILURE(status)) { return name; }
}
- if (tznames != NULL) {
- const UChar *s = tznames->getName(type);
- if (s != NULL) {
- name.setTo(TRUE, s, -1);
+ if (tznames != nullptr) {
+ const char16_t *s = tznames->getName(type);
+ if (s != nullptr) {
+ name.setTo(true, s, -1);
}
}
return name;
@@ -1258,8 +1259,8 @@ TimeZoneNamesImpl::getTimeZoneDisplayName(const UnicodeString& tzID, UTimeZoneNa
UnicodeString&
TimeZoneNamesImpl::getExemplarLocationName(const UnicodeString& tzID, UnicodeString& name) const {
name.setToBogus(); // cleanup result.
- const UChar* locName = NULL;
- ZNames *tznames = NULL;
+ const char16_t* locName = nullptr;
+ ZNames *tznames = nullptr;
TimeZoneNamesImpl *nonConstThis = const_cast<TimeZoneNamesImpl *>(this);
{
@@ -1269,11 +1270,11 @@ TimeZoneNamesImpl::getExemplarLocationName(const UnicodeString& tzID, UnicodeStr
if (U_FAILURE(status)) { return name; }
}
- if (tznames != NULL) {
+ if (tznames != nullptr) {
locName = tznames->getName(UTZNM_EXEMPLAR_LOCATION);
}
- if (locName != NULL) {
- name.setTo(TRUE, locName, -1);
+ if (locName != nullptr) {
+ name.setTo(true, locName, -1);
}
return name;
@@ -1301,26 +1302,26 @@ static void mergeTimeZoneKey(const UnicodeString& mzID, char* result) {
*/
ZNames*
TimeZoneNamesImpl::loadMetaZoneNames(const UnicodeString& mzID, UErrorCode& status) {
- if (U_FAILURE(status)) { return NULL; }
+ if (U_FAILURE(status)) { return nullptr; }
U_ASSERT(mzID.length() <= ZID_KEY_MAX - MZ_PREFIX_LEN);
- UChar mzIDKey[ZID_KEY_MAX + 1];
+ char16_t mzIDKey[ZID_KEY_MAX + 1];
mzID.extract(mzIDKey, ZID_KEY_MAX + 1, status);
U_ASSERT(U_SUCCESS(status)); // already checked length above
mzIDKey[mzID.length()] = 0;
void* mznames = uhash_get(fMZNamesMap, mzIDKey);
- if (mznames == NULL) {
+ if (mznames == nullptr) {
ZNames::ZNamesLoader loader;
loader.loadMetaZone(fZoneStrings, mzID, status);
mznames = ZNames::createMetaZoneAndPutInCache(fMZNamesMap, loader.getNames(), mzID, status);
- if (U_FAILURE(status)) { return NULL; }
+ if (U_FAILURE(status)) { return nullptr; }
}
if (mznames != EMPTY) {
return (ZNames*)mznames;
} else {
- return NULL;
+ return nullptr;
}
}
@@ -1329,20 +1330,20 @@ TimeZoneNamesImpl::loadMetaZoneNames(const UnicodeString& mzID, UErrorCode& stat
*/
ZNames*
TimeZoneNamesImpl::loadTimeZoneNames(const UnicodeString& tzID, UErrorCode& status) {
- if (U_FAILURE(status)) { return NULL; }
+ if (U_FAILURE(status)) { return nullptr; }
U_ASSERT(tzID.length() <= ZID_KEY_MAX);
- UChar tzIDKey[ZID_KEY_MAX + 1];
+ char16_t tzIDKey[ZID_KEY_MAX + 1];
int32_t tzIDKeyLen = tzID.extract(tzIDKey, ZID_KEY_MAX + 1, status);
U_ASSERT(U_SUCCESS(status)); // already checked length above
tzIDKey[tzIDKeyLen] = 0;
void *tznames = uhash_get(fTZNamesMap, tzIDKey);
- if (tznames == NULL) {
+ if (tznames == nullptr) {
ZNames::ZNamesLoader loader;
loader.loadTimeZone(fZoneStrings, tzID, status);
tznames = ZNames::createTimeZoneAndPutInCache(fTZNamesMap, loader.getNames(), tzID, status);
- if (U_FAILURE(status)) { return NULL; }
+ if (U_FAILURE(status)) { return nullptr; }
}
// tznames is never EMPTY
@@ -1362,8 +1363,8 @@ TimeZoneNamesImpl::find(const UnicodeString& text, int32_t start, uint32_t types
// First try of lookup.
matches = doFind(handler, text, start, status);
- if (U_FAILURE(status)) { return NULL; }
- if (matches != NULL) {
+ if (U_FAILURE(status)) { return nullptr; }
+ if (matches != nullptr) {
return matches;
}
@@ -1375,8 +1376,8 @@ TimeZoneNamesImpl::find(const UnicodeString& text, int32_t start, uint32_t types
// Second try of lookup.
matches = doFind(handler, text, start, status);
- if (U_FAILURE(status)) { return NULL; }
- if (matches != NULL) {
+ if (U_FAILURE(status)) { return nullptr; }
+ if (matches != nullptr) {
return matches;
}
@@ -1384,8 +1385,8 @@ TimeZoneNamesImpl::find(const UnicodeString& text, int32_t start, uint32_t types
// Load everything now.
nonConstThis->internalLoadAllDisplayNames(status);
nonConstThis->addAllNamesIntoTrie(status);
- nonConstThis->fNamesTrieFullyLoaded = TRUE;
- if (U_FAILURE(status)) { return NULL; }
+ nonConstThis->fNamesTrieFullyLoaded = true;
+ if (U_FAILURE(status)) { return nullptr; }
// Third try: we must return this one.
return doFind(handler, text, start, status);
@@ -1397,16 +1398,16 @@ TimeZoneNamesImpl::doFind(ZNameSearchHandler& handler,
const UnicodeString& text, int32_t start, UErrorCode& status) const {
fNamesTrie.search(text, start, (TextTrieMapSearchResultHandler *)&handler, status);
- if (U_FAILURE(status)) { return NULL; }
+ if (U_FAILURE(status)) { return nullptr; }
int32_t maxLen = 0;
TimeZoneNames::MatchInfoCollection* matches = handler.getMatches(maxLen);
- if (matches != NULL && ((maxLen == (text.length() - start)) || fNamesTrieFullyLoaded)) {
+ if (matches != nullptr && ((maxLen == (text.length() - start)) || fNamesTrieFullyLoaded)) {
// perfect match, or no more names available
return matches;
}
delete matches;
- return NULL;
+ return nullptr;
}
// Caller must synchronize.
@@ -1416,18 +1417,18 @@ void TimeZoneNamesImpl::addAllNamesIntoTrie(UErrorCode& status) {
const UHashElement* element;
pos = UHASH_FIRST;
- while ((element = uhash_nextElement(fMZNamesMap, &pos)) != NULL) {
+ while ((element = uhash_nextElement(fMZNamesMap, &pos)) != nullptr) {
if (element->value.pointer == EMPTY) { continue; }
- UChar* mzID = (UChar*) element->key.pointer;
+ char16_t* mzID = (char16_t*) element->key.pointer;
ZNames* znames = (ZNames*) element->value.pointer;
znames->addAsMetaZoneIntoTrie(mzID, fNamesTrie, status);
if (U_FAILURE(status)) { return; }
}
pos = UHASH_FIRST;
- while ((element = uhash_nextElement(fTZNamesMap, &pos)) != NULL) {
+ while ((element = uhash_nextElement(fTZNamesMap, &pos)) != nullptr) {
if (element->value.pointer == EMPTY) { continue; }
- UChar* tzID = (UChar*) element->key.pointer;
+ char16_t* tzID = (char16_t*) element->key.pointer;
ZNames* znames = (ZNames*) element->value.pointer;
znames->addAsTimeZoneIntoTrie(tzID, fNamesTrie, status);
if (U_FAILURE(status)) { return; }
@@ -1449,7 +1450,7 @@ struct TimeZoneNamesImpl::ZoneStringsLoader : public ResourceSink {
ZoneStringsLoader(TimeZoneNamesImpl& _tzn, UErrorCode& status)
: tzn(_tzn) {
- keyToLoader = uhash_open(uhash_hashChars, uhash_compareChars, NULL, &status);
+ keyToLoader = uhash_open(uhash_hashChars, uhash_compareChars, nullptr, &status);
if (U_FAILURE(status)) { return; }
uhash_setKeyDeleter(keyToLoader, uprv_free);
uhash_setValueDeleter(keyToLoader, deleteZNamesLoader);
@@ -1459,9 +1460,9 @@ struct TimeZoneNamesImpl::ZoneStringsLoader : public ResourceSink {
void* createKey(const char* key, UErrorCode& status) {
int32_t len = sizeof(char) * (static_cast<int32_t>(uprv_strlen(key)) + 1);
char* newKey = (char*) uprv_malloc(len);
- if (newKey == NULL) {
+ if (newKey == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
uprv_memcpy(newKey, key, len);
newKey[len-1] = '\0';
@@ -1493,7 +1494,7 @@ struct TimeZoneNamesImpl::ZoneStringsLoader : public ResourceSink {
int32_t pos = UHASH_FIRST;
const UHashElement* element;
- while ((element = uhash_nextElement(keyToLoader, &pos)) != NULL) {
+ while ((element = uhash_nextElement(keyToLoader, &pos)) != nullptr) {
if (element->value.pointer == DUMMY_LOADER) { continue; }
ZNames::ZNamesLoader* loader = (ZNames::ZNamesLoader*) element->value.pointer;
char* key = (char*) element->key.pointer;
@@ -1514,16 +1515,16 @@ struct TimeZoneNamesImpl::ZoneStringsLoader : public ResourceSink {
if (U_FAILURE(status)) { return; }
void* loader = uhash_get(keyToLoader, key);
- if (loader == NULL) {
+ if (loader == nullptr) {
if (isMetaZone(key)) {
UnicodeString mzID = mzIDFromKey(key);
void* cacheVal = uhash_get(tzn.fMZNamesMap, mzID.getTerminatedBuffer());
- if (cacheVal != NULL) {
+ if (cacheVal != nullptr) {
// We have already loaded the names for this meta zone.
loader = (void*) DUMMY_LOADER;
} else {
loader = (void*) new ZNames::ZNamesLoader();
- if (loader == NULL) {
+ if (loader == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -1531,12 +1532,12 @@ struct TimeZoneNamesImpl::ZoneStringsLoader : public ResourceSink {
} else {
UnicodeString tzID = tzIDFromKey(key);
void* cacheVal = uhash_get(tzn.fTZNamesMap, tzID.getTerminatedBuffer());
- if (cacheVal != NULL) {
+ if (cacheVal != nullptr) {
// We have already loaded the names for this time zone.
loader = (void*) DUMMY_LOADER;
} else {
loader = (void*) new ZNames::ZNamesLoader();
- if (loader == NULL) {
+ if (loader == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -1596,8 +1597,8 @@ void TimeZoneNamesImpl::getDisplayNames(const UnicodeString& tzID,
if (U_FAILURE(status)) return;
if (tzID.isEmpty()) { return; }
- void* tznames = NULL;
- void* mznames = NULL;
+ void* tznames = nullptr;
+ void* mznames = nullptr;
TimeZoneNamesImpl *nonConstThis = const_cast<TimeZoneNamesImpl*>(this);
// Load the time zone strings
@@ -1606,14 +1607,14 @@ void TimeZoneNamesImpl::getDisplayNames(const UnicodeString& tzID,
tznames = (void*) nonConstThis->loadTimeZoneNames(tzID, status);
if (U_FAILURE(status)) { return; }
}
- U_ASSERT(tznames != NULL);
+ U_ASSERT(tznames != nullptr);
// Load the values into the dest array
for (int i = 0; i < numTypes; i++) {
UTimeZoneNameType type = types[i];
- const UChar* name = ((ZNames*)tznames)->getName(type);
- if (name == NULL) {
- if (mznames == NULL) {
+ const char16_t* name = ((ZNames*)tznames)->getName(type);
+ if (name == nullptr) {
+ if (mznames == nullptr) {
// Load the meta zone name
UnicodeString mzID;
getMetaZoneID(tzID, date, mzID);
@@ -1626,19 +1627,19 @@ void TimeZoneNamesImpl::getDisplayNames(const UnicodeString& tzID,
mznames = (void*) nonConstThis->loadMetaZoneNames(mzID, status);
if (U_FAILURE(status)) { return; }
// Note: when the metazone doesn't exist, in Java, loadMetaZoneNames returns
- // a dummy object instead of NULL.
- if (mznames == NULL) {
+ // a dummy object instead of nullptr.
+ if (mznames == nullptr) {
mznames = (void*) EMPTY;
}
}
}
- U_ASSERT(mznames != NULL);
+ U_ASSERT(mznames != nullptr);
if (mznames != EMPTY) {
name = ((ZNames*)mznames)->getName(type);
}
}
- if (name != NULL) {
- dest[i].setTo(TRUE, name, -1);
+ if (name != nullptr) {
+ dest[i].setTo(true, name, -1);
} else {
dest[i].setToBogus();
}
@@ -1648,7 +1649,7 @@ void TimeZoneNamesImpl::getDisplayNames(const UnicodeString& tzID,
// Caller must synchronize.
void TimeZoneNamesImpl::internalLoadAllDisplayNames(UErrorCode& status) {
if (!fNamesFullyLoaded) {
- fNamesFullyLoaded = TRUE;
+ fNamesFullyLoaded = true;
ZoneStringsLoader loader(*this, status);
loader.load(status);
@@ -1658,21 +1659,21 @@ void TimeZoneNamesImpl::internalLoadAllDisplayNames(UErrorCode& status) {
// load strings for all zones
StringEnumeration *tzIDs = TimeZone::createTimeZoneIDEnumeration(
- UCAL_ZONE_TYPE_CANONICAL, NULL, NULL, status);
+ UCAL_ZONE_TYPE_CANONICAL, nullptr, nullptr, status);
if (U_SUCCESS(status)) {
- while ((id = tzIDs->snext(status)) != NULL) {
+ while ((id = tzIDs->snext(status)) != nullptr) {
if (U_FAILURE(status)) {
break;
}
UnicodeString copy(*id);
void* value = uhash_get(fTZNamesMap, copy.getTerminatedBuffer());
- if (value == NULL) {
+ if (value == nullptr) {
// loadStrings also loads related metazone strings
loadStrings(*id, status);
}
}
}
- if (tzIDs != NULL) {
+ if (tzIDs != nullptr) {
delete tzIDs;
}
}
@@ -1680,11 +1681,11 @@ void TimeZoneNamesImpl::internalLoadAllDisplayNames(UErrorCode& status) {
-static const UChar gEtcPrefix[] = { 0x45, 0x74, 0x63, 0x2F }; // "Etc/"
+static const char16_t gEtcPrefix[] = { 0x45, 0x74, 0x63, 0x2F }; // "Etc/"
static const int32_t gEtcPrefixLen = 4;
-static const UChar gSystemVPrefix[] = { 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x56, 0x2F }; // "SystemV/
+static const char16_t gSystemVPrefix[] = { 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x56, 0x2F }; // "SystemV/
static const int32_t gSystemVPrefixLen = 8;
-static const UChar gRiyadh8[] = { 0x52, 0x69, 0x79, 0x61, 0x64, 0x68, 0x38 }; // "Riyadh8"
+static const char16_t gRiyadh8[] = { 0x52, 0x69, 0x79, 0x61, 0x64, 0x68, 0x38 }; // "Riyadh8"
static const int32_t gRiyadh8Len = 7;
UnicodeString& U_EXPORT2
@@ -1695,11 +1696,11 @@ TimeZoneNamesImpl::getDefaultExemplarLocationName(const UnicodeString& tzID, Uni
return name;
}
- int32_t sep = tzID.lastIndexOf((UChar)0x2F /* '/' */);
+ int32_t sep = tzID.lastIndexOf((char16_t)0x2F /* '/' */);
if (sep > 0 && sep + 1 < tzID.length()) {
name.setTo(tzID, sep + 1);
- name.findAndReplace(UnicodeString((UChar)0x5f /* _ */),
- UnicodeString((UChar)0x20 /* space */));
+ name.findAndReplace(UnicodeString((char16_t)0x5f /* _ */),
+ UnicodeString((char16_t)0x20 /* space */));
} else {
name.setToBogus();
}
@@ -1718,29 +1719,29 @@ public:
virtual ~TZDBNames();
static TZDBNames* createInstance(UResourceBundle* rb, const char* key);
- const UChar* getName(UTimeZoneNameType type) const;
+ const char16_t* getName(UTimeZoneNameType type) const;
const char** getParseRegions(int32_t& numRegions) const;
protected:
- TZDBNames(const UChar** names, char** regions, int32_t numRegions);
+ TZDBNames(const char16_t** names, char** regions, int32_t numRegions);
private:
- const UChar** fNames;
+ const char16_t** fNames;
char** fRegions;
int32_t fNumRegions;
};
-TZDBNames::TZDBNames(const UChar** names, char** regions, int32_t numRegions)
+TZDBNames::TZDBNames(const char16_t** names, char** regions, int32_t numRegions)
: fNames(names),
fRegions(regions),
fNumRegions(numRegions) {
}
TZDBNames::~TZDBNames() {
- if (fNames != NULL) {
+ if (fNames != nullptr) {
uprv_free(fNames);
}
- if (fRegions != NULL) {
+ if (fRegions != nullptr) {
char **p = fRegions;
for (int32_t i = 0; i < fNumRegions; p++, i++) {
uprv_free(*p);
@@ -1751,69 +1752,69 @@ TZDBNames::~TZDBNames() {
TZDBNames*
TZDBNames::createInstance(UResourceBundle* rb, const char* key) {
- if (rb == NULL || key == NULL || *key == 0) {
- return NULL;
+ if (rb == nullptr || key == nullptr || *key == 0) {
+ return nullptr;
}
UErrorCode status = U_ZERO_ERROR;
- const UChar **names = NULL;
- char** regions = NULL;
+ const char16_t **names = nullptr;
+ char** regions = nullptr;
int32_t numRegions = 0;
int32_t len = 0;
- UResourceBundle* rbTable = NULL;
+ UResourceBundle* rbTable = nullptr;
rbTable = ures_getByKey(rb, key, rbTable, &status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
- names = (const UChar **)uprv_malloc(sizeof(const UChar*) * TZDBNAMES_KEYS_SIZE);
- UBool isEmpty = TRUE;
- if (names != NULL) {
+ names = (const char16_t **)uprv_malloc(sizeof(const char16_t*) * TZDBNAMES_KEYS_SIZE);
+ UBool isEmpty = true;
+ if (names != nullptr) {
for (int32_t i = 0; i < TZDBNAMES_KEYS_SIZE; i++) {
status = U_ZERO_ERROR;
- const UChar *value = ures_getStringByKey(rbTable, TZDBNAMES_KEYS[i], &len, &status);
+ const char16_t *value = ures_getStringByKey(rbTable, TZDBNAMES_KEYS[i], &len, &status);
if (U_FAILURE(status) || len == 0) {
- names[i] = NULL;
+ names[i] = nullptr;
} else {
names[i] = value;
- isEmpty = FALSE;
+ isEmpty = false;
}
}
}
if (isEmpty) {
- if (names != NULL) {
+ if (names != nullptr) {
uprv_free(names);
}
- return NULL;
+ return nullptr;
}
- UResourceBundle *regionsRes = ures_getByKey(rbTable, "parseRegions", NULL, &status);
- UBool regionError = FALSE;
+ UResourceBundle *regionsRes = ures_getByKey(rbTable, "parseRegions", nullptr, &status);
+ UBool regionError = false;
if (U_SUCCESS(status)) {
numRegions = ures_getSize(regionsRes);
if (numRegions > 0) {
regions = (char**)uprv_malloc(sizeof(char*) * numRegions);
- if (regions != NULL) {
+ if (regions != nullptr) {
char **pRegion = regions;
for (int32_t i = 0; i < numRegions; i++, pRegion++) {
- *pRegion = NULL;
+ *pRegion = nullptr;
}
// filling regions
pRegion = regions;
for (int32_t i = 0; i < numRegions; i++, pRegion++) {
status = U_ZERO_ERROR;
- const UChar *uregion = ures_getStringByIndex(regionsRes, i, &len, &status);
+ const char16_t *uregion = ures_getStringByIndex(regionsRes, i, &len, &status);
if (U_FAILURE(status)) {
- regionError = TRUE;
+ regionError = true;
break;
}
*pRegion = (char*)uprv_malloc(sizeof(char) * (len + 1));
- if (*pRegion == NULL) {
- regionError = TRUE;
+ if (*pRegion == nullptr) {
+ regionError = true;
break;
}
u_UCharsToChars(uregion, *pRegion, len);
@@ -1826,28 +1827,28 @@ TZDBNames::createInstance(UResourceBundle* rb, const char* key) {
ures_close(rbTable);
if (regionError) {
- if (names != NULL) {
+ if (names != nullptr) {
uprv_free(names);
}
- if (regions != NULL) {
+ if (regions != nullptr) {
char **p = regions;
for (int32_t i = 0; i < numRegions; p++, i++) {
uprv_free(*p);
}
uprv_free(regions);
}
- return NULL;
+ return nullptr;
}
return new TZDBNames(names, regions, numRegions);
}
-const UChar*
+const char16_t*
TZDBNames::getName(UTimeZoneNameType type) const {
- if (fNames == NULL) {
- return NULL;
+ if (fNames == nullptr) {
+ return nullptr;
}
- const UChar *name = NULL;
+ const char16_t *name = nullptr;
switch(type) {
case UTZNM_SHORT_STANDARD:
name = fNames[0];
@@ -1856,14 +1857,14 @@ TZDBNames::getName(UTimeZoneNameType type) const {
name = fNames[1];
break;
default:
- name = NULL;
+ name = nullptr;
}
return name;
}
const char**
TZDBNames::getParseRegions(int32_t& numRegions) const {
- if (fRegions == NULL) {
+ if (fRegions == nullptr) {
numRegions = 0;
} else {
numRegions = fNumRegions;
@@ -1877,7 +1878,7 @@ U_CDECL_BEGIN
* in the trie
*/
typedef struct TZDBNameInfo {
- const UChar* mzID;
+ const char16_t* mzID;
UTimeZoneNameType type;
UBool ambiguousType;
const char** parseRegions;
@@ -1902,11 +1903,11 @@ private:
};
TZDBNameSearchHandler::TZDBNameSearchHandler(uint32_t types, const char* region)
-: fTypes(types), fMaxMatchLen(0), fResults(NULL), fRegion(region) {
+: fTypes(types), fMaxMatchLen(0), fResults(nullptr), fRegion(region) {
}
TZDBNameSearchHandler::~TZDBNameSearchHandler() {
- if (fResults != NULL) {
+ if (fResults != nullptr) {
delete fResults;
}
}
@@ -1914,17 +1915,17 @@ TZDBNameSearchHandler::~TZDBNameSearchHandler() {
UBool
TZDBNameSearchHandler::handleMatch(int32_t matchLength, const CharacterNode *node, UErrorCode &status) {
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
- TZDBNameInfo *match = NULL;
- TZDBNameInfo *defaultRegionMatch = NULL;
+ TZDBNameInfo *match = nullptr;
+ TZDBNameInfo *defaultRegionMatch = nullptr;
if (node->hasValues()) {
int32_t valuesCount = node->countValues();
for (int32_t i = 0; i < valuesCount; i++) {
TZDBNameInfo *ninfo = (TZDBNameInfo *)node->getValue(i);
- if (ninfo == NULL) {
+ if (ninfo == nullptr) {
continue;
}
if ((ninfo->type & fTypes) != 0) {
@@ -1935,14 +1936,14 @@ TZDBNameSearchHandler::handleMatch(int32_t matchLength, const CharacterNode *nod
// multiple results returned for the same time zone type.
// For this reason, this implementation resolve one among same
// zone type with a same name at this level.
- if (ninfo->parseRegions == NULL) {
+ if (ninfo->parseRegions == nullptr) {
// parseRegions == null means this is the default metazone
// mapping for the abbreviation.
- if (defaultRegionMatch == NULL) {
+ if (defaultRegionMatch == nullptr) {
match = defaultRegionMatch = ninfo;
}
} else {
- UBool matchRegion = FALSE;
+ UBool matchRegion = false;
// non-default metazone mapping for an abbreviation
// comes with applicable regions. For example, the default
// metazone mapping for "CST" is America_Central,
@@ -1952,21 +1953,21 @@ TZDBNameSearchHandler::handleMatch(int32_t matchLength, const CharacterNode *nod
const char *region = ninfo->parseRegions[j];
if (uprv_strcmp(fRegion, region) == 0) {
match = ninfo;
- matchRegion = TRUE;
+ matchRegion = true;
break;
}
}
if (matchRegion) {
break;
}
- if (match == NULL) {
+ if (match == nullptr) {
match = ninfo;
}
}
}
}
- if (match != NULL) {
+ if (match != nullptr) {
UTimeZoneNameType ntype = match->type;
// Note: Workaround for duplicated standard/daylight names
// The tz database contains a few zones sharing a
@@ -1987,15 +1988,15 @@ TZDBNameSearchHandler::handleMatch(int32_t matchLength, const CharacterNode *nod
ntype = UTZNM_SHORT_GENERIC;
}
- if (fResults == NULL) {
+ if (fResults == nullptr) {
fResults = new TimeZoneNames::MatchInfoCollection();
- if (fResults == NULL) {
+ if (fResults == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
}
if (U_SUCCESS(status)) {
- U_ASSERT(fResults != NULL);
- U_ASSERT(match->mzID != NULL);
+ U_ASSERT(fResults != nullptr);
+ U_ASSERT(match->mzID != nullptr);
fResults->addMetaZone(ntype, matchLength, UnicodeString(match->mzID, -1), status);
if (U_SUCCESS(status) && matchLength > fMaxMatchLen) {
fMaxMatchLen = matchLength;
@@ -2003,7 +2004,7 @@ TZDBNameSearchHandler::handleMatch(int32_t matchLength, const CharacterNode *nod
}
}
}
- return TRUE;
+ return true;
}
TimeZoneNames::MatchInfoCollection*
@@ -2013,7 +2014,7 @@ TZDBNameSearchHandler::getMatches(int32_t& maxMatchLen) {
maxMatchLen = fMaxMatchLen;
// reset
- fResults = NULL;
+ fResults = nullptr;
fMaxMatchLen = 0;
return results;
}
@@ -2030,9 +2031,9 @@ deleteTZDBNames(void *obj) {
}
static void U_CALLCONV initTZDBNamesMap(UErrorCode &status) {
- gTZDBNamesMap = uhash_open(uhash_hashUChars, uhash_compareUChars, NULL, &status);
+ gTZDBNamesMap = uhash_open(uhash_hashUChars, uhash_compareUChars, nullptr, &status);
if (U_FAILURE(status)) {
- gTZDBNamesMap = NULL;
+ gTZDBNamesMap = nullptr;
return;
}
// no key deleters for tzdb name maps
@@ -2045,7 +2046,7 @@ static void U_CALLCONV initTZDBNamesMap(UErrorCode &status) {
*/
static void U_CALLCONV
deleteTZDBNameInfo(void *obj) {
- if (obj != NULL) {
+ if (obj != nullptr) {
uprv_free(obj);
}
}
@@ -2054,8 +2055,8 @@ static void U_CALLCONV prepareFind(UErrorCode &status) {
if (U_FAILURE(status)) {
return;
}
- gTZDBNamesTrie = new TextTrieMap(TRUE, deleteTZDBNameInfo);
- if (gTZDBNamesTrie == NULL) {
+ gTZDBNamesTrie = new TextTrieMap(true, deleteTZDBNameInfo);
+ if (gTZDBNamesTrie == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -2068,12 +2069,12 @@ static void U_CALLCONV prepareFind(UErrorCode &status) {
if (U_FAILURE(status)) {
break;
}
- if (names == NULL) {
+ if (names == nullptr) {
continue;
}
- const UChar *std = names->getName(UTZNM_SHORT_STANDARD);
- const UChar *dst = names->getName(UTZNM_SHORT_DAYLIGHT);
- if (std == NULL && dst == NULL) {
+ const char16_t *std = names->getName(UTZNM_SHORT_STANDARD);
+ const char16_t *dst = names->getName(UTZNM_SHORT_DAYLIGHT);
+ if (std == nullptr && dst == nullptr) {
continue;
}
int32_t numRegions = 0;
@@ -2084,12 +2085,12 @@ static void U_CALLCONV prepareFind(UErrorCode &status) {
// time. For example, Australia/Sydney observes DST,
// but "EST" is used for both standard and daylight.
// we need to store the information for later processing.
- UBool ambiguousType = (std != NULL && dst != NULL && u_strcmp(std, dst) == 0);
+ UBool ambiguousType = (std != nullptr && dst != nullptr && u_strcmp(std, dst) == 0);
- const UChar *uMzID = ZoneMeta::findMetaZoneID(*mzID);
- if (std != NULL) {
+ const char16_t *uMzID = ZoneMeta::findMetaZoneID(*mzID);
+ if (std != nullptr) {
TZDBNameInfo *stdInf = (TZDBNameInfo *)uprv_malloc(sizeof(TZDBNameInfo));
- if (stdInf == NULL) {
+ if (stdInf == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
}
@@ -2100,9 +2101,9 @@ static void U_CALLCONV prepareFind(UErrorCode &status) {
stdInf->nRegions = numRegions;
gTZDBNamesTrie->put(std, stdInf, status);
}
- if (U_SUCCESS(status) && dst != NULL) {
+ if (U_SUCCESS(status) && dst != nullptr) {
TZDBNameInfo *dstInf = (TZDBNameInfo *)uprv_malloc(sizeof(TZDBNameInfo));
- if (dstInf == NULL) {
+ if (dstInf == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
}
@@ -2119,7 +2120,7 @@ static void U_CALLCONV prepareFind(UErrorCode &status) {
if (U_FAILURE(status)) {
delete gTZDBNamesTrie;
- gTZDBNamesTrie = NULL;
+ gTZDBNamesTrie = nullptr;
return;
}
@@ -2130,7 +2131,7 @@ U_CDECL_END
TZDBTimeZoneNames::TZDBTimeZoneNames(const Locale& locale)
: fLocale(locale) {
- UBool useWorld = TRUE;
+ UBool useWorld = true;
const char* region = fLocale.getCountry();
int32_t regionLen = static_cast<int32_t>(uprv_strlen(region));
if (regionLen == 0) {
@@ -2142,11 +2143,11 @@ TZDBTimeZoneNames::TZDBTimeZoneNames(const Locale& locale)
}
regionLen = uloc_getCountry(loc.data(), fRegion, sizeof(fRegion), &status);
if (U_SUCCESS(status) && regionLen < (int32_t)sizeof(fRegion)) {
- useWorld = FALSE;
+ useWorld = false;
}
} else if (regionLen < (int32_t)sizeof(fRegion)) {
uprv_strcpy(fRegion, region);
- useWorld = FALSE;
+ useWorld = false;
}
if (useWorld) {
uprv_strcpy(fRegion, "001");
@@ -2202,10 +2203,10 @@ TZDBTimeZoneNames::getMetaZoneDisplayName(const UnicodeString& mzID,
UErrorCode status = U_ZERO_ERROR;
const TZDBNames *tzdbNames = TZDBTimeZoneNames::getMetaZoneNames(mzID, status);
if (U_SUCCESS(status)) {
- if (tzdbNames != NULL) {
- const UChar *s = tzdbNames->getName(type);
- if (s != NULL) {
- name.setTo(TRUE, s, -1);
+ if (tzdbNames != nullptr) {
+ const char16_t *s = tzdbNames->getName(type);
+ if (s != nullptr) {
+ name.setTo(true, s, -1);
}
}
}
@@ -2224,13 +2225,13 @@ TZDBTimeZoneNames::MatchInfoCollection*
TZDBTimeZoneNames::find(const UnicodeString& text, int32_t start, uint32_t types, UErrorCode& status) const {
umtx_initOnce(gTZDBNamesTrieInitOnce, &prepareFind, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
TZDBNameSearchHandler handler(types, fRegion);
gTZDBNamesTrie->search(text, start, (TextTrieMapSearchResultHandler *)&handler, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
int32_t maxLen = 0;
return handler.getMatches(maxLen);
@@ -2240,12 +2241,12 @@ const TZDBNames*
TZDBTimeZoneNames::getMetaZoneNames(const UnicodeString& mzID, UErrorCode& status) {
umtx_initOnce(gTZDBNamesMapInitOnce, &initTZDBNamesMap, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
- TZDBNames* tzdbNames = NULL;
+ TZDBNames* tzdbNames = nullptr;
- UChar mzIDKey[ZID_KEY_MAX + 1];
+ char16_t mzIDKey[ZID_KEY_MAX + 1];
mzID.extract(mzIDKey, ZID_KEY_MAX + 1, status);
U_ASSERT(status == U_ZERO_ERROR); // already checked length above
mzIDKey[mzID.length()] = 0;
@@ -2254,7 +2255,7 @@ TZDBTimeZoneNames::getMetaZoneNames(const UnicodeString& mzID, UErrorCode& statu
umtx_lock(&gTZDBNamesMapLock);
{
void *cacheVal = uhash_get(gTZDBNamesMap, mzIDKey);
- if (cacheVal == NULL) {
+ if (cacheVal == nullptr) {
UResourceBundle *zoneStringsRes = ures_openDirect(U_ICUDATA_ZONE, "tzdbNames", &status);
zoneStringsRes = ures_getByKey(zoneStringsRes, gZoneStrings, zoneStringsRes, &status);
if (U_SUCCESS(status)) {
@@ -2262,7 +2263,7 @@ TZDBTimeZoneNames::getMetaZoneNames(const UnicodeString& mzID, UErrorCode& statu
mergeTimeZoneKey(mzID, key);
tzdbNames = TZDBNames::createInstance(zoneStringsRes, key);
- if (tzdbNames == NULL) {
+ if (tzdbNames == nullptr) {
cacheVal = (void *)EMPTY;
} else {
cacheVal = tzdbNames;
@@ -2271,21 +2272,21 @@ TZDBTimeZoneNames::getMetaZoneNames(const UnicodeString& mzID, UErrorCode& statu
// avoid duplications.
// TODO: Is there a more efficient way, like intern() in Java?
void* newKey = (void*) ZoneMeta::findMetaZoneID(mzID);
- if (newKey != NULL) {
+ if (newKey != nullptr) {
uhash_put(gTZDBNamesMap, newKey, cacheVal, &status);
if (U_FAILURE(status)) {
- if (tzdbNames != NULL) {
+ if (tzdbNames != nullptr) {
delete tzdbNames;
- tzdbNames = NULL;
+ tzdbNames = nullptr;
}
}
} else {
// Should never happen with a valid input
- if (tzdbNames != NULL) {
+ if (tzdbNames != nullptr) {
// It's not possible that we get a valid tzdbNames with unknown ID.
// But just in case..
delete tzdbNames;
- tzdbNames = NULL;
+ tzdbNames = nullptr;
}
}
}
diff --git a/contrib/libs/icu/i18n/tznames_impl.h b/contrib/libs/icu/i18n/tznames_impl.h
index d047fa3541..8ca2f84e73 100644
--- a/contrib/libs/icu/i18n/tznames_impl.h
+++ b/contrib/libs/icu/i18n/tznames_impl.h
@@ -33,7 +33,7 @@
U_NAMESPACE_BEGIN
/*
- * ZNStringPool Pool of (UChar *) strings. Provides for sharing of repeated
+ * ZNStringPool Pool of (char16_t *) strings. Provides for sharing of repeated
* zone strings.
*/
struct ZNStringPoolChunk;
@@ -47,17 +47,17 @@ class U_I18N_API ZNStringPool: public UMemory {
*
* Life time of the returned string is that of the pool.
*/
- const UChar *get(const UChar *s, UErrorCode &status);
+ const char16_t *get(const char16_t *s, UErrorCode &status);
/* Get the pooled string that is equal to the supplied string s.
* Copy the string into the pool if it is not already present.
*/
- const UChar *get(const UnicodeString &s, UErrorCode &status);
+ const char16_t *get(const UnicodeString &s, UErrorCode &status);
/* Adopt a string into the pool, without copying it.
* Used for strings from resource bundles, which will persist without copying.
*/
- const UChar *adopt(const UChar *s, UErrorCode &status);
+ const char16_t *adopt(const char16_t *s, UErrorCode &status);
/* Freeze the string pool. Discards the hash table that is used
* for looking up a string. All pointers to pooled strings remain valid.
@@ -86,24 +86,24 @@ struct CharacterNode {
inline const void *getValue(int32_t index) const;
void *fValues; // Union of one single value vs. UVector of values.
- UChar fCharacter; // UTF-16 code unit.
+ char16_t fCharacter; // UTF-16 code unit.
uint16_t fFirstChild; // 0 if no children.
uint16_t fNextSibling; // 0 terminates the list.
UBool fHasValuesVector;
UBool fPadding;
- // No value: fValues == NULL and fHasValuesVector == false
+ // No value: fValues == nullptr and fHasValuesVector == false
// One value: fValues == value and fHasValuesVector == false
// >=2 values: fValues == UVector of values and fHasValuesVector == true
};
inline UBool CharacterNode::hasValues() const {
- return (UBool)(fValues != NULL);
+ return (UBool)(fValues != nullptr);
}
inline int32_t CharacterNode::countValues() const {
return
- fValues == NULL ? 0 :
+ fValues == nullptr ? 0 :
!fHasValuesVector ? 1 :
((const UVector *)fValues)->size();
}
@@ -136,7 +136,7 @@ public:
virtual ~TextTrieMap();
void put(const UnicodeString &key, void *value, ZNStringPool &sp, UErrorCode &status);
- void put(const UChar*, void *value, UErrorCode &status);
+ void put(const char16_t*, void *value, UErrorCode &status);
void search(const UnicodeString &text, int32_t start,
TextTrieMapSearchResultHandler *handler, UErrorCode& status) const;
int32_t isEmpty() const;
@@ -152,8 +152,8 @@ private:
UObjectDeleter *fValueDeleter;
UBool growNodes();
- CharacterNode* addChildNode(CharacterNode *parent, UChar c, UErrorCode &status);
- CharacterNode* getChildNode(CharacterNode *parent, UChar c) const;
+ CharacterNode* addChildNode(CharacterNode *parent, char16_t c, UErrorCode &status);
+ CharacterNode* getChildNode(CharacterNode *parent, char16_t c) const;
void putImpl(const UnicodeString &key, void *value, UErrorCode &status);
void buildTrie(UErrorCode &status);
@@ -249,7 +249,7 @@ public:
TimeZoneNames::MatchInfoCollection* find(const UnicodeString& text, int32_t start, uint32_t types, UErrorCode& status) const override;
- // When TZDBNames for the metazone is not available, this method returns NULL,
+ // When TZDBNames for the metazone is not available, this method returns nullptr,
// but does NOT set U_MISSING_RESOURCE_ERROR to status.
static const TZDBNames* getMetaZoneNames(const UnicodeString& mzId, UErrorCode& status);
diff --git a/contrib/libs/icu/i18n/tzrule.cpp b/contrib/libs/icu/i18n/tzrule.cpp
index a60fffbe02..a3522f1d8b 100644
--- a/contrib/libs/icu/i18n/tzrule.cpp
+++ b/contrib/libs/icu/i18n/tzrule.cpp
@@ -74,12 +74,12 @@ TimeZoneRule::getName(UnicodeString& name) const {
}
int32_t
-TimeZoneRule::getRawOffset(void) const {
+TimeZoneRule::getRawOffset() const {
return fRawOffset;
}
int32_t
-TimeZoneRule::getDSTSavings(void) const {
+TimeZoneRule::getDSTSavings() const {
return fDSTSavings;
}
@@ -135,26 +135,26 @@ InitialTimeZoneRule::operator!=(const TimeZoneRule& that) const {
UBool
InitialTimeZoneRule::isEquivalentTo(const TimeZoneRule& other) const {
if (this == &other) {
- return TRUE;
+ return true;
}
- if (typeid(*this) != typeid(other) || TimeZoneRule::isEquivalentTo(other) == FALSE) {
- return FALSE;
+ if (typeid(*this) != typeid(other) || TimeZoneRule::isEquivalentTo(other) == false) {
+ return false;
}
- return TRUE;
+ return true;
}
UBool
InitialTimeZoneRule::getFirstStart(int32_t /*prevRawOffset*/,
int32_t /*prevDSTSavings*/,
UDate& /*result*/) const {
- return FALSE;
+ return false;
}
UBool
InitialTimeZoneRule::getFinalStart(int32_t /*prevRawOffset*/,
int32_t /*prevDSTSavings*/,
UDate& /*result*/) const {
- return FALSE;
+ return false;
}
UBool
@@ -163,7 +163,7 @@ InitialTimeZoneRule::getNextStart(UDate /*base*/,
int32_t /*prevDSTSavings*/,
UBool /*inclusive*/,
UDate& /*result*/) const {
- return FALSE;
+ return false;
}
UBool
@@ -172,7 +172,7 @@ InitialTimeZoneRule::getPreviousStart(UDate /*base*/,
int32_t /*prevDSTSavings*/,
UBool /*inclusive*/,
UDate& /*result*/) const {
- return FALSE;
+ return false;
}
@@ -210,7 +210,7 @@ AnnualTimeZoneRule::~AnnualTimeZoneRule() {
}
AnnualTimeZoneRule*
-AnnualTimeZoneRule::clone(void) const {
+AnnualTimeZoneRule::clone() const {
return new AnnualTimeZoneRule(*this);
}
@@ -266,14 +266,14 @@ AnnualTimeZoneRule::getStartInYear(int32_t year,
int32_t prevDSTSavings,
UDate &result) const {
if (year < fStartYear || year > fEndYear) {
- return FALSE;
+ return false;
}
double ruleDay;
DateTimeRule::DateRuleType type = fDateTimeRule->getDateRuleType();
if (type == DateTimeRule::DOM) {
ruleDay = Grego::fieldsToDay(year, fDateTimeRule->getRuleMonth(), fDateTimeRule->getRuleDayOfMonth());
} else {
- UBool after = TRUE;
+ UBool after = true;
if (type == DateTimeRule::DOW) {
// Normalize DOW rule into DOW_GEQ_DOM or DOW_LEQ_DOM
int32_t weeks = fDateTimeRule->getRuleWeekInMonth();
@@ -281,7 +281,7 @@ AnnualTimeZoneRule::getStartInYear(int32_t year,
ruleDay = Grego::fieldsToDay(year, fDateTimeRule->getRuleMonth(), 1);
ruleDay += 7 * (weeks - 1);
} else {
- after = FALSE;
+ after = false;
ruleDay = Grego::fieldsToDay(year, fDateTimeRule->getRuleMonth(),
Grego::monthLength(year, fDateTimeRule->getRuleMonth()));
ruleDay += 7 * (weeks + 1);
@@ -290,7 +290,7 @@ AnnualTimeZoneRule::getStartInYear(int32_t year,
int32_t month = fDateTimeRule->getRuleMonth();
int32_t dom = fDateTimeRule->getRuleDayOfMonth();
if (type == DateTimeRule::DOW_LEQ_DOM) {
- after = FALSE;
+ after = false;
// Handle Feb <=29
if (month == UCAL_FEBRUARY && dom == 29 && !Grego::isLeapYear(year)) {
dom--;
@@ -315,16 +315,16 @@ AnnualTimeZoneRule::getStartInYear(int32_t year,
if (fDateTimeRule->getTimeRuleType() == DateTimeRule::WALL_TIME) {
result -= prevDSTSavings;
}
- return TRUE;
+ return true;
}
UBool
AnnualTimeZoneRule::isEquivalentTo(const TimeZoneRule& other) const {
if (this == &other) {
- return TRUE;
+ return true;
}
- if (typeid(*this) != typeid(other) || TimeZoneRule::isEquivalentTo(other) == FALSE) {
- return FALSE;
+ if (typeid(*this) != typeid(other) || TimeZoneRule::isEquivalentTo(other) == false) {
+ return false;
}
AnnualTimeZoneRule* that = (AnnualTimeZoneRule*)&other;
return (*fDateTimeRule == *(that->fDateTimeRule) &&
@@ -344,7 +344,7 @@ AnnualTimeZoneRule::getFinalStart(int32_t prevRawOffset,
int32_t prevDSTSavings,
UDate& result) const {
if (fEndYear == MAX_YEAR) {
- return FALSE;
+ return false;
}
return getStartInYear(fEndYear, prevRawOffset, prevDSTSavings, result);
}
@@ -367,10 +367,10 @@ AnnualTimeZoneRule::getNextStart(UDate base,
return getStartInYear(year + 1, prevRawOffset, prevDSTSavings, result);
} else {
result = tmp;
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
UBool
@@ -391,10 +391,10 @@ AnnualTimeZoneRule::getPreviousStart(UDate base,
return getStartInYear(year - 1, prevRawOffset, prevDSTSavings, result);
} else {
result = tmp;
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeArrayTimeZoneRule)
@@ -406,7 +406,7 @@ TimeArrayTimeZoneRule::TimeArrayTimeZoneRule(const UnicodeString& name,
int32_t numStartTimes,
DateTimeRule::TimeRuleType timeRuleType)
: TimeZoneRule(name, rawOffset, dstSavings), fTimeRuleType(timeRuleType),
- fStartTimes(NULL) {
+ fStartTimes(nullptr) {
UErrorCode status = U_ZERO_ERROR;
initStartTimes(startTimes, numStartTimes, status);
//TODO - status?
@@ -414,7 +414,7 @@ TimeArrayTimeZoneRule::TimeArrayTimeZoneRule(const UnicodeString& name,
TimeArrayTimeZoneRule::TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source)
-: TimeZoneRule(source), fTimeRuleType(source.fTimeRuleType), fStartTimes(NULL) {
+: TimeZoneRule(source), fTimeRuleType(source.fTimeRuleType), fStartTimes(nullptr) {
UErrorCode status = U_ZERO_ERROR;
initStartTimes(source.fStartTimes, source.fNumStartTimes, status);
//TODO - status?
@@ -422,13 +422,13 @@ TimeArrayTimeZoneRule::TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source
TimeArrayTimeZoneRule::~TimeArrayTimeZoneRule() {
- if (fStartTimes != NULL && fStartTimes != fLocalStartTimes) {
+ if (fStartTimes != nullptr && fStartTimes != fLocalStartTimes) {
uprv_free(fStartTimes);
}
}
TimeArrayTimeZoneRule*
-TimeArrayTimeZoneRule::clone(void) const {
+TimeArrayTimeZoneRule::clone() const {
return new TimeArrayTimeZoneRule(*this);
}
@@ -475,42 +475,42 @@ TimeArrayTimeZoneRule::operator!=(const TimeZoneRule& that) const {
}
DateTimeRule::TimeRuleType
-TimeArrayTimeZoneRule::getTimeType(void) const {
+TimeArrayTimeZoneRule::getTimeType() const {
return fTimeRuleType;
}
UBool
TimeArrayTimeZoneRule::getStartTimeAt(int32_t index, UDate& result) const {
if (index >= fNumStartTimes || index < 0) {
- return FALSE;
+ return false;
}
result = fStartTimes[index];
- return TRUE;
+ return true;
}
int32_t
-TimeArrayTimeZoneRule::countStartTimes(void) const {
+TimeArrayTimeZoneRule::countStartTimes() const {
return fNumStartTimes;
}
UBool
TimeArrayTimeZoneRule::isEquivalentTo(const TimeZoneRule& other) const {
if (this == &other) {
- return TRUE;
+ return true;
}
- if (typeid(*this) != typeid(other) || TimeZoneRule::isEquivalentTo(other) == FALSE) {
- return FALSE;
+ if (typeid(*this) != typeid(other) || TimeZoneRule::isEquivalentTo(other) == false) {
+ return false;
}
TimeArrayTimeZoneRule* that = (TimeArrayTimeZoneRule*)&other;
if (fTimeRuleType != that->fTimeRuleType ||
fNumStartTimes != that->fNumStartTimes) {
- return FALSE;
+ return false;
}
// Compare start times
- UBool res = TRUE;
+ UBool res = true;
for (int32_t i = 0; i < fNumStartTimes; i++) {
if (fStartTimes[i] != that->fStartTimes[i]) {
- res = FALSE;
+ res = false;
break;
}
}
@@ -521,22 +521,22 @@ UBool
TimeArrayTimeZoneRule::getFirstStart(int32_t prevRawOffset,
int32_t prevDSTSavings,
UDate& result) const {
- if (fNumStartTimes <= 0 || fStartTimes == NULL) {
- return FALSE;
+ if (fNumStartTimes <= 0 || fStartTimes == nullptr) {
+ return false;
}
result = getUTC(fStartTimes[0], prevRawOffset, prevDSTSavings);
- return TRUE;
+ return true;
}
UBool
TimeArrayTimeZoneRule::getFinalStart(int32_t prevRawOffset,
int32_t prevDSTSavings,
UDate& result) const {
- if (fNumStartTimes <= 0 || fStartTimes == NULL) {
- return FALSE;
+ if (fNumStartTimes <= 0 || fStartTimes == nullptr) {
+ return false;
}
result = getUTC(fStartTimes[fNumStartTimes - 1], prevRawOffset, prevDSTSavings);
- return TRUE;
+ return true;
}
UBool
@@ -554,9 +554,9 @@ TimeArrayTimeZoneRule::getNextStart(UDate base,
result = time;
}
if (i == fNumStartTimes - 1) {
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
UBool
@@ -570,10 +570,10 @@ TimeArrayTimeZoneRule::getPreviousStart(UDate base,
UDate time = getUTC(fStartTimes[i], prevRawOffset, prevDSTSavings);
if (time < base || (inclusive && time == base)) {
result = time;
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
@@ -582,16 +582,16 @@ TimeArrayTimeZoneRule::getPreviousStart(UDate base,
UBool
TimeArrayTimeZoneRule::initStartTimes(const UDate source[], int32_t size, UErrorCode& status) {
// Free old array
- if (fStartTimes != NULL && fStartTimes != fLocalStartTimes) {
+ if (fStartTimes != nullptr && fStartTimes != fLocalStartTimes) {
uprv_free(fStartTimes);
}
// Allocate new one if needed
if (size > TIMEARRAY_STACK_BUFFER_SIZE) {
fStartTimes = (UDate*)uprv_malloc(sizeof(UDate)*size);
- if (fStartTimes == NULL) {
+ if (fStartTimes == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
fNumStartTimes = 0;
- return FALSE;
+ return false;
}
} else {
fStartTimes = (UDate*)fLocalStartTimes;
@@ -599,15 +599,15 @@ TimeArrayTimeZoneRule::initStartTimes(const UDate source[], int32_t size, UError
uprv_memcpy(fStartTimes, source, sizeof(UDate)*size);
fNumStartTimes = size;
// Sort dates
- uprv_sortArray(fStartTimes, fNumStartTimes, (int32_t)sizeof(UDate), compareDates, NULL, TRUE, &status);
+ uprv_sortArray(fStartTimes, fNumStartTimes, (int32_t)sizeof(UDate), compareDates, nullptr, true, &status);
if (U_FAILURE(status)) {
- if (fStartTimes != NULL && fStartTimes != fLocalStartTimes) {
+ if (fStartTimes != nullptr && fStartTimes != fLocalStartTimes) {
uprv_free(fStartTimes);
}
fNumStartTimes = 0;
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
UDate
diff --git a/contrib/libs/icu/i18n/tztrans.cpp b/contrib/libs/icu/i18n/tztrans.cpp
index 900e4be540..dbce342202 100644
--- a/contrib/libs/icu/i18n/tztrans.cpp
+++ b/contrib/libs/icu/i18n/tztrans.cpp
@@ -25,31 +25,31 @@ TimeZoneTransition::TimeZoneTransition(UDate time, const TimeZoneRule& from, con
}
TimeZoneTransition::TimeZoneTransition()
-: UObject(), fTime(0), fFrom(NULL), fTo(NULL) {
+: UObject(), fTime(0), fFrom(nullptr), fTo(nullptr) {
}
TimeZoneTransition::TimeZoneTransition(const TimeZoneTransition& source)
-: UObject(), fTime(source.fTime), fFrom(NULL), fTo(NULL) {
- if (source.fFrom != NULL) {
+: UObject(), fTime(source.fTime), fFrom(nullptr), fTo(nullptr) {
+ if (source.fFrom != nullptr) {
fFrom = source.fFrom->clone();
}
- if (source.fTo != NULL) {
+ if (source.fTo != nullptr) {
fTo = source.fTo->clone();
}
}
TimeZoneTransition::~TimeZoneTransition() {
- if (fFrom != NULL) {
+ if (fFrom != nullptr) {
delete fFrom;
}
- if (fTo != NULL) {
+ if (fTo != nullptr) {
delete fTo;
}
}
TimeZoneTransition*
-TimeZoneTransition::clone(void) const {
+TimeZoneTransition::clone() const {
return new TimeZoneTransition(*this);
}
@@ -74,10 +74,10 @@ TimeZoneTransition::operator==(const TimeZoneTransition& that) const {
if (fTime != that.fTime) {
return false;
}
- if ((fFrom == NULL && that.fFrom == NULL)
- || (fFrom != NULL && that.fFrom != NULL && *fFrom == *(that.fFrom))) {
- if ((fTo == NULL && that.fTo == NULL)
- || (fTo != NULL && that.fTo != NULL && *fTo == *(that.fTo))) {
+ if ((fFrom == nullptr && that.fFrom == nullptr)
+ || (fFrom != nullptr && that.fFrom != nullptr && *fFrom == *(that.fFrom))) {
+ if ((fTo == nullptr && that.fTo == nullptr)
+ || (fTo != nullptr && that.fTo != nullptr && *fTo == *(that.fTo))) {
return true;
}
}
@@ -96,7 +96,7 @@ TimeZoneTransition::setTime(UDate time) {
void
TimeZoneTransition::setFrom(const TimeZoneRule& from) {
- if (fFrom != NULL) {
+ if (fFrom != nullptr) {
delete fFrom;
}
fFrom = from.clone();
@@ -104,7 +104,7 @@ TimeZoneTransition::setFrom(const TimeZoneRule& from) {
void
TimeZoneTransition::adoptFrom(TimeZoneRule* from) {
- if (fFrom != NULL) {
+ if (fFrom != nullptr) {
delete fFrom;
}
fFrom = from;
@@ -112,7 +112,7 @@ TimeZoneTransition::adoptFrom(TimeZoneRule* from) {
void
TimeZoneTransition::setTo(const TimeZoneRule& to) {
- if (fTo != NULL) {
+ if (fTo != nullptr) {
delete fTo;
}
fTo = to.clone();
@@ -120,24 +120,24 @@ TimeZoneTransition::setTo(const TimeZoneRule& to) {
void
TimeZoneTransition::adoptTo(TimeZoneRule* to) {
- if (fTo != NULL) {
+ if (fTo != nullptr) {
delete fTo;
}
fTo = to;
}
UDate
-TimeZoneTransition::getTime(void) const {
+TimeZoneTransition::getTime() const {
return fTime;
}
const TimeZoneRule*
-TimeZoneTransition::getTo(void) const {
+TimeZoneTransition::getTo() const {
return fTo;
}
const TimeZoneRule*
-TimeZoneTransition::getFrom(void) const {
+TimeZoneTransition::getFrom() const {
return fFrom;
}
diff --git a/contrib/libs/icu/i18n/ucal.cpp b/contrib/libs/icu/i18n/ucal.cpp
index 33f72589c5..18d9cf4ec7 100644
--- a/contrib/libs/icu/i18n/ucal.cpp
+++ b/contrib/libs/icu/i18n/ucal.cpp
@@ -32,7 +32,7 @@
U_NAMESPACE_USE
static TimeZone*
-_createTimeZone(const UChar* zoneID, int32_t len, UErrorCode* ec) {
+_createTimeZone(const char16_t* zoneID, int32_t len, UErrorCode* ec) {
TimeZone* zone = nullptr;
if (ec != nullptr && U_SUCCESS(*ec)) {
// Note that if zoneID is invalid, we get back GMT. This odd
@@ -67,7 +67,7 @@ ucal_openCountryTimeZones(const char* country, UErrorCode* ec) {
}
U_CAPI int32_t U_EXPORT2
-ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec) {
+ucal_getDefaultTimeZone(char16_t* result, int32_t resultCapacity, UErrorCode* ec) {
int32_t len = 0;
if (ec != nullptr && U_SUCCESS(*ec)) {
TimeZone* zone = TimeZone::createDefault();
@@ -84,7 +84,7 @@ ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec) {
}
U_CAPI void U_EXPORT2
-ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec) {
+ucal_setDefaultTimeZone(const char16_t* zoneID, UErrorCode* ec) {
TimeZone* zone = _createTimeZone(zoneID, -1, ec);
if (zone != nullptr) {
TimeZone::adoptDefault(zone);
@@ -92,7 +92,7 @@ ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec) {
}
U_CAPI int32_t U_EXPORT2
-ucal_getHostTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec) {
+ucal_getHostTimeZone(char16_t* result, int32_t resultCapacity, UErrorCode* ec) {
int32_t len = 0;
if (ec != nullptr && U_SUCCESS(*ec)) {
TimeZone *zone = TimeZone::detectHostTimeZone();
@@ -109,7 +109,7 @@ ucal_getHostTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec) {
}
U_CAPI int32_t U_EXPORT2
-ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec) {
+ucal_getDSTSavings(const char16_t* zoneID, UErrorCode* ec) {
int32_t result = 0;
TimeZone* zone = _createTimeZone(zoneID, -1, ec);
if (U_SUCCESS(*ec)) {
@@ -124,7 +124,7 @@ ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec) {
UDate d = Calendar::getNow();
for (int32_t i=0; i<53; ++i, d+=U_MILLIS_PER_DAY*7.0) {
int32_t raw, dst;
- zone->getOffset(d, FALSE, raw, dst, *ec);
+ zone->getOffset(d, false, raw, dst, *ec);
if (U_FAILURE(*ec)) {
break;
} else if (dst != 0) {
@@ -148,7 +148,7 @@ ucal_getNow()
#define ULOC_LOCALE_IDENTIFIER_CAPACITY (ULOC_FULLNAME_CAPACITY + 1 + ULOC_KEYWORD_AND_VALUES_CAPACITY)
U_CAPI UCalendar* U_EXPORT2
-ucal_open( const UChar* zoneID,
+ucal_open( const char16_t* zoneID,
int32_t len,
const char* locale,
UCalendarType caltype,
@@ -211,7 +211,7 @@ ucal_clone(const UCalendar* cal,
U_CAPI void U_EXPORT2
ucal_setTimeZone( UCalendar* cal,
- const UChar* zoneID,
+ const char16_t* zoneID,
int32_t len,
UErrorCode *status)
{
@@ -229,7 +229,7 @@ ucal_setTimeZone( UCalendar* cal,
U_CAPI int32_t U_EXPORT2
ucal_getTimeZoneID(const UCalendar *cal,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status)
{
@@ -246,7 +246,7 @@ U_CAPI int32_t U_EXPORT2
ucal_getTimeZoneDisplayName(const UCalendar* cal,
UCalendarDisplayNameType type,
const char *locale,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UErrorCode* status)
{
@@ -263,19 +263,19 @@ ucal_getTimeZoneDisplayName(const UCalendar* cal,
switch(type) {
case UCAL_STANDARD:
- tz.getDisplayName(FALSE, TimeZone::LONG, Locale(locale), id);
+ tz.getDisplayName(false, TimeZone::LONG, Locale(locale), id);
break;
case UCAL_SHORT_STANDARD:
- tz.getDisplayName(FALSE, TimeZone::SHORT, Locale(locale), id);
+ tz.getDisplayName(false, TimeZone::SHORT, Locale(locale), id);
break;
case UCAL_DST:
- tz.getDisplayName(TRUE, TimeZone::LONG, Locale(locale), id);
+ tz.getDisplayName(true, TimeZone::LONG, Locale(locale), id);
break;
case UCAL_SHORT_DST:
- tz.getDisplayName(TRUE, TimeZone::SHORT, Locale(locale), id);
+ tz.getDisplayName(true, TimeZone::SHORT, Locale(locale), id);
break;
}
@@ -338,9 +338,7 @@ ucal_getGregorianChange(const UCalendar *cal, UErrorCode *pErrorCode) {
U_CAPI int32_t U_EXPORT2
ucal_getAttribute( const UCalendar* cal,
- UCalendarAttribute attr)
-{
-
+ UCalendarAttribute attr) UPRV_NO_SANITIZE_UNDEFINED {
switch(attr) {
case UCAL_LENIENT:
return ((Calendar*)cal)->isLenient();
@@ -468,10 +466,12 @@ U_CAPI void U_EXPORT2
ucal_add( UCalendar* cal,
UCalendarDateFields field,
int32_t amount,
- UErrorCode* status)
-{
-
+ UErrorCode* status) UPRV_NO_SANITIZE_UNDEFINED {
if(U_FAILURE(*status)) return;
+ if (field < 0 || UCAL_FIELD_COUNT <= field) {
+ *status = U_ILLEGAL_ARGUMENT_ERROR;
+ return;
+ }
((Calendar*)cal)->add(field, amount, *status);
}
@@ -480,10 +480,12 @@ U_CAPI void U_EXPORT2
ucal_roll( UCalendar* cal,
UCalendarDateFields field,
int32_t amount,
- UErrorCode* status)
-{
-
+ UErrorCode* status) UPRV_NO_SANITIZE_UNDEFINED {
if(U_FAILURE(*status)) return;
+ if (field < 0 || UCAL_FIELD_COUNT <= field) {
+ *status = U_ILLEGAL_ARGUMENT_ERROR;
+ return;
+ }
((Calendar*)cal)->roll(field, amount, *status);
}
@@ -491,10 +493,12 @@ ucal_roll( UCalendar* cal,
U_CAPI int32_t U_EXPORT2
ucal_get( const UCalendar* cal,
UCalendarDateFields field,
- UErrorCode* status )
-{
-
+ UErrorCode* status ) UPRV_NO_SANITIZE_UNDEFINED {
if(U_FAILURE(*status)) return -1;
+ if (field < 0 || UCAL_FIELD_COUNT <= field) {
+ *status = U_ILLEGAL_ARGUMENT_ERROR;
+ return -1;
+ }
return ((Calendar*)cal)->get(field, *status);
}
@@ -502,24 +506,30 @@ ucal_get( const UCalendar* cal,
U_CAPI void U_EXPORT2
ucal_set( UCalendar* cal,
UCalendarDateFields field,
- int32_t value)
-{
+ int32_t value) UPRV_NO_SANITIZE_UNDEFINED {
+ if (field < 0 || UCAL_FIELD_COUNT <= field) {
+ return;
+ }
((Calendar*)cal)->set(field, value);
}
U_CAPI UBool U_EXPORT2
ucal_isSet( const UCalendar* cal,
- UCalendarDateFields field)
-{
+ UCalendarDateFields field) UPRV_NO_SANITIZE_UNDEFINED {
+ if (field < 0 || UCAL_FIELD_COUNT <= field) {
+ return false;
+ }
return ((Calendar*)cal)->isSet(field);
}
U_CAPI void U_EXPORT2
ucal_clearField( UCalendar* cal,
- UCalendarDateFields field)
-{
+ UCalendarDateFields field) UPRV_NO_SANITIZE_UNDEFINED {
+ if (field < 0 || UCAL_FIELD_COUNT <= field) {
+ return;
+ }
((Calendar*)cal)->clear(field);
}
@@ -535,12 +545,14 @@ U_CAPI int32_t U_EXPORT2
ucal_getLimit( const UCalendar* cal,
UCalendarDateFields field,
UCalendarLimitType type,
- UErrorCode *status)
-{
-
+ UErrorCode *status) UPRV_NO_SANITIZE_UNDEFINED {
if(status==0 || U_FAILURE(*status)) {
return -1;
}
+ if (field < 0 || UCAL_FIELD_COUNT <= field) {
+ *status = U_ILLEGAL_ARGUMENT_ERROR;
+ return -1;
+ }
switch(type) {
case UCAL_MINIMUM:
@@ -588,13 +600,13 @@ ucal_getTZDataVersion(UErrorCode* status)
}
U_CAPI int32_t U_EXPORT2
-ucal_getCanonicalTimeZoneID(const UChar* id, int32_t len,
- UChar* result, int32_t resultCapacity, UBool *isSystemID, UErrorCode* status) {
+ucal_getCanonicalTimeZoneID(const char16_t* id, int32_t len,
+ char16_t* result, int32_t resultCapacity, UBool *isSystemID, UErrorCode* status) {
if(status == 0 || U_FAILURE(*status)) {
return 0;
}
if (isSystemID) {
- *isSystemID = FALSE;
+ *isSystemID = false;
}
if (id == 0 || len == 0 || result == 0 || resultCapacity <= 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
@@ -602,7 +614,7 @@ ucal_getCanonicalTimeZoneID(const UChar* id, int32_t len,
}
int32_t reslen = 0;
UnicodeString canonical;
- UBool systemID = FALSE;
+ UBool systemID = false;
TimeZone::getCanonicalID(UnicodeString(id, len), canonical, systemID, *status);
if (U_SUCCESS(*status)) {
if (isSystemID) {
@@ -644,7 +656,7 @@ U_CAPI UBool U_EXPORT2
ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status)
{
if (U_FAILURE(*status)) {
- return FALSE;
+ return false;
}
return ((Calendar*)cal)->isWeekend(date, *status);
}
@@ -697,7 +709,7 @@ U_CAPI UEnumeration* U_EXPORT2
ucal_getKeywordValuesForLocale(const char * /* key */, const char* locale, UBool commonlyUsed, UErrorCode *status) {
// Resolve region
char prefRegion[ULOC_COUNTRY_CAPACITY];
- (void)ulocimp_getRegionForSupplementalData(locale, TRUE, prefRegion, sizeof(prefRegion), status);
+ (void)ulocimp_getRegionForSupplementalData(locale, true, prefRegion, sizeof(prefRegion), status);
// Read preferred calendar values from supplementalData calendarPreference
UResourceBundle *rb = ures_openDirect(nullptr, "supplementalData", status);
@@ -715,7 +727,7 @@ ucal_getKeywordValuesForLocale(const char * /* key */, const char* locale, UBool
if (U_SUCCESS(*status)) {
for (int i = 0; i < ures_getSize(order); i++) {
int32_t len;
- const UChar *type = ures_getStringByIndex(order, i, &len, status);
+ const char16_t *type = ures_getStringByIndex(order, i, &len, status);
char *caltype = (char*)uprv_malloc(len + 1);
if (caltype == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
@@ -724,7 +736,7 @@ ucal_getKeywordValuesForLocale(const char * /* key */, const char* locale, UBool
u_UCharsToChars(type, caltype, len);
*(caltype + len) = 0;
- ulist_addItemEndList(values, caltype, TRUE, status);
+ ulist_addItemEndList(values, caltype, true, status);
if (U_FAILURE(*status)) {
break;
}
@@ -734,7 +746,7 @@ ucal_getKeywordValuesForLocale(const char * /* key */, const char* locale, UBool
// If not commonlyUsed, add other available values
for (int32_t i = 0; CAL_TYPES[i] != nullptr; i++) {
if (!ulist_containsString(values, CAL_TYPES[i], (int32_t)uprv_strlen(CAL_TYPES[i]))) {
- ulist_addItemEndList(values, CAL_TYPES[i], FALSE, status);
+ ulist_addItemEndList(values, CAL_TYPES[i], false, status);
if (U_FAILURE(*status)) {
break;
}
@@ -773,7 +785,7 @@ ucal_getTimeZoneTransitionDate(const UCalendar* cal, UTimeZoneTransitionType typ
UDate* transition, UErrorCode* status)
{
if (U_FAILURE(*status)) {
- return FALSE;
+ return false;
}
UDate base = ((Calendar*)cal)->getTime(*status);
const TimeZone& tz = ((Calendar*)cal)->getTimeZone();
@@ -786,14 +798,14 @@ ucal_getTimeZoneTransitionDate(const UCalendar* cal, UTimeZoneTransitionType typ
btz->getPreviousTransition(base, inclusive, tzt);
if (result) {
*transition = tzt.getTime();
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
U_CAPI int32_t U_EXPORT2
-ucal_getWindowsTimeZoneID(const UChar* id, int32_t len, UChar* winid, int32_t winidCapacity, UErrorCode* status) {
+ucal_getWindowsTimeZoneID(const char16_t* id, int32_t len, char16_t* winid, int32_t winidCapacity, UErrorCode* status) {
if (U_FAILURE(*status)) {
return 0;
}
@@ -811,7 +823,7 @@ ucal_getWindowsTimeZoneID(const UChar* id, int32_t len, UChar* winid, int32_t wi
}
U_CAPI int32_t U_EXPORT2
-ucal_getTimeZoneIDForWindowsID(const UChar* winid, int32_t len, const char* region, UChar* id, int32_t idCapacity, UErrorCode* status) {
+ucal_getTimeZoneIDForWindowsID(const char16_t* winid, int32_t len, const char* region, char16_t* id, int32_t idCapacity, UErrorCode* status) {
if (U_FAILURE(*status)) {
return 0;
}
diff --git a/contrib/libs/icu/i18n/ucln_in.cpp b/contrib/libs/icu/i18n/ucln_in.cpp
index f29cbe41dd..a67487bcc6 100644
--- a/contrib/libs/icu/i18n/ucln_in.cpp
+++ b/contrib/libs/icu/i18n/ucln_in.cpp
@@ -30,7 +30,7 @@ static const char copyright[] = U_COPYRIGHT_STRING;
static cleanupFunc *gCleanupFunctions[UCLN_I18N_COUNT];
-static UBool U_CALLCONV i18n_cleanup(void)
+static UBool U_CALLCONV i18n_cleanup()
{
int32_t libType = UCLN_I18N_START;
(void)copyright; /* Suppress unused variable warning with clang. */
@@ -39,13 +39,13 @@ static UBool U_CALLCONV i18n_cleanup(void)
if (gCleanupFunctions[libType])
{
gCleanupFunctions[libType]();
- gCleanupFunctions[libType] = NULL;
+ gCleanupFunctions[libType] = nullptr;
}
}
#if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL))
ucln_unRegisterAutomaticCleanup();
#endif
- return TRUE;
+ return true;
}
void ucln_i18n_registerCleanup(ECleanupI18NType type,
diff --git a/contrib/libs/icu/i18n/ucol.cpp b/contrib/libs/icu/i18n/ucol.cpp
index f59333ede3..7c9fb00bf3 100644
--- a/contrib/libs/icu/i18n/ucol.cpp
+++ b/contrib/libs/icu/i18n/ucol.cpp
@@ -43,18 +43,18 @@ ucol_openBinary(const uint8_t *bin, int32_t length,
const UCollator *base,
UErrorCode *status)
{
- if(U_FAILURE(*status)) { return NULL; }
+ if(U_FAILURE(*status)) { return nullptr; }
RuleBasedCollator *coll = new RuleBasedCollator(
bin, length,
RuleBasedCollator::rbcFromUCollator(base),
*status);
- if(coll == NULL) {
+ if(coll == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
if(U_FAILURE(*status)) {
delete coll;
- return NULL;
+ return nullptr;
}
return coll->toUCollator();
}
@@ -68,7 +68,7 @@ ucol_cloneBinary(const UCollator *coll,
return 0;
}
const RuleBasedCollator *rbc = RuleBasedCollator::rbcFromUCollator(coll);
- if(rbc == NULL && coll != NULL) {
+ if(rbc == nullptr && coll != nullptr) {
*status = U_UNSUPPORTED_ERROR;
return 0;
}
@@ -78,36 +78,42 @@ ucol_cloneBinary(const UCollator *coll,
U_CAPI UCollator* U_EXPORT2
ucol_safeClone(const UCollator *coll, void * /*stackBuffer*/, int32_t * pBufferSize, UErrorCode *status)
{
- if (status == NULL || U_FAILURE(*status)){
- return NULL;
+ if (status == nullptr || U_FAILURE(*status)){
+ return nullptr;
}
- if (coll == NULL) {
+ if (coll == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
- if (pBufferSize != NULL) {
+ if (pBufferSize != nullptr) {
int32_t inputSize = *pBufferSize;
*pBufferSize = 1;
if (inputSize == 0) {
- return NULL; // preflighting for deprecated functionality
+ return nullptr; // preflighting for deprecated functionality
}
}
Collator *newColl = Collator::fromUCollator(coll)->clone();
- if (newColl == NULL) {
+ if (newColl == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
return nullptr;
- } else {
+ } else if (pBufferSize != nullptr) {
*status = U_SAFECLONE_ALLOCATED_WARNING;
}
return newColl->toUCollator();
}
+U_CAPI UCollator* U_EXPORT2
+ucol_clone(const UCollator *coll, UErrorCode *status)
+{
+ return ucol_safeClone(coll, nullptr, nullptr, status);
+}
+
U_CAPI void U_EXPORT2
ucol_close(UCollator *coll)
{
UTRACE_ENTRY_OC(UTRACE_UCOL_CLOSE);
UTRACE_DATA1(UTRACE_INFO, "coll = %p", coll);
- if(coll != NULL) {
+ if(coll != nullptr) {
delete Collator::fromUCollator(coll);
}
UTRACE_EXIT();
@@ -118,12 +124,12 @@ ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length,
const uint8_t *src2, int32_t src2Length,
uint8_t *dest, int32_t destCapacity) {
/* check arguments */
- if( src1==NULL || src1Length<-1 || src1Length==0 || (src1Length>0 && src1[src1Length-1]!=0) ||
- src2==NULL || src2Length<-1 || src2Length==0 || (src2Length>0 && src2[src2Length-1]!=0) ||
- destCapacity<0 || (destCapacity>0 && dest==NULL)
+ if( src1==nullptr || src1Length<-1 || src1Length==0 || (src1Length>0 && src1[src1Length-1]!=0) ||
+ src2==nullptr || src2Length<-1 || src2Length==0 || (src2Length>0 && src2[src2Length-1]!=0) ||
+ destCapacity<0 || (destCapacity>0 && dest==nullptr)
) {
/* error, attempt to write a zero byte and return 0 */
- if(dest!=NULL && destCapacity>0) {
+ if(dest!=nullptr && destCapacity>0) {
*dest=0;
}
return 0;
@@ -190,7 +196,7 @@ ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length,
U_CAPI int32_t U_EXPORT2
ucol_getSortKey(const UCollator *coll,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
uint8_t *result,
int32_t resultLength)
@@ -198,7 +204,7 @@ ucol_getSortKey(const UCollator *coll,
UTRACE_ENTRY(UTRACE_UCOL_GET_SORTKEY);
if (UTRACE_LEVEL(UTRACE_VERBOSE)) {
UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, source string = %vh ", coll, source,
- ((sourceLength==-1 && source!=NULL) ? u_strlen(source) : sourceLength));
+ ((sourceLength==-1 && source!=nullptr) ? u_strlen(source) : sourceLength));
}
int32_t keySize = Collator::fromUCollator(coll)->
@@ -217,7 +223,7 @@ ucol_nextSortKeyPart(const UCollator *coll,
UErrorCode *status)
{
/* error checking */
- if(status==NULL || U_FAILURE(*status)) {
+ if(status==nullptr || U_FAILURE(*status)) {
return 0;
}
UTRACE_ENTRY(UTRACE_UCOL_NEXTSORTKEYPART);
@@ -247,10 +253,10 @@ ucol_getBound(const uint8_t *source,
UErrorCode *status)
{
// consistency checks
- if(status == NULL || U_FAILURE(*status)) {
+ if(status == nullptr || U_FAILURE(*status)) {
return 0;
}
- if(source == NULL) {
+ if(source == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -275,7 +281,7 @@ ucol_getBound(const uint8_t *source,
// enum will not changes. They are set so that the enum value
// corresponds to the number of extra bytes each bound type
// needs.
- if(result != NULL && resultLength >= sourceIndex+boundType) {
+ if(result != nullptr && resultLength >= sourceIndex+boundType) {
uprv_memcpy(result, source, sourceIndex);
switch(boundType) {
// Lower bound just gets terminated. No extra bytes
@@ -314,15 +320,15 @@ ucol_getMaxVariable(const UCollator *coll) {
}
U_CAPI uint32_t U_EXPORT2
-ucol_setVariableTop(UCollator *coll, const UChar *varTop, int32_t len, UErrorCode *status) {
- if(U_FAILURE(*status) || coll == NULL) {
+ucol_setVariableTop(UCollator *coll, const char16_t *varTop, int32_t len, UErrorCode *status) {
+ if(U_FAILURE(*status) || coll == nullptr) {
return 0;
}
return Collator::fromUCollator(coll)->setVariableTop(varTop, len, *status);
}
U_CAPI uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode *status) {
- if(U_FAILURE(*status) || coll == NULL) {
+ if(U_FAILURE(*status) || coll == nullptr) {
return 0;
}
return Collator::fromUCollator(coll)->getVariableTop(*status);
@@ -330,7 +336,7 @@ U_CAPI uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode
U_CAPI void U_EXPORT2
ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *status) {
- if(U_FAILURE(*status) || coll == NULL) {
+ if(U_FAILURE(*status) || coll == nullptr) {
return;
}
Collator::fromUCollator(coll)->setVariableTop(varTop, *status);
@@ -338,7 +344,7 @@ ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *stat
U_CAPI void U_EXPORT2
ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status) {
- if(U_FAILURE(*status) || coll == NULL) {
+ if(U_FAILURE(*status) || coll == nullptr) {
return;
}
@@ -347,7 +353,7 @@ ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value,
U_CAPI UColAttributeValue U_EXPORT2
ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status) {
- if(U_FAILURE(*status) || coll == NULL) {
+ if(U_FAILURE(*status) || coll == nullptr) {
return UCOL_DEFAULT;
}
@@ -421,7 +427,7 @@ ucol_strcollIter( const UCollator *coll,
UTRACE_ENTRY(UTRACE_UCOL_STRCOLLITER);
UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, sIter=%p, tIter=%p", coll, sIter, tIter);
- if(sIter == NULL || tIter == NULL || coll == NULL) {
+ if(sIter == nullptr || tIter == nullptr || coll == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
UTRACE_EXIT_VALUE_STATUS(UCOL_EQUAL, *status);
return UCOL_EQUAL;
@@ -439,9 +445,9 @@ ucol_strcollIter( const UCollator *coll,
/* */
U_CAPI UCollationResult U_EXPORT2
ucol_strcoll( const UCollator *coll,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
- const UChar *target,
+ const char16_t *target,
int32_t targetLength)
{
UTRACE_ENTRY(UTRACE_UCOL_STRCOLL);
@@ -490,9 +496,9 @@ ucol_strcollUTF8(
/* convenience function for comparing strings */
U_CAPI UBool U_EXPORT2
ucol_greater( const UCollator *coll,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
- const UChar *target,
+ const char16_t *target,
int32_t targetLength)
{
return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
@@ -502,9 +508,9 @@ ucol_greater( const UCollator *coll,
/* convenience function for comparing strings */
U_CAPI UBool U_EXPORT2
ucol_greaterOrEqual( const UCollator *coll,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
- const UChar *target,
+ const char16_t *target,
int32_t targetLength)
{
return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
@@ -514,9 +520,9 @@ ucol_greaterOrEqual( const UCollator *coll,
/* convenience function for comparing strings */
U_CAPI UBool U_EXPORT2
ucol_equal( const UCollator *coll,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
- const UChar *target,
+ const char16_t *target,
int32_t targetLength)
{
return (ucol_strcoll(coll, source, sourceLength, target, targetLength)
@@ -526,7 +532,7 @@ ucol_equal( const UCollator *coll,
U_CAPI void U_EXPORT2
ucol_getUCAVersion(const UCollator* coll, UVersionInfo info) {
const Collator *c = Collator::fromUCollator(coll);
- if(c != NULL) {
+ if(c != nullptr) {
UVersionInfo v;
c->getVersion(v);
// Note: This is tied to how the current implementation encodes the UCA version
@@ -542,29 +548,29 @@ ucol_getUCAVersion(const UCollator* coll, UVersionInfo info) {
}
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
ucol_getRules(const UCollator *coll, int32_t *length) {
const RuleBasedCollator *rbc = RuleBasedCollator::rbcFromUCollator(coll);
- // OK to crash if coll==NULL: We do not want to check "this" pointers.
- if(rbc != NULL || coll == NULL) {
+ // OK to crash if coll==nullptr: We do not want to check "this" pointers.
+ if(rbc != nullptr || coll == nullptr) {
const UnicodeString &rules = rbc->getRules();
U_ASSERT(rules.getBuffer()[rules.length()] == 0);
*length = rules.length();
return rules.getBuffer();
}
- static const UChar _NUL = 0;
+ static const char16_t _NUL = 0;
*length = 0;
return &_NUL;
}
U_CAPI int32_t U_EXPORT2
-ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen) {
+ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, char16_t *buffer, int32_t bufferLen) {
UnicodeString rules;
const RuleBasedCollator *rbc = RuleBasedCollator::rbcFromUCollator(coll);
- if(rbc != NULL || coll == NULL) {
+ if(rbc != nullptr || coll == nullptr) {
rbc->getRules(delta, rules);
}
- if(buffer != NULL && bufferLen > 0) {
+ if(buffer != nullptr && bufferLen > 0) {
UErrorCode errorCode = U_ZERO_ERROR;
return rules.extract(buffer, bufferLen, errorCode);
} else {
@@ -580,16 +586,16 @@ ucol_getLocale(const UCollator *coll, ULocDataLocaleType type, UErrorCode *statu
U_CAPI const char * U_EXPORT2
ucol_getLocaleByType(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status) {
if(U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
UTRACE_ENTRY(UTRACE_UCOL_GETLOCALE);
UTRACE_DATA1(UTRACE_INFO, "coll=%p", coll);
const char *result;
const RuleBasedCollator *rbc = RuleBasedCollator::rbcFromUCollator(coll);
- if(rbc == NULL && coll != NULL) {
+ if(rbc == nullptr && coll != nullptr) {
*status = U_UNSUPPORTED_ERROR;
- result = NULL;
+ result = nullptr;
} else {
result = rbc->internalGetLocaleID(type, *status);
}
@@ -602,12 +608,12 @@ ucol_getLocaleByType(const UCollator *coll, ULocDataLocaleType type, UErrorCode
U_CAPI USet * U_EXPORT2
ucol_getTailoredSet(const UCollator *coll, UErrorCode *status) {
if(U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
UnicodeSet *set = Collator::fromUCollator(coll)->getTailoredSet(*status);
if(U_FAILURE(*status)) {
delete set;
- return NULL;
+ return nullptr;
}
return set->toUSet();
}
diff --git a/contrib/libs/icu/i18n/ucol_res.cpp b/contrib/libs/icu/i18n/ucol_res.cpp
index b277cf3b28..9bf28db264 100644
--- a/contrib/libs/icu/i18n/ucol_res.cpp
+++ b/contrib/libs/icu/i18n/ucol_res.cpp
@@ -59,10 +59,10 @@ U_NAMESPACE_BEGIN
namespace {
-static const UChar *rootRules = NULL;
+static const char16_t *rootRules = nullptr;
static int32_t rootRulesLength = 0;
-static UResourceBundle *rootBundle = NULL;
-static UInitOnce gInitOnceUcolRes = U_INITONCE_INITIALIZER;
+static UResourceBundle *rootBundle = nullptr;
+static UInitOnce gInitOnceUcolRes {};
} // namespace
@@ -70,12 +70,12 @@ U_CDECL_BEGIN
static UBool U_CALLCONV
ucol_res_cleanup() {
- rootRules = NULL;
+ rootRules = nullptr;
rootRulesLength = 0;
ures_close(rootBundle);
- rootBundle = NULL;
+ rootBundle = nullptr;
gInitOnceUcolRes.reset();
- return TRUE;
+ return true;
}
void U_CALLCONV
@@ -86,7 +86,7 @@ CollationLoader::loadRootRules(UErrorCode &errorCode) {
rootRules = ures_getStringByKey(rootBundle, "UCARules", &rootRulesLength, &errorCode);
if(U_FAILURE(errorCode)) {
ures_close(rootBundle);
- rootBundle = NULL;
+ rootBundle = nullptr;
return;
}
ucln_i18n_registerCleanup(UCLN_I18N_UCOL_RES, ucol_res_cleanup);
@@ -107,7 +107,7 @@ void
CollationLoader::loadRules(const char *localeID, const char *collationType,
UnicodeString &rules, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
- U_ASSERT(collationType != NULL && *collationType != 0);
+ U_ASSERT(collationType != nullptr && *collationType != 0);
// Copy the type for lowercasing.
char type[16];
int32_t typeLength = static_cast<int32_t>(uprv_strlen(collationType));
@@ -120,11 +120,11 @@ CollationLoader::loadRules(const char *localeID, const char *collationType,
LocalUResourceBundlePointer bundle(ures_open(U_ICUDATA_COLL, localeID, &errorCode));
LocalUResourceBundlePointer collations(
- ures_getByKey(bundle.getAlias(), "collations", NULL, &errorCode));
+ ures_getByKey(bundle.getAlias(), "collations", nullptr, &errorCode));
LocalUResourceBundlePointer data(
- ures_getByKeyWithFallback(collations.getAlias(), type, NULL, &errorCode));
+ ures_getByKeyWithFallback(collations.getAlias(), type, nullptr, &errorCode));
int32_t length;
- const UChar *s = ures_getStringByKey(data.getAlias(), "Sequence", &length, &errorCode);
+ const char16_t *s = ures_getStringByKey(data.getAlias(), "Sequence", &length, &errorCode);
if(U_FAILURE(errorCode)) { return; }
// No string pointer aliasing so that we need not hold onto the resource bundle.
@@ -147,7 +147,7 @@ LocaleCacheKey<CollationCacheEntry>::createObject(const void *creationContext,
const CollationCacheEntry *
CollationLoader::loadTailoring(const Locale &locale, UErrorCode &errorCode) {
const CollationCacheEntry *rootEntry = CollationRoot::getRootCacheEntry(errorCode);
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
const char *name = locale.getName();
if(*name == 0 || uprv_strcmp(name, "root") == 0) {
@@ -168,8 +168,8 @@ CollationLoader::CollationLoader(const CollationCacheEntry *re, const Locale &re
UErrorCode &errorCode)
: cache(UnifiedCache::getInstance(errorCode)), rootEntry(re),
validLocale(re->validLocale), locale(requested),
- typesTried(0), typeFallback(FALSE),
- bundle(NULL), collations(NULL), data(NULL) {
+ typesTried(0), typeFallback(false),
+ bundle(nullptr), collations(nullptr), data(nullptr) {
type[0] = 0;
defaultType[0] = 0;
if(U_FAILURE(errorCode)) { return; }
@@ -213,11 +213,11 @@ CollationLoader::createCacheEntry(UErrorCode &errorCode) {
// In a cache miss, cache.get() calls CacheKey::createObject(),
// which means that we progress via recursion.
// loadFromCollations() will recurse to itself as well for collation type fallback.
- if(bundle == NULL) {
+ if(bundle == nullptr) {
return loadFromLocale(errorCode);
- } else if(collations == NULL) {
+ } else if(collations == nullptr) {
return loadFromBundle(errorCode);
- } else if(data == NULL) {
+ } else if(data == nullptr) {
return loadFromCollations(errorCode);
} else {
return loadFromData(errorCode);
@@ -226,8 +226,8 @@ CollationLoader::createCacheEntry(UErrorCode &errorCode) {
const CollationCacheEntry *
CollationLoader::loadFromLocale(UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return NULL; }
- U_ASSERT(bundle == NULL);
+ if(U_FAILURE(errorCode)) { return nullptr; }
+ U_ASSERT(bundle == nullptr);
bundle = ures_openNoDefault(U_ICUDATA_COLL, locale.getBaseName(), &errorCode);
if(errorCode == U_MISSING_RESOURCE_ERROR) {
errorCode = U_USING_DEFAULT_WARNING;
@@ -238,7 +238,7 @@ CollationLoader::loadFromLocale(UErrorCode &errorCode) {
}
Locale requestedLocale(locale);
const char *vLocale = ures_getLocaleByType(bundle, ULOC_ACTUAL_LOCALE, &errorCode);
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
locale = validLocale = Locale(vLocale); // no type until loadFromCollations()
if(type[0] != 0) {
locale.setKeywordValue("collation", type, errorCode);
@@ -252,24 +252,24 @@ CollationLoader::loadFromLocale(UErrorCode &errorCode) {
const CollationCacheEntry *
CollationLoader::loadFromBundle(UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return NULL; }
- U_ASSERT(collations == NULL);
+ if(U_FAILURE(errorCode)) { return nullptr; }
+ U_ASSERT(collations == nullptr);
// There are zero or more tailorings in the collations table.
- collations = ures_getByKey(bundle, "collations", NULL, &errorCode);
+ collations = ures_getByKey(bundle, "collations", nullptr, &errorCode);
if(errorCode == U_MISSING_RESOURCE_ERROR) {
errorCode = U_USING_DEFAULT_WARNING;
// Return the root tailoring with the validLocale, without collation type.
return makeCacheEntryFromRoot(validLocale, errorCode);
}
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
// Fetch the default type from the data.
{
UErrorCode internalErrorCode = U_ZERO_ERROR;
LocalUResourceBundlePointer def(
- ures_getByKeyWithFallback(collations, "default", NULL, &internalErrorCode));
+ ures_getByKeyWithFallback(collations, "default", nullptr, &internalErrorCode));
int32_t length;
- const UChar *s = ures_getString(def.getAlias(), &length, &internalErrorCode);
+ const char16_t *s = ures_getString(def.getAlias(), &length, &internalErrorCode);
if(U_SUCCESS(internalErrorCode) && 0 < length && length < UPRV_LENGTHOF(defaultType)) {
u_UCharsToChars(s, defaultType, length + 1);
} else {
@@ -313,15 +313,15 @@ CollationLoader::loadFromBundle(UErrorCode &errorCode) {
const CollationCacheEntry *
CollationLoader::loadFromCollations(UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return NULL; }
- U_ASSERT(data == NULL);
+ if(U_FAILURE(errorCode)) { return nullptr; }
+ U_ASSERT(data == nullptr);
// Load the collations/type tailoring, with type fallback.
LocalUResourceBundlePointer localData(
- ures_getByKeyWithFallback(collations, type, NULL, &errorCode));
+ ures_getByKeyWithFallback(collations, type, nullptr, &errorCode));
int32_t typeLength = static_cast<int32_t>(uprv_strlen(type));
if(errorCode == U_MISSING_RESOURCE_ERROR) {
errorCode = U_USING_DEFAULT_WARNING;
- typeFallback = TRUE;
+ typeFallback = true;
if((typesTried & TRIED_SEARCH) == 0 &&
typeLength > 6 && uprv_strncmp(type, "search", 6) == 0) {
// fall back from something like "searchjl" to "search"
@@ -342,11 +342,11 @@ CollationLoader::loadFromCollations(UErrorCode &errorCode) {
locale.setKeywordValue("collation", type, errorCode);
return getCacheEntry(errorCode);
}
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
data = localData.orphan();
const char *actualLocale = ures_getLocaleByType(data, ULOC_ACTUAL_LOCALE, &errorCode);
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
const char *vLocale = validLocale.getBaseName();
UBool actualAndValidLocalesAreDifferent = Locale(actualLocale) != Locale(vLocale);
@@ -355,7 +355,7 @@ CollationLoader::loadFromCollations(UErrorCode &errorCode) {
// For the valid locale, suppress the default type.
if(uprv_strcmp(type, defaultType) != 0) {
validLocale.setKeywordValue("collation", type, errorCode);
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
}
// Is this the same as the root collator? If so, then use that instead.
@@ -379,32 +379,32 @@ CollationLoader::loadFromCollations(UErrorCode &errorCode) {
const CollationCacheEntry *
CollationLoader::loadFromData(UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
LocalPointer<CollationTailoring> t(new CollationTailoring(rootEntry->tailoring->settings));
if(t.isNull() || t->isBogus()) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
// deserialize
- LocalUResourceBundlePointer binary(ures_getByKey(data, "%%CollationBin", NULL, &errorCode));
+ LocalUResourceBundlePointer binary(ures_getByKey(data, "%%CollationBin", nullptr, &errorCode));
// Note: U_MISSING_RESOURCE_ERROR --> The old code built from rules if available
// but that created undesirable dependencies.
- int32_t length;
+ int32_t length = 0;
const uint8_t *inBytes = ures_getBinary(binary.getAlias(), &length, &errorCode);
CollationDataReader::read(rootEntry->tailoring, inBytes, length, *t, errorCode);
// Note: U_COLLATOR_VERSION_MISMATCH --> The old code built from rules if available
// but that created undesirable dependencies.
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
// Try to fetch the optional rules string.
{
UErrorCode internalErrorCode = U_ZERO_ERROR;
int32_t len;
- const UChar *s = ures_getStringByKey(data, "Sequence", &len,
+ const char16_t *s = ures_getStringByKey(data, "Sequence", &len,
&internalErrorCode);
if(U_SUCCESS(internalErrorCode)) {
- t->rules.setTo(TRUE, s, len);
+ t->rules.setTo(true, s, len);
}
}
@@ -421,13 +421,13 @@ CollationLoader::loadFromData(UErrorCode &errorCode) {
// Opening a bundle for the actual locale should always succeed.
LocalUResourceBundlePointer actualBundle(
ures_open(U_ICUDATA_COLL, actualLocale, &errorCode));
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
UErrorCode internalErrorCode = U_ZERO_ERROR;
LocalUResourceBundlePointer def(
- ures_getByKeyWithFallback(actualBundle.getAlias(), "collations/default", NULL,
+ ures_getByKeyWithFallback(actualBundle.getAlias(), "collations/default", nullptr,
&internalErrorCode));
int32_t len;
- const UChar *s = ures_getString(def.getAlias(), &len, &internalErrorCode);
+ const char16_t *s = ures_getString(def.getAlias(), &len, &internalErrorCode);
if(U_SUCCESS(internalErrorCode) && len < UPRV_LENGTHOF(defaultType)) {
u_UCharsToChars(s, defaultType, len + 1);
} else {
@@ -439,17 +439,17 @@ CollationLoader::loadFromData(UErrorCode &errorCode) {
t->actualLocale.setKeywordValue("collation", type, errorCode);
} else if(uprv_strcmp(locale.getName(), locale.getBaseName()) != 0) {
// Remove the collation keyword if it was set.
- t->actualLocale.setKeywordValue("collation", NULL, errorCode);
+ t->actualLocale.setKeywordValue("collation", nullptr, errorCode);
}
- if(U_FAILURE(errorCode)) { return NULL; }
+ if(U_FAILURE(errorCode)) { return nullptr; }
if(typeFallback) {
errorCode = U_USING_DEFAULT_WARNING;
}
t->bundle = bundle;
- bundle = NULL;
+ bundle = nullptr;
const CollationCacheEntry *entry = new CollationCacheEntry(validLocale, t.getAlias());
- if(entry == NULL) {
+ if(entry == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return nullptr;
} else {
@@ -463,7 +463,7 @@ CollationLoader::loadFromData(UErrorCode &errorCode) {
const CollationCacheEntry *
CollationLoader::getCacheEntry(UErrorCode &errorCode) {
LocaleCacheKey<CollationCacheEntry> key(locale);
- const CollationCacheEntry *entry = NULL;
+ const CollationCacheEntry *entry = nullptr;
cache->get(key, this, entry, errorCode);
return entry;
}
@@ -473,7 +473,7 @@ CollationLoader::makeCacheEntryFromRoot(
const Locale &/*loc*/,
UErrorCode &errorCode) const {
if (U_FAILURE(errorCode)) {
- return NULL;
+ return nullptr;
}
rootEntry->addRef();
return makeCacheEntry(validLocale, rootEntry, errorCode);
@@ -488,10 +488,10 @@ CollationLoader::makeCacheEntry(
return entryFromCache;
}
CollationCacheEntry *entry = new CollationCacheEntry(loc, entryFromCache->tailoring);
- if(entry == NULL) {
+ if(entry == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
entryFromCache->removeRef();
- return NULL;
+ return nullptr;
}
entry->addRef();
entryFromCache->removeRef();
@@ -508,7 +508,7 @@ ucol_open(const char *loc,
{
UTRACE_ENTRY_OC(UTRACE_UCOL_OPEN);
UTRACE_DATA1(UTRACE_INFO, "locale = \"%s\"", loc);
- UCollator *result = NULL;
+ UCollator *result = nullptr;
Collator *coll = Collator::createInstance(loc, *status);
if(U_SUCCESS(*status)) {
@@ -522,14 +522,14 @@ ucol_open(const char *loc,
U_CAPI int32_t U_EXPORT2
ucol_getDisplayName( const char *objLoc,
const char *dispLoc,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status)
{
if(U_FAILURE(*status)) return -1;
UnicodeString dst;
- if(!(result==NULL && resultLength==0)) {
- // NULL destination for pure preflighting: empty dummy string
+ if(!(result==nullptr && resultLength==0)) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
dst.setTo(result, 0, resultLength);
}
@@ -542,10 +542,10 @@ ucol_getAvailable(int32_t index)
{
int32_t count = 0;
const Locale *loc = Collator::getAvailableLocales(count);
- if (loc != NULL && index < count) {
+ if (loc != nullptr && index < count) {
return loc[index].getName();
}
- return NULL;
+ return nullptr;
}
U_CAPI int32_t U_EXPORT2
@@ -561,12 +561,12 @@ U_CAPI UEnumeration* U_EXPORT2
ucol_openAvailableLocales(UErrorCode *status) {
// This is a wrapper over Collator::getAvailableLocales()
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
StringEnumeration *s = icu::Collator::getAvailableLocales();
- if (s == NULL) {
+ if (s == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
return uenum_openFromStringEnumeration(s, status);
}
@@ -582,7 +582,7 @@ static const char* const KEYWORDS[] = { "collation" };
U_CAPI UEnumeration* U_EXPORT2
ucol_getKeywords(UErrorCode *status) {
- UEnumeration *result = NULL;
+ UEnumeration *result = nullptr;
if (U_SUCCESS(*status)) {
return uenum_openCharStringsEnumeration(KEYWORDS, KEYWORD_COUNT, status);
}
@@ -592,21 +592,21 @@ ucol_getKeywords(UErrorCode *status) {
U_CAPI UEnumeration* U_EXPORT2
ucol_getKeywordValues(const char *keyword, UErrorCode *status) {
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
// hard-coded to accept exactly one collation keyword
// modify if additional collation keyword is added later
- if (keyword==NULL || uprv_strcmp(keyword, KEYWORDS[0])!=0)
+ if (keyword==nullptr || uprv_strcmp(keyword, KEYWORDS[0])!=0)
{
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
return ures_getKeywordValues(U_ICUDATA_COLL, RESOURCE_NAME, status);
}
static const UEnumeration defaultKeywordValues = {
- NULL,
- NULL,
+ nullptr,
+ nullptr,
ulist_close_keyword_values_iterator,
ulist_count_keyword_values,
uenum_unextDefault,
@@ -619,7 +619,7 @@ namespace {
struct KeywordsSink : public ResourceSink {
public:
KeywordsSink(UErrorCode &errorCode) :
- values(ulist_createEmptyList(&errorCode)), hasDefault(FALSE) {}
+ values(ulist_createEmptyList(&errorCode)), hasDefault(false) {}
virtual ~KeywordsSink();
virtual void put(const char *key, ResourceValue &value, UBool /*noFallback*/,
@@ -634,18 +634,18 @@ public:
defcoll.appendInvariantChars(value.getUnicodeString(errorCode), errorCode);
if (U_SUCCESS(errorCode) && !defcoll.isEmpty()) {
char *ownedDefault = uprv_strdup(defcoll.data());
- if (ownedDefault == NULL) {
+ if (ownedDefault == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
ulist_removeString(values, defcoll.data());
- ulist_addItemBeginList(values, ownedDefault, TRUE, &errorCode);
- hasDefault = TRUE;
+ ulist_addItemBeginList(values, ownedDefault, true, &errorCode);
+ hasDefault = true;
}
}
} else if (type == URES_TABLE && uprv_strncmp(key, "private-", 8) != 0) {
if (!ulist_containsString(values, key, (int32_t)uprv_strlen(key))) {
- ulist_addItemEndList(values, key, FALSE, &errorCode);
+ ulist_addItemEndList(values, key, false, &errorCode);
}
}
if (U_FAILURE(errorCode)) { return; }
@@ -673,17 +673,17 @@ ucol_getKeywordValuesForLocale(const char* /*key*/, const char* locale,
LocalUResourceBundlePointer bundle(ures_open(U_ICUDATA_COLL, locale, status));
KeywordsSink sink(*status);
ures_getAllItemsWithFallback(bundle.getAlias(), RESOURCE_NAME, sink, *status);
- if (U_FAILURE(*status)) { return NULL; }
+ if (U_FAILURE(*status)) { return nullptr; }
UEnumeration *en = (UEnumeration *)uprv_malloc(sizeof(UEnumeration));
- if (en == NULL) {
+ if (en == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
memcpy(en, &defaultKeywordValues, sizeof(UEnumeration));
ulist_resetList(sink.values); // Initialize the iterator.
en->context = sink.values;
- sink.values = NULL; // Avoid deletion in the sink destructor.
+ sink.values = nullptr; // Avoid deletion in the sink destructor.
return en;
}
@@ -695,7 +695,7 @@ ucol_getFunctionalEquivalent(char* result, int32_t resultCapacity,
// N.B.: Resource name is "collations" but keyword is "collation"
return ures_getFunctionalEquivalent(result, resultCapacity, U_ICUDATA_COLL,
"collations", keyword, locale,
- isAvailable, TRUE, status);
+ isAvailable, true, status);
}
#endif /* #if !UCONFIG_NO_COLLATION */
diff --git a/contrib/libs/icu/i18n/ucol_sit.cpp b/contrib/libs/icu/i18n/ucol_sit.cpp
index 4dc81aebcc..a740286d79 100644
--- a/contrib/libs/icu/i18n/ucol_sit.cpp
+++ b/contrib/libs/icu/i18n/ucol_sit.cpp
@@ -99,7 +99,7 @@ struct CollatorSpec {
CharString locale;
UColAttributeValue options[UCOL_ATTRIBUTE_COUNT];
uint32_t variableTopValue;
- UChar variableTopString[locElementCapacity];
+ char16_t variableTopString[locElementCapacity];
int32_t variableTopStringLen;
UBool variableTopSet;
CharString entries[UCOL_SIT_ITEMS_COUNT];
@@ -109,7 +109,7 @@ CollatorSpec::CollatorSpec() :
locale(),
variableTopValue(0),
variableTopString(),
-variableTopSet(FALSE)
+variableTopSet(false)
{
// set collation options to default
for(int32_t i = 0; i < UCOL_ATTRIBUTE_COUNT; i++) {
@@ -189,7 +189,7 @@ _processRFC3066Locale(CollatorSpec *spec, uint32_t, const char* string,
char terminator = *string;
string++;
const char *end = uprv_strchr(string+1, terminator);
- if(end == NULL || end - string >= loc3066Capacity) {
+ if(end == nullptr || end - string >= loc3066Capacity) {
*status = U_BUFFER_OVERFLOW_ERROR;
return string;
} else {
@@ -217,10 +217,10 @@ _processCollatorOption(CollatorSpec *spec, uint32_t option, const char* string,
U_CDECL_END
-static UChar
+static char16_t
readHexCodeUnit(const char **string, UErrorCode *status)
{
- UChar result = 0;
+ char16_t result = 0;
int32_t value = 0;
char c;
int32_t noDigits = 0;
@@ -238,7 +238,7 @@ readHexCodeUnit(const char **string, UErrorCode *status)
#endif
return 0;
}
- result = (result << 4) | (UChar)value;
+ result = (result << 4) | (char16_t)value;
noDigits++;
(*string)++;
}
@@ -270,7 +270,7 @@ _processVariableTop(CollatorSpec *spec, uint32_t value1, const char* string, UEr
spec->variableTopValue = readHexCodeUnit(&string, status);
}
if(U_SUCCESS(*status)) {
- spec->variableTopSet = TRUE;
+ spec->variableTopSet = true;
}
return string;
}
@@ -456,8 +456,8 @@ ucol_prepareShortStringOpen( const char *definition,
UResourceBundle *b = ures_open(U_ICUDATA_COLL, buffer, status);
/* we try to find stuff from keyword */
- UResourceBundle *collations = ures_getByKey(b, "collations", NULL, status);
- UResourceBundle *collElem = NULL;
+ UResourceBundle *collations = ures_getByKey(b, "collations", nullptr, status);
+ UResourceBundle *collElem = nullptr;
char keyBuffer[256];
// if there is a keyword, we pick it up and try to get elements
int32_t keyLen = uloc_getKeywordValue(buffer, "collation", keyBuffer, sizeof(keyBuffer), status);
@@ -469,10 +469,10 @@ ucol_prepareShortStringOpen( const char *definition,
if(keyLen == 0) {
// no keyword
// we try to find the default setting, which will give us the keyword value
- UResourceBundle *defaultColl = ures_getByKeyWithFallback(collations, "default", NULL, status);
+ UResourceBundle *defaultColl = ures_getByKeyWithFallback(collations, "default", nullptr, status);
if(U_SUCCESS(*status)) {
int32_t defaultKeyLen = 0;
- const UChar *defaultKey = ures_getString(defaultColl, &defaultKeyLen, status);
+ const char16_t *defaultKey = ures_getString(defaultColl, &defaultKeyLen, status);
u_UCharsToChars(defaultKey, keyBuffer, defaultKeyLen);
keyBuffer[defaultKeyLen] = 0;
} else {
@@ -539,7 +539,7 @@ ucol_openFromShortString( const char *definition,
if(U_FAILURE(*status)) {
parseError->offset = (int32_t)(string - definition);
ucol_close(result);
- return NULL;
+ return nullptr;
}
}
@@ -555,7 +555,7 @@ ucol_openFromShortString( const char *definition,
if(U_FAILURE(*status)) { // here it can only be a bogus value
ucol_close(result);
- result = NULL;
+ result = nullptr;
}
UTRACE_EXIT_PTR_STATUS(result, *status);
@@ -571,7 +571,7 @@ ucol_getShortDefinitionString(const UCollator *coll,
UErrorCode *status)
{
if(U_FAILURE(*status)) return 0;
- if(coll == NULL) {
+ if(coll == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -618,7 +618,7 @@ ucol_getContractions( const UCollator *coll,
USet *contractions,
UErrorCode *status)
{
- ucol_getContractionsAndExpansions(coll, contractions, NULL, FALSE, status);
+ ucol_getContractionsAndExpansions(coll, contractions, nullptr, false, status);
return uset_getItemCount(contractions);
}
@@ -642,12 +642,12 @@ ucol_getContractionsAndExpansions( const UCollator *coll,
if(U_FAILURE(*status)) {
return;
}
- if(coll == NULL) {
+ if(coll == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
const icu::RuleBasedCollator *rbc = icu::RuleBasedCollator::rbcFromUCollator(coll);
- if(rbc == NULL) {
+ if(rbc == nullptr) {
*status = U_UNSUPPORTED_ERROR;
return;
}
diff --git a/contrib/libs/icu/i18n/ucoleitr.cpp b/contrib/libs/icu/i18n/ucoleitr.cpp
index 596ce03295..36b83c4c10 100644
--- a/contrib/libs/icu/i18n/ucoleitr.cpp
+++ b/contrib/libs/icu/i18n/ucoleitr.cpp
@@ -92,7 +92,7 @@ void RCEBuffer::put(uint32_t ce, int32_t ixLow, int32_t ixHigh, UErrorCode &erro
}
if (bufferIndex >= bufferSize) {
RCEI *newBuffer = NEW_ARRAY(RCEI, bufferSize + BUFFER_GROW);
- if (newBuffer == NULL) {
+ if (newBuffer == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -120,7 +120,7 @@ const RCEI *RCEBuffer::get()
return &buffer[--bufferIndex];
}
- return NULL;
+ return nullptr;
}
PCEBuffer::PCEBuffer()
@@ -154,7 +154,7 @@ void PCEBuffer::put(uint64_t ce, int32_t ixLow, int32_t ixHigh, UErrorCode &erro
}
if (bufferIndex >= bufferSize) {
PCEI *newBuffer = NEW_ARRAY(PCEI, bufferSize + BUFFER_GROW);
- if (newBuffer == NULL) {
+ if (newBuffer == nullptr) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -182,7 +182,7 @@ const PCEI *PCEBuffer::get()
return &buffer[--bufferIndex];
}
- return NULL;
+ return nullptr;
}
UCollationPCE::UCollationPCE(UCollationElements *elems) { init(elems); }
@@ -205,7 +205,7 @@ void UCollationPCE::init(const Collator &coll)
strength = coll.getAttribute(UCOL_STRENGTH, status);
toShift = coll.getAttribute(UCOL_ALTERNATE_HANDLING, status) == UCOL_SHIFTED;
- isShifted = FALSE;
+ isShifted = false;
variableTop = coll.getVariableTop(status);
}
@@ -254,13 +254,13 @@ uint64_t UCollationPCE::processCE(uint32_t ce)
}
primary = secondary = tertiary = 0;
- isShifted = TRUE;
+ isShifted = true;
} else {
if (strength >= UCOL_QUATERNARY) {
quaternary = 0xFFFF;
}
- isShifted = FALSE;
+ isShifted = false;
}
return primary << 48 | secondary << 32 | tertiary << 16 | quaternary;
@@ -272,28 +272,28 @@ U_NAMESPACE_END
U_CAPI UCollationElements* U_EXPORT2
ucol_openElements(const UCollator *coll,
- const UChar *text,
+ const char16_t *text,
int32_t textLength,
UErrorCode *status)
{
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
- if (coll == NULL || (text == NULL && textLength != 0)) {
+ if (coll == nullptr || (text == nullptr && textLength != 0)) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
const RuleBasedCollator *rbc = RuleBasedCollator::rbcFromUCollator(coll);
- if (rbc == NULL) {
+ if (rbc == nullptr) {
*status = U_UNSUPPORTED_ERROR; // coll is a Collator but not a RuleBasedCollator
- return NULL;
+ return nullptr;
}
UnicodeString s((UBool)(textLength < 0), text, textLength);
CollationElementIterator *cei = rbc->createCollationElementIterator(s);
- if (cei == NULL) {
+ if (cei == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
return cei->toUCollationElements();
@@ -353,11 +353,11 @@ UCollationPCE::nextProcessed(
result = processCE((uint32_t)ce);
} while (result == UCOL_IGNORABLE);
- if (ixLow != NULL) {
+ if (ixLow != nullptr) {
*ixLow = low;
}
- if (ixHigh != NULL) {
+ if (ixHigh != nullptr) {
*ixHigh = high;
}
@@ -433,11 +433,11 @@ UCollationPCE::previousProcessed(
finish:
if (pceBuffer.isEmpty()) {
// **** Is -1 the right value for ixLow, ixHigh? ****
- if (ixLow != NULL) {
+ if (ixLow != nullptr) {
*ixLow = -1;
}
- if (ixHigh != NULL) {
+ if (ixHigh != nullptr) {
*ixHigh = -1
;
}
@@ -446,11 +446,11 @@ finish:
const PCEI *pcei = pceBuffer.get();
- if (ixLow != NULL) {
+ if (ixLow != nullptr) {
*ixLow = pcei->low;
}
- if (ixHigh != NULL) {
+ if (ixHigh != nullptr) {
*ixHigh = pcei->high;
}
@@ -476,7 +476,7 @@ ucol_getMaxExpansion(const UCollationElements *elems,
U_CAPI void U_EXPORT2
ucol_setText( UCollationElements *elems,
- const UChar *text,
+ const char16_t *text,
int32_t textLength,
UErrorCode *status)
{
@@ -484,7 +484,7 @@ ucol_setText( UCollationElements *elems,
return;
}
- if ((text == NULL && textLength != 0)) {
+ if ((text == nullptr && textLength != 0)) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
diff --git a/contrib/libs/icu/i18n/ucsdet.cpp b/contrib/libs/icu/i18n/ucsdet.cpp
index 63f204d0e1..c8b8712fba 100644
--- a/contrib/libs/icu/i18n/ucsdet.cpp
+++ b/contrib/libs/icu/i18n/ucsdet.cpp
@@ -39,7 +39,7 @@ ucsdet_open(UErrorCode *status)
if (U_FAILURE(*status)) {
delete csd;
- csd = NULL;
+ csd = nullptr;
}
return (UCharsetDetector *) csd;
@@ -66,7 +66,7 @@ U_CAPI const char * U_EXPORT2
ucsdet_getName(const UCharsetMatch *ucsm, UErrorCode *status)
{
if(U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
return ((CharsetMatch *) ucsm)->getName();
@@ -86,7 +86,7 @@ U_CAPI const char * U_EXPORT2
ucsdet_getLanguage(const UCharsetMatch *ucsm, UErrorCode *status)
{
if(U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
return ((CharsetMatch *) ucsm)->getLanguage();
@@ -96,7 +96,7 @@ U_CAPI const UCharsetMatch * U_EXPORT2
ucsdet_detect(UCharsetDetector *ucsd, UErrorCode *status)
{
if(U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
return (const UCharsetMatch *) ((CharsetDetector *) ucsd)->detect(*status);
@@ -117,7 +117,7 @@ ucsdet_detectAll(UCharsetDetector *ucsd,
int32_t *maxMatchesFound, UErrorCode *status)
{
if(U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
CharsetDetector *csd = (CharsetDetector *) ucsd;
@@ -147,8 +147,8 @@ U_CAPI UBool U_EXPORT2
ucsdet_isInputFilterEnabled(const UCharsetDetector *ucsd)
{
// todo: could use an error return...
- if (ucsd == NULL) {
- return FALSE;
+ if (ucsd == nullptr) {
+ return false;
}
return ((CharsetDetector *) ucsd)->getStripTagsFlag();
@@ -158,8 +158,8 @@ U_CAPI UBool U_EXPORT2
ucsdet_enableInputFilter(UCharsetDetector *ucsd, UBool filter)
{
// todo: could use an error return...
- if (ucsd == NULL) {
- return FALSE;
+ if (ucsd == nullptr) {
+ return false;
}
CharsetDetector *csd = (CharsetDetector *) ucsd;
@@ -172,7 +172,7 @@ ucsdet_enableInputFilter(UCharsetDetector *ucsd, UBool filter)
U_CAPI int32_t U_EXPORT2
ucsdet_getUChars(const UCharsetMatch *ucsm,
- UChar *buf, int32_t cap, UErrorCode *status)
+ char16_t *buf, int32_t cap, UErrorCode *status)
{
if(U_FAILURE(*status)) {
return 0;
diff --git a/contrib/libs/icu/i18n/udat.cpp b/contrib/libs/icu/i18n/udat.cpp
index d9549d04c5..e249be3aee 100644
--- a/contrib/libs/icu/i18n/udat.cpp
+++ b/contrib/libs/icu/i18n/udat.cpp
@@ -34,11 +34,11 @@ U_NAMESPACE_USE
/**
* Verify that fmt is a SimpleDateFormat. Invalid error if not.
* @param fmt the UDateFormat, definitely a DateFormat, maybe something else
- * @param status error code, will be set to failure if there is a failure or the fmt is NULL.
+ * @param status error code, will be set to failure if there is a failure or the fmt is nullptr.
*/
static void verifyIsSimpleDateFormat(const UDateFormat* fmt, UErrorCode *status) {
if(U_SUCCESS(*status) &&
- dynamic_cast<const SimpleDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))==NULL) {
+ dynamic_cast<const SimpleDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))==nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
}
}
@@ -90,41 +90,41 @@ static UCalendarDateFields gDateFieldMapping[] = {
};
U_CAPI UCalendarDateFields U_EXPORT2
-udat_toCalendarDateField(UDateFormatField field) {
+udat_toCalendarDateField(UDateFormatField field) UPRV_NO_SANITIZE_UNDEFINED {
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;
+static UDateFormatOpener gOpener = nullptr;
U_CAPI void U_EXPORT2
udat_registerOpener(UDateFormatOpener opener, UErrorCode *status)
{
if(U_FAILURE(*status)) return;
- umtx_lock(NULL);
- if(gOpener==NULL) {
+ umtx_lock(nullptr);
+ if(gOpener==nullptr) {
gOpener = opener;
} else {
*status = U_ILLEGAL_ARGUMENT_ERROR;
}
- umtx_unlock(NULL);
+ umtx_unlock(nullptr);
}
U_CAPI UDateFormatOpener U_EXPORT2
udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status)
{
- if(U_FAILURE(*status)) return NULL;
- UDateFormatOpener oldOpener = NULL;
- umtx_lock(NULL);
- if(gOpener==NULL || gOpener!=opener) {
+ if(U_FAILURE(*status)) return nullptr;
+ UDateFormatOpener oldOpener = nullptr;
+ umtx_lock(nullptr);
+ if(gOpener==nullptr || gOpener!=opener) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
} else {
oldOpener=gOpener;
- gOpener=NULL;
+ gOpener=nullptr;
}
- umtx_unlock(NULL);
+ umtx_unlock(nullptr);
return oldOpener;
}
@@ -134,9 +134,9 @@ U_CAPI UDateFormat* U_EXPORT2
udat_open(UDateFormatStyle timeStyle,
UDateFormatStyle dateStyle,
const char *locale,
- const UChar *tzID,
+ const char16_t *tzID,
int32_t tzIDLength,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
UErrorCode *status)
{
@@ -144,9 +144,9 @@ udat_open(UDateFormatStyle timeStyle,
if(U_FAILURE(*status)) {
return 0;
}
- if(gOpener!=NULL) { // if it's registered
+ if(gOpener!=nullptr) { // if it's registered
fmt = (DateFormat*) (*gOpener)(timeStyle,dateStyle,locale,tzID,tzIDLength,pattern,patternLength,status);
- if(fmt!=NULL) {
+ if(fmt!=nullptr) {
return (UDateFormat*)fmt;
} // else fall through.
}
@@ -198,6 +198,7 @@ udat_open(UDateFormatStyle timeStyle,
U_CAPI void U_EXPORT2
udat_close(UDateFormat* format)
{
+ if (format == nullptr) return;
delete (DateFormat*)format;
}
@@ -220,7 +221,7 @@ udat_clone(const UDateFormat *fmt,
U_CAPI int32_t U_EXPORT2
udat_format( const UDateFormat* format,
UDate dateToFormat,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPosition* position,
UErrorCode* status)
@@ -228,14 +229,14 @@ udat_format( const UDateFormat* format,
if(U_FAILURE(*status)) {
return -1;
}
- if (result == NULL ? resultLength != 0 : resultLength < 0) {
+ if (result == nullptr ? resultLength != 0 : resultLength < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
UnicodeString res;
- if (result != NULL) {
- // NULL destination for pure preflighting: empty dummy string
+ if (result != nullptr) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
res.setTo(result, 0, resultLength);
}
@@ -258,7 +259,7 @@ udat_format( const UDateFormat* format,
U_CAPI int32_t U_EXPORT2
udat_formatCalendar(const UDateFormat* format,
UCalendar* calendar,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPosition* position,
UErrorCode* status)
@@ -266,14 +267,14 @@ udat_formatCalendar(const UDateFormat* format,
if(U_FAILURE(*status)) {
return -1;
}
- if (result == NULL ? resultLength != 0 : resultLength < 0) {
+ if (result == nullptr ? resultLength != 0 : resultLength < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
UnicodeString res;
- if (result != NULL) {
- // NULL destination for pure preflighting: empty dummy string
+ if (result != nullptr) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
res.setTo(result, 0, resultLength);
}
@@ -296,7 +297,7 @@ udat_formatCalendar(const UDateFormat* format,
U_CAPI int32_t U_EXPORT2
udat_formatForFields( const UDateFormat* format,
UDate dateToFormat,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPositionIterator* fpositer,
UErrorCode* status)
@@ -304,14 +305,14 @@ udat_formatForFields( const UDateFormat* format,
if(U_FAILURE(*status)) {
return -1;
}
- if (result == NULL ? resultLength != 0 : resultLength < 0) {
+ if (result == nullptr ? resultLength != 0 : resultLength < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
UnicodeString res;
- if (result != NULL) {
- // NULL destination for pure preflighting: empty dummy string
+ if (result != nullptr) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
res.setTo(result, 0, resultLength);
}
@@ -324,7 +325,7 @@ udat_formatForFields( const UDateFormat* format,
U_CAPI int32_t U_EXPORT2
udat_formatCalendarForFields(const UDateFormat* format,
UCalendar* calendar,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPositionIterator* fpositer,
UErrorCode* status)
@@ -332,14 +333,14 @@ udat_formatCalendarForFields(const UDateFormat* format,
if(U_FAILURE(*status)) {
return -1;
}
- if (result == NULL ? resultLength != 0 : resultLength < 0) {
+ if (result == nullptr ? resultLength != 0 : resultLength < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
UnicodeString res;
- if (result != NULL) {
- // NULL destination for pure preflighting: empty dummy string
+ if (result != nullptr) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
res.setTo(result, 0, resultLength);
}
@@ -351,7 +352,7 @@ udat_formatCalendarForFields(const UDateFormat* format,
U_CAPI UDate U_EXPORT2
udat_parse( const UDateFormat* format,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t *parsePos,
UErrorCode *status)
@@ -363,7 +364,7 @@ udat_parse( const UDateFormat* format,
int32_t stackParsePos = 0;
UDate res;
- if(parsePos == NULL) {
+ if(parsePos == nullptr) {
parsePos = &stackParsePos;
}
@@ -384,7 +385,7 @@ udat_parse( const UDateFormat* format,
U_CAPI void U_EXPORT2
udat_parseCalendar(const UDateFormat* format,
UCalendar* calendar,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t *parsePos,
UErrorCode *status)
@@ -395,7 +396,7 @@ udat_parseCalendar(const UDateFormat* format,
ParsePosition pp;
int32_t stackParsePos = 0;
- if(parsePos == NULL) {
+ if(parsePos == nullptr) {
parsePos = &stackParsePos;
}
@@ -429,9 +430,9 @@ udat_getBooleanAttribute(const UDateFormat* fmt,
UDateFormatBooleanAttribute attr,
UErrorCode* status)
{
- if(U_FAILURE(*status)) return FALSE;
+ if(U_FAILURE(*status)) return false;
return ((DateFormat*)fmt)->getBooleanAttribute(attr, *status);
- //return FALSE;
+ //return false;
}
U_CAPI void U_EXPORT2
@@ -458,7 +459,7 @@ udat_setCalendar(UDateFormat* fmt,
}
U_CAPI const UNumberFormat* U_EXPORT2
-udat_getNumberFormatForField(const UDateFormat* fmt, UChar field)
+udat_getNumberFormatForField(const UDateFormat* fmt, char16_t field)
{
UErrorCode status = U_ZERO_ERROR;
verifyIsSimpleDateFormat(fmt, &status);
@@ -474,14 +475,14 @@ udat_getNumberFormat(const UDateFormat* fmt)
U_CAPI void U_EXPORT2
udat_adoptNumberFormatForFields( UDateFormat* fmt,
- const UChar* fields,
+ const char16_t* fields,
UNumberFormat* numberFormatToSet,
UErrorCode* status)
{
verifyIsSimpleDateFormat(fmt, status);
if (U_FAILURE(*status)) return;
- if (fields!=NULL) {
+ if (fields!=nullptr) {
UnicodeString overrideFields(fields);
((SimpleDateFormat*)fmt)->adoptNumberFormat(overrideFields, (NumberFormat*)numberFormatToSet, *status);
}
@@ -535,21 +536,21 @@ udat_set2DigitYearStart( UDateFormat *fmt,
U_CAPI int32_t U_EXPORT2
udat_toPattern( const UDateFormat *fmt,
UBool localized,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status)
{
if(U_FAILURE(*status)) {
return -1;
}
- if (result == NULL ? resultLength != 0 : resultLength < 0) {
+ if (result == nullptr ? resultLength != 0 : resultLength < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
UnicodeString res;
- if (result != NULL) {
- // NULL destination for pure preflighting: empty dummy string
+ if (result != nullptr) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
res.setTo(result, 0, resultLength);
}
@@ -557,12 +558,12 @@ udat_toPattern( const UDateFormat *fmt,
const DateFormat *df=reinterpret_cast<const DateFormat *>(fmt);
const SimpleDateFormat *sdtfmt=dynamic_cast<const SimpleDateFormat *>(df);
const RelativeDateFormat *reldtfmt;
- if (sdtfmt!=NULL) {
+ if (sdtfmt!=nullptr) {
if(localized)
sdtfmt->toLocalizedPattern(res, *status);
else
sdtfmt->toPattern(res);
- } else if (!localized && (reldtfmt=dynamic_cast<const RelativeDateFormat *>(df))!=NULL) {
+ } else if (!localized && (reldtfmt=dynamic_cast<const RelativeDateFormat *>(df))!=nullptr) {
reldtfmt->toPattern(res, *status);
} else {
*status = U_ILLEGAL_ARGUMENT_ERROR;
@@ -577,7 +578,7 @@ udat_toPattern( const UDateFormat *fmt,
U_CAPI void U_EXPORT2
udat_applyPattern( UDateFormat *format,
UBool localized,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength)
{
const UnicodeString pat((UBool)(patternLength == -1), pattern, patternLength);
@@ -598,22 +599,22 @@ U_CAPI int32_t U_EXPORT2
udat_getSymbols(const UDateFormat *fmt,
UDateFormatSymbolType type,
int32_t index,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status)
{
const DateFormatSymbols *syms;
const SimpleDateFormat* sdtfmt;
const RelativeDateFormat* rdtfmt;
- if ((sdtfmt = dynamic_cast<const SimpleDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != NULL) {
+ if ((sdtfmt = dynamic_cast<const SimpleDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != nullptr) {
syms = sdtfmt->getDateFormatSymbols();
- } else if ((rdtfmt = dynamic_cast<const RelativeDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != NULL) {
+ } else if ((rdtfmt = dynamic_cast<const RelativeDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != nullptr) {
syms = rdtfmt->getDateFormatSymbols();
} else {
return -1;
}
int32_t count = 0;
- const UnicodeString *res = NULL;
+ const UnicodeString *res = nullptr;
switch(type) {
case UDAT_ERAS:
@@ -647,8 +648,8 @@ udat_getSymbols(const UDateFormat *fmt,
case UDAT_LOCALIZED_CHARS:
{
UnicodeString res1;
- if(!(result==NULL && resultLength==0)) {
- // NULL destination for pure preflighting: empty dummy string
+ if(!(result==nullptr && resultLength==0)) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
res1.setTo(result, 0, resultLength);
}
@@ -760,9 +761,9 @@ udat_countSymbols( const UDateFormat *fmt,
const DateFormatSymbols *syms;
const SimpleDateFormat* sdtfmt;
const RelativeDateFormat* rdtfmt;
- if ((sdtfmt = dynamic_cast<const SimpleDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != NULL) {
+ if ((sdtfmt = dynamic_cast<const SimpleDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != nullptr) {
syms = sdtfmt->getDateFormatSymbols();
- } else if ((rdtfmt = dynamic_cast<const RelativeDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != NULL) {
+ } else if ((rdtfmt = dynamic_cast<const RelativeDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != nullptr) {
syms = rdtfmt->getDateFormatSymbols();
} else {
return 0;
@@ -925,12 +926,12 @@ class DateFormatSymbolsSingleSetter /* not : public UObject because all methods
public:
static void
setSymbol(UnicodeString *array, int32_t count, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
- if(array!=NULL) {
+ if(array!=nullptr) {
if(index>=count) {
errorCode=U_INDEX_OUTOFBOUNDS_ERROR;
- } else if(value==NULL) {
+ } else if(value==nullptr) {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
} else {
array[index].setTo(value, valueLength);
@@ -940,182 +941,182 @@ public:
static void
setEra(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fEras, syms->fErasCount, index, value, valueLength, errorCode);
}
static void
setEraName(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fEraNames, syms->fEraNamesCount, index, value, valueLength, errorCode);
}
static void
setMonth(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fMonths, syms->fMonthsCount, index, value, valueLength, errorCode);
}
static void
setShortMonth(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fShortMonths, syms->fShortMonthsCount, index, value, valueLength, errorCode);
}
static void
setNarrowMonth(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fNarrowMonths, syms->fNarrowMonthsCount, index, value, valueLength, errorCode);
}
static void
setStandaloneMonth(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneMonths, syms->fStandaloneMonthsCount, index, value, valueLength, errorCode);
}
static void
setStandaloneShortMonth(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneShortMonths, syms->fStandaloneShortMonthsCount, index, value, valueLength, errorCode);
}
static void
setStandaloneNarrowMonth(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneNarrowMonths, syms->fStandaloneNarrowMonthsCount, index, value, valueLength, errorCode);
}
static void
setWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fWeekdays, syms->fWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setShortWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fShortWeekdays, syms->fShortWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setShorterWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fShorterWeekdays, syms->fShorterWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setNarrowWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fNarrowWeekdays, syms->fNarrowWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setStandaloneWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneWeekdays, syms->fStandaloneWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setStandaloneShortWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneShortWeekdays, syms->fStandaloneShortWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setStandaloneShorterWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneShorterWeekdays, syms->fStandaloneShorterWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setStandaloneNarrowWeekday(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneNarrowWeekdays, syms->fStandaloneNarrowWeekdaysCount, index, value, valueLength, errorCode);
}
static void
setQuarter(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fQuarters, syms->fQuartersCount, index, value, valueLength, errorCode);
}
static void
setShortQuarter(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fShortQuarters, syms->fShortQuartersCount, index, value, valueLength, errorCode);
}
static void
setNarrowQuarter(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fNarrowQuarters, syms->fNarrowQuartersCount, index, value, valueLength, errorCode);
}
static void
setStandaloneQuarter(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneQuarters, syms->fStandaloneQuartersCount, index, value, valueLength, errorCode);
}
static void
setStandaloneShortQuarter(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneShortQuarters, syms->fStandaloneShortQuartersCount, index, value, valueLength, errorCode);
}
static void
setStandaloneNarrowQuarter(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fStandaloneNarrowQuarters, syms->fStandaloneNarrowQuartersCount, index, value, valueLength, errorCode);
}
static void
setShortYearNames(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fShortYearNames, syms->fShortYearNamesCount, index, value, valueLength, errorCode);
}
static void
setShortZodiacNames(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fShortZodiacNames, syms->fShortZodiacNamesCount, index, value, valueLength, errorCode);
}
static void
setAmPm(DateFormatSymbols *syms, int32_t index,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(syms->fAmPms, syms->fAmPmsCount, index, value, valueLength, errorCode);
}
static void
setLocalPatternChars(DateFormatSymbols *syms,
- const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+ const char16_t *value, int32_t valueLength, UErrorCode &errorCode)
{
setSymbol(&syms->fLocalPatternChars, 1, 0, value, valueLength, errorCode);
}
@@ -1127,7 +1128,7 @@ U_CAPI void U_EXPORT2
udat_setSymbols( UDateFormat *format,
UDateFormatSymbolType type,
int32_t index,
- UChar *value,
+ char16_t *value,
int32_t valueLength,
UErrorCode *status)
{
@@ -1253,11 +1254,11 @@ udat_getLocaleByType(const UDateFormat *fmt,
ULocDataLocaleType type,
UErrorCode* status)
{
- if (fmt == NULL) {
+ if (fmt == nullptr) {
if (U_SUCCESS(*status)) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
}
- return NULL;
+ return nullptr;
}
return ((Format*)fmt)->getLocaleID(type, *status);
}
@@ -1285,11 +1286,11 @@ udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* st
/**
* Verify that fmt is a RelativeDateFormat. Invalid error if not.
* @param fmt the UDateFormat, definitely a DateFormat, maybe something else
- * @param status error code, will be set to failure if there is a failure or the fmt is NULL.
+ * @param status error code, will be set to failure if there is a failure or the fmt is nullptr.
*/
static void verifyIsRelativeDateFormat(const UDateFormat* fmt, UErrorCode *status) {
if(U_SUCCESS(*status) &&
- dynamic_cast<const RelativeDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))==NULL) {
+ dynamic_cast<const RelativeDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))==nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
}
}
@@ -1297,7 +1298,7 @@ static void verifyIsRelativeDateFormat(const UDateFormat* fmt, UErrorCode *statu
U_CAPI int32_t U_EXPORT2
udat_toPatternRelativeDate(const UDateFormat *fmt,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status)
{
@@ -1305,14 +1306,14 @@ udat_toPatternRelativeDate(const UDateFormat *fmt,
if(U_FAILURE(*status)) {
return -1;
}
- if (result == NULL ? resultLength != 0 : resultLength < 0) {
+ if (result == nullptr ? resultLength != 0 : resultLength < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
UnicodeString datePattern;
- if (result != NULL) {
- // NULL destination for pure preflighting: empty dummy string
+ if (result != nullptr) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
datePattern.setTo(result, 0, resultLength);
}
@@ -1322,7 +1323,7 @@ udat_toPatternRelativeDate(const UDateFormat *fmt,
U_CAPI int32_t U_EXPORT2
udat_toPatternRelativeTime(const UDateFormat *fmt,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status)
{
@@ -1330,14 +1331,14 @@ udat_toPatternRelativeTime(const UDateFormat *fmt,
if(U_FAILURE(*status)) {
return -1;
}
- if (result == NULL ? resultLength != 0 : resultLength < 0) {
+ if (result == nullptr ? resultLength != 0 : resultLength < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
UnicodeString timePattern;
- if (result != NULL) {
- // NULL destination for pure preflighting: empty dummy string
+ if (result != nullptr) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
timePattern.setTo(result, 0, resultLength);
}
@@ -1347,9 +1348,9 @@ udat_toPatternRelativeTime(const UDateFormat *fmt,
U_CAPI void U_EXPORT2
udat_applyPatternRelative(UDateFormat *format,
- const UChar *datePattern,
+ const char16_t *datePattern,
int32_t datePatternLength,
- const UChar *timePattern,
+ const char16_t *timePattern,
int32_t timePatternLength,
UErrorCode *status)
{
diff --git a/contrib/libs/icu/i18n/udateintervalformat.cpp b/contrib/libs/icu/i18n/udateintervalformat.cpp
index 355744346a..a332eacc53 100644
--- a/contrib/libs/icu/i18n/udateintervalformat.cpp
+++ b/contrib/libs/icu/i18n/udateintervalformat.cpp
@@ -36,32 +36,32 @@ UPRV_FORMATTED_VALUE_CAPI_AUTO_IMPL(
U_CAPI UDateIntervalFormat* U_EXPORT2
udtitvfmt_open(const char* locale,
- const UChar* skeleton,
+ const char16_t* skeleton,
int32_t skeletonLength,
- const UChar* tzID,
+ const char16_t* tzID,
int32_t tzIDLength,
UErrorCode* status)
{
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
- if ((skeleton == NULL ? skeletonLength != 0 : skeletonLength < -1) ||
- (tzID == NULL ? tzIDLength != 0 : tzIDLength < -1)
+ if ((skeleton == nullptr ? skeletonLength != 0 : skeletonLength < -1) ||
+ (tzID == nullptr ? tzIDLength != 0 : tzIDLength < -1)
) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
UnicodeString skel((UBool)(skeletonLength == -1), skeleton, skeletonLength);
LocalPointer<DateIntervalFormat> formatter(
DateIntervalFormat::createInstance(skel, Locale(locale), *status));
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
if(tzID != 0) {
TimeZone *zone = TimeZone::createTimeZone(UnicodeString((UBool)(tzIDLength == -1), tzID, tzIDLength));
- if(zone == NULL) {
+ if(zone == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
formatter->adoptTimeZone(zone);
}
@@ -80,7 +80,7 @@ U_CAPI int32_t U_EXPORT2
udtitvfmt_format(const UDateIntervalFormat* formatter,
UDate fromDate,
UDate toDate,
- UChar* result,
+ char16_t* result,
int32_t resultCapacity,
UFieldPosition* position,
UErrorCode* status)
@@ -88,13 +88,13 @@ udtitvfmt_format(const UDateIntervalFormat* formatter,
if (U_FAILURE(*status)) {
return -1;
}
- if (result == NULL ? resultCapacity != 0 : resultCapacity < 0) {
+ if (result == nullptr ? resultCapacity != 0 : resultCapacity < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
UnicodeString res;
- if (result != NULL) {
- // NULL destination for pure preflighting: empty dummy string
+ if (result != nullptr) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer (copied from udat_format)
res.setTo(result, 0, resultCapacity);
}
diff --git a/contrib/libs/icu/i18n/udatpg.cpp b/contrib/libs/icu/i18n/udatpg.cpp
index 332636a938..07aee36882 100644
--- a/contrib/libs/icu/i18n/udatpg.cpp
+++ b/contrib/libs/icu/i18n/udatpg.cpp
@@ -30,7 +30,7 @@ U_NAMESPACE_USE
U_CAPI UDateTimePatternGenerator * U_EXPORT2
udatpg_open(const char *locale, UErrorCode *pErrorCode) {
- if(locale==NULL) {
+ if(locale==nullptr) {
return (UDateTimePatternGenerator *)DateTimePatternGenerator::createInstance(*pErrorCode);
} else {
return (UDateTimePatternGenerator *)DateTimePatternGenerator::createInstance(Locale(locale), *pErrorCode);
@@ -50,15 +50,15 @@ udatpg_close(UDateTimePatternGenerator *dtpg) {
U_CAPI UDateTimePatternGenerator * U_EXPORT2
udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
- return NULL;
+ return nullptr;
}
return (UDateTimePatternGenerator *)(((const DateTimePatternGenerator *)dtpg)->clone());
}
U_CAPI int32_t U_EXPORT2
udatpg_getBestPattern(UDateTimePatternGenerator *dtpg,
- const UChar *skeleton, int32_t length,
- UChar *bestPattern, int32_t capacity,
+ const char16_t *skeleton, int32_t length,
+ char16_t *bestPattern, int32_t capacity,
UErrorCode *pErrorCode) {
return udatpg_getBestPatternWithOptions(dtpg, skeleton, length,
UDATPG_MATCH_NO_OPTIONS,
@@ -67,14 +67,14 @@ udatpg_getBestPattern(UDateTimePatternGenerator *dtpg,
U_CAPI int32_t U_EXPORT2
udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg,
- const UChar *skeleton, int32_t length,
+ const char16_t *skeleton, int32_t length,
UDateTimePatternMatchOptions options,
- UChar *bestPattern, int32_t capacity,
+ char16_t *bestPattern, int32_t capacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
}
- if(skeleton==NULL && length!=0) {
+ if(skeleton==nullptr && length!=0) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -85,13 +85,13 @@ udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg,
U_CAPI int32_t U_EXPORT2
udatpg_getSkeleton(UDateTimePatternGenerator * /* dtpg */,
- const UChar *pattern, int32_t length,
- UChar *skeleton, int32_t capacity,
+ const char16_t *pattern, int32_t length,
+ char16_t *skeleton, int32_t capacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
}
- if(pattern==NULL && length!=0) {
+ if(pattern==nullptr && length!=0) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -103,13 +103,13 @@ udatpg_getSkeleton(UDateTimePatternGenerator * /* dtpg */,
U_CAPI int32_t U_EXPORT2
udatpg_getBaseSkeleton(UDateTimePatternGenerator * /* dtpg */,
- const UChar *pattern, int32_t length,
- UChar *skeleton, int32_t capacity,
+ const char16_t *pattern, int32_t length,
+ char16_t *skeleton, int32_t capacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
}
- if(pattern==NULL && length!=0) {
+ if(pattern==nullptr && length!=0) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -121,14 +121,14 @@ udatpg_getBaseSkeleton(UDateTimePatternGenerator * /* dtpg */,
U_CAPI UDateTimePatternConflict U_EXPORT2
udatpg_addPattern(UDateTimePatternGenerator *dtpg,
- const UChar *pattern, int32_t patternLength,
+ const char16_t *pattern, int32_t patternLength,
UBool override,
- UChar *conflictingPattern, int32_t capacity, int32_t *pLength,
+ char16_t *conflictingPattern, int32_t capacity, int32_t *pLength,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return UDATPG_NO_CONFLICT;
}
- if(pattern==NULL && patternLength!=0) {
+ if(pattern==nullptr && patternLength!=0) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return UDATPG_NO_CONFLICT;
}
@@ -137,7 +137,7 @@ udatpg_addPattern(UDateTimePatternGenerator *dtpg,
UDateTimePatternConflict result=((DateTimePatternGenerator *)dtpg)->
addPattern(patternString, override, conflictingPatternString, *pErrorCode);
int32_t length=conflictingPatternString.extract(conflictingPattern, capacity, *pErrorCode);
- if(pLength!=NULL) {
+ if(pLength!=nullptr) {
*pLength=length;
}
return result;
@@ -146,17 +146,17 @@ udatpg_addPattern(UDateTimePatternGenerator *dtpg,
U_CAPI void U_EXPORT2
udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
- const UChar *value, int32_t length) {
+ const char16_t *value, int32_t length) {
UnicodeString valueString((UBool)(length<0), value, length);
((DateTimePatternGenerator *)dtpg)->setAppendItemFormat(field, valueString);
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
int32_t *pLength) {
const UnicodeString &result=((const DateTimePatternGenerator *)dtpg)->getAppendItemFormat(field);
- if(pLength!=NULL) {
+ if(pLength!=nullptr) {
*pLength=result.length();
}
return result.getBuffer();
@@ -165,17 +165,17 @@ udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg,
U_CAPI void U_EXPORT2
udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
- const UChar *value, int32_t length) {
+ const char16_t *value, int32_t length) {
UnicodeString valueString((UBool)(length<0), value, length);
((DateTimePatternGenerator *)dtpg)->setAppendItemName(field, valueString);
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
int32_t *pLength) {
const UnicodeString &result=((const DateTimePatternGenerator *)dtpg)->getAppendItemName(field);
- if(pLength!=NULL) {
+ if(pLength!=nullptr) {
*pLength=result.length();
}
return result.getBuffer();
@@ -185,16 +185,16 @@ U_CAPI int32_t U_EXPORT2
udatpg_getFieldDisplayName(const UDateTimePatternGenerator *dtpg,
UDateTimePatternField field,
UDateTimePGDisplayWidth width,
- UChar *fieldName, int32_t capacity,
+ char16_t *fieldName, int32_t capacity,
UErrorCode *pErrorCode) {
if (U_FAILURE(*pErrorCode))
return -1;
- if (fieldName == NULL ? capacity != 0 : capacity < 0) {
+ if (fieldName == nullptr ? capacity != 0 : capacity < 0) {
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
UnicodeString result = ((const DateTimePatternGenerator *)dtpg)->getFieldDisplayName(field,width);
- if (fieldName == NULL) {
+ if (fieldName == nullptr) {
return result.length();
}
return result.extract(fieldName, capacity, *pErrorCode);
@@ -202,33 +202,68 @@ udatpg_getFieldDisplayName(const UDateTimePatternGenerator *dtpg,
U_CAPI void U_EXPORT2
udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg,
- const UChar *dtFormat, int32_t length) {
+ const char16_t *dtFormat, int32_t length) {
UnicodeString dtFormatString((UBool)(length<0), dtFormat, length);
((DateTimePatternGenerator *)dtpg)->setDateTimeFormat(dtFormatString);
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg,
int32_t *pLength) {
- const UnicodeString &result=((const DateTimePatternGenerator *)dtpg)->getDateTimeFormat();
- if(pLength!=NULL) {
+ UErrorCode status = U_ZERO_ERROR;
+ return udatpg_getDateTimeFormatForStyle(dtpg, UDAT_MEDIUM, pLength, &status);
+}
+
+U_CAPI void U_EXPORT2
+udatpg_setDateTimeFormatForStyle(UDateTimePatternGenerator *udtpg,
+ UDateFormatStyle style,
+ const char16_t *dateTimeFormat, int32_t length,
+ UErrorCode *pErrorCode) {
+ if (U_FAILURE(*pErrorCode)) {
+ return;
+ } else if (dateTimeFormat==nullptr) {
+ *pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
+ return;
+ }
+ DateTimePatternGenerator *dtpg = reinterpret_cast<DateTimePatternGenerator *>(udtpg);
+ UnicodeString dtFormatString((UBool)(length<0), dateTimeFormat, length);
+ dtpg->setDateTimeFormat(style, dtFormatString, *pErrorCode);
+}
+
+U_CAPI const char16_t* U_EXPORT2
+udatpg_getDateTimeFormatForStyle(const UDateTimePatternGenerator *udtpg,
+ UDateFormatStyle style, int32_t *pLength,
+ UErrorCode *pErrorCode) {
+ static const char16_t emptyString[] = { (char16_t)0 };
+ if (U_FAILURE(*pErrorCode)) {
+ if (pLength !=nullptr) {
+ *pLength = 0;
+ }
+ return emptyString;
+ }
+ const DateTimePatternGenerator *dtpg = reinterpret_cast<const DateTimePatternGenerator *>(udtpg);
+ const UnicodeString &result = dtpg->getDateTimeFormat(style, *pErrorCode);
+ if (pLength != nullptr) {
*pLength=result.length();
}
+ // Note: The UnicodeString for the dateTimeFormat string in the DateTimePatternGenerator
+ // was NUL-terminated what it was set, to avoid doing it here which could re-allocate
+ // the buffe and affect and cont references to the string or its buffer.
return result.getBuffer();
-}
+ }
U_CAPI void U_EXPORT2
udatpg_setDecimal(UDateTimePatternGenerator *dtpg,
- const UChar *decimal, int32_t length) {
+ const char16_t *decimal, int32_t length) {
UnicodeString decimalString((UBool)(length<0), decimal, length);
((DateTimePatternGenerator *)dtpg)->setDecimal(decimalString);
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
udatpg_getDecimal(const UDateTimePatternGenerator *dtpg,
int32_t *pLength) {
const UnicodeString &result=((const DateTimePatternGenerator *)dtpg)->getDecimal();
- if(pLength!=NULL) {
+ if(pLength!=nullptr) {
*pLength=result.length();
}
return result.getBuffer();
@@ -236,9 +271,9 @@ udatpg_getDecimal(const UDateTimePatternGenerator *dtpg,
U_CAPI int32_t U_EXPORT2
udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg,
- const UChar *pattern, int32_t patternLength,
- const UChar *skeleton, int32_t skeletonLength,
- UChar *dest, int32_t destCapacity,
+ const char16_t *pattern, int32_t patternLength,
+ const char16_t *skeleton, int32_t skeletonLength,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode) {
return udatpg_replaceFieldTypesWithOptions(dtpg, pattern, patternLength, skeleton, skeletonLength,
UDATPG_MATCH_NO_OPTIONS,
@@ -247,15 +282,15 @@ udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg,
U_CAPI int32_t U_EXPORT2
udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg,
- const UChar *pattern, int32_t patternLength,
- const UChar *skeleton, int32_t skeletonLength,
+ const char16_t *pattern, int32_t patternLength,
+ const char16_t *skeleton, int32_t skeletonLength,
UDateTimePatternMatchOptions options,
- UChar *dest, int32_t destCapacity,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
}
- if((pattern==NULL && patternLength!=0) || (skeleton==NULL && skeletonLength!=0)) {
+ if((pattern==nullptr && patternLength!=0) || (skeleton==nullptr && skeletonLength!=0)) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -279,13 +314,13 @@ udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErr
pErrorCode);
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg,
- const UChar *skeleton, int32_t skeletonLength,
+ const char16_t *skeleton, int32_t skeletonLength,
int32_t *pLength) {
UnicodeString skeletonString((UBool)(skeletonLength<0), skeleton, skeletonLength);
const UnicodeString &result=((const DateTimePatternGenerator *)dtpg)->getPatternForSkeleton(skeletonString);
- if(pLength!=NULL) {
+ if(pLength!=nullptr) {
*pLength=result.length();
}
return result.getBuffer();
diff --git a/contrib/libs/icu/i18n/ufieldpositer.cpp b/contrib/libs/icu/i18n/ufieldpositer.cpp
index 64de856c30..f28e1aa20e 100644
--- a/contrib/libs/icu/i18n/ufieldpositer.cpp
+++ b/contrib/libs/icu/i18n/ufieldpositer.cpp
@@ -22,10 +22,10 @@ U_CAPI UFieldPositionIterator* U_EXPORT2
ufieldpositer_open(UErrorCode* status)
{
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
FieldPositionIterator* fpositer = new FieldPositionIterator();
- if (fpositer == NULL) {
+ if (fpositer == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
}
return (UFieldPositionIterator*)fpositer;
diff --git a/contrib/libs/icu/i18n/uitercollationiterator.cpp b/contrib/libs/icu/i18n/uitercollationiterator.cpp
index 103c91cac8..6f840f3fe5 100644
--- a/contrib/libs/icu/i18n/uitercollationiterator.cpp
+++ b/contrib/libs/icu/i18n/uitercollationiterator.cpp
@@ -50,11 +50,11 @@ UIterCollationIterator::handleNextCE32(UChar32 &c, UErrorCode & /*errorCode*/) {
return UTRIE2_GET32_FROM_U16_SINGLE_LEAD(trie, c);
}
-UChar
+char16_t
UIterCollationIterator::handleGetTrailSurrogate() {
UChar32 trail = iter.next(&iter);
if(!U16_IS_TRAIL(trail) && trail >= 0) { iter.previous(&iter); }
- return (UChar)trail;
+ return (char16_t)trail;
}
UChar32
@@ -140,7 +140,7 @@ FCDUIterCollationIterator::handleNextCE32(UChar32 &c, UErrorCode &errorCode) {
return UTRIE2_GET32_FROM_U16_SINGLE_LEAD(trie, c);
}
-UChar
+char16_t
FCDUIterCollationIterator::handleGetTrailSurrogate() {
if(state <= ITER_IN_FCD_SEGMENT) {
UChar32 trail = iter.next(&iter);
@@ -149,10 +149,10 @@ FCDUIterCollationIterator::handleGetTrailSurrogate() {
} else if(trail >= 0) {
iter.previous(&iter);
}
- return (UChar)trail;
+ return (char16_t)trail;
} else {
U_ASSERT(pos < normalized.length());
- UChar trail;
+ char16_t trail;
if(U16_IS_TRAIL(trail = normalized[pos])) { ++pos; }
return trail;
}
@@ -303,7 +303,7 @@ FCDUIterCollationIterator::switchToForward() {
UBool
FCDUIterCollationIterator::nextSegment(UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
U_ASSERT(state == ITER_CHECK_FWD);
// The input text [start..(iter index)[ passes the FCD check.
pos = iter.getIndex(&iter, UITER_CURRENT);
@@ -333,12 +333,12 @@ FCDUIterCollationIterator::nextSegment(UErrorCode &errorCode) {
}
s.append(c);
}
- if(!normalize(s, errorCode)) { return FALSE; }
+ if(!normalize(s, errorCode)) { return false; }
start = pos;
limit = pos + s.length();
state = IN_NORM_ITER_AT_LIMIT;
pos = 0;
- return TRUE;
+ return true;
}
prevCC = (uint8_t)fcd16;
if(prevCC == 0) {
@@ -350,7 +350,7 @@ FCDUIterCollationIterator::nextSegment(UErrorCode &errorCode) {
U_ASSERT(pos != limit);
iter.move(&iter, -s.length(), UITER_CURRENT);
state = ITER_IN_FCD_SEGMENT;
- return TRUE;
+ return true;
}
void
@@ -384,7 +384,7 @@ FCDUIterCollationIterator::switchToBackward() {
UBool
FCDUIterCollationIterator::previousSegment(UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
U_ASSERT(state == ITER_CHECK_BWD);
// The input text [(iter index)..limit[ passes the FCD check.
pos = iter.getIndex(&iter, UITER_CURRENT);
@@ -417,12 +417,12 @@ FCDUIterCollationIterator::previousSegment(UErrorCode &errorCode) {
s.append(c);
}
s.reverse();
- if(!normalize(s, errorCode)) { return FALSE; }
+ if(!normalize(s, errorCode)) { return false; }
limit = pos;
start = pos - s.length();
state = IN_NORM_ITER_AT_START;
pos = normalized.length();
- return TRUE;
+ return true;
}
nextCC = (uint8_t)(fcd16 >> 8);
if(nextCC == 0) {
@@ -434,7 +434,7 @@ FCDUIterCollationIterator::previousSegment(UErrorCode &errorCode) {
U_ASSERT(pos != start);
iter.move(&iter, s.length(), UITER_CURRENT);
state = ITER_IN_FCD_SEGMENT;
- return TRUE;
+ return true;
}
UBool
diff --git a/contrib/libs/icu/i18n/uitercollationiterator.h b/contrib/libs/icu/i18n/uitercollationiterator.h
index e0da353f26..23d8562a87 100644
--- a/contrib/libs/icu/i18n/uitercollationiterator.h
+++ b/contrib/libs/icu/i18n/uitercollationiterator.h
@@ -50,7 +50,7 @@ public:
protected:
virtual uint32_t handleNextCE32(UChar32 &c, UErrorCode &errorCode) override;
- virtual UChar handleGetTrailSurrogate() override;
+ virtual char16_t handleGetTrailSurrogate() override;
virtual void forwardNumCodePoints(int32_t num, UErrorCode &errorCode) override;
@@ -82,7 +82,7 @@ public:
protected:
virtual uint32_t handleNextCE32(UChar32 &c, UErrorCode &errorCode) override;
- virtual UChar handleGetTrailSurrogate() override;
+ virtual char16_t handleGetTrailSurrogate() override;
virtual void forwardNumCodePoints(int32_t num, UErrorCode &errorCode) override;
diff --git a/contrib/libs/icu/i18n/ulistformatter.cpp b/contrib/libs/icu/i18n/ulistformatter.cpp
index bfb7cf96bd..721905f097 100644
--- a/contrib/libs/icu/i18n/ulistformatter.cpp
+++ b/contrib/libs/icu/i18n/ulistformatter.cpp
@@ -24,11 +24,11 @@ ulistfmt_open(const char* locale,
UErrorCode* status)
{
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
LocalPointer<ListFormatter> listfmt(ListFormatter::createInstance(Locale(locale), *status));
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
return (UListFormatter*)listfmt.orphan();
}
@@ -39,11 +39,11 @@ ulistfmt_openForType(const char* locale, UListFormatterType type,
UListFormatterWidth width, UErrorCode* status)
{
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
LocalPointer<ListFormatter> listfmt(ListFormatter::createInstance(Locale(locale), type, width, *status));
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
return (UListFormatter*)listfmt.orphan();
}
@@ -67,14 +67,14 @@ UPRV_FORMATTED_VALUE_CAPI_AUTO_IMPL(
static UnicodeString* getUnicodeStrings(
- const UChar* const strings[],
+ const char16_t* const strings[],
const int32_t* stringLengths,
int32_t stringCount,
UnicodeString* length4StackBuffer,
LocalArray<UnicodeString>& maybeOwner,
UErrorCode& status) {
U_ASSERT(U_SUCCESS(status));
- if (stringCount < 0 || (strings == NULL && stringCount > 0)) {
+ if (stringCount < 0 || (strings == nullptr && stringCount > 0)) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return nullptr;
}
@@ -86,9 +86,9 @@ static UnicodeString* getUnicodeStrings(
}
ustrings = maybeOwner.getAlias();
}
- if (stringLengths == NULL) {
+ if (stringLengths == nullptr) {
for (int32_t stringIndex = 0; stringIndex < stringCount; stringIndex++) {
- ustrings[stringIndex].setTo(TRUE, strings[stringIndex], -1);
+ ustrings[stringIndex].setTo(true, strings[stringIndex], -1);
}
} else {
for (int32_t stringIndex = 0; stringIndex < stringCount; stringIndex++) {
@@ -101,17 +101,17 @@ static UnicodeString* getUnicodeStrings(
U_CAPI int32_t U_EXPORT2
ulistfmt_format(const UListFormatter* listfmt,
- const UChar* const strings[],
+ const char16_t* const strings[],
const int32_t * stringLengths,
int32_t stringCount,
- UChar* result,
+ char16_t* result,
int32_t resultCapacity,
UErrorCode* status)
{
if (U_FAILURE(*status)) {
return -1;
}
- if ((result == NULL) ? resultCapacity != 0 : resultCapacity < 0) {
+ if ((result == nullptr) ? resultCapacity != 0 : resultCapacity < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
@@ -123,8 +123,8 @@ ulistfmt_format(const UListFormatter* listfmt,
return -1;
}
UnicodeString res;
- if (result != NULL) {
- // NULL destination for pure preflighting: empty dummy string
+ if (result != nullptr) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer (copied from udat_format)
res.setTo(result, 0, resultCapacity);
}
@@ -136,7 +136,7 @@ ulistfmt_format(const UListFormatter* listfmt,
U_CAPI void U_EXPORT2
ulistfmt_formatStringsToResult(
const UListFormatter* listfmt,
- const UChar* const strings[],
+ const char16_t* const strings[],
const int32_t * stringLengths,
int32_t stringCount,
UFormattedList* uresult,
diff --git a/contrib/libs/icu/i18n/ulocdata.cpp b/contrib/libs/icu/i18n/ulocdata.cpp
index 68b9e0cf63..8e0687c5f6 100644
--- a/contrib/libs/icu/i18n/ulocdata.cpp
+++ b/contrib/libs/icu/i18n/ulocdata.cpp
@@ -55,24 +55,24 @@ ulocdata_open(const char *localeID, UErrorCode *status)
ULocaleData *uld;
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
uld = (ULocaleData *)uprv_malloc(sizeof(ULocaleData));
- if (uld == NULL) {
+ if (uld == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return(NULL);
+ return(nullptr);
}
- uld->langBundle = NULL;
+ uld->langBundle = nullptr;
- uld->noSubstitute = FALSE;
- uld->bundle = ures_open(NULL, localeID, status);
+ uld->noSubstitute = false;
+ uld->bundle = ures_open(nullptr, localeID, status);
uld->langBundle = ures_open(U_ICUDATA_LANG, localeID, status);
if (U_FAILURE(*status)) {
uprv_free(uld);
- return NULL;
+ return nullptr;
}
return uld;
@@ -81,7 +81,7 @@ ulocdata_open(const char *localeID, UErrorCode *status)
U_CAPI void U_EXPORT2
ulocdata_close(ULocaleData *uld)
{
- if ( uld != NULL ) {
+ if ( uld != nullptr ) {
ures_close(uld->langBundle);
ures_close(uld->bundle);
uprv_free(uld);
@@ -108,12 +108,12 @@ ulocdata_getExemplarSet(ULocaleData *uld, USet *fillIn,
"AuxExemplarCharacters",
"ExemplarCharactersIndex",
"ExemplarCharactersPunctuation"};
- const UChar *exemplarChars = NULL;
+ const char16_t *exemplarChars = nullptr;
int32_t len = 0;
UErrorCode localStatus = U_ZERO_ERROR;
if (U_FAILURE(*status))
- return NULL;
+ return nullptr;
exemplarChars = ures_getStringByKey(uld->bundle, exemplarSetTypes[extype], &len, &localStatus);
if ( (localStatus == U_USING_DEFAULT_WARNING) && uld->noSubstitute ) {
@@ -125,9 +125,9 @@ ulocdata_getExemplarSet(ULocaleData *uld, USet *fillIn,
}
if (U_FAILURE(*status))
- return NULL;
+ return nullptr;
- if(fillIn != NULL)
+ if(fillIn != nullptr)
uset_applyPattern(fillIn, exemplarChars, len,
USET_IGNORE_SPACE | options, status);
else
@@ -140,7 +140,7 @@ ulocdata_getExemplarSet(ULocaleData *uld, USet *fillIn,
U_CAPI int32_t U_EXPORT2
ulocdata_getDelimiter(ULocaleData *uld, ULocaleDataDelimiterType type,
- UChar *result, int32_t resultLength, UErrorCode *status){
+ char16_t *result, int32_t resultLength, UErrorCode *status){
static const char* const delimiterKeys[] = {
"quotationStart",
@@ -151,13 +151,13 @@ ulocdata_getDelimiter(ULocaleData *uld, ULocaleDataDelimiterType type,
UResourceBundle *delimiterBundle;
int32_t len = 0;
- const UChar *delimiter = NULL;
+ const char16_t *delimiter = nullptr;
UErrorCode localStatus = U_ZERO_ERROR;
if (U_FAILURE(*status))
return 0;
- delimiterBundle = ures_getByKey(uld->bundle, "delimiters", NULL, &localStatus);
+ delimiterBundle = ures_getByKey(uld->bundle, "delimiters", nullptr, &localStatus);
if ( (localStatus == U_USING_DEFAULT_WARNING) && uld->noSubstitute ) {
localStatus = U_MISSING_RESOURCE_ERROR;
@@ -194,24 +194,24 @@ ulocdata_getDelimiter(ULocaleData *uld, ULocaleDataDelimiterType type,
static UResourceBundle * measurementTypeBundleForLocale(const char *localeID, const char *measurementType, UErrorCode *status){
char region[ULOC_COUNTRY_CAPACITY];
UResourceBundle *rb;
- UResourceBundle *measTypeBundle = NULL;
+ UResourceBundle *measTypeBundle = nullptr;
- ulocimp_getRegionForSupplementalData(localeID, TRUE, region, ULOC_COUNTRY_CAPACITY, status);
+ ulocimp_getRegionForSupplementalData(localeID, true, region, ULOC_COUNTRY_CAPACITY, status);
- rb = ures_openDirect(NULL, "supplementalData", status);
+ rb = ures_openDirect(nullptr, "supplementalData", status);
ures_getByKey(rb, "measurementData", rb, status);
- if (rb != NULL) {
- UResourceBundle *measDataBundle = ures_getByKey(rb, region, NULL, status);
+ if (rb != nullptr) {
+ UResourceBundle *measDataBundle = ures_getByKey(rb, region, nullptr, status);
if (U_SUCCESS(*status)) {
- measTypeBundle = ures_getByKey(measDataBundle, measurementType, NULL, status);
+ measTypeBundle = ures_getByKey(measDataBundle, measurementType, nullptr, status);
}
if (*status == U_MISSING_RESOURCE_ERROR) {
*status = U_ZERO_ERROR;
- if (measDataBundle != NULL) {
+ if (measDataBundle != nullptr) {
ures_close(measDataBundle);
}
- measDataBundle = ures_getByKey(rb, "001", NULL, status);
- measTypeBundle = ures_getByKey(measDataBundle, measurementType, NULL, status);
+ measDataBundle = ures_getByKey(rb, "001", nullptr, status);
+ measTypeBundle = ures_getByKey(measDataBundle, measurementType, nullptr, status);
}
ures_close(measDataBundle);
}
@@ -222,15 +222,18 @@ static UResourceBundle * measurementTypeBundleForLocale(const char *localeID, co
U_CAPI UMeasurementSystem U_EXPORT2
ulocdata_getMeasurementSystem(const char *localeID, UErrorCode *status){
- UResourceBundle* measurement=NULL;
+ UResourceBundle* measurement=nullptr;
UMeasurementSystem system = UMS_LIMIT;
- if(status == NULL || U_FAILURE(*status)){
+ if(status == nullptr || U_FAILURE(*status)){
return system;
}
measurement = measurementTypeBundleForLocale(localeID, MEASUREMENT_SYSTEM, status);
- system = (UMeasurementSystem) ures_getInt(measurement, status);
+ int32_t result = ures_getInt(measurement, status);
+ if (U_SUCCESS(*status)) {
+ system = static_cast<UMeasurementSystem>(result);
+ }
ures_close(measurement);
@@ -240,11 +243,11 @@ ulocdata_getMeasurementSystem(const char *localeID, UErrorCode *status){
U_CAPI void U_EXPORT2
ulocdata_getPaperSize(const char* localeID, int32_t *height, int32_t *width, UErrorCode *status){
- UResourceBundle* paperSizeBundle = NULL;
- const int32_t* paperSize=NULL;
+ UResourceBundle* paperSizeBundle = nullptr;
+ const int32_t* paperSize=nullptr;
int32_t len = 0;
- if(status == NULL || U_FAILURE(*status)){
+ if(status == nullptr || U_FAILURE(*status)){
return;
}
@@ -266,26 +269,26 @@ ulocdata_getPaperSize(const char* localeID, int32_t *height, int32_t *width, UEr
U_CAPI void U_EXPORT2
ulocdata_getCLDRVersion(UVersionInfo versionArray, UErrorCode *status) {
- UResourceBundle *rb = NULL;
- rb = ures_openDirect(NULL, "supplementalData", status);
+ UResourceBundle *rb = nullptr;
+ rb = ures_openDirect(nullptr, "supplementalData", status);
ures_getVersionByKey(rb, "cldrVersion", versionArray, status);
ures_close(rb);
}
U_CAPI int32_t U_EXPORT2
ulocdata_getLocaleDisplayPattern(ULocaleData *uld,
- UChar *result,
+ char16_t *result,
int32_t resultCapacity,
UErrorCode *status) {
UResourceBundle *patternBundle;
int32_t len = 0;
- const UChar *pattern = NULL;
+ const char16_t *pattern = nullptr;
UErrorCode localStatus = U_ZERO_ERROR;
if (U_FAILURE(*status))
return 0;
- patternBundle = ures_getByKey(uld->langBundle, "localeDisplayPattern", NULL, &localStatus);
+ patternBundle = ures_getByKey(uld->langBundle, "localeDisplayPattern", nullptr, &localStatus);
if ( (localStatus == U_USING_DEFAULT_WARNING) && uld->noSubstitute ) {
localStatus = U_MISSING_RESOURCE_ERROR;
@@ -322,22 +325,22 @@ ulocdata_getLocaleDisplayPattern(ULocaleData *uld,
U_CAPI int32_t U_EXPORT2
ulocdata_getLocaleSeparator(ULocaleData *uld,
- UChar *result,
+ char16_t *result,
int32_t resultCapacity,
UErrorCode *status) {
UResourceBundle *separatorBundle;
int32_t len = 0;
- const UChar *separator = NULL;
+ const char16_t *separator = nullptr;
UErrorCode localStatus = U_ZERO_ERROR;
- UChar *p0, *p1;
- static const UChar sub0[4] = { 0x007b, 0x0030, 0x007d , 0x0000 }; /* {0} */
- static const UChar sub1[4] = { 0x007b, 0x0031, 0x007d , 0x0000 }; /* {1} */
+ char16_t *p0, *p1;
+ static const char16_t sub0[4] = { 0x007b, 0x0030, 0x007d , 0x0000 }; /* {0} */
+ static const char16_t sub1[4] = { 0x007b, 0x0031, 0x007d , 0x0000 }; /* {1} */
static const int32_t subLen = 3;
if (U_FAILURE(*status))
return 0;
- separatorBundle = ures_getByKey(uld->langBundle, "localeDisplayPattern", NULL, &localStatus);
+ separatorBundle = ures_getByKey(uld->langBundle, "localeDisplayPattern", nullptr, &localStatus);
if ( (localStatus == U_USING_DEFAULT_WARNING) && uld->noSubstitute ) {
localStatus = U_MISSING_RESOURCE_ERROR;
@@ -370,8 +373,8 @@ ulocdata_getLocaleSeparator(ULocaleData *uld,
/* For backwards compatibility, if we have a pattern, return the portion between {0} and {1} */
p0=u_strstr(separator, sub0);
p1=u_strstr(separator, sub1);
- if (p0!=NULL && p1!=NULL && p0<=p1) {
- separator = (const UChar *)p0 + subLen;
+ if (p0!=nullptr && p1!=nullptr && p0<=p1) {
+ separator = (const char16_t *)p0 + subLen;
len = static_cast<int32_t>(p1 - separator);
/* Desired separator is no longer zero-terminated; handle that if necessary */
if (len < resultCapacity) {
diff --git a/contrib/libs/icu/i18n/umsg.cpp b/contrib/libs/icu/i18n/umsg.cpp
index c2d5a9a1f5..ea6e62e2aa 100644
--- a/contrib/libs/icu/i18n/umsg.cpp
+++ b/contrib/libs/icu/i18n/umsg.cpp
@@ -59,9 +59,9 @@ U_NAMESPACE_USE
U_CAPI int32_t
u_formatMessage(const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status,
...)
@@ -81,16 +81,16 @@ u_formatMessage(const char *locale,
U_CAPI int32_t U_EXPORT2
u_vformatMessage( const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
va_list ap,
UErrorCode *status)
{
//argument checking deferred to subsequent method calls
- UMessageFormat *fmt = umsg_open(pattern,patternLength,locale,NULL,status);
+ UMessageFormat *fmt = umsg_open(pattern,patternLength,locale,nullptr,status);
int32_t retVal = umsg_vformat(fmt,result,resultLength,ap,status);
umsg_close(fmt);
return retVal;
@@ -98,9 +98,9 @@ u_vformatMessage( const char *locale,
U_CAPI int32_t
u_formatMessageWithError(const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UParseError *parseError,
UErrorCode *status,
@@ -121,9 +121,9 @@ u_formatMessageWithError(const char *locale,
U_CAPI int32_t U_EXPORT2
u_vformatMessageWithError( const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UParseError *parseError,
va_list ap,
@@ -144,9 +144,9 @@ u_vformatMessageWithError( const char *locale,
// 3. Iterate through each formattable returned, and assign to the arguments
U_CAPI void
u_parseMessage( const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
UErrorCode *status,
...)
@@ -164,15 +164,15 @@ u_parseMessage( const char *locale,
U_CAPI void U_EXPORT2
u_vparseMessage(const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
va_list ap,
UErrorCode *status)
{
//argument checking deferred to subsequent method calls
- UMessageFormat *fmt = umsg_open(pattern,patternLength,locale,NULL,status);
+ UMessageFormat *fmt = umsg_open(pattern,patternLength,locale,nullptr,status);
int32_t count = 0;
umsg_vparse(fmt,source,sourceLength,&count,ap,status);
umsg_close(fmt);
@@ -180,9 +180,9 @@ u_vparseMessage(const char *locale,
U_CAPI void
u_parseMessageWithError(const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
UParseError *error,
UErrorCode *status,
@@ -201,9 +201,9 @@ u_parseMessageWithError(const char *locale,
}
U_CAPI void U_EXPORT2
u_vparseMessageWithError(const char *locale,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
va_list ap,
UParseError *error,
@@ -223,24 +223,24 @@ u_vparseMessageWithError(const char *locale,
U_CAPI UMessageFormat* U_EXPORT2
-umsg_open( const UChar *pattern,
+umsg_open( const char16_t *pattern,
int32_t patternLength,
const char *locale,
UParseError *parseError,
UErrorCode *status)
{
//check arguments
- if(status==NULL || U_FAILURE(*status))
+ if(status==nullptr || U_FAILURE(*status))
{
return 0;
}
- if(pattern==NULL||patternLength<-1){
+ if(pattern==nullptr||patternLength<-1){
*status=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
UParseError tErr;
- if(parseError==NULL)
+ if(parseError==nullptr)
{
parseError = &tErr;
}
@@ -249,9 +249,9 @@ umsg_open( const UChar *pattern,
UnicodeString patString(patternLength == -1, pattern, len);
MessageFormat* retVal = new MessageFormat(patString,Locale(locale),*parseError,*status);
- if(retVal == NULL) {
+ if(retVal == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
if (U_SUCCESS(*status) && MessageFormatAdapter::hasArgTypeConflicts(*retVal)) {
*status = U_ARGUMENT_TYPE_MISMATCH;
@@ -263,7 +263,7 @@ U_CAPI void U_EXPORT2
umsg_close(UMessageFormat* format)
{
//check arguments
- if(format==NULL){
+ if(format==nullptr){
return;
}
delete (MessageFormat*) format;
@@ -274,12 +274,12 @@ umsg_clone(const UMessageFormat *fmt,
UErrorCode *status)
{
//check arguments
- if(status==NULL || U_FAILURE(*status)){
- return NULL;
+ if(status==nullptr || U_FAILURE(*status)){
+ return nullptr;
}
- if(fmt==NULL){
+ if(fmt==nullptr){
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
UMessageFormat retVal = (UMessageFormat)((MessageFormat*)fmt)->clone();
if(retVal == 0) {
@@ -293,7 +293,7 @@ U_CAPI void U_EXPORT2
umsg_setLocale(UMessageFormat *fmt, const char* locale)
{
//check arguments
- if(fmt==NULL){
+ if(fmt==nullptr){
return;
}
((MessageFormat*)fmt)->setLocale(Locale(locale));
@@ -303,7 +303,7 @@ U_CAPI const char* U_EXPORT2
umsg_getLocale(const UMessageFormat *fmt)
{
//check arguments
- if(fmt==NULL){
+ if(fmt==nullptr){
return "";
}
return ((const MessageFormat*)fmt)->getLocale().getName();
@@ -311,22 +311,22 @@ umsg_getLocale(const UMessageFormat *fmt)
U_CAPI void U_EXPORT2
umsg_applyPattern(UMessageFormat *fmt,
- const UChar* pattern,
+ const char16_t* pattern,
int32_t patternLength,
UParseError* parseError,
UErrorCode* status)
{
//check arguments
UParseError tErr;
- if(status ==NULL||U_FAILURE(*status)){
+ if(status ==nullptr||U_FAILURE(*status)){
return ;
}
- if(fmt==NULL || (pattern==NULL && patternLength!=0) || patternLength<-1) {
+ if(fmt==nullptr || (pattern==nullptr && patternLength!=0) || patternLength<-1) {
*status=U_ILLEGAL_ARGUMENT_ERROR;
return ;
}
- if(parseError==NULL){
+ if(parseError==nullptr){
parseError = &tErr;
}
@@ -336,23 +336,23 @@ umsg_applyPattern(UMessageFormat *fmt,
U_CAPI int32_t U_EXPORT2
umsg_toPattern(const UMessageFormat *fmt,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UErrorCode* status)
{
//check arguments
- if(status ==NULL||U_FAILURE(*status)){
+ if(status ==nullptr||U_FAILURE(*status)){
return -1;
}
- if(fmt==NULL||resultLength<0 || (resultLength>0 && result==0)){
+ if(fmt==nullptr||resultLength<0 || (resultLength>0 && result==0)){
*status=U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
UnicodeString res;
- if(!(result==NULL && resultLength==0)) {
- // NULL destination for pure preflighting: empty dummy string
+ if(!(result==nullptr && resultLength==0)) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
res.setTo(result, 0, resultLength);
}
@@ -362,7 +362,7 @@ umsg_toPattern(const UMessageFormat *fmt,
U_CAPI int32_t
umsg_format( const UMessageFormat *fmt,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UErrorCode *status,
...)
@@ -387,7 +387,7 @@ umsg_format( const UMessageFormat *fmt,
U_CAPI int32_t U_EXPORT2
umsg_vformat( const UMessageFormat *fmt,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
va_list ap,
UErrorCode *status)
@@ -397,7 +397,7 @@ umsg_vformat( const UMessageFormat *fmt,
{
return -1;
}
- if(fmt==NULL||resultLength<0 || (resultLength>0 && result==0)) {
+ if(fmt==nullptr||resultLength<0 || (resultLength>0 && result==0)) {
*status=U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
@@ -412,7 +412,7 @@ umsg_vformat( const UMessageFormat *fmt,
// iterate through the vararg list, and get the arguments out
for(int32_t i = 0; i < count; ++i) {
- UChar *stringVal;
+ char16_t *stringVal;
double tDouble=0;
int32_t tInt =0;
int64_t tInt64 = 0;
@@ -440,7 +440,7 @@ umsg_vformat( const UMessageFormat *fmt,
case Formattable::kString:
// For some reason, a temporary is needed
- stringVal = va_arg(ap, UChar*);
+ stringVal = va_arg(ap, char16_t*);
if(stringVal){
args[i].setString(UnicodeString(stringVal));
}else{
@@ -483,7 +483,7 @@ umsg_vformat( const UMessageFormat *fmt,
U_CAPI void
umsg_parse( const UMessageFormat *fmt,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
int32_t *count,
UErrorCode *status,
@@ -505,18 +505,18 @@ umsg_parse( const UMessageFormat *fmt,
U_CAPI void U_EXPORT2
umsg_vparse(const UMessageFormat *fmt,
- const UChar *source,
+ const char16_t *source,
int32_t sourceLength,
int32_t *count,
va_list ap,
UErrorCode *status)
{
//check arguments
- if(status==NULL||U_FAILURE(*status))
+ if(status==nullptr||U_FAILURE(*status))
{
return;
}
- if(fmt==NULL||source==NULL || sourceLength<-1 || count==NULL){
+ if(fmt==nullptr||source==nullptr || sourceLength<-1 || count==nullptr){
*status=U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@@ -528,7 +528,7 @@ umsg_vparse(const UMessageFormat *fmt,
Formattable *args = ((const MessageFormat*)fmt)->parse(srcString,*count,*status);
UDate *aDate;
double *aDouble;
- UChar *aString;
+ char16_t *aString;
int32_t* aInt;
int64_t* aInt64;
UnicodeString temp;
@@ -574,7 +574,7 @@ umsg_vparse(const UMessageFormat *fmt,
break;
case Formattable::kString:
- aString = va_arg(ap, UChar*);
+ aString = va_arg(ap, char16_t*);
if(aString){
args[i].getString(temp);
len = temp.length();
@@ -602,9 +602,9 @@ umsg_vparse(const UMessageFormat *fmt,
delete [] args;
}
-#define SINGLE_QUOTE ((UChar)0x0027)
-#define CURLY_BRACE_LEFT ((UChar)0x007B)
-#define CURLY_BRACE_RIGHT ((UChar)0x007D)
+#define SINGLE_QUOTE ((char16_t)0x0027)
+#define CURLY_BRACE_LEFT ((char16_t)0x007B)
+#define CURLY_BRACE_RIGHT ((char16_t)0x007D)
#define STATE_INITIAL 0
#define STATE_SINGLE_QUOTE 1
@@ -613,9 +613,9 @@ umsg_vparse(const UMessageFormat *fmt,
#define MAppend(c) if (len < destCapacity) dest[len++] = c; else len++
-int32_t umsg_autoQuoteApostrophe(const UChar* pattern,
+int32_t umsg_autoQuoteApostrophe(const char16_t* pattern,
int32_t patternLength,
- UChar* dest,
+ char16_t* dest,
int32_t destCapacity,
UErrorCode* ec)
{
@@ -623,11 +623,11 @@ int32_t umsg_autoQuoteApostrophe(const UChar* pattern,
int32_t braceCount = 0;
int32_t len = 0;
- if (ec == NULL || U_FAILURE(*ec)) {
+ if (ec == nullptr || U_FAILURE(*ec)) {
return -1;
}
- if (pattern == NULL || patternLength < -1 || (dest == NULL && destCapacity > 0)) {
+ if (pattern == nullptr || patternLength < -1 || (dest == nullptr && destCapacity > 0)) {
*ec = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
@@ -638,7 +638,7 @@ int32_t umsg_autoQuoteApostrophe(const UChar* pattern,
}
for (int i = 0; i < patternLength; ++i) {
- UChar c = pattern[i];
+ char16_t c = pattern[i];
switch (state) {
case STATE_INITIAL:
switch (c) {
diff --git a/contrib/libs/icu/i18n/unesctrn.cpp b/contrib/libs/icu/i18n/unesctrn.cpp
index 0636fe1d14..cce191ca62 100644
--- a/contrib/libs/icu/i18n/unesctrn.cpp
+++ b/contrib/libs/icu/i18n/unesctrn.cpp
@@ -26,47 +26,47 @@ U_NAMESPACE_BEGIN
/**
* Special character marking the end of the spec[] array.
*/
-static const UChar END = 0xFFFF;
+static const char16_t END = 0xFFFF;
// Unicode: "U+10FFFF" hex, min=4, max=6
-static const UChar SPEC_Unicode[] = {
+static const char16_t SPEC_Unicode[] = {
2, 0, 16, 4, 6, 85/*U*/, 43/*+*/,
END
};
// Java: "\\uFFFF" hex, min=4, max=4
-static const UChar SPEC_Java[] = {
+static const char16_t SPEC_Java[] = {
2, 0, 16, 4, 4, 92/*\*/, 117/*u*/,
END
};
// C: "\\uFFFF" hex, min=4, max=4; \\U0010FFFF hex, min=8, max=8
-static const UChar SPEC_C[] = {
+static const char16_t SPEC_C[] = {
2, 0, 16, 4, 4, 92/*\*/, 117/*u*/,
2, 0, 16, 8, 8, 92/*\*/, 85/*U*/,
END
};
// XML: "&#x10FFFF;" hex, min=1, max=6
-static const UChar SPEC_XML[] = {
+static const char16_t SPEC_XML[] = {
3, 1, 16, 1, 6, 38/*&*/, 35/*#*/, 120/*x*/, 59/*;*/,
END
};
// XML10: "&#1114111;" dec, min=1, max=7 (not really "Hex-Any")
-static const UChar SPEC_XML10[] = {
+static const char16_t SPEC_XML10[] = {
2, 1, 10, 1, 7, 38/*&*/, 35/*#*/, 59/*;*/,
END
};
// Perl: "\\x{263A}" hex, min=1, max=6
-static const UChar SPEC_Perl[] = {
+static const char16_t SPEC_Perl[] = {
3, 1, 16, 1, 6, 92/*\*/, 120/*x*/, 123/*{*/, 125/*}*/,
END
};
// All: Java, C, Perl, XML, XML10, Unicode
-static const UChar SPEC_Any[] = {
+static const char16_t SPEC_Any[] = {
2, 0, 16, 4, 6, 85/*U*/, 43/*+*/, // Unicode
2, 0, 16, 4, 4, 92/*\*/, 117/*u*/, // Java
2, 0, 16, 8, 8, 92/*\*/, 85/*U*/, // C (surrogates)
@@ -78,15 +78,15 @@ static const UChar SPEC_Any[] = {
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(UnescapeTransliterator)
-static UChar* copySpec(const UChar* spec) {
+static char16_t* copySpec(const char16_t* spec) {
int32_t len = 0;
while (spec[len] != END) {
++len;
}
++len;
- UChar *result = (UChar *)uprv_malloc(len*sizeof(UChar));
+ char16_t *result = (char16_t *)uprv_malloc(len*sizeof(char16_t));
// Check for memory allocation error.
- if (result != NULL) {
+ if (result != nullptr) {
uprv_memcpy(result, spec, (size_t)len*sizeof(result[0]));
}
return result;
@@ -143,8 +143,8 @@ void UnescapeTransliterator::registerIDs() {
* Constructor. Takes the encoded spec array.
*/
UnescapeTransliterator::UnescapeTransliterator(const UnicodeString& newID,
- const UChar *newSpec) :
- Transliterator(newID, NULL)
+ const char16_t *newSpec) :
+ Transliterator(newID, nullptr)
{
this->spec = copySpec(newSpec);
}
@@ -175,13 +175,13 @@ void UnescapeTransliterator::handleTransliterate(Replaceable& text, UTransPositi
UBool isIncremental) const {
int32_t start = pos.start;
int32_t limit = pos.limit;
- int32_t i, j, ipat;
+ int32_t i, ipat;
while (start < limit) {
// Loop over the forms in spec[]. Exit this loop when we
// match one of the specs. Exit the outer loop if a
// partial match is detected and isIncremental is true.
- for (j=0, ipat=0; spec[ipat] != END; ++j) {
+ for (ipat=0; spec[ipat] != END;) {
// Read the header
int32_t prefixLen = spec[ipat++];
@@ -193,7 +193,7 @@ void UnescapeTransliterator::handleTransliterate(Replaceable& text, UTransPositi
// s is a copy of start that is advanced over the
// characters as we parse them.
int32_t s = start;
- UBool match = TRUE;
+ UBool match = true;
for (i=0; i<prefixLen; ++i) {
if (s >= limit) {
@@ -205,13 +205,13 @@ void UnescapeTransliterator::handleTransliterate(Replaceable& text, UTransPositi
if (isIncremental) {
goto exit;
}
- match = FALSE;
+ match = false;
break;
}
}
- UChar c = text.charAt(s++);
+ char16_t c = text.charAt(s++);
if (c != spec[ipat + i]) {
- match = FALSE;
+ match = false;
break;
}
}
@@ -248,12 +248,12 @@ void UnescapeTransliterator::handleTransliterate(Replaceable& text, UTransPositi
if (s > start && isIncremental) {
goto exit;
}
- match = FALSE;
+ match = false;
break;
}
- UChar c = text.charAt(s++);
+ char16_t c = text.charAt(s++);
if (c != spec[ipat + prefixLen + i]) {
- match = FALSE;
+ match = false;
break;
}
}
diff --git a/contrib/libs/icu/i18n/unesctrn.h b/contrib/libs/icu/i18n/unesctrn.h
index e905c5bc5f..3bea278082 100644
--- a/contrib/libs/icu/i18n/unesctrn.h
+++ b/contrib/libs/icu/i18n/unesctrn.h
@@ -46,7 +46,7 @@ class UnescapeTransliterator : public Transliterator {
* and suffix. The end is marked by a header of length one
* consisting of the character END.
*/
- UChar* spec; // owned; may not be NULL
+ char16_t* spec; // owned; may not be nullptr
public:
@@ -62,7 +62,7 @@ class UnescapeTransliterator : public Transliterator {
* @param spec the encoded spec array
*/
UnescapeTransliterator(const UnicodeString& ID,
- const UChar *spec);
+ const char16_t *spec);
/**
* Copy constructor.
diff --git a/contrib/libs/icu/i18n/uni2name.cpp b/contrib/libs/icu/i18n/uni2name.cpp
index 904da0207b..727f8953db 100644
--- a/contrib/libs/icu/i18n/uni2name.cpp
+++ b/contrib/libs/icu/i18n/uni2name.cpp
@@ -26,8 +26,8 @@ U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(UnicodeNameTransliterator)
-static const UChar OPEN_DELIM[] = {92,78,123,0}; // "\N{"
-static const UChar CLOSE_DELIM = 125; // "}"
+static const char16_t OPEN_DELIM[] = {92,78,123,0}; // "\N{"
+static const char16_t CLOSE_DELIM = 125; // "}"
#define OPEN_DELIM_LEN 3
/**
@@ -73,7 +73,7 @@ void UnicodeNameTransliterator::handleTransliterate(Replaceable& text, UTransPos
UBool /*isIncremental*/) const {
// The failure mode, here and below, is to behave like Any-Null,
// if either there is no name data (max len == 0) or there is no
- // memory (malloc() => NULL).
+ // memory (malloc() => nullptr).
int32_t maxLen = uprv_getMaxCharNameLength();
if (maxLen == 0) {
@@ -83,7 +83,7 @@ void UnicodeNameTransliterator::handleTransliterate(Replaceable& text, UTransPos
// Accommodate the longest possible name plus padding
char* buf = (char*) uprv_malloc(maxLen);
- if (buf == NULL) {
+ if (buf == nullptr) {
offsets.start = offsets.limit;
return;
}
@@ -91,7 +91,7 @@ void UnicodeNameTransliterator::handleTransliterate(Replaceable& text, UTransPos
int32_t cursor = offsets.start;
int32_t limit = offsets.limit;
- UnicodeString str(FALSE, OPEN_DELIM, OPEN_DELIM_LEN);
+ UnicodeString str(false, OPEN_DELIM, OPEN_DELIM_LEN);
UErrorCode status;
int32_t len;
diff --git a/contrib/libs/icu/i18n/units_complexconverter.cpp b/contrib/libs/icu/i18n/units_complexconverter.cpp
index 78cefbf7eb..edbb6573ff 100644
--- a/contrib/libs/icu/i18n/units_complexconverter.cpp
+++ b/contrib/libs/icu/i18n/units_complexconverter.cpp
@@ -143,7 +143,7 @@ MaybeStackVector<Measure> ComplexUnitsConverter::convert(double quantity,
// TODO: return an error for "foot-and-foot"?
MaybeStackVector<Measure> result;
int sign = 1;
- if (quantity < 0) {
+ if (quantity < 0 && unitsConverters_.length() > 1) {
quantity *= -1;
sign = -1;
}
@@ -164,12 +164,14 @@ MaybeStackVector<Measure> ComplexUnitsConverter::convert(double quantity,
if (i < n - 1) {
// If quantity is at the limits of double's precision from an
// integer value, we take that integer value.
- int64_t flooredQuantity = static_cast<int64_t>(floor(quantity * (1 + DBL_EPSILON)));
+ int64_t flooredQuantity;
if (uprv_isNaN(quantity)) {
// With clang on Linux: floor does not support NaN, resulting in
// a giant negative number. For now, we produce "0 feet, NaN
// inches". TODO(icu-units#131): revisit desired output.
flooredQuantity = 0;
+ } else {
+ flooredQuantity = static_cast<int64_t>(floor(quantity * (1 + DBL_EPSILON)));
}
intValues[i] = flooredQuantity;
@@ -183,7 +185,7 @@ MaybeStackVector<Measure> ComplexUnitsConverter::convert(double quantity,
} else {
quantity = remainder;
}
- }
+ }
}
applyRounder(intValues, quantity, rounder, status);
@@ -210,7 +212,6 @@ MaybeStackVector<Measure> ComplexUnitsConverter::convert(double quantity,
}
}
-
// Transfer values into result and return:
for(int32_t i = 0, n = unitsConverters_.length(); i < n; ++i) {
U_ASSERT(tmpResult[i] != nullptr);
@@ -224,6 +225,12 @@ MaybeStackVector<Measure> ComplexUnitsConverter::convert(double quantity,
void ComplexUnitsConverter::applyRounder(MaybeStackArray<int64_t, 5> &intValues, double &quantity,
icu::number::impl::RoundingImpl *rounder,
UErrorCode &status) const {
+ if (uprv_isInfinite(quantity) || uprv_isNaN(quantity)) {
+ // Inf and NaN can't be rounded, and calculating `carry` below is known
+ // to fail on Gentoo on HPPA and OpenSUSE on riscv64. Nothing to do.
+ return;
+ }
+
if (rounder == nullptr) {
// Nothing to do for the quantity.
return;
diff --git a/contrib/libs/icu/i18n/units_complexconverter.h b/contrib/libs/icu/i18n/units_complexconverter.h
index 5c669b45dd..d56ce8d4ce 100644
--- a/contrib/libs/icu/i18n/units_complexconverter.h
+++ b/contrib/libs/icu/i18n/units_complexconverter.h
@@ -108,13 +108,15 @@ class U_I18N_API ComplexUnitsConverter : public UMemory {
MaybeStackVector<Measure>
convert(double quantity, icu::number::impl::RoundingImpl *rounder, UErrorCode &status) const;
- private:
+ // TODO(ICU-21937): Make it private after submitting the public units conversion API.
MaybeStackVector<UnitsConverter> unitsConverters_;
+ // TODO(ICU-21937): Make it private after submitting the public units conversion API.
// Individual units of mixed units, sorted big to small, with indices
// indicating the requested output mixed unit order.
MaybeStackVector<MeasureUnitImplWithIndex> units_;
+ private:
// Sorts units_, which must be populated before calling this, and populates
// unitsConverters_.
void init(const MeasureUnitImpl &inputUnit, const ConversionRates &ratesInfo, UErrorCode &status);
diff --git a/contrib/libs/icu/i18n/units_converter.cpp b/contrib/libs/icu/i18n/units_converter.cpp
index 7e946e584b..b89f495121 100644
--- a/contrib/libs/icu/i18n/units_converter.cpp
+++ b/contrib/libs/icu/i18n/units_converter.cpp
@@ -9,6 +9,7 @@
#include "cmemory.h"
#include "double-conversion-string-to-double.h"
#include "measunit_impl.h"
+#include "putilimp.h"
#include "uassert.h"
#include "unicode/errorcode.h"
#include "unicode/localpointer.h"
@@ -388,8 +389,14 @@ void U_I18N_API addSingleFactorConstant(StringPiece baseStr, int32_t power, Sign
factor.constantExponents[CONSTANT_GLUCOSE_MOLAR_MASS] += power * signum;
} else if (baseStr == "item_per_mole") {
factor.constantExponents[CONSTANT_ITEM_PER_MOLE] += power * signum;
+ } else if (baseStr == "meters_per_AU") {
+ factor.constantExponents[CONSTANT_METERS_PER_AU] += power * signum;
} else if (baseStr == "PI") {
factor.constantExponents[CONSTANT_PI] += power * signum;
+ } else if (baseStr == "sec_per_julian_year") {
+ factor.constantExponents[CONSTANT_SEC_PER_JULIAN_YEAR] += power * signum;
+ } else if (baseStr == "speed_of_light_meters_per_second") {
+ factor.constantExponents[CONSTANT_SPEED_OF_LIGHT_METERS_PER_SECOND] += power * signum;
} else {
if (signum == Signum::NEGATIVE) {
factor.factorDen *= std::pow(strToDouble(baseStr, status), power);
@@ -588,10 +595,7 @@ double UnitsConverter::convert(double inputValue) const {
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;
+ return uprv_getInfinity();
}
result = 1.0 / result;
}
@@ -603,10 +607,7 @@ double UnitsConverter::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;
+ return uprv_getInfinity();
}
result = 1.0 / result;
}
diff --git a/contrib/libs/icu/i18n/units_converter.h b/contrib/libs/icu/i18n/units_converter.h
index 5c002f4147..fd1d6ec422 100644
--- a/contrib/libs/icu/i18n/units_converter.h
+++ b/contrib/libs/icu/i18n/units_converter.h
@@ -30,6 +30,9 @@ enum Constants {
CONSTANT_LB2KG, // Pound to Kilogram
CONSTANT_GLUCOSE_MOLAR_MASS,
CONSTANT_ITEM_PER_MOLE,
+ CONSTANT_METERS_PER_AU,
+ CONSTANT_SEC_PER_JULIAN_YEAR,
+ CONSTANT_SPEED_OF_LIGHT_METERS_PER_SECOND,
// Must be the last element.
CONSTANTS_COUNT
@@ -49,6 +52,9 @@ static const double constantsValues[CONSTANTS_COUNT] = {
0.45359237, // CONSTANT_LB2KG
180.1557, // CONSTANT_GLUCOSE_MOLAR_MASS
6.02214076E+23, // CONSTANT_ITEM_PER_MOLE
+ 149597870700, // CONSTANT_METERS_PER_AU
+ 31557600, // CONSTANT_SEC_PER_JULIAN_YEAR
+ 299792458, // CONSTANT_SPEED_OF_LIGHT_METERS_PER_SECOND
};
typedef enum Signum {
diff --git a/contrib/libs/icu/i18n/units_data.cpp b/contrib/libs/icu/i18n/units_data.cpp
index d1d1fc5bc0..801ede8837 100644
--- a/contrib/libs/icu/i18n/units_data.cpp
+++ b/contrib/libs/icu/i18n/units_data.cpp
@@ -5,10 +5,12 @@
#if !UCONFIG_NO_FORMATTING
+#include "bytesinkutil.h"
#include "cstring.h"
#include "number_decimalquantity.h"
#include "resource.h"
#include "uassert.h"
+#include "unicode/locid.h"
#include "unicode/unistr.h"
#include "unicode/ures.h"
#include "units_data.h"
@@ -203,11 +205,11 @@ class UnitPreferencesSink : public ResourceSink {
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);
+ const char16_t *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);
+ const char16_t *g = value.getString(length, status);
CharString geq;
geq.appendInvariantChars(g, length, status);
DecimalQuantity dq;
@@ -366,7 +368,7 @@ int32_t UnitPreferenceMetadata::compareTo(const UnitPreferenceMetadata &other, b
// 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));
+ LocalUResourceBundlePointer unitsBundle(ures_openDirect(nullptr, "units", &status));
ConversionRateDataSink sink(&result);
ures_getAllItemsWithFallback(unitsBundle.getAlias(), "convertUnits", sink, status);
}
@@ -382,29 +384,107 @@ const ConversionRateInfo *ConversionRates::extractConversionInfo(StringPiece sou
}
U_I18N_API UnitPreferences::UnitPreferences(UErrorCode &status) {
- LocalUResourceBundlePointer unitsBundle(ures_openDirect(NULL, "units", &status));
+ LocalUResourceBundlePointer unitsBundle(ures_openDirect(nullptr, "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);
+CharString getKeyWordValue(const Locale &locale, StringPiece kw, UErrorCode &status) {
+ CharString result;
+ if (U_FAILURE(status)) { return result; }
+ {
+ CharStringByteSink sink(&result);
+ locale.getKeywordValue(kw, sink, status);
+ }
+ if (U_SUCCESS(status) && result.isEmpty()) {
+ status = U_MISSING_RESOURCE_ERROR;
+ }
+ return result;
+}
+
+MaybeStackVector<UnitPreference>
+ U_I18N_API UnitPreferences::getPreferencesFor(StringPiece category, StringPiece usage,
+ const Locale &locale, UErrorCode &status) const {
+
+ MaybeStackVector<UnitPreference> result;
+
+ // TODO: remove this once all the categories are allowed.
+ // WARNING: when this is removed please make sure to keep the "fahrenhe" => "fahrenheit" mapping
+ UErrorCode internalMuStatus = U_ZERO_ERROR;
+ if (category.compare("temperature") == 0) {
+ CharString localeUnitCharString = getKeyWordValue(locale, "mu", internalMuStatus);
+ if (U_SUCCESS(internalMuStatus)) {
+ // The value for -u-mu- is `fahrenhe`, but CLDR and everything else uses `fahrenheit`
+ if (localeUnitCharString == "fahrenhe") {
+ localeUnitCharString = CharString("fahrenheit", status);
+ }
+ // TODO: use the unit category as Java especially when all the categories are allowed..
+ if (localeUnitCharString == "celsius"
+ || localeUnitCharString == "fahrenheit"
+ || localeUnitCharString == "kelvin"
+ ) {
+ UnitPreference unitPref;
+ unitPref.unit.append(localeUnitCharString, status);
+ result.emplaceBackAndCheckErrorCode(status, unitPref);
+ return result;
+ }
+ }
+ }
+
+ CharString region(locale.getCountry(), status);
+
+ // Check the locale system tag, e.g `ms=metric`.
+ UErrorCode internalMeasureTagStatus = U_ZERO_ERROR;
+ CharString localeSystem = getKeyWordValue(locale, "measure", internalMeasureTagStatus);
+ bool isLocaleSystem = false;
+ if (U_SUCCESS(internalMeasureTagStatus)) {
+ if (localeSystem == "metric") {
+ region.clear();
+ region.append("001", status);
+ isLocaleSystem = true;
+ } else if (localeSystem == "ussystem") {
+ region.clear();
+ region.append("US", status);
+ isLocaleSystem = true;
+ } else if (localeSystem == "uksystem") {
+ region.clear();
+ region.append("GB", status);
+ isLocaleSystem = true;
+ }
+ }
+
+ // Check the region tag, e.g. `rg=uszzz`.
+ if (!isLocaleSystem) {
+ UErrorCode internalRgTagStatus = U_ZERO_ERROR;
+ CharString localeRegion = getKeyWordValue(locale, "rg", internalRgTagStatus);
+ if (U_SUCCESS(internalRgTagStatus) && localeRegion.length() >= 3) {
+ if (localeRegion == "default") {
+ region.clear();
+ region.append(localeRegion, status);
+ } else if (localeRegion[0] >= '0' && localeRegion[0] <= '9') {
+ region.clear();
+ region.append(localeRegion.data(), 3, status);
+ } else {
+ // Take the first two character and capitalize them.
+ region.clear();
+ region.append(uprv_toupper(localeRegion[0]), status);
+ region.append(uprv_toupper(localeRegion[1]), status);
+ }
+ }
+ }
+
+ int32_t idx =
+ getPreferenceMetadataIndex(&metadata_, category, usage, region.toStringPiece(), status);
if (U_FAILURE(status)) {
- outPreferences = nullptr;
- preferenceCount = 0;
- return;
+ return result;
}
+
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;
+ for (int32_t i = 0; i < m->prefsCount; i++) {
+ result.emplaceBackAndCheckErrorCode(status, *(unitPrefs_[i + m->prefsOffset]));
+ }
+ return result;
}
} // namespace units
diff --git a/contrib/libs/icu/i18n/units_data.h b/contrib/libs/icu/i18n/units_data.h
index 2c19b9434b..118458ecca 100644
--- a/contrib/libs/icu/i18n/units_data.h
+++ b/contrib/libs/icu/i18n/units_data.h
@@ -99,6 +99,13 @@ struct U_I18N_API UnitPreference : public UMemory {
CharString unit;
double geq;
UnicodeString skeleton;
+
+ UnitPreference(const UnitPreference &other) {
+ UErrorCode status = U_ZERO_ERROR;
+ this->unit.append(other.unit, status);
+ this->geq = other.geq;
+ this->skeleton = other.skeleton;
+ }
};
/**
@@ -189,12 +196,11 @@ class U_I18N_API UnitPreferences {
* @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;
+ MaybeStackVector<UnitPreference> getPreferencesFor(StringPiece category, StringPiece usage,
+ const Locale &locale,
+
+ UErrorCode &status) const;
protected:
// Metadata about the sets of preferences, this is the index for looking up
diff --git a/contrib/libs/icu/i18n/units_router.cpp b/contrib/libs/icu/i18n/units_router.cpp
index 0e6082fae5..03c9b4d1d7 100644
--- a/contrib/libs/icu/i18n/units_router.cpp
+++ b/contrib/libs/icu/i18n/units_router.cpp
@@ -43,17 +43,17 @@ Precision UnitsRouter::parseSkeletonToPrecision(icu::UnicodeString precisionSkel
return result;
}
-UnitsRouter::UnitsRouter(StringPiece inputUnitIdentifier, StringPiece region, StringPiece usage,
+UnitsRouter::UnitsRouter(StringPiece inputUnitIdentifier, const Locale &locale, StringPiece usage,
UErrorCode &status) {
- this->init(MeasureUnit::forIdentifier(inputUnitIdentifier, status), region, usage, status);
+ this->init(MeasureUnit::forIdentifier(inputUnitIdentifier, status), locale, usage, status);
}
-UnitsRouter::UnitsRouter(const MeasureUnit &inputUnit, StringPiece region, StringPiece usage,
+UnitsRouter::UnitsRouter(const MeasureUnit &inputUnit, const Locale &locale, StringPiece usage,
UErrorCode &status) {
- this->init(std::move(inputUnit), region, usage, status);
+ this->init(std::move(inputUnit), locale, usage, status);
}
-void UnitsRouter::init(const MeasureUnit &inputUnit, StringPiece region, StringPiece usage,
+void UnitsRouter::init(const MeasureUnit &inputUnit, const Locale &locale, StringPiece usage,
UErrorCode &status) {
if (U_FAILURE(status)) {
@@ -73,22 +73,19 @@ void UnitsRouter::init(const MeasureUnit &inputUnit, StringPiece region, StringP
return;
}
- const UnitPreference *const *unitPreferences;
- int32_t preferencesCount = 0;
- prefs.getPreferencesFor(category.toStringPiece(), usage, region, unitPreferences, preferencesCount,
- status);
-
- for (int i = 0; i < preferencesCount; ++i) {
- U_ASSERT(unitPreferences[i] != nullptr);
- const auto &preference = *unitPreferences[i];
+ const MaybeStackVector<UnitPreference> unitPrefs =
+ prefs.getPreferencesFor(category.toStringPiece(), usage, locale, status);
+ for (int32_t i = 0, n = unitPrefs.length(); i < n; ++i) {
+ U_ASSERT(unitPrefs[i] != nullptr);
+ const auto preference = unitPrefs[i];
MeasureUnitImpl complexTargetUnitImpl =
- MeasureUnitImpl::forIdentifier(preference.unit.data(), status);
+ MeasureUnitImpl::forIdentifier(preference->unit.data(), status);
if (U_FAILURE(status)) {
return;
}
- UnicodeString precision = preference.skeleton;
+ 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
@@ -103,7 +100,7 @@ void UnitsRouter::init(const MeasureUnit &inputUnit, StringPiece region, StringP
outputUnits_.emplaceBackAndCheckErrorCode(status,
complexTargetUnitImpl.copy(status).build(status));
converterPreferences_.emplaceBackAndCheckErrorCode(status, inputUnitImpl, complexTargetUnitImpl,
- preference.geq, std::move(precision),
+ preference->geq, std::move(precision),
conversionRates, status);
if (U_FAILURE(status)) {
diff --git a/contrib/libs/icu/i18n/units_router.h b/contrib/libs/icu/i18n/units_router.h
index b3300f7e27..978fdf91fd 100644
--- a/contrib/libs/icu/i18n/units_router.h
+++ b/contrib/libs/icu/i18n/units_router.h
@@ -11,6 +11,7 @@
#include "cmemory.h"
#include "measunit_impl.h"
+#include "unicode/locid.h"
#include "unicode/measunit.h"
#include "unicode/stringpiece.h"
#include "unicode/uobject.h"
@@ -30,8 +31,6 @@ 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
@@ -120,9 +119,10 @@ namespace units {
*/
class U_I18N_API UnitsRouter {
public:
- UnitsRouter(StringPiece inputUnitIdentifier, StringPiece locale, StringPiece usage,
+ UnitsRouter(StringPiece inputUnitIdentifier, const Locale &locale, StringPiece usage,
+ UErrorCode &status);
+ UnitsRouter(const MeasureUnit &inputUnit, const Locale &locale, StringPiece usage,
UErrorCode &status);
- UnitsRouter(const MeasureUnit &inputUnit, StringPiece locale, StringPiece usage, UErrorCode &status);
/**
* Performs locale and usage sensitive unit conversion.
@@ -155,7 +155,7 @@ class U_I18N_API UnitsRouter {
static number::Precision parseSkeletonToPrecision(icu::UnicodeString precisionSkeleton,
UErrorCode &status);
- void init(const MeasureUnit &inputUnit, StringPiece locale, StringPiece usage, UErrorCode &status);
+ void init(const MeasureUnit &inputUnit, const Locale &locale, StringPiece usage, UErrorCode &status);
};
} // namespace units
diff --git a/contrib/libs/icu/i18n/unum.cpp b/contrib/libs/icu/i18n/unum.cpp
index 7043f7adc1..11a7bcba57 100644
--- a/contrib/libs/icu/i18n/unum.cpp
+++ b/contrib/libs/icu/i18n/unum.cpp
@@ -39,16 +39,16 @@ U_NAMESPACE_USE
U_CAPI UNumberFormat* U_EXPORT2
unum_open( UNumberFormatStyle style,
- const UChar* pattern,
+ const char16_t* pattern,
int32_t patternLength,
const char* locale,
UParseError* parseErr,
UErrorCode* status) {
if(U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
- NumberFormat *retVal = NULL;
+ NumberFormat *retVal = nullptr;
switch(style) {
case UNUM_DECIMAL:
@@ -68,22 +68,22 @@ unum_open( UNumberFormatStyle style,
/* UnicodeString can handle the case when patternLength = -1. */
const UnicodeString pat(pattern, patternLength);
- if(parseErr==NULL){
+ if(parseErr==nullptr){
parseErr = &tErr;
}
DecimalFormatSymbols *syms = new DecimalFormatSymbols(Locale(locale), *status);
- if(syms == NULL) {
+ if(syms == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
if (U_FAILURE(*status)) {
delete syms;
- return NULL;
+ return nullptr;
}
retVal = new DecimalFormat(pat, syms, *parseErr, *status);
- if(retVal == NULL) {
+ if(retVal == nullptr) {
delete syms;
}
} break;
@@ -94,7 +94,7 @@ unum_open( UNumberFormatStyle style,
/* UnicodeString can handle the case when patternLength = -1. */
const UnicodeString pat(pattern, patternLength);
- if(parseErr==NULL){
+ if(parseErr==nullptr){
parseErr = &tErr;
}
@@ -113,9 +113,20 @@ unum_open( UNumberFormatStyle style,
retVal = new RuleBasedNumberFormat(URBNF_DURATION, Locale(locale), *status);
break;
- case UNUM_NUMBERING_SYSTEM:
- retVal = new RuleBasedNumberFormat(URBNF_NUMBERING_SYSTEM, Locale(locale), *status);
- break;
+ case UNUM_NUMBERING_SYSTEM: {
+ // if the locale ID specifies a numbering system, go through NumberFormat::createInstance()
+ // to handle it properly (we have to specify UNUM_DEFAULT to get it to handle the numbering
+ // system, but we'll always get a RuleBasedNumberFormat back); otherwise, just go ahead and
+ // create a RuleBasedNumberFormat ourselves
+ UErrorCode localErr = U_ZERO_ERROR;
+ Locale localeObj(locale);
+ int32_t keywordLength = localeObj.getKeywordValue("numbers", nullptr, 0, localErr);
+ if (keywordLength > 0) {
+ retVal = NumberFormat::createInstance(localeObj, UNUM_DEFAULT, *status);
+ } else {
+ retVal = new RuleBasedNumberFormat(URBNF_NUMBERING_SYSTEM, localeObj, *status);
+ }
+ } break;
#endif
case UNUM_DECIMAL_COMPACT_SHORT:
@@ -128,16 +139,16 @@ unum_open( UNumberFormatStyle style,
default:
*status = U_UNSUPPORTED_ERROR;
- return NULL;
+ return nullptr;
}
- if(retVal == NULL && U_SUCCESS(*status)) {
+ if(retVal == nullptr && U_SUCCESS(*status)) {
*status = U_MEMORY_ALLOCATION_ERROR;
}
- if (U_FAILURE(*status) && retVal != NULL) {
+ if (U_FAILURE(*status) && retVal != nullptr) {
delete retVal;
- retVal = NULL;
+ retVal = nullptr;
}
return reinterpret_cast<UNumberFormat *>(retVal);
@@ -159,11 +170,11 @@ unum_clone(const UNumberFormat *fmt,
Format *res = 0;
const NumberFormat* nf = reinterpret_cast<const NumberFormat*>(fmt);
const DecimalFormat* df = dynamic_cast<const DecimalFormat*>(nf);
- if (df != NULL) {
+ if (df != nullptr) {
res = df->clone();
} else {
const RuleBasedNumberFormat* rbnf = dynamic_cast<const RuleBasedNumberFormat*>(nf);
- U_ASSERT(rbnf != NULL);
+ U_ASSERT(rbnf != nullptr);
res = rbnf->clone();
}
@@ -178,7 +189,7 @@ unum_clone(const UNumberFormat *fmt,
U_CAPI int32_t U_EXPORT2
unum_format( const UNumberFormat* fmt,
int32_t number,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPosition *pos,
UErrorCode* status)
@@ -189,7 +200,7 @@ unum_format( const UNumberFormat* fmt,
U_CAPI int32_t U_EXPORT2
unum_formatInt64(const UNumberFormat* fmt,
int64_t number,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPosition *pos,
UErrorCode* status)
@@ -198,8 +209,8 @@ unum_formatInt64(const UNumberFormat* fmt,
return -1;
UnicodeString res;
- if(!(result==NULL && resultLength==0)) {
- // NULL destination for pure preflighting: empty dummy string
+ if(!(result==nullptr && resultLength==0)) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
res.setTo(result, 0, resultLength);
}
@@ -222,7 +233,7 @@ unum_formatInt64(const UNumberFormat* fmt,
U_CAPI int32_t U_EXPORT2
unum_formatDouble( const UNumberFormat* fmt,
double number,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPosition *pos, /* 0 if ignore */
UErrorCode* status)
@@ -231,8 +242,8 @@ unum_formatDouble( const UNumberFormat* fmt,
if(U_FAILURE(*status)) return -1;
UnicodeString res;
- if(!(result==NULL && resultLength==0)) {
- // NULL destination for pure preflighting: empty dummy string
+ if(!(result==nullptr && resultLength==0)) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
res.setTo(result, 0, resultLength);
}
@@ -255,7 +266,7 @@ unum_formatDouble( const UNumberFormat* fmt,
U_CAPI int32_t U_EXPORT2
unum_formatDoubleForFields(const UNumberFormat* format,
double number,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPositionIterator* fpositer,
UErrorCode* status)
@@ -263,14 +274,14 @@ unum_formatDoubleForFields(const UNumberFormat* format,
if (U_FAILURE(*status))
return -1;
- if (result == NULL ? resultLength != 0 : resultLength < 0) {
+ if (result == nullptr ? resultLength != 0 : resultLength < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
UnicodeString res;
- if (result != NULL) {
- // NULL destination for pure preflighting: empty dummy string
+ if (result != nullptr) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
res.setTo(result, 0, resultLength);
}
@@ -284,7 +295,7 @@ U_CAPI int32_t U_EXPORT2
unum_formatDecimal(const UNumberFormat* fmt,
const char * number,
int32_t length,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UFieldPosition *pos, /* 0 if ignore */
UErrorCode* status) {
@@ -292,7 +303,7 @@ unum_formatDecimal(const UNumberFormat* fmt,
if(U_FAILURE(*status)) {
return -1;
}
- if ((result == NULL && resultLength != 0) || resultLength < 0) {
+ if ((result == nullptr && resultLength != 0) || resultLength < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
@@ -327,16 +338,16 @@ unum_formatDecimal(const UNumberFormat* fmt,
U_CAPI int32_t U_EXPORT2
unum_formatDoubleCurrency(const UNumberFormat* fmt,
double number,
- UChar* currency,
- UChar* result,
+ char16_t* currency,
+ char16_t* result,
int32_t resultLength,
UFieldPosition* pos, /* ignored if 0 */
UErrorCode* status) {
if (U_FAILURE(*status)) return -1;
UnicodeString res;
- if (!(result==NULL && resultLength==0)) {
- // NULL destination for pure preflighting: empty dummy string
+ if (!(result==nullptr && resultLength==0)) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
res.setTo(result, 0, resultLength);
}
@@ -347,7 +358,7 @@ unum_formatDoubleCurrency(const UNumberFormat* fmt,
}
CurrencyAmount *tempCurrAmnt = new CurrencyAmount(number, currency, *status);
// Check for null pointer.
- if (tempCurrAmnt == NULL) {
+ if (tempCurrAmnt == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
return -1;
}
@@ -365,7 +376,7 @@ unum_formatDoubleCurrency(const UNumberFormat* fmt,
static void
parseRes(Formattable& res,
const UNumberFormat* fmt,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t *parsePos /* 0 = start */,
UErrorCode *status)
@@ -393,7 +404,7 @@ parseRes(Formattable& res,
U_CAPI int32_t U_EXPORT2
unum_parse( const UNumberFormat* fmt,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t *parsePos /* 0 = start */,
UErrorCode *status)
@@ -405,7 +416,7 @@ unum_parse( const UNumberFormat* fmt,
U_CAPI int64_t U_EXPORT2
unum_parseInt64( const UNumberFormat* fmt,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t *parsePos /* 0 = start */,
UErrorCode *status)
@@ -417,7 +428,7 @@ unum_parseInt64( const UNumberFormat* fmt,
U_CAPI double U_EXPORT2
unum_parseDouble( const UNumberFormat* fmt,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t *parsePos /* 0 = start */,
UErrorCode *status)
@@ -429,7 +440,7 @@ unum_parseDouble( const UNumberFormat* fmt,
U_CAPI int32_t U_EXPORT2
unum_parseDecimal(const UNumberFormat* fmt,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t *parsePos /* 0 = start */,
char *outBuf,
@@ -439,7 +450,7 @@ unum_parseDecimal(const UNumberFormat* fmt,
if (U_FAILURE(*status)) {
return -1;
}
- if ((outBuf == NULL && outBufLength != 0) || outBufLength < 0) {
+ if ((outBuf == nullptr && outBufLength != 0) || outBufLength < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
@@ -462,10 +473,10 @@ unum_parseDecimal(const UNumberFormat* fmt,
U_CAPI double U_EXPORT2
unum_parseDoubleCurrency(const UNumberFormat* fmt,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t* parsePos, /* 0 = start */
- UChar* currency,
+ char16_t* currency,
UErrorCode* status) {
double doubleVal = 0.0;
currency[0] = 0;
@@ -474,17 +485,17 @@ unum_parseDoubleCurrency(const UNumberFormat* fmt,
}
const UnicodeString src((UBool)(textLength == -1), text, textLength);
ParsePosition pp;
- if (parsePos != NULL) {
+ if (parsePos != nullptr) {
pp.setIndex(*parsePos);
}
*status = U_PARSE_ERROR; // assume failure, reset if succeed
LocalPointer<CurrencyAmount> currAmt(((const NumberFormat*)fmt)->parseCurrency(src, pp));
if (pp.getErrorIndex() != -1) {
- if (parsePos != NULL) {
+ if (parsePos != nullptr) {
*parsePos = pp.getErrorIndex();
}
} else {
- if (parsePos != NULL) {
+ if (parsePos != nullptr) {
*parsePos = pp.getIndex();
}
if (pp.getIndex() > 0) {
@@ -508,6 +519,28 @@ unum_countAvailable()
return uloc_countAvailable();
}
+U_CAPI bool U_EXPORT2
+unum_hasAttribute(const UNumberFormat* fmt,
+ UNumberFormatAttribute attr)
+{
+ const NumberFormat* nf = reinterpret_cast<const NumberFormat*>(fmt);
+ bool isDecimalFormat = dynamic_cast<const DecimalFormat*>(nf) != nullptr;
+
+ switch (attr) {
+ case UNUM_LENIENT_PARSE:
+ case UNUM_MAX_INTEGER_DIGITS:
+ case UNUM_MIN_INTEGER_DIGITS:
+ case UNUM_INTEGER_DIGITS:
+ case UNUM_MAX_FRACTION_DIGITS:
+ case UNUM_MIN_FRACTION_DIGITS:
+ case UNUM_FRACTION_DIGITS:
+ case UNUM_ROUNDING_MODE:
+ return true;
+ default:
+ return isDecimalFormat;
+ }
+}
+
U_CAPI int32_t U_EXPORT2
unum_getAttribute(const UNumberFormat* fmt,
UNumberFormatAttribute attr)
@@ -543,7 +576,7 @@ unum_getAttribute(const UNumberFormat* fmt,
// The remaining attributes are only supported for DecimalFormat
const DecimalFormat* df = dynamic_cast<const DecimalFormat*>(nf);
- if (df != NULL) {
+ if (df != nullptr) {
UErrorCode ignoredStatus = U_ZERO_ERROR;
return df->getAttribute(attr, ignoredStatus);
}
@@ -588,7 +621,7 @@ unum_setAttribute( UNumberFormat* fmt,
// The remaining attributes are only supported for DecimalFormat
DecimalFormat* df = dynamic_cast<DecimalFormat*>(nf);
- if (df != NULL) {
+ if (df != nullptr) {
UErrorCode ignoredStatus = U_ZERO_ERROR;
df->setAttribute(attr, newValue, ignoredStatus);
}
@@ -600,7 +633,7 @@ unum_getDoubleAttribute(const UNumberFormat* fmt,
{
const NumberFormat* nf = reinterpret_cast<const NumberFormat*>(fmt);
const DecimalFormat* df = dynamic_cast<const DecimalFormat*>(nf);
- if (df != NULL && attr == UNUM_ROUNDING_INCREMENT) {
+ if (df != nullptr && attr == UNUM_ROUNDING_INCREMENT) {
return df->getRoundingIncrement();
} else {
return -1.0;
@@ -614,7 +647,7 @@ unum_setDoubleAttribute( UNumberFormat* fmt,
{
NumberFormat* nf = reinterpret_cast<NumberFormat*>(fmt);
DecimalFormat* df = dynamic_cast<DecimalFormat*>(nf);
- if (df != NULL && attr == UNUM_ROUNDING_INCREMENT) {
+ if (df != nullptr && attr == UNUM_ROUNDING_INCREMENT) {
df->setRoundingIncrement(newValue);
}
}
@@ -622,7 +655,7 @@ unum_setDoubleAttribute( UNumberFormat* fmt,
U_CAPI int32_t U_EXPORT2
unum_getTextAttribute(const UNumberFormat* fmt,
UNumberFormatTextAttribute tag,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UErrorCode* status)
{
@@ -630,15 +663,15 @@ unum_getTextAttribute(const UNumberFormat* fmt,
return -1;
UnicodeString res;
- if(!(result==NULL && resultLength==0)) {
- // NULL destination for pure preflighting: empty dummy string
+ if(!(result==nullptr && resultLength==0)) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
res.setTo(result, 0, resultLength);
}
const NumberFormat* nf = reinterpret_cast<const NumberFormat*>(fmt);
const DecimalFormat* df = dynamic_cast<const DecimalFormat*>(nf);
- if (df != NULL) {
+ if (df != nullptr) {
switch(tag) {
case UNUM_POSITIVE_PREFIX:
df->getPositivePrefix(res);
@@ -670,14 +703,14 @@ unum_getTextAttribute(const UNumberFormat* fmt,
}
} else {
const RuleBasedNumberFormat* rbnf = dynamic_cast<const RuleBasedNumberFormat*>(nf);
- U_ASSERT(rbnf != NULL);
+ U_ASSERT(rbnf != nullptr);
if (tag == UNUM_DEFAULT_RULESET) {
res = rbnf->getDefaultRuleSetName();
} else if (tag == UNUM_PUBLIC_RULESETS) {
int32_t count = rbnf->getNumberOfRuleSetNames();
for (int i = 0; i < count; ++i) {
res += rbnf->getRuleSetName(i);
- res += (UChar)0x003b; // semicolon
+ res += (char16_t)0x003b; // semicolon
}
} else {
*status = U_UNSUPPORTED_ERROR;
@@ -691,7 +724,7 @@ unum_getTextAttribute(const UNumberFormat* fmt,
U_CAPI void U_EXPORT2
unum_setTextAttribute( UNumberFormat* fmt,
UNumberFormatTextAttribute tag,
- const UChar* newValue,
+ const char16_t* newValue,
int32_t newValueLength,
UErrorCode *status)
{
@@ -701,7 +734,7 @@ unum_setTextAttribute( UNumberFormat* fmt,
UnicodeString val(newValue, newValueLength);
NumberFormat* nf = reinterpret_cast<NumberFormat*>(fmt);
DecimalFormat* df = dynamic_cast<DecimalFormat*>(nf);
- if (df != NULL) {
+ if (df != nullptr) {
switch(tag) {
case UNUM_POSITIVE_PREFIX:
df->setPositivePrefix(val);
@@ -733,7 +766,7 @@ unum_setTextAttribute( UNumberFormat* fmt,
}
} else {
RuleBasedNumberFormat* rbnf = dynamic_cast<RuleBasedNumberFormat*>(nf);
- U_ASSERT(rbnf != NULL);
+ U_ASSERT(rbnf != nullptr);
if (tag == UNUM_DEFAULT_RULESET) {
rbnf->setDefaultRuleSet(val, *status);
} else {
@@ -745,7 +778,7 @@ unum_setTextAttribute( UNumberFormat* fmt,
U_CAPI int32_t U_EXPORT2
unum_toPattern( const UNumberFormat* fmt,
UBool isPatternLocalized,
- UChar* result,
+ char16_t* result,
int32_t resultLength,
UErrorCode* status)
{
@@ -753,22 +786,22 @@ unum_toPattern( const UNumberFormat* fmt,
return -1;
UnicodeString pat;
- if(!(result==NULL && resultLength==0)) {
- // NULL destination for pure preflighting: empty dummy string
+ if(!(result==nullptr && resultLength==0)) {
+ // nullptr destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
pat.setTo(result, 0, resultLength);
}
const NumberFormat* nf = reinterpret_cast<const NumberFormat*>(fmt);
const DecimalFormat* df = dynamic_cast<const DecimalFormat*>(nf);
- if (df != NULL) {
+ if (df != nullptr) {
if(isPatternLocalized)
df->toLocalizedPattern(pat);
else
df->toPattern(pat);
} else {
const RuleBasedNumberFormat* rbnf = dynamic_cast<const RuleBasedNumberFormat*>(nf);
- U_ASSERT(rbnf != NULL);
+ U_ASSERT(rbnf != nullptr);
pat = rbnf->getRules();
}
return pat.extract(result, resultLength, *status);
@@ -777,20 +810,19 @@ unum_toPattern( const UNumberFormat* fmt,
U_CAPI int32_t U_EXPORT2
unum_getSymbol(const UNumberFormat *fmt,
UNumberFormatSymbol symbol,
- UChar *buffer,
+ char16_t *buffer,
int32_t size,
- UErrorCode *status)
-{
- if(status==NULL || U_FAILURE(*status)) {
+ UErrorCode *status) UPRV_NO_SANITIZE_UNDEFINED {
+ if(status==nullptr || U_FAILURE(*status)) {
return 0;
}
- if(fmt==NULL || symbol< 0 || symbol>=UNUM_FORMAT_SYMBOL_COUNT) {
+ if(fmt==nullptr || symbol< 0 || symbol>=UNUM_FORMAT_SYMBOL_COUNT) {
*status=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
const NumberFormat *nf = reinterpret_cast<const NumberFormat *>(fmt);
const DecimalFormat *dcf = dynamic_cast<const DecimalFormat *>(nf);
- if (dcf == NULL) {
+ if (dcf == nullptr) {
*status = U_UNSUPPORTED_ERROR;
return 0;
}
@@ -804,20 +836,19 @@ unum_getSymbol(const UNumberFormat *fmt,
U_CAPI void U_EXPORT2
unum_setSymbol(UNumberFormat *fmt,
UNumberFormatSymbol symbol,
- const UChar *value,
+ const char16_t *value,
int32_t length,
- UErrorCode *status)
-{
- if(status==NULL || U_FAILURE(*status)) {
+ UErrorCode *status) UPRV_NO_SANITIZE_UNDEFINED {
+ if(status==nullptr || U_FAILURE(*status)) {
return;
}
- if(fmt==NULL || symbol< 0 || symbol>=UNUM_FORMAT_SYMBOL_COUNT || value==NULL || length<-1) {
+ if(fmt==nullptr || symbol< 0 || symbol>=UNUM_FORMAT_SYMBOL_COUNT || value==nullptr || length<-1) {
*status=U_ILLEGAL_ARGUMENT_ERROR;
return;
}
NumberFormat *nf = reinterpret_cast<NumberFormat *>(fmt);
DecimalFormat *dcf = dynamic_cast<DecimalFormat *>(nf);
- if (dcf == NULL) {
+ if (dcf == nullptr) {
*status = U_UNSUPPORTED_ERROR;
return;
}
@@ -831,7 +862,7 @@ unum_setSymbol(UNumberFormat *fmt,
U_CAPI void U_EXPORT2
unum_applyPattern( UNumberFormat *fmt,
UBool localized,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternLength,
UParseError *parseError,
UErrorCode* status)
@@ -839,21 +870,21 @@ unum_applyPattern( UNumberFormat *fmt,
UErrorCode tStatus = U_ZERO_ERROR;
UParseError tParseError;
- if(parseError == NULL){
+ if(parseError == nullptr){
parseError = &tParseError;
}
- if(status==NULL){
+ if(status==nullptr){
status = &tStatus;
}
int32_t len = (patternLength == -1 ? u_strlen(pattern) : patternLength);
- const UnicodeString pat((UChar*)pattern, len, len);
+ const UnicodeString pat((char16_t*)pattern, len, len);
// Verify if the object passed is a DecimalFormat object
NumberFormat* nf = reinterpret_cast<NumberFormat*>(fmt);
DecimalFormat* df = dynamic_cast<DecimalFormat*>(nf);
- if (df != NULL) {
+ if (df != nullptr) {
if(localized) {
df->applyLocalizedPattern(pat,*parseError, *status);
} else {
@@ -870,11 +901,11 @@ unum_getLocaleByType(const UNumberFormat *fmt,
ULocDataLocaleType type,
UErrorCode* status)
{
- if (fmt == NULL) {
+ if (fmt == nullptr) {
if (U_SUCCESS(*status)) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
}
- return NULL;
+ return nullptr;
}
return ((const Format*)fmt)->getLocaleID(type, *status);
}
@@ -901,23 +932,23 @@ unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode*
U_CAPI UFormattable * U_EXPORT2
unum_parseToUFormattable(const UNumberFormat* fmt,
UFormattable *result,
- const UChar* text,
+ const char16_t* text,
int32_t textLength,
int32_t* parsePos, /* 0 = start */
UErrorCode* status) {
- UFormattable *newFormattable = NULL;
+ UFormattable *newFormattable = nullptr;
if (U_FAILURE(*status)) return result;
- if (fmt == NULL || (text==NULL && textLength!=0)) {
+ if (fmt == nullptr || (text==nullptr && textLength!=0)) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return result;
}
- if (result == NULL) { // allocate if not allocated.
+ if (result == nullptr) { // allocate if not allocated.
newFormattable = result = ufmt_open(status);
}
parseRes(*(Formattable::fromUFormattable(result)), fmt, text, textLength, parsePos, status);
- if (U_FAILURE(*status) && newFormattable != NULL) {
+ if (U_FAILURE(*status) && newFormattable != nullptr) {
ufmt_close(newFormattable);
- result = NULL; // deallocate if there was a parse error
+ result = nullptr; // deallocate if there was a parse error
}
return result;
}
@@ -925,15 +956,15 @@ unum_parseToUFormattable(const UNumberFormat* fmt,
U_CAPI int32_t U_EXPORT2
unum_formatUFormattable(const UNumberFormat* fmt,
const UFormattable *number,
- UChar *result,
+ char16_t *result,
int32_t resultLength,
UFieldPosition *pos, /* ignored if 0 */
UErrorCode *status) {
if (U_FAILURE(*status)) {
return 0;
}
- if (fmt == NULL || number==NULL ||
- (result==NULL ? resultLength!=0 : resultLength<0)) {
+ if (fmt == nullptr || number==nullptr ||
+ (result==nullptr ? resultLength!=0 : resultLength<0)) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
diff --git a/contrib/libs/icu/i18n/unumsys.cpp b/contrib/libs/icu/i18n/unumsys.cpp
index 4a0d0fa3b6..9a9fa12e2f 100644
--- a/contrib/libs/icu/i18n/unumsys.cpp
+++ b/contrib/libs/icu/i18n/unumsys.cpp
@@ -31,7 +31,7 @@ unumsys_openByName(const char *name, UErrorCode *status)
{
// createInstanceByName does NOT return immediately if status indicates error
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
return (UNumberingSystem*)NumberingSystem::createInstanceByName(name, *status);
}
@@ -73,7 +73,7 @@ unumsys_isAlgorithmic(const UNumberingSystem *unumsys)
}
U_CAPI int32_t U_EXPORT2
-unumsys_getDescription(const UNumberingSystem *unumsys, UChar *result,
+unumsys_getDescription(const UNumberingSystem *unumsys, char16_t *result,
int32_t resultLength, UErrorCode *status)
{
if (U_FAILURE(*status)) {
diff --git a/contrib/libs/icu/i18n/upluralrules.cpp b/contrib/libs/icu/i18n/upluralrules.cpp
index 73e59a75c4..9c47312811 100644
--- a/contrib/libs/icu/i18n/upluralrules.cpp
+++ b/contrib/libs/icu/i18n/upluralrules.cpp
@@ -41,7 +41,7 @@ namespace {
UnicodeString select(const PluralRules &rules, const Formattable& obj, const NumberFormat& fmt, UErrorCode& status) {
if (U_SUCCESS(status)) {
const DecimalFormat *decFmt = dynamic_cast<const DecimalFormat *>(&fmt);
- if (decFmt != NULL) {
+ if (decFmt != nullptr) {
number::impl::DecimalQuantity dq;
decFmt->formatToDecimalQuantity(obj, dq, status);
if (U_SUCCESS(status)) {
@@ -80,13 +80,13 @@ uplrules_close(UPluralRules *uplrules)
U_CAPI int32_t U_EXPORT2
uplrules_select(const UPluralRules *uplrules,
double number,
- UChar *keyword, int32_t capacity,
+ char16_t *keyword, int32_t capacity,
UErrorCode *status)
{
if (U_FAILURE(*status)) {
return 0;
}
- if (keyword == NULL ? capacity != 0 : capacity < 0) {
+ if (keyword == nullptr ? capacity != 0 : capacity < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -97,13 +97,13 @@ uplrules_select(const UPluralRules *uplrules,
U_CAPI int32_t U_EXPORT2
uplrules_selectFormatted(const UPluralRules *uplrules,
const UFormattedNumber* number,
- UChar *keyword, int32_t capacity,
+ char16_t *keyword, int32_t capacity,
UErrorCode *status)
{
if (U_FAILURE(*status)) {
return 0;
}
- if (keyword == NULL ? capacity != 0 : capacity < 0) {
+ if (keyword == nullptr ? capacity != 0 : capacity < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -119,13 +119,13 @@ uplrules_selectFormatted(const UPluralRules *uplrules,
U_CAPI int32_t U_EXPORT2
uplrules_selectForRange(const UPluralRules *uplrules,
const UFormattedNumberRange* urange,
- UChar *keyword, int32_t capacity,
+ char16_t *keyword, int32_t capacity,
UErrorCode *status)
{
if (U_FAILURE(*status)) {
return 0;
}
- if (keyword == NULL ? capacity != 0 : capacity < 0) {
+ if (keyword == nullptr ? capacity != 0 : capacity < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -139,7 +139,7 @@ U_CAPI int32_t U_EXPORT2
uplrules_selectWithFormat(const UPluralRules *uplrules,
double number,
const UNumberFormat *fmt,
- UChar *keyword, int32_t capacity,
+ char16_t *keyword, int32_t capacity,
UErrorCode *status)
{
if (U_FAILURE(*status)) {
@@ -147,7 +147,7 @@ uplrules_selectWithFormat(const UPluralRules *uplrules,
}
const PluralRules* plrules = reinterpret_cast<const PluralRules*>(uplrules);
const NumberFormat* nf = reinterpret_cast<const NumberFormat*>(fmt);
- if (plrules == NULL || nf == NULL || ((keyword == NULL)? capacity != 0 : capacity < 0)) {
+ if (plrules == nullptr || nf == nullptr || ((keyword == nullptr)? capacity != 0 : capacity < 0)) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -161,20 +161,20 @@ uplrules_getKeywords(const UPluralRules *uplrules,
UErrorCode *status)
{
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
const PluralRules* plrules = reinterpret_cast<const PluralRules*>(uplrules);
- if (plrules == NULL) {
+ if (plrules == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
StringEnumeration *senum = plrules->getKeywords(*status);
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
- if (senum == NULL) {
+ if (senum == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
return uenum_openFromStringEnumeration(senum, status);
}
diff --git a/contrib/libs/icu/i18n/uregex.cpp b/contrib/libs/icu/i18n/uregex.cpp
index 514159e8b7..2a520209fa 100644
--- a/contrib/libs/icu/i18n/uregex.cpp
+++ b/contrib/libs/icu/i18n/uregex.cpp
@@ -38,10 +38,10 @@ public:
int32_t fMagic;
RegexPattern *fPat;
u_atomic_int32_t *fPatRefCount;
- UChar *fPatString;
+ char16_t *fPatString;
int32_t fPatStringLen;
RegexMatcher *fMatcher;
- const UChar *fText; // Text from setText()
+ const char16_t *fText; // Text from setText()
int32_t fTextLength; // Length provided by user with setText(), which
// may be -1.
UBool fOwnsText;
@@ -51,25 +51,25 @@ static const int32_t REXP_MAGIC = 0x72657870; // "rexp" in ASCII
RegularExpression::RegularExpression() {
fMagic = REXP_MAGIC;
- fPat = NULL;
- fPatRefCount = NULL;
- fPatString = NULL;
+ fPat = nullptr;
+ fPatRefCount = nullptr;
+ fPatString = nullptr;
fPatStringLen = 0;
- fMatcher = NULL;
- fText = NULL;
+ fMatcher = nullptr;
+ fText = nullptr;
fTextLength = 0;
- fOwnsText = FALSE;
+ fOwnsText = false;
}
RegularExpression::~RegularExpression() {
delete fMatcher;
- fMatcher = NULL;
- if (fPatRefCount!=NULL && umtx_atomic_dec(fPatRefCount)==0) {
+ fMatcher = nullptr;
+ if (fPatRefCount!=nullptr && umtx_atomic_dec(fPatRefCount)==0) {
delete fPat;
uprv_free(fPatString);
uprv_free((void *)fPatRefCount);
}
- if (fOwnsText && fText!=NULL) {
+ if (fOwnsText && fText!=nullptr) {
uprv_free((void *)fText);
}
fMagic = 0;
@@ -82,22 +82,22 @@ U_NAMESPACE_USE
//----------------------------------------------------------------------------------------
//
// validateRE Do boilerplate style checks on API function parameters.
-// Return TRUE if they look OK.
+// Return true if they look OK.
//----------------------------------------------------------------------------------------
static UBool validateRE(const RegularExpression *re, UBool requiresText, UErrorCode *status) {
if (U_FAILURE(*status)) {
- return FALSE;
+ return false;
}
- if (re == NULL || re->fMagic != REXP_MAGIC) {
+ if (re == nullptr || re->fMagic != REXP_MAGIC) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return FALSE;
+ return false;
}
// !!! Not sure how to update this with the new UText backing, which is stored in re->fMatcher anyway
- if (requiresText && re->fText == NULL && !re->fOwnsText) {
+ if (requiresText && re->fText == nullptr && !re->fOwnsText) {
*status = U_REGEX_INVALID_STATE;
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
//----------------------------------------------------------------------------------------
@@ -106,18 +106,18 @@ static UBool validateRE(const RegularExpression *re, UBool requiresText, UErrorC
//
//----------------------------------------------------------------------------------------
U_CAPI URegularExpression * U_EXPORT2
-uregex_open( const UChar *pattern,
+uregex_open( const char16_t *pattern,
int32_t patternLength,
uint32_t flags,
UParseError *pe,
UErrorCode *status) {
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
- if (pattern == NULL || patternLength < -1 || patternLength == 0) {
+ if (pattern == nullptr || patternLength < -1 || patternLength == 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
int32_t actualPatLen = patternLength;
if (actualPatLen == -1) {
@@ -126,13 +126,13 @@ uregex_open( const UChar *pattern,
RegularExpression *re = new RegularExpression;
u_atomic_int32_t *refC = (u_atomic_int32_t *)uprv_malloc(sizeof(int32_t));
- UChar *patBuf = (UChar *)uprv_malloc(sizeof(UChar)*(actualPatLen+1));
- if (re == NULL || refC == NULL || patBuf == NULL) {
+ char16_t *patBuf = (char16_t *)uprv_malloc(sizeof(char16_t)*(actualPatLen+1));
+ if (re == nullptr || refC == nullptr || patBuf == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
delete re;
uprv_free((void *)refC);
uprv_free(patBuf);
- return NULL;
+ return nullptr;
}
re->fPatRefCount = refC;
*re->fPatRefCount = 1;
@@ -153,7 +153,7 @@ uregex_open( const UChar *pattern,
//
// Compile the pattern
//
- if (pe != NULL) {
+ if (pe != nullptr) {
re->fPat = RegexPattern::compile(&patText, flags, *pe, *status);
} else {
re->fPat = RegexPattern::compile(&patText, flags, *status);
@@ -174,7 +174,7 @@ uregex_open( const UChar *pattern,
ErrorExit:
delete re;
- return NULL;
+ return nullptr;
}
@@ -190,33 +190,33 @@ uregex_openUText(UText *pattern,
UErrorCode *status) {
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
- if (pattern == NULL) {
+ if (pattern == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
int64_t patternNativeLength = utext_nativeLength(pattern);
if (patternNativeLength == 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
RegularExpression *re = new RegularExpression;
UErrorCode lengthStatus = U_ZERO_ERROR;
- int32_t pattern16Length = utext_extract(pattern, 0, patternNativeLength, NULL, 0, &lengthStatus);
+ int32_t pattern16Length = utext_extract(pattern, 0, patternNativeLength, nullptr, 0, &lengthStatus);
u_atomic_int32_t *refC = (u_atomic_int32_t *)uprv_malloc(sizeof(int32_t));
- UChar *patBuf = (UChar *)uprv_malloc(sizeof(UChar)*(pattern16Length+1));
- if (re == NULL || refC == NULL || patBuf == NULL) {
+ char16_t *patBuf = (char16_t *)uprv_malloc(sizeof(char16_t)*(pattern16Length+1));
+ if (re == nullptr || refC == nullptr || patBuf == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
delete re;
uprv_free((void *)refC);
uprv_free(patBuf);
- return NULL;
+ return nullptr;
}
re->fPatRefCount = refC;
*re->fPatRefCount = 1;
@@ -236,7 +236,7 @@ uregex_openUText(UText *pattern,
//
// Compile the pattern
//
- if (pe != NULL) {
+ if (pe != nullptr) {
re->fPat = RegexPattern::compile(&patText, flags, *pe, *status);
} else {
re->fPat = RegexPattern::compile(&patText, flags, *status);
@@ -257,7 +257,7 @@ uregex_openUText(UText *pattern,
ErrorExit:
delete re;
- return NULL;
+ return nullptr;
}
@@ -270,7 +270,7 @@ U_CAPI void U_EXPORT2
uregex_close(URegularExpression *re2) {
RegularExpression *re = (RegularExpression*)re2;
UErrorCode status = U_ZERO_ERROR;
- if (validateRE(re, FALSE, &status) == FALSE) {
+ if (validateRE(re, false, &status) == false) {
return;
}
delete re;
@@ -285,20 +285,20 @@ uregex_close(URegularExpression *re2) {
U_CAPI URegularExpression * U_EXPORT2
uregex_clone(const URegularExpression *source2, UErrorCode *status) {
RegularExpression *source = (RegularExpression*)source2;
- if (validateRE(source, FALSE, status) == FALSE) {
- return NULL;
+ if (validateRE(source, false, status) == false) {
+ return nullptr;
}
RegularExpression *clone = new RegularExpression;
- if (clone == NULL) {
+ if (clone == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
clone->fMatcher = source->fPat->matcher(*status);
if (U_FAILURE(*status)) {
delete clone;
- return NULL;
+ return nullptr;
}
clone->fPat = source->fPat;
@@ -319,16 +319,16 @@ uregex_clone(const URegularExpression *source2, UErrorCode *status) {
// uregex_pattern
//
//------------------------------------------------------------------------------
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
uregex_pattern(const URegularExpression *regexp2,
int32_t *patLength,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status) == FALSE) {
- return NULL;
+ if (validateRE(regexp, false, status) == false) {
+ return nullptr;
}
- if (patLength != NULL) {
+ if (patLength != nullptr) {
*patLength = regexp->fPatStringLen;
}
return regexp->fPatString;
@@ -356,7 +356,7 @@ uregex_patternUText(const URegularExpression *regexp2,
U_CAPI int32_t U_EXPORT2
uregex_flags(const URegularExpression *regexp2, UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status) == FALSE) {
+ if (validateRE(regexp, false, status) == false) {
return 0;
}
int32_t flags = regexp->fPat->flags();
@@ -371,25 +371,25 @@ uregex_flags(const URegularExpression *regexp2, UErrorCode *status) {
//------------------------------------------------------------------------------
U_CAPI void U_EXPORT2
uregex_setText(URegularExpression *regexp2,
- const UChar *text,
+ const char16_t *text,
int32_t textLength,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status) == FALSE) {
+ if (validateRE(regexp, false, status) == false) {
return;
}
- if (text == NULL || textLength < -1) {
+ if (text == nullptr || textLength < -1) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
- if (regexp->fOwnsText && regexp->fText != NULL) {
+ if (regexp->fOwnsText && regexp->fText != nullptr) {
uprv_free((void *)regexp->fText);
}
regexp->fText = text;
regexp->fTextLength = textLength;
- regexp->fOwnsText = FALSE;
+ regexp->fOwnsText = false;
UText input = UTEXT_INITIALIZER;
utext_openUChars(&input, text, textLength, status);
@@ -408,21 +408,21 @@ uregex_setUText(URegularExpression *regexp2,
UText *text,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status) == FALSE) {
+ if (validateRE(regexp, false, status) == false) {
return;
}
- if (text == NULL) {
+ if (text == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
- if (regexp->fOwnsText && regexp->fText != NULL) {
+ if (regexp->fOwnsText && regexp->fText != nullptr) {
uprv_free((void *)regexp->fText);
}
- regexp->fText = NULL; // only fill it in on request
+ regexp->fText = nullptr; // only fill it in on request
regexp->fTextLength = -1;
- regexp->fOwnsText = TRUE;
+ regexp->fOwnsText = true;
regexp->fMatcher->reset(text);
}
@@ -433,35 +433,35 @@ uregex_setUText(URegularExpression *regexp2,
// uregex_getText
//
//------------------------------------------------------------------------------
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
uregex_getText(URegularExpression *regexp2,
int32_t *textLength,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status) == FALSE) {
- return NULL;
+ if (validateRE(regexp, false, status) == false) {
+ return nullptr;
}
- if (regexp->fText == NULL) {
+ if (regexp->fText == nullptr) {
// need to fill in the text
UText *inputText = regexp->fMatcher->inputText();
int64_t inputNativeLength = utext_nativeLength(inputText);
if (UTEXT_FULL_TEXT_IN_CHUNK(inputText, inputNativeLength)) {
regexp->fText = inputText->chunkContents;
regexp->fTextLength = (int32_t)inputNativeLength;
- regexp->fOwnsText = FALSE; // because the UText owns it
+ regexp->fOwnsText = false; // because the UText owns it
} else {
UErrorCode lengthStatus = U_ZERO_ERROR;
- regexp->fTextLength = utext_extract(inputText, 0, inputNativeLength, NULL, 0, &lengthStatus); // buffer overflow error
- UChar *inputChars = (UChar *)uprv_malloc(sizeof(UChar)*(regexp->fTextLength+1));
+ regexp->fTextLength = utext_extract(inputText, 0, inputNativeLength, nullptr, 0, &lengthStatus); // buffer overflow error
+ char16_t *inputChars = (char16_t *)uprv_malloc(sizeof(char16_t)*(regexp->fTextLength+1));
utext_extract(inputText, 0, inputNativeLength, inputChars, regexp->fTextLength+1, status);
regexp->fText = inputChars;
- regexp->fOwnsText = TRUE; // should already be set but just in case
+ regexp->fOwnsText = true; // should already be set but just in case
}
}
- if (textLength != NULL) {
+ if (textLength != nullptr) {
*textLength = regexp->fTextLength;
}
return regexp->fText;
@@ -478,7 +478,7 @@ uregex_getUText(URegularExpression *regexp2,
UText *dest,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status) == FALSE) {
+ if (validateRE(regexp, false, status) == false) {
return dest;
}
return regexp->fMatcher->getInput(dest, *status);
@@ -495,7 +495,7 @@ uregex_refreshUText(URegularExpression *regexp2,
UText *text,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status) == FALSE) {
+ if (validateRE(regexp, false, status) == false) {
return;
}
regexp->fMatcher->refreshInputText(text, *status);
@@ -519,8 +519,8 @@ uregex_matches64(URegularExpression *regexp2,
int64_t startIndex,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- UBool result = FALSE;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ UBool result = false;
+ if (validateRE(regexp, true, status) == false) {
return result;
}
if (startIndex == -1) {
@@ -549,8 +549,8 @@ uregex_lookingAt64(URegularExpression *regexp2,
int64_t startIndex,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- UBool result = FALSE;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ UBool result = false;
+ if (validateRE(regexp, true, status) == false) {
return result;
}
if (startIndex == -1) {
@@ -580,8 +580,8 @@ uregex_find64(URegularExpression *regexp2,
int64_t startIndex,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- UBool result = FALSE;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ UBool result = false;
+ if (validateRE(regexp, true, status) == false) {
return result;
}
if (startIndex == -1) {
@@ -603,8 +603,8 @@ U_CAPI UBool U_EXPORT2
uregex_findNext(URegularExpression *regexp2,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
- return FALSE;
+ if (validateRE(regexp, true, status) == false) {
+ return false;
}
UBool result = regexp->fMatcher->find(*status);
return result;
@@ -619,7 +619,7 @@ U_CAPI int32_t U_EXPORT2
uregex_groupCount(URegularExpression *regexp2,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status) == FALSE) {
+ if (validateRE(regexp, false, status) == false) {
return 0;
}
int32_t result = regexp->fMatcher->groupCount();
@@ -634,11 +634,11 @@ uregex_groupCount(URegularExpression *regexp2,
//------------------------------------------------------------------------------
int32_t
uregex_groupNumberFromName(URegularExpression *regexp2,
- const UChar *groupName,
+ const char16_t *groupName,
int32_t nameLength,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status) == FALSE) {
+ if (validateRE(regexp, false, status) == false) {
return 0;
}
int32_t result = regexp->fPat->groupNumberFromName(UnicodeString(groupName, nameLength), *status);
@@ -651,7 +651,7 @@ uregex_groupNumberFromCName(URegularExpression *regexp2,
int32_t nameLength,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status) == FALSE) {
+ if (validateRE(regexp, false, status) == false) {
return 0;
}
return regexp->fPat->groupNumberFromName(groupName, nameLength, *status);
@@ -665,19 +665,19 @@ uregex_groupNumberFromCName(URegularExpression *regexp2,
U_CAPI int32_t U_EXPORT2
uregex_group(URegularExpression *regexp2,
int32_t groupNum,
- UChar *dest,
+ char16_t *dest,
int32_t destCapacity,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return 0;
}
- if (destCapacity < 0 || (destCapacity > 0 && dest == NULL)) {
+ if (destCapacity < 0 || (destCapacity > 0 && dest == nullptr)) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
- if (destCapacity == 0 || regexp->fText != NULL) {
+ if (destCapacity == 0 || regexp->fText != nullptr) {
// If preflighting or if we already have the text as UChars,
// this is a little cheaper than extracting from the UText
@@ -739,9 +739,9 @@ uregex_groupUText(URegularExpression *regexp2,
int64_t *groupLength,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
UErrorCode emptyTextStatus = U_ZERO_ERROR;
- return (dest ? dest : utext_openUChars(NULL, NULL, 0, &emptyTextStatus));
+ return (dest ? dest : utext_openUChars(nullptr, nullptr, 0, &emptyTextStatus));
}
return regexp->fMatcher->group(groupNum, dest, *groupLength, *status);
@@ -764,7 +764,7 @@ uregex_start64(URegularExpression *regexp2,
int32_t groupNum,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return 0;
}
int64_t result = regexp->fMatcher->start64(groupNum, *status);
@@ -788,7 +788,7 @@ uregex_end64(URegularExpression *regexp2,
int32_t groupNum,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return 0;
}
int64_t result = regexp->fMatcher->end64(groupNum, *status);
@@ -812,7 +812,7 @@ uregex_reset64(URegularExpression *regexp2,
int64_t index,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return;
}
regexp->fMatcher->reset(index, *status);
@@ -838,7 +838,7 @@ uregex_setRegion64(URegularExpression *regexp2,
int64_t regionLimit,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return;
}
regexp->fMatcher->region(regionStart, regionLimit, *status);
@@ -857,7 +857,7 @@ uregex_setRegionAndStart(URegularExpression *regexp2,
int64_t startIndex,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return;
}
regexp->fMatcher->region(regionStart, regionLimit, startIndex, *status);
@@ -878,7 +878,7 @@ U_CAPI int64_t U_EXPORT2
uregex_regionStart64(const URegularExpression *regexp2,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return 0;
}
return regexp->fMatcher->regionStart();
@@ -900,7 +900,7 @@ U_CAPI int64_t U_EXPORT2
uregex_regionEnd64(const URegularExpression *regexp2,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return 0;
}
return regexp->fMatcher->regionEnd();
@@ -916,8 +916,8 @@ U_CAPI UBool U_EXPORT2
uregex_hasTransparentBounds(const URegularExpression *regexp2,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status) == FALSE) {
- return FALSE;
+ if (validateRE(regexp, false, status) == false) {
+ return false;
}
return regexp->fMatcher->hasTransparentBounds();
}
@@ -933,7 +933,7 @@ uregex_useTransparentBounds(URegularExpression *regexp2,
UBool b,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status) == FALSE) {
+ if (validateRE(regexp, false, status) == false) {
return;
}
regexp->fMatcher->useTransparentBounds(b);
@@ -949,8 +949,8 @@ U_CAPI UBool U_EXPORT2
uregex_hasAnchoringBounds(const URegularExpression *regexp2,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status) == FALSE) {
- return FALSE;
+ if (validateRE(regexp, false, status) == false) {
+ return false;
}
return regexp->fMatcher->hasAnchoringBounds();
}
@@ -966,7 +966,7 @@ uregex_useAnchoringBounds(URegularExpression *regexp2,
UBool b,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status) == FALSE) {
+ if (validateRE(regexp, false, status) == false) {
return;
}
regexp->fMatcher->useAnchoringBounds(b);
@@ -982,8 +982,8 @@ U_CAPI UBool U_EXPORT2
uregex_hitEnd(const URegularExpression *regexp2,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
- return FALSE;
+ if (validateRE(regexp, true, status) == false) {
+ return false;
}
return regexp->fMatcher->hitEnd();
}
@@ -998,8 +998,8 @@ U_CAPI UBool U_EXPORT2
uregex_requireEnd(const URegularExpression *regexp2,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
- return FALSE;
+ if (validateRE(regexp, true, status) == false) {
+ return false;
}
return regexp->fMatcher->requireEnd();
}
@@ -1015,7 +1015,7 @@ uregex_setTimeLimit(URegularExpression *regexp2,
int32_t limit,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status)) {
+ if (validateRE(regexp, false, status)) {
regexp->fMatcher->setTimeLimit(limit, *status);
}
}
@@ -1032,7 +1032,7 @@ uregex_getTimeLimit(const URegularExpression *regexp2,
UErrorCode *status) {
int32_t retVal = 0;
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status)) {
+ if (validateRE(regexp, false, status)) {
retVal = regexp->fMatcher->getTimeLimit();
}
return retVal;
@@ -1050,7 +1050,7 @@ uregex_setStackLimit(URegularExpression *regexp2,
int32_t limit,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status)) {
+ if (validateRE(regexp, false, status)) {
regexp->fMatcher->setStackLimit(limit, *status);
}
}
@@ -1067,7 +1067,7 @@ uregex_getStackLimit(const URegularExpression *regexp2,
UErrorCode *status) {
int32_t retVal = 0;
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status)) {
+ if (validateRE(regexp, false, status)) {
retVal = regexp->fMatcher->getStackLimit();
}
return retVal;
@@ -1085,7 +1085,7 @@ uregex_setMatchCallback(URegularExpression *regexp2,
const void *context,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status)) {
+ if (validateRE(regexp, false, status)) {
regexp->fMatcher->setMatchCallback(callback, context, *status);
}
}
@@ -1102,7 +1102,7 @@ uregex_getMatchCallback(const URegularExpression *regexp2,
const void **context,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status)) {
+ if (validateRE(regexp, false, status)) {
regexp->fMatcher->getMatchCallback(*callback, *context, *status);
}
}
@@ -1119,7 +1119,7 @@ uregex_setFindProgressCallback(URegularExpression *regexp2,
const void *context,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status)) {
+ if (validateRE(regexp, false, status)) {
regexp->fMatcher->setFindProgressCallback(callback, context, *status);
}
}
@@ -1136,7 +1136,7 @@ uregex_getFindProgressCallback(const URegularExpression *regexp2,
const void **context,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, FALSE, status)) {
+ if (validateRE(regexp, false, status)) {
regexp->fMatcher->getFindProgressCallback(*callback, *context, *status);
}
}
@@ -1149,17 +1149,17 @@ uregex_getFindProgressCallback(const URegularExpression *regexp2,
//------------------------------------------------------------------------------
U_CAPI int32_t U_EXPORT2
uregex_replaceAll(URegularExpression *regexp2,
- const UChar *replacementText,
+ const char16_t *replacementText,
int32_t replacementLength,
- UChar *destBuf,
+ char16_t *destBuf,
int32_t destCapacity,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return 0;
}
- if (replacementText == NULL || replacementLength < -1 ||
- (destBuf == NULL && destCapacity > 0) ||
+ if (replacementText == nullptr || replacementLength < -1 ||
+ (destBuf == nullptr && destCapacity > 0) ||
destCapacity < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
@@ -1203,10 +1203,10 @@ uregex_replaceAllUText(URegularExpression *regexp2,
UText *dest,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return 0;
}
- if (replacementText == NULL) {
+ if (replacementText == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -1223,17 +1223,17 @@ uregex_replaceAllUText(URegularExpression *regexp2,
//------------------------------------------------------------------------------
U_CAPI int32_t U_EXPORT2
uregex_replaceFirst(URegularExpression *regexp2,
- const UChar *replacementText,
+ const char16_t *replacementText,
int32_t replacementLength,
- UChar *destBuf,
+ char16_t *destBuf,
int32_t destCapacity,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return 0;
}
- if (replacementText == NULL || replacementLength < -1 ||
- (destBuf == NULL && destCapacity > 0) ||
+ if (replacementText == nullptr || replacementLength < -1 ||
+ (destBuf == nullptr && destCapacity > 0) ||
destCapacity < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
@@ -1264,10 +1264,10 @@ uregex_replaceFirstUText(URegularExpression *regexp2,
UText *dest,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return 0;
}
- if (replacementText == NULL) {
+ if (replacementText == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -1291,22 +1291,22 @@ U_NAMESPACE_BEGIN
class RegexCImpl {
public:
inline static int32_t appendReplacement(RegularExpression *regexp,
- const UChar *replacementText,
+ const char16_t *replacementText,
int32_t replacementLength,
- UChar **destBuf,
+ char16_t **destBuf,
int32_t *destCapacity,
UErrorCode *status);
inline static int32_t appendTail(RegularExpression *regexp,
- UChar **destBuf,
+ char16_t **destBuf,
int32_t *destCapacity,
UErrorCode *status);
inline static int32_t split(RegularExpression *regexp,
- UChar *destBuf,
+ char16_t *destBuf,
int32_t destCapacity,
int32_t *requiredCapacity,
- UChar *destFields[],
+ char16_t *destFields[],
int32_t destFieldsCapacity,
UErrorCode *status);
};
@@ -1315,17 +1315,17 @@ U_NAMESPACE_END
-static const UChar BACKSLASH = 0x5c;
-static const UChar DOLLARSIGN = 0x24;
-static const UChar LEFTBRACKET = 0x7b;
-static const UChar RIGHTBRACKET = 0x7d;
+static const char16_t BACKSLASH = 0x5c;
+static const char16_t DOLLARSIGN = 0x24;
+static const char16_t LEFTBRACKET = 0x7b;
+static const char16_t RIGHTBRACKET = 0x7d;
//
// Move a character to an output buffer, with bounds checking on the index.
// Index advances even if capacity is exceeded, for preflight size computations.
// This little sequence is used a LOT.
//
-static inline void appendToBuf(UChar c, int32_t *idx, UChar *buf, int32_t bufCapacity) {
+static inline void appendToBuf(char16_t c, int32_t *idx, char16_t *buf, int32_t bufCapacity) {
if (*idx < bufCapacity) {
buf[*idx] = c;
}
@@ -1337,42 +1337,42 @@ static inline void appendToBuf(UChar c, int32_t *idx, UChar *buf, int32_t bufCap
// appendReplacement, the actual implementation.
//
int32_t RegexCImpl::appendReplacement(RegularExpression *regexp,
- const UChar *replacementText,
+ const char16_t *replacementText,
int32_t replacementLength,
- UChar **destBuf,
+ char16_t **destBuf,
int32_t *destCapacity,
UErrorCode *status) {
// If we come in with a buffer overflow error, don't suppress the operation.
// A series of appendReplacements, appendTail need to correctly preflight
// the buffer size when an overflow happens somewhere in the middle.
- UBool pendingBufferOverflow = FALSE;
- if (*status == U_BUFFER_OVERFLOW_ERROR && destCapacity != NULL && *destCapacity == 0) {
- pendingBufferOverflow = TRUE;
+ UBool pendingBufferOverflow = false;
+ if (*status == U_BUFFER_OVERFLOW_ERROR && destCapacity != nullptr && *destCapacity == 0) {
+ pendingBufferOverflow = true;
*status = U_ZERO_ERROR;
}
//
// Validate all parameters
//
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return 0;
}
- if (replacementText == NULL || replacementLength < -1 ||
- destCapacity == NULL || destBuf == NULL ||
- (*destBuf == NULL && *destCapacity > 0) ||
+ if (replacementText == nullptr || replacementLength < -1 ||
+ destCapacity == nullptr || destBuf == nullptr ||
+ (*destBuf == nullptr && *destCapacity > 0) ||
*destCapacity < 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
RegexMatcher *m = regexp->fMatcher;
- if (m->fMatch == FALSE) {
+ if (m->fMatch == false) {
*status = U_REGEX_INVALID_STATE;
return 0;
}
- UChar *dest = *destBuf;
+ char16_t *dest = *destBuf;
int32_t capacity = *destCapacity;
int32_t destIdx = 0;
int32_t i;
@@ -1385,7 +1385,7 @@ int32_t RegexCImpl::appendReplacement(RegularExpression *regexp,
}
// Copy input string from the end of previous match to start of current match
- if (regexp->fText != NULL) {
+ if (regexp->fText != nullptr) {
int32_t matchStart;
int32_t lastMatchEnd;
if (UTEXT_USES_U16(m->fInputText)) {
@@ -1394,9 +1394,9 @@ int32_t RegexCImpl::appendReplacement(RegularExpression *regexp,
} else {
// !!!: Would like a better way to do this!
UErrorCode tempStatus = U_ZERO_ERROR;
- lastMatchEnd = utext_extract(m->fInputText, 0, m->fLastMatchEnd, NULL, 0, &tempStatus);
+ lastMatchEnd = utext_extract(m->fInputText, 0, m->fLastMatchEnd, nullptr, 0, &tempStatus);
tempStatus = U_ZERO_ERROR;
- matchStart = lastMatchEnd + utext_extract(m->fInputText, m->fLastMatchEnd, m->fMatchStart, NULL, 0, &tempStatus);
+ matchStart = lastMatchEnd + utext_extract(m->fInputText, m->fLastMatchEnd, m->fMatchStart, nullptr, 0, &tempStatus);
}
for (i=lastMatchEnd; i<matchStart; i++) {
appendToBuf(regexp->fText[i], &destIdx, dest, capacity);
@@ -1404,7 +1404,7 @@ int32_t RegexCImpl::appendReplacement(RegularExpression *regexp,
} else {
UErrorCode possibleOverflowError = U_ZERO_ERROR; // ignore
destIdx += utext_extract(m->fInputText, m->fLastMatchEnd, m->fMatchStart,
- dest==NULL?NULL:&dest[destIdx], REMAINING_CAPACITY(destIdx, capacity),
+ dest==nullptr?nullptr:&dest[destIdx], REMAINING_CAPACITY(destIdx, capacity),
&possibleOverflowError);
}
U_ASSERT(destIdx >= 0);
@@ -1412,7 +1412,7 @@ int32_t RegexCImpl::appendReplacement(RegularExpression *regexp,
// scan the replacement text, looking for substitutions ($n) and \escapes.
int32_t replIdx = 0;
while (replIdx < replacementLength && U_SUCCESS(*status)) {
- UChar c = replacementText[replIdx];
+ char16_t c = replacementText[replIdx];
replIdx++;
if (c != DOLLARSIGN && c != BACKSLASH) {
// Common case, no substitution, no escaping,
@@ -1442,7 +1442,7 @@ int32_t RegexCImpl::appendReplacement(RegularExpression *regexp,
if (escapedChar != (UChar32)0xFFFFFFFF) {
if (escapedChar <= 0xffff) {
- appendToBuf((UChar)escapedChar, &destIdx, dest, capacity);
+ appendToBuf((char16_t)escapedChar, &destIdx, dest, capacity);
} else {
appendToBuf(U16_LEAD(escapedChar), &destIdx, dest, capacity);
appendToBuf(U16_TRAIL(escapedChar), &destIdx, dest, capacity);
@@ -1477,7 +1477,7 @@ int32_t RegexCImpl::appendReplacement(RegularExpression *regexp,
break;
}
U16_GET(replacementText, 0, replIdx, replacementLength, c32);
- if (u_isdigit(c32) == FALSE) {
+ if (u_isdigit(c32) == false) {
break;
}
@@ -1528,7 +1528,7 @@ int32_t RegexCImpl::appendReplacement(RegularExpression *regexp,
// Finally, append the capture group data to the destination.
if (U_SUCCESS(*status)) {
destIdx += uregex_group((URegularExpression*)regexp, groupNum,
- dest==NULL?NULL:&dest[destIdx], REMAINING_CAPACITY(destIdx, capacity), status);
+ dest==nullptr?nullptr:&dest[destIdx], REMAINING_CAPACITY(destIdx, capacity), status);
if (*status == U_BUFFER_OVERFLOW_ERROR) {
// Ignore buffer overflow when extracting the group. We need to
// continue on to get full size of the untruncated result. We will
@@ -1585,9 +1585,9 @@ int32_t RegexCImpl::appendReplacement(RegularExpression *regexp,
//
U_CAPI int32_t U_EXPORT2
uregex_appendReplacement(URegularExpression *regexp2,
- const UChar *replacementText,
+ const char16_t *replacementText,
int32_t replacementLength,
- UChar **destBuf,
+ char16_t **destBuf,
int32_t *destCapacity,
UErrorCode *status) {
@@ -1615,7 +1615,7 @@ uregex_appendReplacementUText(URegularExpression *regexp2,
//
//------------------------------------------------------------------------------
int32_t RegexCImpl::appendTail(RegularExpression *regexp,
- UChar **destBuf,
+ char16_t **destBuf,
int32_t *destCapacity,
UErrorCode *status)
{
@@ -1623,18 +1623,18 @@ int32_t RegexCImpl::appendTail(RegularExpression *regexp,
// If we come in with a buffer overflow error, don't suppress the operation.
// A series of appendReplacements, appendTail need to correctly preflight
// the buffer size when an overflow happens somewhere in the middle.
- UBool pendingBufferOverflow = FALSE;
- if (*status == U_BUFFER_OVERFLOW_ERROR && destCapacity != NULL && *destCapacity == 0) {
- pendingBufferOverflow = TRUE;
+ UBool pendingBufferOverflow = false;
+ if (*status == U_BUFFER_OVERFLOW_ERROR && destCapacity != nullptr && *destCapacity == 0) {
+ pendingBufferOverflow = true;
*status = U_ZERO_ERROR;
}
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return 0;
}
- if (destCapacity == NULL || destBuf == NULL ||
- (*destBuf == NULL && *destCapacity > 0) ||
+ if (destCapacity == nullptr || destBuf == nullptr ||
+ (*destBuf == nullptr && *destCapacity > 0) ||
*destCapacity < 0)
{
*status = U_ILLEGAL_ARGUMENT_ERROR;
@@ -1645,9 +1645,9 @@ int32_t RegexCImpl::appendTail(RegularExpression *regexp,
int32_t destIdx = 0;
int32_t destCap = *destCapacity;
- UChar *dest = *destBuf;
+ char16_t *dest = *destBuf;
- if (regexp->fText != NULL) {
+ if (regexp->fText != nullptr) {
int32_t srcIdx;
int64_t nativeIdx = (m->fMatch ? m->fMatchEnd : m->fLastMatchEnd);
if (nativeIdx == -1) {
@@ -1656,7 +1656,7 @@ int32_t RegexCImpl::appendTail(RegularExpression *regexp,
srcIdx = (int32_t)nativeIdx;
} else {
UErrorCode newStatus = U_ZERO_ERROR;
- srcIdx = utext_extract(m->fInputText, 0, nativeIdx, NULL, 0, &newStatus);
+ srcIdx = utext_extract(m->fInputText, 0, nativeIdx, nullptr, 0, &newStatus);
}
for (;;) {
@@ -1665,7 +1665,7 @@ int32_t RegexCImpl::appendTail(RegularExpression *regexp,
if (srcIdx == regexp->fTextLength) {
break;
}
- UChar c = regexp->fText[srcIdx];
+ char16_t c = regexp->fText[srcIdx];
if (c == 0 && regexp->fTextLength == -1) {
regexp->fTextLength = srcIdx;
break;
@@ -1723,7 +1723,7 @@ int32_t RegexCImpl::appendTail(RegularExpression *regexp,
if (destIdx < destCap) {
*destBuf += destIdx;
*destCapacity -= destIdx;
- } else if (*destBuf != NULL) {
+ } else if (*destBuf != nullptr) {
*destBuf += destCap;
*destCapacity = 0;
}
@@ -1741,7 +1741,7 @@ int32_t RegexCImpl::appendTail(RegularExpression *regexp,
//
U_CAPI int32_t U_EXPORT2
uregex_appendTail(URegularExpression *regexp2,
- UChar **destBuf,
+ char16_t **destBuf,
int32_t *destCapacity,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
@@ -1770,16 +1770,16 @@ uregex_appendTailUText(URegularExpression *regexp2,
//
//------------------------------------------------------------------------------
#if 0
-static void copyString(UChar *destBuffer, // Destination buffer.
+static void copyString(char16_t *destBuffer, // Destination buffer.
int32_t destCapacity, // Total capacity of dest buffer
int32_t *destIndex, // Index into dest buffer. Updated on return.
// Update not clipped to destCapacity.
- const UChar *srcPtr, // Pointer to source string
+ const char16_t *srcPtr, // Pointer to source string
int32_t srcLen) // Source string len.
{
int32_t si;
int32_t di = *destIndex;
- UChar c;
+ char16_t c;
for (si=0; si<srcLen; si++) {
c = srcPtr[si];
@@ -1805,10 +1805,10 @@ static void copyString(UChar *destBuffer, // Destination buffer.
//
//------------------------------------------------------------------------------
int32_t RegexCImpl::split(RegularExpression *regexp,
- UChar *destBuf,
+ char16_t *destBuf,
int32_t destCapacity,
int32_t *requiredCapacity,
- UChar *destFields[],
+ char16_t *destFields[],
int32_t destFieldsCapacity,
UErrorCode *status) {
//
@@ -1845,9 +1845,9 @@ int32_t RegexCImpl::split(RegularExpression *regexp,
destIdx = (int32_t)(destFields[i] - destFields[0]);
}
- destFields[i] = &destBuf[destIdx];
+ destFields[i] = (destBuf == nullptr) ? nullptr : &destBuf[destIdx];
destIdx += 1 + utext_extract(inputText, nextOutputStringStart, inputLen,
- &destBuf[destIdx], REMAINING_CAPACITY(destIdx, destCapacity), status);
+ destFields[i], REMAINING_CAPACITY(destIdx, destCapacity), status);
}
break;
}
@@ -1855,10 +1855,10 @@ int32_t RegexCImpl::split(RegularExpression *regexp,
if (regexp->fMatcher->find()) {
// We found another delimiter. Move everything from where we started looking
// up until the start of the delimiter into the next output string.
- destFields[i] = &destBuf[destIdx];
+ destFields[i] = (destBuf == nullptr) ? nullptr : &destBuf[destIdx];
destIdx += 1 + utext_extract(inputText, nextOutputStringStart, regexp->fMatcher->fMatchStart,
- &destBuf[destIdx], REMAINING_CAPACITY(destIdx, destCapacity), &tStatus);
+ destFields[i], REMAINING_CAPACITY(destIdx, destCapacity), &tStatus);
if (tStatus == U_BUFFER_OVERFLOW_ERROR) {
tStatus = U_ZERO_ERROR;
} else {
@@ -1914,9 +1914,9 @@ int32_t RegexCImpl::split(RegularExpression *regexp,
{
// We ran off the end of the input while looking for the next delimiter.
// All the remaining text goes into the current output string.
- destFields[i] = &destBuf[destIdx];
+ destFields[i] = (destBuf == nullptr) ? nullptr : &destBuf[destIdx];
destIdx += 1 + utext_extract(inputText, nextOutputStringStart, inputLen,
- &destBuf[destIdx], REMAINING_CAPACITY(destIdx, destCapacity), status);
+ destFields[i], REMAINING_CAPACITY(destIdx, destCapacity), status);
break;
}
}
@@ -1924,10 +1924,10 @@ int32_t RegexCImpl::split(RegularExpression *regexp,
// Zero out any unused portion of the destFields array
int j;
for (j=i+1; j<destFieldsCapacity; j++) {
- destFields[j] = NULL;
+ destFields[j] = nullptr;
}
- if (requiredCapacity != NULL) {
+ if (requiredCapacity != nullptr) {
*requiredCapacity = destIdx;
}
if (destIdx > destCapacity) {
@@ -1941,19 +1941,19 @@ int32_t RegexCImpl::split(RegularExpression *regexp,
//
U_CAPI int32_t U_EXPORT2
uregex_split(URegularExpression *regexp2,
- UChar *destBuf,
+ char16_t *destBuf,
int32_t destCapacity,
int32_t *requiredCapacity,
- UChar *destFields[],
+ char16_t *destFields[],
int32_t destFieldsCapacity,
UErrorCode *status) {
RegularExpression *regexp = (RegularExpression*)regexp2;
- if (validateRE(regexp, TRUE, status) == FALSE) {
+ if (validateRE(regexp, true, status) == false) {
return 0;
}
- if ((destBuf == NULL && destCapacity > 0) ||
+ if ((destBuf == nullptr && destCapacity > 0) ||
destCapacity < 0 ||
- destFields == NULL ||
+ destFields == nullptr ||
destFieldsCapacity < 1 ) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
diff --git a/contrib/libs/icu/i18n/uregexc.cpp b/contrib/libs/icu/i18n/uregexc.cpp
index c7d3bcd2c7..8bdac19114 100644
--- a/contrib/libs/icu/i18n/uregexc.cpp
+++ b/contrib/libs/icu/i18n/uregexc.cpp
@@ -29,11 +29,11 @@ uregex_openC( const char *pattern,
UParseError *pe,
UErrorCode *status) {
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
- if (pattern == NULL) {
+ if (pattern == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
UnicodeString patString(pattern);
diff --git a/contrib/libs/icu/i18n/usearch.cpp b/contrib/libs/icu/i18n/usearch.cpp
index 80b80fa3b4..6d9b60cef7 100644
--- a/contrib/libs/icu/i18n/usearch.cpp
+++ b/contrib/libs/icu/i18n/usearch.cpp
@@ -74,9 +74,9 @@ inline uint32_t getMask(UCollationStrength strength)
U_CDECL_BEGIN
static UBool U_CALLCONV
-usearch_cleanup(void) {
+usearch_cleanup() {
g_nfcImpl = nullptr;
- return TRUE;
+ return true;
}
U_CDECL_END
@@ -106,10 +106,10 @@ inline void initializeFCD(UErrorCode *status)
* @return fcd value
*/
static
-uint16_t getFCD(const UChar *str, int32_t *offset,
+uint16_t getFCD(const char16_t *str, int32_t *offset,
int32_t strlength)
{
- const UChar *temp = str + *offset;
+ const char16_t *temp = str + *offset;
uint16_t result = g_nfcImpl->nextFCD16(temp, str + strlength);
*offset = (int32_t)(temp - str);
return result;
@@ -403,7 +403,7 @@ inline void initializePattern(UStringSearch *strsrch, UErrorCode *status)
if (U_FAILURE(*status)) { return; }
UPattern *pattern = &(strsrch->pattern);
- const UChar *patterntext = pattern->text;
+ const char16_t *patterntext = pattern->text;
int32_t length = pattern->textLength;
int32_t index = 0;
@@ -502,7 +502,7 @@ inline void setMatchNotFound(UStringSearch *strsrch, UErrorCode &status)
* Checks if the offset runs out of the text string
* @param offset
* @param textlength of the text string
-* @return TRUE if offset is out of bounds, FALSE otherwise
+* @return true if offset is out of bounds, false otherwise
*/
static
inline UBool isOutOfBounds(int32_t textlength, int32_t offset)
@@ -515,13 +515,13 @@ inline UBool isOutOfBounds(int32_t textlength, int32_t offset)
* @param strsrch string search data
* @param start offset of possible match
* @param end offset of possible match
-* @return TRUE if identical match is found
+* @return true if identical match is found
*/
static
inline UBool checkIdentical(const UStringSearch *strsrch, int32_t start, int32_t end)
{
if (strsrch->strength != UCOL_IDENTICAL) {
- return TRUE;
+ return true;
}
// Note: We could use Normalizer::compare() or similar, but for short strings
@@ -529,18 +529,18 @@ inline UBool checkIdentical(const UStringSearch *strsrch, int32_t start, int32_t
UErrorCode status = U_ZERO_ERROR;
UnicodeString t2, p2;
strsrch->nfd->normalize(
- UnicodeString(FALSE, strsrch->search->text + start, end - start), t2, status);
+ UnicodeString(false, strsrch->search->text + start, end - start), t2, status);
strsrch->nfd->normalize(
- UnicodeString(FALSE, strsrch->pattern.text, strsrch->pattern.textLength), p2, status);
- // return FALSE if NFD failed
+ UnicodeString(false, strsrch->pattern.text, strsrch->pattern.textLength), p2, status);
+ // return false if NFD failed
return U_SUCCESS(status) && t2 == p2;
}
// constructors and destructor -------------------------------------------
-U_CAPI UStringSearch * U_EXPORT2 usearch_open(const UChar *pattern,
+U_CAPI UStringSearch * U_EXPORT2 usearch_open(const char16_t *pattern,
int32_t patternlength,
- const UChar *text,
+ const char16_t *text,
int32_t textlength,
const char *locale,
UBreakIterator *breakiter,
@@ -570,7 +570,7 @@ U_CAPI UStringSearch * U_EXPORT2 usearch_open(const UChar *pattern,
return nullptr;
}
else {
- result->ownCollator = TRUE;
+ result->ownCollator = true;
}
return result;
}
@@ -579,9 +579,9 @@ U_CAPI UStringSearch * U_EXPORT2 usearch_open(const UChar *pattern,
}
U_CAPI UStringSearch * U_EXPORT2 usearch_openFromCollator(
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternlength,
- const UChar *text,
+ const char16_t *text,
int32_t textlength,
const UCollator *collator,
UBreakIterator *breakiter,
@@ -669,7 +669,7 @@ U_CAPI UStringSearch * U_EXPORT2 usearch_openFromCollator(
}
#endif
- result->ownCollator = FALSE;
+ result->ownCollator = false;
result->search->matchedLength = 0;
result->search->matchedIndex = USEARCH_DONE;
result->utilIter = nullptr;
@@ -681,11 +681,11 @@ U_CAPI UStringSearch * U_EXPORT2 usearch_openFromCollator(
return nullptr;
}
- result->search->isOverlap = FALSE;
- result->search->isCanonicalMatch = FALSE;
+ result->search->isOverlap = false;
+ result->search->isCanonicalMatch = false;
result->search->elementComparisonType = 0;
- result->search->isForwardSearching = TRUE;
- result->search->reset = TRUE;
+ result->search->isForwardSearching = true;
+ result->search->reset = true;
initialize(result, status);
@@ -734,17 +734,17 @@ U_CAPI void U_EXPORT2 usearch_close(UStringSearch *strsrch)
namespace {
UBool initTextProcessedIter(UStringSearch *strsrch, UErrorCode *status) {
- if (U_FAILURE(*status)) { return FALSE; }
+ if (U_FAILURE(*status)) { return false; }
if (strsrch->textProcessedIter == nullptr) {
strsrch->textProcessedIter = new icu::UCollationPCE(strsrch->textIter);
if (strsrch->textProcessedIter == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return FALSE;
+ return false;
}
} else {
strsrch->textProcessedIter->init(strsrch->textIter);
}
- return TRUE;
+ return true;
}
}
@@ -764,7 +764,7 @@ U_CAPI void U_EXPORT2 usearch_setOffset(UStringSearch *strsrch,
}
strsrch->search->matchedIndex = USEARCH_DONE;
strsrch->search->matchedLength = 0;
- strsrch->search->reset = FALSE;
+ strsrch->search->reset = false;
}
}
@@ -789,11 +789,11 @@ U_CAPI void U_EXPORT2 usearch_setAttribute(UStringSearch *strsrch,
switch (attribute)
{
case USEARCH_OVERLAP :
- strsrch->search->isOverlap = (value == USEARCH_ON ? TRUE : FALSE);
+ strsrch->search->isOverlap = (value == USEARCH_ON ? true : false);
break;
case USEARCH_CANONICAL_MATCH :
- strsrch->search->isCanonicalMatch = (value == USEARCH_ON ? TRUE :
- FALSE);
+ strsrch->search->isCanonicalMatch = (value == USEARCH_ON ? true :
+ false);
break;
case USEARCH_ELEMENT_COMPARISON :
if (value == USEARCH_PATTERN_BASE_WEIGHT_IS_WILDCARD || value == USEARCH_ANY_BASE_WEIGHT_IS_WILDCARD) {
@@ -819,11 +819,9 @@ U_CAPI USearchAttributeValue U_EXPORT2 usearch_getAttribute(
if (strsrch) {
switch (attribute) {
case USEARCH_OVERLAP :
- return (strsrch->search->isOverlap == TRUE ? USEARCH_ON :
- USEARCH_OFF);
+ return (strsrch->search->isOverlap ? USEARCH_ON : USEARCH_OFF);
case USEARCH_CANONICAL_MATCH :
- return (strsrch->search->isCanonicalMatch == TRUE ? USEARCH_ON :
- USEARCH_OFF);
+ return (strsrch->search->isCanonicalMatch ? USEARCH_ON : USEARCH_OFF);
case USEARCH_ELEMENT_COMPARISON :
{
int16_t value = strsrch->search->elementComparisonType;
@@ -851,7 +849,7 @@ U_CAPI int32_t U_EXPORT2 usearch_getMatchedStart(
U_CAPI int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch,
- UChar *result,
+ char16_t *result,
int32_t resultCapacity,
UErrorCode *status)
{
@@ -876,7 +874,7 @@ U_CAPI int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch,
}
if (copylength > 0) {
uprv_memcpy(result, strsrch->search->text + copyindex,
- copylength * sizeof(UChar));
+ copylength * sizeof(char16_t));
}
return u_terminateUChars(result, resultCapacity,
strsrch->search->matchedLength, status);
@@ -918,7 +916,7 @@ usearch_getBreakIterator(const UStringSearch *strsrch)
#endif
U_CAPI void U_EXPORT2 usearch_setText( UStringSearch *strsrch,
- const UChar *text,
+ const char16_t *text,
int32_t textlength,
UErrorCode *status)
{
@@ -936,7 +934,7 @@ U_CAPI void U_EXPORT2 usearch_setText( UStringSearch *strsrch,
ucol_setText(strsrch->textIter, text, textlength, status);
strsrch->search->matchedIndex = USEARCH_DONE;
strsrch->search->matchedLength = 0;
- strsrch->search->reset = TRUE;
+ strsrch->search->reset = true;
#if !UCONFIG_NO_BREAK_ITERATION
if (strsrch->search->breakIter != nullptr) {
ubrk_setText(strsrch->search->breakIter, text,
@@ -950,7 +948,7 @@ U_CAPI void U_EXPORT2 usearch_setText( UStringSearch *strsrch,
}
}
-U_CAPI const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch,
+U_CAPI const char16_t * U_EXPORT2 usearch_getText(const UStringSearch *strsrch,
int32_t *length)
{
if (strsrch) {
@@ -978,7 +976,7 @@ U_CAPI void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch,
strsrch->textIter = strsrch->utilIter = nullptr;
if (strsrch->ownCollator && (strsrch->collator != collator)) {
ucol_close((UCollator *)strsrch->collator);
- strsrch->ownCollator = FALSE;
+ strsrch->ownCollator = false;
}
strsrch->collator = collator;
strsrch->strength = ucol_getStrength(collator);
@@ -1024,7 +1022,7 @@ U_CAPI UCollator * U_EXPORT2 usearch_getCollator(const UStringSearch *strsrch)
}
U_CAPI void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch,
- const UChar *pattern,
+ const char16_t *pattern,
int32_t patternlength,
UErrorCode *status)
{
@@ -1047,7 +1045,7 @@ U_CAPI void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch,
}
}
-U_CAPI const UChar* U_EXPORT2
+U_CAPI const char16_t* U_EXPORT2
usearch_getPattern(const UStringSearch *strsrch,
int32_t *length)
{
@@ -1064,7 +1062,7 @@ U_CAPI int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch,
UErrorCode *status)
{
if (strsrch && U_SUCCESS(*status)) {
- strsrch->search->isForwardSearching = TRUE;
+ strsrch->search->isForwardSearching = true;
usearch_setOffset(strsrch, 0, status);
if (U_SUCCESS(*status)) {
return usearch_next(strsrch, status);
@@ -1078,7 +1076,7 @@ U_CAPI int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch,
UErrorCode *status)
{
if (strsrch && U_SUCCESS(*status)) {
- strsrch->search->isForwardSearching = TRUE;
+ strsrch->search->isForwardSearching = true;
// position checked in usearch_setOffset
usearch_setOffset(strsrch, position, status);
if (U_SUCCESS(*status)) {
@@ -1092,7 +1090,7 @@ U_CAPI int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch,
UErrorCode *status)
{
if (strsrch && U_SUCCESS(*status)) {
- strsrch->search->isForwardSearching = FALSE;
+ strsrch->search->isForwardSearching = false;
usearch_setOffset(strsrch, strsrch->search->textLength, status);
if (U_SUCCESS(*status)) {
return usearch_previous(strsrch, status);
@@ -1106,7 +1104,7 @@ U_CAPI int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch,
UErrorCode *status)
{
if (strsrch && U_SUCCESS(*status)) {
- strsrch->search->isForwardSearching = FALSE;
+ strsrch->search->isForwardSearching = false;
// position checked in usearch_setOffset
usearch_setOffset(strsrch, position, status);
if (U_SUCCESS(*status)) {
@@ -1146,7 +1144,7 @@ U_CAPI int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch,
// or is set by the user
int32_t offset = usearch_getOffset(strsrch);
USearch *search = strsrch->search;
- search->reset = FALSE;
+ search->reset = false;
int32_t textlength = search->textLength;
if (search->isForwardSearching) {
if (offset == textlength ||
@@ -1164,7 +1162,7 @@ U_CAPI int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch,
// setOffset has been called or that previous ran off the text
// string. the iterator would have been set to offset 0 if a
// match is not found.
- search->isForwardSearching = TRUE;
+ search->isForwardSearching = true;
if (search->matchedIndex != USEARCH_DONE) {
// there's no need to set the collation element iterator
// the next call to next will set the offset.
@@ -1240,8 +1238,8 @@ U_CAPI int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch,
USearch *search = strsrch->search;
if (search->reset) {
offset = search->textLength;
- search->isForwardSearching = FALSE;
- search->reset = FALSE;
+ search->isForwardSearching = false;
+ search->reset = false;
setColEIterOffset(strsrch->textIter, offset, *status);
}
else {
@@ -1249,13 +1247,13 @@ U_CAPI int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch,
}
int32_t matchedindex = search->matchedIndex;
- if (search->isForwardSearching == TRUE) {
+ if (search->isForwardSearching) {
// switching direction.
// if matchedIndex == USEARCH_DONE, it means that either a
// setOffset has been called or that next ran off the text
// string. the iterator would have been set to offset textLength if
// a match is not found.
- search->isForwardSearching = FALSE;
+ search->isForwardSearching = false;
if (matchedindex != USEARCH_DONE) {
return matchedindex;
}
@@ -1318,7 +1316,7 @@ U_CAPI void U_EXPORT2 usearch_reset(UStringSearch *strsrch)
*/
if (strsrch) {
UErrorCode status = U_ZERO_ERROR;
- UBool sameCollAttribute = TRUE;
+ UBool sameCollAttribute = true;
uint32_t ceMask;
UBool shift;
uint32_t varTop;
@@ -1327,14 +1325,14 @@ U_CAPI void U_EXPORT2 usearch_reset(UStringSearch *strsrch)
UCollationStrength newStrength = ucol_getStrength(strsrch->collator);
if ((strsrch->strength < UCOL_QUATERNARY && newStrength >= UCOL_QUATERNARY) ||
(strsrch->strength >= UCOL_QUATERNARY && newStrength < UCOL_QUATERNARY)) {
- sameCollAttribute = FALSE;
+ sameCollAttribute = false;
}
strsrch->strength = ucol_getStrength(strsrch->collator);
ceMask = getMask(strsrch->strength);
if (strsrch->ceMask != ceMask) {
strsrch->ceMask = ceMask;
- sameCollAttribute = FALSE;
+ sameCollAttribute = false;
}
// if status is a failure, ucol_getAttribute returns UCOL_DEFAULT
@@ -1342,14 +1340,14 @@ U_CAPI void U_EXPORT2 usearch_reset(UStringSearch *strsrch)
&status) == UCOL_SHIFTED;
if (strsrch->toShift != shift) {
strsrch->toShift = shift;
- sameCollAttribute = FALSE;
+ sameCollAttribute = false;
}
// if status is a failure, ucol_getVariableTop returns 0
varTop = ucol_getVariableTop(strsrch->collator, &status);
if (strsrch->variableTop != varTop) {
strsrch->variableTop = varTop;
- sameCollAttribute = FALSE;
+ sameCollAttribute = false;
}
if (!sameCollAttribute) {
initialize(strsrch, &status);
@@ -1359,11 +1357,11 @@ U_CAPI void U_EXPORT2 usearch_reset(UStringSearch *strsrch)
&status);
strsrch->search->matchedLength = 0;
strsrch->search->matchedIndex = USEARCH_DONE;
- strsrch->search->isOverlap = FALSE;
- strsrch->search->isCanonicalMatch = FALSE;
+ strsrch->search->isOverlap = false;
+ strsrch->search->isCanonicalMatch = false;
strsrch->search->elementComparisonType = 0;
- strsrch->search->isForwardSearching = TRUE;
- strsrch->search->reset = TRUE;
+ strsrch->search->isForwardSearching = true;
+ strsrch->search->reset = true;
}
}
@@ -1413,11 +1411,11 @@ CEIBuffer::CEIBuffer(UStringSearch *ss, UErrorCode *status) {
strSearch = ss;
bufSize = ss->pattern.pcesLength + CEBUFFER_EXTRA;
if (ss->search->elementComparisonType != 0) {
- const UChar * patText = ss->pattern.text;
+ const char16_t * patText = ss->pattern.text;
if (patText) {
- const UChar * patTextLimit = patText + ss->pattern.textLength;
+ const char16_t * patTextLimit = patText + ss->pattern.textLength;
while ( patText < patTextLimit ) {
- UChar c = *patText++;
+ char16_t c = *patText++;
if (MIGHT_BE_JAMO_L(c)) {
bufSize += MAX_TARGET_IGNORABLES_PER_PAT_JAMO_L;
} else {
@@ -1559,7 +1557,7 @@ static int32_t nextBoundaryAfter(UStringSearch *strsrch, int32_t startIndex, UEr
return startIndex;
}
#if 0
- const UChar *text = strsrch->search->text;
+ const char16_t *text = strsrch->search->text;
int32_t textLen = strsrch->search->textLength;
U_ASSERT(startIndex>=0);
@@ -1610,23 +1608,23 @@ static int32_t nextBoundaryAfter(UStringSearch *strsrch, int32_t startIndex, UEr
}
/*
- * Returns TRUE if index is on a break boundary. If the UStringSearch
+ * Returns true if index is on a break boundary. If the UStringSearch
* has an external break iterator, test using that, otherwise test
* using the internal character break iterator.
*/
static UBool isBreakBoundary(UStringSearch *strsrch, int32_t index, UErrorCode &status) {
if (U_FAILURE(status)) {
- return TRUE;
+ return true;
}
#if 0
- const UChar *text = strsrch->search->text;
+ const char16_t *text = strsrch->search->text;
int32_t textLen = strsrch->search->textLength;
U_ASSERT(index>=0);
U_ASSERT(index<=textLen);
if (index>=textLen || index<=0) {
- return TRUE;
+ return true;
}
// If the character at the current index is not a GRAPHEME_EXTEND
@@ -1635,7 +1633,7 @@ static UBool isBreakBoundary(UStringSearch *strsrch, int32_t index, UErrorCode &
U16_GET(text, 0, index, textLen, c);
int32_t gcProperty = u_getIntPropertyValue(c, UCHAR_GRAPHEME_CLUSTER_BREAK);
if (gcProperty != U_GCB_EXTEND && gcProperty != U_GCB_SPACING_MARK) {
- return TRUE;
+ return true;
}
// We are at a combining mark. If the preceding character is anything
@@ -1647,13 +1645,13 @@ static UBool isBreakBoundary(UStringSearch *strsrch, int32_t index, UErrorCode &
#elif !UCONFIG_NO_BREAK_ITERATION
UBreakIterator *breakiterator = getBreakIterator(strsrch, status);
if (U_FAILURE(status)) {
- return TRUE;
+ return true;
}
return ubrk_isBoundary(breakiterator, index);
#else
// **** or use the original code? ****
- return TRUE;
+ return true;
#endif
}
@@ -1661,7 +1659,7 @@ static UBool isBreakBoundary(UStringSearch *strsrch, int32_t index, UErrorCode &
static UBool onBreakBoundaries(const UStringSearch *strsrch, int32_t start, int32_t end, UErrorCode &status)
{
if (U_FAILURE(status)) {
- return TRUE;
+ return true;
}
#if !UCONFIG_NO_BREAK_ITERATION
@@ -1673,7 +1671,7 @@ static UBool onBreakBoundaries(const UStringSearch *strsrch, int32_t start, int3
// out-of-range indexes are never boundary positions
if (start < startindex || start > endindex ||
end < startindex || end > endindex) {
- return FALSE;
+ return false;
}
return ubrk_isBoundary(breakiterator, start) &&
@@ -1681,7 +1679,7 @@ static UBool onBreakBoundaries(const UStringSearch *strsrch, int32_t start, int3
}
#endif
- return TRUE;
+ return true;
}
#endif
@@ -1773,7 +1771,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
UErrorCode *status)
{
if (U_FAILURE(*status)) {
- return FALSE;
+ return false;
}
// TODO: reject search patterns beginning with a combining char.
@@ -1796,7 +1794,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
startIdx > strsrch->search->textLength ||
strsrch->pattern.ces == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return FALSE;
+ return false;
}
if (strsrch->pattern.pces == nullptr) {
@@ -1809,7 +1807,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
// An out-of-memory (OOM) failure can occur in the initializePatternPCETable function
// or CEIBuffer constructor above, so we need to check the status.
if (U_FAILURE(*status)) {
- return FALSE;
+ return false;
}
int32_t targetIx = 0;
@@ -1840,7 +1838,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
//
for(targetIx=0; ; targetIx++)
{
- found = TRUE;
+ found = true;
// Inner loop checks for a match beginning at each
// position from the outer loop.
int32_t targetIxOffset = 0;
@@ -1851,7 +1849,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
const CEI *firstCEI = ceb.get(targetIx);
if (firstCEI == nullptr) {
*status = U_INTERNAL_PROGRAM_ERROR;
- found = FALSE;
+ found = false;
break;
}
@@ -1863,7 +1861,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
// which will fail the compare, below.
UCompareCEsResult ceMatch = compareCE64s(targetCEI->ce, patCE, strsrch->search->elementComparisonType);
if ( ceMatch == U_CE_NO_MATCH ) {
- found = FALSE;
+ found = false;
break;
} else if ( ceMatch > U_CE_NO_MATCH ) {
if ( ceMatch == U_CE_SKIP_TARG ) {
@@ -1912,7 +1910,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
nextCEI = ceb.get(targetIx + targetIxOffset);
maxLimit = nextCEI->lowIndex;
if (nextCEI->lowIndex == nextCEI->highIndex && nextCEI->ce != UCOL_PROCESSED_NULLORDER) {
- found = FALSE;
+ found = false;
}
} else {
for ( ; ; ++targetIxOffset ) {
@@ -1928,7 +1926,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
if ( (((nextCEI->ce) >> 32) & 0xFFFF0000UL) == 0 ) {
UCompareCEsResult ceMatch = compareCE64s(nextCEI->ce, patCE, strsrch->search->elementComparisonType);
if ( ceMatch == U_CE_NO_MATCH || ceMatch == U_CE_SKIP_PATN ) {
- found = FALSE;
+ found = false;
break;
}
// If lowIndex == highIndex, this target CE is part of an expansion of the last matched
@@ -1951,7 +1949,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
// This type of match should be rejected for not completely consuming a
// combining sequence.
if (!isBreakBoundary(strsrch, mStart, *status)) {
- found = FALSE;
+ found = false;
}
if (U_FAILURE(*status)) {
break;
@@ -1964,7 +1962,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
// _following_ character.
int32_t secondIx = firstCEI->highIndex;
if (mStart == secondIx) {
- found = FALSE;
+ found = false;
}
// Allow matches to end in the middle of a grapheme cluster if the following
@@ -1978,7 +1976,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
// subsequent check for normalization boundary; however they are likely much faster
// tests in any case)
// * the match limit is a normalization boundary
- UBool allowMidclusterMatch = FALSE;
+ UBool allowMidclusterMatch = false;
if (strsrch->search->text != nullptr && strsrch->search->textLength > maxLimit) {
allowMidclusterMatch =
strsrch->search->breakIter == nullptr &&
@@ -2032,11 +2030,11 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
// If advancing to the end of a combining sequence in character indexing space
// advanced us beyond the end of the match in CE space, reject this match.
if (mLimit > maxLimit) {
- found = FALSE;
+ found = false;
}
if (!isBreakBoundary(strsrch, mLimit, *status)) {
- found = FALSE;
+ found = false;
}
if (U_FAILURE(*status)) {
break;
@@ -2044,7 +2042,7 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
}
if (! checkIdentical(strsrch, mStart, mLimit)) {
- found = FALSE;
+ found = false;
}
if (found) {
@@ -2067,10 +2065,10 @@ U_CAPI UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
//
if (U_FAILURE(*status)) {
- found = FALSE; // No match if a failure occured.
+ found = false; // No match if a failure occured.
}
- if (found==FALSE) {
+ if (found==false) {
mLimit = -1;
mStart = -1;
}
@@ -2093,7 +2091,7 @@ U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
UErrorCode *status)
{
if (U_FAILURE(*status)) {
- return FALSE;
+ return false;
}
// TODO: reject search patterns beginning with a combining char.
@@ -2116,7 +2114,7 @@ U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
startIdx > strsrch->search->textLength ||
strsrch->pattern.ces == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return FALSE;
+ return false;
}
if (strsrch->pattern.pces == nullptr) {
@@ -2138,7 +2136,7 @@ U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
if (startIdx < strsrch->search->textLength) {
UBreakIterator *breakiterator = getBreakIterator(strsrch, *status);
if (U_FAILURE(*status)) {
- return FALSE;
+ return false;
}
int32_t next = ubrk_following(breakiterator, startIdx);
@@ -2155,7 +2153,7 @@ U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
// An out-of-memory (OOM) failure can occur above, so we need to check the status.
if (U_FAILURE(*status)) {
- return FALSE;
+ return false;
}
const CEI *targetCEI = nullptr;
@@ -2178,14 +2176,14 @@ U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
// and the beginning of the base text.
for(targetIx = limitIx; ; targetIx += 1)
{
- found = TRUE;
+ found = true;
// For targetIx > limitIx, this ceb.getPrevious gets a CE that is as far back in the ring buffer
// (compared to the last CE fetched for the previous targetIx value) as we need to go
// for this targetIx value, so if it is non-nullptr then other ceb.getPrevious calls should be OK.
const CEI *lastCEI = ceb.getPrevious(targetIx);
if (lastCEI == nullptr) {
*status = U_INTERNAL_PROGRAM_ERROR;
- found = FALSE;
+ found = false;
break;
}
// Inner loop checks for a match beginning at each
@@ -2200,7 +2198,7 @@ U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
// which will fail the compare, below.
UCompareCEsResult ceMatch = compareCE64s(targetCEI->ce, patCE, strsrch->search->elementComparisonType);
if ( ceMatch == U_CE_NO_MATCH ) {
- found = FALSE;
+ found = false;
break;
} else if ( ceMatch > U_CE_NO_MATCH ) {
if ( ceMatch == U_CE_SKIP_TARG ) {
@@ -2240,7 +2238,7 @@ U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
// This type of match should be rejected for not completely consuming a
// combining sequence.
if (!isBreakBoundary(strsrch, mStart, *status)) {
- found = FALSE;
+ found = false;
}
if (U_FAILURE(*status)) {
break;
@@ -2249,7 +2247,7 @@ U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
// Look at the high index of the first CE in the match. If it's the same as the
// low index, the first CE in the match is in the middle of an expansion.
if (mStart == firstCEI->highIndex) {
- found = FALSE;
+ found = false;
}
@@ -2267,7 +2265,7 @@ U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
const CEI *nextCEI = ceb.getPrevious(targetIx - 1);
if (nextCEI->lowIndex == nextCEI->highIndex && nextCEI->ce != UCOL_PROCESSED_NULLORDER) {
- found = FALSE;
+ found = false;
}
mLimit = maxLimit = nextCEI->lowIndex;
@@ -2283,7 +2281,7 @@ U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
// subsequent check for normalization boundary; however they are likely much faster
// tests in any case)
// * the match limit is a normalization boundary
- UBool allowMidclusterMatch = FALSE;
+ UBool allowMidclusterMatch = false;
if (strsrch->search->text != nullptr && strsrch->search->textLength > maxLimit) {
allowMidclusterMatch =
strsrch->search->breakIter == nullptr &&
@@ -2316,12 +2314,12 @@ U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
// If advancing to the end of a combining sequence in character indexing space
// advanced us beyond the end of the match in CE space, reject this match.
if (mLimit > maxLimit) {
- found = FALSE;
+ found = false;
}
// Make sure the end of the match is on a break boundary
if (!isBreakBoundary(strsrch, mLimit, *status)) {
- found = FALSE;
+ found = false;
}
if (U_FAILURE(*status)) {
break;
@@ -2345,7 +2343,7 @@ U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
if (! checkIdentical(strsrch, mStart, mLimit)) {
- found = FALSE;
+ found = false;
}
if (found) {
@@ -2368,10 +2366,10 @@ U_CAPI UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
//
if (U_FAILURE(*status)) {
- found = FALSE; // No match if a failure occured.
+ found = false; // No match if a failure occured.
}
- if (found==FALSE) {
+ if (found==false) {
mLimit = -1;
mStart = -1;
}
@@ -2393,7 +2391,7 @@ UBool usearch_handleNextExact(UStringSearch *strsrch, UErrorCode *status)
{
if (U_FAILURE(*status)) {
setMatchNotFound(strsrch, *status);
- return FALSE;
+ return false;
}
int32_t textOffset = ucol_getOffset(strsrch->textIter);
@@ -2403,10 +2401,10 @@ UBool usearch_handleNextExact(UStringSearch *strsrch, UErrorCode *status)
if (usearch_search(strsrch, textOffset, &start, &end, status)) {
strsrch->search->matchedIndex = start;
strsrch->search->matchedLength = end - start;
- return TRUE;
+ return true;
} else {
setMatchNotFound(strsrch, *status);
- return FALSE;
+ return false;
}
}
@@ -2414,7 +2412,7 @@ UBool usearch_handleNextCanonical(UStringSearch *strsrch, UErrorCode *status)
{
if (U_FAILURE(*status)) {
setMatchNotFound(strsrch, *status);
- return FALSE;
+ return false;
}
int32_t textOffset = ucol_getOffset(strsrch->textIter);
@@ -2424,10 +2422,10 @@ UBool usearch_handleNextCanonical(UStringSearch *strsrch, UErrorCode *status)
if (usearch_search(strsrch, textOffset, &start, &end, status)) {
strsrch->search->matchedIndex = start;
strsrch->search->matchedLength = end - start;
- return TRUE;
+ return true;
} else {
setMatchNotFound(strsrch, *status);
- return FALSE;
+ return false;
}
}
@@ -2435,7 +2433,7 @@ UBool usearch_handlePreviousExact(UStringSearch *strsrch, UErrorCode *status)
{
if (U_FAILURE(*status)) {
setMatchNotFound(strsrch, *status);
- return FALSE;
+ return false;
}
int32_t textOffset;
@@ -2448,7 +2446,7 @@ UBool usearch_handlePreviousExact(UStringSearch *strsrch, UErrorCode *status)
initializePatternPCETable(strsrch, status);
if (!initTextProcessedIter(strsrch, status)) {
setMatchNotFound(strsrch, *status);
- return FALSE;
+ return false;
}
for (int32_t nPCEs = 0; nPCEs < strsrch->pattern.pcesLength - 1; nPCEs++) {
int64_t pce = strsrch->textProcessedIter->nextProcessed(nullptr, nullptr, status);
@@ -2459,7 +2457,7 @@ UBool usearch_handlePreviousExact(UStringSearch *strsrch, UErrorCode *status)
}
if (U_FAILURE(*status)) {
setMatchNotFound(strsrch, *status);
- return FALSE;
+ return false;
}
textOffset = ucol_getOffset(strsrch->textIter);
}
@@ -2473,10 +2471,10 @@ UBool usearch_handlePreviousExact(UStringSearch *strsrch, UErrorCode *status)
if (usearch_searchBackwards(strsrch, textOffset, &start, &end, status)) {
strsrch->search->matchedIndex = start;
strsrch->search->matchedLength = end - start;
- return TRUE;
+ return true;
} else {
setMatchNotFound(strsrch, *status);
- return FALSE;
+ return false;
}
}
@@ -2485,7 +2483,7 @@ UBool usearch_handlePreviousCanonical(UStringSearch *strsrch,
{
if (U_FAILURE(*status)) {
setMatchNotFound(strsrch, *status);
- return FALSE;
+ return false;
}
int32_t textOffset;
@@ -2498,7 +2496,7 @@ UBool usearch_handlePreviousCanonical(UStringSearch *strsrch,
initializePatternPCETable(strsrch, status);
if (!initTextProcessedIter(strsrch, status)) {
setMatchNotFound(strsrch, *status);
- return FALSE;
+ return false;
}
for (int32_t nPCEs = 0; nPCEs < strsrch->pattern.pcesLength - 1; nPCEs++) {
int64_t pce = strsrch->textProcessedIter->nextProcessed(nullptr, nullptr, status);
@@ -2509,7 +2507,7 @@ UBool usearch_handlePreviousCanonical(UStringSearch *strsrch,
}
if (U_FAILURE(*status)) {
setMatchNotFound(strsrch, *status);
- return FALSE;
+ return false;
}
textOffset = ucol_getOffset(strsrch->textIter);
}
@@ -2523,10 +2521,10 @@ UBool usearch_handlePreviousCanonical(UStringSearch *strsrch,
if (usearch_searchBackwards(strsrch, textOffset, &start, &end, status)) {
strsrch->search->matchedIndex = start;
strsrch->search->matchedLength = end - start;
- return TRUE;
+ return true;
} else {
setMatchNotFound(strsrch, *status);
- return FALSE;
+ return false;
}
}
diff --git a/contrib/libs/icu/i18n/uspoof.cpp b/contrib/libs/icu/i18n/uspoof.cpp
index dd4618baa7..271caeafff 100644
--- a/contrib/libs/icu/i18n/uspoof.cpp
+++ b/contrib/libs/icu/i18n/uspoof.cpp
@@ -38,30 +38,30 @@ U_NAMESPACE_USE
//
// Static Objects used by the spoof impl, their thread safe initialization and their cleanup.
//
-static UnicodeSet *gInclusionSet = NULL;
-static UnicodeSet *gRecommendedSet = NULL;
-static const Normalizer2 *gNfdNormalizer = NULL;
-static UInitOnce gSpoofInitStaticsOnce = U_INITONCE_INITIALIZER;
+static UnicodeSet *gInclusionSet = nullptr;
+static UnicodeSet *gRecommendedSet = nullptr;
+static const Normalizer2 *gNfdNormalizer = nullptr;
+static UInitOnce gSpoofInitStaticsOnce {};
namespace {
UBool U_CALLCONV
-uspoof_cleanup(void) {
+uspoof_cleanup() {
delete gInclusionSet;
- gInclusionSet = NULL;
+ gInclusionSet = nullptr;
delete gRecommendedSet;
- gRecommendedSet = NULL;
- gNfdNormalizer = NULL;
+ gRecommendedSet = nullptr;
+ gNfdNormalizer = nullptr;
gSpoofInitStaticsOnce.reset();
- return TRUE;
+ return true;
}
void U_CALLCONV initializeStatics(UErrorCode &status) {
static const char16_t *inclusionPat =
- u"['\\-.\\:\\u00B7\\u0375\\u058A\\u05F3\\u05F4\\u06FD\\u06FE\\u0F0B\\u200C"
- u"\\u200D\\u2010\\u2019\\u2027\\u30A0\\u30FB]";
+ u"['\\-.\\:\\u00B7\\u0375\\u058A\\u05F3\\u05F4\\u06FD\\u06FE\\u0F0B\\u2010"
+ u"\\u2019\\u2027\\u30A0\\u30FB]";
gInclusionSet = new UnicodeSet(UnicodeString(inclusionPat), status);
- if (gInclusionSet == NULL) {
+ if (gInclusionSet == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -103,14 +103,14 @@ void U_CALLCONV initializeStatics(UErrorCode &status) {
u"\\u0C56\\u0C5D\\u0C60\\u0C61\\u0C66-\\u0C6F\\u0C80\\u0C82\\u0C83\\u0C85-"
u"\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-"
u"\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDD\\u0CE0-\\u0CE3"
- u"\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D00\\u0D02\\u0D03\\u0D05-\\u0D0C\\u0D0E-"
+ u"\\u0CE6-\\u0CEF\\u0CF1-\\u0CF3\\u0D00\\u0D02\\u0D03\\u0D05-\\u0D0C\\u0D0E-"
u"\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D43\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D54-"
u"\\u0D57\\u0D60\\u0D61\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-"
u"\\u0D8E\\u0D91-\\u0D96\\u0D9A-\\u0DA5\\u0DA7-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD"
u"\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDE\\u0DF2\\u0E01-"
u"\\u0E32\\u0E34-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84"
u"\\u0E86-\\u0E8A\\u0E8C-\\u0EA3\\u0EA5\\u0EA7-\\u0EB2\\u0EB4-\\u0EBD\\u0EC0-"
- u"\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDE\\u0EDF\\u0F00\\u0F20-"
+ u"\\u0EC4\\u0EC6\\u0EC8-\\u0ECE\\u0ED0-\\u0ED9\\u0EDE\\u0EDF\\u0F00\\u0F20-"
u"\\u0F29\\u0F35\\u0F37\\u0F3E-\\u0F42\\u0F44-\\u0F47\\u0F49-\\u0F4C\\u0F4E-"
u"\\u0F51\\u0F53-\\u0F56\\u0F58-\\u0F5B\\u0F5D-\\u0F68\\u0F6A-\\u0F6C\\u0F71"
u"\\u0F72\\u0F74\\u0F7A-\\u0F80\\u0F82-\\u0F84\\u0F86-\\u0F92\\u0F94-\\u0F97"
@@ -131,20 +131,21 @@ void U_CALLCONV initializeStatics(UErrorCode &status) {
u"\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u3005-"
u"\\u3007\\u3041-\\u3096\\u3099\\u309A\\u309D\\u309E\\u30A1-\\u30FA\\u30FC-"
u"\\u30FE\\u3105-\\u312D\\u312F\\u31A0-\\u31BF\\u3400-\\u4DBF\\u4E00-\\u9FFF"
- u"\\uA67F\\uA717-\\uA71F\\uA788\\uA78D\\uA792\\uA793\\uA7AA\\uA7AE\\uA7B8"
- u"\\uA7B9\\uA7C0-\\uA7CA\\uA7D0\\uA7D1\\uA7D3\\uA7D5-\\uA7D9\\uA9E7-\\uA9FE"
- u"\\uAA60-\\uAA76\\uAA7A-\\uAA7F\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16"
- u"\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB66\\uAB67\\uAC00-\\uD7A3\\uFA0E\\uFA0F"
- u"\\uFA11\\uFA13\\uFA14\\uFA1F\\uFA21\\uFA23\\uFA24\\uFA27-\\uFA29\\U00011301"
- u"\\U00011303\\U0001133B\\U0001133C\\U00016FF0\\U00016FF1\\U0001B11F-"
- u"\\U0001B122\\U0001B150-\\U0001B152\\U0001B164-\\U0001B167\\U0001DF00-"
- u"\\U0001DF1E\\U0001E7E0-\\U0001E7E6\\U0001E7E8-\\U0001E7EB\\U0001E7ED"
- u"\\U0001E7EE\\U0001E7F0-\\U0001E7FE\\U00020000-\\U0002A6DF\\U0002A700-"
- u"\\U0002B738\\U0002B740-\\U0002B81D\\U0002B820-\\U0002CEA1\\U0002CEB0-"
- u"\\U0002EBE0\\U00030000-\\U0003134A]";
+ u"\\uA67F\\uA717-\\uA71F\\uA788\\uA78D\\uA792\\uA793\\uA7AA\\uA7C0-\\uA7CA"
+ u"\\uA7D0\\uA7D1\\uA7D3\\uA7D5-\\uA7D9\\uA9E7-\\uA9FE\\uAA60-\\uAA76\\uAA7A-"
+ u"\\uAA7F\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-"
+ u"\\uAB2E\\uAB66\\uAB67\\uAC00-\\uD7A3\\uFA0E\\uFA0F\\uFA11\\uFA13\\uFA14"
+ u"\\uFA1F\\uFA21\\uFA23\\uFA24\\uFA27-\\uFA29\\U00011301\\U00011303"
+ u"\\U0001133B\\U0001133C\\U00016FF0\\U00016FF1\\U0001B11F-\\U0001B122"
+ u"\\U0001B132\\U0001B150-\\U0001B152\\U0001B155\\U0001B164-\\U0001B167"
+ u"\\U0001DF00-\\U0001DF1E\\U0001DF25-\\U0001DF2A\\U0001E08F\\U0001E7E0-"
+ u"\\U0001E7E6\\U0001E7E8-\\U0001E7EB\\U0001E7ED\\U0001E7EE\\U0001E7F0-"
+ u"\\U0001E7FE\\U00020000-\\U0002A6DF\\U0002A700-\\U0002B739\\U0002B740-"
+ u"\\U0002B81D\\U0002B820-\\U0002CEA1\\U0002CEB0-\\U0002EBE0\\U00030000-"
+ u"\\U0003134A\\U00031350-\\U000323AF]";
gRecommendedSet = new UnicodeSet(UnicodeString(recommendedPat), status);
- if (gRecommendedSet == NULL) {
+ if (gRecommendedSet == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
delete gInclusionSet;
return;
@@ -164,16 +165,16 @@ U_CAPI USpoofChecker * U_EXPORT2
uspoof_open(UErrorCode *status) {
umtx_initOnce(gSpoofInitStaticsOnce, &initializeStatics, *status);
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
SpoofImpl *si = new SpoofImpl(*status);
- if (si == NULL) {
+ if (si == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
if (U_FAILURE(*status)) {
delete si;
- return NULL;
+ return nullptr;
}
return si->asUSpoofChecker();
}
@@ -183,44 +184,44 @@ U_CAPI USpoofChecker * U_EXPORT2
uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength,
UErrorCode *status) {
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
- if (data == NULL) {
+ if (data == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
umtx_initOnce(gSpoofInitStaticsOnce, &initializeStatics, *status);
if (U_FAILURE(*status))
{
- return NULL;
+ return nullptr;
}
SpoofData *sd = new SpoofData(data, length, *status);
- if (sd == NULL) {
+ if (sd == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
if (U_FAILURE(*status)) {
delete sd;
- return NULL;
+ return nullptr;
}
SpoofImpl *si = new SpoofImpl(sd, *status);
- if (si == NULL) {
+ if (si == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
delete sd; // explicit delete as the destructor for si won't be called.
- return NULL;
+ return nullptr;
}
if (U_FAILURE(*status)) {
delete si; // no delete for sd, as the si destructor will delete it.
- return NULL;
+ return nullptr;
}
- if (pActualLength != NULL) {
+ if (pActualLength != nullptr) {
*pActualLength = sd->size();
}
return si->asUSpoofChecker();
@@ -230,17 +231,17 @@ uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLeng
U_CAPI USpoofChecker * U_EXPORT2
uspoof_clone(const USpoofChecker *sc, UErrorCode *status) {
const SpoofImpl *src = SpoofImpl::validateThis(sc, *status);
- if (src == NULL) {
- return NULL;
+ if (src == nullptr) {
+ return nullptr;
}
SpoofImpl *result = new SpoofImpl(*src, *status); // copy constructor
- if (result == NULL) {
+ if (result == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
if (U_FAILURE(*status)) {
delete result;
- result = NULL;
+ result = nullptr;
}
return result->asUSpoofChecker();
}
@@ -257,7 +258,7 @@ uspoof_close(USpoofChecker *sc) {
U_CAPI void U_EXPORT2
uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status) {
SpoofImpl *This = SpoofImpl::validateThis(sc, *status);
- if (This == NULL) {
+ if (This == nullptr) {
return;
}
@@ -275,7 +276,7 @@ uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status) {
U_CAPI int32_t U_EXPORT2
uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status) {
const SpoofImpl *This = SpoofImpl::validateThis(sc, *status);
- if (This == NULL) {
+ if (This == nullptr) {
return 0;
}
return This->fChecks;
@@ -285,7 +286,7 @@ U_CAPI void U_EXPORT2
uspoof_setRestrictionLevel(USpoofChecker *sc, URestrictionLevel restrictionLevel) {
UErrorCode status = U_ZERO_ERROR;
SpoofImpl *This = SpoofImpl::validateThis(sc, status);
- if (This != NULL) {
+ if (This != nullptr) {
This->fRestrictionLevel = restrictionLevel;
This->fChecks |= USPOOF_RESTRICTION_LEVEL;
}
@@ -295,7 +296,7 @@ U_CAPI URestrictionLevel U_EXPORT2
uspoof_getRestrictionLevel(const USpoofChecker *sc) {
UErrorCode status = U_ZERO_ERROR;
const SpoofImpl *This = SpoofImpl::validateThis(sc, status);
- if (This == NULL) {
+ if (This == nullptr) {
return USPOOF_UNRESTRICTIVE;
}
return This->fRestrictionLevel;
@@ -304,7 +305,7 @@ uspoof_getRestrictionLevel(const USpoofChecker *sc) {
U_CAPI void U_EXPORT2
uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status) {
SpoofImpl *This = SpoofImpl::validateThis(sc, *status);
- if (This == NULL) {
+ if (This == nullptr) {
return;
}
This->setAllowedLocales(localesList, *status);
@@ -313,8 +314,8 @@ uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode
U_CAPI const char * U_EXPORT2
uspoof_getAllowedLocales(USpoofChecker *sc, UErrorCode *status) {
SpoofImpl *This = SpoofImpl::validateThis(sc, *status);
- if (This == NULL) {
- return NULL;
+ if (This == nullptr) {
+ return nullptr;
}
return This->getAllowedLocales(*status);
}
@@ -329,8 +330,8 @@ uspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status) {
U_CAPI const UnicodeSet * U_EXPORT2
uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status) {
const SpoofImpl *This = SpoofImpl::validateThis(sc, *status);
- if (This == NULL) {
- return NULL;
+ if (This == nullptr) {
+ return nullptr;
}
return This->fAllowedCharsSet;
}
@@ -346,7 +347,7 @@ uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status)
U_CAPI void U_EXPORT2
uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const UnicodeSet *chars, UErrorCode *status) {
SpoofImpl *This = SpoofImpl::validateThis(sc, *status);
- if (This == NULL) {
+ if (This == nullptr) {
return;
}
if (chars->isBogus()) {
@@ -354,7 +355,7 @@ uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const UnicodeSet *chars, UErrorCo
return;
}
UnicodeSet *clonedSet = chars->clone();
- if (clonedSet == NULL || clonedSet->isBogus()) {
+ if (clonedSet == nullptr || clonedSet->isBogus()) {
*status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -367,28 +368,28 @@ uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const UnicodeSet *chars, UErrorCo
U_CAPI int32_t U_EXPORT2
uspoof_check(const USpoofChecker *sc,
- const UChar *id, int32_t length,
+ const char16_t *id, int32_t length,
int32_t *position,
UErrorCode *status) {
// Backwards compatibility:
- if (position != NULL) {
+ if (position != nullptr) {
*position = 0;
}
// Delegate to uspoof_check2
- return uspoof_check2(sc, id, length, NULL, status);
+ return uspoof_check2(sc, id, length, nullptr, status);
}
U_CAPI int32_t U_EXPORT2
uspoof_check2(const USpoofChecker *sc,
- const UChar* id, int32_t length,
+ const char16_t* id, int32_t length,
USpoofCheckResult* checkResult,
UErrorCode *status) {
const SpoofImpl *This = SpoofImpl::validateThis(sc, *status);
- if (This == NULL) {
+ if (This == nullptr) {
return 0;
}
if (length < -1) {
@@ -408,12 +409,12 @@ uspoof_checkUTF8(const USpoofChecker *sc,
UErrorCode *status) {
// Backwards compatibility:
- if (position != NULL) {
+ if (position != nullptr) {
*position = 0;
}
// Delegate to uspoof_check2
- return uspoof_check2UTF8(sc, id, length, NULL, status);
+ return uspoof_check2UTF8(sc, id, length, nullptr, status);
}
@@ -434,8 +435,8 @@ uspoof_check2UTF8(const USpoofChecker *sc,
U_CAPI int32_t U_EXPORT2
uspoof_areConfusable(const USpoofChecker *sc,
- const UChar *id1, int32_t length1,
- const UChar *id2, int32_t length2,
+ const char16_t *id1, int32_t length1,
+ const char16_t *id2, int32_t length2,
UErrorCode *status) {
SpoofImpl::validateThis(sc, *status);
if (U_FAILURE(*status)) {
@@ -545,19 +546,19 @@ uspoof_checkUnicodeString(const USpoofChecker *sc,
UErrorCode *status) {
// Backwards compatibility:
- if (position != NULL) {
+ if (position != nullptr) {
*position = 0;
}
// Delegate to uspoof_check2
- return uspoof_check2UnicodeString(sc, id, NULL, status);
+ return uspoof_check2UnicodeString(sc, id, nullptr, status);
}
namespace {
int32_t checkImpl(const SpoofImpl* This, const UnicodeString& id, CheckResult* checkResult, UErrorCode* status) {
- U_ASSERT(This != NULL);
- U_ASSERT(checkResult != NULL);
+ U_ASSERT(This != nullptr);
+ U_ASSERT(checkResult != nullptr);
checkResult->clear();
int32_t result = 0;
@@ -611,7 +612,7 @@ int32_t checkImpl(const SpoofImpl* This, const UnicodeString& id, CheckResult* c
int32_t i;
UChar32 c;
UChar32 firstNonspacingMark = 0;
- UBool haveMultipleMarks = FALSE;
+ UBool haveMultipleMarks = false;
UnicodeSet marksSeenSoFar; // Set of combining marks in a single combining sequence.
for (i=0; i<nfdLength ;) {
@@ -621,7 +622,7 @@ int32_t checkImpl(const SpoofImpl* This, const UnicodeString& id, CheckResult* c
firstNonspacingMark = 0;
if (haveMultipleMarks) {
marksSeenSoFar.clear();
- haveMultipleMarks = FALSE;
+ haveMultipleMarks = false;
}
continue;
}
@@ -631,7 +632,7 @@ int32_t checkImpl(const SpoofImpl* This, const UnicodeString& id, CheckResult* c
}
if (!haveMultipleMarks) {
marksSeenSoFar.add(firstNonspacingMark);
- haveMultipleMarks = TRUE;
+ haveMultipleMarks = true;
}
if (marksSeenSoFar.contains(c)) {
// report the error, and stop scanning.
@@ -655,14 +656,14 @@ uspoof_check2UnicodeString(const USpoofChecker *sc,
USpoofCheckResult* checkResult,
UErrorCode *status) {
const SpoofImpl *This = SpoofImpl::validateThis(sc, *status);
- if (This == NULL) {
- return FALSE;
+ if (This == nullptr) {
+ return false;
}
- if (checkResult != NULL) {
+ if (checkResult != nullptr) {
CheckResult* ThisCheckResult = CheckResult::validateThis(checkResult, *status);
- if (ThisCheckResult == NULL) {
- return FALSE;
+ if (ThisCheckResult == nullptr) {
+ return false;
}
return checkImpl(This, id, ThisCheckResult, status);
} else {
@@ -676,15 +677,15 @@ uspoof_check2UnicodeString(const USpoofChecker *sc,
U_CAPI int32_t U_EXPORT2
uspoof_getSkeleton(const USpoofChecker *sc,
uint32_t type,
- const UChar *id, int32_t length,
- UChar *dest, int32_t destCapacity,
+ const char16_t *id, int32_t length,
+ char16_t *dest, int32_t destCapacity,
UErrorCode *status) {
SpoofImpl::validateThis(sc, *status);
if (U_FAILURE(*status)) {
return 0;
}
- if (length<-1 || destCapacity<0 || (destCapacity==0 && dest!=NULL)) {
+ if (length<-1 || destCapacity<0 || (destCapacity==0 && dest!=nullptr)) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -738,7 +739,7 @@ uspoof_getSkeletonUTF8(const USpoofChecker *sc,
if (U_FAILURE(*status)) {
return 0;
}
- if (length<-1 || destCapacity<0 || (destCapacity==0 && dest!=NULL)) {
+ if (length<-1 || destCapacity<0 || (destCapacity==0 && dest!=nullptr)) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -760,7 +761,7 @@ uspoof_getSkeletonUTF8(const USpoofChecker *sc,
U_CAPI int32_t U_EXPORT2
uspoof_serialize(USpoofChecker *sc,void *buf, int32_t capacity, UErrorCode *status) {
SpoofImpl *This = SpoofImpl::validateThis(sc, *status);
- if (This == NULL) {
+ if (This == nullptr) {
U_ASSERT(U_FAILURE(*status));
return 0;
}
@@ -799,9 +800,9 @@ uspoof_getRecommendedUnicodeSet(UErrorCode *status) {
U_CAPI USpoofCheckResult* U_EXPORT2
uspoof_openCheckResult(UErrorCode *status) {
CheckResult* checkResult = new CheckResult();
- if (checkResult == NULL) {
+ if (checkResult == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
return checkResult->asUSpoofCheckResult();
}
@@ -830,7 +831,7 @@ uspoof_getCheckResultRestrictionLevel(const USpoofCheckResult *checkResult, UErr
U_CAPI const USet* U_EXPORT2
uspoof_getCheckResultNumerics(const USpoofCheckResult *checkResult, UErrorCode *status) {
const CheckResult* This = CheckResult::validateThis(checkResult, *status);
- if (U_FAILURE(*status)) { return NULL; }
+ if (U_FAILURE(*status)) { return nullptr; }
return This->fNumerics.toUSet();
}
diff --git a/contrib/libs/icu/i18n/uspoof_build.cpp b/contrib/libs/icu/i18n/uspoof_build.cpp
index 192fb9a688..098d272e19 100644
--- a/contrib/libs/icu/i18n/uspoof_build.cpp
+++ b/contrib/libs/icu/i18n/uspoof_build.cpp
@@ -53,16 +53,16 @@ uspoof_openFromSource(const char *confusables, int32_t confusablesLen,
int32_t *errorType, UParseError *pe, UErrorCode *status) {
uspoof_internalInitStatics(status);
if (U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
#if UCONFIG_NO_REGULAR_EXPRESSIONS
*status = U_UNSUPPORTED_ERROR;
- return NULL;
+ return nullptr;
#else
- if (errorType!=NULL) {
+ if (errorType!=nullptr) {
*errorType = 0;
}
- if (pe != NULL) {
+ if (pe != nullptr) {
pe->line = 0;
pe->offset = 0;
pe->preContext[0] = 0;
@@ -72,26 +72,26 @@ uspoof_openFromSource(const char *confusables, int32_t confusablesLen,
// Set up a shell of a spoof detector, with empty data.
SpoofData *newSpoofData = new SpoofData(*status);
- if (newSpoofData == NULL) {
+ if (newSpoofData == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
if (U_FAILURE(*status)) {
delete newSpoofData;
- return NULL;
+ return nullptr;
}
SpoofImpl *This = new SpoofImpl(newSpoofData, *status);
- if (This == NULL) {
+ if (This == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
delete newSpoofData; // explicit delete as the destructor for SpoofImpl won't be called.
- return NULL;
+ return nullptr;
}
if (U_FAILURE(*status)) {
delete This; // no delete for newSpoofData, as the SpoofImpl destructor will delete it.
- return NULL;
+ return nullptr;
}
// Compile the binary data from the source (text) format.
@@ -99,7 +99,7 @@ uspoof_openFromSource(const char *confusables, int32_t confusablesLen,
if (U_FAILURE(*status)) {
delete This;
- This = NULL;
+ This = nullptr;
}
return (USpoofChecker *)This;
#endif // UCONFIG_NO_REGULAR_EXPRESSIONS
diff --git a/contrib/libs/icu/i18n/uspoof_conf.cpp b/contrib/libs/icu/i18n/uspoof_conf.cpp
index 04081cabfb..42dba1c037 100644
--- a/contrib/libs/icu/i18n/uspoof_conf.cpp
+++ b/contrib/libs/icu/i18n/uspoof_conf.cpp
@@ -63,36 +63,32 @@ U_NAMESPACE_USE
// at the same time
//
-SPUString::SPUString(UnicodeString *s) {
- fStr = s;
+SPUString::SPUString(LocalPointer<UnicodeString> s) {
+ fStr = std::move(s);
fCharOrStrTableIndex = 0;
}
SPUString::~SPUString() {
- delete fStr;
}
-SPUStringPool::SPUStringPool(UErrorCode &status) : fVec(NULL), fHash(NULL) {
- fVec = new UVector(status);
- if (fVec == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
+SPUStringPool::SPUStringPool(UErrorCode &status) : fVec(nullptr), fHash(nullptr) {
+ LocalPointer<UVector> vec(new UVector(status), status);
+ if (U_FAILURE(status)) {
return;
}
+ vec->setDeleter(
+ [](void *obj) {delete (SPUString *)obj;});
+ fVec = vec.orphan();
fHash = uhash_open(uhash_hashUnicodeString, // key hash function
uhash_compareUnicodeString, // Key Comparator
- NULL, // Value Comparator
+ nullptr, // Value Comparator
&status);
}
SPUStringPool::~SPUStringPool() {
- int i;
- for (i=fVec->size()-1; i>=0; i--) {
- SPUString *s = static_cast<SPUString *>(fVec->elementAt(i));
- delete s;
- }
delete fVec;
uhash_close(fHash);
}
@@ -135,18 +131,21 @@ void SPUStringPool::sort(UErrorCode &status) {
SPUString *SPUStringPool::addString(UnicodeString *src, UErrorCode &status) {
+ LocalPointer<UnicodeString> lpSrc(src);
+ if (U_FAILURE(status)) {
+ return nullptr;
+ }
SPUString *hashedString = static_cast<SPUString *>(uhash_get(fHash, src));
- if (hashedString != NULL) {
- delete src;
- } else {
- hashedString = new SPUString(src);
- if (hashedString == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return NULL;
- }
- uhash_put(fHash, src, hashedString, &status);
- fVec->addElementX(hashedString, status);
+ if (hashedString != nullptr) {
+ return hashedString;
+ }
+ LocalPointer<SPUString> spuStr(new SPUString(std::move(lpSrc)), status);
+ hashedString = spuStr.getAlias();
+ fVec->adoptElement(spuStr.orphan(), status);
+ if (U_FAILURE(status)) {
+ return nullptr;
}
+ uhash_put(fHash, src, hashedString, &status);
return hashedString;
}
@@ -154,43 +153,43 @@ SPUString *SPUStringPool::addString(UnicodeString *src, UErrorCode &status) {
ConfusabledataBuilder::ConfusabledataBuilder(SpoofImpl *spImpl, UErrorCode &status) :
fSpoofImpl(spImpl),
- fInput(NULL),
- fTable(NULL),
- fKeySet(NULL),
- fKeyVec(NULL),
- fValueVec(NULL),
- fStringTable(NULL),
- stringPool(NULL),
- fParseLine(NULL),
- fParseHexNum(NULL),
+ fInput(nullptr),
+ fTable(nullptr),
+ fKeySet(nullptr),
+ fKeyVec(nullptr),
+ fValueVec(nullptr),
+ fStringTable(nullptr),
+ stringPool(nullptr),
+ fParseLine(nullptr),
+ fParseHexNum(nullptr),
fLineNum(0)
{
if (U_FAILURE(status)) {
return;
}
- fTable = uhash_open(uhash_hashLong, uhash_compareLong, NULL, &status);
+ fTable = uhash_open(uhash_hashLong, uhash_compareLong, nullptr, &status);
fKeySet = new UnicodeSet();
- if (fKeySet == NULL) {
+ if (fKeySet == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
fKeyVec = new UVector(status);
- if (fKeyVec == NULL) {
+ if (fKeyVec == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
fValueVec = new UVector(status);
- if (fValueVec == NULL) {
+ if (fValueVec == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
stringPool = new SPUStringPool(status);
- if (stringPool == NULL) {
+ if (stringPool == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -218,7 +217,7 @@ void ConfusabledataBuilder::buildConfusableData(SpoofImpl * spImpl, const char *
}
ConfusabledataBuilder builder(spImpl, status);
builder.build(confusables, confusablesLen, status);
- if (U_FAILURE(status) && errorType != NULL) {
+ if (U_FAILURE(status) && errorType != nullptr) {
*errorType = USPOOF_SINGLE_SCRIPT_CONFUSABLE;
pe->line = builder.fLineNum;
}
@@ -228,22 +227,22 @@ void ConfusabledataBuilder::buildConfusableData(SpoofImpl * spImpl, const char *
void ConfusabledataBuilder::build(const char * confusables, int32_t confusablesLen,
UErrorCode &status) {
- // Convert the user input data from UTF-8 to UChar (UTF-16)
+ // Convert the user input data from UTF-8 to char16_t (UTF-16)
int32_t inputLen = 0;
if (U_FAILURE(status)) {
return;
}
- u_strFromUTF8(NULL, 0, &inputLen, confusables, confusablesLen, &status);
+ u_strFromUTF8(nullptr, 0, &inputLen, confusables, confusablesLen, &status);
if (status != U_BUFFER_OVERFLOW_ERROR) {
return;
}
status = U_ZERO_ERROR;
- fInput = static_cast<UChar *>(uprv_malloc((inputLen+1) * sizeof(UChar)));
- if (fInput == NULL) {
+ fInput = static_cast<char16_t *>(uprv_malloc((inputLen+1) * sizeof(char16_t)));
+ if (fInput == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
- u_strFromUTF8(fInput, inputLen+1, NULL, confusables, confusablesLen, &status);
+ u_strFromUTF8(fInput, inputLen+1, nullptr, confusables, confusablesLen, &status);
// Regular Expression to parse a line from Confusables.txt. The expression will match
@@ -264,12 +263,12 @@ void ConfusabledataBuilder::build(const char * confusables, int32_t confusablesL
"|^([ \\t]*(?:#.*?)?)$" // OR match empty lines or lines with only a #comment
"|^(.*?)$", -1, US_INV); // OR match any line, which catches illegal lines.
// TODO: Why are we using the regex C API here? C++ would just take UnicodeString...
- fParseLine = uregex_open(pattern.getBuffer(), pattern.length(), 0, NULL, &status);
+ fParseLine = uregex_open(pattern.getBuffer(), pattern.length(), 0, nullptr, &status);
// Regular expression for parsing a hex number out of a space-separated list of them.
// Capture group 1 gets the number, with spaces removed.
pattern = UNICODE_STRING_SIMPLE("\\s*([0-9A-F]+)");
- fParseHexNum = uregex_open(pattern.getBuffer(), pattern.length(), 0, NULL, &status);
+ fParseHexNum = uregex_open(pattern.getBuffer(), pattern.length(), 0, nullptr, &status);
// Zap any Byte Order Mark at the start of input. Changing it to a space is benign
// given the syntax of the input.
@@ -301,7 +300,7 @@ void ConfusabledataBuilder::build(const char * confusables, int32_t confusablesL
uregex_setText(fParseHexNum, &fInput[mapStringStart], mapStringLength, &status);
UnicodeString *mapString = new UnicodeString();
- if (mapString == NULL) {
+ if (mapString == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -371,7 +370,7 @@ void ConfusabledataBuilder::build(const char * confusables, int32_t confusablesL
for (UChar32 keyChar=fKeySet->getRangeStart(range);
keyChar <= fKeySet->getRangeEnd(range); keyChar++) {
SPUString *targetMapping = static_cast<SPUString *>(uhash_iget(fTable, keyChar));
- U_ASSERT(targetMapping != NULL);
+ U_ASSERT(targetMapping != nullptr);
// Set an error code if trying to consume a long string. Otherwise,
// codePointAndLengthToKey will abort on a U_ASSERT.
@@ -408,7 +407,7 @@ void ConfusabledataBuilder::build(const char * confusables, int32_t confusablesL
//
void ConfusabledataBuilder::outputData(UErrorCode &status) {
- U_ASSERT(fSpoofImpl->fSpoofData->fDataOwned == TRUE);
+ U_ASSERT(fSpoofImpl->fSpoofData->fDataOwned);
// The Key Table
// While copying the keys to the runtime array,
@@ -460,8 +459,8 @@ void ConfusabledataBuilder::outputData(UErrorCode &status) {
uint32_t stringsLength = fStringTable->length();
// Reserve an extra space so the string will be nul-terminated. This is
// only a convenience, for when debugging; it is not needed otherwise.
- UChar *strings =
- static_cast<UChar *>(fSpoofImpl->fSpoofData->reserveSpace(stringsLength*sizeof(UChar)+2, status));
+ char16_t *strings =
+ static_cast<char16_t *>(fSpoofImpl->fSpoofData->reserveSpace(stringsLength*sizeof(char16_t)+2, status));
if (U_FAILURE(status)) {
return;
}
diff --git a/contrib/libs/icu/i18n/uspoof_conf.h b/contrib/libs/icu/i18n/uspoof_conf.h
index 600d7ea42a..a5e3b9e109 100644
--- a/contrib/libs/icu/i18n/uspoof_conf.h
+++ b/contrib/libs/icu/i18n/uspoof_conf.h
@@ -39,11 +39,12 @@ U_NAMESPACE_BEGIN
// Instances of SPUString exist during the compilation process only.
struct SPUString : public UMemory {
- UnicodeString *fStr; // The actual string.
- int32_t fCharOrStrTableIndex; // Index into the final runtime data for this
- // string (or, for length 1, the single string char
- // itself, there being no string table entry for it.)
- SPUString(UnicodeString *s);
+ LocalPointer<UnicodeString> fStr; // The actual string.
+ int32_t fCharOrStrTableIndex; // Index into the final runtime data for this
+ // string (or, for length 1, the single string char
+ // itself, there being no string table entry for it.)
+
+ SPUString(LocalPointer<UnicodeString> s);
~SPUString();
};
@@ -89,7 +90,7 @@ class SPUStringPool : public UMemory {
class ConfusabledataBuilder : public UMemory {
private:
SpoofImpl *fSpoofImpl;
- UChar *fInput;
+ char16_t *fInput;
UHashtable *fTable;
UnicodeSet *fKeySet; // A set of all keys (UChar32s) that go into the four mapping tables.
diff --git a/contrib/libs/icu/i18n/uspoof_impl.cpp b/contrib/libs/icu/i18n/uspoof_impl.cpp
index b283d81321..7a6084a109 100644
--- a/contrib/libs/icu/i18n/uspoof_impl.cpp
+++ b/contrib/libs/icu/i18n/uspoof_impl.cpp
@@ -53,9 +53,9 @@ SpoofImpl::SpoofImpl() {
void SpoofImpl::construct(UErrorCode& status) {
fChecks = USPOOF_ALL_CHECKS;
- fSpoofData = NULL;
- fAllowedCharsSet = NULL;
- fAllowedLocales = NULL;
+ fSpoofData = nullptr;
+ fAllowedCharsSet = nullptr;
+ fAllowedLocales = nullptr;
fRestrictionLevel = USPOOF_HIGHLY_RESTRICTIVE;
if (U_FAILURE(status)) { return; }
@@ -63,7 +63,7 @@ void SpoofImpl::construct(UErrorCode& status) {
UnicodeSet *allowedCharsSet = new UnicodeSet(0, 0x10ffff);
fAllowedCharsSet = allowedCharsSet;
fAllowedLocales = uprv_strdup("");
- if (fAllowedCharsSet == NULL || fAllowedLocales == NULL) {
+ if (fAllowedCharsSet == nullptr || fAllowedLocales == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -73,25 +73,25 @@ void SpoofImpl::construct(UErrorCode& status) {
// Copy Constructor, used by the user level clone() function.
SpoofImpl::SpoofImpl(const SpoofImpl &src, UErrorCode &status) :
- fChecks(USPOOF_ALL_CHECKS), fSpoofData(NULL), fAllowedCharsSet(NULL) ,
- fAllowedLocales(NULL) {
+ fChecks(USPOOF_ALL_CHECKS), fSpoofData(nullptr), fAllowedCharsSet(nullptr) ,
+ fAllowedLocales(nullptr) {
if (U_FAILURE(status)) {
return;
}
fChecks = src.fChecks;
- if (src.fSpoofData != NULL) {
+ if (src.fSpoofData != nullptr) {
fSpoofData = src.fSpoofData->addReference();
}
fAllowedCharsSet = src.fAllowedCharsSet->clone();
fAllowedLocales = uprv_strdup(src.fAllowedLocales);
- if (fAllowedCharsSet == NULL || fAllowedLocales == NULL) {
+ if (fAllowedCharsSet == nullptr || fAllowedLocales == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
fRestrictionLevel = src.fRestrictionLevel;
}
SpoofImpl::~SpoofImpl() {
- if (fSpoofData != NULL) {
+ if (fSpoofData != nullptr) {
fSpoofData->removeReference(); // Will delete if refCount goes to zero.
}
delete fAllowedCharsSet;
@@ -110,10 +110,10 @@ USpoofChecker *SpoofImpl::asUSpoofChecker() {
const SpoofImpl *SpoofImpl::validateThis(const USpoofChecker *sc, UErrorCode &status) {
auto* This = validate(sc, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
- if (This->fSpoofData != NULL && !This->fSpoofData->validateDataVersion(status)) {
- return NULL;
+ if (This->fSpoofData != nullptr && !This->fSpoofData->validateDataVersion(status)) {
+ return nullptr;
}
return This;
}
@@ -126,16 +126,16 @@ SpoofImpl *SpoofImpl::validateThis(USpoofChecker *sc, UErrorCode &status) {
void SpoofImpl::setAllowedLocales(const char *localesList, UErrorCode &status) {
UnicodeSet allowedChars;
- UnicodeSet *tmpSet = NULL;
+ UnicodeSet *tmpSet = nullptr;
const char *locStart = localesList;
- const char *locEnd = NULL;
+ const char *locEnd = nullptr;
const char *localesListEnd = localesList + uprv_strlen(localesList);
int32_t localeListCount = 0; // Number of locales provided by caller.
// Loop runs once per locale from the localesList, a comma separated list of locales.
do {
locEnd = uprv_strchr(locStart, ',');
- if (locEnd == NULL) {
+ if (locEnd == nullptr) {
locEnd = localesListEnd;
}
while (*locStart == ' ') {
@@ -167,7 +167,7 @@ void SpoofImpl::setAllowedLocales(const char *localesList, UErrorCode &status) {
uprv_free((void *)fAllowedLocales);
fAllowedLocales = uprv_strdup("");
tmpSet = new UnicodeSet(0, 0x10ffff);
- if (fAllowedLocales == NULL || tmpSet == NULL) {
+ if (fAllowedLocales == nullptr || tmpSet == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -195,7 +195,7 @@ void SpoofImpl::setAllowedLocales(const char *localesList, UErrorCode &status) {
// Store the updated spoof checker state.
tmpSet = allowedChars.clone();
const char *tmpLocalesList = uprv_strdup(localesList);
- if (tmpSet == NULL || tmpLocalesList == NULL) {
+ if (tmpSet == nullptr || tmpLocalesList == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -320,10 +320,10 @@ URestrictionLevel SpoofImpl::getRestrictionLevel(const UnicodeString& input, UEr
// Section 5.2 step 2
// Java use a static UnicodeSet for this test. In C++, avoid the static variable
// and just do a simple for loop.
- UBool allASCII = TRUE;
+ UBool allASCII = true;
for (int32_t i=0, length=input.length(); i<length; i++) {
if (input.charAt(i) > 0x7f) {
- allASCII = FALSE;
+ allASCII = false;
break;
}
}
@@ -405,11 +405,11 @@ bool SpoofImpl::isIllegalCombiningDotLeadCharacter(UChar32 cp) const {
// Convert a text format hex number. Utility function used by builder code. Static.
-// Input: UChar *string text. Output: a UChar32
+// Input: char16_t *string text. Output: a UChar32
// Input has been pre-checked, and will have no non-hex chars.
// The number must fall in the code point range of 0..0x10ffff
// Static Function.
-UChar32 SpoofImpl::ScanHex(const UChar *s, int32_t start, int32_t limit, UErrorCode &status) {
+UChar32 SpoofImpl::ScanHex(const char16_t *s, int32_t start, int32_t limit, UErrorCode &status) {
if (U_FAILURE(status)) {
return 0;
}
@@ -488,16 +488,16 @@ CheckResult::~CheckResult() {
UBool SpoofData::validateDataVersion(UErrorCode &status) const {
if (U_FAILURE(status) ||
- fRawData == NULL ||
+ fRawData == nullptr ||
fRawData->fMagic != USPOOF_MAGIC ||
fRawData->fFormatVersion[0] != USPOOF_CONFUSABLE_DATA_FORMAT_VERSION ||
fRawData->fFormatVersion[1] != 0 ||
fRawData->fFormatVersion[2] != 0 ||
fRawData->fFormatVersion[3] != 0) {
status = U_INVALID_FORMAT_ERROR;
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
static UBool U_CALLCONV
@@ -515,12 +515,12 @@ spoofDataIsAcceptable(void *context,
pInfo->formatVersion[0] == USPOOF_CONFUSABLE_DATA_FORMAT_VERSION
) {
UVersionInfo *version = static_cast<UVersionInfo *>(context);
- if(version != NULL) {
+ if(version != nullptr) {
uprv_memcpy(version, pInfo->dataVersion, 4);
}
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
@@ -538,18 +538,18 @@ spoofDataIsAcceptable(void *context,
// uspoof_cleanupDefaultData - Called during cleanup.
//
-static UInitOnce gSpoofInitDefaultOnce = U_INITONCE_INITIALIZER;
+static UInitOnce gSpoofInitDefaultOnce {};
static SpoofData* gDefaultSpoofData;
static UBool U_CALLCONV
-uspoof_cleanupDefaultData(void) {
+uspoof_cleanupDefaultData() {
if (gDefaultSpoofData) {
// Will delete, assuming all user-level spoof checkers were closed.
gDefaultSpoofData->removeReference();
gDefaultSpoofData = nullptr;
gSpoofInitDefaultOnce.reset();
}
- return TRUE;
+ return true;
}
static void U_CALLCONV uspoof_loadDefaultData(UErrorCode& status) {
@@ -573,7 +573,7 @@ static void U_CALLCONV uspoof_loadDefaultData(UErrorCode& status) {
SpoofData* SpoofData::getDefault(UErrorCode& status) {
umtx_initOnce(gSpoofInitDefaultOnce, &uspoof_loadDefaultData, status);
- if (U_FAILURE(status)) { return NULL; }
+ if (U_FAILURE(status)) { return nullptr; }
gDefaultSpoofData->addReference();
return gDefaultSpoofData;
}
@@ -605,7 +605,7 @@ SpoofData::SpoofData(const void *data, int32_t length, UErrorCode &status)
status = U_INVALID_FORMAT_ERROR;
return;
}
- if (data == NULL) {
+ if (data == nullptr) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@@ -636,7 +636,7 @@ SpoofData::SpoofData(UErrorCode &status) {
fRawData = static_cast<SpoofDataHeader *>(uprv_malloc(initialSize));
fMemLimit = initialSize;
- if (fRawData == NULL) {
+ if (fRawData == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -654,14 +654,14 @@ SpoofData::SpoofData(UErrorCode &status) {
// Should be updated if any new fields are added.
// Called by constructors to put things in a known initial state.
void SpoofData::reset() {
- fRawData = NULL;
- fDataOwned = FALSE;
- fUDM = NULL;
+ fRawData = nullptr;
+ fDataOwned = false;
+ fUDM = nullptr;
fMemLimit = 0;
fRefCount = 1;
- fCFUKeys = NULL;
- fCFUValues = NULL;
- fCFUStrings = NULL;
+ fCFUKeys = nullptr;
+ fCFUValues = nullptr;
+ fCFUStrings = nullptr;
}
@@ -673,7 +673,7 @@ void SpoofData::reset() {
// during the opening of a Spoof Checker from prebuilt data.
//
// The pointers for non-existent data sections (identified by an offset of 0)
-// are set to NULL.
+// are set to nullptr.
//
// Note: During building the data, adding each new data section
// reallocs the raw data area, which likely relocates it, which
@@ -681,9 +681,9 @@ void SpoofData::reset() {
// multiple calls to this function during building.
//
void SpoofData::initPtrs(UErrorCode &status) {
- fCFUKeys = NULL;
- fCFUValues = NULL;
- fCFUStrings = NULL;
+ fCFUKeys = nullptr;
+ fCFUValues = nullptr;
+ fCFUStrings = nullptr;
if (U_FAILURE(status)) {
return;
}
@@ -694,7 +694,7 @@ void SpoofData::initPtrs(UErrorCode &status) {
fCFUValues = (uint16_t *)((char *)fRawData + fRawData->fCFUStringIndex);
}
if (fRawData->fCFUStringTable != 0) {
- fCFUStrings = (UChar *)((char *)fRawData + fRawData->fCFUStringTable);
+ fCFUStrings = (char16_t *)((char *)fRawData + fRawData->fCFUStringTable);
}
}
@@ -703,11 +703,11 @@ SpoofData::~SpoofData() {
if (fDataOwned) {
uprv_free(fRawData);
}
- fRawData = NULL;
- if (fUDM != NULL) {
+ fRawData = nullptr;
+ if (fUDM != nullptr) {
udata_close(fUDM);
}
- fUDM = NULL;
+ fUDM = nullptr;
}
@@ -726,7 +726,7 @@ SpoofData *SpoofData::addReference() {
void *SpoofData::reserveSpace(int32_t numBytes, UErrorCode &status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
if (!fDataOwned) {
UPRV_UNREACHABLE_EXIT;
@@ -806,7 +806,7 @@ int32_t SpoofData::appendValueTo(int32_t index, UnicodeString& dest) const {
// an index into the string table (for longer strings)
uint16_t value = fCFUValues[index];
if (stringLength == 1) {
- dest.append((UChar)value);
+ dest.append((char16_t)value);
} else {
dest.append(fCFUStrings + value, stringLength);
}
@@ -828,10 +828,10 @@ U_CAPI int32_t U_EXPORT2
uspoof_swap(const UDataSwapper *ds, const void *inData, int32_t length, void *outData,
UErrorCode *status) {
- if (status == NULL || U_FAILURE(*status)) {
+ if (status == nullptr || U_FAILURE(*status)) {
return 0;
}
- if(ds==NULL || inData==NULL || length<-1 || (length>0 && outData==NULL)) {
+ if(ds==nullptr || inData==nullptr || length<-1 || (length>0 && outData==nullptr)) {
*status=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -945,7 +945,7 @@ uspoof_swap(const UDataSwapper *ds, const void *inData, int32_t length, void *ou
uint32_t magic = ds->readUInt32(spoofDH->fMagic);
ds->writeUInt32((uint32_t *)&outputDH->fMagic, magic);
- if (outputDH->fFormatVersion != spoofDH->fFormatVersion) {
+ if (inBytes != outBytes) {
uprv_memcpy(outputDH->fFormatVersion, spoofDH->fFormatVersion, sizeof(spoofDH->fFormatVersion));
}
// swap starting at fLength
diff --git a/contrib/libs/icu/i18n/uspoof_impl.h b/contrib/libs/icu/i18n/uspoof_impl.h
index e75ae262bd..3bdaf76e29 100644
--- a/contrib/libs/icu/i18n/uspoof_impl.h
+++ b/contrib/libs/icu/i18n/uspoof_impl.h
@@ -28,6 +28,7 @@
#ifdef __cplusplus
#include "capi_helper.h"
+#include "umutex.h"
U_NAMESPACE_BEGIN
@@ -90,10 +91,10 @@ public:
bool isIllegalCombiningDotLeadCharacter(UChar32 cp) const;
/** parse a hex number. Untility used by the builders. */
- static UChar32 ScanHex(const UChar *s, int32_t start, int32_t limit, UErrorCode &status);
+ static UChar32 ScanHex(const char16_t *s, int32_t start, int32_t limit, UErrorCode &status);
- static UClassID U_EXPORT2 getStaticClassID(void);
- virtual UClassID getDynamicClassID(void) const override;
+ static UClassID U_EXPORT2 getStaticClassID();
+ virtual UClassID getDynamicClassID() const override;
//
// Data Members
@@ -157,7 +158,7 @@ public:
//
// String Table:
// The strings table contains all of the value strings (those of length two or greater)
-// concatenated together into one long UChar (UTF-16) array.
+// concatenated together into one long char16_t (UTF-16) array.
//
// There is no nul character or other mark between adjacent strings.
//
@@ -276,7 +277,7 @@ class SpoofData: public UMemory {
SpoofDataHeader *fRawData; // Ptr to the raw memory-mapped data
UBool fDataOwned; // True if the raw data is owned, and needs
// to be deleted when refcount goes to zero.
- UDataMemory *fUDM; // If not NULL, our data came from a
+ UDataMemory *fUDM; // If not nullptr, our data came from a
// UDataMemory, which we must close when
// we are done.
@@ -286,7 +287,7 @@ class SpoofData: public UMemory {
// Confusable data
int32_t *fCFUKeys;
uint16_t *fCFUValues;
- UChar *fCFUStrings;
+ char16_t *fCFUStrings;
friend class ConfusabledataBuilder;
};
diff --git a/contrib/libs/icu/i18n/utf16collationiterator.cpp b/contrib/libs/icu/i18n/utf16collationiterator.cpp
index f1bdfabe73..e04721f7d7 100644
--- a/contrib/libs/icu/i18n/utf16collationiterator.cpp
+++ b/contrib/libs/icu/i18n/utf16collationiterator.cpp
@@ -28,11 +28,11 @@
U_NAMESPACE_BEGIN
UTF16CollationIterator::UTF16CollationIterator(const UTF16CollationIterator &other,
- const UChar *newText)
+ const char16_t *newText)
: CollationIterator(other),
start(newText),
pos(newText + (other.pos - other.start)),
- limit(other.limit == NULL ? NULL : newText + (other.limit - other.start)) {
+ limit(other.limit == nullptr ? nullptr : newText + (other.limit - other.start)) {
}
UTF16CollationIterator::~UTF16CollationIterator() {}
@@ -66,21 +66,21 @@ UTF16CollationIterator::handleNextCE32(UChar32 &c, UErrorCode & /*errorCode*/) {
return UTRIE2_GET32_FROM_U16_SINGLE_LEAD(trie, c);
}
-UChar
+char16_t
UTF16CollationIterator::handleGetTrailSurrogate() {
if(pos == limit) { return 0; }
- UChar trail;
+ char16_t trail;
if(U16_IS_TRAIL(trail = *pos)) { ++pos; }
return trail;
}
UBool
UTF16CollationIterator::foundNULTerminator() {
- if(limit == NULL) {
+ if(limit == nullptr) {
limit = --pos;
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
@@ -90,12 +90,12 @@ UTF16CollationIterator::nextCodePoint(UErrorCode & /*errorCode*/) {
return U_SENTINEL;
}
UChar32 c = *pos;
- if(c == 0 && limit == NULL) {
+ if(c == 0 && limit == nullptr) {
limit = pos;
return U_SENTINEL;
}
++pos;
- UChar trail;
+ char16_t trail;
if(U16_IS_LEAD(c) && pos != limit && U16_IS_TRAIL(trail = *pos)) {
++pos;
return U16_GET_SUPPLEMENTARY(c, trail);
@@ -110,7 +110,7 @@ UTF16CollationIterator::previousCodePoint(UErrorCode & /*errorCode*/) {
return U_SENTINEL;
}
UChar32 c = *--pos;
- UChar lead;
+ char16_t lead;
if(U16_IS_TRAIL(c) && pos != start && U16_IS_LEAD(lead = *(pos - 1))) {
--pos;
return U16_GET_SUPPLEMENTARY(lead, c);
@@ -123,7 +123,7 @@ void
UTF16CollationIterator::forwardNumCodePoints(int32_t num, UErrorCode & /*errorCode*/) {
while(num > 0 && pos != limit) {
UChar32 c = *pos;
- if(c == 0 && limit == NULL) {
+ if(c == 0 && limit == nullptr) {
limit = pos;
break;
}
@@ -149,19 +149,19 @@ UTF16CollationIterator::backwardNumCodePoints(int32_t num, UErrorCode & /*errorC
// FCDUTF16CollationIterator ----------------------------------------------- ***
FCDUTF16CollationIterator::FCDUTF16CollationIterator(const FCDUTF16CollationIterator &other,
- const UChar *newText)
+ const char16_t *newText)
: UTF16CollationIterator(other),
rawStart(newText),
segmentStart(newText + (other.segmentStart - other.rawStart)),
- segmentLimit(other.segmentLimit == NULL ? NULL : newText + (other.segmentLimit - other.rawStart)),
- rawLimit(other.rawLimit == NULL ? NULL : newText + (other.rawLimit - other.rawStart)),
+ segmentLimit(other.segmentLimit == nullptr ? nullptr : newText + (other.segmentLimit - other.rawStart)),
+ rawLimit(other.rawLimit == nullptr ? nullptr : newText + (other.rawLimit - other.rawStart)),
nfcImpl(other.nfcImpl),
normalized(other.normalized),
checkDir(other.checkDir) {
if(checkDir != 0 || other.start == other.segmentStart) {
start = newText + (other.start - other.rawStart);
pos = newText + (other.pos - other.rawStart);
- limit = other.limit == NULL ? NULL : newText + (other.limit - other.rawStart);
+ limit = other.limit == nullptr ? nullptr : newText + (other.limit - other.rawStart);
} else {
start = normalized.getBuffer();
pos = start + (other.pos - other.start);
@@ -239,11 +239,11 @@ FCDUTF16CollationIterator::handleNextCE32(UChar32 &c, UErrorCode &errorCode) {
UBool
FCDUTF16CollationIterator::foundNULTerminator() {
- if(limit == NULL) {
+ if(limit == nullptr) {
limit = rawLimit = --pos;
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
@@ -265,7 +265,7 @@ FCDUTF16CollationIterator::nextCodePoint(UErrorCode &errorCode) {
}
c = *pos++;
}
- } else if(c == 0 && limit == NULL) {
+ } else if(c == 0 && limit == nullptr) {
limit = rawLimit = --pos;
return U_SENTINEL;
}
@@ -277,7 +277,7 @@ FCDUTF16CollationIterator::nextCodePoint(UErrorCode &errorCode) {
switchToForward();
}
}
- UChar trail;
+ char16_t trail;
if(U16_IS_LEAD(c) && pos != limit && U16_IS_TRAIL(trail = *pos)) {
++pos;
return U16_GET_SUPPLEMENTARY(c, trail);
@@ -313,7 +313,7 @@ FCDUTF16CollationIterator::previousCodePoint(UErrorCode &errorCode) {
switchToBackward();
}
}
- UChar lead;
+ char16_t lead;
if(U16_IS_TRAIL(c) && pos != start && U16_IS_LEAD(lead = *(pos - 1))) {
--pos;
return U16_GET_SUPPLEMENTARY(lead, c);
@@ -361,7 +361,7 @@ FCDUTF16CollationIterator::switchToForward() {
// Switch to checking forward from it.
pos = start = segmentStart = segmentLimit;
// Note: If this segment is at the end of the input text,
- // then it might help to return FALSE to indicate that, so that
+ // then it might help to return false to indicate that, so that
// we do not have to re-check and normalize when we turn around and go backwards.
// However, that would complicate the call sites for an optimization of an unusual case.
}
@@ -372,14 +372,14 @@ FCDUTF16CollationIterator::switchToForward() {
UBool
FCDUTF16CollationIterator::nextSegment(UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
U_ASSERT(checkDir > 0 && pos != limit);
// The input text [segmentStart..pos[ passes the FCD check.
- const UChar *p = pos;
+ const char16_t *p = pos;
uint8_t prevCC = 0;
for(;;) {
// Fetch the next character's fcd16 value.
- const UChar *q = p;
+ const char16_t *q = p;
uint16_t fcd16 = nfcImpl.nextFCD16(p, rawLimit);
uint8_t leadCC = (uint8_t)(fcd16 >> 8);
if(leadCC == 0 && q != pos) {
@@ -392,7 +392,7 @@ FCDUTF16CollationIterator::nextSegment(UErrorCode &errorCode) {
do {
q = p;
} while(p != rawLimit && nfcImpl.nextFCD16(p, rawLimit) > 0xff);
- if(!normalize(pos, q, errorCode)) { return FALSE; }
+ if(!normalize(pos, q, errorCode)) { return false; }
pos = start;
break;
}
@@ -405,7 +405,7 @@ FCDUTF16CollationIterator::nextSegment(UErrorCode &errorCode) {
}
U_ASSERT(pos != limit);
checkDir = 0;
- return TRUE;
+ return true;
}
void
@@ -436,14 +436,14 @@ FCDUTF16CollationIterator::switchToBackward() {
UBool
FCDUTF16CollationIterator::previousSegment(UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
U_ASSERT(checkDir < 0 && pos != start);
// The input text [pos..segmentLimit[ passes the FCD check.
- const UChar *p = pos;
+ const char16_t *p = pos;
uint8_t nextCC = 0;
for(;;) {
// Fetch the previous character's fcd16 value.
- const UChar *q = p;
+ const char16_t *q = p;
uint16_t fcd16 = nfcImpl.previousFCD16(rawStart, p);
uint8_t trailCC = (uint8_t)fcd16;
if(trailCC == 0 && q != pos) {
@@ -458,7 +458,7 @@ FCDUTF16CollationIterator::previousSegment(UErrorCode &errorCode) {
q = p;
} while(fcd16 > 0xff && p != rawStart &&
(fcd16 = nfcImpl.previousFCD16(rawStart, p)) != 0);
- if(!normalize(q, pos, errorCode)) { return FALSE; }
+ if(!normalize(q, pos, errorCode)) { return false; }
pos = limit;
break;
}
@@ -471,22 +471,22 @@ FCDUTF16CollationIterator::previousSegment(UErrorCode &errorCode) {
}
U_ASSERT(pos != start);
checkDir = 0;
- return TRUE;
+ return true;
}
UBool
-FCDUTF16CollationIterator::normalize(const UChar *from, const UChar *to, UErrorCode &errorCode) {
+FCDUTF16CollationIterator::normalize(const char16_t *from, const char16_t *to, UErrorCode &errorCode) {
// NFD without argument checking.
U_ASSERT(U_SUCCESS(errorCode));
nfcImpl.decompose(from, to, normalized, (int32_t)(to - from), errorCode);
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
// Switch collation processing into the FCD buffer
// with the result of normalizing [segmentStart, segmentLimit[.
segmentStart = from;
segmentLimit = to;
start = normalized.getBuffer();
limit = start + normalized.length();
- return TRUE;
+ return true;
}
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/utf16collationiterator.h b/contrib/libs/icu/i18n/utf16collationiterator.h
index 6db70511b0..34634bf494 100644
--- a/contrib/libs/icu/i18n/utf16collationiterator.h
+++ b/contrib/libs/icu/i18n/utf16collationiterator.h
@@ -34,11 +34,11 @@ U_NAMESPACE_BEGIN
class U_I18N_API UTF16CollationIterator : public CollationIterator {
public:
UTF16CollationIterator(const CollationData *d, UBool numeric,
- const UChar *s, const UChar *p, const UChar *lim)
+ const char16_t *s, const char16_t *p, const char16_t *lim)
: CollationIterator(d, numeric),
start(s), pos(p), limit(lim) {}
- UTF16CollationIterator(const UTF16CollationIterator &other, const UChar *newText);
+ UTF16CollationIterator(const UTF16CollationIterator &other, const char16_t *newText);
virtual ~UTF16CollationIterator();
@@ -48,7 +48,7 @@ public:
virtual int32_t getOffset() const override;
- void setText(const UChar *s, const UChar *lim) {
+ void setText(const char16_t *s, const char16_t *lim) {
reset();
start = pos = s;
limit = lim;
@@ -62,11 +62,11 @@ protected:
// Copy constructor only for subclasses which set the pointers.
UTF16CollationIterator(const UTF16CollationIterator &other)
: CollationIterator(other),
- start(NULL), pos(NULL), limit(NULL) {}
+ start(nullptr), pos(nullptr), limit(nullptr) {}
virtual uint32_t handleNextCE32(UChar32 &c, UErrorCode &errorCode) override;
- virtual UChar handleGetTrailSurrogate() override;
+ virtual char16_t handleGetTrailSurrogate() override;
virtual UBool foundNULTerminator() override;
@@ -75,8 +75,8 @@ protected:
virtual void backwardNumCodePoints(int32_t num, UErrorCode &errorCode) override;
// UTF-16 string pointers.
- // limit can be NULL for NUL-terminated strings.
- const UChar *start, *pos, *limit;
+ // limit can be nullptr for NUL-terminated strings.
+ const char16_t *start, *pos, *limit;
};
/**
@@ -85,13 +85,13 @@ protected:
class U_I18N_API FCDUTF16CollationIterator : public UTF16CollationIterator {
public:
FCDUTF16CollationIterator(const CollationData *data, UBool numeric,
- const UChar *s, const UChar *p, const UChar *lim)
+ const char16_t *s, const char16_t *p, const char16_t *lim)
: UTF16CollationIterator(data, numeric, s, p, lim),
- rawStart(s), segmentStart(p), segmentLimit(NULL), rawLimit(lim),
+ rawStart(s), segmentStart(p), segmentLimit(nullptr), rawLimit(lim),
nfcImpl(data->nfcImpl),
checkDir(1) {}
- FCDUTF16CollationIterator(const FCDUTF16CollationIterator &other, const UChar *newText);
+ FCDUTF16CollationIterator(const FCDUTF16CollationIterator &other, const char16_t *newText);
virtual ~FCDUTF16CollationIterator();
@@ -143,10 +143,10 @@ private:
*/
UBool previousSegment(UErrorCode &errorCode);
- UBool normalize(const UChar *from, const UChar *to, UErrorCode &errorCode);
+ UBool normalize(const char16_t *from, const char16_t *to, UErrorCode &errorCode);
// Text pointers: The input text is [rawStart, rawLimit[
- // where rawLimit can be NULL for NUL-terminated text.
+ // where rawLimit can be nullptr for NUL-terminated text.
//
// checkDir > 0:
//
@@ -168,11 +168,11 @@ private:
// or the current segment had to be normalized so that
// [segmentStart..segmentLimit[ turned into the normalized string,
// corresponding to normalized.getBuffer()==start<=pos<=limit==start+normalized.length().
- const UChar *rawStart;
- const UChar *segmentStart;
- const UChar *segmentLimit;
- // rawLimit==NULL for a NUL-terminated string.
- const UChar *rawLimit;
+ const char16_t *rawStart;
+ const char16_t *segmentStart;
+ const char16_t *segmentLimit;
+ // rawLimit==nullptr for a NUL-terminated string.
+ const char16_t *rawLimit;
const Normalizer2Impl &nfcImpl;
UnicodeString normalized;
diff --git a/contrib/libs/icu/i18n/utf8collationiterator.cpp b/contrib/libs/icu/i18n/utf8collationiterator.cpp
index 345b1994ef..ea7278afc6 100644
--- a/contrib/libs/icu/i18n/utf8collationiterator.cpp
+++ b/contrib/libs/icu/i18n/utf8collationiterator.cpp
@@ -80,15 +80,15 @@ UBool
UTF8CollationIterator::foundNULTerminator() {
if(length < 0) {
length = --pos;
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
UBool
UTF8CollationIterator::forbidSurrogateCodePoints() const {
- return TRUE;
+ return true;
}
UChar32
@@ -224,7 +224,7 @@ FCDUTF8CollationIterator::nextHasLccc() const {
// The lowest code point with ccc!=0 is U+0300 which is CC 80 in UTF-8.
// CJK U+4000..U+DFFF except U+Axxx are also FCD-inert. (Lead bytes E4..ED except EA.)
UChar32 c = u8[pos];
- if(c < 0xcc || (0xe4 <= c && c <= 0xed && c != 0xea)) { return FALSE; }
+ if(c < 0xcc || (0xe4 <= c && c <= 0xed && c != 0xea)) { return false; }
int32_t i = pos;
U8_NEXT_OR_FFFD(u8, i, length, c);
if(c > 0xffff) { c = U16_LEAD(c); }
@@ -235,18 +235,18 @@ UBool
FCDUTF8CollationIterator::previousHasTccc() const {
U_ASSERT(state == CHECK_BWD && pos != 0);
UChar32 c = u8[pos - 1];
- if(U8_IS_SINGLE(c)) { return FALSE; }
+ if(U8_IS_SINGLE(c)) { return false; }
int32_t i = pos;
U8_PREV_OR_FFFD(u8, 0, i, c);
if(c > 0xffff) { c = U16_LEAD(c); }
return CollationFCD::hasTccc(c);
}
-UChar
+char16_t
FCDUTF8CollationIterator::handleGetTrailSurrogate() {
if(state != IN_NORMALIZED) { return 0; }
U_ASSERT(pos < normalized.length());
- UChar trail;
+ char16_t trail;
if(U16_IS_TRAIL(trail = normalized[pos])) { ++pos; }
return trail;
}
@@ -255,9 +255,9 @@ UBool
FCDUTF8CollationIterator::foundNULTerminator() {
if(state == CHECK_FWD && length < 0) {
length = --pos;
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
@@ -383,7 +383,7 @@ FCDUTF8CollationIterator::switchToForward() {
UBool
FCDUTF8CollationIterator::nextSegment(UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
U_ASSERT(state == CHECK_FWD && pos != length);
// The input text [start..pos[ passes the FCD check.
int32_t segmentStart = pos;
@@ -414,12 +414,12 @@ FCDUTF8CollationIterator::nextSegment(UErrorCode &errorCode) {
}
s.append(c);
}
- if(!normalize(s, errorCode)) { return FALSE; }
+ if(!normalize(s, errorCode)) { return false; }
start = segmentStart;
limit = pos;
state = IN_NORMALIZED;
pos = 0;
- return TRUE;
+ return true;
}
prevCC = (uint8_t)fcd16;
if(pos == length || prevCC == 0) {
@@ -431,7 +431,7 @@ FCDUTF8CollationIterator::nextSegment(UErrorCode &errorCode) {
pos = segmentStart;
U_ASSERT(pos != limit);
state = IN_FCD_SEGMENT;
- return TRUE;
+ return true;
}
void
@@ -462,7 +462,7 @@ FCDUTF8CollationIterator::switchToBackward() {
UBool
FCDUTF8CollationIterator::previousSegment(UErrorCode &errorCode) {
- if(U_FAILURE(errorCode)) { return FALSE; }
+ if(U_FAILURE(errorCode)) { return false; }
U_ASSERT(state == CHECK_BWD && pos != 0);
// The input text [pos..limit[ passes the FCD check.
int32_t segmentLimit = pos;
@@ -496,12 +496,12 @@ FCDUTF8CollationIterator::previousSegment(UErrorCode &errorCode) {
s.append(c);
}
s.reverse();
- if(!normalize(s, errorCode)) { return FALSE; }
+ if(!normalize(s, errorCode)) { return false; }
limit = segmentLimit;
start = pos;
state = IN_NORMALIZED;
pos = normalized.length();
- return TRUE;
+ return true;
}
nextCC = (uint8_t)(fcd16 >> 8);
if(pos == 0 || nextCC == 0) {
@@ -513,7 +513,7 @@ FCDUTF8CollationIterator::previousSegment(UErrorCode &errorCode) {
pos = segmentLimit;
U_ASSERT(pos != start);
state = IN_FCD_SEGMENT;
- return TRUE;
+ return true;
}
UBool
diff --git a/contrib/libs/icu/i18n/utf8collationiterator.h b/contrib/libs/icu/i18n/utf8collationiterator.h
index 09cfce4369..13ca87846b 100644
--- a/contrib/libs/icu/i18n/utf8collationiterator.h
+++ b/contrib/libs/icu/i18n/utf8collationiterator.h
@@ -98,7 +98,7 @@ public:
protected:
virtual uint32_t handleNextCE32(UChar32 &c, UErrorCode &errorCode) override;
- virtual UChar handleGetTrailSurrogate() override;
+ virtual char16_t handleGetTrailSurrogate() override;
virtual UBool foundNULTerminator() override;
diff --git a/contrib/libs/icu/i18n/utmscale.cpp b/contrib/libs/icu/i18n/utmscale.cpp
index 7bf6eec331..61df43e778 100644
--- a/contrib/libs/icu/i18n/utmscale.cpp
+++ b/contrib/libs/icu/i18n/utmscale.cpp
@@ -39,7 +39,7 @@ static const int64_t timeScaleTable[UDTS_MAX_SCALE][UTSV_MAX_SCALE_VALUE] = {
U_CAPI int64_t U_EXPORT2
utmscale_getTimeScaleValue(UDateTimeScale timeScale, UTimeScaleValue value, UErrorCode *status)
{
- if (status == NULL || U_FAILURE(*status)) {
+ if (status == nullptr || U_FAILURE(*status)) {
return 0;
}
@@ -54,11 +54,10 @@ utmscale_getTimeScaleValue(UDateTimeScale timeScale, UTimeScaleValue value, UErr
}
U_CAPI int64_t U_EXPORT2
-utmscale_fromInt64(int64_t otherTime, UDateTimeScale timeScale, UErrorCode *status)
-{
+utmscale_fromInt64(int64_t otherTime, UDateTimeScale timeScale, UErrorCode *status) UPRV_NO_SANITIZE_UNDEFINED {
const int64_t *data;
- if (status == NULL || U_FAILURE(*status)) {
+ if (status == nullptr || U_FAILURE(*status)) {
return 0;
}
@@ -78,11 +77,10 @@ utmscale_fromInt64(int64_t otherTime, UDateTimeScale timeScale, UErrorCode *stat
}
U_CAPI int64_t U_EXPORT2
-utmscale_toInt64(int64_t universalTime, UDateTimeScale timeScale, UErrorCode *status)
-{
+utmscale_toInt64(int64_t universalTime, UDateTimeScale timeScale, UErrorCode *status) UPRV_NO_SANITIZE_UNDEFINED {
const int64_t *data;
- if (status == NULL || U_FAILURE(*status)) {
+ if (status == nullptr || U_FAILURE(*status)) {
return 0;
}
diff --git a/contrib/libs/icu/i18n/utrans.cpp b/contrib/libs/icu/i18n/utrans.cpp
index 1cbba81d65..390335f334 100644
--- a/contrib/libs/icu/i18n/utrans.cpp
+++ b/contrib/libs/icu/i18n/utrans.cpp
@@ -28,7 +28,7 @@
#include "rbt.h"
// Following macro is to be followed by <return value>';' or just ';'
-#define utrans_ENTRY(s) if ((s)==NULL || U_FAILURE(*(s))) return
+#define utrans_ENTRY(s) if ((s)==nullptr || U_FAILURE(*(s))) return
/********************************************************************
* Replaceable-UReplaceableCallbacks glue
@@ -60,7 +60,7 @@ public:
virtual void copy(int32_t start, int32_t limit, int32_t dest) override;
- // virtual Replaceable *clone() const { return NULL; } same as default
+ // virtual Replaceable *clone() const { return nullptr; } same as default
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
@@ -80,7 +80,7 @@ protected:
virtual int32_t getLength() const override;
- virtual UChar getCharAt(int32_t offset) const override;
+ virtual char16_t getCharAt(int32_t offset) const override;
virtual UChar32 getChar32At(int32_t offset) const override;
};
@@ -101,7 +101,7 @@ int32_t ReplaceableGlue::getLength() const {
return (*func->length)(rep);
}
-UChar ReplaceableGlue::getCharAt(int32_t offset) const {
+char16_t ReplaceableGlue::getCharAt(int32_t offset) const {
return (*func->charAt)(rep, offset);
}
@@ -132,36 +132,36 @@ U_NAMESPACE_END
U_NAMESPACE_USE
U_CAPI UTransliterator* U_EXPORT2
-utrans_openU(const UChar *id,
+utrans_openU(const char16_t *id,
int32_t idLength,
UTransDirection dir,
- const UChar *rules,
+ const char16_t *rules,
int32_t rulesLength,
UParseError *parseError,
UErrorCode *status) {
- if(status==NULL || U_FAILURE(*status)) {
- return NULL;
+ if(status==nullptr || U_FAILURE(*status)) {
+ return nullptr;
}
- if (id == NULL) {
+ if (id == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
UParseError temp;
- if(parseError == NULL){
+ if(parseError == nullptr){
parseError = &temp;
}
UnicodeString ID(idLength<0, id, idLength); // r-o alias
- if(rules==NULL){
+ if(rules==nullptr){
- Transliterator *trans = NULL;
+ Transliterator *trans = nullptr;
trans = Transliterator::createInstance(ID, dir, *parseError, *status);
if(U_FAILURE(*status)){
- return NULL;
+ return nullptr;
}
return (UTransliterator*) trans;
}else{
@@ -169,10 +169,10 @@ utrans_openU(const UChar *id,
rules,
rulesLength); // r-o alias
- Transliterator *trans = NULL;
+ Transliterator *trans = nullptr;
trans = Transliterator::createFromRules(ID, ruleStr, dir, *parseError, *status);
if(U_FAILURE(*status)) {
- return NULL;
+ return nullptr;
}
return (UTransliterator*) trans;
@@ -182,7 +182,7 @@ utrans_openU(const UChar *id,
U_CAPI UTransliterator* U_EXPORT2
utrans_open(const char* id,
UTransDirection dir,
- const UChar* rules, /* may be Null */
+ const char16_t* rules, /* may be Null */
int32_t rulesLength, /* -1 if null-terminated */
UParseError* parseError, /* may be Null */
UErrorCode* status) {
@@ -196,7 +196,7 @@ U_CAPI UTransliterator* U_EXPORT2
utrans_openInverse(const UTransliterator* trans,
UErrorCode* status) {
- utrans_ENTRY(status) NULL;
+ utrans_ENTRY(status) nullptr;
UTransliterator* result =
(UTransliterator*) ((Transliterator*) trans)->createInverse(*status);
@@ -208,15 +208,15 @@ U_CAPI UTransliterator* U_EXPORT2
utrans_clone(const UTransliterator* trans,
UErrorCode* status) {
- utrans_ENTRY(status) NULL;
+ utrans_ENTRY(status) nullptr;
- if (trans == NULL) {
+ if (trans == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
Transliterator *t = ((Transliterator*) trans)->clone();
- if (t == NULL) {
+ if (t == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
}
return (UTransliterator*) t;
@@ -227,12 +227,12 @@ utrans_close(UTransliterator* trans) {
delete (Transliterator*) trans;
}
-U_CAPI const UChar * U_EXPORT2
+U_CAPI const char16_t * U_EXPORT2
utrans_getUnicodeID(const UTransliterator *trans,
int32_t *resultLength) {
// Transliterator keeps its ID NUL-terminated
const UnicodeString &ID=((Transliterator*) trans)->getID();
- if(resultLength!=NULL) {
+ if(resultLength!=nullptr) {
*resultLength=ID.length();
}
return ID.getBuffer();
@@ -254,7 +254,7 @@ utrans_register(UTransliterator* adoptedTrans,
}
U_CAPI void U_EXPORT2
-utrans_unregisterID(const UChar* id, int32_t idLength) {
+utrans_unregisterID(const char16_t* id, int32_t idLength) {
UnicodeString ID(idLength<0, id, idLength); // r-o alias
Transliterator::unregister(ID);
}
@@ -267,37 +267,37 @@ utrans_unregister(const char* id) {
U_CAPI void U_EXPORT2
utrans_setFilter(UTransliterator* trans,
- const UChar* filterPattern,
+ const char16_t* filterPattern,
int32_t filterPatternLen,
UErrorCode* status) {
utrans_ENTRY(status);
- UnicodeFilter* filter = NULL;
- if (filterPattern != NULL && *filterPattern != 0) {
+ UnicodeFilter* filter = nullptr;
+ if (filterPattern != nullptr && *filterPattern != 0) {
// Create read only alias of filterPattern:
UnicodeString pat(filterPatternLen < 0, filterPattern, filterPatternLen);
filter = new UnicodeSet(pat, *status);
- /* test for NULL */
- if (filter == NULL) {
+ /* test for nullptr */
+ if (filter == nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
return;
}
if (U_FAILURE(*status)) {
delete filter;
- filter = NULL;
+ filter = nullptr;
}
}
((Transliterator*) trans)->adoptFilter(filter);
}
U_CAPI int32_t U_EXPORT2
-utrans_countAvailableIDs(void) {
+utrans_countAvailableIDs() {
return Transliterator::countAvailableIDs();
}
U_CAPI int32_t U_EXPORT2
utrans_getAvailableID(int32_t index,
- char* buf, // may be NULL
+ char* buf, // may be nullptr
int32_t bufCapacity) {
return Transliterator::getAvailableID(index).extract(0, 0x7fffffff, buf, bufCapacity, US_INV);
}
@@ -312,17 +312,17 @@ typedef struct UTransEnumeration {
U_CDECL_BEGIN
static int32_t U_CALLCONV
utrans_enum_count(UEnumeration *uenum, UErrorCode *pErrorCode) {
- if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
+ if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) {
return 0;
}
return ((UTransEnumeration *)uenum)->count;
}
-static const UChar* U_CALLCONV
+static const char16_t* U_CALLCONV
utrans_enum_unext(UEnumeration *uenum,
int32_t* resultLength,
UErrorCode *pErrorCode) {
- if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
+ if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) {
return 0;
}
@@ -331,22 +331,22 @@ utrans_enum_unext(UEnumeration *uenum,
if(index<ute->count) {
const UnicodeString &ID=Transliterator::getAvailableID(index);
ute->index=index+1;
- if(resultLength!=NULL) {
+ if(resultLength!=nullptr) {
*resultLength=ID.length();
}
// Transliterator keeps its ID NUL-terminated
return ID.getBuffer();
}
- if(resultLength!=NULL) {
+ if(resultLength!=nullptr) {
*resultLength=0;
}
- return NULL;
+ return nullptr;
}
static void U_CALLCONV
utrans_enum_reset(UEnumeration *uenum, UErrorCode *pErrorCode) {
- if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
+ if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) {
return;
}
@@ -362,8 +362,8 @@ utrans_enum_close(UEnumeration *uenum) {
U_CDECL_END
static const UEnumeration utransEnumeration={
- NULL,
- NULL,
+ nullptr,
+ nullptr,
utrans_enum_close,
utrans_enum_count,
utrans_enum_unext,
@@ -375,14 +375,14 @@ U_CAPI UEnumeration * U_EXPORT2
utrans_openIDs(UErrorCode *pErrorCode) {
UTransEnumeration *ute;
- if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
- return NULL;
+ if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) {
+ return nullptr;
}
ute=(UTransEnumeration *)uprv_malloc(sizeof(UTransEnumeration));
- if(ute==NULL) {
+ if(ute==nullptr) {
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
- return NULL;
+ return nullptr;
}
ute->uenum=utransEnumeration;
@@ -436,7 +436,7 @@ utrans_transIncremental(const UTransliterator* trans,
U_CAPI void U_EXPORT2
utrans_transUChars(const UTransliterator* trans,
- UChar* text,
+ char16_t* text,
int32_t* textLength,
int32_t textCapacity,
int32_t start,
@@ -450,7 +450,7 @@ utrans_transUChars(const UTransliterator* trans,
return;
}
- int32_t textLen = (textLength == NULL || *textLength < 0)
+ int32_t textLen = (textLength == nullptr || *textLength < 0)
? u_strlen(text) : *textLength;
// writeable alias: for this ct, len CANNOT be -1 (why?)
UnicodeString str(text, textLen, textCapacity);
@@ -458,16 +458,16 @@ utrans_transUChars(const UTransliterator* trans,
*limit = ((Transliterator*) trans)->transliterate(str, start, *limit);
// Copy the string buffer back to text (only if necessary)
- // and fill in *neededCapacity (if neededCapacity != NULL).
+ // and fill in *neededCapacity (if neededCapacity != nullptr).
textLen = str.extract(text, textCapacity, *status);
- if(textLength != NULL) {
+ if(textLength != nullptr) {
*textLength = textLen;
}
}
U_CAPI void U_EXPORT2
utrans_transIncrementalUChars(const UTransliterator* trans,
- UChar* text,
+ char16_t* text,
int32_t* textLength,
int32_t textCapacity,
UTransPosition* pos,
@@ -480,7 +480,7 @@ utrans_transIncrementalUChars(const UTransliterator* trans,
return;
}
- int32_t textLen = (textLength == NULL || *textLength < 0)
+ int32_t textLen = (textLength == nullptr || *textLength < 0)
? u_strlen(text) : *textLength;
// writeable alias: for this ct, len CANNOT be -1 (why?)
UnicodeString str(text, textLen, textCapacity);
@@ -488,9 +488,9 @@ utrans_transIncrementalUChars(const UTransliterator* trans,
((Transliterator*) trans)->transliterate(str, *pos, *status);
// Copy the string buffer back to text (only if necessary)
- // and fill in *neededCapacity (if neededCapacity != NULL).
+ // and fill in *neededCapacity (if neededCapacity != nullptr).
textLen = str.extract(text, textCapacity, *status);
- if(textLength != NULL) {
+ if(textLength != nullptr) {
*textLength = textLen;
}
}
@@ -498,10 +498,10 @@ utrans_transIncrementalUChars(const UTransliterator* trans,
U_CAPI int32_t U_EXPORT2
utrans_toRules( const UTransliterator* trans,
UBool escapeUnprintable,
- UChar* result, int32_t resultLength,
+ char16_t* result, int32_t resultLength,
UErrorCode* status) {
utrans_ENTRY(status) 0;
- if ( (result==NULL)? resultLength!=0: resultLength<0 ) {
+ if ( (result==nullptr)? resultLength!=0: resultLength<0 ) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@@ -519,7 +519,7 @@ utrans_getSourceSet(const UTransliterator* trans,
UErrorCode* status) {
utrans_ENTRY(status) fillIn;
- if (fillIn == NULL) {
+ if (fillIn == nullptr) {
fillIn = uset_openEmpty();
}
if (ignoreFilter) {
diff --git a/contrib/libs/icu/i18n/vtzone.cpp b/contrib/libs/icu/i18n/vtzone.cpp
index 9111e08848..25af556aa2 100644
--- a/contrib/libs/icu/i18n/vtzone.cpp
+++ b/contrib/libs/icu/i18n/vtzone.cpp
@@ -24,50 +24,42 @@
U_NAMESPACE_BEGIN
-// This is the deleter that will be use to remove TimeZoneRule
-U_CDECL_BEGIN
-static void U_CALLCONV
-deleteTimeZoneRule(void* obj) {
- delete (TimeZoneRule*) obj;
-}
-U_CDECL_END
-
// Smybol characters used by RFC2445 VTIMEZONE
-static const UChar COLON = 0x3A; /* : */
-static const UChar SEMICOLON = 0x3B; /* ; */
-static const UChar EQUALS_SIGN = 0x3D; /* = */
-static const UChar COMMA = 0x2C; /* , */
-static const UChar PLUS = 0x2B; /* + */
-static const UChar MINUS = 0x2D; /* - */
+static const char16_t COLON = 0x3A; /* : */
+static const char16_t SEMICOLON = 0x3B; /* ; */
+static const char16_t EQUALS_SIGN = 0x3D; /* = */
+static const char16_t COMMA = 0x2C; /* , */
+static const char16_t PLUS = 0x2B; /* + */
+static const char16_t MINUS = 0x2D; /* - */
// RFC2445 VTIMEZONE tokens
-static const UChar ICAL_BEGIN_VTIMEZONE[] = {0x42, 0x45, 0x47, 0x49, 0x4E, 0x3A, 0x56, 0x54, 0x49, 0x4D, 0x45, 0x5A, 0x4F, 0x4E, 0x45, 0}; /* "BEGIN:VTIMEZONE" */
-static const UChar ICAL_END_VTIMEZONE[] = {0x45, 0x4E, 0x44, 0x3A, 0x56, 0x54, 0x49, 0x4D, 0x45, 0x5A, 0x4F, 0x4E, 0x45, 0}; /* "END:VTIMEZONE" */
-static const UChar ICAL_BEGIN[] = {0x42, 0x45, 0x47, 0x49, 0x4E, 0}; /* "BEGIN" */
-static const UChar ICAL_END[] = {0x45, 0x4E, 0x44, 0}; /* "END" */
-static const UChar ICAL_VTIMEZONE[] = {0x56, 0x54, 0x49, 0x4D, 0x45, 0x5A, 0x4F, 0x4E, 0x45, 0}; /* "VTIMEZONE" */
-static const UChar ICAL_TZID[] = {0x54, 0x5A, 0x49, 0x44, 0}; /* "TZID" */
-static const UChar ICAL_STANDARD[] = {0x53, 0x54, 0x41, 0x4E, 0x44, 0x41, 0x52, 0x44, 0}; /* "STANDARD" */
-static const UChar ICAL_DAYLIGHT[] = {0x44, 0x41, 0x59, 0x4C, 0x49, 0x47, 0x48, 0x54, 0}; /* "DAYLIGHT" */
-static const UChar ICAL_DTSTART[] = {0x44, 0x54, 0x53, 0x54, 0x41, 0x52, 0x54, 0}; /* "DTSTART" */
-static const UChar ICAL_TZOFFSETFROM[] = {0x54, 0x5A, 0x4F, 0x46, 0x46, 0x53, 0x45, 0x54, 0x46, 0x52, 0x4F, 0x4D, 0}; /* "TZOFFSETFROM" */
-static const UChar ICAL_TZOFFSETTO[] = {0x54, 0x5A, 0x4F, 0x46, 0x46, 0x53, 0x45, 0x54, 0x54, 0x4F, 0}; /* "TZOFFSETTO" */
-static const UChar ICAL_RDATE[] = {0x52, 0x44, 0x41, 0x54, 0x45, 0}; /* "RDATE" */
-static const UChar ICAL_RRULE[] = {0x52, 0x52, 0x55, 0x4C, 0x45, 0}; /* "RRULE" */
-static const UChar ICAL_TZNAME[] = {0x54, 0x5A, 0x4E, 0x41, 0x4D, 0x45, 0}; /* "TZNAME" */
-static const UChar ICAL_TZURL[] = {0x54, 0x5A, 0x55, 0x52, 0x4C, 0}; /* "TZURL" */
-static const UChar ICAL_LASTMOD[] = {0x4C, 0x41, 0x53, 0x54, 0x2D, 0x4D, 0x4F, 0x44, 0x49, 0x46, 0x49, 0x45, 0x44, 0}; /* "LAST-MODIFIED" */
-
-static const UChar ICAL_FREQ[] = {0x46, 0x52, 0x45, 0x51, 0}; /* "FREQ" */
-static const UChar ICAL_UNTIL[] = {0x55, 0x4E, 0x54, 0x49, 0x4C, 0}; /* "UNTIL" */
-static const UChar ICAL_YEARLY[] = {0x59, 0x45, 0x41, 0x52, 0x4C, 0x59, 0}; /* "YEARLY" */
-static const UChar ICAL_BYMONTH[] = {0x42, 0x59, 0x4D, 0x4F, 0x4E, 0x54, 0x48, 0}; /* "BYMONTH" */
-static const UChar ICAL_BYDAY[] = {0x42, 0x59, 0x44, 0x41, 0x59, 0}; /* "BYDAY" */
-static const UChar ICAL_BYMONTHDAY[] = {0x42, 0x59, 0x4D, 0x4F, 0x4E, 0x54, 0x48, 0x44, 0x41, 0x59, 0}; /* "BYMONTHDAY" */
-
-static const UChar ICAL_NEWLINE[] = {0x0D, 0x0A, 0}; /* CRLF */
-
-static const UChar ICAL_DOW_NAMES[7][3] = {
+static const char16_t ICAL_BEGIN_VTIMEZONE[] = {0x42, 0x45, 0x47, 0x49, 0x4E, 0x3A, 0x56, 0x54, 0x49, 0x4D, 0x45, 0x5A, 0x4F, 0x4E, 0x45, 0}; /* "BEGIN:VTIMEZONE" */
+static const char16_t ICAL_END_VTIMEZONE[] = {0x45, 0x4E, 0x44, 0x3A, 0x56, 0x54, 0x49, 0x4D, 0x45, 0x5A, 0x4F, 0x4E, 0x45, 0}; /* "END:VTIMEZONE" */
+static const char16_t ICAL_BEGIN[] = {0x42, 0x45, 0x47, 0x49, 0x4E, 0}; /* "BEGIN" */
+static const char16_t ICAL_END[] = {0x45, 0x4E, 0x44, 0}; /* "END" */
+static const char16_t ICAL_VTIMEZONE[] = {0x56, 0x54, 0x49, 0x4D, 0x45, 0x5A, 0x4F, 0x4E, 0x45, 0}; /* "VTIMEZONE" */
+static const char16_t ICAL_TZID[] = {0x54, 0x5A, 0x49, 0x44, 0}; /* "TZID" */
+static const char16_t ICAL_STANDARD[] = {0x53, 0x54, 0x41, 0x4E, 0x44, 0x41, 0x52, 0x44, 0}; /* "STANDARD" */
+static const char16_t ICAL_DAYLIGHT[] = {0x44, 0x41, 0x59, 0x4C, 0x49, 0x47, 0x48, 0x54, 0}; /* "DAYLIGHT" */
+static const char16_t ICAL_DTSTART[] = {0x44, 0x54, 0x53, 0x54, 0x41, 0x52, 0x54, 0}; /* "DTSTART" */
+static const char16_t ICAL_TZOFFSETFROM[] = {0x54, 0x5A, 0x4F, 0x46, 0x46, 0x53, 0x45, 0x54, 0x46, 0x52, 0x4F, 0x4D, 0}; /* "TZOFFSETFROM" */
+static const char16_t ICAL_TZOFFSETTO[] = {0x54, 0x5A, 0x4F, 0x46, 0x46, 0x53, 0x45, 0x54, 0x54, 0x4F, 0}; /* "TZOFFSETTO" */
+static const char16_t ICAL_RDATE[] = {0x52, 0x44, 0x41, 0x54, 0x45, 0}; /* "RDATE" */
+static const char16_t ICAL_RRULE[] = {0x52, 0x52, 0x55, 0x4C, 0x45, 0}; /* "RRULE" */
+static const char16_t ICAL_TZNAME[] = {0x54, 0x5A, 0x4E, 0x41, 0x4D, 0x45, 0}; /* "TZNAME" */
+static const char16_t ICAL_TZURL[] = {0x54, 0x5A, 0x55, 0x52, 0x4C, 0}; /* "TZURL" */
+static const char16_t ICAL_LASTMOD[] = {0x4C, 0x41, 0x53, 0x54, 0x2D, 0x4D, 0x4F, 0x44, 0x49, 0x46, 0x49, 0x45, 0x44, 0}; /* "LAST-MODIFIED" */
+
+static const char16_t ICAL_FREQ[] = {0x46, 0x52, 0x45, 0x51, 0}; /* "FREQ" */
+static const char16_t ICAL_UNTIL[] = {0x55, 0x4E, 0x54, 0x49, 0x4C, 0}; /* "UNTIL" */
+static const char16_t ICAL_YEARLY[] = {0x59, 0x45, 0x41, 0x52, 0x4C, 0x59, 0}; /* "YEARLY" */
+static const char16_t ICAL_BYMONTH[] = {0x42, 0x59, 0x4D, 0x4F, 0x4E, 0x54, 0x48, 0}; /* "BYMONTH" */
+static const char16_t ICAL_BYDAY[] = {0x42, 0x59, 0x44, 0x41, 0x59, 0}; /* "BYDAY" */
+static const char16_t ICAL_BYMONTHDAY[] = {0x42, 0x59, 0x4D, 0x4F, 0x4E, 0x54, 0x48, 0x44, 0x41, 0x59, 0}; /* "BYMONTHDAY" */
+
+static const char16_t ICAL_NEWLINE[] = {0x0D, 0x0A, 0}; /* CRLF */
+
+static const char16_t ICAL_DOW_NAMES[7][3] = {
{0x53, 0x55, 0}, /* "SU" */
{0x4D, 0x4F, 0}, /* "MO" */
{0x54, 0x55, 0}, /* "TU" */
@@ -80,9 +72,9 @@ static const UChar ICAL_DOW_NAMES[7][3] = {
static const int32_t MONTHLENGTH[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// ICU custom property
-static const UChar ICU_TZINFO_PROP[] = {0x58, 0x2D, 0x54, 0x5A, 0x49, 0x4E, 0x46, 0x4F, 0x3A, 0}; /* "X-TZINFO:" */
-static const UChar ICU_TZINFO_PARTIAL[] = {0x2F, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6C, 0x40, 0}; /* "/Partial@" */
-static const UChar ICU_TZINFO_SIMPLE[] = {0x2F, 0x53, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x40, 0}; /* "/Simple@" */
+static const char16_t ICU_TZINFO_PROP[] = {0x58, 0x2D, 0x54, 0x5A, 0x49, 0x4E, 0x46, 0x4F, 0x3A, 0}; /* "X-TZINFO:" */
+static const char16_t ICU_TZINFO_PARTIAL[] = {0x2F, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6C, 0x40, 0}; /* "/Partial@" */
+static const char16_t ICU_TZINFO_SIMPLE[] = {0x2F, 0x53, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x40, 0}; /* "/Simple@" */
/*
@@ -118,12 +110,12 @@ static int32_t parseAsciiDigits(const UnicodeString& str, int32_t start, int32_t
}
static UnicodeString& appendAsciiDigits(int32_t number, uint8_t length, UnicodeString& str) {
- UBool negative = FALSE;
+ UBool negative = false;
int32_t digits[10]; // max int32_t is 10 decimal digits
int32_t i;
if (number < 0) {
- negative = TRUE;
+ negative = true;
number *= -1;
}
@@ -147,13 +139,13 @@ static UnicodeString& appendAsciiDigits(int32_t number, uint8_t length, UnicodeS
str.append(MINUS);
}
for (i = length - 1; i >= 0; i--) {
- str.append((UChar)(digits[i] + 0x0030));
+ str.append((char16_t)(digits[i] + 0x0030));
}
return str;
}
static UnicodeString& appendMillis(UDate date, UnicodeString& str) {
- UBool negative = FALSE;
+ UBool negative = false;
int32_t digits[20]; // max int64_t is 20 decimal digits
int32_t i;
int64_t number;
@@ -166,7 +158,7 @@ static UnicodeString& appendMillis(UDate date, UnicodeString& str) {
number = (int64_t)date;
}
if (number < 0) {
- negative = TRUE;
+ negative = true;
number *= -1;
}
i = 0;
@@ -180,7 +172,7 @@ static UnicodeString& appendMillis(UDate date, UnicodeString& str) {
}
i--;
while (i >= 0) {
- str.append((UChar)(digits[i--] + 0x0030));
+ str.append((char16_t)(digits[i--] + 0x0030));
}
return str;
}
@@ -196,7 +188,7 @@ static UnicodeString& getDateTimeString(UDate time, UnicodeString& str) {
appendAsciiDigits(year, 4, str);
appendAsciiDigits(month + 1, 2, str);
appendAsciiDigits(dom, 2, str);
- str.append((UChar)0x0054 /*'T'*/);
+ str.append((char16_t)0x0054 /*'T'*/);
int32_t t = mid;
int32_t hour = t / U_MILLIS_PER_HOUR;
@@ -216,7 +208,7 @@ static UnicodeString& getDateTimeString(UDate time, UnicodeString& str) {
*/
static UnicodeString& getUTCDateTimeString(UDate time, UnicodeString& str) {
getDateTimeString(time, str);
- str.append((UChar)0x005A /*'Z'*/);
+ str.append((char16_t)0x005A /*'Z'*/);
return str;
}
@@ -230,8 +222,8 @@ static UDate parseDateTimeString(const UnicodeString& str, int32_t offset, UErro
}
int32_t year = 0, month = 0, day = 0, hour = 0, min = 0, sec = 0;
- UBool isUTC = FALSE;
- UBool isValid = FALSE;
+ UBool isUTC = false;
+ UBool isValid = false;
do {
int length = str.length();
if (length != 15 && length != 16) {
@@ -248,7 +240,7 @@ static UDate parseDateTimeString(const UnicodeString& str, int32_t offset, UErro
// invalid format
break;
}
- isUTC = TRUE;
+ isUTC = true;
}
year = parseAsciiDigits(str, 0, 4, status);
@@ -269,7 +261,7 @@ static UDate parseDateTimeString(const UnicodeString& str, int32_t offset, UErro
break;
}
- isValid = TRUE;
+ isValid = true;
} while(false);
if (!isValid) {
@@ -293,7 +285,7 @@ static int32_t offsetStrToMillis(const UnicodeString& str, UErrorCode& status) {
return 0;
}
- UBool isValid = FALSE;
+ UBool isValid = false;
int32_t sign = 0, hour = 0, min = 0, sec = 0;
do {
@@ -303,7 +295,7 @@ static int32_t offsetStrToMillis(const UnicodeString& str, UErrorCode& status) {
break;
}
// sign
- UChar s = str.charAt(0);
+ char16_t s = str.charAt(0);
if (s == PLUS) {
sign = 1;
} else if (s == MINUS) {
@@ -391,19 +383,19 @@ static void parseRRULE(const UnicodeString& rrule, int32_t& month, int32_t& dow,
wim = 0;
until = MIN_MILLIS;
- UBool yearly = FALSE;
- //UBool parseError = FALSE;
+ UBool yearly = false;
+ //UBool parseError = false;
int32_t prop_start = 0;
int32_t prop_end;
UnicodeString prop, attr, value;
- UBool nextProp = TRUE;
+ UBool nextProp = true;
while (nextProp) {
prop_end = rrule.indexOf(SEMICOLON, prop_start);
if (prop_end == -1) {
prop.setTo(rrule, prop_start);
- nextProp = FALSE;
+ nextProp = false;
} else {
prop.setTo(rrule, prop_start, prop_end - prop_start);
prop_start = prop_end + 1;
@@ -419,7 +411,7 @@ static void parseRRULE(const UnicodeString& rrule, int32_t& month, int32_t& dow,
if (attr.compare(ICAL_FREQ, -1) == 0) {
// only support YEARLY frequency type
if (value.compare(ICAL_YEARLY, -1) == 0) {
- yearly = TRUE;
+ yearly = true;
} else {
goto rruleParseError;
}
@@ -486,12 +478,12 @@ static void parseRRULE(const UnicodeString& rrule, int32_t& month, int32_t& dow,
int32_t dom_idx = 0;
int32_t dom_start = 0;
int32_t dom_end;
- UBool nextDOM = TRUE;
+ UBool nextDOM = true;
while (nextDOM) {
dom_end = value.indexOf(COMMA, dom_start);
if (dom_end == -1) {
dom_end = value.length();
- nextDOM = FALSE;
+ nextDOM = false;
}
if (dom_idx < domCount) {
dom[dom_idx] = parseAsciiDigits(value, dom_start, dom_end - dom_start, status);
@@ -571,10 +563,10 @@ static TimeZoneRule* createRuleByRRULE(const UnicodeString& zonename, int rawOff
}
// Make sure days are continuous
for (i = 1; i < 7; i++) {
- UBool found = FALSE;
+ UBool found = false;
for (j = 0; j < 7; j++) {
if (days[j] == firstDay + i) {
- found = TRUE;
+ found = true;
break;
}
}
@@ -711,7 +703,7 @@ static TimeZoneRule* createRuleByRRULE(const UnicodeString& zonename, int rawOff
} else if (dayOfWeek != 0 && nthDayOfWeek == 0 && dayOfMonth != 0) {
// First day of week after day of month rule, for example,
// first Sunday after 15th day in the month
- adtr = new DateTimeRule(month, dayOfMonth, dayOfWeek, TRUE, startMID, DateTimeRule::WALL_TIME);
+ adtr = new DateTimeRule(month, dayOfMonth, dayOfWeek, true, startMID, DateTimeRule::WALL_TIME);
}
if (adtr == nullptr) {
goto unsupportedRRule;
@@ -767,36 +759,36 @@ static TimeZoneRule* createRuleByRDATE(const UnicodeString& zonename, int32_t ra
*/
static UBool isEquivalentDateRule(int32_t month, int32_t weekInMonth, int32_t dayOfWeek, const DateTimeRule *dtrule) {
if (month != dtrule->getRuleMonth() || dayOfWeek != dtrule->getRuleDayOfWeek()) {
- return FALSE;
+ return false;
}
if (dtrule->getTimeRuleType() != DateTimeRule::WALL_TIME) {
// Do not try to do more intelligent comparison for now.
- return FALSE;
+ return false;
}
if (dtrule->getDateRuleType() == DateTimeRule::DOW
&& dtrule->getRuleWeekInMonth() == weekInMonth) {
- return TRUE;
+ return true;
}
int32_t ruleDOM = dtrule->getRuleDayOfMonth();
if (dtrule->getDateRuleType() == DateTimeRule::DOW_GEQ_DOM) {
if (ruleDOM%7 == 1 && (ruleDOM + 6)/7 == weekInMonth) {
- return TRUE;
+ return true;
}
if (month != UCAL_FEBRUARY && (MONTHLENGTH[month] - ruleDOM)%7 == 6
&& weekInMonth == -1*((MONTHLENGTH[month]-ruleDOM+1)/7)) {
- return TRUE;
+ return true;
}
}
if (dtrule->getDateRuleType() == DateTimeRule::DOW_LEQ_DOM) {
if (ruleDOM%7 == 0 && ruleDOM/7 == weekInMonth) {
- return TRUE;
+ return true;
}
if (month != UCAL_FEBRUARY && (MONTHLENGTH[month] - ruleDOM)%7 == 0
&& weekInMonth == -1*((MONTHLENGTH[month] - ruleDOM)/7 + 1)) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
/*
@@ -893,9 +885,9 @@ public:
~VTZWriter();
void write(const UnicodeString& str);
- void write(UChar ch);
- void write(const UChar* str);
- //void write(const UChar* str, int32_t length);
+ void write(char16_t ch);
+ void write(const char16_t* str);
+ //void write(const char16_t* str, int32_t length);
private:
UnicodeString* out;
};
@@ -913,18 +905,18 @@ VTZWriter::write(const UnicodeString& str) {
}
void
-VTZWriter::write(UChar ch) {
+VTZWriter::write(char16_t ch) {
out->append(ch);
}
void
-VTZWriter::write(const UChar* str) {
+VTZWriter::write(const char16_t* str) {
out->append(str, -1);
}
/*
void
-VTZWriter::write(const UChar* str, int32_t length) {
+VTZWriter::write(const char16_t* str, int32_t length) {
out->append(str, length);
}
*/
@@ -934,7 +926,7 @@ public:
VTZReader(const UnicodeString& input);
~VTZReader();
- UChar read(void);
+ char16_t read();
private:
const UnicodeString* in;
int32_t index;
@@ -948,9 +940,9 @@ VTZReader::VTZReader(const UnicodeString& input) {
VTZReader::~VTZReader() {
}
-UChar
-VTZReader::read(void) {
- UChar ch = 0xFFFF;
+char16_t
+VTZReader::read() {
+ char16_t ch = 0xFFFF;
if (index < in->length()) {
ch = in->charAt(index);
}
@@ -976,22 +968,19 @@ VTimeZone::VTimeZone(const VTimeZone& source)
if (source.vtzlines != nullptr) {
UErrorCode status = U_ZERO_ERROR;
int32_t size = source.vtzlines->size();
- vtzlines = new UVector(uprv_deleteUObject, uhash_compareUnicodeString, size, status);
- if (vtzlines == nullptr) {
+ LocalPointer<UVector> lpVtzLines(
+ new UVector(uprv_deleteUObject, uhash_compareUnicodeString, size, status), status);
+ if (U_FAILURE(status)) {
return;
}
- if (U_SUCCESS(status)) {
- for (int32_t i = 0; i < size; i++) {
- UnicodeString *line = (UnicodeString*)source.vtzlines->elementAt(i);
- vtzlines->addElementX(line->clone(), status);
- if (U_FAILURE(status)) {
- break;
- }
+ for (int32_t i = 0; i < size; i++) {
+ UnicodeString *line = ((UnicodeString*)source.vtzlines->elementAt(i))->clone();
+ lpVtzLines->adoptElement(line, status);
+ if (U_FAILURE(status) || line == nullptr) {
+ return;
}
}
- if (U_FAILURE(status) && vtzlines != nullptr) {
- delete vtzlines;
- }
+ vtzlines = lpVtzLines.orphan();
}
}
@@ -1020,23 +1009,25 @@ VTimeZone::operator=(const VTimeZone& right) {
}
if (vtzlines != nullptr) {
delete vtzlines;
+ vtzlines = nullptr;
}
if (right.vtzlines != nullptr) {
UErrorCode status = U_ZERO_ERROR;
int32_t size = right.vtzlines->size();
- vtzlines = new UVector(uprv_deleteUObject, uhash_compareUnicodeString, size, status);
- if (vtzlines != nullptr && U_SUCCESS(status)) {
+ LocalPointer<UVector> lpVtzLines(
+ new UVector(uprv_deleteUObject, uhash_compareUnicodeString, size, status), status);
+ if (U_SUCCESS(status)) {
for (int32_t i = 0; i < size; i++) {
- UnicodeString *line = (UnicodeString*)right.vtzlines->elementAt(i);
- vtzlines->addElementX(line->clone(), status);
+ LocalPointer<UnicodeString> line(
+ ((UnicodeString*)right.vtzlines->elementAt(i))->clone(), status);
+ lpVtzLines->adoptElement(line.orphan(), status);
if (U_FAILURE(status)) {
break;
}
}
- }
- if (U_FAILURE(status) && vtzlines != nullptr) {
- delete vtzlines;
- vtzlines = nullptr;
+ if (U_SUCCESS(status)) {
+ vtzlines = lpVtzLines.orphan();
+ }
}
}
tzurl = right.tzurl;
@@ -1083,7 +1074,7 @@ VTimeZone::createVTimeZoneByID(const UnicodeString& ID) {
// Set ICU tzdata version
UErrorCode status = U_ZERO_ERROR;
UResourceBundle *bundle = nullptr;
- const UChar* versionStr = nullptr;
+ const char16_t* versionStr = nullptr;
int32_t len = 0;
bundle = ures_openDirect(nullptr, "zoneinfo64", &status);
versionStr = ures_getStringByKey(bundle, "TZVersion", &len, &status);
@@ -1114,7 +1105,7 @@ VTimeZone::createVTimeZoneFromBasicTimeZone(const BasicTimeZone& basic_time_zone
// Set ICU tzdata version
UResourceBundle *bundle = nullptr;
- const UChar* versionStr = nullptr;
+ const char16_t* versionStr = nullptr;
int32_t len = 0;
bundle = ures_openDirect(nullptr, "zoneinfo64", &status);
versionStr = ures_getStringByKey(bundle, "TZVersion", &len, &status);
@@ -1148,9 +1139,9 @@ UBool
VTimeZone::getTZURL(UnicodeString& url) const {
if (tzurl.length() > 0) {
url = tzurl;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
void
@@ -1162,9 +1153,9 @@ UBool
VTimeZone::getLastModified(UDate& lastModified) const {
if (lastmod != MAX_MILLIS) {
lastModified = lastmod;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
void
@@ -1229,12 +1220,12 @@ VTimeZone::setRawOffset(int32_t offsetMillis) {
}
int32_t
-VTimeZone::getRawOffset(void) const {
+VTimeZone::getRawOffset() const {
return tz->getRawOffset();
}
UBool
-VTimeZone::useDaylightTime(void) const {
+VTimeZone::useDaylightTime() const {
return tz->useDaylightTime();
}
@@ -1272,33 +1263,28 @@ VTimeZone::getTimeZoneRules(const InitialTimeZoneRule*& initial,
void
VTimeZone::load(VTZReader& reader, UErrorCode& status) {
- vtzlines = new UVector(uprv_deleteUObject, uhash_compareUnicodeString, DEFAULT_VTIMEZONE_LINES, status);
- if (vtzlines == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- }
+ U_ASSERT(vtzlines == nullptr);
+ LocalPointer<UVector> lpVtzLines(
+ new UVector(uprv_deleteUObject, uhash_compareUnicodeString, DEFAULT_VTIMEZONE_LINES, status), status);
if (U_FAILURE(status)) {
return;
}
- UBool eol = FALSE;
- UBool start = FALSE;
- UBool success = FALSE;
+ UBool eol = false;
+ UBool start = false;
+ UBool success = false;
UnicodeString line;
- while (TRUE) {
- UChar ch = reader.read();
+ while (true) {
+ char16_t ch = reader.read();
if (ch == 0xFFFF) {
// end of file
if (start && line.startsWith(ICAL_END_VTIMEZONE, -1)) {
LocalPointer<UnicodeString> element(new UnicodeString(line), status);
+ lpVtzLines->adoptElement(element.orphan(), status);
if (U_FAILURE(status)) {
- goto cleanupVtzlines;
- }
- vtzlines->addElementX(element.getAlias(), status);
- if (U_FAILURE(status)) {
- goto cleanupVtzlines;
+ return;
}
- element.orphan(); // on success, vtzlines owns the object.
- success = TRUE;
+ success = true;
}
break;
}
@@ -1312,14 +1298,10 @@ VTimeZone::load(VTZReader& reader, UErrorCode& status) {
if (start) {
if (line.length() > 0) {
LocalPointer<UnicodeString> element(new UnicodeString(line), status);
+ lpVtzLines->adoptElement(element.orphan(), status);
if (U_FAILURE(status)) {
- goto cleanupVtzlines;
- }
- vtzlines->addElementX(element.getAlias(), status);
- if (U_FAILURE(status)) {
- goto cleanupVtzlines;
+ return;
}
- element.orphan(); // on success, vtzlines owns the object.
}
}
line.remove();
@@ -1327,39 +1309,31 @@ VTimeZone::load(VTZReader& reader, UErrorCode& status) {
line.append(ch);
}
}
- eol = FALSE;
+ eol = false;
} else {
if (ch == 0x000A) {
// LF
- eol = TRUE;
+ eol = true;
if (start) {
if (line.startsWith(ICAL_END_VTIMEZONE, -1)) {
LocalPointer<UnicodeString> element(new UnicodeString(line), status);
+ lpVtzLines->adoptElement(element.orphan(), status);
if (U_FAILURE(status)) {
- goto cleanupVtzlines;
- }
- vtzlines->addElementX(element.getAlias(), status);
- if (U_FAILURE(status)) {
- goto cleanupVtzlines;
+ return;
}
- element.orphan(); // on success, vtzlines owns the object.
- success = TRUE;
+ success = true;
break;
}
} else {
if (line.startsWith(ICAL_BEGIN_VTIMEZONE, -1)) {
LocalPointer<UnicodeString> element(new UnicodeString(line), status);
+ lpVtzLines->adoptElement(element.orphan(), status);
if (U_FAILURE(status)) {
- goto cleanupVtzlines;
+ return;
}
- vtzlines->addElementX(element.getAlias(), status);
- if (U_FAILURE(status)) {
- goto cleanupVtzlines;
- }
- element.orphan(); // on success, vtzlines owns the object.
line.remove();
- start = TRUE;
- eol = FALSE;
+ start = true;
+ eol = false;
}
}
} else {
@@ -1371,14 +1345,10 @@ VTimeZone::load(VTZReader& reader, UErrorCode& status) {
if (U_SUCCESS(status)) {
status = U_INVALID_STATE_ERROR;
}
- goto cleanupVtzlines;
+ return;
}
+ vtzlines = lpVtzLines.orphan();
parse(status);
- return;
-
-cleanupVtzlines:
- delete vtzlines;
- vtzlines = nullptr;
}
// parser state
@@ -1398,48 +1368,34 @@ VTimeZone::parse(UErrorCode& status) {
status = U_INVALID_STATE_ERROR;
return;
}
- InitialTimeZoneRule *initialRule = nullptr;
- RuleBasedTimeZone *rbtz = nullptr;
// timezone ID
UnicodeString tzid;
int32_t state = INI;
int32_t n = 0;
- UBool dst = FALSE; // current zone type
+ UBool dst = false; // current zone type
UnicodeString from; // current zone from offset
UnicodeString to; // current zone offset
UnicodeString zonename; // current zone name
UnicodeString dtstart; // current zone starts
- UBool isRRULE = FALSE; // true if the rule is described by RRULE
+ UBool isRRULE = false; // true if the rule is described by RRULE
int32_t initialRawOffset = 0; // initial offset
int32_t initialDSTSavings = 0; // initial offset
UDate firstStart = MAX_MILLIS; // the earliest rule start time
UnicodeString name; // RFC2445 prop name
UnicodeString value; // RFC2445 prop value
- UVector *dates = nullptr; // list of RDATE or RRULE strings
- UVector *rules = nullptr; // list of TimeZoneRule instances
-
int32_t finalRuleIdx = -1;
int32_t finalRuleCount = 0;
- rules = new UVector(status);
- if (rules == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- }
- if (U_FAILURE(status)) {
- goto cleanupParse;
- }
- // Set the deleter to remove TimeZoneRule vectors to avoid memory leaks due to unowned TimeZoneRules.
- rules->setDeleter(deleteTimeZoneRule);
+ // Set the deleter on rules to remove TimeZoneRule vectors to avoid memory leaks due to unowned TimeZoneRules.
+ UVector rules(uprv_deleteUObject, nullptr, status);
- dates = new UVector(uprv_deleteUObject, uhash_compareUnicodeString, status);
- if (dates == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- }
+ // list of RDATE or RRULE strings
+ UVector dates(uprv_deleteUObject, uhash_compareUnicodeString, status);
if (U_FAILURE(status)) {
- goto cleanupParse;
+ return;
}
for (n = 0; n < vtzlines->size(); n++) {
@@ -1469,20 +1425,20 @@ VTimeZone::parse(UErrorCode& status) {
// can be any value.
lastmod = parseDateTimeString(value, 0, status);
if (U_FAILURE(status)) {
- goto cleanupParse;
+ return;
}
} else if (name.compare(ICAL_BEGIN, -1) == 0) {
UBool isDST = (value.compare(ICAL_DAYLIGHT, -1) == 0);
if (value.compare(ICAL_STANDARD, -1) == 0 || isDST) {
// tzid must be ready at this point
if (tzid.length() == 0) {
- goto cleanupParse;
+ return;
}
// initialize current zone properties
- if (dates->size() != 0) {
- dates->removeAllElements();
+ if (dates.size() != 0) {
+ dates.removeAllElements();
}
- isRRULE = FALSE;
+ isRRULE = false;
from.remove();
to.remove();
zonename.remove();
@@ -1491,7 +1447,7 @@ VTimeZone::parse(UErrorCode& status) {
} else {
// BEGIN property other than STANDARD/DAYLIGHT
// must not be there.
- goto cleanupParse;
+ return;
}
} else if (name.compare(ICAL_END, -1) == 0) {
break;
@@ -1509,50 +1465,42 @@ VTimeZone::parse(UErrorCode& status) {
} else if (name.compare(ICAL_RDATE, -1) == 0) {
// RDATE mixed with RRULE is not supported
if (isRRULE) {
- goto cleanupParse;
+ return;
}
// RDATE value may contain multiple date delimited
// by comma
- UBool nextDate = TRUE;
+ UBool nextDate = true;
int32_t dstart = 0;
- UnicodeString *dstr = nullptr;
+ LocalPointer<UnicodeString> dstr;
while (nextDate) {
int32_t dend = value.indexOf(COMMA, dstart);
if (dend == -1) {
- dstr = new UnicodeString(value, dstart);
- nextDate = FALSE;
- } else {
- dstr = new UnicodeString(value, dstart, dend - dstart);
- }
- if (dstr == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
+ dstr.adoptInsteadAndCheckErrorCode(new UnicodeString(value, dstart), status);
+ nextDate = false;
} else {
- dates->addElementX(dstr, status);
+ dstr.adoptInsteadAndCheckErrorCode(new UnicodeString(value, dstart, dend - dstart), status);
}
+ dates.adoptElement(dstr.orphan(), status);
if (U_FAILURE(status)) {
- goto cleanupParse;
+ return;
}
dstart = dend + 1;
}
} else if (name.compare(ICAL_RRULE, -1) == 0) {
// RRULE mixed with RDATE is not supported
- if (!isRRULE && dates->size() != 0) {
- goto cleanupParse;
+ if (!isRRULE && dates.size() != 0) {
+ return;
}
isRRULE = true;
LocalPointer<UnicodeString> element(new UnicodeString(value), status);
+ dates.adoptElement(element.orphan(), status);
if (U_FAILURE(status)) {
- goto cleanupParse;
+ return;
}
- dates->addElementX(element.getAlias(), status);
- if (U_FAILURE(status)) {
- goto cleanupParse;
- }
- element.orphan(); // on success, dates owns the object.
} else if (name.compare(ICAL_END, -1) == 0) {
// Mandatory properties
if (dtstart.length() == 0 || from.length() == 0 || to.length() == 0) {
- goto cleanupParse;
+ return;
}
// if zonename is not available, create one from tzid
if (zonename.length() == 0) {
@@ -1560,7 +1508,7 @@ VTimeZone::parse(UErrorCode& status) {
}
// create a time zone rule
- TimeZoneRule *rule = nullptr;
+ LocalPointer<TimeZoneRule> rule;
int32_t fromOffset = 0;
int32_t toOffset = 0;
int32_t rawOffset = 0;
@@ -1571,7 +1519,7 @@ VTimeZone::parse(UErrorCode& status) {
fromOffset = offsetStrToMillis(from, status);
toOffset = offsetStrToMillis(to, status);
if (U_FAILURE(status)) {
- goto cleanupParse;
+ return;
}
if (dst) {
@@ -1592,18 +1540,20 @@ VTimeZone::parse(UErrorCode& status) {
// start time
start = parseDateTimeString(dtstart, fromOffset, status);
if (U_FAILURE(status)) {
- goto cleanupParse;
+ return;
}
// Create the rule
UDate actualStart = MAX_MILLIS;
if (isRRULE) {
- rule = createRuleByRRULE(zonename, rawOffset, dstSavings, start, dates, fromOffset, status);
+ rule.adoptInsteadAndCheckErrorCode(
+ createRuleByRRULE(zonename, rawOffset, dstSavings, start, &dates, fromOffset, status), status);
} else {
- rule = createRuleByRDATE(zonename, rawOffset, dstSavings, start, dates, fromOffset, status);
+ rule.adoptInsteadAndCheckErrorCode(
+ createRuleByRDATE(zonename, rawOffset, dstSavings, start, &dates, fromOffset, status), status);
}
- if (U_FAILURE(status) || rule == nullptr) {
- goto cleanupParse;
+ if (U_FAILURE(status)) {
+ return;
} else {
UBool startAvail = rule->getFirstStart(fromOffset, 0, actualStart);
if (startAvail && actualStart < firstStart) {
@@ -1626,9 +1576,9 @@ VTimeZone::parse(UErrorCode& status) {
}
}
}
- rules->addElementX(rule, status);
+ rules.adoptElement(rule.orphan(), status);
if (U_FAILURE(status)) {
- goto cleanupParse;
+ return;
}
state = VTZ;
}
@@ -1636,28 +1586,31 @@ VTimeZone::parse(UErrorCode& status) {
}
}
// Must have at least one rule
- if (rules->size() == 0) {
- goto cleanupParse;
+ if (rules.size() == 0) {
+ return;
}
// Create a initial rule
- getDefaultTZName(tzid, FALSE, zonename);
- initialRule = new InitialTimeZoneRule(zonename, initialRawOffset, initialDSTSavings);
- if (initialRule == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- goto cleanupParse;
+ getDefaultTZName(tzid, false, zonename);
+ LocalPointer<InitialTimeZoneRule> initialRule(
+ new InitialTimeZoneRule(zonename, initialRawOffset, initialDSTSavings), status);
+ if (U_FAILURE(status)) {
+ return;
}
// Finally, create the RuleBasedTimeZone
- rbtz = new RuleBasedTimeZone(tzid, initialRule);
- if (rbtz == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- goto cleanupParse;
+ // C++ awkwardness on memory allocation failure: the constructor wont be run, meaning
+ // that initialRule wont be adopted/deleted, as it normally would be.
+ LocalPointer<RuleBasedTimeZone> rbtz(
+ new RuleBasedTimeZone(tzid, initialRule.getAlias()), status);
+ if (U_SUCCESS(status)) {
+ initialRule.orphan();
+ } else {
+ return;
}
- initialRule = nullptr; // already adopted by RBTZ, no need to delete
- for (n = 0; n < rules->size(); n++) {
- TimeZoneRule *r = (TimeZoneRule*)rules->elementAt(n);
+ for (n = 0; n < rules.size(); n++) {
+ TimeZoneRule *r = (TimeZoneRule*)rules.elementAt(n);
AnnualTimeZoneRule *atzrule = dynamic_cast<AnnualTimeZoneRule *>(r);
if (atzrule != nullptr) {
if (atzrule->getEndYear() == AnnualTimeZoneRule::MAX_YEAR) {
@@ -1669,18 +1622,18 @@ VTimeZone::parse(UErrorCode& status) {
if (finalRuleCount > 2) {
// Too many final rules
status = U_ILLEGAL_ARGUMENT_ERROR;
- goto cleanupParse;
+ return;
}
if (finalRuleCount == 1) {
- if (rules->size() == 1) {
+ if (rules.size() == 1) {
// Only one final rule, only governs the initial rule,
// which is already initialized, thus, we do not need to
// add this transition rule
- rules->removeAllElements();
+ rules.removeAllElements();
} else {
// Normalize the final rule
- AnnualTimeZoneRule *finalRule = (AnnualTimeZoneRule*)rules->elementAt(finalRuleIdx);
+ AnnualTimeZoneRule *finalRule = (AnnualTimeZoneRule*)rules.elementAt(finalRuleIdx);
int32_t tmpRaw = finalRule->getRawOffset();
int32_t tmpDST = finalRule->getDSTSavings();
@@ -1688,94 +1641,74 @@ VTimeZone::parse(UErrorCode& status) {
UDate finalStart, start;
finalRule->getFirstStart(initialRawOffset, initialDSTSavings, finalStart);
start = finalStart;
- for (n = 0; n < rules->size(); n++) {
+ for (n = 0; n < rules.size(); n++) {
if (finalRuleIdx == n) {
continue;
}
- TimeZoneRule *r = (TimeZoneRule*)rules->elementAt(n);
+ TimeZoneRule *r = (TimeZoneRule*)rules.elementAt(n);
UDate lastStart;
r->getFinalStart(tmpRaw, tmpDST, lastStart);
if (lastStart > start) {
finalRule->getNextStart(lastStart,
r->getRawOffset(),
r->getDSTSavings(),
- FALSE,
+ false,
start);
}
}
- TimeZoneRule *newRule = nullptr;
+ LocalPointer<TimeZoneRule> newRule;
UnicodeString tznam;
if (start == finalStart) {
// Transform this into a single transition
- newRule = new TimeArrayTimeZoneRule(
- finalRule->getName(tznam),
- finalRule->getRawOffset(),
- finalRule->getDSTSavings(),
- &finalStart,
- 1,
- DateTimeRule::UTC_TIME);
+ newRule.adoptInsteadAndCheckErrorCode(
+ new TimeArrayTimeZoneRule(
+ finalRule->getName(tznam),
+ finalRule->getRawOffset(),
+ finalRule->getDSTSavings(),
+ &finalStart,
+ 1,
+ DateTimeRule::UTC_TIME),
+ status);
} else {
// Update the end year
int32_t y, m, d, dow, doy, mid;
Grego::timeToFields(start, y, m, d, dow, doy, mid);
- newRule = new AnnualTimeZoneRule(
- finalRule->getName(tznam),
- finalRule->getRawOffset(),
- finalRule->getDSTSavings(),
- *(finalRule->getRule()),
- finalRule->getStartYear(),
- y);
+ newRule.adoptInsteadAndCheckErrorCode(
+ new AnnualTimeZoneRule(
+ finalRule->getName(tznam),
+ finalRule->getRawOffset(),
+ finalRule->getDSTSavings(),
+ *(finalRule->getRule()),
+ finalRule->getStartYear(),
+ y),
+ status);
}
- if (newRule == nullptr) {
- status = U_MEMORY_ALLOCATION_ERROR;
- goto cleanupParse;
+ if (U_FAILURE(status)) {
+ return;
}
- rules->removeElementAt(finalRuleIdx);
- rules->addElementX(newRule, status);
+ rules.removeElementAt(finalRuleIdx);
+ rules.adoptElement(newRule.orphan(), status);
if (U_FAILURE(status)) {
- delete newRule;
- goto cleanupParse;
+ return;
}
}
}
- while (!rules->isEmpty()) {
- TimeZoneRule *tzr = (TimeZoneRule*)rules->orphanElementAt(0);
+ while (!rules.isEmpty()) {
+ TimeZoneRule *tzr = (TimeZoneRule*)rules.orphanElementAt(0);
rbtz->addTransitionRule(tzr, status);
if (U_FAILURE(status)) {
- goto cleanupParse;
+ return;
}
}
rbtz->complete(status);
if (U_FAILURE(status)) {
- goto cleanupParse;
+ return;
}
- delete rules;
- delete dates;
- tz = rbtz;
+ tz = rbtz.orphan();
setID(tzid);
- return;
-
-cleanupParse:
- if (rules != nullptr) {
- while (!rules->isEmpty()) {
- TimeZoneRule *r = (TimeZoneRule*)rules->orphanElementAt(0);
- delete r;
- }
- delete rules;
- }
- if (dates != nullptr) {
- delete dates;
- }
- if (initialRule != nullptr) {
- delete initialRule;
- }
- if (rbtz != nullptr) {
- delete rbtz;
- }
- return;
}
void
@@ -1809,7 +1742,7 @@ VTimeZone::write(VTZWriter& writer, UErrorCode& status) const {
icutzprop.append(u'[');
icutzprop.append(icutzver);
icutzprop.append(u']');
- customProps.addElementX(&icutzprop, status);
+ customProps.addElement(&icutzprop, status);
}
writeZone(writer, *tz, &customProps, status);
}
@@ -1827,58 +1760,48 @@ VTimeZone::write(UDate start, VTZWriter& writer, UErrorCode& status) const {
// Extract rules applicable to dates after the start time
getTimeZoneRulesAfter(start, initial, transitionRules, status);
+ LocalPointer<InitialTimeZoneRule> lpInitial(initial);
+ LocalPointer<UVector> lpTransitionRules(transitionRules);
if (U_FAILURE(status)) {
return;
}
// Create a RuleBasedTimeZone with the subset rule
getID(tzid);
- RuleBasedTimeZone rbtz(tzid, initial);
- if (transitionRules != nullptr) {
- while (!transitionRules->isEmpty()) {
- TimeZoneRule *tr = (TimeZoneRule*)transitionRules->orphanElementAt(0);
+ RuleBasedTimeZone rbtz(tzid, lpInitial.orphan());
+ if (lpTransitionRules.isValid()) {
+ U_ASSERT(transitionRules->hasDeleter()); // Assumed for U_FAILURE early return, below.
+ while (!lpTransitionRules->isEmpty()) {
+ TimeZoneRule *tr = (TimeZoneRule*)lpTransitionRules->orphanElementAt(0);
rbtz.addTransitionRule(tr, status);
if (U_FAILURE(status)) {
- goto cleanupWritePartial;
+ return;
}
}
- delete transitionRules;
- transitionRules = nullptr;
}
rbtz.complete(status);
if (U_FAILURE(status)) {
- goto cleanupWritePartial;
+ return;
}
if (olsonzid.length() > 0 && icutzver.length() > 0) {
UnicodeString *icutzprop = new UnicodeString(ICU_TZINFO_PROP);
if (icutzprop == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
- goto cleanupWritePartial;
+ return;
}
icutzprop->append(olsonzid);
- icutzprop->append((UChar)0x005B/*'['*/);
+ icutzprop->append((char16_t)0x005B/*'['*/);
icutzprop->append(icutzver);
icutzprop->append(ICU_TZINFO_PARTIAL, -1);
appendMillis(start, *icutzprop);
- icutzprop->append((UChar)0x005D/*']'*/);
- customProps.addElementX(icutzprop, status);
+ icutzprop->append((char16_t)0x005D/*']'*/);
+ customProps.adoptElement(icutzprop, status);
if (U_FAILURE(status)) {
- delete icutzprop;
- goto cleanupWritePartial;
+ return;
}
}
writeZone(writer, rbtz, &customProps, status);
- return;
-
-cleanupWritePartial:
- if (initial != nullptr) {
- delete initial;
- }
- if (transitionRules != nullptr) {
- U_ASSERT(transitionRules->hasDeleter());
- delete transitionRules;
- }
}
void
@@ -1915,11 +1838,11 @@ VTimeZone::writeSimple(UDate time, VTZWriter& writer, UErrorCode& status) const
return;
}
icutzprop->append(olsonzid);
- icutzprop->append((UChar)0x005B/*'['*/);
+ icutzprop->append((char16_t)0x005B/*'['*/);
icutzprop->append(icutzver);
icutzprop->append(ICU_TZINFO_SIMPLE, -1);
appendMillis(time, *icutzprop);
- icutzprop->append((UChar)0x005D/*']'*/);
+ icutzprop->append((char16_t)0x005D/*']'*/);
customProps.adoptElement(icutzprop.orphan(), status);
}
writeZone(writer, rbtz, &customProps, status);
@@ -1975,19 +1898,19 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz,
AnnualTimeZoneRule *finalStdRule = nullptr;
int32_t year, month, dom, dow, doy, mid;
- UBool hasTransitions = FALSE;
+ UBool hasTransitions = false;
TimeZoneTransition tzt;
UBool tztAvail;
UnicodeString name;
UBool isDst;
// Going through all transitions
- while (TRUE) {
- tztAvail = basictz.getNextTransition(t, FALSE, tzt);
+ while (true) {
+ tztAvail = basictz.getNextTransition(t, false, tzt);
if (!tztAvail) {
break;
}
- hasTransitions = TRUE;
+ hasTransitions = true;
t = tzt.getTime();
tzt.getTo()->getName(name);
isDst = (tzt.getTo()->getDSTSavings() != 0);
@@ -1996,7 +1919,7 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz,
int32_t toOffset = tzt.getTo()->getRawOffset() + tzt.getTo()->getDSTSavings();
Grego::timeToFields(tzt.getTime() + fromOffset, year, month, dom, dow, doy, mid);
int32_t weekInMonth = Grego::dayOfWeekInMonth(year, month, dom);
- UBool sameRule = FALSE;
+ UBool sameRule = false;
const AnnualTimeZoneRule *atzrule;
if (isDst) {
if (finalDstRule == nullptr
@@ -2017,14 +1940,14 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz,
// Update until time
dstUntilTime = t;
dstCount++;
- sameRule = TRUE;
+ sameRule = true;
}
if (!sameRule) {
if (dstCount == 1) {
- writeZonePropsByTime(w, TRUE, dstName, dstFromOffset, dstToOffset, dstStartTime,
- TRUE, status);
+ writeZonePropsByTime(w, true, dstName, dstFromOffset, dstToOffset, dstStartTime,
+ true, status);
} else {
- writeZonePropsByDOW(w, TRUE, dstName, dstFromOffset, dstToOffset,
+ writeZonePropsByDOW(w, true, dstName, dstFromOffset, dstToOffset,
dstMonth, dstWeekInMonth, dstDayOfWeek, dstStartTime, dstUntilTime, status);
}
if (U_FAILURE(status)) {
@@ -2068,14 +1991,14 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz,
// Update until time
stdUntilTime = t;
stdCount++;
- sameRule = TRUE;
+ sameRule = true;
}
if (!sameRule) {
if (stdCount == 1) {
- writeZonePropsByTime(w, FALSE, stdName, stdFromOffset, stdToOffset, stdStartTime,
- TRUE, status);
+ writeZonePropsByTime(w, false, stdName, stdFromOffset, stdToOffset, stdStartTime,
+ true, status);
} else {
- writeZonePropsByDOW(w, FALSE, stdName, stdFromOffset, stdToOffset,
+ writeZonePropsByDOW(w, false, stdName, stdFromOffset, stdToOffset,
stdMonth, stdWeekInMonth, stdDayOfWeek, stdStartTime, stdUntilTime, status);
}
if (U_FAILURE(status)) {
@@ -2105,7 +2028,7 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz,
if (!hasTransitions) {
// No transition - put a single non transition RDATE
int32_t raw, dst, offset;
- basictz.getOffset(0.0/*any time*/, FALSE, raw, dst, status);
+ basictz.getOffset(0.0/*any time*/, false, raw, dst, status);
if (U_FAILURE(status)) {
goto cleanupWriteZone;
}
@@ -2115,7 +2038,7 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz,
basictz.getID(tzid);
getDefaultTZName(tzid, isDst, name);
writeZonePropsByTime(w, isDst, name,
- offset, offset, DEF_TZSTARTTIME - offset, FALSE, status);
+ offset, offset, DEF_TZSTARTTIME - offset, false, status);
if (U_FAILURE(status)) {
goto cleanupWriteZone;
}
@@ -2123,10 +2046,10 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz,
if (dstCount > 0) {
if (finalDstRule == nullptr) {
if (dstCount == 1) {
- writeZonePropsByTime(w, TRUE, dstName, dstFromOffset, dstToOffset, dstStartTime,
- TRUE, status);
+ writeZonePropsByTime(w, true, dstName, dstFromOffset, dstToOffset, dstStartTime,
+ true, status);
} else {
- writeZonePropsByDOW(w, TRUE, dstName, dstFromOffset, dstToOffset,
+ writeZonePropsByDOW(w, true, dstName, dstFromOffset, dstToOffset,
dstMonth, dstWeekInMonth, dstDayOfWeek, dstStartTime, dstUntilTime, status);
}
if (U_FAILURE(status)) {
@@ -2134,16 +2057,16 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz,
}
} else {
if (dstCount == 1) {
- writeFinalRule(w, TRUE, finalDstRule,
+ writeFinalRule(w, true, finalDstRule,
dstFromOffset - dstFromDSTSavings, dstFromDSTSavings, dstStartTime, status);
} else {
// Use a single rule if possible
if (isEquivalentDateRule(dstMonth, dstWeekInMonth, dstDayOfWeek, finalDstRule->getRule())) {
- writeZonePropsByDOW(w, TRUE, dstName, dstFromOffset, dstToOffset,
+ writeZonePropsByDOW(w, true, dstName, dstFromOffset, dstToOffset,
dstMonth, dstWeekInMonth, dstDayOfWeek, dstStartTime, MAX_MILLIS, status);
} else {
// Not equivalent rule - write out two different rules
- writeZonePropsByDOW(w, TRUE, dstName, dstFromOffset, dstToOffset,
+ writeZonePropsByDOW(w, true, dstName, dstFromOffset, dstToOffset,
dstMonth, dstWeekInMonth, dstDayOfWeek, dstStartTime, dstUntilTime, status);
if (U_FAILURE(status)) {
goto cleanupWriteZone;
@@ -2152,7 +2075,7 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz,
UBool nextStartAvail = finalDstRule->getNextStart(dstUntilTime, dstFromOffset - dstFromDSTSavings, dstFromDSTSavings, false, nextStart);
U_ASSERT(nextStartAvail);
if (nextStartAvail) {
- writeFinalRule(w, TRUE, finalDstRule,
+ writeFinalRule(w, true, finalDstRule,
dstFromOffset - dstFromDSTSavings, dstFromDSTSavings, nextStart, status);
}
}
@@ -2165,10 +2088,10 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz,
if (stdCount > 0) {
if (finalStdRule == nullptr) {
if (stdCount == 1) {
- writeZonePropsByTime(w, FALSE, stdName, stdFromOffset, stdToOffset, stdStartTime,
- TRUE, status);
+ writeZonePropsByTime(w, false, stdName, stdFromOffset, stdToOffset, stdStartTime,
+ true, status);
} else {
- writeZonePropsByDOW(w, FALSE, stdName, stdFromOffset, stdToOffset,
+ writeZonePropsByDOW(w, false, stdName, stdFromOffset, stdToOffset,
stdMonth, stdWeekInMonth, stdDayOfWeek, stdStartTime, stdUntilTime, status);
}
if (U_FAILURE(status)) {
@@ -2176,16 +2099,16 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz,
}
} else {
if (stdCount == 1) {
- writeFinalRule(w, FALSE, finalStdRule,
+ writeFinalRule(w, false, finalStdRule,
stdFromOffset - stdFromDSTSavings, stdFromDSTSavings, stdStartTime, status);
} else {
// Use a single rule if possible
if (isEquivalentDateRule(stdMonth, stdWeekInMonth, stdDayOfWeek, finalStdRule->getRule())) {
- writeZonePropsByDOW(w, FALSE, stdName, stdFromOffset, stdToOffset,
+ writeZonePropsByDOW(w, false, stdName, stdFromOffset, stdToOffset,
stdMonth, stdWeekInMonth, stdDayOfWeek, stdStartTime, MAX_MILLIS, status);
} else {
// Not equivalent rule - write out two different rules
- writeZonePropsByDOW(w, FALSE, stdName, stdFromOffset, stdToOffset,
+ writeZonePropsByDOW(w, false, stdName, stdFromOffset, stdToOffset,
stdMonth, stdWeekInMonth, stdDayOfWeek, stdStartTime, stdUntilTime, status);
if (U_FAILURE(status)) {
goto cleanupWriteZone;
@@ -2194,7 +2117,7 @@ VTimeZone::writeZone(VTZWriter& w, BasicTimeZone& basictz,
UBool nextStartAvail = finalStdRule->getNextStart(stdUntilTime, stdFromOffset - stdFromDSTSavings, stdFromDSTSavings, false, nextStart);
U_ASSERT(nextStartAvail);
if (nextStartAvail) {
- writeFinalRule(w, FALSE, finalStdRule,
+ writeFinalRule(w, false, finalStdRule,
stdFromOffset - stdFromDSTSavings, stdFromDSTSavings, nextStart, status);
}
}
@@ -2524,13 +2447,13 @@ VTimeZone::writeFinalRule(VTZWriter& writer, UBool isDst, const AnnualTimeZoneRu
if (U_FAILURE(status)) {
return;
}
- UBool modifiedRule = TRUE;
+ UBool modifiedRule = true;
const DateTimeRule *dtrule = toWallTimeRule(rule->getRule(), fromRawOffset, fromDSTSavings, status);
if (U_FAILURE(status)) {
return;
}
if (dtrule == nullptr) {
- modifiedRule = FALSE;
+ modifiedRule = false;
dtrule = rule->getRule();
}
diff --git a/contrib/libs/icu/i18n/vzone.cpp b/contrib/libs/icu/i18n/vzone.cpp
index 7e3a5544fd..5517e5144c 100644
--- a/contrib/libs/icu/i18n/vzone.cpp
+++ b/contrib/libs/icu/i18n/vzone.cpp
@@ -26,13 +26,13 @@
U_NAMESPACE_USE
U_CAPI VZone* U_EXPORT2
-vzone_openID(const UChar* ID, int32_t idLength){
+vzone_openID(const char16_t* ID, int32_t idLength){
UnicodeString s(idLength==-1, ID, idLength);
return (VZone*) (VTimeZone::createVTimeZoneByID(s));
}
U_CAPI VZone* U_EXPORT2
-vzone_openData(const UChar* vtzdata, int32_t vtzdataLength, UErrorCode& status) {
+vzone_openData(const char16_t* vtzdata, int32_t vtzdataLength, UErrorCode& status) {
UnicodeString s(vtzdataLength==-1, vtzdata, vtzdataLength);
return (VZone*) (VTimeZone::createVTimeZone(s,status));
}
@@ -53,7 +53,7 @@ vzone_equals(const VZone* zone1, const VZone* zone2) {
}
U_CAPI UBool U_EXPORT2
-vzone_getTZURL(VZone* zone, UChar* & url, int32_t & urlLength) {
+vzone_getTZURL(VZone* zone, char16_t* & url, int32_t & urlLength) {
UnicodeString s;
UBool b = ((VTimeZone*)zone)->VTimeZone::getTZURL(s);
@@ -64,7 +64,7 @@ vzone_getTZURL(VZone* zone, UChar* & url, int32_t & urlLength) {
}
U_CAPI void U_EXPORT2
-vzone_setTZURL(VZone* zone, UChar* url, int32_t urlLength) {
+vzone_setTZURL(VZone* zone, char16_t* url, int32_t urlLength) {
UnicodeString s(urlLength==-1, url, urlLength);
((VTimeZone*)zone)->VTimeZone::setTZURL(s);
}
@@ -80,36 +80,36 @@ vzone_setLastModified(VZone* zone, UDate lastModified) {
}
U_CAPI void U_EXPORT2
-vzone_write(VZone* zone, UChar* & result, int32_t & resultLength, UErrorCode& status) {
+vzone_write(VZone* zone, char16_t* & result, int32_t & resultLength, UErrorCode& status) {
UnicodeString s;
((VTimeZone*)zone)->VTimeZone::write(s, status);
resultLength = s.length();
- result = (UChar*)uprv_malloc(resultLength);
+ result = (char16_t*)uprv_malloc(resultLength);
memcpy(result,s.getBuffer(),resultLength);
return;
}
U_CAPI void U_EXPORT2
-vzone_writeFromStart(VZone* zone, UDate start, UChar* & result, int32_t & resultLength, UErrorCode& status) {
+vzone_writeFromStart(VZone* zone, UDate start, char16_t* & result, int32_t & resultLength, UErrorCode& status) {
UnicodeString s;
((VTimeZone*)zone)->VTimeZone::write(start, s, status);
resultLength = s.length();
- result = (UChar*)uprv_malloc(resultLength);
+ result = (char16_t*)uprv_malloc(resultLength);
memcpy(result,s.getBuffer(),resultLength);
return;
}
U_CAPI void U_EXPORT2
-vzone_writeSimple(VZone* zone, UDate time, UChar* & result, int32_t & resultLength, UErrorCode& status) {
+vzone_writeSimple(VZone* zone, UDate time, char16_t* & result, int32_t & resultLength, UErrorCode& status) {
UnicodeString s;
((VTimeZone*)zone)->VTimeZone::writeSimple(time, s, status);
resultLength = s.length();
- result = (UChar*)uprv_malloc(resultLength);
+ result = (char16_t*)uprv_malloc(resultLength);
memcpy(result,s.getBuffer(),resultLength);
return;
diff --git a/contrib/libs/icu/i18n/vzone.h b/contrib/libs/icu/i18n/vzone.h
index d1b6d8d820..bf9b45ea20 100644
--- a/contrib/libs/icu/i18n/vzone.h
+++ b/contrib/libs/icu/i18n/vzone.h
@@ -24,14 +24,12 @@
#include "unicode/uobject.h"
#include "ztrans.h"
-#ifndef UCNV_H
struct VZone;
/**
* A UnicodeSet. Use the vzone_* API to manipulate. Create with
* vzone_open*, and destroy with vzone_close.
*/
typedef struct VZone VZone;
-#endif
/*********************************************************************
* VZone API
diff --git a/contrib/libs/icu/i18n/windtfmt.cpp b/contrib/libs/icu/i18n/windtfmt.cpp
index f6a990ea29..2118f92dce 100644
--- a/contrib/libs/icu/i18n/windtfmt.cpp
+++ b/contrib/libs/icu/i18n/windtfmt.cpp
@@ -56,13 +56,13 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(Win32DateFormat)
UnicodeString* Win32DateFormat::getTimeDateFormat(const Calendar *cal, const Locale *locale, UErrorCode &status) const
{
- UnicodeString *result = NULL;
+ UnicodeString *result = nullptr;
const char *type = cal->getType();
const char *base = locale->getBaseName();
UResourceBundle *topBundle = ures_open((char *) 0, base, &status);
- UResourceBundle *calBundle = ures_getByKey(topBundle, "calendar", NULL, &status);
- UResourceBundle *typBundle = ures_getByKeyWithFallback(calBundle, type, NULL, &status);
- UResourceBundle *patBundle = ures_getByKeyWithFallback(typBundle, "DateTimePatterns", NULL, &status);
+ UResourceBundle *calBundle = ures_getByKey(topBundle, "calendar", nullptr, &status);
+ UResourceBundle *typBundle = ures_getByKeyWithFallback(calBundle, type, nullptr, &status);
+ UResourceBundle *patBundle = ures_getByKeyWithFallback(typBundle, "DateTimePatterns", nullptr, &status);
if (status == U_MISSING_RESOURCE_ERROR) {
status = U_ZERO_ERROR;
@@ -71,7 +71,7 @@ UnicodeString* Win32DateFormat::getTimeDateFormat(const Calendar *cal, const Loc
}
if (U_FAILURE(status)) {
- static const UChar defaultPattern[] = {0x007B, 0x0031, 0x007D, 0x0020, 0x007B, 0x0030, 0x007D, 0x0000}; // "{1} {0}"
+ static const char16_t defaultPattern[] = {0x007B, 0x0031, 0x007D, 0x0020, 0x007B, 0x0030, 0x007D, 0x0000}; // "{1} {0}"
return new UnicodeString(defaultPattern, UPRV_LENGTHOF(defaultPattern));
}
@@ -82,9 +82,9 @@ UnicodeString* Win32DateFormat::getTimeDateFormat(const Calendar *cal, const Loc
// Get proper date time format
glueIndex = (int32_t)(DateFormat::kDateTimeOffset + (fDateStyle - DateFormat::kDateOffset));
}
- const UChar *resStr = ures_getStringByIndex(patBundle, glueIndex, &resStrLen, &status);
+ const char16_t *resStr = ures_getStringByIndex(patBundle, glueIndex, &resStrLen, &status);
- result = new UnicodeString(TRUE, resStr, resStrLen);
+ result = new UnicodeString(true, resStr, resStrLen);
ures_close(patBundle);
ures_close(typBundle);
@@ -102,7 +102,7 @@ static UErrorCode GetEquivalentWindowsLocaleName(const Locale& locale, UnicodeSt
char asciiBCP47Tag[LOCALE_NAME_MAX_LENGTH] = {};
// Convert from names like "en_CA" and "de_DE@collation=phonebook" to "en-CA" and "de-DE-u-co-phonebk".
- (void)uloc_toLanguageTag(locale.getName(), asciiBCP47Tag, UPRV_LENGTHOF(asciiBCP47Tag), FALSE, &status);
+ (void)uloc_toLanguageTag(locale.getName(), asciiBCP47Tag, UPRV_LENGTHOF(asciiBCP47Tag), false, &status);
if (U_SUCCESS(status))
{
@@ -160,7 +160,7 @@ static UErrorCode GetEquivalentWindowsLocaleName(const Locale& locale, UnicodeSt
// TODO: Range-check timeStyle, dateStyle
Win32DateFormat::Win32DateFormat(DateFormat::EStyle timeStyle, DateFormat::EStyle dateStyle, const Locale &locale, UErrorCode &status)
- : DateFormat(), fDateTimeMsg(NULL), fTimeStyle(timeStyle), fDateStyle(dateStyle), fLocale(locale), fZoneID(), fWindowsLocaleName(nullptr)
+ : DateFormat(), fDateTimeMsg(nullptr), fTimeStyle(timeStyle), fDateStyle(dateStyle), fLocale(locale), fZoneID(), fWindowsLocaleName(nullptr)
{
if (U_SUCCESS(status)) {
GetEquivalentWindowsLocaleName(locale, &fWindowsLocaleName);
@@ -199,7 +199,7 @@ Win32DateFormat &Win32DateFormat::operator=(const Win32DateFormat &other)
// delete fCalendar;
- this->fDateTimeMsg = other.fDateTimeMsg == NULL ? NULL : new UnicodeString(*other.fDateTimeMsg);
+ this->fDateTimeMsg = other.fDateTimeMsg == nullptr ? nullptr : new UnicodeString(*other.fDateTimeMsg);
this->fTimeStyle = other.fTimeStyle;
this->fDateStyle = other.fDateStyle;
this->fLocale = other.fLocale;
@@ -209,7 +209,7 @@ Win32DateFormat &Win32DateFormat::operator=(const Win32DateFormat &other)
this->fTZI = NEW_ARRAY(TIME_ZONE_INFORMATION, 1);
*this->fTZI = *other.fTZI;
- this->fWindowsLocaleName = other.fWindowsLocaleName == NULL ? NULL : new UnicodeString(*other.fWindowsLocaleName);
+ this->fWindowsLocaleName = other.fWindowsLocaleName == nullptr ? nullptr : new UnicodeString(*other.fWindowsLocaleName);
return *this;
}
@@ -271,7 +271,7 @@ void Win32DateFormat::parse(const UnicodeString& /* text */, Calendar& /* cal */
void Win32DateFormat::adoptCalendar(Calendar *newCalendar)
{
- if (fCalendar == NULL || strcmp(fCalendar->getType(), newCalendar->getType()) != 0) {
+ if (fCalendar == nullptr || strcmp(fCalendar->getType(), newCalendar->getType()) != 0) {
UErrorCode status = U_ZERO_ERROR;
if (fDateStyle != DateFormat::kNone && fTimeStyle != DateFormat::kNone) {
@@ -317,19 +317,19 @@ void Win32DateFormat::formatDate(const SYSTEMTIME *st, UnicodeString &appendTo)
localeName = reinterpret_cast<const wchar_t*>(toOldUCharPtr(fWindowsLocaleName->getTerminatedBuffer()));
}
- result = GetDateFormatEx(localeName, dfFlags[fDateStyle - kDateOffset], st, NULL, buffer, STACK_BUFFER_SIZE, NULL);
+ result = GetDateFormatEx(localeName, dfFlags[fDateStyle - kDateOffset], st, nullptr, buffer, STACK_BUFFER_SIZE, nullptr);
if (result == 0) {
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
- int newLength = GetDateFormatEx(localeName, dfFlags[fDateStyle - kDateOffset], st, NULL, NULL, 0, NULL);
+ int newLength = GetDateFormatEx(localeName, dfFlags[fDateStyle - kDateOffset], st, nullptr, nullptr, 0, nullptr);
buffer = NEW_ARRAY(wchar_t, newLength);
- GetDateFormatEx(localeName, dfFlags[fDateStyle - kDateOffset], st, NULL, buffer, newLength, NULL);
+ GetDateFormatEx(localeName, dfFlags[fDateStyle - kDateOffset], st, nullptr, buffer, newLength, nullptr);
}
}
- appendTo.append((const UChar *)buffer, (int32_t) wcslen(buffer));
+ appendTo.append((const char16_t *)buffer, (int32_t) wcslen(buffer));
if (buffer != stackBuffer) {
DELETE_ARRAY(buffer);
@@ -350,19 +350,19 @@ void Win32DateFormat::formatTime(const SYSTEMTIME *st, UnicodeString &appendTo)
localeName = reinterpret_cast<const wchar_t*>(toOldUCharPtr(fWindowsLocaleName->getTerminatedBuffer()));
}
- result = GetTimeFormatEx(localeName, tfFlags[fTimeStyle], st, NULL, buffer, STACK_BUFFER_SIZE);
+ result = GetTimeFormatEx(localeName, tfFlags[fTimeStyle], st, nullptr, buffer, STACK_BUFFER_SIZE);
if (result == 0) {
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
- int newLength = GetTimeFormatEx(localeName, tfFlags[fTimeStyle], st, NULL, NULL, 0);
+ int newLength = GetTimeFormatEx(localeName, tfFlags[fTimeStyle], st, nullptr, nullptr, 0);
buffer = NEW_ARRAY(wchar_t, newLength);
- GetTimeFormatEx(localeName, tfFlags[fTimeStyle], st, NULL, buffer, newLength);
+ GetTimeFormatEx(localeName, tfFlags[fTimeStyle], st, nullptr, buffer, newLength);
}
}
- appendTo.append((const UChar *)buffer, (int32_t) wcslen(buffer));
+ appendTo.append((const char16_t *)buffer, (int32_t) wcslen(buffer));
if (buffer != stackBuffer) {
DELETE_ARRAY(buffer);
@@ -380,7 +380,7 @@ UnicodeString Win32DateFormat::setTimeZoneInfo(TIME_ZONE_INFORMATION *tzi, const
zone.getID(icuid);
if (! uprv_getWindowsTimeZoneInfo(tzi, icuid.getBuffer(), icuid.length())) {
- UBool found = FALSE;
+ UBool found = false;
int32_t ec = TimeZone::countEquivalentIDs(icuid);
for (int z = 0; z < ec; z += 1) {
diff --git a/contrib/libs/icu/i18n/windtfmt.h b/contrib/libs/icu/i18n/windtfmt.h
index 7fe7f68f45..0c3f542785 100644
--- a/contrib/libs/icu/i18n/windtfmt.h
+++ b/contrib/libs/icu/i18n/windtfmt.h
@@ -99,7 +99,7 @@ public:
* </pre>
* @return The class ID for all objects of this class.
*/
- U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
+ U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
/**
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
@@ -111,7 +111,7 @@ public:
* given class have the same class ID. Objects of
* other classes have different class IDs.
*/
- virtual UClassID getDynamicClassID(void) const;
+ virtual UClassID getDynamicClassID() const;
private:
void formatDate(const SYSTEMTIME *st, UnicodeString &appendTo) const;
diff --git a/contrib/libs/icu/i18n/winnmfmt.cpp b/contrib/libs/icu/i18n/winnmfmt.cpp
index 8b2a9a4f95..6efa9a63d8 100644
--- a/contrib/libs/icu/i18n/winnmfmt.cpp
+++ b/contrib/libs/icu/i18n/winnmfmt.cpp
@@ -101,7 +101,7 @@ static void getNumberFormat(NUMBERFMTW *fmt, const wchar_t *windowsLocaleName)
static void freeNumberFormat(NUMBERFMTW *fmt)
{
- if (fmt != NULL) {
+ if (fmt != nullptr) {
DELETE_ARRAY(fmt->lpThousandSep);
DELETE_ARRAY(fmt->lpDecimalSep);
}
@@ -132,7 +132,7 @@ static void getCurrencyFormat(CURRENCYFMTW *fmt, const wchar_t *windowsLocaleNam
static void freeCurrencyFormat(CURRENCYFMTW *fmt)
{
- if (fmt != NULL) {
+ if (fmt != nullptr) {
DELETE_ARRAY(fmt->lpCurrencySymbol);
DELETE_ARRAY(fmt->lpThousandSep);
DELETE_ARRAY(fmt->lpDecimalSep);
@@ -147,7 +147,7 @@ static UErrorCode GetEquivalentWindowsLocaleName(const Locale& locale, UnicodeSt
char asciiBCP47Tag[LOCALE_NAME_MAX_LENGTH] = {};
// Convert from names like "en_CA" and "de_DE@collation=phonebook" to "en-CA" and "de-DE-u-co-phonebk".
- (void) uloc_toLanguageTag(locale.getName(), asciiBCP47Tag, UPRV_LENGTHOF(asciiBCP47Tag), FALSE, &status);
+ (void) uloc_toLanguageTag(locale.getName(), asciiBCP47Tag, UPRV_LENGTHOF(asciiBCP47Tag), false, &status);
if (U_SUCCESS(status))
{
@@ -204,7 +204,7 @@ static UErrorCode GetEquivalentWindowsLocaleName(const Locale& locale, UnicodeSt
}
Win32NumberFormat::Win32NumberFormat(const Locale &locale, UBool currency, UErrorCode &status)
- : NumberFormat(), fCurrency(currency), fFormatInfo(NULL), fFractionDigitsSet(FALSE), fWindowsLocaleName(nullptr)
+ : NumberFormat(), fCurrency(currency), fFormatInfo(nullptr), fFractionDigitsSet(false), fWindowsLocaleName(nullptr)
{
if (!U_FAILURE(status)) {
fLCID = locale.getLCID();
@@ -246,7 +246,7 @@ Win32NumberFormat::Win32NumberFormat(const Locale &locale, UBool currency, UErro
Win32NumberFormat::Win32NumberFormat(const Win32NumberFormat &other)
: NumberFormat(other), fFormatInfo((FormatInfo*)uprv_malloc(sizeof(FormatInfo)))
{
- if (fFormatInfo != NULL) {
+ if (fFormatInfo != nullptr) {
uprv_memset(fFormatInfo, 0, sizeof(*fFormatInfo));
}
*this = other;
@@ -254,7 +254,7 @@ Win32NumberFormat::Win32NumberFormat(const Win32NumberFormat &other)
Win32NumberFormat::~Win32NumberFormat()
{
- if (fFormatInfo != NULL) {
+ if (fFormatInfo != nullptr) {
if (fCurrency) {
freeCurrencyFormat(&fFormatInfo->currency);
} else {
@@ -275,7 +275,7 @@ Win32NumberFormat &Win32NumberFormat::operator=(const Win32NumberFormat &other)
this->fLocale = other.fLocale;
this->fLCID = other.fLCID;
this->fFractionDigitsSet = other.fFractionDigitsSet;
- this->fWindowsLocaleName = other.fWindowsLocaleName == NULL ? NULL : new UnicodeString(*other.fWindowsLocaleName);
+ this->fWindowsLocaleName = other.fWindowsLocaleName == nullptr ? nullptr : new UnicodeString(*other.fWindowsLocaleName);
const wchar_t *localeName = nullptr;
@@ -325,13 +325,13 @@ void Win32NumberFormat::parse(const UnicodeString& text, Formattable& result, Pa
}
void Win32NumberFormat::setMaximumFractionDigits(int32_t newValue)
{
- fFractionDigitsSet = TRUE;
+ fFractionDigitsSet = true;
NumberFormat::setMaximumFractionDigits(newValue);
}
void Win32NumberFormat::setMinimumFractionDigits(int32_t newValue)
{
- fFractionDigitsSet = TRUE;
+ fFractionDigitsSet = true;
NumberFormat::setMinimumFractionDigits(newValue);
}
@@ -344,7 +344,7 @@ UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen
nBuffer[0] = 0x0000;
- /* Due to the arguments causing a result to be <= 23 characters (+2 for NULL and minus),
+ /* Due to the arguments causing a result to be <= 23 characters (+2 for nullptr and minus),
we don't need to reallocate the buffer. */
va_start(args, fmt);
result = _vsnwprintf(nBuffer, STACK_BUFFER_SIZE, fmt, args);
@@ -360,7 +360,7 @@ UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen
newLength = _vscwprintf(fmt, args);
va_end(args);
- nBuffer = NEW_ARRAY(UChar, newLength + 1);
+ nBuffer = NEW_ARRAY(char16_t, newLength + 1);
va_start(args, fmt);
result = _vsnwprintf(nBuffer, newLength + 1, fmt, args);
@@ -412,7 +412,7 @@ UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen
DWORD lastError = GetLastError();
if (lastError == ERROR_INSUFFICIENT_BUFFER) {
- int newLength = GetCurrencyFormatEx(localeName, 0, nBuffer, &formatInfo.currency, NULL, 0);
+ int newLength = GetCurrencyFormatEx(localeName, 0, nBuffer, &formatInfo.currency, nullptr, 0);
buffer = NEW_ARRAY(wchar_t, newLength);
buffer[0] = 0x0000;
@@ -432,7 +432,7 @@ UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen
if (result == 0) {
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
- int newLength = GetNumberFormatEx(localeName, 0, nBuffer, &formatInfo.number, NULL, 0);
+ int newLength = GetNumberFormatEx(localeName, 0, nBuffer, &formatInfo.number, nullptr, 0);
buffer = NEW_ARRAY(wchar_t, newLength);
buffer[0] = 0x0000;
@@ -441,7 +441,7 @@ UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen
}
}
- appendTo.append((UChar *)buffer, (int32_t) wcslen(buffer));
+ appendTo.append((char16_t *)buffer, (int32_t) wcslen(buffer));
if (buffer != stackBuffer) {
DELETE_ARRAY(buffer);
diff --git a/contrib/libs/icu/i18n/winnmfmt.h b/contrib/libs/icu/i18n/winnmfmt.h
index 99571d2013..1cf87f4d2c 100644
--- a/contrib/libs/icu/i18n/winnmfmt.h
+++ b/contrib/libs/icu/i18n/winnmfmt.h
@@ -132,7 +132,7 @@ public:
* </pre>
* @return The class ID for all objects of this class.
*/
- U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
+ U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
/**
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
@@ -144,7 +144,7 @@ public:
* given class have the same class ID. Objects of
* other classes have different class IDs.
*/
- virtual UClassID getDynamicClassID(void) const;
+ virtual UClassID getDynamicClassID() const;
private:
UnicodeString &format(int32_t numDigits, UnicodeString &appendTo, const wchar_t *format, ...) const;
diff --git a/contrib/libs/icu/i18n/wintzimpl.cpp b/contrib/libs/icu/i18n/wintzimpl.cpp
index a6d9330063..8f2961f8f0 100644
--- a/contrib/libs/icu/i18n/wintzimpl.cpp
+++ b/contrib/libs/icu/i18n/wintzimpl.cpp
@@ -39,14 +39,14 @@ U_NAMESPACE_USE
static UBool getSystemTimeInformation(TimeZone *tz, SYSTEMTIME &daylightDate, SYSTEMTIME &standardDate, int32_t &bias, int32_t &daylightBias, int32_t &standardBias) {
UErrorCode status = U_ZERO_ERROR;
- UBool result = TRUE;
+ UBool result = true;
BasicTimeZone *btz = (BasicTimeZone*)tz; // we should check type
- InitialTimeZoneRule *initial = NULL;
- AnnualTimeZoneRule *std = NULL, *dst = NULL;
+ InitialTimeZoneRule *initial = nullptr;
+ AnnualTimeZoneRule *std = nullptr, *dst = nullptr;
btz->getSimpleRulesNear(uprv_getUTCtime(), initial, std, dst, status);
if (U_SUCCESS(status)) {
- if (std == NULL || dst == NULL) {
+ if (std == nullptr || dst == nullptr) {
bias = -1 * (initial->getRawOffset()/60000);
standardBias = 0;
daylightBias = 0;
@@ -107,7 +107,7 @@ static UBool getSystemTimeInformation(TimeZone *tz, SYSTEMTIME &daylightDate, SY
daylightDate.wMilliseconds = static_cast<WORD>(mil);
}
} else {
- result = FALSE;
+ result = false;
}
delete initial;
@@ -117,12 +117,12 @@ static UBool getSystemTimeInformation(TimeZone *tz, SYSTEMTIME &daylightDate, SY
return result;
}
-static UBool getWindowsTimeZoneInfo(TIME_ZONE_INFORMATION *zoneInfo, const UChar *icuid, int32_t length) {
- UBool result = FALSE;
+static UBool getWindowsTimeZoneInfo(TIME_ZONE_INFORMATION *zoneInfo, const char16_t *icuid, int32_t length) {
+ UBool result = false;
UnicodeString id = UnicodeString(icuid, length);
TimeZone *tz = TimeZone::createTimeZone(id);
- if (tz != NULL) {
+ if (tz != nullptr) {
int32_t bias;
int32_t daylightBias;
int32_t standardBias;
@@ -137,7 +137,7 @@ static UBool getWindowsTimeZoneInfo(TIME_ZONE_INFORMATION *zoneInfo, const UChar
zoneInfo->DaylightDate = daylightDate;
zoneInfo->StandardDate = standardDate;
- result = TRUE;
+ result = true;
}
}
@@ -149,12 +149,12 @@ static UBool getWindowsTimeZoneInfo(TIME_ZONE_INFORMATION *zoneInfo, const UChar
* information to put into zoneInfo. This includes bias and standard time date and daylight saving date.
*/
U_CAPI UBool U_EXPORT2
-uprv_getWindowsTimeZoneInfo(TIME_ZONE_INFORMATION *zoneInfo, const UChar *icuid, int32_t length)
+uprv_getWindowsTimeZoneInfo(TIME_ZONE_INFORMATION *zoneInfo, const char16_t *icuid, int32_t length)
{
if (getWindowsTimeZoneInfo(zoneInfo, icuid, length)) {
- return TRUE;
+ return true;
} else {
- return FALSE;
+ return false;
}
}
diff --git a/contrib/libs/icu/i18n/zonemeta.cpp b/contrib/libs/icu/i18n/zonemeta.cpp
index b8afa4760f..42051e2f41 100644
--- a/contrib/libs/icu/i18n/zonemeta.cpp
+++ b/contrib/libs/icu/i18n/zonemeta.cpp
@@ -33,85 +33,77 @@
static icu::UMutex gZoneMetaLock;
// CLDR Canonical ID mapping table
-static UHashtable *gCanonicalIDCache = NULL;
-static icu::UInitOnce gCanonicalIDCacheInitOnce = U_INITONCE_INITIALIZER;
+static UHashtable *gCanonicalIDCache = nullptr;
+static icu::UInitOnce gCanonicalIDCacheInitOnce {};
// Metazone mapping table
-static UHashtable *gOlsonToMeta = NULL;
-static icu::UInitOnce gOlsonToMetaInitOnce = U_INITONCE_INITIALIZER;
+static UHashtable *gOlsonToMeta = nullptr;
+static icu::UInitOnce gOlsonToMetaInitOnce {};
// Available metazone IDs vector and table
-static icu::UVector *gMetaZoneIDs = NULL;
-static UHashtable *gMetaZoneIDTable = NULL;
-static icu::UInitOnce gMetaZoneIDsInitOnce = U_INITONCE_INITIALIZER;
+static icu::UVector *gMetaZoneIDs = nullptr;
+static UHashtable *gMetaZoneIDTable = nullptr;
+static icu::UInitOnce gMetaZoneIDsInitOnce {};
// Country info vectors
-static icu::UVector *gSingleZoneCountries = NULL;
-static icu::UVector *gMultiZonesCountries = NULL;
-static icu::UInitOnce gCountryInfoVectorsInitOnce = U_INITONCE_INITIALIZER;
+static icu::UVector *gSingleZoneCountries = nullptr;
+static icu::UVector *gMultiZonesCountries = nullptr;
+static icu::UInitOnce gCountryInfoVectorsInitOnce {};
U_CDECL_BEGIN
/**
* Cleanup callback func
*/
-static UBool U_CALLCONV zoneMeta_cleanup(void)
+static UBool U_CALLCONV zoneMeta_cleanup()
{
- if (gCanonicalIDCache != NULL) {
+ if (gCanonicalIDCache != nullptr) {
uhash_close(gCanonicalIDCache);
- gCanonicalIDCache = NULL;
+ gCanonicalIDCache = nullptr;
}
gCanonicalIDCacheInitOnce.reset();
- if (gOlsonToMeta != NULL) {
+ if (gOlsonToMeta != nullptr) {
uhash_close(gOlsonToMeta);
- gOlsonToMeta = NULL;
+ gOlsonToMeta = nullptr;
}
gOlsonToMetaInitOnce.reset();
- if (gMetaZoneIDTable != NULL) {
+ if (gMetaZoneIDTable != nullptr) {
uhash_close(gMetaZoneIDTable);
- gMetaZoneIDTable = NULL;
+ gMetaZoneIDTable = nullptr;
}
// delete after closing gMetaZoneIDTable, because it holds
// value objects held by the hashtable
delete gMetaZoneIDs;
- gMetaZoneIDs = NULL;
+ gMetaZoneIDs = nullptr;
gMetaZoneIDsInitOnce.reset();
delete gSingleZoneCountries;
- gSingleZoneCountries = NULL;
+ gSingleZoneCountries = nullptr;
delete gMultiZonesCountries;
- gMultiZonesCountries = NULL;
+ gMultiZonesCountries = nullptr;
gCountryInfoVectorsInitOnce.reset();
- return TRUE;
+ return true;
}
/**
- * Deleter for UChar* string
+ * Deleter for char16_t* string
*/
static void U_CALLCONV
deleteUCharString(void *obj) {
- UChar *entry = (UChar*)obj;
+ char16_t *entry = (char16_t*)obj;
uprv_free(entry);
}
/**
- * Deleter for UVector
- */
-static void U_CALLCONV
-deleteUVector(void *obj) {
- delete (icu::UVector*) obj;
-}
-
-/**
* Deleter for OlsonToMetaMappingEntry
*/
static void U_CALLCONV
deleteOlsonToMetaMappingEntry(void *obj) {
icu::OlsonToMetaMappingEntry *entry = (icu::OlsonToMetaMappingEntry*)obj;
- uprv_free(entry);
+ delete entry;
}
U_CDECL_END
@@ -133,14 +125,14 @@ static const char gPrimaryZonesTag[] = "primaryZones";
static const char gWorldTag[] = "001";
-static const UChar gWorld[] = {0x30, 0x30, 0x31, 0x00}; // "001"
+static const char16_t gWorld[] = {0x30, 0x30, 0x31, 0x00}; // "001"
-static const UChar gDefaultFrom[] = {0x31, 0x39, 0x37, 0x30, 0x2D, 0x30, 0x31, 0x2D, 0x30, 0x31,
+static const char16_t gDefaultFrom[] = {0x31, 0x39, 0x37, 0x30, 0x2D, 0x30, 0x31, 0x2D, 0x30, 0x31,
0x20, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x00}; // "1970-01-01 00:00"
-static const UChar gDefaultTo[] = {0x39, 0x39, 0x39, 0x39, 0x2D, 0x31, 0x32, 0x2D, 0x33, 0x31,
+static const char16_t gDefaultTo[] = {0x39, 0x39, 0x39, 0x39, 0x2D, 0x31, 0x32, 0x2D, 0x33, 0x31,
0x20, 0x32, 0x33, 0x3A, 0x35, 0x39, 0x00}; // "9999-12-31 23:59"
-static const UChar gCustomTzPrefix[] = {0x47, 0x4D, 0x54, 0}; // "GMT"
+static const char16_t gCustomTzPrefix[] = {0x47, 0x4D, 0x54, 0}; // "GMT"
#define ASCII_DIGIT(c) (((c)>=0x30 && (c)<=0x39) ? (c)-0x30 : -1)
@@ -149,7 +141,7 @@ static const UChar gCustomTzPrefix[] = {0x47, 0x4D, 0x54, 0}; // "GMT"
* The format used by CLDR metazone mapping is "yyyy-MM-dd HH:mm".
*/
static UDate
-parseDate (const UChar *text, UErrorCode &status) {
+parseDate (const char16_t *text, UErrorCode &status) {
if (U_FAILURE(status)) {
return 0;
}
@@ -220,61 +212,61 @@ parseDate (const UChar *text, UErrorCode &status) {
}
static void U_CALLCONV initCanonicalIDCache(UErrorCode &status) {
- gCanonicalIDCache = uhash_open(uhash_hashUChars, uhash_compareUChars, NULL, &status);
- if (gCanonicalIDCache == NULL) {
+ gCanonicalIDCache = uhash_open(uhash_hashUChars, uhash_compareUChars, nullptr, &status);
+ if (gCanonicalIDCache == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
if (U_FAILURE(status)) {
- gCanonicalIDCache = NULL;
+ gCanonicalIDCache = nullptr;
}
// No key/value deleters - keys/values are from a resource bundle
ucln_i18n_registerCleanup(UCLN_I18N_ZONEMETA, zoneMeta_cleanup);
}
-const UChar* U_EXPORT2
+const char16_t* U_EXPORT2
ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status) {
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
if (tzid.isBogus() || tzid.length() > ZID_KEY_MAX) {
status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
// Checking the cached results
umtx_initOnce(gCanonicalIDCacheInitOnce, &initCanonicalIDCache, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
- const UChar *canonicalID = NULL;
+ const char16_t *canonicalID = nullptr;
UErrorCode tmpStatus = U_ZERO_ERROR;
- UChar utzid[ZID_KEY_MAX + 1];
+ char16_t utzid[ZID_KEY_MAX + 1];
tzid.extract(utzid, ZID_KEY_MAX + 1, tmpStatus);
U_ASSERT(tmpStatus == U_ZERO_ERROR); // we checked the length of tzid already
if (!uprv_isInvariantUString(utzid, -1)) {
// All of known tz IDs are only containing ASCII invariant characters.
status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
// Check if it was already cached
umtx_lock(&gZoneMetaLock);
{
- canonicalID = (const UChar *)uhash_get(gCanonicalIDCache, utzid);
+ canonicalID = (const char16_t *)uhash_get(gCanonicalIDCache, utzid);
}
umtx_unlock(&gZoneMetaLock);
- if (canonicalID != NULL) {
+ if (canonicalID != nullptr) {
return canonicalID;
}
// If not, resolve CLDR canonical ID with resource data
- UBool isInputCanonical = FALSE;
+ UBool isInputCanonical = false;
char id[ZID_KEY_MAX + 1];
tzid.extract(0, 0x7fffffff, id, UPRV_LENGTHOF(id), US_INV);
@@ -286,32 +278,32 @@ ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status) {
}
}
- UResourceBundle *top = ures_openDirect(NULL, gKeyTypeData, &tmpStatus);
- UResourceBundle *rb = ures_getByKey(top, gTypeMapTag, NULL, &tmpStatus);
+ UResourceBundle *top = ures_openDirect(nullptr, gKeyTypeData, &tmpStatus);
+ UResourceBundle *rb = ures_getByKey(top, gTypeMapTag, nullptr, &tmpStatus);
ures_getByKey(rb, gTimezoneTag, rb, &tmpStatus);
ures_getByKey(rb, id, rb, &tmpStatus);
if (U_SUCCESS(tmpStatus)) {
// type entry (canonical) found
- // the input is the canonical ID. resolve to const UChar*
+ // the input is the canonical ID. resolve to const char16_t*
canonicalID = TimeZone::findID(tzid);
- isInputCanonical = TRUE;
+ isInputCanonical = true;
}
- if (canonicalID == NULL) {
+ if (canonicalID == nullptr) {
// If a map element not found, then look for an alias
tmpStatus = U_ZERO_ERROR;
ures_getByKey(top, gTypeAliasTag, rb, &tmpStatus);
ures_getByKey(rb, gTimezoneTag, rb, &tmpStatus);
- const UChar *canonical = ures_getStringByKey(rb,id,NULL,&tmpStatus);
+ const char16_t *canonical = ures_getStringByKey(rb,id,nullptr,&tmpStatus);
if (U_SUCCESS(tmpStatus)) {
// canonical map found
canonicalID = canonical;
}
- if (canonicalID == NULL) {
+ if (canonicalID == nullptr) {
// Dereference the input ID using the tz data
- const UChar *derefer = TimeZone::dereferOlsonLink(tzid);
- if (derefer == NULL) {
+ const char16_t *derefer = TimeZone::dereferOlsonLink(tzid);
+ if (derefer == nullptr) {
status = U_ILLEGAL_ARGUMENT_ERROR;
} else {
int32_t len = u_strlen(derefer);
@@ -330,13 +322,13 @@ ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status) {
// rb still points to the alias table, so we don't have to go looking
// for it.
tmpStatus = U_ZERO_ERROR;
- canonical = ures_getStringByKey(rb,id,NULL,&tmpStatus);
+ canonical = ures_getStringByKey(rb,id,nullptr,&tmpStatus);
if (U_SUCCESS(tmpStatus)) {
// canonical map for the dereferenced ID found
canonicalID = canonical;
} else {
canonicalID = derefer;
- isInputCanonical = TRUE;
+ isInputCanonical = true;
}
}
}
@@ -345,26 +337,26 @@ ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status) {
ures_close(top);
if (U_SUCCESS(status)) {
- U_ASSERT(canonicalID != NULL); // canocanilD must be non-NULL here
+ U_ASSERT(canonicalID != nullptr); // canocanilD must be non-nullptr here
// Put the resolved canonical ID to the cache
umtx_lock(&gZoneMetaLock);
{
- const UChar* idInCache = (const UChar *)uhash_get(gCanonicalIDCache, utzid);
- if (idInCache == NULL) {
- const UChar* key = ZoneMeta::findTimeZoneID(tzid);
- U_ASSERT(key != NULL);
- if (key != NULL) {
- idInCache = (const UChar *)uhash_put(gCanonicalIDCache, (void *)key, (void *)canonicalID, &status);
- U_ASSERT(idInCache == NULL);
+ const char16_t* idInCache = (const char16_t *)uhash_get(gCanonicalIDCache, utzid);
+ if (idInCache == nullptr) {
+ const char16_t* key = ZoneMeta::findTimeZoneID(tzid);
+ U_ASSERT(key != nullptr);
+ if (key != nullptr) {
+ idInCache = (const char16_t *)uhash_put(gCanonicalIDCache, (void *)key, (void *)canonicalID, &status);
+ U_ASSERT(idInCache == nullptr);
}
}
if (U_SUCCESS(status) && isInputCanonical) {
// Also put canonical ID itself into the cache if not exist
- const UChar *canonicalInCache = (const UChar*)uhash_get(gCanonicalIDCache, canonicalID);
- if (canonicalInCache == NULL) {
- canonicalInCache = (const UChar *)uhash_put(gCanonicalIDCache, (void *)canonicalID, (void *)canonicalID, &status);
- U_ASSERT(canonicalInCache == NULL);
+ const char16_t *canonicalInCache = (const char16_t*)uhash_get(gCanonicalIDCache, canonicalID);
+ if (canonicalInCache == nullptr) {
+ canonicalInCache = (const char16_t *)uhash_put(gCanonicalIDCache, (void *)canonicalID, (void *)canonicalID, &status);
+ U_ASSERT(canonicalInCache == nullptr);
}
}
}
@@ -376,18 +368,18 @@ ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status) {
UnicodeString& U_EXPORT2
ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UnicodeString &systemID, UErrorCode& status) {
- const UChar *canonicalID = getCanonicalCLDRID(tzid, status);
- if (U_FAILURE(status) || canonicalID == NULL) {
+ const char16_t *canonicalID = getCanonicalCLDRID(tzid, status);
+ if (U_FAILURE(status) || canonicalID == nullptr) {
systemID.setToBogus();
return systemID;
}
- systemID.setTo(TRUE, canonicalID, -1);
+ systemID.setTo(true, canonicalID, -1);
return systemID;
}
-const UChar* U_EXPORT2
+const char16_t* U_EXPORT2
ZoneMeta::getCanonicalCLDRID(const TimeZone& tz) {
- if (dynamic_cast<const OlsonTimeZone *>(&tz) != NULL) {
+ if (dynamic_cast<const OlsonTimeZone *>(&tz) != nullptr) {
// short cut for OlsonTimeZone
const OlsonTimeZone *otz = (const OlsonTimeZone*)&tz;
return otz->getCanonicalID();
@@ -400,40 +392,40 @@ ZoneMeta::getCanonicalCLDRID(const TimeZone& tz) {
static void U_CALLCONV countryInfoVectorsInit(UErrorCode &status) {
// Create empty vectors
// No deleters for these UVectors, it's a reference to a resource bundle string.
- gSingleZoneCountries = new UVector(NULL, uhash_compareUChars, status);
- if (gSingleZoneCountries == NULL) {
+ gSingleZoneCountries = new UVector(nullptr, uhash_compareUChars, status);
+ if (gSingleZoneCountries == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
- gMultiZonesCountries = new UVector(NULL, uhash_compareUChars, status);
- if (gMultiZonesCountries == NULL) {
+ gMultiZonesCountries = new UVector(nullptr, uhash_compareUChars, status);
+ if (gMultiZonesCountries == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
if (U_FAILURE(status)) {
delete gSingleZoneCountries;
delete gMultiZonesCountries;
- gSingleZoneCountries = NULL;
- gMultiZonesCountries = NULL;
+ gSingleZoneCountries = nullptr;
+ gMultiZonesCountries = nullptr;
}
ucln_i18n_registerCleanup(UCLN_I18N_ZONEMETA, zoneMeta_cleanup);
}
UnicodeString& U_EXPORT2
-ZoneMeta::getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country, UBool *isPrimary /* = NULL */) {
- if (isPrimary != NULL) {
- *isPrimary = FALSE;
+ZoneMeta::getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country, UBool *isPrimary /* = nullptr */) {
+ if (isPrimary != nullptr) {
+ *isPrimary = false;
}
- const UChar *region = TimeZone::getRegion(tzid);
- if (region != NULL && u_strcmp(gWorld, region) != 0) {
+ const char16_t *region = TimeZone::getRegion(tzid);
+ if (region != nullptr && u_strcmp(gWorld, region) != 0) {
country.setTo(region, -1);
} else {
country.setToBogus();
return country;
}
- if (isPrimary != NULL) {
+ if (isPrimary != nullptr) {
char regionBuf[] = {0, 0, 0};
// Checking the cached results
@@ -444,8 +436,8 @@ ZoneMeta::getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country,
}
// Check if it was already cached
- UBool cached = FALSE;
- UBool singleZone = FALSE;
+ UBool cached = false;
+ UBool singleZone = false;
umtx_lock(&gZoneMetaLock);
{
singleZone = cached = gSingleZoneCountries->contains((void*)region);
@@ -463,11 +455,11 @@ ZoneMeta::getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country,
u_UCharsToChars(region, regionBuf, 2);
- StringEnumeration *ids = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL_LOCATION, regionBuf, NULL, status);
+ StringEnumeration *ids = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL_LOCATION, regionBuf, nullptr, status);
int32_t idsLen = ids->count(status);
if (U_SUCCESS(status) && idsLen == 1) {
// only the single zone is available for the region
- singleZone = TRUE;
+ singleZone = true;
}
delete ids;
@@ -477,11 +469,11 @@ ZoneMeta::getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country,
UErrorCode ec = U_ZERO_ERROR;
if (singleZone) {
if (!gSingleZoneCountries->contains((void*)region)) {
- gSingleZoneCountries->addElementX((void*)region, ec);
+ gSingleZoneCountries->addElement((void*)region, ec);
}
} else {
if (!gMultiZonesCountries->contains((void*)region)) {
- gMultiZonesCountries->addElementX((void*)region, ec);
+ gMultiZonesCountries->addElement((void*)region, ec);
}
}
}
@@ -489,7 +481,7 @@ ZoneMeta::getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country,
}
if (singleZone) {
- *isPrimary = TRUE;
+ *isPrimary = true;
} else {
// Note: We may cache the primary zone map in future.
@@ -500,18 +492,18 @@ ZoneMeta::getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country,
u_UCharsToChars(region, regionBuf, 2);
}
- UResourceBundle *rb = ures_openDirect(NULL, gMetaZones, &status);
+ UResourceBundle *rb = ures_openDirect(nullptr, gMetaZones, &status);
ures_getByKey(rb, gPrimaryZonesTag, rb, &status);
- const UChar *primaryZone = ures_getStringByKey(rb, regionBuf, &idLen, &status);
+ const char16_t *primaryZone = ures_getStringByKey(rb, regionBuf, &idLen, &status);
if (U_SUCCESS(status)) {
if (tzid.compare(primaryZone, idLen) == 0) {
- *isPrimary = TRUE;
+ *isPrimary = true;
} else {
// The given ID might not be a canonical ID
UnicodeString canonicalID;
TimeZone::getCanonicalID(tzid, canonicalID, status);
if (U_SUCCESS(status) && canonicalID.compare(primaryZone, idLen) == 0) {
- *isPrimary = TRUE;
+ *isPrimary = true;
}
}
}
@@ -524,14 +516,14 @@ ZoneMeta::getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country,
UnicodeString& U_EXPORT2
ZoneMeta::getMetazoneID(const UnicodeString &tzid, UDate date, UnicodeString &result) {
- UBool isSet = FALSE;
+ UBool isSet = false;
const UVector *mappings = getMetazoneMappings(tzid);
- if (mappings != NULL) {
+ if (mappings != nullptr) {
for (int32_t i = 0; i < mappings->size(); i++) {
OlsonToMetaMappingEntry *mzm = (OlsonToMetaMappingEntry*)mappings->elementAt(i);
if (mzm->from <= date && mzm->to > date) {
result.setTo(mzm->mzid, -1);
- isSet = TRUE;
+ isSet = true;
break;
}
}
@@ -543,14 +535,14 @@ ZoneMeta::getMetazoneID(const UnicodeString &tzid, UDate date, UnicodeString &re
}
static void U_CALLCONV olsonToMetaInit(UErrorCode &status) {
- U_ASSERT(gOlsonToMeta == NULL);
+ U_ASSERT(gOlsonToMeta == nullptr);
ucln_i18n_registerCleanup(UCLN_I18N_ZONEMETA, zoneMeta_cleanup);
- gOlsonToMeta = uhash_open(uhash_hashUChars, uhash_compareUChars, NULL, &status);
+ gOlsonToMeta = uhash_open(uhash_hashUChars, uhash_compareUChars, nullptr, &status);
if (U_FAILURE(status)) {
- gOlsonToMeta = NULL;
+ gOlsonToMeta = nullptr;
} else {
uhash_setKeyDeleter(gOlsonToMeta, deleteUCharString);
- uhash_setValueDeleter(gOlsonToMeta, deleteUVector);
+ uhash_setValueDeleter(gOlsonToMeta, uprv_deleteUObject);
}
}
@@ -558,19 +550,19 @@ static void U_CALLCONV olsonToMetaInit(UErrorCode &status) {
const UVector* U_EXPORT2
ZoneMeta::getMetazoneMappings(const UnicodeString &tzid) {
UErrorCode status = U_ZERO_ERROR;
- UChar tzidUChars[ZID_KEY_MAX + 1];
+ char16_t tzidUChars[ZID_KEY_MAX + 1];
tzid.extract(tzidUChars, ZID_KEY_MAX + 1, status);
if (U_FAILURE(status) || status == U_STRING_NOT_TERMINATED_WARNING) {
- return NULL;
+ return nullptr;
}
umtx_initOnce(gOlsonToMetaInitOnce, &olsonToMetaInit, status);
if (U_FAILURE(status)) {
- return NULL;
+ return nullptr;
}
// get the mapping from cache
- const UVector *result = NULL;
+ const UVector *result = nullptr;
umtx_lock(&gZoneMetaLock);
{
@@ -578,15 +570,15 @@ ZoneMeta::getMetazoneMappings(const UnicodeString &tzid) {
}
umtx_unlock(&gZoneMetaLock);
- if (result != NULL) {
+ if (result != nullptr) {
return result;
}
// miss the cache - create new one
UVector *tmpResult = createMetazoneMappings(tzid);
- if (tmpResult == NULL) {
+ if (tmpResult == nullptr) {
// not available
- return NULL;
+ return nullptr;
}
// put the new one into the cache
@@ -594,20 +586,20 @@ ZoneMeta::getMetazoneMappings(const UnicodeString &tzid) {
{
// make sure it's already created
result = (UVector*) uhash_get(gOlsonToMeta, tzidUChars);
- if (result == NULL) {
+ if (result == nullptr) {
// add the one just created
int32_t tzidLen = tzid.length() + 1;
- UChar *key = (UChar*)uprv_malloc(tzidLen * sizeof(UChar));
- if (key == NULL) {
- // memory allocation error.. just return NULL
- result = NULL;
+ char16_t *key = (char16_t*)uprv_malloc(tzidLen * sizeof(char16_t));
+ if (key == nullptr) {
+ // memory allocation error.. just return nullptr
+ result = nullptr;
delete tmpResult;
} else {
tzid.extract(key, tzidLen, status);
uhash_put(gOlsonToMeta, key, tmpResult, &status);
if (U_FAILURE(status)) {
// delete the mapping
- result = NULL;
+ result = nullptr;
delete tmpResult;
} else {
result = tmpResult;
@@ -625,11 +617,11 @@ ZoneMeta::getMetazoneMappings(const UnicodeString &tzid) {
UVector*
ZoneMeta::createMetazoneMappings(const UnicodeString &tzid) {
- UVector *mzMappings = NULL;
+ LocalPointer <UVector> mzMappings;
UErrorCode status = U_ZERO_ERROR;
UnicodeString canonicalID;
- UResourceBundle *rb = ures_openDirect(NULL, gMetaZones, &status);
+ UResourceBundle *rb = ures_openDirect(nullptr, gMetaZones, &status);
ures_getByKey(rb, gMetazoneInfo, rb, &status);
getCanonicalCLDRID(tzid, canonicalID, status);
@@ -650,17 +642,17 @@ ZoneMeta::createMetazoneMappings(const UnicodeString &tzid) {
ures_getByKey(rb, tzKey, rb, &status);
if (U_SUCCESS(status)) {
- UResourceBundle *mz = NULL;
+ UResourceBundle *mz = nullptr;
while (ures_hasNext(rb)) {
mz = ures_getNextResource(rb, mz, &status);
- const UChar *mz_name = ures_getStringByIndex(mz, 0, NULL, &status);
- const UChar *mz_from = gDefaultFrom;
- const UChar *mz_to = gDefaultTo;
+ const char16_t *mz_name = ures_getStringByIndex(mz, 0, nullptr, &status);
+ const char16_t *mz_from = gDefaultFrom;
+ const char16_t *mz_to = gDefaultTo;
if (ures_getSize(mz) == 3) {
- mz_from = ures_getStringByIndex(mz, 1, NULL, &status);
- mz_to = ures_getStringByIndex(mz, 2, NULL, &status);
+ mz_from = ures_getStringByIndex(mz, 1, nullptr, &status);
+ mz_to = ures_getStringByIndex(mz, 2, nullptr, &status);
}
if(U_FAILURE(status)){
@@ -677,47 +669,38 @@ ZoneMeta::createMetazoneMappings(const UnicodeString &tzid) {
continue;
}
- OlsonToMetaMappingEntry *entry = (OlsonToMetaMappingEntry*)uprv_malloc(sizeof(OlsonToMetaMappingEntry));
- if (entry == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
+ LocalPointer<OlsonToMetaMappingEntry> entry(new OlsonToMetaMappingEntry, status);
+ if (U_FAILURE(status)) {
break;
}
entry->mzid = mz_name;
entry->from = from;
entry->to = to;
- if (mzMappings == NULL) {
- mzMappings = new UVector(deleteOlsonToMetaMappingEntry, NULL, status);
+ if (mzMappings.isNull()) {
+ mzMappings.adoptInsteadAndCheckErrorCode(
+ new UVector(deleteOlsonToMetaMappingEntry, nullptr, status), status);
if (U_FAILURE(status)) {
- delete mzMappings;
- mzMappings = NULL;
- uprv_free(entry);
break;
}
}
- mzMappings->addElementX(entry, status);
+ mzMappings->adoptElement(entry.orphan(), status);
if (U_FAILURE(status)) {
break;
}
}
ures_close(mz);
- if (U_FAILURE(status)) {
- if (mzMappings != NULL) {
- delete mzMappings;
- mzMappings = NULL;
- }
- }
}
}
ures_close(rb);
- return mzMappings;
+ return U_SUCCESS(status) ? mzMappings.orphan() : nullptr;
}
UnicodeString& U_EXPORT2
ZoneMeta::getZoneIdByMetazone(const UnicodeString &mzid, const UnicodeString &region, UnicodeString &result) {
UErrorCode status = U_ZERO_ERROR;
- const UChar *tzid = NULL;
+ const char16_t *tzid = nullptr;
int32_t tzidLen = 0;
char keyBuf[ZID_KEY_MAX + 1];
int32_t keyLen = 0;
@@ -730,7 +713,7 @@ ZoneMeta::getZoneIdByMetazone(const UnicodeString &mzid, const UnicodeString &re
keyLen = mzid.extract(0, mzid.length(), keyBuf, ZID_KEY_MAX + 1, US_INV);
keyBuf[keyLen] = 0;
- UResourceBundle *rb = ures_openDirect(NULL, gMetaZones, &status);
+ UResourceBundle *rb = ures_openDirect(nullptr, gMetaZones, &status);
ures_getByKey(rb, gMapTimezonesTag, rb, &status);
ures_getByKey(rb, keyBuf, rb, &status);
@@ -744,14 +727,14 @@ ZoneMeta::getZoneIdByMetazone(const UnicodeString &mzid, const UnicodeString &re
status = U_ZERO_ERROR;
}
}
- if (U_SUCCESS(status) && tzid == NULL) {
+ if (U_SUCCESS(status) && tzid == nullptr) {
// try "001"
tzid = ures_getStringByKey(rb, gWorldTag, &tzidLen, &status);
}
}
ures_close(rb);
- if (tzid == NULL) {
+ if (tzid == nullptr) {
result.setToBogus();
} else {
result.setTo(tzid, tzidLen);
@@ -761,29 +744,30 @@ ZoneMeta::getZoneIdByMetazone(const UnicodeString &mzid, const UnicodeString &re
}
static void U_CALLCONV initAvailableMetaZoneIDs () {
- U_ASSERT(gMetaZoneIDs == NULL);
- U_ASSERT(gMetaZoneIDTable == NULL);
+ U_ASSERT(gMetaZoneIDs == nullptr);
+ U_ASSERT(gMetaZoneIDTable == nullptr);
ucln_i18n_registerCleanup(UCLN_I18N_ZONEMETA, zoneMeta_cleanup);
UErrorCode status = U_ZERO_ERROR;
- gMetaZoneIDTable = uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, NULL, &status);
- if (U_FAILURE(status) || gMetaZoneIDTable == NULL) {
- gMetaZoneIDTable = NULL;
+ gMetaZoneIDTable = uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, nullptr, &status);
+ if (U_FAILURE(status) || gMetaZoneIDTable == nullptr) {
+ gMetaZoneIDTable = nullptr;
return;
}
uhash_setKeyDeleter(gMetaZoneIDTable, uprv_deleteUObject);
// No valueDeleter, because the vector maintain the value objects
- gMetaZoneIDs = new UVector(NULL, uhash_compareUChars, status);
- if (U_FAILURE(status) || gMetaZoneIDs == NULL) {
- gMetaZoneIDs = NULL;
+ gMetaZoneIDs = new UVector(nullptr, uhash_compareUChars, status);
+ if (U_FAILURE(status) || gMetaZoneIDs == nullptr) {
+ delete gMetaZoneIDs;
+ gMetaZoneIDs = nullptr;
uhash_close(gMetaZoneIDTable);
- gMetaZoneIDTable = NULL;
+ gMetaZoneIDTable = nullptr;
return;
}
gMetaZoneIDs->setDeleter(uprv_free);
- UResourceBundle *rb = ures_openDirect(NULL, gMetaZones, &status);
- UResourceBundle *bundle = ures_getByKey(rb, gMapTimezonesTag, NULL, &status);
+ UResourceBundle *rb = ures_openDirect(nullptr, gMetaZones, &status);
+ UResourceBundle *bundle = ures_getByKey(rb, gMapTimezonesTag, nullptr, &status);
StackUResourceBundle res;
while (U_SUCCESS(status) && ures_hasNext(bundle)) {
ures_getNextResource(bundle, res.getAlias(), &status);
@@ -792,20 +776,22 @@ static void U_CALLCONV initAvailableMetaZoneIDs () {
}
const char *mzID = ures_getKey(res.getAlias());
int32_t len = static_cast<int32_t>(uprv_strlen(mzID));
- UChar *uMzID = (UChar*)uprv_malloc(sizeof(UChar) * (len + 1));
- if (uMzID == NULL) {
+ LocalMemory<char16_t> uMzID((char16_t*)uprv_malloc(sizeof(char16_t) * (len + 1)));
+ if (uMzID.isNull()) {
status = U_MEMORY_ALLOCATION_ERROR;
break;
}
- u_charsToUChars(mzID, uMzID, len);
+ u_charsToUChars(mzID, uMzID.getAlias(), len);
uMzID[len] = 0;
- UnicodeString *usMzID = new UnicodeString(uMzID);
- if (uhash_get(gMetaZoneIDTable, usMzID) == NULL) {
- gMetaZoneIDs->addElementX((void *)uMzID, status);
- uhash_put(gMetaZoneIDTable, (void *)usMzID, (void *)uMzID, &status);
- } else {
- uprv_free(uMzID);
- delete usMzID;
+ LocalPointer<UnicodeString> usMzID(new UnicodeString(uMzID.getAlias()), status);
+ if (U_FAILURE(status)) {
+ break;
+ }
+ if (uhash_get(gMetaZoneIDTable, usMzID.getAlias()) == nullptr) {
+ // Note: gMetaZoneIDTable adopts its keys, but not its values.
+ // gMetaZoneIDs adopts its values.
+ uhash_put(gMetaZoneIDTable, usMzID.orphan(), uMzID.getAlias(), &status);
+ gMetaZoneIDs->adoptElement(uMzID.orphan(), status);
}
}
ures_close(bundle);
@@ -814,8 +800,8 @@ static void U_CALLCONV initAvailableMetaZoneIDs () {
if (U_FAILURE(status)) {
uhash_close(gMetaZoneIDTable);
delete gMetaZoneIDs;
- gMetaZoneIDTable = NULL;
- gMetaZoneIDs = NULL;
+ gMetaZoneIDTable = nullptr;
+ gMetaZoneIDs = nullptr;
}
}
@@ -825,16 +811,16 @@ ZoneMeta::getAvailableMetazoneIDs() {
return gMetaZoneIDs;
}
-const UChar*
+const char16_t*
ZoneMeta::findMetaZoneID(const UnicodeString& mzid) {
umtx_initOnce(gMetaZoneIDsInitOnce, &initAvailableMetaZoneIDs);
- if (gMetaZoneIDTable == NULL) {
- return NULL;
+ if (gMetaZoneIDTable == nullptr) {
+ return nullptr;
}
- return (const UChar*)uhash_get(gMetaZoneIDTable, &mzid);
+ return (const char16_t*)uhash_get(gMetaZoneIDTable, &mzid);
}
-const UChar*
+const char16_t*
ZoneMeta::findTimeZoneID(const UnicodeString& tzid) {
return TimeZone::findID(tzid);
}
@@ -842,10 +828,10 @@ ZoneMeta::findTimeZoneID(const UnicodeString& tzid) {
TimeZone*
ZoneMeta::createCustomTimeZone(int32_t offset) {
- UBool negative = FALSE;
+ UBool negative = false;
int32_t tmp = offset;
if (offset < 0) {
- negative = TRUE;
+ negative = true;
tmp = -offset;
}
uint8_t hour, min, sec;
@@ -867,52 +853,52 @@ ZoneMeta::formatCustomID(uint8_t hour, uint8_t min, uint8_t sec, UBool negative,
id.setTo(gCustomTzPrefix, -1);
if (hour != 0 || min != 0) {
if (negative) {
- id.append((UChar)0x2D); // '-'
+ id.append((char16_t)0x2D); // '-'
} else {
- id.append((UChar)0x2B); // '+'
+ id.append((char16_t)0x2B); // '+'
}
// Always use US-ASCII digits
- id.append((UChar)(0x30 + (hour%100)/10));
- id.append((UChar)(0x30 + (hour%10)));
- id.append((UChar)0x3A); // ':'
- id.append((UChar)(0x30 + (min%100)/10));
- id.append((UChar)(0x30 + (min%10)));
+ id.append((char16_t)(0x30 + (hour%100)/10));
+ id.append((char16_t)(0x30 + (hour%10)));
+ id.append((char16_t)0x3A); // ':'
+ id.append((char16_t)(0x30 + (min%100)/10));
+ id.append((char16_t)(0x30 + (min%10)));
if (sec != 0) {
- id.append((UChar)0x3A); // ':'
- id.append((UChar)(0x30 + (sec%100)/10));
- id.append((UChar)(0x30 + (sec%10)));
+ id.append((char16_t)0x3A); // ':'
+ id.append((char16_t)(0x30 + (sec%100)/10));
+ id.append((char16_t)(0x30 + (sec%10)));
}
}
return id;
}
-const UChar*
+const char16_t*
ZoneMeta::getShortID(const TimeZone& tz) {
- const UChar* canonicalID = NULL;
- if (dynamic_cast<const OlsonTimeZone *>(&tz) != NULL) {
+ const char16_t* canonicalID = nullptr;
+ if (dynamic_cast<const OlsonTimeZone *>(&tz) != nullptr) {
// short cut for OlsonTimeZone
const OlsonTimeZone *otz = (const OlsonTimeZone*)&tz;
canonicalID = otz->getCanonicalID();
}
- if (canonicalID == NULL) {
- return NULL;
+ if (canonicalID == nullptr) {
+ return nullptr;
}
return getShortIDFromCanonical(canonicalID);
}
-const UChar*
+const char16_t*
ZoneMeta::getShortID(const UnicodeString& id) {
UErrorCode status = U_ZERO_ERROR;
- const UChar* canonicalID = ZoneMeta::getCanonicalCLDRID(id, status);
- if (U_FAILURE(status) || canonicalID == NULL) {
- return NULL;
+ const char16_t* canonicalID = ZoneMeta::getCanonicalCLDRID(id, status);
+ if (U_FAILURE(status) || canonicalID == nullptr) {
+ return nullptr;
}
return ZoneMeta::getShortIDFromCanonical(canonicalID);
}
-const UChar*
-ZoneMeta::getShortIDFromCanonical(const UChar* canonicalID) {
- const UChar* shortID = NULL;
+const char16_t*
+ZoneMeta::getShortIDFromCanonical(const char16_t* canonicalID) {
+ const char16_t* shortID = nullptr;
int32_t len = u_strlen(canonicalID);
char tzidKey[ZID_KEY_MAX + 1];
@@ -928,10 +914,10 @@ ZoneMeta::getShortIDFromCanonical(const UChar* canonicalID) {
}
UErrorCode status = U_ZERO_ERROR;
- UResourceBundle *rb = ures_openDirect(NULL, gKeyTypeData, &status);
+ UResourceBundle *rb = ures_openDirect(nullptr, gKeyTypeData, &status);
ures_getByKey(rb, gTypeMapTag, rb, &status);
ures_getByKey(rb, gTimezoneTag, rb, &status);
- shortID = ures_getStringByKey(rb, tzidKey, NULL, &status);
+ shortID = ures_getStringByKey(rb, tzidKey, nullptr, &status);
ures_close(rb);
return shortID;
diff --git a/contrib/libs/icu/i18n/zonemeta.h b/contrib/libs/icu/i18n/zonemeta.h
index f21399342b..8c5840c265 100644
--- a/contrib/libs/icu/i18n/zonemeta.h
+++ b/contrib/libs/icu/i18n/zonemeta.h
@@ -18,11 +18,11 @@
U_NAMESPACE_BEGIN
-typedef struct OlsonToMetaMappingEntry {
- const UChar *mzid; // const because it's a reference to a resource bundle string.
+struct OlsonToMetaMappingEntry : public UMemory {
+ const char16_t *mzid; // const because it's a reference to a resource bundle string.
UDate from;
UDate to;
-} OlsonToMetaMappingEntry;
+};
class UVector;
class TimeZone;
@@ -40,19 +40,19 @@ public:
/**
* Return the canonical id for this tzid defined by CLDR, which might be the id itself.
- * This overload method returns a persistent const UChar*, which is guaranteed to persist
+ * This overload method returns a persistent const char16_t*, which is guaranteed to persist
* (a pointer to a resource). If the given system tzid is not known, U_ILLEGAL_ARGUMENT_ERROR
* is set in the status.
* @param tzid Zone ID
* @param status Receives the status
* @return The canonical ID for the input time zone ID
*/
- static const UChar* U_EXPORT2 getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status);
+ static const char16_t* U_EXPORT2 getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status);
/*
* Convenient method returning CLDR canonical ID for the given time zone
*/
- static const UChar* U_EXPORT2 getCanonicalCLDRID(const TimeZone& tz);
+ static const char16_t* U_EXPORT2 getCanonicalCLDRID(const TimeZone& tz);
/**
* Return the canonical country code for this tzid. If we have none, or if the time zone
@@ -62,7 +62,7 @@ public:
* @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);
+ static UnicodeString& U_EXPORT2 getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country, UBool *isPrimary = nullptr);
/**
* Returns a CLDR metazone ID for the given Olson tzid and time.
@@ -78,16 +78,16 @@ public:
static const UVector* U_EXPORT2 getAvailableMetazoneIDs();
/**
- * Returns the pointer to the persistent time zone ID string, or NULL if the given tzid is not in the
+ * Returns the pointer to the persistent time zone ID string, or nullptr if the given tzid is not in the
* tz database. This method is useful when you maintain persistent zone IDs without duplication.
*/
- static const UChar* U_EXPORT2 findTimeZoneID(const UnicodeString& tzid);
+ static const char16_t* U_EXPORT2 findTimeZoneID(const UnicodeString& tzid);
/**
- * Returns the pointer to the persistent meta zone ID string, or NULL if the given mzid is not available.
+ * Returns the pointer to the persistent meta zone ID string, or nullptr if the given mzid is not available.
* This method is useful when you maintain persistent meta zone IDs without duplication.
*/
- static const UChar* U_EXPORT2 findMetaZoneID(const UnicodeString& mzid);
+ static const char16_t* U_EXPORT2 findMetaZoneID(const UnicodeString& mzid);
/**
* Creates a custom zone for the offset
@@ -102,7 +102,7 @@ public:
* @param tz the time zone
* @return the short ID of the time zone, or null if the short ID is not available.
*/
- static const UChar* U_EXPORT2 getShortID(const TimeZone& tz);
+ static const char16_t* U_EXPORT2 getShortID(const TimeZone& tz);
/**
* Returns the time zone's short ID (null terminated) for the zone ID.
@@ -110,13 +110,13 @@ public:
* @param tz the time zone ID
* @return the short ID of the time zone ID, or null if the short ID is not available.
*/
- static const UChar* U_EXPORT2 getShortID(const UnicodeString& id);
+ static const char16_t* U_EXPORT2 getShortID(const UnicodeString& id);
private:
- ZoneMeta(); // Prevent construction.
+ ZoneMeta() = delete; // Prevent construction.
static UVector* createMetazoneMappings(const UnicodeString &tzid);
static UnicodeString& formatCustomID(uint8_t hour, uint8_t min, uint8_t sec, UBool negative, UnicodeString& id);
- static const UChar* getShortIDFromCanonical(const UChar* canonicalID);
+ static const char16_t* getShortIDFromCanonical(const char16_t* canonicalID);
};
U_NAMESPACE_END
diff --git a/contrib/libs/icu/i18n/zrule.cpp b/contrib/libs/icu/i18n/zrule.cpp
index bdf84965b5..1ba0c9705e 100644
--- a/contrib/libs/icu/i18n/zrule.cpp
+++ b/contrib/libs/icu/i18n/zrule.cpp
@@ -40,7 +40,7 @@ zrule_equals(const ZRule* rule1, const ZRule* rule2) {
}
U_CAPI void U_EXPORT2
-zrule_getName(ZRule* rule, UChar* name, int32_t nameLength) {
+zrule_getName(ZRule* rule, char16_t* name, int32_t nameLength) {
UnicodeString s(nameLength==-1, name, nameLength);
s = ((TimeZoneRule*)rule)->TimeZoneRule::getName(s);
nameLength = s.length();
@@ -68,7 +68,7 @@ zrule_isEquivalentTo(ZRule* rule1, ZRule* rule2) {
*********************************************************************/
U_CAPI IZRule* U_EXPORT2
-izrule_open(const UChar* name, int32_t nameLength, int32_t rawOffset, int32_t dstSavings) {
+izrule_open(const char16_t* name, int32_t nameLength, int32_t rawOffset, int32_t dstSavings) {
UnicodeString s(nameLength==-1, name, nameLength);
return (IZRule*) new InitialTimeZoneRule(s, rawOffset, dstSavings);
}
@@ -89,12 +89,12 @@ izrule_equals(const IZRule* rule1, const IZRule* rule2) {
}
U_CAPI void U_EXPORT2
-izrule_getName(IZRule* rule, UChar* & name, int32_t & nameLength) {
+izrule_getName(IZRule* rule, char16_t* & name, int32_t & nameLength) {
// UnicodeString s(nameLength==-1, name, nameLength);
UnicodeString s;
((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getName(s);
nameLength = s.length();
- name = (UChar*)uprv_malloc(nameLength);
+ name = (char16_t*)uprv_malloc(nameLength);
memcpy(name, s.getBuffer(), nameLength);
return;
}
diff --git a/contrib/libs/icu/i18n/zrule.h b/contrib/libs/icu/i18n/zrule.h
index f395ad4c3f..2bea64c6d4 100644
--- a/contrib/libs/icu/i18n/zrule.h
+++ b/contrib/libs/icu/i18n/zrule.h
@@ -20,8 +20,6 @@
#include "unicode/uobject.h"
-#ifndef UCNV_H
-
/**
* A TimeZoneRule. Use the zrule_* API to manipulate. Create with
* zrule_open*, and destroy with zrule_close.
@@ -43,8 +41,6 @@ typedef struct IZRule IZRule;
struct AZRule;
typedef struct AZRule AZRule;
-#endif
-
/*********************************************************************
* ZRule API
*********************************************************************/
diff --git a/contrib/libs/icu/i18n/ztrans.h b/contrib/libs/icu/i18n/ztrans.h
index b23bb4fc70..a1f3910055 100644
--- a/contrib/libs/icu/i18n/ztrans.h
+++ b/contrib/libs/icu/i18n/ztrans.h
@@ -20,8 +20,6 @@
#include "unicode/uobject.h"
-#ifndef UCNV_H
-
/**
* A TimeZoneTransition. Use the ztrans_* API to manipulate. Create with
* ztrans_open*, and destroy with ztrans_close.
@@ -29,8 +27,6 @@
struct ZTrans;
typedef struct ZTrans ZTrans;
-#endif
-
/**
* Constructs a time zone transition with the time and the rules before/after
* the transition.