ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/misc.C
(Generate patch)

Comparing rxvt-unicode/src/misc.C (file contents):
Revision 1.12 by pcg, Wed Mar 17 05:15:02 2004 UTC vs.
Revision 1.60 by sf-exg, Thu May 13 19:40:19 2021 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*----------------------------------------------------------------------*
2 * File: misc.c 2 * File: misc.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 1996 mj olesen <olesen@me.QueensU.CA> Queen's Univ at Kingston 6 * Copyright (c) 1996 mj olesen <olesen@me.QueensU.CA> Queen's Univ at Kingston
7 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> 7 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de>
8 * Copyright (c) 1998-2000 Geoff Wing <gcw@pobox.com> 8 * Copyright (c) 1998-2000 Geoff Wing <gcw@pobox.com>
9 * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> 9 * Copyright (c) 2003-2006 Marc Lehmann <schmorp@schmorp.de>
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or 13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version. 14 * (at your option) any later version.
15 * 15 *
16 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *----------------------------------------------------------------------*/ 24 *----------------------------------------------------------------------*/
25 25
26#include "../config.h" /* NECESSARY */ 26#include "../config.h" /* NECESSARY */
27#include "rxvt.h" /* NECESSARY */ 27#include "rxvt.h" /* NECESSARY */
28#include "misc.intpro" /* PROTOS for internal routines */
29 28
30/* EXTPROTO */ 29#include <new>
30
31// alas new/delete cannot be specified as inline in C++11 (see 17.6.4.6)
32void *
33operator new (size_t s)
34{
35 return rxvt_malloc (s);
36}
37
38void
39operator delete (void *p) noexcept
40{
41 free (p);
42}
43
31char * 44char *
32rxvt_wcstombs (const wchar_t *str, int len) 45rxvt_wcstombs (const wchar_t *str, int len)
33{ 46{
47 if (len < 0) len = wcslen (str);
48
34 mbstate mbs; 49 mbstate mbs;
35 char *r = (char *)rxvt_malloc (len * MB_CUR_MAX + 1); 50 char *r = (char *)rxvt_malloc (len * MB_CUR_MAX + 1);
36 51
37 char *dst = r; 52 char *dst = r;
38 while (len--) 53 while (len--)
39 { 54 {
40 int l = wcrtomb (dst, *str++, mbs); 55 ssize_t l = wcrtomb (dst, *str++, mbs);
56
41 if (l < 0) 57 if (l < 0)
58 {
42 *dst++ = '?'; 59 *dst++ = '?';
60 wcrtomb (0, 0, mbs); // reset undefined state
61 }
43 else 62 else
44 dst += l; 63 dst += l;
45 } 64 }
46 65
47 *dst++ = 0; 66 *dst++ = 0;
48 67
68 return (char *)rxvt_realloc (r, dst - r);
69}
70
71wchar_t *
72rxvt_mbstowcs (const char *str, int len)
73{
74 if (len < 0) len = strlen (str);
75
76 wchar_t *r = (wchar_t *)rxvt_malloc ((len + 1) * sizeof (wchar_t));
77
78 if ((ssize_t)mbstowcs (r, str, len + 1) < 0)
79 *r = 0;
80
49 return r; 81 return r;
50} 82}
51 83
52/* EXTPROTO */
53char * 84char *
54rxvt_strdup (const char *str) 85rxvt_wcstoutf8 (const wchar_t *str, int len)
55{ 86{
56 return str ? strdup (str) : 0; 87 if (len < 0) len = wcslen (str);
57}
58 88
59/* EXTPROTO */ 89 char *r = (char *)rxvt_malloc (len * 4 + 1);
90 char *p = r;
91
92 while (len--)
93 {
94 unicode_t w = *str++ & UNICODE_MASK;
95
96 if (w < 0x000080)
97 *p++ = w;
98 else if (w < 0x000800)
99 *p++ = 0xc0 | ( w >> 6),
100 *p++ = 0x80 | ( w & 0x3f);
101 else if (w < 0x010000)
102 *p++ = 0xe0 | ( w >> 12),
103 *p++ = 0x80 | ((w >> 6) & 0x3f),
104 *p++ = 0x80 | ( w & 0x3f);
105 else if (w < 0x110000)
106 *p++ = 0xf0 | ( w >> 18),
107 *p++ = 0x80 | ((w >> 12) & 0x3f),
108 *p++ = 0x80 | ((w >> 6) & 0x3f),
109 *p++ = 0x80 | ( w & 0x3f);
110 else
111 *p++ = '?';
112 }
113
114 *p++ = 0;
115
116 return (char *)rxvt_realloc (r, p - r);
117}
118
60char * 119wchar_t *
120rxvt_utf8towcs (const char *str, int len)
121{
122 if (len < 0) len = strlen (str);
123
124 wchar_t *r = (wchar_t *)rxvt_malloc ((len + 1) * sizeof (wchar_t)),
125 *p = r;
126
127 unsigned char *s = (unsigned char *)str,
128 *e = s + len;
129
130 for (;;)
131 {
132 len = e - s;
133
134 if (len == 0)
135 break;
136 else if (s[0] < 0x80)
137 *p++ = *s++;
138 else if (len >= 2
139 && s[0] >= 0xc2 && s[0] <= 0xdf
140 && (s[1] & 0xc0) == 0x80)
141 {
142 *p++ = ((s[0] & 0x1f) << 6)
143 | (s[1] & 0x3f);
144 s += 2;
145 }
146 else if (len >= 3
147 && ( (s[0] == 0xe0 && s[1] >= 0xa0 && s[1] <= 0xbf)
148 || (s[0] >= 0xe1 && s[0] <= 0xec && s[1] >= 0x80 && s[1] <= 0xbf)
149 || (s[0] == 0xed && s[1] >= 0x80 && s[1] <= 0x9f)
150 || (s[0] >= 0xee && s[0] <= 0xef && s[1] >= 0x80 && s[1] <= 0xbf)
151 )
152 && (s[2] & 0xc0) == 0x80)
153 {
154 *p++ = ((s[0] & 0x0f) << 12)
155 | ((s[1] & 0x3f) << 6)
156 | (s[2] & 0x3f);
157 s += 3;
158 }
159 else if (len >= 4
160 && ( (s[0] == 0xf0 && s[1] >= 0x90 && s[1] <= 0xbf)
161 || (s[0] >= 0xf1 && s[0] <= 0xf3 && s[1] >= 0x80 && s[1] <= 0xbf)
162 || (s[0] == 0xf4 && s[1] >= 0x80 && s[1] <= 0x8f)
163 )
164 && (s[2] & 0xc0) == 0x80
165 && (s[3] & 0xc0) == 0x80)
166 {
167 *p++ = ((s[0] & 0x07) << 18)
168 | ((s[1] & 0x3f) << 12)
169 | ((s[2] & 0x3f) << 6)
170 | (s[3] & 0x3f);
171 s += 4;
172 }
173 else
174 {
175 *p++ = 0xfffd;
176 s++;
177 }
178 }
179
180 *p = 0;
181
182 return r;
183}
184
185const char *
61rxvt_r_basename (const char *str) 186rxvt_basename (const char *str) noexcept
62{ 187{
63 char *base = STRRCHR (str, '/'); 188 const char *base = strrchr (str, '/');
64 189
65 return (char *) (base ? base + 1 : str); 190 return base ? base + 1 : str;
66} 191}
67 192
68/* 193/*
69 * Print an error message 194 * Print an error message
70 */ 195 */
71/* EXTPROTO */
72void 196void
73rxvt_vlog (const char *fmt, va_list arg_ptr) 197rxvt_vlog (const char *fmt, va_list arg_ptr) noexcept
74{ 198{
75 char msg[1024]; 199 char msg[1024];
76 200
77 vsnprintf (msg, sizeof msg, fmt, arg_ptr); 201 vsnprintf (msg, sizeof msg, fmt, arg_ptr);
78 202
80 (*GET_R->log_hook) (msg); 204 (*GET_R->log_hook) (msg);
81 else 205 else
82 write (STDOUT_FILENO, msg, strlen (msg)); 206 write (STDOUT_FILENO, msg, strlen (msg));
83} 207}
84 208
85/* EXTPROTO */
86void 209void
87rxvt_log (const char *fmt,...) 210rxvt_log (const char *fmt,...) noexcept
88{ 211{
89 va_list arg_ptr; 212 va_list arg_ptr;
90 213
91 va_start (arg_ptr, fmt); 214 va_start (arg_ptr, fmt);
92 rxvt_vlog (fmt, arg_ptr); 215 rxvt_vlog (fmt, arg_ptr);
94} 217}
95 218
96/* 219/*
97 * Print an error message 220 * Print an error message
98 */ 221 */
99/* EXTPROTO */
100void 222void
101rxvt_warn (const char *fmt,...) 223rxvt_warn (const char *fmt,...) noexcept
102{ 224{
103 va_list arg_ptr; 225 va_list arg_ptr;
104 226
105 rxvt_log ("%s: ", RESNAME); 227 rxvt_log ("%s: ", RESNAME);
106 228
107 va_start (arg_ptr, fmt); 229 va_start (arg_ptr, fmt);
108 rxvt_vlog (fmt, arg_ptr); 230 rxvt_vlog (fmt, arg_ptr);
109 va_end (arg_ptr); 231 va_end (arg_ptr);
110} 232}
111 233
112/* EXTPROTO */
113void 234void
114rxvt_fatal (const char *fmt,...) 235rxvt_fatal (const char *fmt,...)
115{ 236{
116 va_list arg_ptr; 237 va_list arg_ptr;
117 238
122 va_end (arg_ptr); 243 va_end (arg_ptr);
123 244
124 rxvt_exit_failure (); 245 rxvt_exit_failure ();
125} 246}
126 247
127class rxvt_failure_exception rxvt_failure_exception;
128
129/* EXTPROTO */
130void 248void
131rxvt_exit_failure () 249rxvt_exit_failure ()
132{ 250{
251 static class rxvt_failure_exception rxvt_failure_exception;
133 throw (rxvt_failure_exception); 252 throw (rxvt_failure_exception);
134} 253}
135 254
136/* 255/*
137 * check that the first characters of S1 match S2 256 * remove leading/trailing space in place.
138 *
139 * No Match
140 * return: 0
141 * Match
142 * return: STRLEN (S2)
143 */ 257 */
144/* EXTPROTO */ 258char *
145int
146rxvt_Str_match (const char *s1, const char *s2)
147{
148 int n = STRLEN (s2);
149
150 return ((STRNCMP (s1, s2, n) == 0) ? n : 0);
151}
152
153/* EXTPROTO */
154const char *
155rxvt_Str_skip_space (const char *str)
156{
157 if (str)
158 while (*str && isspace (*str))
159 str++;
160
161 return str;
162}
163
164/*
165 * remove leading/trailing space and strip-off leading/trailing quotes.
166 * in place.
167 */
168/* EXTPROTO */
169char *
170rxvt_Str_trim (char *str) 259rxvt_strtrim (char *str) noexcept
171{ 260{
172 char *r, *s; 261 char *r, *s;
173 int n;
174 262
175 if (!str || !*str) /* shortcut */ 263 if (!str || !*str) /* shortcut */
176 return str; 264 return str;
177 265
178 /* skip leading spaces */ 266 /* skip leading spaces */
179 for (s = str; *s && isspace (*s); s++) ; 267 for (s = str; *s && isspace (*s); s++) ;
268
180 /* goto end of string */ 269 /* goto end of string */
181 for (n = 0, r = s; *r++; n++) ; 270 r = s + strlen (s) - 1;
182 r -= 2; 271
183 /* dump return */ 272 /* dump return and other trailing whitespace */
184 if (n > 0 && *r == '\n') 273 while (r > s && isspace (*r))
185 n--, r--; 274 r--;
186 /* backtrack along trailing spaces */
187 for (; n > 0 && isspace (*r); r--, n--) ;
188 /* skip matching leading/trailing quotes */
189 if (*s == '"' && *r == '"' && n > 1)
190 {
191 s++;
192 n -= 2;
193 }
194 275
195 /* copy back over: forwards copy */ 276 memmove (str, s, r + 1 - s);
196 for (r = str; n; n--) 277 str[r + 1 - s] = 0;
197 *r++ = *s++;
198 *r = '\0';
199 278
200 return str; 279 return str;
201} 280}
202 281
203/* 282/*
204 * in-place interpretation of string: 283 * Split a string into an array based on the given delimiter, stripping leading and
205 * 284 * trailing spaces from each entry. Empty strings are properly returned
206 * backslash-escaped: "\a\b\E\e\n\r\t", "\octal"
207 * Ctrl chars: ^@ .. ^_, ^?
208 *
209 * Emacs-style: "M-" prefix
210 *
211 * Also,
212 * "M-x" prefixed strings, append "\r" if needed
213 * "\E]" prefixed strings (XTerm escape sequence) append ST if needed
214 *
215 * returns the converted string length
216 */ 285 */
217/* EXTPROTO */ 286char **
218int 287rxvt_strsplit (char delim, const char *str) noexcept
219rxvt_Str_escaped (char *str)
220{ 288{
221 char ch, *s, *d; 289 int l, n;
222 int i, num, append = 0; 290 char *s, *t;
291 char **ret;
223 292
224 if (!str || !*str) 293 s = strdup (str ? str : "");
225 return 0;
226
227 d = s = str;
228
229 if (*s == 'M' && s[1] == '-')
230 {
231 /* Emacs convenience, replace leading `M-..' with `\E..' */
232 *d++ = C0_ESC;
233 s += 2;
234 if (toupper (*s) == 'X')
235 /* append carriage-return for `M-xcommand' */
236 for (*d++ = 'x', append = '\r', s++; isspace (*s); s++) ;
237 }
238 for (; (ch = *s++);)
239 {
240 if (ch == '\\')
241 {
242 ch = *s++;
243 if (ch >= '0' && ch <= '7')
244 { /* octal */
245 num = ch - '0';
246 for (i = 0; i < 2; i++, s++)
247 {
248 ch = *s;
249 if (ch < '0' || ch > '7')
250 break;
251 num = num * 8 + ch - '0';
252 }
253 ch = (char)num;
254 }
255 else if (ch == 'a')
256 ch = C0_BEL; /* bell */
257 else if (ch == 'b')
258 ch = C0_BS; /* backspace */
259 else if (ch == 'E' || ch == 'e')
260 ch = C0_ESC; /* escape */
261 else if (ch == 'n')
262 ch = '\n'; /* newline */
263 else if (ch == 'r')
264 ch = '\r'; /* carriage-return */
265 else if (ch == 't')
266 ch = C0_HT; /* tab */
267 }
268 else if (ch == '^')
269 {
270 ch = *s++;
271 ch = toupper (ch);
272 ch = (ch == '?' ? 127 : (ch - '@'));
273 }
274 *d++ = ch;
275 }
276
277 /* ESC] is an XTerm escape sequence, must be terminated */
278 if (*str == '\0' && str[1] == C0_ESC && str[2] == ']')
279 append = CHAR_ST;
280
281 /* add trailing character as required */
282 if (append && d[-1] != append)
283 *d++ = append;
284 *d = '\0';
285
286 return (d - str);
287}
288
289/*
290 * Split a comma-separated string into an array, stripping leading and
291 * trailing spaces (and paired quotes) from each entry. Empty strings
292 * are properly returned
293 * Caller should free each entry and array when done
294 */
295/* EXTPROTO */
296char **
297rxvt_splitcommastring (const char *cs)
298{
299 int l, n, p;
300 const char *s, *t;
301 char **ret;
302
303 if ((s = cs) == NULL)
304 s = "";
305 294
306 for (n = 1, t = s; *t; t++) 295 for (n = 1, t = s; *t; t++)
307 if (*t == ',') 296 if (*t == delim)
308 n++; 297 n++;
298
309 ret = (char **)malloc ((n + 1) * sizeof (char *)); 299 ret = (char **)malloc ((n + 1) * sizeof (char *));
310 ret[n] = NULL; 300 ret[n] = NULL;
311 301
312 for (l = 0, t = s; l < n; l++) 302 for (l = 0, t = s; l < n; l++)
313 { 303 {
314 for ( ; *t && *t != ','; t++) ; 304 for (; *t && *t != delim; t++)
315 p = t - s; 305 ;
316 ret[l] = (char *)malloc (p + 1); 306 *t = '\0';
317 strncpy (ret[l], s, p);
318 ret[l][p] = '\0'; 307 ret[l] = s;
319 rxvt_Str_trim (ret[l]); 308 rxvt_strtrim (ret[l]);
320 s = ++t; 309 s = ++t;
321 } 310 }
311
322 return ret; 312 return ret;
323} 313}
324 314
325/*----------------------------------------------------------------------* 315void *
326 * file searching 316rxvt_malloc (size_t size)
327 */
328
329/* #define DEBUG_SEARCH_PATH */
330
331#if defined (XPM_BACKGROUND) || (MENUBAR_MAX)
332/*
333 * search for FILE in the current working directory, and within the
334 * colon-delimited PATHLIST, adding the file extension EXT if required.
335 *
336 * FILE is either semi-colon or zero terminated
337 */
338/* INTPROTO */
339char *
340rxvt_File_search_path (const char *pathlist, const char *file, const char *ext)
341{ 317{
342 int maxpath, len; 318 void *p = malloc (size);
343 const char *p, *path;
344 char name[256];
345 319
346 if (!access (file, R_OK)) /* found (plain name) in current directory */
347 return STRDUP (file);
348
349 /* semi-colon delimited */
350 if ((p = STRCHR (file, ';')))
351 len = (p - file);
352 else
353 len = STRLEN (file);
354
355#ifdef DEBUG_SEARCH_PATH
356 getcwd (name, sizeof (name));
357 fprintf (stderr, "pwd: \"%s\"\n", name);
358 fprintf (stderr, "find: \"%.*s\"\n", len, file);
359#endif
360
361 /* leave room for an extra '/' and trailing '\0' */
362 maxpath = sizeof (name) - (len + (ext ? STRLEN (ext) : 0) + 2);
363 if (maxpath <= 0)
364 return NULL;
365
366 /* check if we can find it now */
367 STRNCPY (name, file, len);
368 name[len] = '\0';
369
370 if (!access (name, R_OK))
371 return STRDUP (name);
372 if (ext)
373 {
374 STRCAT (name, ext);
375 if (!access (name, R_OK))
376 return STRDUP (name);
377 }
378 for (path = pathlist; path != NULL && *path != '\0'; path = p)
379 {
380 int n;
381
382 /* colon delimited */
383 if ((p = STRCHR (path, ':')) == NULL)
384 p = STRCHR (path, '\0');
385
386 n = (p - path);
387 if (*p != '\0')
388 p++;
389
390 if (n > 0 && n <= maxpath)
391 {
392 STRNCPY (name, path, n);
393 if (name[n - 1] != '/')
394 name[n++] = '/';
395 name[n] = '\0';
396 STRNCAT (name, file, len);
397
398 if (!access (name, R_OK))
399 return STRDUP (name);
400 if (ext)
401 {
402 STRCAT (name, ext);
403 if (!access (name, R_OK))
404 return STRDUP (name);
405 }
406 }
407 }
408 return NULL;
409}
410
411/* EXTPROTO */
412char *
413rxvt_File_find (const char *file, const char *ext, const char *path)
414{
415 char *f;
416
417 if (file == NULL || *file == '\0')
418 return NULL;
419
420 /* search environment variables here too */
421 if ((f = rxvt_File_search_path (path, file, ext)) == NULL)
422#ifdef PATH_ENV
423 if ((f = rxvt_File_search_path (getenv (PATH_ENV), file, ext)) == NULL)
424#endif
425 f = rxvt_File_search_path (getenv ("PATH"), file, ext);
426
427#ifdef DEBUG_SEARCH_PATH
428 if (f) 320 if (!p)
429 fprintf (stderr, "found: \"%s\"\n", f); 321 rxvt_fatal ("memory allocation failure. aborting.\n");
430#endif
431 322
432 return f; 323 return p;
433} 324}
434#endif /* defined (XPM_BACKGROUND) || (MENUBAR_MAX) */
435 325
436/*----------------------------------------------------------------------*
437 * miscellaneous drawing routines
438 */
439
440/*
441 * Draw top/left and bottom/right border shadows around windows
442 */
443#if defined(RXVT_SCROLLBAR) || defined(MENUBAR)
444/* EXTPROTO */
445void 326void *
446rxvt_Draw_Shadow (Display *display, Window win, GC topShadow, GC botShadow, int x, int y, int w, int h) 327rxvt_calloc (size_t number, size_t size)
447{ 328{
448 int shadow; 329 void *p = calloc (number, size);
449 330
450 shadow = (w == 0 || h == 0) ? 1 : SHADOW; 331 if (!p)
451 w += x - 1; 332 rxvt_fatal ("memory allocation failure. aborting.\n");
452 h += y - 1;
453 for (; shadow-- > 0; x++, y++, w--, h--)
454 {
455 XDrawLine (display, win, topShadow, x, y, w, y);
456 XDrawLine (display, win, topShadow, x, y, x, h);
457 XDrawLine (display, win, botShadow, w, h, w, y + 1);
458 XDrawLine (display, win, botShadow, w, h, x + 1, h);
459 }
460}
461#endif
462 333
463/* button shapes */ 334 return p;
464#ifdef MENUBAR 335}
465/* EXTPROTO */ 336
466void 337void *
467rxvt_Draw_Triangle (Display *display, Window win, GC topShadow, GC botShadow, int x, int y, int w, int type) 338rxvt_realloc (void *ptr, size_t size)
468{ 339{
469 switch (type) 340 void *p = realloc (ptr, size);
470 {
471 case 'r': /* right triangle */
472 XDrawLine (display, win, topShadow, x, y, x, y + w);
473 XDrawLine (display, win, topShadow, x, y, x + w, y + w / 2);
474 XDrawLine (display, win, botShadow, x, y + w, x + w, y + w / 2);
475 break;
476 341
477 case 'l': /* left triangle */ 342 if (!p)
478 XDrawLine (display, win, botShadow, x + w, y + w, x + w, y); 343 rxvt_fatal ("memory allocation failure. aborting.\n");
479 XDrawLine (display, win, botShadow, x + w, y + w, x, y + w / 2);
480 XDrawLine (display, win, topShadow, x, y + w / 2, x + w, y);
481 break;
482 344
483 case 'd': /* down triangle */ 345 return p;
484 XDrawLine (display, win, topShadow, x, y, x + w / 2, y + w);
485 XDrawLine (display, win, topShadow, x, y, x + w, y);
486 XDrawLine (display, win, botShadow, x + w, y, x + w / 2, y + w);
487 break;
488
489 case 'u': /* up triangle */
490 XDrawLine (display, win, botShadow, x + w, y + w, x + w / 2, y);
491 XDrawLine (display, win, botShadow, x + w, y + w, x, y + w);
492 XDrawLine (display, win, topShadow, x, y + w, x + w / 2, y);
493 break;
494#if 0
495 case 's': /* square */
496 XDrawLine (display, win, topShadow, x + w, y, x, y);
497 XDrawLine (display, win, topShadow, x, y, x, y + w);
498 XDrawLine (display, win, botShadow, x, y + w, x + w, y + w);
499 XDrawLine (display, win, botShadow, x + w, y + w, x + w, y);
500 break;
501#endif
502
503 }
504} 346}
505#endif 347
506/*----------------------- end-of-file (C source) -----------------------*/ 348KeySym
349rxvt_XKeycodeToKeysym (Display *dpy, KeyCode code, int index)
350{
351 int size;
352 KeySym *mapping = XGetKeyboardMapping (dpy, code, 1, &size);
353 KeySym keysym = IN_RANGE_EXC (index, 0, size) ? mapping[index] : NoSymbol;
354 XFree (mapping);
355 return keysym;
356}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines