integrate change#3115 from maint-5.005
[p5sagit/p5-mst-13.2.git] / pp.c
diff --git a/pp.c b/pp.c
index d5b7081..b03acf3 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -1,6 +1,6 @@
 /*    pp.c
  *
- *    Copyright (c) 1991-1997, Larry Wall
+ *    Copyright (c) 1991-1999, Larry Wall
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -78,6 +78,9 @@ typedef unsigned UBW;
 #define SIZE16 2
 #define SIZE32 4
 
+/* CROSSCOMPILE and MULTIARCH are going to affect pp_pack() and pp_unpack().
+   --jhi Feb 1999 */
+
 #if SHORTSIZE != SIZE16 || LONGSIZE != SIZE32
 #   define PERL_NATINT_PACK
 #endif
@@ -3271,7 +3274,7 @@ PP(pp_unpack)
 #endif
        if (isSPACE(datumtype))
            continue;
-       if (*pat == '_') {
+       if (*pat == '!') {
            char *natstr = "sSiIlL";
 
            if (strchr(natstr, datumtype)) {
@@ -3281,7 +3284,7 @@ PP(pp_unpack)
                pat++;
            }
            else
-               croak("'_' allowed only after types %s", natstr);
+               croak("'!' allowed only after types %s", natstr);
        }
        if (pat >= patend)
            len = 1;
@@ -3549,6 +3552,10 @@ PP(pp_unpack)
                 {
                    while (len-- > 0) {
                        COPY16(s, &ashort);
+#if SHORTSIZE > SIZE16
+                       if (ashort > 32767)
+                         ashort -= 65536;
+#endif
                        s += SIZE16;
                        culong += ashort;
                    }
@@ -3572,6 +3579,10 @@ PP(pp_unpack)
                 {
                    while (len-- > 0) {
                        COPY16(s, &ashort);
+#if SHORTSIZE > SIZE16
+                       if (ashort > 32767)
+                         ashort -= 65536;
+#endif
                        s += SIZE16;
                        sv = NEWSV(38, 0);
                        sv_setiv(sv, (IV)ashort);
@@ -3747,6 +3758,10 @@ PP(pp_unpack)
                 {
                    while (len-- > 0) {
                        COPY32(s, &along);
+#if LONGSIZE > SIZE32
+                       if (along > 2147483647)
+                         along -= 4294967296;
+#endif
                        s += SIZE32;
                        if (checksum > 32)
                            cdouble += (double)along;
@@ -3773,6 +3788,10 @@ PP(pp_unpack)
                 {
                    while (len-- > 0) {
                        COPY32(s, &along);
+#if LONGSIZE > SIZE32
+                       if (along > 2147483647)
+                         along -= 4294967296;
+#endif
                        s += SIZE32;
                        sv = NEWSV(42, 0);
                        sv_setiv(sv, (IV)along);
@@ -4275,7 +4294,7 @@ PP(pp_pack)
 #endif
        if (isSPACE(datumtype))
            continue;
-        if (*pat == '_') {
+        if (*pat == '!') {
            char *natstr = "sSiIlL";
 
            if (strchr(natstr, datumtype)) {
@@ -4285,7 +4304,7 @@ PP(pp_pack)
                pat++;
            }
            else
-               croak("'_' allowed only after types %s", natstr);
+               croak("'!' allowed only after types %s", natstr);
        }
        if (*pat == '*') {
            len = strchr("@Xxu", datumtype) ? 0 : items;
@@ -4555,7 +4574,7 @@ PP(pp_pack)
            }
            break;
        case 's':
-#if SHORTSIZE != 2
+#if SHORTSIZE != SIZE16
            if (natint) {
                while (len-- > 0) {
                    fromstr = NEXTFROM;