31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'ext/u/rb_u_string_casecmp.c', line 31
VALUE
rb_u_string_casecmp(int argc, VALUE *argv, VALUE self)
{
const char *locale = NULL;
VALUE rbother, rblocale;
if (rb_scan_args(argc, argv, "11", &rbother, &rblocale) == 2)
locale = StringValuePtr(rblocale);
const struct rb_u_string *string = RVAL2USTRING(self);
const struct rb_u_string *other = RVAL2USTRING_ANY(rbother);
char *folded;
size_t folded_n = foldcase(&folded, string, locale, NULL);
char *folded_other;
size_t folded_other_n = foldcase(&folded_other, other, locale, folded);
errno = 0;
int r = u_collate(folded, folded_n,
folded_other, folded_other_n,
locale);
free(folded_other);
free(folded);
if (errno != 0)
rb_u_raise_errno(errno, "can’t collate strings");
return INT2FIX(r);
}
|