/src/mozilla-central/intl/icu/source/i18n/regextxt.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | // © 2016 and later: Unicode, Inc. and others. |
2 | | // License & terms of use: http://www.unicode.org/copyright.html |
3 | | /******************************************************************** |
4 | | * COPYRIGHT: |
5 | | * Copyright (c) 2008-2011, International Business Machines Corporation and |
6 | | * others. All Rights Reserved. |
7 | | ********************************************************************/ |
8 | | // |
9 | | // file: regextxt.cpp |
10 | | // |
11 | | // This file contains utility code for supporting UText in the regular expression engine. |
12 | | // |
13 | | |
14 | | #include "unicode/utf.h" |
15 | | #include "regextxt.h" |
16 | | |
17 | | U_NAMESPACE_BEGIN |
18 | | |
19 | | U_CFUNC UChar U_CALLCONV |
20 | 0 | uregex_utext_unescape_charAt(int32_t offset, void *ct) { |
21 | 0 | struct URegexUTextUnescapeCharContext *context = (struct URegexUTextUnescapeCharContext *)ct; |
22 | 0 | UChar32 c; |
23 | 0 | if (offset == context->lastOffset + 1) { |
24 | 0 | c = UTEXT_NEXT32(context->text); |
25 | 0 | context->lastOffset++; |
26 | 0 | } else if (offset == context->lastOffset) { |
27 | 0 | c = UTEXT_PREVIOUS32(context->text); |
28 | 0 | UTEXT_NEXT32(context->text); |
29 | 0 | } else { |
30 | 0 | utext_moveIndex32(context->text, offset - context->lastOffset - 1); |
31 | 0 | c = UTEXT_NEXT32(context->text); |
32 | 0 | context->lastOffset = offset; |
33 | 0 | } |
34 | 0 |
|
35 | 0 | // !!!: Doesn't handle characters outside BMP |
36 | 0 | if (U_IS_BMP(c)) { |
37 | 0 | return (UChar)c; |
38 | 0 | } else { |
39 | 0 | return 0; |
40 | 0 | } |
41 | 0 | } |
42 | | |
43 | | U_CFUNC UChar U_CALLCONV |
44 | 0 | uregex_ucstr_unescape_charAt(int32_t offset, void *context) { |
45 | 0 | return ((UChar *)context)[offset]; |
46 | 0 | } |
47 | | |
48 | | U_NAMESPACE_END |