Skip to content
Browse files

Update culture infos and implement missing or not implemented members

  • Loading branch information...
1 parent a61485e commit 9d5de965400790491165ff842a2f36b1c0cd3e44 @marek-safar marek-safar committed May 15, 2012
View
34 mcs/class/corlib/System.Globalization/CompareInfo.cs
@@ -62,19 +62,21 @@ void IDeserializationCallback.OnDeserialization(object sender)
/* This will build the ICU collator, and store
* the pointer in ICU_collator
*/
+ /*
try {
this.construct_compareinfo (icu_name);
} catch {
// ICU_collator=IntPtr.Zero;
}
+ */
}
}
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- private extern void construct_compareinfo (string locale);
+ //[MethodImplAttribute (MethodImplOptions.InternalCall)]
+ //private extern void construct_compareinfo (string locale);
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- private extern void free_internal_collator ();
+ //[MethodImplAttribute (MethodImplOptions.InternalCall)]
+ //private extern void free_internal_collator ();
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern int internal_compare (string str1, int offset1,
@@ -113,15 +115,16 @@ public class CompareInfo {
// Keep in synch with MonoCompareInfo in the runtime.
private int culture;
- [NonSerialized]
- private string icu_name;
+// [NonSerialized]
+// private string icu_name;
// [NonSerialized]
// private IntPtr ICU_collator;
#pragma warning disable 169
private int win32LCID; // Unused, but MS.NET serializes this
- private string m_name; // Unused, but MS.NET serializes this
#pragma warning restore 169
+
+ readonly string m_name; // MS.NET serializes this
[NonSerialized]
SimpleCollator collator;
@@ -133,12 +136,10 @@ public class CompareInfo {
// Protects access to 'collators'
private static object monitor = new Object ();
- /* Hide the .ctor() */
- CompareInfo() {}
-
internal CompareInfo (CultureInfo ci)
{
this.culture = ci.LCID;
+ this.m_name = ci.Name;
if (UseManagedCollation) {
lock (monitor) {
if (collators == null)
@@ -150,20 +151,22 @@ internal CompareInfo (CultureInfo ci)
}
}
} else {
+/*
#if !MOONLIGHT
this.icu_name = ci.IcuName;
this.construct_compareinfo (icu_name);
#endif
+*/
}
}
-
+/*
~CompareInfo ()
{
#if !MOONLIGHT
free_internal_collator ();
#endif
}
-
+*/
#if !MOONLIGHT
private int internal_compare_managed (string str1, int offset1,
int length1, string str2,
@@ -853,16 +856,15 @@ public override string ToString()
* shows it. Some documentation about what it does
* would be nice.
*/
- public int LCID
- {
+ public int LCID {
get {
- return(culture);
+ return culture;
}
}
[ComVisible (false)]
public virtual string Name {
- get { return icu_name; }
+ get { return m_name; }
}
}
}
View
249 mcs/class/corlib/System.Globalization/CultureInfo.cs
@@ -1,14 +1,14 @@
//
// System.Globalization.CultureInfo.cs
//
+// Authors:
// Miguel de Icaza (miguel@ximian.com)
// Dick Porter (dick@ximian.com)
+// Marek Safar (marek.safar@gmail.com)
//
// (C) 2001, 2002, 2003 Ximian, Inc. (http://www.ximian.com)
-//
-
-//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -46,21 +46,17 @@ public class CultureInfo : ICloneable, IFormatProvider
static object shared_table_lock = new object ();
internal static int BootstrapCultureID;
- const int NumOptionalCalendars = 5;
- const int GregorianTypeMask = 0x00FFFFFF;
- const int CalendarTypeBits = 24;
-
#pragma warning disable 169, 649
bool m_isReadOnly;
int cultureID;
[NonSerialized]
int parent_lcid;
[NonSerialized]
- int specific_lcid;
- [NonSerialized]
int datetime_index;
[NonSerialized]
int number_index;
+ [NonSerialized]
+ int default_calendar_type;
bool m_useUserOverride;
[NonSerialized]
volatile NumberFormatInfo numInfo;
@@ -69,8 +65,6 @@ public class CultureInfo : ICloneable, IFormatProvider
private string m_name;
[NonSerialized]
- private string displayname;
- [NonSerialized]
private string englishname;
[NonSerialized]
private string nativename;
@@ -79,25 +73,24 @@ public class CultureInfo : ICloneable, IFormatProvider
[NonSerialized]
private string iso2lang;
[NonSerialized]
- private string icu_name;
- [NonSerialized]
private string win3lang;
[NonSerialized]
private string territory;
- volatile CompareInfo compareInfo;
[NonSerialized]
- private unsafe readonly int *calendar_data;
+ string[] native_calendar_names;
+
+ volatile CompareInfo compareInfo;
[NonSerialized]
private unsafe readonly void *textinfo_data;
- [NonSerialized]
- private Calendar [] optional_calendars;
- [NonSerialized]
- CultureInfo parent_culture;
int m_dataItem; // MS.NET serializes this.
- Calendar calendar; // MS.NET serializes this.
#pragma warning restore 169, 649
+ Calendar calendar;
+
+ [NonSerialized]
+ CultureInfo parent_culture;
+
// Deserialized instances will set this to false
[NonSerialized]
bool constructed;
@@ -107,10 +100,11 @@ public class CultureInfo : ICloneable, IFormatProvider
internal byte[] cached_serialized_form;
const int InvariantCultureId = 0x7F;
+ const int CalendarTypeBits = 8;
- private static readonly string MSG_READONLY = "This instance is read only";
+ const string MSG_READONLY = "This instance is read only";
- static public CultureInfo InvariantCulture {
+ public static CultureInfo InvariantCulture {
get {
return invariant_culture_info;
}
@@ -126,7 +120,7 @@ public static CultureInfo CreateSpecificCulture (string name)
return InvariantCulture;
CultureInfo ci = new CultureInfo ();
- if (!ConstructInternalLocaleFromSpecificName (ci, name.ToLowerInvariant ()))
+ if (!construct_internal_locale_from_specific_name (ci, name.ToLowerInvariant ()))
throw new ArgumentException ("Culture name " + name +
" is not supported.", name);
@@ -272,29 +266,35 @@ public CultureInfo GetConsoleFallbackUICulture ()
}
}
- public virtual string NativeName
- {
+ public virtual string NativeName {
get {
if (!constructed) Construct ();
- return(nativename);
+ return nativename;
+ }
+ }
+
+ internal string NativeCalendarName {
+ get {
+ if (!constructed) Construct ();
+ return native_calendar_names[(default_calendar_type >> CalendarTypeBits) - 1];
}
}
- public virtual Calendar Calendar
- {
- get { return DateTimeFormat.Calendar; }
+ public virtual Calendar Calendar {
+ get {
+ if (calendar == null) {
+ if (!constructed) Construct ();
+ calendar = CreateCalendar (default_calendar_type);
+ }
+
+ return calendar;
+ }
}
- public virtual Calendar[] OptionalCalendars
- {
+ [MonoLimitation ("Optional calendars are not supported only default calendar is returned")]
+ public virtual Calendar[] OptionalCalendars {
get {
- if (optional_calendars == null) {
- lock (this) {
- if (optional_calendars == null)
- ConstructCalendars ();
- }
- }
- return optional_calendars;
+ return new[] { Calendar };
}
}
@@ -334,11 +334,10 @@ public virtual TextInfo TextInfo
}
}
- public virtual string ThreeLetterISOLanguageName
- {
+ public virtual string ThreeLetterISOLanguageName {
get {
if (!constructed) Construct ();
- return(iso3lang);
+ return iso3lang;
}
}
@@ -350,8 +349,7 @@ public virtual string ThreeLetterWindowsLanguageName
}
}
- public virtual string TwoLetterISOLanguageName
- {
+ public virtual string TwoLetterISOLanguageName {
get {
if (!constructed) Construct ();
return(iso2lang);
@@ -365,13 +363,6 @@ public bool UseUserOverride
}
}
- internal string IcuName {
- get {
- if (!constructed) Construct ();
- return icu_name;
- }
- }
-
public void ClearCachedData()
{
Thread.CurrentThread.CurrentCulture = null;
@@ -419,9 +410,9 @@ public static CultureInfo[] GetCultures(CultureTypes types)
}
#endif
- public override int GetHashCode()
+ public override int GetHashCode ()
{
- return cultureID;
+ return cultureID.GetHashCode ();
}
public static CultureInfo ReadOnly(CultureInfo ci)
@@ -439,7 +430,6 @@ public static CultureInfo ReadOnly(CultureInfo ci)
new_ci.numInfo = NumberFormatInfo.ReadOnly (new_ci.numInfo);
if (new_ci.dateTimeInfo != null)
new_ci.dateTimeInfo = DateTimeFormatInfo.ReadOnly (new_ci.dateTimeInfo);
- // TextInfo doesn't have a ReadOnly method in 1.1...
if (new_ci.textInfo != null)
new_ci.textInfo = TextInfo.ReadOnly (new_ci.textInfo);
return(new_ci);
@@ -469,22 +459,13 @@ public virtual CompareInfo CompareInfo
}
}
- internal static bool IsIDNeutralCulture (int lcid)
- {
- bool ret;
- if (!internal_is_lcid_neutral (lcid, out ret))
- throw new ArgumentException (String.Format ("Culture id 0x{:x4} is not supported.", lcid));
-
- return ret;
- }
-
public virtual bool IsNeutralCulture {
get {
- if (!constructed) Construct ();
if (cultureID == InvariantCultureId)
return false;
- return ((cultureID & 0xff00) == 0 || specific_lcid == 0);
+ if (!constructed) Construct ();
+ return territory == null;
}
}
@@ -527,30 +508,29 @@ internal void CheckNeutral ()
}
}
- public virtual DateTimeFormatInfo DateTimeFormat
- {
- get
- {
+ public virtual DateTimeFormatInfo DateTimeFormat {
+ get {
+ if (dateTimeInfo != null)
+ return dateTimeInfo;
+
if (!constructed) Construct ();
CheckNeutral ();
- if (dateTimeInfo == null)
- {
- lock (this)
- {
- if (dateTimeInfo == null) {
- dateTimeInfo = new DateTimeFormatInfo(m_isReadOnly);
+
+ // TODO: Have to lock because construct_datetime_format is not atomic
+ lock (this) {
+ if (cultureID == InvariantCultureId && m_isReadOnly)
+ dateTimeInfo = DateTimeFormatInfo.InvariantInfo;
+ else if (dateTimeInfo == null) {
+ dateTimeInfo = new DateTimeFormatInfo (this, m_isReadOnly);
+ if (cultureID != InvariantCultureId)
construct_datetime_format ();
- if (optional_calendars != null)
- dateTimeInfo.Calendar = optional_calendars [0];
- }
}
}
return dateTimeInfo;
}
- set
- {
+ set {
if (!constructed) Construct ();
if (m_isReadOnly) throw new InvalidOperationException(MSG_READONLY);
@@ -561,30 +541,28 @@ public virtual DateTimeFormatInfo DateTimeFormat
}
}
- public virtual string DisplayName
- {
+ public virtual string DisplayName {
get {
- if (!constructed) Construct ();
- return(displayname);
+ // Mono is not localized and will always return english name regardless of OS locale
+ return EnglishName;
}
}
- public virtual string EnglishName
- {
+ public virtual string EnglishName {
get {
if (!constructed) Construct ();
- return(englishname);
+ return englishname;
}
}
public static CultureInfo InstalledUICulture
{
get { return GetCultureInfo (BootstrapCultureID); }
}
- public bool IsReadOnly
- {
+
+ public bool IsReadOnly {
get {
- return(m_isReadOnly);
+ return m_isReadOnly;
}
}
@@ -610,43 +588,6 @@ void Construct ()
constructed = true;
}
- bool ConstructInternalLocaleFromName (string locale)
- {
- // It is sort of hack to get those new pseudo-alias
- // culture names that are not supported in good old
- // Windows.
-#if MOONLIGHT
- if (locale == "zh-chs" || locale == "zh-cht")
- return false;
-#endif
- switch (locale) {
- case "zh-hans":
- locale = "zh-chs";
- break;
- case "zh-hant":
- locale = "zh-cht";
- break;
- }
-
- if (!construct_internal_locale_from_name (locale))
- return false;
- return true;
- }
-
- bool ConstructInternalLocaleFromLcid (int lcid)
- {
- if (!construct_internal_locale_from_lcid (lcid))
- return false;
- return true;
- }
-
- static bool ConstructInternalLocaleFromSpecificName (CultureInfo ci, string name)
- {
- if (!construct_internal_locale_from_specific_name (ci, name))
- return false;
- return true;
- }
-
static bool ConstructInternalLocaleFromCurrentLocale (CultureInfo ci)
{
if (!construct_internal_locale_from_current_locale (ci))
@@ -676,34 +617,26 @@ static bool ConstructInternalLocaleFromCurrentLocale (CultureInfo ci)
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern void construct_number_format ();
- // Returns false if the culture can not be found, sets is_neutral if it is
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- private extern static bool internal_is_lcid_neutral (int lcid, out bool is_neutral);
-
private void ConstructInvariant (bool read_only)
{
cultureID = InvariantCultureId;
/* NumberFormatInfo defaults to the invariant data */
numInfo=NumberFormatInfo.InvariantInfo;
- /* DateTimeFormatInfo defaults to the invariant data */
- dateTimeInfo=DateTimeFormatInfo.InvariantInfo;
if (!read_only) {
numInfo = (NumberFormatInfo) numInfo.Clone ();
- dateTimeInfo = (DateTimeFormatInfo) dateTimeInfo.Clone ();
}
textInfo = CreateTextInfo (read_only);
m_name=String.Empty;
- displayname=
englishname=
nativename="Invariant Language (Invariant Country)";
iso3lang="IVL";
iso2lang="iv";
- icu_name="en_US_POSIX";
win3lang="IVL";
+ default_calendar_type = 1 << CalendarTypeBits;
}
private unsafe TextInfo CreateTextInfo (bool readOnly)
@@ -732,7 +665,7 @@ private CultureInfo (int culture, bool useUserOverride, bool read_only)
return;
}
- if (!ConstructInternalLocaleFromLcid (culture)) {
+ if (!construct_internal_locale_from_lcid (culture)) {
#if NET_4_0
throw new CultureNotFoundException ("culture",
String.Format ("Culture ID {0} (0x{0:X4}) is not a " +
@@ -765,7 +698,7 @@ private CultureInfo (string name, bool useUserOverride, bool read_only)
return;
}
- if (!ConstructInternalLocaleFromName (name.ToLowerInvariant ())) {
+ if (!construct_internal_locale_from_name (name.ToLowerInvariant ())) {
#if NET_4_0
throw new CultureNotFoundException ("name",
"Culture name " + name + " is not supported.");
@@ -871,35 +804,21 @@ internal static CultureInfo CreateCulture (string name, bool reference)
return new CultureInfo (name, use_user_override, read_only);
}
- unsafe internal void ConstructCalendars ()
+ static Calendar CreateCalendar (int calendarType)
{
- if (calendar_data == null) {
- optional_calendars = new Calendar [] {new GregorianCalendar (GregorianCalendarTypes.Localized)};
- return;
- }
-
- optional_calendars = new Calendar [NumOptionalCalendars];
-
- for (int i=0; i<NumOptionalCalendars; i++) {
- Calendar cal = null;
- int caldata = *(calendar_data + i);
- int caltype = (caldata >> CalendarTypeBits);
- switch (caltype) {
- case 0:
- GregorianCalendarTypes greg_type;
- greg_type = (GregorianCalendarTypes) (caldata & GregorianTypeMask);
- cal = new GregorianCalendar (greg_type);
- break;
- case 1:
- cal = new HijriCalendar ();
- break;
- case 2:
- cal = new ThaiBuddhistCalendar ();
- break;
- default:
- throw new Exception ("invalid calendar type: " + caldata);
- }
- optional_calendars [i] = cal;
+ switch (calendarType >> CalendarTypeBits) {
+ case 1:
+ GregorianCalendarTypes greg_type;
+ greg_type = (GregorianCalendarTypes) (calendarType & 0xFF);
+ return new GregorianCalendar (greg_type);
+ case 2:
+ return new ThaiBuddhistCalendar ();
+ case 3:
+ return new UmAlQuraCalendar ();
+ case 4:
+ return new HijriCalendar ();
+ default:
+ throw new NotImplementedException ("Unknown calendar type: " + calendarType);
}
}
}
View
286 mcs/class/corlib/System.Globalization/DateTimeFormatInfo.cs
@@ -50,22 +50,20 @@ enum DateTimeFormatFlags {
[StructLayout (LayoutKind.Sequential)]
public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider
{
- private static readonly string MSG_READONLY = "This instance is read only";
+ const string MSG_READONLY = "This instance is read only";
private static readonly string[] INVARIANT_ABBREVIATED_DAY_NAMES
- = new string[7] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
+ = new string[7] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
private static readonly string[] INVARIANT_DAY_NAMES
- = new string[7] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
+ = new string[7] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
private static readonly string[] INVARIANT_ABBREVIATED_MONTH_NAMES
- = new string[13] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""};
+ = new string[13] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "" };
private static readonly string[] INVARIANT_MONTH_NAMES
- = new string[13] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", ""};
+ = new string[13] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "" };
// private static readonly string[] INVARIANT_ERA_NAMES = {"A.D."};
- static readonly string [] INVARIANT_SHORT_DAY_NAMES =
- new string [7] {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"};
+ static readonly string[] INVARIANT_SHORT_DAY_NAMES =
+ new string[7] { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" };
private static DateTimeFormatInfo theInvariantDateTimeFormatInfo;
- private const string _RoundtripPattern = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK";
-
#pragma warning disable 169
#region Sync with object-internals.h
private bool m_isReadOnly;
@@ -79,29 +77,29 @@ public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider
private string longTimePattern;
private string monthDayPattern;
private string yearMonthPattern;
- private string fullDateTimePattern;
- private string _RFC1123Pattern;
- private string _SortableDateTimePattern;
- private string _UniversalSortableDateTimePattern;
private int firstDayOfWeek;
- private Calendar calendar;
private int calendarWeekRule;
private string[] abbreviatedDayNames;
private string[] dayNames;
private string[] monthNames;
+ private string[] genitiveMonthNames;
private string[] abbreviatedMonthNames;
+ private string[] m_genitiveAbbreviatedMonthNames;
- // FIXME: not supported other than invariant
- private string [] allShortDatePatterns;
- private string [] allLongDatePatterns;
- private string [] allShortTimePatterns;
- private string [] allLongTimePatterns;
- private string [] monthDayPatterns;
- private string [] yearMonthPatterns;
- private string [] shortDayNames;
+ private string[] allShortDatePatterns;
+ private string[] allLongDatePatterns;
+ private string[] allShortTimePatterns;
+ private string[] allLongTimePatterns;
+ private string[] monthDayPatterns;
+ private string[] yearMonthPatterns;
+ private string[] shortestDayNames;
#endregion
+ internal readonly CultureInfo culture;
+ Calendar calendar;
+
// MS Serialization needs this
+ private string fullDateTimePattern;
private int nDataItem;
private bool m_useUserOverride;
private bool m_isDefaultCalendar;
@@ -114,17 +112,19 @@ public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider
private string[] m_abbrevEnglishEraNames;
private string[] m_dateWords;
private int[] optionalCalendars;
- private string[] m_superShortDayNames;
- private string[] genitiveMonthNames;
- private string[] m_genitiveAbbreviatedMonthNames;
private string[] leapYearMonthNames;
private DateTimeFormatFlags formatFlags;
private string m_name; // Unused, but MS.NET serializes this
#pragma warning restore 169
- internal DateTimeFormatInfo(bool read_only)
+ internal DateTimeFormatInfo (CultureInfo culture, bool read_only)
{
+ if (culture == null)
+ throw new ArgumentNullException ("culture");
+
+ this.culture = culture;
m_isReadOnly = read_only;
+
amDesignator = "AM";
pmDesignator = "PM";
dateSeparator = "/";
@@ -135,35 +135,21 @@ internal DateTimeFormatInfo(bool read_only)
longTimePattern = "HH:mm:ss";
monthDayPattern = "MMMM dd";
yearMonthPattern = "yyyy MMMM";
- fullDateTimePattern = "dddd, dd MMMM yyyy HH:mm:ss";
-
- // FIXME: for the following three pattern: "The
- // default value of this property is derived
- // from the calendar that is set for
- // CultureInfo.CurrentCulture or the default
- // calendar of CultureInfo.CurrentCulture."
-
- // Actually, no predefined culture has different values
- // than those default values.
- _RFC1123Pattern = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'";
- _SortableDateTimePattern = "yyyy'-'MM'-'dd'T'HH':'mm':'ss";
- _UniversalSortableDateTimePattern = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'";
-
- firstDayOfWeek = (int)DayOfWeek.Sunday;
- calendar = new GregorianCalendar();
- calendarWeekRule = (int)CalendarWeekRule.FirstDay;
+ firstDayOfWeek = (int) DayOfWeek.Sunday;
+ calendarWeekRule = (int) CalendarWeekRule.FirstDay;
abbreviatedDayNames = INVARIANT_ABBREVIATED_DAY_NAMES;
dayNames = INVARIANT_DAY_NAMES;
abbreviatedMonthNames = INVARIANT_ABBREVIATED_MONTH_NAMES;
monthNames = INVARIANT_MONTH_NAMES;
m_genitiveAbbreviatedMonthNames = INVARIANT_ABBREVIATED_MONTH_NAMES;
genitiveMonthNames = INVARIANT_MONTH_NAMES;
- shortDayNames = INVARIANT_SHORT_DAY_NAMES;
+ shortestDayNames = INVARIANT_SHORT_DAY_NAMES;
}
- public DateTimeFormatInfo() : this (false)
+ public DateTimeFormatInfo ()
+ : this (CultureInfo.InvariantCulture, false)
{
}
@@ -207,9 +193,9 @@ public object GetFormat(Type formatType)
public string GetAbbreviatedEraName (int era)
{
- if (era < 0 || era >= calendar.AbbreviatedEraNames.Length)
+ if (era < 0 || era >= Calendar.AbbreviatedEraNames.Length)
throw new ArgumentOutOfRangeException ("era", era.ToString ());
- return calendar.AbbreviatedEraNames [era];
+ return Calendar.AbbreviatedEraNames [era];
}
public string GetAbbreviatedMonthName(int month)
@@ -222,28 +208,28 @@ public int GetEra (string eraName)
{
if (eraName == null)
throw new ArgumentNullException ();
- string [] eras = calendar.EraNames;
+ string [] eras = Calendar.EraNames;
for (int i = 0; i < eras.Length; i++)
if (CultureInfo.InvariantCulture.CompareInfo
.Compare (eraName, eras [i],
CompareOptions.IgnoreCase) == 0)
- return calendar.Eras [i];
+ return Calendar.Eras [i];
- eras = calendar.AbbreviatedEraNames;
+ eras = Calendar.AbbreviatedEraNames;
for (int i = 0; i < eras.Length; i++)
if (CultureInfo.InvariantCulture.CompareInfo
.Compare (eraName, eras [i],
CompareOptions.IgnoreCase) == 0)
- return calendar.Eras [i];
+ return Calendar.Eras [i];
return -1;
}
public string GetEraName (int era)
{
- if (era < 0 || era > calendar.EraNames.Length)
+ if (era < 0 || era > Calendar.EraNames.Length)
throw new ArgumentOutOfRangeException ("era", era.ToString ());
- return calendar.EraNames [era - 1];
+ return Calendar.EraNames [era - 1];
}
public string GetMonthName(int month)
@@ -324,7 +310,6 @@ internal string[] RawMonthNames
}
}
- [MonoLimitation ("Returns only the English month abbreviated names")]
[ComVisible (false)]
public string[] AbbreviatedMonthGenitiveNames {
get {
@@ -336,7 +321,6 @@ internal string[] RawMonthNames
}
}
- [MonoLimitation ("Returns only the English month names")]
[ComVisible (false)]
public string[] MonthGenitiveNames {
get {
@@ -348,48 +332,45 @@ internal string[] RawMonthNames
}
}
- [MonoLimitation ("Returns an empty string as if the calendar name wasn't available")]
+ [MonoLimitation ("Oly default calendar is supported")]
[ComVisible (false)]
public string NativeCalendarName {
get {
- return String.Empty;
+ if (Calendar != culture.Calendar)
+ return "";
+
+ return culture.NativeCalendarName;
}
}
[ComVisible (false)]
public string[] ShortestDayNames {
get {
- return (string[]) shortDayNames.Clone ();
+ return (string[]) shortestDayNames.Clone ();
}
set {
CheckDaysValue (value);
- shortDayNames = value;
+ shortestDayNames = value;
}
}
- public string AMDesignator
- {
- get
- {
+ public string AMDesignator {
+ get {
return amDesignator;
}
- set
- {
+ set {
if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
if (value == null) throw new ArgumentNullException();
amDesignator = value;
}
}
- public string PMDesignator
- {
- get
- {
+ public string PMDesignator {
+ get {
return pmDesignator;
}
- set
- {
+ set {
if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
if (value == null) throw new ArgumentNullException();
pmDesignator = value;
@@ -510,13 +491,8 @@ public string YearMonthPattern
public string FullDateTimePattern
{
- get
- {
- if(fullDateTimePattern!=null) {
- return fullDateTimePattern;
- } else {
- return(longDatePattern + " " + longTimePattern);
- }
+ get {
+ return fullDateTimePattern ?? (longDatePattern + " " + longTimePattern);
}
set
{
@@ -536,13 +512,13 @@ public static DateTimeFormatInfo CurrentInfo
public static DateTimeFormatInfo InvariantInfo
{
- get
- {
+ get {
if (theInvariantDateTimeFormatInfo == null) {
- theInvariantDateTimeFormatInfo =
- DateTimeFormatInfo.ReadOnly(new DateTimeFormatInfo());
- theInvariantDateTimeFormatInfo.FillInvariantPatterns ();
+ var tmp = new DateTimeFormatInfo (CultureInfo.InvariantCulture, true);
+ tmp.FillInvariantPatterns ();
+ theInvariantDateTimeFormatInfo = tmp;
}
+
return theInvariantDateTimeFormatInfo;
}
}
@@ -561,14 +537,13 @@ public DayOfWeek FirstDayOfWeek
}
}
- public Calendar Calendar
- {
- get
- {
- return calendar;
+ public Calendar Calendar {
+ get {
+ return calendar ?? culture.Calendar;
}
- set
- {
+
+ [MonoLimitation ("Only default calendar specific data are available")]
+ set {
if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
if (value == null) throw new ArgumentNullException();
calendar = value;
@@ -588,35 +563,27 @@ public CalendarWeekRule CalendarWeekRule
}
}
- public string RFC1123Pattern
- {
- get
- {
- return _RFC1123Pattern;
+ public string RFC1123Pattern {
+ get {
+ return "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'";
}
}
- internal string RoundtripPattern
- {
- get
- {
- return _RoundtripPattern;
+ internal string RoundtripPattern {
+ get {
+ return "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK";
}
}
- public string SortableDateTimePattern
- {
- get
- {
- return _SortableDateTimePattern;
+ public string SortableDateTimePattern {
+ get {
+ return "yyyy'-'MM'-'dd'T'HH':'mm':'ss";
}
}
- public string UniversalSortableDateTimePattern
- {
- get
- {
- return _UniversalSortableDateTimePattern;
+ public string UniversalSortableDateTimePattern {
+ get {
+ return "yyyy'-'MM'-'dd HH':'mm':'ss'Z'";
}
}
@@ -642,20 +609,17 @@ public string[] GetAllDateTimePatterns ()
if (all_date_time_patterns != null)
return;
- var al = new List<string> ();
+ var al = new List<string> (16);
al.AddRange (GetAllRawDateTimePatterns ('d'));
al.AddRange (GetAllRawDateTimePatterns ('D'));
- al.AddRange (GetAllRawDateTimePatterns ('g'));
- al.AddRange (GetAllRawDateTimePatterns ('G'));
al.AddRange (GetAllRawDateTimePatterns ('f'));
al.AddRange (GetAllRawDateTimePatterns ('F'));
- // Yes, that is very meaningless, but that is what MS
- // is doing (LAMESPEC: Since it is documented that
- // 'M' and 'm' are equal, they should not cosider
- // that there is a possibility that 'M' and 'm' are
- // different.)
+ al.AddRange (GetAllRawDateTimePatterns ('g'));
+ al.AddRange (GetAllRawDateTimePatterns ('G'));
al.AddRange (GetAllRawDateTimePatterns ('m'));
al.AddRange (GetAllRawDateTimePatterns ('M'));
+ al.AddRange (GetAllRawDateTimePatterns ('o'));
+ al.AddRange (GetAllRawDateTimePatterns ('O'));
al.AddRange (GetAllRawDateTimePatterns ('r'));
al.AddRange (GetAllRawDateTimePatterns ('R'));
al.AddRange (GetAllRawDateTimePatterns ('s'));
@@ -682,7 +646,6 @@ public string[] GetAllDateTimePatterns (char format)
internal string[] GetAllRawDateTimePatterns (char format)
{
- string [] list;
switch (format) {
// Date
case 'D':
@@ -702,52 +665,50 @@ internal string[] GetAllRawDateTimePatterns (char format)
if (allShortTimePatterns != null && allShortTimePatterns.Length > 0)
return allShortTimePatterns;
return new string [] {ShortTimePattern};
- // {Short|Long}Date + {Short|Long}Time
- // FIXME: they should be the agglegation of the
- // combination of the Date patterns and Time patterns.
- case 'G':
- list = PopulateCombinedList (allShortDatePatterns, allLongTimePatterns);
- if (list != null && list.Length > 0)
- return list;
- return new string [] {ShortDatePattern + " " + LongTimePattern};
- case 'g':
- list = PopulateCombinedList (allShortDatePatterns, allShortTimePatterns);
- if (list != null && list.Length > 0)
- return list;
- return new string [] {ShortDatePattern + " " + ShortTimePattern};
- // The 'U' pattern strings are always the same as 'F'.
- // (only differs in assuming UTC or not.)
- case 'U':
- case 'F':
- list = PopulateCombinedList (allLongDatePatterns, allLongTimePatterns);
- if (list != null && list.Length > 0)
- return list;
- return new string [] {LongDatePattern + " " + LongTimePattern};
- case 'f':
- list = PopulateCombinedList (allLongDatePatterns, allShortTimePatterns);
- if (list != null && list.Length > 0)
- return list;
- return new string [] {LongDatePattern + " " + ShortTimePattern};
// MonthDay
case 'm':
case 'M':
if (monthDayPatterns != null && monthDayPatterns.Length > 0)
return monthDayPatterns;
- return new string [] {MonthDayPattern};
+ return new string[] { MonthDayPattern };
// YearMonth
case 'Y':
case 'y':
if (yearMonthPatterns != null && yearMonthPatterns.Length > 0)
return yearMonthPatterns;
- return new string [] {YearMonthPattern};
- // RFC1123
+ return new string[] { YearMonthPattern };
case 'r':
case 'R':
- return new string [] {RFC1123Pattern};
+ return new string[] { RFC1123Pattern };
+ case 'O':
+ case 'o':
+ return new string[] { RoundtripPattern };
case 's':
- return new string [] {SortableDateTimePattern};
+ return new string[] { SortableDateTimePattern };
case 'u':
- return new string [] {UniversalSortableDateTimePattern};
+ return new string[] { UniversalSortableDateTimePattern };
+
+ //
+ // Following patterns are combinations of {Short|Long}Date + {Short|Long}Time. Patters can
+ // be null for non-readonly invariant culture
+ //
+ case 'G':
+ return allShortDatePatterns == null ?
+ new string [] { ShortDatePattern + " " + LongTimePattern } :
+ PopulateCombinedList (allShortDatePatterns, allLongTimePatterns);
+ case 'g':
+ return allShortDatePatterns == null ?
+ new string [] { ShortDatePattern + " " + ShortTimePattern } :
+ PopulateCombinedList (allShortDatePatterns, allShortTimePatterns);
+ case 'U': // The 'U' pattern strings are always the same as 'F' (only differs in assuming UTC or not.)
+ case 'F':
+ return allLongDatePatterns == null ?
+ new string [] { LongDatePattern + " " + ShortTimePattern } :
+ PopulateCombinedList (allLongDatePatterns, allLongTimePatterns);
+ case 'f':
+ return allLongDatePatterns == null ?
+ new string [] { LongDatePattern + " " + ShortTimePattern } :
+ PopulateCombinedList (allLongDatePatterns, allShortTimePatterns);
}
throw new ArgumentException ("Format specifier was invalid.");
}
@@ -766,7 +727,7 @@ public string GetAbbreviatedDayName(DayOfWeek dayofweek)
return abbreviatedDayNames[index];
}
- private void FillInvariantPatterns ()
+ void FillInvariantPatterns ()
{
allShortDatePatterns = new string [] {"MM/dd/yyyy"};
allLongDatePatterns = new string [] {"dddd, dd MMMM yyyy"};
@@ -779,29 +740,28 @@ private void FillInvariantPatterns ()
};
monthDayPatterns = new string [] {"MMMM dd"};
yearMonthPatterns = new string [] {"yyyy MMMM"};
+
+ fullDateTimePattern = "dddd, dd MMMM yyyy HH:mm:ss";
}
static string [] PopulateCombinedList (string [] dates, string [] times)
{
- if (dates != null && times != null) {
- string [] list = new string [dates.Length * times.Length];
- int i = 0;
- foreach (string d in dates)
- foreach (string t in times)
- list [i++] = d + " " + t;
- return list;
- }
- return null;
+ string[] list = new string[dates.Length * times.Length];
+ int i = 0;
+ foreach (string d in dates)
+ foreach (string t in times)
+ list[i++] = d + " " + t;
+ return list;
}
[ComVisible (false)]
public string GetShortestDayName (DayOfWeek dayOfWeek)
{
int index = (int) dayOfWeek;
if (index < 0 || index > 6)
- throw new ArgumentOutOfRangeException();
+ throw new ArgumentOutOfRangeException ("dayOfWeek");
- return shortDayNames [index];
+ return shortestDayNames [index];
}
[ComVisible (false)]
View
31 mcs/class/corlib/System.Globalization/RegionInfo.cs
@@ -1,12 +1,12 @@
//
// System.Globalization.RegionInfo.cs
//
-// Author:
+// Authors:
// Atsushi Enomoto <atsushi@ximian.com>
-//
-
+// Marek Safar (marek.safar@gmail.com)
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -68,15 +68,13 @@ public partial class RegionInfo
string iso3Name;
string win3Name;
string englishName;
+ string nativeName;
string currencySymbol;
string isoCurrencySymbol;
string currencyEnglishName;
+ string currencyNativeName;
#pragma warning restore 649
- // new (instance) fields should be added here (and do not have to be duplicated in the runtime)
-
- int lcid; // it is used only for Equals() (not even used in GetHashCode()).
-
public RegionInfo (int culture)
{
if (!GetByTerritory (CultureInfo.GetCultureInfo (culture)))
@@ -90,7 +88,6 @@ public RegionInfo (string name)
throw new ArgumentNullException ();
if (construct_internal_region_from_name (name.ToUpperInvariant ())) {
- lcid = name.GetHashCode (); // random-ish
return;
}
if (!GetByTerritory (CultureInfo.GetCultureInfo (name)))
@@ -103,7 +100,7 @@ bool GetByTerritory (CultureInfo ci)
throw new Exception ("INTERNAL ERROR: should not happen.");
if (ci.IsNeutralCulture || ci.Territory == null)
return false;
- this.lcid = ci.LCID;
+
return construct_internal_region_from_name (ci.Territory.ToUpperInvariant ());
}
@@ -149,15 +146,14 @@ bool GetByTerritory (CultureInfo ci)
get { return isoCurrencySymbol; }
}
- [System.Runtime.InteropServices.ComVisible(false)]
+ [ComVisible(false)]
public virtual string NativeName {
- get { return DisplayName; }
+ get { return nativeName; }
}
- [MonoTODO ("Not implemented")]
- [System.Runtime.InteropServices.ComVisible(false)]
+ [ComVisible(false)]
public virtual string CurrencyNativeName {
- get { throw new NotImplementedException (); }
+ get { return currencyNativeName; }
}
public virtual string Name {
@@ -176,18 +172,15 @@ bool GetByTerritory (CultureInfo ci)
get { return iso2Name; }
}
- //
- // methods
-
public override bool Equals (object value)
{
RegionInfo other = value as RegionInfo;
- return other != null && lcid == other.lcid;
+ return other != null && Name == other.Name;
}
public override int GetHashCode ()
{
- return (int) (0x80000000 + (regionId << 3) + regionId); // it i still based on regionId
+ return Name.GetHashCode ();
}
public override string ToString ()
View
35 mcs/class/corlib/System.Globalization/TextInfo.cs
@@ -53,6 +53,7 @@ struct Data {
public int ebcdic;
public int mac;
public int oem;
+ public bool right_to_left;
public byte list_sep;
}
@@ -175,39 +176,7 @@ public virtual int OEMCodePage
[ComVisible (false)]
public bool IsRightToLeft {
get {
- // hardcoded
- switch (m_win32LangID) {
- case 1: // ar
- case 13: // he
- case 32: // ur
- case 41: // fa
- case 90: // syr
- case 101: // div
- case 1025: // ar-SA
- case 1037: // he-IL
- case 1056: // ur-PK
- case 1065: // ra-IR
- case 1114: // syr-SY
- case 1125: // div-MV
- case 2049: // ar-IQ
- case 3073: // ar-EG
- case 4097: // ar-LY
- case 5121: // ar-DZ
- case 6145: // ar-MA
- case 7169: // ar-TN
- case 8193: // ar-OM
- case 9217: // ar-YE
- case 10241: // ar-SY
- case 11265: // ar-JO
- case 12289: // ar-LB
- case 13313: // ar-KW
- case 14337: // ar-AE
- case 15361: // ar-BH
- case 16385: // ar-QA
- return true;
- default:
- return false;
- }
+ return data.right_to_left;
}
}
View
2 mcs/class/corlib/System/Environment.cs
@@ -55,7 +55,7 @@ public static class Environment {
* of icalls, do not require an increment.
*/
#pragma warning disable 169
- private const int mono_corlib_version = 100;
+ private const int mono_corlib_version = 101;
#pragma warning restore 169
[ComVisible (true)]
View
22 mcs/class/corlib/Test/System.Globalization/CultureInfoTest.cs
@@ -205,6 +205,18 @@ public void CloneNeutral ()
Assert.IsTrue (culture.Equals (cultureClone));
}
+ [Test]
+ public void IsNeutral ()
+ {
+ var ci = new CultureInfo (0x6C1A);
+ Assert.IsTrue (ci.IsNeutralCulture, "#1");
+ Assert.AreEqual ("srp", ci.ThreeLetterISOLanguageName, "#2");
+
+ ci = new CultureInfo ("en-US");
+ Assert.IsFalse (ci.IsNeutralCulture, "#1a");
+ Assert.AreEqual ("eng", ci.ThreeLetterISOLanguageName, "#2a");
+ }
+
[Test] // bug #81930
public void IsReadOnly ()
{
@@ -340,7 +352,6 @@ public void NumberFormat_Neutral_Culture ()
}
}
-#if NET_2_0
[Test]
[Category ("NotDotNet")] // On MS, the NumberFormatInfo of the CultureInfo matching the current locale is not read-only
public void GetCultureInfo_Identifier ()
@@ -438,7 +449,6 @@ public void GetCultureInfo_Name_Null ()
Assert.AreEqual ("name", ex.ParamName, "#6");
}
}
-#endif
[Test]
public void UseUserOverride_CurrentCulture ()
@@ -462,7 +472,6 @@ public void UseUserOverride_CurrentUICulture ()
Assert.AreEqual (expected, ci.UseUserOverride, "#2");
}
-#if NET_2_0
[Test]
public void UseUserOverride_GetCultureInfo ()
{
@@ -476,21 +485,16 @@ public void UseUserOverride_GetCultureInfo ()
Assert.IsFalse (culture.UseUserOverride, "#2: " + cultureMsg);
}
}
-#endif
[Test]
public void UseUserOverride_GetCultures ()
{
foreach (CultureInfo ci in CultureInfo.GetCultures (CultureTypes.AllCultures)) {
string cultureMsg = String.Format ("{0} {1}", ci.LCID, ci.Name);
-#if NET_2_0
if (ci.LCID == CultureInfo.InvariantCulture.LCID)
Assert.IsFalse (ci.UseUserOverride, cultureMsg);
else
Assert.IsTrue (ci.UseUserOverride, cultureMsg);
-#else
- Assert.IsTrue (ci.UseUserOverride, cultureMsg);
-#endif
}
}
@@ -519,9 +523,7 @@ public void Bug402128 ()
public void ZhHant ()
{
Assert.AreEqual (31748, new CultureInfo ("zh-Hant").LCID);
-#if NET_2_0
Assert.AreEqual (31748, CultureInfo.GetCultureInfo ("zh-Hant").LCID);
-#endif
}
}
}
View
7 mcs/class/corlib/Test/System.Globalization/DateTimeFormatInfoTest.cs
@@ -116,6 +116,13 @@ public void Clone ()
Assert.AreEqual ("Jan", DateTimeFormatInfo.InvariantInfo.AbbreviatedMonthGenitiveNames[0], "#3");
}
+ [Test]
+ public void MonthGenitiveNames ()
+ {
+ var dfi = new CultureInfo ("cs-CZ").DateTimeFormat;
+ Assert.AreEqual ("ledna", dfi.MonthGenitiveNames[0], "#1");
+ }
+
#if !TARGET_JVM
[Test]
public void Bug78569 ()
View
18 mcs/class/corlib/Test/System.Globalization/RegionInfoTest.cs
@@ -42,13 +42,15 @@ public void RegionByWrongName ()
} catch (ArgumentException) {
}
}
+
+ try {
+ new RegionInfo ("2342#");
+ Assert.Fail ("#2");
+ } catch (ArgumentException) {
+ }
}
[Test]
-#if NET_2_0
-#else
- [ExpectedException (typeof (ArgumentException))]
-#endif
public void RegionByLocaleName ()
{
string [] names = new string [] {
@@ -73,5 +75,13 @@ public void HongKong ()
Assert.IsTrue (hk.ThreeLetterISORegionName.Length <= 3, "ThreeLetterISORegionName");
Assert.IsTrue (hk.ThreeLetterWindowsRegionName.Length <= 3, "ThreeLetterWindowsRegionName");
}
+
+ [Test]
+ public void Equals ()
+ {
+ var a = new RegionInfo (0x414);
+ var b = new RegionInfo (0x43B);
+ Assert.AreEqual (a, b);
+ }
}
}
View
6 mcs/class/corlib/Test/System.Globalization/TextInfoTest.cs
@@ -86,13 +86,11 @@ private void CompareProperties (TextInfo t1, TextInfo t2, bool compareReadOnly)
Assert.AreEqual (t1.ListSeparator, t2.ListSeparator, "ListSeparator");
Assert.AreEqual (t1.MacCodePage, t2.MacCodePage, "MacCodePage");
Assert.AreEqual (t1.OEMCodePage, t2.OEMCodePage, "OEMCodePage");
-#if NET_2_0
Assert.AreEqual (t1.CultureName, t2.CultureName, "CultureName");
if (compareReadOnly)
Assert.AreEqual (t1.IsReadOnly, t2.IsReadOnly, "IsReadOnly");
//FIXME Assert.AreEqual (t1.IsRightToLeft, t2.IsRightToLeft, "IsRightToLeft");
Assert.AreEqual (t1.LCID, t2.LCID, "LCID");
-#endif
}
[Test]
@@ -109,7 +107,6 @@ public void SerializationRoundtrip ()
CompareProperties (enus, clone, true);
}
-#if NET_2_0
[Test]
public void Clone ()
{
@@ -148,6 +145,7 @@ public void IsRightToLeft ()
case 13: // he
case 32: // ur
case 41: // fa
+ case 0x63: // ps
case 90: // syr
case 101: // div
case 1025: // ar-SA
@@ -171,6 +169,7 @@ public void IsRightToLeft ()
case 14337: // ar-AE
case 15361: // ar-BH
case 16385: // ar-QA
+ case 0x463: // ps-AF
Assert.IsTrue (ci.TextInfo.IsRightToLeft, ci.Name);
break;
default:
@@ -179,7 +178,6 @@ public void IsRightToLeft ()
}
}
}
-#endif
[Test]
public void Deserialization ()
View
9 mcs/class/corlib/Test/System/DoubleTest.cs
@@ -46,7 +46,7 @@ public class DoubleTest
};
[SetUp]
- public void GetReady ()
+ public void Setup ()
{
string sep = NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;
string_values = new string [15];
@@ -224,11 +224,12 @@ public void Parse ()
[Test]
public void ParseAllowWhitespaces ()
{
+ var nf = CultureInfo.CurrentCulture.NumberFormat;
NumberStyles style = NumberStyles.Float;
double.Parse (" 32 ");
- double.Parse (" Infinity ");
- double.Parse (" -Infinity ");
- double.Parse (" NaN ");
+ double.Parse (string.Format (" {0} ", nf.PositiveInfinitySymbol));
+ double.Parse (string.Format (" {0} ", nf.NegativeInfinitySymbol));
+ double.Parse (string.Format (" {0} ", nf.NaNSymbol));
}
[Test] // bug #81630
View
27 mcs/class/corlib/Test/System/NumberFormatterTest.cs
@@ -2954,19 +2954,20 @@ public void Test11031 ()
[Test]
public void TestNaNToString ()
{
- Assert.AreEqual ("Infinity", Double.PositiveInfinity.ToString(), "#01");
- Assert.AreEqual ("-Infinity", Double.NegativeInfinity.ToString(), "#02");
- Assert.AreEqual ("NaN", Double.NaN.ToString(), "#03");
- Assert.AreEqual ("Infinity", Single.PositiveInfinity.ToString(), "#04");
- Assert.AreEqual ("-Infinity", Single.NegativeInfinity.ToString(), "#05");
- Assert.AreEqual ("NaN", Single.NaN.ToString(), "#06");
-
- Assert.AreEqual ("Infinity", Double.PositiveInfinity.ToString("R"), "#07");
- Assert.AreEqual ("-Infinity", Double.NegativeInfinity.ToString("R"), "#08");
- Assert.AreEqual ("NaN", Double.NaN.ToString("R"), "#09");
- Assert.AreEqual ("Infinity", Single.PositiveInfinity.ToString("R"), "#10");
- Assert.AreEqual ("-Infinity", Single.NegativeInfinity.ToString("R"), "#11");
- Assert.AreEqual ("NaN", Single.NaN.ToString("R"), "#12");
+ var nfi = CultureInfo.CurrentCulture.NumberFormat;
+ Assert.AreEqual (nfi.PositiveInfinitySymbol, Double.PositiveInfinity.ToString(), "#01");
+ Assert.AreEqual (nfi.NegativeInfinitySymbol, Double.NegativeInfinity.ToString(), "#02");
+ Assert.AreEqual (nfi.NaNSymbol, Double.NaN.ToString(), "#03");
+ Assert.AreEqual (nfi.PositiveInfinitySymbol, Single.PositiveInfinity.ToString(), "#04");
+ Assert.AreEqual (nfi.NegativeInfinitySymbol, Single.NegativeInfinity.ToString(), "#05");
+ Assert.AreEqual (nfi.NaNSymbol, Single.NaN.ToString(), "#06");
+
+ Assert.AreEqual (nfi.PositiveInfinitySymbol, Double.PositiveInfinity.ToString("R"), "#07");
+ Assert.AreEqual (nfi.NegativeInfinitySymbol, Double.NegativeInfinity.ToString("R"), "#08");
+ Assert.AreEqual (nfi.NaNSymbol, Double.NaN.ToString("R"), "#09");
+ Assert.AreEqual (nfi.PositiveInfinitySymbol, Single.PositiveInfinity.ToString("R"), "#10");
+ Assert.AreEqual (nfi.NegativeInfinitySymbol, Single.NegativeInfinity.ToString("R"), "#11");
+ Assert.AreEqual (nfi.NaNSymbol, Single.NaN.ToString("R"), "#12");
}
[Test]
View
40 mcs/class/corlib/Test/System/SingleTest.cs
@@ -118,18 +118,18 @@ public void Parse_Roundtrip ()
string posInf = float.PositiveInfinity.ToString ("r");
float result;
- Assert.IsTrue (float.TryParse (maxVal, NumberStyles.Float, CultureInfo.InvariantCulture, out result), "MaxValue#1a");
+ Assert.IsTrue (float.TryParse (maxVal, NumberStyles.Float, CultureInfo.CurrentCulture, out result), "MaxValue#1a");
Assert.AreEqual (float.MaxValue, result, "MaxValue#1b");
- Assert.IsTrue (float.TryParse (minVal, NumberStyles.Float, CultureInfo.InvariantCulture, out result), "MinValue#1a");
+ Assert.IsTrue (float.TryParse (minVal, NumberStyles.Float, CultureInfo.CurrentCulture, out result), "MinValue#1a");
Assert.AreEqual (float.MinValue, result, "MinValue#1b");
- Assert.IsTrue (float.TryParse (epsilon, NumberStyles.Float, CultureInfo.InvariantCulture, out result), "Epsilon#1a");
+ Assert.IsTrue (float.TryParse (epsilon, NumberStyles.Float, CultureInfo.CurrentCulture, out result), "Epsilon#1a");
Assert.AreEqual (float.Epsilon, result, "Epsilon#1b");
- Assert.IsTrue (float.TryParse (nan, NumberStyles.Float, CultureInfo.InvariantCulture, out result), "NaN#1a");
+ Assert.IsTrue (float.TryParse (nan, NumberStyles.Float, CultureInfo.CurrentCulture, out result), "NaN#1a");
Assert.AreEqual (float.NaN, result, "NaN#1b");
Assert.IsNaN (result, "NaN#1c");
- Assert.IsTrue (float.TryParse (negInf, NumberStyles.Float, CultureInfo.InvariantCulture, out result), "-Inf#1a");
+ Assert.IsTrue (float.TryParse (negInf, NumberStyles.Float, CultureInfo.CurrentCulture, out result), "-Inf#1a");
Assert.AreEqual (float.NegativeInfinity, result, "-Inf#1b");
- Assert.IsTrue (float.TryParse (posInf, NumberStyles.Float, CultureInfo.InvariantCulture, out result), "+Inf#1a");
+ Assert.IsTrue (float.TryParse (posInf, NumberStyles.Float, CultureInfo.CurrentCulture, out result), "+Inf#1a");
Assert.AreEqual (float.PositiveInfinity, result, "+Inf#1b");
Assert.AreEqual (float.MaxValue, float.Parse (maxVal), "MaxValue#2");
@@ -140,13 +140,13 @@ public void Parse_Roundtrip ()
Assert.AreEqual (float.NegativeInfinity, float.Parse (negInf), "-Inf#2");
Assert.AreEqual (float.PositiveInfinity, float.Parse (posInf), "+Inf#2");
- Assert.AreEqual (float.MaxValue, float.Parse (maxVal, CultureInfo.InvariantCulture), "MaxValue#3");
- Assert.AreEqual (float.MinValue, float.Parse (minVal, CultureInfo.InvariantCulture), "MinValue#3");
- Assert.AreEqual (float.Epsilon, float.Parse (epsilon, CultureInfo.InvariantCulture), "Epsilon#3");
- Assert.AreEqual (float.NaN, float.Parse (nan, CultureInfo.InvariantCulture), "NaN#3a");
- Assert.IsNaN (float.Parse (nan, CultureInfo.InvariantCulture), "NaN#3b");
- Assert.AreEqual (float.NegativeInfinity, float.Parse (negInf, CultureInfo.InvariantCulture), "-Inf#3");
- Assert.AreEqual (float.PositiveInfinity, float.Parse (posInf, CultureInfo.InvariantCulture), "+Inf#3");
+ Assert.AreEqual (float.MaxValue, float.Parse (maxVal, CultureInfo.CurrentCulture), "MaxValue#3");
+ Assert.AreEqual (float.MinValue, float.Parse (minVal, CultureInfo.CurrentCulture), "MinValue#3");
+ Assert.AreEqual (float.Epsilon, float.Parse (epsilon, CultureInfo.CurrentCulture), "Epsilon#3");
+ Assert.AreEqual (float.NaN, float.Parse (nan, CultureInfo.CurrentCulture), "NaN#3a");
+ Assert.IsNaN (float.Parse (nan, CultureInfo.CurrentCulture), "NaN#3b");
+ Assert.AreEqual (float.NegativeInfinity, float.Parse (negInf, CultureInfo.CurrentCulture), "-Inf#3");
+ Assert.AreEqual (float.PositiveInfinity, float.Parse (posInf, CultureInfo.CurrentCulture), "+Inf#3");
Assert.AreEqual (float.MaxValue, float.Parse (maxVal, NumberStyles.Float), "MaxValue#4");
Assert.AreEqual (float.MinValue, float.Parse (minVal, NumberStyles.Float), "MinValue#4");
@@ -156,13 +156,13 @@ public void Parse_Roundtrip ()
Assert.AreEqual (float.NegativeInfinity, float.Parse (negInf, NumberStyles.Float), "-Inf#4");
Assert.AreEqual (float.PositiveInfinity, float.Parse (posInf, NumberStyles.Float), "+Inf#4");
- Assert.AreEqual (float.MaxValue, float.Parse (maxVal, NumberStyles.Float, CultureInfo.InvariantCulture), "MaxValue#5");
- Assert.AreEqual (float.MinValue, float.Parse (minVal, NumberStyles.Float, CultureInfo.InvariantCulture), "MinValue#5");
- Assert.AreEqual (float.Epsilon, float.Parse (epsilon, NumberStyles.Float, CultureInfo.InvariantCulture), "Epsilon#5");
- Assert.AreEqual (float.NaN, float.Parse (nan, NumberStyles.Float, CultureInfo.InvariantCulture), "NaN#5a");
- Assert.IsNaN (float.Parse (nan, NumberStyles.Float, CultureInfo.InvariantCulture), "NaN#5b");
- Assert.AreEqual (float.NegativeInfinity, float.Parse (negInf, NumberStyles.Float, CultureInfo.InvariantCulture), "-Inf#5");
- Assert.AreEqual (float.PositiveInfinity, float.Parse (posInf, NumberStyles.Float, CultureInfo.InvariantCulture), "+Inf#5");
+ Assert.AreEqual (float.MaxValue, float.Parse (maxVal, NumberStyles.Float, CultureInfo.CurrentCulture), "MaxValue#5");
+ Assert.AreEqual (float.MinValue, float.Parse (minVal, NumberStyles.Float, CultureInfo.CurrentCulture), "MinValue#5");
+ Assert.AreEqual (float.Epsilon, float.Parse (epsilon, NumberStyles.Float, CultureInfo.CurrentCulture), "Epsilon#5");
+ Assert.AreEqual (float.NaN, float.Parse (nan, NumberStyles.Float, CultureInfo.CurrentCulture), "NaN#5a");
+ Assert.IsNaN (float.Parse (nan, NumberStyles.Float, CultureInfo.CurrentCulture), "NaN#5b");
+ Assert.AreEqual (float.NegativeInfinity, float.Parse (negInf, NumberStyles.Float, CultureInfo.CurrentCulture), "-Inf#5");
+ Assert.AreEqual (float.PositiveInfinity, float.Parse (posInf, NumberStyles.Float, CultureInfo.CurrentCulture), "+Inf#5");
}
#if NET_2_0
View
2 mono/metadata/appdomain.c
@@ -74,7 +74,7 @@
* Changes which are already detected at runtime, like the addition
* of icalls, do not require an increment.
*/
-#define MONO_CORLIB_VERSION 100
+#define MONO_CORLIB_VERSION 101
typedef struct
{
View
6,884 mono/metadata/culture-info-tables.h
4,671 additions, 2,213 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
62 mono/metadata/culture-info.h
@@ -6,21 +6,20 @@
#define NUM_DAYS 7
#define NUM_MONTHS 13
-#define GROUP_SIZE 5
-#define NUM_OPT_CALS 5
+#define GROUP_SIZE 2
+#define NUM_CALENDARS 4
#define NUM_SHORT_DATE_PATTERNS 14
#define NUM_LONG_DATE_PATTERNS 8
-#define NUM_SHORT_TIME_PATTERNS 11
-#define NUM_LONG_TIME_PATTERNS 10
+#define NUM_SHORT_TIME_PATTERNS 12
+#define NUM_LONG_TIME_PATTERNS 9
#define idx2string(idx) (locale_strings + (idx))
/* need to change this if the string data ends up to not fit in a 64KB array. */
typedef guint16 stridx_t;
typedef struct {
- const stridx_t full_date_time_pattern;
const stridx_t long_date_pattern;
const stridx_t short_date_pattern;
const stridx_t long_time_pattern;
@@ -33,11 +32,14 @@ typedef struct {
const stridx_t day_names [NUM_DAYS];
const stridx_t abbreviated_day_names [NUM_DAYS];
+ const stridx_t shortest_day_names [NUM_DAYS];
const stridx_t month_names [NUM_MONTHS];
+ const stridx_t month_genitive_names [NUM_MONTHS];
const stridx_t abbreviated_month_names [NUM_MONTHS];
+ const stridx_t abbreviated_month_genitive_names [NUM_MONTHS];
- gint8 calendar_week_rule;
- gint8 first_day_of_week;
+ const gint8 calendar_week_rule;
+ const gint8 first_day_of_week;
const stridx_t date_separator;
const stridx_t time_separator;
@@ -66,15 +68,15 @@ typedef struct {
const stridx_t negative_sign;
const stridx_t positive_sign;
- gint8 currency_negative_pattern;
- gint8 currency_positive_pattern;
- gint8 percent_negative_pattern;
- gint8 percent_positive_pattern;
- gint8 number_negative_pattern;
+ const gint8 currency_negative_pattern;
+ const gint8 currency_positive_pattern;
+ const gint8 percent_negative_pattern;
+ const gint8 percent_positive_pattern;
+ const gint8 number_negative_pattern;
- gint8 currency_decimal_digits;
- gint8 percent_decimal_digits;
- gint8 number_decimal_digits;
+ const gint8 currency_decimal_digits;
+ const gint8 percent_decimal_digits;
+ const gint8 number_decimal_digits;
const gint currency_group_sizes [GROUP_SIZE];
const gint percent_group_sizes [GROUP_SIZE];
@@ -86,53 +88,51 @@ typedef struct {
const gint ebcdic;
const gint mac;
const gint oem;
+ const MonoBoolean is_right_to_left;
const char list_sep;
} TextInfoEntry;
typedef struct {
- gint16 lcid;
- gint16 parent_lcid;
- gint16 specific_lcid;
- gint16 region_entry_index;
+ const gint16 lcid;
+ const gint16 parent_lcid;
+ const gint16 calendar_type;
+ const gint16 region_entry_index;
const stridx_t name;
- const stridx_t icu_name;
const stridx_t englishname;
- const stridx_t displayname;
const stridx_t nativename;
const stridx_t win3lang;
const stridx_t iso3lang;
const stridx_t iso2lang;
const stridx_t territory;
+ const stridx_t native_calendar_names [NUM_CALENDARS];
- gint calendar_data [NUM_OPT_CALS];
-
- gint16 datetime_format_index;
- gint16 number_format_index;
+ const gint16 datetime_format_index;
+ const gint16 number_format_index;
- TextInfoEntry text_info;
+ const TextInfoEntry text_info;
} CultureInfoEntry;
typedef struct {
const stridx_t name;
- gint16 culture_entry_index;
+ const gint16 culture_entry_index;
} CultureInfoNameEntry;
typedef struct {
- gint16 lcid;
- gint16 region_id; /* it also works as geoId in 2.0 */
- /* gint8 measurement_system; // 0:metric 1:US 2:UK */
+ const gint16 geo_id;
const stridx_t iso2name;
const stridx_t iso3name;
const stridx_t win3name;
const stridx_t english_name;
+ const stridx_t native_name;
const stridx_t currency_symbol;
const stridx_t iso_currency_symbol;
const stridx_t currency_english_name;
+ const stridx_t currency_native_name;
} RegionInfoEntry;
typedef struct {
const stridx_t name;
- gint16 region_entry_index;
+ const gint16 region_entry_index;
} RegionInfoNameEntry;
#endif
View
2 mono/metadata/icall-def.h
@@ -290,7 +290,7 @@ ICALL(CULINF_6, "construct_internal_locale_from_name", ves_icall_System_Globaliz
ICALL(CULINF_7, "construct_internal_locale_from_specific_name", ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_specific_name)
ICALL(CULINF_8, "construct_number_format", ves_icall_System_Globalization_CultureInfo_construct_number_format)
ICALL(CULINF_9, "internal_get_cultures", ves_icall_System_Globalization_CultureInfo_internal_get_cultures)
-ICALL(CULINF_10, "internal_is_lcid_neutral", ves_icall_System_Globalization_CultureInfo_internal_is_lcid_neutral)
+//ICALL(CULINF_10, "internal_is_lcid_neutral", ves_icall_System_Globalization_CultureInfo_internal_is_lcid_neutral)
ICALL_TYPE(REGINF, "System.Globalization.RegionInfo", REGINF_1)
ICALL(REGINF_1, "construct_internal_region_from_lcid", ves_icall_System_Globalization_RegionInfo_construct_internal_region_from_lcid)
View
100 mono/metadata/locales.c
@@ -1,13 +1,15 @@
/*
* locales.c: Culture-sensitive handling
*
- * Author:
+ * Authors:
* Dick Porter (dick@ximian.com)
* Mohammad DAMT (mdamt@cdl2000.com)
+ * Marek Safar (marek.safar@gmail.com)
*
* Copyright 2003 Ximian, Inc (http://www.ximian.com)
* Copyright 2004-2009 Novell, Inc (http://www.novell.com)
* (C) 2003 PT Cakram Datalingga Duaribu http://www.cdl2000.com
+ * Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
*/
#include <config.h>
@@ -57,15 +59,6 @@ static const RegionInfoEntry* region_info_entry_from_lcid (int lcid);
static int
culture_lcid_locator (const void *a, const void *b)
{
- const CultureInfoEntry *aa = a;
- const CultureInfoEntry *bb = b;
-
- return (aa->lcid - bb->lcid);
-}
-
-static int
-region_lcid_locator (const void *a, const void *b)
-{
const int *lcid = a;
const CultureInfoEntry *bb = b;
@@ -122,6 +115,26 @@ create_names_array_idx (const guint16 *names, int ml)
{
MonoArray *ret;
MonoDomain *domain;
+ int i;
+
+ if (names == NULL)
+ return NULL;
+
+ domain = mono_domain_get ();
+
+ ret = mono_array_new_cached (mono_domain_get (), mono_get_string_class (), ml);
+
+ for(i = 0; i < ml; i++)
+ mono_array_setref (ret, i, mono_string_new (domain, idx2string (names [i])));
+
+ return ret;
+}
+
+static MonoArray*
+create_names_array_idx_dynamic (const guint16 *names, int ml)
+{
+ MonoArray *ret;
+ MonoDomain *domain;
int i, len = 0;
if (names == NULL)
@@ -160,16 +173,16 @@ ves_icall_System_Globalization_CultureInfo_construct_datetime_format (MonoCultur
domain = mono_domain_get ();
datetime->readOnly = this->is_read_only;
- MONO_OBJECT_SETREF (datetime, AbbreviatedDayNames, create_names_array_idx (dfe->abbreviated_day_names,
+ MONO_OBJECT_SETREF (datetime, AbbreviatedDayNames, create_names_array_idx (dfe->abbreviated_day_names,
NUM_DAYS));
MONO_OBJECT_SETREF (datetime, AbbreviatedMonthNames, create_names_array_idx (dfe->abbreviated_month_names,
NUM_MONTHS));
MONO_OBJECT_SETREF (datetime, AMDesignator, mono_string_new (domain, idx2string (dfe->am_designator)));
datetime->CalendarWeekRule = dfe->calendar_week_rule;
MONO_OBJECT_SETREF (datetime, DateSeparator, mono_string_new (domain, idx2string (dfe->date_separator)));
MONO_OBJECT_SETREF (datetime, DayNames, create_names_array_idx (dfe->day_names, NUM_DAYS));
+ MONO_OBJECT_SETREF (datetime, ShortestDayNames, create_names_array_idx (dfe->shortest_day_names, NUM_DAYS));
datetime->FirstDayOfWeek = dfe->first_day_of_week;
- MONO_OBJECT_SETREF (datetime, FullDateTimePattern, mono_string_new (domain, idx2string (dfe->full_date_time_pattern)));
MONO_OBJECT_SETREF (datetime, LongDatePattern, mono_string_new (domain, idx2string (dfe->long_date_pattern)));
MONO_OBJECT_SETREF (datetime, LongTimePattern, mono_string_new (domain, idx2string (dfe->long_time_pattern)));
MONO_OBJECT_SETREF (datetime, MonthDayPattern, mono_string_new (domain, idx2string (dfe->month_day_pattern)));
@@ -179,15 +192,16 @@ ves_icall_System_Globalization_CultureInfo_construct_datetime_format (MonoCultur
MONO_OBJECT_SETREF (datetime, ShortTimePattern, mono_string_new (domain, idx2string (dfe->short_time_pattern)));
MONO_OBJECT_SETREF (datetime, TimeSeparator, mono_string_new (domain, idx2string (dfe->time_separator)));
MONO_OBJECT_SETREF (datetime, YearMonthPattern, mono_string_new (domain, idx2string (dfe->year_month_pattern)));
- MONO_OBJECT_SETREF (datetime, ShortDatePatterns, create_names_array_idx (dfe->short_date_patterns,
+ MONO_OBJECT_SETREF (datetime, ShortDatePatterns, create_names_array_idx_dynamic (dfe->short_date_patterns,
NUM_SHORT_DATE_PATTERNS));
- MONO_OBJECT_SETREF (datetime, LongDatePatterns, create_names_array_idx (dfe->long_date_patterns,
+ MONO_OBJECT_SETREF (datetime, LongDatePatterns, create_names_array_idx_dynamic (dfe->long_date_patterns,
NUM_LONG_DATE_PATTERNS));
- MONO_OBJECT_SETREF (datetime, ShortTimePatterns, create_names_array_idx (dfe->short_time_patterns,
+ MONO_OBJECT_SETREF (datetime, ShortTimePatterns, create_names_array_idx_dynamic (dfe->short_time_patterns,
NUM_SHORT_TIME_PATTERNS));
- MONO_OBJECT_SETREF (datetime, LongTimePatterns, create_names_array_idx (dfe->long_time_patterns,
+ MONO_OBJECT_SETREF (datetime, LongTimePatterns, create_names_array_idx_dynamic (dfe->long_time_patterns,
NUM_LONG_TIME_PATTERNS));
-
+ MONO_OBJECT_SETREF (datetime, GenitiveMonthNames, create_names_array_idx (dfe->month_genitive_names, NUM_MONTHS));
+ MONO_OBJECT_SETREF (datetime, GenitiveAbbreviatedMonthNames, create_names_array_idx (dfe->abbreviated_month_genitive_names, NUM_MONTHS));
}
void
@@ -253,19 +267,20 @@ construct_culture (MonoCultureInfo *this, const CultureInfoEntry *ci)
this->lcid = ci->lcid;
MONO_OBJECT_SETREF (this, name, mono_string_new (domain, idx2string (ci->name)));
- MONO_OBJECT_SETREF (this, icu_name, mono_string_new (domain, idx2string (ci->icu_name)));
- MONO_OBJECT_SETREF (this, displayname, mono_string_new (domain, idx2string (ci->displayname)));
MONO_OBJECT_SETREF (this, englishname, mono_string_new (domain, idx2string (ci->englishname)));
MONO_OBJECT_SETREF (this, nativename, mono_string_new (domain, idx2string (ci->nativename)));
MONO_OBJECT_SETREF (this, win3lang, mono_string_new (domain, idx2string (ci->win3lang)));
MONO_OBJECT_SETREF (this, iso3lang, mono_string_new (domain, idx2string (ci->iso3lang)));
MONO_OBJECT_SETREF (this, iso2lang, mono_string_new (domain, idx2string (ci->iso2lang)));
- MONO_OBJECT_SETREF (this, territory, mono_string_new (domain, idx2string (ci->territory)));
+
+ // It's null for neutral cultures
+ if (ci->territory > 0)
+ MONO_OBJECT_SETREF (this, territory, mono_string_new (domain, idx2string (ci->territory)));
+ MONO_OBJECT_SETREF (this, native_calendar_names, create_names_array_idx (ci->native_calendar_names, NUM_CALENDARS));
this->parent_lcid = ci->parent_lcid;
- this->specific_lcid = ci->specific_lcid;
this->datetime_index = ci->datetime_format_index;
this->number_index = ci->number_format_index;
- this->calendar_data = ci->calendar_data;
+ this->calendar_type = ci->calendar_type;
this->text_info_data = &ci->text_info;
return TRUE;
@@ -276,14 +291,16 @@ construct_region (MonoRegionInfo *this, const RegionInfoEntry *ri)
{
MonoDomain *domain = mono_domain_get ();
- this->region_id = ri->region_id;
+ this->geo_id = ri->geo_id;
MONO_OBJECT_SETREF (this, iso2name, mono_string_new (domain, idx2string (ri->iso2name)));
MONO_OBJECT_SETREF (this, iso3name, mono_string_new (domain, idx2string (ri->iso3name)));
MONO_OBJECT_SETREF (this, win3name, mono_string_new (domain, idx2string (ri->win3name)));
MONO_OBJECT_SETREF (this, english_name, mono_string_new (domain, idx2string (ri->english_name)));
+ MONO_OBJECT_SETREF (this, native_name, mono_string_new (domain, idx2string (ri->native_name)));
MONO_OBJECT_SETREF (this, currency_symbol, mono_string_new (domain, idx2string (ri->currency_symbol)));
MONO_OBJECT_SETREF (this, iso_currency_symbol, mono_string_new (domain, idx2string (ri->iso_currency_symbol)));
MONO_OBJECT_SETREF (this, currency_english_name, mono_string_new (domain, idx2string (ri->currency_english_name)));
+ MONO_OBJECT_SETREF (this, currency_native_name, mono_string_new (domain, idx2string (ri->currency_native_name)));
return TRUE;
}
@@ -304,10 +321,6 @@ construct_culture_from_specific_name (MonoCultureInfo *ci, gchar *name)
entry = &culture_entries [ne->culture_entry_index];
- /* try avoiding another lookup, often the culture is its own specific culture */
- if (entry->lcid != entry->specific_lcid)
- entry = culture_info_entry_from_lcid (entry->specific_lcid);
-
if (entry)
return construct_culture (ci, entry);
else
@@ -318,10 +331,8 @@ static const CultureInfoEntry*
culture_info_entry_from_lcid (int lcid)
{
const CultureInfoEntry *ci;
- CultureInfoEntry key;
- key.lcid = lcid;
- ci = bsearch (&key, culture_entries, NUM_CULTURE_ENTRIES, sizeof (CultureInfoEntry), culture_lcid_locator);
+ ci = bsearch (&lcid, culture_entries, NUM_CULTURE_ENTRIES, sizeof (CultureInfoEntry), culture_lcid_locator);
return ci;
}
@@ -334,8 +345,7 @@ region_info_entry_from_lcid (int lcid)
MONO_ARCH_SAVE_REGS;
- ne = bsearch (&lcid, culture_entries, NUM_CULTURE_ENTRIES,
- sizeof (CultureInfoEntry), region_lcid_locator);
+ ne = bsearch (&lcid, culture_entries, NUM_CULTURE_ENTRIES, sizeof (CultureInfoEntry), culture_lcid_locator);
if (ne == NULL)
return FALSE;
@@ -613,7 +623,7 @@ ves_icall_System_Globalization_CultureInfo_internal_get_cultures (MonoBoolean ne
len = 0;
for (i = 0; i < NUM_CULTURE_ENTRIES; i++) {
ci = &culture_entries [i];
- is_neutral = ((ci->lcid & 0xff00) == 0 || ci->specific_lcid == 0);
+ is_neutral = ci->territory == 0;
if ((neutral && is_neutral) || (specific && !is_neutral))
len++;
}
@@ -637,7 +647,7 @@ ves_icall_System_Globalization_CultureInfo_internal_get_cultures (MonoBoolean ne
for (i = 0; i < NUM_CULTURE_ENTRIES; i++) {
ci = &culture_entries [i];
- is_neutral = ((ci->lcid & 0xff00) == 0 || ci->specific_lcid == 0);
+ is_neutral = ci->territory == 0;
if ((neutral && is_neutral) || (specific && !is_neutral)) {
culture = (MonoCultureInfo *) mono_object_new (domain, class);
mono_runtime_object_init ((MonoObject *) culture);
@@ -650,28 +660,6 @@ ves_icall_System_Globalization_CultureInfo_internal_get_cultures (MonoBoolean ne
return ret;
}
-/**
- * ves_icall_System_Globalization_CultureInfo_internal_is_lcid_neutral:
- *
- * Set is_neutral and return TRUE if the culture is found. If it is not found return FALSE.
- */
-MonoBoolean
-ves_icall_System_Globalization_CultureInfo_internal_is_lcid_neutral (gint lcid, MonoBoolean *is_neutral)
-{
- const CultureInfoEntry *entry;
-
- MONO_ARCH_SAVE_REGS;
-
- entry = culture_info_entry_from_lcid (lcid);
-
- if (entry == NULL)
- return FALSE;
-
- *is_neutral = (entry->specific_lcid == 0);
-
- return TRUE;
-}
-
void ves_icall_System_Globalization_CompareInfo_construct_compareinfo (MonoCompareInfo *comp, MonoString *locale)
{
/* Nothing to do here */
View
1 mono/metadata/locales.h
@@ -32,7 +32,6 @@ extern MonoBoolean ves_icall_System_Globalization_CultureInfo_construct_internal
extern MonoBoolean ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_name (MonoCultureInfo *this, MonoString *name) MONO_INTERNAL;
extern MonoBoolean ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_specific_name (MonoCultureInfo *ci, MonoString *name) MONO_INTERNAL;
extern MonoArray *ves_icall_System_Globalization_CultureInfo_internal_get_cultures (MonoBoolean neutral, MonoBoolean specific, MonoBoolean installed) MONO_INTERNAL;
-extern MonoBoolean ves_icall_System_Globalization_CultureInfo_internal_is_lcid_neutral (gint lcid, MonoBoolean *is_neutral) MONO_INTERNAL;
extern void ves_icall_System_Globalization_CultureInfo_construct_datetime_format (MonoCultureInfo *this) MONO_INTERNAL;
extern void ves_icall_System_Globalization_CultureInfo_construct_number_format (MonoCultureInfo *this) MONO_INTERNAL;
extern void ves_icall_System_Globalization_CompareInfo_construct_compareinfo (MonoCompareInfo *comp, MonoString *locale) MONO_INTERNAL;
View
19 mono/metadata/object-internals.h
@@ -442,24 +442,21 @@ typedef struct {
MonoString *LongTimePattern;
MonoString *MonthDayPattern;
MonoString *YearMonthPattern;
- MonoString *FullDateTimePattern;
- MonoString *RFC1123Pattern;
- MonoString *SortableDateTimePattern;
- MonoString *UniversalSortableDateTimePattern;
guint32 FirstDayOfWeek;
- MonoObject *Calendar;
guint32 CalendarWeekRule;
MonoArray *AbbreviatedDayNames;
MonoArray *DayNames;
MonoArray *MonthNames;
+ MonoArray *GenitiveMonthNames;
MonoArray *AbbreviatedMonthNames;
+ MonoArray *GenitiveAbbreviatedMonthNames;
MonoArray *ShortDatePatterns;
MonoArray *LongDatePatterns;
MonoArray *ShortTimePatterns;
MonoArray *LongTimePatterns;
MonoArray *MonthDayPatterns;
MonoArray *YearMonthPatterns;
- MonoArray *shortDayNames;
+ MonoArray *ShortestDayNames;
} MonoDateTimeFormatInfo;
typedef struct
@@ -510,37 +507,37 @@ typedef struct {
MonoBoolean is_read_only;
gint32 lcid;
gint32 parent_lcid;
- gint32 specific_lcid;
gint32 datetime_index;
gint32 number_index;
+ gint3