summaryrefslogtreecommitdiff
path: root/regex.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-03 07:15:05 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-03 07:15:05 +0000
commitdcdffdb03b0b1a1e405f2fd3c4d8a0c10a11920e (patch)
tree998108f3adaf0ed87dffc2b853a209c116081375 /regex.c
parent4a8544e2be759553f7e73c6304056e86557023f9 (diff)
merge revision(s) 13513:
* parse.y (yyerror): limit error message length. [ruby-dev:31848] * regex.c (re_mbc_startpos): separated from re_adjust_startpos. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_5@16786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/regex.c b/regex.c
index ae0694b764..e721097e32 100644
--- a/regex.c
+++ b/regex.c
@@ -3109,6 +3109,28 @@ re_compile_fastmap(bufp)
/* adjust startpos value to the position between characters. */
int
+re_mbc_startpos(string, size, startpos, range)
+ const char *string;
+ int size, startpos, range;
+{
+ int i = mbc_startpos(string, startpos);
+
+ if (i < startpos) {
+ if (range > 0) {
+ startpos = i + mbclen(string[i]);
+ }
+ else {
+ int len = mbclen(string[i]);
+ if (i + len <= startpos)
+ startpos = i + len;
+ else
+ startpos = i;
+ }
+ }
+ return startpos;
+}
+
+int
re_adjust_startpos(bufp, string, size, startpos, range)
struct re_pattern_buffer *bufp;
const char *string;
@@ -3121,20 +3143,7 @@ re_adjust_startpos(bufp, string, size, startpos, range)
/* Adjust startpos for mbc string */
if (current_mbctype && startpos>0 && !(bufp->options&RE_OPTIMIZE_BMATCH)) {
- int i = mbc_startpos(string, startpos);
-
- if (i < startpos) {
- if (range > 0) {
- startpos = i + mbclen(string[i]);
- }
- else {
- int len = mbclen(string[i]);
- if (i + len <= startpos)
- startpos = i + len;
- else
- startpos = i;
- }
- }
+ startpos = re_mbc_startpos(string, size, startpos, range);
}
return startpos;
}