constify rb_encoding and OnigEncoding

* include/ruby/encoding.h: constify `rb_encoding` arguments.
* include/ruby/oniguruma.h: constify `OnigEncoding` arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-06-01 22:06:11 +00:00
Родитель b16245145b
Коммит 046831094b
16 изменённых файлов: 161 добавлений и 154 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Mon Jun 2 07:05:59 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* include/ruby/encoding.h: constify `rb_encoding` arguments.
* include/ruby/oniguruma.h: constify `OnigEncoding` arguments.
Sun Jun 1 12:05:10 2014 Tanaka Akira <akr@fsij.org>
* test/drb: Wrap tests definitions by DRbTests module. This makes

Просмотреть файл

@ -178,7 +178,7 @@ onigenc_unicode_ctype_code_range(int ctype, const OnigCodePoint* ranges[])
extern int
onigenc_utf16_32_get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out,
const OnigCodePoint* ranges[],
struct OnigEncodingTypeST* enc ARG_UNUSED)
OnigEncoding enc ARG_UNUSED)
{
*sb_out = 0x00;
return onigenc_unicode_ctype_code_range(ctype, ranges);

Просмотреть файл

@ -22,7 +22,7 @@
#if defined __GNUC__ && __GNUC__ >= 4
#pragma GCC visibility push(default)
int rb_enc_register(const char *name, rb_encoding *encoding);
int rb_enc_register(const char *name, const rb_encoding *encoding);
void rb_enc_set_base(const char *name, const char *orig);
int rb_enc_set_dummy(int index);
void rb_encdb_declare(const char *name);
@ -99,7 +99,7 @@ rb_enc_from_encoding_index(int idx)
}
VALUE
rb_enc_from_encoding(rb_encoding *encoding)
rb_enc_from_encoding(const rb_encoding *encoding)
{
int idx;
if (!encoding) return Qnil;
@ -254,9 +254,10 @@ enc_table_expand(int newsize)
}
static int
enc_register_at(int index, const char *name, rb_encoding *encoding)
enc_register_at(int index, const char *name, const rb_encoding *base_encoding)
{
struct rb_encoding_entry *ent = &enc_table.list[index];
rb_encoding *encoding;
VALUE list;
if (!valid_encoding_name_p(name)) return -1;
@ -269,8 +270,8 @@ enc_register_at(int index, const char *name, rb_encoding *encoding)
if (!ent->enc) {
ent->enc = xmalloc(sizeof(rb_encoding));
}
if (encoding) {
*ent->enc = *encoding;
if (base_encoding) {
*ent->enc = *base_encoding;
}
else {
memset(ent->enc, 0, sizeof(*ent->enc));
@ -288,7 +289,7 @@ enc_register_at(int index, const char *name, rb_encoding *encoding)
}
static int
enc_register(const char *name, rb_encoding *encoding)
enc_register(const char *name, const rb_encoding *encoding)
{
int index = enc_table.count;
@ -297,11 +298,11 @@ enc_register(const char *name, rb_encoding *encoding)
return enc_register_at(index - 1, name, encoding);
}
static void set_encoding_const(const char *, rb_encoding *);
static void set_encoding_const(const char *, const rb_encoding *);
int rb_enc_registered(const char *name);
int
rb_enc_register(const char *name, rb_encoding *encoding)
rb_enc_register(const char *name, const rb_encoding *encoding)
{
int index = rb_enc_registered(name);
@ -493,7 +494,7 @@ enc_ascii_compatible_p(VALUE enc)
* Returns 1 when the encoding is Unicode series other than UTF-7 else 0.
*/
int
rb_enc_unicode_p(rb_encoding *enc)
rb_enc_unicode_p(const rb_encoding *enc)
{
return ONIGENC_IS_UNICODE(enc);
}
@ -824,7 +825,7 @@ rb_enc_associate_index(VALUE obj, int idx)
}
VALUE
rb_enc_associate(VALUE obj, rb_encoding *enc)
rb_enc_associate(VALUE obj, const rb_encoding *enc)
{
return rb_enc_associate_index(obj, rb_enc_to_index(enc));
}
@ -938,13 +939,13 @@ rb_obj_encoding(VALUE obj)
}
int
rb_enc_fast_mbclen(const char *p, const char *e, rb_encoding *enc)
rb_enc_fast_mbclen(const char *p, const char *e, const rb_encoding *enc)
{
return ONIGENC_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e);
}
int
rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
rb_enc_mbclen(const char *p, const char *e, const rb_encoding *enc)
{
int n = ONIGENC_PRECISE_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e);
if (MBCLEN_CHARFOUND_P(n) && MBCLEN_CHARFOUND_LEN(n) <= e-p)
@ -956,7 +957,7 @@ rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
}
int
rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
rb_enc_precise_mbclen(const char *p, const char *e, const rb_encoding *enc)
{
int n;
if (e <= p)
@ -968,7 +969,7 @@ rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
}
int
rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
rb_enc_ascget(const char *p, const char *e, int *len, const rb_encoding *enc)
{
unsigned int c, l;
if (e <= p)
@ -991,7 +992,7 @@ rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
}
unsigned int
rb_enc_codepoint_len(const char *p, const char *e, int *len_p, rb_encoding *enc)
rb_enc_codepoint_len(const char *p, const char *e, int *len_p, const rb_encoding *enc)
{
int r;
if (e <= p)
@ -1006,13 +1007,13 @@ rb_enc_codepoint_len(const char *p, const char *e, int *len_p, rb_encoding *enc)
#undef rb_enc_codepoint
unsigned int
rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc)
rb_enc_codepoint(const char *p, const char *e, const rb_encoding *enc)
{
return rb_enc_codepoint_len(p, e, 0, enc);
}
int
rb_enc_codelen(int c, rb_encoding *enc)
rb_enc_codelen(int c, const rb_encoding *enc)
{
int n = ONIGENC_CODE_TO_MBCLEN(enc,c);
if (n == 0) {
@ -1023,19 +1024,19 @@ rb_enc_codelen(int c, rb_encoding *enc)
#undef rb_enc_code_to_mbclen
int
rb_enc_code_to_mbclen(int code, rb_encoding *enc)
rb_enc_code_to_mbclen(int code, const rb_encoding *enc)
{
return ONIGENC_CODE_TO_MBCLEN(enc, code);
}
int
rb_enc_toupper(int c, rb_encoding *enc)
rb_enc_toupper(int c, const rb_encoding *enc)
{
return (ONIGENC_IS_ASCII_CODE(c)?ONIGENC_ASCII_CODE_TO_UPPER_CASE(c):(c));
}
int
rb_enc_tolower(int c, rb_encoding *enc)
rb_enc_tolower(int c, const rb_encoding *enc)
{
return (ONIGENC_IS_ASCII_CODE(c)?ONIGENC_ASCII_CODE_TO_LOWER_CASE(c):(c));
}
@ -1543,7 +1544,7 @@ VALUE
rb_locale_charmap(VALUE klass);
static void
set_encoding_const(const char *name, rb_encoding *enc)
set_encoding_const(const char *name, const rb_encoding *enc)
{
VALUE encoding = rb_enc_from_encoding(enc);
char *s = (char *)name;

Просмотреть файл

@ -1891,7 +1891,7 @@ Init_Exception(void)
}
void
rb_enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
rb_enc_raise(const rb_encoding *enc, VALUE exc, const char *fmt, ...)
{
va_list args;
VALUE mesg;

18
file.c
Просмотреть файл

@ -2953,7 +2953,7 @@ skiproot(const char *path, const char *end, rb_encoding *enc)
#define nextdirsep rb_enc_path_next
char *
rb_enc_path_next(const char *s, const char *e, rb_encoding *enc)
rb_enc_path_next(const char *s, const char *e, const rb_encoding *enc)
{
while (s < e && !isdirsep(*s)) {
Inc(s, e, enc);
@ -2967,7 +2967,7 @@ rb_enc_path_next(const char *s, const char *e, rb_encoding *enc)
#define skipprefix(path, end, enc) (path)
#endif
char *
rb_enc_path_skip_prefix(const char *path, const char *end, rb_encoding *enc)
rb_enc_path_skip_prefix(const char *path, const char *end, const rb_encoding *enc)
{
#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER)
#ifdef DOSISH_UNC
@ -3001,7 +3001,7 @@ skipprefixroot(const char *path, const char *end, rb_encoding *enc)
#define strrdirsep rb_enc_path_last_separator
char *
rb_enc_path_last_separator(const char *path, const char *end, rb_encoding *enc)
rb_enc_path_last_separator(const char *path, const char *end, const rb_encoding *enc)
{
char *last = NULL;
while (path < end) {
@ -3019,7 +3019,7 @@ rb_enc_path_last_separator(const char *path, const char *end, rb_encoding *enc)
}
static char *
chompdirsep(const char *path, const char *end, rb_encoding *enc)
chompdirsep(const char *path, const char *end, const rb_encoding *enc)
{
while (path < end) {
if (isdirsep(*path)) {
@ -3035,7 +3035,7 @@ chompdirsep(const char *path, const char *end, rb_encoding *enc)
}
char *
rb_enc_path_end(const char *path, const char *end, rb_encoding *enc)
rb_enc_path_end(const char *path, const char *end, const rb_encoding *enc)
{
if (path < end && isdirsep(*path)) path++;
return chompdirsep(path, end, enc);
@ -3043,7 +3043,7 @@ rb_enc_path_end(const char *path, const char *end, rb_encoding *enc)
#if USE_NTFS
static char *
ntfs_tail(const char *path, const char *end, rb_encoding *enc)
ntfs_tail(const char *path, const char *end, const rb_encoding *enc)
{
while (path < end && *path == '.') path++;
while (path < end && *path != ':') {
@ -3833,7 +3833,7 @@ rb_file_s_realdirpath(int argc, VALUE *argv, VALUE klass)
}
static size_t
rmext(const char *p, long l0, long l1, const char *e, long l2, rb_encoding *enc)
rmext(const char *p, long l0, long l1, const char *e, long l2, const rb_encoding *enc)
{
int len1, len2;
unsigned int c;
@ -3869,7 +3869,7 @@ rmext(const char *p, long l0, long l1, const char *e, long l2, rb_encoding *enc)
}
const char *
ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc)
ruby_enc_find_basename(const char *name, long *baselen, long *alllen, const rb_encoding *enc)
{
const char *p, *q, *e, *end;
#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
@ -4064,7 +4064,7 @@ rb_file_dirname(VALUE fname)
*
*/
const char *
ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
ruby_enc_find_extname(const char *name, long *len, const rb_encoding *enc)
{
const char *p, *e, *end = name + (len ? *len : (long)strlen(name));

Просмотреть файл

@ -85,24 +85,24 @@ rb_encoding* rb_enc_get(VALUE);
rb_encoding* rb_enc_compatible(VALUE,VALUE);
rb_encoding* rb_enc_check(VALUE,VALUE);
VALUE rb_enc_associate_index(VALUE, int);
VALUE rb_enc_associate(VALUE, rb_encoding*);
VALUE rb_enc_associate(VALUE, const rb_encoding*);
void rb_enc_copy(VALUE dst, VALUE src);
VALUE rb_enc_str_new(const char*, long, rb_encoding*);
VALUE rb_enc_str_new_cstr(const char*, rb_encoding*);
VALUE rb_enc_reg_new(const char*, long, rb_encoding*, int);
PRINTF_ARGS(VALUE rb_enc_sprintf(rb_encoding *, const char*, ...), 2, 3);
VALUE rb_enc_vsprintf(rb_encoding *, const char*, va_list);
long rb_enc_strlen(const char*, const char*, rb_encoding*);
char* rb_enc_nth(const char*, const char*, long, rb_encoding*);
VALUE rb_enc_str_new(const char*, long, const rb_encoding*);
VALUE rb_enc_str_new_cstr(const char*, const rb_encoding*);
VALUE rb_enc_reg_new(const char*, long, const rb_encoding*, int);
PRINTF_ARGS(VALUE rb_enc_sprintf(const rb_encoding *, const char*, ...), 2, 3);
VALUE rb_enc_vsprintf(const rb_encoding *, const char*, va_list);
long rb_enc_strlen(const char*, const char*, const rb_encoding*);
char* rb_enc_nth(const char*, const char*, long, const rb_encoding*);
VALUE rb_obj_encoding(VALUE);
VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc);
VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc);
VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, const rb_encoding *enc);
VALUE rb_enc_uint_chr(unsigned int code, const rb_encoding *enc);
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *);
VALUE rb_str_export_to_enc(VALUE, rb_encoding *);
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to);
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts);
VALUE rb_external_str_new_with_enc(const char *ptr, long len, const rb_encoding *);
VALUE rb_str_export_to_enc(VALUE, const rb_encoding *);
VALUE rb_str_conv_enc(VALUE str, const rb_encoding *from, const rb_encoding *to);
VALUE rb_str_conv_enc_opts(VALUE str, const rb_encoding *from, const rb_encoding *to, int ecflags, VALUE ecopts);
#if defined(__GNUC__) && !defined(__PCC__)
#define rb_enc_str_new_cstr(str, enc) __extension__ ( \
@ -113,7 +113,7 @@ VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ec
})
#endif
PRINTF_ARGS(NORETURN(void rb_enc_raise(rb_encoding *, VALUE, const char*, ...)), 3, 4);
PRINTF_ARGS(NORETURN(void rb_enc_raise(const rb_encoding *, VALUE, const char*, ...)), 3, 4);
/* index -> rb_encoding */
rb_encoding* rb_enc_from_index(int idx);
@ -129,13 +129,13 @@ rb_encoding * rb_enc_find(const char *name);
#define rb_enc_mbmaxlen(enc) (enc)->max_enc_len
/* -> mbclen (no error notification: 0 < ret <= e-p, no exception) */
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc);
int rb_enc_mbclen(const char *p, const char *e, const rb_encoding *enc);
/* -> mbclen (only for valid encoding) */
int rb_enc_fast_mbclen(const char *p, const char *e, rb_encoding *enc);
int rb_enc_fast_mbclen(const char *p, const char *e, const rb_encoding *enc);
/* -> chlen, invalid or needmore */
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc);
int rb_enc_precise_mbclen(const char *p, const char *e, const rb_encoding *enc);
#define MBCLEN_CHARFOUND_P(ret) ONIGENC_MBCLEN_CHARFOUND_P(ret)
#define MBCLEN_CHARFOUND_LEN(ret) ONIGENC_MBCLEN_CHARFOUND_LEN(ret)
#define MBCLEN_INVALID_P(ret) ONIGENC_MBCLEN_INVALID_P(ret)
@ -143,22 +143,22 @@ int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc);
#define MBCLEN_NEEDMORE_LEN(ret) ONIGENC_MBCLEN_NEEDMORE_LEN(ret)
/* -> 0x00..0x7f, -1 */
int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc);
int rb_enc_ascget(const char *p, const char *e, int *len, const rb_encoding *enc);
/* -> code (and len) or raise exception */
unsigned int rb_enc_codepoint_len(const char *p, const char *e, int *len, rb_encoding *enc);
unsigned int rb_enc_codepoint_len(const char *p, const char *e, int *len, const rb_encoding *enc);
/* prototype for obsolete function */
unsigned int rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc);
unsigned int rb_enc_codepoint(const char *p, const char *e, const rb_encoding *enc);
/* overriding macro */
#define rb_enc_codepoint(p,e,enc) rb_enc_codepoint_len((p),(e),0,(enc))
#define rb_enc_mbc_to_codepoint(p, e, enc) ONIGENC_MBC_TO_CODE((enc),(UChar*)(p),(UChar*)(e))
/* -> codelen>0 or raise exception */
int rb_enc_codelen(int code, rb_encoding *enc);
int rb_enc_codelen(int code, const rb_encoding *enc);
/* -> 0 for invalid codepoint */
int rb_enc_code_to_mbclen(int code, rb_encoding *enc);
int rb_enc_code_to_mbclen(int code, const rb_encoding *enc);
#define rb_enc_code_to_mbclen(c, enc) ONIGENC_CODE_TO_MBCLEN((enc), (c));
/* code,ptr,encoding -> write buf */
@ -187,19 +187,19 @@ int rb_enc_code_to_mbclen(int code, rb_encoding *enc);
#define rb_enc_asciicompat(enc) (rb_enc_mbminlen(enc)==1 && !rb_enc_dummy_p(enc))
int rb_enc_casefold(char *to, const char *p, const char *e, rb_encoding *enc);
int rb_enc_toupper(int c, rb_encoding *enc);
int rb_enc_tolower(int c, rb_encoding *enc);
ID rb_intern3(const char*, long, rb_encoding*);
ID rb_interned_id_p(const char *, long, rb_encoding *);
int rb_enc_symname_p(const char*, rb_encoding*);
int rb_enc_symname2_p(const char*, long, rb_encoding*);
int rb_enc_casefold(char *to, const char *p, const char *e, const rb_encoding *enc);
int rb_enc_toupper(int c, const rb_encoding *enc);
int rb_enc_tolower(int c, const rb_encoding *enc);
ID rb_intern3(const char*, long, const rb_encoding*);
ID rb_interned_id_p(const char *, long, const rb_encoding *);
int rb_enc_symname_p(const char*, const rb_encoding*);
int rb_enc_symname2_p(const char*, long, const rb_encoding*);
int rb_enc_str_coderange(VALUE);
long rb_str_coderange_scan_restartable(const char*, const char*, rb_encoding*, int*);
long rb_str_coderange_scan_restartable(const char*, const char*, const rb_encoding*, int*);
int rb_enc_str_asciionly_p(VALUE);
#define rb_enc_str_asciicompat_p(str) rb_enc_asciicompat(rb_enc_get(str))
VALUE rb_enc_from_encoding(rb_encoding *enc);
int rb_enc_unicode_p(rb_encoding *enc);
VALUE rb_enc_from_encoding(const rb_encoding *enc);
int rb_enc_unicode_p(const rb_encoding *enc);
rb_encoding *rb_ascii8bit_encoding(void);
rb_encoding *rb_utf8_encoding(void);
rb_encoding *rb_usascii_encoding(void);
@ -223,14 +223,14 @@ VALUE rb_enc_default_internal(void);
void rb_enc_set_default_external(VALUE encoding);
void rb_enc_set_default_internal(VALUE encoding);
VALUE rb_locale_charmap(VALUE klass);
long rb_memsearch(const void*,long,const void*,long,rb_encoding*);
char *rb_enc_path_next(const char *,const char *,rb_encoding*);
char *rb_enc_path_skip_prefix(const char *,const char *,rb_encoding*);
char *rb_enc_path_last_separator(const char *,const char *,rb_encoding*);
char *rb_enc_path_end(const char *,const char *,rb_encoding*);
const char *ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc);
const char *ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc);
ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc);
long rb_memsearch(const void*,long,const void*,long,const rb_encoding*);
char *rb_enc_path_next(const char *,const char *,const rb_encoding*);
char *rb_enc_path_skip_prefix(const char *,const char *,const rb_encoding*);
char *rb_enc_path_last_separator(const char *,const char *,const rb_encoding*);
char *rb_enc_path_end(const char *,const char *,const rb_encoding*);
const char *ruby_enc_find_basename(const char *name, long *baselen, long *alllen, const rb_encoding *enc);
const char *ruby_enc_find_extname(const char *name, long *len, const rb_encoding *enc);
ID rb_check_id_cstr(const char *ptr, long len, const rb_encoding *enc);
RUBY_EXTERN VALUE rb_cEncoding;
#define ENC_DUMMY_FLAG (1<<24)
@ -242,7 +242,7 @@ RUBY_EXTERN VALUE rb_cEncoding;
#define ENC_SET_DUMMY(enc) ((enc)->ruby_encoding_index |= ENC_DUMMY_FLAG)
static inline int
rb_enc_dummy_p(rb_encoding *enc)
rb_enc_dummy_p(const rb_encoding *enc)
{
return ENC_DUMMY_P(enc) != 0;
}

Просмотреть файл

@ -156,29 +156,29 @@ typedef struct {
typedef int (*OnigApplyAllCaseFoldFunc)(OnigCodePoint from, OnigCodePoint* to, int to_len, void* arg);
typedef struct OnigEncodingTypeST {
int (*precise_mbc_enc_len)(const OnigUChar* p,const OnigUChar* e, struct OnigEncodingTypeST* enc);
int (*precise_mbc_enc_len)(const OnigUChar* p,const OnigUChar* e, const struct OnigEncodingTypeST* enc);
const char* name;
int max_enc_len;
int min_enc_len;
int (*is_mbc_newline)(const OnigUChar* p, const OnigUChar* end, struct OnigEncodingTypeST* enc);
OnigCodePoint (*mbc_to_code)(const OnigUChar* p, const OnigUChar* end, struct OnigEncodingTypeST* enc);
int (*code_to_mbclen)(OnigCodePoint code, struct OnigEncodingTypeST* enc);
int (*code_to_mbc)(OnigCodePoint code, OnigUChar *buf, struct OnigEncodingTypeST* enc);
int (*mbc_case_fold)(OnigCaseFoldType flag, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to, struct OnigEncodingTypeST* enc);
int (*apply_all_case_fold)(OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, struct OnigEncodingTypeST* enc);
int (*get_case_fold_codes_by_str)(OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem acs[], struct OnigEncodingTypeST* enc);
int (*property_name_to_ctype)(struct OnigEncodingTypeST* enc, OnigUChar* p, OnigUChar* end);
int (*is_code_ctype)(OnigCodePoint code, OnigCtype ctype, struct OnigEncodingTypeST* enc);
int (*get_ctype_code_range)(OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[], struct OnigEncodingTypeST* enc);
OnigUChar* (*left_adjust_char_head)(const OnigUChar* start, const OnigUChar* p, const OnigUChar* end, struct OnigEncodingTypeST* enc);
int (*is_allowed_reverse_match)(const OnigUChar* p, const OnigUChar* end, struct OnigEncodingTypeST* enc);
int (*is_mbc_newline)(const OnigUChar* p, const OnigUChar* end, const struct OnigEncodingTypeST* enc);
OnigCodePoint (*mbc_to_code)(const OnigUChar* p, const OnigUChar* end, const struct OnigEncodingTypeST* enc);
int (*code_to_mbclen)(OnigCodePoint code, const struct OnigEncodingTypeST* enc);
int (*code_to_mbc)(OnigCodePoint code, OnigUChar *buf, const struct OnigEncodingTypeST* enc);
int (*mbc_case_fold)(OnigCaseFoldType flag, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to, const struct OnigEncodingTypeST* enc);
int (*apply_all_case_fold)(OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, const struct OnigEncodingTypeST* enc);
int (*get_case_fold_codes_by_str)(OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem acs[], const struct OnigEncodingTypeST* enc);
int (*property_name_to_ctype)(const struct OnigEncodingTypeST* enc, OnigUChar* p, OnigUChar* end);
int (*is_code_ctype)(OnigCodePoint code, OnigCtype ctype, const struct OnigEncodingTypeST* enc);
int (*get_ctype_code_range)(OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[], const struct OnigEncodingTypeST* enc);
OnigUChar* (*left_adjust_char_head)(const OnigUChar* start, const OnigUChar* p, const OnigUChar* end, const struct OnigEncodingTypeST* enc);
int (*is_allowed_reverse_match)(const OnigUChar* p, const OnigUChar* end, const struct OnigEncodingTypeST* enc);
int ruby_encoding_index;
unsigned int flags;
} OnigEncodingType;
typedef OnigEncodingType* OnigEncoding;
typedef const OnigEncodingType* OnigEncoding;
ONIG_EXTERN OnigEncodingType OnigEncodingASCII;
ONIG_EXTERN const OnigEncodingType OnigEncodingASCII;
#define ONIG_ENCODING_ASCII (&OnigEncodingASCII)
@ -256,7 +256,7 @@ ONIG_EXTERN OnigEncodingType OnigEncodingASCII;
#define ONIGENC_PRECISE_MBC_ENC_LEN(enc,p,e) (enc)->precise_mbc_enc_len(p,e,enc)
ONIG_EXTERN
int onigenc_mbclen_approximate P_((const OnigUChar* p,const OnigUChar* e, struct OnigEncodingTypeST* enc));
int onigenc_mbclen_approximate P_((const OnigUChar* p,const OnigUChar* e, const struct OnigEncodingTypeST* enc));
#define ONIGENC_MBC_ENC_LEN(enc,p,e) onigenc_mbclen_approximate(p,e,enc)
#define ONIGENC_MBC_MAXLEN(enc) ((enc)->max_enc_len)
@ -807,7 +807,7 @@ void onig_set_syntax_options P_((OnigSyntaxType* syntax, OnigOptionType options)
ONIG_EXTERN
int onig_set_meta_char P_((OnigSyntaxType* syntax, unsigned int what, OnigCodePoint code));
ONIG_EXTERN
void onig_copy_encoding P_((OnigEncoding to, OnigEncoding from));
void onig_copy_encoding P_((OnigEncodingType *to, OnigEncoding from));
ONIG_EXTERN
OnigCaseFoldType onig_get_default_case_fold_flag P_((void));
ONIG_EXTERN

Просмотреть файл

@ -769,7 +769,7 @@ VALUE rb_str_dynamic_intern(VALUE);
ID rb_check_id_without_pindown(VALUE *);
ID rb_sym2id_without_pindown(VALUE);
#ifdef RUBY_ENCODING_H
ID rb_check_id_cstr_without_pindown(const char *, long, rb_encoding *);
ID rb_check_id_cstr_without_pindown(const char *, long, const rb_encoding *);
#endif
ID rb_id_attrget(ID id);
@ -867,7 +867,7 @@ VALUE rb_id_quote_unprintable(ID);
void rb_str_fill_terminator(VALUE str, const int termlen);
VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg);
#ifdef RUBY_ENCODING_H
VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc);
VALUE rb_external_str_with_enc(VALUE str, const rb_encoding *eenc);
#endif
#define STR_NOEMBED FL_USER1
#define STR_SHARED FL_USER2 /* = ELTS_SHARED */

Просмотреть файл

@ -2626,7 +2626,7 @@ rb_int_pred(VALUE num)
#define int_pred rb_int_pred
VALUE
rb_enc_uint_chr(unsigned int code, rb_encoding *enc)
rb_enc_uint_chr(unsigned int code, const rb_encoding *enc)
{
int n;
VALUE str;

18
parse.y
Просмотреть файл

@ -304,7 +304,7 @@ struct parser_params {
#ifdef RIPPER
#define intern_cstr_without_pindown(n,l,en) rb_intern3(n,l,en)
#else
static ID intern_cstr_without_pindown(const char *, long, rb_encoding *);
static ID intern_cstr_without_pindown(const char *, long, const rb_encoding *);
#endif
#define STR_NEW(p,n) rb_enc_str_new((p),(n),current_enc)
@ -10258,7 +10258,7 @@ id_type(ID id)
#ifndef RIPPER
static int
is_special_global_name(const char *m, const char *e, rb_encoding *enc)
is_special_global_name(const char *m, const char *e, const rb_encoding *enc)
{
int mb = 0;
@ -10290,7 +10290,7 @@ rb_symname_p(const char *name)
}
int
rb_enc_symname_p(const char *name, rb_encoding *enc)
rb_enc_symname_p(const char *name, const rb_encoding *enc)
{
return rb_enc_symname2_p(name, strlen(name), enc);
}
@ -10299,7 +10299,7 @@ rb_enc_symname_p(const char *name, rb_encoding *enc)
#define IDSET_ATTRSET_FOR_INTERN (~(~0U<<(1<<ID_SCOPE_SHIFT)) & ~(1U<<ID_ATTRSET))
static int
rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int allowed_attrset)
rb_enc_symname_type(const char *name, long len, const rb_encoding *enc, unsigned int allowed_attrset)
{
const char *m = name;
const char *e = m + len;
@ -10397,7 +10397,7 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
}
int
rb_enc_symname2_p(const char *name, long len, rb_encoding *enc)
rb_enc_symname2_p(const char *name, long len, const rb_encoding *enc)
{
return rb_enc_symname_type(name, len, enc, IDSET_ATTRSET_FOR_SYNTAX) != -1;
}
@ -10507,7 +10507,7 @@ lookup_sym_id(st_data_t str, st_data_t *data)
}
static ID
intern_cstr_without_pindown(const char *name, long len, rb_encoding *enc)
intern_cstr_without_pindown(const char *name, long len, const rb_encoding *enc)
{
st_data_t data;
struct RString fake_str;
@ -10523,7 +10523,7 @@ intern_cstr_without_pindown(const char *name, long len, rb_encoding *enc)
}
ID
rb_intern3(const char *name, long len, rb_encoding *enc)
rb_intern3(const char *name, long len, const rb_encoding *enc)
{
ID id;
@ -11013,7 +11013,7 @@ rb_check_id(volatile VALUE *namep)
}
ID
rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc)
rb_check_id_cstr(const char *ptr, long len, const rb_encoding *enc)
{
ID id;
@ -11080,7 +11080,7 @@ attrsetname_to_attr(VALUE name)
}
ID
rb_check_id_cstr_without_pindown(const char *ptr, long len, rb_encoding *enc)
rb_check_id_cstr_without_pindown(const char *ptr, long len, const rb_encoding *enc)
{
st_data_t id;
struct RString fake_str;

62
re.c
Просмотреть файл

@ -224,7 +224,7 @@ rb_memsearch_qs_utf8(const unsigned char *xs, long m, const unsigned char *ys, l
}
long
rb_memsearch(const void *x0, long m, const void *y0, long n, rb_encoding *enc)
rb_memsearch(const void *x0, long m, const void *y0, long n, const rb_encoding *enc)
{
const unsigned char *x = x0, *y = y0;
@ -333,7 +333,7 @@ rb_reg_check(VALUE re)
static void
rb_reg_expr_str(VALUE str, const char *s, long len,
rb_encoding *enc, rb_encoding *resenc)
const rb_encoding *enc, rb_encoding *resenc)
{
const char *p, *pend;
int cr = ENC_CODERANGE_UNKNOWN;
@ -636,7 +636,7 @@ rb_reg_raise(const char *s, long len, const char *err, VALUE re)
}
static VALUE
rb_enc_reg_error_desc(const char *s, long len, rb_encoding *enc, int options, const char *err)
rb_enc_reg_error_desc(const char *s, long len, const rb_encoding *enc, int options, const char *err)
{
char opts[6];
VALUE desc = rb_str_buf_new2(err);
@ -653,7 +653,7 @@ rb_enc_reg_error_desc(const char *s, long len, rb_encoding *enc, int options, co
}
static void
rb_enc_reg_raise(const char *s, long len, rb_encoding *enc, int options, const char *err)
rb_enc_reg_raise(const char *s, long len, const rb_encoding *enc, int options, const char *err)
{
rb_exc_raise(rb_enc_reg_error_desc(s, len, enc, options, err));
}
@ -826,7 +826,7 @@ onig_new_with_source(regex_t** reg, const UChar* pattern, const UChar* pattern_e
}
static Regexp*
make_regexp(const char *s, long len, rb_encoding *enc, int flags, onig_errmsg_buffer err,
make_regexp(const char *s, long len, const rb_encoding *enc, int flags, onig_errmsg_buffer err,
const char *sourcefile, int sourceline)
{
Regexp *rp;
@ -1288,8 +1288,8 @@ rb_reg_fixed_encoding_p(VALUE re)
}
static VALUE
rb_reg_preprocess(const char *p, const char *end, rb_encoding *enc,
rb_encoding **fixed_enc, onig_errmsg_buffer err);
rb_reg_preprocess(const char *p, const char *end, const rb_encoding *enc,
const rb_encoding **fixed_enc, onig_errmsg_buffer err);
static void
@ -1301,10 +1301,10 @@ reg_enc_error(VALUE re, VALUE str)
rb_enc_name(rb_enc_get(str)));
}
static rb_encoding*
static const rb_encoding*
rb_reg_prepare_enc(VALUE re, VALUE str, int warn)
{
rb_encoding *enc = 0;
const rb_encoding *enc = 0;
if (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN) {
rb_raise(rb_eArgError,
@ -1345,8 +1345,8 @@ rb_reg_prepare_re(VALUE re, VALUE str)
OnigErrorInfo einfo;
const char *pattern;
VALUE unescaped;
rb_encoding *fixed_enc = 0;
rb_encoding *enc = rb_reg_prepare_enc(re, str, 1);
const rb_encoding *fixed_enc = 0;
const rb_encoding *enc = rb_reg_prepare_enc(re, str, 1);
if (reg->enc == enc) return reg;
@ -1379,7 +1379,7 @@ long
rb_reg_adjust_startpos(VALUE re, VALUE str, long pos, int reverse)
{
long range;
rb_encoding *enc;
const rb_encoding *enc;
UChar *p, *string;
enc = rb_reg_prepare_enc(re, str, 0);
@ -2087,8 +2087,8 @@ again:
}
static int
unescape_escaped_nonascii(const char **pp, const char *end, rb_encoding *enc,
VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
unescape_escaped_nonascii(const char **pp, const char *end, const rb_encoding *enc,
VALUE buf, const rb_encoding **encp, onig_errmsg_buffer err)
{
const char *p = *pp;
int chmaxlen = rb_enc_mbmaxlen(enc);
@ -2151,7 +2151,7 @@ check_unicode_range(unsigned long code, onig_errmsg_buffer err)
static int
append_utf8(unsigned long uv,
VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
VALUE buf, const rb_encoding **encp, onig_errmsg_buffer err)
{
if (check_unicode_range(uv, err) != 0)
return -1;
@ -2178,7 +2178,7 @@ append_utf8(unsigned long uv,
static int
unescape_unicode_list(const char **pp, const char *end,
VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
VALUE buf, const rb_encoding **encp, onig_errmsg_buffer err)
{
const char *p = *pp;
int has_unicode = 0;
@ -2215,7 +2215,7 @@ unescape_unicode_list(const char **pp, const char *end,
static int
unescape_unicode_bmp(const char **pp, const char *end,
VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
VALUE buf, const rb_encoding **encp, onig_errmsg_buffer err)
{
const char *p = *pp;
size_t len;
@ -2237,8 +2237,8 @@ unescape_unicode_bmp(const char **pp, const char *end,
}
static int
unescape_nonascii(const char *p, const char *end, rb_encoding *enc,
VALUE buf, rb_encoding **encp, int *has_property,
unescape_nonascii(const char *p, const char *end, const rb_encoding *enc,
VALUE buf, const rb_encoding **encp, int *has_property,
onig_errmsg_buffer err)
{
char c;
@ -2343,8 +2343,8 @@ escape_asis:
}
static VALUE
rb_reg_preprocess(const char *p, const char *end, rb_encoding *enc,
rb_encoding **fixed_enc, onig_errmsg_buffer err)
rb_reg_preprocess(const char *p, const char *end, const rb_encoding *enc,
const rb_encoding **fixed_enc, onig_errmsg_buffer err)
{
VALUE buf;
int has_property = 0;
@ -2375,11 +2375,11 @@ rb_reg_preprocess(const char *p, const char *end, rb_encoding *enc,
VALUE
rb_reg_check_preprocess(VALUE str)
{
rb_encoding *fixed_enc = 0;
const rb_encoding *fixed_enc = 0;
onig_errmsg_buffer err = "";
VALUE buf;
char *p, *end;
rb_encoding *enc;
const rb_encoding *enc;
StringValue(str);
p = RSTRING_PTR(str);
@ -2398,12 +2398,12 @@ rb_reg_check_preprocess(VALUE str)
static VALUE
rb_reg_preprocess_dregexp(VALUE ary, int options)
{
rb_encoding *fixed_enc = 0;
rb_encoding *regexp_enc = 0;
const rb_encoding *fixed_enc = 0;
const rb_encoding *regexp_enc = 0;
onig_errmsg_buffer err = "";
int i;
VALUE result = 0;
rb_encoding *ascii8bit = rb_ascii8bit_encoding();
const rb_encoding *ascii8bit = rb_ascii8bit_encoding();
if (RARRAY_LEN(ary) == 0) {
rb_raise(rb_eArgError, "no arguments given");
@ -2413,7 +2413,7 @@ rb_reg_preprocess_dregexp(VALUE ary, int options)
VALUE str = RARRAY_AREF(ary, i);
VALUE buf;
char *p, *end;
rb_encoding *src_enc;
const rb_encoding *src_enc;
src_enc = rb_enc_get(str);
if (options & ARG_ENCODING_NONE &&
@ -2454,14 +2454,14 @@ rb_reg_preprocess_dregexp(VALUE ary, int options)
}
static int
rb_reg_initialize(VALUE obj, const char *s, long len, rb_encoding *enc,
rb_reg_initialize(VALUE obj, const char *s, long len, const rb_encoding *enc,
int options, onig_errmsg_buffer err,
const char *sourcefile, int sourceline)
{
struct RRegexp *re = RREGEXP(obj);
VALUE unescaped;
rb_encoding *fixed_enc = 0;
rb_encoding *a_enc = rb_ascii8bit_encoding();
const rb_encoding *fixed_enc = 0;
const rb_encoding *a_enc = rb_ascii8bit_encoding();
rb_check_frozen(obj);
if (FL_TEST(obj, REG_LITERAL))
@ -2577,7 +2577,7 @@ rb_reg_new_ary(VALUE ary, int opt)
}
VALUE
rb_enc_reg_new(const char *s, long len, rb_encoding *enc, int options)
rb_enc_reg_new(const char *s, long len, const rb_encoding *enc, int options)
{
VALUE re = rb_reg_alloc();
onig_errmsg_buffer err = "";

Просмотреть файл

@ -52,7 +52,7 @@ onigenc_set_default_encoding(OnigEncoding enc)
}
extern int
onigenc_mbclen_approximate(const OnigUChar* p,const OnigUChar* e, struct OnigEncodingTypeST* enc)
onigenc_mbclen_approximate(const OnigUChar* p,const OnigUChar* e, OnigEncoding enc)
{
int ret = ONIGENC_PRECISE_MBC_ENC_LEN(enc,p,e);
if (ONIGENC_MBCLEN_CHARFOUND_P(ret))

Просмотреть файл

@ -197,9 +197,9 @@ ONIG_EXTERN const unsigned short OnigEncAsciiCtypeTable[];
#ifdef ONIG_ENC_REGISTER
extern int ONIG_ENC_REGISTER(const char *, OnigEncodingType*);
extern int ONIG_ENC_REGISTER(const char *, OnigEncoding);
#define OnigEncodingName(n) encoding_##n
#define OnigEncodingDeclare(n) static OnigEncodingType OnigEncodingName(n)
#define OnigEncodingDeclare(n) static const OnigEncodingType OnigEncodingName(n)
#define OnigEncodingDefine(f,n) \
OnigEncodingDeclare(n); \
void Init_##f(void) { \
@ -209,7 +209,7 @@ extern int ONIG_ENC_REGISTER(const char *, OnigEncodingType*);
OnigEncodingDeclare(n)
#else
#define OnigEncodingName(n) OnigEncoding##n
#define OnigEncodingDeclare(n) OnigEncodingType OnigEncodingName(n)
#define OnigEncodingDeclare(n) const OnigEncodingType OnigEncodingName(n)
#define OnigEncodingDefine(f,n) OnigEncodingDeclare(n)
#endif

Просмотреть файл

@ -4336,7 +4336,7 @@ onig_number_of_capture_histories(regex_t* reg)
}
extern void
onig_copy_encoding(OnigEncoding to, OnigEncoding from)
onig_copy_encoding(OnigEncodingType *to, OnigEncoding from)
{
*to = *from;
}

Просмотреть файл

@ -1192,7 +1192,7 @@ ruby__sfvextra(rb_printf_buffer *fp, size_t valsize, void *valp, long *sz, int s
}
VALUE
rb_enc_vsprintf(rb_encoding *enc, const char *fmt, va_list ap)
rb_enc_vsprintf(const rb_encoding *enc, const char *fmt, va_list ap)
{
rb_printf_buffer_extra buffer;
#define f buffer.base
@ -1225,7 +1225,7 @@ rb_enc_vsprintf(rb_encoding *enc, const char *fmt, va_list ap)
}
VALUE
rb_enc_sprintf(rb_encoding *enc, const char *format, ...)
rb_enc_sprintf(const rb_encoding *enc, const char *format, ...)
{
VALUE result;
va_list ap;

Просмотреть файл

@ -333,7 +333,7 @@ coderange_scan(const char *p, long len, rb_encoding *enc)
}
long
rb_str_coderange_scan_restartable(const char *s, const char *e, rb_encoding *enc, int *cr)
rb_str_coderange_scan_restartable(const char *s, const char *e, const rb_encoding *enc, int *cr)
{
const char *p = s;
@ -544,7 +544,7 @@ rb_usascii_str_new(const char *ptr, long len)
}
VALUE
rb_enc_str_new(const char *ptr, long len, rb_encoding *enc)
rb_enc_str_new(const char *ptr, long len, const rb_encoding *enc)
{
VALUE str;
@ -571,7 +571,7 @@ rb_usascii_str_new_cstr(const char *ptr)
}
VALUE
rb_enc_str_new_cstr(const char *ptr, rb_encoding *enc)
rb_enc_str_new_cstr(const char *ptr, const rb_encoding *enc)
{
must_not_null(ptr);
if (rb_enc_mbminlen(enc) != 1) {
@ -599,7 +599,7 @@ rb_tainted_str_new_cstr(const char *ptr)
}
VALUE
rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
rb_str_conv_enc_opts(VALUE str, const rb_encoding *from, const rb_encoding *to, int ecflags, VALUE ecopts)
{
extern VALUE rb_cEncodingConverter;
rb_econv_t *ec;
@ -672,13 +672,13 @@ rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags,
}
VALUE
rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
rb_str_conv_enc(VALUE str, const rb_encoding *from, const rb_encoding *to)
{
return rb_str_conv_enc_opts(str, from, to, 0, Qnil);
}
VALUE
rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *eenc)
rb_external_str_new_with_enc(const char *ptr, long len, const rb_encoding *eenc)
{
VALUE str;
@ -687,7 +687,7 @@ rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *eenc)
}
VALUE
rb_external_str_with_enc(VALUE str, rb_encoding *eenc)
rb_external_str_with_enc(VALUE str, const rb_encoding *eenc)
{
if (eenc == rb_usascii_encoding() &&
rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
@ -747,7 +747,7 @@ rb_str_export_locale(VALUE str)
}
VALUE
rb_str_export_to_enc(VALUE str, rb_encoding *enc)
rb_str_export_to_enc(VALUE str, const rb_encoding *enc)
{
return rb_str_conv_enc(str, STR_ENC_GET(str), enc);
}
@ -1097,7 +1097,7 @@ count_utf8_lead_bytes_with_word(const uintptr_t *s)
#endif
static inline long
enc_strlen(const char *p, const char *e, rb_encoding *enc, int cr)
enc_strlen(const char *p, const char *e, const rb_encoding *enc, int cr)
{
long c;
const char *q;
@ -1168,7 +1168,7 @@ enc_strlen(const char *p, const char *e, rb_encoding *enc, int cr)
}
long
rb_enc_strlen(const char *p, const char *e, rb_encoding *enc)
rb_enc_strlen(const char *p, const char *e, const rb_encoding *enc)
{
return enc_strlen(p, e, enc, ENC_CODERANGE_UNKNOWN);
}
@ -1635,7 +1635,7 @@ rb_str_s_try_convert(VALUE dummy, VALUE str)
}
static char*
str_nth_len(const char *p, const char *e, long *nthp, rb_encoding *enc)
str_nth_len(const char *p, const char *e, long *nthp, const rb_encoding *enc)
{
long nth = *nthp;
if (rb_enc_mbmaxlen(enc) == 1) {
@ -1685,7 +1685,7 @@ str_nth_len(const char *p, const char *e, long *nthp, rb_encoding *enc)
}
char*
rb_enc_nth(const char *p, const char *e, long nth, rb_encoding *enc)
rb_enc_nth(const char *p, const char *e, long nth, const rb_encoding *enc)
{
return str_nth_len(p, e, &nth, enc);
}
@ -2152,7 +2152,7 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
}
VALUE
rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *ptr_enc)
rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, const rb_encoding *ptr_enc)
{
return rb_enc_cr_str_buf_cat(str, ptr, len,
rb_enc_to_index(ptr_enc), ENC_CODERANGE_UNKNOWN, NULL);