2003-07-22 Jerome Laban <jlaban@wanadoo.fr>
authorJerome Laban <jerome@mono-cvs.ximian.com>
Tue, 22 Jul 2003 19:15:43 +0000 (19:15 -0000)
committerJerome Laban <jerome@mono-cvs.ximian.com>
Tue, 22 Jul 2003 19:15:43 +0000 (19:15 -0000)
* Guid.cs: Fixed ToString (), was producing incorrect string.

svn path=/trunk/mcs/; revision=16539

mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/Guid.cs

index a8f6eaac13c38c206cd22b25f66f61e95a2a339e..b98da56deb1408b9417fd75bf8cef03a2bccf054 100644 (file)
@@ -1,3 +1,6 @@
+2003-07-22  Jerome Laban <jlaban@wanadoo.fr>
+
+       * Guid.cs: Fixed ToString (), was producing incorrect string.
 
 2003-07-20  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
index eaa1a0e09a9426f39f22e0a563496944a87a2daa..8df2b5fda9abda4b561979c1f858b0334f63ecba 100755 (executable)
@@ -518,6 +518,11 @@ public struct Guid  : IFormattable, IComparable  {
                return res;
        }
 
+       private static char ToHex(int b)
+       {
+               return (char)((b<0xA)?('0' + b):('a' + b - 0xA));
+       }
+
        [MonoTODO]
        public static Guid NewGuid ()
        {
@@ -580,25 +585,36 @@ public struct Guid  : IFormattable, IComparable  {
                if (h) {
                        res.Append ('-');
                }
-               res.Append ((char)('0' + ((_clockSeqHiAndReserved >> 4) & 0xf)));
-               res.Append ((char)('0' + (_clockSeqHiAndReserved & 0xf)));
-               res.Append ((char)('0' + ((_clockSeqLow >> 4) & 0xf)));
-               res.Append ((char)('0' + (_clockSeqLow & 0xf)));
+
+               char[] vals1 = {
+                                                  ToHex((_clockSeqHiAndReserved >> 4) & 0xf),
+                                                  ToHex(_clockSeqHiAndReserved & 0xf),
+                                                  ToHex((_clockSeqLow >> 4) & 0xf),
+                                                  ToHex(_clockSeqLow & 0xf)
+                                          };
+
+               res.Append (vals1);
+
                if (h) {
                        res.Append ('-');
                }
-               res.Append ((char)('0' + ((_node0 >> 4) & 0xf)));
-               res.Append ((char)('0' + (_node0 & 0xf)));
-               res.Append ((char)('0' + ((_node1 >> 4) & 0xf)));
-               res.Append ((char)('0' + (_node1 & 0xf)));
-               res.Append ((char)('0' + ((_node2 >> 4) & 0xf)));
-               res.Append ((char)('0' + (_node2 & 0xf)));
-               res.Append ((char)('0' + ((_node3 >> 4) & 0xf)));
-               res.Append ((char)('0' + (_node3 & 0xf)));
-               res.Append ((char)('0' + ((_node4 >> 4) & 0xf)));
-               res.Append ((char)('0' + (_node4 & 0xf)));
-               res.Append ((char)('0' + ((_node5 >> 4) & 0xf)));
-               res.Append ((char)('0' + (_node5 & 0xf)));
+       
+               char[] vals2 = {
+                                                 ToHex((_node0 >> 4) & 0xf),
+                                                 ToHex(_node0 & 0xf),
+                                                 ToHex((_node1 >> 4) & 0xf),
+                                                 ToHex(_node1 & 0xf),
+                                                 ToHex((_node2 >> 4) & 0xf),
+                                                 ToHex(_node2 & 0xf),
+                                                 ToHex((_node3 >> 4) & 0xf),
+                                                 ToHex(_node3 & 0xf),
+                                                 ToHex((_node4 >> 4) & 0xf),
+                                                 ToHex(_node4 & 0xf),
+                                                 ToHex((_node5 >> 4) & 0xf),
+                                                 ToHex(_node5 & 0xf)
+               };
+
+               res.Append (vals2);
 
                if (p) {
                        res.Append (')');