aboutsummaryrefslogtreecommitdiffstats
path: root/util/ttyio.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/ttyio.c')
-rw-r--r--util/ttyio.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/util/ttyio.c b/util/ttyio.c
index 6c1a5059a..8d0824aad 100644
--- a/util/ttyio.c
+++ b/util/ttyio.c
@@ -107,23 +107,6 @@ init_ttyfp(void)
SetConsoleMode(con.in, DEF_INPMODE );
SetConsoleMode(con.out, DEF_OUTMODE );
-#warning DEBUG CODE
- {
- unsigned int cp1, cp2;
-
- cp1 = GetConsoleCP();
- cp2 = GetConsoleOutputCP();
-
- log_info("InputCP=%u OutputCP=%u\n", cp1, cp2 );
-
- if( !SetConsoleOutputCP( 1252 ) )
- log_info("SetConsoleOutputCP failed: %d\n", (int)GetLastError() );
-
- cp1 = GetConsoleCP();
- cp2 = GetConsoleOutputCP();
- log_info("InputCP=%u OutputCP=%u after switch1\n", cp1, cp2 );
-
- }
#elif defined(__EMX__)
ttyfp = stdout; /* Fixme: replace by the real functions: see wklib */
#else
@@ -253,7 +236,7 @@ tty_print_string( byte *p, size_t n )
}
void
-tty_print_utf8_string( byte *p, size_t n )
+tty_print_utf8_string2( byte *p, size_t n, size_t max_n )
{
size_t i;
char *buf;
@@ -268,15 +251,26 @@ tty_print_utf8_string( byte *p, size_t n )
}
if( i < n ) {
buf = utf8_to_native( p, n );
+ if( strlen( buf ) > max_n ) {
+ buf[max_n] = 0;
+ }
+ /*(utf8 conversion already does the control character quoting)*/
tty_printf("%s", buf );
m_free( buf );
}
- else
+ else {
+ if( n > max_n ) {
+ n = max_n;
+ }
tty_print_string( p, n );
+ }
}
-
-
+void
+tty_print_utf8_string( byte *p, size_t n )
+{
+ tty_print_utf8_string2( p, n, n );
+}
static char *
@@ -304,7 +298,7 @@ do_get( const char *prompt, int hidden )
buf = m_alloc(n=50);
i = 0;
- #if __MINGW32__ /* windoze version */
+ #ifdef __MINGW32__ /* windoze version */
if( hidden )
SetConsoleMode(con.in, HID_INPMODE );
@@ -419,7 +413,7 @@ tty_kill_prompt()
last_prompt_len = 0;
if( !last_prompt_len )
return;
- #if __MINGW32__
+ #ifdef __MINGW32__
tty_printf("\r%*s\r", last_prompt_len, "");
#else
{