1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

wmaker: work around compilers that do not support nested functions

There are a few cases in which nested functions are an helpful way to write
code, as this is explained in 'script/nested-func-to-macro.sh'. However,
some compiler do not support them (like clang), so this patch proposes an
elegant solution, where developers can get the benefit of them, but for
users they are automatically converted to C macro if needed.

The advantage of this solution is that we keep the code simple, there is no
hack in the source (like #ifdef and code duplication), yet still having the
full advantages.

The translation is done according to what have been detected by configure
(see the WM_PROG_CC_NESTEDFUNC macro) so that user has nothing to do.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-12-05 18:02:40 +01:00
committed by Carlos R. Mafra
parent a24efec61f
commit 10371836ed
6 changed files with 285 additions and 5 deletions

View File

@@ -763,8 +763,10 @@ char *GetShortcutKey(WShortKey key)
char buffer[256];
char *wr;
void append_string(const char *string)
void append_string(const char *text)
{
const char *string = text;
while (*string) {
if (wr >= buffer + sizeof(buffer) - 1)
break;
@@ -774,10 +776,11 @@ char *GetShortcutKey(WShortKey key)
void append_modifier(int modifier_index, const char *fallback_name)
{
if (wPreferences.modifier_labels[modifier_index])
if (wPreferences.modifier_labels[modifier_index]) {
append_string(wPreferences.modifier_labels[modifier_index]);
else
} else {
append_string(fallback_name);
}
}
key_name = XKeysymToString(XkbKeycodeToKeysym(dpy, key.keycode, 0, 0));