* Recai Oktas [2004-07-05 10:16:30+0300] [...] > > Index: packages/kbd-chooser/getfd.c > > =================================================================== > > --- packages/kbd-chooser/getfd.c (revision 17443) > > +++ packages/kbd-chooser/getfd.c (working copy) > > @@ -45,7 +45,9 @@ > > } > > > > int getfd() { > > - int fd; > > + static int fd = -1; > > + if (fd >= 0) > > + return fd; > > > > fd = open_a_console("/dev/tty"); > > if (fd >= 0) > > Ok, This should be the way to go. I'll test it and modify the patch. > Thanks for your time and comments. I prepared a new patch against kbd-chooser. First of all, I applied Denis's patch for plus symbols. I also modified my previous patch in accordance with Denis's suggestion quoted above. By reverting the changes applied to some functions, now kbd-chooser codebase doesn't divert from the console-tools. The problem regarding the getfd calls was solved by modifying only the kbd-chooser spesific getfd.c file. Here is the changelog: * Denis Barbier - Make kbd-chooser work with keymaps containing plus symbols. * Recai Oktas - Preserve compatibility with the console-tools by modifying the previous patch. I tested it for French, Ukrainian and Turkish keyboards and didn't see any problem. It should also work with the 'ua.kmap' containing plus symbols. Eugeniy, could it be possible to confirm this? [1] Regards, [1] http://l10n-turkish.alioth.debian.org/kbd/kbd-chooser_0.58_i386.udeb -- roktas
diff -ruN kbd-chooser.orig/analyze.l kbd-chooser/analyze.l --- kbd-chooser.orig/analyze.l 2004-07-04 20:05:15.000000000 +0300 +++ kbd-chooser/analyze.l 2004-07-05 20:52:29.000000000 +0300 @@ -6,7 +6,6 @@ #include "xmalloc.h" extern int line_nr; -extern int file_descriptor; int yylval; int rvalct; @@ -80,7 +79,7 @@ \+ {return(PLUS);} {Unicode} {yylval=strtol(yytext+1,NULL,16) ^ 0xf000;return(UNUMBER);} {Decimal}|{Octal}|{Hex} {yylval=strtol(yytext,NULL,0);return(NUMBER);} -<RVALUE>{Literal} {return((yylval=ksymtocode(yytext,file_descriptor))==-1?ERROR:LITERAL); +<RVALUE>{Literal} {return((yylval=ksymtocode(yytext))==-1?ERROR:LITERAL); } {Charset} {return(CHARSET);} {Keymaps} {return(KEYMAPS);} diff -ruN kbd-chooser.orig/debian/changelog kbd-chooser/debian/changelog --- kbd-chooser.orig/debian/changelog 2004-07-04 20:05:14.000000000 +0300 +++ kbd-chooser/debian/changelog 2004-07-05 20:54:23.000000000 +0300 @@ -1,3 +1,13 @@ +kbd-chooser (0.58) unstable; urgency=low + + * Denis Barbier + - Make kbd-chooser work with keymaps containing plus symbols. + * Recai Oktas + - Preserve compatibility with the console-tools by modifying + the previous patch. + + -- Alastair McKinstry <mckinstry@debian.org> Mon, 5 Jul 2004 12:35:06 +0300 + kbd-chooser (0.57) unstable; urgency=low * Denis Barbier diff -ruN kbd-chooser.orig/getfd.c kbd-chooser/getfd.c --- kbd-chooser.orig/getfd.c 2004-03-26 03:48:25.000000000 +0200 +++ kbd-chooser/getfd.c 2004-07-05 20:52:29.000000000 +0300 @@ -45,7 +45,10 @@ } int getfd() { - int fd; + static int fd = -1; + + if (fd >= 0) + return fd; fd = open_a_console("/dev/tty"); if (fd >= 0) diff -ruN kbd-chooser.orig/ksyms.c kbd-chooser/ksyms.c --- kbd-chooser.orig/ksyms.c 2004-07-04 20:05:14.000000000 +0300 +++ kbd-chooser/ksyms.c 2004-07-05 20:52:29.000000000 +0300 @@ -5,6 +5,7 @@ #include <string.h> #include <debian-installer.h> #include "ksyms.h" +#include "getfd.h" #include "nls.h" @@ -1686,6 +1687,8 @@ if (KTYP(code) == KT_META) return NULL; + if (KTYP(code) == KT_LETTER) + code = K(KT_LATIN, KVAL(code)); if (KTYP(code) < syms_size) return syms[KTYP(code)].table[KVAL(code)]; code = code ^ 0xf000; @@ -1706,10 +1709,11 @@ /* Functions for loadkeys. */ int -ksymtocode(const char *s, int fd) { +ksymtocode(const char *s) { int i; int j; int keycode; + int fd; int kbd_mode; int syms_start = 0; sym *p; @@ -1719,12 +1723,14 @@ return -1; } + fd = getfd(); + ioctl(fd, KDGKBMODE, &kbd_mode); if (!strncmp(s, "Meta_", 5)) { /* Temporarily change kbd_mode to ensure that keycode is * right. */ ioctl(fd, KDSKBMODE, K_XLATE); - keycode = ksymtocode(s+5, fd); + keycode = ksymtocode(s+5); ioctl(fd, KDSKBMODE, kbd_mode); if (KTYP(keycode) == KT_LATIN) return K(KT_META, KVAL(keycode)); @@ -1745,7 +1751,7 @@ for (i = 0; i < syn_size; i++) if (!strcmp(s, synonyms[i].synonym)) - return ksymtocode(synonyms[i].official_name, fd); + return ksymtocode(synonyms[i].official_name); if (kbd_mode == K_UNICODE) { for (i = 0; i < sizeof(charsets)/sizeof(charsets[0]); i++) { @@ -1800,14 +1806,14 @@ } int -add_number(int code, int fd) +add_number(int code) { - int kbd_mode; + int kbd_mode; if (KTYP(code) == KT_META) return code; - ioctl(fd, KDGKBMODE, &kbd_mode); + ioctl(getfd(), KDGKBMODE, &kbd_mode); if (kbd_mode == K_UNICODE && KTYP(code) >= syms_size) { if ((code ^ 0xf000) < 0x80) return K(KT_LATIN, code ^ 0xf000); @@ -1816,14 +1822,15 @@ } if (kbd_mode != K_UNICODE && KTYP(code) < syms_size) return code; - return ksymtocode(codetoksym(code), fd); + return ksymtocode(codetoksym(code)); } int add_capslock(int code) { if (KTYP(code) == KT_LATIN) - return K(KT_LETTER, KVAL(code)); - return code; + code = K(KT_LETTER, KVAL(code)); + + return add_number(code); } diff -ruN kbd-chooser.orig/ksyms.h kbd-chooser/ksyms.h --- kbd-chooser.orig/ksyms.h 2004-07-04 20:05:15.000000000 +0300 +++ kbd-chooser/ksyms.h 2004-07-05 20:52:29.000000000 +0300 @@ -23,9 +23,9 @@ extern const int syn_size; extern int set_charset(const char *name); -extern int ksymtocode(const char *s, int fd); +extern int ksymtocode(const char *s); extern const char *codetoksym(int code); -extern int add_number(int code, int fd); +extern int add_number(int code); extern int add_capslock(int code); #endif diff -ruN kbd-chooser.orig/loadkeys.y kbd-chooser/loadkeys.y --- kbd-chooser.orig/loadkeys.y 2004-07-04 20:05:15.000000000 +0300 +++ kbd-chooser/loadkeys.y 2004-07-05 20:52:29.000000000 +0300 @@ -85,8 +85,6 @@ extern int rvalct; extern struct kbsentry kbs_buf; -extern int file_descriptor; /* File descriptor of current console. */ - #include "ksyms.h" @@ -236,11 +234,11 @@ } ; rvalue : NUMBER - {$$=add_number($1,file_descriptor);} + {$$=add_number($1);} | LITERAL - {$$=add_number($1,file_descriptor);} + {$$=add_number($1);} | UNUMBER - {$$=add_number($1,file_descriptor);} + {$$=add_number($1);} | PLUS NUMBER {$$=add_capslock($2);} | PLUS UNUMBER @@ -255,27 +253,20 @@ char *keymap_name; int nocompose = 0; -/* File descriptor referring to the current console. */ -int file_descriptor = -1; - -void get_file_descriptor (void) -{ - file_descriptor = getfd (); -} - void loadkeys_wrapper (char *map) { - /* File descriptor will be used repeatedly for symbol conversions. */ - get_file_descriptor (); + int fd; + fd = getfd(); keymap_name = map; + yywrap (); if (yyparse() || private_error_ct) { di_error ("kbd-chooser: Syntax error in keymap\n"); exit (1); } do_constant(); - loadkeys (file_descriptor); + loadkeys (fd); exit (0); }
Attachment:
signature.asc
Description: Digital signature