Commit 439f84f
treat warning as fatal
Changed files (3)
Diff
@@ -60,7 +60,7 @@ class Argument : GLib.Object { } // valid parameter- if (a == "--autosave" || a == "--exit" || a == "--slow" || a == "--help" || a == "--test") {+ if (a == "--autosave" || a == "--exit" || a == "--slow" || a == "--help" || a == "--test" || a == "--fatal-warning") { prev = a; i++; continue;@@ -182,6 +182,8 @@ class Argument : GLib.Object { return "--autosave"; case 'e': return "--exit";+ case 'f': + return "--fatal-warning"; case 's': return "--slow"; case 'h': @@ -225,6 +227,7 @@ class Argument : GLib.Object { stdout.printf (" [FILE] [OPTION ...]\n"); print_padded ("-e, --exit", "exit if a testcase failes");+ print_padded ("-f, --fatal-warning", "treat warnings as fatal"); print_padded ("-h, --help", "show this message"); print_padded ("-s, --slow", "sleep between each command in test suite"); print_padded ("-t, --test [TEST]", "run test case");@@ -461,6 +461,10 @@ class Table : Object { return (!) font_data; } + public bool has_data () { + return length > 0; + } + public virtual void parse (FontData dis) { warning (@"Parse is not implemented for $(id)."); } @@ -4733,11 +4737,20 @@ class DirectoryTable : Table { loca_table.parse (dis, head_table, maxp_table); hmtx_table.parse (dis, hhea_table, loca_table); cmap_table.parse (dis); - kern_table.parse (dis); + + if (kern_table.has_data ()) { + kern_table.parse (dis); + } + glyf_table.parse (dis, cmap_table, loca_table, hmtx_table, head_table, post_table, kern_table); - gasp_table.parse (dis); - cvt_table.parse (dis); + if (kern_table.has_data ()) { + gasp_table.parse (dis); + } + + if (kern_table.has_data ()) { + cvt_table.parse (dis); + } } public bool validate_tables (FontData dis, File file) { @@ -29,6 +29,18 @@ class Supplement { return current_font; } + public static void fatal_warning (string? log_domain, LogLevelFlags log_levels, string message) { + bool fatal = true; + + if (log_domain != null) { + stderr.printf ("%s: \n", (!) log_domain); + } + + stderr.printf ("\n%s\n\n", message); + + assert (!fatal); + } + public static void new_font () { current_font = new Font (); } @@ -106,10 +118,15 @@ class Supplement { } Gtk.init (ref arg); - var window = new MainWindow ("Supplement"); + MainWindow window = new MainWindow ("Supplement"); window.show_all (); - var idle = new IdleSource (); + if (has_argument ("--fatal-warning")) { + LogLevelFlags levels = LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL | LogLevelFlags.LEVEL_WARNING; + Log.set_handler (null, levels, fatal_warning); + } + + IdleSource idle = new IdleSource (); idle.set_callback(() => { preferences.load ();