Commit Graph

5 Commits

Author SHA1 Message Date
Edward Thomson
1196de4f26 util: introduce git__strlcmp
Introduce a utility function that compares a NUL terminated string to a
possibly not-NUL terminated string with length.  This is similar to
`strncmp` but with an added check to ensure that the lengths match (not
just the `size` portion of the two strings).
2021-09-01 20:39:51 -04:00
Edward Thomson
86219f4068 util: introduce git__prefixncmp and consolidate implementations
Introduce `git_prefixncmp` that will search up to the first `n`
characters of a string to see if it is prefixed by another string.
This is useful for examining if a non-null terminated character
array is prefixed by a particular substring.

Consolidate the various implementations of `git__prefixcmp` around a
single core implementation and add some test cases to validate its
behavior.
2017-12-20 16:08:01 +00:00
Edward Thomson
bad33a5dfb git__tolower: test that some non-ASCII downcasing isn't 2015-05-29 18:16:51 -04:00
Edward Thomson
006548da91 git__strcasecmp: treat input bytes as unsigned
Treat input bytes as unsigned before doing arithmetic on them,
lest we look at some non-ASCII byte (like a UTF-8 character) as a
negative value and perform the comparison incorrectly.
2015-05-29 16:07:51 -04:00
Ben Straub
1782038144 Rename tests-clar to tests 2013-11-14 14:05:52 -08:00