| 1 | /* |
| 2 | * Copyright (C) 1999-2000 Harri Porten ([email protected]) |
| 3 | * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 4 | * Copyright (C) 2007 Cameron Zwarich ([email protected]) |
| 5 | * Copyright (C) 2009 Google Inc. All rights reserved. |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Library General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Library General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Library General Public License |
| 18 | * along with this library; see the file COPYING.LIB. If not, write to |
| 19 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 | * Boston, MA 02110-1301, USA. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include "config.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/config.h`/ |
| 25 | #include "UString.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UString.h`/ |
| 26 | |
| 27 | #include "JSGlobalObjectFunctions.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObjectFunctions.h`/ |
| 28 | #include "Collector.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h`/ |
| 29 | #include "dtoa.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/dtoa.h`/ |
| 30 | #include "Identifier.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Identifier.h`/ |
| 31 | #include "Operations.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Operations.h`/ |
| 32 | #include <ctype.h> |
| 33 | #include <limits.h> |
| 34 | #include <limits> |
| 35 | #include <math.h> |
| 36 | #include <stdio.h> |
| 37 | #include <stdlib.h> |
| 38 | #include <string.h> |
| 39 | #include <wtf/ASCIICType.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ASCIICType.h`/ |
| 40 | #include <wtf/Assertions.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h`/ |
| 41 | #include <wtf/MathExtras.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h`/ |
| 42 | #include <wtf/StringExtras.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/StringExtras.h`/ |
| 43 | #include <wtf/Vector.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Vector.h`/ |
| 44 | #include <wtf/unicode/UTF8.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/unicode/UTF8.h`/ |
| 45 | #include <wtf/StringExtras.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/StringExtras.h`/ |
| 46 | |
| 47 | #if HAVEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:46:9`!(STRINGS_H) |
| 48 | #include <strings.h> |
| 49 | #endif |
| 50 | |
| 51 | using namespace WTFcxx . . $ `<built-in>:467:9`!; |
| 52 | using namespace WTFcxx . . $ `<built-in>:467:9`!::Unicode; |
| 53 | using namespace std; |
| 54 | |
| 55 | namespace JSCcxx . . $ `<built-in>:463:9`! { |
| 56 | |
| 57 | extern const double NaNcxx . . $ QTJSC/NaN.; |
| 58 | extern const double Infcxx . . $ QTJSC/Inf.; |
| 59 | |
| 60 | CStringcxx . . $ QTJSC/CString#::CStringcxx . . $ QTJSC/CString#CString(85c52e162fed56f9).(const char* c) |
| 61 | : m_lengthcxx . . $ QTJSC/CString#m_length.(strlen(c)) |
| 62 | , m_datacxx . . $ QTJSC/CString#m_data.(new char[m_lengthcxx . . $ QTJSC/CString#m_length. + 1]) |
| 63 | { |
| 64 | memcpy(m_datacxx . . $ QTJSC/CString#m_data., c, m_lengthcxx . . $ QTJSC/CString#m_length. + 1); |
| 65 | } |
| 66 | |
| 67 | CStringcxx . . $ QTJSC/CString#::CStringcxx . . $ QTJSC/CString#CString(7cafb6e0818eff3b).(const char* c, size_t length) |
| 68 | : m_lengthcxx . . $ QTJSC/CString#m_length.(length) |
| 69 | , m_datacxx . . $ QTJSC/CString#m_data.(new char[length + 1]) |
| 70 | { |
| 71 | memcpy(m_datacxx . . $ QTJSC/CString#m_data., c, m_lengthcxx . . $ QTJSC/CString#m_length.); |
| 72 | m_datacxx . . $ QTJSC/CString#m_data.[m_lengthcxx . . $ QTJSC/CString#m_length.] = 0; |
| 73 | } |
| 74 | |
| 75 | CStringcxx . . $ QTJSC/CString#::CStringcxx . . $ QTJSC/CString#CString(f113043c45ce5422).(const CStringcxx . . $ QTJSC/CString#& b) |
| 76 | { |
| 77 | m_lengthcxx . . $ QTJSC/CString#m_length. = b.m_lengthcxx . . $ QTJSC/CString#m_length.; |
| 78 | if (b.m_datacxx . . $ QTJSC/CString#m_data.) { |
| 79 | m_datacxx . . $ QTJSC/CString#m_data. = new char[m_lengthcxx . . $ QTJSC/CString#m_length. + 1]; |
| 80 | memcpy(m_datacxx . . $ QTJSC/CString#m_data., b.m_datacxx . . $ QTJSC/CString#m_data., m_lengthcxx . . $ QTJSC/CString#m_length. + 1); |
| 81 | } else |
| 82 | m_datacxx . . $ QTJSC/CString#m_data. = 0; |
| 83 | } |
| 84 | |
| 85 | CStringcxx . . $ QTJSC/CString#::~cxx . . $ QTJSC/CString#`~CString`(49f6e7a06ebc5aa8).CStringcxx . . $ QTJSC/CString#() |
| 86 | { |
| 87 | delete [] m_datacxx . . $ QTJSC/CString#m_data.; |
| 88 | } |
| 89 | |
| 90 | CStringcxx . . $ QTJSC/CString# CStringcxx . . $ QTJSC/CString#::adoptcxx . . $ QTJSC/CString#adopt(328b68d1112ffd19).(char* c, size_t length) |
| 91 | { |
| 92 | CStringcxx . . $ QTJSC/CString# scxx . . $ QTJSC/CString#CString(49f6e7a06ebc5aa8).; |
| 93 | s.m_datacxx . . $ QTJSC/CString#m_data. = c; |
| 94 | s.m_lengthcxx . . $ QTJSC/CString#m_length. = length; |
| 95 | return scxx . . $ QTJSC/CString#CString(f113043c45ce5422).; |
| 96 | } |
| 97 | |
| 98 | CStringcxx . . $ QTJSC/CString#& CStringcxx . . $ QTJSC/CString#::appendcxx . . $ QTJSC/CString#append(6cdc8ba6a410cc19).(const CStringcxx . . $ QTJSC/CString#& t) |
| 99 | { |
| 100 | char* n; |
| 101 | n = new char[m_lengthcxx . . $ QTJSC/CString#m_length. + t.m_lengthcxx . . $ QTJSC/CString#m_length. + 1]; |
| 102 | if (m_lengthcxx . . $ QTJSC/CString#m_length.) |
| 103 | memcpy(n, m_datacxx . . $ QTJSC/CString#m_data., m_lengthcxx . . $ QTJSC/CString#m_length.); |
| 104 | if (t.m_lengthcxx . . $ QTJSC/CString#m_length.) |
| 105 | memcpy(n + m_lengthcxx . . $ QTJSC/CString#m_length., t.m_datacxx . . $ QTJSC/CString#m_data., t.m_lengthcxx . . $ QTJSC/CString#m_length.); |
| 106 | m_lengthcxx . . $ QTJSC/CString#m_length. += t.m_lengthcxx . . $ QTJSC/CString#m_length.; |
| 107 | n[m_lengthcxx . . $ QTJSC/CString#m_length.] = 0; |
| 108 | |
| 109 | delete [] m_datacxx . . $ QTJSC/CString#m_data.; |
| 110 | m_datacxx . . $ QTJSC/CString#m_data. = n; |
| 111 | |
| 112 | return *this; |
| 113 | } |
| 114 | |
| 115 | CStringcxx . . $ QTJSC/CString#& CStringcxx . . $ QTJSC/CString#::operatorcxx . . $ QTJSC/CString#`operator=`(fbe391b56b16ab89).=(const char* c) |
| 116 | { |
| 117 | if (m_datacxx . . $ QTJSC/CString#m_data.) |
| 118 | delete [] m_datacxx . . $ QTJSC/CString#m_data.; |
| 119 | m_lengthcxx . . $ QTJSC/CString#m_length. = strlen(c); |
| 120 | m_datacxx . . $ QTJSC/CString#m_data. = new char[m_lengthcxx . . $ QTJSC/CString#m_length. + 1]; |
| 121 | memcpy(m_datacxx . . $ QTJSC/CString#m_data., c, m_lengthcxx . . $ QTJSC/CString#m_length. + 1); |
| 122 | |
| 123 | return *this; |
| 124 | } |
| 125 | |
| 126 | CStringcxx . . $ QTJSC/CString#& CStringcxx . . $ QTJSC/CString#::operatorcxx . . $ QTJSC/CString#`operator=`(6cdc8ba6a410cc19).=(const CStringcxx . . $ QTJSC/CString#& str) |
| 127 | { |
| 128 | if (this == &str) |
| 129 | return *this; |
| 130 | |
| 131 | if (m_datacxx . . $ QTJSC/CString#m_data.) |
| 132 | delete [] m_datacxx . . $ QTJSC/CString#m_data.; |
| 133 | m_lengthcxx . . $ QTJSC/CString#m_length. = str.m_lengthcxx . . $ QTJSC/CString#m_length.; |
| 134 | if (str.m_datacxx . . $ QTJSC/CString#m_data.) { |
| 135 | m_datacxx . . $ QTJSC/CString#m_data. = new char[m_lengthcxx . . $ QTJSC/CString#m_length. + 1]; |
| 136 | memcpy(m_datacxx . . $ QTJSC/CString#m_data., str.m_datacxx . . $ QTJSC/CString#m_data., m_lengthcxx . . $ QTJSC/CString#m_length. + 1); |
| 137 | } else |
| 138 | m_datacxx . . $ QTJSC/CString#m_data. = 0; |
| 139 | |
| 140 | return *this; |
| 141 | } |
| 142 | |
| 143 | bool operatorcxx . . $ QTJSC/`operator==`(e9142ab59ce7dac8).==(const CStringcxx . . $ QTJSC/CString#& c1, const CStringcxx . . $ QTJSC/CString#& c2) |
| 144 | { |
| 145 | size_t len = c1.sizecxx . . $ QTJSC/CString#size(fe4d2d262d4164a8).(); |
| 146 | return len == c2.sizecxx . . $ QTJSC/CString#size(fe4d2d262d4164a8).() && (len == 0 || memcmp(c1.c_strcxx . . $ QTJSC/CString#c_str(a9f41ea0e82d88cf).(), c2.c_strcxx . . $ QTJSC/CString#c_str(a9f41ea0e82d88cf).(), len) == 0); |
| 147 | } |
| 148 | |
| 149 | // These static strings are immutable, except for rc, whose initial value is chosen to |
| 150 | // reduce the possibility of it becoming zero due to ref/deref not being thread-safe. |
| 151 | static UCharcxx . . $ UChar# sharedEmptyCharcxx . . $ QTJSC/sharedEmptyChar.; |
| 152 | UStringImplcxx . . $ QTJSC/UStringImpl#* UStringImplcxx . . $ QTJSC/UStringImpl#::s_nullcxx . . $ QTJSC/UStringImpl#s_null.; |
| 153 | UStringImplcxx . . $ QTJSC/UStringImpl#* UStringImplcxx . . $ QTJSC/UStringImpl#::s_emptycxx . . $ QTJSC/UStringImpl#s_empty.; |
| 154 | UStringcxx . . $ QTJSC/UString#* UStringcxx . . $ QTJSC/UString#::nullUStringcxx . . $ QTJSC/UString#nullUString.; |
| 155 | |
| 156 | void initializeUStringcxx . . $ QTJSC/initializeUString(49f6e7a06ebc5aa8).() |
| 157 | { |
| 158 | UStringImplcxx . . $ QTJSC/UStringImpl#::s_nullcxx . . $ QTJSC/UStringImpl#s_null. = new UStringImplcxx . . $ QTJSC/UStringImpl#(0, 0, UStringImplcxx . . $ QTJSC/UStringImpl#::ConstructStaticStringcxx . . $ QTJSC/UStringImpl#ConstructStaticString.); |
| 159 | UStringImplcxx . . $ QTJSC/UStringImpl#::s_emptycxx . . $ QTJSC/UStringImpl#s_empty. = new UStringImplcxx . . $ QTJSC/UStringImpl#(&sharedEmptyCharcxx . . $ QTJSC/sharedEmptyChar., 0, UStringImplcxx . . $ QTJSC/UStringImpl#::ConstructStaticStringcxx . . $ QTJSC/UStringImpl#ConstructStaticString.); |
| 160 | UStringcxx . . $ QTJSC/UString#::nullUStringcxx . . $ QTJSC/UString#nullUString. = new UStringcxx . . $ QTJSC/UString#; |
| 161 | } |
| 162 | |
| 163 | static PassRefPtrcxx . . $ PassRefPtr#<UStringcxx . . $ QTJSC/UString#::Repcxx . . $ QTJSC/UString#Rep#> createRepcxx . . $ QTJSC/createRep(ea9cac048ae7d00a).(const char* c) |
| 164 | { |
| 165 | if (!c) |
| 166 | return &UStringcxx . . $ QTJSC/UString#::Repcxx . . $ QTJSC/UString#Rep#::nullcxx . . $ QTJSC/UStringImpl#null(fdf30dd1b4d8233c).(); |
| 167 | |
| 168 | if (!c[0]) |
| 169 | return &UStringcxx . . $ QTJSC/UString#::Repcxx . . $ QTJSC/UString#Rep#::emptycxx . . $ QTJSC/UStringImpl#empty(fdf30dd1b4d8233c).(); |
| 170 | |
| 171 | size_t length = strlen(c); |
| 172 | UCharcxx . . $ UChar#* d; |
| 173 | PassRefPtrcxx . . $ PassRefPtr#<UStringImplcxx . . $ QTJSC/UStringImpl#> result = UStringImpl::tryCreateUninitialized(length, d); |
| 174 | if (!result) |
| 175 | return &UStringcxx . . $ QTJSC/UString#::Repcxx . . $ QTJSC/UString#Rep#::nullcxx . . $ QTJSC/UStringImpl#null(fdf30dd1b4d8233c).(); |
| 176 | |
| 177 | for (size_t i = 0; i < length; i++) |
| 178 | d[i] = static_cast<unsigned char>(c[i]); // use unsigned char to zero-extend instead of sign-extend |
| 179 | return result; |
| 180 | } |
| 181 | |
| 182 | static inline PassRefPtrcxx . . $ PassRefPtr#<UStringcxx . . $ QTJSC/UString#::Repcxx . . $ QTJSC/UString#Rep#> createRepcxx . . $ QTJSC/createRep(d2ede7de4550ffa9).(const char* c, int length) |
| 183 | { |
| 184 | if (!c) |
| 185 | return &UStringcxx . . $ QTJSC/UString#::Repcxx . . $ QTJSC/UString#Rep#::nullcxx . . $ QTJSC/UStringImpl#null(fdf30dd1b4d8233c).(); |
| 186 | |
| 187 | if (!length) |
| 188 | return &UStringcxx . . $ QTJSC/UString#::Repcxx . . $ QTJSC/UString#Rep#::emptycxx . . $ QTJSC/UStringImpl#empty(fdf30dd1b4d8233c).(); |
| 189 | |
| 190 | UCharcxx . . $ UChar#* d; |
| 191 | PassRefPtrcxx . . $ PassRefPtr#<UStringImplcxx . . $ QTJSC/UStringImpl#> result = UStringImpl::tryCreateUninitialized(length, d); |
| 192 | if (!result) |
| 193 | return &UStringcxx . . $ QTJSC/UString#::Repcxx . . $ QTJSC/UString#Rep#::nullcxx . . $ QTJSC/UStringImpl#null(fdf30dd1b4d8233c).(); |
| 194 | |
| 195 | for (int i = 0; i < length; i++) |
| 196 | d[i] = static_cast<unsigned char>(c[i]); // use unsigned char to zero-extend instead of sign-extend |
| 197 | return result; |
| 198 | } |
| 199 | |
| 200 | UStringcxx . . $ QTJSC/UString#::UStringcxx . . $ QTJSC/UString#UString(85c52e162fed56f9).(const char* c) |
| 201 | : m_rep(createRep(c)) |
| 202 | { |
| 203 | } |
| 204 | |
| 205 | UStringcxx . . $ QTJSC/UString#::UStringcxx . . $ QTJSC/UString#UString(34d26762b42c433a).(const char* c, int length) |
| 206 | : m_rep(createRep(c, length)) |
| 207 | { |
| 208 | } |
| 209 | |
| 210 | UStringcxx . . $ QTJSC/UString#::UStringcxx . . $ QTJSC/UString#UString(280060e335061cbc).(const UCharcxx . . $ UChar#* c, int length) |
| 211 | { |
| 212 | if (length == 0) |
| 213 | m_rep = &Rep::empty(); |
| 214 | else |
| 215 | m_rep = Rep::create(c, length); |
| 216 | } |
| 217 | |
| 218 | UStringcxx . . $ QTJSC/UString# UStringcxx . . $ QTJSC/UString#::createFromUTF8cxx . . $ QTJSC/UString#createFromUTF8(7997a73d481bd958).(const char* string) |
| 219 | { |
| 220 | if (!string) |
| 221 | return nullcxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).(); |
| 222 | |
| 223 | size_t length = strlen(string); |
| 224 | Vectorcxx . . $ Vector#<UCharcxx . . $ UChar#, 1024> buffer(length); |
| 225 | UCharcxx . . $ UChar#* p = buffer.data(); |
| 226 | if (conversionOKcxx . . $ QTWTF/Unicode/conversionOK. != convertUTF8ToUTF16cxx . . $ QTWTF/Unicode/convertUTF8ToUTF16(de240f0d207e4f19).(&string, string + length, &p, p + length)) |
| 227 | return nullcxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).(); |
| 228 | |
| 229 | return UStringcxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).(buffer.data(), p -cxx . . $ std/operator-(a6e85813984128c7). buffer.data()); |
| 230 | } |
| 231 | |
| 232 | UStringcxx . . $ QTJSC/UString# UStringcxx . . $ QTJSC/UString#::fromcxx . . $ QTJSC/UString#from(1ed97944dfe079ad).(int i) |
| 233 | { |
| 234 | UCharcxx . . $ UChar# buf[1 + sizeof(i) * 3]; |
| 235 | UCharcxx . . $ UChar#* end = buf + sizeof(buf) / sizeof(UCharcxx . . $ UChar#); |
| 236 | UCharcxx . . $ UChar#* p = end; |
| 237 | |
| 238 | if (i == 0) |
| 239 | *--p = '0'; |
| 240 | else if (i == INT_MINcxx . . $ `<external>/67164224788392828/limits.h:118:9`!) { |
| 241 | char minBuf[1 + sizeof(i) * 3]; |
| 242 | sprintf(minBuf, "%d", INT_MINcxx . . $ `<external>/67164224788392828/limits.h:118:9`!); |
| 243 | return UStringcxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).(minBuf); |
| 244 | } else { |
| 245 | bool negative = false; |
| 246 | if (i < 0) { |
| 247 | negative = true; |
| 248 | i = -i; |
| 249 | } |
| 250 | while (i) { |
| 251 | *--p = static_cast<unsigned short>((i % 10) + '0'); |
| 252 | i /= 10; |
| 253 | } |
| 254 | if (negative) |
| 255 | *--p = '-'; |
| 256 | } |
| 257 | |
| 258 | return UStringcxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).(p, static_cast<int>(end - p)); |
| 259 | } |
| 260 | |
| 261 | UStringcxx . . $ QTJSC/UString# UStringcxx . . $ QTJSC/UString#::fromcxx . . $ QTJSC/UString#from(e0c62135984997e0).(long long i) |
| 262 | { |
| 263 | UCharcxx . . $ UChar# buf[1 + sizeof(i) * 3]; |
| 264 | UCharcxx . . $ UChar#* end = buf + sizeof(buf) / sizeof(UCharcxx . . $ UChar#); |
| 265 | UCharcxx . . $ UChar#* p = end; |
| 266 | |
| 267 | if (i == 0) |
| 268 | *--p = '0'; |
| 269 | else if (i == std::numeric_limitscxx . . $ std/numeric_limits#<long long>::mincxx . . $ std/numeric_limits#min(a5d9f2bf8849668d).()) { |
| 270 | char minBuf[1 + sizeof(i) * 3]; |
| 271 | #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(WINDOWS) |
| 272 | snprintf(minBuf, sizeof(minBuf) - 1, "%I64d", std::numeric_limits<long long>::min()); |
| 273 | #else |
| 274 | snprintf(minBuf, sizeof(minBuf) - 1, "%lld", std::numeric_limitscxx . . $ std/numeric_limits#<long long>::mincxx . . $ std/numeric_limits#min(a5d9f2bf8849668d).()); |
| 275 | #endif |
| 276 | return UStringcxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).(minBuf); |
| 277 | } else { |
| 278 | bool negative = false; |
| 279 | if (i < 0) { |
| 280 | negative = true; |
| 281 | i = -i; |
| 282 | } |
| 283 | while (i) { |
| 284 | *--p = static_cast<unsigned short>((i % 10) + '0'); |
| 285 | i /= 10; |
| 286 | } |
| 287 | if (negative) |
| 288 | *--p = '-'; |
| 289 | } |
| 290 | |
| 291 | return UStringcxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).(p, static_cast<int>(end - p)); |
| 292 | } |
| 293 | |
| 294 | UStringcxx . . $ QTJSC/UString# UStringcxx . . $ QTJSC/UString#::fromcxx . . $ QTJSC/UString#from(54d53174fb977824).(unsigned int u) |
| 295 | { |
| 296 | UCharcxx . . $ UChar# buf[sizeof(u) * 3]; |
| 297 | UCharcxx . . $ UChar#* end = buf + sizeof(buf) / sizeof(UCharcxx . . $ UChar#); |
| 298 | UCharcxx . . $ UChar#* p = end; |
| 299 | |
| 300 | if (u == 0) |
| 301 | *--p = '0'; |
| 302 | else { |
| 303 | while (u) { |
| 304 | *--p = static_cast<unsigned short>((u % 10) + '0'); |
| 305 | u /= 10; |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | return UStringcxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).(p, static_cast<int>(end - p)); |
| 310 | } |
| 311 | |
| 312 | UStringcxx . . $ QTJSC/UString# UStringcxx . . $ QTJSC/UString#::fromcxx . . $ QTJSC/UString#from(243dcffc87344efa).(long l) |
| 313 | { |
| 314 | UCharcxx . . $ UChar# buf[1 + sizeof(l) * 3]; |
| 315 | UCharcxx . . $ UChar#* end = buf + sizeof(buf) / sizeof(UCharcxx . . $ UChar#); |
| 316 | UCharcxx . . $ UChar#* p = end; |
| 317 | |
| 318 | if (l == 0) |
| 319 | *--p = '0'; |
| 320 | else if (l == LONG_MINcxx . . $ `<external>/67164224788392828/limits.h:129:9`!) { |
| 321 | char minBuf[1 + sizeof(l) * 3]; |
| 322 | sprintf(minBuf, "%ld", LONG_MINcxx . . $ `<external>/67164224788392828/limits.h:129:9`!); |
| 323 | return UStringcxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).(minBuf); |
| 324 | } else { |
| 325 | bool negative = false; |
| 326 | if (l < 0) { |
| 327 | negative = true; |
| 328 | l = -l; |
| 329 | } |
| 330 | while (l) { |
| 331 | *--p = static_cast<unsigned short>((l % 10) + '0'); |
| 332 | l /= 10; |
| 333 | } |
| 334 | if (negative) |
| 335 | *--p = '-'; |
| 336 | } |
| 337 | |
| 338 | return UStringcxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).(p, static_cast<int>(end - p)); |
| 339 | } |
| 340 | |
| 341 | UStringcxx . . $ QTJSC/UString# UStringcxx . . $ QTJSC/UString#::fromcxx . . $ QTJSC/UString#from(f1fb2f715195f7ba).(double d) |
| 342 | { |
| 343 | DtoaBuffercxx . . $ DtoaBuffer# buffer; |
| 344 | unsigned length; |
| 345 | doubleToStringInJavaScriptFormatcxx . . $ doubleToStringInJavaScriptFormat(c050df3a9a955355).(d, buffer, &length); |
| 346 | return UStringcxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).(buffer, length); |
| 347 | } |
| 348 | |
| 349 | UStringcxx . . $ QTJSC/UString# UStringcxx . . $ QTJSC/UString#::spliceSubstringsWithSeparatorscxx . . $ QTJSC/UString#spliceSubstringsWithSeparators(ed9cadda3b49decf).(const Rangecxx . . $ QTJSC/UString#Range#* substringRanges, int rangeCount, const UStringcxx . . $ QTJSC/UString#* separators, int separatorCount) const |
| 350 | { |
| 351 | m_rep->checkConsistency(); |
| 352 | |
| 353 | if (rangeCount == 1 && separatorCount == 0) { |
| 354 | int thisSize = sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 355 | int position = substringRanges[0].positioncxx . . $ QTJSC/UString#Range#position.; |
| 356 | int length = substringRanges[0].lengthcxx . . $ QTJSC/UString#Range#length.; |
| 357 | if (position <= 0 && length >= thisSize) |
| 358 | return *cxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).this; |
| 359 | return UString::Rep::create(m_rep, maxcxx . . $ QTWTF/max(2a338fce5842aa6a).(0, position), mincxx . . $ QTWTF/min(2a338fce5842aa6a).(thisSize, length)); |
| 360 | } |
| 361 | |
| 362 | int totalLength = 0; |
| 363 | for (int i = 0; i < rangeCount; i++) |
| 364 | totalLength += substringRanges[i].lengthcxx . . $ QTJSC/UString#Range#length.; |
| 365 | for (int i = 0; i < separatorCount; i++) |
| 366 | totalLength += separators[i].sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 367 | |
| 368 | if (totalLength == 0) |
| 369 | returncxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d). ""cxx . . $ QTJSC/UString#UString(85c52e162fed56f9).; |
| 370 | |
| 371 | UCharcxx . . $ UChar#* buffer; |
| 372 | PassRefPtrcxx . . $ PassRefPtr#<Repcxx . . $ QTJSC/UString#Rep#> rep = Rep::tryCreateUninitialized(totalLength, buffer); |
| 373 | if (!rep) |
| 374 | return nullcxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).(); |
| 375 | |
| 376 | int maxCount = maxcxx . . $ QTWTF/max(2a338fce5842aa6a).(rangeCount, separatorCount); |
| 377 | int bufferPos = 0; |
| 378 | for (int i = 0; i < maxCount; i++) { |
| 379 | if (i < rangeCount) { |
| 380 | UStringImplcxx . . $ QTJSC/UStringImpl#::copyCharscxx . . $ QTJSC/UStringImpl#copyChars(a032ecf025a4823a).(buffer + bufferPos, datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).() + substringRanges[i].positioncxx . . $ QTJSC/UString#Range#position., substringRanges[i].lengthcxx . . $ QTJSC/UString#Range#length.); |
| 381 | bufferPos += substringRanges[i].lengthcxx . . $ QTJSC/UString#Range#length.; |
| 382 | } |
| 383 | if (i < separatorCount) { |
| 384 | UStringImplcxx . . $ QTJSC/UStringImpl#::copyCharscxx . . $ QTJSC/UStringImpl#copyChars(a032ecf025a4823a).(buffer + bufferPos, separators[i].datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(), separators[i].sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).()); |
| 385 | bufferPos += separators[i].sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | return rep; |
| 390 | } |
| 391 | |
| 392 | UStringcxx . . $ QTJSC/UString# UStringcxx . . $ QTJSC/UString#::replaceRangecxx . . $ QTJSC/UString#replaceRange(53b02ab961aae626).(int rangeStart, int rangeLength, const UStringcxx . . $ QTJSC/UString#& replacement) const |
| 393 | { |
| 394 | m_rep->checkConsistency(); |
| 395 | |
| 396 | int replacementLength = replacement.sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 397 | int totalLength = sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).() - rangeLength + replacementLength; |
| 398 | if (totalLength == 0) |
| 399 | returncxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d). ""cxx . . $ QTJSC/UString#UString(85c52e162fed56f9).; |
| 400 | |
| 401 | UCharcxx . . $ UChar#* buffer; |
| 402 | PassRefPtrcxx . . $ PassRefPtr#<Repcxx . . $ QTJSC/UString#Rep#> rep = Rep::tryCreateUninitialized(totalLength, buffer); |
| 403 | if (!rep) |
| 404 | return nullcxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).(); |
| 405 | |
| 406 | UStringImplcxx . . $ QTJSC/UStringImpl#::copyCharscxx . . $ QTJSC/UStringImpl#copyChars(a032ecf025a4823a).(buffer, datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(), rangeStart); |
| 407 | UStringImplcxx . . $ QTJSC/UStringImpl#::copyCharscxx . . $ QTJSC/UStringImpl#copyChars(a032ecf025a4823a).(buffer + rangeStart, replacement.datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(), replacementLength); |
| 408 | int rangeEnd = rangeStart + rangeLength; |
| 409 | UStringImplcxx . . $ QTJSC/UStringImpl#::copyCharscxx . . $ QTJSC/UStringImpl#copyChars(a032ecf025a4823a).(buffer + rangeStart + replacementLength, datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).() + rangeEnd, sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).() - rangeEnd); |
| 410 | |
| 411 | return rep; |
| 412 | } |
| 413 | |
| 414 | bool UStringcxx . . $ QTJSC/UString#::getCStringcxx . . $ QTJSC/UString#getCString(64738f2312fe887d).(CStringBuffercxx . . $ QTJSC/CStringBuffer#& buffer) const |
| 415 | { |
| 416 | int length = sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 417 | int neededSize = length + 1; |
| 418 | buffer.resize(neededSize); |
| 419 | char* buf = buffer.data(); |
| 420 | |
| 421 | UCharcxx . . $ UChar# ored = 0; |
| 422 | const UCharcxx . . $ UChar#* p = datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(); |
| 423 | char* q = buf; |
| 424 | const UCharcxx . . $ UChar#* limit = p + length; |
| 425 | while (p != limit) { |
| 426 | UCharcxx . . $ UChar# c = p[0]; |
| 427 | ored |= c; |
| 428 | *q = static_cast<char>(c); |
| 429 | ++p; |
| 430 | ++q; |
| 431 | } |
| 432 | *q = '\0'; |
| 433 | |
| 434 | return !(ored & 0xFF00); |
| 435 | } |
| 436 | |
| 437 | char* UStringcxx . . $ QTJSC/UString#::asciicxx . . $ QTJSC/UString#ascii(e7e5aa338b9d5147).() const |
| 438 | { |
| 439 | static char* asciiBuffer = 0; |
| 440 | |
| 441 | int length = sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 442 | int neededSize = length + 1; |
| 443 | delete[] asciiBuffer; |
| 444 | asciiBuffer = new char[neededSize]; |
| 445 | |
| 446 | const UCharcxx . . $ UChar#* p = datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(); |
| 447 | char* q = asciiBuffer; |
| 448 | const UCharcxx . . $ UChar#* limit = p + length; |
| 449 | while (p != limit) { |
| 450 | *q = static_cast<char>(p[0]); |
| 451 | ++p; |
| 452 | ++q; |
| 453 | } |
| 454 | *q = '\0'; |
| 455 | |
| 456 | return asciiBuffer; |
| 457 | } |
| 458 | |
| 459 | UStringcxx . . $ QTJSC/UString#& UStringcxx . . $ QTJSC/UString#::operatorcxx . . $ QTJSC/UString#`operator=`(70cadf8fa21ba6da).=(const char* c) |
| 460 | { |
| 461 | if (!c) { |
| 462 | m_rep = &Rep::null(); |
| 463 | return *this; |
| 464 | } |
| 465 | |
| 466 | if (!c[0]) { |
| 467 | m_rep = &Rep::empty(); |
| 468 | return *this; |
| 469 | } |
| 470 | |
| 471 | int l = static_cast<int>(strlen(c)); |
| 472 | UCharcxx . . $ UChar#* d = 0; |
| 473 | m_rep = Rep::tryCreateUninitialized(l, d); |
| 474 | if (m_rep) { |
| 475 | for (int i = 0; i < l; i++) |
| 476 | d[i] = static_cast<unsigned char>(c[i]); // use unsigned char to zero-extend instead of sign-extend |
| 477 | } else |
| 478 | makeNullcxx . . $ QTJSC/UString#makeNull(49f6e7a06ebc5aa8).(); |
| 479 | |
| 480 | return *this; |
| 481 | } |
| 482 | |
| 483 | bool UStringcxx . . $ QTJSC/UString#::is8Bitcxx . . $ QTJSC/UString#is8Bit(50ce9a9e25b4a850).() const |
| 484 | { |
| 485 | const UCharcxx . . $ UChar#* u = datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(); |
| 486 | const UCharcxx . . $ UChar#* limit = u + sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 487 | while (u < limit) { |
| 488 | if (u[0] > 0xFF) |
| 489 | return false; |
| 490 | ++u; |
| 491 | } |
| 492 | |
| 493 | return true; |
| 494 | } |
| 495 | |
| 496 | UCharcxx . . $ UChar# UStringcxx . . $ QTJSC/UString#::operatorcxx . . $ QTJSC/UString#`operator[]`(81721cd16838b595).[](int pos) const |
| 497 | { |
| 498 | if (pos >= sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).()) |
| 499 | return '\0'; |
| 500 | return datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).()[pos]; |
| 501 | } |
| 502 | |
| 503 | double UStringcxx . . $ QTJSC/UString#::toDoublecxx . . $ QTJSC/UString#toDouble(b2da4fe40e23cdf4).(bool tolerateTrailingJunk, bool tolerateEmptyString) const |
| 504 | { |
| 505 | if (sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).() == 1) { |
| 506 | UCharcxx . . $ UChar# c = datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).()[0]; |
| 507 | if (isASCIIDigitcxx . . $ isASCIIDigit(3c978dac0e5ee2ad).(c)) |
| 508 | return c - '0'; |
| 509 | if (isASCIISpacecxx . . $ isASCIISpace(3c978dac0e5ee2ad).(c) && tolerateEmptyString) |
| 510 | return 0; |
| 511 | return NaNcxx . . $ QTJSC/NaN.; |
| 512 | } |
| 513 | |
| 514 | // FIXME: If tolerateTrailingJunk is true, then we want to tolerate non-8-bit junk |
| 515 | // after the number, so this is too strict a check. |
| 516 | CStringBuffercxx . . $ QTJSC/CStringBuffer# s; |
| 517 | if (!getCStringcxx . . $ QTJSC/UString#getCString(64738f2312fe887d).(s)) |
| 518 | return NaNcxx . . $ QTJSC/NaN.; |
| 519 | const char* c = s.data(); |
| 520 | |
| 521 | // skip leading white space |
| 522 | while (isASCIISpacecxx . . $ isASCIISpace(b5fd09639b7a0261).(*c)) |
| 523 | c++; |
| 524 | |
| 525 | // empty string ? |
| 526 | if (*c == '\0') |
| 527 | return tolerateEmptyString ? 0.0 : NaNcxx . . $ QTJSC/NaN.; |
| 528 | |
| 529 | double d; |
| 530 | |
| 531 | // hex number ? |
| 532 | if (*c == '0' && (*(c + 1) == 'x' || *(c + 1) == 'X')) { |
| 533 | const char* firstDigitPosition = c + 2; |
| 534 | c++; |
| 535 | d = 0.0; |
| 536 | while (*(++c)) { |
| 537 | if (*c >= '0' && *c <= '9') |
| 538 | d = d * 16.0 + *c - '0'; |
| 539 | else if ((*c >= 'A' && *c <= 'F') || (*c >= 'a' && *c <= 'f')) |
| 540 | d = d * 16.0 + (*c & 0xdf) - 'A' + 10.0; |
| 541 | else |
| 542 | break; |
| 543 | } |
| 544 | |
| 545 | if (d >= mantissaOverflowLowerBoundcxx . . $ QTJSC/mantissaOverflowLowerBound.) |
| 546 | d = parseIntOverflowcxx . . $ QTJSC/parseIntOverflow(aac88a90e076343c).(firstDigitPosition, c - firstDigitPosition, 16); |
| 547 | } else { |
| 548 | // regular number ? |
| 549 | char* end; |
| 550 | d = WTFcxx . . $ `<built-in>:467:9`!::strtodcxx . . $ QTWTF/strtod(3dfe5620a0d3160e).(c, &end); |
| 551 | if ((d != 0.0 || end != c) && d != Infcxx . . $ QTJSC/Inf. && d != -Infcxx . . $ QTJSC/Inf.) { |
| 552 | c = end; |
| 553 | } else { |
| 554 | double sign = 1.0; |
| 555 | |
| 556 | if (*c == '+') |
| 557 | c++; |
| 558 | else if (*c == '-') { |
| 559 | sign = -1.0; |
| 560 | c++; |
| 561 | } |
| 562 | |
| 563 | // We used strtod() to do the conversion. However, strtod() handles |
| 564 | // infinite values slightly differently than JavaScript in that it |
| 565 | // converts the string "inf" with any capitalization to infinity, |
| 566 | // whereas the ECMA spec requires that it be converted to NaN. |
| 567 | |
| 568 | if (c[0] == 'I' && c[1] == 'n' && c[2] == 'f' && c[3] == 'i' && c[4] == 'n' && c[5] == 'i' && c[6] == 't' && c[7] == 'y') { |
| 569 | d = sign * Infcxx . . $ QTJSC/Inf.; |
| 570 | c += 8; |
| 571 | } else if ((d == Infcxx . . $ QTJSC/Inf. || d == -Infcxx . . $ QTJSC/Inf.) && *c != 'I' && *c != 'i') |
| 572 | c = end; |
| 573 | else |
| 574 | return NaNcxx . . $ QTJSC/NaN.; |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | // allow trailing white space |
| 579 | while (isASCIISpacecxx . . $ isASCIISpace(b5fd09639b7a0261).(*c)) |
| 580 | c++; |
| 581 | // don't allow anything after - unless tolerant=true |
| 582 | if (!tolerateTrailingJunk && *c != '\0') |
| 583 | d = NaNcxx . . $ QTJSC/NaN.; |
| 584 | |
| 585 | return d; |
| 586 | } |
| 587 | |
| 588 | double UStringcxx . . $ QTJSC/UString#::toDoublecxx . . $ QTJSC/UString#toDouble(305e4bce9887ae63).(bool tolerateTrailingJunk) const |
| 589 | { |
| 590 | return toDoublecxx . . $ QTJSC/UString#toDouble(b2da4fe40e23cdf4).(tolerateTrailingJunk, true); |
| 591 | } |
| 592 | |
| 593 | double UStringcxx . . $ QTJSC/UString#::toDoublecxx . . $ QTJSC/UString#toDouble(21b6c25e127938e2).() const |
| 594 | { |
| 595 | return toDoublecxx . . $ QTJSC/UString#toDouble(b2da4fe40e23cdf4).(false, true); |
| 596 | } |
| 597 | |
| 598 | uint32_tcxx . . $ uint32_t# UStringcxx . . $ QTJSC/UString#::toUInt32cxx . . $ QTJSC/UString#toUInt32(870b63f89c7fb98).(bool* ok) const |
| 599 | { |
| 600 | double d = toDoublecxx . . $ QTJSC/UString#toDouble(21b6c25e127938e2).(); |
| 601 | bool b = true; |
| 602 | |
| 603 | if (d != static_cast<uint32_tcxx . . $ uint32_t#>(d)) { |
| 604 | b = false; |
| 605 | d = 0; |
| 606 | } |
| 607 | |
| 608 | if (ok) |
| 609 | *ok = b; |
| 610 | |
| 611 | return static_cast<uint32_tcxx . . $ uint32_t#>(d); |
| 612 | } |
| 613 | |
| 614 | uint32_tcxx . . $ uint32_t# UStringcxx . . $ QTJSC/UString#::toUInt32cxx . . $ QTJSC/UString#toUInt32(7e25dc0896afbd5b).(bool* ok, bool tolerateEmptyString) const |
| 615 | { |
| 616 | double d = toDoublecxx . . $ QTJSC/UString#toDouble(b2da4fe40e23cdf4).(false, tolerateEmptyString); |
| 617 | bool b = true; |
| 618 | |
| 619 | if (d != static_cast<uint32_tcxx . . $ uint32_t#>(d)) { |
| 620 | b = false; |
| 621 | d = 0; |
| 622 | } |
| 623 | |
| 624 | if (ok) |
| 625 | *ok = b; |
| 626 | |
| 627 | return static_cast<uint32_tcxx . . $ uint32_t#>(d); |
| 628 | } |
| 629 | |
| 630 | uint32_tcxx . . $ uint32_t# UStringcxx . . $ QTJSC/UString#::toStrictUInt32cxx . . $ QTJSC/UString#toStrictUInt32(870b63f89c7fb98).(bool* ok) const |
| 631 | { |
| 632 | if (ok) |
| 633 | *ok = false; |
| 634 | |
| 635 | // Empty string is not OK. |
| 636 | int len = m_rep->size(); |
| 637 | if (len == 0) |
| 638 | return 0; |
| 639 | const UCharcxx . . $ UChar#* p = m_rep->data(); |
| 640 | unsigned short c = p[0]; |
| 641 | |
| 642 | // If the first digit is 0, only 0 itself is OK. |
| 643 | if (c == '0') { |
| 644 | if (len == 1 && ok) |
| 645 | *ok = true; |
| 646 | return 0; |
| 647 | } |
| 648 | |
| 649 | // Convert to UInt32, checking for overflow. |
| 650 | uint32_tcxx . . $ uint32_t# i = 0; |
| 651 | while (1) { |
| 652 | // Process character, turning it into a digit. |
| 653 | if (c < '0' || c > '9') |
| 654 | return 0; |
| 655 | const unsigned d = c - '0'; |
| 656 | |
| 657 | // Multiply by 10, checking for overflow out of 32 bits. |
| 658 | if (i > 0xFFFFFFFFU / 10) |
| 659 | return 0; |
| 660 | i *= 10; |
| 661 | |
| 662 | // Add in the digit, checking for overflow out of 32 bits. |
| 663 | const unsigned max = 0xFFFFFFFFU - d; |
| 664 | if (i > max) |
| 665 | return 0; |
| 666 | i += d; |
| 667 | |
| 668 | // Handle end of string. |
| 669 | if (--len == 0) { |
| 670 | if (ok) |
| 671 | *ok = true; |
| 672 | return i; |
| 673 | } |
| 674 | |
| 675 | // Get next character. |
| 676 | c = *(++p); |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | int UStringcxx . . $ QTJSC/UString#::findcxx . . $ QTJSC/UString#find(70eccbdd5fc86362).(const UStringcxx . . $ QTJSC/UString#& f, int pos) const |
| 681 | { |
| 682 | int fsz = f.sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 683 | |
| 684 | if (pos < 0) |
| 685 | pos = 0; |
| 686 | |
| 687 | if (fsz == 1) { |
| 688 | UCharcxx . . $ UChar# ch = f[cxx . . $ QTJSC/UString#`operator[]`(81721cd16838b595).0]; |
| 689 | const UCharcxx . . $ UChar#* end = datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).() + sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 690 | for (const UCharcxx . . $ UChar#* c = datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).() + pos; c < end; c++) { |
| 691 | if (*c == ch) |
| 692 | return static_cast<int>(c - datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).()); |
| 693 | } |
| 694 | return -1; |
| 695 | } |
| 696 | |
| 697 | int sz = sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 698 | if (sz < fsz) |
| 699 | return -1; |
| 700 | if (fsz == 0) |
| 701 | return pos; |
| 702 | const UCharcxx . . $ UChar#* end = datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).() + sz - fsz; |
| 703 | int fsizeminusone = (fsz - 1) * sizeof(UCharcxx . . $ UChar#); |
| 704 | const UCharcxx . . $ UChar#* fdata = f.datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(); |
| 705 | unsigned short fchar = fdata[0]; |
| 706 | ++fdata; |
| 707 | for (const UCharcxx . . $ UChar#* c = datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).() + pos; c <= end; c++) { |
| 708 | if (c[0] == fchar && !memcmp(c + 1, fdata, fsizeminusone)) |
| 709 | return static_cast<int>(c - datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).()); |
| 710 | } |
| 711 | |
| 712 | return -1; |
| 713 | } |
| 714 | |
| 715 | int UStringcxx . . $ QTJSC/UString#::findcxx . . $ QTJSC/UString#find(2e669bd8f683556).(UCharcxx . . $ UChar# ch, int pos) const |
| 716 | { |
| 717 | if (pos < 0) |
| 718 | pos = 0; |
| 719 | const UCharcxx . . $ UChar#* end = datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).() + sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 720 | for (const UCharcxx . . $ UChar#* c = datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).() + pos; c < end; c++) { |
| 721 | if (*c == ch) |
| 722 | return static_cast<int>(c - datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).()); |
| 723 | } |
| 724 | |
| 725 | return -1; |
| 726 | } |
| 727 | |
| 728 | int UStringcxx . . $ QTJSC/UString#::rfindcxx . . $ QTJSC/UString#rfind(70eccbdd5fc86362).(const UStringcxx . . $ QTJSC/UString#& f, int pos) const |
| 729 | { |
| 730 | int sz = sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 731 | int fsz = f.sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 732 | if (sz < fsz) |
| 733 | return -1; |
| 734 | if (pos < 0) |
| 735 | pos = 0; |
| 736 | if (pos > sz - fsz) |
| 737 | pos = sz - fsz; |
| 738 | if (fsz == 0) |
| 739 | return pos; |
| 740 | int fsizeminusone = (fsz - 1) * sizeof(UCharcxx . . $ UChar#); |
| 741 | const UCharcxx . . $ UChar#* fdata = f.datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(); |
| 742 | for (const UCharcxx . . $ UChar#* c = datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).() + pos; c >= datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(); c--) { |
| 743 | if (*c == *fdata && !memcmp(c + 1, fdata + 1, fsizeminusone)) |
| 744 | return static_cast<int>(c - datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).()); |
| 745 | } |
| 746 | |
| 747 | return -1; |
| 748 | } |
| 749 | |
| 750 | int UStringcxx . . $ QTJSC/UString#::rfindcxx . . $ QTJSC/UString#rfind(2e669bd8f683556).(UCharcxx . . $ UChar# ch, int pos) const |
| 751 | { |
| 752 | if (isEmptycxx . . $ QTJSC/UString#isEmpty(50ce9a9e25b4a850).()) |
| 753 | return -1; |
| 754 | if (pos + 1 >= sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).()) |
| 755 | pos = sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).() - 1; |
| 756 | for (const UCharcxx . . $ UChar#* c = datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).() + pos; c >= datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(); c--) { |
| 757 | if (*c == ch) |
| 758 | return static_cast<int>(c - datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).()); |
| 759 | } |
| 760 | |
| 761 | return -1; |
| 762 | } |
| 763 | |
| 764 | UStringcxx . . $ QTJSC/UString# UStringcxx . . $ QTJSC/UString#::substrcxx . . $ QTJSC/UString#substr(2aae7669e5263855).(int pos, int len) const |
| 765 | { |
| 766 | int s = sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 767 | |
| 768 | if (pos < 0) |
| 769 | pos = 0; |
| 770 | else if (pos >= s) |
| 771 | pos = s; |
| 772 | if (len < 0) |
| 773 | len = s; |
| 774 | if (pos + len >= s) |
| 775 | len = s - pos; |
| 776 | |
| 777 | if (pos == 0 && len == s) |
| 778 | return *cxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).this; |
| 779 | |
| 780 | return UStringcxx . . $ QTJSC/UString#UString(e6bad6cb9b63b14d).(Rep::create(m_rep, pos, len)); |
| 781 | } |
| 782 | |
| 783 | bool operatorcxx . . $ QTJSC/`operator==`(593d45c770f98d7c).==(const UStringcxx . . $ QTJSC/UString#& s1, const char *s2) |
| 784 | { |
| 785 | if (s2 == 0) |
| 786 | return s1.isEmptycxx . . $ QTJSC/UString#isEmpty(50ce9a9e25b4a850).(); |
| 787 | |
| 788 | const UCharcxx . . $ UChar#* u = s1.datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(); |
| 789 | const UCharcxx . . $ UChar#* uend = u + s1.sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 790 | while (u != uend && *s2) { |
| 791 | if (u[0] != (unsigned char)*s2) |
| 792 | return false; |
| 793 | s2++; |
| 794 | u++; |
| 795 | } |
| 796 | |
| 797 | return u == uend && *s2 == 0; |
| 798 | } |
| 799 | |
| 800 | bool operatorcxx . . $ QTJSC/`operator<`(11610d830df66bbf).<(const UStringcxx . . $ QTJSC/UString#& s1, const UStringcxx . . $ QTJSC/UString#& s2) |
| 801 | { |
| 802 | const int l1 = s1.sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 803 | const int l2 = s2.sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 804 | const int lmin = l1 < l2 ? l1 : l2; |
| 805 | const UCharcxx . . $ UChar#* c1 = s1.datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(); |
| 806 | const UCharcxx . . $ UChar#* c2 = s2.datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(); |
| 807 | int l = 0; |
| 808 | while (l < lmin && *c1 == *c2) { |
| 809 | c1++; |
| 810 | c2++; |
| 811 | l++; |
| 812 | } |
| 813 | if (l < lmin) |
| 814 | return (c1[0] < c2[0]); |
| 815 | |
| 816 | return (l1 < l2); |
| 817 | } |
| 818 | |
| 819 | bool operatorcxx . . $ QTJSC/`operator>`(11610d830df66bbf).>(const UStringcxx . . $ QTJSC/UString#& s1, const UStringcxx . . $ QTJSC/UString#& s2) |
| 820 | { |
| 821 | const int l1 = s1.sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 822 | const int l2 = s2.sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 823 | const int lmin = l1 < l2 ? l1 : l2; |
| 824 | const UCharcxx . . $ UChar#* c1 = s1.datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(); |
| 825 | const UCharcxx . . $ UChar#* c2 = s2.datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(); |
| 826 | int l = 0; |
| 827 | while (l < lmin && *c1 == *c2) { |
| 828 | c1++; |
| 829 | c2++; |
| 830 | l++; |
| 831 | } |
| 832 | if (l < lmin) |
| 833 | return (c1[0] > c2[0]); |
| 834 | |
| 835 | return (l1 > l2); |
| 836 | } |
| 837 | |
| 838 | int comparecxx . . $ QTJSC/compare(3b03898a94650926).(const UStringcxx . . $ QTJSC/UString#& s1, const UStringcxx . . $ QTJSC/UString#& s2) |
| 839 | { |
| 840 | const int l1 = s1.sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 841 | const int l2 = s2.sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 842 | const int lmin = l1 < l2 ? l1 : l2; |
| 843 | const UCharcxx . . $ UChar#* c1 = s1.datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(); |
| 844 | const UCharcxx . . $ UChar#* c2 = s2.datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).(); |
| 845 | int l = 0; |
| 846 | while (l < lmin && *c1 == *c2) { |
| 847 | c1++; |
| 848 | c2++; |
| 849 | l++; |
| 850 | } |
| 851 | |
| 852 | if (l < lmin) |
| 853 | return (c1[0] > c2[0]) ? 1 : -1; |
| 854 | |
| 855 | if (l1 == l2) |
| 856 | return 0; |
| 857 | |
| 858 | return (l1 > l2) ? 1 : -1; |
| 859 | } |
| 860 | |
| 861 | #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(SOLARIS) && COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(SUNCC) |
| 862 | // Signature must match that of UStringImpl.h, otherwise the linker complains about undefined symbol. |
| 863 | bool equal(const UStringImpl* r, const UStringImpl* b) |
| 864 | #else |
| 865 | bool equalcxx . . $ QTJSC/equal(ec03a94da9606b8d).(const UStringcxx . . $ QTJSC/UString#::Repcxx . . $ QTJSC/UString#Rep#* r, const UStringcxx . . $ QTJSC/UString#::Repcxx . . $ QTJSC/UString#Rep#* b) |
| 866 | #endif |
| 867 | { |
| 868 | int length = r->sizecxx . . $ QTJSC/UStringImpl#size(455f465bc33b4cdf).(); |
| 869 | if (length != b->sizecxx . . $ QTJSC/UStringImpl#size(455f465bc33b4cdf).()) |
| 870 | return false; |
| 871 | const UCharcxx . . $ UChar#* d = r->datacxx . . $ QTJSC/UStringImpl#data(da28cdd8371e77b7).(); |
| 872 | const UCharcxx . . $ UChar#* s = b->datacxx . . $ QTJSC/UStringImpl#data(da28cdd8371e77b7).(); |
| 873 | for (int i = 0; i != length; ++i) { |
| 874 | if (d[i] != s[i]) |
| 875 | return false; |
| 876 | } |
| 877 | return true; |
| 878 | } |
| 879 | |
| 880 | CStringcxx . . $ QTJSC/CString# UStringcxx . . $ QTJSC/UString#::UTF8Stringcxx . . $ QTJSC/UString#UTF8String(93ff631091aac352).(bool strict) const |
| 881 | { |
| 882 | // Allocate a buffer big enough to hold all the characters. |
| 883 | const int length = sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).(); |
| 884 | Vectorcxx . . $ Vector#<char, 1024> buffer(length * 3); |
| 885 | |
| 886 | // Convert to runs of 8-bit characters. |
| 887 | char* p = buffer.data(); |
| 888 | const UCharcxx . . $ UChar#* d = reinterpret_cast<const UCharcxx . . $ UChar#*>(&datacxx . . $ QTJSC/UString#data(9865edf6270d80f8).()[0]); |
| 889 | ConversionResultcxx . . $ QTWTF/Unicode/ConversionResult# result = convertUTF16ToUTF8cxx . . $ QTWTF/Unicode/convertUTF16ToUTF8(c3351d9d7f212dbf).(&d, d + length, &p, p +cxx . . $ operator+(f3789794639247d3). buffer.size(), strict); |
| 890 | if (result != conversionOKcxx . . $ QTWTF/Unicode/conversionOK.) |
| 891 | return CStringcxx . . $ QTJSC/CString#CString(f113043c45ce5422).(); |
| 892 | |
| 893 | return CStringcxx . . $ QTJSC/CString#CString(f113043c45ce5422).(buffer.data(), p -cxx . . $ std/operator-(a6e85813984128c7). buffer.data()); |
| 894 | } |
| 895 | |
| 896 | // For use in error handling code paths -- having this not be inlined helps avoid PIC branches to fetch the global on Mac OS X. |
| 897 | NEVER_INLINEcxx . . $ `../3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:35:9`! void UStringcxx . . $ QTJSC/UString#::makeNullcxx . . $ QTJSC/UString#makeNull(49f6e7a06ebc5aa8).() |
| 898 | { |
| 899 | m_rep = &Rep::null(); |
| 900 | } |
| 901 | |
| 902 | // For use in error handling code paths -- having this not be inlined helps avoid PIC branches to fetch the global on Mac OS X. |
| 903 | NEVER_INLINEcxx . . $ `../3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:35:9`! UStringcxx . . $ QTJSC/UString#::Repcxx . . $ QTJSC/UString#Rep#* UStringcxx . . $ QTJSC/UString#::nullRepcxx . . $ QTJSC/UString#nullRep(b56a90d0afa3b8ee).() |
| 904 | { |
| 905 | return &Repcxx . . $ QTJSC/UString#Rep#::nullcxx . . $ QTJSC/UStringImpl#null(fdf30dd1b4d8233c).(); |
| 906 | } |
| 907 | |
| 908 | } // namespace JSC |