File: | home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx |
Warning: | line 54, column 5 Null pointer passed to 1st parameter expecting 'nonnull' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||
2 | /* | |||
3 | * This file is part of the LibreOffice project. | |||
4 | * | |||
5 | * This Source Code Form is subject to the terms of the Mozilla Public | |||
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this | |||
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |||
8 | * | |||
9 | * This file incorporates work covered by the following license notice: | |||
10 | * | |||
11 | * Licensed to the Apache Software Foundation (ASF) under one or more | |||
12 | * contributor license agreements. See the NOTICE file distributed | |||
13 | * with this work for additional information regarding copyright | |||
14 | * ownership. The ASF licenses this file to you under the Apache | |||
15 | * License, Version 2.0 (the "License"); you may not use this file | |||
16 | * except in compliance with the License. You may obtain a copy of | |||
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | |||
18 | */ | |||
19 | ||||
20 | #include <sal/config.h> | |||
21 | ||||
22 | #include <cassert> | |||
23 | #include <cstdlib> | |||
24 | #include <limits> | |||
25 | #include <stdexcept> | |||
26 | #include <string> | |||
27 | ||||
28 | #include <osl/diagnose.h> | |||
29 | #include <osl/interlck.h> | |||
30 | #include <rtl/alloc.h> | |||
31 | #include <osl/mutex.h> | |||
32 | #include <rtl/tencinfo.h> | |||
33 | ||||
34 | #include <string.h> | |||
35 | #include <sal/alloca.h> | |||
36 | #include <sal/log.hxx> | |||
37 | ||||
38 | #include "hash.hxx" | |||
39 | #include "strimp.hxx" | |||
40 | #include <rtl/character.hxx> | |||
41 | #include <rtl/ustring.h> | |||
42 | ||||
43 | #include <rtl/math.h> | |||
44 | ||||
45 | /* ======================================================================= */ | |||
46 | ||||
47 | /* static data to be referenced by all empty strings | |||
48 | * the refCount is predefined to 1 and must never become 0 ! | |||
49 | */ | |||
50 | rtl_uString const aImplEmpty_rtl_uString = | |||
51 | { | |||
52 | sal_Int32(SAL_STRING_INTERN_FLAG0x80000000|SAL_STRING_STATIC_FLAG0x40000000|1), /*sal_Int32 refCount; */ | |||
53 | 0, /*sal_Int32 length; */ | |||
54 | { 0 } /*sal_Unicode buffer[1];*/ | |||
55 | }; | |||
56 | ||||
57 | /* ======================================================================= */ | |||
58 | /* These macros are for the "poor-man templates" included from | |||
59 | * the strtmpl.cxx just below, used to share code between here and | |||
60 | * string.cxx | |||
61 | */ | |||
62 | ||||
63 | #define IMPL_RTL_IS_USTRING 1 | |||
64 | ||||
65 | #define IMPL_RTL_STRCODE sal_Unicode | |||
66 | #define IMPL_RTL_USTRCODE( c ) (c) | |||
67 | #define IMPL_RTL_STRNAME( n ) rtl_ustr_ ## n | |||
68 | ||||
69 | #define IMPL_RTL_STRINGNAME( n ) rtl_uString_ ## n | |||
70 | #define IMPL_RTL_STRINGDATA rtl_uString | |||
71 | #define IMPL_RTL_EMPTYSTRING aImplEmpty_rtl_uString | |||
72 | ||||
73 | static void internRelease (rtl_uString *pThis); | |||
74 | ||||
75 | #if USE_SDT_PROBES1 | |||
76 | #define RTL_LOG_STRING_BITS 16 | |||
77 | #endif | |||
78 | ||||
79 | /* ======================================================================= */ | |||
80 | ||||
81 | /* Include String/UString template code */ | |||
82 | ||||
83 | #include "strtmpl.cxx" | |||
84 | ||||
85 | #undef IMPL_RTL_EMPTYSTRING | |||
86 | #undef IMPL_RTL_IS_USTRING | |||
87 | #undef IMPL_RTL_STRCODE | |||
88 | #undef IMPL_RTL_STRINGDATA | |||
89 | #undef IMPL_RTL_STRINGNAME | |||
90 | #undef IMPL_RTL_STRNAME | |||
91 | #undef IMPL_RTL_USTRCODE | |||
92 | #undef RTL_LOG_STRING_BITS | |||
93 | ||||
94 | sal_Int32 rtl_ustr_indexOfAscii_WithLength( | |||
95 | sal_Unicode const * str, sal_Int32 len, | |||
96 | char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()throw () | |||
97 | { | |||
98 | assert(len >= 0)(static_cast <bool> (len >= 0) ? void (0) : __assert_fail ("len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 98, __extension__ __PRETTY_FUNCTION__)); | |||
99 | assert(subLen >= 0)(static_cast <bool> (subLen >= 0) ? void (0) : __assert_fail ("subLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 99, __extension__ __PRETTY_FUNCTION__)); | |||
100 | if (subLen > 0 && subLen <= len) | |||
101 | { | |||
102 | sal_Unicode const* end = str + len; | |||
103 | sal_Unicode const* cursor = str; | |||
104 | ||||
105 | while(cursor < end) | |||
106 | { | |||
107 | cursor = std::char_traits<sal_Unicode>::find(cursor, end - cursor, *subStr); | |||
108 | if(!cursor || (end - cursor < subLen)) | |||
109 | { | |||
110 | /* no enough left to actually have a match */ | |||
111 | break; | |||
112 | } | |||
113 | /* now it is worth trying a full match */ | |||
114 | if (rtl_ustr_asciil_reverseEquals_WithLength(cursor, subStr, subLen)) | |||
115 | { | |||
116 | return cursor - str; | |||
117 | } | |||
118 | cursor += 1; | |||
119 | } | |||
120 | } | |||
121 | return -1; | |||
122 | } | |||
123 | ||||
124 | sal_Int32 rtl_ustr_lastIndexOfAscii_WithLength( | |||
125 | sal_Unicode const * str, sal_Int32 len, | |||
126 | char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()throw () | |||
127 | { | |||
128 | assert(len >= 0)(static_cast <bool> (len >= 0) ? void (0) : __assert_fail ("len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 128, __extension__ __PRETTY_FUNCTION__)); | |||
129 | assert(subLen >= 0)(static_cast <bool> (subLen >= 0) ? void (0) : __assert_fail ("subLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 129, __extension__ __PRETTY_FUNCTION__)); | |||
130 | if (subLen > 0 && subLen <= len) { | |||
131 | sal_Int32 i; | |||
132 | for (i = len - subLen; i >= 0; --i) { | |||
133 | if (rtl_ustr_asciil_reverseEquals_WithLength( | |||
134 | str + i, subStr, subLen)) | |||
135 | { | |||
136 | return i; | |||
137 | } | |||
138 | } | |||
139 | } | |||
140 | return -1; | |||
141 | } | |||
142 | ||||
143 | sal_Int32 SAL_CALL rtl_ustr_valueOfFloat(sal_Unicode * pStr, float f) | |||
144 | SAL_THROW_EXTERN_C()throw () | |||
145 | { | |||
146 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 146, __extension__ __PRETTY_FUNCTION__)); | |||
147 | rtl_uString * pResult = nullptr; | |||
148 | sal_Int32 nLen; | |||
149 | rtl_math_doubleToUString( | |||
150 | &pResult, nullptr, 0, f, rtl_math_StringFormat_G, | |||
151 | RTL_USTR_MAX_VALUEOFFLOAT15 - RTL_CONSTASCII_LENGTH("-x.E-xxx")((sal_Int32)((sizeof(sal_n_array_size("-x.E-xxx")))-1)), '.', nullptr, | |||
152 | 0, true); | |||
153 | nLen = pResult->length; | |||
154 | OSL_ASSERT(nLen < RTL_USTR_MAX_VALUEOFFLOAT)do { if (true && (!(nLen < 15))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "154" ": "), "OSL_ASSERT: %s", "nLen < RTL_USTR_MAX_VALUEOFFLOAT" ); } } while (false); | |||
155 | memcpy(pStr, pResult->buffer, (nLen + 1) * sizeof(sal_Unicode)); | |||
156 | rtl_uString_release(pResult); | |||
157 | return nLen; | |||
158 | } | |||
159 | ||||
160 | sal_Int32 SAL_CALL rtl_ustr_valueOfDouble(sal_Unicode * pStr, double d) | |||
161 | SAL_THROW_EXTERN_C()throw () | |||
162 | { | |||
163 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 163, __extension__ __PRETTY_FUNCTION__)); | |||
164 | rtl_uString * pResult = nullptr; | |||
165 | sal_Int32 nLen; | |||
166 | rtl_math_doubleToUString( | |||
167 | &pResult, nullptr, 0, d, rtl_math_StringFormat_G, | |||
168 | RTL_USTR_MAX_VALUEOFDOUBLE25 - RTL_CONSTASCII_LENGTH("-x.E-xxx")((sal_Int32)((sizeof(sal_n_array_size("-x.E-xxx")))-1)), '.', nullptr, | |||
169 | 0, true); | |||
170 | nLen = pResult->length; | |||
171 | OSL_ASSERT(nLen < RTL_USTR_MAX_VALUEOFDOUBLE)do { if (true && (!(nLen < 25))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "171" ": "), "OSL_ASSERT: %s", "nLen < RTL_USTR_MAX_VALUEOFDOUBLE" ); } } while (false); | |||
172 | memcpy(pStr, pResult->buffer, (nLen + 1) * sizeof(sal_Unicode)); | |||
173 | rtl_uString_release(pResult); | |||
174 | return nLen; | |||
175 | } | |||
176 | ||||
177 | namespace { | |||
178 | ||||
179 | // Avoid -fsanitize=undefined warning e.g. "runtime error: value 1e+99 is | |||
180 | // outside the range of representable values of type 'float'": | |||
181 | float doubleToFloat(double x) { | |||
182 | return | |||
183 | x < -std::numeric_limits<float>::max() | |||
184 | ? -std::numeric_limits<float>::infinity() | |||
185 | : x > std::numeric_limits<float>::max() | |||
186 | ? std::numeric_limits<float>::infinity() | |||
187 | : static_cast<float>(x); | |||
188 | } | |||
189 | ||||
190 | } | |||
191 | ||||
192 | float SAL_CALL rtl_ustr_toFloat(sal_Unicode const * pStr) SAL_THROW_EXTERN_C()throw () | |||
193 | { | |||
194 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 194, __extension__ __PRETTY_FUNCTION__)); | |||
195 | return doubleToFloat(rtl_math_uStringToDouble(pStr, | |||
196 | pStr + rtl_ustr_getLength(pStr), | |||
197 | '.', 0, nullptr, nullptr)); | |||
198 | } | |||
199 | ||||
200 | double SAL_CALL rtl_ustr_toDouble(sal_Unicode const * pStr) SAL_THROW_EXTERN_C()throw () | |||
201 | { | |||
202 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 202, __extension__ __PRETTY_FUNCTION__)); | |||
203 | return rtl_math_uStringToDouble(pStr, pStr + rtl_ustr_getLength(pStr), '.', | |||
204 | 0, nullptr, nullptr); | |||
205 | } | |||
206 | ||||
207 | /* ======================================================================= */ | |||
208 | ||||
209 | sal_Int32 SAL_CALL rtl_ustr_ascii_compare( const sal_Unicode* pStr1, | |||
210 | const char* pStr2 ) | |||
211 | SAL_THROW_EXTERN_C()throw () | |||
212 | { | |||
213 | assert(pStr1)(static_cast <bool> (pStr1) ? void (0) : __assert_fail ( "pStr1", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 213, __extension__ __PRETTY_FUNCTION__)); | |||
214 | assert(pStr2)(static_cast <bool> (pStr2) ? void (0) : __assert_fail ( "pStr2", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 214, __extension__ __PRETTY_FUNCTION__)); | |||
215 | sal_Int32 nRet; | |||
216 | for (;;) | |||
217 | { | |||
218 | nRet = static_cast<sal_Int32>(*pStr1)- | |||
219 | static_cast<sal_Int32>(static_cast<unsigned char>(*pStr2)); | |||
220 | if (!(nRet == 0 && *pStr2 )) | |||
221 | break; | |||
222 | /* Check ASCII range */ | |||
223 | SAL_WARN_IF( (static_cast<unsigned char>(*pStr2)) > 127, "rtl.string",do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_ascii_compare - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "224" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compare - Found char > 127"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compare - Found char > 127"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string"), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "224" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compare - Found char > 127") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "224" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compare - Found char > 127"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compare - Found char > 127"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string"), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "224" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false) | |||
224 | "rtl_ustr_ascii_compare - Found char > 127" )do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_ascii_compare - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "224" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compare - Found char > 127"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compare - Found char > 127"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string"), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "224" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compare - Found char > 127") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "224" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compare - Found char > 127"), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compare - Found char > 127"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string"), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "224" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false); | |||
225 | pStr1++; | |||
226 | pStr2++; | |||
227 | } | |||
228 | ||||
229 | return nRet; | |||
230 | } | |||
231 | ||||
232 | /* ----------------------------------------------------------------------- */ | |||
233 | ||||
234 | sal_Int32 SAL_CALL rtl_ustr_ascii_compare_WithLength( const sal_Unicode* pStr1, | |||
235 | sal_Int32 nStr1Len, | |||
236 | const char* pStr2 ) | |||
237 | SAL_THROW_EXTERN_C()throw () | |||
238 | { | |||
239 | assert(pStr1)(static_cast <bool> (pStr1) ? void (0) : __assert_fail ( "pStr1", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 239, __extension__ __PRETTY_FUNCTION__)); | |||
240 | assert(nStr1Len >= 0)(static_cast <bool> (nStr1Len >= 0) ? void (0) : __assert_fail ("nStr1Len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 240, __extension__ __PRETTY_FUNCTION__)); | |||
241 | assert(pStr2)(static_cast <bool> (pStr2) ? void (0) : __assert_fail ( "pStr2", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 241, __extension__ __PRETTY_FUNCTION__)); | |||
242 | sal_Int32 nRet = 0; | |||
243 | for (;;) | |||
244 | { | |||
245 | nRet = (nStr1Len ? static_cast<sal_Int32>(*pStr1) : 0) - | |||
246 | static_cast<sal_Int32>(static_cast<unsigned char>(*pStr2)); | |||
247 | if (!(nRet == 0 && nStr1Len && *pStr2 )) | |||
248 | break; | |||
249 | /* Check ASCII range */ | |||
250 | SAL_WARN_IF( (static_cast<unsigned char>(*pStr2)) > 127, "rtl.string",do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_ascii_compare_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "251" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compare_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compare_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "251" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compare_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "251" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compare_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compare_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "251" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false) | |||
251 | "rtl_ustr_ascii_compare_WithLength - Found char > 127" )do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_ascii_compare_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "251" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compare_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compare_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "251" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compare_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "251" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compare_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compare_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "251" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false); | |||
252 | pStr1++; | |||
253 | pStr2++; | |||
254 | nStr1Len--; | |||
255 | } | |||
256 | ||||
257 | return nRet; | |||
258 | } | |||
259 | ||||
260 | /* ----------------------------------------------------------------------- */ | |||
261 | ||||
262 | sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompare_WithLength( const sal_Unicode* pStr1, | |||
263 | sal_Int32 nStr1Len, | |||
264 | const char* pStr2, | |||
265 | sal_Int32 nShortenedLength ) | |||
266 | SAL_THROW_EXTERN_C()throw () | |||
267 | { | |||
268 | assert(nStr1Len >= 0)(static_cast <bool> (nStr1Len >= 0) ? void (0) : __assert_fail ("nStr1Len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 268, __extension__ __PRETTY_FUNCTION__)); | |||
269 | assert(nShortenedLength >= 0)(static_cast <bool> (nShortenedLength >= 0) ? void ( 0) : __assert_fail ("nShortenedLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 269, __extension__ __PRETTY_FUNCTION__)); | |||
270 | const sal_Unicode* pStr1End = pStr1 + nStr1Len; | |||
271 | sal_Int32 nRet; | |||
272 | while ( (nShortenedLength > 0) && | |||
273 | (pStr1 < pStr1End) && *pStr2 ) | |||
274 | { | |||
275 | /* Check ASCII range */ | |||
276 | SAL_WARN_IF( (static_cast<unsigned char>(*pStr2)) > 127, "rtl.string",do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_ascii_shortenedCompare_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "277" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_shortenedCompare_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_shortenedCompare_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "277" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_ascii_shortenedCompare_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "277" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_shortenedCompare_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_shortenedCompare_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "277" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false) | |||
277 | "rtl_ustr_ascii_shortenedCompare_WithLength - Found char > 127" )do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_ascii_shortenedCompare_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "277" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_shortenedCompare_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_shortenedCompare_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "277" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_ascii_shortenedCompare_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "277" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_shortenedCompare_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_shortenedCompare_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "277" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false); | |||
278 | ||||
279 | nRet = static_cast<sal_Int32>(*pStr1)- | |||
280 | static_cast<sal_Int32>(static_cast<unsigned char>(*pStr2)); | |||
281 | if ( nRet != 0 ) | |||
282 | return nRet; | |||
283 | ||||
284 | nShortenedLength--; | |||
285 | pStr1++; | |||
286 | pStr2++; | |||
287 | } | |||
288 | ||||
289 | if ( nShortenedLength <= 0 ) | |||
290 | return 0; | |||
291 | ||||
292 | if ( *pStr2 ) | |||
293 | { | |||
294 | OSL_ENSURE( pStr1 == pStr1End, "pStr1 == pStr1End failed" )do { if (true && (!(pStr1 == pStr1End))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "294" ": "), "%s", "pStr1 == pStr1End failed"); } } while (false); | |||
295 | // first is a substring of the second string => less (negative value) | |||
296 | nRet = -1; | |||
297 | } | |||
298 | else | |||
299 | { | |||
300 | // greater or equal | |||
301 | nRet = pStr1End - pStr1; | |||
302 | } | |||
303 | ||||
304 | return nRet; | |||
305 | } | |||
306 | ||||
307 | /* ----------------------------------------------------------------------- */ | |||
308 | ||||
309 | sal_Int32 SAL_CALL rtl_ustr_asciil_reverseCompare_WithLength( const sal_Unicode* pStr1, | |||
310 | sal_Int32 nStr1Len, | |||
311 | const char* pStr2, | |||
312 | sal_Int32 nStr2Len ) | |||
313 | SAL_THROW_EXTERN_C()throw () | |||
314 | { | |||
315 | assert(nStr1Len >= 0 && nStr2Len >= 0)(static_cast <bool> (nStr1Len >= 0 && nStr2Len >= 0) ? void (0) : __assert_fail ("nStr1Len >= 0 && nStr2Len >= 0" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 315 , __extension__ __PRETTY_FUNCTION__)); | |||
316 | const sal_Unicode* pStr1Run = pStr1+nStr1Len; | |||
317 | const char* pStr2Run = pStr2+nStr2Len; | |||
318 | sal_Int32 nRet; | |||
319 | while ( (pStr1 < pStr1Run) && (pStr2 < pStr2Run) ) | |||
320 | { | |||
321 | /* Check ASCII range */ | |||
322 | SAL_WARN_IF( (static_cast<unsigned char>(*pStr2)) > 127, "rtl.string",do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_asciil_reverseCompare_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "323" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_asciil_reverseCompare_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_asciil_reverseCompare_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "323" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_asciil_reverseCompare_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "323" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_asciil_reverseCompare_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_asciil_reverseCompare_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "323" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false) | |||
323 | "rtl_ustr_asciil_reverseCompare_WithLength - Found char > 127" )do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_asciil_reverseCompare_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "323" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_asciil_reverseCompare_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_asciil_reverseCompare_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "323" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_asciil_reverseCompare_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "323" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_asciil_reverseCompare_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_asciil_reverseCompare_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "323" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false); | |||
324 | pStr1Run--; | |||
325 | pStr2Run--; | |||
326 | nRet = static_cast<sal_Int32>(*pStr1Run)- static_cast<sal_Int32>(*pStr2Run); | |||
327 | if ( nRet ) | |||
328 | return nRet; | |||
329 | } | |||
330 | ||||
331 | return nStr1Len - nStr2Len; | |||
332 | } | |||
333 | ||||
334 | /* ----------------------------------------------------------------------- */ | |||
335 | ||||
336 | sal_Bool SAL_CALL rtl_ustr_asciil_reverseEquals_WithLength( const sal_Unicode* pStr1, | |||
337 | const char* pStr2, | |||
338 | sal_Int32 nStrLen ) | |||
339 | SAL_THROW_EXTERN_C()throw () | |||
340 | { | |||
341 | assert(nStrLen >= 0)(static_cast <bool> (nStrLen >= 0) ? void (0) : __assert_fail ("nStrLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 341, __extension__ __PRETTY_FUNCTION__)); | |||
342 | const sal_Unicode* pStr1Run = pStr1+nStrLen; | |||
343 | const char* pStr2Run = pStr2+nStrLen; | |||
344 | while ( pStr1 < pStr1Run ) | |||
345 | { | |||
346 | /* Check ASCII range */ | |||
347 | SAL_WARN_IF( (static_cast<unsigned char>(*pStr2)) > 127, "rtl.string",do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_asciil_reverseEquals_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "348" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_asciil_reverseEquals_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_asciil_reverseEquals_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "348" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_asciil_reverseEquals_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "348" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_asciil_reverseEquals_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_asciil_reverseEquals_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "348" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false) | |||
348 | "rtl_ustr_asciil_reverseEquals_WithLength - Found char > 127" )do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_asciil_reverseEquals_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "348" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_asciil_reverseEquals_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_asciil_reverseEquals_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "348" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_asciil_reverseEquals_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "348" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_asciil_reverseEquals_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_asciil_reverseEquals_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "348" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false); | |||
349 | pStr1Run--; | |||
350 | pStr2Run--; | |||
351 | if( *pStr1Run != static_cast<sal_Unicode>(*pStr2Run) ) | |||
352 | return false; | |||
353 | } | |||
354 | ||||
355 | return true; | |||
356 | } | |||
357 | ||||
358 | /* ----------------------------------------------------------------------- */ | |||
359 | ||||
360 | sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase( const sal_Unicode* pStr1, | |||
361 | const char* pStr2 ) | |||
362 | SAL_THROW_EXTERN_C()throw () | |||
363 | { | |||
364 | assert(pStr1)(static_cast <bool> (pStr1) ? void (0) : __assert_fail ( "pStr1", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 364, __extension__ __PRETTY_FUNCTION__)); | |||
365 | assert(pStr2)(static_cast <bool> (pStr2) ? void (0) : __assert_fail ( "pStr2", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 365, __extension__ __PRETTY_FUNCTION__)); | |||
366 | sal_Int32 nRet; | |||
367 | sal_Int32 c1; | |||
368 | sal_Int32 c2; | |||
369 | do | |||
370 | { | |||
371 | /* Check ASCII range */ | |||
372 | SAL_WARN_IF( (static_cast<unsigned char>(*pStr2)) > 127, "rtl.string",do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_ascii_compareIgnoreAsciiCase - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "373" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compareIgnoreAsciiCase - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "373" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "373" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compareIgnoreAsciiCase - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "373" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false) | |||
373 | "rtl_ustr_ascii_compareIgnoreAsciiCase - Found char > 127" )do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_ascii_compareIgnoreAsciiCase - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "373" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compareIgnoreAsciiCase - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "373" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "373" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compareIgnoreAsciiCase - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "373" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false); | |||
374 | /* If character between 'A' and 'Z', then convert it to lowercase */ | |||
375 | c1 = static_cast<sal_Int32>(*pStr1); | |||
376 | c2 = static_cast<sal_Int32>(static_cast<unsigned char>(*pStr2)); | |||
377 | if ( (c1 >= 65) && (c1 <= 90) ) | |||
378 | c1 += 32; | |||
379 | if ( (c2 >= 65) && (c2 <= 90) ) | |||
380 | c2 += 32; | |||
381 | nRet = c1-c2; | |||
382 | if ( nRet != 0 ) | |||
383 | return nRet; | |||
384 | ||||
385 | pStr1++; | |||
386 | pStr2++; | |||
387 | } | |||
388 | while ( c2 ); | |||
389 | ||||
390 | return 0; | |||
391 | } | |||
392 | ||||
393 | /* ----------------------------------------------------------------------- */ | |||
394 | ||||
395 | sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( const sal_Unicode* pStr1, | |||
396 | sal_Int32 nStr1Len, | |||
397 | const char* pStr2 ) | |||
398 | SAL_THROW_EXTERN_C()throw () | |||
399 | { | |||
400 | assert(nStr1Len >= 0)(static_cast <bool> (nStr1Len >= 0) ? void (0) : __assert_fail ("nStr1Len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 400, __extension__ __PRETTY_FUNCTION__)); | |||
401 | assert(pStr2)(static_cast <bool> (pStr2) ? void (0) : __assert_fail ( "pStr2", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 401, __extension__ __PRETTY_FUNCTION__)); | |||
402 | sal_Int32 nRet; | |||
403 | sal_Int32 c1; | |||
404 | sal_Int32 c2; | |||
405 | do | |||
406 | { | |||
407 | /* Check ASCII range */ | |||
408 | SAL_WARN_IF( (static_cast<unsigned char>(*pStr2)) > 127, "rtl.string",do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "409" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "409" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "409" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "409" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false) | |||
409 | "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength - Found char > 127" )do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "409" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "409" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "409" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "409" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false); | |||
410 | if ( !nStr1Len ) | |||
411 | return *pStr2 == '\0' ? 0 : -1; | |||
412 | ||||
413 | /* If character between 'A' and 'Z', then convert it to lowercase */ | |||
414 | c1 = static_cast<sal_Int32>(*pStr1); | |||
415 | c2 = static_cast<sal_Int32>(static_cast<unsigned char>(*pStr2)); | |||
416 | if ( (c1 >= 65) && (c1 <= 90) ) | |||
417 | c1 += 32; | |||
418 | if ( (c2 >= 65) && (c2 <= 90) ) | |||
419 | c2 += 32; | |||
420 | nRet = c1-c2; | |||
421 | if ( nRet != 0 ) | |||
422 | return nRet; | |||
423 | ||||
424 | pStr1++; | |||
425 | pStr2++; | |||
426 | nStr1Len--; | |||
427 | } | |||
428 | while( c2 ); | |||
429 | ||||
430 | return 0; | |||
431 | } | |||
432 | ||||
433 | sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths( | |||
434 | sal_Unicode const * first, sal_Int32 firstLen, | |||
435 | char const * second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()throw () | |||
436 | { | |||
437 | assert(firstLen >= 0 && secondLen >= 0)(static_cast <bool> (firstLen >= 0 && secondLen >= 0) ? void (0) : __assert_fail ("firstLen >= 0 && secondLen >= 0" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 437 , __extension__ __PRETTY_FUNCTION__)); | |||
438 | sal_Int32 i; | |||
439 | sal_Int32 len = std::min(firstLen, secondLen); | |||
440 | for (i = 0; i < len; ++i) { | |||
441 | /* Check ASCII range */ | |||
442 | SAL_WARN_IF( (static_cast<unsigned char>(*second)) > 127, "rtl.string",do { if (true && ((static_cast<unsigned char>(* second)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "443" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "443" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "443" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "443" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false) | |||
443 | "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths - Found char > 127" )do { if (true && ((static_cast<unsigned char>(* second)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "443" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "443" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "443" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "443" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false); | |||
444 | sal_Int32 c1 = *first++; | |||
445 | sal_Int32 c2 = static_cast<unsigned char>(*second++); | |||
446 | sal_Int32 d; | |||
447 | if (c1 >= 65 && c1 <= 90) { | |||
448 | c1 += 32; | |||
449 | } | |||
450 | if (c2 >= 65 && c2 <= 90) { | |||
451 | c2 += 32; | |||
452 | } | |||
453 | d = c1 - c2; | |||
454 | if (d != 0) { | |||
455 | return d; | |||
456 | } | |||
457 | } | |||
458 | return firstLen - secondLen; | |||
459 | } | |||
460 | ||||
461 | /* ----------------------------------------------------------------------- */ | |||
462 | ||||
463 | sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( const sal_Unicode* pStr1, | |||
464 | sal_Int32 nStr1Len, | |||
465 | const char* pStr2, | |||
466 | sal_Int32 nShortenedLength ) | |||
467 | SAL_THROW_EXTERN_C()throw () | |||
468 | { | |||
469 | assert(nStr1Len >= 0)(static_cast <bool> (nStr1Len >= 0) ? void (0) : __assert_fail ("nStr1Len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 469, __extension__ __PRETTY_FUNCTION__)); | |||
470 | assert(nShortenedLength >= 0)(static_cast <bool> (nShortenedLength >= 0) ? void ( 0) : __assert_fail ("nShortenedLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 470, __extension__ __PRETTY_FUNCTION__)); | |||
471 | const sal_Unicode* pStr1End = pStr1 + nStr1Len; | |||
472 | sal_Int32 nRet; | |||
473 | sal_Int32 c1; | |||
474 | sal_Int32 c2; | |||
475 | while ( (nShortenedLength > 0) && | |||
476 | (pStr1 < pStr1End) && *pStr2 ) | |||
477 | { | |||
478 | /* Check ASCII range */ | |||
479 | SAL_WARN_IF( (static_cast<unsigned char>(*pStr2)) > 127, "rtl.string",do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "480" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "480" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "480" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "480" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false) | |||
480 | "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" )do { if (true && ((static_cast<unsigned char>(* pStr2)) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "480" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "480" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "480" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "480" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false); | |||
481 | ||||
482 | /* If character between 'A' and 'Z', then convert it to lowercase */ | |||
483 | c1 = static_cast<sal_Int32>(*pStr1); | |||
484 | c2 = static_cast<sal_Int32>(static_cast<unsigned char>(*pStr2)); | |||
485 | if ( (c1 >= 65) && (c1 <= 90) ) | |||
486 | c1 += 32; | |||
487 | if ( (c2 >= 65) && (c2 <= 90) ) | |||
488 | c2 += 32; | |||
489 | nRet = c1-c2; | |||
490 | if ( nRet != 0 ) | |||
491 | return nRet; | |||
492 | ||||
493 | nShortenedLength--; | |||
494 | pStr1++; | |||
495 | pStr2++; | |||
496 | } | |||
497 | ||||
498 | if ( nShortenedLength <= 0 ) | |||
499 | return 0; | |||
500 | ||||
501 | if ( *pStr2 ) | |||
502 | { | |||
503 | OSL_ENSURE( pStr1 == pStr1End, "pStr1 == pStr1End failed" )do { if (true && (!(pStr1 == pStr1End))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "503" ": "), "%s", "pStr1 == pStr1End failed"); } } while (false); | |||
504 | // first is a substring of the second string => less (negative value) | |||
505 | nRet = -1; | |||
506 | } | |||
507 | else | |||
508 | { | |||
509 | // greater or equal | |||
510 | nRet = pStr1End - pStr1; | |||
511 | } | |||
512 | ||||
513 | return nRet; | |||
514 | } | |||
515 | ||||
516 | /* ----------------------------------------------------------------------- */ | |||
517 | ||||
518 | void SAL_CALL rtl_uString_newFromAscii( rtl_uString** ppThis, | |||
519 | const char* pCharStr ) | |||
520 | SAL_THROW_EXTERN_C()throw () | |||
521 | { | |||
522 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 522, __extension__ __PRETTY_FUNCTION__)); | |||
523 | sal_Int32 nLen; | |||
524 | ||||
525 | if ( pCharStr ) | |||
526 | { | |||
527 | const char* pTempStr = pCharStr; | |||
528 | while( *pTempStr ) | |||
529 | pTempStr++; | |||
530 | nLen = pTempStr-pCharStr; | |||
531 | } | |||
532 | else | |||
533 | nLen = 0; | |||
534 | ||||
535 | if ( !nLen ) | |||
536 | { | |||
537 | rtl_uString_new( ppThis ); | |||
538 | return; | |||
539 | } | |||
540 | ||||
541 | if ( *ppThis ) | |||
542 | rtl_uString_release( *ppThis ); | |||
543 | ||||
544 | *ppThis = rtl_uString_ImplAlloc( nLen ); | |||
545 | OSL_ASSERT(*ppThis != nullptr)do { if (true && (!(*ppThis != nullptr))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "545" ": "), "OSL_ASSERT: %s", "*ppThis != nullptr"); } } while (false); | |||
546 | if ( !(*ppThis) ) | |||
547 | return; | |||
548 | ||||
549 | sal_Unicode* pBuffer = (*ppThis)->buffer; | |||
550 | do | |||
551 | { | |||
552 | assert(static_cast<unsigned char>(*pCharStr) < 0x80)(static_cast <bool> (static_cast<unsigned char>(* pCharStr) < 0x80) ? void (0) : __assert_fail ("static_cast<unsigned char>(*pCharStr) < 0x80" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 552 , __extension__ __PRETTY_FUNCTION__)); // ASCII range | |||
553 | *pBuffer = *pCharStr; | |||
554 | pBuffer++; | |||
555 | pCharStr++; | |||
556 | } | |||
557 | while ( *pCharStr ); | |||
558 | ||||
559 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
560 | } | |||
561 | ||||
562 | void SAL_CALL rtl_uString_newFromCodePoints( | |||
563 | rtl_uString ** newString, sal_uInt32 const * codePoints, | |||
564 | sal_Int32 codePointCount) SAL_THROW_EXTERN_C()throw () | |||
565 | { | |||
566 | sal_Int32 n; | |||
567 | sal_Int32 i; | |||
568 | sal_Unicode * p; | |||
569 | assert(newString != nullptr)(static_cast <bool> (newString != nullptr) ? void (0) : __assert_fail ("newString != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 569, __extension__ __PRETTY_FUNCTION__)); | |||
570 | assert((codePoints != nullptr || codePointCount == 0) && codePointCount >= 0)(static_cast <bool> ((codePoints != nullptr || codePointCount == 0) && codePointCount >= 0) ? void (0) : __assert_fail ("(codePoints != nullptr || codePointCount == 0) && codePointCount >= 0" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 570 , __extension__ __PRETTY_FUNCTION__)); | |||
571 | if (codePointCount == 0) { | |||
572 | rtl_uString_new(newString); | |||
573 | return; | |||
574 | } | |||
575 | if (*newString != nullptr) { | |||
576 | rtl_uString_release(*newString); | |||
577 | } | |||
578 | n = codePointCount; | |||
579 | for (i = 0; i < codePointCount; ++i) { | |||
580 | OSL_ASSERT(rtl::isUnicodeCodePoint(codePoints[i]))do { if (true && (!(rtl::isUnicodeCodePoint(codePoints [i])))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ( "legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "580" ": "), "OSL_ASSERT: %s", "rtl::isUnicodeCodePoint(codePoints[i])" ); } } while (false); | |||
581 | if (codePoints[i] >= 0x10000) { | |||
582 | ++n; | |||
583 | } | |||
584 | } | |||
585 | /* Builds on the assumption that sal_Int32 uses 32 bit two's complement | |||
586 | representation with wrap around (the necessary number of UTF-16 code | |||
587 | units will be no larger than 2 * SAL_MAX_INT32, represented as | |||
588 | sal_Int32 -2): */ | |||
589 | if (n < 0) { | |||
590 | // coverity[dead_error_begin] - assumes wrap around | |||
591 | *newString = nullptr; | |||
592 | return; | |||
593 | } | |||
594 | *newString = rtl_uString_ImplAlloc(n); | |||
595 | if (*newString == nullptr) { | |||
596 | return; | |||
597 | } | |||
598 | p = (*newString)->buffer; | |||
599 | for (i = 0; i < codePointCount; ++i) { | |||
600 | p += rtl::splitSurrogates(codePoints[i], p); | |||
601 | } | |||
602 | RTL_LOG_STRING_NEW( *newString )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*newString) == 14 || __builtin_classify_type (*newString) == 5) && __sdt_type<__typeof (*newString )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (*newString) == 14 || __builtin_classify_type (*newString) == 5) ? sizeof (void *) : sizeof (*newString))), [_SDT_A1] "nor" ((*newString)), [_SDT_S2] "n" (((!(__builtin_classify_type ( (*newString)->refCount) == 14 || __builtin_classify_type ( (*newString)->refCount) == 5) && __sdt_type<__typeof ((*newString)->refCount)>::__sdt_signed) ? 1 : -1) * ( int) ((__builtin_classify_type ((*newString)->refCount) == 14 || __builtin_classify_type ((*newString)->refCount) == 5) ? sizeof (void *) : sizeof ((*newString)->refCount))), [_SDT_A2] "nor" (((*newString)->refCount)), [_SDT_S3] "n" (((!(__builtin_classify_type ((*newString)->length) == 14 || __builtin_classify_type ((*newString)->length) == 5) && __sdt_type<__typeof ((*newString)->length)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*newString)-> length) == 14 || __builtin_classify_type ((*newString)->length ) == 5) ? sizeof (void *) : sizeof ((*newString)->length)) ), [_SDT_A3] "nor" (((*newString)->length)), [_SDT_S4] "n" (((!(__builtin_classify_type ((*newString)->buffer) == 14 || __builtin_classify_type ((*newString)->buffer) == 5) && __sdt_type<__typeof ((*newString)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*newString)-> buffer) == 14 || __builtin_classify_type ((*newString)->buffer ) == 5) ? sizeof (void *) : sizeof ((*newString)->buffer)) ), [_SDT_A4] "nor" (((*newString)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
603 | } | |||
604 | ||||
605 | void rtl_uString_newConcatAsciiL( | |||
606 | rtl_uString ** newString, rtl_uString * left, char const * right, | |||
607 | sal_Int32 rightLength) | |||
608 | { | |||
609 | assert(newString != nullptr)(static_cast <bool> (newString != nullptr) ? void (0) : __assert_fail ("newString != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 609, __extension__ __PRETTY_FUNCTION__)); | |||
| ||||
610 | assert(left != nullptr)(static_cast <bool> (left != nullptr) ? void (0) : __assert_fail ("left != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 610, __extension__ __PRETTY_FUNCTION__)); | |||
611 | assert(right != nullptr)(static_cast <bool> (right != nullptr) ? void (0) : __assert_fail ("right != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 611, __extension__ __PRETTY_FUNCTION__)); | |||
612 | assert(rightLength >= 0)(static_cast <bool> (rightLength >= 0) ? void (0) : __assert_fail ("rightLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 612, __extension__ __PRETTY_FUNCTION__)); | |||
613 | if (left->length > std::numeric_limits<sal_Int32>::max() - rightLength) { | |||
614 | #if !defined(__COVERITY__) | |||
615 | throw std::length_error("rtl_uString_newConcatAsciiL"); | |||
616 | #else | |||
617 | //coverity doesn't report std::bad_alloc as an unhandled exception when | |||
618 | //potentially thrown from destructors but does report std::length_error | |||
619 | throw std::bad_alloc(); | |||
620 | #endif | |||
621 | } | |||
622 | sal_Int32 n = left->length + rightLength; | |||
623 | rtl_uString_assign(newString, left); | |||
624 | rtl_uString_ensureCapacity(newString, n); | |||
625 | sal_Unicode * p = (*newString)->buffer + (*newString)->length; | |||
626 | for (sal_Int32 i = 0; i != rightLength; ++i) { | |||
627 | p[i] = static_cast<unsigned char>(right[i]); | |||
628 | } | |||
629 | (*newString)->buffer[n] = 0; | |||
630 | (*newString)->length = n; | |||
631 | } | |||
632 | ||||
633 | void rtl_uString_newConcatUtf16L( | |||
634 | rtl_uString ** newString, rtl_uString * left, sal_Unicode const * right, | |||
635 | sal_Int32 rightLength) | |||
636 | { | |||
637 | assert(newString != nullptr)(static_cast <bool> (newString != nullptr) ? void (0) : __assert_fail ("newString != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 637, __extension__ __PRETTY_FUNCTION__)); | |||
638 | assert(left != nullptr)(static_cast <bool> (left != nullptr) ? void (0) : __assert_fail ("left != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 638, __extension__ __PRETTY_FUNCTION__)); | |||
639 | assert(right != nullptr)(static_cast <bool> (right != nullptr) ? void (0) : __assert_fail ("right != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 639, __extension__ __PRETTY_FUNCTION__)); | |||
640 | assert(rightLength >= 0)(static_cast <bool> (rightLength >= 0) ? void (0) : __assert_fail ("rightLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 640, __extension__ __PRETTY_FUNCTION__)); | |||
641 | if (left->length > std::numeric_limits<sal_Int32>::max() - rightLength) { | |||
642 | #if !defined(__COVERITY__) | |||
643 | throw std::length_error("rtl_uString_newConcatUtf16L"); | |||
644 | #else | |||
645 | //coverity doesn't report std::bad_alloc as an unhandled exception when | |||
646 | //potentially thrown from destructors but does report std::length_error | |||
647 | throw std::bad_alloc(); | |||
648 | #endif | |||
649 | } | |||
650 | sal_Int32 n = left->length + rightLength; | |||
651 | rtl_uString_assign(newString, left); | |||
652 | rtl_uString_ensureCapacity(newString, n); | |||
653 | memcpy( | |||
654 | (*newString)->buffer + (*newString)->length, right, | |||
655 | rightLength * sizeof (sal_Unicode)); | |||
656 | (*newString)->buffer[n] = 0; | |||
657 | (*newString)->length = n; | |||
658 | } | |||
659 | ||||
660 | /* ======================================================================= */ | |||
661 | ||||
662 | static int rtl_ImplGetFastUTF8UnicodeLen( const char* pStr, sal_Int32 nLen, bool * ascii ) | |||
663 | { | |||
664 | int n; | |||
665 | const char* pEndStr; | |||
666 | ||||
667 | *ascii = true; | |||
668 | n = 0; | |||
669 | pEndStr = pStr+nLen; | |||
670 | while ( pStr < pEndStr ) | |||
671 | { | |||
672 | unsigned char c = static_cast<unsigned char>(*pStr); | |||
673 | ||||
674 | if ( !(c & 0x80) ) | |||
675 | pStr++; | |||
676 | else | |||
677 | { | |||
678 | if ( (c & 0xE0) == 0xC0 ) | |||
679 | pStr += 2; | |||
680 | else if ( (c & 0xF0) == 0xE0 ) | |||
681 | pStr += 3; | |||
682 | else if ( (c & 0xF8) == 0xF0 ) | |||
683 | pStr += 4; | |||
684 | else if ( (c & 0xFC) == 0xF8 ) | |||
685 | pStr += 5; | |||
686 | else if ( (c & 0xFE) == 0xFC ) | |||
687 | pStr += 6; | |||
688 | else | |||
689 | pStr++; | |||
690 | *ascii = false; | |||
691 | } | |||
692 | ||||
693 | n++; | |||
694 | } | |||
695 | ||||
696 | return n; | |||
697 | } | |||
698 | ||||
699 | /* ----------------------------------------------------------------------- */ | |||
700 | ||||
701 | static void rtl_string2UString_status( rtl_uString** ppThis, | |||
702 | const char* pStr, | |||
703 | sal_Int32 nLen, | |||
704 | rtl_TextEncoding eTextEncoding, | |||
705 | sal_uInt32 nCvtFlags, | |||
706 | sal_uInt32 *pInfo ) | |||
707 | { | |||
708 | OSL_ENSURE(nLen == 0 || rtl_isOctetTextEncoding(eTextEncoding),do { if (true && (!(nLen == 0 || rtl_isOctetTextEncoding (eTextEncoding)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "709" ": "), "%s", "rtl_string2UString_status() - Wrong TextEncoding" ); } } while (false) | |||
709 | "rtl_string2UString_status() - Wrong TextEncoding" )do { if (true && (!(nLen == 0 || rtl_isOctetTextEncoding (eTextEncoding)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "709" ": "), "%s", "rtl_string2UString_status() - Wrong TextEncoding" ); } } while (false); | |||
710 | ||||
711 | if ( !nLen ) | |||
712 | { | |||
713 | rtl_uString_new( ppThis ); | |||
714 | if (pInfo != nullptr) { | |||
715 | *pInfo = 0; | |||
716 | } | |||
717 | } | |||
718 | else | |||
719 | { | |||
720 | if ( *ppThis ) | |||
721 | rtl_uString_release( *ppThis ); | |||
722 | ||||
723 | /* Optimization for US-ASCII */ | |||
724 | if ( eTextEncoding == RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) ) | |||
725 | { | |||
726 | sal_Unicode* pBuffer; | |||
727 | *ppThis = rtl_uString_ImplAlloc( nLen ); | |||
728 | if (*ppThis == nullptr) { | |||
729 | if (pInfo != nullptr) { | |||
730 | *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR((sal_uInt32)0x0001) | | |||
731 | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOOSMALL((sal_uInt32)0x0004); | |||
732 | } | |||
733 | return; | |||
734 | } | |||
735 | pBuffer = (*ppThis)->buffer; | |||
736 | sal_Int32 nLenCopy(nLen); | |||
737 | const char *pStrCopy(pStr); | |||
738 | do | |||
739 | { | |||
740 | /* Check ASCII range */ | |||
741 | if (static_cast<unsigned char>(*pStrCopy) > 127) | |||
742 | { | |||
743 | rtl_uString_release(*ppThis); | |||
744 | goto retry; // cancel loop - try again with the converter | |||
745 | } | |||
746 | ||||
747 | *pBuffer = *pStrCopy; | |||
748 | pBuffer++; | |||
749 | pStrCopy++; | |||
750 | nLenCopy--; | |||
751 | } | |||
752 | while (nLenCopy); | |||
753 | if (pInfo != nullptr) { | |||
754 | *pInfo = 0; | |||
755 | } | |||
756 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
757 | return; | |||
758 | } | |||
759 | retry: | |||
760 | { | |||
761 | rtl_uString* pTemp; | |||
762 | rtl_uString* pTemp2 = nullptr; | |||
763 | rtl_TextToUnicodeConverter hConverter; | |||
764 | sal_uInt32 nInfo; | |||
765 | sal_Size nSrcBytes; | |||
766 | sal_Size nDestChars; | |||
767 | sal_Size nNewLen; | |||
768 | ||||
769 | /* Optimization for UTF-8 - we try to calculate the exact length */ | |||
770 | /* For all other encoding we try the maximum - and reallocate | |||
771 | the buffer if needed */ | |||
772 | if ( eTextEncoding == RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ) | |||
773 | { | |||
774 | bool ascii; | |||
775 | nNewLen = rtl_ImplGetFastUTF8UnicodeLen( pStr, nLen, &ascii ); | |||
776 | /* Includes the string only ASCII, then we could copy | |||
777 | the buffer faster */ | |||
778 | if ( ascii ) | |||
779 | { | |||
780 | sal_Unicode* pBuffer; | |||
781 | *ppThis = rtl_uString_ImplAlloc( nLen ); | |||
782 | if (*ppThis == nullptr) | |||
783 | { | |||
784 | if (pInfo != nullptr) { | |||
785 | *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR((sal_uInt32)0x0001) | | |||
786 | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOOSMALL((sal_uInt32)0x0004); | |||
787 | } | |||
788 | return; | |||
789 | } | |||
790 | pBuffer = (*ppThis)->buffer; | |||
791 | do | |||
792 | { | |||
793 | assert((static_cast<unsigned char>(*pStr)) <= 127)(static_cast <bool> ((static_cast<unsigned char>( *pStr)) <= 127) ? void (0) : __assert_fail ("(static_cast<unsigned char>(*pStr)) <= 127" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 793 , __extension__ __PRETTY_FUNCTION__)); | |||
794 | *pBuffer = *pStr; | |||
795 | pBuffer++; | |||
796 | pStr++; | |||
797 | nLen--; | |||
798 | } | |||
799 | while ( nLen ); | |||
800 | if (pInfo != nullptr) { | |||
801 | *pInfo = 0; | |||
802 | } | |||
803 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
804 | return; | |||
805 | } | |||
806 | } | |||
807 | else | |||
808 | nNewLen = nLen; | |||
809 | ||||
810 | nCvtFlags |= RTL_TEXTTOUNICODE_FLAGS_FLUSH((sal_uInt32)0x8000); | |||
811 | hConverter = rtl_createTextToUnicodeConverter( eTextEncoding ); | |||
812 | ||||
813 | pTemp = rtl_uString_ImplAlloc( nNewLen ); | |||
814 | if (pTemp == nullptr) { | |||
815 | if (pInfo != nullptr) { | |||
816 | *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR((sal_uInt32)0x0001) | | |||
817 | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOOSMALL((sal_uInt32)0x0004); | |||
818 | } | |||
819 | return; | |||
820 | } | |||
821 | nDestChars = rtl_convertTextToUnicode( hConverter, nullptr, | |||
822 | pStr, nLen, | |||
823 | pTemp->buffer, nNewLen, | |||
824 | nCvtFlags, | |||
825 | &nInfo, &nSrcBytes ); | |||
826 | ||||
827 | /* Buffer not big enough, try again with enough space */ | |||
828 | /* Shouldn't be the case, but if we get textencoding which | |||
829 | could results in more unicode characters we have this | |||
830 | code here. Could be the case for apple encodings */ | |||
831 | while ( nInfo & RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOOSMALL((sal_uInt32)0x0004) ) | |||
832 | { | |||
833 | rtl_freeString( pTemp ); | |||
834 | nNewLen += 8; | |||
835 | pTemp = rtl_uString_ImplAlloc( nNewLen ); | |||
836 | if (pTemp == nullptr) { | |||
837 | if (pInfo != nullptr) { | |||
838 | *pInfo = RTL_TEXTTOUNICODE_INFO_ERROR((sal_uInt32)0x0001) | | |||
839 | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOOSMALL((sal_uInt32)0x0004); | |||
840 | } | |||
841 | return; | |||
842 | } | |||
843 | nDestChars = rtl_convertTextToUnicode( hConverter, nullptr, | |||
844 | pStr, nLen, | |||
845 | pTemp->buffer, nNewLen, | |||
846 | nCvtFlags, | |||
847 | &nInfo, &nSrcBytes ); | |||
848 | } | |||
849 | ||||
850 | if (pInfo) | |||
851 | *pInfo = nInfo; | |||
852 | ||||
853 | /* Set the buffer to the correct size or if there is too | |||
854 | much overhead, reallocate to the correct size */ | |||
855 | if ( nNewLen > nDestChars+8 ) | |||
856 | { | |||
857 | pTemp2 = rtl_uString_ImplAlloc( nDestChars ); | |||
858 | } | |||
859 | if (pTemp2 != nullptr) | |||
860 | { | |||
861 | rtl_str_ImplCopy(pTemp2->buffer, pTemp->buffer, nDestChars); | |||
862 | rtl_freeString(pTemp); | |||
863 | pTemp = pTemp2; | |||
864 | } | |||
865 | else | |||
866 | { | |||
867 | pTemp->length = nDestChars; | |||
868 | pTemp->buffer[nDestChars] = 0; | |||
869 | } | |||
870 | ||||
871 | rtl_destroyTextToUnicodeConverter( hConverter ); | |||
872 | *ppThis = pTemp; | |||
873 | ||||
874 | /* Results the conversion in an empty buffer - | |||
875 | create an empty string */ | |||
876 | if ( pTemp && !nDestChars ) | |||
877 | rtl_uString_new( ppThis ); | |||
878 | } | |||
879 | } | |||
880 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
881 | } | |||
882 | ||||
883 | void SAL_CALL rtl_string2UString( rtl_uString** ppThis, | |||
884 | const char* pStr, | |||
885 | sal_Int32 nLen, | |||
886 | rtl_TextEncoding eTextEncoding, | |||
887 | sal_uInt32 nCvtFlags ) SAL_THROW_EXTERN_C()throw () | |||
888 | { | |||
889 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 889, __extension__ __PRETTY_FUNCTION__)); | |||
890 | assert(nLen >= 0)(static_cast <bool> (nLen >= 0) ? void (0) : __assert_fail ("nLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 890, __extension__ __PRETTY_FUNCTION__)); | |||
891 | rtl_string2UString_status( ppThis, pStr, nLen, eTextEncoding, | |||
892 | nCvtFlags, nullptr ); | |||
893 | } | |||
894 | ||||
895 | /* ----------------------------------------------------------------------- */ | |||
896 | ||||
897 | namespace { | |||
898 | ||||
899 | enum StrLifecycle { | |||
900 | CANNOT_RETURN, | |||
901 | CAN_RETURN = 1 | |||
902 | }; | |||
903 | ||||
904 | } | |||
905 | ||||
906 | static oslMutex | |||
907 | getInternMutex() | |||
908 | { | |||
909 | static oslMutex pPoolGuard = osl_createMutex(); | |||
910 | ||||
911 | return pPoolGuard; | |||
912 | } | |||
913 | ||||
914 | /* returns true if we found a dup in the pool */ | |||
915 | static void rtl_ustring_intern_internal( rtl_uString ** newStr, | |||
916 | rtl_uString * str, | |||
917 | StrLifecycle can_return ) | |||
918 | { | |||
919 | oslMutex pPoolMutex; | |||
920 | ||||
921 | pPoolMutex = getInternMutex(); | |||
922 | ||||
923 | osl_acquireMutex( pPoolMutex ); | |||
924 | ||||
925 | *newStr = rtl_str_hash_intern (str, can_return); | |||
926 | ||||
927 | osl_releaseMutex( pPoolMutex ); | |||
928 | ||||
929 | RTL_LOG_STRING_INTERN_NEW(*newStr, str)do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_intern_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4] %n[_SDT_S5]@%[_SDT_A5]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*newStr) == 14 || __builtin_classify_type (*newStr) == 5) && __sdt_type<__typeof (*newStr)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *newStr) == 14 || __builtin_classify_type (*newStr) == 5) ? sizeof (void *) : sizeof (*newStr))), [_SDT_A1] "nor" ((*newStr)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*newStr)->refCount ) == 14 || __builtin_classify_type ((*newStr)->refCount) == 5) && __sdt_type<__typeof ((*newStr)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*newStr)->refCount) == 14 || __builtin_classify_type (( *newStr)->refCount) == 5) ? sizeof (void *) : sizeof ((*newStr )->refCount))), [_SDT_A2] "nor" (((*newStr)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*newStr)->length ) == 14 || __builtin_classify_type ((*newStr)->length) == 5 ) && __sdt_type<__typeof ((*newStr)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*newStr)->length) == 14 || __builtin_classify_type ((*newStr )->length) == 5) ? sizeof (void *) : sizeof ((*newStr)-> length))), [_SDT_A3] "nor" (((*newStr)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*newStr)->buffer) == 14 || __builtin_classify_type ((*newStr)->buffer) == 5) && __sdt_type<__typeof ((*newStr)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*newStr)-> buffer) == 14 || __builtin_classify_type ((*newStr)->buffer ) == 5) ? sizeof (void *) : sizeof ((*newStr)->buffer))), [ _SDT_A4] "nor" (((*newStr)->buffer)), [_SDT_S5] "n" (((!(__builtin_classify_type (str) == 14 || __builtin_classify_type (str) == 5) && __sdt_type<__typeof (str)>::__sdt_signed) ? 1 : -1) * ( int) ((__builtin_classify_type (str) == 14 || __builtin_classify_type (str) == 5) ? sizeof (void *) : sizeof (str))), [_SDT_A5] "nor" ((str))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
930 | ||||
931 | if( can_return && *newStr != str ) | |||
932 | { /* we dupped, then found a match */ | |||
933 | rtl_freeString( str ); | |||
934 | } | |||
935 | } | |||
936 | ||||
937 | void SAL_CALL rtl_uString_intern( rtl_uString ** newStr, | |||
938 | rtl_uString * str) SAL_THROW_EXTERN_C()throw () | |||
939 | { | |||
940 | assert(newStr)(static_cast <bool> (newStr) ? void (0) : __assert_fail ("newStr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 940, __extension__ __PRETTY_FUNCTION__)); | |||
941 | assert(str)(static_cast <bool> (str) ? void (0) : __assert_fail ("str" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 941 , __extension__ __PRETTY_FUNCTION__)); | |||
942 | if (SAL_STRING_IS_INTERN(str)((str)->refCount & 0x80000000)) | |||
943 | { | |||
944 | IMPL_RTL_ACQUIRE( str ); | |||
945 | *newStr = str; | |||
946 | } | |||
947 | else | |||
948 | { | |||
949 | rtl_uString *pOrg = *newStr; | |||
950 | *newStr = nullptr; | |||
951 | rtl_ustring_intern_internal( newStr, str, CANNOT_RETURN ); | |||
952 | if (pOrg) | |||
953 | rtl_uString_release (pOrg); | |||
954 | } | |||
955 | } | |||
956 | ||||
957 | static int rtl_canGuessUOutputLength( int len, rtl_TextEncoding eTextEncoding ) | |||
958 | { | |||
959 | // FIXME: Maybe we should use a bit flag in the higher bits of the | |||
960 | // eTextEncoding value itself to determine the encoding type. But if we | |||
961 | // do, be sure to mask the value in certain places that expect the values | |||
962 | // to be numbered serially from 0 and up. One such place is | |||
963 | // Impl_getTextEncodingData(). | |||
964 | ||||
965 | switch ( eTextEncoding ) | |||
966 | { | |||
967 | // 1 to 1 (with no zero elements) | |||
968 | case RTL_TEXTENCODING_IBM_437(((rtl_TextEncoding) 3)): | |||
969 | case RTL_TEXTENCODING_IBM_850(((rtl_TextEncoding) 4)): | |||
970 | case RTL_TEXTENCODING_IBM_860(((rtl_TextEncoding) 5)): | |||
971 | case RTL_TEXTENCODING_IBM_861(((rtl_TextEncoding) 6)): | |||
972 | case RTL_TEXTENCODING_IBM_863(((rtl_TextEncoding) 7)): | |||
973 | case RTL_TEXTENCODING_IBM_865(((rtl_TextEncoding) 8)): | |||
974 | return len; | |||
975 | break; | |||
976 | } | |||
977 | return 0; | |||
978 | } | |||
979 | ||||
980 | void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr, | |||
981 | const char * str, | |||
982 | sal_Int32 len, | |||
983 | rtl_TextEncoding eTextEncoding, | |||
984 | sal_uInt32 convertFlags, | |||
985 | sal_uInt32 * pInfo ) | |||
986 | SAL_THROW_EXTERN_C()throw () | |||
987 | { | |||
988 | assert(newStr)(static_cast <bool> (newStr) ? void (0) : __assert_fail ("newStr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 988, __extension__ __PRETTY_FUNCTION__)); | |||
989 | assert(len >= 0)(static_cast <bool> (len >= 0) ? void (0) : __assert_fail ("len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 989, __extension__ __PRETTY_FUNCTION__)); | |||
990 | rtl_uString *scratch; | |||
991 | ||||
992 | if (*newStr) | |||
993 | { | |||
994 | rtl_uString_release (*newStr); | |||
995 | *newStr = nullptr; | |||
996 | } | |||
997 | ||||
998 | if ( len < 256 ) | |||
999 | { // try various optimisations | |||
1000 | sal_Int32 ulen; | |||
1001 | if ( eTextEncoding == RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) ) | |||
1002 | { | |||
1003 | int i; | |||
1004 | rtl_uString *pScratch; | |||
1005 | pScratch = static_cast< rtl_uString * >( | |||
1006 | alloca(sizeof (rtl_uString) + len * sizeof (sal_Unicode))__builtin_alloca (sizeof (rtl_uString) + len * sizeof (sal_Unicode ))); | |||
1007 | for (i = 0; i < len; i++) | |||
1008 | { | |||
1009 | /* Check ASCII range */ | |||
1010 | SAL_WARN_IF( (static_cast<unsigned char>(str[i])) > 127, "rtl.string",do { if (true && ((static_cast<unsigned char>(str [i])) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "1011" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "1011" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "1011" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "1011" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false) | |||
1011 | "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" )do { if (true && ((static_cast<unsigned char>(str [i])) > 127)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "1011" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "1011" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "1011" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" ":" "1011" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false); | |||
1012 | pScratch->buffer[i] = str[i]; | |||
1013 | } | |||
1014 | pScratch->length = len; | |||
1015 | rtl_ustring_intern_internal( newStr, pScratch, CANNOT_RETURN ); | |||
1016 | return; | |||
1017 | } | |||
1018 | if ( (ulen = rtl_canGuessUOutputLength(len, eTextEncoding)) != 0 ) | |||
1019 | { | |||
1020 | rtl_uString *pScratch; | |||
1021 | rtl_TextToUnicodeConverter hConverter; | |||
1022 | sal_Size nSrcBytes; | |||
1023 | sal_uInt32 nInfo; | |||
1024 | ||||
1025 | pScratch = static_cast< rtl_uString * >( | |||
1026 | alloca(__builtin_alloca (sizeof (rtl_uString) + ulen * sizeof (sal_Unicode )) | |||
1027 | sizeof (rtl_uString) + ulen * sizeof (sal_Unicode))__builtin_alloca (sizeof (rtl_uString) + ulen * sizeof (sal_Unicode ))); | |||
1028 | ||||
1029 | hConverter = rtl_createTextToUnicodeConverter( eTextEncoding ); | |||
1030 | rtl_convertTextToUnicode( | |||
1031 | hConverter, nullptr, str, len, pScratch->buffer, ulen, convertFlags, &nInfo, &nSrcBytes ); | |||
1032 | rtl_destroyTextToUnicodeConverter( hConverter ); | |||
1033 | ||||
1034 | if (pInfo) | |||
1035 | *pInfo = nInfo; | |||
1036 | ||||
1037 | pScratch->length = ulen; | |||
1038 | rtl_ustring_intern_internal( newStr, pScratch, CANNOT_RETURN ); | |||
1039 | return; | |||
1040 | } | |||
1041 | ||||
1042 | /* FIXME: we want a nice UTF-8 / alloca shortcut here */ | |||
1043 | } | |||
1044 | ||||
1045 | scratch = nullptr; | |||
1046 | rtl_string2UString_status( &scratch, str, len, eTextEncoding, convertFlags, | |||
1047 | pInfo ); | |||
1048 | if (!scratch) { | |||
1049 | return; | |||
1050 | } | |||
1051 | rtl_ustring_intern_internal( newStr, scratch, CAN_RETURN ); | |||
1052 | } | |||
1053 | ||||
1054 | static void | |||
1055 | internRelease (rtl_uString *pThis) | |||
1056 | { | |||
1057 | rtl_uString *pFree = nullptr; | |||
1058 | if ( SAL_STRING_REFCOUNT(((__sync_sub_and_fetch((&(pThis->refCount)), 1)) & 0x3fffffff) | |||
1059 | osl_atomic_decrement( &(pThis->refCount) ) )((__sync_sub_and_fetch((&(pThis->refCount)), 1)) & 0x3fffffff) == 0) | |||
1060 | { | |||
1061 | RTL_LOG_STRING_INTERN_DELETE(pThis)do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"delete_string_intern_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (pThis) == 14 || __builtin_classify_type (pThis) == 5) && __sdt_type<__typeof (pThis)>:: __sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (pThis ) == 14 || __builtin_classify_type (pThis) == 5) ? sizeof (void *) : sizeof (pThis))), [_SDT_A1] "nor" ((pThis)), [_SDT_S2] "n" (((!(__builtin_classify_type ((pThis)->refCount) == 14 || __builtin_classify_type ((pThis)->refCount) == 5) && __sdt_type<__typeof ((pThis)->refCount)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((pThis)->refCount ) == 14 || __builtin_classify_type ((pThis)->refCount) == 5 ) ? sizeof (void *) : sizeof ((pThis)->refCount))), [_SDT_A2 ] "nor" (((pThis)->refCount)), [_SDT_S3] "n" (((!(__builtin_classify_type ((pThis)->length) == 14 || __builtin_classify_type ((pThis )->length) == 5) && __sdt_type<__typeof ((pThis )->length)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((pThis)->length) == 14 || __builtin_classify_type ((pThis )->length) == 5) ? sizeof (void *) : sizeof ((pThis)->length ))), [_SDT_A3] "nor" (((pThis)->length)), [_SDT_S4] "n" (( (!(__builtin_classify_type ((pThis)->buffer) == 14 || __builtin_classify_type ((pThis)->buffer) == 5) && __sdt_type<__typeof ((pThis)->buffer)>::__sdt_signed) ? 1 : -1) * (int) (( __builtin_classify_type ((pThis)->buffer) == 14 || __builtin_classify_type ((pThis)->buffer) == 5) ? sizeof (void *) : sizeof ((pThis )->buffer))), [_SDT_A4] "nor" (((pThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
1062 | oslMutex pPoolMutex = getInternMutex(); | |||
1063 | osl_acquireMutex( pPoolMutex ); | |||
1064 | ||||
1065 | rtl_str_hash_remove (pThis); | |||
1066 | ||||
1067 | /* May have been separately acquired */ | |||
1068 | if ( SAL_STRING_REFCOUNT(((__sync_add_and_fetch((&(pThis->refCount)), 1)) & 0x3fffffff) | |||
1069 | osl_atomic_increment( &(pThis->refCount) ) )((__sync_add_and_fetch((&(pThis->refCount)), 1)) & 0x3fffffff) == 1 ) | |||
1070 | { | |||
1071 | /* we got the last ref */ | |||
1072 | pFree = pThis; | |||
1073 | } | |||
1074 | else /* very unusual */ | |||
1075 | { | |||
1076 | internRelease (pThis); | |||
1077 | } | |||
1078 | ||||
1079 | osl_releaseMutex( pPoolMutex ); | |||
1080 | } | |||
1081 | if (pFree) | |||
1082 | rtl_freeString (pFree); | |||
1083 | } | |||
1084 | ||||
1085 | sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints( | |||
1086 | rtl_uString const * string, sal_Int32 * indexUtf16, | |||
1087 | sal_Int32 incrementCodePoints) | |||
1088 | { | |||
1089 | sal_Int32 n; | |||
1090 | sal_Unicode cu; | |||
1091 | sal_uInt32 cp; | |||
1092 | assert(string != nullptr && indexUtf16 != nullptr)(static_cast <bool> (string != nullptr && indexUtf16 != nullptr) ? void (0) : __assert_fail ("string != nullptr && indexUtf16 != nullptr" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1092 , __extension__ __PRETTY_FUNCTION__)); | |||
1093 | n = *indexUtf16; | |||
1094 | assert(n >= 0 && n <= string->length)(static_cast <bool> (n >= 0 && n <= string ->length) ? void (0) : __assert_fail ("n >= 0 && n <= string->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1094 , __extension__ __PRETTY_FUNCTION__)); | |||
1095 | while (incrementCodePoints < 0) { | |||
1096 | assert(n > 0)(static_cast <bool> (n > 0) ? void (0) : __assert_fail ("n > 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1096, __extension__ __PRETTY_FUNCTION__)); | |||
1097 | cu = string->buffer[--n]; | |||
1098 | if (rtl::isLowSurrogate(cu) && n != 0 && | |||
1099 | rtl::isHighSurrogate(string->buffer[n - 1])) | |||
1100 | { | |||
1101 | --n; | |||
1102 | } | |||
1103 | ++incrementCodePoints; | |||
1104 | } | |||
1105 | assert(n >= 0 && n < string->length)(static_cast <bool> (n >= 0 && n < string ->length) ? void (0) : __assert_fail ("n >= 0 && n < string->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1105 , __extension__ __PRETTY_FUNCTION__)); | |||
1106 | cu = string->buffer[n]; | |||
1107 | if (rtl::isHighSurrogate(cu) && string->length - n >= 2 && | |||
1108 | rtl::isLowSurrogate(string->buffer[n + 1])) | |||
1109 | { | |||
1110 | cp = rtl::combineSurrogates(cu, string->buffer[n + 1]); | |||
1111 | } else { | |||
1112 | cp = cu; | |||
1113 | } | |||
1114 | while (incrementCodePoints > 0) { | |||
1115 | assert(n < string->length)(static_cast <bool> (n < string->length) ? void ( 0) : __assert_fail ("n < string->length", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1115, __extension__ __PRETTY_FUNCTION__)); | |||
1116 | cu = string->buffer[n++]; | |||
1117 | if (rtl::isHighSurrogate(cu) && n != string->length && | |||
1118 | rtl::isLowSurrogate(string->buffer[n])) | |||
1119 | { | |||
1120 | ++n; | |||
1121 | } | |||
1122 | --incrementCodePoints; | |||
1123 | } | |||
1124 | assert(n >= 0 && n <= string->length)(static_cast <bool> (n >= 0 && n <= string ->length) ? void (0) : __assert_fail ("n >= 0 && n <= string->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1124 , __extension__ __PRETTY_FUNCTION__)); | |||
1125 | *indexUtf16 = n; | |||
1126 | return cp; | |||
1127 | } | |||
1128 | ||||
1129 | sal_Bool rtl_convertStringToUString( | |||
1130 | rtl_uString ** target, char const * source, sal_Int32 length, | |||
1131 | rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C()throw () | |||
1132 | { | |||
1133 | assert(target)(static_cast <bool> (target) ? void (0) : __assert_fail ("target", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1133, __extension__ __PRETTY_FUNCTION__)); | |||
1134 | assert(length >= 0)(static_cast <bool> (length >= 0) ? void (0) : __assert_fail ("length >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1134, __extension__ __PRETTY_FUNCTION__)); | |||
1135 | sal_uInt32 info; | |||
1136 | rtl_string2UString_status(target, source, length, encoding, flags, &info); | |||
1137 | return (info & RTL_TEXTTOUNICODE_INFO_ERROR((sal_uInt32)0x0001)) == 0; | |||
1138 | } | |||
1139 | ||||
1140 | void rtl_uString_newReplaceFirst( | |||
1141 | rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from, | |||
1142 | rtl_uString const * to, sal_Int32 * index) SAL_THROW_EXTERN_C()throw () | |||
1143 | { | |||
1144 | assert(str != nullptr)(static_cast <bool> (str != nullptr) ? void (0) : __assert_fail ("str != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1144, __extension__ __PRETTY_FUNCTION__)); | |||
1145 | assert(index != nullptr)(static_cast <bool> (index != nullptr) ? void (0) : __assert_fail ("index != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1145, __extension__ __PRETTY_FUNCTION__)); | |||
1146 | assert(*index >= 0 && *index <= str->length)(static_cast <bool> (*index >= 0 && *index <= str->length) ? void (0) : __assert_fail ("*index >= 0 && *index <= str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1146 , __extension__ __PRETTY_FUNCTION__)); | |||
1147 | assert(from != nullptr)(static_cast <bool> (from != nullptr) ? void (0) : __assert_fail ("from != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1147, __extension__ __PRETTY_FUNCTION__)); | |||
1148 | assert(to != nullptr)(static_cast <bool> (to != nullptr) ? void (0) : __assert_fail ("to != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1148, __extension__ __PRETTY_FUNCTION__)); | |||
1149 | sal_Int32 i = rtl_ustr_indexOfStr_WithLength( | |||
1150 | str->buffer + *index, str->length - *index, from->buffer, from->length); | |||
1151 | if (i == -1) { | |||
1152 | rtl_uString_assign(newStr, str); | |||
1153 | } else { | |||
1154 | assert(i <= str->length - *index)(static_cast <bool> (i <= str->length - *index) ? void (0) : __assert_fail ("i <= str->length - *index", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1154 , __extension__ __PRETTY_FUNCTION__)); | |||
1155 | i += *index; | |||
1156 | assert(from->length <= str->length)(static_cast <bool> (from->length <= str->length ) ? void (0) : __assert_fail ("from->length <= str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1156 , __extension__ __PRETTY_FUNCTION__)); | |||
1157 | if (str->length - from->length > SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF) - to->length) { | |||
1158 | std::abort(); | |||
1159 | } | |||
1160 | sal_Int32 n = str->length - from->length + to->length; | |||
1161 | rtl_uString_acquire(str); // in case *newStr == str | |||
1162 | rtl_uString_new_WithLength(newStr, n); | |||
1163 | if (n != 0) { | |||
1164 | (*newStr)->length = n; | |||
1165 | assert(i >= 0 && i < str->length)(static_cast <bool> (i >= 0 && i < str-> length) ? void (0) : __assert_fail ("i >= 0 && i < str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1165 , __extension__ __PRETTY_FUNCTION__)); | |||
1166 | memcpy( | |||
1167 | (*newStr)->buffer, str->buffer, i * sizeof (sal_Unicode)); | |||
1168 | memcpy( | |||
1169 | (*newStr)->buffer + i, to->buffer, | |||
1170 | to->length * sizeof (sal_Unicode)); | |||
1171 | memcpy( | |||
1172 | (*newStr)->buffer + i + to->length, | |||
1173 | str->buffer + i + from->length, | |||
1174 | (str->length - i - from->length) * sizeof (sal_Unicode)); | |||
1175 | } | |||
1176 | rtl_uString_release(str); | |||
1177 | } | |||
1178 | *index = i; | |||
1179 | } | |||
1180 | ||||
1181 | void rtl_uString_newReplaceFirstAsciiL( | |||
1182 | rtl_uString ** newStr, rtl_uString * str, char const * from, | |||
1183 | sal_Int32 fromLength, rtl_uString const * to, sal_Int32 * index) | |||
1184 | SAL_THROW_EXTERN_C()throw () | |||
1185 | { | |||
1186 | assert(str != nullptr)(static_cast <bool> (str != nullptr) ? void (0) : __assert_fail ("str != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1186, __extension__ __PRETTY_FUNCTION__)); | |||
1187 | assert(index != nullptr)(static_cast <bool> (index != nullptr) ? void (0) : __assert_fail ("index != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1187, __extension__ __PRETTY_FUNCTION__)); | |||
1188 | assert(*index >= 0 && *index <= str->length)(static_cast <bool> (*index >= 0 && *index <= str->length) ? void (0) : __assert_fail ("*index >= 0 && *index <= str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1188 , __extension__ __PRETTY_FUNCTION__)); | |||
1189 | assert(fromLength >= 0)(static_cast <bool> (fromLength >= 0) ? void (0) : __assert_fail ("fromLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1189, __extension__ __PRETTY_FUNCTION__)); | |||
1190 | assert(to != nullptr)(static_cast <bool> (to != nullptr) ? void (0) : __assert_fail ("to != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1190, __extension__ __PRETTY_FUNCTION__)); | |||
1191 | sal_Int32 i = rtl_ustr_indexOfAscii_WithLength( | |||
1192 | str->buffer + *index, str->length - *index, from, fromLength); | |||
1193 | if (i == -1) { | |||
1194 | rtl_uString_assign(newStr, str); | |||
1195 | } else { | |||
1196 | assert(i <= str->length - *index)(static_cast <bool> (i <= str->length - *index) ? void (0) : __assert_fail ("i <= str->length - *index", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1196 , __extension__ __PRETTY_FUNCTION__)); | |||
1197 | i += *index; | |||
1198 | assert(fromLength <= str->length)(static_cast <bool> (fromLength <= str->length) ? void (0) : __assert_fail ("fromLength <= str->length", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1198 , __extension__ __PRETTY_FUNCTION__)); | |||
1199 | if (str->length - fromLength > SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF) - to->length) { | |||
1200 | std::abort(); | |||
1201 | } | |||
1202 | sal_Int32 n = str->length - fromLength + to->length; | |||
1203 | rtl_uString_acquire(str); // in case *newStr == str | |||
1204 | rtl_uString_new_WithLength(newStr, n); | |||
1205 | if (n != 0) { | |||
1206 | (*newStr)->length = n; | |||
1207 | assert(i >= 0 && i < str->length)(static_cast <bool> (i >= 0 && i < str-> length) ? void (0) : __assert_fail ("i >= 0 && i < str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1207 , __extension__ __PRETTY_FUNCTION__)); | |||
1208 | memcpy( | |||
1209 | (*newStr)->buffer, str->buffer, i * sizeof (sal_Unicode)); | |||
1210 | memcpy( | |||
1211 | (*newStr)->buffer + i, to->buffer, | |||
1212 | to->length * sizeof (sal_Unicode)); | |||
1213 | memcpy( | |||
1214 | (*newStr)->buffer + i + to->length, | |||
1215 | str->buffer + i + fromLength, | |||
1216 | (str->length - i - fromLength) * sizeof (sal_Unicode)); | |||
1217 | } | |||
1218 | rtl_uString_release(str); | |||
1219 | } | |||
1220 | *index = i; | |||
1221 | } | |||
1222 | ||||
1223 | void rtl_uString_newReplaceFirstToAsciiL( | |||
1224 | rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from, | |||
1225 | char const * to, sal_Int32 toLength, sal_Int32 * index) | |||
1226 | SAL_THROW_EXTERN_C()throw () | |||
1227 | { | |||
1228 | assert(str != nullptr)(static_cast <bool> (str != nullptr) ? void (0) : __assert_fail ("str != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1228, __extension__ __PRETTY_FUNCTION__)); | |||
1229 | assert(index != nullptr)(static_cast <bool> (index != nullptr) ? void (0) : __assert_fail ("index != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1229, __extension__ __PRETTY_FUNCTION__)); | |||
1230 | assert(*index >= 0 && *index <= str->length)(static_cast <bool> (*index >= 0 && *index <= str->length) ? void (0) : __assert_fail ("*index >= 0 && *index <= str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1230 , __extension__ __PRETTY_FUNCTION__)); | |||
1231 | assert(from != nullptr)(static_cast <bool> (from != nullptr) ? void (0) : __assert_fail ("from != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1231, __extension__ __PRETTY_FUNCTION__)); | |||
1232 | assert(toLength >= 0)(static_cast <bool> (toLength >= 0) ? void (0) : __assert_fail ("toLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1232, __extension__ __PRETTY_FUNCTION__)); | |||
1233 | sal_Int32 i = rtl_ustr_indexOfStr_WithLength( | |||
1234 | str->buffer + *index, str->length - *index, from->buffer, from->length); | |||
1235 | if (i == -1) { | |||
1236 | rtl_uString_assign(newStr, str); | |||
1237 | } else { | |||
1238 | assert(i <= str->length - *index)(static_cast <bool> (i <= str->length - *index) ? void (0) : __assert_fail ("i <= str->length - *index", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1238 , __extension__ __PRETTY_FUNCTION__)); | |||
1239 | i += *index; | |||
1240 | assert(from->length <= str->length)(static_cast <bool> (from->length <= str->length ) ? void (0) : __assert_fail ("from->length <= str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1240 , __extension__ __PRETTY_FUNCTION__)); | |||
1241 | if (str->length - from->length > SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF) - toLength) { | |||
1242 | std::abort(); | |||
1243 | } | |||
1244 | sal_Int32 n = str->length - from->length + toLength; | |||
1245 | rtl_uString_acquire(str); // in case *newStr == str | |||
1246 | rtl_uString_new_WithLength(newStr, n); | |||
1247 | if (n != 0) { | |||
1248 | (*newStr)->length = n; | |||
1249 | assert(i >= 0 && i < str->length)(static_cast <bool> (i >= 0 && i < str-> length) ? void (0) : __assert_fail ("i >= 0 && i < str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1249 , __extension__ __PRETTY_FUNCTION__)); | |||
1250 | memcpy( | |||
1251 | (*newStr)->buffer, str->buffer, i * sizeof (sal_Unicode)); | |||
1252 | for (sal_Int32 j = 0; j != toLength; ++j) { | |||
1253 | assert(static_cast< unsigned char >(to[j]) <= 0x7F)(static_cast <bool> (static_cast< unsigned char > (to[j]) <= 0x7F) ? void (0) : __assert_fail ("static_cast< unsigned char >(to[j]) <= 0x7F" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1253 , __extension__ __PRETTY_FUNCTION__)); | |||
1254 | (*newStr)->buffer[i + j] = to[j]; | |||
1255 | } | |||
1256 | memcpy( | |||
1257 | (*newStr)->buffer + i + toLength, | |||
1258 | str->buffer + i + from->length, | |||
1259 | (str->length - i - from->length) * sizeof (sal_Unicode)); | |||
1260 | } | |||
1261 | rtl_uString_release(str); | |||
1262 | } | |||
1263 | *index = i; | |||
1264 | } | |||
1265 | ||||
1266 | void rtl_uString_newReplaceFirstAsciiLAsciiL( | |||
1267 | rtl_uString ** newStr, rtl_uString * str, char const * from, | |||
1268 | sal_Int32 fromLength, char const * to, sal_Int32 toLength, | |||
1269 | sal_Int32 * index) SAL_THROW_EXTERN_C()throw () | |||
1270 | { | |||
1271 | assert(str != nullptr)(static_cast <bool> (str != nullptr) ? void (0) : __assert_fail ("str != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1271, __extension__ __PRETTY_FUNCTION__)); | |||
1272 | assert(index != nullptr)(static_cast <bool> (index != nullptr) ? void (0) : __assert_fail ("index != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1272, __extension__ __PRETTY_FUNCTION__)); | |||
1273 | assert(*index >= 0 && *index <= str->length)(static_cast <bool> (*index >= 0 && *index <= str->length) ? void (0) : __assert_fail ("*index >= 0 && *index <= str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1273 , __extension__ __PRETTY_FUNCTION__)); | |||
1274 | assert(fromLength >= 0)(static_cast <bool> (fromLength >= 0) ? void (0) : __assert_fail ("fromLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1274, __extension__ __PRETTY_FUNCTION__)); | |||
1275 | assert(to != nullptr)(static_cast <bool> (to != nullptr) ? void (0) : __assert_fail ("to != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1275, __extension__ __PRETTY_FUNCTION__)); | |||
1276 | assert(toLength >= 0)(static_cast <bool> (toLength >= 0) ? void (0) : __assert_fail ("toLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1276, __extension__ __PRETTY_FUNCTION__)); | |||
1277 | sal_Int32 i = rtl_ustr_indexOfAscii_WithLength( | |||
1278 | str->buffer + *index, str->length - *index, from, fromLength); | |||
1279 | if (i == -1) { | |||
1280 | rtl_uString_assign(newStr, str); | |||
1281 | } else { | |||
1282 | assert(i <= str->length - *index)(static_cast <bool> (i <= str->length - *index) ? void (0) : __assert_fail ("i <= str->length - *index", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1282 , __extension__ __PRETTY_FUNCTION__)); | |||
1283 | i += *index; | |||
1284 | assert(fromLength <= str->length)(static_cast <bool> (fromLength <= str->length) ? void (0) : __assert_fail ("fromLength <= str->length", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1284 , __extension__ __PRETTY_FUNCTION__)); | |||
1285 | if (str->length - fromLength > SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF) - toLength) { | |||
1286 | std::abort(); | |||
1287 | } | |||
1288 | sal_Int32 n = str->length - fromLength + toLength; | |||
1289 | rtl_uString_acquire(str); // in case *newStr == str | |||
1290 | rtl_uString_new_WithLength(newStr, n); | |||
1291 | if (n != 0) { | |||
1292 | (*newStr)->length = n; | |||
1293 | assert(i >= 0 && i < str->length)(static_cast <bool> (i >= 0 && i < str-> length) ? void (0) : __assert_fail ("i >= 0 && i < str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1293 , __extension__ __PRETTY_FUNCTION__)); | |||
1294 | memcpy( | |||
1295 | (*newStr)->buffer, str->buffer, i * sizeof (sal_Unicode)); | |||
1296 | for (sal_Int32 j = 0; j != toLength; ++j) { | |||
1297 | assert(static_cast< unsigned char >(to[j]) <= 0x7F)(static_cast <bool> (static_cast< unsigned char > (to[j]) <= 0x7F) ? void (0) : __assert_fail ("static_cast< unsigned char >(to[j]) <= 0x7F" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1297 , __extension__ __PRETTY_FUNCTION__)); | |||
1298 | (*newStr)->buffer[i + j] = to[j]; | |||
1299 | } | |||
1300 | memcpy( | |||
1301 | (*newStr)->buffer + i + toLength, | |||
1302 | str->buffer + i + fromLength, | |||
1303 | (str->length - i - fromLength) * sizeof (sal_Unicode)); | |||
1304 | } | |||
1305 | rtl_uString_release(str); | |||
1306 | } | |||
1307 | *index = i; | |||
1308 | } | |||
1309 | ||||
1310 | void rtl_uString_newReplaceFirstAsciiLUtf16L( | |||
1311 | rtl_uString ** newStr, rtl_uString * str, char const * from, | |||
1312 | sal_Int32 fromLength, sal_Unicode const * to, sal_Int32 toLength, | |||
1313 | sal_Int32 * index) SAL_THROW_EXTERN_C()throw () | |||
1314 | { | |||
1315 | assert(str != nullptr)(static_cast <bool> (str != nullptr) ? void (0) : __assert_fail ("str != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1315, __extension__ __PRETTY_FUNCTION__)); | |||
1316 | assert(index != nullptr)(static_cast <bool> (index != nullptr) ? void (0) : __assert_fail ("index != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1316, __extension__ __PRETTY_FUNCTION__)); | |||
1317 | assert(*index >= 0 && *index <= str->length)(static_cast <bool> (*index >= 0 && *index <= str->length) ? void (0) : __assert_fail ("*index >= 0 && *index <= str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1317 , __extension__ __PRETTY_FUNCTION__)); | |||
1318 | assert(fromLength >= 0)(static_cast <bool> (fromLength >= 0) ? void (0) : __assert_fail ("fromLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1318, __extension__ __PRETTY_FUNCTION__)); | |||
1319 | assert(to != nullptr)(static_cast <bool> (to != nullptr) ? void (0) : __assert_fail ("to != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1319, __extension__ __PRETTY_FUNCTION__)); | |||
1320 | assert(toLength >= 0)(static_cast <bool> (toLength >= 0) ? void (0) : __assert_fail ("toLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1320, __extension__ __PRETTY_FUNCTION__)); | |||
1321 | sal_Int32 i = rtl_ustr_indexOfAscii_WithLength( | |||
1322 | str->buffer + *index, str->length - *index, from, fromLength); | |||
1323 | if (i == -1) { | |||
1324 | rtl_uString_assign(newStr, str); | |||
1325 | } else { | |||
1326 | assert(i <= str->length - *index)(static_cast <bool> (i <= str->length - *index) ? void (0) : __assert_fail ("i <= str->length - *index", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1326 , __extension__ __PRETTY_FUNCTION__)); | |||
1327 | i += *index; | |||
1328 | assert(fromLength <= str->length)(static_cast <bool> (fromLength <= str->length) ? void (0) : __assert_fail ("fromLength <= str->length", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1328 , __extension__ __PRETTY_FUNCTION__)); | |||
1329 | if (str->length - fromLength > SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF) - toLength) { | |||
1330 | rtl_uString_release(*newStr); | |||
1331 | *newStr = nullptr; | |||
1332 | } else { | |||
1333 | sal_Int32 n = str->length - fromLength + toLength; | |||
1334 | rtl_uString_acquire(str); // in case *newStr == str | |||
1335 | rtl_uString_new_WithLength(newStr, n); | |||
1336 | if (n != 0 && /*TODO:*/ *newStr != nullptr) { | |||
1337 | (*newStr)->length = n; | |||
1338 | assert(i >= 0 && i < str->length)(static_cast <bool> (i >= 0 && i < str-> length) ? void (0) : __assert_fail ("i >= 0 && i < str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1338 , __extension__ __PRETTY_FUNCTION__)); | |||
1339 | memcpy( | |||
1340 | (*newStr)->buffer, str->buffer, i * sizeof (sal_Unicode)); | |||
1341 | memcpy( | |||
1342 | (*newStr)->buffer + i, to, toLength * sizeof (sal_Unicode)); | |||
1343 | memcpy( | |||
1344 | (*newStr)->buffer + i + toLength, | |||
1345 | str->buffer + i + fromLength, | |||
1346 | (str->length - i - fromLength) * sizeof (sal_Unicode)); | |||
1347 | } | |||
1348 | rtl_uString_release(str); | |||
1349 | } | |||
1350 | } | |||
1351 | *index = i; | |||
1352 | } | |||
1353 | ||||
1354 | void rtl_uString_newReplaceFirstUtf16LAsciiL( | |||
1355 | rtl_uString ** newStr, rtl_uString * str, sal_Unicode const * from, | |||
1356 | sal_Int32 fromLength, char const * to, sal_Int32 toLength, | |||
1357 | sal_Int32 * index) SAL_THROW_EXTERN_C()throw () | |||
1358 | { | |||
1359 | assert(str != nullptr)(static_cast <bool> (str != nullptr) ? void (0) : __assert_fail ("str != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1359, __extension__ __PRETTY_FUNCTION__)); | |||
1360 | assert(index != nullptr)(static_cast <bool> (index != nullptr) ? void (0) : __assert_fail ("index != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1360, __extension__ __PRETTY_FUNCTION__)); | |||
1361 | assert(*index >= 0 && *index <= str->length)(static_cast <bool> (*index >= 0 && *index <= str->length) ? void (0) : __assert_fail ("*index >= 0 && *index <= str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1361 , __extension__ __PRETTY_FUNCTION__)); | |||
1362 | assert(fromLength >= 0)(static_cast <bool> (fromLength >= 0) ? void (0) : __assert_fail ("fromLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1362, __extension__ __PRETTY_FUNCTION__)); | |||
1363 | assert(to != nullptr)(static_cast <bool> (to != nullptr) ? void (0) : __assert_fail ("to != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1363, __extension__ __PRETTY_FUNCTION__)); | |||
1364 | assert(toLength >= 0)(static_cast <bool> (toLength >= 0) ? void (0) : __assert_fail ("toLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1364, __extension__ __PRETTY_FUNCTION__)); | |||
1365 | sal_Int32 i = rtl_ustr_indexOfStr_WithLength( | |||
1366 | str->buffer + *index, str->length - *index, from, fromLength); | |||
1367 | if (i == -1) { | |||
1368 | rtl_uString_assign(newStr, str); | |||
1369 | } else { | |||
1370 | assert(i <= str->length - *index)(static_cast <bool> (i <= str->length - *index) ? void (0) : __assert_fail ("i <= str->length - *index", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1370 , __extension__ __PRETTY_FUNCTION__)); | |||
1371 | i += *index; | |||
1372 | assert(fromLength <= str->length)(static_cast <bool> (fromLength <= str->length) ? void (0) : __assert_fail ("fromLength <= str->length", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1372 , __extension__ __PRETTY_FUNCTION__)); | |||
1373 | if (str->length - fromLength > SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF) - toLength) { | |||
1374 | rtl_uString_release(*newStr); | |||
1375 | *newStr = nullptr; | |||
1376 | } else { | |||
1377 | sal_Int32 n = str->length - fromLength + toLength; | |||
1378 | rtl_uString_acquire(str); // in case *newStr == str | |||
1379 | rtl_uString_new_WithLength(newStr, n); | |||
1380 | if (n != 0 && /*TODO:*/ *newStr != nullptr) { | |||
1381 | (*newStr)->length = n; | |||
1382 | assert(i >= 0 && i < str->length)(static_cast <bool> (i >= 0 && i < str-> length) ? void (0) : __assert_fail ("i >= 0 && i < str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1382 , __extension__ __PRETTY_FUNCTION__)); | |||
1383 | memcpy( | |||
1384 | (*newStr)->buffer, str->buffer, i * sizeof (sal_Unicode)); | |||
1385 | for (sal_Int32 j = 0; j != toLength; ++j) { | |||
1386 | assert(static_cast< unsigned char >(to[j]) <= 0x7F)(static_cast <bool> (static_cast< unsigned char > (to[j]) <= 0x7F) ? void (0) : __assert_fail ("static_cast< unsigned char >(to[j]) <= 0x7F" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1386 , __extension__ __PRETTY_FUNCTION__)); | |||
1387 | (*newStr)->buffer[i + j] = to[j]; | |||
1388 | } | |||
1389 | memcpy( | |||
1390 | (*newStr)->buffer + i + toLength, | |||
1391 | str->buffer + i + fromLength, | |||
1392 | (str->length - i - fromLength) * sizeof (sal_Unicode)); | |||
1393 | } | |||
1394 | rtl_uString_release(str); | |||
1395 | } | |||
1396 | } | |||
1397 | *index = i; | |||
1398 | } | |||
1399 | ||||
1400 | void rtl_uString_newReplaceFirstUtf16LUtf16L( | |||
1401 | rtl_uString ** newStr, rtl_uString * str, sal_Unicode const * from, | |||
1402 | sal_Int32 fromLength, sal_Unicode const * to, sal_Int32 toLength, | |||
1403 | sal_Int32 * index) SAL_THROW_EXTERN_C()throw () | |||
1404 | { | |||
1405 | assert(str != nullptr)(static_cast <bool> (str != nullptr) ? void (0) : __assert_fail ("str != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1405, __extension__ __PRETTY_FUNCTION__)); | |||
1406 | assert(index != nullptr)(static_cast <bool> (index != nullptr) ? void (0) : __assert_fail ("index != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1406, __extension__ __PRETTY_FUNCTION__)); | |||
1407 | assert(*index >= 0 && *index <= str->length)(static_cast <bool> (*index >= 0 && *index <= str->length) ? void (0) : __assert_fail ("*index >= 0 && *index <= str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1407 , __extension__ __PRETTY_FUNCTION__)); | |||
1408 | assert(fromLength >= 0)(static_cast <bool> (fromLength >= 0) ? void (0) : __assert_fail ("fromLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1408, __extension__ __PRETTY_FUNCTION__)); | |||
1409 | assert(to != nullptr)(static_cast <bool> (to != nullptr) ? void (0) : __assert_fail ("to != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1409, __extension__ __PRETTY_FUNCTION__)); | |||
1410 | assert(toLength >= 0)(static_cast <bool> (toLength >= 0) ? void (0) : __assert_fail ("toLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1410, __extension__ __PRETTY_FUNCTION__)); | |||
1411 | sal_Int32 i = rtl_ustr_indexOfStr_WithLength( | |||
1412 | str->buffer + *index, str->length - *index, from, fromLength); | |||
1413 | if (i == -1) { | |||
1414 | rtl_uString_assign(newStr, str); | |||
1415 | } else { | |||
1416 | assert(i <= str->length - *index)(static_cast <bool> (i <= str->length - *index) ? void (0) : __assert_fail ("i <= str->length - *index", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1416 , __extension__ __PRETTY_FUNCTION__)); | |||
1417 | i += *index; | |||
1418 | assert(fromLength <= str->length)(static_cast <bool> (fromLength <= str->length) ? void (0) : __assert_fail ("fromLength <= str->length", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1418 , __extension__ __PRETTY_FUNCTION__)); | |||
1419 | if (str->length - fromLength > SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF) - toLength) { | |||
1420 | rtl_uString_release(*newStr); | |||
1421 | *newStr = nullptr; | |||
1422 | } else { | |||
1423 | sal_Int32 n = str->length - fromLength + toLength; | |||
1424 | rtl_uString_acquire(str); // in case *newStr == str | |||
1425 | rtl_uString_new_WithLength(newStr, n); | |||
1426 | if (n != 0 && /*TODO:*/ *newStr != nullptr) { | |||
1427 | (*newStr)->length = n; | |||
1428 | assert(i >= 0 && i < str->length)(static_cast <bool> (i >= 0 && i < str-> length) ? void (0) : __assert_fail ("i >= 0 && i < str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1428 , __extension__ __PRETTY_FUNCTION__)); | |||
1429 | memcpy( | |||
1430 | (*newStr)->buffer, str->buffer, i * sizeof (sal_Unicode)); | |||
1431 | memcpy( | |||
1432 | (*newStr)->buffer + i, to, toLength * sizeof (sal_Unicode)); | |||
1433 | memcpy( | |||
1434 | (*newStr)->buffer + i + toLength, | |||
1435 | str->buffer + i + fromLength, | |||
1436 | (str->length - i - fromLength) * sizeof (sal_Unicode)); | |||
1437 | } | |||
1438 | rtl_uString_release(str); | |||
1439 | } | |||
1440 | } | |||
1441 | *index = i; | |||
1442 | } | |||
1443 | ||||
1444 | void rtl_uString_newReplaceAll( | |||
1445 | rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from, | |||
1446 | rtl_uString const * to) SAL_THROW_EXTERN_C()throw () | |||
1447 | { | |||
1448 | rtl_uString_newReplaceAllFromIndex( newStr, str, from, to, 0 ); | |||
1449 | } | |||
1450 | ||||
1451 | void rtl_uString_newReplaceAllFromIndex( | |||
1452 | rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from, | |||
1453 | rtl_uString const * to, sal_Int32 fromIndex) SAL_THROW_EXTERN_C()throw () | |||
1454 | { | |||
1455 | assert(to != nullptr)(static_cast <bool> (to != nullptr) ? void (0) : __assert_fail ("to != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1455, __extension__ __PRETTY_FUNCTION__)); | |||
1456 | assert(fromIndex >= 0 && fromIndex <= str->length)(static_cast <bool> (fromIndex >= 0 && fromIndex <= str->length) ? void (0) : __assert_fail ("fromIndex >= 0 && fromIndex <= str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1456 , __extension__ __PRETTY_FUNCTION__)); | |||
1457 | rtl_uString_assign(newStr, str); | |||
1458 | for (sal_Int32 i = fromIndex;; i += to->length) { | |||
1459 | rtl_uString_newReplaceFirst(newStr, *newStr, from, to, &i); | |||
1460 | if (i == -1) { | |||
1461 | break; | |||
1462 | } | |||
1463 | } | |||
1464 | } | |||
1465 | ||||
1466 | void rtl_uString_newReplaceAllAsciiL( | |||
1467 | rtl_uString ** newStr, rtl_uString * str, char const * from, | |||
1468 | sal_Int32 fromLength, rtl_uString const * to) SAL_THROW_EXTERN_C()throw () | |||
1469 | { | |||
1470 | assert(to != nullptr)(static_cast <bool> (to != nullptr) ? void (0) : __assert_fail ("to != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1470, __extension__ __PRETTY_FUNCTION__)); | |||
1471 | rtl_uString_assign(newStr, str); | |||
1472 | for (sal_Int32 i = 0;; i += to->length) { | |||
1473 | rtl_uString_newReplaceFirstAsciiL( | |||
1474 | newStr, *newStr, from, fromLength, to, &i); | |||
1475 | if (i == -1) { | |||
1476 | break; | |||
1477 | } | |||
1478 | } | |||
1479 | } | |||
1480 | ||||
1481 | void rtl_uString_newReplaceAllToAsciiL( | |||
1482 | rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from, | |||
1483 | char const * to, sal_Int32 toLength) SAL_THROW_EXTERN_C()throw () | |||
1484 | { | |||
1485 | assert(from != nullptr)(static_cast <bool> (from != nullptr) ? void (0) : __assert_fail ("from != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1485, __extension__ __PRETTY_FUNCTION__)); | |||
1486 | rtl_uString_assign(newStr, str); | |||
1487 | for (sal_Int32 i = 0;; i += toLength) { | |||
1488 | rtl_uString_newReplaceFirstToAsciiL( | |||
1489 | newStr, *newStr, from, to, toLength, &i); | |||
1490 | if (i == -1) { | |||
1491 | break; | |||
1492 | } | |||
1493 | } | |||
1494 | } | |||
1495 | ||||
1496 | void rtl_uString_newReplaceAllAsciiLAsciiL( | |||
1497 | rtl_uString ** newStr, rtl_uString * str, char const * from, | |||
1498 | sal_Int32 fromLength, char const * to, sal_Int32 toLength) | |||
1499 | SAL_THROW_EXTERN_C()throw () | |||
1500 | { | |||
1501 | assert(toLength >= 0)(static_cast <bool> (toLength >= 0) ? void (0) : __assert_fail ("toLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1501, __extension__ __PRETTY_FUNCTION__)); | |||
1502 | rtl_uString_assign(newStr, str); | |||
1503 | for (sal_Int32 i = 0;; i += toLength) { | |||
1504 | rtl_uString_newReplaceFirstAsciiLAsciiL( | |||
1505 | newStr, *newStr, from, fromLength, to, toLength, &i); | |||
1506 | if (i == -1) { | |||
1507 | break; | |||
1508 | } | |||
1509 | } | |||
1510 | } | |||
1511 | ||||
1512 | void rtl_uString_newReplaceAllAsciiLUtf16L( | |||
1513 | rtl_uString ** newStr, rtl_uString * str, char const * from, | |||
1514 | sal_Int32 fromLength, sal_Unicode const * to, sal_Int32 toLength) | |||
1515 | SAL_THROW_EXTERN_C()throw () | |||
1516 | { | |||
1517 | assert(toLength >= 0)(static_cast <bool> (toLength >= 0) ? void (0) : __assert_fail ("toLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1517, __extension__ __PRETTY_FUNCTION__)); | |||
1518 | rtl_uString_assign(newStr, str); | |||
1519 | for (sal_Int32 i = 0;; i += toLength) { | |||
1520 | rtl_uString_newReplaceFirstAsciiLUtf16L( | |||
1521 | newStr, *newStr, from, fromLength, to, toLength, &i); | |||
1522 | if (i == -1 || *newStr == nullptr) { | |||
1523 | break; | |||
1524 | } | |||
1525 | } | |||
1526 | } | |||
1527 | ||||
1528 | void rtl_uString_newReplaceAllUtf16LAsciiL( | |||
1529 | rtl_uString ** newStr, rtl_uString * str, sal_Unicode const * from, | |||
1530 | sal_Int32 fromLength, char const * to, sal_Int32 toLength) | |||
1531 | SAL_THROW_EXTERN_C()throw () | |||
1532 | { | |||
1533 | assert(toLength >= 0)(static_cast <bool> (toLength >= 0) ? void (0) : __assert_fail ("toLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1533, __extension__ __PRETTY_FUNCTION__)); | |||
1534 | rtl_uString_assign(newStr, str); | |||
1535 | for (sal_Int32 i = 0;; i += toLength) { | |||
1536 | rtl_uString_newReplaceFirstUtf16LAsciiL( | |||
1537 | newStr, *newStr, from, fromLength, to, toLength, &i); | |||
1538 | if (i == -1 || *newStr == nullptr) { | |||
1539 | break; | |||
1540 | } | |||
1541 | } | |||
1542 | } | |||
1543 | ||||
1544 | void rtl_uString_newReplaceAllUtf16LUtf16L( | |||
1545 | rtl_uString ** newStr, rtl_uString * str, sal_Unicode const * from, | |||
1546 | sal_Int32 fromLength, sal_Unicode const * to, sal_Int32 toLength) | |||
1547 | SAL_THROW_EXTERN_C()throw () | |||
1548 | { | |||
1549 | rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(newStr, str, from, fromLength, to, toLength, 0); | |||
1550 | } | |||
1551 | ||||
1552 | void rtl_uString_newReplaceAllFromIndexUtf16LUtf16L( | |||
1553 | rtl_uString ** newStr, rtl_uString * str, sal_Unicode const * from, | |||
1554 | sal_Int32 fromLength, sal_Unicode const * to, sal_Int32 toLength, sal_Int32 fromIndex) | |||
1555 | SAL_THROW_EXTERN_C()throw () | |||
1556 | { | |||
1557 | assert(toLength >= 0)(static_cast <bool> (toLength >= 0) ? void (0) : __assert_fail ("toLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx" , 1557, __extension__ __PRETTY_FUNCTION__)); | |||
1558 | assert(fromIndex >= 0 && fromIndex <= str->length)(static_cast <bool> (fromIndex >= 0 && fromIndex <= str->length) ? void (0) : __assert_fail ("fromIndex >= 0 && fromIndex <= str->length" , "/home/maarten/src/libreoffice/core/sal/rtl/ustring.cxx", 1558 , __extension__ __PRETTY_FUNCTION__)); | |||
1559 | rtl_uString_assign(newStr, str); | |||
1560 | for (sal_Int32 i = fromIndex;; i += toLength) { | |||
1561 | rtl_uString_newReplaceFirstUtf16LUtf16L( | |||
1562 | newStr, *newStr, from, fromLength, to, toLength, &i); | |||
1563 | if (i == -1 || *newStr == nullptr) { | |||
1564 | break; | |||
1565 | } | |||
1566 | } | |||
1567 | } | |||
1568 | ||||
1569 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||
2 | /* | |||
3 | * This file is part of the LibreOffice project. | |||
4 | * | |||
5 | * This Source Code Form is subject to the terms of the Mozilla Public | |||
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this | |||
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |||
8 | * | |||
9 | * This file incorporates work covered by the following license notice: | |||
10 | * | |||
11 | * Licensed to the Apache Software Foundation (ASF) under one or more | |||
12 | * contributor license agreements. See the NOTICE file distributed | |||
13 | * with this work for additional information regarding copyright | |||
14 | * ownership. The ASF licenses this file to you under the Apache | |||
15 | * License, Version 2.0 (the "License"); you may not use this file | |||
16 | * except in compliance with the License. You may obtain a copy of | |||
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | |||
18 | */ | |||
19 | ||||
20 | /* ======================================================================= */ | |||
21 | /* Internal C-String help functions which could be used without the */ | |||
22 | /* String-Class */ | |||
23 | /* ======================================================================= */ | |||
24 | ||||
25 | #include <algorithm> | |||
26 | #include <cassert> | |||
27 | #include <limits> | |||
28 | ||||
29 | #include <cstring> | |||
30 | #include <wchar.h> | |||
31 | #include <sal/log.hxx> | |||
32 | #include <rtl/character.hxx> | |||
33 | ||||
34 | /* | |||
35 | inline void rtl_str_ImplCopy( IMPL_RTL_STRCODE* pDest, | |||
36 | const IMPL_RTL_STRCODE* pSrc, | |||
37 | sal_Int32 nCount ) | |||
38 | { | |||
39 | while ( nCount > 0 ) | |||
40 | { | |||
41 | *pDest = *pSrc; | |||
42 | pDest++; | |||
43 | pSrc++; | |||
44 | nCount--; | |||
45 | } | |||
46 | } | |||
47 | */ | |||
48 | ||||
49 | static void rtl_str_ImplCopy( IMPL_RTL_STRCODE* _pDest, | |||
50 | const IMPL_RTL_STRCODE* _pSrc, | |||
51 | sal_Int32 _nCount ) | |||
52 | { | |||
53 | // take advantage of builtin optimisations | |||
54 | memcpy( _pDest, _pSrc, _nCount * sizeof(IMPL_RTL_STRCODE)); | |||
| ||||
55 | } | |||
56 | ||||
57 | /* ======================================================================= */ | |||
58 | /* C-String functions which could be used without the String-Class */ | |||
59 | /* ======================================================================= */ | |||
60 | ||||
61 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( getLength )( const IMPL_RTL_STRCODE* pStr ) | |||
62 | SAL_THROW_EXTERN_C()throw () | |||
63 | { | |||
64 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 64, __extension__ __PRETTY_FUNCTION__)); | |||
65 | #if !IMPL_RTL_IS_USTRING | |||
66 | // take advantage of builtin optimisations | |||
67 | return strlen( pStr); | |||
68 | #else | |||
69 | if (sizeof(IMPL_RTL_STRCODE) == sizeof(wchar_t)) | |||
70 | { | |||
71 | // take advantage of builtin optimisations | |||
72 | return wcslen(reinterpret_cast<wchar_t const *>(pStr)); | |||
73 | } | |||
74 | else | |||
75 | { | |||
76 | const IMPL_RTL_STRCODE* pTempStr = pStr; | |||
77 | while( *pTempStr ) | |||
78 | pTempStr++; | |||
79 | return pTempStr-pStr; | |||
80 | } | |||
81 | #endif | |||
82 | } | |||
83 | ||||
84 | /* ----------------------------------------------------------------------- */ | |||
85 | ||||
86 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compare )( const IMPL_RTL_STRCODE* pStr1, | |||
87 | const IMPL_RTL_STRCODE* pStr2 ) | |||
88 | SAL_THROW_EXTERN_C()throw () | |||
89 | { | |||
90 | assert(pStr1)(static_cast <bool> (pStr1) ? void (0) : __assert_fail ( "pStr1", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 90, __extension__ __PRETTY_FUNCTION__)); | |||
91 | assert(pStr2)(static_cast <bool> (pStr2) ? void (0) : __assert_fail ( "pStr2", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 91, __extension__ __PRETTY_FUNCTION__)); | |||
92 | #if !IMPL_RTL_IS_USTRING | |||
93 | // take advantage of builtin optimisations | |||
94 | return strcmp( pStr1, pStr2); | |||
95 | #else | |||
96 | if (sizeof(IMPL_RTL_STRCODE) == sizeof(wchar_t)) | |||
97 | { | |||
98 | // take advantage of builtin optimisations | |||
99 | return wcscmp(reinterpret_cast<wchar_t const *>(pStr1), reinterpret_cast<wchar_t const *>(pStr2)); | |||
100 | } | |||
101 | else | |||
102 | { | |||
103 | sal_Int32 nRet; | |||
104 | for (;;) | |||
105 | { | |||
106 | nRet = static_cast<sal_Int32>(IMPL_RTL_USTRCODE(*pStr1)) - | |||
107 | static_cast<sal_Int32>(IMPL_RTL_USTRCODE(*pStr2)); | |||
108 | if (!(nRet == 0 && *pStr2 )) | |||
109 | break; | |||
110 | pStr1++; | |||
111 | pStr2++; | |||
112 | } | |||
113 | ||||
114 | return nRet; | |||
115 | } | |||
116 | #endif | |||
117 | } | |||
118 | ||||
119 | /* ----------------------------------------------------------------------- */ | |||
120 | ||||
121 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compare_WithLength )( const IMPL_RTL_STRCODE* pStr1, | |||
122 | sal_Int32 nStr1Len, | |||
123 | const IMPL_RTL_STRCODE* pStr2, | |||
124 | sal_Int32 nStr2Len ) | |||
125 | SAL_THROW_EXTERN_C()throw () | |||
126 | { | |||
127 | assert(nStr1Len >= 0)(static_cast <bool> (nStr1Len >= 0) ? void (0) : __assert_fail ("nStr1Len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 127, __extension__ __PRETTY_FUNCTION__)); | |||
128 | assert(nStr2Len >= 0)(static_cast <bool> (nStr2Len >= 0) ? void (0) : __assert_fail ("nStr2Len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 128, __extension__ __PRETTY_FUNCTION__)); | |||
129 | #if !IMPL_RTL_IS_USTRING | |||
130 | // take advantage of builtin optimisations | |||
131 | sal_Int32 nMin = std::min(nStr1Len, nStr2Len); | |||
132 | sal_Int32 nRet = memcmp(pStr1, pStr2, nMin); | |||
133 | return nRet == 0 ? nStr1Len - nStr2Len : nRet; | |||
134 | #else | |||
135 | if (sizeof(IMPL_RTL_STRCODE) == sizeof(wchar_t)) | |||
136 | { | |||
137 | // take advantage of builtin optimisations | |||
138 | sal_Int32 nMin = std::min(nStr1Len, nStr2Len); | |||
139 | sal_Int32 nRet = wmemcmp(reinterpret_cast<wchar_t const *>(pStr1), | |||
140 | reinterpret_cast<wchar_t const *>(pStr2), nMin); | |||
141 | return nRet == 0 ? nStr1Len - nStr2Len : nRet; | |||
142 | } | |||
143 | else | |||
144 | { | |||
145 | sal_Int32 nRet = nStr1Len - nStr2Len; | |||
146 | int nCount = (nRet <= 0) ? nStr1Len : nStr2Len; | |||
147 | ||||
148 | --pStr1; | |||
149 | --pStr2; | |||
150 | while( (--nCount >= 0) && (*++pStr1 == *++pStr2) ) ; | |||
151 | ||||
152 | if( nCount >= 0 ) | |||
153 | nRet = static_cast<sal_Int32>(IMPL_RTL_USTRCODE( *pStr1 )) | |||
154 | - static_cast<sal_Int32>(IMPL_RTL_USTRCODE( *pStr2 )); | |||
155 | ||||
156 | return nRet; | |||
157 | } | |||
158 | #endif | |||
159 | } | |||
160 | ||||
161 | /* ----------------------------------------------------------------------- */ | |||
162 | ||||
163 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( shortenedCompare_WithLength )( const IMPL_RTL_STRCODE* pStr1, | |||
164 | sal_Int32 nStr1Len, | |||
165 | const IMPL_RTL_STRCODE* pStr2, | |||
166 | sal_Int32 nStr2Len, | |||
167 | sal_Int32 nShortenedLength ) | |||
168 | SAL_THROW_EXTERN_C()throw () | |||
169 | { | |||
170 | assert(nStr1Len >= 0)(static_cast <bool> (nStr1Len >= 0) ? void (0) : __assert_fail ("nStr1Len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 170, __extension__ __PRETTY_FUNCTION__)); | |||
171 | assert(nStr2Len >= 0)(static_cast <bool> (nStr2Len >= 0) ? void (0) : __assert_fail ("nStr2Len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 171, __extension__ __PRETTY_FUNCTION__)); | |||
172 | assert(nShortenedLength >= 0)(static_cast <bool> (nShortenedLength >= 0) ? void ( 0) : __assert_fail ("nShortenedLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 172, __extension__ __PRETTY_FUNCTION__)); | |||
173 | #if !IMPL_RTL_IS_USTRING | |||
174 | // take advantage of builtin optimisations | |||
175 | sal_Int32 nMin = std::min(std::min(nStr1Len, nStr2Len), nShortenedLength); | |||
176 | sal_Int32 nRet = memcmp(pStr1, pStr2, nMin); | |||
177 | if (nRet == 0 && nShortenedLength > std::min(nStr1Len, nStr2Len)) | |||
178 | return nStr1Len - nStr2Len; | |||
179 | return nRet; | |||
180 | #else | |||
181 | if (sizeof(IMPL_RTL_STRCODE) == sizeof(wchar_t)) | |||
182 | { | |||
183 | // take advantage of builtin optimisations | |||
184 | sal_Int32 nMin = std::min(std::min(nStr1Len, nStr2Len), nShortenedLength); | |||
185 | sal_Int32 nRet = wmemcmp(reinterpret_cast<wchar_t const *>(pStr1), reinterpret_cast<wchar_t const *>(pStr2), nMin); | |||
186 | if (nRet == 0 && nShortenedLength > std::min(nStr1Len, nStr2Len)) | |||
187 | return nStr1Len - nStr2Len; | |||
188 | return nRet; | |||
189 | } | |||
190 | else | |||
191 | { | |||
192 | const IMPL_RTL_STRCODE* pStr1End = pStr1 + nStr1Len; | |||
193 | const IMPL_RTL_STRCODE* pStr2End = pStr2 + nStr2Len; | |||
194 | sal_Int32 nRet; | |||
195 | while ( (nShortenedLength > 0) && | |||
196 | (pStr1 < pStr1End) && (pStr2 < pStr2End) ) | |||
197 | { | |||
198 | nRet = static_cast<sal_Int32>(IMPL_RTL_USTRCODE( *pStr1 ))- | |||
199 | static_cast<sal_Int32>(IMPL_RTL_USTRCODE( *pStr2 )); | |||
200 | if ( nRet ) | |||
201 | return nRet; | |||
202 | ||||
203 | nShortenedLength--; | |||
204 | pStr1++; | |||
205 | pStr2++; | |||
206 | } | |||
207 | ||||
208 | if ( nShortenedLength <= 0 ) | |||
209 | return 0; | |||
210 | return nStr1Len - nStr2Len; | |||
211 | } | |||
212 | #endif | |||
213 | } | |||
214 | ||||
215 | /* ----------------------------------------------------------------------- */ | |||
216 | ||||
217 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( reverseCompare_WithLength )( const IMPL_RTL_STRCODE* pStr1, | |||
218 | sal_Int32 nStr1Len, | |||
219 | const IMPL_RTL_STRCODE* pStr2, | |||
220 | sal_Int32 nStr2Len ) | |||
221 | SAL_THROW_EXTERN_C()throw () | |||
222 | { | |||
223 | assert(nStr1Len >= 0)(static_cast <bool> (nStr1Len >= 0) ? void (0) : __assert_fail ("nStr1Len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 223, __extension__ __PRETTY_FUNCTION__)); | |||
224 | assert(nStr2Len >= 0)(static_cast <bool> (nStr2Len >= 0) ? void (0) : __assert_fail ("nStr2Len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 224, __extension__ __PRETTY_FUNCTION__)); | |||
225 | const IMPL_RTL_STRCODE* pStr1Run = pStr1+nStr1Len; | |||
226 | const IMPL_RTL_STRCODE* pStr2Run = pStr2+nStr2Len; | |||
227 | sal_Int32 nRet; | |||
228 | while ( (pStr1 < pStr1Run) && (pStr2 < pStr2Run) ) | |||
229 | { | |||
230 | pStr1Run--; | |||
231 | pStr2Run--; | |||
232 | nRet = static_cast<sal_Int32>(IMPL_RTL_USTRCODE( *pStr1Run ))- | |||
233 | static_cast<sal_Int32>(IMPL_RTL_USTRCODE( *pStr2Run )); | |||
234 | if ( nRet ) | |||
235 | return nRet; | |||
236 | } | |||
237 | ||||
238 | return nStr1Len - nStr2Len; | |||
239 | } | |||
240 | ||||
241 | /* ----------------------------------------------------------------------- */ | |||
242 | ||||
243 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compareIgnoreAsciiCase )( const IMPL_RTL_STRCODE* pStr1, | |||
244 | const IMPL_RTL_STRCODE* pStr2 ) | |||
245 | SAL_THROW_EXTERN_C()throw () | |||
246 | { | |||
247 | assert(pStr1)(static_cast <bool> (pStr1) ? void (0) : __assert_fail ( "pStr1", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 247, __extension__ __PRETTY_FUNCTION__)); | |||
248 | assert(pStr2)(static_cast <bool> (pStr2) ? void (0) : __assert_fail ( "pStr2", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 248, __extension__ __PRETTY_FUNCTION__)); | |||
249 | sal_uInt32 c1; | |||
250 | do | |||
251 | { | |||
252 | c1 = IMPL_RTL_USTRCODE(*pStr1); | |||
253 | sal_Int32 nRet = rtl::compareIgnoreAsciiCase( | |||
254 | c1, IMPL_RTL_USTRCODE(*pStr2)); | |||
255 | if ( nRet != 0 ) | |||
256 | return nRet; | |||
257 | ||||
258 | pStr1++; | |||
259 | pStr2++; | |||
260 | } | |||
261 | while (c1); | |||
262 | ||||
263 | return 0; | |||
264 | } | |||
265 | ||||
266 | /* ----------------------------------------------------------------------- */ | |||
267 | ||||
268 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compareIgnoreAsciiCase_WithLength )( const IMPL_RTL_STRCODE* pStr1, | |||
269 | sal_Int32 nStr1Len, | |||
270 | const IMPL_RTL_STRCODE* pStr2, | |||
271 | sal_Int32 nStr2Len ) | |||
272 | SAL_THROW_EXTERN_C()throw () | |||
273 | { | |||
274 | assert(nStr1Len >= 0)(static_cast <bool> (nStr1Len >= 0) ? void (0) : __assert_fail ("nStr1Len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 274, __extension__ __PRETTY_FUNCTION__)); | |||
275 | assert(nStr2Len >= 0)(static_cast <bool> (nStr2Len >= 0) ? void (0) : __assert_fail ("nStr2Len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 275, __extension__ __PRETTY_FUNCTION__)); | |||
276 | const IMPL_RTL_STRCODE* pStr1End = pStr1 + nStr1Len; | |||
277 | const IMPL_RTL_STRCODE* pStr2End = pStr2 + nStr2Len; | |||
278 | while ( (pStr1 < pStr1End) && (pStr2 < pStr2End) ) | |||
279 | { | |||
280 | sal_Int32 nRet = rtl::compareIgnoreAsciiCase( | |||
281 | IMPL_RTL_USTRCODE(*pStr1), IMPL_RTL_USTRCODE(*pStr2)); | |||
282 | if ( nRet != 0 ) | |||
283 | return nRet; | |||
284 | ||||
285 | pStr1++; | |||
286 | pStr2++; | |||
287 | } | |||
288 | ||||
289 | return nStr1Len - nStr2Len; | |||
290 | } | |||
291 | ||||
292 | /* ----------------------------------------------------------------------- */ | |||
293 | ||||
294 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( shortenedCompareIgnoreAsciiCase_WithLength )( const IMPL_RTL_STRCODE* pStr1, | |||
295 | sal_Int32 nStr1Len, | |||
296 | const IMPL_RTL_STRCODE* pStr2, | |||
297 | sal_Int32 nStr2Len, | |||
298 | sal_Int32 nShortenedLength ) | |||
299 | SAL_THROW_EXTERN_C()throw () | |||
300 | { | |||
301 | assert(nStr1Len >= 0)(static_cast <bool> (nStr1Len >= 0) ? void (0) : __assert_fail ("nStr1Len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 301, __extension__ __PRETTY_FUNCTION__)); | |||
302 | assert(nStr2Len >= 0)(static_cast <bool> (nStr2Len >= 0) ? void (0) : __assert_fail ("nStr2Len >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 302, __extension__ __PRETTY_FUNCTION__)); | |||
303 | assert(nShortenedLength >= 0)(static_cast <bool> (nShortenedLength >= 0) ? void ( 0) : __assert_fail ("nShortenedLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 303, __extension__ __PRETTY_FUNCTION__)); | |||
304 | const IMPL_RTL_STRCODE* pStr1End = pStr1 + nStr1Len; | |||
305 | const IMPL_RTL_STRCODE* pStr2End = pStr2 + nStr2Len; | |||
306 | while ( (nShortenedLength > 0) && | |||
307 | (pStr1 < pStr1End) && (pStr2 < pStr2End) ) | |||
308 | { | |||
309 | sal_Int32 nRet = rtl::compareIgnoreAsciiCase( | |||
310 | IMPL_RTL_USTRCODE(*pStr1), IMPL_RTL_USTRCODE(*pStr2)); | |||
311 | if ( nRet != 0 ) | |||
312 | return nRet; | |||
313 | ||||
314 | nShortenedLength--; | |||
315 | pStr1++; | |||
316 | pStr2++; | |||
317 | } | |||
318 | ||||
319 | if ( nShortenedLength <= 0 ) | |||
320 | return 0; | |||
321 | return nStr1Len - nStr2Len; | |||
322 | } | |||
323 | ||||
324 | /* ----------------------------------------------------------------------- */ | |||
325 | ||||
326 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( hashCode )( const IMPL_RTL_STRCODE* pStr ) | |||
327 | SAL_THROW_EXTERN_C()throw () | |||
328 | { | |||
329 | return IMPL_RTL_STRNAME( hashCode_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ) ); | |||
330 | } | |||
331 | ||||
332 | /* ----------------------------------------------------------------------- */ | |||
333 | ||||
334 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( hashCode_WithLength )( const IMPL_RTL_STRCODE* pStr, | |||
335 | sal_Int32 nLen ) | |||
336 | SAL_THROW_EXTERN_C()throw () | |||
337 | { | |||
338 | assert(nLen >= 0)(static_cast <bool> (nLen >= 0) ? void (0) : __assert_fail ("nLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 338, __extension__ __PRETTY_FUNCTION__)); | |||
339 | sal_uInt32 h = static_cast<sal_uInt32>(nLen); | |||
340 | while ( nLen > 0 ) | |||
341 | { | |||
342 | h = (h*37U) + IMPL_RTL_USTRCODE( *pStr ); | |||
343 | pStr++; | |||
344 | nLen--; | |||
345 | } | |||
346 | return static_cast<sal_Int32>(h); | |||
347 | } | |||
348 | ||||
349 | /* ----------------------------------------------------------------------- */ | |||
350 | ||||
351 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfChar )( const IMPL_RTL_STRCODE* pStr, | |||
352 | IMPL_RTL_STRCODE c ) | |||
353 | SAL_THROW_EXTERN_C()throw () | |||
354 | { | |||
355 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 355, __extension__ __PRETTY_FUNCTION__)); | |||
356 | #if !IMPL_RTL_IS_USTRING | |||
357 | // take advantage of builtin optimisations | |||
358 | const IMPL_RTL_STRCODE* p = strchr(pStr, c); | |||
359 | return p ? p - pStr : -1; | |||
360 | #else | |||
361 | if (sizeof(IMPL_RTL_STRCODE) == sizeof(wchar_t)) | |||
362 | { | |||
363 | // take advantage of builtin optimisations | |||
364 | wchar_t const * p = wcschr(reinterpret_cast<wchar_t const *>(pStr), static_cast<wchar_t>(c)); | |||
365 | return p ? p - reinterpret_cast<wchar_t const *>(pStr) : -1; | |||
366 | } | |||
367 | else | |||
368 | { | |||
369 | const IMPL_RTL_STRCODE* pTempStr = pStr; | |||
370 | while ( *pTempStr ) | |||
371 | { | |||
372 | if ( *pTempStr == c ) | |||
373 | return pTempStr-pStr; | |||
374 | ||||
375 | pTempStr++; | |||
376 | } | |||
377 | ||||
378 | return -1; | |||
379 | } | |||
380 | #endif | |||
381 | } | |||
382 | ||||
383 | /* ----------------------------------------------------------------------- */ | |||
384 | ||||
385 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfChar_WithLength )( const IMPL_RTL_STRCODE* pStr, | |||
386 | sal_Int32 nLen, | |||
387 | IMPL_RTL_STRCODE c ) | |||
388 | SAL_THROW_EXTERN_C()throw () | |||
389 | { | |||
390 | // assert(nLen >= 0); | |||
391 | #if !IMPL_RTL_IS_USTRING | |||
392 | // take advantage of builtin optimisations | |||
393 | IMPL_RTL_STRCODE* p = static_cast<IMPL_RTL_STRCODE*>(std::memchr(const_cast<IMPL_RTL_STRCODE *>(pStr), c, nLen)); | |||
394 | return p ? p - pStr : -1; | |||
395 | #else | |||
396 | const IMPL_RTL_STRCODE* pTempStr = pStr; | |||
397 | while ( nLen > 0 ) | |||
398 | { | |||
399 | if ( *pTempStr == c ) | |||
400 | return pTempStr-pStr; | |||
401 | ||||
402 | pTempStr++; | |||
403 | nLen--; | |||
404 | } | |||
405 | ||||
406 | return -1; | |||
407 | #endif | |||
408 | } | |||
409 | ||||
410 | /* ----------------------------------------------------------------------- */ | |||
411 | ||||
412 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( lastIndexOfChar )( const IMPL_RTL_STRCODE* pStr, | |||
413 | IMPL_RTL_STRCODE c ) | |||
414 | SAL_THROW_EXTERN_C()throw () | |||
415 | { | |||
416 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 416, __extension__ __PRETTY_FUNCTION__)); | |||
417 | #if !IMPL_RTL_IS_USTRING | |||
418 | // take advantage of builtin optimisations | |||
419 | const IMPL_RTL_STRCODE* p = strrchr(pStr, c); | |||
420 | return p ? p - pStr : -1; | |||
421 | #else | |||
422 | if (sizeof(IMPL_RTL_STRCODE) == sizeof(wchar_t)) | |||
423 | { | |||
424 | // take advantage of builtin optimisations | |||
425 | wchar_t const * p = wcsrchr(reinterpret_cast<wchar_t const *>(pStr), static_cast<wchar_t>(c)); | |||
426 | return p ? p - reinterpret_cast<wchar_t const *>(pStr) : -1; | |||
427 | } | |||
428 | else | |||
429 | { | |||
430 | return IMPL_RTL_STRNAME( lastIndexOfChar_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ), c ); | |||
431 | } | |||
432 | #endif | |||
433 | } | |||
434 | ||||
435 | /* ----------------------------------------------------------------------- */ | |||
436 | ||||
437 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( lastIndexOfChar_WithLength )( const IMPL_RTL_STRCODE* pStr, | |||
438 | sal_Int32 nLen, | |||
439 | IMPL_RTL_STRCODE c ) | |||
440 | SAL_THROW_EXTERN_C()throw () | |||
441 | { | |||
442 | assert(nLen >= 0)(static_cast <bool> (nLen >= 0) ? void (0) : __assert_fail ("nLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 442, __extension__ __PRETTY_FUNCTION__)); | |||
443 | pStr += nLen; | |||
444 | while ( nLen > 0 ) | |||
445 | { | |||
446 | nLen--; | |||
447 | pStr--; | |||
448 | ||||
449 | if ( *pStr == c ) | |||
450 | return nLen; | |||
451 | } | |||
452 | ||||
453 | return -1; | |||
454 | } | |||
455 | ||||
456 | /* ----------------------------------------------------------------------- */ | |||
457 | ||||
458 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfStr )( const IMPL_RTL_STRCODE* pStr, | |||
459 | const IMPL_RTL_STRCODE* pSubStr ) | |||
460 | SAL_THROW_EXTERN_C()throw () | |||
461 | { | |||
462 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 462, __extension__ __PRETTY_FUNCTION__)); | |||
463 | assert(pSubStr)(static_cast <bool> (pSubStr) ? void (0) : __assert_fail ("pSubStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 463, __extension__ __PRETTY_FUNCTION__)); | |||
464 | #if !IMPL_RTL_IS_USTRING | |||
465 | // take advantage of builtin optimisations | |||
466 | const IMPL_RTL_STRCODE* p = strstr(pStr, pSubStr); | |||
467 | return p ? p - pStr : -1; | |||
468 | #else | |||
469 | if (sizeof(IMPL_RTL_STRCODE) == sizeof(wchar_t)) | |||
470 | { | |||
471 | // take advantage of builtin optimisations | |||
472 | wchar_t const * p = wcsstr(reinterpret_cast<wchar_t const *>(pStr), reinterpret_cast<wchar_t const *>(pSubStr)); | |||
473 | return p ? p - reinterpret_cast<wchar_t const *>(pStr) : -1; | |||
474 | } | |||
475 | else | |||
476 | { | |||
477 | return IMPL_RTL_STRNAME( indexOfStr_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ), | |||
478 | pSubStr, IMPL_RTL_STRNAME( getLength )( pSubStr ) ); | |||
479 | } | |||
480 | #endif | |||
481 | } | |||
482 | ||||
483 | /* ----------------------------------------------------------------------- */ | |||
484 | ||||
485 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfStr_WithLength )( const IMPL_RTL_STRCODE* pStr, | |||
486 | sal_Int32 nStrLen, | |||
487 | const IMPL_RTL_STRCODE* pSubStr, | |||
488 | sal_Int32 nSubLen ) | |||
489 | SAL_THROW_EXTERN_C()throw () | |||
490 | { | |||
491 | assert(nStrLen >= 0)(static_cast <bool> (nStrLen >= 0) ? void (0) : __assert_fail ("nStrLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 491, __extension__ __PRETTY_FUNCTION__)); | |||
492 | assert(nSubLen >= 0)(static_cast <bool> (nSubLen >= 0) ? void (0) : __assert_fail ("nSubLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 492, __extension__ __PRETTY_FUNCTION__)); | |||
493 | /* faster search for a single character */ | |||
494 | if ( nSubLen < 2 ) | |||
495 | { | |||
496 | /* an empty SubString is always not findable */ | |||
497 | if ( nSubLen == 1 ) | |||
498 | { | |||
499 | IMPL_RTL_STRCODE c = *pSubStr; | |||
500 | const IMPL_RTL_STRCODE* pTempStr = pStr; | |||
501 | while ( nStrLen > 0 ) | |||
502 | { | |||
503 | if ( *pTempStr == c ) | |||
504 | return pTempStr-pStr; | |||
505 | ||||
506 | pTempStr++; | |||
507 | nStrLen--; | |||
508 | } | |||
509 | } | |||
510 | } | |||
511 | else | |||
512 | { | |||
513 | const IMPL_RTL_STRCODE* pTempStr = pStr; | |||
514 | while ( nStrLen > 0 ) | |||
515 | { | |||
516 | if ( *pTempStr == *pSubStr ) | |||
517 | { | |||
518 | /* Compare SubString */ | |||
519 | if ( nSubLen <= nStrLen ) | |||
520 | { | |||
521 | const IMPL_RTL_STRCODE* pTempStr1 = pTempStr; | |||
522 | const IMPL_RTL_STRCODE* pTempStr2 = pSubStr; | |||
523 | sal_Int32 nTempLen = nSubLen; | |||
524 | while ( nTempLen ) | |||
525 | { | |||
526 | if ( *pTempStr1 != *pTempStr2 ) | |||
527 | break; | |||
528 | ||||
529 | pTempStr1++; | |||
530 | pTempStr2++; | |||
531 | nTempLen--; | |||
532 | } | |||
533 | ||||
534 | if ( !nTempLen ) | |||
535 | return pTempStr-pStr; | |||
536 | } | |||
537 | else | |||
538 | break; | |||
539 | } | |||
540 | ||||
541 | nStrLen--; | |||
542 | pTempStr++; | |||
543 | } | |||
544 | } | |||
545 | ||||
546 | return -1; | |||
547 | } | |||
548 | ||||
549 | /* ----------------------------------------------------------------------- */ | |||
550 | ||||
551 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( lastIndexOfStr )( const IMPL_RTL_STRCODE* pStr, | |||
552 | const IMPL_RTL_STRCODE* pSubStr ) | |||
553 | SAL_THROW_EXTERN_C()throw () | |||
554 | { | |||
555 | return IMPL_RTL_STRNAME( lastIndexOfStr_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ), | |||
556 | pSubStr, IMPL_RTL_STRNAME( getLength )( pSubStr ) ); | |||
557 | } | |||
558 | ||||
559 | /* ----------------------------------------------------------------------- */ | |||
560 | ||||
561 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( lastIndexOfStr_WithLength )( const IMPL_RTL_STRCODE* pStr, | |||
562 | sal_Int32 nStrLen, | |||
563 | const IMPL_RTL_STRCODE* pSubStr, | |||
564 | sal_Int32 nSubLen ) | |||
565 | SAL_THROW_EXTERN_C()throw () | |||
566 | { | |||
567 | assert(nStrLen >= 0)(static_cast <bool> (nStrLen >= 0) ? void (0) : __assert_fail ("nStrLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 567, __extension__ __PRETTY_FUNCTION__)); | |||
568 | assert(nSubLen >= 0)(static_cast <bool> (nSubLen >= 0) ? void (0) : __assert_fail ("nSubLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 568, __extension__ __PRETTY_FUNCTION__)); | |||
569 | /* faster search for a single character */ | |||
570 | if ( nSubLen < 2 ) | |||
571 | { | |||
572 | /* an empty SubString is always not findable */ | |||
573 | if ( nSubLen == 1 ) | |||
574 | { | |||
575 | IMPL_RTL_STRCODE c = *pSubStr; | |||
576 | pStr += nStrLen; | |||
577 | while ( nStrLen > 0 ) | |||
578 | { | |||
579 | nStrLen--; | |||
580 | pStr--; | |||
581 | ||||
582 | if ( *pStr == c ) | |||
583 | return nStrLen; | |||
584 | } | |||
585 | } | |||
586 | } | |||
587 | else | |||
588 | { | |||
589 | pStr += nStrLen; | |||
590 | nStrLen -= nSubLen; | |||
591 | pStr -= nSubLen; | |||
592 | while ( nStrLen >= 0 ) | |||
593 | { | |||
594 | const IMPL_RTL_STRCODE* pTempStr1 = pStr; | |||
595 | const IMPL_RTL_STRCODE* pTempStr2 = pSubStr; | |||
596 | sal_Int32 nTempLen = nSubLen; | |||
597 | while ( nTempLen ) | |||
598 | { | |||
599 | if ( *pTempStr1 != *pTempStr2 ) | |||
600 | break; | |||
601 | ||||
602 | pTempStr1++; | |||
603 | pTempStr2++; | |||
604 | nTempLen--; | |||
605 | } | |||
606 | ||||
607 | if ( !nTempLen ) | |||
608 | return nStrLen; | |||
609 | ||||
610 | nStrLen--; | |||
611 | pStr--; | |||
612 | } | |||
613 | } | |||
614 | ||||
615 | return -1; | |||
616 | } | |||
617 | ||||
618 | /* ----------------------------------------------------------------------- */ | |||
619 | ||||
620 | void SAL_CALL IMPL_RTL_STRNAME( replaceChar )( IMPL_RTL_STRCODE* pStr, | |||
621 | IMPL_RTL_STRCODE cOld, | |||
622 | IMPL_RTL_STRCODE cNew ) | |||
623 | SAL_THROW_EXTERN_C()throw () | |||
624 | { | |||
625 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 625, __extension__ __PRETTY_FUNCTION__)); | |||
626 | while ( *pStr ) | |||
627 | { | |||
628 | if ( *pStr == cOld ) | |||
629 | *pStr = cNew; | |||
630 | ||||
631 | pStr++; | |||
632 | } | |||
633 | } | |||
634 | ||||
635 | /* ----------------------------------------------------------------------- */ | |||
636 | ||||
637 | void SAL_CALL IMPL_RTL_STRNAME( replaceChar_WithLength )( IMPL_RTL_STRCODE* pStr, | |||
638 | sal_Int32 nLen, | |||
639 | IMPL_RTL_STRCODE cOld, | |||
640 | IMPL_RTL_STRCODE cNew ) | |||
641 | SAL_THROW_EXTERN_C()throw () | |||
642 | { | |||
643 | assert(nLen >= 0)(static_cast <bool> (nLen >= 0) ? void (0) : __assert_fail ("nLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 643, __extension__ __PRETTY_FUNCTION__)); | |||
644 | while ( nLen > 0 ) | |||
645 | { | |||
646 | if ( *pStr == cOld ) | |||
647 | *pStr = cNew; | |||
648 | ||||
649 | pStr++; | |||
650 | nLen--; | |||
651 | } | |||
652 | } | |||
653 | ||||
654 | /* ----------------------------------------------------------------------- */ | |||
655 | ||||
656 | void SAL_CALL IMPL_RTL_STRNAME( toAsciiLowerCase )( IMPL_RTL_STRCODE* pStr ) | |||
657 | SAL_THROW_EXTERN_C()throw () | |||
658 | { | |||
659 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 659, __extension__ __PRETTY_FUNCTION__)); | |||
660 | while ( *pStr ) | |||
661 | { | |||
662 | *pStr = rtl::toAsciiLowerCase(IMPL_RTL_USTRCODE(*pStr)); | |||
663 | ||||
664 | pStr++; | |||
665 | } | |||
666 | } | |||
667 | ||||
668 | /* ----------------------------------------------------------------------- */ | |||
669 | ||||
670 | void SAL_CALL IMPL_RTL_STRNAME( toAsciiLowerCase_WithLength )( IMPL_RTL_STRCODE* pStr, | |||
671 | sal_Int32 nLen ) | |||
672 | SAL_THROW_EXTERN_C()throw () | |||
673 | { | |||
674 | assert(nLen >= 0)(static_cast <bool> (nLen >= 0) ? void (0) : __assert_fail ("nLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 674, __extension__ __PRETTY_FUNCTION__)); | |||
675 | while ( nLen > 0 ) | |||
676 | { | |||
677 | *pStr = rtl::toAsciiLowerCase(IMPL_RTL_USTRCODE(*pStr)); | |||
678 | ||||
679 | pStr++; | |||
680 | nLen--; | |||
681 | } | |||
682 | } | |||
683 | ||||
684 | /* ----------------------------------------------------------------------- */ | |||
685 | ||||
686 | void SAL_CALL IMPL_RTL_STRNAME( toAsciiUpperCase )( IMPL_RTL_STRCODE* pStr ) | |||
687 | SAL_THROW_EXTERN_C()throw () | |||
688 | { | |||
689 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 689, __extension__ __PRETTY_FUNCTION__)); | |||
690 | while ( *pStr ) | |||
691 | { | |||
692 | *pStr = rtl::toAsciiUpperCase(IMPL_RTL_USTRCODE(*pStr)); | |||
693 | ||||
694 | pStr++; | |||
695 | } | |||
696 | } | |||
697 | ||||
698 | /* ----------------------------------------------------------------------- */ | |||
699 | ||||
700 | void SAL_CALL IMPL_RTL_STRNAME( toAsciiUpperCase_WithLength )( IMPL_RTL_STRCODE* pStr, | |||
701 | sal_Int32 nLen ) | |||
702 | SAL_THROW_EXTERN_C()throw () | |||
703 | { | |||
704 | assert(nLen >= 0)(static_cast <bool> (nLen >= 0) ? void (0) : __assert_fail ("nLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 704, __extension__ __PRETTY_FUNCTION__)); | |||
705 | while ( nLen > 0 ) | |||
706 | { | |||
707 | *pStr = rtl::toAsciiUpperCase(IMPL_RTL_USTRCODE(*pStr)); | |||
708 | ||||
709 | pStr++; | |||
710 | nLen--; | |||
711 | } | |||
712 | } | |||
713 | ||||
714 | /* ----------------------------------------------------------------------- */ | |||
715 | ||||
716 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( trim )( IMPL_RTL_STRCODE* pStr ) | |||
717 | SAL_THROW_EXTERN_C()throw () | |||
718 | { | |||
719 | return IMPL_RTL_STRNAME( trim_WithLength )( pStr, IMPL_RTL_STRNAME( getLength )( pStr ) ); | |||
720 | } | |||
721 | ||||
722 | /* ----------------------------------------------------------------------- */ | |||
723 | ||||
724 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( trim_WithLength )( IMPL_RTL_STRCODE* pStr, sal_Int32 nLen ) | |||
725 | SAL_THROW_EXTERN_C()throw () | |||
726 | { | |||
727 | assert(nLen >= 0)(static_cast <bool> (nLen >= 0) ? void (0) : __assert_fail ("nLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 727, __extension__ __PRETTY_FUNCTION__)); | |||
728 | sal_Int32 nPreSpaces = 0; | |||
729 | sal_Int32 nPostSpaces = 0; | |||
730 | sal_Int32 nIndex = nLen-1; | |||
731 | ||||
732 | while ( (nPreSpaces < nLen) && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE(*(pStr+nPreSpaces)) ) ) | |||
733 | nPreSpaces++; | |||
734 | ||||
735 | while ( (nIndex > nPreSpaces) && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE(*(pStr+nIndex)) ) ) | |||
736 | { | |||
737 | nPostSpaces++; | |||
738 | nIndex--; | |||
739 | } | |||
740 | ||||
741 | if ( nPostSpaces ) | |||
742 | { | |||
743 | nLen -= nPostSpaces; | |||
744 | *(pStr+nLen) = 0; | |||
745 | } | |||
746 | ||||
747 | if ( nPreSpaces ) | |||
748 | { | |||
749 | nLen -= nPreSpaces; | |||
750 | memmove(pStr, pStr + nPreSpaces, nLen * sizeof(IMPL_RTL_STRCODE)); | |||
751 | pStr += nLen; | |||
752 | *pStr = 0; | |||
753 | } | |||
754 | ||||
755 | return nLen; | |||
756 | } | |||
757 | ||||
758 | /* ----------------------------------------------------------------------- */ | |||
759 | ||||
760 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfBoolean )( IMPL_RTL_STRCODE* pStr, sal_Bool b ) | |||
761 | SAL_THROW_EXTERN_C()throw () | |||
762 | { | |||
763 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 763, __extension__ __PRETTY_FUNCTION__)); | |||
764 | if ( b ) | |||
765 | { | |||
766 | *pStr = 't'; | |||
767 | pStr++; | |||
768 | *pStr = 'r'; | |||
769 | pStr++; | |||
770 | *pStr = 'u'; | |||
771 | pStr++; | |||
772 | *pStr = 'e'; | |||
773 | pStr++; | |||
774 | *pStr = 0; | |||
775 | return 4; | |||
776 | } | |||
777 | else | |||
778 | { | |||
779 | *pStr = 'f'; | |||
780 | pStr++; | |||
781 | *pStr = 'a'; | |||
782 | pStr++; | |||
783 | *pStr = 'l'; | |||
784 | pStr++; | |||
785 | *pStr = 's'; | |||
786 | pStr++; | |||
787 | *pStr = 'e'; | |||
788 | pStr++; | |||
789 | *pStr = 0; | |||
790 | return 5; | |||
791 | } | |||
792 | } | |||
793 | ||||
794 | /* ----------------------------------------------------------------------- */ | |||
795 | ||||
796 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfChar )( IMPL_RTL_STRCODE* pStr, | |||
797 | IMPL_RTL_STRCODE c ) | |||
798 | SAL_THROW_EXTERN_C()throw () | |||
799 | { | |||
800 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 800, __extension__ __PRETTY_FUNCTION__)); | |||
801 | *pStr++ = c; | |||
802 | *pStr = 0; | |||
803 | return 1; | |||
804 | } | |||
805 | ||||
806 | /* ----------------------------------------------------------------------- */ | |||
807 | ||||
808 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfInt32 )( IMPL_RTL_STRCODE* pStr, | |||
809 | sal_Int32 n, | |||
810 | sal_Int16 nRadix ) | |||
811 | SAL_THROW_EXTERN_C()throw () | |||
812 | { | |||
813 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 813, __extension__ __PRETTY_FUNCTION__)); | |||
814 | assert( nRadix >= RTL_STR_MIN_RADIX && nRadix <= RTL_STR_MAX_RADIX )(static_cast <bool> (nRadix >= 2 && nRadix <= 36) ? void (0) : __assert_fail ("nRadix >= RTL_STR_MIN_RADIX && nRadix <= RTL_STR_MAX_RADIX" , "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx", 814 , __extension__ __PRETTY_FUNCTION__)); | |||
815 | char aBuf[RTL_STR_MAX_VALUEOFINT3233]; | |||
816 | char* pBuf = aBuf; | |||
817 | sal_Int32 nLen = 0; | |||
818 | sal_uInt32 nValue; | |||
819 | ||||
820 | /* Radix must be valid */ | |||
821 | if ( (nRadix < RTL_STR_MIN_RADIX2) || (nRadix > RTL_STR_MAX_RADIX36) ) | |||
822 | nRadix = 10; | |||
823 | ||||
824 | /* is value negative */ | |||
825 | if ( n < 0 ) | |||
826 | { | |||
827 | *pStr = '-'; | |||
828 | pStr++; | |||
829 | nLen++; | |||
830 | nValue = n == SAL_MIN_INT32((sal_Int32) (-0x7FFFFFFF - 1)) ? static_cast<sal_uInt32>(n) : -n; | |||
831 | } | |||
832 | else | |||
833 | nValue = n; | |||
834 | ||||
835 | /* create a recursive buffer with all values, except the last one */ | |||
836 | do | |||
837 | { | |||
838 | char nDigit = static_cast<char>(nValue % nRadix); | |||
839 | nValue /= nRadix; | |||
840 | if ( nDigit > 9 ) | |||
841 | *pBuf = (nDigit-10) + 'a'; | |||
842 | else | |||
843 | *pBuf = (nDigit + '0' ); | |||
844 | pBuf++; | |||
845 | } | |||
846 | while ( nValue > 0 ); | |||
847 | ||||
848 | /* copy the values in the right direction into the destination buffer */ | |||
849 | do | |||
850 | { | |||
851 | pBuf--; | |||
852 | *pStr = *pBuf; | |||
853 | pStr++; | |||
854 | nLen++; | |||
855 | } | |||
856 | while ( pBuf != aBuf ); | |||
857 | *pStr = 0; | |||
858 | ||||
859 | return nLen; | |||
860 | } | |||
861 | ||||
862 | /* ----------------------------------------------------------------------- */ | |||
863 | ||||
864 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfInt64 )( IMPL_RTL_STRCODE* pStr, | |||
865 | sal_Int64 n, | |||
866 | sal_Int16 nRadix ) | |||
867 | SAL_THROW_EXTERN_C()throw () | |||
868 | { | |||
869 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 869, __extension__ __PRETTY_FUNCTION__)); | |||
870 | assert( nRadix >= RTL_STR_MIN_RADIX && nRadix <= RTL_STR_MAX_RADIX )(static_cast <bool> (nRadix >= 2 && nRadix <= 36) ? void (0) : __assert_fail ("nRadix >= RTL_STR_MIN_RADIX && nRadix <= RTL_STR_MAX_RADIX" , "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx", 870 , __extension__ __PRETTY_FUNCTION__)); | |||
871 | char aBuf[RTL_STR_MAX_VALUEOFINT6465]; | |||
872 | char* pBuf = aBuf; | |||
873 | sal_Int32 nLen = 0; | |||
874 | sal_uInt64 nValue; | |||
875 | ||||
876 | /* Radix must be valid */ | |||
877 | if ( (nRadix < RTL_STR_MIN_RADIX2) || (nRadix > RTL_STR_MAX_RADIX36) ) | |||
878 | nRadix = 10; | |||
879 | ||||
880 | /* is value negative */ | |||
881 | if ( n < 0 ) | |||
882 | { | |||
883 | *pStr = '-'; | |||
884 | pStr++; | |||
885 | nLen++; | |||
886 | nValue = n == SAL_MIN_INT64((sal_Int64) (-0x7FFFFFFFFFFFFFFFl - 1)) ? static_cast<sal_uInt64>(n) : -n; | |||
887 | } | |||
888 | else | |||
889 | nValue = n; | |||
890 | ||||
891 | /* create a recursive buffer with all values, except the last one */ | |||
892 | do | |||
893 | { | |||
894 | char nDigit = static_cast<char>(nValue % nRadix); | |||
895 | nValue /= nRadix; | |||
896 | if ( nDigit > 9 ) | |||
897 | *pBuf = (nDigit-10) + 'a'; | |||
898 | else | |||
899 | *pBuf = (nDigit + '0' ); | |||
900 | pBuf++; | |||
901 | } | |||
902 | while ( nValue > 0 ); | |||
903 | ||||
904 | /* copy the values in the right direction into the destination buffer */ | |||
905 | do | |||
906 | { | |||
907 | pBuf--; | |||
908 | *pStr = *pBuf; | |||
909 | pStr++; | |||
910 | nLen++; | |||
911 | } | |||
912 | while ( pBuf != aBuf ); | |||
913 | *pStr = 0; | |||
914 | ||||
915 | return nLen; | |||
916 | } | |||
917 | ||||
918 | /* ----------------------------------------------------------------------- */ | |||
919 | ||||
920 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfUInt64 )( IMPL_RTL_STRCODE* pStr, | |||
921 | sal_uInt64 n, | |||
922 | sal_Int16 nRadix ) | |||
923 | SAL_THROW_EXTERN_C()throw () | |||
924 | { | |||
925 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 925, __extension__ __PRETTY_FUNCTION__)); | |||
926 | assert( nRadix >= RTL_STR_MIN_RADIX && nRadix <= RTL_STR_MAX_RADIX )(static_cast <bool> (nRadix >= 2 && nRadix <= 36) ? void (0) : __assert_fail ("nRadix >= RTL_STR_MIN_RADIX && nRadix <= RTL_STR_MAX_RADIX" , "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx", 926 , __extension__ __PRETTY_FUNCTION__)); | |||
927 | char aBuf[RTL_STR_MAX_VALUEOFUINT6465]; | |||
928 | char* pBuf = aBuf; | |||
929 | sal_Int32 nLen = 0; | |||
930 | sal_uInt64 nValue; | |||
931 | ||||
932 | /* Radix must be valid */ | |||
933 | if ( (nRadix < RTL_STR_MIN_RADIX2) || (nRadix > RTL_STR_MAX_RADIX36) ) | |||
934 | nRadix = 10; | |||
935 | ||||
936 | nValue = n; | |||
937 | ||||
938 | /* create a recursive buffer with all values, except the last one */ | |||
939 | do | |||
940 | { | |||
941 | char nDigit = static_cast<char>(nValue % nRadix); | |||
942 | nValue /= nRadix; | |||
943 | if ( nDigit > 9 ) | |||
944 | *pBuf = (nDigit-10) + 'a'; | |||
945 | else | |||
946 | *pBuf = (nDigit + '0' ); | |||
947 | pBuf++; | |||
948 | } | |||
949 | while ( nValue > 0 ); | |||
950 | ||||
951 | /* copy the values in the right direction into the destination buffer */ | |||
952 | do | |||
953 | { | |||
954 | pBuf--; | |||
955 | *pStr = *pBuf; | |||
956 | pStr++; | |||
957 | nLen++; | |||
958 | } | |||
959 | while ( pBuf != aBuf ); | |||
960 | *pStr = 0; | |||
961 | ||||
962 | return nLen; | |||
963 | } | |||
964 | ||||
965 | /* ----------------------------------------------------------------------- */ | |||
966 | ||||
967 | sal_Bool SAL_CALL IMPL_RTL_STRNAME( toBoolean )( const IMPL_RTL_STRCODE* pStr ) | |||
968 | SAL_THROW_EXTERN_C()throw () | |||
969 | { | |||
970 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 970, __extension__ __PRETTY_FUNCTION__)); | |||
971 | if ( *pStr == '1' ) | |||
972 | return true; | |||
973 | ||||
974 | if ( (*pStr == 'T') || (*pStr == 't') ) | |||
975 | { | |||
976 | pStr++; | |||
977 | if ( (*pStr == 'R') || (*pStr == 'r') ) | |||
978 | { | |||
979 | pStr++; | |||
980 | if ( (*pStr == 'U') || (*pStr == 'u') ) | |||
981 | { | |||
982 | pStr++; | |||
983 | if ( (*pStr == 'E') || (*pStr == 'e') ) | |||
984 | return true; | |||
985 | } | |||
986 | } | |||
987 | } | |||
988 | ||||
989 | return false; | |||
990 | } | |||
991 | ||||
992 | /* ----------------------------------------------------------------------- */ | |||
993 | namespace { | |||
994 | template<typename T, typename U> T IMPL_RTL_STRNAME( toInt_WithLength )( const IMPL_RTL_STRCODE* pStr, | |||
995 | sal_Int16 nRadix, | |||
996 | sal_Int32 nStrLength ) | |||
997 | { | |||
998 | static_assert(std::numeric_limits<T>::is_signed, "is signed"); | |||
999 | assert( nRadix >= RTL_STR_MIN_RADIX && nRadix <= RTL_STR_MAX_RADIX )(static_cast <bool> (nRadix >= 2 && nRadix <= 36) ? void (0) : __assert_fail ("nRadix >= RTL_STR_MIN_RADIX && nRadix <= RTL_STR_MAX_RADIX" , "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx", 999 , __extension__ __PRETTY_FUNCTION__)); | |||
1000 | assert( nStrLength >= 0 )(static_cast <bool> (nStrLength >= 0) ? void (0) : __assert_fail ("nStrLength >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1000, __extension__ __PRETTY_FUNCTION__)); | |||
1001 | bool bNeg; | |||
1002 | sal_Int16 nDigit; | |||
1003 | U n = 0; | |||
1004 | const IMPL_RTL_STRCODE* pEnd = pStr + nStrLength; | |||
1005 | ||||
1006 | if ( (nRadix < RTL_STR_MIN_RADIX2) || (nRadix > RTL_STR_MAX_RADIX36) ) | |||
1007 | nRadix = 10; | |||
1008 | ||||
1009 | /* Skip whitespaces */ | |||
1010 | while ( pStr != pEnd && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE( *pStr ) ) ) | |||
1011 | pStr++; | |||
1012 | ||||
1013 | if ( *pStr == '-' ) | |||
1014 | { | |||
1015 | bNeg = true; | |||
1016 | pStr++; | |||
1017 | } | |||
1018 | else | |||
1019 | { | |||
1020 | if ( *pStr == '+' ) | |||
1021 | pStr++; | |||
1022 | bNeg = false; | |||
1023 | } | |||
1024 | ||||
1025 | T nDiv; | |||
1026 | sal_Int16 nMod; | |||
1027 | if ( bNeg ) | |||
1028 | { | |||
1029 | nDiv = std::numeric_limits<T>::min() / nRadix; | |||
1030 | nMod = std::numeric_limits<T>::min() % nRadix; | |||
1031 | // Cater for C++03 implementations that round the quotient down | |||
1032 | // instead of truncating towards zero as mandated by C++11: | |||
1033 | if ( nMod > 0 ) | |||
1034 | { | |||
1035 | --nDiv; | |||
1036 | nMod -= nRadix; | |||
1037 | } | |||
1038 | nDiv = -nDiv; | |||
1039 | nMod = -nMod; | |||
1040 | } | |||
1041 | else | |||
1042 | { | |||
1043 | nDiv = std::numeric_limits<T>::max() / nRadix; | |||
1044 | nMod = std::numeric_limits<T>::max() % nRadix; | |||
1045 | } | |||
1046 | ||||
1047 | while ( pStr != pEnd ) | |||
1048 | { | |||
1049 | nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix ); | |||
1050 | if ( nDigit < 0 ) | |||
1051 | break; | |||
1052 | assert(nDiv > 0)(static_cast <bool> (nDiv > 0) ? void (0) : __assert_fail ("nDiv > 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1052, __extension__ __PRETTY_FUNCTION__)); | |||
1053 | if( static_cast<U>( nMod < nDigit ? nDiv-1 : nDiv ) < n ) | |||
1054 | return 0; | |||
1055 | ||||
1056 | n *= nRadix; | |||
1057 | n += nDigit; | |||
1058 | ||||
1059 | pStr++; | |||
1060 | } | |||
1061 | ||||
1062 | if ( bNeg ) | |||
1063 | return n == static_cast<U>(std::numeric_limits<T>::min()) | |||
1064 | ? std::numeric_limits<T>::min() : -static_cast<T>(n); | |||
1065 | else | |||
1066 | return static_cast<T>(n); | |||
1067 | } | |||
1068 | } | |||
1069 | ||||
1070 | sal_Int32 SAL_CALL IMPL_RTL_STRNAME( toInt32 )( const IMPL_RTL_STRCODE* pStr, | |||
1071 | sal_Int16 nRadix ) | |||
1072 | SAL_THROW_EXTERN_C()throw () | |||
1073 | { | |||
1074 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1074, __extension__ __PRETTY_FUNCTION__)); | |||
1075 | return IMPL_RTL_STRNAME( toInt_WithLength )<sal_Int32, sal_uInt32>(pStr, nRadix, IMPL_RTL_STRNAME( getLength )(pStr)); | |||
1076 | } | |||
1077 | ||||
1078 | sal_Int64 SAL_CALL IMPL_RTL_STRNAME( toInt64 )( const IMPL_RTL_STRCODE* pStr, | |||
1079 | sal_Int16 nRadix ) | |||
1080 | SAL_THROW_EXTERN_C()throw () | |||
1081 | { | |||
1082 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1082, __extension__ __PRETTY_FUNCTION__)); | |||
1083 | return IMPL_RTL_STRNAME( toInt_WithLength )<sal_Int64, sal_uInt64>(pStr, nRadix, IMPL_RTL_STRNAME( getLength )(pStr)); | |||
1084 | } | |||
1085 | ||||
1086 | sal_Int64 SAL_CALL IMPL_RTL_STRNAME( toInt64_WithLength )( const IMPL_RTL_STRCODE* pStr, | |||
1087 | sal_Int16 nRadix, | |||
1088 | sal_Int32 nStrLength) | |||
1089 | SAL_THROW_EXTERN_C()throw () | |||
1090 | { | |||
1091 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1091, __extension__ __PRETTY_FUNCTION__)); | |||
1092 | return IMPL_RTL_STRNAME( toInt_WithLength )<sal_Int64, sal_uInt64>(pStr, nRadix, nStrLength); | |||
1093 | } | |||
1094 | ||||
1095 | /* ----------------------------------------------------------------------- */ | |||
1096 | namespace { | |||
1097 | template <typename T> T IMPL_RTL_STRNAME( toUInt )( const IMPL_RTL_STRCODE* pStr, | |||
1098 | sal_Int16 nRadix ) | |||
1099 | { | |||
1100 | static_assert(!std::numeric_limits<T>::is_signed, "is not signed"); | |||
1101 | assert( nRadix >= RTL_STR_MIN_RADIX && nRadix <= RTL_STR_MAX_RADIX )(static_cast <bool> (nRadix >= 2 && nRadix <= 36) ? void (0) : __assert_fail ("nRadix >= RTL_STR_MIN_RADIX && nRadix <= RTL_STR_MAX_RADIX" , "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx", 1101 , __extension__ __PRETTY_FUNCTION__)); | |||
1102 | sal_Int16 nDigit; | |||
1103 | T n = 0; | |||
1104 | ||||
1105 | if ( (nRadix < RTL_STR_MIN_RADIX2) || (nRadix > RTL_STR_MAX_RADIX36) ) | |||
1106 | nRadix = 10; | |||
1107 | ||||
1108 | /* Skip whitespaces */ | |||
1109 | while ( *pStr && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE( *pStr ) ) ) | |||
1110 | ++pStr; | |||
1111 | ||||
1112 | // skip optional explicit sign | |||
1113 | if ( *pStr == '+' ) | |||
1114 | ++pStr; | |||
1115 | ||||
1116 | T nDiv = std::numeric_limits<T>::max() / nRadix; | |||
1117 | sal_Int16 nMod = std::numeric_limits<T>::max() % nRadix; | |||
1118 | while ( *pStr ) | |||
1119 | { | |||
1120 | nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix ); | |||
1121 | if ( nDigit < 0 ) | |||
1122 | break; | |||
1123 | if( ( nMod < nDigit ? nDiv-1 : nDiv ) < n ) | |||
1124 | return 0; | |||
1125 | ||||
1126 | n *= nRadix; | |||
1127 | n += nDigit; | |||
1128 | ||||
1129 | ++pStr; | |||
1130 | } | |||
1131 | ||||
1132 | return n; | |||
1133 | } | |||
1134 | } | |||
1135 | ||||
1136 | sal_uInt32 SAL_CALL IMPL_RTL_STRNAME( toUInt32 )( const IMPL_RTL_STRCODE* pStr, | |||
1137 | sal_Int16 nRadix ) | |||
1138 | SAL_THROW_EXTERN_C()throw () | |||
1139 | { | |||
1140 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1140, __extension__ __PRETTY_FUNCTION__)); | |||
1141 | return IMPL_RTL_STRNAME( toUInt )<sal_uInt32>(pStr, nRadix); | |||
1142 | } | |||
1143 | ||||
1144 | sal_uInt64 SAL_CALL IMPL_RTL_STRNAME( toUInt64 )( const IMPL_RTL_STRCODE* pStr, | |||
1145 | sal_Int16 nRadix ) | |||
1146 | SAL_THROW_EXTERN_C()throw () | |||
1147 | { | |||
1148 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1148, __extension__ __PRETTY_FUNCTION__)); | |||
1149 | return IMPL_RTL_STRNAME( toUInt )<sal_uInt64>(pStr, nRadix); | |||
1150 | } | |||
1151 | ||||
1152 | /* ======================================================================= */ | |||
1153 | /* Internal String-Class help functions */ | |||
1154 | /* ======================================================================= */ | |||
1155 | ||||
1156 | IMPL_RTL_STRINGDATA* IMPL_RTL_STRINGNAME( ImplAlloc )( sal_Int32 nLen ) | |||
1157 | { | |||
1158 | IMPL_RTL_STRINGDATA * pData | |||
1159 | = (sal::static_int_cast< sal_uInt32 >(nLen) | |||
1160 | <= ((SAL_MAX_UINT32((sal_uInt32) 0xFFFFFFFF) - sizeof (IMPL_RTL_STRINGDATA)) | |||
1161 | / sizeof (IMPL_RTL_STRCODE))) | |||
1162 | ? static_cast<IMPL_RTL_STRINGDATA *>(rtl_allocateString( | |||
1163 | sizeof (IMPL_RTL_STRINGDATA) + nLen * sizeof (IMPL_RTL_STRCODE))) | |||
1164 | : nullptr; | |||
1165 | if (pData != nullptr) { | |||
1166 | pData->refCount = 1; | |||
1167 | pData->length = nLen; | |||
1168 | pData->buffer[nLen] = 0; | |||
1169 | } | |||
1170 | return pData; | |||
1171 | } | |||
1172 | ||||
1173 | /* ----------------------------------------------------------------------- */ | |||
1174 | ||||
1175 | static IMPL_RTL_STRCODE* IMPL_RTL_STRINGNAME( ImplNewCopy )( IMPL_RTL_STRINGDATA** ppThis, | |||
1176 | IMPL_RTL_STRINGDATA* pStr, | |||
1177 | sal_Int32 nCount ) | |||
1178 | { | |||
1179 | assert(nCount >= 0)(static_cast <bool> (nCount >= 0) ? void (0) : __assert_fail ("nCount >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1179, __extension__ __PRETTY_FUNCTION__)); | |||
1180 | IMPL_RTL_STRCODE* pDest; | |||
1181 | const IMPL_RTL_STRCODE* pSrc; | |||
1182 | IMPL_RTL_STRINGDATA* pData = IMPL_RTL_STRINGNAME( ImplAlloc )( pStr->length ); | |||
1183 | OSL_ASSERT(pData != nullptr)do { if (true && (!(pData != nullptr))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1183" ": "), "OSL_ASSERT: %s", "pData != nullptr"); } } while (false); | |||
1184 | ||||
1185 | pDest = pData->buffer; | |||
1186 | pSrc = pStr->buffer; | |||
1187 | ||||
1188 | memcpy( pDest, pSrc, nCount * sizeof(IMPL_RTL_STRCODE)); | |||
1189 | ||||
1190 | *ppThis = pData; | |||
1191 | ||||
1192 | RTL_LOG_STRING_NEW( pData )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (pData) == 14 || __builtin_classify_type (pData) == 5) && __sdt_type<__typeof (pData)>:: __sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (pData ) == 14 || __builtin_classify_type (pData) == 5) ? sizeof (void *) : sizeof (pData))), [_SDT_A1] "nor" ((pData)), [_SDT_S2] "n" (((!(__builtin_classify_type ((pData)->refCount) == 14 || __builtin_classify_type ((pData)->refCount) == 5) && __sdt_type<__typeof ((pData)->refCount)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((pData)->refCount ) == 14 || __builtin_classify_type ((pData)->refCount) == 5 ) ? sizeof (void *) : sizeof ((pData)->refCount))), [_SDT_A2 ] "nor" (((pData)->refCount)), [_SDT_S3] "n" (((!(__builtin_classify_type ((pData)->length) == 14 || __builtin_classify_type ((pData )->length) == 5) && __sdt_type<__typeof ((pData )->length)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((pData)->length) == 14 || __builtin_classify_type ((pData )->length) == 5) ? sizeof (void *) : sizeof ((pData)->length ))), [_SDT_A3] "nor" (((pData)->length)), [_SDT_S4] "n" (( (!(__builtin_classify_type ((pData)->buffer) == 14 || __builtin_classify_type ((pData)->buffer) == 5) && __sdt_type<__typeof ((pData)->buffer)>::__sdt_signed) ? 1 : -1) * (int) (( __builtin_classify_type ((pData)->buffer) == 14 || __builtin_classify_type ((pData)->buffer) == 5) ? sizeof (void *) : sizeof ((pData )->buffer))), [_SDT_A4] "nor" (((pData)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
1193 | return pDest + nCount; | |||
1194 | } | |||
1195 | ||||
1196 | /* ======================================================================= */ | |||
1197 | /* String-Class functions */ | |||
1198 | /* ======================================================================= */ | |||
1199 | ||||
1200 | namespace { | |||
1201 | ||||
1202 | void IMPL_RTL_ACQUIRE(IMPL_RTL_STRINGDATA * pThis) | |||
1203 | { | |||
1204 | if (!SAL_STRING_IS_STATIC (pThis)((pThis)->refCount & 0x40000000)) | |||
1205 | osl_atomic_increment( &((pThis)->refCount) )__sync_add_and_fetch((&((pThis)->refCount)), 1); | |||
1206 | } | |||
1207 | ||||
1208 | } | |||
1209 | ||||
1210 | /* ----------------------------------------------------------------------- */ | |||
1211 | ||||
1212 | void SAL_CALL IMPL_RTL_STRINGNAME( acquire )( IMPL_RTL_STRINGDATA* pThis ) | |||
1213 | SAL_THROW_EXTERN_C()throw () | |||
1214 | { | |||
1215 | IMPL_RTL_ACQUIRE( pThis ); | |||
1216 | } | |||
1217 | ||||
1218 | /* ----------------------------------------------------------------------- */ | |||
1219 | ||||
1220 | void SAL_CALL IMPL_RTL_STRINGNAME( release )( IMPL_RTL_STRINGDATA* pThis ) | |||
1221 | SAL_THROW_EXTERN_C()throw () | |||
1222 | { | |||
1223 | if (SAL_UNLIKELY(SAL_STRING_IS_STATIC (pThis))__builtin_expect(__extension__ ({ int sal_boolean_var_; if (( ((pThis)->refCount & 0x40000000))) sal_boolean_var_ = 1 ; else sal_boolean_var_ = 0; sal_boolean_var_; }), 0)) | |||
1224 | return; | |||
1225 | ||||
1226 | /* OString doesn't have an 'intern' */ | |||
1227 | #if IMPL_RTL_IS_USTRING | |||
1228 | if (SAL_STRING_IS_INTERN (pThis)((pThis)->refCount & 0x80000000)) | |||
1229 | { | |||
1230 | internRelease (pThis); | |||
1231 | return; | |||
1232 | } | |||
1233 | #endif | |||
1234 | ||||
1235 | if ( !osl_atomic_decrement( &(pThis->refCount) )__sync_sub_and_fetch((&(pThis->refCount)), 1) ) | |||
1236 | { | |||
1237 | RTL_LOG_STRING_DELETE( pThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"delete_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (pThis) == 14 || __builtin_classify_type (pThis) == 5) && __sdt_type<__typeof (pThis)>:: __sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type (pThis ) == 14 || __builtin_classify_type (pThis) == 5) ? sizeof (void *) : sizeof (pThis))), [_SDT_A1] "nor" ((pThis)), [_SDT_S2] "n" (((!(__builtin_classify_type ((pThis)->refCount) == 14 || __builtin_classify_type ((pThis)->refCount) == 5) && __sdt_type<__typeof ((pThis)->refCount)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((pThis)->refCount ) == 14 || __builtin_classify_type ((pThis)->refCount) == 5 ) ? sizeof (void *) : sizeof ((pThis)->refCount))), [_SDT_A2 ] "nor" (((pThis)->refCount)), [_SDT_S3] "n" (((!(__builtin_classify_type ((pThis)->length) == 14 || __builtin_classify_type ((pThis )->length) == 5) && __sdt_type<__typeof ((pThis )->length)>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((pThis)->length) == 14 || __builtin_classify_type ((pThis )->length) == 5) ? sizeof (void *) : sizeof ((pThis)->length ))), [_SDT_A3] "nor" (((pThis)->length)), [_SDT_S4] "n" (( (!(__builtin_classify_type ((pThis)->buffer) == 14 || __builtin_classify_type ((pThis)->buffer) == 5) && __sdt_type<__typeof ((pThis)->buffer)>::__sdt_signed) ? 1 : -1) * (int) (( __builtin_classify_type ((pThis)->buffer) == 14 || __builtin_classify_type ((pThis)->buffer) == 5) ? sizeof (void *) : sizeof ((pThis )->buffer))), [_SDT_A4] "nor" (((pThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
1238 | rtl_freeString( pThis ); | |||
1239 | } | |||
1240 | } | |||
1241 | ||||
1242 | /* ----------------------------------------------------------------------- */ | |||
1243 | ||||
1244 | void SAL_CALL IMPL_RTL_STRINGNAME( new )( IMPL_RTL_STRINGDATA** ppThis ) | |||
1245 | SAL_THROW_EXTERN_C()throw () | |||
1246 | { | |||
1247 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1247, __extension__ __PRETTY_FUNCTION__)); | |||
1248 | if ( *ppThis) | |||
1249 | IMPL_RTL_STRINGNAME( release )( *ppThis ); | |||
1250 | ||||
1251 | *ppThis = const_cast<IMPL_RTL_STRINGDATA*>(&IMPL_RTL_EMPTYSTRING); | |||
1252 | } | |||
1253 | ||||
1254 | /* ----------------------------------------------------------------------- */ | |||
1255 | ||||
1256 | IMPL_RTL_STRINGDATA* SAL_CALL IMPL_RTL_STRINGNAME( alloc )( sal_Int32 nLen ) | |||
1257 | SAL_THROW_EXTERN_C()throw () | |||
1258 | { | |||
1259 | assert(nLen >= 0)(static_cast <bool> (nLen >= 0) ? void (0) : __assert_fail ("nLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1259, __extension__ __PRETTY_FUNCTION__)); | |||
1260 | return IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); | |||
1261 | } | |||
1262 | ||||
1263 | /* ----------------------------------------------------------------------- */ | |||
1264 | ||||
1265 | void SAL_CALL IMPL_RTL_STRINGNAME( new_WithLength )( IMPL_RTL_STRINGDATA** ppThis, sal_Int32 nLen ) | |||
1266 | SAL_THROW_EXTERN_C()throw () | |||
1267 | { | |||
1268 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1268, __extension__ __PRETTY_FUNCTION__)); | |||
1269 | assert(nLen >= 0)(static_cast <bool> (nLen >= 0) ? void (0) : __assert_fail ("nLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1269, __extension__ __PRETTY_FUNCTION__)); | |||
1270 | if ( nLen <= 0 ) | |||
1271 | IMPL_RTL_STRINGNAME( new )( ppThis ); | |||
1272 | else | |||
1273 | { | |||
1274 | if ( *ppThis) | |||
1275 | IMPL_RTL_STRINGNAME( release )( *ppThis ); | |||
1276 | ||||
1277 | *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); | |||
1278 | OSL_ASSERT(*ppThis != nullptr)do { if (true && (!(*ppThis != nullptr))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1278" ": "), "OSL_ASSERT: %s", "*ppThis != nullptr"); } } while (false); | |||
1279 | (*ppThis)->length = 0; | |||
1280 | ||||
1281 | IMPL_RTL_STRCODE* pTempStr = (*ppThis)->buffer; | |||
1282 | memset(pTempStr, 0, nLen*sizeof(IMPL_RTL_STRCODE)); | |||
1283 | } | |||
1284 | } | |||
1285 | ||||
1286 | /* ----------------------------------------------------------------------- */ | |||
1287 | ||||
1288 | void SAL_CALL IMPL_RTL_STRINGNAME( newFromString )( IMPL_RTL_STRINGDATA** ppThis, | |||
1289 | const IMPL_RTL_STRINGDATA* pStr ) | |||
1290 | SAL_THROW_EXTERN_C()throw () | |||
1291 | { | |||
1292 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1292, __extension__ __PRETTY_FUNCTION__)); | |||
1293 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1293, __extension__ __PRETTY_FUNCTION__)); | |||
1294 | IMPL_RTL_STRINGDATA* pOrg; | |||
1295 | ||||
1296 | if ( !pStr->length ) | |||
1297 | { | |||
1298 | IMPL_RTL_STRINGNAME( new )( ppThis ); | |||
1299 | return; | |||
1300 | } | |||
1301 | ||||
1302 | pOrg = *ppThis; | |||
1303 | *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( pStr->length ); | |||
1304 | OSL_ASSERT(*ppThis != nullptr)do { if (true && (!(*ppThis != nullptr))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1304" ": "), "OSL_ASSERT: %s", "*ppThis != nullptr"); } } while (false); | |||
1305 | rtl_str_ImplCopy( (*ppThis)->buffer, pStr->buffer, pStr->length ); | |||
1306 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
1307 | ||||
1308 | /* must be done last, if pStr == *ppThis */ | |||
1309 | if ( pOrg ) | |||
1310 | IMPL_RTL_STRINGNAME( release )( pOrg ); | |||
1311 | } | |||
1312 | ||||
1313 | /* ----------------------------------------------------------------------- */ | |||
1314 | ||||
1315 | void SAL_CALL IMPL_RTL_STRINGNAME( newFromStr )( IMPL_RTL_STRINGDATA** ppThis, | |||
1316 | const IMPL_RTL_STRCODE* pCharStr ) | |||
1317 | SAL_THROW_EXTERN_C()throw () | |||
1318 | { | |||
1319 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1319, __extension__ __PRETTY_FUNCTION__)); | |||
1320 | IMPL_RTL_STRINGDATA* pOrg; | |||
1321 | sal_Int32 nLen; | |||
1322 | ||||
1323 | if ( pCharStr ) | |||
1324 | { | |||
1325 | nLen = IMPL_RTL_STRNAME( getLength )( pCharStr ); | |||
1326 | } | |||
1327 | else | |||
1328 | nLen = 0; | |||
1329 | ||||
1330 | if ( !nLen ) | |||
1331 | { | |||
1332 | IMPL_RTL_STRINGNAME( new )( ppThis ); | |||
1333 | return; | |||
1334 | } | |||
1335 | ||||
1336 | pOrg = *ppThis; | |||
1337 | *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); | |||
1338 | OSL_ASSERT(*ppThis != nullptr)do { if (true && (!(*ppThis != nullptr))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1338" ": "), "OSL_ASSERT: %s", "*ppThis != nullptr"); } } while (false); | |||
1339 | rtl_str_ImplCopy( (*ppThis)->buffer, pCharStr, nLen ); | |||
1340 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
1341 | ||||
1342 | /* must be done last, if pCharStr == *ppThis */ | |||
1343 | if ( pOrg ) | |||
1344 | IMPL_RTL_STRINGNAME( release )( pOrg ); | |||
1345 | } | |||
1346 | ||||
1347 | /* ----------------------------------------------------------------------- */ | |||
1348 | ||||
1349 | void SAL_CALL IMPL_RTL_STRINGNAME( newFromStr_WithLength )( IMPL_RTL_STRINGDATA** ppThis, | |||
1350 | const IMPL_RTL_STRCODE* pCharStr, | |||
1351 | sal_Int32 nLen ) | |||
1352 | SAL_THROW_EXTERN_C()throw () | |||
1353 | { | |||
1354 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1354, __extension__ __PRETTY_FUNCTION__)); | |||
1355 | assert(nLen >= 0)(static_cast <bool> (nLen >= 0) ? void (0) : __assert_fail ("nLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1355, __extension__ __PRETTY_FUNCTION__)); | |||
1356 | IMPL_RTL_STRINGDATA* pOrg; | |||
1357 | ||||
1358 | if ( !pCharStr || (nLen <= 0) ) | |||
1359 | { | |||
1360 | IMPL_RTL_STRINGNAME( new )( ppThis ); | |||
1361 | return; | |||
1362 | } | |||
1363 | ||||
1364 | pOrg = *ppThis; | |||
1365 | *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); | |||
1366 | OSL_ASSERT(*ppThis != nullptr)do { if (true && (!(*ppThis != nullptr))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1366" ": "), "OSL_ASSERT: %s", "*ppThis != nullptr"); } } while (false); | |||
1367 | rtl_str_ImplCopy( (*ppThis)->buffer, pCharStr, nLen ); | |||
1368 | ||||
1369 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
1370 | ||||
1371 | /* must be done last, if pCharStr == *ppThis */ | |||
1372 | if ( pOrg ) | |||
1373 | IMPL_RTL_STRINGNAME( release )( pOrg ); | |||
1374 | } | |||
1375 | ||||
1376 | /* ----------------------------------------------------------------------- */ | |||
1377 | ||||
1378 | void SAL_CALL IMPL_RTL_STRINGNAME( newFromSubString )( IMPL_RTL_STRINGDATA** ppThis, | |||
1379 | const IMPL_RTL_STRINGDATA* pFrom, | |||
1380 | sal_Int32 beginIndex, | |||
1381 | sal_Int32 count ) | |||
1382 | SAL_THROW_EXTERN_C()throw () | |||
1383 | { | |||
1384 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1384, __extension__ __PRETTY_FUNCTION__)); | |||
1385 | if ( beginIndex == 0 && count == pFrom->length ) | |||
1386 | { | |||
1387 | IMPL_RTL_STRINGNAME( assign )( ppThis, const_cast< IMPL_RTL_STRINGDATA * >( pFrom ) ); | |||
1388 | return; | |||
1389 | } | |||
1390 | if ( count < 0 || beginIndex < 0 || beginIndex + count > pFrom->length ) | |||
1391 | { | |||
1392 | assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1392, __extension__ __PRETTY_FUNCTION__)); // fail fast at least in debug builds | |||
1393 | IMPL_RTL_STRINGNAME( newFromLiteral )( ppThis, "!!br0ken!!", 10, 0 ); | |||
1394 | return; | |||
1395 | } | |||
1396 | ||||
1397 | IMPL_RTL_STRINGNAME( newFromStr_WithLength )( ppThis, pFrom->buffer + beginIndex, count ); | |||
1398 | } | |||
1399 | ||||
1400 | /* ----------------------------------------------------------------------- */ | |||
1401 | ||||
1402 | // Used when creating from string literals. | |||
1403 | void SAL_CALL IMPL_RTL_STRINGNAME( newFromLiteral )( IMPL_RTL_STRINGDATA** ppThis, | |||
1404 | const char* pCharStr, | |||
1405 | sal_Int32 nLen, | |||
1406 | sal_Int32 allocExtra ) | |||
1407 | SAL_THROW_EXTERN_C()throw () | |||
1408 | { | |||
1409 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1409, __extension__ __PRETTY_FUNCTION__)); | |||
1410 | assert(nLen >= 0)(static_cast <bool> (nLen >= 0) ? void (0) : __assert_fail ("nLen >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1410, __extension__ __PRETTY_FUNCTION__)); | |||
1411 | assert(allocExtra >= 0)(static_cast <bool> (allocExtra >= 0) ? void (0) : __assert_fail ("allocExtra >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1411, __extension__ __PRETTY_FUNCTION__)); | |||
1412 | if ( nLen + allocExtra == 0 ) | |||
1413 | { | |||
1414 | IMPL_RTL_STRINGNAME( new )( ppThis ); | |||
1415 | return; | |||
1416 | } | |||
1417 | ||||
1418 | if ( *ppThis ) | |||
1419 | IMPL_RTL_STRINGNAME( release )( *ppThis ); | |||
1420 | ||||
1421 | *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen + allocExtra ); | |||
1422 | assert( *ppThis != nullptr )(static_cast <bool> (*ppThis != nullptr) ? void (0) : __assert_fail ("*ppThis != nullptr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1422, __extension__ __PRETTY_FUNCTION__)); | |||
1423 | ||||
1424 | (*ppThis)->length = nLen; // fix after possible allocExtra != 0 | |||
1425 | (*ppThis)->buffer[nLen] = 0; | |||
1426 | IMPL_RTL_STRCODE* pBuffer = (*ppThis)->buffer; | |||
1427 | sal_Int32 nCount; | |||
1428 | for( nCount = nLen; nCount > 0; --nCount ) | |||
1429 | { | |||
1430 | #if IMPL_RTL_IS_USTRING | |||
1431 | assert(static_cast<unsigned char>(*pCharStr) < 0x80)(static_cast <bool> (static_cast<unsigned char>(* pCharStr) < 0x80) ? void (0) : __assert_fail ("static_cast<unsigned char>(*pCharStr) < 0x80" , "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx", 1431 , __extension__ __PRETTY_FUNCTION__)); // ASCII range | |||
1432 | #endif | |||
1433 | SAL_WARN_IF( (static_cast<unsigned char>(*pCharStr)) == '\0', "rtl.string",do { if (true && ((static_cast<unsigned char>(* pCharStr)) == '\0')) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_uString_newFromLiteral - Found embedded \\0 character" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1434" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_uString_newFromLiteral - Found embedded \\0 character" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_uString_newFromLiteral - Found embedded \\0 character" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1434" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_uString_newFromLiteral - Found embedded \\0 character" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1434" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_uString_newFromLiteral - Found embedded \\0 character" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_uString_newFromLiteral - Found embedded \\0 character" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1434" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false) | |||
1434 | "rtl_uString_newFromLiteral - Found embedded \\0 character" )do { if (true && ((static_cast<unsigned char>(* pCharStr)) == '\0')) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "rtl.string")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "rtl_uString_newFromLiteral - Found embedded \\0 character" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1434" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_uString_newFromLiteral - Found embedded \\0 character" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_uString_newFromLiteral - Found embedded \\0 character" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1434" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "rtl_uString_newFromLiteral - Found embedded \\0 character" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1434" ": "), ::sal::detail::unwrapStream( ::sal::detail::StreamStart () << "rtl_uString_newFromLiteral - Found embedded \\0 character" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "rtl_uString_newFromLiteral - Found embedded \\0 character" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("rtl.string" ), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1434" ": "), sal_detail_stream, 0); }; std::abort(); break; } } } while (false); | |||
1435 | ||||
1436 | *pBuffer = *pCharStr; | |||
1437 | pBuffer++; | |||
1438 | pCharStr++; | |||
1439 | } | |||
1440 | ||||
1441 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
1442 | } | |||
1443 | ||||
1444 | /* ----------------------------------------------------------------------- */ | |||
1445 | ||||
1446 | void SAL_CALL IMPL_RTL_STRINGNAME( assign )( IMPL_RTL_STRINGDATA** ppThis, | |||
1447 | IMPL_RTL_STRINGDATA* pStr ) | |||
1448 | SAL_THROW_EXTERN_C()throw () | |||
1449 | { | |||
1450 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1450, __extension__ __PRETTY_FUNCTION__)); | |||
1451 | /* must be done at first, if pStr == *ppThis */ | |||
1452 | IMPL_RTL_ACQUIRE( pStr ); | |||
1453 | ||||
1454 | if ( *ppThis ) | |||
1455 | IMPL_RTL_STRINGNAME( release )( *ppThis ); | |||
1456 | ||||
1457 | *ppThis = pStr; | |||
1458 | } | |||
1459 | ||||
1460 | /* ----------------------------------------------------------------------- */ | |||
1461 | ||||
1462 | sal_Int32 SAL_CALL IMPL_RTL_STRINGNAME( getLength )( const IMPL_RTL_STRINGDATA* pThis ) | |||
1463 | SAL_THROW_EXTERN_C()throw () | |||
1464 | { | |||
1465 | assert(pThis)(static_cast <bool> (pThis) ? void (0) : __assert_fail ( "pThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1465, __extension__ __PRETTY_FUNCTION__)); | |||
1466 | return pThis->length; | |||
1467 | } | |||
1468 | ||||
1469 | /* ----------------------------------------------------------------------- */ | |||
1470 | ||||
1471 | IMPL_RTL_STRCODE* SAL_CALL IMPL_RTL_STRINGNAME( getStr )( IMPL_RTL_STRINGDATA * pThis ) | |||
1472 | SAL_THROW_EXTERN_C()throw () | |||
1473 | { | |||
1474 | assert(pThis)(static_cast <bool> (pThis) ? void (0) : __assert_fail ( "pThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1474, __extension__ __PRETTY_FUNCTION__)); | |||
1475 | return pThis->buffer; | |||
1476 | } | |||
1477 | ||||
1478 | /* ----------------------------------------------------------------------- */ | |||
1479 | ||||
1480 | void SAL_CALL IMPL_RTL_STRINGNAME( newConcat )( IMPL_RTL_STRINGDATA** ppThis, | |||
1481 | IMPL_RTL_STRINGDATA* pLeft, | |||
1482 | IMPL_RTL_STRINGDATA* pRight ) | |||
1483 | SAL_THROW_EXTERN_C()throw () | |||
1484 | { | |||
1485 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1485, __extension__ __PRETTY_FUNCTION__)); | |||
1486 | IMPL_RTL_STRINGDATA* pOrg = *ppThis; | |||
1487 | ||||
1488 | /* Test for 0-Pointer - if not, change newReplaceStrAt! */ | |||
1489 | if ( !pRight || !pRight->length ) | |||
1490 | { | |||
1491 | *ppThis = pLeft; | |||
1492 | IMPL_RTL_ACQUIRE( pLeft ); | |||
1493 | } | |||
1494 | else if ( !pLeft || !pLeft->length ) | |||
1495 | { | |||
1496 | *ppThis = pRight; | |||
1497 | IMPL_RTL_ACQUIRE( pRight ); | |||
1498 | } | |||
1499 | else if (pLeft->length | |||
1500 | > std::numeric_limits<sal_Int32>::max() - pRight->length) | |||
1501 | { | |||
1502 | *ppThis = nullptr; | |||
1503 | } | |||
1504 | else | |||
1505 | { | |||
1506 | IMPL_RTL_STRINGDATA* pTempStr = IMPL_RTL_STRINGNAME( ImplAlloc )( pLeft->length + pRight->length ); | |||
1507 | OSL_ASSERT(pTempStr != nullptr)do { if (true && (!(pTempStr != nullptr))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1507" ": "), "OSL_ASSERT: %s", "pTempStr != nullptr"); } } while (false); | |||
1508 | *ppThis = pTempStr; | |||
1509 | if (*ppThis != nullptr) { | |||
1510 | rtl_str_ImplCopy( pTempStr->buffer, pLeft->buffer, pLeft->length ); | |||
1511 | rtl_str_ImplCopy( pTempStr->buffer+pLeft->length, pRight->buffer, pRight->length ); | |||
1512 | ||||
1513 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
1514 | } | |||
1515 | } | |||
1516 | ||||
1517 | /* must be done last, if left or right == *ppThis */ | |||
1518 | if ( pOrg ) | |||
1519 | IMPL_RTL_STRINGNAME( release )( pOrg ); | |||
1520 | } | |||
1521 | ||||
1522 | /* ----------------------------------------------------------------------- */ | |||
1523 | ||||
1524 | void SAL_CALL IMPL_RTL_STRINGNAME( ensureCapacity )( IMPL_RTL_STRINGDATA** ppThis, | |||
1525 | sal_Int32 size ) | |||
1526 | SAL_THROW_EXTERN_C()throw () | |||
1527 | { | |||
1528 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1528, __extension__ __PRETTY_FUNCTION__)); | |||
1529 | IMPL_RTL_STRINGDATA* const pOrg = *ppThis; | |||
1530 | if ( pOrg->refCount == 1 && pOrg->length >= size ) | |||
1531 | return; | |||
1532 | assert( pOrg->length <= size )(static_cast <bool> (pOrg->length <= size) ? void (0) : __assert_fail ("pOrg->length <= size", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1532, __extension__ __PRETTY_FUNCTION__)); // do not truncate | |||
1533 | IMPL_RTL_STRINGDATA* pTempStr = IMPL_RTL_STRINGNAME( ImplAlloc )( size ); | |||
1534 | rtl_str_ImplCopy( pTempStr->buffer, pOrg->buffer, pOrg->length ); | |||
1535 | // right now the length is still the same as of the original | |||
1536 | pTempStr->length = pOrg->length; | |||
1537 | pTempStr->buffer[ pOrg->length ] = '\0'; | |||
1538 | *ppThis = pTempStr; | |||
1539 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
1540 | ||||
1541 | IMPL_RTL_STRINGNAME( release )( pOrg ); | |||
1542 | } | |||
1543 | ||||
1544 | /* ----------------------------------------------------------------------- */ | |||
1545 | ||||
1546 | void SAL_CALL IMPL_RTL_STRINGNAME( newReplaceStrAt )( IMPL_RTL_STRINGDATA** ppThis, | |||
1547 | IMPL_RTL_STRINGDATA* pStr, | |||
1548 | sal_Int32 nIndex, | |||
1549 | sal_Int32 nCount, | |||
1550 | IMPL_RTL_STRINGDATA* pNewSubStr ) | |||
1551 | SAL_THROW_EXTERN_C()throw () | |||
1552 | { | |||
1553 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1553, __extension__ __PRETTY_FUNCTION__)); | |||
1554 | assert(nIndex >= 0 && nIndex <= pStr->length)(static_cast <bool> (nIndex >= 0 && nIndex <= pStr->length) ? void (0) : __assert_fail ("nIndex >= 0 && nIndex <= pStr->length" , "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx", 1554 , __extension__ __PRETTY_FUNCTION__)); | |||
1555 | assert(nCount >= 0)(static_cast <bool> (nCount >= 0) ? void (0) : __assert_fail ("nCount >= 0", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1555, __extension__ __PRETTY_FUNCTION__)); | |||
1556 | assert(nCount <= pStr->length - nIndex)(static_cast <bool> (nCount <= pStr->length - nIndex ) ? void (0) : __assert_fail ("nCount <= pStr->length - nIndex" , "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx", 1556 , __extension__ __PRETTY_FUNCTION__)); | |||
1557 | /* Append? */ | |||
1558 | if ( nIndex >= pStr->length ) | |||
1559 | { | |||
1560 | /* newConcat test, if pNewSubStr is 0 */ | |||
1561 | IMPL_RTL_STRINGNAME( newConcat )( ppThis, pStr, pNewSubStr ); | |||
1562 | return; | |||
1563 | } | |||
1564 | ||||
1565 | /* negative index? */ | |||
1566 | if ( nIndex < 0 ) | |||
1567 | { | |||
1568 | nCount -= nIndex; | |||
1569 | nIndex = 0; | |||
1570 | } | |||
1571 | ||||
1572 | /* not more than the String length could be deleted */ | |||
1573 | if ( nCount >= pStr->length-nIndex ) | |||
1574 | { | |||
1575 | nCount = pStr->length-nIndex; | |||
1576 | ||||
1577 | /* Assign of NewSubStr? */ | |||
1578 | if ( !nIndex && (nCount >= pStr->length) ) | |||
1579 | { | |||
1580 | if ( !pNewSubStr ) | |||
1581 | IMPL_RTL_STRINGNAME( new )( ppThis ); | |||
1582 | else | |||
1583 | IMPL_RTL_STRINGNAME( assign )( ppThis, pNewSubStr ); | |||
1584 | return; | |||
1585 | } | |||
1586 | } | |||
1587 | ||||
1588 | /* Assign of Str? */ | |||
1589 | if ( !nCount && (!pNewSubStr || !pNewSubStr->length) ) | |||
1590 | { | |||
1591 | IMPL_RTL_STRINGNAME( assign )( ppThis, pStr ); | |||
1592 | return; | |||
1593 | } | |||
1594 | ||||
1595 | IMPL_RTL_STRINGDATA* pOrg = *ppThis; | |||
1596 | IMPL_RTL_STRCODE* pBuffer; | |||
1597 | sal_Int32 nNewLen; | |||
1598 | ||||
1599 | /* Calculate length of the new string */ | |||
1600 | nNewLen = pStr->length-nCount; | |||
1601 | if ( pNewSubStr ) | |||
1602 | nNewLen += pNewSubStr->length; | |||
1603 | ||||
1604 | /* Alloc New Buffer */ | |||
1605 | *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); | |||
1606 | OSL_ASSERT(*ppThis != nullptr)do { if (true && (!(*ppThis != nullptr))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" ":" "1606" ": "), "OSL_ASSERT: %s", "*ppThis != nullptr"); } } while (false); | |||
1607 | pBuffer = (*ppThis)->buffer; | |||
1608 | if ( nIndex ) | |||
1609 | { | |||
1610 | rtl_str_ImplCopy( pBuffer, pStr->buffer, nIndex ); | |||
1611 | pBuffer += nIndex; | |||
1612 | } | |||
1613 | if ( pNewSubStr && pNewSubStr->length ) | |||
1614 | { | |||
1615 | rtl_str_ImplCopy( pBuffer, pNewSubStr->buffer, pNewSubStr->length ); | |||
1616 | pBuffer += pNewSubStr->length; | |||
1617 | } | |||
1618 | rtl_str_ImplCopy( pBuffer, pStr->buffer+nIndex+nCount, pStr->length-nIndex-nCount ); | |||
1619 | ||||
1620 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
1621 | /* must be done last, if pStr or pNewSubStr == *ppThis */ | |||
1622 | if ( pOrg ) | |||
1623 | IMPL_RTL_STRINGNAME( release )( pOrg ); | |||
1624 | } | |||
1625 | ||||
1626 | /* ----------------------------------------------------------------------- */ | |||
1627 | ||||
1628 | void SAL_CALL IMPL_RTL_STRINGNAME( newReplace )( IMPL_RTL_STRINGDATA** ppThis, | |||
1629 | IMPL_RTL_STRINGDATA* pStr, | |||
1630 | IMPL_RTL_STRCODE cOld, | |||
1631 | IMPL_RTL_STRCODE cNew ) | |||
1632 | SAL_THROW_EXTERN_C()throw () | |||
1633 | { | |||
1634 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1634, __extension__ __PRETTY_FUNCTION__)); | |||
1635 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1635, __extension__ __PRETTY_FUNCTION__)); | |||
1636 | IMPL_RTL_STRINGDATA* pOrg = *ppThis; | |||
1637 | bool bChanged = false; | |||
1638 | sal_Int32 nLen = pStr->length; | |||
1639 | const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; | |||
1640 | ||||
1641 | while ( nLen > 0 ) | |||
1642 | { | |||
1643 | if ( *pCharStr == cOld ) | |||
1644 | { | |||
1645 | /* Copy String */ | |||
1646 | IMPL_RTL_STRCODE* pNewCharStr = IMPL_RTL_STRINGNAME( ImplNewCopy )( ppThis, pStr, pCharStr-pStr->buffer ); | |||
1647 | ||||
1648 | /* replace/copy rest of the string */ | |||
1649 | if ( pNewCharStr ) | |||
1650 | { | |||
1651 | *pNewCharStr = cNew; | |||
1652 | pNewCharStr++; | |||
1653 | pCharStr++; | |||
1654 | nLen--; | |||
1655 | ||||
1656 | while ( nLen > 0 ) | |||
1657 | { | |||
1658 | if ( *pCharStr == cOld ) | |||
1659 | *pNewCharStr = cNew; | |||
1660 | else | |||
1661 | *pNewCharStr = *pCharStr; | |||
1662 | ||||
1663 | pNewCharStr++; | |||
1664 | pCharStr++; | |||
1665 | nLen--; | |||
1666 | } | |||
1667 | } | |||
1668 | ||||
1669 | bChanged = true; | |||
1670 | break; | |||
1671 | } | |||
1672 | ||||
1673 | pCharStr++; | |||
1674 | nLen--; | |||
1675 | } | |||
1676 | ||||
1677 | if ( !bChanged ) | |||
1678 | { | |||
1679 | *ppThis = pStr; | |||
1680 | IMPL_RTL_ACQUIRE( pStr ); | |||
1681 | } | |||
1682 | ||||
1683 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
1684 | /* must be done last, if pStr == *ppThis */ | |||
1685 | if ( pOrg ) | |||
1686 | IMPL_RTL_STRINGNAME( release )( pOrg ); | |||
1687 | } | |||
1688 | ||||
1689 | /* ----------------------------------------------------------------------- */ | |||
1690 | ||||
1691 | void SAL_CALL IMPL_RTL_STRINGNAME( newToAsciiLowerCase )( IMPL_RTL_STRINGDATA** ppThis, | |||
1692 | IMPL_RTL_STRINGDATA* pStr ) | |||
1693 | SAL_THROW_EXTERN_C()throw () | |||
1694 | { | |||
1695 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1695, __extension__ __PRETTY_FUNCTION__)); | |||
1696 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1696, __extension__ __PRETTY_FUNCTION__)); | |||
1697 | IMPL_RTL_STRINGDATA* pOrg = *ppThis; | |||
1698 | bool bChanged = false; | |||
1699 | sal_Int32 nLen = pStr->length; | |||
1700 | const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; | |||
1701 | ||||
1702 | while ( nLen > 0 ) | |||
1703 | { | |||
1704 | if ( rtl::isAsciiUpperCase(IMPL_RTL_USTRCODE(*pCharStr)) ) | |||
1705 | { | |||
1706 | /* Copy String */ | |||
1707 | IMPL_RTL_STRCODE* pNewCharStr = IMPL_RTL_STRINGNAME( ImplNewCopy )( ppThis, pStr, pCharStr-pStr->buffer ); | |||
1708 | ||||
1709 | /* replace/copy rest of the string */ | |||
1710 | if ( pNewCharStr ) | |||
1711 | { | |||
1712 | *pNewCharStr = rtl::toAsciiLowerCase(IMPL_RTL_USTRCODE(*pCharStr)); | |||
1713 | pNewCharStr++; | |||
1714 | pCharStr++; | |||
1715 | nLen--; | |||
1716 | ||||
1717 | while ( nLen > 0 ) | |||
1718 | { | |||
1719 | *pNewCharStr = rtl::toAsciiLowerCase(IMPL_RTL_USTRCODE(*pCharStr)); | |||
1720 | ||||
1721 | pNewCharStr++; | |||
1722 | pCharStr++; | |||
1723 | nLen--; | |||
1724 | } | |||
1725 | } | |||
1726 | ||||
1727 | bChanged = true; | |||
1728 | break; | |||
1729 | } | |||
1730 | ||||
1731 | pCharStr++; | |||
1732 | nLen--; | |||
1733 | } | |||
1734 | ||||
1735 | if ( !bChanged ) | |||
1736 | { | |||
1737 | *ppThis = pStr; | |||
1738 | IMPL_RTL_ACQUIRE( pStr ); | |||
1739 | } | |||
1740 | ||||
1741 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
1742 | /* must be done last, if pStr == *ppThis */ | |||
1743 | if ( pOrg ) | |||
1744 | IMPL_RTL_STRINGNAME( release )( pOrg ); | |||
1745 | } | |||
1746 | ||||
1747 | /* ----------------------------------------------------------------------- */ | |||
1748 | ||||
1749 | void SAL_CALL IMPL_RTL_STRINGNAME( newToAsciiUpperCase )( IMPL_RTL_STRINGDATA** ppThis, | |||
1750 | IMPL_RTL_STRINGDATA* pStr ) | |||
1751 | SAL_THROW_EXTERN_C()throw () | |||
1752 | { | |||
1753 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1753, __extension__ __PRETTY_FUNCTION__)); | |||
1754 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1754, __extension__ __PRETTY_FUNCTION__)); | |||
1755 | IMPL_RTL_STRINGDATA* pOrg = *ppThis; | |||
1756 | bool bChanged = false; | |||
1757 | sal_Int32 nLen = pStr->length; | |||
1758 | const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; | |||
1759 | ||||
1760 | while ( nLen > 0 ) | |||
1761 | { | |||
1762 | if ( rtl::isAsciiLowerCase(IMPL_RTL_USTRCODE(*pCharStr)) ) | |||
1763 | { | |||
1764 | /* Copy String */ | |||
1765 | IMPL_RTL_STRCODE* pNewCharStr = IMPL_RTL_STRINGNAME( ImplNewCopy )( ppThis, pStr, pCharStr-pStr->buffer ); | |||
1766 | ||||
1767 | /* replace/copy rest of the string */ | |||
1768 | if ( pNewCharStr ) | |||
1769 | { | |||
1770 | *pNewCharStr = rtl::toAsciiUpperCase(IMPL_RTL_USTRCODE(*pCharStr)); | |||
1771 | pNewCharStr++; | |||
1772 | pCharStr++; | |||
1773 | nLen--; | |||
1774 | ||||
1775 | while ( nLen > 0 ) | |||
1776 | { | |||
1777 | *pNewCharStr = rtl::toAsciiUpperCase(IMPL_RTL_USTRCODE(*pCharStr)); | |||
1778 | ||||
1779 | pNewCharStr++; | |||
1780 | pCharStr++; | |||
1781 | nLen--; | |||
1782 | } | |||
1783 | } | |||
1784 | ||||
1785 | bChanged = true; | |||
1786 | break; | |||
1787 | } | |||
1788 | ||||
1789 | pCharStr++; | |||
1790 | nLen--; | |||
1791 | } | |||
1792 | ||||
1793 | if ( !bChanged ) | |||
1794 | { | |||
1795 | *ppThis = pStr; | |||
1796 | IMPL_RTL_ACQUIRE( pStr ); | |||
1797 | } | |||
1798 | ||||
1799 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
1800 | /* must be done last, if pStr == *ppThis */ | |||
1801 | if ( pOrg ) | |||
1802 | IMPL_RTL_STRINGNAME( release )( pOrg ); | |||
1803 | } | |||
1804 | ||||
1805 | /* ----------------------------------------------------------------------- */ | |||
1806 | ||||
1807 | void SAL_CALL IMPL_RTL_STRINGNAME( newTrim )( IMPL_RTL_STRINGDATA** ppThis, | |||
1808 | IMPL_RTL_STRINGDATA* pStr ) | |||
1809 | SAL_THROW_EXTERN_C()throw () | |||
1810 | { | |||
1811 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1811, __extension__ __PRETTY_FUNCTION__)); | |||
1812 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1812, __extension__ __PRETTY_FUNCTION__)); | |||
1813 | IMPL_RTL_STRINGDATA* pOrg = *ppThis; | |||
1814 | const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; | |||
1815 | sal_Int32 nPreSpaces = 0; | |||
1816 | sal_Int32 nPostSpaces = 0; | |||
1817 | sal_Int32 nLen = pStr->length; | |||
1818 | sal_Int32 nIndex = nLen-1; | |||
1819 | ||||
1820 | while ( (nPreSpaces < nLen) && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE(*(pCharStr+nPreSpaces)) ) ) | |||
1821 | nPreSpaces++; | |||
1822 | ||||
1823 | while ( (nIndex > nPreSpaces) && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE(*(pCharStr+nIndex)) ) ) | |||
1824 | { | |||
1825 | nPostSpaces++; | |||
1826 | nIndex--; | |||
1827 | } | |||
1828 | ||||
1829 | if ( !nPreSpaces && !nPostSpaces ) | |||
1830 | { | |||
1831 | *ppThis = pStr; | |||
1832 | IMPL_RTL_ACQUIRE( pStr ); | |||
1833 | } | |||
1834 | else | |||
1835 | { | |||
1836 | nLen -= nPostSpaces+nPreSpaces; | |||
1837 | *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); | |||
1838 | assert(*ppThis)(static_cast <bool> (*ppThis) ? void (0) : __assert_fail ("*ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1838, __extension__ __PRETTY_FUNCTION__)); | |||
1839 | rtl_str_ImplCopy( (*ppThis)->buffer, pStr->buffer+nPreSpaces, nLen ); | |||
1840 | } | |||
1841 | ||||
1842 | RTL_LOG_STRING_NEW( *ppThis )do { ; __asm__ __volatile__ ("990: nop" "\n" ".pushsection .note.stapsdt" "," "\"?\"" "," "\"note\"" "\n" ".balign 4" "\n" ".4byte 992f-991f" "," "994f-993f" "," "3" "\n" "991: .asciz \"stapsdt\"" "\n" "992: .balign 4" "\n" "993: .8byte 990b" "\n" ".8byte _.stapsdt.base" "\n" ".8byte 0" "\n" ".asciz \"libreoffice\"" "\n" ".asciz \"new_string_RTL_LOG_STRING_BITS\"" "\n" ".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2] %n[_SDT_S3]@%[_SDT_A3] %n[_SDT_S4]@%[_SDT_A4]\"" "\n" "994: .balign 4" "\n" ".popsection" "\n" :: [_SDT_S1] "n" (((!(__builtin_classify_type (*ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) && __sdt_type<__typeof (*ppThis)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( *ppThis) == 14 || __builtin_classify_type (*ppThis) == 5) ? sizeof (void *) : sizeof (*ppThis))), [_SDT_A1] "nor" ((*ppThis)), [ _SDT_S2] "n" (((!(__builtin_classify_type ((*ppThis)->refCount ) == 14 || __builtin_classify_type ((*ppThis)->refCount) == 5) && __sdt_type<__typeof ((*ppThis)->refCount )>::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)->refCount) == 14 || __builtin_classify_type (( *ppThis)->refCount) == 5) ? sizeof (void *) : sizeof ((*ppThis )->refCount))), [_SDT_A2] "nor" (((*ppThis)->refCount)) , [_SDT_S3] "n" (((!(__builtin_classify_type ((*ppThis)->length ) == 14 || __builtin_classify_type ((*ppThis)->length) == 5 ) && __sdt_type<__typeof ((*ppThis)->length)> ::__sdt_signed) ? 1 : -1) * (int) ((__builtin_classify_type ( (*ppThis)->length) == 14 || __builtin_classify_type ((*ppThis )->length) == 5) ? sizeof (void *) : sizeof ((*ppThis)-> length))), [_SDT_A3] "nor" (((*ppThis)->length)), [_SDT_S4 ] "n" (((!(__builtin_classify_type ((*ppThis)->buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer) == 5) && __sdt_type<__typeof ((*ppThis)->buffer)>::__sdt_signed ) ? 1 : -1) * (int) ((__builtin_classify_type ((*ppThis)-> buffer) == 14 || __builtin_classify_type ((*ppThis)->buffer ) == 5) ? sizeof (void *) : sizeof ((*ppThis)->buffer))), [ _SDT_A4] "nor" (((*ppThis)->buffer))); __asm__ __volatile__ (".ifndef _.stapsdt.base" "\n" ".pushsection .stapsdt.base" "," "\"aG\"" "," "\"progbits\"" "," ".stapsdt.base" "," "comdat" "\n" ".weak _.stapsdt.base" "\n" ".hidden _.stapsdt.base" "\n" "_.stapsdt.base: .space 1" "\n" ".size _.stapsdt.base" "," "1" "\n" ".popsection" "\n" ".endif" "\n"); } while (0); | |||
1843 | /* must be done last, if pStr == *ppThis */ | |||
1844 | if ( pOrg ) | |||
1845 | IMPL_RTL_STRINGNAME( release )( pOrg ); | |||
1846 | } | |||
1847 | ||||
1848 | /* ----------------------------------------------------------------------- */ | |||
1849 | ||||
1850 | sal_Int32 SAL_CALL IMPL_RTL_STRINGNAME( getToken )( IMPL_RTL_STRINGDATA** ppThis, | |||
1851 | IMPL_RTL_STRINGDATA* pStr, | |||
1852 | sal_Int32 nToken, | |||
1853 | IMPL_RTL_STRCODE cTok, | |||
1854 | sal_Int32 nIndex ) | |||
1855 | SAL_THROW_EXTERN_C()throw () | |||
1856 | { | |||
1857 | assert(ppThis)(static_cast <bool> (ppThis) ? void (0) : __assert_fail ("ppThis", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1857, __extension__ __PRETTY_FUNCTION__)); | |||
1858 | assert(pStr)(static_cast <bool> (pStr) ? void (0) : __assert_fail ( "pStr", "/home/maarten/src/libreoffice/core/sal/rtl/strtmpl.cxx" , 1858, __extension__ __PRETTY_FUNCTION__)); | |||
1859 | const IMPL_RTL_STRCODE* pCharStr = pStr->buffer; | |||
1860 | const IMPL_RTL_STRCODE* pCharStrStart; | |||
1861 | const IMPL_RTL_STRCODE* pOrgCharStr; | |||
1862 | sal_Int32 nLen = pStr->length-nIndex; | |||
1863 | sal_Int32 nTokCount = 0; | |||
1864 | ||||
1865 | // Set ppThis to an empty string and return -1 if either nToken or nIndex is | |||
1866 | // negative: | |||
1867 | if (nIndex < 0) | |||
1868 | nToken = -1; | |||
1869 | ||||
1870 | pCharStr += nIndex; | |||
1871 | pOrgCharStr = pCharStr; | |||
1872 | pCharStrStart = pCharStr; | |||
1873 | while ( nLen > 0 ) | |||
1874 | { | |||
1875 | if ( *pCharStr == cTok ) | |||
1876 | { | |||
1877 | nTokCount++; | |||
1878 | ||||
1879 | if ( nTokCount == nToken ) | |||
1880 | pCharStrStart = pCharStr+1; | |||
1881 | else | |||
1882 | { | |||
1883 | if ( nTokCount > nToken ) | |||
1884 | break; | |||
1885 | } | |||
1886 | } | |||
1887 | ||||
1888 | pCharStr++; | |||
1889 | nLen--; | |||
1890 | } | |||
1891 | ||||
1892 | if ( (nToken < 0) || (nTokCount < nToken) || (pCharStr == pCharStrStart) ) | |||
1893 | { | |||
1894 | IMPL_RTL_STRINGNAME( new )( ppThis ); | |||
1895 | if( (nToken < 0) || (nTokCount < nToken ) ) | |||
1896 | return -1; | |||
1897 | else if( nLen > 0 ) | |||
1898 | return nIndex+(pCharStr-pOrgCharStr)+1; | |||
1899 | else return -1; | |||
1900 | } | |||
1901 | else | |||
1902 | { | |||
1903 | IMPL_RTL_STRINGNAME( newFromStr_WithLength )( ppThis, pCharStrStart, pCharStr-pCharStrStart ); | |||
1904 | if ( nLen ) | |||
1905 | return nIndex+(pCharStr-pOrgCharStr)+1; | |||
1906 | else | |||
1907 | return -1; | |||
1908 | } | |||
1909 | } | |||
1910 | ||||
1911 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |