Skip to content

Commit

Permalink
enc/unicode.c: constify
Browse files Browse the repository at this point in the history
* enc/unicode.c (code{2,3}_{cmp,hash}): constify and adjust
  argument types.

* enc/unicode.c (onigenc_unicode_fold_lookup): constify.

* enc/unicode.c (onigenc_unicode_apply_all_case_fold): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed May 23, 2014
1 parent 688b4cb commit dcaf699
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions enc/unicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,18 @@ onigenc_unicode_property_name_to_ctype(OnigEncoding enc, UChar* name, UChar* end


static int
code2_cmp(OnigCodePoint* x, OnigCodePoint* y)
code2_cmp(st_data_t x0, st_data_t y0)
{
const OnigCodePoint *x = (const OnigCodePoint *)x0;
const OnigCodePoint *y = (const OnigCodePoint *)y0;
if (x[0] == y[0] && x[1] == y[1]) return 0;
return 1;
}

static st_index_t
code2_hash(OnigCodePoint* x)
code2_hash(st_data_t x0)
{
const OnigCodePoint *x = (const OnigCodePoint *)x0;
return (st_index_t )(x[0] + x[1]);
}

Expand All @@ -204,15 +207,18 @@ static const struct st_hash_type type_code2_hash = {
};

static int
code3_cmp(OnigCodePoint* x, OnigCodePoint* y)
code3_cmp(st_data_t x0, st_data_t y0)
{
const OnigCodePoint *x = (const OnigCodePoint *)x0;
const OnigCodePoint *y = (const OnigCodePoint *)y0;
if (x[0] == y[0] && x[1] == y[1] && x[2] == y[2]) return 0;
return 1;
}

static st_index_t
code3_hash(OnigCodePoint* x)
code3_hash(st_data_t x0)
{
const OnigCodePoint *x = (const OnigCodePoint *)x0;
return (st_index_t )(x[0] + x[1] + x[2]);
}

Expand Down Expand Up @@ -291,7 +297,7 @@ onigenc_unicode_mbc_case_fold(OnigEncoding enc,
OnigCaseFoldType flag ARG_UNUSED, const UChar** pp, const UChar* end,
UChar* fold)
{
CodePointList3 *to;
const CodePointList3 *to;
OnigCodePoint code;
int i, len, rlen;
const UChar *p = *pp;
Expand Down Expand Up @@ -483,8 +489,8 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
{
int n, i, j, k, len;
OnigCodePoint code, codes[3];
CodePointList3 *to, *z3;
CodePointList2 *z2;
const CodePointList3 *to, *z3;
const CodePointList2 *z2;

if (CaseFoldInited == 0) init_case_fold_table();

Expand Down

0 comments on commit dcaf699

Please sign in to comment.