Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sal/rtl/string.cxx
Line
Count
Source
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
25
#include <o3tl/untaint.hxx>
26
#include <osl/diagnose.h>
27
#include <rtl/tencinfo.h>
28
29
#include "strimp.hxx"
30
#include <rtl/character.hxx>
31
#include <rtl/string.h>
32
33
#include <rtl/math.h>
34
35
/* ======================================================================= */
36
37
#if USE_SDT_PROBES
38
#define RTL_LOG_STRING_BITS         8
39
#endif
40
41
#include "strtmpl.hxx"
42
43
/* ======================================================================= */
44
45
sal_Int32 SAL_CALL rtl_str_valueOfFloat(char * pStr, float f) noexcept
46
0
{
47
0
    return rtl::str::valueOfFP<RTL_STR_MAX_VALUEOFFLOAT>(pStr, f);
48
0
}
49
50
sal_Int32 SAL_CALL rtl_str_valueOfDouble(char * pStr, double d) noexcept
51
0
{
52
0
    return rtl::str::valueOfFP<RTL_STR_MAX_VALUEOFDOUBLE>(pStr, d);
53
0
}
54
55
float SAL_CALL rtl_str_toFloat(char const * pStr) noexcept
56
0
{
57
0
    assert(pStr);
58
0
    return static_cast<float>(rtl_math_stringToDouble(pStr, pStr + rtl_str_getLength(pStr),
59
0
                                           '.', 0, nullptr, nullptr));
60
0
}
61
62
double SAL_CALL rtl_str_toDouble(char const * pStr) noexcept
63
0
{
64
0
    assert(pStr);
65
0
    return rtl_math_stringToDouble(pStr, pStr + rtl_str_getLength(pStr), '.', 0,
66
0
                                   nullptr, nullptr);
67
0
}
68
69
/* ======================================================================= */
70
71
static int rtl_ImplGetFastUTF8ByteLen( const sal_Unicode* pStr, sal_Int32 nLen )
72
19.2M
{
73
19.2M
    int                 n;
74
19.2M
    sal_Unicode         c;
75
19.2M
    sal_uInt32          nUCS4Char;
76
19.2M
    const sal_Unicode*  pEndStr;
77
78
19.2M
    n = 0;
79
19.2M
    pEndStr  = pStr+nLen;
80
273M
    while ( pStr < pEndStr )
81
254M
    {
82
254M
        c = *pStr;
83
84
254M
        if ( c < 0x80 )
85
252M
            n++;
86
2.09M
        else if ( c < 0x800 )
87
1.07M
            n += 2;
88
1.01M
        else
89
1.01M
        {
90
1.01M
            if ( !rtl::isHighSurrogate(c) )
91
1.01M
                n += 3;
92
6.30k
            else
93
6.30k
            {
94
6.30k
                nUCS4Char = c;
95
96
6.30k
                if ( pStr+1 < pEndStr )
97
6.28k
                {
98
6.28k
                    c = *(pStr+1);
99
6.28k
                    if ( rtl::isLowSurrogate(c) )
100
2.42k
                    {
101
2.42k
                        nUCS4Char = rtl::combineSurrogates(nUCS4Char, c);
102
2.42k
                        pStr++;
103
2.42k
                    }
104
6.28k
                }
105
106
6.30k
                if ( nUCS4Char < 0x10000 )
107
3.87k
                    n += 3;
108
2.42k
                else if ( nUCS4Char < 0x200000 )
109
2.42k
                    n += 4;
110
0
                else if ( nUCS4Char < 0x4000000 )
111
0
                    n += 5;
112
0
                else
113
0
                    n += 6;
114
6.30k
            }
115
1.01M
        }
116
117
254M
        pStr++;
118
254M
    }
119
120
19.2M
    return n;
121
19.2M
}
122
123
/* ----------------------------------------------------------------------- */
124
125
static bool rtl_impl_convertUStringToString(rtl_String ** pTarget,
126
                                                  sal_Unicode const * pSource,
127
                                                  sal_Int32 nLength,
128
                                                  rtl_TextEncoding nEncoding,
129
                                                  sal_uInt32 nFlags,
130
                                                  bool bCheckErrors)
131
48.1M
{
132
48.1M
    assert(pTarget != nullptr);
133
48.1M
    assert(pSource != nullptr || nLength == 0);
134
48.1M
    assert(nLength >= 0);
135
48.1M
    OSL_ASSERT(nLength == 0 || rtl_isOctetTextEncoding(nEncoding));
136
137
48.1M
    if ( !nLength )
138
1.58M
        rtl_string_new( pTarget );
139
46.5M
    else
140
46.5M
    {
141
46.5M
        rtl_String*                 pTemp;
142
46.5M
        rtl_UnicodeToTextConverter  hConverter;
143
46.5M
        sal_uInt32                  nInfo;
144
46.5M
        sal_Size                    nSrcChars;
145
46.5M
        sal_Size                    nDestBytes;
146
46.5M
        sal_Size                    nNewLen;
147
46.5M
        sal_Size                    nNotConvertedChars;
148
46.5M
        sal_Size                    nMaxCharLen;
149
150
        /* Optimization for UTF-8 - we try to calculate the exact length */
151
        /* For all other encoding we try a good estimation */
152
46.5M
        if ( nEncoding == RTL_TEXTENCODING_UTF8 )
153
19.2M
        {
154
19.2M
            nNewLen = rtl_ImplGetFastUTF8ByteLen( pSource, nLength );
155
            /* Includes the string only ASCII, then we could copy
156
               the buffer faster */
157
19.2M
            if ( nNewLen == static_cast<sal_Size>(nLength) )
158
19.2M
            {
159
19.2M
                char* pBuffer;
160
19.2M
                if ( *pTarget )
161
14.7M
                    rtl_string_release( *pTarget );
162
19.2M
                *pTarget = rtl_string_ImplAlloc( nLength );
163
19.2M
                assert(*pTarget != nullptr);
164
19.2M
                pBuffer = (*pTarget)->buffer;
165
19.2M
                do
166
232M
                {
167
                    /* Check ASCII range */
168
232M
                    OSL_ENSURE( *pSource <= 127,
169
232M
                                "rtl_uString2String() - UTF8 test is encoding is wrong" );
170
171
232M
                    *pBuffer = static_cast<char>(static_cast<unsigned char>(*pSource));
172
232M
                    pBuffer++;
173
232M
                    pSource++;
174
232M
                    nLength--;
175
232M
                }
176
232M
                while ( nLength );
177
19.2M
                return true;
178
19.2M
            }
179
180
91.3k
            nMaxCharLen = 4;
181
91.3k
        }
182
27.2M
        else
183
27.2M
        {
184
27.2M
            rtl_TextEncodingInfo aTextEncInfo;
185
27.2M
            aTextEncInfo.StructSize = sizeof( aTextEncInfo );
186
27.2M
            if ( !rtl_getTextEncodingInfo( nEncoding, &aTextEncInfo ) )
187
0
            {
188
0
                aTextEncInfo.AverageCharSize    = 1;
189
0
                aTextEncInfo.MaximumCharSize    = 8;
190
0
            }
191
192
27.2M
            nNewLen = nLength * static_cast<sal_Size>(aTextEncInfo.AverageCharSize);
193
27.2M
            nMaxCharLen = aTextEncInfo.MaximumCharSize;
194
27.2M
        }
195
196
27.3M
        nFlags |= RTL_UNICODETOTEXT_FLAGS_FLUSH;
197
27.3M
        hConverter = rtl_createUnicodeToTextConverter( nEncoding );
198
199
27.3M
        for (;;)
200
27.3M
        {
201
27.3M
            pTemp = rtl_string_ImplAlloc( nNewLen );
202
27.3M
            assert(pTemp != nullptr);
203
27.3M
            nDestBytes = rtl_convertUnicodeToText( hConverter, nullptr,
204
27.3M
                                                   pSource, nLength,
205
27.3M
                                                   pTemp->buffer, nNewLen,
206
27.3M
                                                   nFlags,
207
27.3M
                                                   &nInfo, &nSrcChars );
208
27.3M
            if (bCheckErrors && (nInfo & RTL_UNICODETOTEXT_INFO_ERROR) != 0)
209
126
            {
210
126
                rtl_freeString(pTemp);
211
126
                rtl_destroyUnicodeToTextConverter(hConverter);
212
126
                return false;
213
126
            }
214
215
27.3M
            if ((nInfo & RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL) == 0)
216
27.3M
                break;
217
218
            /* Buffer not big enough, try again with enough space */
219
0
            rtl_freeString( pTemp );
220
221
            /* Try with the max. count of characters with
222
               additional overhead for replacing functionality */
223
0
            nNotConvertedChars = nLength-nSrcChars;
224
0
            nNewLen = nDestBytes+(nNotConvertedChars*nMaxCharLen)+nNotConvertedChars+4;
225
0
        }
226
227
        /* Set the buffer to the correct size or is there to
228
           much overhead, reallocate to the correct size */
229
27.3M
        if ( nNewLen > nDestBytes+8 )
230
5.23k
        {
231
5.23k
            rtl_String* pTemp2 = rtl_string_ImplAlloc( nDestBytes );
232
5.23k
            assert(pTemp2 != nullptr);
233
5.23k
            rtl::str::Copy(pTemp2->buffer, pTemp->buffer, nDestBytes);
234
5.23k
            rtl_freeString( pTemp );
235
5.23k
            pTemp = pTemp2;
236
5.23k
        }
237
27.3M
        else
238
27.3M
        {
239
27.3M
            pTemp->length = nDestBytes;
240
27.3M
            pTemp->buffer[nDestBytes] = 0;
241
27.3M
        }
242
243
27.3M
        rtl_destroyUnicodeToTextConverter( hConverter );
244
27.3M
        if ( *pTarget )
245
49.9k
            rtl_string_release( *pTarget );
246
27.3M
        *pTarget = pTemp;
247
248
        /* Results the conversion in an empty buffer -
249
           create an empty string */
250
27.3M
        if ( pTemp && !nDestBytes )
251
863
            rtl_string_new( pTarget );
252
27.3M
    }
253
28.9M
    return true;
254
48.1M
}
255
256
void SAL_CALL rtl_uString2String( rtl_String** ppThis,
257
                                  const sal_Unicode* pUStr,
258
                                  sal_Int32 nULen,
259
                                  rtl_TextEncoding eTextEncoding,
260
                                  sal_uInt32 nCvtFlags ) noexcept
261
31.8M
{
262
31.8M
    rtl_impl_convertUStringToString(ppThis, pUStr, nULen, eTextEncoding,
263
31.8M
                                    nCvtFlags, false);
264
31.8M
}
265
266
sal_Bool SAL_CALL rtl_convertUStringToString(rtl_String ** pTarget,
267
                                             sal_Unicode const * pSource,
268
                                             sal_Int32 nLength,
269
                                             rtl_TextEncoding nEncoding,
270
                                             sal_uInt32 nFlags) noexcept
271
16.2M
{
272
16.2M
    return rtl_impl_convertUStringToString(pTarget, pSource, nLength, nEncoding,
273
16.2M
                                           nFlags, true);
274
16.2M
}
275
276
void rtl_string_newReplaceFirst(
277
    rtl_String ** newStr, rtl_String * str, char const * from,
278
    sal_Int32 fromLength, char const * to, sal_Int32 toLength,
279
    sal_Int32 * index) noexcept
280
0
{
281
0
    assert(str != nullptr);
282
0
    assert(index != nullptr);
283
0
    assert(*index >= 0 && *index <= str->length);
284
0
    assert(fromLength >= 0);
285
0
    assert(toLength >= 0);
286
0
    sal_Int32 i = rtl_str_indexOfStr_WithLength(
287
0
        str->buffer + *index, str->length - *index, from, fromLength);
288
0
    if (i == -1) {
289
0
        rtl_string_assign(newStr, str);
290
0
    } else {
291
0
        assert(i <= str->length - *index);
292
0
        i += *index;
293
0
        assert(fromLength <= str->length);
294
0
        if (str->length - fromLength > SAL_MAX_INT32 - toLength) {
295
0
            std::abort();
296
0
        }
297
0
        rtl::str::newReplaceStrAt(newStr, str, i, fromLength, to, toLength);
298
0
    }
299
0
    *index = i;
300
0
}
301
302
void rtl_string_newReplaceAll(
303
    rtl_String ** newStr, rtl_String * str, char const * from,
304
    sal_Int32 fromLength, char const * to, sal_Int32 toLength) noexcept
305
309
{
306
309
    rtl::str::newReplaceAllFromIndex(newStr, str, from, fromLength, to, toLength, 0);
307
309
}
308
309
sal_Int32 SAL_CALL rtl_str_getLength(const char* pStr) noexcept
310
138M
{
311
138M
    return rtl::str::getLength(pStr);
312
138M
}
313
314
sal_Int32 SAL_CALL rtl_str_compare(const char* pStr1, const char* pStr2) noexcept
315
209k
{
316
209k
    return rtl::str::compare(rtl::str::null_terminated(pStr1), rtl::str::null_terminated(pStr2),
317
209k
                             rtl::str::CompareNormal(), rtl::str::noShortening);
318
209k
}
319
320
sal_Int32 SAL_CALL rtl_str_compare_WithLength(const char* pStr1, sal_Int32 nStr1Len,
321
                                              const char* pStr2, sal_Int32 nStr2Len) noexcept
322
139M
{
323
139M
    return rtl::str::compare(rtl::str::with_length(pStr1, nStr1Len),
324
139M
                             rtl::str::with_length(pStr2, nStr2Len),
325
139M
                             rtl::str::CompareNormal(), rtl::str::noShortening);
326
139M
}
327
328
sal_Int32 SAL_CALL rtl_str_shortenedCompare_WithLength(const char* pStr1, sal_Int32 nStr1Len,
329
                                                       const char* pStr2, sal_Int32 nStr2Len,
330
                                                       sal_Int32 nShortenedLength) noexcept
331
2.64M
{
332
2.64M
    return rtl::str::compare(rtl::str::with_length(pStr1, nStr1Len),
333
2.64M
                             rtl::str::with_length(pStr2, nStr2Len),
334
2.64M
                             rtl::str::CompareNormal(), nShortenedLength);
335
2.64M
}
336
337
sal_Int32 SAL_CALL rtl_str_reverseCompare_WithLength(const char* pStr1, sal_Int32 nStr1Len,
338
                                                     const char* pStr2, sal_Int32 nStr2Len) noexcept
339
21.3M
{
340
21.3M
    return rtl::str::reverseCompare_WithLengths(pStr1, nStr1Len, pStr2, nStr2Len,
341
21.3M
                                                rtl::str::CompareNormal());
342
21.3M
}
343
344
sal_Int32 SAL_CALL rtl_str_compareIgnoreAsciiCase(const char* pStr1, const char* pStr2) noexcept
345
170k
{
346
170k
    return rtl::str::compare(rtl::str::null_terminated(pStr1), rtl::str::null_terminated(pStr2),
347
170k
                             rtl::str::CompareIgnoreAsciiCase(), rtl::str::noShortening);
348
170k
}
349
350
sal_Int32 SAL_CALL rtl_str_compareIgnoreAsciiCase_WithLength(const char* pStr1, sal_Int32 nStr1Len,
351
                                                             const char* pStr2, sal_Int32 nStr2Len) noexcept
352
185k
{
353
185k
    return rtl::str::compare(rtl::str::with_length(pStr1, nStr1Len),
354
185k
                             rtl::str::with_length(pStr2, nStr2Len),
355
185k
                             rtl::str::CompareIgnoreAsciiCase(), rtl::str::noShortening);
356
185k
}
357
358
sal_Int32 SAL_CALL rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
359
    const char* pStr1, sal_Int32 nStr1Len, const char* pStr2, sal_Int32 nStr2Len,
360
    sal_Int32 nShortenedLength) noexcept
361
0
{
362
0
    return rtl::str::compare(rtl::str::with_length(pStr1, nStr1Len),
363
0
                             rtl::str::with_length(pStr2, nStr2Len),
364
0
                             rtl::str::CompareIgnoreAsciiCase(), nShortenedLength);
365
0
}
366
367
sal_Int32 SAL_CALL rtl_str_hashCode(const char* pStr) noexcept
368
0
{
369
0
    return rtl::str::hashCode(pStr);
370
0
}
371
372
sal_Int32 SAL_CALL rtl_str_hashCode_WithLength(const char* pStr, sal_Int32 nLen) noexcept
373
256k
{
374
256k
    return rtl::str::hashCode_WithLength(pStr, nLen);
375
256k
}
376
377
sal_Int32 SAL_CALL rtl_str_indexOfChar(const char* pStr, char c) noexcept
378
0
{
379
0
    return rtl::str::indexOfChar(pStr, c);
380
0
}
381
382
sal_Int32 SAL_CALL rtl_str_indexOfChar_WithLength(const char* pStr, sal_Int32 nLen, char c) noexcept
383
3.32M
{
384
3.32M
    sal_Int32 ret = rtl::str::indexOfChar_WithLength(pStr, nLen, c);
385
3.32M
    o3tl::untaint_for_overrun(ret);
386
3.32M
    return ret;
387
3.32M
}
388
389
sal_Int32 SAL_CALL rtl_str_lastIndexOfChar(const char* pStr, char c) noexcept
390
0
{
391
0
    return rtl::str::lastIndexOfChar(pStr, c);
392
0
}
393
394
sal_Int32 SAL_CALL rtl_str_lastIndexOfChar_WithLength(const char* pStr, sal_Int32 nLen, char c) noexcept
395
306k
{
396
306k
    return rtl::str::lastIndexOfChar_WithLength(pStr, nLen, c);
397
306k
}
398
399
sal_Int32 SAL_CALL rtl_str_indexOfStr(const char* pStr, const char* pSubStr) noexcept
400
0
{
401
0
    return rtl::str::indexOfStr(pStr, pSubStr);
402
0
}
403
404
sal_Int32 SAL_CALL rtl_str_indexOfStr_WithLength(const char* pStr, sal_Int32 nStrLen,
405
                                                 const char* pSubStr, sal_Int32 nSubLen) noexcept
406
2.40M
{
407
2.40M
    sal_Int32 ret = rtl::str::indexOfStr_WithLength(pStr, nStrLen, pSubStr, nSubLen);
408
2.40M
    o3tl::untaint_for_overrun(ret);
409
2.40M
    return ret;
410
2.40M
}
411
412
sal_Int32 SAL_CALL rtl_str_lastIndexOfStr(const char* pStr, const char* pSubStr) noexcept
413
0
{
414
0
    return rtl::str::lastIndexOfStr(pStr, pSubStr);
415
0
}
416
417
sal_Int32 SAL_CALL rtl_str_lastIndexOfStr_WithLength(const char* pStr, sal_Int32 nStrLen,
418
                                                     const char* pSubStr, sal_Int32 nSubLen) noexcept
419
0
{
420
0
    return rtl::str::lastIndexOfStr_WithLength(pStr, nStrLen, pSubStr, nSubLen);
421
0
}
422
423
void SAL_CALL rtl_str_replaceChar(char* pStr, char cOld, char cNew) noexcept
424
0
{
425
0
    return rtl::str::replaceChars(rtl::str::null_terminated(pStr), rtl::str::FromTo(cOld, cNew));
426
0
}
427
428
void SAL_CALL rtl_str_replaceChar_WithLength(char* pStr, sal_Int32 nLen, char cOld, char cNew) noexcept
429
0
{
430
0
    return rtl::str::replaceChars(rtl::str::with_length(pStr, nLen), rtl::str::FromTo(cOld, cNew));
431
0
}
432
433
void SAL_CALL rtl_str_toAsciiLowerCase(char* pStr) noexcept
434
0
{
435
0
    return rtl::str::replaceChars(rtl::str::null_terminated(pStr), rtl::str::toAsciiLower);
436
0
}
437
438
void SAL_CALL rtl_str_toAsciiLowerCase_WithLength(char* pStr, sal_Int32 nLen) noexcept
439
0
{
440
0
    return rtl::str::replaceChars(rtl::str::with_length(pStr, nLen), rtl::str::toAsciiLower);
441
0
}
442
443
void SAL_CALL rtl_str_toAsciiUpperCase(char* pStr) noexcept
444
0
{
445
0
    return rtl::str::replaceChars(rtl::str::null_terminated(pStr), rtl::str::toAsciiUpper);
446
0
}
447
448
void SAL_CALL rtl_str_toAsciiUpperCase_WithLength(char* pStr, sal_Int32 nLen) noexcept
449
0
{
450
0
    return rtl::str::replaceChars(rtl::str::with_length(pStr, nLen), rtl::str::toAsciiUpper);
451
0
}
452
453
0
sal_Int32 SAL_CALL rtl_str_trim(char* pStr) noexcept { return rtl::str::trim(pStr); }
454
455
sal_Int32 SAL_CALL rtl_str_trim_WithLength(char* pStr, sal_Int32 nLen) noexcept
456
0
{
457
0
    return rtl::str::trim_WithLength(pStr, nLen);
458
0
}
459
460
sal_Int32 SAL_CALL rtl_str_valueOfBoolean(char* pStr, sal_Bool b) noexcept
461
0
{
462
0
    return rtl::str::valueOfBoolean(pStr, b);
463
0
}
464
465
sal_Int32 SAL_CALL rtl_str_valueOfChar(char* pStr, char c) noexcept
466
0
{
467
0
    return rtl::str::valueOfChar(pStr, c);
468
0
}
469
470
sal_Int32 SAL_CALL rtl_str_valueOfInt32(char* pStr, sal_Int32 n, sal_Int16 nRadix) noexcept
471
19.8M
{
472
19.8M
    return rtl::str::valueOfInt<RTL_STR_MAX_VALUEOFINT32>(pStr, n, nRadix);
473
19.8M
}
474
475
sal_Int32 SAL_CALL rtl_str_valueOfInt64(char* pStr, sal_Int64 n, sal_Int16 nRadix) noexcept
476
165k
{
477
165k
    return rtl::str::valueOfInt<RTL_STR_MAX_VALUEOFINT64>(pStr, n, nRadix);
478
165k
}
479
480
sal_Int32 SAL_CALL rtl_str_valueOfUInt64(char* pStr, sal_uInt64 n, sal_Int16 nRadix) noexcept
481
561k
{
482
561k
    return rtl::str::valueOfInt<RTL_STR_MAX_VALUEOFUINT64>(pStr, n, nRadix);
483
561k
}
484
485
sal_Bool SAL_CALL rtl_str_toBoolean(const char* pStr) noexcept
486
69
{
487
69
    return rtl::str::toBoolean(pStr);
488
69
}
489
490
sal_Int32 SAL_CALL rtl_str_toInt32(const char* pStr, sal_Int16 nRadix) noexcept
491
628
{
492
628
    return rtl::str::toInt<sal_Int32>(rtl::str::null_terminated(pStr), nRadix);
493
628
}
494
495
sal_Int64 SAL_CALL rtl_str_toInt64(const char* pStr, sal_Int16 nRadix) noexcept
496
0
{
497
0
    return rtl::str::toInt<sal_Int64>(rtl::str::null_terminated(pStr), nRadix);
498
0
}
499
500
sal_Int64 SAL_CALL rtl_str_toInt64_WithLength(const char* pStr, sal_Int16 nRadix,
501
                                              sal_Int32 nStrLength) noexcept
502
10.9M
{
503
10.9M
    return rtl::str::toInt<sal_Int64>(rtl::str::with_length(pStr, nStrLength), nRadix);
504
10.9M
}
505
506
sal_uInt32 SAL_CALL rtl_str_toUInt32(const char* pStr, sal_Int16 nRadix) noexcept
507
0
{
508
0
    return rtl::str::toInt<sal_uInt32>(rtl::str::null_terminated(pStr), nRadix);
509
0
}
510
511
sal_uInt64 SAL_CALL rtl_str_toUInt64(const char* pStr, sal_Int16 nRadix) noexcept
512
0
{
513
0
    return rtl::str::toInt<sal_uInt64>(rtl::str::null_terminated(pStr), nRadix);
514
0
}
515
516
46.5M
rtl_String* rtl_string_ImplAlloc(sal_Int32 nLen) { return rtl::str::Alloc<rtl_String>(nLen); }
517
518
void SAL_CALL rtl_string_acquire(rtl_String* pThis) noexcept
519
17.9M
{
520
17.9M
    return rtl::str::acquire(pThis);
521
17.9M
}
522
523
void SAL_CALL rtl_string_release(rtl_String* pThis) noexcept
524
196M
{
525
196M
    return rtl::str::release(pThis);
526
196M
}
527
528
void SAL_CALL rtl_string_new(rtl_String** ppThis) noexcept
529
33.6M
{
530
33.6M
    return rtl::str::new_(ppThis);
531
33.6M
}
532
533
rtl_String* SAL_CALL rtl_string_alloc(sal_Int32 nLen) noexcept
534
16.8M
{
535
16.8M
    assert(nLen >= 0);
536
16.8M
    return rtl::str::Alloc<rtl_String>(nLen);
537
16.8M
}
538
539
void SAL_CALL rtl_string_new_WithLength(rtl_String** ppThis, sal_Int32 nLen) noexcept
540
23.1M
{
541
23.1M
    rtl::str::new_WithLength(ppThis, nLen);
542
23.1M
}
543
544
void SAL_CALL rtl_string_newFromString(rtl_String** ppThis, const rtl_String* pStr) noexcept
545
0
{
546
0
    rtl::str::newFromString(ppThis, pStr);
547
0
}
548
549
void SAL_CALL rtl_string_newFromStr(rtl_String** ppThis, const char* pCharStr) noexcept
550
5.94M
{
551
5.94M
    rtl::str::newFromStr(ppThis, pCharStr);
552
5.94M
}
553
554
void SAL_CALL rtl_string_newFromStr_WithLength(rtl_String** ppThis, const char* pCharStr,
555
                                               sal_Int32 nLen) noexcept
556
2.83M
{
557
2.83M
    rtl::str::newFromStr_WithLength(ppThis, pCharStr, nLen);
558
2.83M
}
559
560
void SAL_CALL rtl_string_newFromSubString(rtl_String** ppThis, const rtl_String* pFrom,
561
                                          sal_Int32 beginIndex, sal_Int32 count) noexcept
562
1.44M
{
563
1.44M
    rtl::str::newFromSubString(ppThis, pFrom, beginIndex, count);
564
1.44M
}
565
566
// Used when creating from string literals.
567
void SAL_CALL rtl_string_newFromLiteral(rtl_String** ppThis, const char* pCharStr, sal_Int32 nLen,
568
                                        sal_Int32 allocExtra) noexcept
569
2.62k
{
570
2.62k
    rtl::str::newFromStr_WithLength(ppThis, pCharStr, nLen, allocExtra);
571
2.62k
}
572
573
void SAL_CALL rtl_string_assign(rtl_String** ppThis, rtl_String* pStr) noexcept
574
1.32M
{
575
1.32M
    rtl::str::assign(ppThis, pStr);
576
1.32M
}
577
578
sal_Int32 SAL_CALL rtl_string_getLength(const rtl_String* pThis) noexcept
579
0
{
580
0
    return rtl::str::getLength(pThis);
581
0
}
582
583
char* SAL_CALL rtl_string_getStr(rtl_String* pThis) noexcept
584
142k
{
585
142k
    return rtl::str::getStr(pThis);
586
142k
}
587
588
void SAL_CALL rtl_string_newConcat(rtl_String** ppThis, rtl_String* pLeft, rtl_String* pRight) noexcept
589
207k
{
590
207k
    rtl::str::newConcat(ppThis, pLeft, pRight);
591
207k
}
592
593
void SAL_CALL rtl_string_ensureCapacity(rtl_String** ppThis, sal_Int32 size) noexcept
594
3.51M
{
595
3.51M
    rtl::str::ensureCapacity(ppThis, size);
596
3.51M
}
597
598
void SAL_CALL rtl_string_newReplaceStrAt(rtl_String** ppThis, rtl_String* pStr, sal_Int32 nIndex,
599
                                         sal_Int32 nCount, rtl_String* pNewSubStr) noexcept
600
0
{
601
0
    rtl::str::newReplaceStrAt(ppThis, pStr, nIndex, nCount, pNewSubStr);
602
0
}
603
604
void SAL_CALL rtl_string_newReplaceStrAt_WithLength(rtl_String** ppThis, rtl_String* pStr, sal_Int32 nIndex,
605
                                         sal_Int32 nCount, char const * subStr, sal_Int32 substrLen) noexcept
606
4.56k
{
607
4.56k
    rtl::str::newReplaceStrAt(ppThis, pStr, nIndex, nCount, subStr, substrLen);
608
4.56k
}
609
610
void SAL_CALL rtl_string_newReplace(rtl_String** ppThis, rtl_String* pStr, char cOld, char cNew) noexcept
611
0
{
612
0
    rtl::str::newReplaceChars(ppThis, pStr, rtl::str::FromTo(cOld, cNew));
613
0
}
614
615
void SAL_CALL rtl_string_newToAsciiLowerCase(rtl_String** ppThis, rtl_String* pStr) noexcept
616
11.7k
{
617
11.7k
    rtl::str::newReplaceChars(ppThis, pStr, rtl::str::toAsciiLower);
618
11.7k
}
619
620
void SAL_CALL rtl_string_newToAsciiUpperCase(rtl_String** ppThis, rtl_String* pStr) noexcept
621
325
{
622
325
    rtl::str::newReplaceChars(ppThis, pStr, rtl::str::toAsciiUpper);
623
325
}
624
625
void SAL_CALL rtl_string_newTrim(rtl_String** ppThis, rtl_String* pStr) noexcept
626
0
{
627
0
    rtl::str::newTrim(ppThis, pStr);
628
0
}
629
630
sal_Int32 SAL_CALL rtl_string_getToken(rtl_String** ppThis, rtl_String* pStr, sal_Int32 nToken,
631
                                       char cTok, sal_Int32 nIndex) noexcept
632
309
{
633
309
    return rtl::str::getToken(ppThis, pStr, nToken, cTok, nIndex);
634
309
}
635
636
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */