intl/icu/source/common/appendable.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.

michael@0 1 /*
michael@0 2 *******************************************************************************
michael@0 3 * Copyright (C) 2011-2012, International Business Machines
michael@0 4 * Corporation and others. All Rights Reserved.
michael@0 5 *******************************************************************************
michael@0 6 * file name: appendable.cpp
michael@0 7 * encoding: US-ASCII
michael@0 8 * tab size: 8 (not used)
michael@0 9 * indentation:4
michael@0 10 *
michael@0 11 * created on: 2010dec07
michael@0 12 * created by: Markus W. Scherer
michael@0 13 */
michael@0 14
michael@0 15 #include "unicode/utypes.h"
michael@0 16 #include "unicode/appendable.h"
michael@0 17 #include "unicode/utf16.h"
michael@0 18
michael@0 19 U_NAMESPACE_BEGIN
michael@0 20
michael@0 21 Appendable::~Appendable() {}
michael@0 22
michael@0 23 UBool
michael@0 24 Appendable::appendCodePoint(UChar32 c) {
michael@0 25 if(c<=0xffff) {
michael@0 26 return appendCodeUnit((UChar)c);
michael@0 27 } else {
michael@0 28 return appendCodeUnit(U16_LEAD(c)) && appendCodeUnit(U16_TRAIL(c));
michael@0 29 }
michael@0 30 }
michael@0 31
michael@0 32 UBool
michael@0 33 Appendable::appendString(const UChar *s, int32_t length) {
michael@0 34 if(length<0) {
michael@0 35 UChar c;
michael@0 36 while((c=*s++)!=0) {
michael@0 37 if(!appendCodeUnit(c)) {
michael@0 38 return FALSE;
michael@0 39 }
michael@0 40 }
michael@0 41 } else if(length>0) {
michael@0 42 const UChar *limit=s+length;
michael@0 43 do {
michael@0 44 if(!appendCodeUnit(*s++)) {
michael@0 45 return FALSE;
michael@0 46 }
michael@0 47 } while(s<limit);
michael@0 48 }
michael@0 49 return TRUE;
michael@0 50 }
michael@0 51
michael@0 52 UBool
michael@0 53 Appendable::reserveAppendCapacity(int32_t /*appendCapacity*/) {
michael@0 54 return TRUE;
michael@0 55 }
michael@0 56
michael@0 57 UChar *
michael@0 58 Appendable::getAppendBuffer(int32_t minCapacity,
michael@0 59 int32_t /*desiredCapacityHint*/,
michael@0 60 UChar *scratch, int32_t scratchCapacity,
michael@0 61 int32_t *resultCapacity) {
michael@0 62 if(minCapacity<1 || scratchCapacity<minCapacity) {
michael@0 63 *resultCapacity=0;
michael@0 64 return NULL;
michael@0 65 }
michael@0 66 *resultCapacity=scratchCapacity;
michael@0 67 return scratch;
michael@0 68 }
michael@0 69
michael@0 70 // UnicodeStringAppendable is implemented in unistr.cpp.
michael@0 71
michael@0 72 U_NAMESPACE_END

mercurial