zsh-workers
 help / color / mirror / code / Atom feed
* Question about mb_metastrlen
@ 2015-10-27  8:31 Sebastian Gniazdowski
  2015-10-27  9:10 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Gniazdowski @ 2015-10-27  8:31 UTC (permalink / raw)
  To: zsh-workers

Hello,
the function counts bytes in last incomplete wide character:

        ret = mbrtowc(&wc, &inchar, 1, &mb_shiftstate);
        if (ret == MB_INCOMPLETE) {
            num_in_char++;
        } else {

When returning, it makes use of the count:

    /* If incomplete, treat remainder as trailing single bytes */
    return num + num_in_char;

Strings are stored in wchar_t arrays. The incomplete character will
occupy single index, correct? So maybe the return should be:

    return num + ( num_in_char > 0 ? 1 : 0 );

?

Best regards,
Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-27 10:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-27  8:31 Question about mb_metastrlen Sebastian Gniazdowski
2015-10-27  9:10 ` Peter Stephenson
2015-10-27 10:34   ` Sebastian Gniazdowski
2015-10-27 10:50     ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).