зеркало из https://github.com/github/ruby.git
* regcomp.c, regint.h: fixed PLATFORM_UNALIGNED_WORD_ACCESS problem ([ruby-dev:24802] and [ruby-core:3733])
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
39eac7ded8
Коммит
7eac88ecd5
|
@ -1,3 +1,8 @@
|
|||
Sun Nov 28 12:05:48 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
|
||||
|
||||
* regcomp.c, regint.h: fixed PLATFORM_UNALIGNED_WORD_ACCESS
|
||||
problem ([ruby-dev:24802] and [ruby-core:3733])
|
||||
|
||||
Sat Nov 27 21:43:39 2004 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* io.c: avoid data lost with nonblocking fd and
|
||||
|
|
47
regcomp.c
47
regcomp.c
|
@ -158,13 +158,7 @@ add_rel_addr(regex_t* reg, int addr)
|
|||
{
|
||||
RelAddrType ra = (RelAddrType )addr;
|
||||
|
||||
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
|
||||
BBUF_ADD(reg, &ra, SIZE_RELADDR);
|
||||
#else
|
||||
UChar buf[SERIALIZE_BUFSIZE];
|
||||
SERIALIZE_RELADDR(ra, buf);
|
||||
BBUF_ADD(reg, buf, SIZE_RELADDR);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -173,13 +167,7 @@ add_abs_addr(regex_t* reg, int addr)
|
|||
{
|
||||
AbsAddrType ra = (AbsAddrType )addr;
|
||||
|
||||
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
|
||||
BBUF_ADD(reg, &ra, SIZE_ABSADDR);
|
||||
#else
|
||||
UChar buf[SERIALIZE_BUFSIZE];
|
||||
SERIALIZE_ABSADDR(ra, buf);
|
||||
BBUF_ADD(reg, buf, SIZE_ABSADDR);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -188,13 +176,7 @@ add_length(regex_t* reg, int len)
|
|||
{
|
||||
LengthType l = (LengthType )len;
|
||||
|
||||
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
|
||||
BBUF_ADD(reg, &l, SIZE_LENGTH);
|
||||
#else
|
||||
UChar buf[SERIALIZE_BUFSIZE];
|
||||
SERIALIZE_LENGTH(l, buf);
|
||||
BBUF_ADD(reg, buf, SIZE_LENGTH);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -203,13 +185,7 @@ add_mem_num(regex_t* reg, int num)
|
|||
{
|
||||
MemNumType n = (MemNumType )num;
|
||||
|
||||
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
|
||||
BBUF_ADD(reg, &n, SIZE_MEMNUM);
|
||||
#else
|
||||
UChar buf[SERIALIZE_BUFSIZE];
|
||||
SERIALIZE_MEMNUM(n, buf);
|
||||
BBUF_ADD(reg, buf, SIZE_MEMNUM);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -219,13 +195,7 @@ add_repeat_num(regex_t* reg, int num)
|
|||
{
|
||||
RepeatNumType n = (RepeatNumType )num;
|
||||
|
||||
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
|
||||
BBUF_ADD(reg, &n, SIZE_REPEATNUM);
|
||||
#else
|
||||
UChar buf[SERIALIZE_BUFSIZE];
|
||||
SERIALIZE_REPEATNUM(n, buf);
|
||||
BBUF_ADD(reg, buf, SIZE_REPEATNUM);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -233,13 +203,7 @@ add_repeat_num(regex_t* reg, int num)
|
|||
static int
|
||||
add_option(regex_t* reg, OnigOptionType option)
|
||||
{
|
||||
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
|
||||
BBUF_ADD(reg, &option, SIZE_OPTION);
|
||||
#else
|
||||
UChar buf[SERIALIZE_BUFSIZE];
|
||||
SERIALIZE_OPTION(option, buf);
|
||||
BBUF_ADD(reg, buf, SIZE_OPTION);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1638,9 +1602,6 @@ unset_addr_list_fix(UnsetAddrList* uslist, regex_t* reg)
|
|||
int i, offset;
|
||||
EffectNode* en;
|
||||
AbsAddrType addr;
|
||||
#ifndef PLATFORM_UNALIGNED_WORD_ACCESS
|
||||
UChar buf[SERIALIZE_BUFSIZE];
|
||||
#endif
|
||||
|
||||
for (i = 0; i < uslist->num; i++) {
|
||||
en = &(NEFFECT(uslist->us[i].target));
|
||||
|
@ -1648,12 +1609,7 @@ unset_addr_list_fix(UnsetAddrList* uslist, regex_t* reg)
|
|||
addr = en->call_addr;
|
||||
offset = uslist->us[i].offset;
|
||||
|
||||
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
|
||||
BBUF_WRITE(reg, offset, &addr, SIZE_ABSADDR);
|
||||
#else
|
||||
SERIALIZE_ABSADDR(addr, buf);
|
||||
BBUF_WRITE(reg, offset, buf, SIZE_ABSADDR);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -5125,8 +5081,7 @@ onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar** nextp,
|
|||
case ARG_NON:
|
||||
break;
|
||||
case ARG_RELADDR:
|
||||
addr = *((RelAddrType* )bp);
|
||||
bp += SIZE_RELADDR;
|
||||
GET_RELADDR_INC(addr, bp);
|
||||
fprintf(f, ":(%d)", addr);
|
||||
break;
|
||||
case ARG_ABSADDR:
|
||||
|
|
58
regint.h
58
regint.h
|
@ -580,57 +580,31 @@ typedef short int MemNumType;
|
|||
#define SIZE_OPTION sizeof(OnigOptionType)
|
||||
#define SIZE_CODE_POINT sizeof(OnigCodePoint)
|
||||
|
||||
|
||||
|
||||
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
|
||||
#define GET_RELADDR_INC(addr,p) do{\
|
||||
addr = *((RelAddrType* )(p));\
|
||||
(p) += SIZE_RELADDR;\
|
||||
} while(0)
|
||||
|
||||
#define GET_ABSADDR_INC(addr,p) do{\
|
||||
addr = *((AbsAddrType* )(p));\
|
||||
(p) += SIZE_ABSADDR;\
|
||||
} while(0)
|
||||
|
||||
#define GET_LENGTH_INC(len,p) do{\
|
||||
len = *((LengthType* )(p));\
|
||||
(p) += SIZE_LENGTH;\
|
||||
} while(0)
|
||||
|
||||
#define GET_MEMNUM_INC(num,p) do{\
|
||||
num = *((MemNumType* )(p));\
|
||||
(p) += SIZE_MEMNUM;\
|
||||
} while(0)
|
||||
|
||||
#define GET_REPEATNUM_INC(num,p) do{\
|
||||
num = *((RepeatNumType* )(p));\
|
||||
(p) += SIZE_REPEATNUM;\
|
||||
} while(0)
|
||||
|
||||
#define GET_OPTION_INC(option,p) do{\
|
||||
option = *((OnigOptionType* )(p));\
|
||||
(p) += SIZE_OPTION;\
|
||||
#define PLATFORM_GET_INC(val,p,type) do{\
|
||||
val = *(type* )p;\
|
||||
(p) += sizeof(type);\
|
||||
} while(0)
|
||||
|
||||
#else
|
||||
|
||||
#define GET_RELADDR_INC(addr,p) GET_SHORT_INC(addr,p)
|
||||
#define GET_ABSADDR_INC(addr,p) GET_SHORT_INC(addr,p)
|
||||
#define GET_LENGTH_INC(len,p) GET_SHORT_INC(len,p)
|
||||
#define GET_MEMNUM_INC(num,p) GET_SHORT_INC(num,p)
|
||||
#define GET_REPEATNUM_INC(num,p) GET_INT_INC(num,p)
|
||||
#define GET_OPTION_INC(option,p) GET_UINT_INC(option,p)
|
||||
|
||||
#define SERIALIZE_RELADDR(addr,p) SERIALIZE_SHORT(addr,p)
|
||||
#define SERIALIZE_ABSADDR(addr,p) SERIALIZE_SHORT(addr,p)
|
||||
#define SERIALIZE_LENGTH(len,p) SERIALIZE_SHORT(len,p)
|
||||
#define SERIALIZE_MEMNUM(num,p) SERIALIZE_SHORT(num,p)
|
||||
#define SERIALIZE_REPEATNUM(num,p) SERIALIZE_INT(num,p)
|
||||
#define SERIALIZE_OPTION(option,p) SERIALIZE_UINT(option,p)
|
||||
|
||||
#define SERIALIZE_BUFSIZE SIZEOF_INT
|
||||
#define PLATFORM_GET_INC(val,p,type) do{\
|
||||
xmemcpy(&val, (p), sizeof(type));\
|
||||
(p) += sizeof(type);\
|
||||
} while(0)
|
||||
|
||||
#endif /* PLATFORM_UNALIGNED_WORD_ACCESS */
|
||||
|
||||
#define GET_RELADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, RelAddrType)
|
||||
#define GET_ABSADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, AbsAddrType)
|
||||
#define GET_LENGTH_INC(len,p) PLATFORM_GET_INC(len, p, LengthType)
|
||||
#define GET_MEMNUM_INC(num,p) PLATFORM_GET_INC(num, p, MemNumType)
|
||||
#define GET_REPEATNUM_INC(num,p) PLATFORM_GET_INC(num, p, RepeatNumType)
|
||||
#define GET_OPTION_INC(option,p) PLATFORM_GET_INC(option, p, OnigOptionType)
|
||||
|
||||
/* code point's address must be aligned address. */
|
||||
#define GET_CODE_POINT(code,p) code = *((OnigCodePoint* )(p))
|
||||
#define GET_BYTE_INC(byte,p) do{\
|
||||
|
|
Загрузка…
Ссылка в новой задаче