[core] fix buffer_to_upper()

fix buffer_to_upper() and case-insensitive filesystem detection
personal/stbuehler/fix-fdevent
Glenn Strauss 2018-05-02 20:58:24 -04:00
parent 1c68589c67
commit 2e385a1a53
2 changed files with 19 additions and 1 deletions

View File

@ -955,7 +955,7 @@ void buffer_to_upper(buffer *b) {
for (i = 0; i < b->used; ++i) {
char c = b->ptr[i];
if (c >= 'A' && c <= 'Z') b->ptr[i] &= ~0x20;
if (c >= 'a' && c <= 'z') b->ptr[i] &= ~0x20;
}
}

View File

@ -1,5 +1,6 @@
#include "first.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@ -83,8 +84,25 @@ static void test_buffer_path_simplify(void) {
buffer_free(pdest);
}
static void test_buffer_to_lower_upper(void) {
buffer *psrc = buffer_init();
buffer_copy_string_len(psrc, CONST_STR_LEN("0123456789abcdefghijklmnopqrstuvwxyz"));
buffer_to_lower(psrc);
assert(buffer_is_equal_string(psrc, CONST_STR_LEN("0123456789abcdefghijklmnopqrstuvwxyz")));
buffer_to_upper(psrc);
assert(buffer_is_equal_string(psrc, CONST_STR_LEN("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")));
buffer_to_upper(psrc);
assert(buffer_is_equal_string(psrc, CONST_STR_LEN("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")));
buffer_to_lower(psrc);
assert(buffer_is_equal_string(psrc, CONST_STR_LEN("0123456789abcdefghijklmnopqrstuvwxyz")));
buffer_free(psrc);
}
int main() {
test_buffer_path_simplify();
test_buffer_to_lower_upper();
return 0;
}