mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
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
This commit is contained in:
parent
0e5e3d0d65
commit
8345a42cd0
@ -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))
|
||||
;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user