[ion] unicode: UTF8Helper::CopyAndRemoveCodePoints returns a boolean

which is true if the whole source was copied
This commit is contained in:
Émilie Feral
2020-02-03 11:01:39 +01:00
committed by Léa Saviot
parent 0a61e0f7bc
commit 0c55ea4531
2 changed files with 6 additions and 5 deletions

View File

@@ -22,7 +22,7 @@ const char * NotCodePointSearch(const char * s, CodePoint c, bool goingLeft = fa
/* Copy src into dst while removing all code points in codePoints. Ensure null-
* termination of dst. */
void CopyAndRemoveCodePoints(char * dst, size_t dstSize, const char * src, CodePoint * codePoints, int numberOfCodePoints);
bool CopyAndRemoveCodePoints(char * dst, size_t dstSize, const char * src, CodePoint * codePoints, int numberOfCodePoints);
/* Remove all code points c. and update an index that should be lower if code
* points where removed before it. Ensure null-termination of dst. */

View File

@@ -94,14 +94,14 @@ const char * NotCodePointSearch(const char * s, CodePoint c, bool goingLeft, con
return codePointPointer;
}
void CopyAndRemoveCodePoints(char * dst, size_t dstSize, const char * src, CodePoint * codePoints, int numberOfCodePoints) {
bool CopyAndRemoveCodePoints(char * dst, size_t dstSize, const char * src, CodePoint * codePoints, int numberOfCodePoints) {
UTF8Decoder decoder(src);
CodePoint codePoint = decoder.nextCodePoint();
if (dstSize <= 0) {
return;
return codePoint == UCodePointNull;
}
assert(numberOfCodePoints >= 1);
UTF8Decoder decoder(src);
const char * currentPointer = src;
CodePoint codePoint = decoder.nextCodePoint();
const char * nextPointer = decoder.stringPosition();
size_t bufferIndex = 0;
@@ -128,6 +128,7 @@ void CopyAndRemoveCodePoints(char * dst, size_t dstSize, const char * src, CodeP
nextPointer = decoder.stringPosition();
}
*(dst + bufferIndex) = 0;
return codePoint == UCodePointNull;
}
void RemoveCodePoint(char * buffer, CodePoint c, const char * * pointerToUpdate, const char * stoppingPosition) {