]> gcc.gnu.org Git - gcc.git/commitdiff
libphobos: Merge upstream phobos b538f758a
authorIain Buclaw <ibuclaw@gcc.gnu.org>
Mon, 22 Apr 2019 13:46:25 +0000 (13:46 +0000)
committerIain Buclaw <ibuclaw@gcc.gnu.org>
Mon, 22 Apr 2019 13:46:25 +0000 (13:46 +0000)
Fixes endian bugs in std.uni, and corrects unit-tests that failed on
version(BigEndian) targets.

Initial patch by Robin Dapp.

Reviewed-on: https://github.com/dlang/phobos/pull/6975

From-SVN: r270491

libphobos/src/MERGE
libphobos/src/std/net/curl.d
libphobos/src/std/outbuffer.d
libphobos/src/std/uni.d
libphobos/src/std/xml.d

index 3935c059403399a9f5b8f1390ceb82785cc5a202..e4807fbf437c500223e122832ec2852902a67313 100644 (file)
@@ -1,4 +1,4 @@
-428460ddd8087fa28815e613ff04facb51108a7b
+b538f758a4d274b64751f80564b0207845cd018c
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/phobos repository.
index e3ce527c30314d1dd0d4d2717bed8107348943ea..32ba45ce2de7c222265af63614d70f98483f988c 100644 (file)
@@ -207,9 +207,7 @@ version (unittest)
             }
             catch (Throwable e)
             {
-                import core.stdc.stdlib : exit, EXIT_FAILURE;
-                stderr.writeln(e);
-                exit(EXIT_FAILURE); // Bugzilla 7018
+                stderr.writeln(e);  // Bugzilla 7018
             }
         }
     }
index 1d594982cc1a81b90747b4ff9b41a3a975ca2315..d76ead2ed4979b810a2a701296b2c1464c7d5791 100644 (file)
@@ -408,11 +408,17 @@ class OutBuffer
   {
     OutBuffer buf = new OutBuffer();
     "hello"w.copy(buf);
-    assert(buf.toBytes() == "h\x00e\x00l\x00l\x00o\x00");
+    version (LittleEndian)
+        assert(buf.toBytes() == "h\x00e\x00l\x00l\x00o\x00");
+    version (BigEndian)
+        assert(buf.toBytes() == "\x00h\x00e\x00l\x00l\x00o");
   }
   {
     OutBuffer buf = new OutBuffer();
     "hello"d.copy(buf);
-    assert(buf.toBytes() == "h\x00\x00\x00e\x00\x00\x00l\x00\x00\x00l\x00\x00\x00o\x00\x00\x00");
+    version (LittleEndian)
+        assert(buf.toBytes() == "h\x00\x00\x00e\x00\x00\x00l\x00\x00\x00l\x00\x00\x00o\x00\x00\x00");
+    version (BigEndian)
+        assert(buf.toBytes() == "\x00\x00\x00h\x00\x00\x00e\x00\x00\x00l\x00\x00\x00l\x00\x00\x00o");
   }
 }
index 5f24ad16be5f27cb7baac392e5d1ab4e832dd731..0b3da58286c128047fe4fd2e8814e5b21d326c4f 100644 (file)
@@ -770,6 +770,8 @@ version (X86)
     enum hasUnalignedReads = true;
 else version (X86_64)
     enum hasUnalignedReads = true;
+else version (SystemZ)
+    enum hasUnalignedReads = true;
 else
     enum hasUnalignedReads = false; // better be safe then sorry
 
@@ -1245,8 +1247,13 @@ pure nothrow:
 
         T opIndex(size_t idx) inout
         {
-            return __ctfe ? simpleIndex(idx) :
-                cast(inout(T))(cast(U*) origin)[idx];
+            T ret;
+            version (LittleEndian)
+                ret = __ctfe ? simpleIndex(idx) :
+                    cast(inout(T))(cast(U*) origin)[idx];
+            else
+                ret = simpleIndex(idx);
+            return ret;
         }
 
         static if (isBitPacked!T) // lack of user-defined implicit conversion
@@ -1259,10 +1266,15 @@ pure nothrow:
 
         void opIndexAssign(TypeOfBitPacked!T val, size_t idx)
         {
-            if (__ctfe)
-                simpleWrite(val, idx);
+            version (LittleEndian)
+            {
+                if (__ctfe)
+                    simpleWrite(val, idx);
+                else
+                    (cast(U*) origin)[idx] = cast(U) val;
+            }
             else
-                (cast(U*) origin)[idx] = cast(U) val;
+                simpleWrite(val, idx);
         }
     }
     else
index 770c56fdbfbe8ca53de68e4eddc7bbb40ce7f39a..13241f53613f6e719bdb0437b94e089068cd6445 100644 (file)
@@ -2201,8 +2201,10 @@ private
         mixin Check!("Chars");
 
         dchar c;
-        int n = -1;
-        foreach (int i,dchar d; s)
+        ptrdiff_t n = -1;
+        // 'i' must not be smaller than size_t because size_t is used internally in
+        // aApply.d and it will be cast e.g to (int *) which fails on BigEndian targets.
+        foreach (size_t i, dchar d; s)
         {
             if (!isChar(d))
             {
@@ -2238,8 +2240,10 @@ private
         mixin Check!("Name");
 
         if (s.length == 0) fail();
-        int n;
-        foreach (int i,dchar c;s)
+        ptrdiff_t n;
+        // 'i' must not be smaller than size_t because size_t is used internally in
+        // aApply.d and it will be cast e.g to (int *) which fails on BigEndian targets.
+        foreach (size_t i, dchar c; s)
         {
             if (c == '_' || c == ':' || isLetter(c)) continue;
             if (i == 0) fail();
This page took 0.074222 seconds and 5 git commands to generate.