mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1299615 - Part 3: Update in-tree ICU to release 58.1. rs=Waldo
This commit is contained in:
parent
fb59f826a3
commit
a934a3b70d
15
config/external/icu/common/sources.mozbuild
vendored
15
config/external/icu/common/sources.mozbuild
vendored
@ -12,6 +12,7 @@ SOURCES += [
|
||||
'/intl/icu/source/common/chariter.cpp',
|
||||
'/intl/icu/source/common/charstr.cpp',
|
||||
'/intl/icu/source/common/cmemory.c',
|
||||
'/intl/icu/source/common/cstr.cpp',
|
||||
'/intl/icu/source/common/cstring.c',
|
||||
'/intl/icu/source/common/cwchar.c',
|
||||
'/intl/icu/source/common/dictbe.cpp',
|
||||
@ -27,6 +28,7 @@ SOURCES += [
|
||||
'/intl/icu/source/common/locavailable.cpp',
|
||||
'/intl/icu/source/common/locbased.cpp',
|
||||
'/intl/icu/source/common/locdispnames.cpp',
|
||||
'/intl/icu/source/common/locdspnm.cpp',
|
||||
'/intl/icu/source/common/locid.cpp',
|
||||
'/intl/icu/source/common/loclikely.cpp',
|
||||
'/intl/icu/source/common/locmap.c',
|
||||
@ -53,6 +55,7 @@ SOURCES += [
|
||||
'/intl/icu/source/common/rbbitblb.cpp',
|
||||
'/intl/icu/source/common/resbund.cpp',
|
||||
'/intl/icu/source/common/resbund_cnv.cpp',
|
||||
'/intl/icu/source/common/resource.cpp',
|
||||
'/intl/icu/source/common/ruleiter.cpp',
|
||||
'/intl/icu/source/common/schriter.cpp',
|
||||
'/intl/icu/source/common/serv.cpp',
|
||||
@ -63,13 +66,14 @@ SOURCES += [
|
||||
'/intl/icu/source/common/servrbf.cpp',
|
||||
'/intl/icu/source/common/servslkf.cpp',
|
||||
'/intl/icu/source/common/sharedobject.cpp',
|
||||
'/intl/icu/source/common/simplepatternformatter.cpp',
|
||||
'/intl/icu/source/common/simpleformatter.cpp',
|
||||
'/intl/icu/source/common/stringpiece.cpp',
|
||||
'/intl/icu/source/common/stringtriebuilder.cpp',
|
||||
'/intl/icu/source/common/uarrsort.c',
|
||||
'/intl/icu/source/common/ubidi.c',
|
||||
'/intl/icu/source/common/ubidi_props.c',
|
||||
'/intl/icu/source/common/ubidiln.c',
|
||||
'/intl/icu/source/common/ubiditransform.c',
|
||||
'/intl/icu/source/common/ubidiwrt.c',
|
||||
'/intl/icu/source/common/ubrk.cpp',
|
||||
'/intl/icu/source/common/ucase.cpp',
|
||||
@ -107,6 +111,7 @@ SOURCES += [
|
||||
'/intl/icu/source/common/ucnvscsu.c',
|
||||
'/intl/icu/source/common/ucnvsel.cpp',
|
||||
'/intl/icu/source/common/ucol_swp.cpp',
|
||||
'/intl/icu/source/common/ucurr.cpp',
|
||||
'/intl/icu/source/common/udata.cpp',
|
||||
'/intl/icu/source/common/udatamem.c',
|
||||
'/intl/icu/source/common/udataswp.c',
|
||||
@ -145,7 +150,7 @@ SOURCES += [
|
||||
'/intl/icu/source/common/uprops.cpp',
|
||||
'/intl/icu/source/common/ures_cnv.c',
|
||||
'/intl/icu/source/common/uresbund.cpp',
|
||||
'/intl/icu/source/common/uresdata.c',
|
||||
'/intl/icu/source/common/uresdata.cpp',
|
||||
'/intl/icu/source/common/usc_impl.c',
|
||||
'/intl/icu/source/common/uscript.c',
|
||||
'/intl/icu/source/common/uscript_props.cpp',
|
||||
@ -199,6 +204,7 @@ EXPORTS.unicode += [
|
||||
'/intl/icu/source/common/unicode/idna.h',
|
||||
'/intl/icu/source/common/unicode/listformatter.h',
|
||||
'/intl/icu/source/common/unicode/localpointer.h',
|
||||
'/intl/icu/source/common/unicode/locdspnm.h',
|
||||
'/intl/icu/source/common/unicode/locid.h',
|
||||
'/intl/icu/source/common/unicode/messagepattern.h',
|
||||
'/intl/icu/source/common/unicode/normalizer2.h',
|
||||
@ -212,12 +218,14 @@ EXPORTS.unicode += [
|
||||
'/intl/icu/source/common/unicode/rep.h',
|
||||
'/intl/icu/source/common/unicode/resbund.h',
|
||||
'/intl/icu/source/common/unicode/schriter.h',
|
||||
'/intl/icu/source/common/unicode/simpleformatter.h',
|
||||
'/intl/icu/source/common/unicode/std_string.h',
|
||||
'/intl/icu/source/common/unicode/strenum.h',
|
||||
'/intl/icu/source/common/unicode/stringpiece.h',
|
||||
'/intl/icu/source/common/unicode/stringtriebuilder.h',
|
||||
'/intl/icu/source/common/unicode/symtable.h',
|
||||
'/intl/icu/source/common/unicode/ubidi.h',
|
||||
'/intl/icu/source/common/unicode/ubiditransform.h',
|
||||
'/intl/icu/source/common/unicode/ubrk.h',
|
||||
'/intl/icu/source/common/unicode/ucasemap.h',
|
||||
'/intl/icu/source/common/unicode/ucat.h',
|
||||
@ -231,10 +239,13 @@ EXPORTS.unicode += [
|
||||
'/intl/icu/source/common/unicode/ucnv_err.h',
|
||||
'/intl/icu/source/common/unicode/ucnvsel.h',
|
||||
'/intl/icu/source/common/unicode/uconfig.h',
|
||||
'/intl/icu/source/common/unicode/ucurr.h',
|
||||
'/intl/icu/source/common/unicode/udata.h',
|
||||
'/intl/icu/source/common/unicode/udisplaycontext.h',
|
||||
'/intl/icu/source/common/unicode/uenum.h',
|
||||
'/intl/icu/source/common/unicode/uidna.h',
|
||||
'/intl/icu/source/common/unicode/uiter.h',
|
||||
'/intl/icu/source/common/unicode/uldnames.h',
|
||||
'/intl/icu/source/common/unicode/ulistformatter.h',
|
||||
'/intl/icu/source/common/unicode/uloc.h',
|
||||
'/intl/icu/source/common/unicode/umachine.h',
|
||||
|
Binary file not shown.
11
config/external/icu/i18n/sources.mozbuild
vendored
11
config/external/icu/i18n/sources.mozbuild
vendored
@ -51,6 +51,7 @@ SOURCES += [
|
||||
'/intl/icu/source/i18n/currunit.cpp',
|
||||
'/intl/icu/source/i18n/dangical.cpp',
|
||||
'/intl/icu/source/i18n/datefmt.cpp',
|
||||
'/intl/icu/source/i18n/dayperiodrules.cpp',
|
||||
'/intl/icu/source/i18n/dcfmtsym.cpp',
|
||||
'/intl/icu/source/i18n/decContext.c',
|
||||
'/intl/icu/source/i18n/decfmtst.cpp',
|
||||
@ -81,12 +82,10 @@ SOURCES += [
|
||||
'/intl/icu/source/i18n/gregocal.cpp',
|
||||
'/intl/icu/source/i18n/gregoimp.cpp',
|
||||
'/intl/icu/source/i18n/hebrwcal.cpp',
|
||||
'/intl/icu/source/i18n/identifier_info.cpp',
|
||||
'/intl/icu/source/i18n/indiancal.cpp',
|
||||
'/intl/icu/source/i18n/inputext.cpp',
|
||||
'/intl/icu/source/i18n/islamcal.cpp',
|
||||
'/intl/icu/source/i18n/japancal.cpp',
|
||||
'/intl/icu/source/i18n/locdspnm.cpp',
|
||||
'/intl/icu/source/i18n/measfmt.cpp',
|
||||
'/intl/icu/source/i18n/measunit.cpp',
|
||||
'/intl/icu/source/i18n/measure.cpp',
|
||||
@ -135,6 +134,7 @@ SOURCES += [
|
||||
'/intl/icu/source/i18n/smpdtfmt.cpp',
|
||||
'/intl/icu/source/i18n/smpdtfst.cpp',
|
||||
'/intl/icu/source/i18n/sortkey.cpp',
|
||||
'/intl/icu/source/i18n/standardplural.cpp',
|
||||
'/intl/icu/source/i18n/strmatch.cpp',
|
||||
'/intl/icu/source/i18n/strrepl.cpp',
|
||||
'/intl/icu/source/i18n/stsearch.cpp',
|
||||
@ -162,7 +162,6 @@ SOURCES += [
|
||||
'/intl/icu/source/i18n/ucol_sit.cpp',
|
||||
'/intl/icu/source/i18n/ucoleitr.cpp',
|
||||
'/intl/icu/source/i18n/ucsdet.cpp',
|
||||
'/intl/icu/source/i18n/ucurr.cpp',
|
||||
'/intl/icu/source/i18n/udat.cpp',
|
||||
'/intl/icu/source/i18n/udateintervalformat.cpp',
|
||||
'/intl/icu/source/i18n/udatpg.cpp',
|
||||
@ -183,7 +182,6 @@ SOURCES += [
|
||||
'/intl/icu/source/i18n/uspoof_build.cpp',
|
||||
'/intl/icu/source/i18n/uspoof_conf.cpp',
|
||||
'/intl/icu/source/i18n/uspoof_impl.cpp',
|
||||
'/intl/icu/source/i18n/uspoof_wsconf.cpp',
|
||||
'/intl/icu/source/i18n/utf16collationiterator.cpp',
|
||||
'/intl/icu/source/i18n/utf8collationiterator.cpp',
|
||||
'/intl/icu/source/i18n/utmscale.c',
|
||||
@ -225,7 +223,6 @@ EXPORTS.unicode += [
|
||||
'/intl/icu/source/i18n/unicode/fpositer.h',
|
||||
'/intl/icu/source/i18n/unicode/gender.h',
|
||||
'/intl/icu/source/i18n/unicode/gregocal.h',
|
||||
'/intl/icu/source/i18n/unicode/locdspnm.h',
|
||||
'/intl/icu/source/i18n/unicode/measfmt.h',
|
||||
'/intl/icu/source/i18n/unicode/measunit.h',
|
||||
'/intl/icu/source/i18n/unicode/measure.h',
|
||||
@ -260,15 +257,12 @@ EXPORTS.unicode += [
|
||||
'/intl/icu/source/i18n/unicode/ucol.h',
|
||||
'/intl/icu/source/i18n/unicode/ucoleitr.h',
|
||||
'/intl/icu/source/i18n/unicode/ucsdet.h',
|
||||
'/intl/icu/source/i18n/unicode/ucurr.h',
|
||||
'/intl/icu/source/i18n/unicode/udat.h',
|
||||
'/intl/icu/source/i18n/unicode/udateintervalformat.h',
|
||||
'/intl/icu/source/i18n/unicode/udatpg.h',
|
||||
'/intl/icu/source/i18n/unicode/udisplaycontext.h',
|
||||
'/intl/icu/source/i18n/unicode/ufieldpositer.h',
|
||||
'/intl/icu/source/i18n/unicode/uformattable.h',
|
||||
'/intl/icu/source/i18n/unicode/ugender.h',
|
||||
'/intl/icu/source/i18n/unicode/uldnames.h',
|
||||
'/intl/icu/source/i18n/unicode/ulocdata.h',
|
||||
'/intl/icu/source/i18n/unicode/umsg.h',
|
||||
'/intl/icu/source/i18n/unicode/unirepl.h',
|
||||
@ -277,6 +271,7 @@ EXPORTS.unicode += [
|
||||
'/intl/icu/source/i18n/unicode/upluralrules.h',
|
||||
'/intl/icu/source/i18n/unicode/uregex.h',
|
||||
'/intl/icu/source/i18n/unicode/uregion.h',
|
||||
'/intl/icu/source/i18n/unicode/ureldatefmt.h',
|
||||
'/intl/icu/source/i18n/unicode/usearch.h',
|
||||
'/intl/icu/source/i18n/unicode/uspoof.h',
|
||||
'/intl/icu/source/i18n/unicode/utmscale.h',
|
||||
|
@ -1,9 +1,10 @@
|
||||
Path: release-56-1
|
||||
URL: http://source.icu-project.org/repos/icu/icu/tags/release-56-1
|
||||
Repository Root: http://source.icu-project.org/repos/icu
|
||||
Path: release-58-1
|
||||
URL: https://ssl.icu-project.org/repos/icu/icu/tags/release-58-1
|
||||
Relative URL: ^/icu/tags/release-58-1
|
||||
Repository Root: https://ssl.icu-project.org/repos/icu
|
||||
Repository UUID: 251d0590-4201-4cf1-90de-194747b24ca1
|
||||
Node Kind: directory
|
||||
Last Changed Author: mow
|
||||
Last Changed Rev: 38044
|
||||
Last Changed Date: 2015-10-07 22:20:20 +0000 (Wed, 07 Oct 2015)
|
||||
Last Changed Author: srl
|
||||
Last Changed Rev: 39472
|
||||
Last Changed Date: 2016-10-19 20:35:30 +0000 (Wed, 19 Oct 2016)
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
# Doxyfile 1.3.7
|
||||
# Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
# License & terms of use: http://www.unicode.org/copyright.html
|
||||
# ********************************************************************
|
||||
# * COPYRIGHT:
|
||||
# * Copyright (c) 2004-2015, International Business Machines Corporation
|
||||
|
@ -1,6 +1,8 @@
|
||||
# Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
# License & terms of use: http://www.unicode.org/copyright.html
|
||||
#******************************************************************************
|
||||
#
|
||||
# Copyright (C) 1998-2015, International Business Machines
|
||||
# Copyright (C) 1998-2016, International Business Machines
|
||||
# Corporation and others. All Rights Reserved.
|
||||
#
|
||||
#******************************************************************************
|
||||
@ -29,7 +31,6 @@ subdir = .
|
||||
#AUTOCONF = @AUTOCONF@
|
||||
|
||||
## Optional directory setup
|
||||
@LAYOUT_TRUE@LAYOUT = layout
|
||||
@LAYOUTEX_TRUE@LAYOUTEX = layoutex
|
||||
@ICUIO_TRUE@ICUIO = io
|
||||
@EXTRAS_TRUE@EXTRA = extra
|
||||
@ -39,7 +40,6 @@ subdir = .
|
||||
|
||||
## pkgconfig setup. Always have uc and i18n. Others are optional.
|
||||
ALL_PKGCONFIG_SUFFIX=uc i18n
|
||||
@LAYOUT_TRUE@ALL_PKGCONFIG_SUFFIX+= le
|
||||
@LAYOUTEX_TRUE@ALL_PKGCONFIG_SUFFIX+= lx
|
||||
@ICUIO_TRUE@ALL_PKGCONFIG_SUFFIX+= io
|
||||
|
||||
@ -58,7 +58,7 @@ INSTALLED_BUILT_FILES = $(top_builddir)/config/Makefile.inc $(top_builddir)/conf
|
||||
LOCAL_BUILT_FILES = icudefs.mk config/icucross.mk config/icucross.inc
|
||||
|
||||
DOCDIRS = common i18n
|
||||
SUBDIRS = stubdata common i18n $(LAYOUT) $(LAYOUTEX) $(ICUIO) $(TOOLS) data $(EXTRA) $(SAMPLE) $(TEST)
|
||||
SUBDIRS = stubdata common i18n $(LAYOUTEX) $(ICUIO) $(TOOLS) data $(EXTRA) $(SAMPLE) $(TEST)
|
||||
|
||||
SECTION = 1
|
||||
|
||||
@ -113,13 +113,13 @@ doc doc-searchengine:
|
||||
else
|
||||
doc: doc/html/index.html
|
||||
|
||||
doc-searchengine: Doxyfile $(wildcard ./common/unicode/platform.h $(srcdir)/common/unicode/*.h $(srcdir)/i18n/unicode/*.h $(srcdir)/layout/unicode/*.h $(srcdir)/io/unicode/*.h)
|
||||
doc-searchengine: Doxyfile $(wildcard ./common/unicode/platform.h $(srcdir)/common/unicode/*.h $(srcdir)/i18n/unicode/*.h $(srcdir)/io/unicode/*.h)
|
||||
sed < Doxyfile -e 's%[^#]*SEARCHENGINE.*%SEARCHENGINE=YES%' | $(DOXYGEN) -
|
||||
@echo adding links from non-namespaced class files
|
||||
find doc/html -name 'classicu_1_1*' -print | sed -e 's%^\(.*class\)icu_1_1\(.*\)$$%ln & \1\2%' | sh
|
||||
@echo Docs created - WARNING, probably contains non-GPL .js files
|
||||
|
||||
doc/html/index.html: Doxyfile $(wildcard ./common/unicode/platform.h $(srcdir)/common/unicode/*.h $(srcdir)/i18n/unicode/*.h $(srcdir)/layout/unicode/*.h $(srcdir)/io/unicode/*.h)
|
||||
doc/html/index.html: Doxyfile $(wildcard ./common/unicode/platform.h $(srcdir)/common/unicode/*.h $(srcdir)/i18n/unicode/*.h $(srcdir)/io/unicode/*.h)
|
||||
$(DOXYGEN)
|
||||
@echo adding links from non-namespaced class files
|
||||
find doc/html -name 'classicu_1_1*' -print | sed -e 's%^\(.*class\)icu_1_1\(.*\)$$%ln & \1\2%' | sh
|
||||
@ -184,7 +184,7 @@ install-icu: $(INSTALLED_BUILT_FILES)
|
||||
$(INSTALL_SCRIPT) $(top_srcdir)/install-sh $(DESTDIR)$(pkgdatadir)/install-sh
|
||||
@$(MKINSTALLDIRS) $(DESTDIR)$(libdir)/pkgconfig
|
||||
$(INSTALL_DATA) $(ALL_PKGCONFIG_FILES) $(DESTDIR)$(libdir)/pkgconfig/
|
||||
$(INSTALL_DATA) $(top_srcdir)/../license.html $(DESTDIR)$(pkgdatadir)/license.html
|
||||
$(INSTALL_DATA) $(top_srcdir)/../LICENSE $(DESTDIR)$(pkgdatadir)/LICENSE
|
||||
$(INSTALL_SCRIPT) $(top_builddir)/config/icu-config $(DESTDIR)$(bindir)/icu-config
|
||||
$(INSTALL_DATA) $(top_builddir)/config/Makefile.inc $(DESTDIR)$(pkglibdir)/Makefile.inc
|
||||
$(INSTALL_DATA) $(top_builddir)/config/pkgdata.inc $(DESTDIR)$(pkglibdir)/pkgdata.inc
|
||||
@ -287,14 +287,6 @@ config/icu-io.pc: config/icu.pc Makefile icudefs.mk
|
||||
@echo "Libs:" "${ICULIBS_IO}" >> $@
|
||||
@echo $@ updated.
|
||||
|
||||
config/icu-le.pc: config/icu.pc Makefile icudefs.mk
|
||||
@cat config/icu.pc > $@
|
||||
@echo "Description: $(PACKAGE_ICU_DESCRIPTION): Layout library" >> $@
|
||||
@echo "Name: $(PACKAGE)-le" >> $@
|
||||
@echo "Requires: icu-uc" >> $@
|
||||
@echo "Libs:" "${ICULIBS_LE}" >> $@
|
||||
@echo $@ updated.
|
||||
|
||||
ICULEHB_LIBS=@ICULEHB_LIBS@
|
||||
USING_HB=
|
||||
ifneq ($(ICULEHB_LIBS),)
|
||||
|
@ -1,4 +1,6 @@
|
||||
# Copyright (c) 1999-2015, International Business Machines Corporation and
|
||||
# Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
# License & terms of use: http://www.unicode.org/copyright.html
|
||||
# Copyright (c) 1999-2016, International Business Machines Corporation and
|
||||
# others. All Rights Reserved.
|
||||
# acinclude.m4 for ICU
|
||||
# Don't edit aclocal.m4, do edit acinclude.m4
|
||||
@ -461,6 +463,9 @@ AC_DEFUN([AC_CHECK_STRICT_COMPILE],
|
||||
if test "$GCC" = yes
|
||||
then
|
||||
case "${host}" in
|
||||
*-*-solaris*)
|
||||
# Don't use -std=c99 on Solaris because of timezone check fails
|
||||
;;
|
||||
*)
|
||||
# Do not use -ansi. It limits us to C90, and it breaks some platforms.
|
||||
# We use -std=c99 to disable the gnu99 defaults and its associated warnings
|
||||
|
209
intl/icu/source/aclocal.m4
vendored
209
intl/icu/source/aclocal.m4
vendored
@ -12,32 +12,63 @@
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
|
||||
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
||||
# serial 1 (pkg-config-0.24)
|
||||
#
|
||||
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
||||
dnl serial 11 (pkg-config-0.29.1)
|
||||
dnl
|
||||
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
|
||||
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
|
||||
dnl
|
||||
dnl This program is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 2 of the License, or
|
||||
dnl (at your option) any later version.
|
||||
dnl
|
||||
dnl This program is distributed in the hope that it will be useful, but
|
||||
dnl WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
dnl General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with this program; if not, write to the Free Software
|
||||
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
dnl 02111-1307, USA.
|
||||
dnl
|
||||
dnl As a special exception to the GNU General Public License, if you
|
||||
dnl distribute this file as part of a program that contains a
|
||||
dnl configuration script generated by Autoconf, you may include it under
|
||||
dnl the same distribution terms that you use for the rest of that
|
||||
dnl program.
|
||||
|
||||
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
|
||||
# ----------------------------------
|
||||
dnl PKG_PREREQ(MIN-VERSION)
|
||||
dnl -----------------------
|
||||
dnl Since: 0.29
|
||||
dnl
|
||||
dnl Verify that the version of the pkg-config macros are at least
|
||||
dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
|
||||
dnl installed version of pkg-config, this checks the developer's version
|
||||
dnl of pkg.m4 when generating configure.
|
||||
dnl
|
||||
dnl To ensure that this macro is defined, also add:
|
||||
dnl m4_ifndef([PKG_PREREQ],
|
||||
dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
|
||||
dnl
|
||||
dnl See the "Since" comment for each macro you use to see what version
|
||||
dnl of the macros you require.
|
||||
m4_defun([PKG_PREREQ],
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29.1])
|
||||
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
|
||||
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
|
||||
])dnl PKG_PREREQ
|
||||
|
||||
dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
|
||||
dnl ----------------------------------
|
||||
dnl Since: 0.16
|
||||
dnl
|
||||
dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
|
||||
dnl first found in the path. Checks that the version of pkg-config found
|
||||
dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
|
||||
dnl used since that's the first version where most current features of
|
||||
dnl pkg-config existed.
|
||||
AC_DEFUN([PKG_PROG_PKG_CONFIG],
|
||||
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
|
||||
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
|
||||
@ -59,18 +90,19 @@ if test -n "$PKG_CONFIG"; then
|
||||
PKG_CONFIG=""
|
||||
fi
|
||||
fi[]dnl
|
||||
])# PKG_PROG_PKG_CONFIG
|
||||
])dnl PKG_PROG_PKG_CONFIG
|
||||
|
||||
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
||||
#
|
||||
# Check to see whether a particular set of modules exists. Similar
|
||||
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
|
||||
#
|
||||
# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
|
||||
# only at the first occurence in configure.ac, so if the first place
|
||||
# it's called might be skipped (such as if it is within an "if", you
|
||||
# have to call PKG_CHECK_EXISTS manually
|
||||
# --------------------------------------------------------------
|
||||
dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
||||
dnl -------------------------------------------------------------------
|
||||
dnl Since: 0.18
|
||||
dnl
|
||||
dnl Check to see whether a particular set of modules exists. Similar to
|
||||
dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
|
||||
dnl
|
||||
dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
|
||||
dnl only at the first occurence in configure.ac, so if the first place
|
||||
dnl it's called might be skipped (such as if it is within an "if", you
|
||||
dnl have to call PKG_CHECK_EXISTS manually
|
||||
AC_DEFUN([PKG_CHECK_EXISTS],
|
||||
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
@ -80,8 +112,10 @@ m4_ifvaln([$3], [else
|
||||
$3])dnl
|
||||
fi])
|
||||
|
||||
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
|
||||
# ---------------------------------------------
|
||||
dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
|
||||
dnl ---------------------------------------------
|
||||
dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
|
||||
dnl pkg_failed based on the result.
|
||||
m4_define([_PKG_CONFIG],
|
||||
[if test -n "$$1"; then
|
||||
pkg_cv_[]$1="$$1"
|
||||
@ -93,10 +127,11 @@ m4_define([_PKG_CONFIG],
|
||||
else
|
||||
pkg_failed=untried
|
||||
fi[]dnl
|
||||
])# _PKG_CONFIG
|
||||
])dnl _PKG_CONFIG
|
||||
|
||||
# _PKG_SHORT_ERRORS_SUPPORTED
|
||||
# -----------------------------
|
||||
dnl _PKG_SHORT_ERRORS_SUPPORTED
|
||||
dnl ---------------------------
|
||||
dnl Internal check to see if pkg-config supports short errors.
|
||||
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
|
||||
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
|
||||
@ -104,19 +139,17 @@ if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
|
||||
else
|
||||
_pkg_short_errors_supported=no
|
||||
fi[]dnl
|
||||
])# _PKG_SHORT_ERRORS_SUPPORTED
|
||||
])dnl _PKG_SHORT_ERRORS_SUPPORTED
|
||||
|
||||
|
||||
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
|
||||
# [ACTION-IF-NOT-FOUND])
|
||||
#
|
||||
#
|
||||
# Note that if there is a possibility the first call to
|
||||
# PKG_CHECK_MODULES might not happen, you should be sure to include an
|
||||
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
|
||||
#
|
||||
#
|
||||
# --------------------------------------------------------------
|
||||
dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
|
||||
dnl [ACTION-IF-NOT-FOUND])
|
||||
dnl --------------------------------------------------------------
|
||||
dnl Since: 0.4.0
|
||||
dnl
|
||||
dnl Note that if there is a possibility the first call to
|
||||
dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
|
||||
dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
|
||||
AC_DEFUN([PKG_CHECK_MODULES],
|
||||
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
|
||||
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
|
||||
@ -170,16 +203,40 @@ else
|
||||
AC_MSG_RESULT([yes])
|
||||
$3
|
||||
fi[]dnl
|
||||
])# PKG_CHECK_MODULES
|
||||
])dnl PKG_CHECK_MODULES
|
||||
|
||||
|
||||
# PKG_INSTALLDIR(DIRECTORY)
|
||||
# -------------------------
|
||||
# Substitutes the variable pkgconfigdir as the location where a module
|
||||
# should install pkg-config .pc files. By default the directory is
|
||||
# $libdir/pkgconfig, but the default can be changed by passing
|
||||
# DIRECTORY. The user can override through the --with-pkgconfigdir
|
||||
# parameter.
|
||||
dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
|
||||
dnl [ACTION-IF-NOT-FOUND])
|
||||
dnl ---------------------------------------------------------------------
|
||||
dnl Since: 0.29
|
||||
dnl
|
||||
dnl Checks for existence of MODULES and gathers its build flags with
|
||||
dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
|
||||
dnl and VARIABLE-PREFIX_LIBS from --libs.
|
||||
dnl
|
||||
dnl Note that if there is a possibility the first call to
|
||||
dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
|
||||
dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
|
||||
dnl configure.ac.
|
||||
AC_DEFUN([PKG_CHECK_MODULES_STATIC],
|
||||
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
|
||||
_save_PKG_CONFIG=$PKG_CONFIG
|
||||
PKG_CONFIG="$PKG_CONFIG --static"
|
||||
PKG_CHECK_MODULES($@)
|
||||
PKG_CONFIG=$_save_PKG_CONFIG[]dnl
|
||||
])dnl PKG_CHECK_MODULES_STATIC
|
||||
|
||||
|
||||
dnl PKG_INSTALLDIR([DIRECTORY])
|
||||
dnl -------------------------
|
||||
dnl Since: 0.27
|
||||
dnl
|
||||
dnl Substitutes the variable pkgconfigdir as the location where a module
|
||||
dnl should install pkg-config .pc files. By default the directory is
|
||||
dnl $libdir/pkgconfig, but the default can be changed by passing
|
||||
dnl DIRECTORY. The user can override through the --with-pkgconfigdir
|
||||
dnl parameter.
|
||||
AC_DEFUN([PKG_INSTALLDIR],
|
||||
[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
|
||||
m4_pushdef([pkg_description],
|
||||
@ -190,16 +247,18 @@ AC_ARG_WITH([pkgconfigdir],
|
||||
AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
|
||||
m4_popdef([pkg_default])
|
||||
m4_popdef([pkg_description])
|
||||
]) dnl PKG_INSTALLDIR
|
||||
])dnl PKG_INSTALLDIR
|
||||
|
||||
|
||||
# PKG_NOARCH_INSTALLDIR(DIRECTORY)
|
||||
# -------------------------
|
||||
# Substitutes the variable noarch_pkgconfigdir as the location where a
|
||||
# module should install arch-independent pkg-config .pc files. By
|
||||
# default the directory is $datadir/pkgconfig, but the default can be
|
||||
# changed by passing DIRECTORY. The user can override through the
|
||||
# --with-noarch-pkgconfigdir parameter.
|
||||
dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
|
||||
dnl --------------------------------
|
||||
dnl Since: 0.27
|
||||
dnl
|
||||
dnl Substitutes the variable noarch_pkgconfigdir as the location where a
|
||||
dnl module should install arch-independent pkg-config .pc files. By
|
||||
dnl default the directory is $datadir/pkgconfig, but the default can be
|
||||
dnl changed by passing DIRECTORY. The user can override through the
|
||||
dnl --with-noarch-pkgconfigdir parameter.
|
||||
AC_DEFUN([PKG_NOARCH_INSTALLDIR],
|
||||
[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
|
||||
m4_pushdef([pkg_description],
|
||||
@ -210,13 +269,15 @@ AC_ARG_WITH([noarch-pkgconfigdir],
|
||||
AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
|
||||
m4_popdef([pkg_default])
|
||||
m4_popdef([pkg_description])
|
||||
]) dnl PKG_NOARCH_INSTALLDIR
|
||||
])dnl PKG_NOARCH_INSTALLDIR
|
||||
|
||||
|
||||
# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
|
||||
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
||||
# -------------------------------------------
|
||||
# Retrieves the value of the pkg-config variable for the given module.
|
||||
dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
|
||||
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
||||
dnl -------------------------------------------
|
||||
dnl Since: 0.28
|
||||
dnl
|
||||
dnl Retrieves the value of the pkg-config variable for the given module.
|
||||
AC_DEFUN([PKG_CHECK_VAR],
|
||||
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
|
||||
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
|
||||
@ -225,7 +286,7 @@ _PKG_CONFIG([$1], [variable="][$3]["], [$2])
|
||||
AS_VAR_COPY([$1], [pkg_cv_][$1])
|
||||
|
||||
AS_VAR_IF([$1], [""], [$5], [$4])dnl
|
||||
])# PKG_CHECK_VAR
|
||||
])dnl PKG_CHECK_VAR
|
||||
|
||||
m4_include([config/m4/icu-conditional.m4])
|
||||
m4_include([acinclude.m4])
|
||||
|
@ -31,10 +31,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "i18n", "..\i18n\i18n.vcxpro
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "intltest", "..\test\intltest\intltest.vcxproj", "{73632960-B3A6-464D-83A3-4B43365F19B8}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "layout", "..\layout\layout.vcxproj", "{C920062A-0647-4553-A3B2-37C58065664B}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "layoutex", "..\layoutex\layoutex.vcxproj", "{37FC2C7F-1904-4811-8955-2F478830EAD1}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "makeconv", "..\tools\makeconv\makeconv.vcxproj", "{F5AD9738-1A3D-4906-B9C4-A7D9CE33DC2C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "makedata", "..\data\makedata.vcxproj", "{D9DF7F2F-93B7-4810-B5CD-96F4F33C079B}"
|
||||
@ -57,8 +53,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icupkg", "..\tools\icupkg\i
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gendict", "..\tools\gendict\gendict.vcxproj", "{9D4211F7-2C77-439C-82F0-30A4E43BA569}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "letest", "..\test\letest\letest.vcxproj", "{67351485-4D18-4245-BE39-A7EF0675ACD2}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gencfu", "..\tools\gencfu\gencfu.vcxproj", "{691EE0C0-DC57-4A48-8AEE-8ED75EB3A057}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gennorm2", "..\tools\gennorm2\gennorm2.vcxproj", "{C7891A65-80AB-4245-912E-5F1E17B0E6C4}"
|
||||
@ -295,14 +289,6 @@ Global
|
||||
{9D4211F7-2C77-439C-82F0-30A4E43BA569}.Release|Win32.Build.0 = Release|Win32
|
||||
{9D4211F7-2C77-439C-82F0-30A4E43BA569}.Release|x64.ActiveCfg = Release|x64
|
||||
{9D4211F7-2C77-439C-82F0-30A4E43BA569}.Release|x64.Build.0 = Release|x64
|
||||
{67351485-4D18-4245-BE39-A7EF0675ACD2}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{67351485-4D18-4245-BE39-A7EF0675ACD2}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{67351485-4D18-4245-BE39-A7EF0675ACD2}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{67351485-4D18-4245-BE39-A7EF0675ACD2}.Debug|x64.Build.0 = Debug|x64
|
||||
{67351485-4D18-4245-BE39-A7EF0675ACD2}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{67351485-4D18-4245-BE39-A7EF0675ACD2}.Release|Win32.Build.0 = Release|Win32
|
||||
{67351485-4D18-4245-BE39-A7EF0675ACD2}.Release|x64.ActiveCfg = Release|x64
|
||||
{67351485-4D18-4245-BE39-A7EF0675ACD2}.Release|x64.Build.0 = Release|x64
|
||||
{691EE0C0-DC57-4A48-8AEE-8ED75EB3A057}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{691EE0C0-DC57-4A48-8AEE-8ED75EB3A057}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{691EE0C0-DC57-4A48-8AEE-8ED75EB3A057}.Debug|x64.ActiveCfg = Debug|x64
|
||||
|
@ -1,4 +1,6 @@
|
||||
@echo off
|
||||
REM Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
REM License & terms of use: http://www.unicode.org/copyright.html
|
||||
REM ********************************************************************
|
||||
REM * COPYRIGHT:
|
||||
REM * Copyright (c) 2010-2014, International Business Machines Corporation
|
||||
@ -89,7 +91,7 @@ set ICUFAILCNT=0
|
||||
:OK_cintltst
|
||||
@set ICURUN=%ICURUN% %THT%
|
||||
|
||||
@REM (Layout is deprecated)
|
||||
@REM (Layout is deprecated - this would require HarfBuzz)
|
||||
@REM @set THT=letest
|
||||
@REM @echo ==== %THT% =========================================================================
|
||||
@REM @cd %ICU_ICUDIR%\source\test\letest
|
||||
@ -126,4 +128,4 @@ echo Failing Tests: %ICUFAILED%
|
||||
echo -
|
||||
echo FAILED!
|
||||
|
||||
exit /b 1
|
||||
exit /b 1
|
||||
|
@ -1,6 +1,8 @@
|
||||
# Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
# License & terms of use: http://www.unicode.org/copyright.html
|
||||
#******************************************************************************
|
||||
#
|
||||
# Copyright (C) 1999-2015, International Business Machines
|
||||
# Copyright (C) 1999-2016, International Business Machines
|
||||
# Corporation and others. All Rights Reserved.
|
||||
#
|
||||
#******************************************************************************
|
||||
@ -78,14 +80,15 @@ endif
|
||||
LIBS = $(LIBICUDT) $(DEFAULT_LIBS)
|
||||
|
||||
OBJECTS = errorcode.o putil.o umath.o utypes.o uinvchar.o umutex.o ucln_cmn.o \
|
||||
uinit.o uobject.o cmemory.o charstr.o \
|
||||
uinit.o uobject.o cmemory.o charstr.o cstr.o \
|
||||
udata.o ucmndata.o udatamem.o umapfile.o udataswp.o ucol_swp.o utrace.o \
|
||||
uhash.o uhash_us.o uenum.o ustrenum.o uvector.o ustack.o uvectr32.o uvectr64.o \
|
||||
ucnv.o ucnv_bld.o ucnv_cnv.o ucnv_io.o ucnv_cb.o ucnv_err.o ucnvlat1.o \
|
||||
ucnv_u7.o ucnv_u8.o ucnv_u16.o ucnv_u32.o ucnvscsu.o ucnvbocu.o \
|
||||
ucnv_ext.o ucnvmbcs.o ucnv2022.o ucnvhz.o ucnv_lmb.o ucnvisci.o ucnvdisp.o ucnv_set.o ucnv_ct.o \
|
||||
uresbund.o ures_cnv.o uresdata.o resbund.o resbund_cnv.o \
|
||||
messagepattern.o ucat.o locmap.o uloc.o locid.o locutil.o locavailable.o locdispnames.o loclikely.o locresdata.o \
|
||||
resource.o uresbund.o ures_cnv.o uresdata.o resbund.o resbund_cnv.o \
|
||||
ucurr.o \
|
||||
messagepattern.o ucat.o locmap.o uloc.o locid.o locutil.o locavailable.o locdispnames.o locdspnm.o loclikely.o locresdata.o \
|
||||
bytestream.o stringpiece.o \
|
||||
stringtriebuilder.o bytestriebuilder.o \
|
||||
bytestrie.o bytestrieiterator.o \
|
||||
@ -105,7 +108,8 @@ serv.o servnotf.o servls.o servlk.o servlkf.o servrbf.o servslkf.o \
|
||||
uidna.o usprep.o uts46.o punycode.o \
|
||||
util.o util_props.o parsepos.o locbased.o cwchar.o wintz.o dtintrv.o ucnvsel.o propsvec.o \
|
||||
ulist.o uloc_tag.o icudataver.o icuplug.o listformatter.o ulistformatter.o \
|
||||
sharedobject.o simplepatternformatter.o unifiedcache.o uloc_keytype.o \
|
||||
sharedobject.o simpleformatter.o unifiedcache.o uloc_keytype.o \
|
||||
ubiditransform.o \
|
||||
pluralmap.o
|
||||
|
||||
## Header files to install
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011-2012, International Business Machines
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
************************************************************************************
|
||||
* Copyright (C) 2006-2015, International Business Machines Corporation
|
||||
* Copyright (C) 2006-2016, International Business Machines Corporation
|
||||
* and others. All Rights Reserved.
|
||||
************************************************************************************
|
||||
*/
|
||||
@ -10,6 +12,7 @@
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
|
||||
#include "brkeng.h"
|
||||
#include "cmemory.h"
|
||||
#include "dictbe.h"
|
||||
#include "unicode/uchar.h"
|
||||
#include "unicode/uniset.h"
|
||||
@ -56,13 +59,13 @@ LanguageBreakFactory::~LanguageBreakFactory() {
|
||||
*/
|
||||
|
||||
UnhandledEngine::UnhandledEngine(UErrorCode &/*status*/) {
|
||||
for (int32_t i = 0; i < (int32_t)(sizeof(fHandled)/sizeof(fHandled[0])); ++i) {
|
||||
for (int32_t i = 0; i < UPRV_LENGTHOF(fHandled); ++i) {
|
||||
fHandled[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
UnhandledEngine::~UnhandledEngine() {
|
||||
for (int32_t i = 0; i < (int32_t)(sizeof(fHandled)/sizeof(fHandled[0])); ++i) {
|
||||
for (int32_t i = 0; i < UPRV_LENGTHOF(fHandled); ++i) {
|
||||
if (fHandled[i] != 0) {
|
||||
delete fHandled[i];
|
||||
}
|
||||
@ -71,7 +74,7 @@ UnhandledEngine::~UnhandledEngine() {
|
||||
|
||||
UBool
|
||||
UnhandledEngine::handles(UChar32 c, int32_t breakType) const {
|
||||
return (breakType >= 0 && breakType < (int32_t)(sizeof(fHandled)/sizeof(fHandled[0]))
|
||||
return (breakType >= 0 && breakType < UPRV_LENGTHOF(fHandled)
|
||||
&& fHandled[breakType] != 0 && fHandled[breakType]->contains(c));
|
||||
}
|
||||
|
||||
@ -82,7 +85,7 @@ UnhandledEngine::findBreaks( UText *text,
|
||||
UBool reverse,
|
||||
int32_t breakType,
|
||||
UStack &/*foundBreaks*/ ) const {
|
||||
if (breakType >= 0 && breakType < (int32_t)(sizeof(fHandled)/sizeof(fHandled[0]))) {
|
||||
if (breakType >= 0 && breakType < UPRV_LENGTHOF(fHandled)) {
|
||||
UChar32 c = utext_current32(text);
|
||||
if (reverse) {
|
||||
while((int32_t)utext_getNativeIndex(text) > startPos && fHandled[breakType]->contains(c)) {
|
||||
@ -101,7 +104,7 @@ UnhandledEngine::findBreaks( UText *text,
|
||||
|
||||
void
|
||||
UnhandledEngine::handleCharacter(UChar32 c, int32_t breakType) {
|
||||
if (breakType >= 0 && breakType < (int32_t)(sizeof(fHandled)/sizeof(fHandled[0]))) {
|
||||
if (breakType >= 0 && breakType < UPRV_LENGTHOF(fHandled)) {
|
||||
if (fHandled[breakType] == 0) {
|
||||
fHandled[breakType] = new UnicodeSet();
|
||||
if (fHandled[breakType] == 0) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/**
|
||||
************************************************************************************
|
||||
* Copyright (C) 2006-2012, International Business Machines Corporation and others. *
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2015, International Business Machines Corporation and
|
||||
@ -418,6 +420,7 @@ BreakIterator::makeInstance(const Locale& loc, int32_t kind, UErrorCode& status)
|
||||
break;
|
||||
case UBRK_SENTENCE:
|
||||
result = BreakIterator::buildInstance(loc, "sentence", kind, status);
|
||||
#if !UCONFIG_NO_FILTERED_BREAK_ITERATION
|
||||
{
|
||||
char ssKeyValue[kKeyValueLenMax] = {0};
|
||||
UErrorCode kvStatus = U_ZERO_ERROR;
|
||||
@ -430,6 +433,7 @@ BreakIterator::makeInstance(const Locale& loc, int32_t kind, UErrorCode& status)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case UBRK_TITLE:
|
||||
result = BreakIterator::buildInstance(loc, "title", kind, status);
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
// Copyright (C) 2009-2011, International Business Machines
|
||||
// Corporation and others. All Rights Reserved.
|
||||
//
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010-2011, International Business Machines
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010-2012, International Business Machines
|
||||
@ -35,7 +37,7 @@ class BytesTrieElement : public UMemory {
|
||||
public:
|
||||
// Use compiler's default constructor, initializes nothing.
|
||||
|
||||
void setTo(const StringPiece &s, int32_t val, CharString &strings, UErrorCode &errorCode);
|
||||
void setTo(StringPiece s, int32_t val, CharString &strings, UErrorCode &errorCode);
|
||||
|
||||
StringPiece getString(const CharString &strings) const {
|
||||
int32_t offset=stringOffset;
|
||||
@ -86,7 +88,7 @@ private:
|
||||
};
|
||||
|
||||
void
|
||||
BytesTrieElement::setTo(const StringPiece &s, int32_t val,
|
||||
BytesTrieElement::setTo(StringPiece s, int32_t val,
|
||||
CharString &strings, UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return;
|
||||
@ -143,7 +145,7 @@ BytesTrieBuilder::~BytesTrieBuilder() {
|
||||
}
|
||||
|
||||
BytesTrieBuilder &
|
||||
BytesTrieBuilder::add(const StringPiece &s, int32_t value, UErrorCode &errorCode) {
|
||||
BytesTrieBuilder::add(StringPiece s, int32_t value, UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return *this;
|
||||
}
|
||||
@ -165,7 +167,7 @@ BytesTrieBuilder::add(const StringPiece &s, int32_t value, UErrorCode &errorCode
|
||||
return *this; // error instead of dereferencing null
|
||||
}
|
||||
if(elementsLength>0) {
|
||||
uprv_memcpy(newElements, elements, elementsLength*sizeof(BytesTrieElement));
|
||||
uprv_memcpy(newElements, elements, (size_t)elementsLength*sizeof(BytesTrieElement));
|
||||
}
|
||||
delete[] elements;
|
||||
elements=newElements;
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010-2012, International Business Machines
|
||||
@ -139,7 +141,6 @@ BytesTrie::Iterator::next(UErrorCode &errorCode) {
|
||||
} else {
|
||||
pos_=skipValue(pos, node);
|
||||
}
|
||||
sp_.set(str_->data(), str_->length());
|
||||
return TRUE;
|
||||
}
|
||||
if(maxLength_>0 && str_->length()==maxLength_) {
|
||||
@ -167,10 +168,14 @@ BytesTrie::Iterator::next(UErrorCode &errorCode) {
|
||||
}
|
||||
}
|
||||
|
||||
StringPiece
|
||||
BytesTrie::Iterator::getString() const {
|
||||
return str_ == NULL ? StringPiece() : str_->toStringPiece();
|
||||
}
|
||||
|
||||
UBool
|
||||
BytesTrie::Iterator::truncateAndStop() {
|
||||
pos_=NULL;
|
||||
sp_.set(str_->data(), str_->length());
|
||||
value_=-1; // no real value for str
|
||||
return TRUE;
|
||||
}
|
||||
@ -199,7 +204,6 @@ BytesTrie::Iterator::branchNext(const uint8_t *pos, int32_t length, UErrorCode &
|
||||
str_->append((char)trieByte, errorCode);
|
||||
if(isFinal) {
|
||||
pos_=NULL;
|
||||
sp_.set(str_->data(), str_->length());
|
||||
value_=value;
|
||||
return NULL;
|
||||
} else {
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1996-2015, International Business Machines Corporation and
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1999-2011, International Business Machines
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010-2015, International Business Machines
|
||||
@ -144,7 +146,7 @@ UBool CharString::ensureCapacity(int32_t capacity,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CharString &CharString::appendPathPart(const StringPiece &s, UErrorCode &errorCode) {
|
||||
CharString &CharString::appendPathPart(StringPiece s, UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return *this;
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2001-2015, International Business Machines
|
||||
@ -39,7 +41,7 @@ template class U_COMMON_API MaybeStackArray<char, 40>;
|
||||
class U_COMMON_API CharString : public UMemory {
|
||||
public:
|
||||
CharString() : len(0) { buffer[0]=0; }
|
||||
CharString(const StringPiece &s, UErrorCode &errorCode) : len(0) {
|
||||
CharString(StringPiece s, UErrorCode &errorCode) : len(0) {
|
||||
buffer[0]=0;
|
||||
append(s, errorCode);
|
||||
}
|
||||
@ -76,7 +78,7 @@ public:
|
||||
CharString &truncate(int32_t newLength);
|
||||
|
||||
CharString &append(char c, UErrorCode &errorCode);
|
||||
CharString &append(const StringPiece &s, UErrorCode &errorCode) {
|
||||
CharString &append(StringPiece s, UErrorCode &errorCode) {
|
||||
return append(s.data(), s.length(), errorCode);
|
||||
}
|
||||
CharString &append(const CharString &s, UErrorCode &errorCode) {
|
||||
@ -115,7 +117,7 @@ public:
|
||||
* First appends a U_FILE_SEP_CHAR if necessary.
|
||||
* Does nothing if s is empty.
|
||||
*/
|
||||
CharString &appendPathPart(const StringPiece &s, UErrorCode &errorCode);
|
||||
CharString &appendPathPart(StringPiece s, UErrorCode &errorCode);
|
||||
|
||||
/**
|
||||
* Appends a U_FILE_SEP_CHAR if this string is not empty
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
|
@ -1,7 +1,9 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1997-2015, International Business Machines
|
||||
* Copyright (C) 1997-2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
@ -153,6 +155,8 @@ U_NAMESPACE_BEGIN
|
||||
template<typename T>
|
||||
class LocalMemory : public LocalPointerBase<T> {
|
||||
public:
|
||||
using LocalPointerBase<T>::operator*;
|
||||
using LocalPointerBase<T>::operator->;
|
||||
/**
|
||||
* Constructor takes ownership.
|
||||
* @param p simple pointer to an array of T items that is adopted
|
||||
@ -279,7 +283,7 @@ inline T *LocalMemory<T>::allocateInsteadAndCopy(int32_t newCapacity, int32_t le
|
||||
if(length>newCapacity) {
|
||||
length=newCapacity;
|
||||
}
|
||||
uprv_memcpy(p, LocalPointerBase<T>::ptr, length*sizeof(T));
|
||||
uprv_memcpy(p, LocalPointerBase<T>::ptr, (size_t)length*sizeof(T));
|
||||
}
|
||||
uprv_free(LocalPointerBase<T>::ptr);
|
||||
LocalPointerBase<T>::ptr=p;
|
||||
@ -426,7 +430,7 @@ inline T *MaybeStackArray<T, stackCapacity>::resize(int32_t newCapacity, int32_t
|
||||
if(length>newCapacity) {
|
||||
length=newCapacity;
|
||||
}
|
||||
uprv_memcpy(p, ptr, length*sizeof(T));
|
||||
uprv_memcpy(p, ptr, (size_t)length*sizeof(T));
|
||||
}
|
||||
releaseArray();
|
||||
ptr=p;
|
||||
@ -457,7 +461,7 @@ inline T *MaybeStackArray<T, stackCapacity>::orphanOrClone(int32_t length, int32
|
||||
if(p==NULL) {
|
||||
return NULL;
|
||||
}
|
||||
uprv_memcpy(p, ptr, length*sizeof(T));
|
||||
uprv_memcpy(p, ptr, (size_t)length*sizeof(T));
|
||||
}
|
||||
resultCapacity=length;
|
||||
ptr=stackArray;
|
||||
@ -605,7 +609,7 @@ inline H *MaybeStackHeaderAndArray<H, T, stackCapacity>::resize(int32_t newCapac
|
||||
length=newCapacity;
|
||||
}
|
||||
}
|
||||
uprv_memcpy(p, ptr, sizeof(H)+length*sizeof(T));
|
||||
uprv_memcpy(p, ptr, sizeof(H)+(size_t)length*sizeof(T));
|
||||
releaseMemory();
|
||||
ptr=p;
|
||||
capacity=newCapacity;
|
||||
@ -636,7 +640,7 @@ inline H *MaybeStackHeaderAndArray<H, T, stackCapacity>::orphanOrClone(int32_t l
|
||||
if(p==NULL) {
|
||||
return NULL;
|
||||
}
|
||||
uprv_memcpy(p, ptr, sizeof(H)+length*sizeof(T));
|
||||
uprv_memcpy(p, ptr, sizeof(H)+(size_t)length*sizeof(T));
|
||||
}
|
||||
resultCapacity=length;
|
||||
ptr=&stackHeader;
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Do not edit with Microsoft Developer Studio Resource Editor.
|
||||
// It will permanently substitute version numbers that are intended to be
|
||||
// picked up by the pre-processor during each build.
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
// Copyright (c) 2001-2010 International Business Machines
|
||||
// Corporation and others. All Rights Reserved.
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
@ -26,21 +26,25 @@
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
@ -104,7 +108,7 @@
|
||||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<OutputFile>..\..\bin\icuuc56.dll</OutputFile>
|
||||
<OutputFile>..\..\bin\icuuc58.dll</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<ProgramDatabaseFile>.\..\..\lib\icuuc.pdb</ProgramDatabaseFile>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
@ -145,7 +149,7 @@
|
||||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<OutputFile>..\..\bin\icuuc56d.dll</OutputFile>
|
||||
<OutputFile>..\..\bin\icuuc58d.dll</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>.\..\..\lib\icuucd.pdb</ProgramDatabaseFile>
|
||||
@ -183,7 +187,7 @@
|
||||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<OutputFile>..\..\bin64\icuuc56.dll</OutputFile>
|
||||
<OutputFile>..\..\bin64\icuuc58.dll</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<ProgramDatabaseFile>.\..\..\lib64\icuuc.pdb</ProgramDatabaseFile>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
@ -222,7 +226,7 @@
|
||||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<OutputFile>..\..\bin64\icuuc56d.dll</OutputFile>
|
||||
<OutputFile>..\..\bin64\icuuc58d.dll</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>.\..\..\lib64\icuucd.pdb</ProgramDatabaseFile>
|
||||
@ -234,6 +238,7 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="filteredbrk.cpp" />
|
||||
<ClCompile Include="ubidi.c" />
|
||||
<ClCompile Include="ubiditransform.c" />
|
||||
<ClCompile Include="ubidi_props.c" />
|
||||
<ClCompile Include="ubidiln.c" />
|
||||
<ClCompile Include="ubidiwrt.c" />
|
||||
@ -365,6 +370,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="locbased.cpp" />
|
||||
<ClCompile Include="locdispnames.cpp" />
|
||||
<ClCompile Include="locdspnm.cpp" />
|
||||
<ClCompile Include="locid.cpp">
|
||||
</ClCompile>
|
||||
<ClCompile Include="loclikely.cpp" />
|
||||
@ -379,7 +385,9 @@
|
||||
<ClCompile Include="uloc_tag.c" />
|
||||
<ClCompile Include="ures_cnv.c" />
|
||||
<ClCompile Include="uresbund.cpp" />
|
||||
<ClCompile Include="uresdata.c" />
|
||||
<ClCompile Include="uresdata.cpp" />
|
||||
<ClCompile Include="resource.cpp" />
|
||||
<ClCompile Include="ucurr.cpp" />
|
||||
<ClCompile Include="caniter.cpp">
|
||||
</ClCompile>
|
||||
<ClCompile Include="filterednormalizer2.cpp" />
|
||||
@ -439,12 +447,13 @@
|
||||
<ClCompile Include="chariter.cpp" />
|
||||
<ClCompile Include="charstr.cpp" />
|
||||
<ClCompile Include="cstring.c" />
|
||||
<ClCompile Include="cstr.cpp" />
|
||||
<ClCompile Include="cwchar.c" />
|
||||
<ClCompile Include="messagepattern.cpp" />
|
||||
<ClCompile Include="schriter.cpp" />
|
||||
<ClCompile Include="stringpiece.cpp" />
|
||||
<ClCompile Include="stringtriebuilder.cpp" />
|
||||
<ClCompile Include="simplepatternformatter.cpp" />
|
||||
<ClCompile Include="simpleformatter.cpp" />
|
||||
<ClCompile Include="ucasemap.cpp" />
|
||||
<ClCompile Include="ucasemap_titlecase_brkiter.cpp" />
|
||||
<ClCompile Include="ucharstrie.cpp" />
|
||||
@ -578,6 +587,7 @@
|
||||
<ClInclude Include="uchar_props_data.h" />
|
||||
<ClInclude Include="ucol_data.h" />
|
||||
<ClInclude Include="ucol_swp.h" />
|
||||
<ClInclude Include="unicode\ubiditransform.h" />
|
||||
<ClInclude Include="unistrappender.h" />
|
||||
<ClInclude Include="hash.h" />
|
||||
<ClInclude Include="propsvec.h" />
|
||||
@ -1087,7 +1097,34 @@
|
||||
</CustomBuild>
|
||||
<ClInclude Include="sharedobject.h" />
|
||||
<ClCompile Include="sharedobject.cpp" />
|
||||
<ClInclude Include="simplepatternformatter.h" />
|
||||
<CustomBuild Include="unicode\locdspnm.h">
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="unicode\simpleformatter.h">
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="unicode\ucat.h">
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
@ -1099,6 +1136,34 @@
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="unicode\udisplaycontext.h">
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="unicode\uldnames.h">
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
@ -1135,6 +1200,22 @@
|
||||
<ClInclude Include="uresdata.h" />
|
||||
<ClInclude Include="uresimp.h" />
|
||||
<ClInclude Include="ureslocs.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<CustomBuild Include="unicode\ucurr.h">
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="ucurrimp.h" />
|
||||
<CustomBuild Include="unicode\caniter.h">
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||
</Command>
|
||||
@ -1449,6 +1530,7 @@
|
||||
</CustomBuild>
|
||||
<ClInclude Include="charstr.h" />
|
||||
<ClInclude Include="cstring.h" />
|
||||
<ClInclude Include="cstr.h" />
|
||||
<ClInclude Include="cwchar.h" />
|
||||
<CustomBuild Include="unicode\messagepattern.h">
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" ..\..\include\unicode
|
||||
@ -1774,4 +1856,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
@ -277,10 +277,16 @@
|
||||
<ClCompile Include="dtintrv.cpp">
|
||||
<Filter>formatting</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="locdspnm.cpp">
|
||||
<Filter>formatting</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="parsepos.cpp">
|
||||
<Filter>formatting</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="simplepatternformatter.cpp">
|
||||
<ClCompile Include="simpleformatter.cpp">
|
||||
<Filter>formatting</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ucurr.cpp">
|
||||
<Filter>formatting</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ustrfmt.c">
|
||||
@ -343,7 +349,10 @@
|
||||
<ClCompile Include="uresbund.cpp">
|
||||
<Filter>locales & resources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="uresdata.c">
|
||||
<ClCompile Include="uresdata.cpp">
|
||||
<Filter>locales & resources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="resource.cpp">
|
||||
<Filter>locales & resources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="caniter.cpp">
|
||||
@ -463,6 +472,9 @@
|
||||
<ClCompile Include="cstring.c">
|
||||
<Filter>strings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cstr.cpp">
|
||||
<Filter>strings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cwchar.c">
|
||||
<Filter>strings</Filter>
|
||||
</ClCompile>
|
||||
@ -574,13 +586,18 @@
|
||||
<ClCompile Include="stringtriebuilder.cpp">
|
||||
<Filter>collections</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="icuplug.cpp" />
|
||||
<ClCompile Include="uloc_keytype.cpp">
|
||||
<Filter>locales & resources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="filteredbrk.cpp">
|
||||
<Filter>break iteration</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="icuplug.cpp">
|
||||
<Filter>registration</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ubiditransform.c">
|
||||
<Filter>bidi</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ubidi_props.h">
|
||||
@ -745,15 +762,30 @@
|
||||
<ClInclude Include="umapfile.h">
|
||||
<Filter>data & memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="simplepatternformatter.h">
|
||||
<CustomBuild Include="unicode\locdspnm.h">
|
||||
<Filter>formatting</Filter>
|
||||
</ClInclude>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="unicode\simpleformatter.h">
|
||||
<Filter>formatting</Filter>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="ustrfmt.h">
|
||||
<Filter>formatting</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="util.h">
|
||||
<Filter>formatting</Filter>
|
||||
</ClInclude>
|
||||
<CustomBuild Include="unicode\ucurr.h">
|
||||
<Filter>formatting</Filter>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="ucurrimp.h">
|
||||
<Filter>formatting</Filter>
|
||||
</ClInclude>
|
||||
<CustomBuild Include="unicode\udisplaycontext.h">
|
||||
<Filter>formatting</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="unicode\uldnames.h">
|
||||
<Filter>formatting</Filter>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="punycode.h">
|
||||
<Filter>idna</Filter>
|
||||
</ClInclude>
|
||||
@ -769,6 +801,9 @@
|
||||
<ClInclude Include="uresdata.h">
|
||||
<Filter>locales & resources</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>locales & resources</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="uresimp.h">
|
||||
<Filter>locales & resources</Filter>
|
||||
</ClInclude>
|
||||
@ -829,6 +864,9 @@
|
||||
<ClInclude Include="cstring.h">
|
||||
<Filter>strings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="cstr.h">
|
||||
<Filter>strings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="cwchar.h">
|
||||
<Filter>strings</Filter>
|
||||
</ClInclude>
|
||||
@ -877,6 +915,9 @@
|
||||
<ClInclude Include="unicode\filteredbrk.h">
|
||||
<Filter>break iteration</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="unicode\ubiditransform.h">
|
||||
<Filter>bidi</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="common.rc">
|
||||
@ -1140,4 +1181,4 @@
|
||||
<Filter>collections</Filter>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
@ -24,45 +26,45 @@
|
||||
|
||||
static
|
||||
inline void uprv_arrayCopy(const double* src, double* dst, int32_t count)
|
||||
{ uprv_memcpy(dst, src, (size_t)(count * sizeof(*src))); }
|
||||
{ uprv_memcpy(dst, src, (size_t)count * sizeof(*src)); }
|
||||
|
||||
static
|
||||
inline void uprv_arrayCopy(const double* src, int32_t srcStart,
|
||||
double* dst, int32_t dstStart, int32_t count)
|
||||
{ uprv_memcpy(dst+dstStart, src+srcStart, (size_t)(count * sizeof(*src))); }
|
||||
{ uprv_memcpy(dst+dstStart, src+srcStart, (size_t)count * sizeof(*src)); }
|
||||
|
||||
static
|
||||
inline void uprv_arrayCopy(const int8_t* src, int8_t* dst, int32_t count)
|
||||
{ uprv_memcpy(dst, src, (size_t)(count * sizeof(*src))); }
|
||||
{ uprv_memcpy(dst, src, (size_t)count * sizeof(*src)); }
|
||||
|
||||
static
|
||||
inline void uprv_arrayCopy(const int8_t* src, int32_t srcStart,
|
||||
int8_t* dst, int32_t dstStart, int32_t count)
|
||||
{ uprv_memcpy(dst+dstStart, src+srcStart, (size_t)(count * sizeof(*src))); }
|
||||
{ uprv_memcpy(dst+dstStart, src+srcStart, (size_t)count * sizeof(*src)); }
|
||||
|
||||
static
|
||||
inline void uprv_arrayCopy(const int16_t* src, int16_t* dst, int32_t count)
|
||||
{ uprv_memcpy(dst, src, (size_t)(count * sizeof(*src))); }
|
||||
{ uprv_memcpy(dst, src, (size_t)count * sizeof(*src)); }
|
||||
|
||||
static
|
||||
inline void uprv_arrayCopy(const int16_t* src, int32_t srcStart,
|
||||
int16_t* dst, int32_t dstStart, int32_t count)
|
||||
{ uprv_memcpy(dst+dstStart, src+srcStart, (size_t)(count * sizeof(*src))); }
|
||||
{ uprv_memcpy(dst+dstStart, src+srcStart, (size_t)count * sizeof(*src)); }
|
||||
|
||||
static
|
||||
inline void uprv_arrayCopy(const int32_t* src, int32_t* dst, int32_t count)
|
||||
{ uprv_memcpy(dst, src, (size_t)(count * sizeof(*src))); }
|
||||
{ uprv_memcpy(dst, src, (size_t)count * sizeof(*src)); }
|
||||
|
||||
static
|
||||
inline void uprv_arrayCopy(const int32_t* src, int32_t srcStart,
|
||||
int32_t* dst, int32_t dstStart, int32_t count)
|
||||
{ uprv_memcpy(dst+dstStart, src+srcStart, (size_t)(count * sizeof(*src))); }
|
||||
{ uprv_memcpy(dst+dstStart, src+srcStart, (size_t)count * sizeof(*src)); }
|
||||
|
||||
static
|
||||
inline void
|
||||
uprv_arrayCopy(const UChar *src, int32_t srcStart,
|
||||
UChar *dst, int32_t dstStart, int32_t count)
|
||||
{ uprv_memcpy(dst+dstStart, src+srcStart, (size_t)(count * sizeof(*src))); }
|
||||
{ uprv_memcpy(dst+dstStart, src+srcStart, (size_t)count * sizeof(*src)); }
|
||||
|
||||
/**
|
||||
* Copy an array of UnicodeString OBJECTS (not pointers).
|
||||
|
54
intl/icu/source/common/cstr.cpp
Normal file
54
intl/icu/source/common/cstr.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2015-2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* file name: charstr.cpp
|
||||
*/
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/putil.h"
|
||||
#include "unicode/unistr.h"
|
||||
|
||||
#include "cstr.h"
|
||||
|
||||
#include "charstr.h"
|
||||
#include "uinvchar.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
CStr::CStr(const UnicodeString &in) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
#if !UCONFIG_NO_CONVERSION || U_CHARSET_IS_UTF8
|
||||
int32_t length = in.extract(0, in.length(), static_cast<char *>(NULL), static_cast<uint32_t>(0));
|
||||
int32_t resultCapacity = 0;
|
||||
char *buf = s.getAppendBuffer(length, length, resultCapacity, status);
|
||||
if (U_SUCCESS(status)) {
|
||||
in.extract(0, in.length(), buf, resultCapacity);
|
||||
s.append(buf, length, status);
|
||||
}
|
||||
#else
|
||||
// No conversion available. Convert any invariant characters; substitute '?' for the rest.
|
||||
// Note: can't just call u_UCharsToChars() or CharString.appendInvariantChars() on the
|
||||
// whole string because they require that the entire input be invariant.
|
||||
char buf[2];
|
||||
for (int i=0; i<in.length(); i = in.moveIndex32(i, 1)) {
|
||||
if (uprv_isInvariantUString(in.getBuffer()+i, 1)) {
|
||||
u_UCharsToChars(in.getBuffer()+i, buf, 1);
|
||||
} else {
|
||||
buf[0] = '?';
|
||||
}
|
||||
s.append(buf, 1, status);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
CStr::~CStr() {
|
||||
}
|
||||
|
||||
const char * CStr::operator ()() const {
|
||||
return s.data();
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
60
intl/icu/source/common/cstr.h
Normal file
60
intl/icu/source/common/cstr.h
Normal file
@ -0,0 +1,60 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* File: cstr.h
|
||||
*/
|
||||
|
||||
#ifndef CSTR_H
|
||||
#define CSTR_H
|
||||
|
||||
#include "unicode/unistr.h"
|
||||
#include "unicode/uobject.h"
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#include "charstr.h"
|
||||
|
||||
/**
|
||||
* ICU-internal class CStr, a small helper class to facilitate passing UnicodeStrings
|
||||
* to functions needing (const char *) strings, such as printf().
|
||||
*
|
||||
* It is intended primarily for use in debugging or in tests. Uses platform
|
||||
* default code page conversion, which will do the best job possible,
|
||||
* but may be lossy, depending on the platform.
|
||||
*
|
||||
* If no other conversion is available, use invariant conversion and substitue
|
||||
* '?' for non-invariant characters.
|
||||
*
|
||||
* Example Usage:
|
||||
* UnicodeString s = whatever;
|
||||
* printf("%s", CStr(s)());
|
||||
*
|
||||
* The explicit call to the CStr() constructor creates a temporary object.
|
||||
* Operator () on the temporary object returns a (const char *) pointer.
|
||||
* The lifetime of the (const char *) data is that of the temporary object,
|
||||
* which works well when passing it as a parameter to another function, such as printf.
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class U_COMMON_API CStr : public UMemory {
|
||||
public:
|
||||
CStr(const UnicodeString &in);
|
||||
~CStr();
|
||||
const char * operator ()() const;
|
||||
|
||||
private:
|
||||
CharString s;
|
||||
CStr(const CStr &other); // Forbid copying of this class.
|
||||
CStr &operator =(const CStr &other); // Forbid assignment.
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2015, International Business Machines Corporation
|
||||
* Copyright (C) 2006-2016, International Business Machines Corporation
|
||||
* and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -70,13 +72,13 @@ DictionaryBreakEngine::findBreaks( UText *text,
|
||||
rangeStart = current;
|
||||
if (!isDict) {
|
||||
utext_next32(text);
|
||||
rangeStart = utext_getNativeIndex(text);
|
||||
rangeStart = (int32_t)utext_getNativeIndex(text);
|
||||
}
|
||||
}
|
||||
// rangeEnd = start + 1;
|
||||
utext_setNativeIndex(text, start);
|
||||
utext_next32(text);
|
||||
rangeEnd = utext_getNativeIndex(text);
|
||||
rangeEnd = (int32_t)utext_getNativeIndex(text);
|
||||
}
|
||||
else {
|
||||
while((current = (int32_t)utext_getNativeIndex(text)) < endPos && fSet.contains(c)) {
|
||||
@ -335,9 +337,9 @@ foundBest:
|
||||
UChar32 pc;
|
||||
int32_t chars = 0;
|
||||
for (;;) {
|
||||
int32_t pcIndex = utext_getNativeIndex(text);
|
||||
int32_t pcIndex = (int32_t)utext_getNativeIndex(text);
|
||||
pc = utext_next32(text);
|
||||
int32_t pcSize = utext_getNativeIndex(text) - pcIndex;
|
||||
int32_t pcSize = (int32_t)utext_getNativeIndex(text) - pcIndex;
|
||||
chars += pcSize;
|
||||
remaining -= pcSize;
|
||||
if (remaining <= 0) {
|
||||
@ -390,9 +392,9 @@ foundBest:
|
||||
if (!fSuffixSet.contains(utext_previous32(text))) {
|
||||
// Skip over previous end and PAIYANNOI
|
||||
utext_next32(text);
|
||||
int32_t paiyannoiIndex = utext_getNativeIndex(text);
|
||||
int32_t paiyannoiIndex = (int32_t)utext_getNativeIndex(text);
|
||||
utext_next32(text);
|
||||
cuWordLength += utext_getNativeIndex(text) - paiyannoiIndex; // Add PAIYANNOI to word
|
||||
cuWordLength += (int32_t)utext_getNativeIndex(text) - paiyannoiIndex; // Add PAIYANNOI to word
|
||||
uc = utext_current32(text); // Fetch next character
|
||||
}
|
||||
else {
|
||||
@ -404,9 +406,9 @@ foundBest:
|
||||
if (utext_previous32(text) != THAI_MAIYAMOK) {
|
||||
// Skip over previous end and MAIYAMOK
|
||||
utext_next32(text);
|
||||
int32_t maiyamokIndex = utext_getNativeIndex(text);
|
||||
int32_t maiyamokIndex = (int32_t)utext_getNativeIndex(text);
|
||||
utext_next32(text);
|
||||
cuWordLength += utext_getNativeIndex(text) - maiyamokIndex; // Add MAIYAMOK to word
|
||||
cuWordLength += (int32_t)utext_getNativeIndex(text) - maiyamokIndex; // Add MAIYAMOK to word
|
||||
}
|
||||
else {
|
||||
// Restore prior position
|
||||
@ -568,9 +570,9 @@ foundBest:
|
||||
UChar32 uc;
|
||||
int32_t chars = 0;
|
||||
for (;;) {
|
||||
int32_t pcIndex = utext_getNativeIndex(text);
|
||||
int32_t pcIndex = (int32_t)utext_getNativeIndex(text);
|
||||
pc = utext_next32(text);
|
||||
int32_t pcSize = utext_getNativeIndex(text) - pcIndex;
|
||||
int32_t pcSize = (int32_t)utext_getNativeIndex(text) - pcIndex;
|
||||
chars += pcSize;
|
||||
remaining -= pcSize;
|
||||
if (remaining <= 0) {
|
||||
@ -761,9 +763,9 @@ foundBest:
|
||||
UChar32 uc;
|
||||
int32_t chars = 0;
|
||||
for (;;) {
|
||||
int32_t pcIndex = utext_getNativeIndex(text);
|
||||
int32_t pcIndex = (int32_t)utext_getNativeIndex(text);
|
||||
pc = utext_next32(text);
|
||||
int32_t pcSize = utext_getNativeIndex(text) - pcIndex;
|
||||
int32_t pcSize = (int32_t)utext_getNativeIndex(text) - pcIndex;
|
||||
chars += pcSize;
|
||||
remaining -= pcSize;
|
||||
if (remaining <= 0) {
|
||||
@ -967,9 +969,9 @@ foundBest:
|
||||
UChar32 uc;
|
||||
int32_t chars = 0;
|
||||
for (;;) {
|
||||
int32_t pcIndex = utext_getNativeIndex(text);
|
||||
int32_t pcIndex = (int32_t)utext_getNativeIndex(text);
|
||||
pc = utext_next32(text);
|
||||
int32_t pcSize = utext_getNativeIndex(text) - pcIndex;
|
||||
int32_t pcSize = (int32_t)utext_getNativeIndex(text) - pcIndex;
|
||||
chars += pcSize;
|
||||
remaining -= pcSize;
|
||||
if (remaining <= 0) {
|
||||
@ -1166,14 +1168,14 @@ CjkBreakEngine::divideUpDictionaryRange( UText *inText,
|
||||
int32_t limit = rangeEnd;
|
||||
U_ASSERT(limit <= utext_nativeLength(inText));
|
||||
if (limit > utext_nativeLength(inText)) {
|
||||
limit = utext_nativeLength(inText);
|
||||
limit = (int32_t)utext_nativeLength(inText);
|
||||
}
|
||||
inputMap.adoptInsteadAndCheckErrorCode(new UVector32(status), status);
|
||||
if (U_FAILURE(status)) {
|
||||
return 0;
|
||||
}
|
||||
while (utext_getNativeIndex(inText) < limit) {
|
||||
int32_t nativePosition = utext_getNativeIndex(inText);
|
||||
int32_t nativePosition = (int32_t)utext_getNativeIndex(inText);
|
||||
UChar32 c = utext_next32(inText);
|
||||
U_ASSERT(c != U_SENTINEL);
|
||||
inString.append(c);
|
||||
@ -1293,6 +1295,7 @@ CjkBreakEngine::divideUpDictionaryRange( UText *inText,
|
||||
// ix is the corresponding string (code unit) index.
|
||||
// They differ when the string contains supplementary characters.
|
||||
int32_t ix = 0;
|
||||
bool is_prev_katakana = false;
|
||||
for (int32_t i = 0; i < numCodePts; ++i, ix = inString.moveIndex32(ix, 1)) {
|
||||
if ((uint32_t)bestSnlp.elementAti(i) == kuint32max) {
|
||||
continue;
|
||||
@ -1306,7 +1309,7 @@ CjkBreakEngine::divideUpDictionaryRange( UText *inText,
|
||||
// The NULL parameter is the ignored code unit lengths.
|
||||
|
||||
// if there are no single character matches found in the dictionary
|
||||
// starting with this charcter, treat character as a 1-character word
|
||||
// starting with this character, treat character as a 1-character word
|
||||
// with the highest value possible, i.e. the least likely to occur.
|
||||
// Exclude Korean characters from this treatment, as they should be left
|
||||
// together by default.
|
||||
@ -1331,7 +1334,6 @@ CjkBreakEngine::divideUpDictionaryRange( UText *inText,
|
||||
// characters is considered a candidate word with a default cost
|
||||
// specified in the katakanaCost table according to its length.
|
||||
|
||||
bool is_prev_katakana = false;
|
||||
bool is_katakana = isKatakana(inString.char32At(ix));
|
||||
int32_t katakanaRunLength = 1;
|
||||
if (!is_prev_katakana && is_katakana) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2014, International Business Machines Corporation *
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2014, International Business Machines
|
||||
* Copyright (C) 2014-2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* dictionarydata.h
|
||||
@ -45,13 +47,13 @@ int32_t UCharsDictionaryMatcher::matches(UText *text, int32_t maxLength, int32_t
|
||||
int32_t *prefix) const {
|
||||
|
||||
UCharsTrie uct(characters);
|
||||
int32_t startingTextIndex = utext_getNativeIndex(text);
|
||||
int32_t startingTextIndex = (int32_t)utext_getNativeIndex(text);
|
||||
int32_t wordCount = 0;
|
||||
int32_t codePointsMatched = 0;
|
||||
|
||||
for (UChar32 c = utext_next32(text); c >= 0; c=utext_next32(text)) {
|
||||
UStringTrieResult result = (codePointsMatched == 0) ? uct.first(c) : uct.next(c);
|
||||
int32_t lengthMatched = utext_getNativeIndex(text) - startingTextIndex;
|
||||
int32_t lengthMatched = (int32_t)utext_getNativeIndex(text) - startingTextIndex;
|
||||
codePointsMatched += 1;
|
||||
if (USTRINGTRIE_HAS_VALUE(result)) {
|
||||
if (wordCount < limit) {
|
||||
@ -112,13 +114,13 @@ int32_t BytesDictionaryMatcher::matches(UText *text, int32_t maxLength, int32_t
|
||||
int32_t *lengths, int32_t *cpLengths, int32_t *values,
|
||||
int32_t *prefix) const {
|
||||
BytesTrie bt(characters);
|
||||
int32_t startingTextIndex = utext_getNativeIndex(text);
|
||||
int32_t startingTextIndex = (int32_t)utext_getNativeIndex(text);
|
||||
int32_t wordCount = 0;
|
||||
int32_t codePointsMatched = 0;
|
||||
|
||||
for (UChar32 c = utext_next32(text); c >= 0; c=utext_next32(text)) {
|
||||
UStringTrieResult result = (codePointsMatched == 0) ? bt.first(transform(c)) : bt.next(transform(c));
|
||||
int32_t lengthMatched = utext_getNativeIndex(text) - startingTextIndex;
|
||||
int32_t lengthMatched = (int32_t)utext_getNativeIndex(text) - startingTextIndex;
|
||||
codePointsMatched += 1;
|
||||
if (USTRINGTRIE_HAS_VALUE(result)) {
|
||||
if (wordCount < limit) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2014, International Business Machines
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2008, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2014-2015, International Business Machines Corporation and
|
||||
@ -401,7 +403,8 @@ SimpleFilteredSentenceBreakIterator::next() {
|
||||
|
||||
int32_t
|
||||
SimpleFilteredSentenceBreakIterator::first(void) {
|
||||
return internalNext(fDelegate->first());
|
||||
// Don't suppress a break opportunity at the beginning of text.
|
||||
return fDelegate->first();
|
||||
}
|
||||
|
||||
int32_t
|
||||
@ -415,7 +418,9 @@ SimpleFilteredSentenceBreakIterator::previous(void) {
|
||||
}
|
||||
|
||||
UBool SimpleFilteredSentenceBreakIterator::isBoundary(int32_t offset) {
|
||||
if(!fDelegate->isBoundary(offset)) return false; // no break to suppress
|
||||
if (!fDelegate->isBoundary(offset)) return false; // no break to suppress
|
||||
|
||||
if (fData->fBackwardsTrie.isNull()) return true; // no data = no suppressions
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
resetState(status);
|
||||
@ -476,13 +481,42 @@ SimpleFilteredBreakIteratorBuilder::SimpleFilteredBreakIteratorBuilder(const Loc
|
||||
: fSet(status)
|
||||
{
|
||||
if(U_SUCCESS(status)) {
|
||||
LocalUResourceBundlePointer b(ures_open(U_ICUDATA_BRKITR, fromLocale.getBaseName(), &status));
|
||||
LocalUResourceBundlePointer exceptions(ures_getByKeyWithFallback(b.getAlias(), "exceptions", NULL, &status));
|
||||
LocalUResourceBundlePointer breaks(ures_getByKeyWithFallback(exceptions.getAlias(), "SentenceBreak", NULL, &status));
|
||||
if(U_FAILURE(status)) return; // leaves the builder empty, if you try to use it.
|
||||
UErrorCode subStatus = U_ZERO_ERROR;
|
||||
LocalUResourceBundlePointer b(ures_open(U_ICUDATA_BRKITR, fromLocale.getBaseName(), &subStatus));
|
||||
if (U_FAILURE(subStatus) || (subStatus == U_USING_DEFAULT_WARNING) ) {
|
||||
status = subStatus; // copy the failing status
|
||||
#if FB_DEBUG
|
||||
fprintf(stderr, "open BUNDLE %s : %s, %s\n", fromLocale.getBaseName(), "[exit]", u_errorName(status));
|
||||
#endif
|
||||
return; // leaves the builder empty, if you try to use it.
|
||||
}
|
||||
LocalUResourceBundlePointer exceptions(ures_getByKeyWithFallback(b.getAlias(), "exceptions", NULL, &subStatus));
|
||||
if (U_FAILURE(subStatus) || (subStatus == U_USING_DEFAULT_WARNING) ) {
|
||||
status = subStatus; // copy the failing status
|
||||
#if FB_DEBUG
|
||||
fprintf(stderr, "open EXCEPTIONS %s : %s, %s\n", fromLocale.getBaseName(), "[exit]", u_errorName(status));
|
||||
#endif
|
||||
return; // leaves the builder empty, if you try to use it.
|
||||
}
|
||||
LocalUResourceBundlePointer breaks(ures_getByKeyWithFallback(exceptions.getAlias(), "SentenceBreak", NULL, &subStatus));
|
||||
|
||||
#if FB_DEBUG
|
||||
{
|
||||
UErrorCode subsub = subStatus;
|
||||
fprintf(stderr, "open SentenceBreak %s => %s, %s\n", fromLocale.getBaseName(), ures_getLocale(breaks.getAlias(), &subsub), u_errorName(subStatus));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (U_FAILURE(subStatus) || (subStatus == U_USING_DEFAULT_WARNING) ) {
|
||||
status = subStatus; // copy the failing status
|
||||
#if FB_DEBUG
|
||||
fprintf(stderr, "open %s : %s, %s\n", fromLocale.getBaseName(), "[exit]", u_errorName(status));
|
||||
#endif
|
||||
return; // leaves the builder empty, if you try to use it.
|
||||
}
|
||||
|
||||
LocalUResourceBundlePointer strs;
|
||||
UErrorCode subStatus = status;
|
||||
subStatus = status; // Pick up inherited warning status now
|
||||
do {
|
||||
strs.adoptInstead(ures_getNextResource(breaks.getAlias(), strs.orphan(), &subStatus));
|
||||
if(strs.isValid() && U_SUCCESS(subStatus)) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 1997-2014, International Business Machines
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
|
@ -1,7 +1,9 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2013-2014, International Business Machines
|
||||
* Copyright (C) 2013-2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
@ -15,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "unicode/listformatter.h"
|
||||
#include "simplepatternformatter.h"
|
||||
#include "unicode/simpleformatter.h"
|
||||
#include "mutex.h"
|
||||
#include "hash.h"
|
||||
#include "cstring.h"
|
||||
@ -27,26 +29,27 @@
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
struct ListFormatInternal : public UMemory {
|
||||
SimplePatternFormatter twoPattern;
|
||||
SimplePatternFormatter startPattern;
|
||||
SimplePatternFormatter middlePattern;
|
||||
SimplePatternFormatter endPattern;
|
||||
SimpleFormatter twoPattern;
|
||||
SimpleFormatter startPattern;
|
||||
SimpleFormatter middlePattern;
|
||||
SimpleFormatter endPattern;
|
||||
|
||||
ListFormatInternal(
|
||||
const UnicodeString& two,
|
||||
const UnicodeString& start,
|
||||
const UnicodeString& middle,
|
||||
const UnicodeString& end) :
|
||||
twoPattern(two),
|
||||
startPattern(start),
|
||||
middlePattern(middle),
|
||||
endPattern(end) {}
|
||||
const UnicodeString& end,
|
||||
UErrorCode &errorCode) :
|
||||
twoPattern(two, 2, 2, errorCode),
|
||||
startPattern(start, 2, 2, errorCode),
|
||||
middlePattern(middle, 2, 2, errorCode),
|
||||
endPattern(end, 2, 2, errorCode) {}
|
||||
|
||||
ListFormatInternal(const ListFormatData &data) :
|
||||
twoPattern(data.twoPattern),
|
||||
startPattern(data.startPattern),
|
||||
middlePattern(data.middlePattern),
|
||||
endPattern(data.endPattern) { }
|
||||
ListFormatInternal(const ListFormatData &data, UErrorCode &errorCode) :
|
||||
twoPattern(data.twoPattern, errorCode),
|
||||
startPattern(data.startPattern, errorCode),
|
||||
middlePattern(data.middlePattern, errorCode),
|
||||
endPattern(data.endPattern, errorCode) { }
|
||||
|
||||
ListFormatInternal(const ListFormatInternal &other) :
|
||||
twoPattern(other.twoPattern),
|
||||
@ -191,11 +194,15 @@ static ListFormatInternal* loadListFormatInternal(
|
||||
if (U_FAILURE(errorCode)) {
|
||||
return NULL;
|
||||
}
|
||||
ListFormatInternal* result = new ListFormatInternal(two, start, middle, end);
|
||||
ListFormatInternal* result = new ListFormatInternal(two, start, middle, end, errorCode);
|
||||
if (result == NULL) {
|
||||
errorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
if (U_FAILURE(errorCode)) {
|
||||
delete result;
|
||||
return NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -231,8 +238,8 @@ ListFormatter* ListFormatter::createInstance(const Locale& locale, const char *s
|
||||
return p;
|
||||
}
|
||||
|
||||
ListFormatter::ListFormatter(const ListFormatData& listFormatData) {
|
||||
owned = new ListFormatInternal(listFormatData);
|
||||
ListFormatter::ListFormatter(const ListFormatData& listFormatData, UErrorCode &errorCode) {
|
||||
owned = new ListFormatInternal(listFormatData, errorCode);
|
||||
data = owned;
|
||||
}
|
||||
|
||||
@ -252,7 +259,7 @@ ListFormatter::~ListFormatter() {
|
||||
* according to pat. Any previous value of result gets replaced.
|
||||
*/
|
||||
static void joinStringsAndReplace(
|
||||
const SimplePatternFormatter& pat,
|
||||
const SimpleFormatter& pat,
|
||||
const UnicodeString& first,
|
||||
const UnicodeString& second,
|
||||
UnicodeString &result,
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2014, International Business Machines
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
***************************************************************************
|
||||
* Copyright (C) 2006 International Business Machines Corporation *
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2004-2014, International Business Machines
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2004-2014, International Business Machines
|
||||
|
@ -1,7 +1,9 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1997-2013, International Business Machines
|
||||
* Copyright (C) 1997-2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
@ -638,7 +640,7 @@ uloc_getDisplayName(const char *locale,
|
||||
break;
|
||||
case 3:
|
||||
kenum = uloc_openKeywords(locale, pErrorCode);
|
||||
/* fall through */
|
||||
U_FALLTHROUGH;
|
||||
default: {
|
||||
const char* kw=uenum_next(kenum, &len, pErrorCode);
|
||||
if (kw == NULL) {
|
||||
@ -852,7 +854,7 @@ uloc_getDisplayKeywordValue( const char* locale,
|
||||
/* now copy the dispName over if not NULL */
|
||||
if(dispName != NULL){
|
||||
if(dispNameLen <= destCapacity){
|
||||
uprv_memcpy(dest, dispName, dispNameLen * U_SIZEOF_UCHAR);
|
||||
u_memcpy(dest, dispName, dispNameLen);
|
||||
return u_terminateUChars(dest, destCapacity, dispNameLen, status);
|
||||
}else{
|
||||
*status = U_BUFFER_OVERFLOW_ERROR;
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010-2014, International Business Machines Corporation and
|
||||
* Copyright (C) 2010-2016, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -10,11 +12,11 @@
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/locdspnm.h"
|
||||
#include "unicode/msgfmt.h"
|
||||
#include "unicode/simpleformatter.h"
|
||||
#include "unicode/ures.h"
|
||||
#include "unicode/udisplaycontext.h"
|
||||
#include "unicode/udisplaycontext.h"
|
||||
#include "unicode/brkiter.h"
|
||||
|
||||
#include "unicode/ucurr.h"
|
||||
#include "cmemory.h"
|
||||
#include "cstring.h"
|
||||
#include "mutex.h"
|
||||
@ -274,11 +276,15 @@ class LocaleDisplayNamesImpl : public LocaleDisplayNames {
|
||||
UDialectHandling dialectHandling;
|
||||
ICUDataTable langData;
|
||||
ICUDataTable regionData;
|
||||
MessageFormat *separatorFormat;
|
||||
MessageFormat *format;
|
||||
MessageFormat *keyTypeFormat;
|
||||
SimpleFormatter separatorFormat;
|
||||
SimpleFormatter format;
|
||||
SimpleFormatter keyTypeFormat;
|
||||
UDisplayContext capitalizationContext;
|
||||
BreakIterator* capitalizationBrkIter;
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
BreakIterator* capitalizationBrkIter;
|
||||
#else
|
||||
UObject* capitalizationBrkIter;
|
||||
#endif
|
||||
static UMutex capitalizationBrkIterLock;
|
||||
UnicodeString formatOpenParen;
|
||||
UnicodeString formatReplaceOpenParen;
|
||||
@ -334,7 +340,15 @@ private:
|
||||
UnicodeString& result) const;
|
||||
UnicodeString& appendWithSep(UnicodeString& buffer, const UnicodeString& src) const;
|
||||
UnicodeString& adjustForUsageAndContext(CapContextUsage usage, UnicodeString& result) const;
|
||||
UnicodeString& scriptDisplayName(const char* script, UnicodeString& result, UBool skipAdjust) const;
|
||||
UnicodeString& regionDisplayName(const char* region, UnicodeString& result, UBool skipAdjust) const;
|
||||
UnicodeString& variantDisplayName(const char* variant, UnicodeString& result, UBool skipAdjust) const;
|
||||
UnicodeString& keyDisplayName(const char* key, UnicodeString& result, UBool skipAdjust) const;
|
||||
UnicodeString& keyValueDisplayName(const char* key, const char* value,
|
||||
UnicodeString& result, UBool skipAdjust) const;
|
||||
void initialize(void);
|
||||
|
||||
struct CapitalizationContextSink;
|
||||
};
|
||||
|
||||
UMutex LocaleDisplayNamesImpl::capitalizationBrkIterLock = U_MUTEX_INITIALIZER;
|
||||
@ -344,9 +358,6 @@ LocaleDisplayNamesImpl::LocaleDisplayNamesImpl(const Locale& locale,
|
||||
: dialectHandling(dialectHandling)
|
||||
, langData(U_ICUDATA_LANG, locale)
|
||||
, regionData(U_ICUDATA_REGION, locale)
|
||||
, separatorFormat(NULL)
|
||||
, format(NULL)
|
||||
, keyTypeFormat(NULL)
|
||||
, capitalizationContext(UDISPCTX_CAPITALIZATION_NONE)
|
||||
, capitalizationBrkIter(NULL)
|
||||
, nameLength(UDISPCTX_LENGTH_FULL)
|
||||
@ -359,9 +370,6 @@ LocaleDisplayNamesImpl::LocaleDisplayNamesImpl(const Locale& locale,
|
||||
: dialectHandling(ULDN_STANDARD_NAMES)
|
||||
, langData(U_ICUDATA_LANG, locale)
|
||||
, regionData(U_ICUDATA_REGION, locale)
|
||||
, separatorFormat(NULL)
|
||||
, format(NULL)
|
||||
, keyTypeFormat(NULL)
|
||||
, capitalizationContext(UDISPCTX_CAPITALIZATION_NONE)
|
||||
, capitalizationBrkIter(NULL)
|
||||
, nameLength(UDISPCTX_LENGTH_FULL)
|
||||
@ -386,6 +394,54 @@ LocaleDisplayNamesImpl::LocaleDisplayNamesImpl(const Locale& locale,
|
||||
initialize();
|
||||
}
|
||||
|
||||
struct LocaleDisplayNamesImpl::CapitalizationContextSink : public ResourceSink {
|
||||
UBool hasCapitalizationUsage;
|
||||
LocaleDisplayNamesImpl& parent;
|
||||
|
||||
CapitalizationContextSink(LocaleDisplayNamesImpl& _parent)
|
||||
: hasCapitalizationUsage(FALSE), parent(_parent) {}
|
||||
virtual ~CapitalizationContextSink();
|
||||
|
||||
virtual void put(const char *key, ResourceValue &value, UBool /*noFallback*/,
|
||||
UErrorCode &errorCode) {
|
||||
ResourceTable contexts = value.getTable(errorCode);
|
||||
if (U_FAILURE(errorCode)) { return; }
|
||||
for (int i = 0; contexts.getKeyAndValue(i, key, value); ++i) {
|
||||
|
||||
CapContextUsage usageEnum;
|
||||
if (uprv_strcmp(key, "key") == 0) {
|
||||
usageEnum = kCapContextUsageKey;
|
||||
} else if (uprv_strcmp(key, "keyValue") == 0) {
|
||||
usageEnum = kCapContextUsageKeyValue;
|
||||
} else if (uprv_strcmp(key, "languages") == 0) {
|
||||
usageEnum = kCapContextUsageLanguage;
|
||||
} else if (uprv_strcmp(key, "script") == 0) {
|
||||
usageEnum = kCapContextUsageScript;
|
||||
} else if (uprv_strcmp(key, "territory") == 0) {
|
||||
usageEnum = kCapContextUsageTerritory;
|
||||
} else if (uprv_strcmp(key, "variant") == 0) {
|
||||
usageEnum = kCapContextUsageVariant;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
int32_t len = 0;
|
||||
const int32_t* intVector = value.getIntVector(len, errorCode);
|
||||
if (U_FAILURE(errorCode)) { return; }
|
||||
if (len < 2) { continue; }
|
||||
|
||||
int32_t titlecaseInt = (parent.capitalizationContext == UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU) ? intVector[0] : intVector[1];
|
||||
if (titlecaseInt == 0) { continue; }
|
||||
|
||||
parent.fCapitalization[usageEnum] = TRUE;
|
||||
hasCapitalizationUsage = TRUE;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Virtual destructors must be defined out of line.
|
||||
LocaleDisplayNamesImpl::CapitalizationContextSink::~CapitalizationContextSink() {}
|
||||
|
||||
void
|
||||
LocaleDisplayNamesImpl::initialize(void) {
|
||||
LocaleDisplayNamesImpl *nonConstThis = (LocaleDisplayNamesImpl *)this;
|
||||
@ -399,14 +455,14 @@ LocaleDisplayNamesImpl::initialize(void) {
|
||||
sep = UnicodeString("{0}, {1}", -1, US_INV);
|
||||
}
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
separatorFormat = new MessageFormat(sep, status);
|
||||
separatorFormat.applyPatternMinMaxArguments(sep, 2, 2, status);
|
||||
|
||||
UnicodeString pattern;
|
||||
langData.getNoFallback("localeDisplayPattern", "pattern", pattern);
|
||||
if (pattern.isBogus()) {
|
||||
pattern = UnicodeString("{0} ({1})", -1, US_INV);
|
||||
}
|
||||
format = new MessageFormat(pattern, status);
|
||||
format.applyPatternMinMaxArguments(pattern, 2, 2, status);
|
||||
if (pattern.indexOf((UChar)0xFF08) >= 0) {
|
||||
formatOpenParen.setTo((UChar)0xFF08); // fullwidth (
|
||||
formatReplaceOpenParen.setTo((UChar)0xFF3B); // fullwidth [
|
||||
@ -424,62 +480,25 @@ LocaleDisplayNamesImpl::initialize(void) {
|
||||
if (ktPattern.isBogus()) {
|
||||
ktPattern = UnicodeString("{0}={1}", -1, US_INV);
|
||||
}
|
||||
keyTypeFormat = new MessageFormat(ktPattern, status);
|
||||
keyTypeFormat.applyPatternMinMaxArguments(ktPattern, 2, 2, status);
|
||||
|
||||
uprv_memset(fCapitalization, 0, sizeof(fCapitalization));
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
// The following is basically copied from DateFormatSymbols::initializeData
|
||||
typedef struct {
|
||||
const char * usageName;
|
||||
LocaleDisplayNamesImpl::CapContextUsage usageEnum;
|
||||
} ContextUsageNameToEnum;
|
||||
const ContextUsageNameToEnum contextUsageTypeMap[] = {
|
||||
// Entries must be sorted by usageTypeName; entry with NULL name terminates list.
|
||||
{ "key", kCapContextUsageKey },
|
||||
{ "keyValue", kCapContextUsageKeyValue },
|
||||
{ "languages", kCapContextUsageLanguage },
|
||||
{ "script", kCapContextUsageScript },
|
||||
{ "territory", kCapContextUsageTerritory },
|
||||
{ "variant", kCapContextUsageVariant },
|
||||
{ NULL, (CapContextUsage)0 },
|
||||
};
|
||||
// Only get the context data if we need it! This is a const object so we know now...
|
||||
// Also check whether we will need a break iterator (depends on the data)
|
||||
UBool needBrkIter = FALSE;
|
||||
if (capitalizationContext == UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU || capitalizationContext == UDISPCTX_CAPITALIZATION_FOR_STANDALONE) {
|
||||
int32_t len = 0;
|
||||
UResourceBundle *localeBundle = ures_open(NULL, locale.getName(), &status);
|
||||
if (U_SUCCESS(status)) {
|
||||
UResourceBundle *contextTransforms = ures_getByKeyWithFallback(localeBundle, "contextTransforms", NULL, &status);
|
||||
if (U_SUCCESS(status)) {
|
||||
UResourceBundle *contextTransformUsage;
|
||||
while ( (contextTransformUsage = ures_getNextResource(contextTransforms, NULL, &status)) != NULL ) {
|
||||
const int32_t * intVector = ures_getIntVector(contextTransformUsage, &len, &status);
|
||||
if (U_SUCCESS(status) && intVector != NULL && len >= 2) {
|
||||
const char* usageKey = ures_getKey(contextTransformUsage);
|
||||
if (usageKey != NULL) {
|
||||
const ContextUsageNameToEnum * typeMapPtr = contextUsageTypeMap;
|
||||
int32_t compResult = 0;
|
||||
// linear search; list is short and we cannot be sure that bsearch is available
|
||||
while ( typeMapPtr->usageName != NULL && (compResult = uprv_strcmp(usageKey, typeMapPtr->usageName)) > 0 ) {
|
||||
++typeMapPtr;
|
||||
}
|
||||
if (typeMapPtr->usageName != NULL && compResult == 0) {
|
||||
int32_t titlecaseInt = (capitalizationContext == UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU)? intVector[0]: intVector[1];
|
||||
if (titlecaseInt != 0) {
|
||||
fCapitalization[typeMapPtr->usageEnum] = TRUE;;
|
||||
needBrkIter = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
status = U_ZERO_ERROR;
|
||||
ures_close(contextTransformUsage);
|
||||
}
|
||||
ures_close(contextTransforms);
|
||||
}
|
||||
ures_close(localeBundle);
|
||||
LocalUResourceBundlePointer resource(ures_open(NULL, locale.getName(), &status));
|
||||
if (U_FAILURE(status)) { return; }
|
||||
CapitalizationContextSink sink(*this);
|
||||
ures_getAllItemsWithFallback(resource.getAlias(), "contextTransforms", sink, status);
|
||||
if (status == U_MISSING_RESOURCE_ERROR) {
|
||||
// Silently ignore. Not every locale has contextTransforms.
|
||||
status = U_ZERO_ERROR;
|
||||
} else if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
needBrkIter = sink.hasCapitalizationUsage;
|
||||
}
|
||||
// Get a sentence break iterator if we will need it
|
||||
if (needBrkIter || capitalizationContext == UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE) {
|
||||
@ -494,11 +513,10 @@ LocaleDisplayNamesImpl::initialize(void) {
|
||||
}
|
||||
|
||||
LocaleDisplayNamesImpl::~LocaleDisplayNamesImpl() {
|
||||
delete separatorFormat;
|
||||
delete format;
|
||||
delete keyTypeFormat;
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
delete capitalizationBrkIter;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
const Locale&
|
||||
LocaleDisplayNamesImpl::getLocale() const {
|
||||
@ -543,6 +561,10 @@ LocaleDisplayNamesImpl::adjustForUsageAndContext(CapContextUsage usage,
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::localeDisplayName(const Locale& locale,
|
||||
UnicodeString& result) const {
|
||||
if (locale.isBogus()) {
|
||||
result.setToBogus();
|
||||
return result;
|
||||
}
|
||||
UnicodeString resultName;
|
||||
|
||||
const char* lang = locale.getLanguage();
|
||||
@ -593,45 +615,41 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& locale,
|
||||
|
||||
UnicodeString resultRemainder;
|
||||
UnicodeString temp;
|
||||
StringEnumeration *e = NULL;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
if (hasScript) {
|
||||
resultRemainder.append(scriptDisplayName(script, temp));
|
||||
resultRemainder.append(scriptDisplayName(script, temp, TRUE));
|
||||
}
|
||||
if (hasCountry) {
|
||||
appendWithSep(resultRemainder, regionDisplayName(country, temp));
|
||||
appendWithSep(resultRemainder, regionDisplayName(country, temp, TRUE));
|
||||
}
|
||||
if (hasVariant) {
|
||||
appendWithSep(resultRemainder, variantDisplayName(variant, temp));
|
||||
appendWithSep(resultRemainder, variantDisplayName(variant, temp, TRUE));
|
||||
}
|
||||
resultRemainder.findAndReplace(formatOpenParen, formatReplaceOpenParen);
|
||||
resultRemainder.findAndReplace(formatCloseParen, formatReplaceCloseParen);
|
||||
|
||||
e = locale.createKeywords(status);
|
||||
if (e && U_SUCCESS(status)) {
|
||||
LocalPointer<StringEnumeration> e(locale.createKeywords(status));
|
||||
if (e.isValid() && U_SUCCESS(status)) {
|
||||
UnicodeString temp2;
|
||||
char value[ULOC_KEYWORD_AND_VALUES_CAPACITY]; // sigh, no ULOC_VALUE_CAPACITY
|
||||
const char* key;
|
||||
while ((key = e->next((int32_t *)0, status)) != NULL) {
|
||||
locale.getKeywordValue(key, value, ULOC_KEYWORD_AND_VALUES_CAPACITY, status);
|
||||
keyDisplayName(key, temp);
|
||||
if (U_FAILURE(status)) {
|
||||
return result;
|
||||
}
|
||||
keyDisplayName(key, temp, TRUE);
|
||||
temp.findAndReplace(formatOpenParen, formatReplaceOpenParen);
|
||||
temp.findAndReplace(formatCloseParen, formatReplaceCloseParen);
|
||||
keyValueDisplayName(key, value, temp2);
|
||||
keyValueDisplayName(key, value, temp2, TRUE);
|
||||
temp2.findAndReplace(formatOpenParen, formatReplaceOpenParen);
|
||||
temp2.findAndReplace(formatCloseParen, formatReplaceCloseParen);
|
||||
if (temp2 != UnicodeString(value, -1, US_INV)) {
|
||||
appendWithSep(resultRemainder, temp2);
|
||||
} else if (temp != UnicodeString(key, -1, US_INV)) {
|
||||
UnicodeString temp3;
|
||||
Formattable data[] = {
|
||||
temp,
|
||||
temp2
|
||||
};
|
||||
FieldPosition fpos;
|
||||
status = U_ZERO_ERROR;
|
||||
keyTypeFormat->format(data, 2, temp3, fpos, status);
|
||||
keyTypeFormat.format(temp, temp2, temp3, status);
|
||||
appendWithSep(resultRemainder, temp3);
|
||||
} else {
|
||||
appendWithSep(resultRemainder, temp)
|
||||
@ -639,17 +657,10 @@ LocaleDisplayNamesImpl::localeDisplayName(const Locale& locale,
|
||||
.append(temp2);
|
||||
}
|
||||
}
|
||||
delete e;
|
||||
}
|
||||
|
||||
if (!resultRemainder.isEmpty()) {
|
||||
Formattable data[] = {
|
||||
resultName,
|
||||
resultRemainder
|
||||
};
|
||||
FieldPosition fpos;
|
||||
status = U_ZERO_ERROR;
|
||||
format->format(data, 2, result, fpos, status);
|
||||
format.format(resultName, resultRemainder, result.remove(), status);
|
||||
return adjustForUsageAndContext(kCapContextUsageLanguage, result);
|
||||
}
|
||||
|
||||
@ -662,17 +673,9 @@ LocaleDisplayNamesImpl::appendWithSep(UnicodeString& buffer, const UnicodeString
|
||||
if (buffer.isEmpty()) {
|
||||
buffer.setTo(src);
|
||||
} else {
|
||||
UnicodeString combined;
|
||||
Formattable data[] = {
|
||||
buffer,
|
||||
src
|
||||
};
|
||||
FieldPosition fpos;
|
||||
const UnicodeString *values[2] = { &buffer, &src };
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
separatorFormat->format(data, 2, combined, fpos, status);
|
||||
if (U_SUCCESS(status)) {
|
||||
buffer.setTo(combined);
|
||||
}
|
||||
separatorFormat.formatAndReplace(values, 2, buffer, NULL, 0, status);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
@ -714,56 +717,86 @@ LocaleDisplayNamesImpl::languageDisplayName(const char* lang,
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::scriptDisplayName(const char* script,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result,
|
||||
UBool skipAdjust) const {
|
||||
if (nameLength == UDISPCTX_LENGTH_SHORT) {
|
||||
langData.get("Scripts%short", script, result);
|
||||
if (!result.isBogus()) {
|
||||
return adjustForUsageAndContext(kCapContextUsageScript, result);
|
||||
return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageScript, result);
|
||||
}
|
||||
}
|
||||
langData.get("Scripts", script, result);
|
||||
return adjustForUsageAndContext(kCapContextUsageScript, result);
|
||||
return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageScript, result);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::scriptDisplayName(const char* script,
|
||||
UnicodeString& result) const {
|
||||
return scriptDisplayName(script, result, FALSE);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::scriptDisplayName(UScriptCode scriptCode,
|
||||
UnicodeString& result) const {
|
||||
return scriptDisplayName(uscript_getName(scriptCode), result);
|
||||
return scriptDisplayName(uscript_getName(scriptCode), result, FALSE);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::regionDisplayName(const char* region,
|
||||
UnicodeString& result,
|
||||
UBool skipAdjust) const {
|
||||
if (nameLength == UDISPCTX_LENGTH_SHORT) {
|
||||
regionData.get("Countries%short", region, result);
|
||||
if (!result.isBogus()) {
|
||||
return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageTerritory, result);
|
||||
}
|
||||
}
|
||||
regionData.get("Countries", region, result);
|
||||
return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageTerritory, result);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::regionDisplayName(const char* region,
|
||||
UnicodeString& result) const {
|
||||
if (nameLength == UDISPCTX_LENGTH_SHORT) {
|
||||
regionData.get("Countries%short", region, result);
|
||||
if (!result.isBogus()) {
|
||||
return adjustForUsageAndContext(kCapContextUsageTerritory, result);
|
||||
}
|
||||
}
|
||||
regionData.get("Countries", region, result);
|
||||
return adjustForUsageAndContext(kCapContextUsageTerritory, result);
|
||||
return regionDisplayName(region, result, FALSE);
|
||||
}
|
||||
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::variantDisplayName(const char* variant,
|
||||
UnicodeString& result,
|
||||
UBool skipAdjust) const {
|
||||
// don't have a resource for short variant names
|
||||
langData.get("Variants", variant, result);
|
||||
return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageVariant, result);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::variantDisplayName(const char* variant,
|
||||
UnicodeString& result) const {
|
||||
// don't have a resource for short variant names
|
||||
langData.get("Variants", variant, result);
|
||||
return adjustForUsageAndContext(kCapContextUsageVariant, result);
|
||||
return variantDisplayName(variant, result, FALSE);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::keyDisplayName(const char* key,
|
||||
UnicodeString& result,
|
||||
UBool skipAdjust) const {
|
||||
// don't have a resource for short key names
|
||||
langData.get("Keys", key, result);
|
||||
return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageKey, result);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::keyDisplayName(const char* key,
|
||||
UnicodeString& result) const {
|
||||
// don't have a resource for short key names
|
||||
langData.get("Keys", key, result);
|
||||
return adjustForUsageAndContext(kCapContextUsageKey, result);
|
||||
return keyDisplayName(key, result, FALSE);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::keyValueDisplayName(const char* key,
|
||||
const char* value,
|
||||
UnicodeString& result) const {
|
||||
UnicodeString& result,
|
||||
UBool skipAdjust) const {
|
||||
if (uprv_strcmp(key, "currency") == 0) {
|
||||
// ICU4C does not have ICU4J CurrencyDisplayInfo equivalent for now.
|
||||
UErrorCode sts = U_ZERO_ERROR;
|
||||
@ -778,17 +811,24 @@ LocaleDisplayNamesImpl::keyValueDisplayName(const char* key,
|
||||
return result;
|
||||
}
|
||||
result.setTo(currencyName, len);
|
||||
return adjustForUsageAndContext(kCapContextUsageKeyValue, result);
|
||||
return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageKeyValue, result);
|
||||
}
|
||||
|
||||
if (nameLength == UDISPCTX_LENGTH_SHORT) {
|
||||
langData.get("Types%short", key, value, result);
|
||||
if (!result.isBogus()) {
|
||||
return adjustForUsageAndContext(kCapContextUsageKeyValue, result);
|
||||
return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageKeyValue, result);
|
||||
}
|
||||
}
|
||||
langData.get("Types", key, value, result);
|
||||
return adjustForUsageAndContext(kCapContextUsageKeyValue, result);
|
||||
return skipAdjust? result: adjustForUsageAndContext(kCapContextUsageKeyValue, result);
|
||||
}
|
||||
|
||||
UnicodeString&
|
||||
LocaleDisplayNamesImpl::keyValueDisplayName(const char* key,
|
||||
const char* value,
|
||||
UnicodeString& result) const {
|
||||
return keyValueDisplayName(key, value, result, FALSE);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -887,6 +927,10 @@ uldn_localeDisplayName(const ULocaleDisplayNames *ldn,
|
||||
}
|
||||
UnicodeString temp(result, 0, maxResultSize);
|
||||
((const LocaleDisplayNames *)ldn)->localeDisplayName(locale, temp);
|
||||
if (temp.isBogus()) {
|
||||
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
return temp.extract(result, maxResultSize, *pErrorCode);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1997-2015, International Business Machines
|
||||
* Copyright (C) 1997-2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
*
|
||||
@ -42,6 +44,7 @@
|
||||
#include "uhash.h"
|
||||
#include "ucln_cmn.h"
|
||||
#include "ustr_imp.h"
|
||||
#include "charstr.h"
|
||||
|
||||
U_CDECL_BEGIN
|
||||
static UBool U_CALLCONV locale_cleanup(void);
|
||||
@ -57,6 +60,12 @@ static UMutex gDefaultLocaleMutex = U_MUTEX_INITIALIZER;
|
||||
static UHashtable *gDefaultLocalesHashT = NULL;
|
||||
static Locale *gDefaultLocale = NULL;
|
||||
|
||||
/**
|
||||
* \def ULOC_STRING_LIMIT
|
||||
* strings beyond this value crash in CharString
|
||||
*/
|
||||
#define ULOC_STRING_LIMIT 357913941
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
typedef enum ELocalePos {
|
||||
@ -283,13 +292,12 @@ Locale::Locale( const char * newLanguage,
|
||||
}
|
||||
else
|
||||
{
|
||||
MaybeStackArray<char, ULOC_FULLNAME_CAPACITY> togo;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t size = 0;
|
||||
int32_t lsize = 0;
|
||||
int32_t csize = 0;
|
||||
int32_t vsize = 0;
|
||||
int32_t ksize = 0;
|
||||
char *p;
|
||||
|
||||
// Calculate the size of the resulting string.
|
||||
|
||||
@ -297,13 +305,23 @@ Locale::Locale( const char * newLanguage,
|
||||
if ( newLanguage != NULL )
|
||||
{
|
||||
lsize = (int32_t)uprv_strlen(newLanguage);
|
||||
if ( lsize < 0 || lsize > ULOC_STRING_LIMIT ) { // int32 wrap
|
||||
setToBogus();
|
||||
return;
|
||||
}
|
||||
size = lsize;
|
||||
}
|
||||
|
||||
CharString togo(newLanguage, lsize, status); // start with newLanguage
|
||||
|
||||
// _Country
|
||||
if ( newCountry != NULL )
|
||||
{
|
||||
csize = (int32_t)uprv_strlen(newCountry);
|
||||
if ( csize < 0 || csize > ULOC_STRING_LIMIT ) { // int32 wrap
|
||||
setToBogus();
|
||||
return;
|
||||
}
|
||||
size += csize;
|
||||
}
|
||||
|
||||
@ -318,6 +336,10 @@ Locale::Locale( const char * newLanguage,
|
||||
|
||||
// remove trailing _'s
|
||||
vsize = (int32_t)uprv_strlen(newVariant);
|
||||
if ( vsize < 0 || vsize > ULOC_STRING_LIMIT ) { // int32 wrap
|
||||
setToBogus();
|
||||
return;
|
||||
}
|
||||
while( (vsize>1) && (newVariant[vsize-1] == SEP_CHAR) )
|
||||
{
|
||||
vsize--;
|
||||
@ -342,70 +364,56 @@ Locale::Locale( const char * newLanguage,
|
||||
if ( newKeywords != NULL)
|
||||
{
|
||||
ksize = (int32_t)uprv_strlen(newKeywords);
|
||||
if ( ksize < 0 || ksize > ULOC_STRING_LIMIT ) {
|
||||
setToBogus();
|
||||
return;
|
||||
}
|
||||
size += ksize + 1;
|
||||
}
|
||||
|
||||
|
||||
// NOW we have the full locale string..
|
||||
|
||||
/*if the whole string is longer than our internal limit, we need
|
||||
to go to the heap for temporary buffers*/
|
||||
if (size >= togo.getCapacity())
|
||||
{
|
||||
// If togo_heap could not be created, initialize with default settings.
|
||||
if (togo.resize(size+1) == NULL) {
|
||||
init(NULL, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
togo[0] = 0;
|
||||
|
||||
// Now, copy it back.
|
||||
p = togo.getAlias();
|
||||
if ( lsize != 0 )
|
||||
{
|
||||
uprv_strcpy(p, newLanguage);
|
||||
p += lsize;
|
||||
}
|
||||
|
||||
// newLanguage is already copied
|
||||
|
||||
if ( ( vsize != 0 ) || (csize != 0) ) // at least: __v
|
||||
{ // ^
|
||||
*p++ = SEP_CHAR;
|
||||
togo.append(SEP_CHAR, status);
|
||||
}
|
||||
|
||||
if ( csize != 0 )
|
||||
{
|
||||
uprv_strcpy(p, newCountry);
|
||||
p += csize;
|
||||
togo.append(newCountry, status);
|
||||
}
|
||||
|
||||
if ( vsize != 0)
|
||||
{
|
||||
*p++ = SEP_CHAR; // at least: __v
|
||||
|
||||
uprv_strncpy(p, newVariant, vsize); // Must use strncpy because
|
||||
p += vsize; // of trimming (above).
|
||||
*p = 0; // terminate
|
||||
togo.append(SEP_CHAR, status)
|
||||
.append(newVariant, vsize, status);
|
||||
}
|
||||
|
||||
if ( ksize != 0)
|
||||
{
|
||||
if (uprv_strchr(newKeywords, '=')) {
|
||||
*p++ = '@'; /* keyword parsing */
|
||||
togo.append('@', status); /* keyword parsing */
|
||||
}
|
||||
else {
|
||||
*p++ = '_'; /* Variant parsing with a script */
|
||||
togo.append('_', status); /* Variant parsing with a script */
|
||||
if ( vsize == 0) {
|
||||
*p++ = '_'; /* No country found */
|
||||
togo.append('_', status); /* No country found */
|
||||
}
|
||||
}
|
||||
uprv_strcpy(p, newKeywords);
|
||||
p += ksize;
|
||||
togo.append(newKeywords, status);
|
||||
}
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
// Something went wrong with appending, etc.
|
||||
setToBogus();
|
||||
return;
|
||||
}
|
||||
// Parse it, because for example 'language' might really be a complete
|
||||
// string.
|
||||
init(togo.getAlias(), FALSE);
|
||||
init(togo.data(), FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -536,7 +544,7 @@ Locale& Locale::init(const char* localeID, UBool canonicalize)
|
||||
/* after uloc_getName/canonicalize() we know that only '_' are separators */
|
||||
separator = field[0] = fullName;
|
||||
fieldIdx = 1;
|
||||
while ((separator = uprv_strchr(field[fieldIdx-1], SEP_CHAR)) && fieldIdx < (int32_t)(sizeof(field)/sizeof(field[0]))-1) {
|
||||
while ((separator = uprv_strchr(field[fieldIdx-1], SEP_CHAR)) && fieldIdx < UPRV_LENGTHOF(field)-1) {
|
||||
field[fieldIdx] = separator + 1;
|
||||
fieldLen[fieldIdx-1] = (int32_t)(separator - field[fieldIdx-1]);
|
||||
fieldIdx++;
|
||||
@ -662,6 +670,7 @@ Locale::setToBogus() {
|
||||
*script = 0;
|
||||
*country = 0;
|
||||
fIsBogus = TRUE;
|
||||
variantBegin = 0;
|
||||
}
|
||||
|
||||
const Locale& U_EXPORT2
|
||||
|
@ -1,7 +1,9 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1997-2014, International Business Machines
|
||||
* Copyright (C) 1997-2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
@ -1331,3 +1333,53 @@ Locale::isRightToLeft() const {
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
// The following must at least allow for rg key value (6) plus terminator (1).
|
||||
#define ULOC_RG_BUFLEN 8
|
||||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
ulocimp_getRegionForSupplementalData(const char *localeID, UBool inferRegion,
|
||||
char *region, int32_t regionCapacity, UErrorCode* status) {
|
||||
if (U_FAILURE(*status)) {
|
||||
return 0;
|
||||
}
|
||||
char rgBuf[ULOC_RG_BUFLEN];
|
||||
UErrorCode rgStatus = U_ZERO_ERROR;
|
||||
|
||||
// First check for rg keyword value
|
||||
int32_t rgLen = uloc_getKeywordValue(localeID, "rg", rgBuf, ULOC_RG_BUFLEN, &rgStatus);
|
||||
if (U_FAILURE(rgStatus) || rgLen != 6) {
|
||||
rgLen = 0;
|
||||
} else {
|
||||
// rgBuf guaranteed to be zero terminated here, with text len 6
|
||||
char *rgPtr = rgBuf;
|
||||
for (; *rgPtr!= 0; rgPtr++) {
|
||||
*rgPtr = uprv_toupper(*rgPtr);
|
||||
}
|
||||
rgLen = (uprv_strcmp(rgBuf+2, "ZZZZ") == 0)? 2: 0;
|
||||
}
|
||||
|
||||
if (rgLen == 0) {
|
||||
// No valid rg keyword value, try for unicode_region_subtag
|
||||
rgLen = uloc_getCountry(localeID, rgBuf, ULOC_RG_BUFLEN, status);
|
||||
if (U_FAILURE(*status)) {
|
||||
rgLen = 0;
|
||||
} else if (rgLen == 0 && inferRegion) {
|
||||
// no unicode_region_subtag but inferRegion TRUE, try likely subtags
|
||||
char locBuf[ULOC_FULLNAME_CAPACITY];
|
||||
rgStatus = U_ZERO_ERROR;
|
||||
(void)uloc_addLikelySubtags(localeID, locBuf, ULOC_FULLNAME_CAPACITY, &rgStatus);
|
||||
if (U_SUCCESS(rgStatus)) {
|
||||
rgLen = uloc_getCountry(locBuf, rgBuf, ULOC_RG_BUFLEN, status);
|
||||
if (U_FAILURE(*status)) {
|
||||
rgLen = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rgBuf[rgLen] = 0;
|
||||
uprv_strncpy(region, rgBuf, regionCapacity);
|
||||
return u_terminateChars(region, regionCapacity, rgLen, status);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1996-2014, International Business Machines
|
||||
* Copyright (C) 1996-2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
*
|
||||
@ -113,7 +115,7 @@ static const ILcidPosixElement locmap_ ## id [] =
|
||||
* @param _posixID the full POSIX ID for this entry.
|
||||
*/
|
||||
#define ILCID_POSIX_MAP(_posixID) \
|
||||
{sizeof(locmap_ ## _posixID)/sizeof(ILcidPosixElement), locmap_ ## _posixID}
|
||||
{UPRV_LENGTHOF(locmap_ ## _posixID), locmap_ ## _posixID}
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////
|
||||
@ -196,7 +198,8 @@ ILCID_POSIX_SUBTABLE(bn) {
|
||||
ILCID_POSIX_SUBTABLE(bo) {
|
||||
{0x51, "bo"},
|
||||
{0x0851, "bo_BT"},
|
||||
{0x0451, "bo_CN"}
|
||||
{0x0451, "bo_CN"},
|
||||
{0x0c51, "dz_BT"}
|
||||
};
|
||||
|
||||
ILCID_POSIX_ELEMENT_ARRAY(0x047e, br, br_FR)
|
||||
@ -212,11 +215,8 @@ ILCID_POSIX_ELEMENT_ARRAY(0x045c, chr,chr_US)
|
||||
|
||||
ILCID_POSIX_SUBTABLE(ckb) {
|
||||
{0x92, "ckb"},
|
||||
{0x92, "ku"},
|
||||
{0x7c92, "ckb_Arab"},
|
||||
{0x7c92, "ku_Arab"},
|
||||
{0x0492, "ckb_Arab_IQ"},
|
||||
{0x0492, "ku_Arab_IQ"}
|
||||
{0x0492, "ckb_Arab_IQ"}
|
||||
};
|
||||
|
||||
/* Declared as cs_CZ to get around compiler errors on z/OS, which defines cs as a function */
|
||||
@ -279,6 +279,7 @@ ILCID_POSIX_SUBTABLE(es) {
|
||||
{0x340a, "es_CL"},
|
||||
{0x240a, "es_CO"},
|
||||
{0x140a, "es_CR"},
|
||||
{0x5c0a, "es_CU"},
|
||||
{0x1c0a, "es_DO"},
|
||||
{0x300a, "es_EC"},
|
||||
{0x0c0a, "es_ES"}, /*Modern sort.*/
|
||||
@ -318,7 +319,8 @@ ILCID_POSIX_SUBTABLE(fa_AF) {
|
||||
ILCID_POSIX_SUBTABLE(ff) {
|
||||
{0x67, "ff"},
|
||||
{0x7c67, "ff_Latn"},
|
||||
{0x0867, "ff_Latn_SN"}
|
||||
{0x0867, "ff_Latn_SN"},
|
||||
{0x0467, "ff_NG"}
|
||||
};
|
||||
|
||||
ILCID_POSIX_ELEMENT_ARRAY(0x040b, fi, fi_FI)
|
||||
@ -552,7 +554,35 @@ ILCID_POSIX_SUBTABLE(qu) {
|
||||
{0x0C6b, "quz_PE"}
|
||||
};
|
||||
|
||||
ILCID_POSIX_ELEMENT_ARRAY(0x0486, qut, qut_GT) /* qut is an ISO-639-3 code */
|
||||
ILCID_POSIX_SUBTABLE(quc) {
|
||||
{0x93, "quc"},
|
||||
{0x0493, "quc_CO"},
|
||||
/*
|
||||
"quc_Latn_GT" is an exceptional case. Language ID of "quc"
|
||||
is 0x93, but LCID of "quc_Latn_GT" is 0x486, which should be
|
||||
under the group of "qut". "qut" is a retired ISO 639-3 language
|
||||
code for West Central Quiche, and merged to "quc".
|
||||
It looks Windows previously reserved "qut" for K'iche', but,
|
||||
decided to use "quc" when adding a locale for K'iche' (Guatemala).
|
||||
|
||||
This data structure used here assumes language ID bits in
|
||||
LCID is unique for alphabetic language code. But this is not true
|
||||
for "quc_Latn_GT". If we don't have the data below, LCID look up
|
||||
by alphabetic locale ID (POSIX) will fail. The same entry is found
|
||||
under "qut" below, which is required for reverse look up.
|
||||
*/
|
||||
{0x0486, "quc_Latn_GT"}
|
||||
};
|
||||
|
||||
ILCID_POSIX_SUBTABLE(qut) {
|
||||
{0x86, "qut"},
|
||||
{0x0486, "qut_GT"},
|
||||
/*
|
||||
See the note in "quc" above.
|
||||
*/
|
||||
{0x0486, "quc_Latn_GT"}
|
||||
};
|
||||
|
||||
ILCID_POSIX_ELEMENT_ARRAY(0x0417, rm, rm_CH)
|
||||
|
||||
ILCID_POSIX_SUBTABLE(ro) {
|
||||
@ -578,6 +608,7 @@ ILCID_POSIX_ELEMENT_ARRAY(0x0485, sah,sah_RU)
|
||||
ILCID_POSIX_SUBTABLE(sd) {
|
||||
{0x59, "sd"},
|
||||
{0x0459, "sd_IN"},
|
||||
{0x0459, "sd_Deva_IN"},
|
||||
{0x0859, "sd_PK"}
|
||||
};
|
||||
|
||||
@ -660,6 +691,7 @@ ILCID_POSIX_SUBTABLE(tzm) {
|
||||
{0x7c5f, "tzm_Latn"},
|
||||
{0x085f, "tzm_Latn_DZ"},
|
||||
{0x105f, "tzm_Tfng_MA"},
|
||||
{0x045f, "tzm_Arab_MA"},
|
||||
{0x045f, "tmz"}
|
||||
};
|
||||
|
||||
@ -828,6 +860,7 @@ static const ILcidPosixMap gPosixIDmap[] = {
|
||||
ILCID_POSIX_MAP(ps), /* ps Pashto 0x63 */
|
||||
ILCID_POSIX_MAP(pt), /* pt Portuguese 0x16 */
|
||||
ILCID_POSIX_MAP(qu), /* qu Quechua 0x6B */
|
||||
ILCID_POSIX_MAP(quc), /* quc K'iche 0x93 */
|
||||
ILCID_POSIX_MAP(qut), /* qut K'iche 0x86 */
|
||||
ILCID_POSIX_MAP(rm), /* rm Raeto-Romance/Romansh 0x17 */
|
||||
ILCID_POSIX_MAP(ro), /* ro Romanian 0x18 */
|
||||
@ -874,7 +907,7 @@ static const ILcidPosixMap gPosixIDmap[] = {
|
||||
ILCID_POSIX_MAP(zu), /* zu Zulu 0x35 */
|
||||
};
|
||||
|
||||
static const uint32_t gLocaleCount = sizeof(gPosixIDmap)/sizeof(ILcidPosixMap);
|
||||
static const uint32_t gLocaleCount = UPRV_LENGTHOF(gPosixIDmap);
|
||||
|
||||
/**
|
||||
* Do not call this function. It is called by hostID.
|
||||
@ -985,33 +1018,40 @@ uprv_convertToPosix(uint32_t hostid, char *posixID, int32_t posixIDCapacity, UEr
|
||||
const char *pPosixID = NULL;
|
||||
|
||||
#ifdef USE_WINDOWS_LOCALE_API
|
||||
int32_t tmpLen = 0;
|
||||
char locName[157]; /* ULOC_FULLNAME_CAPACITY */
|
||||
// Note: Windows primary lang ID 0x92 in LCID is used for Central Kurdish and
|
||||
// GetLocaleInfo() maps such LCID to "ku". However, CLDR uses "ku" for
|
||||
// Northern Kurdish and "ckb" for Central Kurdish. For this reason, we cannot
|
||||
// use the Windows API to resolve locale ID for this specific case.
|
||||
if (hostid & 0x3FF != 0x92) {
|
||||
int32_t tmpLen = 0;
|
||||
char locName[157]; /* ULOC_FULLNAME_CAPACITY */
|
||||
|
||||
tmpLen = GetLocaleInfoA(hostid, LOCALE_SNAME, (LPSTR)locName, sizeof(locName)/sizeof(locName[0]));
|
||||
if (tmpLen > 1) {
|
||||
/* Windows locale name may contain sorting variant, such as "es-ES_tradnl".
|
||||
In such case, we need special mapping data found in the hardcoded table
|
||||
in this source file. */
|
||||
char *p = uprv_strchr(locName, '_');
|
||||
if (p) {
|
||||
/* Keep the base locale, without variant */
|
||||
*p = 0;
|
||||
tmpLen = uprv_strlen(locName);
|
||||
} else {
|
||||
/* No hardcoded table lookup necessary */
|
||||
bLookup = FALSE;
|
||||
}
|
||||
/* Change the tag separator from '-' to '_' */
|
||||
p = locName;
|
||||
while (*p) {
|
||||
if (*p == '-') {
|
||||
*p = '_';
|
||||
tmpLen = GetLocaleInfoA(hostid, LOCALE_SNAME, (LPSTR)locName, UPRV_LENGTHOF(locName));
|
||||
if (tmpLen > 1) {
|
||||
/* Windows locale name may contain sorting variant, such as "es-ES_tradnl".
|
||||
In such case, we need special mapping data found in the hardcoded table
|
||||
in this source file. */
|
||||
char *p = uprv_strchr(locName, '_');
|
||||
if (p) {
|
||||
/* Keep the base locale, without variant */
|
||||
*p = 0;
|
||||
tmpLen = uprv_strlen(locName);
|
||||
}
|
||||
p++;
|
||||
else {
|
||||
/* No hardcoded table lookup necessary */
|
||||
bLookup = FALSE;
|
||||
}
|
||||
/* Change the tag separator from '-' to '_' */
|
||||
p = locName;
|
||||
while (*p) {
|
||||
if (*p == '-') {
|
||||
*p = '_';
|
||||
}
|
||||
p++;
|
||||
}
|
||||
FIX_LANGUAGE_ID_TAG(locName, tmpLen);
|
||||
pPosixID = locName;
|
||||
}
|
||||
FIX_LANGUAGE_ID_TAG(locName, tmpLen);
|
||||
pPosixID = locName;
|
||||
}
|
||||
#endif
|
||||
if (bLookup) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2014, International Business Machines Corporation and
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2005, International Business Machines Corporation and *
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011-2012, International Business Machines
|
||||
@ -114,7 +116,7 @@ MessagePatternList<T, stackCapacity>::copyFrom(
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
uprv_memcpy(a.getAlias(), other.a.getAlias(), length*sizeof(T));
|
||||
uprv_memcpy(a.getAlias(), other.a.getAlias(), (size_t)length*sizeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Copyright (c) 2003-2010 International Business Machines
|
||||
// Corporation and others. All Rights Reserved.
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2014, International Business Machines
|
||||
|
@ -1,7 +1,9 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2014, International Business Machines
|
||||
* Copyright (C) 2009-2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
@ -31,6 +33,7 @@
|
||||
using icu::Normalizer2Impl;
|
||||
|
||||
// NFC/NFD data machine-generated by gennorm2 --csource
|
||||
#define INCLUDED_FROM_NORMALIZER2_CPP
|
||||
#include "norm2_nfc_data.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*************************************************************************
|
||||
* COPYRIGHT:
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 2003-2003, International Business Machines
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
* Copyright (C) 2015, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 2015, International Business Machines Corporation and
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2002-2014, International Business Machines
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2002-2011, International Business Machines
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
@ -218,7 +220,7 @@ upvec_setValue(UPropsVectors *pv,
|
||||
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
uprv_memcpy(newVectors, pv->v, rows*columns*4);
|
||||
uprv_memcpy(newVectors, pv->v, (size_t)rows*columns*4);
|
||||
firstRow=newVectors+(firstRow-pv->v);
|
||||
lastRow=newVectors+(lastRow-pv->v);
|
||||
uprv_free(pv->v);
|
||||
@ -240,7 +242,7 @@ upvec_setValue(UPropsVectors *pv,
|
||||
if(splitFirstRow) {
|
||||
/* copy all affected rows up one and move the lastRow pointer */
|
||||
count = (int32_t)((lastRow-firstRow)+columns);
|
||||
uprv_memmove(firstRow+columns, firstRow, count*4);
|
||||
uprv_memmove(firstRow+columns, firstRow, (size_t)count*4);
|
||||
lastRow+=columns;
|
||||
|
||||
/* split the range and move the firstRow pointer */
|
||||
@ -251,7 +253,7 @@ upvec_setValue(UPropsVectors *pv,
|
||||
/* split the last row */
|
||||
if(splitLastRow) {
|
||||
/* copy the last row data */
|
||||
uprv_memcpy(lastRow+columns, lastRow, columns*4);
|
||||
uprv_memcpy(lastRow+columns, lastRow, (size_t)columns*4);
|
||||
|
||||
/* split the range and move the firstRow pointer */
|
||||
lastRow[1]=lastRow[columns]=(uint32_t)limit;
|
||||
@ -415,7 +417,7 @@ upvec_compact(UPropsVectors *pv, UPVecCompactHandler *handler, void *context, UE
|
||||
/* add a new values vector if it is different from the current one */
|
||||
if(count<0 || 0!=uprv_memcmp(row+2, pv->v+count, valueColumns*4)) {
|
||||
count+=valueColumns;
|
||||
uprv_memmove(pv->v+count, row+2, valueColumns*4);
|
||||
uprv_memmove(pv->v+count, row+2, (size_t)valueColumns*4);
|
||||
}
|
||||
|
||||
if(start<UPVEC_FIRST_SPECIAL_CP) {
|
||||
@ -477,7 +479,7 @@ upvec_cloneArray(const UPropsVectors *pv,
|
||||
|
||||
U_CAPI UTrie2 * U_EXPORT2
|
||||
upvec_compactToUTrie2WithRowIndexes(UPropsVectors *pv, UErrorCode *pErrorCode) {
|
||||
UPVecToUTrie2Context toUTrie2={ NULL };
|
||||
UPVecToUTrie2Context toUTrie2={ NULL, 0, 0, 0 };
|
||||
upvec_compact(pv, upvec_compactToUTrie2Handler, &toUTrie2, pErrorCode);
|
||||
utrie2_freeze(toUTrie2.trie, UTRIE2_16_VALUE_BITS, pErrorCode);
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -1,7 +1,9 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1997-2014, International Business Machines
|
||||
* Copyright (C) 1997-2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
@ -832,7 +834,6 @@ static const char* remapShortTimeZone(const char *stdID, const char *dstID, int3
|
||||
#endif
|
||||
|
||||
#ifdef SEARCH_TZFILE
|
||||
#define MAX_PATH_SIZE PATH_MAX /* Set the limit for the size of the path. */
|
||||
#define MAX_READ_SIZE 512
|
||||
|
||||
typedef struct DefaultTZInfo {
|
||||
@ -908,15 +909,19 @@ static UBool compareBinaryFiles(const char* defaultTZFileName, const char* TZFil
|
||||
|
||||
return result;
|
||||
}
|
||||
/*
|
||||
* This method recursively traverses the directory given for a matching TZ file and returns the first match.
|
||||
*/
|
||||
|
||||
|
||||
/* dirent also lists two entries: "." and ".." that we can safely ignore. */
|
||||
#define SKIP1 "."
|
||||
#define SKIP2 ".."
|
||||
static char SEARCH_TZFILE_RESULT[MAX_PATH_SIZE] = "";
|
||||
static UBool U_CALLCONV putil_cleanup(void);
|
||||
static CharString *gSearchTZFileResult = NULL;
|
||||
|
||||
/*
|
||||
* This method recursively traverses the directory given for a matching TZ file and returns the first match.
|
||||
* This function is not thread safe - it uses a global, gSearchTZFileResult, to hold its results.
|
||||
*/
|
||||
static char* searchForTZFile(const char* path, DefaultTZInfo* tzInfo) {
|
||||
char curpath[MAX_PATH_SIZE];
|
||||
DIR* dirp = opendir(path);
|
||||
DIR* subDirp = NULL;
|
||||
struct dirent* dirEntry = NULL;
|
||||
@ -926,24 +931,40 @@ static char* searchForTZFile(const char* path, DefaultTZInfo* tzInfo) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (gSearchTZFileResult == NULL) {
|
||||
gSearchTZFileResult = new CharString;
|
||||
if (gSearchTZFileResult == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
ucln_common_registerCleanup(UCLN_COMMON_PUTIL, putil_cleanup);
|
||||
}
|
||||
|
||||
/* Save the current path */
|
||||
uprv_memset(curpath, 0, MAX_PATH_SIZE);
|
||||
uprv_strcpy(curpath, path);
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
CharString curpath(path, -1, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Check each entry in the directory. */
|
||||
while((dirEntry = readdir(dirp)) != NULL) {
|
||||
const char* dirName = dirEntry->d_name;
|
||||
if (uprv_strcmp(dirName, SKIP1) != 0 && uprv_strcmp(dirName, SKIP2) != 0) {
|
||||
/* Create a newpath with the new entry to test each entry in the directory. */
|
||||
char newpath[MAX_PATH_SIZE];
|
||||
uprv_strcpy(newpath, curpath);
|
||||
uprv_strcat(newpath, dirName);
|
||||
CharString newpath(curpath, status);
|
||||
newpath.append(dirName, -1, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((subDirp = opendir(newpath)) != NULL) {
|
||||
if ((subDirp = opendir(newpath.data())) != NULL) {
|
||||
/* If this new path is a directory, make a recursive call with the newpath. */
|
||||
closedir(subDirp);
|
||||
uprv_strcat(newpath, "/");
|
||||
result = searchForTZFile(newpath, tzInfo);
|
||||
newpath.append('/', status);
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
}
|
||||
result = searchForTZFile(newpath.data(), tzInfo);
|
||||
/*
|
||||
Have to get out here. Otherwise, we'd keep looking
|
||||
and return the first match in the top-level directory
|
||||
@ -955,11 +976,19 @@ static char* searchForTZFile(const char* path, DefaultTZInfo* tzInfo) {
|
||||
if (result != NULL)
|
||||
break;
|
||||
} else if (uprv_strcmp(TZFILE_SKIP, dirName) != 0 && uprv_strcmp(TZFILE_SKIP2, dirName) != 0) {
|
||||
if(compareBinaryFiles(TZDEFAULT, newpath, tzInfo)) {
|
||||
const char* zoneid = newpath + (sizeof(TZZONEINFO)) - 1;
|
||||
if(compareBinaryFiles(TZDEFAULT, newpath.data(), tzInfo)) {
|
||||
int32_t amountToSkip = sizeof(TZZONEINFO) - 1;
|
||||
if (amountToSkip > newpath.length()) {
|
||||
amountToSkip = newpath.length();
|
||||
}
|
||||
const char* zoneid = newpath.data() + amountToSkip;
|
||||
skipZoneIDPrefix(&zoneid);
|
||||
uprv_strcpy(SEARCH_TZFILE_RESULT, zoneid);
|
||||
result = SEARCH_TZFILE_RESULT;
|
||||
gSearchTZFileResult->clear();
|
||||
gSearchTZFileResult->append(zoneid, -1, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
}
|
||||
result = gSearchTZFileResult->data();
|
||||
/* Get out after the first one found. */
|
||||
break;
|
||||
}
|
||||
@ -1009,6 +1038,10 @@ uprv_tzname(int n)
|
||||
&& uprv_strcmp(tzid, TZ_ENV_CHECK) != 0
|
||||
#endif
|
||||
) {
|
||||
/* The colon forces tzset() to treat the remainder as zoneinfo path */
|
||||
if (tzid[0] == ':') {
|
||||
tzid++;
|
||||
}
|
||||
/* This might be a good Olson ID. */
|
||||
skipZoneIDPrefix(&tzid);
|
||||
return tzid;
|
||||
@ -1024,7 +1057,7 @@ uprv_tzname(int n)
|
||||
because the tzfile contents is underspecified.
|
||||
This isn't guaranteed to work because it may not be a symlink.
|
||||
*/
|
||||
int32_t ret = (int32_t)readlink(TZDEFAULT, gTimeZoneBuffer, sizeof(gTimeZoneBuffer));
|
||||
int32_t ret = (int32_t)readlink(TZDEFAULT, gTimeZoneBuffer, sizeof(gTimeZoneBuffer)-1);
|
||||
if (0 < ret) {
|
||||
int32_t tzZoneInfoLen = uprv_strlen(TZZONEINFO);
|
||||
gTimeZoneBuffer[ret] = 0;
|
||||
@ -1144,6 +1177,11 @@ static UBool U_CALLCONV putil_cleanup(void)
|
||||
gTimeZoneFilesDirectory = NULL;
|
||||
gTimeZoneFilesInitOnce.reset();
|
||||
|
||||
#ifdef SEARCH_TZFILE
|
||||
delete gSearchTZFileResult;
|
||||
gSearchTZFileResult = NULL;
|
||||
#endif
|
||||
|
||||
#if U_POSIX_LOCALE || U_PLATFORM_USES_ONLY_WIN32_API
|
||||
if (gCorrectedPOSIXLocale) {
|
||||
uprv_free(gCorrectedPOSIXLocale);
|
||||
@ -1392,9 +1430,18 @@ static const char *uprv_getPOSIXIDForCategory(int category)
|
||||
{
|
||||
/* Maybe we got some garbage. Try something more reasonable */
|
||||
posixID = getenv("LC_ALL");
|
||||
/* Solaris speaks POSIX - See IEEE Std 1003.1-2008
|
||||
* This is needed to properly handle empty env. variables
|
||||
*/
|
||||
#if U_PLATFORM == U_PF_SOLARIS
|
||||
if ((posixID == 0) || (posixID[0] == '\0')) {
|
||||
posixID = getenv(category == LC_MESSAGES ? "LC_MESSAGES" : "LC_CTYPE");
|
||||
if ((posixID == 0) || (posixID[0] == '\0')) {
|
||||
#else
|
||||
if (posixID == 0) {
|
||||
posixID = getenv(category == LC_MESSAGES ? "LC_MESSAGES" : "LC_CTYPE");
|
||||
if (posixID == 0) {
|
||||
#endif
|
||||
posixID = getenv("LANG");
|
||||
}
|
||||
}
|
||||
@ -1886,7 +1933,10 @@ int_getDefaultCodepage()
|
||||
|
||||
localeName = uprv_getPOSIXIDForDefaultCodepage();
|
||||
uprv_memset(codesetName, 0, sizeof(codesetName));
|
||||
#if U_HAVE_NL_LANGINFO_CODESET
|
||||
/* On Solaris nl_langinfo returns C locale values unless setlocale
|
||||
* was called earlier.
|
||||
*/
|
||||
#if (U_HAVE_NL_LANGINFO_CODESET && U_PLATFORM != U_PF_SOLARIS)
|
||||
/* When available, check nl_langinfo first because it usually gives more
|
||||
useful names. It depends on LC_CTYPE.
|
||||
nl_langinfo may use the same buffer as setlocale. */
|
||||
@ -2197,6 +2247,7 @@ uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
|
||||
|
||||
U_INTERNAL void * U_EXPORT2
|
||||
uprv_dl_open(const char *libName, UErrorCode *status) {
|
||||
(void)libName;
|
||||
if(U_FAILURE(*status)) return NULL;
|
||||
*status = U_UNSUPPORTED_ERROR;
|
||||
return NULL;
|
||||
@ -2204,6 +2255,7 @@ uprv_dl_open(const char *libName, UErrorCode *status) {
|
||||
|
||||
U_INTERNAL void U_EXPORT2
|
||||
uprv_dl_close(void *lib, UErrorCode *status) {
|
||||
(void)lib;
|
||||
if(U_FAILURE(*status)) return;
|
||||
*status = U_UNSUPPORTED_ERROR;
|
||||
return;
|
||||
@ -2212,6 +2264,8 @@ uprv_dl_close(void *lib, UErrorCode *status) {
|
||||
|
||||
U_INTERNAL UVoidFunction* U_EXPORT2
|
||||
uprv_dlsym_func(void *lib, const char* sym, UErrorCode *status) {
|
||||
(void)lib;
|
||||
(void)sym;
|
||||
if(U_SUCCESS(*status)) {
|
||||
*status = U_UNSUPPORTED_ERROR;
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1997-2015, International Business Machines
|
||||
* Copyright (C) 1997-2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
@ -148,7 +150,7 @@ typedef size_t uintptr_t;
|
||||
|
||||
#ifdef U_HAVE_MMAP
|
||||
/* Use the predefined value. */
|
||||
#elif U_PLATFORM_HAS_WIN32_API
|
||||
#elif U_PLATFORM_USES_ONLY_WIN32_API
|
||||
# define U_HAVE_MMAP 0
|
||||
#else
|
||||
# define U_HAVE_MMAP 1
|
||||
@ -171,7 +173,7 @@ typedef size_t uintptr_t;
|
||||
*/
|
||||
#ifdef U_HAVE_DIRENT_H
|
||||
/* Use the predefined value. */
|
||||
#elif U_PLATFORM_HAS_WIN32_API
|
||||
#elif U_PLATFORM_USES_ONLY_WIN32_API
|
||||
# define U_HAVE_DIRENT_H 0
|
||||
#else
|
||||
# define U_HAVE_DIRENT_H 1
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
***************************************************************************
|
||||
* Copyright (C) 1999-2014 International Business Machines Corporation
|
||||
* Copyright (C) 1999-2016 International Business Machines Corporation
|
||||
* and others. All rights reserved.
|
||||
***************************************************************************
|
||||
*/
|
||||
@ -72,21 +74,6 @@ RuleBasedBreakIterator::RuleBasedBreakIterator(RBBIDataHeader* data, UErrorCode
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as above but does not adopt memory
|
||||
*/
|
||||
RuleBasedBreakIterator::RuleBasedBreakIterator(const RBBIDataHeader* data, enum EDontAdopt, UErrorCode &status)
|
||||
{
|
||||
init();
|
||||
fData = new RBBIDataWrapper(data, RBBIDataWrapper::kDontAdopt, status); // status checked in constructor
|
||||
if (U_FAILURE(status)) {return;}
|
||||
if(fData == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Construct from precompiled binary rules (tables). This constructor is public API,
|
||||
// taking the rules as a (const uint8_t *) to match the type produced by getBinaryRules().
|
||||
@ -715,7 +702,7 @@ int32_t RuleBasedBreakIterator::following(int32_t offset) {
|
||||
// Move requested offset to a code point start. It might be on a trail surrogate,
|
||||
// or on a trail byte if the input is UTF-8.
|
||||
utext_setNativeIndex(fText, offset);
|
||||
offset = utext_getNativeIndex(fText);
|
||||
offset = (int32_t)utext_getNativeIndex(fText);
|
||||
|
||||
// if we have cached break positions and offset is in the range
|
||||
// covered by them, use them
|
||||
@ -826,7 +813,7 @@ int32_t RuleBasedBreakIterator::preceding(int32_t offset) {
|
||||
// Move requested offset to a code point start. It might be on a trail surrogate,
|
||||
// or on a trail byte if the input is UTF-8.
|
||||
utext_setNativeIndex(fText, offset);
|
||||
offset = utext_getNativeIndex(fText);
|
||||
offset = (int32_t)utext_getNativeIndex(fText);
|
||||
|
||||
// if we have cached break positions and offset is in the range
|
||||
// covered by them, use them
|
||||
@ -983,6 +970,54 @@ enum RBBIRunMode {
|
||||
};
|
||||
|
||||
|
||||
// Map from look-ahead break states (corresponds to rules) to boundary positions.
|
||||
// Allows multiple lookahead break rules to be in flight at the same time.
|
||||
//
|
||||
// This is a temporary approach for ICU 57. A better fix is to make the look-ahead numbers
|
||||
// in the state table be sequential, then we can just index an array. And the
|
||||
// table could also tell us in advance how big that array needs to be.
|
||||
//
|
||||
// Before ICU 57 there was just a single simple variable for a look-ahead match that
|
||||
// was in progress. Two rules at once did not work.
|
||||
|
||||
static const int32_t kMaxLookaheads = 8;
|
||||
struct LookAheadResults {
|
||||
int32_t fUsedSlotLimit;
|
||||
int32_t fPositions[8];
|
||||
int16_t fKeys[8];
|
||||
|
||||
LookAheadResults() : fUsedSlotLimit(0), fPositions(), fKeys() {};
|
||||
|
||||
int32_t getPosition(int16_t key) {
|
||||
for (int32_t i=0; i<fUsedSlotLimit; ++i) {
|
||||
if (fKeys[i] == key) {
|
||||
return fPositions[i];
|
||||
}
|
||||
}
|
||||
U_ASSERT(FALSE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void setPosition(int16_t key, int32_t position) {
|
||||
int32_t i;
|
||||
for (i=0; i<fUsedSlotLimit; ++i) {
|
||||
if (fKeys[i] == key) {
|
||||
fPositions[i] = position;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (i >= kMaxLookaheads) {
|
||||
U_ASSERT(FALSE);
|
||||
i = kMaxLookaheads - 1;
|
||||
}
|
||||
fKeys[i] = key;
|
||||
fPositions[i] = position;
|
||||
U_ASSERT(fUsedSlotLimit == i);
|
||||
fUsedSlotLimit = i + 1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
//
|
||||
// handleNext(stateTable)
|
||||
@ -1000,14 +1035,11 @@ int32_t RuleBasedBreakIterator::handleNext(const RBBIStateTable *statetable) {
|
||||
|
||||
RBBIStateTableRow *row;
|
||||
UChar32 c;
|
||||
int32_t lookaheadStatus = 0;
|
||||
int32_t lookaheadTagIdx = 0;
|
||||
int32_t result = 0;
|
||||
int32_t initialPosition = 0;
|
||||
int32_t lookaheadResult = 0;
|
||||
UBool lookAheadHardBreak = (statetable->fFlags & RBBI_LOOKAHEAD_HARD_BREAK) != 0;
|
||||
const char *tableData = statetable->fTableData;
|
||||
uint32_t tableRowLen = statetable->fRowLen;
|
||||
LookAheadResults lookAheadMatches;
|
||||
int32_t result = 0;
|
||||
int32_t initialPosition = 0;
|
||||
const char *tableData = statetable->fTableData;
|
||||
uint32_t tableRowLen = statetable->fRowLen;
|
||||
|
||||
#ifdef RBBI_DEBUG
|
||||
if (fTrace) {
|
||||
@ -1050,14 +1082,6 @@ int32_t RuleBasedBreakIterator::handleNext(const RBBIStateTable *statetable) {
|
||||
// We have already run the loop one last time with the
|
||||
// character set to the psueudo {eof} value. Now it is time
|
||||
// to unconditionally bail out.
|
||||
if (lookaheadResult > result) {
|
||||
// We ran off the end of the string with a pending look-ahead match.
|
||||
// Treat this as if the look-ahead condition had been met, and return
|
||||
// the match at the / position from the look-ahead rule.
|
||||
result = lookaheadResult;
|
||||
fLastRuleStatusIndex = lookaheadTagIdx;
|
||||
lookaheadStatus = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Run the loop one last time with the fake end-of-input character category.
|
||||
@ -1123,38 +1147,23 @@ int32_t RuleBasedBreakIterator::handleNext(const RBBIStateTable *statetable) {
|
||||
fLastRuleStatusIndex = row->fTagIdx; // Remember the break status (tag) values.
|
||||
}
|
||||
|
||||
if (row->fLookAhead != 0) {
|
||||
if (lookaheadStatus != 0
|
||||
&& row->fAccepting == lookaheadStatus) {
|
||||
// Lookahead match is completed.
|
||||
result = lookaheadResult;
|
||||
fLastRuleStatusIndex = lookaheadTagIdx;
|
||||
lookaheadStatus = 0;
|
||||
// TODO: make a standalone hard break in a rule work.
|
||||
if (lookAheadHardBreak) {
|
||||
UTEXT_SETNATIVEINDEX(fText, result);
|
||||
return result;
|
||||
}
|
||||
// Look-ahead completed, but other rules may match further. Continue on
|
||||
// TODO: junk this feature? I don't think it's used anywhwere.
|
||||
goto continueOn;
|
||||
int16_t completedRule = row->fAccepting;
|
||||
if (completedRule > 0) {
|
||||
// Lookahead match is completed.
|
||||
int32_t lookaheadResult = lookAheadMatches.getPosition(completedRule);
|
||||
if (lookaheadResult >= 0) {
|
||||
fLastRuleStatusIndex = row->fTagIdx;
|
||||
UTEXT_SETNATIVEINDEX(fText, lookaheadResult);
|
||||
return lookaheadResult;
|
||||
}
|
||||
|
||||
int32_t r = (int32_t)UTEXT_GETNATIVEINDEX(fText);
|
||||
lookaheadResult = r;
|
||||
lookaheadStatus = row->fLookAhead;
|
||||
lookaheadTagIdx = row->fTagIdx;
|
||||
goto continueOn;
|
||||
}
|
||||
int16_t rule = row->fLookAhead;
|
||||
if (rule != 0) {
|
||||
// At the position of a '/' in a look-ahead match. Record it.
|
||||
int32_t pos = (int32_t)UTEXT_GETNATIVEINDEX(fText);
|
||||
lookAheadMatches.setPosition(rule, pos);
|
||||
}
|
||||
|
||||
|
||||
if (row->fAccepting != 0) {
|
||||
// Because this is an accepting state, any in-progress look-ahead match
|
||||
// is no longer relavant. Clear out the pending lookahead status.
|
||||
lookaheadStatus = 0; // clear out any pending look-ahead match.
|
||||
}
|
||||
|
||||
continueOn:
|
||||
if (state == STOP_STATE) {
|
||||
// This is the normal exit from the lookup state machine.
|
||||
// We have advanced through the string until it is certain that no
|
||||
@ -1216,11 +1225,9 @@ int32_t RuleBasedBreakIterator::handlePrevious(const RBBIStateTable *statetable)
|
||||
RBBIRunMode mode;
|
||||
RBBIStateTableRow *row;
|
||||
UChar32 c;
|
||||
int32_t lookaheadStatus = 0;
|
||||
LookAheadResults lookAheadMatches;
|
||||
int32_t result = 0;
|
||||
int32_t initialPosition = 0;
|
||||
int32_t lookaheadResult = 0;
|
||||
UBool lookAheadHardBreak = (statetable->fFlags & RBBI_LOOKAHEAD_HARD_BREAK) != 0;
|
||||
|
||||
#ifdef RBBI_DEBUG
|
||||
if (fTrace) {
|
||||
@ -1266,13 +1273,7 @@ int32_t RuleBasedBreakIterator::handlePrevious(const RBBIStateTable *statetable)
|
||||
// We have already run the loop one last time with the
|
||||
// character set to the psueudo {eof} value. Now it is time
|
||||
// to unconditionally bail out.
|
||||
if (lookaheadResult < result) {
|
||||
// We ran off the end of the string with a pending look-ahead match.
|
||||
// Treat this as if the look-ahead condition had been met, and return
|
||||
// the match at the / position from the look-ahead rule.
|
||||
result = lookaheadResult;
|
||||
lookaheadStatus = 0;
|
||||
} else if (result == initialPosition) {
|
||||
if (result == initialPosition) {
|
||||
// Ran off start, no match found.
|
||||
// move one index one (towards the start, since we are doing a previous())
|
||||
UTEXT_SETNATIVEINDEX(fText, initialPosition);
|
||||
@ -1338,36 +1339,22 @@ int32_t RuleBasedBreakIterator::handlePrevious(const RBBIStateTable *statetable)
|
||||
result = (int32_t)UTEXT_GETNATIVEINDEX(fText);
|
||||
}
|
||||
|
||||
if (row->fLookAhead != 0) {
|
||||
if (lookaheadStatus != 0
|
||||
&& row->fAccepting == lookaheadStatus) {
|
||||
// Lookahead match is completed.
|
||||
result = lookaheadResult;
|
||||
lookaheadStatus = 0;
|
||||
// TODO: make a standalone hard break in a rule work.
|
||||
if (lookAheadHardBreak) {
|
||||
UTEXT_SETNATIVEINDEX(fText, result);
|
||||
return result;
|
||||
}
|
||||
// Look-ahead completed, but other rules may match further. Continue on
|
||||
// TODO: junk this feature? I don't think it's used anywhwere.
|
||||
goto continueOn;
|
||||
int16_t completedRule = row->fAccepting;
|
||||
if (completedRule > 0) {
|
||||
// Lookahead match is completed.
|
||||
int32_t lookaheadResult = lookAheadMatches.getPosition(completedRule);
|
||||
if (lookaheadResult >= 0) {
|
||||
UTEXT_SETNATIVEINDEX(fText, lookaheadResult);
|
||||
return lookaheadResult;
|
||||
}
|
||||
|
||||
int32_t r = (int32_t)UTEXT_GETNATIVEINDEX(fText);
|
||||
lookaheadResult = r;
|
||||
lookaheadStatus = row->fLookAhead;
|
||||
goto continueOn;
|
||||
}
|
||||
int16_t rule = row->fLookAhead;
|
||||
if (rule != 0) {
|
||||
// At the position of a '/' in a look-ahead match. Record it.
|
||||
int32_t pos = (int32_t)UTEXT_GETNATIVEINDEX(fText);
|
||||
lookAheadMatches.setPosition(rule, pos);
|
||||
}
|
||||
|
||||
|
||||
if (row->fAccepting != 0) {
|
||||
// Because this is an accepting state, any in-progress look-ahead match
|
||||
// is no longer relavant. Clear out the pending lookahead status.
|
||||
lookaheadStatus = 0;
|
||||
}
|
||||
|
||||
continueOn:
|
||||
if (state == STOP_STATE) {
|
||||
// This is the normal exit from the lookup state machine.
|
||||
// We have advanced through the string until it is certain that no
|
||||
|
@ -1,6 +1,10 @@
|
||||
#**************************************************************************
|
||||
# Copyright (C) 2002-2005 International Business Machines Corporation *
|
||||
# and others. All rights reserved. *
|
||||
# Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
# License & terms of use: http://www.unicode.org/copyright.html#License
|
||||
#**************************************************************************
|
||||
#**************************************************************************
|
||||
# Copyright (C) 2002-2016 International Business Machines Corporation
|
||||
# and others. All rights reserved.
|
||||
#**************************************************************************
|
||||
#
|
||||
# rbbicst Compile the RBBI rule paser state table data into initialized C data.
|
||||
@ -348,6 +352,8 @@ else
|
||||
print "#ifndef RBBIRPT_H\n";
|
||||
print "#define RBBIRPT_H\n";
|
||||
print "\n";
|
||||
print "#include \"unicode/utypes.h\"\n";
|
||||
print "\n";
|
||||
print "U_NAMESPACE_BEGIN\n";
|
||||
|
||||
#
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
***************************************************************************
|
||||
* Copyright (C) 1999-2014 International Business Machines Corporation *
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
***************************************************************************
|
||||
* Copyright (C) 2002-2008 International Business Machines Corporation *
|
||||
* Copyright (C) 2002-2016 International Business Machines Corporation *
|
||||
* and others. All rights reserved. *
|
||||
***************************************************************************
|
||||
*/
|
||||
@ -23,6 +25,8 @@
|
||||
#include "unicode/uniset.h"
|
||||
#include "unicode/uchar.h"
|
||||
#include "unicode/parsepos.h"
|
||||
|
||||
#include "cstr.h"
|
||||
#include "uvector.h"
|
||||
|
||||
#include "rbbirb.h"
|
||||
@ -56,6 +60,8 @@ RBBINode::RBBINode(NodeType t) : UMemory() {
|
||||
fLastPos = 0;
|
||||
fNullable = FALSE;
|
||||
fLookAheadEnd = FALSE;
|
||||
fRuleRoot = FALSE;
|
||||
fChainIn = FALSE;
|
||||
fVal = 0;
|
||||
fPrecedence = precZero;
|
||||
|
||||
@ -86,6 +92,8 @@ RBBINode::RBBINode(const RBBINode &other) : UMemory(other) {
|
||||
fLastPos = other.fLastPos;
|
||||
fNullable = other.fNullable;
|
||||
fVal = other.fVal;
|
||||
fRuleRoot = FALSE;
|
||||
fChainIn = other.fChainIn;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
fFirstPosSet = new UVector(status); // TODO - get a real status from somewhere
|
||||
fLastPosSet = new UVector(status);
|
||||
@ -186,8 +194,12 @@ RBBINode *RBBINode::cloneTree() {
|
||||
//-------------------------------------------------------------------------
|
||||
RBBINode *RBBINode::flattenVariables() {
|
||||
if (fType == varRef) {
|
||||
RBBINode *retNode = fLeftChild->cloneTree();
|
||||
delete this;
|
||||
RBBINode *retNode = fLeftChild->cloneTree();
|
||||
if (retNode != NULL) {
|
||||
retNode->fRuleRoot = this->fRuleRoot;
|
||||
retNode->fChainIn = this->fChainIn;
|
||||
}
|
||||
delete this; // TODO: undefined behavior. Fix.
|
||||
return retNode;
|
||||
}
|
||||
|
||||
@ -272,7 +284,13 @@ void RBBINode::findNodes(UVector *dest, RBBINode::NodeType kind, UErrorCode &s
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
#ifdef RBBI_DEBUG
|
||||
void RBBINode::printNode() {
|
||||
|
||||
static int32_t serial(const RBBINode *node) {
|
||||
return (node == NULL? -1 : node->fSerialNum);
|
||||
}
|
||||
|
||||
|
||||
void RBBINode::printNode(const RBBINode *node) {
|
||||
static const char * const nodeTypeNames[] = {
|
||||
"setRef",
|
||||
"uset",
|
||||
@ -292,14 +310,16 @@ void RBBINode::printNode() {
|
||||
"opLParen"
|
||||
};
|
||||
|
||||
if (this==NULL) {
|
||||
RBBIDebugPrintf("%10p", (void *)this);
|
||||
if (node==NULL) {
|
||||
RBBIDebugPrintf("%10p", (void *)node);
|
||||
} else {
|
||||
RBBIDebugPrintf("%10p %12s %10p %10p %10p %4d %6d %d ",
|
||||
(void *)this, nodeTypeNames[fType], (void *)fParent, (void *)fLeftChild, (void *)fRightChild,
|
||||
fSerialNum, fFirstPos, fVal);
|
||||
if (fType == varRef) {
|
||||
RBBI_DEBUG_printUnicodeString(fText);
|
||||
RBBIDebugPrintf("%10p %5d %12s %c%c %5d %5d %5d %6d %d ",
|
||||
(void *)node, node->fSerialNum, nodeTypeNames[node->fType],
|
||||
node->fRuleRoot?'R':' ', node->fChainIn?'C':' ',
|
||||
serial(node->fLeftChild), serial(node->fRightChild), serial(node->fParent),
|
||||
node->fFirstPos, node->fVal);
|
||||
if (node->fType == varRef) {
|
||||
RBBI_DEBUG_printUnicodeString(node->fText);
|
||||
}
|
||||
}
|
||||
RBBIDebugPrintf("\n");
|
||||
@ -308,16 +328,8 @@ void RBBINode::printNode() {
|
||||
|
||||
|
||||
#ifdef RBBI_DEBUG
|
||||
U_CFUNC void RBBI_DEBUG_printUnicodeString(const UnicodeString &s, int minWidth)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<s.length(); i++) {
|
||||
RBBIDebugPrintf("%c", s.charAt(i));
|
||||
// putc(s.charAt(i), stdout);
|
||||
}
|
||||
for (i=s.length(); i<minWidth; i++) {
|
||||
RBBIDebugPrintf(" ");
|
||||
}
|
||||
U_CFUNC void RBBI_DEBUG_printUnicodeString(const UnicodeString &s, int minWidth) {
|
||||
RBBIDebugPrintf("%*s", minWidth, CStr(s)());
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -328,23 +340,25 @@ U_CFUNC void RBBI_DEBUG_printUnicodeString(const UnicodeString &s, int minWidth)
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
#ifdef RBBI_DEBUG
|
||||
void RBBINode::printTree(UBool printHeading) {
|
||||
void RBBINode::printNodeHeader() {
|
||||
RBBIDebugPrintf(" Address serial type LeftChild RightChild Parent position value\n");
|
||||
}
|
||||
|
||||
void RBBINode::printTree(const RBBINode *node, UBool printHeading) {
|
||||
if (printHeading) {
|
||||
RBBIDebugPrintf( "-------------------------------------------------------------------\n"
|
||||
" Address type Parent LeftChild RightChild serial position value\n"
|
||||
);
|
||||
printNodeHeader();
|
||||
}
|
||||
this->printNode();
|
||||
if (this != NULL) {
|
||||
printNode(node);
|
||||
if (node != NULL) {
|
||||
// Only dump the definition under a variable reference if asked to.
|
||||
// Unconditinally dump children of all other node types.
|
||||
if (fType != varRef) {
|
||||
if (fLeftChild != NULL) {
|
||||
fLeftChild->printTree(FALSE);
|
||||
if (node->fType != varRef) {
|
||||
if (node->fLeftChild != NULL) {
|
||||
printTree(node->fLeftChild, FALSE);
|
||||
}
|
||||
|
||||
if (fRightChild != NULL) {
|
||||
fRightChild->printTree(FALSE);
|
||||
if (node->fRightChild != NULL) {
|
||||
printTree(node->fRightChild, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 2001-2006, International Business Machines Corporation and
|
||||
* Copyright (c) 2001-2016, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
|
||||
@ -8,6 +10,7 @@
|
||||
#define RBBINODE_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/unistr.h"
|
||||
#include "unicode/uobject.h"
|
||||
|
||||
//
|
||||
@ -79,6 +82,10 @@ class RBBINode : public UMemory {
|
||||
UBool fLookAheadEnd; // For endMark nodes, set TRUE if
|
||||
// marking the end of a look-ahead rule.
|
||||
|
||||
UBool fRuleRoot; // True if this node is the root of a rule.
|
||||
UBool fChainIn; // True if chaining into this rule is allowed
|
||||
// (no '^' present).
|
||||
|
||||
UVector *fFirstPosSet;
|
||||
UVector *fLastPosSet; // TODO: rename fFirstPos & fLastPos to avoid confusion.
|
||||
UVector *fFollowPos;
|
||||
@ -94,8 +101,9 @@ class RBBINode : public UMemory {
|
||||
void findNodes(UVector *dest, RBBINode::NodeType kind, UErrorCode &status);
|
||||
|
||||
#ifdef RBBI_DEBUG
|
||||
void printNode();
|
||||
void printTree(UBool withHeading);
|
||||
static void printNodeHeader();
|
||||
static void printNode(const RBBINode *n);
|
||||
static void printTree(const RBBINode *n, UBool withHeading);
|
||||
#endif
|
||||
|
||||
private:
|
||||
@ -103,6 +111,7 @@ class RBBINode : public UMemory {
|
||||
UBool operator == (const RBBINode &other); // Private, so these functions won't accidently be used.
|
||||
|
||||
#ifdef RBBI_DEBUG
|
||||
public:
|
||||
int fSerialNum; // Debugging aids.
|
||||
#endif
|
||||
};
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
//
|
||||
// file: rbbirb.cpp
|
||||
//
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
//
|
||||
// rbbirb.h
|
||||
//
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Generated Header File. Do not edit by hand.
|
||||
@ -6,13 +8,15 @@
|
||||
// It is generated by the Perl script "rbbicst.pl" from
|
||||
// the rule parser state definitions file "rbbirpt.txt".
|
||||
//
|
||||
// Copyright (C) 2002-2005 International Business Machines Corporation
|
||||
// Copyright (C) 2002-2016 International Business Machines Corporation
|
||||
// and others. All rights reserved.
|
||||
//
|
||||
//---------------------------------------------------------------------------------
|
||||
#ifndef RBBIRPT_H
|
||||
#define RBBIRPT_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
//
|
||||
// Character classes for RBBI rule scanning.
|
||||
@ -38,6 +42,7 @@ enum RBBI_RuleParseAction {
|
||||
doExprStart,
|
||||
doLParen,
|
||||
doNOP,
|
||||
doNoChain,
|
||||
doOptionEnd,
|
||||
doOptionStart,
|
||||
doReverseDir,
|
||||
@ -75,101 +80,109 @@ struct RBBIRuleTableEl {
|
||||
|
||||
static const struct RBBIRuleTableEl gRuleParseStateTable[] = {
|
||||
{doNOP, 0, 0, 0, TRUE}
|
||||
, {doExprStart, 254, 21, 8, FALSE} // 1 start
|
||||
, {doExprStart, 254, 29, 9, FALSE} // 1 start
|
||||
, {doNOP, 132, 1,0, TRUE} // 2
|
||||
, {doExprStart, 36 /* $ */, 80, 90, FALSE} // 3
|
||||
, {doNOP, 33 /* ! */, 11,0, TRUE} // 4
|
||||
, {doNOP, 59 /* ; */, 1,0, TRUE} // 5
|
||||
, {doNOP, 252, 0,0, FALSE} // 6
|
||||
, {doExprStart, 255, 21, 8, FALSE} // 7
|
||||
, {doEndOfRule, 59 /* ; */, 1,0, TRUE} // 8 break-rule-end
|
||||
, {doNOP, 132, 8,0, TRUE} // 9
|
||||
, {doRuleError, 255, 95,0, FALSE} // 10
|
||||
, {doNOP, 33 /* ! */, 13,0, TRUE} // 11 rev-option
|
||||
, {doReverseDir, 255, 20, 8, FALSE} // 12
|
||||
, {doOptionStart, 130, 15,0, TRUE} // 13 option-scan1
|
||||
, {doRuleError, 255, 95,0, FALSE} // 14
|
||||
, {doNOP, 129, 15,0, TRUE} // 15 option-scan2
|
||||
, {doOptionEnd, 255, 17,0, FALSE} // 16
|
||||
, {doNOP, 59 /* ; */, 1,0, TRUE} // 17 option-scan3
|
||||
, {doNOP, 132, 17,0, TRUE} // 18
|
||||
, {doRuleError, 255, 95,0, FALSE} // 19
|
||||
, {doExprStart, 255, 21, 8, FALSE} // 20 reverse-rule
|
||||
, {doRuleChar, 254, 30,0, TRUE} // 21 term
|
||||
, {doNOP, 132, 21,0, TRUE} // 22
|
||||
, {doRuleChar, 131, 30,0, TRUE} // 23
|
||||
, {doNOP, 91 /* [ */, 86, 30, FALSE} // 24
|
||||
, {doLParen, 40 /* ( */, 21, 30, TRUE} // 25
|
||||
, {doNOP, 36 /* $ */, 80, 29, FALSE} // 26
|
||||
, {doDotAny, 46 /* . */, 30,0, TRUE} // 27
|
||||
, {doRuleError, 255, 95,0, FALSE} // 28
|
||||
, {doCheckVarDef, 255, 30,0, FALSE} // 29 term-var-ref
|
||||
, {doNOP, 132, 30,0, TRUE} // 30 expr-mod
|
||||
, {doUnaryOpStar, 42 /* * */, 35,0, TRUE} // 31
|
||||
, {doUnaryOpPlus, 43 /* + */, 35,0, TRUE} // 32
|
||||
, {doUnaryOpQuestion, 63 /* ? */, 35,0, TRUE} // 33
|
||||
, {doNOP, 255, 35,0, FALSE} // 34
|
||||
, {doExprCatOperator, 254, 21,0, FALSE} // 35 expr-cont
|
||||
, {doNOP, 132, 35,0, TRUE} // 36
|
||||
, {doExprCatOperator, 131, 21,0, FALSE} // 37
|
||||
, {doExprCatOperator, 91 /* [ */, 21,0, FALSE} // 38
|
||||
, {doExprCatOperator, 40 /* ( */, 21,0, FALSE} // 39
|
||||
, {doExprCatOperator, 36 /* $ */, 21,0, FALSE} // 40
|
||||
, {doExprCatOperator, 46 /* . */, 21,0, FALSE} // 41
|
||||
, {doExprCatOperator, 47 /* / */, 47,0, FALSE} // 42
|
||||
, {doExprCatOperator, 123 /* { */, 59,0, TRUE} // 43
|
||||
, {doExprOrOperator, 124 /* | */, 21,0, TRUE} // 44
|
||||
, {doExprRParen, 41 /* ) */, 255,0, TRUE} // 45
|
||||
, {doExprFinished, 255, 255,0, FALSE} // 46
|
||||
, {doSlash, 47 /* / */, 49,0, TRUE} // 47 look-ahead
|
||||
, {doNOP, 255, 95,0, FALSE} // 48
|
||||
, {doExprCatOperator, 254, 21,0, FALSE} // 49 expr-cont-no-slash
|
||||
, {doNOP, 132, 35,0, TRUE} // 50
|
||||
, {doExprCatOperator, 131, 21,0, FALSE} // 51
|
||||
, {doExprCatOperator, 91 /* [ */, 21,0, FALSE} // 52
|
||||
, {doExprCatOperator, 40 /* ( */, 21,0, FALSE} // 53
|
||||
, {doExprCatOperator, 36 /* $ */, 21,0, FALSE} // 54
|
||||
, {doExprCatOperator, 46 /* . */, 21,0, FALSE} // 55
|
||||
, {doExprOrOperator, 124 /* | */, 21,0, TRUE} // 56
|
||||
, {doExprRParen, 41 /* ) */, 255,0, TRUE} // 57
|
||||
, {doExprFinished, 255, 255,0, FALSE} // 58
|
||||
, {doNOP, 132, 59,0, TRUE} // 59 tag-open
|
||||
, {doStartTagValue, 128, 62,0, FALSE} // 60
|
||||
, {doTagExpectedError, 255, 95,0, FALSE} // 61
|
||||
, {doNOP, 132, 66,0, TRUE} // 62 tag-value
|
||||
, {doNOP, 125 /* } */, 66,0, FALSE} // 63
|
||||
, {doTagDigit, 128, 62,0, TRUE} // 64
|
||||
, {doTagExpectedError, 255, 95,0, FALSE} // 65
|
||||
, {doNOP, 132, 66,0, TRUE} // 66 tag-close
|
||||
, {doTagValue, 125 /* } */, 69,0, TRUE} // 67
|
||||
, {doTagExpectedError, 255, 95,0, FALSE} // 68
|
||||
, {doExprCatOperator, 254, 21,0, FALSE} // 69 expr-cont-no-tag
|
||||
, {doNOP, 132, 69,0, TRUE} // 70
|
||||
, {doExprCatOperator, 131, 21,0, FALSE} // 71
|
||||
, {doExprCatOperator, 91 /* [ */, 21,0, FALSE} // 72
|
||||
, {doExprCatOperator, 40 /* ( */, 21,0, FALSE} // 73
|
||||
, {doExprCatOperator, 36 /* $ */, 21,0, FALSE} // 74
|
||||
, {doExprCatOperator, 46 /* . */, 21,0, FALSE} // 75
|
||||
, {doExprCatOperator, 47 /* / */, 47,0, FALSE} // 76
|
||||
, {doExprOrOperator, 124 /* | */, 21,0, TRUE} // 77
|
||||
, {doExprRParen, 41 /* ) */, 255,0, TRUE} // 78
|
||||
, {doExprFinished, 255, 255,0, FALSE} // 79
|
||||
, {doStartVariableName, 36 /* $ */, 82,0, TRUE} // 80 scan-var-name
|
||||
, {doNOP, 255, 95,0, FALSE} // 81
|
||||
, {doNOP, 130, 84,0, TRUE} // 82 scan-var-start
|
||||
, {doVariableNameExpectedErr, 255, 95,0, FALSE} // 83
|
||||
, {doNOP, 129, 84,0, TRUE} // 84 scan-var-body
|
||||
, {doEndVariableName, 255, 255,0, FALSE} // 85
|
||||
, {doScanUnicodeSet, 91 /* [ */, 255,0, TRUE} // 86 scan-unicode-set
|
||||
, {doScanUnicodeSet, 112 /* p */, 255,0, TRUE} // 87
|
||||
, {doScanUnicodeSet, 80 /* P */, 255,0, TRUE} // 88
|
||||
, {doNOP, 255, 95,0, FALSE} // 89
|
||||
, {doNOP, 132, 90,0, TRUE} // 90 assign-or-rule
|
||||
, {doStartAssign, 61 /* = */, 21, 93, TRUE} // 91
|
||||
, {doNOP, 255, 29, 8, FALSE} // 92
|
||||
, {doEndAssign, 59 /* ; */, 1,0, TRUE} // 93 assign-end
|
||||
, {doRuleErrorAssignExpr, 255, 95,0, FALSE} // 94
|
||||
, {doExit, 255, 95,0, TRUE} // 95 errorDeath
|
||||
, {doNoChain, 94 /* ^ */, 12, 9, TRUE} // 3
|
||||
, {doExprStart, 36 /* $ */, 88, 98, FALSE} // 4
|
||||
, {doNOP, 33 /* ! */, 19,0, TRUE} // 5
|
||||
, {doNOP, 59 /* ; */, 1,0, TRUE} // 6
|
||||
, {doNOP, 252, 0,0, FALSE} // 7
|
||||
, {doExprStart, 255, 29, 9, FALSE} // 8
|
||||
, {doEndOfRule, 59 /* ; */, 1,0, TRUE} // 9 break-rule-end
|
||||
, {doNOP, 132, 9,0, TRUE} // 10
|
||||
, {doRuleError, 255, 103,0, FALSE} // 11
|
||||
, {doExprStart, 254, 29,0, FALSE} // 12 start-after-caret
|
||||
, {doNOP, 132, 12,0, TRUE} // 13
|
||||
, {doRuleError, 94 /* ^ */, 103,0, FALSE} // 14
|
||||
, {doExprStart, 36 /* $ */, 88, 37, FALSE} // 15
|
||||
, {doRuleError, 59 /* ; */, 103,0, FALSE} // 16
|
||||
, {doRuleError, 252, 103,0, FALSE} // 17
|
||||
, {doExprStart, 255, 29,0, FALSE} // 18
|
||||
, {doNOP, 33 /* ! */, 21,0, TRUE} // 19 rev-option
|
||||
, {doReverseDir, 255, 28, 9, FALSE} // 20
|
||||
, {doOptionStart, 130, 23,0, TRUE} // 21 option-scan1
|
||||
, {doRuleError, 255, 103,0, FALSE} // 22
|
||||
, {doNOP, 129, 23,0, TRUE} // 23 option-scan2
|
||||
, {doOptionEnd, 255, 25,0, FALSE} // 24
|
||||
, {doNOP, 59 /* ; */, 1,0, TRUE} // 25 option-scan3
|
||||
, {doNOP, 132, 25,0, TRUE} // 26
|
||||
, {doRuleError, 255, 103,0, FALSE} // 27
|
||||
, {doExprStart, 255, 29, 9, FALSE} // 28 reverse-rule
|
||||
, {doRuleChar, 254, 38,0, TRUE} // 29 term
|
||||
, {doNOP, 132, 29,0, TRUE} // 30
|
||||
, {doRuleChar, 131, 38,0, TRUE} // 31
|
||||
, {doNOP, 91 /* [ */, 94, 38, FALSE} // 32
|
||||
, {doLParen, 40 /* ( */, 29, 38, TRUE} // 33
|
||||
, {doNOP, 36 /* $ */, 88, 37, FALSE} // 34
|
||||
, {doDotAny, 46 /* . */, 38,0, TRUE} // 35
|
||||
, {doRuleError, 255, 103,0, FALSE} // 36
|
||||
, {doCheckVarDef, 255, 38,0, FALSE} // 37 term-var-ref
|
||||
, {doNOP, 132, 38,0, TRUE} // 38 expr-mod
|
||||
, {doUnaryOpStar, 42 /* * */, 43,0, TRUE} // 39
|
||||
, {doUnaryOpPlus, 43 /* + */, 43,0, TRUE} // 40
|
||||
, {doUnaryOpQuestion, 63 /* ? */, 43,0, TRUE} // 41
|
||||
, {doNOP, 255, 43,0, FALSE} // 42
|
||||
, {doExprCatOperator, 254, 29,0, FALSE} // 43 expr-cont
|
||||
, {doNOP, 132, 43,0, TRUE} // 44
|
||||
, {doExprCatOperator, 131, 29,0, FALSE} // 45
|
||||
, {doExprCatOperator, 91 /* [ */, 29,0, FALSE} // 46
|
||||
, {doExprCatOperator, 40 /* ( */, 29,0, FALSE} // 47
|
||||
, {doExprCatOperator, 36 /* $ */, 29,0, FALSE} // 48
|
||||
, {doExprCatOperator, 46 /* . */, 29,0, FALSE} // 49
|
||||
, {doExprCatOperator, 47 /* / */, 55,0, FALSE} // 50
|
||||
, {doExprCatOperator, 123 /* { */, 67,0, TRUE} // 51
|
||||
, {doExprOrOperator, 124 /* | */, 29,0, TRUE} // 52
|
||||
, {doExprRParen, 41 /* ) */, 255,0, TRUE} // 53
|
||||
, {doExprFinished, 255, 255,0, FALSE} // 54
|
||||
, {doSlash, 47 /* / */, 57,0, TRUE} // 55 look-ahead
|
||||
, {doNOP, 255, 103,0, FALSE} // 56
|
||||
, {doExprCatOperator, 254, 29,0, FALSE} // 57 expr-cont-no-slash
|
||||
, {doNOP, 132, 43,0, TRUE} // 58
|
||||
, {doExprCatOperator, 131, 29,0, FALSE} // 59
|
||||
, {doExprCatOperator, 91 /* [ */, 29,0, FALSE} // 60
|
||||
, {doExprCatOperator, 40 /* ( */, 29,0, FALSE} // 61
|
||||
, {doExprCatOperator, 36 /* $ */, 29,0, FALSE} // 62
|
||||
, {doExprCatOperator, 46 /* . */, 29,0, FALSE} // 63
|
||||
, {doExprOrOperator, 124 /* | */, 29,0, TRUE} // 64
|
||||
, {doExprRParen, 41 /* ) */, 255,0, TRUE} // 65
|
||||
, {doExprFinished, 255, 255,0, FALSE} // 66
|
||||
, {doNOP, 132, 67,0, TRUE} // 67 tag-open
|
||||
, {doStartTagValue, 128, 70,0, FALSE} // 68
|
||||
, {doTagExpectedError, 255, 103,0, FALSE} // 69
|
||||
, {doNOP, 132, 74,0, TRUE} // 70 tag-value
|
||||
, {doNOP, 125 /* } */, 74,0, FALSE} // 71
|
||||
, {doTagDigit, 128, 70,0, TRUE} // 72
|
||||
, {doTagExpectedError, 255, 103,0, FALSE} // 73
|
||||
, {doNOP, 132, 74,0, TRUE} // 74 tag-close
|
||||
, {doTagValue, 125 /* } */, 77,0, TRUE} // 75
|
||||
, {doTagExpectedError, 255, 103,0, FALSE} // 76
|
||||
, {doExprCatOperator, 254, 29,0, FALSE} // 77 expr-cont-no-tag
|
||||
, {doNOP, 132, 77,0, TRUE} // 78
|
||||
, {doExprCatOperator, 131, 29,0, FALSE} // 79
|
||||
, {doExprCatOperator, 91 /* [ */, 29,0, FALSE} // 80
|
||||
, {doExprCatOperator, 40 /* ( */, 29,0, FALSE} // 81
|
||||
, {doExprCatOperator, 36 /* $ */, 29,0, FALSE} // 82
|
||||
, {doExprCatOperator, 46 /* . */, 29,0, FALSE} // 83
|
||||
, {doExprCatOperator, 47 /* / */, 55,0, FALSE} // 84
|
||||
, {doExprOrOperator, 124 /* | */, 29,0, TRUE} // 85
|
||||
, {doExprRParen, 41 /* ) */, 255,0, TRUE} // 86
|
||||
, {doExprFinished, 255, 255,0, FALSE} // 87
|
||||
, {doStartVariableName, 36 /* $ */, 90,0, TRUE} // 88 scan-var-name
|
||||
, {doNOP, 255, 103,0, FALSE} // 89
|
||||
, {doNOP, 130, 92,0, TRUE} // 90 scan-var-start
|
||||
, {doVariableNameExpectedErr, 255, 103,0, FALSE} // 91
|
||||
, {doNOP, 129, 92,0, TRUE} // 92 scan-var-body
|
||||
, {doEndVariableName, 255, 255,0, FALSE} // 93
|
||||
, {doScanUnicodeSet, 91 /* [ */, 255,0, TRUE} // 94 scan-unicode-set
|
||||
, {doScanUnicodeSet, 112 /* p */, 255,0, TRUE} // 95
|
||||
, {doScanUnicodeSet, 80 /* P */, 255,0, TRUE} // 96
|
||||
, {doNOP, 255, 103,0, FALSE} // 97
|
||||
, {doNOP, 132, 98,0, TRUE} // 98 assign-or-rule
|
||||
, {doStartAssign, 61 /* = */, 29, 101, TRUE} // 99
|
||||
, {doNOP, 255, 37, 9, FALSE} // 100
|
||||
, {doEndAssign, 59 /* ; */, 1,0, TRUE} // 101 assign-end
|
||||
, {doRuleErrorAssignExpr, 255, 103,0, FALSE} // 102
|
||||
, {doExit, 255, 103,0, TRUE} // 103 errorDeath
|
||||
};
|
||||
#ifdef RBBI_DEBUG
|
||||
static const char * const RBBIRuleStateNames[] = { 0,
|
||||
@ -179,9 +192,17 @@ static const char * const RBBIRuleStateNames[] = { 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"break-rule-end",
|
||||
0,
|
||||
0,
|
||||
"start-after-caret",
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"rev-option",
|
||||
0,
|
||||
|
@ -1,7 +1,13 @@
|
||||
|
||||
#*****************************************************************************
|
||||
#
|
||||
# Copyright (C) 2002-2003, International Business Machines Corporation and others.
|
||||
# Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
# License & terms of use: http://www.unicode.org/copyright.html#License
|
||||
#
|
||||
#*****************************************************************************
|
||||
#*****************************************************************************
|
||||
#
|
||||
# Copyright (C) 2002-2016, International Business Machines Corporation and others.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
#*****************************************************************************
|
||||
@ -19,6 +25,7 @@
|
||||
# This file is processed by a perl script "rbbicst.pl" to produce initialized C arrays
|
||||
# that are then built with the rule parser.
|
||||
#
|
||||
# perl rbbicst.pl < rbbirpt.txt > rbbirpt.h
|
||||
|
||||
#
|
||||
# Here is the syntax of the state definitions in this file:
|
||||
@ -57,6 +64,7 @@
|
||||
start:
|
||||
escaped term ^break-rule-end doExprStart
|
||||
white_space n start
|
||||
'^' n start-after-caret ^break-rule-end doNoChain
|
||||
'$' scan-var-name ^assign-or-rule doExprStart
|
||||
'!' n rev-option
|
||||
';' n start # ignore empty rules.
|
||||
@ -71,7 +79,21 @@ break-rule-end:
|
||||
white_space n break-rule-end
|
||||
default errorDeath doRuleError
|
||||
|
||||
|
||||
#
|
||||
# start of a rule, after having seen a '^' (inhibits rule chain in).
|
||||
# Similar to the main 'start' state in most respects, except
|
||||
# - empty rule is an error.
|
||||
# - A second '^' is an error.
|
||||
#
|
||||
start-after-caret:
|
||||
escaped term doExprStart
|
||||
white_space n start-after-caret
|
||||
'^' errorDeath doRuleError # two '^'s
|
||||
'$' scan-var-name ^term-var-ref doExprStart
|
||||
';' errorDeath doRuleError # ^ ;
|
||||
eof errorDeath doRuleError
|
||||
default term doExprStart
|
||||
|
||||
#
|
||||
# ! We've just scanned a '!', indicating either a !!key word flag or a
|
||||
# !Reverse rule.
|
||||
|
@ -1,7 +1,9 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
//
|
||||
// file: rbbiscan.cpp
|
||||
//
|
||||
// Copyright (C) 2002-2015, International Business Machines Corporation and others.
|
||||
// Copyright (C) 2002-2016, International Business Machines Corporation and others.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// This file contains the Rule Based Break Iterator Rule Builder functions for
|
||||
@ -87,24 +89,27 @@ U_NAMESPACE_BEGIN
|
||||
RBBIRuleScanner::RBBIRuleScanner(RBBIRuleBuilder *rb)
|
||||
{
|
||||
fRB = rb;
|
||||
fScanIndex = 0;
|
||||
fNextIndex = 0;
|
||||
fQuoteMode = FALSE;
|
||||
fLineNum = 1;
|
||||
fCharNum = 0;
|
||||
fLastChar = 0;
|
||||
|
||||
fStateTable = NULL;
|
||||
fStack[0] = 0;
|
||||
fStackPtr = 0;
|
||||
fStack[fStackPtr] = 0;
|
||||
fNodeStackPtr = 0;
|
||||
fRuleNum = 0;
|
||||
fNodeStack[0] = NULL;
|
||||
|
||||
fSymbolTable = NULL;
|
||||
fSetTable = NULL;
|
||||
|
||||
fScanIndex = 0;
|
||||
fNextIndex = 0;
|
||||
fNodeStackPtr = 0;
|
||||
|
||||
fReverseRule = FALSE;
|
||||
fLookAheadRule = FALSE;
|
||||
fNoChainInRule = FALSE;
|
||||
|
||||
fLineNum = 1;
|
||||
fCharNum = 0;
|
||||
fQuoteMode = FALSE;
|
||||
fSymbolTable = NULL;
|
||||
fSetTable = NULL;
|
||||
fRuleNum = 0;
|
||||
fOptionStart = 0;
|
||||
|
||||
// Do not check status until after all critical fields are sufficiently initialized
|
||||
// that the destructor can run cleanly.
|
||||
@ -205,6 +210,12 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
break;
|
||||
|
||||
|
||||
case doNoChain:
|
||||
// Scanned a '^' while on the rule start state.
|
||||
fNoChainInRule = TRUE;
|
||||
break;
|
||||
|
||||
|
||||
case doExprOrOperator:
|
||||
{
|
||||
fixOpStack(RBBINode::precOpCat);
|
||||
@ -318,11 +329,11 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
if (fRB->fDebugEnv && uprv_strstr(fRB->fDebugEnv, "rtree")) {printNodeStack("end of rule");}
|
||||
#endif
|
||||
U_ASSERT(fNodeStackPtr == 1);
|
||||
RBBINode *thisRule = fNodeStack[fNodeStackPtr];
|
||||
|
||||
// If this rule includes a look-ahead '/', add a endMark node to the
|
||||
// expression tree.
|
||||
if (fLookAheadRule) {
|
||||
RBBINode *thisRule = fNodeStack[fNodeStackPtr];
|
||||
RBBINode *endNode = pushNewNode(RBBINode::endMark);
|
||||
RBBINode *catNode = pushNewNode(RBBINode::opCat);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
@ -334,8 +345,24 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
fNodeStack[fNodeStackPtr] = catNode;
|
||||
endNode->fVal = fRuleNum;
|
||||
endNode->fLookAheadEnd = TRUE;
|
||||
thisRule = catNode;
|
||||
|
||||
// TODO: Disable chaining out of look-ahead (hard break) rules.
|
||||
// The break on rule match is forced, so there is no point in building up
|
||||
// the state table to chain into another rule for a longer match.
|
||||
}
|
||||
|
||||
// Mark this node as being the root of a rule.
|
||||
thisRule->fRuleRoot = TRUE;
|
||||
|
||||
// Flag if chaining into this rule is wanted.
|
||||
//
|
||||
if (fRB->fChainRules && // If rule chaining is enabled globally via !!chain
|
||||
!fNoChainInRule) { // and no '^' chain-in inhibit was on this rule
|
||||
thisRule->fChainIn = TRUE;
|
||||
}
|
||||
|
||||
|
||||
// All rule expressions are ORed together.
|
||||
// The ';' that terminates an expression really just functions as a '|' with
|
||||
// a low operator prededence.
|
||||
@ -372,6 +399,7 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
}
|
||||
fReverseRule = FALSE; // in preparation for the next rule.
|
||||
fLookAheadRule = FALSE;
|
||||
fNoChainInRule = FALSE;
|
||||
fNodeStackPtr = 0;
|
||||
}
|
||||
break;
|
||||
@ -994,7 +1022,7 @@ void RBBIRuleScanner::parse() {
|
||||
|
||||
for (;;) {
|
||||
#ifdef RBBI_DEBUG
|
||||
if (fRB->fDebugEnv && uprv_strstr(fRB->fDebugEnv, "scan")) { RBBIDebugPrintf(".");}
|
||||
if (fRB->fDebugEnv && uprv_strstr(fRB->fDebugEnv, "scan")) { RBBIDebugPrintf("."); fflush(stdout);}
|
||||
#endif
|
||||
if (tableEl->fCharClass < 127 && fC.fEscaped == FALSE && tableEl->fCharClass == fC.fChar) {
|
||||
// Table row specified an individual character, not a set, and
|
||||
@ -1077,6 +1105,17 @@ void RBBIRuleScanner::parse() {
|
||||
|
||||
}
|
||||
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If there are no forward rules set an error.
|
||||
//
|
||||
if (fRB->fForwardTree == NULL) {
|
||||
error(U_BRK_RULE_SYNTAX);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// If there were NO user specified reverse rules, set up the equivalent of ".*;"
|
||||
//
|
||||
@ -1100,16 +1139,15 @@ void RBBIRuleScanner::parse() {
|
||||
//
|
||||
#ifdef RBBI_DEBUG
|
||||
if (fRB->fDebugEnv && uprv_strstr(fRB->fDebugEnv, "symbols")) {fSymbolTable->rbbiSymtablePrint();}
|
||||
if (fRB->fDebugEnv && uprv_strstr(fRB->fDebugEnv, "ptree"))
|
||||
{
|
||||
if (fRB->fDebugEnv && uprv_strstr(fRB->fDebugEnv, "ptree")) {
|
||||
RBBIDebugPrintf("Completed Forward Rules Parse Tree...\n");
|
||||
fRB->fForwardTree->printTree(TRUE);
|
||||
RBBINode::printTree(fRB->fForwardTree, TRUE);
|
||||
RBBIDebugPrintf("\nCompleted Reverse Rules Parse Tree...\n");
|
||||
fRB->fReverseTree->printTree(TRUE);
|
||||
RBBINode::printTree(fRB->fReverseTree, TRUE);
|
||||
RBBIDebugPrintf("\nCompleted Safe Point Forward Rules Parse Tree...\n");
|
||||
fRB->fSafeFwdTree->printTree(TRUE);
|
||||
RBBINode::printTree(fRB->fSafeFwdTree, TRUE);
|
||||
RBBIDebugPrintf("\nCompleted Safe Point Reverse Rules Parse Tree...\n");
|
||||
fRB->fSafeRevTree->printTree(TRUE);
|
||||
RBBINode::printTree(fRB->fSafeRevTree, TRUE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1124,7 +1162,7 @@ void RBBIRuleScanner::parse() {
|
||||
void RBBIRuleScanner::printNodeStack(const char *title) {
|
||||
int i;
|
||||
RBBIDebugPrintf("%s. Dumping node stack...\n", title);
|
||||
for (i=fNodeStackPtr; i>0; i--) {fNodeStack[i]->printTree(TRUE);}
|
||||
for (i=fNodeStackPtr; i>0; i--) {RBBINode::printTree(fNodeStack[i], TRUE);}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
//
|
||||
// rbbiscan.h
|
||||
//
|
||||
// Copyright (C) 2002-2008, International Business Machines Corporation and others.
|
||||
// Copyright (C) 2002-2016, International Business Machines Corporation and others.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// This file contains declarations for class RBBIRuleScanner
|
||||
@ -21,9 +23,7 @@
|
||||
#include "unicode/symtable.h"// For UnicodeSet parsing, is the interface that
|
||||
// looks up references to $variables within a set.
|
||||
#include "rbbinode.h"
|
||||
//#include "rbbitblb.h"
|
||||
|
||||
|
||||
#include "rbbirpt.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
@ -54,6 +54,7 @@ public:
|
||||
struct RBBIRuleChar {
|
||||
UChar32 fChar;
|
||||
UBool fEscaped;
|
||||
RBBIRuleChar() : fChar(0), fEscaped(FALSE) {};
|
||||
};
|
||||
|
||||
RBBIRuleScanner(RBBIRuleBuilder *rb);
|
||||
@ -129,6 +130,8 @@ private:
|
||||
UBool fLookAheadRule; // True if the rule includes a '/'
|
||||
// somewhere within it.
|
||||
|
||||
UBool fNoChainInRule; // True if the current rule starts with a '^'.
|
||||
|
||||
RBBISymbolTable *fSymbolTable; // symbol table, holds definitions of
|
||||
// $variable symbols.
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user