From patchwork Fri Jul 22 20:27:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexander_F=2E_R=C3=B8dseth?= X-Patchwork-Id: 2071 Return-Path: Delivered-To: patchwork@archlinux.org Received: from mail.archlinux.org [95.216.189.61] by patchwork.archlinux.org with IMAP (fetchmail-6.4.30) for (single-drop); Fri, 22 Jul 2022 20:27:19 +0000 (UTC) Received: from mail.archlinux.org by mail.archlinux.org with LMTP id yGdMHyYI22Lstg0AK+/4rw (envelope-from ) for ; Fri, 22 Jul 2022 20:27:18 +0000 Received: from lists.archlinux.org (lists.archlinux.org [IPv6:2a01:4f9:c010:9eb4::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.archlinux.org (Postfix) with ESMTPS id F0872125E7E7; Fri, 22 Jul 2022 20:27:17 +0000 (UTC) Received: from lists.archlinux.org (localhost [IPv6:::1]) by lists.archlinux.org (Postfix) with ESMTP id 06AFD1227519; Fri, 22 Jul 2022 20:27:15 +0000 (UTC) X-Original-To: pacman-dev@lists.archlinux.org Delivered-To: pacman-dev@lists.archlinux.org Received: from mail.archlinux.org (mail.archlinux.org [IPv6:2a01:4f9:c010:3052::1]) by lists.archlinux.org (Postfix) with ESMTPS id 1C6DC12274F4 for ; Fri, 22 Jul 2022 20:27:11 +0000 (UTC) From: =?utf-8?q?Alexander_F=2E_R=C3=B8dseth?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=archlinux.org; s=dkim-rsa; t=1658521630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VuBudvS1ecS1ktXfCKor1i1bAaQB2zMPkstL8YkBsoQ=; b=AeR/NuRBdHfg2s8HlsymMmWDjfyK1j3Qq7y94BgNoZaB7yUrSkts7XMGYvPgBbLSASPX1Z DbtUF8QxEI5udKCjiecUf7/Rrz1zy7plWcq0T3FsE5HXfwqYARIYmWYYKlgPlKLNS6gaoD 0cBRMCqd5aQ4dDji6VMu0wk05/WGi3/l6SvPx97KxTglPpKnA1behxajWOAARlZey8hKLN i2nnfzRrKmIbmf9Qta0lPj0Ezom6ylecQS2MBp7KxkeoZNOD2A3TiZzltJhg7URYTfyg4h bfljijgDmg6gkHLu+r0ob5/SPxuKZyawqM2F50K419r0j7yPKZaiF16QpiS/fzO//m4tc7 DnTFEz+fCWwMLjnK9pdldGjJcUx9BAY4aBY5zBfNQcRVUvblrzheTSgtXv5qq8bGv87NaI +bLi2Su+rWoKaxMtJdVscq/+Cuzn4hIc1rQZRXusHLFFLFj7iCR5gcgARRU49Xy1AFtisD oDAZBK5xLQmg27GieVuS63/KjEM4F6M3mfoXpSu56+3yDUfNKnPcVl4eOxidSpI4oPHE/u pdxBl8K4ePlAiMGQP7hz043qn/VnkBinzaczvvu3IhSapqvzAoMmqj2+JX8DnUnS9i3ZTV 08D0RJ5g0BFRnxFeLtrCT4Ez4+xAeEYKJZPbqmA6AFogjEy1ae5TI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=archlinux.org; s=dkim-ed25519; t=1658521630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VuBudvS1ecS1ktXfCKor1i1bAaQB2zMPkstL8YkBsoQ=; b=fMqx3rQqwYRo15WkEumOZmbIwc/gnLT+BFTYtgCSLocPqFqpTwBJ0UCjHZfFQAUZvP0fS2 Z1T7I3lYGE7Iv2AQ== To: pacman-dev@lists.archlinux.org Cc: =?utf-8?q?Alexander_F=2E_R=C3=B8dseth?= Subject: [PATCH 1/2] pacman: remove redundant argument Date: Fri, 22 Jul 2022 22:27:04 +0200 Message-Id: <20220722202705.67778-1-xyproto@archlinux.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-BeenThere: pacman-dev@lists.archlinux.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: Discussion list for pacman development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-dev-bounces@lists.archlinux.org Sender: "pacman-dev" X-Spamd-Result: default: False [-3.11 / 15.00]; DWL_DNSWL_MED(-2.00)[archlinux.org:dkim]; MID_CONTAINS_FROM(1.00)[]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; DMARC_POLICY_ALLOW(-0.50)[archlinux.org,none]; RCVD_IN_DNSWL_MED(-0.40)[2a01:4f9:c010:3052::1:received,2a01:4f9:c010:9eb4::1:from]; R_DKIM_ALLOW(-0.20)[archlinux.org:s=dkim-rsa,archlinux.org:s=dkim-ed25519]; R_SPF_ALLOW(-0.20)[+ip6:2a01:4f9:c010:9eb4::1:c]; MAILLIST(-0.20)[mailman]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:2a01:4f9::/32, country:DE]; RCVD_TLS_LAST(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; FROM_NEQ_ENVFROM(0.00)[xyproto@archlinux.org,pacman-dev-bounces@lists.archlinux.org]; FROM_HAS_DN(0.00)[]; NEURAL_HAM(-0.00)[-0.998]; DKIM_TRACE(0.00)[archlinux.org:+]; TO_DN_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; PREVIOUSLY_DELIVERED(0.00)[pacman-dev@lists.archlinux.org]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Server: mail.archlinux.org X-Rspamd-Queue-Id: F0872125E7E7 Authentication-Results: mail.archlinux.org; dkim=pass header.d=archlinux.org header.s=dkim-rsa header.b="AeR/NuRB"; dkim=pass header.d=archlinux.org header.s=dkim-ed25519 header.b=fMqx3rQq; dmarc=pass (policy=none) header.from=archlinux.org; spf=pass (mail.archlinux.org: domain of pacman-dev-bounces@lists.archlinux.org designates 2a01:4f9:c010:9eb4::1 as permitted sender) smtp.mailfrom=pacman-dev-bounces@lists.archlinux.org The fill_progress function is called from two locations, and both locations pass in the same percentage value twice. This patch modifies the function signature to to receive the percentage value just once. Signed-off-by: Alexander F. Rødseth --- src/pacman/callback.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pacman/callback.c b/src/pacman/callback.c index a06f3bcc..df4032a4 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -150,12 +150,11 @@ static int64_t get_update_timediff(int first_call) } /* refactored from cb_trans_progress */ -static void fill_progress(const int bar_percent, const int disp_percent, - const int proglen) +static void fill_progress(const int percent, const int proglen) { /* 8 = 1 space + 1 [ + 1 ] + 5 for percent */ const int hashlen = proglen > 8 ? proglen - 8 : 0; - const int hash = bar_percent * hashlen / 100; + const int hash = percent * hashlen / 100; int i; if(hashlen > 0) { @@ -188,7 +187,7 @@ static void fill_progress(const int bar_percent, const int disp_percent, /* print display percent after progress bar */ /* 5 = 1 space + 3 digits + 1 % */ if(proglen >= 5) { - printf(" %3d%%", disp_percent); + printf(" %3d%%", percent); } putchar('\r'); @@ -677,7 +676,7 @@ void cb_progress(void *ctx, alpm_progress_t event, const char *pkgname, free(wcstr); /* call refactored fill progress function */ - fill_progress(percent, percent, cols - infolen); + fill_progress(percent, cols - infolen); if(percent == 100) { putchar('\n'); @@ -855,7 +854,7 @@ static void draw_pacman_progress_bar(struct pacman_progress_bar *bar) free(fname); free(wcfname); - fill_progress(file_percent, file_percent, cols - infolen); + fill_progress(file_percent, cols - infolen); return; } From patchwork Fri Jul 22 20:27:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexander_F=2E_R=C3=B8dseth?= X-Patchwork-Id: 2070 Return-Path: Delivered-To: patchwork@archlinux.org Received: from mail.archlinux.org [95.216.189.61] by patchwork.archlinux.org with IMAP (fetchmail-6.4.30) for (single-drop); Fri, 22 Jul 2022 20:27:16 +0000 (UTC) Received: from mail.archlinux.org by mail.archlinux.org with LMTP id SIb3NCMI22LYtg0AK+/4rw (envelope-from ) for ; Fri, 22 Jul 2022 20:27:15 +0000 Received: from lists.archlinux.org (lists.archlinux.org [IPv6:2a01:4f9:c010:9eb4::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.archlinux.org (Postfix) with ESMTPS id 81AB3125E7BB; Fri, 22 Jul 2022 20:27:14 +0000 (UTC) Received: from lists.archlinux.org (localhost [IPv6:::1]) by lists.archlinux.org (Postfix) with ESMTP id 59B811227503; Fri, 22 Jul 2022 20:27:14 +0000 (UTC) X-Original-To: pacman-dev@lists.archlinux.org Delivered-To: pacman-dev@lists.archlinux.org Received: from mail.archlinux.org (mail.archlinux.org [IPv6:2a01:4f9:c010:3052::1]) by lists.archlinux.org (Postfix) with ESMTPS id 4207112274F5 for ; Fri, 22 Jul 2022 20:27:13 +0000 (UTC) From: =?utf-8?q?Alexander_F=2E_R=C3=B8dseth?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=archlinux.org; s=dkim-rsa; t=1658521633; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vJF2I32DxHQd1gE+vncMcLI1Rz4edllnw0TYKsDIcuo=; b=MqLLfjLPFYBVyvqO+Q8NpVn7jEfLOB7EiBlJU9dh51mARyGMHDIeNlhp2bkwmc2mfNJlYh 8mdZHDQv+ib36kEjJSdSCwBiHgeGo2CtjgBCeecBqcyKtbd56y5nFjRLCsR8LX/3PbOroF VCEAkmiYU5rOpS/MLZhRNTv6J9PxHIMiOxUfRnTihYiV9NSJLuSgnPqu1itwITrftRxRQ0 TRrx/OyrjckfpCxWf/SCr4BVxdrClcOCC1BQCLdfUoWIAydu/L3czBjsN2s8Zh9JmsEBz3 T7vB7tYkohlZqQgQ5EyrZZWTI5dsM3DUujiSMD2uL9lfZ/9lqG59nYOGdPQby19k7mIayy 3PxrIablwAkqk6aeal3j6wb3jpdaOkBb41qYuzBbMpuFjyRNYdlDoes3zRnx0lFdf+nbCT meMVDgNHvh3DDNDbqDXqtz7kbPCzA7LFf7wyqI5BrU3uuDlxV4veWO31lHTRCxLKpeZ8GX QKFaRHSrw2sERXhQ0XZ7po3zXzbWGMphBK6eeOWL0mAJhjViKbmGNRMfrHRVqLmzkd/a7y yG228GM6v4w5+oHAKRHf6PT0fmvSxHs//7ecQu5kFeJPdXV0apBOk80QvGo+UCOmgVYG+P RZHZ5yVne0sIYkuzEY+M7ZT6LeyLn0uob9q5TL4vtbY+253J8ZpQI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=archlinux.org; s=dkim-ed25519; t=1658521633; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vJF2I32DxHQd1gE+vncMcLI1Rz4edllnw0TYKsDIcuo=; b=IvQClf8WE1dXCjges1lDLLnw9y1pVNSEZCr3N4EIZY5WgqopqGzFbZmDoJ2eTV7XPIyN6d ehtnSuuVhUJcrNAQ== To: pacman-dev@lists.archlinux.org Cc: =?utf-8?q?Alexander_F=2E_R=C3=B8dseth?= Subject: [PATCH 2/2] pacman: let the progress bar "C"/"c" move up and down at a more regular rate Date: Fri, 22 Jul 2022 22:27:05 +0200 Message-Id: <20220722202705.67778-2-xyproto@archlinux.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220722202705.67778-1-xyproto@archlinux.org> References: <20220722202705.67778-1-xyproto@archlinux.org> MIME-Version: 1.0 X-BeenThere: pacman-dev@lists.archlinux.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: Discussion list for pacman development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-dev-bounces@lists.archlinux.org Sender: "pacman-dev" X-Spamd-Result: default: False [-7.11 / 15.00]; REPLY(-4.00)[]; DWL_DNSWL_MED(-2.00)[archlinux.org:dkim]; MID_CONTAINS_FROM(1.00)[]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; DMARC_POLICY_ALLOW(-0.50)[archlinux.org,none]; RCVD_IN_DNSWL_MED(-0.40)[2a01:4f9:c010:9eb4::1:from,2a01:4f9:c010:3052::1:received]; R_DKIM_ALLOW(-0.20)[archlinux.org:s=dkim-rsa,archlinux.org:s=dkim-ed25519]; R_SPF_ALLOW(-0.20)[+ip6:2a01:4f9:c010:9eb4::1:c]; MAILLIST(-0.20)[mailman]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:2a01:4f9::/32, country:DE]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[archlinux.org:+]; FROM_HAS_DN(0.00)[]; NEURAL_HAM(-0.00)[-1.000]; RCPT_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[]; FROM_NEQ_ENVFROM(0.00)[xyproto@archlinux.org,pacman-dev-bounces@lists.archlinux.org]; PREVIOUSLY_DELIVERED(0.00)[pacman-dev@lists.archlinux.org]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Server: mail.archlinux.org X-Rspamd-Queue-Id: 81AB3125E7BB Authentication-Results: mail.archlinux.org; dkim=pass header.d=archlinux.org header.s=dkim-rsa header.b=MqLLfjLP; dkim=pass header.d=archlinux.org header.s=dkim-ed25519 header.b=IvQClf8W; dmarc=pass (policy=none) header.from=archlinux.org; spf=pass (mail.archlinux.org: domain of pacman-dev-bounces@lists.archlinux.org designates 2a01:4f9:c010:9eb4::1 as permitted sender) smtp.mailfrom=pacman-dev-bounces@lists.archlinux.org For some terminal widths, the "C"/"c" character does not alternate at regular intervals, but may look like it is stuck at either lowercase or uppercase. The previous behavior toggled based on the character position, while this new behavior toggles the chomp alternation based on the progress percentage value. This leads to slightly improved chomping. Signed-off-by: Alexander F. Rødseth --- src/pacman/callback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pacman/callback.c b/src/pacman/callback.c index df4032a4..aa6303bf 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -165,7 +165,7 @@ static void fill_progress(const int percent, const int proglen) if(i > hashlen - hash) { putchar('-'); } else if(i == hashlen - hash) { - if(i % 2 == 0) { + if(percent % 2 == 0) { fputs("\033[1;33mC\033[m", stdout); } else { fputs("\033[1;33mc\033[m", stdout);