diff options
author | Russell Belfer <rb@github.com> | 2012-12-10 15:29:44 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-12-10 15:38:41 -0800 |
commit | 91e7d26303b17c7ebc45ba565247e968aaa20848 (patch) | |
tree | cb205e56dfcbf9dd4df6ed150f152106aa6da342 /src/util.c | |
parent | 9950d27ab62cc31a3ebf1944fd33dd65432be790 (diff) | |
download | libgit2-91e7d26303b17c7ebc45ba565247e968aaa20848.tar.gz |
Fix iterator reset and add reset ranges
The `git_iterator_reset` command has not been working in all cases
particularly when there is a start and end range. This fixes it
and adds tests for it, and also extends it with the ability to
update the start/end range strings when an iterator is reset.
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/util.c b/src/util.c index 9813eb694..831b07385 100644 --- a/src/util.c +++ b/src/util.c @@ -199,9 +199,17 @@ int git__strncmp(const char *a, const char *b, size_t sz) int git__strncasecmp(const char *a, const char *b, size_t sz) { - while (sz && *a && *b && tolower(*a) == tolower(*b)) + int al, bl; + + while (sz && *a && *b) { + al = (unsigned char)tolower(*a); + bl = (unsigned char)tolower(*b); + if (al != bl) + break; --sz, ++a, ++b; - return !sz ? 0 : (tolower(*a) - tolower(*b)); + } + + return !sz ? 0 : al - bl; } void git__strntolower(char *str, size_t len) |