]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/uspoof_build.cpp
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 ***************************************************************************
5 * Copyright (C) 2008-2015, International Business Machines Corporation
6 * and others. All Rights Reserved.
7 ***************************************************************************
8 * file name: uspoof_build.cpp
10 * tab size: 8 (not used)
13 * created on: 2008 Dec 8
14 * created by: Andy Heninger
16 * Unicode Spoof Detection Data Builder
17 * Builder-related functions are kept in separate files so that applications not needing
18 * the builder can more easily exclude them, typically by means of static linking.
20 * There are three relatively independent sets of Spoof data,
22 * Whole Script Confusables
23 * ID character extensions.
25 * The data tables for each are built separately, each from its own definitions
28 #include "unicode/utypes.h"
29 #include "unicode/uspoof.h"
30 #include "unicode/unorm.h"
31 #include "unicode/uregex.h"
32 #include "unicode/ustring.h"
34 #include "uspoof_impl.h"
39 #include "uspoof_conf.h"
41 #if !UCONFIG_NO_NORMALIZATION
45 // Defined in uspoof.cpp, initializes file-static variables.
46 U_CFUNC
void uspoof_internalInitStatics(UErrorCode
*status
);
48 // The main data building function
50 U_CAPI USpoofChecker
* U_EXPORT2
51 uspoof_openFromSource(const char *confusables
, int32_t confusablesLen
,
52 const char* /*confusablesWholeScript*/, int32_t /*confusablesWholeScriptLen*/,
53 int32_t *errorType
, UParseError
*pe
, UErrorCode
*status
) {
54 uspoof_internalInitStatics(status
);
55 if (U_FAILURE(*status
)) {
58 #if UCONFIG_NO_REGULAR_EXPRESSIONS
59 *status
= U_UNSUPPORTED_ERROR
;
62 if (errorType
!=NULL
) {
68 pe
->preContext
[0] = 0;
69 pe
->postContext
[0] = 0;
72 // Set up a shell of a spoof detector, with empty data.
73 SpoofData
*newSpoofData
= new SpoofData(*status
);
74 SpoofImpl
*This
= new SpoofImpl(newSpoofData
, *status
);
76 // Compile the binary data from the source (text) format.
77 ConfusabledataBuilder::buildConfusableData(This
, confusables
, confusablesLen
, errorType
, pe
, *status
);
79 if (U_FAILURE(*status
)) {
83 return (USpoofChecker
*)This
;
84 #endif // UCONFIG_NO_REGULAR_EXPRESSIONS