Bug Summary

File:out/../deps/icu-small/source/common/normalizer2.cpp
Warning:line 409, column 17
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name normalizer2.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/home/maurizio/node-v18.6.0/out -resource-dir /usr/local/lib/clang/16.0.0 -D V8_DEPRECATION_WARNINGS -D V8_IMMINENT_DEPRECATION_WARNINGS -D _GLIBCXX_USE_CXX11_ABI=1 -D NODE_OPENSSL_CONF_NAME=nodejs_conf -D NODE_OPENSSL_HAS_QUIC -D __STDC_FORMAT_MACROS -D OPENSSL_NO_PINSHARED -D OPENSSL_THREADS -D U_COMMON_IMPLEMENTATION=1 -D U_ATTRIBUTE_DEPRECATED= -D _CRT_SECURE_NO_DEPRECATE= -D U_STATIC_IMPLEMENTATION=1 -D UCONFIG_NO_SERVICE=1 -D U_ENABLE_DYLOAD=0 -D U_HAVE_STD_STRING=1 -D UCONFIG_NO_BREAK_ITERATION=0 -I ../deps/icu-small/source/common -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8 -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/x86_64-redhat-linux -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/backward -internal-isystem /usr/local/lib/clang/16.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-unused-parameter -Wno-deprecated-declarations -Wno-strict-aliasing -std=gnu++17 -fdeprecated-macro -fdebug-compilation-dir=/home/maurizio/node-v18.6.0/out -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2022-08-22-142216-507842-1 -x c++ ../deps/icu-small/source/common/normalizer2.cpp
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3/*
4*******************************************************************************
5*
6* Copyright (C) 2009-2016, International Business Machines
7* Corporation and others. All Rights Reserved.
8*
9*******************************************************************************
10* file name: normalizer2.cpp
11* encoding: UTF-8
12* tab size: 8 (not used)
13* indentation:4
14*
15* created on: 2009nov22
16* created by: Markus W. Scherer
17*/
18
19#include "unicode/utypes.h"
20
21#if !UCONFIG_NO_NORMALIZATION0
22
23#include "unicode/edits.h"
24#include "unicode/normalizer2.h"
25#include "unicode/stringoptions.h"
26#include "unicode/unistr.h"
27#include "unicode/unorm.h"
28#include "cstring.h"
29#include "mutex.h"
30#include "norm2allmodes.h"
31#include "normalizer2impl.h"
32#include "uassert.h"
33#include "ucln_cmn.h"
34
35using icu::Normalizer2Impl;
36
37#if NORM2_HARDCODE_NFC_DATA1
38// NFC/NFD data machine-generated by gennorm2 --csource
39#define INCLUDED_FROM_NORMALIZER2_CPP
40#include "norm2_nfc_data.h"
41#endif
42
43U_NAMESPACE_BEGINnamespace icu_71 {
44
45// Public API dispatch via Normalizer2 subclasses -------------------------- ***
46
47Normalizer2::~Normalizer2() {}
48
49void
50Normalizer2::normalizeUTF8(uint32_t /*options*/, StringPiece src, ByteSink &sink,
51 Edits *edits, UErrorCode &errorCode) const {
52 if (U_FAILURE(errorCode)) {
53 return;
54 }
55 if (edits != nullptr) {
56 errorCode = U_UNSUPPORTED_ERROR;
57 return;
58 }
59 UnicodeString src16 = UnicodeString::fromUTF8(src);
60 normalize(src16, errorCode).toUTF8(sink);
61}
62
63UBool
64Normalizer2::getRawDecomposition(UChar32, UnicodeString &) const {
65 return FALSE0;
66}
67
68UChar32
69Normalizer2::composePair(UChar32, UChar32) const {
70 return U_SENTINEL(-1);
71}
72
73uint8_t
74Normalizer2::getCombiningClass(UChar32 /*c*/) const {
75 return 0;
76}
77
78UBool
79Normalizer2::isNormalizedUTF8(StringPiece s, UErrorCode &errorCode) const {
80 return U_SUCCESS(errorCode) && isNormalized(UnicodeString::fromUTF8(s), errorCode);
81}
82
83// Normalizer2 implementation for the old UNORM_NONE.
84class NoopNormalizer2 : public Normalizer2 {
85 virtual ~NoopNormalizer2();
86
87 virtual UnicodeString &
88 normalize(const UnicodeString &src,
89 UnicodeString &dest,
90 UErrorCode &errorCode) const U_OVERRIDEoverride {
91 if(U_SUCCESS(errorCode)) {
92 if(&dest!=&src) {
93 dest=src;
94 } else {
95 errorCode=U_ILLEGAL_ARGUMENT_ERROR;
96 }
97 }
98 return dest;
99 }
100 virtual void
101 normalizeUTF8(uint32_t options, StringPiece src, ByteSink &sink,
102 Edits *edits, UErrorCode &errorCode) const U_OVERRIDEoverride {
103 if(U_SUCCESS(errorCode)) {
104 if (edits != nullptr) {
105 if ((options & U_EDITS_NO_RESET0x2000) == 0) {
106 edits->reset();
107 }
108 edits->addUnchanged(src.length());
109 }
110 if ((options & U_OMIT_UNCHANGED_TEXT0x4000) == 0) {
111 sink.Append(src.data(), src.length());
112 }
113 sink.Flush();
114 }
115 }
116
117 virtual UnicodeString &
118 normalizeSecondAndAppend(UnicodeString &first,
119 const UnicodeString &second,
120 UErrorCode &errorCode) const U_OVERRIDEoverride {
121 if(U_SUCCESS(errorCode)) {
122 if(&first!=&second) {
123 first.append(second);
124 } else {
125 errorCode=U_ILLEGAL_ARGUMENT_ERROR;
126 }
127 }
128 return first;
129 }
130 virtual UnicodeString &
131 append(UnicodeString &first,
132 const UnicodeString &second,
133 UErrorCode &errorCode) const U_OVERRIDEoverride {
134 if(U_SUCCESS(errorCode)) {
135 if(&first!=&second) {
136 first.append(second);
137 } else {
138 errorCode=U_ILLEGAL_ARGUMENT_ERROR;
139 }
140 }
141 return first;
142 }
143 virtual UBool
144 getDecomposition(UChar32, UnicodeString &) const U_OVERRIDEoverride {
145 return FALSE0;
146 }
147 // No need to U_OVERRIDE the default getRawDecomposition().
148 virtual UBool
149 isNormalized(const UnicodeString &, UErrorCode &errorCode) const U_OVERRIDEoverride {
150 return U_SUCCESS(errorCode);
151 }
152 virtual UBool
153 isNormalizedUTF8(StringPiece, UErrorCode &errorCode) const U_OVERRIDEoverride {
154 return U_SUCCESS(errorCode);
155 }
156 virtual UNormalizationCheckResult
157 quickCheck(const UnicodeString &, UErrorCode &) const U_OVERRIDEoverride {
158 return UNORM_YES;
159 }
160 virtual int32_t
161 spanQuickCheckYes(const UnicodeString &s, UErrorCode &) const U_OVERRIDEoverride {
162 return s.length();
163 }
164 virtual UBool hasBoundaryBefore(UChar32) const U_OVERRIDEoverride { return TRUE1; }
165 virtual UBool hasBoundaryAfter(UChar32) const U_OVERRIDEoverride { return TRUE1; }
166 virtual UBool isInert(UChar32) const U_OVERRIDEoverride { return TRUE1; }
167};
168
169NoopNormalizer2::~NoopNormalizer2() {}
170
171Normalizer2WithImpl::~Normalizer2WithImpl() {}
172
173DecomposeNormalizer2::~DecomposeNormalizer2() {}
174
175ComposeNormalizer2::~ComposeNormalizer2() {}
176
177FCDNormalizer2::~FCDNormalizer2() {}
178
179// instance cache ---------------------------------------------------------- ***
180
181U_CDECL_BEGINextern "C" {
182static UBool U_CALLCONV uprv_normalizer2_cleanup();
183U_CDECL_END}
184
185static Normalizer2 *noopSingleton;
186static icu::UInitOnce noopInitOnce = U_INITONCE_INITIALIZER{{ 0 }, U_ZERO_ERROR};
187
188static void U_CALLCONV initNoopSingleton(UErrorCode &errorCode) {
189 if(U_FAILURE(errorCode)) {
190 return;
191 }
192 noopSingleton=new NoopNormalizer2;
193 if(noopSingleton==NULL__null) {
194 errorCode=U_MEMORY_ALLOCATION_ERROR;
195 return;
196 }
197 ucln_common_registerCleanupucln_common_registerCleanup_71(UCLN_COMMON_NORMALIZER2, uprv_normalizer2_cleanup);
198}
199
200const Normalizer2 *Normalizer2Factory::getNoopInstance(UErrorCode &errorCode) {
201 if(U_FAILURE(errorCode)) { return NULL__null; }
202 umtx_initOnce(noopInitOnce, &initNoopSingleton, errorCode);
203 return noopSingleton;
204}
205
206const Normalizer2Impl *
207Normalizer2Factory::getImpl(const Normalizer2 *norm2) {
208 return &((Normalizer2WithImpl *)norm2)->impl;
209}
210
211Norm2AllModes::~Norm2AllModes() {
212 delete impl;
213}
214
215Norm2AllModes *
216Norm2AllModes::createInstance(Normalizer2Impl *impl, UErrorCode &errorCode) {
217 if(U_FAILURE(errorCode)) {
218 delete impl;
219 return NULL__null;
220 }
221 Norm2AllModes *allModes=new Norm2AllModes(impl);
222 if(allModes==NULL__null) {
223 errorCode=U_MEMORY_ALLOCATION_ERROR;
224 delete impl;
225 return NULL__null;
226 }
227 return allModes;
228}
229
230#if NORM2_HARDCODE_NFC_DATA1
231Norm2AllModes *
232Norm2AllModes::createNFCInstance(UErrorCode &errorCode) {
233 if(U_FAILURE(errorCode)) {
234 return NULL__null;
235 }
236 Normalizer2Impl *impl=new Normalizer2Impl;
237 if(impl==NULL__null) {
238 errorCode=U_MEMORY_ALLOCATION_ERROR;
239 return NULL__null;
240 }
241 impl->init(norm2_nfc_data_indexes, &norm2_nfc_data_trie,
242 norm2_nfc_data_extraData, norm2_nfc_data_smallFCD);
243 return createInstance(impl, errorCode);
244}
245
246static Norm2AllModes *nfcSingleton;
247
248static icu::UInitOnce nfcInitOnce = U_INITONCE_INITIALIZER{{ 0 }, U_ZERO_ERROR};
249
250static void U_CALLCONV initNFCSingleton(UErrorCode &errorCode) {
251 nfcSingleton=Norm2AllModes::createNFCInstance(errorCode);
252 ucln_common_registerCleanupucln_common_registerCleanup_71(UCLN_COMMON_NORMALIZER2, uprv_normalizer2_cleanup);
253}
254
255const Norm2AllModes *
256Norm2AllModes::getNFCInstance(UErrorCode &errorCode) {
257 if(U_FAILURE(errorCode)) { return NULL__null; }
258 umtx_initOnce(nfcInitOnce, &initNFCSingleton, errorCode);
259 return nfcSingleton;
260}
261
262const Normalizer2 *
263Normalizer2::getNFCInstance(UErrorCode &errorCode) {
264 const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
265 return allModes!=NULL__null ? &allModes->comp : NULL__null;
266}
267
268const Normalizer2 *
269Normalizer2::getNFDInstance(UErrorCode &errorCode) {
270 const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
271 return allModes!=NULL__null ? &allModes->decomp : NULL__null;
272}
273
274const Normalizer2 *Normalizer2Factory::getFCDInstance(UErrorCode &errorCode) {
275 const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
276 return allModes!=NULL__null ? &allModes->fcd : NULL__null;
277}
278
279const Normalizer2 *Normalizer2Factory::getFCCInstance(UErrorCode &errorCode) {
280 const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
281 return allModes!=NULL__null ? &allModes->fcc : NULL__null;
282}
283
284const Normalizer2Impl *
285Normalizer2Factory::getNFCImpl(UErrorCode &errorCode) {
286 const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
287 return allModes!=NULL__null ? allModes->impl : NULL__null;
288}
289#endif // NORM2_HARDCODE_NFC_DATA
290
291U_CDECL_BEGINextern "C" {
292
293static UBool U_CALLCONV uprv_normalizer2_cleanup() {
294 delete noopSingleton;
295 noopSingleton = NULL__null;
296 noopInitOnce.reset();
297#if NORM2_HARDCODE_NFC_DATA1
298 delete nfcSingleton;
299 nfcSingleton = NULL__null;
300 nfcInitOnce.reset();
301#endif
302 return TRUE1;
303}
304
305U_CDECL_END}
306
307U_NAMESPACE_END}
308
309// C API ------------------------------------------------------------------- ***
310
311U_NAMESPACE_USEusing namespace icu_71;
312
313U_CAPIextern "C" const UNormalizer2 * U_EXPORT2
314unorm2_getNFCInstanceunorm2_getNFCInstance_71(UErrorCode *pErrorCode) {
315 return (const UNormalizer2 *)Normalizer2::getNFCInstance(*pErrorCode);
316}
317
318U_CAPIextern "C" const UNormalizer2 * U_EXPORT2
319unorm2_getNFDInstanceunorm2_getNFDInstance_71(UErrorCode *pErrorCode) {
320 return (const UNormalizer2 *)Normalizer2::getNFDInstance(*pErrorCode);
321}
322
323U_CAPIextern "C" void U_EXPORT2
324unorm2_closeunorm2_close_71(UNormalizer2 *norm2) {
325 delete (Normalizer2 *)norm2;
326}
327
328U_CAPIextern "C" int32_t U_EXPORT2
329unorm2_normalizeunorm2_normalize_71(const UNormalizer2 *norm2,
330 const UChar *src, int32_t length,
331 UChar *dest, int32_t capacity,
332 UErrorCode *pErrorCode) {
333 if(U_FAILURE(*pErrorCode)) {
334 return 0;
335 }
336 if( (src==NULL__null ? length!=0 : length<-1) ||
337 (dest==NULL__null ? capacity!=0 : capacity<0) ||
338 (src==dest && src!=NULL__null)
339 ) {
340 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
341 return 0;
342 }
343 UnicodeString destString(dest, 0, capacity);
344 // length==0: Nothing to do, and n2wi->normalize(NULL, NULL, buffer, ...) would crash.
345 if(length!=0) {
346 const Normalizer2 *n2=(const Normalizer2 *)norm2;
347 const Normalizer2WithImpl *n2wi=dynamic_cast<const Normalizer2WithImpl *>(n2);
348 if(n2wi!=NULL__null) {
349 // Avoid duplicate argument checking and support NUL-terminated src.
350 ReorderingBuffer buffer(n2wi->impl, destString);
351 if(buffer.init(length, *pErrorCode)) {
352 n2wi->normalize(src, length>=0 ? src+length : NULL__null, buffer, *pErrorCode);
353 }
354 } else {
355 UnicodeString srcString(length<0, src, length);
356 n2->normalize(srcString, destString, *pErrorCode);
357 }
358 }
359 return destString.extract(dest, capacity, *pErrorCode);
360}
361
362static int32_t
363normalizeSecondAndAppend(const UNormalizer2 *norm2,
364 UChar *first, int32_t firstLength, int32_t firstCapacity,
365 const UChar *second, int32_t secondLength,
366 UBool doNormalize,
367 UErrorCode *pErrorCode) {
368 if(U_FAILURE(*pErrorCode)) {
369 return 0;
370 }
371 if( (second==NULL__null ? secondLength!=0 : secondLength<-1) ||
3
Assuming 'second' is not equal to NULL
4
'?' condition is false
5
Assuming the condition is false
372 (first==NULL__null ? (firstCapacity!=0 || firstLength!=0) :
6
Assuming 'first' is equal to NULL
7
Assuming 'firstCapacity' is equal to 0
8
Assuming 'firstLength' is equal to 0
373 (firstCapacity<0 || firstLength<-1)) ||
374 (first
8.1
'first' is not equal to 'second'
==second && first!=NULL__null)
375 ) {
376 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
377 return 0;
378 }
379 UnicodeString firstString(first, firstLength, firstCapacity);
380 firstLength=firstString.length(); // In case it was -1.
381 // secondLength==0: Nothing to do, and n2wi->normalizeAndAppend(NULL, NULL, buffer, ...) would crash.
382 if(secondLength!=0) {
9
Assuming 'secondLength' is not equal to 0
10
Taking true branch
383 const Normalizer2 *n2=(const Normalizer2 *)norm2;
11
'n2' initialized here
384 const Normalizer2WithImpl *n2wi=dynamic_cast<const Normalizer2WithImpl *>(n2);
385 if(n2wi!=NULL__null) {
12
Assuming 'n2wi' is equal to NULL
13
Taking false branch
386 // Avoid duplicate argument checking and support NUL-terminated src.
387 UnicodeString safeMiddle;
388 {
389 ReorderingBuffer buffer(n2wi->impl, firstString);
390 if(buffer.init(firstLength+secondLength+1, *pErrorCode)) { // destCapacity>=-1
391 n2wi->normalizeAndAppend(second, secondLength>=0 ? second+secondLength : NULL__null,
392 doNormalize, safeMiddle, buffer, *pErrorCode);
393 }
394 } // The ReorderingBuffer destructor finalizes firstString.
395 if(U_FAILURE(*pErrorCode) || firstString.length()>firstCapacity) {
396 // Restore the modified suffix of the first string.
397 // This does not restore first[] array contents between firstLength and firstCapacity.
398 // (That might be uninitialized memory, as far as we know.)
399 if(first!=NULL__null) { /* don't dereference NULL */
400 safeMiddle.extract(0, 0x7fffffff, first+firstLength-safeMiddle.length());
401 if(firstLength<firstCapacity) {
402 first[firstLength]=0; // NUL-terminate in case it was originally.
403 }
404 }
405 }
406 } else {
407 UnicodeString secondString(secondLength<0, second, secondLength);
14
Assuming 'secondLength' is >= 0
408 if(doNormalize
14.1
'doNormalize' is 1
) {
15
Taking true branch
409 n2->normalizeSecondAndAppend(firstString, secondString, *pErrorCode);
16
Called C++ object pointer is null
410 } else {
411 n2->append(firstString, secondString, *pErrorCode);
412 }
413 }
414 }
415 return firstString.extract(first, firstCapacity, *pErrorCode);
416}
417
418U_CAPIextern "C" int32_t U_EXPORT2
419unorm2_normalizeSecondAndAppendunorm2_normalizeSecondAndAppend_71(const UNormalizer2 *norm2,
420 UChar *first, int32_t firstLength, int32_t firstCapacity,
421 const UChar *second, int32_t secondLength,
422 UErrorCode *pErrorCode) {
423 return normalizeSecondAndAppend(norm2,
1
Passing value via 1st parameter 'norm2'
2
Calling 'normalizeSecondAndAppend'
424 first, firstLength, firstCapacity,
425 second, secondLength,
426 TRUE1, pErrorCode);
427}
428
429U_CAPIextern "C" int32_t U_EXPORT2
430unorm2_appendunorm2_append_71(const UNormalizer2 *norm2,
431 UChar *first, int32_t firstLength, int32_t firstCapacity,
432 const UChar *second, int32_t secondLength,
433 UErrorCode *pErrorCode) {
434 return normalizeSecondAndAppend(norm2,
435 first, firstLength, firstCapacity,
436 second, secondLength,
437 FALSE0, pErrorCode);
438}
439
440U_CAPIextern "C" int32_t U_EXPORT2
441unorm2_getDecompositionunorm2_getDecomposition_71(const UNormalizer2 *norm2,
442 UChar32 c, UChar *decomposition, int32_t capacity,
443 UErrorCode *pErrorCode) {
444 if(U_FAILURE(*pErrorCode)) {
445 return 0;
446 }
447 if(decomposition==NULL__null ? capacity!=0 : capacity<0) {
448 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
449 return 0;
450 }
451 UnicodeString destString(decomposition, 0, capacity);
452 if(reinterpret_cast<const Normalizer2 *>(norm2)->getDecomposition(c, destString)) {
453 return destString.extract(decomposition, capacity, *pErrorCode);
454 } else {
455 return -1;
456 }
457}
458
459U_CAPIextern "C" int32_t U_EXPORT2
460unorm2_getRawDecompositionunorm2_getRawDecomposition_71(const UNormalizer2 *norm2,
461 UChar32 c, UChar *decomposition, int32_t capacity,
462 UErrorCode *pErrorCode) {
463 if(U_FAILURE(*pErrorCode)) {
464 return 0;
465 }
466 if(decomposition==NULL__null ? capacity!=0 : capacity<0) {
467 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
468 return 0;
469 }
470 UnicodeString destString(decomposition, 0, capacity);
471 if(reinterpret_cast<const Normalizer2 *>(norm2)->getRawDecomposition(c, destString)) {
472 return destString.extract(decomposition, capacity, *pErrorCode);
473 } else {
474 return -1;
475 }
476}
477
478U_CAPIextern "C" UChar32 U_EXPORT2
479unorm2_composePairunorm2_composePair_71(const UNormalizer2 *norm2, UChar32 a, UChar32 b) {
480 return reinterpret_cast<const Normalizer2 *>(norm2)->composePair(a, b);
481}
482
483U_CAPIextern "C" uint8_t U_EXPORT2
484unorm2_getCombiningClassunorm2_getCombiningClass_71(const UNormalizer2 *norm2, UChar32 c) {
485 return reinterpret_cast<const Normalizer2 *>(norm2)->getCombiningClass(c);
486}
487
488U_CAPIextern "C" UBool U_EXPORT2
489unorm2_isNormalizedunorm2_isNormalized_71(const UNormalizer2 *norm2,
490 const UChar *s, int32_t length,
491 UErrorCode *pErrorCode) {
492 if(U_FAILURE(*pErrorCode)) {
493 return 0;
494 }
495 if((s==NULL__null && length!=0) || length<-1) {
496 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
497 return 0;
498 }
499 UnicodeString sString(length<0, s, length);
500 return ((const Normalizer2 *)norm2)->isNormalized(sString, *pErrorCode);
501}
502
503U_CAPIextern "C" UNormalizationCheckResult U_EXPORT2
504unorm2_quickCheckunorm2_quickCheck_71(const UNormalizer2 *norm2,
505 const UChar *s, int32_t length,
506 UErrorCode *pErrorCode) {
507 if(U_FAILURE(*pErrorCode)) {
508 return UNORM_NO;
509 }
510 if((s==NULL__null && length!=0) || length<-1) {
511 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
512 return UNORM_NO;
513 }
514 UnicodeString sString(length<0, s, length);
515 return ((const Normalizer2 *)norm2)->quickCheck(sString, *pErrorCode);
516}
517
518U_CAPIextern "C" int32_t U_EXPORT2
519unorm2_spanQuickCheckYesunorm2_spanQuickCheckYes_71(const UNormalizer2 *norm2,
520 const UChar *s, int32_t length,
521 UErrorCode *pErrorCode) {
522 if(U_FAILURE(*pErrorCode)) {
523 return 0;
524 }
525 if((s==NULL__null && length!=0) || length<-1) {
526 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
527 return 0;
528 }
529 UnicodeString sString(length<0, s, length);
530 return ((const Normalizer2 *)norm2)->spanQuickCheckYes(sString, *pErrorCode);
531}
532
533U_CAPIextern "C" UBool U_EXPORT2
534unorm2_hasBoundaryBeforeunorm2_hasBoundaryBefore_71(const UNormalizer2 *norm2, UChar32 c) {
535 return ((const Normalizer2 *)norm2)->hasBoundaryBefore(c);
536}
537
538U_CAPIextern "C" UBool U_EXPORT2
539unorm2_hasBoundaryAfterunorm2_hasBoundaryAfter_71(const UNormalizer2 *norm2, UChar32 c) {
540 return ((const Normalizer2 *)norm2)->hasBoundaryAfter(c);
541}
542
543U_CAPIextern "C" UBool U_EXPORT2
544unorm2_isInertunorm2_isInert_71(const UNormalizer2 *norm2, UChar32 c) {
545 return ((const Normalizer2 *)norm2)->isInert(c);
546}
547
548// Some properties APIs ---------------------------------------------------- ***
549
550U_CAPIextern "C" uint8_t U_EXPORT2
551u_getCombiningClassu_getCombiningClass_71(UChar32 c) {
552 UErrorCode errorCode=U_ZERO_ERROR;
553 const Normalizer2 *nfd=Normalizer2::getNFDInstance(errorCode);
554 if(U_SUCCESS(errorCode)) {
555 return nfd->getCombiningClass(c);
556 } else {
557 return 0;
558 }
559}
560
561U_CFUNCextern "C" uint16_t
562unorm_getFCD16unorm_getFCD16_71(UChar32 c) {
563 UErrorCode errorCode=U_ZERO_ERROR;
564 const Normalizer2Impl *impl=Normalizer2Factory::getNFCImpl(errorCode);
565 if(U_SUCCESS(errorCode)) {
566 return impl->getFCD16(c);
567 } else {
568 return 0;
569 }
570}
571
572#endif // !UCONFIG_NO_NORMALIZATION