Age | Commit message (Collapse) | Author | Lines |
2020年12月09日 | fix misleading comment in strstr | Rich Felker | -1/+1 |
|
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.
|
2020年04月30日 | fix undefined behavior from signed overflow in strstr and memmem | Rich Felker | -4/+4 |
|
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.
|
2018年11月08日 | optimize two-way strstr and memmem bad character shift | Rich Felker | -1/+1 |
|
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.
|
2018年11月02日 | remove commented-out debug printf from strstr | Rich Felker | -1/+0 |
|
this was leftover from before the initial commit.
|
2018年11月02日 | fix spuriously slow check in twoway strstr/memmem cores | Rich Felker | -1/+1 |
|
mem0 && mem && ... is redundant since mem can only be nonzero when
mem0 is nonzero.
|
2014年04月18日 | fix false negatives with periodic needles in strstr, wcsstr, and memmem | Rich Felker | -1/+1 |
|
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.
|
2013年12月12日 | include cleanups: remove unused headers and add feature test macros | Szabolcs Nagy | -1/+0 |
|
2012年08月11日 | remove unused but buggy code from strstr.c | Rich Felker | -10/+0 |
|
2011年03月25日 | fix all implicit conversion between signed/unsigned pointers | Rich Felker | -5/+5 |
|
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.
|
2011年02月12日 | initial check-in, version 0.5.0 v0.5.0 | Rich Felker | -0/+166 |
|