resources: Skip initial underscores in resource section names

Initial underscores are used in c identifier to make them private,
for instance in Gtk+. However, we don't want to have this in the
resource section name, that just looks ugly.
This commit is contained in:
Alexander Larsson 2012-01-17 12:32:37 +01:00
parent 7dfbe5aa30
commit d825828b7b

View File

@ -387,6 +387,7 @@ main (int argc, char **argv)
gboolean generate_header = FALSE; gboolean generate_header = FALSE;
gboolean manual_register = FALSE; gboolean manual_register = FALSE;
char *c_name = NULL; char *c_name = NULL;
char *c_name_no_underscores;
GOptionContext *context; GOptionContext *context;
GOptionEntry entries[] = { GOptionEntry entries[] = {
{ "target", 0, 0, G_OPTION_ARG_FILENAME, &target, N_("name of the output file"), N_("FILE") }, { "target", 0, 0, G_OPTION_ARG_FILENAME, &target, N_("name of the output file"), N_("FILE") },
@ -528,6 +529,10 @@ main (int argc, char **argv)
else else
binary_target = g_strdup (target); binary_target = g_strdup (target);
c_name_no_underscores = c_name;
while (c_name_no_underscores && *c_name_no_underscores == '_')
c_name_no_underscores++;
if (binary_target != NULL && if (binary_target != NULL &&
!write_to_file (table, binary_target, &error)) !write_to_file (table, binary_target, &error))
{ {
@ -602,7 +607,7 @@ main (int argc, char **argv)
"#endif\n" "#endif\n"
"\n" "\n"
"static const SECTION union { const guint8 data[%"G_GSIZE_FORMAT"]; const double alignment; void * const ptr;} %s_resource_data = { {\n", "static const SECTION union { const guint8 data[%"G_GSIZE_FORMAT"]; const double alignment; void * const ptr;} %s_resource_data = { {\n",
c_name, data_size, c_name); c_name_no_underscores, data_size, c_name);
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
if (i % 8 == 0) if (i % 8 == 0)