From patchwork Fri Jun 9 09:18:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 70816 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 76196385661C for ; Fri, 9 Jun 2023 09:19:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76196385661C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1686302348; bh=COenok1TSaoTlREgx7xUdF+wtME8cSUouhJ10VU/PCw=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ZAuLPF9mvitOrLnE4j/2C4rD9/a1tzBYMB9fOTovABME1rM7CdmHkwx4Q6pjUZaO3 5v8/ZsFz7ZzomdYsu8FrUQgYc/j6ucAxiJEHjrcK5K94llla7Uph4x4oOMU7CcxcGm nkhn58vnxcHQPChk1okXgBwK72noFZCCrUpPeF00= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 31DED3858D35 for ; Fri, 9 Jun 2023 09:18:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 31DED3858D35 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5DB4C1FDF9; Fri, 9 Jun 2023 09:18:41 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4769D139C8; Fri, 9 Jun 2023 09:18:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id b+xoEHHugmStdQAAMHmgww (envelope-from ); Fri, 09 Jun 2023 09:18:41 +0000 To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 1/2] [gdb/tui] Simplify tui_puts_internal Date: Fri, 9 Jun 2023 11:18:49 +0200 Message-Id: <20230609091850.21301-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Simplify tui_puts_internal by using continue, as per this [1] coding standard rule, making the function more readable and easier to understand. No functional changes. Tested on x86_64-linux. [1] https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code Reviewed-By: Tom Tromey --- gdb/tui/tui-io.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) base-commit: 30711c89cc7dcd2bd4ea772b2f5dc639c5b1cfcc diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index 908cb834e4c..8cb68d12408 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -523,36 +523,37 @@ tui_puts_internal (WINDOW *w, const char *string, int *height) while ((c = *string++) != 0) { - if (c == '\n') - saw_nl = true; - if (c == '\1' || c == '\2') { /* Ignore these, they are readline escape-marking sequences. */ + continue; } - else + + if (c == '\033') { - if (c == '\033') + size_t bytes_read = apply_ansi_escape (w, string - 1); + if (bytes_read > 0) { - size_t bytes_read = apply_ansi_escape (w, string - 1); - if (bytes_read > 0) - { - string = string + bytes_read - 1; - continue; - } + string = string + bytes_read - 1; + continue; } - do_tui_putc (w, c); + } - if (height != nullptr) - { - int col = getcurx (w); - if (col <= prev_col) - ++*height; - prev_col = col; - } + if (c == '\n') + saw_nl = true; + + do_tui_putc (w, c); + + if (height != nullptr) + { + int col = getcurx (w); + if (col <= prev_col) + ++*height; + prev_col = col; } } + if (TUI_CMD_WIN != nullptr && w == TUI_CMD_WIN->handle.get ()) update_cmdwin_start_line (); if (saw_nl)