private void Resize (int len)
{
- char[] newBuf = new char [len];
- Array.Copy (_cbuf, newBuf, _ind);
- _cbuf = newBuf;
+ Array.Resize (ref _cbuf, len);
}
private void Append (char c)
threadNumberFormatter = null;
if (res == null)
return new NumberFormatter (Thread.CurrentThread);
+ res.CurrentCulture = Thread.CurrentThread.CurrentCulture;
return res;
}
threadNumberFormatter = this;
}
- internal static void SetThreadCurrentCulture (CultureInfo culture)
- {
- if (threadNumberFormatter != null)
- threadNumberFormatter.CurrentCulture = culture;
- }
-
public static string NumberToString (string format, sbyte value, IFormatProvider fp)
{
NumberFormatter inst = GetInstance();
int[] lens = new int [3];
int index = 0;
int lastPos = 0;
- char literal = '\0';
+ bool quoted = false;
+
for (int i = 0; i < format.Length; i++) {
char c = format [i];
- if (c == literal || (literal == '\0' && (c == '\"' || c == '\''))) {
- if (literal == '\0')
- literal = c;
- else
- literal = '\0';
+ if (c == '\"' || c == '\'') {
+ if (i == 0 || format [i - 1] != '\\')
+ quoted = !quoted;
+
continue;
}
- if (literal == '\0' && format [i] == ';' && (i == 0 || format [i - 1] != '\\')) {
+ if (c == ';' && !quoted && (i == 0 || format [i - 1] != '\\')) {
lens [index++] = i - lastPos;
lastPos = i + 1;
if (index == 3)