intl/icu/source/common/unistr_props.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /*
     2 *******************************************************************************
     3 *
     4 *   Copyright (C) 1999-2011, International Business Machines
     5 *   Corporation and others.  All Rights Reserved.
     6 *
     7 *******************************************************************************
     8 *   file name:  unistr_props.cpp
     9 *   encoding:   US-ASCII
    10 *   tab size:   8 (not used)
    11 *   indentation:2
    12 *
    13 *   created on: 2004aug25
    14 *   created by: Markus W. Scherer
    15 *
    16 *   Character property dependent functions moved here from unistr.cpp
    17 */
    19 #include "unicode/utypes.h"
    20 #include "unicode/uchar.h"
    21 #include "unicode/unistr.h"
    22 #include "unicode/utf16.h"
    24 U_NAMESPACE_BEGIN
    26 UnicodeString& 
    27 UnicodeString::trim()
    28 {
    29   if(isBogus()) {
    30     return *this;
    31   }
    33   UChar *array = getArrayStart();
    34   UChar32 c;
    35   int32_t oldLength = this->length();
    36   int32_t i = oldLength, length;
    38   // first cut off trailing white space
    39   for(;;) {
    40     length = i;
    41     if(i <= 0) {
    42       break;
    43     }
    44     U16_PREV(array, 0, i, c);
    45     if(!(c == 0x20 || u_isWhitespace(c))) {
    46       break;
    47     }
    48   }
    49   if(length < oldLength) {
    50     setLength(length);
    51   }
    53   // find leading white space
    54   int32_t start;
    55   i = 0;
    56   for(;;) {
    57     start = i;
    58     if(i >= length) {
    59       break;
    60     }
    61     U16_NEXT(array, i, length, c);
    62     if(!(c == 0x20 || u_isWhitespace(c))) {
    63       break;
    64     }
    65   }
    67   // move string forward over leading white space
    68   if(start > 0) {
    69     doReplace(0, start, 0, 0, 0);
    70   }
    72   return *this;
    73 }
    75 U_NAMESPACE_END

mercurial