aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-01-24 21:48:50 +0000
committerJordan Rose <jordan_rose@apple.com>2013-01-24 21:48:50 +0000
commit6c23bd2890acdc87b9d52ac65108d36ecb703c0b (patch)
treedc69923f4ba2b13ac08eb95b9c0508aaa78123e7
parent4055cfc46a5beb13d0daeace53ac3fe56a1f4ad1 (diff)
Move 'convertUTF8Sequence' helper into the C++ section of the header file.
It's annotated as "inline", but ConvertUTF.c should still be able to compile as C89. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173376 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/ConvertUTF.h36
1 files changed, 26 insertions, 10 deletions
diff --git a/include/clang/Basic/ConvertUTF.h b/include/clang/Basic/ConvertUTF.h
index 38956ee340..2d13d2c2b9 100644
--- a/include/clang/Basic/ConvertUTF.h
+++ b/include/clang/Basic/ConvertUTF.h
@@ -161,16 +161,6 @@ Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd);
unsigned getNumBytesForUTF8(UTF8 firstByte);
-static inline ConversionResult convertUTF8Sequence(const UTF8 **source,
- const UTF8 *sourceEnd,
- UTF32 *target,
- ConversionFlags flags) {
- unsigned size = getNumBytesForUTF8(**source);
- if (size > sourceEnd - *source)
- return sourceExhausted;
- return ConvertUTF8toUTF32(source, *source + size, &target, target + 1, flags);
-}
-
#ifdef __cplusplus
}
@@ -205,6 +195,32 @@ bool ConvertUTF8toWide(unsigned WideCharWidth, llvm::StringRef Source,
*/
bool ConvertCodePointToUTF8(unsigned Source, char *&ResultPtr);
+/**
+ * Convert the first UTF8 sequence in the given source buffer to a UTF32
+ * code point.
+ *
+ * \param [in,out] source A pointer to the source buffer. If the conversion
+ * succeeds, this pointer will be updated to point to the byte just past the
+ * end of the converted sequence.
+ * \param sourceEnd A pointer just past the end of the source buffer.
+ * \param [out] target The converted code
+ * \param flags Whether the conversion is strict or lenient.
+ *
+ * \returns conversionOK on success
+ *
+ * \sa ConvertUTF8toUTF32
+ */
+static inline ConversionResult convertUTF8Sequence(const UTF8 **source,
+ const UTF8 *sourceEnd,
+ UTF32 *target,
+ ConversionFlags flags) {
+ if (*source == sourceEnd)
+ return sourceExhausted;
+ unsigned size = getNumBytesForUTF8(**source);
+ if (size > sourceEnd - *source)
+ return sourceExhausted;
+ return ConvertUTF8toUTF32(source, *source + size, &target, target + 1, flags);
+}
}
#endif