From: Mark Lee Date: Thu, 28 May 2009 08:43:40 +0000 (-0700) Subject: GIR writer: Remove GLib.Regex reference X-Git-Tag: 0.7.4~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=357f23fd794db87a5a2054d7d94f4efd31f06e6b;p=thirdparty%2Fvala.git GIR writer: Remove GLib.Regex reference The GRegex reference prevents compilation with GLib 2.12. The code has been replaced with equivalent code derived from the string class. Fixes bug 584098. --- diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala index 2bb6c00d3..06c8bf6d3 100644 --- a/compiler/valacompiler.vala +++ b/compiler/valacompiler.vala @@ -363,22 +363,29 @@ class Vala.Compiler { if (library != null) { if (gir != null) { if (context.profile == Profile.GOBJECT) { - string[] split_gir = Regex.split_simple("(.*)-([0-9]+(\\.[0-9]+)?)\\.gir$", gir); + long gir_len = gir.len (); + unowned string? last_hyphen = gir.rchr (gir_len, '-'); - if (split_gir.length < 4) { + if (last_hyphen == null || !gir.has_suffix (".gir")) { Report.error (null, "GIR file name `%s' is not well-formed, expected NAME-VERSION.gir".printf (gir)); } else { - var gir_writer = new GIRWriter (); - string gir_namespace = split_gir[1]; - string gir_version = split_gir[2]; - - // put .gir file in current directory unless -d has been explicitly specified - string gir_directory = "."; - if (directory != null) { - gir_directory = context.directory; + long offset = gir.pointer_to_offset (last_hyphen); + string gir_namespace = gir.substring (0, offset); + string gir_version = gir.substring (offset + 1, gir_len - offset - 5); + gir_version.canon ("0123456789.", '?'); + if (gir_namespace == "" || gir_version == "" || !gir_version[0].isdigit () || gir_version.contains ("?")) { + Report.error (null, "GIR file name `%s' is not well-formed, expected NAME-VERSION.gir".printf (gir)); + } else { + var gir_writer = new GIRWriter (); + + // put .gir file in current directory unless -d has been explicitly specified + string gir_directory = "."; + if (directory != null) { + gir_directory = context.directory; + } + + gir_writer.write_file (context, gir_directory, gir_namespace, gir_version, library); } - - gir_writer.write_file (context, gir_directory, gir_namespace, gir_version, library); } }