diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2008-03-10 17:23:50 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2008-03-10 17:23:50 +0000 |
commit | 949c0ec28c86623b83ae56651c00d1bd3c3a5d0c (patch) | |
tree | dd6c5f8bc305a71dfe392e13e19583c9ee37ad53 /winsup/cygwin | |
parent | f37e220e862843a933d5fac1e446b1b9fceacfa1 (diff) | |
download | cygnal-949c0ec28c86623b83ae56651c00d1bd3c3a5d0c.tar.gz cygnal-949c0ec28c86623b83ae56651c00d1bd3c3a5d0c.tar.bz2 cygnal-949c0ec28c86623b83ae56651c00d1bd3c3a5d0c.zip |
* fhandler.h (class fhandler_console): Add write_buf as pointer to
temporary buffer space.
* fhandler_console.cc (CONVERT_LIMIT): Define as NT_MAX_PATH. Add
comment.
(fhandler_console::write_normal): Use write_buf throughout.
(fhandler_console::write): Use tmp_pathbuf to allocate write_buf.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 9 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.h | 3 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_console.cc | 21 |
3 files changed, 25 insertions, 8 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index d1697badf..6ee0b2cfe 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,14 @@ 2008-03-10 Corinna Vinschen <corinna@vinschen.de> + * fhandler.h (class fhandler_console): Add write_buf as pointer to + temporary buffer space. + * fhandler_console.cc (CONVERT_LIMIT): Define as NT_MAX_PATH. Add + comment. + (fhandler_console::write_normal): Use write_buf throughout. + (fhandler_console::write): Use tmp_pathbuf to allocate write_buf. + +2008-03-10 Corinna Vinschen <corinna@vinschen.de> + * fhandler_console.cc (fhandler_console::write_normal): Don't print chars marked as ERR chars. diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index cedf7f987..f78861cde 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -884,7 +884,7 @@ class dev_console bool raw_win32_keyboard_mode; inline UINT get_console_cp (); - bool con_to_str (char *d, int dlen, WCHAR w); + DWORD con_to_str (char *d, int dlen, WCHAR w); DWORD str_to_con (PWCHAR d, const char *s, DWORD sz); void set_color (HANDLE); bool fillin_info (HANDLE); @@ -906,6 +906,7 @@ class fhandler_console: public fhandler_termios int len; unsigned char buf[4]; /* Max len of valid UTF-8 sequence. */ } trunc_buf; + PWCHAR write_buf; /* Output calls */ void set_default_attr (); diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 2b8b45703..2d5e18b9b 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -31,9 +31,12 @@ details. */ #include "pinfo.h" #include "shared_info.h" #include "cygtls.h" +#include "tls_pbuf.h" #include "registry.h" -#define CONVERT_LIMIT 65536 +/* Don't make this bigger than NT_MAX_PATH as long as the temporary buffer + is allocated using tmp_pathbuf!!! */ +#define CONVERT_LIMIT NT_MAX_PATH /* * Scroll the screen context. @@ -1473,10 +1476,10 @@ fhandler_console::write_normal (const unsigned char *src, /* Valid multibyte sequence? Process. */ if (nfound) { - WCHAR buf[2]; - buf_len = dev_state->str_to_con (buf, (const char *) trunc_buf.buf, + buf_len = dev_state->str_to_con (write_buf, + (const char *) trunc_buf.buf, nfound - trunc_buf.buf); - WriteConsoleW (get_output_handle (), buf, buf_len, &done, 0); + WriteConsoleW (get_output_handle (), write_buf, buf_len, &done, 0); found = src + (nfound - trunc_buf.buf - trunc_buf.len); trunc_buf.len = 0; return found; @@ -1509,9 +1512,7 @@ fhandler_console::write_normal (const unsigned char *src, if (found != src) { DWORD len = found - src; - PWCHAR buf = (PWCHAR) alloca (CONVERT_LIMIT * sizeof (WCHAR)); - - buf_len = dev_state->str_to_con (buf, (const char *) src, len); + buf_len = dev_state->str_to_con (write_buf, (const char *) src, len); if (!buf_len) { debug_printf ("conversion error, handle %p", @@ -1527,6 +1528,7 @@ fhandler_console::write_normal (const unsigned char *src, scroll_screen (x, y, -1, y, x + buf_len, y); } + register PWCHAR buf = write_buf; do { if (!WriteConsoleW (get_output_handle (), buf, buf_len, &done, 0)) @@ -1600,6 +1602,11 @@ fhandler_console::write (const void *vsrc, size_t len) /* Run and check for ansi sequences */ unsigned const char *src = (unsigned char *) vsrc; unsigned const char *end = src + len; + /* This might look a bit far fetched, but using the TLS path buffer allows + to allocate a big buffer without using the stack too much. Doing it here + in write instead of in write_normal should be faster, too. */ + tmp_pathbuf tp; + write_buf = tp.w_get (); debug_printf ("%x, %d", vsrc, len); |