From: Jim Meyering Date: Fri, 14 Jul 2023 05:29:52 +0000 (-0700) Subject: cksum: improve problematic_chars function X-Git-Tag: v9.4~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0e7e4a1d41049bbf38cf902d13746b1ab5b1e38;p=thirdparty%2Fcoreutils.git cksum: improve problematic_chars function * src/digest.c (problematic_chars): Implement using strcspn, and traversing S only once, rather than once per escaped byte. --- diff --git a/src/digest.c b/src/digest.c index e80eb3406a..60ba82e5f9 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')