From: Alexander LAW <exclusion@gmail.com>
To: Alvaro Herrera <alvherre@commandprompt.com>
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Subject: Re: BUG #6510: A simple prompt is displayed using wrong charset
Date: Tue, 20 Mar 2012 23:50:14 +0400
Message-ID: <4F68DF76.1030609@gmail.com> (raw)
In-Reply-To: <1332187409-sup-4631@alvh.no-ip.org>
References: <E1S3twb-0004OY-4g@wrigleys.postgresql.org>
<1331925178-sup-9261@alvh.no-ip.org>
<4F65A533.7090208@gmail.com>
<1332187409-sup-4631@alvh.no-ip.org>
Thanks, I've understood your point.
Please look at the patch. It implements the first way and it makes psql
work too.
Regards,
Alexander
20.03.2012 00:05, Alvaro Herrera пишет:
> Excerpts from Alexander LAW's message of dom mar 18 06:04:51 -0300 2012:
>> I see two ways to resolve the issue.
>> First is to use CharToOemBuff when writing a string to the "con" and
>> OemToCharBuff when reading an input from it.
>> The other is to always use stderr/stdin for Win32 as it was done for
>> msys before. I think it's more straightforward.
> Using console directly instead of stdin/out/err is more appropriate when
> asking for passwords and reading them back, because you can redirect the
> rest of the output to/from files or pipes, without the prompt
> interfering with that. This also explains why stderr is used instead of
> stdout.
>
Attachments:sprompt.diff (text/x-patch, 1.1K) download--- a/src/port/sprompt.c 2012-02-24 02:53:36.000000000 +0400+++ b/src/port/sprompt.c 2012-03-20 23:34:22.181979200 +0400@@ -41,6 +41,7 @@
char *destination;
FILE *termin,
*termout;
+ char *_prompt;
#ifdef HAVE_TERMIOS_H
struct termios t_orig,
@@ -49,6 +50,7 @@
#ifdef WIN32
HANDLE t = NULL;
LPDWORD t_orig = NULL;
+ char *oem_prompt = NULL;
#endif
#endif
@@ -104,7 +106,20 @@
if (prompt)
{
- fputs(_(prompt), termout);+ _prompt = _(prompt);+#ifdef WIN32+ if ((termout != stderr) && (termout != stdout))+ {+ oem_prompt = (char*) malloc(strlen(_prompt) + 1);+ CharToOemBuff(_prompt, oem_prompt, strlen(_prompt) + 1);+ _prompt = oem_prompt;+ }+#endif+ fputs(_prompt, termout);+#ifdef WIN32+ if (oem_prompt)+ free(oem_prompt);+#endif
fflush(termout);
}
@@ -130,6 +145,13 @@
/* remove trailing newline */
destination[length - 1] = '\0';
+#ifdef WIN32+ if (termin != stdin)+ {+ OemToCharBuff(destination, destination, strlen(destination) + 1);+ }+#endif+
#ifdef HAVE_TERMIOS_H
if (!echo)
{
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: exclusion@gmail.com, alvherre@commandprompt.com
Subject: Re: BUG #6510: A simple prompt is displayed using wrong charset
In-Reply-To: <4F68DF76.1030609@gmail.com>
References: <E1S3twb-0004OY-4g@wrigleys.postgresql.org> <1331925178-sup-9261@alvh.no-ip.org> <4F65A533.7090208@gmail.com> <1332187409-sup-4631@alvh.no-ip.org> <4F68DF76.1030609@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox