intl/icu/source/i18n/regextxt.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /********************************************************************
     2  * COPYRIGHT:
     3  * Copyright (c) 2008-2011, International Business Machines Corporation and
     4  * others. All Rights Reserved.
     5  ********************************************************************/
     6 //
     7 //  file:  regextxt.cpp
     8 //
     9 //  This file contains utility code for supporting UText in the regular expression engine.
    10 //
    12 #include "unicode/utf.h"
    13 #include "regextxt.h"
    15 U_NAMESPACE_BEGIN
    17 U_CFUNC UChar U_CALLCONV
    18 uregex_utext_unescape_charAt(int32_t offset, void *ct) {
    19     struct URegexUTextUnescapeCharContext *context = (struct URegexUTextUnescapeCharContext *)ct;
    20     UChar32 c;
    21     if (offset == context->lastOffset + 1) {
    22         c = UTEXT_NEXT32(context->text);
    23         context->lastOffset++;
    24     } else if (offset == context->lastOffset) {
    25         c = UTEXT_PREVIOUS32(context->text);
    26         UTEXT_NEXT32(context->text);
    27     } else {
    28         utext_moveIndex32(context->text, offset - context->lastOffset - 1);
    29         c = UTEXT_NEXT32(context->text);
    30         context->lastOffset = offset;
    31     }
    33     // !!!: Doesn't handle characters outside BMP
    34     if (U_IS_BMP(c)) {
    35         return (UChar)c;
    36     } else {
    37         return 0;
    38     }
    39 }
    41 U_CFUNC UChar U_CALLCONV
    42 uregex_ucstr_unescape_charAt(int32_t offset, void *context) {
    43     return ((UChar *)context)[offset];
    44 }
    46 U_NAMESPACE_END

mercurial