From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Kf2mAb6wfGl6rx0AWB0awg (envelope-from ) for ; Fri, 30 Jan 2026 08:23:10 -0500 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=ep2hJaYi; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 028A71E0DD; Fri, 30 Jan 2026 08:23:10 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A39691E08D for ; Fri, 30 Jan 2026 08:23:09 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 429904BA2E22 for ; Fri, 30 Jan 2026 13:23:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 429904BA2E22 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=ep2hJaYi Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id 509A04BA23DA for ; Fri, 30 Jan 2026 13:17:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 509A04BA23DA Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 509A04BA23DA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1769779045; cv=none; b=uXmvWLaFEsJwvTj9wryJ3dRtpjdnI6QbQuq5gg/n3cik1ipH0D49WqZdKS9qpSM98dCm5T5SRMeLV4kXGfMXc0ZXoI+C3PEkZWX0Oj2dl2yTsAIpVmTAsSxgvt4E6vn6IO5lCdfygLx4VLAxGBMFVbAEWt4Rx1AbVPOPeP+ol74= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1769779045; c=relaxed/simple; bh=G7lCSg4g70cuILo+tTA6jAKqUFif8BB3uMEIdQ0zrMk=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=xEHdAcXTp2jRAHRlkUUdu//R6dw65SYv0YJPDB2TcehEsf2qPD/zmiDYLC6LfN2jAMNlpxhBvbDZfJjs3/DjimNO0xPw/OucJfKCTAsH8VN/D/9SdbLmTmrv8zAOCMeKTIYdIdF/s6SWlFRp7pkUGHPJItc2v4+w9lJqHaTEyUY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 509A04BA23DA Received: from eig-obgw-5006b.ext.cloudfilter.net ([10.0.29.217]) by cmsmtp with ESMTPS id lnTEvG28TSkcfloNJvvWXX; Fri, 30 Jan 2026 13:17:25 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id loNIvVYXfOs9RloNIvvYrT; Fri, 30 Jan 2026 13:17:24 +0000 X-Authority-Analysis: v=2.4 cv=HPPDFptv c=1 sm=1 tr=0 ts=697caf64 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=ItBw4LHWJt0A:10 a=20KFwNOVAAAA:8 a=-5VyOvkT6sHsLppJW30A:9 a=QEXdDO2ut3YA:10 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=7mepBlpxxbt1ZoHjtVZKrJBxHqVm/MkmQZSleFQ/Cqo=; b=ep2hJaYia9UG1HBM/F5FA6JTTB W9nrut+UGq+mIvKQvfVwx/tJURdZyvKGPY6ZNha98XtrPzbX+4rz1cZc8t3zJY5f8BtktJxOUttoI K4dsOevChyCJIKCi3GCSLvJlj; Received: from 97-122-114-32.hlrn.qwest.net ([97.122.114.32]:33716 helo=[192.168.122.1]) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vloNH-00000001JjQ-3xNr; Fri, 30 Jan 2026 06:17:23 -0700 From: Tom Tromey Date: Fri, 30 Jan 2026 06:17:23 -0700 Subject: [PATCH v3 09/21] Improve fputs_highlighted by using ui_file::write MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260130-pr-28948-logging-5-v3-9-3eec47ef3cba@tromey.com> References: <20260130-pr-28948-logging-5-v3-0-3eec47ef3cba@tromey.com> In-Reply-To: <20260130-pr-28948-logging-5-v3-0-3eec47ef3cba@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey , Andrew Burgess X-Mailer: b4 0.14.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.114.32 X-Source-L: No X-Exim-ID: 1vloNH-00000001JjQ-3xNr X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-114-32.hlrn.qwest.net ([192.168.122.1]) [97.122.114.32]:33716 X-Source-Auth: tom+tromey.com X-Email-Count: 16 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfMozBeRx2bI3l0T5hPRn3BixqRQ/jCmPetmU5rjtqAeEyFVrngSAgzXa+B9XsWj3chFLXJzF2o+QnRyrbgF8PR31sw8J61tG5dKp9yhwd+JqNyJtU0c9 9GPgFKxRiEE5JRW59V6bj+n/BuytiqR8XB506T8GqcRB24CixHAvSTsfQk3xO/xAVXQaj6gSZzcS7VJtvx0zhgdOmwrzx6RJhjA= X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org I noticed that fputs_highlighted writes a single character at a time. It's more idiomatic to use ui_file::write. Approved-By: Andrew Burgess --- gdb/utils.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/gdb/utils.c b/gdb/utils.c index ef2d0fa0c41..f4c9e584628 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1921,22 +1921,20 @@ fputs_highlighted (const char *str, const compiled_regex &highlight, size_t n_highlight = pmatch.rm_eo - pmatch.rm_so; /* Output the part before pmatch with current style. */ - while (pmatch.rm_so > 0) + if (pmatch.rm_so > 0) { - gdb_putc (*str, stream); - pmatch.rm_so--; - str++; + stream->write (str, pmatch.rm_so); + str += pmatch.rm_so; } /* Output pmatch with the highlight style. */ - stream->emit_style_escape (highlight_style.style ()); - while (n_highlight > 0) + if (n_highlight > 0) { - gdb_putc (*str, stream); - n_highlight--; - str++; + stream->emit_style_escape (highlight_style.style ()); + stream->write (str, n_highlight); + str += n_highlight; + stream->emit_style_escape (ui_file_style ()); } - stream->emit_style_escape (ui_file_style ()); } /* Output the trailing part of STR not matching HIGHLIGHT. */ -- 2.49.0