[vala] GIR writer: Remove GLib.Regex reference
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [vala] GIR writer: Remove GLib.Regex reference
- Date: Thu, 28 May 2009 15:03:47 -0400 (EDT)
commit 357f23fd794db87a5a2054d7d94f4efd31f06e6b
Author: Mark Lee <marklee src gnome org>
Date: Thu May 28 01:43:40 2009 -0700
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.
---
compiler/valacompiler.vala | 31 +++++++++++++++++++------------
1 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index 2bb6c00..06c8bf6 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);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]