Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1AAE710986 for ; Thu, 6 Feb 2014 17:30:29 +0000 (UTC) Received: (qmail 12108 invoked by uid 500); 6 Feb 2014 17:28:18 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 11330 invoked by uid 500); 6 Feb 2014 17:27:58 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 10859 invoked by uid 99); 6 Feb 2014 17:27:46 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Feb 2014 17:27:46 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C08C98A349C; Thu, 6 Feb 2014 17:27:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davisp@apache.org To: commits@couchdb.apache.org Date: Thu, 06 Feb 2014 17:28:26 -0000 Message-Id: <2e24cce9698f4d569b6768d5c4f736ef@git.apache.org> In-Reply-To: <24a97e2b76944cf6952863df43b7ba3e@git.apache.org> References: <24a97e2b76944cf6952863df43b7ba3e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [44/46] couch-collate commit: updated refs/heads/import-rcouch to 8ecdb84 support static build This change backport the static build from rcouch. A static build of spidermonkey is the default. To build with the libraries installed you can pass the parameter `libs=shared` to the make. By default couch_collate is using ICU installed on the system except if you pass the option `icu=static` to the Make. At anytime you can override the compilation environnement with the following variables: JS_CFLAGS JS_LIBS ICU_CFLAGS ICU_LDFLAGS Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-collate/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-collate/commit/32ffa429 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-collate/tree/32ffa429 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-collate/diff/32ffa429 Branch: refs/heads/import-rcouch Commit: 32ffa4290c54ca59357d9481fbcd39630aa4e036 Parents: 9ea1202 Author: benoitc Authored: Wed Jan 8 23:15:49 2014 +0100 Committer: Paul J. Davis Committed: Thu Feb 6 11:25:49 2014 -0600 ---------------------------------------------------------------------- build_icu.sh | 191 + patches/icu/common-uloc_c.patch | 26 + patches/icu/layout_LookupProcessor_cpp.patch | 13 + patches/icu/source_config_Makefile_inc_in.patch | 12 + patches/icu/source_icudefs_mk_in.patch | 19 + platform/osx/icu/unicode/basictz.h | 210 + platform/osx/icu/unicode/brkiter.h | 557 +++ platform/osx/icu/unicode/calendar.h | 2170 +++++++++ platform/osx/icu/unicode/caniter.h | 201 + platform/osx/icu/unicode/chariter.h | 716 +++ platform/osx/icu/unicode/choicfmt.h | 746 +++ platform/osx/icu/unicode/coleitr.h | 400 ++ platform/osx/icu/unicode/coll.h | 1035 +++++ platform/osx/icu/unicode/curramt.h | 130 + platform/osx/icu/unicode/currunit.h | 117 + platform/osx/icu/unicode/datefmt.h | 700 +++ platform/osx/icu/unicode/dbbi.h | 41 + platform/osx/icu/unicode/dcfmtsym.h | 370 ++ platform/osx/icu/unicode/decimfmt.h | 1901 ++++++++ platform/osx/icu/unicode/docmain.h | 202 + platform/osx/icu/unicode/dtfmtsym.h | 721 +++ platform/osx/icu/unicode/dtintrv.h | 159 + platform/osx/icu/unicode/dtitvfmt.h | 949 ++++ platform/osx/icu/unicode/dtitvinf.h | 528 +++ platform/osx/icu/unicode/dtptngen.h | 423 ++ platform/osx/icu/unicode/dtrule.h | 250 ++ platform/osx/icu/unicode/fieldpos.h | 291 ++ platform/osx/icu/unicode/fmtable.h | 591 +++ platform/osx/icu/unicode/format.h | 296 ++ platform/osx/icu/unicode/gregocal.h | 823 ++++ platform/osx/icu/unicode/locid.h | 765 ++++ platform/osx/icu/unicode/measfmt.h | 77 + platform/osx/icu/unicode/measunit.h | 71 + platform/osx/icu/unicode/measure.h | 137 + platform/osx/icu/unicode/msgfmt.h | 940 ++++ platform/osx/icu/unicode/normlzr.h | 823 ++++ platform/osx/icu/unicode/numfmt.h | 886 ++++ platform/osx/icu/unicode/parseerr.h | 92 + platform/osx/icu/unicode/parsepos.h | 230 + platform/osx/icu/unicode/platform.h | 316 ++ platform/osx/icu/unicode/plurfmt.h | 541 +++ platform/osx/icu/unicode/plurrule.h | 291 ++ platform/osx/icu/unicode/ppalmos.h | 273 ++ platform/osx/icu/unicode/putil.h | 184 + platform/osx/icu/unicode/pwin32.h | 311 ++ platform/osx/icu/unicode/rbbi.h | 722 +++ platform/osx/icu/unicode/rbnf.h | 1049 +++++ platform/osx/icu/unicode/rbtz.h | 361 ++ platform/osx/icu/unicode/regex.h | 1232 +++++ platform/osx/icu/unicode/rep.h | 259 ++ platform/osx/icu/unicode/resbund.h | 485 ++ platform/osx/icu/unicode/schriter.h | 187 + platform/osx/icu/unicode/search.h | 569 +++ platform/osx/icu/unicode/simpletz.h | 927 ++++ platform/osx/icu/unicode/smpdtfmt.h | 975 ++++ platform/osx/icu/unicode/sortkey.h | 324 ++ platform/osx/icu/unicode/strenum.h | 271 ++ platform/osx/icu/unicode/stsearch.h | 518 +++ platform/osx/icu/unicode/symtable.h | 112 + platform/osx/icu/unicode/tblcoll.h | 926 ++++ platform/osx/icu/unicode/timezone.h | 803 ++++ platform/osx/icu/unicode/translit.h | 1323 ++++++ platform/osx/icu/unicode/tzrule.h | 828 ++++ platform/osx/icu/unicode/tztrans.h | 195 + platform/osx/icu/unicode/ubidi.h | 2013 +++++++++ platform/osx/icu/unicode/ubrk.h | 482 ++ platform/osx/icu/unicode/ucal.h | 1161 +++++ platform/osx/icu/unicode/ucasemap.h | 391 ++ platform/osx/icu/unicode/ucat.h | 158 + platform/osx/icu/unicode/uchar.h | 3062 +++++++++++++ platform/osx/icu/unicode/uchriter.h | 381 ++ platform/osx/icu/unicode/uclean.h | 267 ++ platform/osx/icu/unicode/ucnv.h | 1967 ++++++++ platform/osx/icu/unicode/ucnv_cb.h | 162 + platform/osx/icu/unicode/ucnv_err.h | 463 ++ platform/osx/icu/unicode/ucol.h | 1132 +++++ platform/osx/icu/unicode/ucoleitr.h | 315 ++ platform/osx/icu/unicode/uconfig.h | 228 + platform/osx/icu/unicode/ucsdet.h | 349 ++ platform/osx/icu/unicode/ucurr.h | 270 ++ platform/osx/icu/unicode/udat.h | 962 ++++ platform/osx/icu/unicode/udata.h | 389 ++ platform/osx/icu/unicode/udatpg.h | 471 ++ platform/osx/icu/unicode/udeprctd.h | 50 + platform/osx/icu/unicode/udraft.h | 166 + platform/osx/icu/unicode/uenum.h | 134 + platform/osx/icu/unicode/uidna.h | 312 ++ platform/osx/icu/unicode/uintrnal.h | 180 + platform/osx/icu/unicode/uiter.h | 707 +++ platform/osx/icu/unicode/uloc.h | 1046 +++++ platform/osx/icu/unicode/ulocdata.h | 192 + platform/osx/icu/unicode/umachine.h | 338 ++ platform/osx/icu/unicode/umisc.h | 60 + platform/osx/icu/unicode/umsg.h | 647 +++ platform/osx/icu/unicode/unifilt.h | 127 + platform/osx/icu/unicode/unifunct.h | 125 + platform/osx/icu/unicode/unimatch.h | 163 + platform/osx/icu/unicode/unirepl.h | 97 + platform/osx/icu/unicode/uniset.h | 1566 +++++++ platform/osx/icu/unicode/unistr.h | 4230 ++++++++++++++++++ platform/osx/icu/unicode/unorm.h | 576 +++ platform/osx/icu/unicode/unum.h | 869 ++++ platform/osx/icu/unicode/uobject.h | 308 ++ platform/osx/icu/unicode/uobslete.h | 32 + platform/osx/icu/unicode/urbtok.h | 126 + platform/osx/icu/unicode/uregex.h | 989 ++++ platform/osx/icu/unicode/urename.h | 1775 ++++++++ platform/osx/icu/unicode/urep.h | 155 + platform/osx/icu/unicode/ures.h | 871 ++++ platform/osx/icu/unicode/uscript.h | 254 ++ platform/osx/icu/unicode/usearch.h | 766 ++++ platform/osx/icu/unicode/uset.h | 1052 +++++ platform/osx/icu/unicode/usetiter.h | 318 ++ platform/osx/icu/unicode/ushape.h | 263 ++ platform/osx/icu/unicode/usprep.h | 156 + platform/osx/icu/unicode/ustring.h | 1479 ++++++ platform/osx/icu/unicode/usystem.h | 46 + platform/osx/icu/unicode/utext.h | 1562 +++++++ platform/osx/icu/unicode/utf.h | 227 + platform/osx/icu/unicode/utf16.h | 605 +++ platform/osx/icu/unicode/utf32.h | 23 + platform/osx/icu/unicode/utf8.h | 652 +++ platform/osx/icu/unicode/utf_old.h | 1171 +++++ platform/osx/icu/unicode/utmscale.h | 481 ++ platform/osx/icu/unicode/utrace.h | 358 ++ platform/osx/icu/unicode/utrans.h | 583 +++ platform/osx/icu/unicode/utypes.h | 801 ++++ platform/osx/icu/unicode/uversion.h | 275 ++ platform/osx/icu/unicode/vtzone.h | 443 ++ rebar.config.script | 66 +- 130 files changed, 74825 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch-collate/blob/32ffa429/build_icu.sh ---------------------------------------------------------------------- diff --git a/build_icu.sh b/build_icu.sh new file mode 100755 index 0000000..e6ba834 --- /dev/null +++ b/build_icu.sh @@ -0,0 +1,191 @@ +#!/bin/sh + +CORE_TOP=`pwd` +export CORE_TOP + +CURLBIN=`which curl` +if ! test -n "CURLBIN"; then + display_error "Error: curl is required. Add it to 'PATH'" + exit 1 +fi + +GUNZIP=`which gunzip` +UNZIP=`which unzip` +TAR=`which tar` +GNUMAKE=`which gmake 2>/dev/null || which make` +PATCHES=$CORE_TOP/patches +STATICLIBS=$CORE_TOP/.libs +DISTDIR=$CORE_TOP/.dists + +# icu sources +ICU_VER=4.4.2 +ICU_DISTNAME=icu4c-4_4_2-src.tgz +ICU_SITE=http://dl.refuge.io +ICUDIR=$STATICLIBS/icu_src/icu + + +[ "$MACHINE" ] || MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown" +[ "$RELEASE" ] || RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown" +[ "$SYSTEM" ] || SYSTEM=`(uname -s) 2>/dev/null` || SYSTEM="unknown" +[ "$BUILD" ] || VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown" + + +CFLAGS="-g -O2 -Wall" +LDFLAGS="-lstdc++" +ARCH= +ISA64= +GNUMAKE=make +CC=gcc +CXX=g++ +PATCH=patch +case "$SYSTEM" in + Linux) + ARCH=`arch 2>/dev/null` + ;; + FreeBSD|OpenBSD|NetBSD) + ARCH=`(uname -p) 2>/dev/null` + GNUMAKE=gmake + ;; + Darwin) + ARCH=`(uname -p) 2>/dev/null` + ISA64=`(sysctl -n hw.optional.x86_64) 2>/dev/null` + ;; + Solaris) + ARCH=`(uname -p) 2>/dev/null` + GNUMAKE=gmake + PATCH=gpatch + ;; + *) + ARCH="unknown" + ;; +esac + + +# TODO: add mirror & signature validation support +fetch() +{ + TARGET=$DISTDIR/$1 + if ! test -f $TARGET; then + echo "==> Fetch $1 to $TARGET" + $CURLBIN --progress-bar -L $2/$1 -o $TARGET + fi +} + +build_icu() +{ + fetch $ICU_DISTNAME $ICU_SITE + + mkdir -p $ICUDIR + + echo "==> icu (compile)" + + rm -rf $STATICLIBS/icu* + + cd $STATICLIBS + $GUNZIP -c $DISTDIR/$ICU_DISTNAME | $TAR xf - -C $STATICLIBS/icu_src + + # apply patches + cd $STATICLIBS/icu_src + for P in $PATCHES/icu/*.patch; do \ + (patch -p0 -i $P || echo "skipping patch"); \ + done + + cd $ICUDIR/source + + CFLAGS="-g -Wall -fPIC -Os" + + env CC="gcc" CXX="g++" CPPFLAGS="" LDFLAGS="-fPIC" \ + CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" \ + ./configure --disable-debug \ + --enable-static \ + --disable-shared \ + --disable-icuio \ + --disable-layout \ + --disable-extras \ + --disable-tests \ + --disable-samples \ + --prefix=$STATICLIBS/icu && \ + $GNUMAKE && $GNUMAKE install +} + +do_setup() +{ + echo "==> build icu" + mkdir -p $DISTDIR + mkdir -p $STATICLIBS +} + +do_builddeps() +{ + if [ ! -f $STATICLIBS/icu/lib/libicui18n.a ]; then + build_icu + fi +} + + +clean() +{ + rm -rf $STATICLIBS + rm -rf $DISTDIR +} + + + +usage() +{ + cat << EOF +Usage: $basename [command] [OPTIONS] + +The $basename command compile Mozilla Spidermonkey and ICU statically +for couch_core. + +Commands: + + all: build couch_core static libs + clean: clean static libs + -?: display usage + +Report bugs at . +EOF +} + + +if [ ! "x$COUCHDB_STATIC" = "x1" ]; then + exit 0 +fi + +if [ ! "x$USE_STATIC_ICU" = "x1" ]; then + exit 0 +fi + +if [ "x$1" = "x" ]; then + do_setup + do_builddeps + exit 0 +fi + +case "$1" in + all) + shift 1 + do_setup + do_builddeps + ;; + clean) + shift 1 + clean + ;; + help|--help|-h|-?) + usage + exit 0 + ;; + *) + echo $basename: ERROR Unknown command $arg 1>&2 + echo 1>&2 + usage 1>&2 + echo "### $basename: Exitting." 1>&2 + exit 1; + ;; +esac + + +exit 0 http://git-wip-us.apache.org/repos/asf/couchdb-couch-collate/blob/32ffa429/patches/icu/common-uloc_c.patch ---------------------------------------------------------------------- diff --git a/patches/icu/common-uloc_c.patch b/patches/icu/common-uloc_c.patch new file mode 100644 index 0000000..fe60732 --- /dev/null +++ b/patches/icu/common-uloc_c.patch @@ -0,0 +1,26 @@ +$FreeBSD: ports/devel/icu/files/patch-common-uloc.c,v 1.1 2011/12/23 14:54:18 crees Exp $ + +From http://bugs.icu-project.org/trac/ticket/8984 + +Submitted by: Andrei Lavreniyuk (thanks!) + +--- icu/source/common/uloc.c ++++ icu/source/common/uloc.c +@@ -1797,7 +1797,7 @@ + int32_t variantLen = _deleteVariant(variant, uprv_min(variantSize, (nameCapacity-len)), variantToCompare, n); + len -= variantLen; + if (variantLen > 0) { +- if (name[len-1] == '_') { /* delete trailing '_' */ ++ if (len > 0 && name[len-1] == '_') { /* delete trailing '_' */ + --len; + } + addKeyword = VARIANT_MAP[j].keyword; +@@ -1805,7 +1805,7 @@ + break; + } + } +- if (name[len-1] == '_') { /* delete trailing '_' */ ++ if (len > 0 && len <= nameCapacity && name[len-1] == '_') { /* delete trailing '_' */ + --len; + } + } http://git-wip-us.apache.org/repos/asf/couchdb-couch-collate/blob/32ffa429/patches/icu/layout_LookupProcessor_cpp.patch ---------------------------------------------------------------------- diff --git a/patches/icu/layout_LookupProcessor_cpp.patch b/patches/icu/layout_LookupProcessor_cpp.patch new file mode 100644 index 0000000..304d266 --- /dev/null +++ b/patches/icu/layout_LookupProcessor_cpp.patch @@ -0,0 +1,13 @@ +--- icu/source/layout/LookupProcessor.cpp ++++ icu/source/layout/LookupProcessor.cpp +@@ -201,7 +201,9 @@ + + if (requiredFeatureIndex != 0xFFFF) { + requiredFeatureTable = featureListTable->getFeatureTable(requiredFeatureIndex, &requiredFeatureTag); +- featureReferences += SWAPW(featureTable->lookupCount); ++ if (requiredFeatureTable) { ++ featureReferences += SWAPW(requiredFeatureTable->lookupCount); ++ } + } + + lookupOrderArray = LE_NEW_ARRAY(le_uint16, featureReferences); http://git-wip-us.apache.org/repos/asf/couchdb-couch-collate/blob/32ffa429/patches/icu/source_config_Makefile_inc_in.patch ---------------------------------------------------------------------- diff --git a/patches/icu/source_config_Makefile_inc_in.patch b/patches/icu/source_config_Makefile_inc_in.patch new file mode 100644 index 0000000..89d428e --- /dev/null +++ b/patches/icu/source_config_Makefile_inc_in.patch @@ -0,0 +1,12 @@ +--- icu/source/config/Makefile.inc.in.orig 2011-04-07 17:41:15.000000000 +0200 ++++ icu/source/config/Makefile.inc.in 2011-04-07 17:41:40.000000000 +0200 +@@ -44,8 +44,7 @@ + LIBICU = lib$(ICUPREFIX) + + # Static library prefix and file extension +-STATIC_PREFIX = s +-LIBSICU = lib$(STATIC_PREFIX)$(ICUPREFIX) ++LIBSICU = lib$(ICUPREFIX) + A = a + + # Suffix at the end of libraries. Usually empty. http://git-wip-us.apache.org/repos/asf/couchdb-couch-collate/blob/32ffa429/patches/icu/source_icudefs_mk_in.patch ---------------------------------------------------------------------- diff --git a/patches/icu/source_icudefs_mk_in.patch b/patches/icu/source_icudefs_mk_in.patch new file mode 100644 index 0000000..a1add5e --- /dev/null +++ b/patches/icu/source_icudefs_mk_in.patch @@ -0,0 +1,19 @@ +--- icu/source/icudefs.mk.in.orig 2011-04-07 17:15:44.000000000 +0200 ++++ icu/source/icudefs.mk.in 2011-04-07 17:15:56.000000000 +0200 +@@ -189,14 +189,13 @@ + + ## If we can't use the shared libraries, use the static libraries + ifneq ($(ENABLE_SHARED),YES) +-STATIC_PREFIX_WHEN_USED = s ++STATIC_PREFIX_WHEN_USED = + else + STATIC_PREFIX_WHEN_USED = + endif + + # Static library prefix and file extension +-STATIC_PREFIX = s +-LIBSICU = $(LIBPREFIX)$(STATIC_PREFIX)$(ICUPREFIX) ++LIBSICU = $(LIBPREFIX)$(ICUPREFIX) + A = a + SOBJ = $(SO) + http://git-wip-us.apache.org/repos/asf/couchdb-couch-collate/blob/32ffa429/platform/osx/icu/unicode/basictz.h ---------------------------------------------------------------------- diff --git a/platform/osx/icu/unicode/basictz.h b/platform/osx/icu/unicode/basictz.h new file mode 100644 index 0000000..c616a3e --- /dev/null +++ b/platform/osx/icu/unicode/basictz.h @@ -0,0 +1,210 @@ +/* +******************************************************************************* +* Copyright (C) 2007-2008, International Business Machines Corporation and * +* others. All Rights Reserved. * +******************************************************************************* +*/ +#ifndef BASICTZ_H +#define BASICTZ_H + +/** + * \file + * \brief C++ API: ICU TimeZone base class + */ + +#include "unicode/utypes.h" + +#if !UCONFIG_NO_FORMATTING + +#include "unicode/timezone.h" +#include "unicode/tzrule.h" +#include "unicode/tztrans.h" + +U_NAMESPACE_BEGIN + +// forward declarations +class UVector; + +/** + * BasicTimeZone is an abstract class extending TimeZone. + * This class provides some additional methods to access time zone transitions and rules. + * All ICU TimeZone concrete subclasses extend this class. + * @stable ICU 4.0 + */ +class U_I18N_API BasicTimeZone: public TimeZone { +public: + /** + * Destructor. + * @stable ICU 4.0 + */ + virtual ~BasicTimeZone(); + + /** + * Gets the first time zone transition after the base time. + * @param base The base time. + * @param inclusive Whether the base time is inclusive or not. + * @param result Receives the first transition after the base time. + * @return TRUE if the transition is found. + * @stable ICU 4.0 + */ + virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ = 0; + + /** + * Gets the most recent time zone transition before the base time. + * @param base The base time. + * @param inclusive Whether the base time is inclusive or not. + * @param result Receives the most recent transition before the base time. + * @return TRUE if the transition is found. + * @stable ICU 4.0 + */ + virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ = 0; + + /** + * Checks if the time zone has equivalent transitions in the time range. + * This method returns true when all of transition times, from/to standard + * offsets and DST savings used by this time zone match the other in the + * time range. + * @param tz The BasicTimeZone object to be compared with. + * @param start The start time of the evaluated time range (inclusive) + * @param end The end time of the evaluated time range (inclusive) + * @param ignoreDstAmount + * When true, any transitions with only daylight saving amount + * changes will be ignored, except either of them is zero. + * For example, a transition from rawoffset 3:00/dstsavings 1:00 + * to rawoffset 2:00/dstsavings 2:00 is excluded from the comparison, + * but a transtion from rawoffset 2:00/dstsavings 1:00 to + * rawoffset 3:00/dstsavings 0:00 is included. + * @param ec Output param to filled in with a success or an error. + * @return true if the other time zone has the equivalent transitions in the + * time range. + * @stable ICU 4.0 + */ + virtual UBool hasEquivalentTransitions(/*const*/ BasicTimeZone& tz, UDate start, UDate end, + UBool ignoreDstAmount, UErrorCode& ec) /*const*/; + + /** + * Returns the number of TimeZoneRules which represents time transitions, + * for this time zone, that is, all TimeZoneRules for this time zone except + * InitialTimeZoneRule. The return value range is 0 or any positive value. + * @param status Receives error status code. + * @return The number of TimeZoneRules representing time transitions. + * @stable ICU 4.0 + */ + virtual int32_t countTransitionRules(UErrorCode& status) /*const*/ = 0; + + /** + * Gets the InitialTimeZoneRule and the set of TimeZoneRule + * which represent time transitions for this time zone. On successful return, + * the argument initial points to non-NULL InitialTimeZoneRule and + * the array trsrules is filled with 0 or multiple TimeZoneRule + * instances up to the size specified by trscount. The results are referencing the + * rule instance held by this time zone instance. Therefore, after this time zone + * is destructed, they are no longer available. + * @param initial Receives the initial timezone rule + * @param trsrules Receives the timezone transition rules + * @param trscount On input, specify the size of the array 'transitions' receiving + * the timezone transition rules. On output, actual number of + * rules filled in the array will be set. + * @param status Receives error status code. + * @stable ICU 4.0 + */ + virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial, + const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/ = 0; + + /** + * Gets the set of time zone rules valid at the specified time. Some known external time zone + * implementations are not capable to handle historic time zone rule changes. Also some + * implementations can only handle certain type of rule definitions. + * If this time zone does not use any daylight saving time within about 1 year from the specified + * time, only the InitialTimeZone is returned. Otherwise, the rule for standard + * time and daylight saving time transitions are returned in addition to the + * InitialTimeZoneRule. The standard and daylight saving time transition rules are + * represented by AnnualTimeZoneRule with DateTimeRule::DOW for its date + * rule and DateTimeRule::WALL_TIME for its time rule. Because daylight saving time + * rule is changing time to time in many time zones and also mapping a transition time rule to + * different type is lossy transformation, the set of rules returned by this method may be valid + * for short period of time. + * The time zone rule objects returned by this method is owned by the caller, so the caller is + * responsible for deleting them after use. + * @param date The date used for extracting time zone rules. + * @param initial Receives the InitialTimeZone, always not NULL. + * @param std Receives the AnnualTimeZoneRule for standard time transitions. + * When this time time zone does not observe daylight saving times around the + * specified date, NULL is set. + * @param dst Receives the AnnualTimeZoneRule for daylight saving time + * transitions. When this time zone does not observer daylight saving times + * around the specified date, NULL is set. + * @param status Receives error status code. + * @stable ICU 4.0 + */ + virtual void getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial, + AnnualTimeZoneRule*& std, AnnualTimeZoneRule*& dst, UErrorCode& status) /*const*/; + + + /** + * The time type option bit flags used by getOffsetFromLocal + * @internal + */ + enum { + kStandard = 0x01, + kDaylight = 0x03, + kFormer = 0x04, + kLatter = 0x0C + }; + + /** + * Get time zone offsets from local wall time. + * @internal + */ + virtual void getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32_t duplicatedTimeOpt, + int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) /*const*/; + +protected: + + /** + * The time type option bit masks used by getOffsetFromLocal + * @internal + */ + enum { + kStdDstMask = kDaylight, + kFormerLatterMask = kLatter + }; + + /** + * Default constructor. + * @stable ICU 4.0 + */ + BasicTimeZone(); + + /** + * Construct a timezone with a given ID. + * @param id a system time zone ID + * @stable ICU 4.0 + */ + BasicTimeZone(const UnicodeString &id); + + /** + * Copy constructor. + * @param source the object to be copied. + * @stable ICU 4.0 + */ + BasicTimeZone(const BasicTimeZone& source); + + /** + * Gets the set of TimeZoneRule instances applicable to the specified time and after. + * @param start The start date used for extracting time zone rules + * @param initial Receives the InitialTimeZone, always not NULL + * @param transitionRules Receives the transition rules, could be NULL + * @param status Receives error status code + */ + void getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial, UVector*& transitionRules, + UErrorCode& status) /*const*/; +}; + +U_NAMESPACE_END + +#endif /* #if !UCONFIG_NO_FORMATTING */ + +#endif // BASICTZ_H + +//eof http://git-wip-us.apache.org/repos/asf/couchdb-couch-collate/blob/32ffa429/platform/osx/icu/unicode/brkiter.h ---------------------------------------------------------------------- diff --git a/platform/osx/icu/unicode/brkiter.h b/platform/osx/icu/unicode/brkiter.h new file mode 100644 index 0000000..7df5f14 --- /dev/null +++ b/platform/osx/icu/unicode/brkiter.h @@ -0,0 +1,557 @@ +/* +******************************************************************************** +* Copyright (C) 1997-2007, International Business Machines +* Corporation and others. All Rights Reserved. +******************************************************************************** +* +* File brkiter.h +* +* Modification History: +* +* Date Name Description +* 02/18/97 aliu Added typedef for TextCount. Made DONE const. +* 05/07/97 aliu Fixed DLL declaration. +* 07/09/97 jfitz Renamed BreakIterator and interface synced with JDK +* 08/11/98 helena Sync-up JDK1.2. +* 01/13/2000 helena Added UErrorCode parameter to createXXXInstance methods. +******************************************************************************** +*/ + +#ifndef BRKITER_H +#define BRKITER_H + +#include "unicode/utypes.h" + +/** + * \file + * \brief C++ API: Break Iterator. + */ + +#if UCONFIG_NO_BREAK_ITERATION + +U_NAMESPACE_BEGIN + +/* + * Allow the declaration of APIs with pointers to BreakIterator + * even when break iteration is removed from the build. + */ +class BreakIterator; + +U_NAMESPACE_END + +#else + +#include "unicode/uobject.h" +#include "unicode/unistr.h" +#include "unicode/chariter.h" +#include "unicode/locid.h" +#include "unicode/ubrk.h" +#include "unicode/strenum.h" +#include "unicode/utext.h" +#include "unicode/umisc.h" + +U_NAMESPACE_BEGIN + +/** + * The BreakIterator class implements methods for finding the location + * of boundaries in text. BreakIterator is an abstract base class. + * Instances of BreakIterator maintain a current position and scan over + * text returning the index of characters where boundaries occur. + *

+ * Line boundary analysis determines where a text string can be broken + * when line-wrapping. The mechanism correctly handles punctuation and + * hyphenated words. + *

+ * Sentence boundary analysis allows selection with correct + * interpretation of periods within numbers and abbreviations, and + * trailing punctuation marks such as quotation marks and parentheses. + *

+ * Word boundary analysis is used by search and replace functions, as + * well as within text editing applications that allow the user to + * select words with a double click. Word selection provides correct + * interpretation of punctuation marks within and following + * words. Characters that are not part of a word, such as symbols or + * punctuation marks, have word-breaks on both sides. + *

+ * Character boundary analysis allows users to interact with + * characters as they expect to, for example, when moving the cursor + * through a text string. Character boundary analysis provides correct + * navigation of through character strings, regardless of how the + * character is stored. For example, an accented character might be + * stored as a base character and a diacritical mark. What users + * consider to be a character can differ between languages. + *

+ * The text boundary positions are found according to the rules + * described in Unicode Standard Annex #29, Text Boundaries, and + * Unicode Standard Annex #14, Line Breaking Properties. These + * are available at http://www.unicode.org/reports/tr14/ and + * http://www.unicode.org/reports/tr29/. + *

+ * In addition to the C++ API defined in this header file, a + * plain C API with equivalent functionality is defined in the + * file ubrk.h + *

+ * Code snippits illustrating the use of the Break Iterator APIs + * are available in the ICU User Guide, + * http://icu-project.org/userguide/boundaryAnalysis.html + * and in the sample program icu/source/samples/break/break.cpp" + * + */ +class U_COMMON_API BreakIterator : public UObject { +public: + /** + * destructor + * @stable ICU 2.0 + */ + virtual ~BreakIterator(); + + /** + * Return true if another object is semantically equal to this + * one. The other object should be an instance of the same subclass of + * BreakIterator. Objects of different subclasses are considered + * unequal. + *

+ * Return true if this BreakIterator is at the same position in the + * same text, and is the same class and type (word, line, etc.) of + * BreakIterator, as the argument. Text is considered the same if + * it contains the same characters, it need not be the same + * object, and styles are not considered. + * @stable ICU 2.0 + */ + virtual UBool operator==(const BreakIterator&) const = 0; + + /** + * Returns the complement of the result of operator== + * @param rhs The BreakIterator to be compared for inequality + * @return the complement of the result of operator== + * @stable ICU 2.0 + */ + UBool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); } + + /** + * Return a polymorphic copy of this object. This is an abstract + * method which subclasses implement. + * @stable ICU 2.0 + */ + virtual BreakIterator* clone(void) const = 0; + + /** + * Return a polymorphic class ID for this object. Different subclasses + * will return distinct unequal values. + * @stable ICU 2.0 + */ + virtual UClassID getDynamicClassID(void) const = 0; + + /** + * Return a CharacterIterator over the text being analyzed. + * @stable ICU 2.0 + */ + virtual CharacterIterator& getText(void) const = 0; + + + /** + * Get a UText for the text being analyzed. + * The returned UText is a shallow clone of the UText used internally + * by the break iterator implementation. It can safely be used to + * access the text without impacting any break iterator operations, + * but the underlying text itself must not be altered. + * + * @param fillIn A UText to be filled in. If NULL, a new UText will be + * allocated to hold the result. + * @param status receives any error codes. + * @return The current UText for this break iterator. If an input + * UText was provided, it will always be returned. + * @stable ICU 3.4 + */ + virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0; + + /** + * Change the text over which this operates. The text boundary is + * reset to the start. + * @param text The UnicodeString used to change the text. + * @stable ICU 2.0 + */ + virtual void setText(const UnicodeString &text) = 0; + + /** + * Reset the break iterator to operate over the text represented by + * the UText. The iterator position is reset to the start. + * + * This function makes a shallow clone of the supplied UText. This means + * that the caller is free to immediately close or otherwise reuse the + * Utext that was passed as a parameter, but that the underlying text itself + * must not be altered while being referenced by the break iterator. + * + * @param text The UText used to change the text. + * @param status receives any error codes. + * @stable ICU 3.4 + */ + virtual void setText(UText *text, UErrorCode &status) = 0; + + /** + * Change the text over which this operates. The text boundary is + * reset to the start. + * Note that setText(UText *) provides similar functionality to this function, + * and is more efficient. + * @param it The CharacterIterator used to change the text. + * @stable ICU 2.0 + */ + virtual void adoptText(CharacterIterator* it) = 0; + + enum { + /** + * DONE is returned by previous() and next() after all valid + * boundaries have been returned. + * @stable ICU 2.0 + */ + DONE = (int32_t)-1 + }; + + /** + * Return the index of the first character in the text being scanned. + * @stable ICU 2.0 + */ + virtual int32_t first(void) = 0; + + /** + * Return the index immediately BEYOND the last character in the text being scanned. + * @stable ICU 2.0 + */ + virtual int32_t last(void) = 0; + + /** + * Return the boundary preceding the current boundary. + * @return The character index of the previous text boundary or DONE if all + * boundaries have been returned. + * @stable ICU 2.0 + */ + virtual int32_t previous(void) = 0; + + /** + * Return the boundary following the current boundary. + * @return The character index of the next text boundary or DONE if all + * boundaries have been returned. + * @stable ICU 2.0 + */ + virtual int32_t next(void) = 0; + + /** + * Return character index of the current interator position within the text. + * @return The boundary most recently returned. + * @stable ICU 2.0 + */ + virtual int32_t current(void) const = 0; + + /** + * Return the first boundary following the specified offset. + * The value returned is always greater than the offset or + * the value BreakIterator.DONE + * @param offset the offset to begin scanning. + * @return The first boundary after the specified offset. + * @stable ICU 2.0 + */ + virtual int32_t following(int32_t offset) = 0; + + /** + * Return the first boundary preceding the specified offset. + * The value returned is always smaller than the offset or + * the value BreakIterator.DONE + * @param offset the offset to begin scanning. + * @return The first boundary before the specified offset. + * @stable ICU 2.0 + */ + virtual int32_t preceding(int32_t offset) = 0; + + /** + * Return true if the specfied position is a boundary position. + * As a side effect, the current position of the iterator is set + * to the first boundary position at or following the specified offset. + * @param offset the offset to check. + * @return True if "offset" is a boundary position. + * @stable ICU 2.0 + */ + virtual UBool isBoundary(int32_t offset) = 0; + + /** + * Return the nth boundary from the current boundary + * @param n which boundary to return. A value of 0 + * does nothing. Negative values move to previous boundaries + * and positive values move to later boundaries. + * @return The index of the nth boundary from the current position, or + * DONE if there are fewer than |n| boundaries in the specfied direction. + * @stable ICU 2.0 + */ + virtual int32_t next(int32_t n) = 0; + + /** + * Create BreakIterator for word-breaks using the given locale. + * Returns an instance of a BreakIterator implementing word breaks. + * WordBreak is useful for word selection (ex. double click) + * @param where the locale. + * @param status the error code + * @return A BreakIterator for word-breaks. The UErrorCode& status + * parameter is used to return status information to the user. + * To check whether the construction succeeded or not, you should check + * the value of U_SUCCESS(err). If you wish more detailed information, you + * can check for informational error results which still indicate success. + * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For + * example, 'de_CH' was requested, but nothing was found there, so 'de' was + * used. U_USING_DEFAULT_WARNING indicates that the default locale data was + * used; neither the requested locale nor any of its fall back locales + * could be found. + * The caller owns the returned object and is responsible for deleting it. + * @stable ICU 2.0 + */ + static BreakIterator* U_EXPORT2 + createWordInstance(const Locale& where, UErrorCode& status); + + /** + * Create BreakIterator for line-breaks using specified locale. + * Returns an instance of a BreakIterator implementing line breaks. Line + * breaks are logically possible line breaks, actual line breaks are + * usually determined based on display width. + * LineBreak is useful for word wrapping text. + * @param where the locale. + * @param status The error code. + * @return A BreakIterator for line-breaks. The UErrorCode& status + * parameter is used to return status information to the user. + * To check whether the construction succeeded or not, you should check + * the value of U_SUCCESS(err). If you wish more detailed information, you + * can check for informational error results which still indicate success. + * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For + * example, 'de_CH' was requested, but nothing was found there, so 'de' was + * used. U_USING_DEFAULT_WARNING indicates that the default locale data was + * used; neither the requested locale nor any of its fall back locales + * could be found. + * The caller owns the returned object and is responsible for deleting it. + * @stable ICU 2.0 + */ + static BreakIterator* U_EXPORT2 + createLineInstance(const Locale& where, UErrorCode& status); + + /** + * Create BreakIterator for character-breaks using specified locale + * Returns an instance of a BreakIterator implementing character breaks. + * Character breaks are boundaries of combining character sequences. + * @param where the locale. + * @param status The error code. + * @return A BreakIterator for character-breaks. The UErrorCode& status + * parameter is used to return status information to the user. + * To check whether the construction succeeded or not, you should check + * the value of U_SUCCESS(err). If you wish more detailed information, you + * can check for informational error results which still indicate success. + * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For + * example, 'de_CH' was requested, but nothing was found there, so 'de' was + * used. U_USING_DEFAULT_WARNING indicates that the default locale data was + * used; neither the requested locale nor any of its fall back locales + * could be found. + * The caller owns the returned object and is responsible for deleting it. + * @stable ICU 2.0 + */ + static BreakIterator* U_EXPORT2 + createCharacterInstance(const Locale& where, UErrorCode& status); + + /** + * Create BreakIterator for sentence-breaks using specified locale + * Returns an instance of a BreakIterator implementing sentence breaks. + * @param where the locale. + * @param status The error code. + * @return A BreakIterator for sentence-breaks. The UErrorCode& status + * parameter is used to return status information to the user. + * To check whether the construction succeeded or not, you should check + * the value of U_SUCCESS(err). If you wish more detailed information, you + * can check for informational error results which still indicate success. + * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For + * example, 'de_CH' was requested, but nothing was found there, so 'de' was + * used. U_USING_DEFAULT_WARNING indicates that the default locale data was + * used; neither the requested locale nor any of its fall back locales + * could be found. + * The caller owns the returned object and is responsible for deleting it. + * @stable ICU 2.0 + */ + static BreakIterator* U_EXPORT2 + createSentenceInstance(const Locale& where, UErrorCode& status); + + /** + * Create BreakIterator for title-casing breaks using the specified locale + * Returns an instance of a BreakIterator implementing title breaks. + * The iterator returned locates title boundaries as described for + * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration, + * please use Word Boundary iterator.{@link #createWordInstance } + * + * @param where the locale. + * @param status The error code. + * @return A BreakIterator for title-breaks. The UErrorCode& status + * parameter is used to return status information to the user. + * To check whether the construction succeeded or not, you should check + * the value of U_SUCCESS(err). If you wish more detailed information, you + * can check for informational error results which still indicate success. + * U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For + * example, 'de_CH' was requested, but nothing was found there, so 'de' was + * used. U_USING_DEFAULT_WARNING indicates that the default locale data was + * used; neither the requested locale nor any of its fall back locales + * could be found. + * The caller owns the returned object and is responsible for deleting it. + * @stable ICU 2.1 + */ + static BreakIterator* U_EXPORT2 + createTitleInstance(const Locale& where, UErrorCode& status); + + /** + * Get the set of Locales for which TextBoundaries are installed. + *

Note: this will not return locales added through the register + * call. To see the registered locales too, use the getAvailableLocales + * function that returns a StringEnumeration object

+ * @param count the output parameter of number of elements in the locale list + * @return available locales + * @stable ICU 2.0 + */ + static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count); + + /** + * Get name of the object for the desired Locale, in the desired langauge. + * @param objectLocale must be from getAvailableLocales. + * @param displayLocale specifies the desired locale for output. + * @param name the fill-in parameter of the return value + * Uses best match. + * @return user-displayable name + * @stable ICU 2.0 + */ + static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale, + const Locale& displayLocale, + UnicodeString& name); + + /** + * Get name of the object for the desired Locale, in the langauge of the + * default locale. + * @param objectLocale must be from getMatchingLocales + * @param name the fill-in parameter of the return value + * @return user-displayable name + * @stable ICU 2.0 + */ + static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale, + UnicodeString& name); + + /** + * Thread safe client-buffer-based cloning operation + * Do NOT call delete on a safeclone, since 'new' is not used to create it. + * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated. + * If buffer is not large enough, new memory will be allocated. + * @param BufferSize reference to size of allocated space. + * If BufferSize == 0, a sufficient size for use in cloning will + * be returned ('pre-flighting') + * If BufferSize is not enough for a stack-based safe clone, + * new memory will be allocated. + * @param status to indicate whether the operation went on smoothly or there were errors + * An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were + * necessary. + * @return pointer to the new clone + * + * @stable ICU 2.0 + */ + virtual BreakIterator * createBufferClone(void *stackBuffer, + int32_t &BufferSize, + UErrorCode &status) = 0; + + /** + * Determine whether the BreakIterator was created in user memory by + * createBufferClone(), and thus should not be deleted. Such objects + * must be closed by an explicit call to the destructor (not delete). + * @stable ICU 2.0 + */ + inline UBool isBufferClone(void); + +#if !UCONFIG_NO_SERVICE + /** + * Register a new break iterator of the indicated kind, to use in the given locale. + * The break iterator will be adopted. Clones of the iterator will be returned + * if a request for a break iterator of the given kind matches or falls back to + * this locale. + * @param toAdopt the BreakIterator instance to be adopted + * @param locale the Locale for which this instance is to be registered + * @param kind the type of iterator for which this instance is to be registered + * @param status the in/out status code, no special meanings are assigned + * @return a registry key that can be used to unregister this instance + * @stable ICU 2.4 + */ + static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt, + const Locale& locale, + UBreakIteratorType kind, + UErrorCode& status); + + /** + * Unregister a previously-registered BreakIterator using the key returned from the + * register call. Key becomes invalid after a successful call and should not be used again. + * The BreakIterator corresponding to the key will be deleted. + * @param key the registry key returned by a previous call to registerInstance + * @param status the in/out status code, no special meanings are assigned + * @return TRUE if the iterator for the key was successfully unregistered + * @stable ICU 2.4 + */ + static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status); + + /** + * Return a StringEnumeration over the locales available at the time of the call, + * including registered locales. + * @return a StringEnumeration over the locales available at the time of the call + * @stable ICU 2.4 + */ + static StringEnumeration* U_EXPORT2 getAvailableLocales(void); +#endif + + /** + * Returns the locale for this break iterator. Two flavors are available: valid and + * actual locale. + * @stable ICU 2.8 + */ + Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const; + + /** Get the locale for this break iterator object. You can choose between valid and actual locale. + * @param type type of the locale we're looking for (valid or actual) + * @param status error code for the operation + * @return the locale + * @internal + */ + const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const; + + private: + static BreakIterator* buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode& status); + static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status); + static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status); + + friend class ICUBreakIteratorFactory; + friend class ICUBreakIteratorService; + +protected: + /** @internal */ + BreakIterator(); + /** @internal */ + UBool fBufferClone; + /** @internal */ + BreakIterator (const BreakIterator &other) : UObject(other), fBufferClone(FALSE) {} + +private: + + /** @internal */ + char actualLocale[ULOC_FULLNAME_CAPACITY]; + char validLocale[ULOC_FULLNAME_CAPACITY]; + + /** + * The assignment operator has no real implementation. + * It's provided to make the compiler happy. Do not call. + */ + BreakIterator& operator=(const BreakIterator&); +}; + +inline UBool BreakIterator::isBufferClone() +{ + return fBufferClone; +} + +U_NAMESPACE_END + +#endif /* #if !UCONFIG_NO_BREAK_ITERATION */ + +#endif // _BRKITER +//eof +