home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume10 / x10r4.sunpch / part03 / Xlib / changes / XKeyBind.c.patch < prev   
Text File  |  1987-07-14  |  5KB  |  170 lines

  1. *** /usr/src/new/X.V10R4/Xlib/XKeyBind.c    Mon Dec  1 19:05:22 1986
  2. --- XKeyBind.c    Mon Jun  8 14:29:50 1987
  3. ***************
  4. *** 1,6 ****
  5.   #include <X/mit-copyright.h>
  6.   
  7. ! /* $Header: XKeyBind.c,v 10.12 86/07/21 15:27:14 wesommer Rel $ */
  8.   /* Copyright 1985, Massachusetts Institute of Technology */
  9.   
  10.   #include "XlibInternal.h"
  11. --- 1,6 ----
  12.   #include <X/mit-copyright.h>
  13.   
  14. ! /* $Header: XKeyBind.c,v 1.2 87/05/02 17:22:44 mayer Exp $ */
  15.   /* Copyright 1985, Massachusetts Institute of Technology */
  16.   
  17.   #include "XlibInternal.h"
  18. ***************
  19. *** 10,15 ****
  20. --- 10,18 ----
  21.   #include "Xkeyboard.h"
  22.   #include <stdio.h>
  23.   #include <strings.h>
  24. + #ifdef KEYBD
  25. + #include "Xdefault.h"
  26. + #endif KEYBD
  27.   
  28.   #define EMPTY_ENTRY LeftMask 
  29.      /* if the "metabits" field of a runtime table entry contains this,
  30. ***************
  31. *** 25,31 ****
  32.   
  33.   typedef struct {
  34.       unsigned char keycode;
  35. !     unsigned char metabits;
  36.       short length;
  37.       char *value;
  38.       } RuntimeTableEntry;
  39. --- 28,34 ----
  40.   
  41.   typedef struct {
  42.       unsigned char keycode;
  43. !     unsigned short metabits;
  44.       short length;
  45.       char *value;
  46.       } RuntimeTableEntry;
  47. ***************
  48. *** 35,40 ****
  49. --- 38,47 ----
  50.      *rt_end,    /* this and all succeeding entries are empty */
  51.      *rt_buf_end;/* points beyond end of allocated storage for table */
  52.   
  53. + #ifdef KEYBD
  54. + char *keyboardtype = NULL;
  55. + #endif KEYBD
  56.   #define RT_INITIAL_SIZE 100  /* initial size of runtime table */
  57.   #define RT_INCREMENT 40  /* size to grow by if expanded */
  58.   
  59. ***************
  60. *** 54,61 ****
  61.       if (filesize < 256*sizeof(KeyMapElt)) {
  62.       fprintf (stderr, "Keymap file %s is too small\n", filename);
  63.       close (file);
  64. !     free (filename);
  65. !     return;
  66.       }
  67.       read (file, &magic, 1);
  68.       if (magic != X_KEYMAP_MAGIC) {
  69. --- 61,67 ----
  70.       if (filesize < 256*sizeof(KeyMapElt)) {
  71.       fprintf (stderr, "Keymap file %s is too small\n", filename);
  72.       close (file);
  73. !     return(0);
  74.       }
  75.       read (file, &magic, 1);
  76.       if (magic != X_KEYMAP_MAGIC) {
  77. ***************
  78. *** 84,98 ****
  79.   }
  80.   
  81.   static Initialize() {
  82. !     int file;
  83.       int filesize;
  84.       unsigned char magic;
  85.       struct stat filestat;
  86.       char *getenv();
  87. !     char *filename;
  88.       char *home = getenv ("HOME");
  89.       inited = TRUE;
  90. !     if (home) {
  91.       int homelen = strlen (home);
  92.       char *keymapstr = "/.Xkeymap";
  93.       int keymapstrlen = strlen (keymapstr);
  94. --- 90,125 ----
  95.   }
  96.   
  97.   static Initialize() {
  98. !     int file = -1;
  99.       int filesize;
  100.       unsigned char magic;
  101.       struct stat filestat;
  102.       char *getenv();
  103. !     char *filename = NULL;
  104. ! #ifdef KEYBD
  105. !     char *home;
  106. !     char *kdefault = "default";
  107. !     char *keybddir = KEYBDDIR;
  108. ! #else KEYBD
  109.       char *home = getenv ("HOME");
  110. + #endif KEYBD
  111.       inited = TRUE;
  112. ! #ifdef KEYBD
  113. !     if(keyboardtype && *keyboardtype) {    /* Use keyboard type keymap */
  114. !     filename = malloc(strlen(keybddir) + strlen(keyboardtype) + 1);
  115. !     strcpy(filename, keybddir);
  116. !     strcat(filename, keyboardtype);
  117. !     if((file = open (filename, O_RDONLY, 0)) < 0) {
  118. !         free (filename);
  119. !         filename = NULL;
  120. !     }
  121. !     }
  122. !     if(file < 0 && (home = getenv ("HOME")))
  123. ! #else KEYBD
  124. !     if (home)
  125. ! #endif KEYBD
  126. !      {
  127.       int homelen = strlen (home);
  128.       char *keymapstr = "/.Xkeymap";
  129.       int keymapstrlen = strlen (keymapstr);
  130. ***************
  131. *** 100,112 ****
  132.       strncpy (filename, home, homelen+1);
  133.       strncat (filename, keymapstr, keymapstrlen);
  134.       file = open (filename, O_RDONLY, 0);
  135. -     if (file < 0) {
  136. -         free (filename);
  137. -         return; /* no keymap file found */
  138. -         }
  139.       }
  140. !     else
  141. !         return;  /* no home directory to find keymap file in! */
  142.       fstat (file, &filestat);
  143.       filesize = filestat.st_size - 1; /* first byte is magic number */
  144.       if (filesize < 256*sizeof(KeyMapElt)) {
  145. --- 127,148 ----
  146.       strncpy (filename, home, homelen+1);
  147.       strncat (filename, keymapstr, keymapstrlen);
  148.       file = open (filename, O_RDONLY, 0);
  149.       }
  150. ! #ifdef KEYBD
  151. !     if (file < 0) {    /* Try system default keymap */
  152. !     if(filename)
  153. !         free(filename);
  154. !     filename = malloc(strlen(keybddir) + strlen(kdefault) + 1);
  155. !     strcpy(filename, keybddir);
  156. !     strcat(filename, kdefault);
  157. !     file = open (filename, O_RDONLY, 0);
  158. !     }
  159. ! #endif KEYBD
  160. !     if (file < 0) {
  161. !     if(filename)
  162. !         free(filename);
  163. !     return; /* no keymap file found */
  164. !     }
  165.       fstat (file, &filestat);
  166.       filesize = filestat.st_size - 1; /* first byte is magic number */
  167.       if (filesize < 256*sizeof(KeyMapElt)) {
  168.