From: Christophe CURIS <[email protected]>
CLang does not support nested function declaration, so we have to fall back
to using a macro, with all the drawbacks it has.
A new version, because in my anger against CLang I missed undefining the
macro at the end, something automatic when using a nested function...
---
src/misc.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/src/misc.c b/src/misc.c
index 51eb1ee..9f1e51b 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -763,21 +763,23 @@ char *GetShortcutKey(WShortKey key)
char buffer[256];
char *wr;
- void append_string(const char *string)
- {
- while (*string) {
- if (wr >= buffer + sizeof(buffer) - 1)
- break;
- *wr++ = *string++;
- }
+#define append_string(text) \
+ { \
+ const char *string = text; \
+\
+ while (*string) { \
+ if (wr >= buffer + sizeof(buffer) - 1) \
+ break; \
+ *wr++ = *string++; \
+ } \
}
- void append_modifier(int modifier_index, const char *fallback_name)
- {
- if (wPreferences.modifier_labels[modifier_index])
-
append_string(wPreferences.modifier_labels[modifier_index]);
- else
- append_string(fallback_name);
+#define append_modifier(modifier_index, fallback_name) \
+ { \
+ if (wPreferences.modifier_labels[modifier_index])
\
+
append_string(wPreferences.modifier_labels[modifier_index]) \
+ else \
+ append_string(fallback_name) \
}
key_name = XKeysymToString(XkbKeycodeToKeysym(dpy, key.keycode, 0, 0));
@@ -795,6 +797,9 @@ char *GetShortcutKey(WShortKey key)
append_string(key_name);
*wr = '\0';
+#undef append_string
+#undef append_modifier
+
return GetShortcutString(buffer);
}
--
2.1.3
--
To unsubscribe, send mail to [email protected].