From a3378338bde48bbe52ffba64bcd32131aa730357 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 13 Jul 2012 17:10:48 +0300 Subject: [PATCH] remove unused function xkb_canonicalise_components commit 46441b1184dfa8553409d493ae6336aabb900d79 removed this from the public API, and we don't need it internally. So send it to the archives. Signed-off-by: Ran Benita --- Makefile.am | 2 - src/xkb-priv.h | 20 -------- src/xkb.c | 64 ------------------------ test/canonicalise.c | 139 ---------------------------------------------------- 4 files changed, 225 deletions(-) delete mode 100644 test/canonicalise.c diff --git a/Makefile.am b/Makefile.am index a2fe5ea..3e41ba6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -121,7 +121,6 @@ TESTS = \ test/filecomp \ test/namescomp \ test/rulescomp \ - test/canonicalise \ test/state \ test/context \ test/rules-file \ @@ -134,7 +133,6 @@ test_xkey_LDADD = $(TESTS_LDADD) test_filecomp_LDADD = $(TESTS_LDADD) test_namescomp_LDADD = $(TESTS_LDADD) test_rulescomp_LDADD = $(TESTS_LDADD) -lrt -test_canonicalise_LDADD = $(TESTS_LDADD) test_state_LDADD = $(TESTS_LDADD) test_context_LDADD = $(TESTS_LDADD) test_rules_file_CFLAGS = $(AM_CFLAGS) -Wno-declaration-after-statement diff --git a/src/xkb-priv.h b/src/xkb-priv.h index bfaa300..41dc3c6 100644 --- a/src/xkb-priv.h +++ b/src/xkb-priv.h @@ -414,8 +414,6 @@ struct xkb_keymap { #define XkbKeycodeInRange(d, k) \ (((k) >= (d)->min_key_code) && ((k) <= (d)->max_key_code)) -struct xkb_state; - typedef uint32_t xkb_atom_t; #define XKB_ATOM_NONE 0 @@ -441,24 +439,6 @@ xkb_key_get_syms_by_level(struct xkb_keymap *keymap, xkb_keycode_t key, unsigned int group, unsigned int level, const xkb_keysym_t **syms_out); -/* - * Canonicalises component names by prepending the relevant component from - * 'old' to the one in 'names' when the latter has a leading '+' or '|', and - * by replacing a '%' with the relevant component, e.g.: - * - * names old output - * ------------------------------------------ - * +bar foo foo+bar - * |quux baz baz|quux - * foo+%|baz bar foo+bar|baz - * - * If a component in names needs to be modified, the existing value will be - * free()d, and a new one allocated with malloc(). - */ -void -xkb_canonicalise_components(struct xkb_component_names *names, - const struct xkb_component_names *old); - /** * Deprecated entrypoint for legacy users who need to be able to compile * XKB keymaps by KcCGST (Keycodes + Compat + Geometry + Symbols + Types) diff --git a/src/xkb.c b/src/xkb.c index 94642e3..9d9d0ba 100644 --- a/src/xkb.c +++ b/src/xkb.c @@ -26,70 +26,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "xkb-priv.h" -static char * -XkbcCanonicaliseComponent(char *name, const char *old) -{ - char *tmp; - int i; - - if (!name) - return NULL; - - /* Treachery. */ - if (old && strchr(old, '%')) - return NULL; - - if (name[0] == '+' || name[0] == '|') { - if (old) { - tmp = malloc(strlen(name) + strlen(old) + 1); - if (!tmp) - return NULL; - sprintf(tmp, "%s%s", old, name); - free(name); - name = tmp; - } - else { - memmove(name, &name[1], strlen(&name[1]) + 1); - } - } - - for (i = 0; name[i]; i++) { - if (name[i] == '%') { - if (old) { - tmp = malloc(strlen(name) + strlen(old)); - if (!tmp) - return NULL; - strncpy(tmp, name, i); - strcat(tmp + i, old); - strcat(tmp + i + strlen(old), &name[i + 1]); - free(name); - name = tmp; - i--; - } - else { - memmove(&name[i - 1], &name[i + 1], strlen(&name[i + 1]) + 1); - i -= 2; - } - } - } - - return name; -} - -_X_EXPORT void -xkb_canonicalise_components(struct xkb_component_names * names, - const struct xkb_component_names * old) -{ - names->keycodes = XkbcCanonicaliseComponent(names->keycodes, - old ? old->keycodes : NULL); - names->compat = XkbcCanonicaliseComponent(names->compat, - old ? old->compat : NULL); - names->symbols = XkbcCanonicaliseComponent(names->symbols, - old ? old->symbols : NULL); - names->types = XkbcCanonicaliseComponent(names->types, - old ? old->types : NULL); -} - static bool VirtualModsToReal(struct xkb_keymap *keymap, unsigned virtual_mask, unsigned *mask_rtrn) diff --git a/test/canonicalise.c b/test/canonicalise.c deleted file mode 100644 index c437345..0000000 --- a/test/canonicalise.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright © 2009 Daniel Stone - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Author: Daniel Stone - */ - -#include -#include -#include -#include - -#include "xkbcommon/xkbcommon.h" -#include "xkb-priv.h" - -struct test_data { - struct xkb_component_names new; - struct xkb_component_names old; - int pass_old; - const char *exp_keycodes; - const char *exp_compat; - const char *exp_symbols; - const char *exp_types; -}; - -static struct test_data * -new_data(void) -{ - return calloc(1, sizeof(struct test_data)); -} - -static void -free_data(struct test_data *data) -{ - free(data->new.keycodes); - free(data->new.compat); - free(data->new.symbols); - free(data->new.types); - free(data->old.keycodes); - free(data->old.compat); - free(data->old.symbols); - free(data->old.types); - free(data); -} - -static void -set_new(struct test_data *data, const char *keycodes, const char *compat, - const char *symbols, const char *types) -{ - data->new.keycodes = strdup(keycodes); - data->new.compat = strdup(compat); - data->new.symbols = strdup(symbols); - data->new.types = strdup(types); -} - -static void -set_old(struct test_data *data, const char *keycodes, const char *compat, - const char *symbols, const char *types) -{ - data->old.keycodes = strdup(keycodes); - data->old.compat = strdup(compat); - data->old.symbols = strdup(symbols); - data->old.types = strdup(types); - data->pass_old = 1; -} - -static void -set_exp(struct test_data *data, const char *keycodes, const char *compat, - const char *symbols, const char *types) -{ - data->exp_keycodes = keycodes; - data->exp_compat = compat; - data->exp_symbols = symbols; - data->exp_types = types; -} - -static int -test_canonicalise(struct test_data *data) -{ - fprintf(stderr, "New: %s %s %s %s\n", data->new.keycodes, - data->new.compat, data->new.symbols, data->new.types); - if (data->pass_old) - fprintf(stderr, "Old: %s %s %s %s\n", data->old.keycodes, - data->old.compat, data->old.symbols, data->old.types); - fprintf(stderr, "Expected: %s %s %s %s\n", data->exp_keycodes, - data->exp_compat, data->exp_symbols, data->exp_types); - - if (data->pass_old) - xkb_canonicalise_components(&data->new, &data->old); - else - xkb_canonicalise_components(&data->new, NULL); - - fprintf(stderr, "Received: %s %s %s %s\n\n", data->new.keycodes, - data->new.compat, data->new.symbols, data->new.types); - - return (strcmp(data->new.keycodes, data->exp_keycodes) == 0) && - (strcmp(data->new.compat, data->exp_compat) == 0) && - (strcmp(data->new.symbols, data->exp_symbols) == 0) && - (strcmp(data->new.types, data->exp_types) == 0); -} - -int -main(void) -{ - struct test_data *twopart, *onepart; - - twopart = new_data(); - set_new(twopart, "+inet(pc104)", "%+complete", "pc(pc104)+%+ctrl(nocaps)", "|complete"); - set_old(twopart, "xfree86", "basic", "us(dvorak)", "xfree86"); - set_exp(twopart, "xfree86+inet(pc104)", "basic+complete", "pc(pc104)+us(dvorak)+ctrl(nocaps)", "xfree86|complete"); - assert(test_canonicalise(twopart)); - free_data(twopart); - - onepart = new_data(); - set_new(onepart, "evdev", "complete", "pc(pc104)+us+compose(ralt)", "complete"); - set_exp(onepart, "evdev", "complete", "pc(pc104)+us+compose(ralt)", "complete"); - assert(test_canonicalise(onepart)); - free_data(onepart); - - return 0; -} -- 2.7.4