From 7ec5240ab9eb3566257072f2ebf4d9348361d303 Mon Sep 17 00:00:00 2001 From: Alexey Gladkov Date: Fri, 21 Oct 2011 14:15:54 +0400 Subject: [PATCH] Fix -d option Signed-off-by: Alexey Gladkov Reported-by: Jaroslav Skarvada --- src/loadkeys.c | 36 +++++++++++++++++------------------- src/loadkeys.y | 36 +++++++++++++++++------------------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/src/loadkeys.c b/src/loadkeys.c index 4ea48a4..f92a765 100644 --- a/src/loadkeys.c +++ b/src/loadkeys.c @@ -2899,6 +2899,8 @@ int main(int argc, char *argv[]) int kbd_mode; int kd_mode; char *console = NULL; + char *ev; + FILE *f; set_progname(argv[0]); @@ -2987,29 +2989,26 @@ int main(int argc, char *argv[]) } } - for (i = optind; argv[i]; i++) { - FILE *f; - char *ev; + dirpath = dirpath1; + if ((ev = getenv("LOADKEYS_KEYMAP_PATH")) != NULL) { + if (!quiet && !optm) + fprintf(stdout, _("Searching in %s\n"), ev); - dirpath = dirpath1; - if ((ev = getenv("LOADKEYS_KEYMAP_PATH")) != NULL) { - if (!quiet && !optm) - fprintf(stdout, _("Searching in %s\n"), ev); + dirpath2[0] = ev; + dirpath = dirpath2; + } - dirpath2[0] = ev; - dirpath = dirpath2; - } + if (optd) { + /* first read default map - search starts in . */ - if (optd) { - /* first read default map - search starts in . */ - optd = 0; - if ((f = findfile(DEFMAP, dirpath, suffixes)) == NULL) { - fprintf(stderr, _("Cannot find %s\n"), DEFMAP); - exit(EXIT_FAILURE); - } - goto gotf; + if ((f = findfile(DEFMAP, dirpath, suffixes)) == NULL) { + fprintf(stderr, _("Cannot find %s\n"), DEFMAP); + exit(EXIT_FAILURE); } + parse_keymap(f); + } + for (i = optind; argv[i]; i++) { if (!strcmp(argv[i], "-")) { f = stdin; strcpy(pathname, ""); @@ -3019,7 +3018,6 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - gotf: parse_keymap(f); } diff --git a/src/loadkeys.y b/src/loadkeys.y index b03ff51..1a32440 100644 --- a/src/loadkeys.y +++ b/src/loadkeys.y @@ -1088,6 +1088,8 @@ int main(int argc, char *argv[]) int kbd_mode; int kd_mode; char *console = NULL; + char *ev; + FILE *f; set_progname(argv[0]); @@ -1176,29 +1178,26 @@ int main(int argc, char *argv[]) } } - for (i = optind; argv[i]; i++) { - FILE *f; - char *ev; + dirpath = dirpath1; + if ((ev = getenv("LOADKEYS_KEYMAP_PATH")) != NULL) { + if (!quiet && !optm) + fprintf(stdout, _("Searching in %s\n"), ev); - dirpath = dirpath1; - if ((ev = getenv("LOADKEYS_KEYMAP_PATH")) != NULL) { - if (!quiet && !optm) - fprintf(stdout, _("Searching in %s\n"), ev); + dirpath2[0] = ev; + dirpath = dirpath2; + } - dirpath2[0] = ev; - dirpath = dirpath2; - } + if (optd) { + /* first read default map - search starts in . */ - if (optd) { - /* first read default map - search starts in . */ - optd = 0; - if ((f = findfile(DEFMAP, dirpath, suffixes)) == NULL) { - fprintf(stderr, _("Cannot find %s\n"), DEFMAP); - exit(EXIT_FAILURE); - } - goto gotf; + if ((f = findfile(DEFMAP, dirpath, suffixes)) == NULL) { + fprintf(stderr, _("Cannot find %s\n"), DEFMAP); + exit(EXIT_FAILURE); } + parse_keymap(f); + } + for (i = optind; argv[i]; i++) { if (!strcmp(argv[i], "-")) { f = stdin; strcpy(pathname, ""); @@ -1208,7 +1207,6 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - gotf: parse_keymap(f); } -- 2.7.4