MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / pad_spaces

Function pad_spaces

src/jrd/intl.cpp:1342–1383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1340
1341
1342static void pad_spaces(thread_db* tdbb, CHARSET_ID charset, BYTE* ptr, ULONG len)
1343{ /* byte count */
1344/**************************************
1345 *
1346 * p a d _ s p a c e s
1347 *
1348 **************************************
1349 *
1350 * Functional description
1351 * Pad a buffer with the character set defined space character.
1352 *
1353 **************************************/
1354 SET_TDBB(tdbb);
1355
1356 fb_assert(ptr != NULL);
1357
1358 CharSet* obj = INTL_charset_lookup(tdbb, charset);
1359
1360 // Single-octet character sets are optimized here
1361 if (obj->getSpaceLength() == 1)
1362 {
1363 const BYTE* const end = &ptr[len];
1364 while (ptr < end)
1365 *ptr++ = *obj->getSpace();
1366 }
1367 else
1368 {
1369 const BYTE* const end = &ptr[len];
1370 const UCHAR* space = obj->getSpace();
1371 const UCHAR* const end_space = &space[obj->getSpaceLength()];
1372 while (ptr < end)
1373 {
1374 space = obj->getSpace();
1375 while (ptr < end && space < end_space) {
1376 *ptr++ = *space++;
1377 }
1378 // This fb_assert is checking that we didn't have a buffer-end
1379 // in the middle of a space character
1380 fb_assert(!(ptr == end) || (space == end_space));
1381 }
1382 }
1383}

Callers 2

INTL_convert_stringFunction · 0.85
INTL_pad_spacesFunction · 0.85

Calls 4

SET_TDBBFunction · 0.85
INTL_charset_lookupFunction · 0.85
getSpaceLengthMethod · 0.80
getSpaceMethod · 0.45

Tested by

no test coverage detected