develooper Front page | perl.perl5.porters | Postings from November 2012

Re: [perl #115746] [PATCH] clean up inline string comparisons ingv_fetchpvn_flags

Thread Previous | Thread Next
From:
Tony Cook
Date:
November 15, 2012 16:06
Subject:
Re: [perl #115746] [PATCH] clean up inline string comparisons ingv_fetchpvn_flags
Message ID:
20121116000633.GC11118@mars.tony.develop-help.com
On Thu, Nov 15, 2012 at 11:48:03AM -0800, bulk 88 via RT wrote:
> Forgot to attach.
> 
> ---
> via perlbug:  queue: perl5 status: new
> https://rt.perl.org:443/rt3/Ticket/Display.html?id=115746

                    stash = GvHV(gv) = newHV();
                    if (!HvNAME_get(stash)) {
+#if I32SIZE == 4
+                       const char COREs [4] = "CORE";
+#endif
                        if (GvSTASH(gv) == PL_defstash && len == 6
+#if I32SIZE == 4
+                        && *(I32 *)name == *(I32 *)COREs)
+#else
                         && strnEQ(name, "CORE", 4))
+#endif
                            hv_name_set(stash, "CORE", 4, 0);
+#if I32SIZE == 4
+                   /* assume we have a term null even though len is 3 */
+                   const char INCs [4] = "INC\0"; 
+                   const char ENVs [4] = "ENV\0";
+                   const char SIGs [4] = "SIG\0";
+                   if (*(I32 *)name == *(I32 *)INCs
+                       || *(I32 *)name == *(I32 *)ENVs
+                       || *(I32 *)name == *(I32 *)SIGs)
+#else
+

This code makes non-portable assumptions about alignment, or at least
about accessing unaligned memory as an I32.

Tony

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About