[glib] Recognise common C++ extension for automatic target selection
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Recognise common C++ extension for automatic target selection
- Date: Sun, 17 Jul 2016 03:32:22 +0000 (UTC)
commit 8345a42cd0deec27664f1a2a815feadeb53e2556
Author: Christian Persch <chpe gnome org>
Date: Tue Mar 31 20:49:58 2015 +0200
Recognise common C++ extension for automatic target selection
glib-compile-resources --generate is supposed to automatically detect
whether to generate source code or header from the target's file extension.
However, this only worked for C; extend this to include the canonical
C++ filename extensions. Also make the check case insensitive.
https://bugzilla.gnome.org/show_bug.cgi?id=747134
gio/glib-compile-resources.c | 33 ++++++++++++++++++++++++++++++---
1 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/gio/glib-compile-resources.c b/gio/glib-compile-resources.c
index bc38b56..71a0f48 100644
--- a/gio/glib-compile-resources.c
+++ b/gio/glib-compile-resources.c
@@ -573,6 +573,33 @@ write_to_file (GHashTable *table,
return success;
}
+static gboolean
+extension_in_set (const char *str,
+ ...)
+{
+ va_list list;
+ const char *ext, *value;
+ gboolean rv = FALSE;
+
+ ext = strrchr (str, '.');
+ if (ext == NULL)
+ return FALSE;
+
+ ext++;
+ va_start (list, str);
+ while ((value = va_arg (list, const char *)) != NULL)
+ {
+ if (g_ascii_strcasecmp (ext, value) != 0)
+ continue;
+
+ rv = TRUE;
+ break;
+ }
+
+ va_end (list);
+ return rv;
+}
+
int
main (int argc, char **argv)
{
@@ -697,11 +724,11 @@ main (int argc, char **argv)
}
else if (generate_automatic)
{
- if (g_str_has_suffix (target, ".c"))
+ if (extension_in_set (target, "c", "cc", "cpp", "cxx", "c++", NULL))
generate_source = TRUE;
- else if (g_str_has_suffix (target, ".h"))
+ else if (extension_in_set (target, "h", "hh", "hpp", "hxx", "h++", NULL))
generate_header = TRUE;
- else if (g_str_has_suffix (target, ".gresource"))
+ else if (extension_in_set (target, "gresource", NULL))
;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]