ICU-2860 add UCONFIG_NO_NORMALIZATION and UCONFIG_NO_IDNA

X-SVN-Rev: 11808
This commit is contained in:
Markus Scherer 2003-05-06 01:22:23 +00:00
parent 8554a06031
commit 9a4e0e4af2
24 changed files with 192 additions and 33 deletions

View File

@ -1,10 +1,14 @@
/*
*****************************************************************************
* Copyright (C) 1996-2002, International Business Machines Corporation and *
* Copyright (C) 1996-2003, International Business Machines Corporation and *
* others. All Rights Reserved. *
*****************************************************************************
*/
#include "unicode/utypes.h"
#if !UCONFIG_NO_NORMALIZATION
#include "unicode/uset.h"
#include "unicode/ustring.h"
#include "hash.h"
@ -687,3 +691,5 @@ Hashtable *CanonicalIterator::extract(UChar32 comp, const UChar *segment, int32_
}
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_NORMALIZATION */

View File

@ -1,12 +1,15 @@
/*
*************************************************************************
* COPYRIGHT:
* Copyright (c) 1996-2001, International Business Machines Corporation and
* Copyright (c) 1996-2003, International Business Machines Corporation and
* others. All Rights Reserved.
*************************************************************************
*/
#include "unicode/utypes.h"
#if !UCONFIG_NO_NORMALIZATION
#include "unicode/unistr.h"
#include "unicode/chariter.h"
#include "unicode/schriter.h"
@ -604,3 +607,5 @@ Normalizer::previousNormalize() {
}
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_NORMALIZATION */

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2002, International Business Machines Corporation and *
* Copyright (C) 1996-2003, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -9,6 +9,9 @@
#define CANITER_H
#include "unicode/utypes.h"
#if !UCONFIG_NO_NORMALIZATION
#include "unicode/uobject.h"
#include "unicode/unistr.h"
@ -200,4 +203,7 @@ CanonicalIterator::getDynamicClassID() const
{ return CanonicalIterator::getStaticClassID(); }
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_NORMALIZATION */
#endif

View File

@ -10,6 +10,9 @@
#define NORMLZR_H
#include "unicode/utypes.h"
#if !UCONFIG_NO_NORMALIZATION
#include "unicode/uobject.h"
#include "unicode/unistr.h"
#include "unicode/chariter.h"
@ -807,4 +810,7 @@ Normalizer::compare(const UnicodeString &s1, const UnicodeString &s2,
}
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_NORMALIZATION */
#endif // NORMLZR_H

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (C) 2002, International Business Machines
* Copyright (C) 2002-2003, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* file name: uconfig.h
@ -45,6 +45,7 @@
#if UCONFIG_ONLY_COLLATION
/* common library */
# define UCONFIG_NO_BREAK_ITERATION 1
# define UCONFIG_NO_IDNA 1
/* i18n library */
# if UCONFIG_NO_COLLATION
@ -73,6 +74,28 @@
# define UCONFIG_NO_LEGACY_CONVERSION 0
#endif
/**
* \def UCONFIG_NO_NORMALIZATION
* This switch turns off normalization.
* It implies turning off several other services as well, for example
* collation and IDNA.
*
* @draft ICU 2.6
*/
#ifndef UCONFIG_NO_NORMALIZATION
# define UCONFIG_NO_NORMALIZATION 0
#elif UCONFIG_NO_NORMALIZATION
/* common library */
# define UCONFIG_NO_IDNA 1
/* i18n library */
# if UCONFIG_ONLY_COLLATION
# error Contradictory collation switches in uconfig.h.
# endif
# define UCONFIG_NO_COLLATION 1
# define UCONFIG_NO_TRANSLITERATION 1
#endif
/**
* \def UCONFIG_NO_BREAK_ITERATION
* This switch turns off break iteration.
@ -83,6 +106,16 @@
# define UCONFIG_NO_BREAK_ITERATION 0
#endif
/**
* \def UCONFIG_NO_IDNA
* This switch turns off IDNA.
*
* @draft ICU 2.6
*/
#ifndef UCONFIG_NO_IDNA
# define UCONFIG_NO_IDNA 0
#endif
/* i18n library switches ---------------------------------------------------- */
/**

View File

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2001, International Business Machines Corporation and
* Copyright (c) 1997-2003, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@ -15,12 +15,21 @@
*********************************************************************************/
/*tests for u_normalization*/
#include "unicode/utypes.h"
#include "cintltst.h"
#if UCONFIG_NO_NORMALIZATION
void addNormTest(TestNode** root) {
/* no normalization - nothing to do */
}
#else
#include <stdlib.h>
#include <time.h>
#include "unicode/uchar.h"
#include "unicode/ustring.h"
#include "unicode/unorm.h"
#include "cintltst.h"
#include "cnormtst.h"
#define ARRAY_LENGTH(array) (sizeof (array) / sizeof (*array))
@ -101,8 +110,6 @@ const static char* compatTests[][3] = {
};
void addNormTest(TestNode** root);
void addNormTest(TestNode** root)
{
addTest(root, &TestAPI, "tscoll/cnormtst/TestAPI");
@ -1367,3 +1374,5 @@ TestFCNFKCClosure(void) {
log_err("u_getFC_NFKC_Closure(U_FAILURE) is wrong (%s)\n", u_errorName(errorCode));
}
}
#endif /* #if !UCONFIG_NO_NORMALIZATION */

View File

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2001, International Business Machines Corporation and
* Copyright (c) 1997-2003, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@ -960,9 +960,11 @@ unicodeDataLineFn(void *context,
log_err("error in UnicodeData.txt: combining class %lu out of range\n", value);
return;
}
#if !UCONFIG_NO_NORMALIZATION
if(value!=u_getCombiningClass(c) || value!=(uint32_t)u_getIntPropertyValue(c, UCHAR_CANONICAL_COMBINING_CLASS)) {
log_err("error: u_getCombiningClass(U+%04lx)==%hu instead of %lu\n", c, u_getCombiningClass(c), value);
}
#endif
/* get BiDi category, field 4 */
*fields[4][1]=0;
@ -2240,9 +2242,11 @@ TestAdditionalProperties() {
{ 0x0e46, UCHAR_EXTENDER, TRUE },
{ 0x0020, UCHAR_EXTENDER, FALSE },
#if !UCONFIG_NO_NORMALIZATION
{ 0xfb1d, UCHAR_FULL_COMPOSITION_EXCLUSION, TRUE },
{ 0x1d15f, UCHAR_FULL_COMPOSITION_EXCLUSION, TRUE },
{ 0xfb1e, UCHAR_FULL_COMPOSITION_EXCLUSION, FALSE },
#endif
{ 0x0044, UCHAR_HEX_DIGIT, TRUE },
{ 0xff46, UCHAR_HEX_DIGIT, TRUE },
@ -2833,12 +2837,16 @@ _setAddSerialized(USet *set, const USerializedSet *sset) {
/* various tests for consistency of UCD data and API behavior */
static void
TestConsistency() {
#if !UCONFIG_NO_NORMALIZATION
UChar buffer16[300];
#endif
char buffer[300];
USet *set1, *set2, *set3, *set4;
UErrorCode errorCode;
#if !UCONFIG_NO_NORMALIZATION
USerializedSet sset;
#endif
UChar32 start, end;
int32_t i, length;
@ -2938,6 +2946,8 @@ TestConsistency() {
}
uset_close(set1);
#if !UCONFIG_NO_NORMALIZATION
/*
* Test for an example that unorm_getCanonStartSet() delivers
* all characters that compose from the input one,
@ -2965,4 +2975,6 @@ TestConsistency() {
TRUE);
uset_close(set1);
uset_close(set2);
#endif
}

View File

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 2002, International Business Machines Corporation and
* Copyright (c) 2003, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************
*
@ -8,6 +8,9 @@
* @author Vladimir Weinstein
*/
#include "unicode/utypes.h"
#if !UCONFIG_NO_NORMALIZATION
#include "intltest.h"
#include "cstring.h"
@ -306,4 +309,4 @@ void CanonicalIteratorTest::TestAPI() {
}
}
#endif /* #if !UCONFIG_NO_NORMALIZATION */

View File

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 2002, International Business Machines Corporation and
* Copyright (c) 2002-2003, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************
*
@ -17,6 +17,9 @@
#include "unicode/utypes.h"
#if !UCONFIG_NO_NORMALIZATION
U_NAMESPACE_BEGIN
class Transliterator;
@ -50,4 +53,6 @@ private:
UnicodeString getReadable(const UnicodeString &obj);
};
#endif /* #if !UCONFIG_NO_NORMALIZATION */
#endif // _CANITTST

View File

@ -1,11 +1,11 @@
/*
*******************************************************************************
*
* Copyright (C) 2002, International Business Machines
* Copyright (C) 2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: strprep.cpp
* file name: idnaref.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
@ -13,6 +13,11 @@
* created on: 2003feb1
* created by: Ram Viswanadha
*/
#include "unicode/utypes.h"
#if !UCONFIG_NO_IDNA
#include "idnaref.h"
#include "strprep.h"
#include "punyref.h"
@ -968,3 +973,4 @@ CLEANUP:
return result;
}
#endif /* #if !UCONFIG_NO_IDNA */

View File

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 2002, International Business Machines
* Copyright (C) 2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -18,6 +18,9 @@
#define __IDNAREF_H__
#include "unicode/utypes.h"
#if !UCONFIG_NO_IDNA
#include "unicode/parseerr.h"
#define IDNAREF_DEFAULT 0x0000
@ -220,7 +223,6 @@ idnaref_compare( const UChar *s1, int32_t length1,
int32_t options,
UErrorCode* status);
#endif /* #if !UCONFIG_NO_IDNA */
#endif

View File

@ -52,11 +52,13 @@ void MajorTestLevel::runIndexedTest( int32_t index, UBool exec, const char* &nam
break;
case 1: name = "normalize";
#if !UCONFIG_NO_NORMALIZATION
if (exec) {
logln("TestSuite Normalize---"); logln();
IntlTestNormalize test;
callTest( test, par );
}
#endif
break;
case 2: name = "collate";
@ -137,11 +139,13 @@ void MajorTestLevel::runIndexedTest( int32_t index, UBool exec, const char* &nam
#endif
break;
case 10: name = "idna";
#if !UCONFIG_NO_IDNA
if(exec){
logln("TestSuite IDNA----"); logln();
TestIDNA test;
callTest(test,par);
}
#endif
break;
default: name = ""; break;
}
@ -150,6 +154,9 @@ void MajorTestLevel::runIndexedTest( int32_t index, UBool exec, const char* &nam
void IntlTestNormalize::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par )
{
if(exec) logln("TestSuite Normalize:");
#if UCONFIG_NO_NORMALIZATION
name="";
#else
switch (index) {
CASE_SUITE(0, BasicNormalizerTest);
CASE_SUITE(1, NormalizerConformanceTest); // this takes a long time
@ -158,4 +165,5 @@ void IntlTestNormalize::runIndexedTest( int32_t index, UBool exec, const char* &
name="";
break;
}
#endif
}

View File

@ -1,11 +1,14 @@
/*
************************************************************************
* Copyright (c) 1997-2002, International Business Machines
* Copyright (c) 1997-2003, International Business Machines
* Corporation and others. All Rights Reserved.
************************************************************************
*/
#include "unicode/utypes.h"
#if !UCONFIG_NO_NORMALIZATION
#include "unicode/uchar.h"
#include "unicode/normlzr.h"
#include "unicode/uniset.h"
@ -556,3 +559,5 @@ void NormalizerConformanceTest::_testOneLine(const char *line) {
checkConformance(fields, line, 0);
}
}
#endif /* #if !UCONFIG_NO_NORMALIZATION */

View File

@ -1,6 +1,6 @@
/*
************************************************************************
* Copyright (c) 1997-2001, International Business Machines
* Copyright (c) 1997-2003, International Business Machines
* Corporation and others. All Rights Reserved.
************************************************************************
*/
@ -9,6 +9,9 @@
#define _NORMCONF
#include "unicode/utypes.h"
#if !UCONFIG_NO_NORMALIZATION
#include "unicode/normlzr.h"
#include "intltest.h"
@ -96,4 +99,6 @@ class NormalizerConformanceTest : public IntlTest {
void compare(const UnicodeString& s1,const UnicodeString& s2);
};
#endif /* #if !UCONFIG_NO_NORMALIZATION */
#endif

View File

@ -1,11 +1,11 @@
/*
*******************************************************************************
*
* Copyright (C) 2002, International Business Machines
* Copyright (C) 2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: nameprep.h
* file name: nptrans.h
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
@ -14,6 +14,10 @@
* created by: Ram Viswanadha
*/
#include "unicode/utypes.h"
#if !UCONFIG_NO_IDNA
#include "nptrans.h"
#include "unicode/resbund.h"
#include "unicode/uniset.h"
@ -272,4 +276,4 @@ UBool NamePrepTransform::isLabelSeparator(UChar32 ch, UErrorCode& status){
return labelSeparatorSet.contains(ch);
}
#endif /* #if !UCONFIG_NO_IDNA */

View File

@ -1,11 +1,11 @@
/*
*******************************************************************************
*
* Copyright (C) 2002, International Business Machines
* Copyright (C) 2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: nameprep.h
* file name: nptrans.h
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
@ -18,6 +18,9 @@
#define NPTRANS_H
#include "unicode/utypes.h"
#if !UCONFIG_NO_IDNA
#include "strprep.h"
#include "unicode/uniset.h"
#include "unicode/ures.h"
@ -141,6 +144,9 @@ inline UBool NamePrepTransform::isLDHChar(UChar32 ch){
}
return FALSE;
}
#endif /* #if !UCONFIG_NO_IDNA */
#endif
/*

View File

@ -9,6 +9,11 @@ http://www.nicemice.net/amc/
/* Implementation (would normally go in its own .c file): */
#include <string.h>
#include "unicode/utypes.h"
#if !UCONFIG_NO_IDNA
#include "punyref.h"
/*** Bootstring parameters for Punycode ***/
@ -266,4 +271,4 @@ enum punycode_status punycode_decode(
U_CDECL_END
#endif /* #if !UCONFIG_NO_IDNA */

View File

@ -17,6 +17,8 @@ Punycode (draft-ietf-idn-punycode-03).
#include <limits.h>
#include "unicode/utypes.h"
#if !UCONFIG_NO_IDNA
enum punycode_status {
punycode_success,
punycode_bad_input, /* Input is invalid. */
@ -89,5 +91,7 @@ enum punycode_status punycode_decode(
/* decoder will never need to write an output_length greater than */
/* input_length, because of how the encoding is defined. */
U_CDECL_END
#endif
#endif /* #if !UCONFIG_NO_IDNA */
#endif

View File

@ -217,6 +217,9 @@ StringCaseTest::TestCaseConversion()
}
}
#if !UCONFIG_NO_NORMALIZATION
// some context-sensitive casing depends on normalization data being present
// Unicode 3.1.1 SpecialCasing tests
{
UnicodeString t;
@ -292,6 +295,8 @@ StringCaseTest::TestCaseConversion()
}
}
#endif
// test case folding
{
UnicodeString

View File

@ -1,11 +1,11 @@
/*
*******************************************************************************
*
* Copyright (C) 2002, International Business Machines
* Copyright (C) 2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: strprep.cpp
* file name: testidna.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
@ -13,6 +13,11 @@
* created on: 2003feb1
* created by: Ram Viswanadha
*/
#include "unicode/utypes.h"
#if !UCONFIG_NO_IDNA
#include "unicode/uidna.h"
#include <time.h>
#include <limits.h>
@ -1408,4 +1413,4 @@ void TestIDNA::TestDataFile(){
testData(*this);
}
#endif /* #if !UCONFIG_NO_IDNA */

View File

@ -1,11 +1,11 @@
/*
*******************************************************************************
*
* Copyright (C) 2002, International Business Machines
* Copyright (C) 2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: strprep.cpp
* file name: testidna.h
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
@ -17,6 +17,10 @@
#ifndef TESTIDNA_H
#define TESTIDNA_H
#include "unicode/utypes.h"
#if !UCONFIG_NO_IDNA
#include "sprpimpl.h"
#include "intltest.h"
#include "unicode/parseerr.h"
@ -106,4 +110,6 @@ private:
// test the TRIE data structure
int testData(TestIDNA& test);
#endif /* #if !UCONFIG_NO_IDNA */
#endif

View File

@ -1,10 +1,13 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2001, International Business Machines Corporation and
* Copyright (c) 1997-2003, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
#include "unicode/utypes.h"
#if !UCONFIG_NO_NORMALIZATION
#include "unicode/uchar.h"
#include "unicode/normlzr.h"
#include "unicode/uniset.h"
@ -1832,3 +1835,5 @@ BasicNormalizerTest::TestSkippable() {
}
}
}
#endif /* #if !UCONFIG_NO_NORMALIZATION */

View File

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2001, International Business Machines Corporation and
* Copyright (c) 1997-2003, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
@ -11,6 +11,10 @@
#ifndef _TSTNORM
#define _TSTNORM
#include "unicode/utypes.h"
#if !UCONFIG_NO_NORMALIZATION
#include "unicode/normlzr.h"
#include "intltest.h"
@ -66,4 +70,6 @@ private:
};
#endif /* #if !UCONFIG_NO_NORMALIZATION */
#endif // _TSTNORM

View File

@ -214,7 +214,9 @@ void UObjectTest::testIDs()
//TESTCLASSID_DEFAULT(AnonymousStringFactory);
#if !UCONFIG_NO_NORMALIZATION
TESTCLASSID_FACTORY(CanonicalIterator, new CanonicalIterator(UnicodeString("abc"), status));
#endif
//TESTCLASSID_DEFAULT(CollationElementIterator);
#if !UCONFIG_NO_COLLATION
TESTCLASSID_DEFAULT(CollationKey);