summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2013-02-25 20:14:26 -0700
committerKarl Williamson <public@khwilliamson.com>2013-08-29 09:55:57 -0600
commit010ab96b9b802bbf77168b5af384569e053cdb63 (patch)
tree0e860c4bd54c6c7af3e507314217fac9f8c88518
parent38bce45e4f5366ae2508941b451d5710880a4c22 (diff)
downloadperl-010ab96b9b802bbf77168b5af384569e053cdb63.tar.gz
utf8.c: Swap which fcn wraps the other
This is in preparation for the current wrapee becoming deprecated
-rw-r--r--embed.fnc3
-rw-r--r--embed.h2
-rw-r--r--proto.h15
-rw-r--r--utf8.c52
-rw-r--r--utf8.h1
5 files changed, 32 insertions, 41 deletions
diff --git a/embed.fnc b/embed.fnc
index 0331056ee1..6960b1375c 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -1549,11 +1549,10 @@ pM |bool |check_utf8_print |NN const U8 *s|const STRLEN len
#ifdef EBCDIC
Adp |UV |utf8n_to_uvchr |NN const U8 *s|STRLEN curlen|NULLOK STRLEN *retlen|U32 flags
-ApM |UV |valid_utf8_to_uvchr |NN const U8 *s|NULLOK STRLEN *retlen
#else
Adpbm |UV |utf8n_to_uvchr |NN const U8 *s|STRLEN curlen|NULLOK STRLEN *retlen|U32 flags
-ApbmM |UV |valid_utf8_to_uvchr |NN const U8 *s|NULLOK STRLEN *retlen
#endif
+ApM |UV |valid_utf8_to_uvchr |NN const U8 *s|NULLOK STRLEN *retlen
Adp |UV |utf8n_to_uvuni |NN const U8 *s|STRLEN curlen|NULLOK STRLEN *retlen|U32 flags
diff --git a/embed.h b/embed.h
index 9d31874a30..d15099113c 100644
--- a/embed.h
+++ b/embed.h
@@ -699,6 +699,7 @@
#define utf8n_to_uvuni(a,b,c,d) Perl_utf8n_to_uvuni(aTHX_ a,b,c,d)
#define uvchr_to_utf8_flags(a,b,c) Perl_uvchr_to_utf8_flags(aTHX_ a,b,c)
#define uvuni_to_utf8_flags(a,b,c) Perl_uvuni_to_utf8_flags(aTHX_ a,b,c)
+#define valid_utf8_to_uvchr(a,b) Perl_valid_utf8_to_uvchr(aTHX_ a,b)
#define valid_utf8_to_uvuni(a,b) Perl_valid_utf8_to_uvuni(aTHX_ a,b)
#define vcmp(a,b) Perl_vcmp(aTHX_ a,b)
#define vcroak(a,b) Perl_vcroak(aTHX_ a,b)
@@ -762,7 +763,6 @@
#if defined(EBCDIC)
#define utf8n_to_uvchr(a,b,c,d) Perl_utf8n_to_uvchr(aTHX_ a,b,c,d)
#define uvchr_to_utf8(a,b) Perl_uvchr_to_utf8(aTHX_ a,b)
-#define valid_utf8_to_uvchr(a,b) Perl_valid_utf8_to_uvchr(aTHX_ a,b)
#endif
#if defined(HAS_SIGACTION) && defined(SA_SIGINFO)
#define csighandler Perl_csighandler
diff --git a/proto.h b/proto.h
index 51e4009aa9..458b073684 100644
--- a/proto.h
+++ b/proto.h
@@ -4786,6 +4786,11 @@ PERL_CALLCONV U8* Perl_uvuni_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags)
#define PERL_ARGS_ASSERT_UVUNI_TO_UTF8_FLAGS \
assert(d)
+PERL_CALLCONV UV Perl_valid_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
+ __attribute__nonnull__(pTHX_1);
+#define PERL_ARGS_ASSERT_VALID_UTF8_TO_UVCHR \
+ assert(s)
+
PERL_CALLCONV UV Perl_valid_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_VALID_UTF8_TO_UVUNI \
@@ -4983,11 +4988,6 @@ STATIC int S_sv_2iuv_non_preserve(pTHX_ SV *const sv)
#define PERL_ARGS_ASSERT_UVCHR_TO_UTF8 \
assert(d)
-/* PERL_CALLCONV UV Perl_valid_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
- __attribute__nonnull__(pTHX_1); */
-#define PERL_ARGS_ASSERT_VALID_UTF8_TO_UVCHR \
- assert(s)
-
#endif
#if !(defined(HAS_SIGACTION) && defined(SA_SIGINFO))
PERL_CALLCONV Signal_t Perl_csighandler(int sig);
@@ -5326,11 +5326,6 @@ PERL_CALLCONV U8* Perl_uvchr_to_utf8(pTHX_ U8 *d, UV uv)
#define PERL_ARGS_ASSERT_UVCHR_TO_UTF8 \
assert(d)
-PERL_CALLCONV UV Perl_valid_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
- __attribute__nonnull__(pTHX_1);
-#define PERL_ARGS_ASSERT_VALID_UTF8_TO_UVCHR \
- assert(s)
-
#endif
#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
PERL_CALLCONV I32 Perl_do_ipcctl(pTHX_ I32 optype, SV** mark, SV** sp)
diff --git a/utf8.c b/utf8.c
index 4e27e0afc4..4ab8c7c2be 100644
--- a/utf8.c
+++ b/utf8.c
@@ -37,7 +37,6 @@
/* Separate prototypes needed because in ASCII systems these are
* usually macros but they still are compiled as code, too. */
PERL_CALLCONV UV Perl_utf8n_to_uvchr(pTHX_ const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags);
-PERL_CALLCONV UV Perl_valid_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen);
PERL_CALLCONV U8* Perl_uvchr_to_utf8(pTHX_ U8 *d, UV uv);
#endif
@@ -934,11 +933,34 @@ Perl_utf8_to_uvchr_buf(pTHX_ const U8 *s, const U8 *send, STRLEN *retlen)
UV
Perl_valid_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
{
- const UV uv = valid_utf8_to_uvuni(s, retlen);
+ UV expectlen = UTF8SKIP(s);
+ const U8* send = s + expectlen;
+ UV uv = NATIVE_UTF8_TO_I8(*s);
PERL_ARGS_ASSERT_VALID_UTF8_TO_UVCHR;
+ if (retlen) {
+ *retlen = expectlen;
+ }
+
+ /* An invariant is trivially returned */
+ if (expectlen == 1) {
+ return LATIN1_TO_NATIVE(uv);
+ }
+
+ /* Remove the leading bits that indicate the number of bytes, leaving just
+ * the bits that are part of the value */
+ uv &= UTF_START_MASK(expectlen);
+
+ /* Now, loop through the remaining bytes, accumulating each into the
+ * working total as we go. (I khw tried unrolling the loop for up to 4
+ * bytes, but there was no performance improvement) */
+ for (++s; s < send; s++) {
+ uv = UTF8_ACCUMULATE(uv, *s);
+ }
+
return UNI_TO_NATIVE(uv);
+
}
/*
@@ -1011,33 +1033,9 @@ Perl_utf8_to_uvuni_buf(pTHX_ const U8 *s, const U8 *send, STRLEN *retlen)
UV
Perl_valid_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
{
- UV expectlen = UTF8SKIP(s);
- const U8* send = s + expectlen;
- UV uv = NATIVE_UTF8_TO_I8(*s);
-
PERL_ARGS_ASSERT_VALID_UTF8_TO_UVUNI;
- if (retlen) {
- *retlen = expectlen;
- }
-
- /* An invariant is trivially returned */
- if (expectlen == 1) {
- return uv;
- }
-
- /* Remove the leading bits that indicate the number of bytes, leaving just
- * the bits that are part of the value */
- uv &= UTF_START_MASK(expectlen);
-
- /* Now, loop through the remaining bytes, accumulating each into the
- * working total as we go. (I khw tried unrolling the loop for up to 4
- * bytes, but there was no performance improvement) */
- for (++s; s < send; s++) {
- uv = UTF8_ACCUMULATE(uv, *s);
- }
-
- return uv;
+ return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
}
/*
diff --git a/utf8.h b/utf8.h
index f1205a6be5..d8ca84eca8 100644
--- a/utf8.h
+++ b/utf8.h
@@ -125,7 +125,6 @@ END_EXTERN_C
/* As there are no translations, avoid the function wrapper */
#define utf8n_to_uvchr utf8n_to_uvuni
-#define valid_utf8_to_uvchr valid_utf8_to_uvuni
#define uvchr_to_utf8 uvuni_to_utf8
/*