bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patch] make man page of addnstr() say that n = number of bytes


From: Thomas Dickey
Subject: Re: [patch] make man page of addnstr() say that n = number of bytes
Date: Tue, 17 Mar 2020 21:04:12 -0400
User-agent: NeoMutt/20170113 (1.7.2)

On Mon, Mar 16, 2020 at 05:10:35PM +0100, Benno Schulenberg wrote:
> 
> Hello,
> 
> Reading the man page of waddnstr() yesterday, I noticed that it says:
> "The four functions with n as the last argument write at most n characters".
> 
> However, this is not right.  When the string is a single multibyte character
> that consists of three bytes, then specifying 1 or 2 for n means that nothing
> gets written to the screen.  Only when specifying 3 for n does the three-byte
> character get "printed".
> 
> Attached patch fixes this in the manual page.  But maybe the manual should
> also say that when not all bytes of a multibyte character are covered by the
> n, that then nothing is written, zero bytes?  As that is what seems to happen.
> 
> Benno

> diff -ur ncurses-6.2/man/curs_addstr.3x ncurses-patched/man/curs_addstr.3x
> --- ncurses-6.2/man/curs_addstr.3x    2020-02-03 00:34:34.000000000 +0100
> +++ ncurses-patched/man/curs_addstr.3x        2020-03-16 13:30:24.030001334 
> +0100
> @@ -80,7 +80,7 @@
>  Thereafter, the cursor is advanced as a side-effect of writing to the window.
>  .PP
>  The four functions with \fIn\fR as the last argument
> -write at most \fIn\fR characters,
> +write at most \fIn\fR bytes,

ahh... it's a shame that "char" is not synonymous with "character".

>  or until a terminating null is reached.
>  If \fIn\fR is \-1, then the entire string will be added.
>  .SH RETURN VALUE

Aside from terminology, it's more complicated than that.

waddnstr calls waddch, which is where it gets complicated...

https://invisible-island.net/ncurses/man/curs_addch.3x.html#h3-Character-Set

The short answer is that even though the partial string isn't displayed,
it's stored in the window and could be completed on a following call.

-- 
Thomas E. Dickey <address@hidden>
https://invisible-island.net
ftp://ftp.invisible-island.net

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]