From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686302321; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=COenok1TSaoTlREgx7xUdF+wtME8cSUouhJ10VU/PCw=; b=HplkaGCSRYXRpfx+kb2U14iOeP7Otb/GrtQaVHBy+nGI3YDtssZJQe2CRlBVZAVX5nHWfw 6R70m4vjXaGtjvsR2IhI6xezzH3buTT6kXg1ccXqePTT7rrn8qgPHeig0d05YOX4sfFGkZ F7VquWwOc/O//QsRetZRsDXldOc6la0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686302321; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=COenok1TSaoTlREgx7xUdF+wtME8cSUouhJ10VU/PCw=; b=8VCbub/Nw2kdZDibO38j2zi8QdKYki7jhBpfbmf+VnjXjs3f+fHlTKNV0hrlwLP2qR9H4D 3XwRy4DpHhXF0+DA== 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 From: Tom de Vries 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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 --- gdb/tui/tui-io.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) 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) base-commit: 30711c89cc7dcd2bd4ea772b2f5dc639c5b1cfcc -- 2.35.3