summaryrefslogtreecommitdiff
path: root/inline.h
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2013-02-09 21:23:30 -0700
committerKarl Williamson <public@khwilliamson.com>2013-08-29 09:55:50 -0600
commit55d09dc854b450c4051bea8318009a46a7c083f7 (patch)
tree8236a7ebb103a8d309b420bfa8761d2508cb626e /inline.h
parentc12874164f0487ef49dc48d5e4263b86b4b87f5d (diff)
downloadperl-55d09dc854b450c4051bea8318009a46a7c083f7.tar.gz
Extract common code to an inline function
This fairly short paradigm is repeated in several places; a later commit will improve it.
Diffstat (limited to 'inline.h')
-rw-r--r--inline.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/inline.h b/inline.h
index 066edf1bda..63a5e064d1 100644
--- a/inline.h
+++ b/inline.h
@@ -203,8 +203,26 @@ S_croak_memory_wrap(void)
/* ------------------------------- utf8.h ------------------------------- */
-/* These exist only to replace the macros they formerly were so that their use
- * can be deprecated */
+PERL_STATIC_INLINE void
+S_append_utf8_from_native_byte(const U8 byte, U8** dest)
+{
+ /* Takes an input 'byte' (Latin1 or EBCDIC) and appends it to the UTF-8
+ * encoded string at '*dest', updating '*dest' to include it */
+
+ const U8 uv = NATIVE_TO_LATIN1(byte);
+
+ PERL_ARGS_ASSERT_APPEND_UTF8_FROM_NATIVE_BYTE;
+
+ if (UNI_IS_INVARIANT(uv))
+ *(*dest)++ = UNI_TO_NATIVE(uv);
+ else {
+ *(*dest)++ = UTF8_EIGHT_BIT_HI(uv);
+ *(*dest)++ = UTF8_EIGHT_BIT_LO(uv);
+ }
+}
+
+/* These two exist only to replace the macros they formerly were so that their
+ * use can be deprecated */
PERL_STATIC_INLINE bool
S_isIDFIRST_lazy(pTHX_ const char* p)