S_reguni should return its length
Andy Lester [Sun, 14 May 2006 09:46:32 +0000 (04:46 -0500)]
Message-ID: <20060514144632.GA20935@petdance.com>

p4raw-id: //depot/perl@28194

embed.fnc
embed.h
proto.h
regcomp.c

index 98b980f..bab0ae5 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -1284,7 +1284,7 @@ Es        |regnode*|reg           |NN struct RExC_state_t *state|I32 paren|NN I32 *flagp
 Es     |regnode*|reganode      |NN struct RExC_state_t *state|U8 op|U32 arg
 Es     |regnode*|regatom       |NN struct RExC_state_t *state|NN I32 *flagp
 Es     |regnode*|regbranch     |NN struct RExC_state_t *state|NN I32 *flagp|I32 first
-Es     |void   |reguni         |NN const struct RExC_state_t *state|UV uv|NN char *s|NN STRLEN *lenp
+Es     |STRLEN |reguni         |NN const struct RExC_state_t *state|UV uv|NN char *s
 Es     |regnode*|regclass      |NN struct RExC_state_t *state
 ERsn   |I32    |regcurly       |NN const char *
 Es     |regnode*|reg_node      |NN struct RExC_state_t *state|U8 op
diff --git a/embed.h b/embed.h
index 9f2d04f..69a920b 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define reganode(a,b,c)                S_reganode(aTHX_ a,b,c)
 #define regatom(a,b)           S_regatom(aTHX_ a,b)
 #define regbranch(a,b,c)       S_regbranch(aTHX_ a,b,c)
-#define reguni(a,b,c,d)                S_reguni(aTHX_ a,b,c,d)
+#define reguni(a,b,c)          S_reguni(aTHX_ a,b,c)
 #define regclass(a)            S_regclass(aTHX_ a)
 #define regcurly               S_regcurly
 #define reg_node(a,b)          S_reg_node(aTHX_ a,b)
diff --git a/proto.h b/proto.h
index 07ee72d..80063e1 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -3516,10 +3516,9 @@ STATIC regnode*  S_regbranch(pTHX_ struct RExC_state_t *state, I32 *flagp, I32 fi
                        __attribute__nonnull__(pTHX_1)
                        __attribute__nonnull__(pTHX_2);
 
-STATIC void    S_reguni(pTHX_ const struct RExC_state_t *state, UV uv, char *s, STRLEN *lenp)
+STATIC STRLEN  S_reguni(pTHX_ const struct RExC_state_t *state, UV uv, char *s)
                        __attribute__nonnull__(pTHX_1)
-                       __attribute__nonnull__(pTHX_3)
-                       __attribute__nonnull__(pTHX_4);
+                       __attribute__nonnull__(pTHX_3);
 
 STATIC regnode*        S_regclass(pTHX_ struct RExC_state_t *state)
                        __attribute__nonnull__(pTHX_1);
index e98fcf9..9dc5395 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -4277,8 +4277,6 @@ tryagain:
                    if (len)
                        p = oldp;
                    else if (UTF) {
-                        STRLEN unilen;
-
                         if (FOLD) {
                              /* Emit all the Unicode characters. */
                              STRLEN numlen;
@@ -4287,7 +4285,7 @@ tryagain:
                                   foldlen -= numlen) {
                                   ender = utf8_to_uvchr(foldbuf, &numlen);
                                   if (numlen > 0) {
-                                       reguni(pRExC_state, ender, s, &unilen);
+                                       const STRLEN unilen = reguni(pRExC_state, ender, s);
                                        s       += unilen;
                                        len     += unilen;
                                        /* In EBCDIC the numlen
@@ -4301,7 +4299,7 @@ tryagain:
                              }
                         }
                         else {
-                             reguni(pRExC_state, ender, s, &unilen);
+                             const STRLEN unilen = reguni(pRExC_state, ender, s);
                              if (unilen > 0) {
                                   s   += unilen;
                                   len += unilen;
@@ -4315,8 +4313,6 @@ tryagain:
                    break;
                }
                if (UTF) {
-                    STRLEN unilen;
-
                     if (FOLD) {
                          /* Emit all the Unicode characters. */
                          STRLEN numlen;
@@ -4325,7 +4321,7 @@ tryagain:
                               foldlen -= numlen) {
                               ender = utf8_to_uvchr(foldbuf, &numlen);
                               if (numlen > 0) {
-                                   reguni(pRExC_state, ender, s, &unilen);
+                                   const STRLEN unilen = reguni(pRExC_state, ender, s);
                                    len     += unilen;
                                    s       += unilen;
                                    /* In EBCDIC the numlen
@@ -4339,7 +4335,7 @@ tryagain:
                          }
                     }
                     else {
-                         reguni(pRExC_state, ender, s, &unilen);
+                         const STRLEN unilen = reguni(pRExC_state, ender, s);
                          if (unilen > 0) {
                               s   += unilen;
                               len += unilen;
@@ -5503,11 +5499,11 @@ S_reganode(pTHX_ RExC_state_t *pRExC_state, U8 op, U32 arg)
 /*
 - reguni - emit (if appropriate) a Unicode character
 */
-STATIC void
-S_reguni(pTHX_ const RExC_state_t *pRExC_state, UV uv, char* s, STRLEN* lenp)
+STATIC STRLEN
+S_reguni(pTHX_ const RExC_state_t *pRExC_state, UV uv, char* s)
 {
     dVAR;
-    *lenp = SIZE_ONLY ? UNISKIP(uv) : (uvchr_to_utf8((U8*)s, uv) - (U8*)s);
+    return SIZE_ONLY ? UNISKIP(uv) : (uvchr_to_utf8((U8*)s, uv) - (U8*)s);
 }
 
 /*