summaryrefslogtreecommitdiff
path: root/lib/wcsstr-impl.h
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2026-03-08 17:28:50 +0100
committerJörg Frings-Fürst <debian@jff.email>2026-03-08 17:28:50 +0100
commitff33e1d252f46bec1a33e28700da3282fc24047a (patch)
tree5c15bc695be820b393a8496c5807ecafbbdeb89b /lib/wcsstr-impl.h
parentb2ac982cc8b5290699eb5f52fb043d3d15e2624b (diff)
parent5f59a34ab747dde8ede7357f3431bf06bd6002fe (diff)
Update upstream source from tag 'upstream/1.4.2'
Update to upstream version '1.4.2' with Debian dir 493e96bcd865e4f9990e20bee26408c96231d727
Diffstat (limited to 'lib/wcsstr-impl.h')
-rw-r--r--lib/wcsstr-impl.h32
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/wcsstr-impl.h b/lib/wcsstr-impl.h
index 60463b4b..423c7fd9 100644
--- a/lib/wcsstr-impl.h
+++ b/lib/wcsstr-impl.h
@@ -1,5 +1,5 @@
/* Locate a substring in a wide string.
- Copyright (C) 1999, 2011-2025 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2011-2026 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -24,31 +24,33 @@
RETURN_TYPE
FUNC (const UNIT *haystack_start, const UNIT *needle_start)
{
- const UNIT *haystack = haystack_start;
const UNIT *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 (RETURN_TYPE) haystack_start;
+ {
+ const UNIT *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 (RETURN_TYPE) 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 UNIT *haystack = STRCHR (haystack_start + 1, *needle_start);
if (!haystack || __builtin_expect (needle_len == 1, 0))
return (RETURN_TYPE) 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. */
return two_way_short_needle (haystack, haystack_len,