From d0a8d263ac7126b5911a79c7d4374e858954f2b2 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 29 Apr 2020 00:07:27 +0800 Subject: [PATCH] gtk/gtkaccelgroup.c: Fix build on Visual Studio Visual Studio does not allow one to initialize structure members with non-constant expressions, caused by using strlen(s), so fix this by using sizeof(s) - 1 instead. --- gtk/gtkaccelgroup.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gtk/gtkaccelgroup.c b/gtk/gtkaccelgroup.c index a941b6055c..b749581629 100644 --- a/gtk/gtkaccelgroup.c +++ b/gtk/gtkaccelgroup.c @@ -574,18 +574,20 @@ char * gtk_accelerator_name (guint accelerator_key, GdkModifierType accelerator_mods) { +#define TXTLEN(s) sizeof (s) - 1 static const struct { guint mask; const char *text; gsize text_len; } mask_text[] = { - { GDK_SHIFT_MASK, "", strlen ("") }, - { GDK_CONTROL_MASK, "", strlen ("") }, - { GDK_ALT_MASK, "", strlen ("") }, - { GDK_META_MASK, "", strlen ("") }, - { GDK_SUPER_MASK, "", strlen ("") }, - { GDK_HYPER_MASK, "", strlen ("") } + { GDK_SHIFT_MASK, "", TXTLEN ("") }, + { GDK_CONTROL_MASK, "", TXTLEN ("") }, + { GDK_ALT_MASK, "", TXTLEN ("") }, + { GDK_META_MASK, "", TXTLEN ("") }, + { GDK_SUPER_MASK, "", TXTLEN ("") }, + { GDK_HYPER_MASK, "", TXTLEN ("") } }; +#undef TXTLEN GdkModifierType saved_mods; guint l; guint name_len;