intl/icu/source/i18n/regextxt.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial