Small suggested improvement:
>From c0e7e4a1d41049bbf38cf902d13746b1ab5b1e38 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@meta.com> Date: Thu, 13 Jul 2023 22:29:52 -0700 Subject: [PATCH] cksum: improve problematic_chars function
* src/digest.c (problematic_chars): Implement using strcspn, and traversing S only once, rather than once per escaped byte. --- src/digest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/digest.c b/src/digest.c index e80eb3406..60ba82e5f 100644 --- a/src/digest.c +++ b/src/digest.c @@ -568,7 +568,8 @@ ATTRIBUTE_PURE static bool problematic_chars (char const *s) { - return strchr (s, '\\') || strchr (s, '\n') || strchr (s, '\r'); + size_t length = strcspn (s, "\\\n\r"); + return s[length] != '\0'; } #define ISWHITE(c) ((c) == ' ' || (c) == '\t') -- 2.41.0.327.gaa9166bcc0