diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Support/ConvertUTF.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Support/ConvertUTF.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/contrib/llvm-project/llvm/lib/Support/ConvertUTF.cpp b/contrib/llvm-project/llvm/lib/Support/ConvertUTF.cpp index e24a918c5c89..5436f557b993 100644 --- a/contrib/llvm-project/llvm/lib/Support/ConvertUTF.cpp +++ b/contrib/llvm-project/llvm/lib/Support/ConvertUTF.cpp @@ -417,6 +417,16 @@ Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) { return isLegalUTF8(source, length); } +/* + * Exported function to return the size of the first utf-8 code unit sequence, + * Or 0 if the sequence is not valid; + */ +unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) { + int length = trailingBytesForUTF8[*source] + 1; + return (length <= sourceEnd - source && isLegalUTF8(source, length)) ? length + : 0; +} + /* --------------------------------------------------------------------- */ static unsigned |