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/fhandler_console.cc | |
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/fhandler_console.cc')
-rw-r--r-- | winsup/cygwin/fhandler_console.cc | 21 |
1 files changed, 14 insertions, 7 deletions
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); |