Patch #914291: Restore locale while readline is running.

This commit is contained in:
Martin v. Löwis 2004-08-18 13:34:00 +00:00
parent ae075b6cb7
commit 78a8acc55b
1 changed files with 8 additions and 0 deletions

View File

@ -821,6 +821,10 @@ readline_until_enter_or_signal(char *prompt, int *signal)
static char *
call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
{
#ifdef SAVE_LOCALE
char *saved_locale = strdup(setlocale(LC_CTYPE, NULL));
setlocale(LC_CTYPE, "");
#endif
size_t n;
char *p, *q;
int signal;
@ -879,6 +883,10 @@ call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
p[n+1] = '\0';
}
free(q);
#ifdef SAVE_LOCALE
setlocale(LC_CTYPE, saved_locale); /* Restore locale */
free(saved_locale);
#endif
return p;
}