summaryrefslogtreecommitdiff
path: root/regex.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-03 07:17:01 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-03 07:17:01 +0000
commit34cc6247c67e8f99ef5927c43dbb9435853943f0 (patch)
tree14eee8b6a45566a8abc2cc5210050958638ab527 /regex.c
parent2062a9149e8a4232b08520200b18a393782e87dd (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_6@16788 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 fa04871c1b..a7a831286e 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;
}