From 13e14a6bfd9f29cbfeab0c5161d2a994f97532e7 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Thu, 26 Mar 2026 12:53:53 +0100 Subject: Update/gnulib 2026 03 (#2247) * Sync with the 202601-stable Gnulib code (4a3650d887) * Ignore more deps stuff in gnulib * Remove autogenerated gnulib files * Ignore more gnulib generated headers --- gl/strstr.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'gl/strstr.c') diff --git a/gl/strstr.c b/gl/strstr.c index d6953f90..a5730a37 100644 --- a/gl/strstr.c +++ b/gl/strstr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2025 Free Software +/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2026 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -36,31 +36,33 @@ char * strstr (const char *haystack_start, const char *needle_start) { - const char *haystack = haystack_start; const char *needle = needle_start; - size_t needle_len; /* Length of NEEDLE. */ - size_t haystack_len; /* Known minimum length of HAYSTACK. */ - bool ok = true; /* True if NEEDLE is prefix of HAYSTACK. */ /* Determine length of NEEDLE, and in the process, make sure HAYSTACK is at least as long (no point processing all of a long NEEDLE if HAYSTACK is too short). */ - while (*haystack && *needle) - ok &= *haystack++ == *needle++; - if (*needle) - return NULL; - if (ok) - return (char *) haystack_start; + { + const char *haystack = haystack_start; + bool ok = true; /* True if NEEDLE is prefix of HAYSTACK. */ + while (*haystack && *needle) + ok &= *haystack++ == *needle++; + if (*needle) + return NULL; + if (ok) + return (char *) haystack_start; + } /* Reduce the size of haystack using strchr, since it has a smaller linear coefficient than the Two-Way algorithm. */ - needle_len = needle - needle_start; - haystack = strchr (haystack_start + 1, *needle_start); + size_t needle_len = /* Length of NEEDLE. */ + needle - needle_start; + const char *haystack = strchr (haystack_start + 1, *needle_start); if (!haystack || __builtin_expect (needle_len == 1, 0)) return (char *) haystack; needle -= needle_len; - haystack_len = (haystack > haystack_start + needle_len ? 1 - : needle_len + haystack_start - haystack); + size_t haystack_len = /* Known minimum length of HAYSTACK. */ + (haystack > haystack_start + needle_len ? 1 + : needle_len + haystack_start - haystack); /* Perform the search. Abstract memory is considered to be an array of 'unsigned char' values, not an array of 'char' values. See -- cgit v1.2.3-74-g34f1