From patchwork Tue Nov 8 18:56:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 17298 Received: (qmail 10153 invoked by alias); 8 Nov 2016 18:59:44 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 10137 invoked by uid 89); 8 Nov 2016 18:59:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_SEMBACKSCATTER autolearn=no version=3.3.2 spammy=dimensions, Hx-languages-length:1363, Allocate X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Nov 2016 18:59:42 +0000 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uA8IwZRg009517 for ; Tue, 8 Nov 2016 13:59:40 -0500 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 26kgfxqv5p-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 08 Nov 2016 13:59:40 -0500 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 8 Nov 2016 18:59:37 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 8 Nov 2016 18:59:36 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9C5BA1B0805F for ; Tue, 8 Nov 2016 19:01:48 +0000 (GMT) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uA8Ixahh42074362 for ; Tue, 8 Nov 2016 18:59:36 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id uA8Hxb0T020447 for ; Tue, 8 Nov 2016 10:59:37 -0700 Received: from oc1027705133.ibm.com (dyn-9-152-212-182.boeblingen.de.ibm.com [9.152.212.182]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id uA8HvanA019676 for ; Tue, 8 Nov 2016 10:59:37 -0700 From: Andreas Arnez To: gdb-patches@sourceware.org Subject: [PATCH 3/4] tui-winsource: Allocate for actual lines only Date: Tue, 8 Nov 2016 19:56:53 +0100 In-Reply-To: <1478631454-9447-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1478631454-9447-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16110818-0016-0000-0000-0000026134E3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16110818-0017-0000-0000-000023BBE28F Message-Id: <1478631454-9447-4-git-send-email-arnez@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-11-08_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611080344 X-IsSubscribed: yes The logic for allocating a TUI source window's content buffer allocates two more lines than needed, because it does not reduce the window height by the highlight box's overhead. However, it does reduce the line width accordingly. This patch makes the height and width calculation consistent and improves the comment. gdb/ChangeLog: * tui/tui-winsource.c (tui_alloc_source_buffer): Subtract highlight box's overhead when calculating the content height. --- gdb/tui/tui-winsource.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 09080b8..4a82ae4 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -604,8 +604,11 @@ tui_alloc_source_buffer (struct tui_win_info *win_info) char *src_line_buf; int i, line_width, max_lines; - max_lines = win_info->generic.height; /* Less the highlight box. */ - line_width = win_info->generic.width - 1; + /* The window width/height includes the highlight box. Determine actual + content dimensions, including string null-terminators. */ + max_lines = win_info->generic.height - 2; + line_width = win_info->generic.width - 2 + 1; + /* * Allocate the buffer for the source lines. Do this only once * since they will be re-used for all source displays. The only