[前][次][番号順一覧][スレッド一覧]

ruby-changes:7811

From: akr <ko1@a...>
Date: Sun, 14 Sep 2008 03:23:03 +0900 (JST)
Subject: [ruby-changes:7811] Ruby:r19332 (trunk): * include/ruby/oniguruma.h (onigenc_get_prev_char_head): add end

akr	2008-09-14 03:22:04 +0900 (Sun, 14 Sep 2008)

  New Revision: 19332

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19332

  Log:
    * include/ruby/oniguruma.h (onigenc_get_prev_char_head): add end
      argument.
    
    * include/ruby/encoding.h (rb_enc_prev_char): ditto.
    
    * regenc.c (onigenc_get_prev_char_head): add end argument.
    
    * regparse.c: follow the interface change.
    
    * regexec.c: ditto.
    
    * string.c: ditto.
    
    * parse.y: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/encoding.h
    trunk/include/ruby/oniguruma.h
    trunk/parse.y
    trunk/regenc.c
    trunk/regexec.c
    trunk/regparse.c
    trunk/string.c

Index: regparse.c
===================================================================
--- regparse.c	(revision 19331)
+++ regparse.c	(revision 19332)
@@ -1540,7 +1540,7 @@
   Node* n = NULL_NODE;
 
   if (sn->end > sn->s) {
-    p = onigenc_get_prev_char_head(enc, sn->s, sn->end);
+    p = onigenc_get_prev_char_head(enc, sn->s, sn->end, sn->end);
     if (p && p > sn->s) { /* can be splitted. */
       n = node_new_str(p, sn->end);
       if ((sn->flag & NSTR_RAW) != 0)
Index: include/ruby/encoding.h
===================================================================
--- include/ruby/encoding.h	(revision 19331)
+++ include/ruby/encoding.h	(revision 19332)
@@ -129,9 +129,9 @@
 /* code,ptr,encoding -> write buf */
 #define rb_enc_mbcput(c,buf,enc) ONIGENC_CODE_TO_MBC(enc,c,(UChar*)(buf))
 
-/* ptr, ptr, encoding -> prev_char */
-#define rb_enc_prev_char(s,p,enc) (char *)onigenc_get_prev_char_head(enc,(UChar*)(s),(UChar*)(p))
-/* ptr, ptr, encoding -> next_char */
+/* start, ptr, end, encoding -> prev_char */
+#define rb_enc_prev_char(s,p,e,enc) (char *)onigenc_get_prev_char_head(enc,(UChar*)(s),(UChar*)(p),(UChar*)(e))
+/* start, ptr, end, encoding -> next_char */
 #define rb_enc_left_char_head(s,p,enc) (char *)onigenc_get_left_adjust_char_head(enc,(UChar*)(s),(UChar*)(p))
 #define rb_enc_right_char_head(s,p,e,enc) (char *)onigenc_get_right_adjust_char_head(enc,(UChar*)(s),(UChar*)(p),(UChar*)(e))
 
Index: include/ruby/oniguruma.h
===================================================================
--- include/ruby/oniguruma.h	(revision 19331)
+++ include/ruby/oniguruma.h	(revision 19332)
@@ -305,7 +305,7 @@
 ONIG_EXTERN
 OnigUChar* onigenc_get_right_adjust_char_head_with_prev P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, const OnigUChar* end, const OnigUChar** prev));
 ONIG_EXTERN
-OnigUChar* onigenc_get_prev_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
+OnigUChar* onigenc_get_prev_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, const OnigUChar* end));
 ONIG_EXTERN
 OnigUChar* onigenc_get_left_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
 ONIG_EXTERN
Index: regenc.c
===================================================================
--- regenc.c	(revision 19331)
+++ regenc.c	(revision 19332)
@@ -88,7 +88,7 @@
 }
 
 extern UChar*
-onigenc_get_prev_char_head(OnigEncoding enc, const UChar* start, const UChar* s)
+onigenc_get_prev_char_head(OnigEncoding enc, const UChar* start, const UChar* s, const UChar* end)
 {
   if (s <= start)
     return (UChar* )NULL;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 19331)
+++ ChangeLog	(revision 19332)
@@ -1,3 +1,20 @@
+Sun Sep 14 03:20:03 2008  Tanaka Akira  <akr@f...>
+
+	* include/ruby/oniguruma.h (onigenc_get_prev_char_head): add end
+	  argument.
+
+	* include/ruby/encoding.h (rb_enc_prev_char): ditto.
+
+	* regenc.c (onigenc_get_prev_char_head): add end argument.
+
+	* regparse.c: follow the interface change.
+
+	* regexec.c: ditto.
+
+	* string.c: ditto.
+
+	* parse.y: ditto.
+
 Sun Sep 14 02:04:28 2008  Tanaka Akira  <akr@f...>
 
 	* include/ruby/oniguruma.h
Index: string.c
===================================================================
--- string.c	(revision 19331)
+++ string.c	(revision 19332)
@@ -1291,10 +1291,10 @@
 	if (len > -beg) len = -beg;
 	if (-beg * rb_enc_mbmaxlen(enc) < RSTRING_LEN(str) / 8) {
 	    beg = -beg;
-	    while (beg-- > len && (e = rb_enc_prev_char(s, e, enc)) != 0);
+	    while (beg-- > len && (e = rb_enc_prev_char(s, e, e, enc)) != 0);
 	    p = e;
 	    if (!p) return Qnil;
-	    while (len-- > 0 && (p = rb_enc_prev_char(s, p, enc)) != 0);
+	    while (len-- > 0 && (p = rb_enc_prev_char(s, p, e, enc)) != 0);
 	    if (!p) return Qnil;
 	    len = e - p;
 	    goto sub;
@@ -2572,7 +2572,7 @@
     sbeg = RSTRING_PTR(str);
     s = e = sbeg + RSTRING_LEN(str);
 
-    while ((s = rb_enc_prev_char(sbeg, s, enc)) != 0) {
+    while ((s = rb_enc_prev_char(sbeg, s, e, enc)) != 0) {
 	if (neighbor == NEIGHBOR_NOT_CHAR && last_alnum) {
 	    if (ISALPHA(*last_alnum) ? ISDIGIT(*s) :
 		ISDIGIT(*last_alnum) ? ISALPHA(*s) : 0) {
@@ -2597,7 +2597,7 @@
     }
     if (c == -1) {		/* str contains no alnum */
 	s = e;
-	while ((s = rb_enc_prev_char(sbeg, s, enc)) != 0) {
+	while ((s = rb_enc_prev_char(sbeg, s, e, enc)) != 0) {
             enum neighbor_char neighbor;
             if ((l = rb_enc_precise_mbclen(s, e, enc)) <= 0) continue;
             neighbor = enc_succ_char(s, l, enc);
@@ -5336,10 +5336,10 @@
     beg = RSTRING_PTR(str);
     end = beg + RSTRING_LEN(str);
     if (beg > end) return 0;
-    p = rb_enc_prev_char(beg, end, enc);
+    p = rb_enc_prev_char(beg, end, end, enc);
     if (!p) return 0;
     if (p > beg && rb_enc_codepoint(p, end, enc) == '\n') {
-	p2 = rb_enc_prev_char(beg, p, enc);
+	p2 = rb_enc_prev_char(beg, p, end, enc);
 	if (p2 && rb_enc_codepoint(p2, end, enc) == '\r') p = p2;
     }
     return p - beg;
Index: parse.y
===================================================================
--- parse.y	(revision 19331)
+++ parse.y	(revision 19332)
@@ -4877,11 +4877,11 @@
 
 	if (len > max_line_margin * 2 + 10) {
 	    if (lex_p - p > max_line_margin) {
-		p = rb_enc_prev_char(p, lex_p - max_line_margin, rb_enc_get(lex_lastline));
+		p = rb_enc_prev_char(p, lex_p - max_line_margin, pe, rb_enc_get(lex_lastline));
 		pre = "...";
 	    }
 	    if (pe - lex_p > max_line_margin) {
-		pe = rb_enc_prev_char(lex_p, lex_p + max_line_margin, rb_enc_get(lex_lastline));
+		pe = rb_enc_prev_char(lex_p, lex_p + max_line_margin, pe, rb_enc_get(lex_lastline));
 		post = "...";
 	    }
 	    len = pe - p;
Index: regexec.c
===================================================================
--- regexec.c	(revision 19331)
+++ regexec.c	(revision 19332)
@@ -2649,7 +2649,7 @@
       GET_LENGTH_INC(tlen, p);
       s = (UChar* )ONIGENC_STEP_BACK(encode, str, s, (int )tlen);
       if (IS_NULL(s)) goto fail;
-      sprev = (UChar* )onigenc_get_prev_char_head(encode, str, s);
+      sprev = (UChar* )onigenc_get_prev_char_head(encode, str, s, end);
       MOP_OUT;
       continue;
       break;
@@ -2667,7 +2667,7 @@
       else {
 	STACK_PUSH_LOOK_BEHIND_NOT(p + addr, s, sprev);
 	s = q;
-	sprev = (UChar* )onigenc_get_prev_char_head(encode, str, s);
+	sprev = (UChar* )onigenc_get_prev_char_head(encode, str, s, end);
       }
       MOP_OUT;
       continue;
@@ -2857,7 +2857,7 @@
       if (t == target_end)
 	return s;
     }
-    s = (UChar* )onigenc_get_prev_char_head(enc, adjust_text, s);
+    s = (UChar* )onigenc_get_prev_char_head(enc, adjust_text, s, text_end);
   }
 
   return (UChar* )NULL;
@@ -2883,7 +2883,7 @@
                              target, target_end, s, text_end))
       return s;
 
-    s = (UChar* )onigenc_get_prev_char_head(enc, adjust_text, s);
+    s = (UChar* )onigenc_get_prev_char_head(enc, adjust_text, s, text_end);
   }
 
   return (UChar* )NULL;
@@ -3053,14 +3053,14 @@
 static UChar*
 map_search_backward(OnigEncoding enc, UChar map[],
 		    const UChar* text, const UChar* adjust_text,
-		    const UChar* text_start)
+		    const UChar* text_start, const UChar* text_end)
 {
   const UChar *s = text_start;
 
   while (s >= text) {
     if (map[*s]) return (UChar* )s;
 
-    s = onigenc_get_prev_char_head(enc, adjust_text, s);
+    s = onigenc_get_prev_char_head(enc, adjust_text, s, text_end);
   }
   return (UChar* )NULL;
 }
@@ -3117,7 +3117,7 @@
     r = 0;
 
   if (r == 0) {
-    prev = (UChar* )onigenc_get_prev_char_head(reg->enc, str, at);
+    prev = (UChar* )onigenc_get_prev_char_head(reg->enc, str, at, end);
     r = match_at(reg, str, end,
 #ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
 		 end,
@@ -3190,7 +3190,7 @@
       case ANCHOR_BEGIN_LINE:
 	if (!ON_STR_BEGIN(p)) {
 	  prev = onigenc_get_prev_char_head(reg->enc,
-					    (pprev ? pprev : str), p);
+					    (pprev ? pprev : str), p, end);
 	  if (!ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end))
 	    goto retry_gate;
 	}
@@ -3219,10 +3219,10 @@
       *low = p;
       if (low_prev) {
 	if (*low > s)
-	  *low_prev = onigenc_get_prev_char_head(reg->enc, s, p);
+	  *low_prev = onigenc_get_prev_char_head(reg->enc, s, p, end);
 	else
 	  *low_prev = onigenc_get_prev_char_head(reg->enc,
-						 (pprev ? pprev : str), p);
+						 (pprev ? pprev : str), p, end);
       }
     }
     else {
@@ -3233,12 +3233,12 @@
 							      *low, end, (const UChar** )low_prev);
 	  if (low_prev && IS_NULL(*low_prev))
 	    *low_prev = onigenc_get_prev_char_head(reg->enc,
-						   (pprev ? pprev : s), *low);
+						   (pprev ? pprev : s), *low, end);
 	}
 	else {
 	  if (low_prev)
 	    *low_prev = onigenc_get_prev_char_head(reg->enc,
-					       (pprev ? pprev : str), *low);
+					       (pprev ? pprev : str), *low, end);
 	}
       }
     }
@@ -3301,7 +3301,7 @@
     break;
 
   case ONIG_OPTIMIZE_MAP:
-    p = map_search_backward(reg->enc, reg->map, range, adjrange, p);
+    p = map_search_backward(reg->enc, reg->map, range, adjrange, p, end);
     break;
   }
 
@@ -3312,7 +3312,7 @@
       switch (reg->sub_anchor) {
       case ANCHOR_BEGIN_LINE:
 	if (!ON_STR_BEGIN(p)) {
-	  prev = onigenc_get_prev_char_head(reg->enc, str, p);
+	  prev = onigenc_get_prev_char_head(reg->enc, str, p, end);
 	  if (!ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end)) {
 	    p = prev;
 	    goto retry;
@@ -3336,7 +3336,7 @@
               && ! ONIGENC_IS_MBC_CRNL(reg->enc, p, end)
 #endif
                 ) {
-	  p = onigenc_get_prev_char_head(reg->enc, adjrange, p);
+	  p = onigenc_get_prev_char_head(reg->enc, adjrange, p, end);
 	  if (IS_NULL(p)) goto fail;
 	  goto retry;
 	}
@@ -3508,7 +3508,7 @@
 	  if (start < end)
 	    start = onigenc_get_right_adjust_char_head(reg->enc, str, start, end);
 	  else { /* match with empty at end */
-	    start = onigenc_get_prev_char_head(reg->enc, str, end);
+	    start = onigenc_get_prev_char_head(reg->enc, str, end, end);
 	  }
 	}
 	if ((OnigDistance )(max_semi_end - (range - 1)) < reg->anchor_dmin) {
@@ -3594,7 +3594,7 @@
   s = (UChar* )start;
   if (range > start) {   /* forward search */
     if (s > str)
-      prev = onigenc_get_prev_char_head(reg->enc, str, s);
+      prev = onigenc_get_prev_char_head(reg->enc, str, s, end);
     else
       prev = (UChar* )NULL;
 
@@ -3687,7 +3687,7 @@
 	    s = high;
 
 	  while (s >= low) {
-	    prev = onigenc_get_prev_char_head(reg->enc, str, s);
+	    prev = onigenc_get_prev_char_head(reg->enc, str, s, end);
 	    MATCH_AND_RETURN_CHECK(orig_start);
 	    s = prev;
 	  }
@@ -3715,7 +3715,7 @@
     }
 
     do {
-      prev = onigenc_get_prev_char_head(reg->enc, str, s);
+      prev = onigenc_get_prev_char_head(reg->enc, str, s, end);
       MATCH_AND_RETURN_CHECK(orig_start);
       s = prev;
     } while (s >= range);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]