From 6186383e70b56ba0782fae3c851779f2f079cbcd Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 16 Jul 2018 22:22:10 +0200 Subject: Keyboard.c: simplify RLMVO string handling --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 46 ++++++--------------------- 1 file changed, 9 insertions(+), 37 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 103a817dd..9c0fd0212 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -570,7 +570,6 @@ int nxagentKeyboardProc(DeviceIntPtr pDev, int onoff) int i, j; XKeyboardState values; char *model = NULL, *layout = NULL; - int free_model = 0, free_layout = 0; XkbDescPtr xkb = NULL; switch (onoff) @@ -726,16 +725,9 @@ XkbError: XkbFreeKeyboard(xkb, XkbAllComponentsMask, True); xkb = NULL; - if (free_model) - { - free_model = 0; - free(model); - } - if (free_layout) - { - free_layout = 0; - free(layout); - } + + free(model); + free(layout); #endif XGetKeyboardControl(nxagentDisplay, &values); @@ -757,7 +749,7 @@ XkbError: #ifdef XKB } else { /* if (noXkbExtension) */ XkbComponentNamesRec names = {0}; - char *rules, *variants, *options; + char *rules = NULL, *variants = NULL, *options = NULL; /* use xkb default */ #ifdef TEST fprintf(stderr, "nxagentKeyboardProc: Using XKB extension.\n"); @@ -767,8 +759,6 @@ XkbError: fprintf(stderr, "nxagentKeyboardProc: nxagentKeyboard is [%s].\n", nxagentKeyboard ? nxagentKeyboard : "NULL"); #endif - rules = NULL; /* use xkb default */ - /* from nxagent changelog: 2.0.22: @@ -791,11 +781,8 @@ XkbError: goto XkbError; } - free_model = 1; - model = strndup(nxagentKeyboard, i); - - free_layout = 1; - layout = strdup(&nxagentKeyboard[i + 1]); + model = strndup(nxagentKeyboard, i); + layout = strdup(&nxagentKeyboard[i + 1]); /* * There is no description for pc105 on Solaris. @@ -824,18 +811,12 @@ XkbError: } else { - layout = NULL; /* use xkb default */ - model = NULL; /* use xkb default */ - #ifdef TEST fprintf(stderr, "nxagentKeyboardProc: Using default keyboard: model [%s] layout [%s].\n", model, layout); #endif } - variants = NULL; /* use xkb default */ - options = NULL; /* use xkb default */ - #ifdef TEST fprintf(stderr, "nxagentKeyboardProc: Init XKB extension.\n"); #endif @@ -900,20 +881,11 @@ XkbEnd: NXShadowInitKeymap(&(pDev->key->curKeySyms)); } - if (free_model) - { - free_model = 0; - free(model); - } - - if (free_layout) - { - free_layout = 0; - free(layout); - } - XkbFreeKeyboard(xkb, XkbAllComponentsMask, True); xkb = NULL; + + free(model); + free(layout); } #endif -- cgit v1.2.3