From f940a828ebc36e86db558233cc13fb8fc074ed73 Mon Sep 17 00:00:00 2001 From: Andy Heninger Date: Fri, 17 Apr 2009 01:02:11 +0000 Subject: [PATCH] ICU-5260 'multiple passes' rules in C API of the transliteration functions X-SVN-Rev: 25806 --- icu4c/source/i18n/utrans.cpp | 15 ++++++--------- icu4c/source/test/cintltst/utransts.c | 9 ++++++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/icu4c/source/i18n/utrans.cpp b/icu4c/source/i18n/utrans.cpp index 11da9d79438..16a09bdcb6a 100644 --- a/icu4c/source/i18n/utrans.cpp +++ b/icu4c/source/i18n/utrans.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1997-2005, International Business Machines + * Copyright (C) 1997-2009, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************* * Date Name Description @@ -166,15 +166,12 @@ utrans_openU(const UChar *id, rules, rulesLength); // r-o alias - RuleBasedTransliterator *trans = NULL; - trans = new RuleBasedTransliterator(ID, ruleStr, dir, - NULL, *parseError, *status); - if (trans == NULL) { - *status = U_MEMORY_ALLOCATION_ERROR; - } else if (U_FAILURE(*status)) { - delete trans; - trans = NULL; + Transliterator *trans = NULL; + trans = Transliterator::createFromRules(ID, ruleStr, dir, *parseError, *status); + if(U_FAILURE(*status)) { + return NULL; } + return (UTransliterator*) trans; } } diff --git a/icu4c/source/test/cintltst/utransts.c b/icu4c/source/test/cintltst/utransts.c index ec99292aa9f..e0e970c5ad6 100644 --- a/icu4c/source/test/cintltst/utransts.c +++ b/icu4c/source/test/cintltst/utransts.c @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1997-2006, International Business Machines + * Copyright (C) 1997-2009, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************* * Date Name Description @@ -474,6 +474,13 @@ static void TestSimpleRules() { "$lu > '*';" "a > ERROR", "abcdefgABCDEFGU", "&bcd&fg!^**!^*&"); + + /* Test multiple passes + */ + _expectRules("abc > xy;" + "::Null;" + "aba > z;", + "abc ababc aba", "xy abxy z"); } static void TestFilter() {