[cfe-commits] r173376 - /cfe/trunk/include/clang/Basic/ConvertUTF.h

Jordan Rose jordan_rose at apple.com
Thu Jan 24 13:48:50 PST 2013


Author: jrose
Date: Thu Jan 24 15:48:50 2013
New Revision: 173376

URL: http://llvm.org/viewvc/llvm-project?rev=173376&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Basic/ConvertUTF.h

Modified: cfe/trunk/include/clang/Basic/ConvertUTF.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ConvertUTF.h?rev=173376&r1=173375&r2=173376&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/ConvertUTF.h (original)
+++ cfe/trunk/include/clang/Basic/ConvertUTF.h Thu Jan 24 15:48:50 2013
@@ -161,16 +161,6 @@
 
 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 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





More information about the cfe-commits mailing list