NetBSD Problem Report #55433

From www@netbsd.org  Tue Jun 30 10:02:21 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 9A4A11A9217
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 30 Jun 2020 10:02:21 +0000 (UTC)
Message-Id: <20200630100220.C80981A9218@mollari.NetBSD.org>
Date: Tue, 30 Jun 2020 10:02:20 +0000 (UTC)
From: jnaman806@gmail.com
Reply-To: jnaman806@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Bug in special character handling of ins_wstr() of libcurses
X-Send-Pr-Version: www-1.0

>Number:         55433
>Category:       lib
>Synopsis:       Bug in special character handling of ins_wstr() of libcurses
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 30 10:05:00 +0000 2020
>Last-Modified:  Thu Jul 16 21:50:01 +0000 2020
>Originator:     Naman Jain
>Release:        NetBSD 9.0
>Organization:
IIT Kanpur
>Environment:
NetBSD localhost 9.0 NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64

>Description:
int main() {
    initscr();
    wchar_t wstr[] = {'A', '\n', 'A', L'\0'};
    ins_wstr(wstr);
    refresh();
    getch();
    endwin();
    return 0;
}

This code should result into 2 As, one at the start of first-line(0,0) and second at the start of second-line(1,0). Instead, it prints only a single A that too at (0,1).
Similarly, it shows unexpected behavior for \r also. For wstr[] = {'A', '\r', 'B', L'\0'}, the expected behaviour is a single B but it displays AB.


>How-To-Repeat:

>Fix:

>Audit-Trail:
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: lib/55433: Bug in special character handling of ins_wstr() of
 libcurses
Date: Thu, 16 Jul 2020 02:45:15 +0300

 wins_nwstr - the worker function doesn't seem to handle special
 character correctly in its first part as it computes wcwidth of the
 whole argument.

 As an aside, insstr() &c don't even pretend to try to handle special
 characters.

 -uwe

From: Brett Lymn <blymn@internode.on.net>
To: gnats-bugs@netbsd.org
Cc: lib-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
        jnaman806@gmail.com
Subject: Re: lib/55433: Bug in special character handling of ins_wstr() of
 libcurses
Date: Fri, 17 Jul 2020 07:18:01 +0930

 On Wed, Jul 15, 2020 at 11:50:02PM +0000, Valery Ushakov wrote:
 > 
 >  wins_nwstr - the worker function doesn't seem to handle special
 >  character correctly in its first part as it computes wcwidth of the
 >  whole argument.
 >  
 >  As an aside, insstr() &c don't even pretend to try to handle special
 >  characters.
 >  

 They should according to SUS v2 so we should be doing it.

 -- 
 Brett Lymn
 --
 Sent from my NetBSD device.

 "We are were wolves",
 "You mean werewolves?",
 "No we were wolves, now we are something else entirely",
 "Oh"

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.