CVS: rdesktop proto.h,1.77,1.78 rdesktop.c,1.130,1.131 xkeymap.c,1.78,1.79
Peter Åstrand <[email protected]>
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17770
Modified Files:
proto.h rdesktop.c xkeymap.c
Log Message:
Autoselecting keyboard map based on current locale. Re-implementation of patch #1068995.
Index: proto.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/proto.h,v
retrieving revision 1.77
retrieving revision 1.78
diff -C2 -d -r1.77 -r1.78
*** proto.h 3 Aug 2005 08:25:32 -0000 1.77
--- proto.h 3 Aug 2005 09:56:00 -0000 1.78
***************
*** 167,170 ****
--- 167,171 ----
void xclip_init(void);
/* xkeymap.c */
+ void xkeymap_from_locale(const char *locale);
FILE *xkeymap_open(const char *filename);
void xkeymap_init(void);
Index: rdesktop.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdesktop.c,v
retrieving revision 1.130
retrieving revision 1.131
diff -C2 -d -r1.130 -r1.131
*** rdesktop.c 3 Aug 2005 08:36:08 -0000 1.130
--- rdesktop.c 3 Aug 2005 09:56:17 -0000 1.131
***************
*** 31,38 ****
#include "rdesktop.h"
- #ifdef HAVE_ICONV
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
--- 31,38 ----
#include "rdesktop.h"
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
+ #ifdef HAVE_ICONV
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
***************
*** 51,55 ****
char g_username[64];
char g_hostname[16];
! char keymapname[PATH_MAX];
int g_keylayout = 0x409; /* Defaults to US keyboard layout */
--- 51,55 ----
char g_username[64];
char g_hostname[16];
! char keymapname[PATH_MAX] = "en-us";
int g_keylayout = 0x409; /* Defaults to US keyboard layout */
***************
*** 371,381 ****
char *p;
int c;
!
int username_option = 0;
flags = RDP_LOGON_NORMAL;
prompt_password = False;
domain[0] = password[0] = shell[0] = directory[0] = 0;
- strcpy(keymapname, "en-us");
g_embed_wnd = 0;
--- 371,387 ----
char *p;
int c;
! char *locale;
int username_option = 0;
+ /* Set locale according to environment */
+ locale = setlocale(LC_ALL, "");
+ if (locale)
+ {
+ xkeymap_from_locale(locale);
+ }
+
flags = RDP_LOGON_NORMAL;
prompt_password = False;
domain[0] = password[0] = shell[0] = directory[0] = 0;
g_embed_wnd = 0;
Index: xkeymap.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/xkeymap.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -C2 -d -r1.78 -r1.79
*** xkeymap.c 3 Aug 2005 09:32:22 -0000 1.78
--- xkeymap.c 3 Aug 2005 09:56:17 -0000 1.79
***************
*** 157,160 ****
--- 157,217 ----
}
+ void
+ xkeymap_from_locale(const char *locale)
+ {
+ char *str, *ptr;
+ FILE *fp;
+
+ /* Create a working copy */
+ str = strdup(locale);
+ if (str == NULL)
+ {
+ perror("strdup");
+ exit(1);
+ }
+
+ /* Truncate at dot and at */
+ ptr = strrchr(str, '.');
+ if (ptr)
+ *ptr = '\0';
+ ptr = strrchr(str, '@');
+ if (ptr)
+ *ptr = '\0';
+
+ /* Replace _ with - */
+ ptr = strrchr(str, '_');
+ if (ptr)
+ *ptr = '-';
+
+ /* Convert to lowercase */
+ ptr = str;
+ while (*ptr)
+ {
+ *ptr = tolower((int) *ptr);
+ ptr++;
+ }
+
+ /* Try to open this keymap (da-dk) */
+ fp = xkeymap_open(str);
+ if (fp == NULL)
+ {
+ /* Truncate at dash */
+ ptr = strrchr(str, '-');
+ if (ptr)
+ *ptr = '\0';
+
+ /* Try the short name (da) */
+ fp = xkeymap_open(str);
+ }
+
+ if (fp)
+ {
+ fclose(fp);
+ STRNCPY(keymapname, str, sizeof(keymapname));
+ fprintf(stderr, "Autoselected keyboard map %s.\n", keymapname);
+ }
+ }
+
+
/* Joins two path components. The result should be freed with
xfree(). */
***************
*** 360,364 ****
{
unsigned int max_keycode;
- char *mapname_ptr;
if (strcmp(keymapname, "none"))
--- 417,420 ----
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click