History
+2004/03/04: Version 2.2.4
+
+2004/03/04: [impl] (thanks Moriyoshi Koizumi)
+ fix many warning in Win32 VC++ with /W3 option.
+
+2004/03/02: Version 2.2.3
+
+2004/03/02: [bug] (thanks Isao Sonobe)
+ return invalid capture region value if capture history
+ is used. (OP_MEMORY_END_PUSH_REC bug)
+ ex. /\\g<p>(?@<p>\\(\\g<s>\\)){0}(?<s>(?:\\g<p>)*|){0}/
+ .match("((())())")
+2004/03/02: [impl] add :nodoc: to onig_stat_print() for RDoc.
+2004/03/02: [impl] don't use ONIG_SOURCE_IS_WRAPPED.
+
2004/02/27: Version 2.2.2
2004/02/27: [impl] fix the position of onig_stat_print().
2004/02/26: Version 2.2.1
-2004/02/26: [bug] invalid definition at onig_error_code_to_str()
+2004/02/26: [bug] [bugs.php.net:#26677] (thanks behrens)
+ invalid definition at onig_error_code_to_str()
in the case of NOT HAVE_STDARG_PROTOTYPES.
2004/02/25: Version 2.2.0
{
UChar *p = buf;
- if ((code & 0xff0000) != 0) *p++ = ((code >> 16) & 0xff);
- if ((code & 0xff00) != 0) *p++ = ((code >> 8) & 0xff);
- *p++ = (code & 0xff);
+ if ((code & 0xff0000) != 0) *p++ = (UChar )(((code >> 16) & 0xff));
+ if ((code & 0xff00) != 0) *p++ = (UChar )(((code >> 8) & 0xff));
+ *p++ = (UChar )(code & 0xff);
#if 1
if (enc_len(ONIG_ENCODING_EUC_JP, buf[0]) != (p - buf))
{
UChar *p = buf;
- if ((code & 0xff00) != 0) *p++ = ((code >> 8) & 0xff);
- *p++ = (code & 0xff);
+ if ((code & 0xff00) != 0) *p++ = (UChar )(((code >> 8) & 0xff));
+ *p++ = (UChar )(code & 0xff);
#if 0
if (enc_len(ONIG_ENCODING_SJIS, buf[0]) != (p - buf))
static int
utf8_code_to_mbc(OnigCodePoint code, UChar *buf)
{
-#define UTF8_TRAILS(code, shift) ((((code) >> (shift)) & 0x3f) | 0x80)
-#define UTF8_TRAIL0(code) (((code) & 0x3f) | 0x80)
+#define UTF8_TRAILS(code, shift) (UChar )((((code) >> (shift)) & 0x3f) | 0x80)
+#define UTF8_TRAIL0(code) (UChar )(((code) & 0x3f) | 0x80)
if ((code & 0xffffff80) == 0) {
- *buf = code;
+ *buf = (UChar )code;
return 1;
}
else {
UChar *p = buf;
if ((code & 0xfffff800) == 0) {
- *p++ = ((code>>6)& 0x1f) | 0xc0;
+ *p++ = (UChar )(((code>>6)& 0x1f) | 0xc0);
}
else if ((code & 0xffff0000) == 0) {
- *p++ = ((code>>12) & 0x0f) | 0xe0;
+ *p++ = (UChar )(((code>>12) & 0x0f) | 0xe0);
*p++ = UTF8_TRAILS(code, 6);
}
else if ((code & 0xffe00000) == 0) {
- *p++ = ((code>>18) & 0x07) | 0xf0;
+ *p++ = (UChar )(((code>>18) & 0x07) | 0xf0);
*p++ = UTF8_TRAILS(code, 12);
*p++ = UTF8_TRAILS(code, 6);
}
else if ((code & 0xfc000000) == 0) {
- *p++ = ((code>>24) & 0x03) | 0xf8;
+ *p++ = (UChar )(((code>>24) & 0x03) | 0xf8);
*p++ = UTF8_TRAILS(code, 18);
*p++ = UTF8_TRAILS(code, 12);
*p++ = UTF8_TRAILS(code, 6);
}
else if ((code & 0x80000000) == 0) {
- *p++ = ((code>>30) & 0x01) | 0xfc;
+ *p++ = (UChar )(((code>>30) & 0x01) | 0xfc);
*p++ = UTF8_TRAILS(code, 24);
*p++ = UTF8_TRAILS(code, 18);
*p++ = UTF8_TRAILS(code, 12);
#define ONIGURUMA
#define ONIGURUMA_VERSION_MAJOR 2
#define ONIGURUMA_VERSION_MINOR 2
-#define ONIGURUMA_VERSION_TEENY 2
+#define ONIGURUMA_VERSION_TEENY 4
#ifndef P_
#if defined(__STDC__) || defined(_WIN32)
r = compile_tree_empty_check(qn->target, reg, empty_info);
if (r) return r;
r = add_opcode_rel_addr(reg, OP_JUMP,
- -(mod_tlen + SIZE_OP_JUMP + SIZE_OP_PUSH_OR_JUMP_EXACT1));
+ -(mod_tlen + (int )SIZE_OP_JUMP + (int )SIZE_OP_PUSH_OR_JUMP_EXACT1));
}
else if (IS_NOT_NULL(qn->next_head_exact)) {
r = add_opcode_rel_addr(reg, OP_PUSH_IF_PEEK_NEXT,
r = compile_tree_empty_check(qn->target, reg, empty_info);
if (r) return r;
r = add_opcode_rel_addr(reg, OP_JUMP,
- -(mod_tlen + SIZE_OP_JUMP + SIZE_OP_PUSH_IF_PEEK_NEXT));
+ -(mod_tlen + (int )SIZE_OP_JUMP + (int )SIZE_OP_PUSH_IF_PEEK_NEXT));
}
else {
r = add_opcode_rel_addr(reg, OP_PUSH, mod_tlen + SIZE_OP_JUMP);
r = compile_tree_empty_check(qn->target, reg, empty_info);
if (r) return r;
r = add_opcode_rel_addr(reg, OP_JUMP,
- -(mod_tlen + SIZE_OP_JUMP + SIZE_OP_PUSH));
+ -(mod_tlen + (int )SIZE_OP_JUMP + (int )SIZE_OP_PUSH));
}
}
else {
if (r) return r;
r = compile_tree_empty_check(qn->target, reg, empty_info);
if (r) return r;
- r = add_opcode_rel_addr(reg, OP_PUSH, -(mod_tlen + SIZE_OP_PUSH));
+ r = add_opcode_rel_addr(reg, OP_PUSH, -(mod_tlen + (int )SIZE_OP_PUSH));
}
}
else if (qn->upper == 0 && qn->is_refered != 0) { /* /(?<n>..){0}/ */
r = add_opcode(reg, OP_POP);
if (r) return r;
r = add_opcode_rel_addr(reg, OP_JUMP,
- -(SIZE_OP_PUSH + len + SIZE_OP_POP + SIZE_OP_JUMP));
+ -((int )SIZE_OP_PUSH + len + (int )SIZE_OP_POP + (int )SIZE_OP_JUMP));
}
else {
r = add_opcode(reg, OP_PUSH_STOP_BT);
if (to->expr.len > 0) {
if (add->len.max > 0) {
- if (to->expr.len > add->len.max)
+ if (to->expr.len > (int )add->len.max)
to->expr.len = add->len.max;
if (to->expr.mmd.max == 0)
extern int
onigenc_single_byte_code_to_mbc(OnigCodePoint code, UChar *buf)
{
- *buf = (code & 0xff);
+ *buf = (UChar )(code & 0xff);
return 1;
}
UChar *p = buf;
if ((code & 0xff00) != 0) {
- *p++ = ((code >> 8) & 0xff);
+ *p++ = (UChar )((code >> 8) & 0xff);
}
- *p++ = (code & 0xff);
+ *p++ = (UChar )(code & 0xff);
#if 1
if (enc_len(enc, buf[0]) != (p - buf))
UChar *p = buf;
if ((code & 0xff000000) != 0) {
- *p++ = ((code >> 24) & 0xff);
+ *p++ = (UChar )((code >> 24) & 0xff);
}
if ((code & 0xff0000) != 0) {
- *p++ = ((code >> 16) & 0xff);
+ *p++ = (UChar )((code >> 16) & 0xff);
}
if ((code & 0xff00) != 0) {
- *p++ = ((code >> 8) & 0xff);
+ *p++ = (UChar )((code >> 8) & 0xff);
}
- *p++ = (code & 0xff);
+ *p++ = (UChar )(code & 0xff);
#if 1
if (enc_len(enc, buf[0]) != (p - buf))
#ifndef REGENC_H
#define REGENC_H
-#ifndef ONIG_SOURCE_IS_WRAPPED
+#ifndef RUBY_PLATFORM
#include "config.h"
#endif
-
#include "oniguruma.h"
#ifndef NULL
/*
* Source wrapper for Ruby.
*/
-#define ONIG_SOURCE_IS_WRAPPED
-
#include "regint.h"
#include "regex.h"
} while (0)
#ifdef RUBY_PLATFORM
+/*
+ * :nodoc:
+ */
static VALUE onig_stat_print()
{
onig_print_statistics(stderr);
MaxStackDepth = 0;
#ifdef RUBY_PLATFORM
- ONIG_RUBY_DEFINE_GLOBAL_FUNCTION("onig_stat_print", onig_stat_print, 0);
+ rb_define_global_function("onig_stat_print", onig_stat_print, 0);
#endif
}
onig_is_in_code_range(UChar* p, OnigCodePoint code)
{
OnigCodePoint n, *data;
- int low, high, x;
+ OnigCodePoint low, high, x;
GET_CODE_POINT(n, p);
data = (OnigCodePoint* )p;
#ifdef USE_SUBEXP_CALL
case OP_MEMORY_END_PUSH_REC: STAT_OP_IN(OP_MEMORY_END_PUSH_REC);
GET_MEMNUM_INC(mem, p);
+ STACK_GET_MEM_START(mem, stkp); /* should be before push mem-end. */
STACK_PUSH_MEM_END(mem, s);
- STACK_GET_MEM_START(mem, stkp);
mem_start_stk[mem] = GET_STACK_INDEX(stkp);
STAT_OP_OUT;
continue;
GET_MEMNUM_INC(mem, p);
mem_end_stk[mem] = (StackIndex )((void* )s);
STACK_GET_MEM_START(mem, stkp);
- mem_start_stk[mem] = GET_STACK_INDEX(stkp);
+
+ if (BIT_STATUS_AT(reg->bt_mem_start, mem))
+ mem_start_stk[mem] = GET_STACK_INDEX(stkp);
+ else
+ mem_start_stk[mem] = (StackIndex )((void* )stkp->u.mem.pstr);
+
STACK_PUSH_MEM_END_MARK(mem);
STAT_OP_OUT;
continue;
semi_end = end;
end_buf:
- if (semi_end - str < reg->anchor_dmin)
+ if ((OnigDistance )(semi_end - str) < reg->anchor_dmin)
goto mismatch_no_msa;
if (range > start) {
- if (semi_end - start > reg->anchor_dmax) {
+ if ((OnigDistance )(semi_end - start) > reg->anchor_dmax) {
start = semi_end - reg->anchor_dmax;
if (start < end)
start = onigenc_get_right_adjust_char_head(reg->enc, str, start);
start = onigenc_get_prev_char_head(reg->enc, str, end);
}
}
- if (semi_end - (range - 1) < reg->anchor_dmin) {
+ if ((OnigDistance )(semi_end - (range - 1)) < reg->anchor_dmin) {
range = semi_end - reg->anchor_dmin + 1;
}
if (start >= range) goto mismatch_no_msa;
}
else {
- if (semi_end - range > reg->anchor_dmax) {
+ if ((OnigDistance )(semi_end - range) > reg->anchor_dmax) {
range = semi_end - reg->anchor_dmax;
}
- if (semi_end - start < reg->anchor_dmin) {
+ if ((OnigDistance )(semi_end - start) < reg->anchor_dmin) {
start = semi_end - reg->anchor_dmin;
start = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, str, start);
if (range > start) goto mismatch_no_msa;
#endif
#endif
-#define ONIG_RUBY_DEFINE_GLOBAL_FUNCTION(s,f,n) \
- rb_define_global_function(s, f, n)
#endif /* else NOT_RUBY */
#define THREAD_PASS_LIMIT_COUNT 10
} while (0)
#define BBUF_EXPAND(buf,low) do{\
- do { (buf)->alloc *= 2; } while ((buf)->alloc < low);\
+ do { (buf)->alloc *= 2; } while ((buf)->alloc < (unsigned int )low);\
(buf)->p = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
} while (0)
#define BBUF_ENSURE_SIZE(buf,size) do{\
- int new_alloc = (buf)->alloc;\
- while (new_alloc < (size)) { new_alloc *= 2; }\
+ unsigned int new_alloc = (buf)->alloc;\
+ while (new_alloc < (unsigned int )(size)) { new_alloc *= 2; }\
if ((buf)->alloc != new_alloc) {\
(buf)->p = (UChar* )xrealloc((buf)->p, new_alloc);\
if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
#define BBUF_WRITE(buf,pos,bytes,n) do{\
int used = (pos) + (n);\
- if ((buf)->alloc < used) BBUF_EXPAND((buf),used);\
+ if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
xmemcpy((buf)->p + (pos), (bytes), (n));\
- if ((buf)->used < used) (buf)->used = used;\
+ if ((buf)->used < (unsigned int )used) (buf)->used = used;\
} while (0)
#define BBUF_WRITE1(buf,pos,byte) do{\
int used = (pos) + 1;\
- if ((buf)->alloc < used) BBUF_EXPAND((buf),used);\
+ if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
(buf)->p[(pos)] = (byte);\
- if ((buf)->used < used) (buf)->used = used;\
+ if ((buf)->used < (unsigned int )used) (buf)->used = used;\
} while (0)
#define BBUF_ADD(buf,bytes,n) BBUF_WRITE((buf),(buf)->used,(bytes),(n))
/* from < to */
#define BBUF_MOVE_RIGHT(buf,from,to,n) do {\
- if ((to) + (n) > (buf)->alloc) BBUF_EXPAND((buf),(to) + (n));\
+ if ((unsigned int )((to)+(n)) > (buf)->alloc) BBUF_EXPAND((buf),(to) + (n));\
xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
- if ((to) + (n) > (buf)->used) (buf)->used = (to) + (n);\
+ if ((unsigned int )((to)+(n)) > (buf)->used) (buf)->used = (to) + (n);\
} while (0)
/* from > to */
typedef struct {
- OnigCodePoint esc;
- OnigCodePoint anychar;
- OnigCodePoint anytime;
- OnigCodePoint zero_or_one_time;
- OnigCodePoint one_or_more_time;
- OnigCodePoint anychar_anytime;
+ UChar esc;
+ UChar anychar;
+ UChar anytime;
+ UChar zero_or_one_time;
+ UChar one_or_more_time;
+ UChar anychar_anytime;
} OnigMetaCharTableType;
extern OnigMetaCharTableType OnigMetaCharTable;
to = data[(high - 1)*2 + 1];
}
- if (inc_n != 0 && high < n) {
+ if (inc_n != 0 && (OnigCodePoint )high < n) {
int from_pos = SIZE_CODE_POINT * (1 + high * 2);
int to_pos = SIZE_CODE_POINT * (1 + (low + 1) * 2);
int size = (n - high) * 2 * SIZE_CODE_POINT;
static int
or_code_range_buf(BBuf* bbuf1, int not1, BBuf* bbuf2, int not2, BBuf** pbuf)
{
- int i, r;
- OnigCodePoint n1, *data1;
+ int r;
+ OnigCodePoint i, n1, *data1;
OnigCodePoint from, to;
*pbuf = (BBuf* )NULL;
static int
and_code_range_buf(BBuf* bbuf1, int not1, BBuf* bbuf2, int not2, BBuf** pbuf)
{
- int i, j, r;
- OnigCodePoint n1, n2, *data1, *data2;
+ int r;
+ OnigCodePoint i, j, n1, n2, *data1, *data2;
OnigCodePoint from, to, from1, to1, from2, to2;
*pbuf = (BBuf* )NULL;
add_ctype_to_cc_by_list(CClassNode* cc, int ctype, int not,
OnigEncoding enc)
{
- int i, j, r, nsb, nmb;
+ int i, r, nsb, nmb;
OnigCodePointRange *sbr, *mbr;
+ OnigCodePoint j;
r = ONIGENC_GET_CTYPE_CODE_RANGE(enc, ctype, &nsb, &nmb, &sbr, &mbr);
if (r != 0) return r;
}
else if (r == ONIG_MISMATCH) {
r = REG_NOMATCH;
- for (i = 0; i < nmatch; i++)
+ for (i = 0; i < (int )nmatch; i++)
pmatch[i].rm_so = pmatch[i].rm_eo = ONIG_REGION_NOTPOS;
}
else {