I've now constructed a patch that fixes this problem for me. (I don't
think this will fix the original problem as that was running loadkeys
without --mktable)

I now do:

LD_PRELOAD=./libconsole.so ./loadkeys -u --mktable keymap_psion_us.map 
>keymap_psion_us.patch.c

and the mapfile is created correctly and there is no attempt to access
the console.

(This patch is against sarge. If you want it against unstable then let
me know and I'll do that)

Tim.

diff -aur console-tools-0.2.3.orig/include/lct/ksyms.h 
console-tools-0.2.3/include/lct/ksyms.h
--- console-tools-0.2.3.orig/include/lct/ksyms.h        2006-04-01 
10:44:24.000000000 +0100
+++ console-tools-0.2.3/include/lct/ksyms.h     2006-04-01 10:46:07.000000000 
+0100
@@ -21,8 +21,8 @@
 extern const int charsets_size;

 extern int set_charset(const char *name);
-extern int add_number(int code);
-extern int add_capslock(int code);
+extern int add_number(int code, const int *kbd_mode);
+extern int add_capslock(int code, const int *kbd_mode);
 extern const char *codetoksym(int code);
 extern void list_charsets(FILE *f);

diff -aur console-tools-0.2.3.orig/kbdtools/analyze.l 
console-tools-0.2.3/kbdtools/analyze.l
--- console-tools-0.2.3.orig/kbdtools/analyze.l 2006-04-01 10:42:22.000000000 
+0100
+++ console-tools-0.2.3/kbdtools/analyze.l      2006-04-01 10:59:26.000000000 
+0100
@@ -6,10 +6,11 @@
 #include <lct/utils.h>
 #include "loadkeys.h"

-extern int ksymtocode(char *s);
+extern int ksymtocode(char *s, const int *kbd_mode);

 extern int line_nr;
 extern int verbose;                              /* loadkeys.y */
+extern const int *p_kbd_mode;                    /* loadkeys.y */
 extern char pathname[];                                  /* idem */
 int    yylval;
 int    rvalct;
@@ -88,7 +89,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))==-1?ERROR:LITERAL);}
+<RVALUE>{Literal}        {return((yylval=ksymtocode(yytext, 
p_kbd_mode))==-1?ERROR:LITERAL);}
 {Charset}              {return(CHARSET);}
 {Keymaps}              {return(KEYMAPS);}
 {Keycode}              {return(KEYCODE);}
diff -aur console-tools-0.2.3.orig/kbdtools/loadkeys.y 
console-tools-0.2.3/kbdtools/loadkeys.y
--- console-tools-0.2.3.orig/kbdtools/loadkeys.y        2006-04-01 
10:46:55.000000000 +0100
+++ console-tools-0.2.3/kbdtools/loadkeys.y     2006-04-01 11:09:36.000000000 
+0100
@@ -85,6 +85,9 @@
 int lk_pop(void);                                /* idem */
 extern int infile_stack_ptr;                     /* idem */

+static int kbd_mode = K_RAW;                     /* Default kbd mode if 
running with -m */
+const int *p_kbd_mode;
+
 #ifndef KT_LETTER
 #define KT_LETTER KT_LATIN
 #endif
@@ -285,17 +288,17 @@
                        }
                ;
 rvalue         : NUMBER
-                       {$$=add_number($1);}
+                       {$$=add_number($1, p_kbd_mode);}
                | LITERAL
-                       {$$=add_number($1);}
+                       {$$=add_number($1, p_kbd_mode);}
                | UNUMBER
-                       {$$=add_number($1);}
+                       {$$=add_number($1, p_kbd_mode);}
                 | PLUS NUMBER
-                        {$$=add_capslock($2);}
+                        {$$=add_capslock($2, p_kbd_mode);}
                | PLUS UNUMBER
-                       {$$=add_capslock($2);}
+                       {$$=add_capslock($2, p_kbd_mode);}
                 | PLUS LITERAL
-                        {$$=add_capslock($2);}
+                        {$$=add_capslock($2, p_kbd_mode);}
                ;
 %%

@@ -380,6 +383,7 @@
        case 'm':
          optm = 1;
          quiet = 1;
+         p_kbd_mode = &kbd_mode;
          break;
        case 's':
          opts = 1;
@@ -389,6 +393,7 @@
          break;
        case 'u':
                set_charset("unicode");
+               kbd_mode = K_UNICODE;
                break;
        case 'v':
          verbose++;
diff -aur console-tools-0.2.3.orig/lib/ksyms.c console-tools-0.2.3/lib/ksyms.c
--- console-tools-0.2.3.orig/lib/ksyms.c        2006-04-01 09:32:27.000000000 
+0100
+++ console-tools-0.2.3/lib/ksyms.c     2006-04-01 10:49:16.000000000 +0100
@@ -1711,12 +1711,12 @@
 /* Functions for loadkeys. */

 int
-ksymtocode(const char *s) {
+ksymtocode(const char *s, const int *kbd_mode) {
        int i;
        int j;
        int keycode;
        static int fd = -1;
-       int kbd_mode;
+       int lcl_kbd_mode;
        int syms_start = 0;
        sym *p;

@@ -1725,21 +1725,25 @@
                return -1;
        }

-       if (fd < 0)
-               fd = get_console_fd(NULL);
-       ioctl(fd, KDGKBMODE, &kbd_mode);
+       if(kbd_mode)
+               lcl_kbd_mode = *kbd_mode;
+       else {
+               if (fd < 0)
+                       fd = get_console_fd(NULL);
+               ioctl(fd, KDGKBMODE, &lcl_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);
-               ioctl(fd, KDSKBMODE, kbd_mode);
+               int xlate_kbd_mode = K_XLATE;
+               keycode = ksymtocode(s+5, &xlate_kbd_mode);
                if (KTYP(keycode) == KT_LATIN)
                        return K(KT_META, KVAL(keycode));
                /* fall through to error printf */
        }

-       if (kbd_mode == K_UNICODE) {
+       if (lcl_kbd_mode == K_UNICODE) {
                for (j = 0; j < 0x80; j++)
                        if (!strcmp(s,iso646_syms[j]))
                                return (j ^ 0xf000);
@@ -1752,9 +1756,9 @@
        }
        for (i = 0; i < syn_size; i++)
                if (!strcmp(s, synonyms[i].synonym))
-                       return ksymtocode(synonyms[i].official_name);
+                       return ksymtocode(synonyms[i].official_name, kbd_mode);

-       if (kbd_mode == K_UNICODE) {
+       if (lcl_kbd_mode == K_UNICODE) {
                for (i = 0; i < sizeof(charsets)/sizeof(charsets[0]); i++) {
                        p = charsets[i].charnames;
                        for (j = charsets[i].start; j < 256; j++, p++)
@@ -1807,32 +1811,38 @@
 }

 int
-add_number(int code)
+add_number(int code, const int *kbd_mode)
 {
-       int kbd_mode;
+       int lcl_kbd_mode;
        static int fd =  -1;

-       if (fd < 0)
-               fd = get_console_fd(NULL);
-
        if (KTYP(code) == KT_META)
                return code;
-       ioctl(fd, KDGKBMODE, &kbd_mode);
-       if (kbd_mode == K_UNICODE && KTYP(code) >= syms_size) {
+
+       if(kbd_mode)
+               lcl_kbd_mode = *kbd_mode;
+       else {
+               if (fd < 0)
+                       fd = get_console_fd(NULL);
+
+               ioctl(fd, KDGKBMODE, &lcl_kbd_mode);
+       }
+ + if (lcl_kbd_mode == K_UNICODE && KTYP(code) >= syms_size) {
                if ((code ^ 0xf000) < 0x80)
                        return K(KT_LATIN, code ^ 0xf000);
                else
                        return code;
        }
-       if (kbd_mode != K_UNICODE && KTYP(code) < syms_size)
+       if (lcl_kbd_mode != K_UNICODE && KTYP(code) < syms_size)
                return code;
-       return ksymtocode(codetoksym(code));
+       return ksymtocode(codetoksym(code), kbd_mode);
 }

 int
-add_capslock(int code)
+add_capslock(int code, const int *kbd_mode)
 {
        if (KTYP(code) == KT_LATIN)
                code = K(KT_LETTER, KVAL(code));
-       return add_number(code);
+       return add_number(code, kbd_mode);
 }

--
God said, "div D = rho, div B = 0, curl E = - @B/@t, curl H = J + @D/@t,"
and there was light.

     http://tjw.hn.org/      http://www.locofungus.btinternet.co.uk/


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to