if (enclen(ONIG_ENCODING_EUC_JP, buf) != (p - buf))
return ONIGERR_INVALID_CODE_POINT_VALUE;
#endif
- return p - buf;
+ return (int )(p - buf);
}
static int
property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end)
{
struct PropertyNameCtype* pc;
- int len = end - p;
+ int len = (int )(end - p);
char q[32];
if (len < sizeof(q) - 1) {
static UChar*
str_dup(UChar* s, UChar* end)
{
- int len = end - s;
+ int len = (int )(end - s);
if (len > 0) {
UChar* r = (UChar* )xmalloc(len + 1);
if (NODE_TYPE(a) == NODE_STRING) {
StrNode* sn = STR_(a);
if (sn->capa == 0) {
- int len = sn->end - sn->s;
+ int len = (int )(sn->end - sn->s);
sn->s = sn->buf;
sn->end = sn->s + len;
}
if (NODE_TYPE(b) == NODE_STRING) {
StrNode* sn = STR_(b);
if (sn->capa == 0) {
- int len = sn->end - sn->s;
+ int len = (int )(sn->end - sn->s);
sn->s = sn->buf;
sn->end = sn->s + len;
}
if (sn->end <= sn->s)
return 0;
- return add_compile_string_length(sn->s, 1 /* sb */, sn->end - sn->s, reg, 0);
+ return add_compile_string_length(sn->s, 1 /* sb */, (int )(sn->end - sn->s),
+ reg, 0);
}
static int
if (sn->end <= sn->s)
return 0;
- return add_compile_string(sn->s, 1 /* sb */, sn->end - sn->s, reg, 0);
+ return add_compile_string(sn->s, 1 /* sb */, (int )(sn->end - sn->s), reg, 0);
}
static int
case NODE_STRING:
{
StrNode* sn = STR_(node);
- len = sn->end - sn->s;
+ len = (int )(sn->end - sn->s);
}
break;
break;
case ENCLOSURE_IF_ELSE:
{
- int elen;
+ OnigLen elen;
len = tree_min_len(NODE_BODY(node), env);
if (IS_NOT_NULL(en->te.Then))
case NODE_STRING:
{
StrNode* sn = STR_(node);
- len = sn->end - sn->s;
+ len = (OnigLen )(sn->end - sn->s);
}
break;
break;
case ENCLOSURE_IF_ELSE:
{
- int tlen, elen;
+ OnigLen tlen, elen;
len = tree_max_len(NODE_BODY(node), env);
if (IS_NOT_NULL(en->te.Then)) {
StrNode* sn = STR_(node);
end = sn->end;
- sbuf_size = (end - sn->s) * 2;
+ sbuf_size = (int )(end - sn->s) * 2;
sbuf = (UChar* )xmalloc(sbuf_size);
CHECK_NULL_RETURN_MEMERR(sbuf);
ebuf = sbuf + sbuf_size;
{
int i, len;
- len = end - s;
+ len = (int )(end - s);
if (len < ONIG_CHAR_TABLE_SIZE) {
for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) skip[i] = len;
case NODE_STRING:
{
StrNode* sn = STR_(node);
- int slen = sn->end - sn->s;
+ int slen = (int )(sn->end - sn->s);
int is_raw = NODE_STRING_IS_RAW(node);
if (! NODE_STRING_IS_AMBIG(node)) {
reg->dmax = e->mmd.max;
if (reg->dmin != INFINITE_LEN) {
- reg->threshold_len = reg->dmin + (reg->exact_end - reg->exact);
+ reg->threshold_len = reg->dmin + (int )(reg->exact_end - reg->exact);
}
return 0;
#endif
if (reg->alloc == 0) {
- init_size = (pattern_end - pattern) * 2;
+ init_size = (int )(pattern_end - pattern) * 2;
if (init_size <= 0) init_size = COMPILE_INIT_SIZE;
r = BB_INIT(reg, init_size);
if (r != 0) goto end;
regenc.c - Oniguruma (regular expression library)
**********************************************************************/
/*-
- * Copyright (c) 2002-2016 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2002-2017 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
if (enclen(enc, buf) != (p - buf))
return ONIGERR_INVALID_CODE_POINT_VALUE;
#endif
- return p - buf;
+ return (int )(p - buf);
}
extern int
if (enclen(enc, buf) != (p - buf))
return ONIGERR_INVALID_CODE_POINT_VALUE;
#endif
- return p - buf;
+ return (int )(p - buf);
}
extern int
*is_over = ((p < end) ? 1 : 0);
}
else {
- len = MIN((end - s), buf_size);
+ len = MIN((int )(end - s), buf_size);
xmemcpy(buf, s, (size_t )len);
*is_over = ((buf_size < (end - s)) ? 1 : 0);
}
}
}
*p = '\0';
- len = p - s;
+ len = (int )(p - s);
break;
default:
n = xvsnprintf((char* )buf, bufsize, (const char* )fmt, args);
va_end(args);
- need = (pat_end - pat) * 4 + 4;
+ need = (int )(pat_end - pat) * 4 + 4;
if (n + need < bufsize) {
xstrcat((char* )buf, ": /", bufsize);
#define STACK_SAVE do{\
- msa->stack_n = stk_end - stk_base;\
+ msa->stack_n = (int )(stk_end - stk_base);\
if (is_alloca != 0) {\
size_t size = sizeof(StackIndex) * msa->ptr_num \
+ sizeof(StackType) * msa->stack_n;\
stk_end = *arg_stk_end;
stk = *arg_stk;
- n = stk_end - stk_base;
+ n = (unsigned int )(stk_end - stk_base);
size = sizeof(StackIndex) * msa->ptr_num + sizeof(StackType) * n;
n *= 2;
new_size = sizeof(StackIndex) * msa->ptr_num + sizeof(StackType) * n;
}
alloc_base = new_alloc_base;
- used = stk - stk_base;
+ used = (int )(stk - stk_base);
*arg_alloc_base = alloc_base;
*arg_stk_base = (StackType* )(alloc_base
+ (sizeof(StackIndex) * msa->ptr_num));
}
#define STACK_ENSURE(n) do {\
- if (stk_end - stk < (n)) {\
+ if ((int )(stk_end - stk) < (n)) {\
int r = stack_double(is_alloca, &alloc_base, &stk_base, &stk_end, &stk, msa);\
if (r != 0) { STACK_SAVE; return r; } \
is_alloca = 0;\
sbegin = s;
switch (*p++) {
case OP_END: MOP_IN(OP_END);
- n = s - sstart;
+ n = (int )(s - sstart);
if (n > best_len) {
OnigRegion* region;
#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
if (IS_POSIX_REGION(msa->options)) {
posix_regmatch_t* rmt = (posix_regmatch_t* )region;
- rmt[0].rm_so = keep - str;
- rmt[0].rm_eo = s - str;
+ rmt[0].rm_so = (regoff_t )(keep - str);
+ rmt[0].rm_eo = (regoff_t )(s - str);
for (i = 1; i <= num_mem; i++) {
if (mem_end_stk[i] != INVALID_STACK_INDEX) {
if (MEM_STATUS_AT(reg->bt_mem_start, i))
- rmt[i].rm_so = STACK_AT(mem_start_stk[i])->u.mem.pstr - str;
+ rmt[i].rm_so = (regoff_t )(STACK_AT(mem_start_stk[i])->u.mem.pstr - str);
else
- rmt[i].rm_so = (UChar* )((void* )(mem_start_stk[i])) - str;
+ rmt[i].rm_so = (regoff_t )((UChar* )((void* )(mem_start_stk[i])) - str);
- rmt[i].rm_eo = (MEM_STATUS_AT(reg->bt_mem_end, i)
- ? STACK_AT(mem_end_stk[i])->u.mem.pstr
- : (UChar* )((void* )mem_end_stk[i])) - str;
+ rmt[i].rm_eo = (regoff_t )((MEM_STATUS_AT(reg->bt_mem_end, i)
+ ? STACK_AT(mem_end_stk[i])->u.mem.pstr
+ : (UChar* )((void* )mem_end_stk[i]))
+ - str);
}
else {
rmt[i].rm_so = rmt[i].rm_eo = ONIG_REGION_NOTPOS;
}
else {
#endif /* USE_POSIX_API_REGION_OPTION */
- region->beg[0] = keep - str;
- region->end[0] = s - str;
+ region->beg[0] = (int )(keep - str);
+ region->end[0] = (int )(s - str);
for (i = 1; i <= num_mem; i++) {
if (mem_end_stk[i] != INVALID_STACK_INDEX) {
if (MEM_STATUS_AT(reg->bt_mem_start, i))
- region->beg[i] = STACK_AT(mem_start_stk[i])->u.mem.pstr - str;
+ region->beg[i] = (int )(STACK_AT(mem_start_stk[i])->u.mem.pstr - str);
else
- region->beg[i] = (UChar* )((void* )mem_start_stk[i]) - str;
+ region->beg[i] = (int )((UChar* )((void* )mem_start_stk[i]) - str);
- region->end[i] = (MEM_STATUS_AT(reg->bt_mem_end, i)
- ? STACK_AT(mem_end_stk[i])->u.mem.pstr
- : (UChar* )((void* )mem_end_stk[i])) - str;
+ region->end[i] = (int )((MEM_STATUS_AT(reg->bt_mem_end, i)
+ ? STACK_AT(mem_end_stk[i])->u.mem.pstr
+ : (UChar* )((void* )mem_end_stk[i])) - str);
}
else {
region->beg[i] = region->end[i] = ONIG_REGION_NOTPOS;
}
node->group = 0;
- node->beg = keep - str;
- node->end = s - str;
+ node->beg = (int )(keep - str);
+ node->end = (int )(s - str);
stkp = stk_base;
r = make_capture_history_tree(region->history_root, &stkp,
pend = (MEM_STATUS_AT(reg->bt_mem_end, mem)
? STACK_AT(mem_end_stk[mem])->u.mem.pstr
: (UChar* )((void* )mem_end_stk[mem]));
- n = pend - pstart;
+ n = (int )(pend - pstart);
DATA_ENSURE(n);
sprev = s;
STRING_CMP(pstart, s, n);
pend = (MEM_STATUS_AT(reg->bt_mem_end, mem)
? STACK_AT(mem_end_stk[mem])->u.mem.pstr
: (UChar* )((void* )mem_end_stk[mem]));
- n = pend - pstart;
+ n = (int )(pend - pstart);
DATA_ENSURE(n);
sprev = s;
STRING_CMP_IC(case_fold_flag, pstart, &s, n);
pend = (MEM_STATUS_AT(reg->bt_mem_end, mem)
? STACK_AT(mem_end_stk[mem])->u.mem.pstr
: (UChar* )((void* )mem_end_stk[mem]));
- n = pend - pstart;
+ n = (int )(pend - pstart);
DATA_ENSURE(n);
sprev = s;
swork = s;
pend = (MEM_STATUS_AT(reg->bt_mem_end, mem)
? STACK_AT(mem_end_stk[mem])->u.mem.pstr
: (UChar* )((void* )mem_end_stk[mem]));
- n = pend - pstart;
+ n = (int )(pend - pstart);
DATA_ENSURE(n);
sprev = s;
swork = s;
#endif
tail = target_end - 1;
- tlen1 = tail - target;
+ tlen1 = (int )(tail - target);
end = text_range;
if (end + tlen1 > text_end)
end = text_end - tlen1;
match:
MATCH_ARG_FREE(msa);
- return s - str;
+ return (int )(s - str);
}
extern int
conv_encoding(OnigEncoding from, OnigEncoding to, const UChar* s, const UChar* end,
UChar** conv, UChar** conv_end)
{
- int len = end - s;
+ int len = (int )(end - s);
if (to == ONIG_ENCODING_UTF16_BE) {
if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) {
reggnu.c - Oniguruma (regular expression library)
**********************************************************************/
/*-
- * Copyright (c) 2002-2008 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2002-2017 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
else {
p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, (UChar* )string, s);
}
- return p - (UChar* )string;
+ return (int )(p - (UChar* )string);
}
return startpos;
extern void
onig_strcpy(UChar* dest, const UChar* src, const UChar* end)
{
- int len = end - src;
+ int len = (int )(end - src);
if (len > 0) {
xmemcpy(dest, src, len);
dest[len] = (UChar )0;
int slen, term_len, i;
UChar *r;
- slen = end - s;
+ slen = (int )(end - s);
term_len = ONIGENC_MBC_MINLEN(enc);
r = (UChar* )xmalloc(slen + term_len);
(HashDataType )e);
if (r < 0) return r;
- e->name_len = name_end - name;
+ e->name_len = (int )(name_end - name);
e->back_num = 0;
e->back_alloc = 0;
e->back_refs = (int* )NULL;
extern int
onig_node_str_cat(Node* node, const UChar* s, const UChar* end)
{
- int addlen = end - s;
+ int addlen = (int )(end - s);
if (addlen > 0) {
- int len = STR_(node)->end - STR_(node)->s;
+ int len = (int )(STR_(node)->end - STR_(node)->s);
if (STR_(node)->capa > 0 || (len + addlen > NODE_STRING_BUF_SIZE - 1)) {
UChar* p;
case ONIGENC_CTYPE_ASCII:
case ONIGENC_CTYPE_ALNUM:
if (not != 0) {
- for (c = 0; c < limit; c++) {
+ for (c = 0; c < (int )limit; c++) {
if (! ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))
BITSET_SET_BIT(cc->bs, c);
}
ADD_ALL_MULTI_BYTE_RANGE(enc, cc->mbuf);
}
else {
- for (c = 0; c < limit; c++) {
+ for (c = 0; c < (int )limit; c++) {
if (ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))
BITSET_SET_BIT(cc->bs, c);
}
case ONIGENC_CTYPE_PRINT:
case ONIGENC_CTYPE_WORD:
if (not != 0) {
- for (c = 0; c < limit; c++) {
+ for (c = 0; c < (int )limit; c++) {
if (ONIGENC_CODE_TO_MBCLEN(enc, c) > 0 /* check invalid code point */
&& ! ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))
BITSET_SET_BIT(cc->bs, c);
}
}
else {
- for (c = 0; c < limit; c++) {
+ for (c = 0; c < (int )limit; c++) {
if (ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))
BITSET_SET_BIT(cc->bs, c);
}
#define STRING_AMBIG (1<<1)
#define STRING_DONT_GET_OPT_INFO (1<<2)
-#define NODE_STRING_LEN(node) ((node)->u.str.end - (node)->u.str.s)
+#define NODE_STRING_LEN(node) (int )((node)->u.str.end - (node)->u.str.s)
#define NODE_STRING_SET_RAW(node) (node)->u.str.flag |= STRING_RAW
#define NODE_STRING_CLEAR_RAW(node) (node)->u.str.flag &= ~STRING_RAW
#define NODE_STRING_SET_AMBIG(node) (node)->u.str.flag |= STRING_AMBIG
if (ONIGENC_MBC_MINLEN(enc) == 1) { \
UChar* tmps = (UChar* )(s); \
while (*tmps != 0) tmps++; \
- len = tmps - (UChar* )(s); \
+ len = (int )(tmps - (UChar* )(s));\
} \
else { \
len = onigenc_str_bytelen_null(enc, (UChar* )s); \
sjis.c - Oniguruma (regular expression library)
**********************************************************************/
/*-
- * Copyright (c) 2002-2016 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2002-2017 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
if (enclen(ONIG_ENCODING_SJIS, buf) != (p - buf))
return REGERR_INVALID_CODE_POINT_VALUE;
#endif
- return p - buf;
+ return (int )(p - buf);
}
static int
property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end)
{
struct PropertyNameCtype* pc;
- int len = end - p;
+ int len = (int )(end - p);
char q[32];
if (len < sizeof(q) - 1) {
if (UserDefinedPropertyNum >= USER_DEFINED_PROPERTY_MAX_NUM)
return ONIGERR_TOO_MANY_USER_DEFINED_OBJECTS;
- len = strlen(name);
+ len = (int )strlen(name);
if (len >= PROPERTY_NAME_MAX_SIZE)
return ONIGERR_TOO_LONG_PROPERTY_NAME;
utf8.c - Oniguruma (regular expression library)
**********************************************************************/
/*-
- * Copyright (c) 2002-2016 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2002-2017 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
OnigCodePoint n;
len = mbc_enc_len(p);
- if (len > end - p) len = end - p;
+ if (len > (int )(end - p)) len = (int )(end - p);
c = *p++;
if (len > 1) {
}
*p++ = UTF8_TRAIL0(code);
- return p - buf;
+ return (int )(p - buf);
}
}