dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System Byte.cs,1.8,1.9 Conver


From: Jonathan Springer <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System Byte.cs,1.8,1.9 Convert.cs,1.7,1.8 Decimal.cs,1.9,1.10 Double.cs,1.8,1.9 Guid.cs,1.3,1.4 Int16.cs,1.9,1.10 Int32.cs,1.9,1.10 Int64.cs,1.8,1.9 SByte.cs,1.9,1.10 Single.cs,1.8,1.9 String.cs,1.28,1.29 UInt16.cs,1.8,1.9 UInt32.cs,1.8,1.9 UInt64.cs,1.8,1.9
Date: Wed, 27 Nov 2002 09:37:29 -0500

Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System
In directory subversions:/tmp/cvs-serv18774/runtime/System

Modified Files:
        Byte.cs Convert.cs Decimal.cs Double.cs Guid.cs Int16.cs 
        Int32.cs Int64.cs SByte.cs Single.cs String.cs UInt16.cs 
        UInt32.cs UInt64.cs 
Log Message:

New number formatting code.


Index: Byte.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Byte.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** Byte.cs     26 Nov 2002 04:00:35 -0000      1.8
--- Byte.cs     27 Nov 2002 14:37:27 -0000      1.9
***************
*** 23,26 ****
--- 23,27 ----
  
  using System.Private;
+ using System.Private.NumberFormat;
  using System.Globalization;
  
***************
*** 53,77 ****
        public override String ToString()
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, null,
!                                                        
NumberFormatInfo.CurrentInfo);
                        }
        public String ToString(String format)
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, format,
!                                                        
NumberFormatInfo.CurrentInfo);
                        }
        public String ToString(IFormatProvider provider)
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, null,
!                                                        
NumberFormatInfo.GetInstance(provider));
                        }
        public String ToString(String format, IFormatProvider provider)
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, format,
!                                                        
NumberFormatInfo.GetInstance(provider));
                        }
  
--- 54,72 ----
        public override String ToString()
                        {
!                               return ToString(null, null);
                        }
        public String ToString(String format)
                        {
!                               return ToString(format, null);
                        }
        public String ToString(IFormatProvider provider)
                        {
!                               return ToString(null, provider);
                        }
        public String ToString(String format, IFormatProvider provider)
                        {
!                               if (format == null) format = "G";
!                               return 
!                                       
Formatter.CreateFormatter(format).Format(this, provider);
                        }
  

Index: Convert.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Convert.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** Convert.cs  17 Jul 2002 04:53:35 -0000      1.7
--- Convert.cs  27 Nov 2002 14:37:27 -0000      1.8
***************
*** 1686,1689 ****
--- 1686,1785 ----
                        }
  #if !ECMA_COMPAT
+       // Format an integer in base 10.
+       private static String FormatBase10(ulong value, bool isneg)
+       {
+               String basic;
+               if(value == 0)
+               {
+                       basic = "0";
+               }
+               else
+               {
+                       basic = "";
+                       while(value != 0)
+                       {
+                               basic = ((char)((value % 10) + (int)'0')) + 
basic;
+                               value /= 10;
+                       }
+               }
+               if(isneg)
+               {
+                       return "-" + basic;
+               }
+               else
+               {
+                       return basic;
+               }
+       }
+ 
+       // Format a number in a specific base.
+       private static String FormatInBase(long value, int toBase, int numBits)
+       {
+               char[] buf;
+               int posn;
+               int digit;
+               if(toBase == 2)
+               {
+                       buf = new char[numBits];
+                       posn = numBits - 1;
+                       while(posn >= 0)
+                       {
+                               if((value & 1) != 0)
+                               {
+                                       buf[posn--] = '1';
+                               }
+                               else
+                               {
+                                       buf[posn--] = '0';
+                               }
+                               value >>= 1;
+                       }
+               }
+               else if(toBase == 8)
+               {
+                       buf = new char[(numBits + 2) / 3];
+                       posn = ((numBits + 2) / 3) - 1;
+                       while(posn >= 0)
+                       {
+                               buf[posn--] = unchecked((char)((value % 8) + 
(long)'0'));
+                               value >>= 3;
+                       }
+               }
+               else if(toBase == 10)
+               {
+                       if(value < 0)
+                       {
+                               return FormatBase10(unchecked((ulong)(-value)), 
true);
+                       }
+                       else
+                       {
+                               return FormatBase10(unchecked((ulong)value), 
false);
+                       }
+               }
+               else if(toBase == 16)
+               {
+                       buf = new char[numBits / 4];
+                       posn = (numBits / 4) - 1;
+                       while(posn >= 0)
+                       {
+                               digit = unchecked((int)(value % 16));
+                               if(digit < 10)
+                               {
+                                       buf[posn--] = unchecked((char)(digit + 
(int)'0'));
+                               }
+                               else
+                               {
+                                       buf[posn--] = unchecked((char)(digit - 
10 + (int)'A'));
+                               }
+                               value >>= 4;
+                       }
+               }
+               else
+               {
+                       throw new ArgumentException(_("Arg_InvalidBase"));
+               }
+               return new String(buf);
+       }
+ 
        public static String ToString(bool value, IFormatProvider provider)
                        {
***************
*** 1696,1733 ****
        public static String ToString(byte value, int toBase)
                        {
!                               return 
NumberFormatter.FormatInBase((long)value, toBase, 8);
                        }
        [CLSCompliant(false)]
        public static String ToString(sbyte value, int toBase)
                        {
!                               return 
NumberFormatter.FormatInBase((long)value, toBase, 8);
                        }
        public static String ToString(short value, int toBase)
                        {
!                               return 
NumberFormatter.FormatInBase((long)value, toBase, 16);
                        }
        [CLSCompliant(false)]
        public static String ToString(ushort value, int toBase)
                        {
!                               return 
NumberFormatter.FormatInBase((long)value, toBase, 16);
                        }
        public static String ToString(int value, int toBase)
                        {
!                               return 
NumberFormatter.FormatInBase((long)value, toBase, 32);
                        }
        [CLSCompliant(false)]
        public static String ToString(uint value, int toBase)
                        {
!                               return 
NumberFormatter.FormatInBase((long)value, toBase, 32);
                        }
        public static String ToString(long value, int toBase)
                        {
!                               return 
NumberFormatter.FormatInBase((long)value, toBase, 64);
                        }
        [CLSCompliant(false)]
        public static String ToString(ulong value, int toBase)
                        {
!                               return NumberFormatter.FormatInBaseUnsigned
!                                                       (value, toBase, 64);
                        }
        public static String ToString(Object value)
--- 1792,1832 ----
        public static String ToString(byte value, int toBase)
                        {
!                               return FormatInBase((long)value, toBase, 8);
                        }
        [CLSCompliant(false)]
        public static String ToString(sbyte value, int toBase)
                        {
!                               return FormatInBase((long)value, toBase, 8);
                        }
        public static String ToString(short value, int toBase)
                        {
!                               return FormatInBase((long)value, toBase, 16);
                        }
        [CLSCompliant(false)]
        public static String ToString(ushort value, int toBase)
                        {
!                               return FormatInBase((long)value, toBase, 16);
                        }
        public static String ToString(int value, int toBase)
                        {
!                               return FormatInBase((long)value, toBase, 32);
                        }
        [CLSCompliant(false)]
        public static String ToString(uint value, int toBase)
                        {
!                               return FormatInBase((long)value, toBase, 32);
                        }
        public static String ToString(long value, int toBase)
                        {
!                               return FormatInBase((long)value, toBase, 64);
                        }
        [CLSCompliant(false)]
        public static String ToString(ulong value, int toBase)
                        {
!                               if(toBase != 10)
!                               {
!                                       return 
FormatInBase(unchecked((long)value), toBase, 64);
!                               }
!                               return FormatBase10(value, false);
                        }
        public static String ToString(Object value)

Index: Decimal.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Decimal.cs,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** Decimal.cs  20 Apr 2002 00:50:56 -0000      1.9
--- Decimal.cs  27 Nov 2002 14:37:27 -0000      1.10
***************
*** 23,26 ****
--- 23,27 ----
  
  using System.Private;
+ using System.Private.NumberFormat;
  using System.Globalization;
  using System.Runtime.CompilerServices;
***************
*** 318,324 ****
        public String ToString(String format, IFormatProvider provider)
                        {
!                               return NumberFormatter.FormatDecimal
!                                                       (this, format,
!                                                        
NumberFormatInfo.GetInstance(provider));
                        }
  
--- 319,325 ----
        public String ToString(String format, IFormatProvider provider)
                        {
!                               if (format == null) format = "G";
!                               return 
!                                       
Formatter.CreateFormatter(format).Format(this, provider);
                        }
  

Index: Double.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Double.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** Double.cs   26 Nov 2002 04:00:35 -0000      1.8
--- Double.cs   27 Nov 2002 14:37:27 -0000      1.9
***************
*** 23,26 ****
--- 23,27 ----
  
  using System.Private;
+ using System.Private.NumberFormat;
  using System.Globalization;
  using System.Runtime.CompilerServices;
***************
*** 105,111 ****
        public String ToString(String format, IFormatProvider provider)
                        {
!                               return NumberFormatter.FormatDouble
!                                               (value_, format,
!                                                
NumberFormatInfo.GetInstance(provider));
                        }
  
--- 106,112 ----
        public String ToString(String format, IFormatProvider provider)
                        {
!                               if (format == null) format = "G";
!                               return
!                                       
Formatter.CreateFormatter(format).Format(this, provider);
                        }
  

Index: Guid.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Guid.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Guid.cs     20 Dec 2001 10:11:39 -0000      1.3
--- Guid.cs     27 Nov 2002 14:37:27 -0000      1.4
***************
*** 330,345 ****
                                        throw new 
FormatException(_("Format_Guid"));
                                }
!                               return start + 
NumberFormatter.FormatInBase(a__, 16, 32) +
!                                          sep   + 
NumberFormatter.FormatInBase(b__, 16, 16) +
!                                          sep   + 
NumberFormatter.FormatInBase(c__, 16, 16) +
!                                          sep   + NumberFormatter.FormatInBase
!                                                                       
((((int)d__) << 8) | ((int)e__), 16, 16) +
!                                          sep   + NumberFormatter.FormatInBase
!                                                                       
((((int)f__) << 8) | ((int)g__), 16, 16) +
!                                                          
NumberFormatter.FormatInBase
!                                                                       
((((int)h__) << 24) |
!                                                                        
(((int)i__) << 16) |
!                                                                        
(((int)j__) << 8) |
!                                                                         
((int)k__), 16, 32) +
                                           end;
                        }
--- 330,344 ----
                                        throw new 
FormatException(_("Format_Guid"));
                                }
!                               return start + Convert.ToString(a__, 16) +
!                                          sep   + Convert.ToString(b__, 16) +
!                                          sep   + Convert.ToString(c__, 16) +
!                                          sep   + Convert.ToString(d__, 16) + 
!                                                               
Convert.ToString(e__, 16) +
!                                          sep   + Convert.ToString(f__, 16) +
!                                                               
Convert.ToString(g__, 16) +
!                                                               
Convert.ToString(h__, 16) +
!                                                               
Convert.ToString(i__, 16) +
!                                                               
Convert.ToString(j__, 16) +
!                                                               
Convert.ToString(k__, 16) +
                                           end;
                        }

Index: Int16.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Int16.cs,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** Int16.cs    26 Nov 2002 04:00:35 -0000      1.9
--- Int16.cs    27 Nov 2002 14:37:27 -0000      1.10
***************
*** 23,26 ****
--- 23,27 ----
  
  using System.Private;
+ using System.Private.NumberFormat;
  using System.Globalization;
  
***************
*** 69,88 ****
        public String ToString(String format, IFormatProvider provider)
                        {
!                               unchecked
!                               {
!                                       if(value_ >= 0)
!                                       {
!                                               return 
NumberFormatter.FormatFixedPoint
!                                                                       
((ulong)value_, 0, 0, false, format,
!                                                                        
NumberFormatInfo.GetInstance(provider));
!                                       }
!                                       else
!                                       {
!                                               return 
NumberFormatter.FormatFixedPoint
!                                                                       
((ulong)(uint)(-value_), 0, 0,
!                                                                        true, 
format,
!                                                                        
NumberFormatInfo.GetInstance(provider));
!                                       }
!                               }
                        }
  
--- 70,76 ----
        public String ToString(String format, IFormatProvider provider)
                        {
!                               if (format == null) format = "G";
!                               return 
!                                       
Formatter.CreateFormatter(format).Format(this, provider);
                        }
  

Index: Int32.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Int32.cs,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** Int32.cs    26 Nov 2002 04:00:35 -0000      1.9
--- Int32.cs    27 Nov 2002 14:37:27 -0000      1.10
***************
*** 23,26 ****
--- 23,27 ----
  
  using System.Private;
+ using System.Private.NumberFormat;
  using System.Globalization;
  
***************
*** 65,84 ****
        public String ToString(String format, IFormatProvider provider)
                        {
!                               unchecked
!                               {
!                                       if(value_ >= 0)
!                                       {
!                                               return 
NumberFormatter.FormatFixedPoint
!                                                                       
((ulong)value_, 0, 0, false, format,
!                                                                        
NumberFormatInfo.GetInstance(provider));
!                                       }
!                                       else
!                                       {
!                                               return 
NumberFormatter.FormatFixedPoint
!                                                                       
((ulong)(uint)(-value_), 0, 0,
!                                                                        true, 
format,
!                                                                        
NumberFormatInfo.GetInstance(provider));
!                                       }
!                               }
                        }
  
--- 66,72 ----
        public String ToString(String format, IFormatProvider provider)
                        {
!                               if (format == null) format = "G";
!                               return 
!                                       
Formatter.CreateFormatter(format).Format(this, provider);
                        }
  

Index: Int64.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Int64.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** Int64.cs    26 Nov 2002 04:00:35 -0000      1.8
--- Int64.cs    27 Nov 2002 14:37:27 -0000      1.9
***************
*** 23,26 ****
--- 23,27 ----
  
  using System.Private;
+ using System.Private.NumberFormat;
  using System.Globalization;
  
***************
*** 68,86 ****
        public String ToString(String format, IFormatProvider provider)
                        {
!                               unchecked
!                               {
!                                       if(value_ >= 0)
!                                       {
!                                               return 
NumberFormatter.FormatFixedPoint
!                                                                       
((ulong)value_, 0, 0, false, format,
!                                                                        
NumberFormatInfo.GetInstance(provider));
!                                       }
!                                       else
!                                       {
!                                               return 
NumberFormatter.FormatFixedPoint
!                                                                       
((ulong)(-value_), 0, 0, true, format,
!                                                                        
NumberFormatInfo.GetInstance(provider));
!                                       }
!                               }
                        }
  
--- 69,75 ----
        public String ToString(String format, IFormatProvider provider)
                        {
!                               if (format == null) format = "G";
!                               return
!                                       
Formatter.CreateFormatter(format).Format(this, provider);
                        }
  

Index: SByte.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/SByte.cs,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** SByte.cs    26 Nov 2002 04:00:36 -0000      1.9
--- SByte.cs    27 Nov 2002 14:37:27 -0000      1.10
***************
*** 23,26 ****
--- 23,27 ----
  
  using System.Private;
+ using System.Private.NumberFormat;
  using System.Globalization;
  
***************
*** 68,87 ****
        public String ToString(String format, IFormatProvider provider)
                        {
!                               unchecked
!                               {
!                                       if(value_ >= 0)
!                                       {
!                                               return 
NumberFormatter.FormatFixedPoint
!                                                                       
((ulong)value_, 0, 0, false, format,
!                                                                        
NumberFormatInfo.GetInstance(provider));
!                                       }
!                                       else
!                                       {
!                                               return 
NumberFormatter.FormatFixedPoint
!                                                                       
((ulong)(uint)(-value_), 0, 0,
!                                                                        true, 
format,
!                                                                        
NumberFormatInfo.GetInstance(provider));
!                                       }
!                               }
                        }
  
--- 69,75 ----
        public String ToString(String format, IFormatProvider provider)
                        {
!                               if (format == null) format = "G";
!                               return
!                                       
Formatter.CreateFormatter(format).Format(this, provider);
                        }
  

Index: Single.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Single.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** Single.cs   26 Nov 2002 04:00:36 -0000      1.8
--- Single.cs   27 Nov 2002 14:37:27 -0000      1.9
***************
*** 23,26 ****
--- 23,27 ----
  
  using System.Private;
+ using System.Private.NumberFormat;
  using System.Globalization;
  using System.Runtime.CompilerServices;
***************
*** 85,91 ****
        public String ToString(String format, IFormatProvider provider)
                        {
!                               return NumberFormatter.FormatSingle
!                                               (value_, format,
!                                                
NumberFormatInfo.GetInstance(provider));
                        }
  
--- 86,92 ----
        public String ToString(String format, IFormatProvider provider)
                        {
!                               if (format == null) format = "G";
!                               return
!                                       
Formatter.CreateFormatter(format).Format(this, provider);
                        }
  

Index: String.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/String.cs,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** String.cs   14 Nov 2002 11:43:53 -0000      1.28
--- String.cs   27 Nov 2002 14:37:27 -0000      1.29
***************
*** 41,44 ****
--- 41,47 ----
        private char firstChar;                 // First character in the 
string.
  
+       // Private constants
+       private static readonly char[] curlyBraces = { '{', '}' };
+ 
        // Public constants.
        public static readonly String Empty = "";
***************
*** 541,549 ****
        public override bool Equals(Object obj)
                        {
!                               if(this == null)
!                               {
!                                       throw new NullReferenceException();
!                               }
! 
                                if(obj is String)
                                {
--- 544,552 ----
        public override bool Equals(Object obj)
                        {
!                               //  Rhys changed the compile so all C# is 
callvirt.
!                               //  This code is now unnecessary.  It had been 
for ECMA
!                               //  compliance.
!                               // if(this == null) throw new 
NullReferenceException(); 
!                               
                                if(obj is String)
                                {
***************
*** 573,576 ****
--- 576,586 ----
        public static String Format(String format, Object arg0)
                        {
+                               // This check is peculiar to this method.  Ask 
ECMA.  Really.
+                               if (arg0 == null)
+                               {
+                                       throw new ArgumentNullException("arg0");
+                               }
+ 
+                               // Now that the paperwork's done, hand the 
request along.
                                return Format((IFormatProvider)null, format, 
arg0);
                        }
***************
*** 648,658 ****
                                int posn = 0;
                                int next, argNum, width;
                                Object arg;
                                String specifier;
                                String formatted;
!                               while((next = format.IndexOf('{', posn, len - 
posn)) != -1)
                                {
                                        // Append everything up to this point 
to the builder.
                                        sb.Append(format, posn, next - posn);
                                        posn = next + 1;
  
--- 658,689 ----
                                int posn = 0;
                                int next, argNum, width;
+                               char curr;
                                Object arg;
                                String specifier;
                                String formatted;
!                               for(
!                                       next = format.IndexOfAny(curlyBraces, 
posn, len - posn);
!                                       next != -1;
!                                       next = format.IndexOfAny(curlyBraces, 
posn, len - posn))
                                {
                                        // Append everything up to this point 
to the builder.
                                        sb.Append(format, posn, next - posn);
+ 
+                                       // Take care of escape sequences before 
trying anything
+                                       // fancy...
+                                       if(format[next] == '{' && 
format[next+1] == '{')
+                                       {
+                                               sb.Append('{');
+                         posn = next + 2;
+                         continue;
+                                       }
+ 
+                                       if(format[next] == '}')
+                                       {
+                                               sb.Append('}');
+                                               posn = next + 1;
+                                               if (format[posn] == '}') posn++;
+                                               continue;
+                                       }
                                        posn = next + 1;
  
***************
*** 660,742 ****
                                        if(posn >= len)
                                        {
!                                               throw new 
FormatException(_("Format_FormatString"));
                                        }
!                                       if(format[posn] != '{')
                                        {
!                                               // Get the argument number.
!                                               argNum = 
GetFormatInteger(format, len, ref posn);
!                                               if(argNum == -1)
                                                {
                                                        throw new 
FormatException
!                                                                       
(_("Format_FormatString"));
                                                }
!                                               if(format[posn] == ',')
                                                {
                                                        ++posn;
!                                                       if(posn >= len)
                                                        {
                                                                throw new 
FormatException
!                                                                               
(_("Format_FormatString"));
!                                                       }
!                                                       if(format[posn] == '-')
!                                                       {
!                                                               ++posn;
!                                                               width = 
GetFormatInteger(format, len, ref posn);
!                                                               if(width == -1)
!                                                               {
!                                                                       throw 
new FormatException
!                                                                               
        (_("Format_FormatString"));
!                                                               }
!                                                               width = -width;
!                                                       }
!                                                       else
!                                                       {
!                                                               width = 
GetFormatInteger(format, len, ref posn);
!                                                               if(width == -1)
!                                                               {
!                                                                       throw 
new FormatException
!                                                                               
        (_("Format_FormatString"));
!                                                               }
                                                        }
                                                }
                                                else
                                                {
!                                                       width = 0;
!                                               }
!                                               if(format[posn] == ':')
!                                               {
!                                                       ++posn;
!                                                       if(posn >= len)
!                                                       {
!                                                               throw new 
FormatException
!                                                                               
(_("Format_FormatString"));
!                                                       }
!                                                       next = 
format.IndexOf('}', posn, len - posn);
!                                                       if(next == -1)
                                                        {
                                                                throw new 
FormatException
!                                                                               
(_("Format_FormatString"));
                                                        }
-                                                       specifier = 
format.Substring(posn, next - posn);
-                                                       posn = next;
                                                }
!                                               else
                                                {
!                                                       specifier = null;
                                                }
!                                               if(format[posn] != '}')
                                                {
                                                        throw new 
FormatException
!                                                                       
(_("Format_FormatString"));
                                                }
!                                               ++posn;
                                        }
                                        else
                                        {
!                                               // This is a literal '{' 
character.
!                                               sb.Append('{');
!                                               ++posn;
!                                               continue;
                                        }
  
                                        // Get the formatted string version of 
the argument.
--- 691,765 ----
                                        if(posn >= len)
                                        {
!                                               throw new FormatException 
(_("Format_FormatString"));
!                                       }
!                                       
!                                       // Get the argument number.
!                                       argNum = GetFormatInteger(format, len, 
ref posn);
! 
!                                       if(argNum == -1)
!                                       {
!                                               throw new FormatException 
(_("Format_FormatString"));
                                        }
! 
!                                       if(format[posn] == ',')
                                        {
!                                               ++posn;
!                                               if(posn >= len)
                                                {
                                                        throw new 
FormatException
!                                                                               
                (_("Format_FormatString"));
                                                }
!                                               if(format[posn] == '-')
                                                {
                                                        ++posn;
!                                                       width = 
GetFormatInteger(format, len, ref posn);
!                                                       if(width == -1)
                                                        {
                                                                throw new 
FormatException
!                                                                               
                (_("Format_FormatString"));
                                                        }
+                                                       width = -width;
                                                }
                                                else
                                                {
!                                                       width = 
GetFormatInteger(format, len, ref posn);
!                                                       if(width == -1)
                                                        {
                                                                throw new 
FormatException
!                                                                               
                (_("Format_FormatString"));
                                                        }
                                                }
!                                       }
!                                       else
!                                       {
!                                               width = 0;
!                                       }
! 
!                                       if(format[posn] == ':')
!                                       {
!                                               ++posn;
!                                               if(posn >= len)
                                                {
!                                                       throw new 
FormatException
!                                                                               
                (_("Format_FormatString"));
                                                }
!                                               next = format.IndexOf('}', 
posn, len - posn);
!                                               if(next == -1)
                                                {
                                                        throw new 
FormatException
!                                                                               
                (_("Format_FormatString"));
                                                }
!                                               specifier = 
format.Substring(posn, next - posn);
!                                               posn = next;
                                        }
                                        else
                                        {
!                                               specifier = null;
!                                       }
!                                       if(format[posn] != '}')
!                                       {
!                                               throw new FormatException 
(_("Format_FormatString"));
                                        }
+                                       ++posn;
  
                                        // Get the formatted string version of 
the argument.
***************
*** 744,748 ****
                                        {
                                                throw new FormatException
!                                                               
(_("Format_FormatArgNumber"));
                                        }
                                        arg = args[argNum];
--- 767,771 ----
                                        {
                                                throw new FormatException
!                                                                               
                (_("Format_FormatArgNumber"));
                                        }
                                        arg = args[argNum];
***************
*** 778,782 ****
                                                sb.Append(formatted);
                                        }
!                                       else
                                        {
                                                // Left-justify the string.
--- 801,805 ----
                                                sb.Append(formatted);
                                        }
!                                       else // width < 0
                                        {
                                                // Left-justify the string.
***************
*** 788,792 ****
                                                }
                                        }
!                               }
  
                                // Append the last non-specifier part to the 
builder.
--- 811,815 ----
                                                }
                                        }
!                               } // for (...; next != -1; ...)
  
                                // Append the last non-specifier part to the 
builder.

Index: UInt16.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/UInt16.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** UInt16.cs   26 Nov 2002 04:00:36 -0000      1.8
--- UInt16.cs   27 Nov 2002 14:37:27 -0000      1.9
***************
*** 23,26 ****
--- 23,27 ----
  
  using System.Private;
+ using System.Private.NumberFormat;
  using System.Globalization;
  
***************
*** 54,78 ****
        public override String ToString()
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, null,
!                                                        
NumberFormatInfo.CurrentInfo);
                        }
        public String ToString(String format)
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, format,
!                                                        
NumberFormatInfo.CurrentInfo);
                        }
        public String ToString(IFormatProvider provider)
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, null,
!                                                        
NumberFormatInfo.GetInstance(provider));
                        }
        public String ToString(String format, IFormatProvider provider)
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, format,
!                                                        
NumberFormatInfo.GetInstance(provider));
                        }
  
--- 55,73 ----
        public override String ToString()
                        {
!                               return ToString(null, null);
                        }
        public String ToString(String format)
                        {
!                               return ToString(format, null);
                        }
        public String ToString(IFormatProvider provider)
                        {
!                               return ToString(null, provider);
                        }
        public String ToString(String format, IFormatProvider provider)
                        {
!                               if (format == null) format = "G";
!                               return 
!                                       
Formatter.CreateFormatter(format).Format(this, provider);
                        }
  

Index: UInt32.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/UInt32.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** UInt32.cs   26 Nov 2002 04:00:36 -0000      1.8
--- UInt32.cs   27 Nov 2002 14:37:27 -0000      1.9
***************
*** 23,26 ****
--- 23,27 ----
  
  using System.Private;
+ using System.Private.NumberFormat;
  using System.Globalization;
  
***************
*** 56,80 ****
        public override String ToString()
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, null,
!                                                        
NumberFormatInfo.CurrentInfo);
                        }
        public String ToString(String format)
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, format,
!                                                        
NumberFormatInfo.CurrentInfo);
                        }
        public String ToString(IFormatProvider provider)
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, null,
!                                                        
NumberFormatInfo.GetInstance(provider));
                        }
        public String ToString(String format, IFormatProvider provider)
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, format,
!                                                        
NumberFormatInfo.GetInstance(provider));
                        }
  
--- 57,75 ----
        public override String ToString()
                        {
!                               return ToString(null, null);
                        }
        public String ToString(String format)
                        {
!                               return ToString(format, null);
                        }
        public String ToString(IFormatProvider provider)
                        {
!                               return ToString(null, provider);
                        }
        public String ToString(String format, IFormatProvider provider)
                        {
!                               if (format == null) format ="G";
!                               return 
!                                       
Formatter.CreateFormatter(format).Format(this, provider);
                        }
  

Index: UInt64.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/UInt64.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** UInt64.cs   26 Nov 2002 04:00:36 -0000      1.8
--- UInt64.cs   27 Nov 2002 14:37:27 -0000      1.9
***************
*** 23,26 ****
--- 23,27 ----
  
  using System.Private;
+ using System.Private.NumberFormat;
  using System.Globalization;
  
***************
*** 57,83 ****
        public override String ToString()
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, null,
!                                                        
NumberFormatInfo.CurrentInfo);
                        }
        public String ToString(String format)
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, format,
!                                                        
NumberFormatInfo.CurrentInfo);
                        }
        public String ToString(IFormatProvider provider)
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, null,
!                                                        
NumberFormatInfo.GetInstance(provider));
                        }
        public String ToString(String format, IFormatProvider provider)
                        {
!                               return NumberFormatter.FormatFixedPoint
!                                                       ((ulong)value_, 0, 0, 
false, format,
!                                                        
NumberFormatInfo.GetInstance(provider));
                        }
- 
  
        // Parsing methods.
--- 58,79 ----
        public override String ToString()
                        {
!                               return ToString(null, null);
                        }
        public String ToString(String format)
                        {
!                               return ToString(format, null);
                        }
+ 
        public String ToString(IFormatProvider provider)
                        {
!                               return ToString(null, provider);
                        }
+ 
        public String ToString(String format, IFormatProvider provider)
                        {
!                               if (format == null) format = "G";
!                               return
!                                       
Formatter.CreateFormatter(format).Format(this, provider);
                        }
  
        // Parsing methods.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]