| Commit message (Expand) | Author | Age | Files | Lines |
| * | fix misleading comment in strstr•••the intent here is just to scan at least l bytes forward for the end
of the haystack and at least some decent minimum to avoid doing it
over and over if the needle is short, with no need to be precise. the
comment erroneously stated this as an estimate for MIN when it's
actually an estimate for MAX.
| Rich Felker | 2020-12-09 | 1 | -1/+1 |
| * | fix undefined behavior from signed overflow in strstr and memmem•••unsigned char promotes to int, which can overflow when shifted left by
24 bits or more. this has been reported multiple times but then
forgotten. it's expected to be benign UB, but can trap when built with
explicit overflow catching (ubsan or similar). fix it now.
note that promotion to uint32_t is safe and portable even outside of
the assumptions usually made in musl, since either uint32_t has rank
at least unsigned int, so that no further default promotions happen,
or int is wide enough that the shift can't overflow. this is a
desirable property to have in case someone wants to reuse the code
elsewhere.
| Rich Felker | 2020-04-30 | 1 | -4/+4 |
| * | optimize two-way strstr and memmem bad character shift•••first, the condition (mem && k < p) is redundant, because mem being
nonzero implies the needle is periodic with period exactly p, in which
case any byte that appears in the needle must appear in the last p
bytes of the needle, bounding the shift (k) by p.
second, the whole point of replacing the shift k by mem (=l-p) is to
prevent shifting by less than mem when discarding the memory on shift,
in which case linear time could not be guaranteed. but as written, the
check also replaced shifts greater than mem by mem, reducing the
benefit of the shift. there is no possible benefit to this reduction of
the shift; since mem is being cleared, the full shift is valid and
more optimal. so only replace the shift by mem when it would be less
than mem.
| Rich Felker | 2018-11-08 | 1 | -1/+1 |
| * | remove commented-out debug printf from strstr•••this was leftover from before the initial commit.
| Rich Felker | 2018-11-02 | 1 | -1/+0 |
| * | fix spuriously slow check in twoway strstr/memmem cores•••mem0 && mem && ... is redundant since mem can only be nonzero when
mem0 is nonzero.
| Rich Felker | 2018-11-02 | 1 | -1/+1 |
| * | fix false negatives with periodic needles in strstr, wcsstr, and memmem•••in cases where the memorized match range from the right factor
exceeded the length of the left factor, it was wrongly treated as a
mismatch rather than a match.
issue reported by Yves Bastide.
| Rich Felker | 2014-04-18 | 1 | -1/+1 |
| * | include cleanups: remove unused headers and add feature test macros | Szabolcs Nagy | 2013-12-12 | 1 | -1/+0 |
| * | remove unused but buggy code from strstr.c | Rich Felker | 2012-08-11 | 1 | -10/+0 |
| * | fix all implicit conversion between signed/unsigned pointers•••sadly the C language does not specify any such implicit conversion, so
this is not a matter of just fixing warnings (as gcc treats it) but
actual errors. i would like to revisit a number of these changes and
possibly revise the types used to reduce the number of casts required.
| Rich Felker | 2011-03-25 | 1 | -5/+5 |
| * | initial check-in, version 0.5.0 | Rich Felker | 2011-02-12 | 1 | -0/+166 |