2004-06-19 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Sat, 19 Jun 2004 13:11:50 +0000 (13:11 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Sat, 19 Jun 2004 13:11:50 +0000 (13:11 -0000)
* FloatingPointFormatter.cs : Literal string should be kept in the
  output.

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

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

index 4969f9327b0c1ea39c9cfd8f322d8a0850900c57..b1c198b9d5dd315e51fc5cbb102da19da20a7dd4 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FloatingPointFormatter.cs : Literal string should be kept in the
+         output.
+
 2004-06-18  Atsushi Enomoto  <atsushi@ximian.com>
 
        * DateTime.cs : Concatenating whitespace removal was not working fine.
index 0e56717ad986eb4ebaeb1eab08bfb1c4da3a12f4..7bdf8fe26575fe2313da78a5ca980fdce27c490e 100644 (file)
@@ -734,7 +734,20 @@ namespace System {
                        f.Percent = false;
                        f.FirstFormatPos = -1;
                        int aux = 0, i = 0, count = 0;
+                       bool inQuote = false;
                        foreach (char c in format) {
+                               if (c == '\'') {
+                                       if (inQuote)
+                                               inQuote = false;
+                                       else
+                                               inQuote = true;
+                                       i++;
+                                       continue;
+                               } else if (inQuote) {
+                                       i++;
+                                       continue;
+                               }
+
                                switch (c) {
                                case ',':
                                        aux++;
@@ -777,6 +790,8 @@ namespace System {
                                }
                                i++;
                        }
+                       if (inQuote)
+                               throw new FormatException ("Literal in format string is not correctly terminated.");
                        if (aux > 0) {
                                f.NumberOfColons = aux;
                        }
@@ -969,6 +984,15 @@ namespace System {
                                                sb.Append (nfi.PercentSymbol);
                                        else if (format [i] == '\u2030')
                                                sb.Append (nfi.PerMilleSymbol);
+                                       else if (format [i] == '\'') {
+                                               int l = ++i;
+                                               while (i < format.Length) {
+                                                       if (format [i] == '\'')
+                                                               break;
+                                                       i++;
+                                               }
+                                               sb.Insert (0, format.Substring (l, i - l));
+                                       }
                                        else {
                                                sb.Append(format[i]);
                                        }
@@ -1000,6 +1024,15 @@ namespace System {
                                        sb.Insert (0, nfi.PercentSymbol);
                                else if (format [i] == '\u2030')
                                        sb.Insert (0, nfi.PerMilleSymbol);
+                               else if (format [i] == '\'') {
+                                       int l = i;
+                                       while (i >= 0) {
+                                               if (format [i] == '\'')
+                                                       break;
+                                               i--;
+                                       }
+                                       sb.Insert (0, format.Substring (i, l - i));
+                               }
                                else if (format[i] != ',') {
                                        sb.Insert(0, format[i]);
                                }
@@ -1031,6 +1064,15 @@ namespace System {
                                        sb.Insert (0, nfi.PercentSymbol);
                                else if (format [i] == '\u2030')
                                        sb.Insert (0, nfi.PerMilleSymbol);
+                               else if (format [i] == '\'') {
+                                       int l = i;
+                                       while (i >= 0) {
+                                               if (format [i] == '\'')
+                                                       break;
+                                               i--;
+                                       }
+                                       sb.Insert (0, format.Substring (i, l - i));
+                               }
                                else if (format [i] != '.')
                                        sb.Insert(0, format[i]);
                        }