diff options
author | Christopher Faylor <me@cgf.cx> | 2009-06-30 21:18:44 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2009-06-30 21:18:44 +0000 |
commit | b4fa8164748f263f152f8ec26bf361fa2d364737 (patch) | |
tree | cface150f510c4525d88eb186c897f8a81859fb8 /winsup/cygwin/strfuncs.cc | |
parent | 840bb397986fa6914a67e62e25df97e1dd88dc45 (diff) | |
download | newlib-b4fa8164748f263f152f8ec26bf361fa2d364737.zip newlib-b4fa8164748f263f152f8ec26bf361fa2d364737.tar.gz newlib-b4fa8164748f263f152f8ec26bf361fa2d364737.tar.bz2 |
* select.h: New file split from fhandler.h.
(select_record::select_record): Define do-nothing constructor for "new" to
avoid gratuitous zeroing.
(select_info): New base class.
(select_pipe_info): New class with methods for dealing with pipes.
(select_socket_info): New class with methods for dealing with sockets.
(select_serial_info): Dummy class for serial.
(select_mailslot_info): Dummy class for mailslots.
(select_stuff): Define device_specific_* as actual classes rather than void *.
* dtable.h (dtable::select_read): Accommodate return value change to 'bool' and
argument change to "select_stuff".
(dtable::select_write): Ditto.
(dtable::select_except): Ditto.
* dtable.cc (dtable::select_read): Accommodate return value change to 'bool'
and argument change to "select_stuff".
(dtable::select_write): Ditto.
(dtable::select_except): Ditto.
* fhandler.h: Excise select-related classes.
(fhandler_*::select_read): Change argument to select_stuff.
(fhandler_*::select_write): Ditto.
(fhandler_*::select_except): Ditto.
* select.cc (UNIX_FD_ZERO): Use memset rather than bzero.
(select_stuff::test_and_set): Change return type to bool. Allocate
select_record on entry and let fhandler_*::select_* operate on the start.next
field of select_stuff.
(pipeinf): Delete.
(select_pipe_info::select_pipe_info): New constructor. Allocates event for
controlling pipe waits.
(select_pipe_info::~select_pipe_info): New destructor. Destroy event. Stop
thread.
(select_pipe_info::add_watch_handle): New function.
(thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking.
(start_thread_pipe): Don't allocate device_specific_pipe stuff here. Assume
that it has been allocated earlier.
(pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe
paraphenalia.
(fhandler_*::select_*): Derive select_record from new select_stuff argument.
(fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not already
allocated.
(serialinf): Delete.
(thread_serial): serialinf -> select_serial_info.
(fhandler_base::ready_for_read): Rewrite to accommodate change in argument to
fhandler_*::select_*.
(socketinf): Delete.
(thread_socket): socketinf -> select_socket_info.
(mailslotinf): Delete.
(thread_mailslot): mailslotinf -> select_mailslot_info.
Diffstat (limited to 'winsup/cygwin/strfuncs.cc')
-rw-r--r-- | winsup/cygwin/strfuncs.cc | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/winsup/cygwin/strfuncs.cc b/winsup/cygwin/strfuncs.cc index e0ce040..4d66dd5 100644 --- a/winsup/cygwin/strfuncs.cc +++ b/winsup/cygwin/strfuncs.cc @@ -151,7 +151,7 @@ __db_mbtowc (struct _reent *r, wchar_t *pwc, const char *s, size_t n, UINT cp, if (n == 0) return -2; - + if (pwc == NULL) pwc = &dummy; @@ -221,7 +221,7 @@ __eucjp_mbtowc (struct _reent *r, wchar_t *pwc, const char *s, size_t n, if (n == 0) return -2; - + if (pwc == NULL) pwc = &dummy; @@ -437,7 +437,7 @@ sys_cp_wcstombs (wctomb_p f_wctomb, char *charset, char *dst, size_t len, bytes = 1; } else if (bytes == -1 && *charset != 'U'/*TF-8*/) - { + { /* Convert chars invalid in the current codepage to a sequence ASCII SO; UTF-8 representation of invalid char. */ buf[0] = 0x0e; /* ASCII SO */ @@ -460,20 +460,20 @@ sys_cp_wcstombs (wctomb_p f_wctomb, char *charset, char *dst, size_t len, } bytes += __utf8_wctomb (_REENT, buf + bytes, *pwcs, charset, &ps); } - } + } if (n + bytes <= len) - { - n += bytes; - if (dst) - { - for (int i = 0; i < bytes; ++i) - *ptr++ = buf[i]; - } - if (*pwcs++ == 0x00) + { + n += bytes; + if (dst) + { + for (int i = 0; i < bytes; ++i) + *ptr++ = buf[i]; + } + if (*pwcs++ == 0x00) break; - } + } else - break; + break; } if (n && dst) { @@ -558,10 +558,10 @@ sys_cp_mbstowcs (mbtowc_p f_mbtowc, char *charset, wchar_t *dst, size_t dlen, if (bytes < 0) { /* Invalid UTF-8 sequence? Treat the ASCII SO character as - stand-alone ASCII SO char. */ + stand-alone ASCII SO char. */ bytes = 1; if (dst) - *ptr = 0x0e; + *ptr = 0x0e; memset (&ps, 0, sizeof ps); break; } @@ -602,13 +602,13 @@ sys_cp_mbstowcs (mbtowc_p f_mbtowc, char *charset, wchar_t *dst, size_t dlen, } if (bytes > 0) - { - pmbs += bytes; - nms -= bytes; - ++count; + { + pmbs += bytes; + nms -= bytes; + ++count; ptr = dst ? ptr + 1 : NULL; - --len; - } + --len; + } else { if (bytes == 0) |