From: handa Date: Sat, 25 Apr 2009 08:23:24 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=48b06b6df84ac937f4e1a1a16de355ccdc3c18ad;p=m17n%2Fm17n-lib-cs.git *** empty log message *** --- diff --git a/M17N.cs b/M17N.cs index bc72060..154e9a8 100644 --- a/M17N.cs +++ b/M17N.cs @@ -2,11 +2,13 @@ using System; namespace M17N { - public class M17N + public static class M17n { - public static readonly int MajorVersion = 0; - public static readonly int MinorVersion = 0; - public static readonly int ReleaseNumber = 0; + public const int Version = 0x020101; + + public static int MajorVersion { get { return (Version >> 16); } } + public static int MinorVersion { get { return ((Version >> 8) & 0xFF); } } + public static int ReleaseNumber { get { return (Version & 0xFF); } } public static bool debug = false; diff --git a/MDatabase.cs b/MDatabase.cs index 5b65568..9a1b3e6 100644 --- a/MDatabase.cs +++ b/MDatabase.cs @@ -39,39 +39,64 @@ namespace M17N.Core { private class MDatabaseDir { + private const string ListFileName = "mdb.dir"; + public string Dirname; - public DirectoryInfo Info; + public DirectoryInfo DirInfo; public DateTime LastScanned; + public FileInfo ListInfo; + + private static void GetInfo (string dirname, out DirectoryInfo dirinfo, + out FileInfo listinfo) + { + if (Directory.Exists (dirname)) + try { dirinfo = new DirectoryInfo (dirname); + try { listinfo = dirinfo.GetFiles (ListFileName)[0]; + } catch { listinfo = null; } + } catch { dirinfo = null; listinfo = null; } + else + { + dirinfo = null; + listinfo = null; + } + } public MDatabaseDir (string dirname) { Dirname = dirname; - try { - Info = new DirectoryInfo (dirname); - } finally { - Info = null; - } + GetInfo (dirname, out DirInfo, out ListInfo); } public bool StatusChanged { get { bool exists = Directory.Exists (Dirname); - if (Info != null) + if (DirInfo != null) { if (! exists) { - Info = null; - return true; + DirInfo = null; + ListInfo = null; + LastScanned = new DateTime (0); } - Info.Refresh (); - return (LastScanned < Info.LastWriteTime); + if (LastScanned.Year == 0) + return true; + DirInfo.Refresh (); + if (ListInfo != null) + ListInfo.Refresh (); + return (LastScanned < DirInfo.LastWriteTime + || LastScanned < ListInfo.LastWriteTime); } else { if (exists) { - Info = new DirectoryInfo (Dirname); + DirInfo = new DirectoryInfo (Dirname); + try { + ListInfo = DirInfo.GetFiles (ListFileName)[0]; + } catch { + ListInfo = null; + } return true; } return false; @@ -81,122 +106,57 @@ namespace M17N.Core public void UpdateStatus () { - LastScanned = DateTime.Now; - } - } - - private class MDatabaseDefinition - { - private static readonly MSymbol Mversion; - public MDatabaseTag Tag; - public string Description; - public MText Filename; - public bool IsWildcard; - public MSymbol Format; - public MSymbol Schema; - public MText SchemaFile; - public MPlist props; - public bool Supported; - - static MDatabaseDefinition () - { - Mversion = new MSymbol ("version"); + if (DirInfo != null) + LastScanned = DateTime.UtcNow; } - public MDatabaseDefinition (MPlist plist) + public FileInfo[] Scan (string filename) { - MSymbol[] tags = new MSymbol[4]; - int i; - - for (i = 0; plist.IsSymbol; i++, plist = plist.Next) - tags[i] = plist.Symbol; - while (i < 4) - tags[i++] = MSymbol.nil; - Tag = new MDatabaseTag (tags[0], tags[1], tags[2], tags[3]); - if (plist.IsMText) - { - Filename = plist.Text; - plist = plist.Next; - } - else if (plist.IsPlist) - { - MPlist p = plist.Plist; - - if (p.IsMText) - Filename = plist.Text; - p = p.Next; - if (! p.IsEmpty) - { - if (p.IsSymbol) - Format = p.Symbol; - p = p.Next; - if (! p.IsEmpty) - { - if (p.IsSymbol) - Schema = p.Symbol; - p = p.Next; - if (p.IsMText) - SchemaFile = p.Text; - } - } - plist = plist.Next; - } - Supported = true; - props = new MPlist (); - foreach (MPlist pl in plist) - { - if (pl.IsPlist) - { - MPlist p = pl.Plist; - - if (p.IsSymbol && p.Symbol == Mversion - && ! check_version (p.Next)) - Supported = false; - props.Put (pl); - } - } + if (DirInfo == null) + return null; + DirInfo.Refresh (); + return DirInfo.GetFiles (filename); } + } - private bool check_version (MPlist plist) - { - string[] str; - int major, minor, release; - - if (! plist.IsMText) - return false; - str = plist.Text.ToString ().Split ('.'); - if (str.Length != 3) - return false; - try { major = int.Parse (str[0]); } catch { return false; } - try { minor = int.Parse (str[1]); } catch { return false; } - try { release = int.Parse (str[2]); } catch { return false; } - return (M17N.MajorVersion > major - || (M17N.MajorVersion == major - && (M17N.MinorVersion > minor - || (M17N.MinorVersion == minor - && M17N.ReleaseNumber >= release)))); - } + internal class MDatabaseInfo { + internal DirectoryInfo Dir; + internal string Description; + internal MText Filename; + internal FileInfo FileInfo; + internal FileInfo Validater; + internal int Version; + internal MSymbol Format; + internal MSymbol Schema; + internal MText SchemaFile; + internal DateTime ModifiedTime; + internal MPlist Props; } + private static Dictionary DBDict + = new Dictionary (); + private static MDatabaseDir[] DBDirs = new MDatabaseDir[3]; private const string SystemDirectory = "/usr/share/m17n"; - - private static Dictionary DBDict - = new Dictionary (); + private readonly MSymbol Mversion = new MSymbol ("version"); /// Type of database private enum MDBType { - /// The database was defined automatically (from mdb.dir - /// file(s)) with no wildcard tag. + /// The database was defined automatically from mdb.dir + /// file(s) with no wildcard tag. AUTO, - /// The database was defined automatically (from mdb.dir - /// file(s)) with a wildcard tag to define multiple databases + /// The database was defined automatically from mdb.dir + /// file(s) with a wildcard tag to define multiple databases /// of the same kind. - AUTO_WILDCARD, - /// The database was defined explicitely (by MDatabaseDefine). - EXPLICIT + MULTIPLE, + /// The database was defined explicitely by MDatabase.Define + /// without a special loader. + EXPLICIT, + /// The database was defined explicitely by MDatabase.Define + /// with a special loader. + UNKNOWN, }; /// Status of database @@ -212,29 +172,18 @@ namespace M17N.Core // The database file has not been modified after the previous // loading. UPDATED, - // The database file is updated but the validation was failed. - // If this is for a database directory, the directory is - // readable but "mdb.dir" doesn't exist in it. - INVALID + // The database file is updated but the validation was failed + // or the version is not supported by the current system. + INVALID, }; public readonly MDatabaseTag Tag; private MDatabaseLoader Loader; private object ExtraInfo; - - private bool IsSystemDatabase; - private DirectoryInfo Dir; - private MText Filename; - private FileInfo FileInfo; - private FileInfo Validater; - private int MajorVersion, MinorVersion, ReleaseNumber; private MDBType DBType; private MDBStatus DBStatus; - private MSymbol Format; - private MSymbol Schema; - private DateTime Mtime; - private DateTime Ltime; - private MPlist Props; + internal DateTime LoadedTime; + internal MDatabaseInfo Info; public static string ApplicationDirectory; @@ -249,7 +198,82 @@ namespace M17N.Core private MDatabase (MDatabaseTag tag, string filename) { Tag = tag; - Filename = new MText (filename); + Info = new MDatabaseInfo (); + Info.Filename = new MText (filename); + } + + private MDatabase (MPlist plist) + { + MSymbol[] tags = new MSymbol[4]; + int i; + + for (i = 0; plist.IsSymbol; i++, plist = plist.Next) + tags[i] = plist.Symbol; + while (i < 4) + tags[i++] = MSymbol.nil; + Tag = new MDatabaseTag (tags[0], tags[1], tags[2], tags[3]); + if (plist.IsMText) + { + Info.Filename = plist.Text; + plist = plist.Next; + } + else if (plist.IsPlist) + { + MPlist p = plist.Plist; + + if (p.IsMText) + Info.Filename = plist.Text; + p = p.Next; + if (! p.IsEmpty) + { + if (p.IsSymbol) + Info.Format = p.Symbol; + p = p.Next; + if (! p.IsEmpty) + { + if (p.IsSymbol) + Info.Schema = p.Symbol; + p = p.Next; + if (p.IsMText) + Info.SchemaFile = p.Text; + } + } + plist = plist.Next; + } + DBStatus = MDBStatus.OUTDATED;; + Info.Version = 0; + Info.Props = new MPlist (); + foreach (MPlist pl in plist) + { + if (pl.IsPlist) + { + MPlist p = pl.Plist; + + if (p.IsSymbol && p.Symbol == Mversion) + { + Info.Version = parse_version (p.Next); + if (M17n.Version < Info.Version) + DBStatus = MDBStatus.DISABLED; + } + } + Info.Props.Put (pl.Key, pl.Val); + } + } + + private static int parse_version (MPlist plist) + { + string[] str; + int major, minor, release; + + if (! plist.IsMText) + return 0xFFFFFF; + str = plist.Text.ToString ().Split ('.'); + if (str.Length != 3) + return 0xFFFFFF; + try { major = int.Parse (str[0]); } catch { return 0xFFFFFF; } + try { minor = int.Parse (str[1]); } catch { return 0xFFFFFF; } + try { release = int.Parse (str[2]); } catch { return 0xFFFFFF; } + return ((major << 16) | (minor << 8) | release); } public static MDatabase Define (MDatabaseTag tag, MDatabaseLoader loader, @@ -261,6 +285,9 @@ namespace M17N.Core { db.Loader = loader; db.ExtraInfo = extra_info; + db.DBType = MDBType.EXPLICIT; + db.DBStatus = MDBStatus.OUTDATED; + db.Info = null; return db; } return new MDatabase (tag, loader, extra_info); @@ -273,7 +300,11 @@ namespace M17N.Core if (db != null) { db.Loader = null; - db.Filename = new MText (filename); + db.DBType = MDBType.EXPLICIT; + db.DBStatus = MDBStatus.OUTDATED; + db.Info = new MDatabaseInfo (); + db.Info.Filename = new MText (filename); + return db; } return new MDatabase (tag, filename); @@ -289,13 +320,13 @@ namespace M17N.Core try { DBDirs[0] = new MDatabaseDir (Path.Combine (usr_dir, ".m17n.d")); } catch (ArgumentException) { - DBDirs[0] = new MDatabaseDir (Path.Combine (usr_dir, "_m17n.d")); + DBDirs[0] = new MDatabaseDir (Path.Combine (usr_dir, "_m17n_d")); } DBDirs[1] = null; DBDirs[2] = new MDatabaseDir (Path.Combine (share_dir, "m17n")); } - internal static void Update () + private static void Update () { } @@ -323,7 +354,7 @@ namespace M17N.Core private object load (MSymbol key, MSymbol stop) { - Ltime = DateTime.Now; + LoadedTime = DateTime.UtcNow; diff --git a/MPlist.cs b/MPlist.cs index 27e23e3..b6da903 100644 --- a/MPlist.cs +++ b/MPlist.cs @@ -194,6 +194,14 @@ namespace M17N.Core return p.Push (key, val); } + public MPlist Clear () + { + Key = MSymbol.nil; + Val = null; + next = null; + return this; + } + // Implement IEnumerable interface. // foreach (MPlist p in plist) { ... } diff --git a/MSymbol.cs b/MSymbol.cs index 96ff477..fe2a698 100644 --- a/MSymbol.cs +++ b/MSymbol.cs @@ -10,13 +10,15 @@ namespace M17N.Core private class MSymbolData { - public string name; - public object value; - public MPlist plist; + public readonly string Name; + public readonly MTextProperty.Flags Flags; + public object Value; + public MPlist Plist; - public MSymbolData (string name) + public MSymbolData (string name, MTextProperty.Flags flags) { - this.name = name; + Name = name; + Flags = flags; } } @@ -33,18 +35,34 @@ namespace M17N.Core { if (! pool.ContainsKey (name)) { - data = new MSymbolData (name); + data = new MSymbolData (name, MTextProperty.Flags.None); pool.Add (name, data); } else data = (MSymbolData) pool[name]; } + public MSymbol (string name, MTextProperty.Flags flags) + { + if (! pool.ContainsKey (name)) + { + data = new MSymbolData (name, flags); + pool.Add (name, data); + } + else + { + if (((MSymbolData) pool[name]).Flags != flags) + throw new ArgumentException ("Invalid MTextProperty.Flags"); + } + } + + public MTextProperty.Flags TextPropertyFlags { get { return data.Flags; } } + public override string ToString () { string str = ""; - foreach (char c in data.name) + foreach (char c in data.Name) { if (c == '\\' || c == ' ' || c == '\'' || c == '\"' || c == ':') str += "\\"; @@ -76,24 +94,24 @@ namespace M17N.Core public override int GetHashCode () { - return (data.name.GetHashCode ()); + return (data.Name.GetHashCode ()); } public MPlist Find (MSymbol key) { - return (data.plist == null ? null : data.plist.Find (key)); + return (data.Plist == null ? null : data.Plist.Find (key)); } public object Get (MSymbol key) { - return (data.plist == null ? null : data.plist.Get (key)); + return (data.Plist == null ? null : data.Plist.Get (key)); } public object Put (MSymbol key, object val) { - if (data.plist == null) - data.plist = new MPlist (); - return data.plist.Put (key, val); + if (data.Plist == null) + data.Plist = new MPlist (); + return data.Plist.Put (key, val); } } } diff --git a/MText.cs b/MText.cs index 5d8fb1b..9d98c4e 100644 --- a/MText.cs +++ b/MText.cs @@ -21,33 +21,33 @@ namespace M17N.Core public class MTextProperty { + [FlagsAttribute] + public enum Flags + { + None = 0, + /// A text inserted before a character that has this property + /// inherits this property. If the text already has properties + /// of the same key, they are deleted. See the documentation of + /// Sensitive for exception. + FrontSticky = 1, + /// A text inserted after a character that has this property + /// inherits this property. If the text already has properties + /// of the same key, they are deleted. See the documentation of + /// Sensitive for exception. + RearSticky = 2, + /// This property is deleted from a span of text if the span is + /// modified (i.e. a character is changed, a text is inserted, + /// some part is deleted). If this property is also FrontSticky + /// (or RearSticky), text insertion just before (or after) the + /// span also deletes this property from the span of text. + Sensitive = 4 + }; + internal MSymbol key; internal object val; - [FlagsAttribute] - internal enum Flag : byte - { - None = 0, - FrontSticky = 1, - RearSticky = 2, - Sensitive = 4 - }; - internal Flag flags; - public MSymbol Key { get { return key; } } public object Val { get { return val; } } - public bool FrontSticky - { - get { return (flags & Flag.FrontSticky) != Flag.None; } - } - public bool RearSticky - { - get { return (flags & Flag.RearSticky) != Flag.None; } - } - public bool Sensitive - { - get { return (flags & Flag.Sensitive) != Flag.None; } - } public MTextProperty (MSymbol key, object val) { @@ -55,19 +55,6 @@ namespace M17N.Core this.val = val; } - public MTextProperty (MSymbol key, object val, - bool front_sticky, bool rear_sticky, bool sensitive) - { - this.key = key; - this.val = val; - if (front_sticky) - flags |= Flag.FrontSticky; - if (rear_sticky) - flags |= Flag.RearSticky; - if (sensitive) - flags |= Flag.Sensitive; - } - public override string ToString () { return key.ToString () + ":" + val; @@ -341,6 +328,18 @@ namespace M17N.Core return mt; } + public MText Dup (int from, int to) + { + if (check_range (from, to, true)) + return new MText (); + + MText mt = new MText (sb.ToString ().Substring (pos_to_idx (this, from), + pos_to_idx (this, to))); + foreach (MPlist p in intervals) + mt.intervals.Add (p.Key, ((MInterval) p.Val).Copy (mt, from, to)); + return mt; + } + public MText Ins (int pos, int c) { insert (pos, c); @@ -378,7 +377,7 @@ namespace M17N.Core ((MInterval) plist.Val).Delete (from, to); else intervals = new MPlist (); - if (M17N.debug) + if (M17n.debug) DumpPropNested (); return this; } @@ -572,6 +571,24 @@ namespace M17N.Core ID = count++; } + private bool isRearSticky + { + get { return ((Key.TextPropertyFlags & MTextProperty.Flags.RearSticky) + != MTextProperty.Flags.None); } + } + + private bool isFrontSticky + { + get { return ((Key.TextPropertyFlags & MTextProperty.Flags.FrontSticky) + != MTextProperty.Flags.None); } + } + + private bool isSensitive + { + get { return ((Key.TextPropertyFlags & MTextProperty.Flags.Sensitive) + != MTextProperty.Flags.None); } + } + private void update_from_to () { if (Parent == null) @@ -795,7 +812,14 @@ namespace M17N.Core copy = new MInterval (Key, null, end - start, Stack); copy.mtext = mt; - remove_properties (MTextProperty.Flag.Sensitive); + + if (isSensitive) + { + if (isRearSticky && start < From && ! Left.Stack.IsEmpty) + Stack.Clear (); + else if (isFrontSticky && end > To && ! Right.Stack.IsEmpty) + Stack.Clear (); + } if (left_copy != null) { copy.Left = left_copy; @@ -816,7 +840,7 @@ namespace M17N.Core { MInterval interval = new MInterval (Key, mtext, To - pos, Stack); - M17N.DebugPrint ("divide-right({0}) at ", pos); DumpOne (false, true); + M17n.DebugPrint ("divide-right({0}) at ", pos); DumpOne (false, true); To = pos; if (Right != null) { @@ -836,7 +860,7 @@ namespace M17N.Core { MInterval interval = new MInterval (Key, mtext, pos - From, Stack); - M17N.DebugPrint ("divide-left({0}) at ", pos); DumpOne (false, true); + M17n.DebugPrint ("divide-left({0}) at ", pos); DumpOne (false, true); From = pos; if (Left != null) { @@ -849,17 +873,11 @@ namespace M17N.Core return interval; } - private void remove_properties (MTextProperty.Flag flags) + private void remove_properties (MTextProperty.Flags flags) { - for (MPlist p = Stack; ! p.IsEmpty;) - { - MTextProperty prop = (MTextProperty) p.Val; - - if ((prop.flags & flags) == flags) - p.Pop (); - else - p = p.Next; - } + if (! Stack.IsEmpty + && (Key.TextPropertyFlags & flags) == flags) + Stack.Clear (); } private void inherit_front_properties (MPlist plist) @@ -872,8 +890,8 @@ namespace M17N.Core { MTextProperty prop = (MTextProperty) p.Val; - if ((prop.flags & MTextProperty.Flag.RearSticky) - == MTextProperty.Flag.RearSticky) + if ((p.Key.TextPropertyFlags & MTextProperty.Flags.RearSticky) + == MTextProperty.Flags.RearSticky) i.Stack.Add (prop.key, prop); } } @@ -889,8 +907,8 @@ namespace M17N.Core { MTextProperty prop = (MTextProperty) p.Val; - if ((prop.flags & MTextProperty.Flag.FrontSticky) - == MTextProperty.Flag.FrontSticky) + if ((p.Key.TextPropertyFlags & MTextProperty.Flags.FrontSticky) + == MTextProperty.Flags.FrontSticky) i.Stack.Add (prop.key, prop); } } @@ -981,7 +999,7 @@ namespace M17N.Core return interval; Length += len; To += len; - M17N.DebugPrint ("grafted {0} in ", len); DumpOne (false, true); + M17n.DebugPrint ("grafted {0} in ", len); DumpOne (false, true); for (MInterval prev = this, ii = this.Parent; ii != null; prev = ii, ii = ii.Parent) { @@ -1000,7 +1018,7 @@ namespace M17N.Core public void Insert (int pos, MInterval interval) { update_from_to (); - M17N.DebugPrint ("insert({0}) at {1} in ", interval.Length, pos); + M17n.DebugPrint ("insert({0}) at {1} in ", interval.Length, pos); DumpOne (false, false); interval.set_mtext (mtext); @@ -1019,11 +1037,11 @@ namespace M17N.Core return; } prev.remove_properties - (MTextProperty.Flag.Sensitive|MTextProperty.Flag.RearSticky); + (MTextProperty.Flags.Sensitive|MTextProperty.Flags.RearSticky); interval.inherit_front_properties (prev.Stack); } remove_properties - (MTextProperty.Flag.Sensitive|MTextProperty.Flag.FrontSticky); + (MTextProperty.Flags.Sensitive|MTextProperty.Flags.FrontSticky); interval.inherit_rear_properties (Stack); int len; @@ -1055,7 +1073,7 @@ namespace M17N.Core } else if (pos < To) { - remove_properties (MTextProperty.Flag.Sensitive); + remove_properties (MTextProperty.Flags.Sensitive); int len; interval = graft (interval, true, out len); @@ -1083,11 +1101,11 @@ namespace M17N.Core return; } next.remove_properties - (MTextProperty.Flag.Sensitive|MTextProperty.Flag.FrontSticky); + (MTextProperty.Flags.Sensitive|MTextProperty.Flags.FrontSticky); interval.inherit_rear_properties (next.Stack); } remove_properties - (MTextProperty.Flag.Sensitive|MTextProperty.Flag.RearSticky); + (MTextProperty.Flags.Sensitive|MTextProperty.Flags.RearSticky); interval.inherit_front_properties (Stack); int len; @@ -1120,7 +1138,7 @@ namespace M17N.Core } else // (pos > To) Next.Insert (pos, interval); - M17N.DebugPrint (" done\n"); + M17n.DebugPrint (" done\n"); } private void vacate_node (MInterval interval) @@ -1131,9 +1149,9 @@ namespace M17N.Core private void vacate_node (MInterval interval, MInterval stop) { if (interval != null) - M17N.DebugPrint ("vacate #{0} to #{1}\n", ID, interval.ID); + M17n.DebugPrint ("vacate #{0} to #{1}\n", ID, interval.ID); else - M17N.DebugPrint ("vacate #{0} to null\n", ID); + M17n.DebugPrint ("vacate #{0} to null\n", ID); if (interval != null) interval.Parent = Parent; if (Parent == null) @@ -1159,7 +1177,7 @@ namespace M17N.Core public void Delete (int start, int end) { update_from_to (); - M17N.DebugPrint ("delete({0} {1}) from ", start, end); DumpOne (false, true); + M17n.DebugPrint ("delete({0} {1}) from ", start, end); DumpOne (false, true); if (start < From) { if (end <= From) @@ -1215,7 +1233,7 @@ namespace M17N.Core public void Push (int start, int end, MTextProperty prop) { update_from_to (); - M17N.DebugPrint ("push({0} {1}) at ", start, end); DumpOne (false, true); + M17n.DebugPrint ("push({0} {1}) at ", start, end); DumpOne (false, true); if (start < From) { if (end <= From) @@ -1246,8 +1264,8 @@ namespace M17N.Core private static void merge_nodes (MInterval head, MInterval tail) { - M17N.DebugPrint ("merging "); head.DumpOne (true, false); - M17N.DebugPrint (" through "); tail.DumpOne (true, false); + M17n.DebugPrint ("merging "); head.DumpOne (true, false); + M17n.DebugPrint (" through "); tail.DumpOne (true, false); int from = head.From; int to = tail.To; @@ -1256,7 +1274,7 @@ namespace M17N.Core for (root = head; root.To + root.RightLength < to; root = root.Parent); - M17N.DebugPrint (" common root is "); root.DumpOne (false, true); + M17n.DebugPrint (" common root is "); root.DumpOne (false, true); if (from < root.From) { @@ -1264,7 +1282,7 @@ namespace M17N.Core while (true) { - M17N.DebugPrint ("merging "); prev.DumpOne (false, true); + M17n.DebugPrint ("merging "); prev.DumpOne (false, true); prev.vacate_node (prev.Left, root); if (prev == head) break; @@ -1280,7 +1298,7 @@ namespace M17N.Core while (true) { - M17N.DebugPrint ("merging "); next.DumpOne (false, true); + M17n.DebugPrint ("merging "); next.DumpOne (false, true); next.vacate_node (next.Right, root); if (next == tail) break; @@ -1334,7 +1352,7 @@ namespace M17N.Core public void Pop (int start, int end) { update_from_to (); - M17N.DebugPrint ("pop({0} {1}) at ", start, end); DumpOne (false, true); + M17n.DebugPrint ("pop({0} {1}) at ", start, end); DumpOne (false, true); if (start < From) { if (end <= From) @@ -1373,7 +1391,7 @@ namespace M17N.Core private void DumpOne (bool with_prop, bool newline, bool force) { - if (force || M17N.debug) + if (force || M17n.debug) { Console.Write ("#{0}({1} {2} {3}", ID, Length, From, To); if (with_prop) @@ -1391,7 +1409,7 @@ namespace M17N.Core public void Dump (bool force) { - if (force || M17N.debug) + if (force || M17n.debug) { update_from_to (); @@ -1416,7 +1434,7 @@ namespace M17N.Core public void DumpNested (string indent, bool force) { - if (force || M17N.debug) + if (force || M17n.debug) { int indent_type = (Parent == null ? 1 : Parent.Left == this ? 0 : 2); diff --git a/plist.cs b/plist.cs index 00c2b16..249f179 100644 --- a/plist.cs +++ b/plist.cs @@ -22,7 +22,7 @@ public class Test Console.WriteLine (p.Key + ":" + p.Val); Console.WriteLine (plist.Clone ()); - M17N.M17N.debug = true; + M17n.debug = true; using (FileStream stream = File.OpenRead ("temp.plist")) { diff --git a/symbol.cs b/symbol.cs index 60d9439..f672b09 100644 --- a/symbol.cs +++ b/symbol.cs @@ -11,8 +11,8 @@ public class Test MSymbol sym2 = new MSymbol ("symbol"); MSymbol sym3 = new MSymbol ("another sym:bol"); - Console.WriteLine ("version {0}-{1}-{2}", M17N.M17N.MajorVersion, - M17N.M17N.MinorVersion, M17N.M17N.ReleaseNumber); + Console.WriteLine ("version {0}-{1}-{2}", M17n.MajorVersion, + M17n.MinorVersion, M17n.ReleaseNumber); Console.WriteLine ("sym1 = {0}", sym1); Console.WriteLine ("sym2 = {0}", sym2); @@ -25,5 +25,13 @@ public class Test Console.WriteLine (sym1.Get (sym2) + "," + sym1.Get (sym3)); Console.WriteLine (sym2.Get (sym2) + "," + sym2.Get (sym3)); Console.WriteLine (sym3.Get (sym2)); + + MSymbol sym4; + try { + sym4 = new MSymbol ("symbol", MTextProperty.Flags.Sensitive); + } catch { + Console.WriteLine ("MTextProperty.Flags mismatch"); + } + sym4 = new MSymbol ("sensitive", MTextProperty.Flags.Sensitive); } } diff --git a/textprop.cs b/textprop.cs index 3a020de..391e113 100644 --- a/textprop.cs +++ b/textprop.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using M17N; using M17N.Core; public class Test @@ -204,7 +205,7 @@ public class Test { mt.DumpPropNested (); Dump (); - M17N.M17N.debug = true; + M17n.debug = true; } int from = r.Next (LENGTH);