Clean up regexec.c, and remove two functions
authorAndy Lester <andy@petdance.com>
Wed, 29 Mar 2006 10:13:36 +0000 (04:13 -0600)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Thu, 30 Mar 2006 08:17:12 +0000 (08:17 +0000)
Message-ID: <20060329161336.GA12456@petdance.com>

p4raw-id: //depot/perl@27630

embed.fnc
embed.h
proto.h
regexec.c

index d74193e..3cc2d14 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -456,8 +456,8 @@ p   |char*  |mem_collxfrm   |NN const char* s|STRLEN len|NN STRLEN* xlen
 Afp    |SV*    |mess           |NN const char* pat|...
 Ap     |SV*    |vmess          |NN const char* pat|NULLOK va_list* args
 p      |void   |qerror         |NN SV* err
-Apd    |void   |sortsv         |NN SV** array|size_t num_elts|SVCOMPARE_t cmp
-Apd    |void   |sortsv_flags   |NN SV** array|size_t num_elts|SVCOMPARE_t cmp|U32 flags
+Apd    |void   |sortsv         |NN SV** array|size_t num_elts|NN SVCOMPARE_t cmp
+Apd    |void   |sortsv_flags   |NN SV** array|size_t num_elts|NN SVCOMPARE_t cmp|U32 flags
 Apd    |int    |mg_clear       |NN SV* sv
 Apd    |int    |mg_copy        |NN SV* sv|NN SV* nsv|NULLOK const char* key|I32 klen
 pd     |void   |mg_localize    |NN SV* sv|NN SV* nsv
@@ -1312,9 +1312,7 @@ ERs       |bool   |reginclass     |NN const regnode *n|NN const U8 *p|NULLOK STRLEN *lenp\
 Es     |CHECKPOINT|regcppush   |I32 parenfloor
 Es     |char*|regcppop
 Es     |void   |cache_re       |NN regexp *prog
-ERs    |U8*    |reghop         |NN U8 *pos|I32 off
 ERsn   |U8*    |reghop3        |NN U8 *pos|I32 off|NN U8 *lim
-ERs    |U8*    |reghopmaybe    |NN U8 *pos|I32 off
 ERsn   |U8*    |reghopmaybe3   |NN U8 *pos|I32 off|NN U8 *lim
 ERs    |char*  |find_byclass   |NN regexp * prog|NN regnode *c|NN char *s|NN const char *strend|I32 norun
 Es     |void   |to_utf8_substr |NN regexp * prog
diff --git a/embed.h b/embed.h
index d6b9bfa..53d6043 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define regcppush              S_regcppush
 #define regcppop               S_regcppop
 #define cache_re               S_cache_re
-#define reghop                 S_reghop
 #define reghop3                        S_reghop3
-#define reghopmaybe            S_reghopmaybe
 #define reghopmaybe3           S_reghopmaybe3
 #define find_byclass           S_find_byclass
 #define to_utf8_substr         S_to_utf8_substr
 #define regcppush(a)           S_regcppush(aTHX_ a)
 #define regcppop()             S_regcppop(aTHX)
 #define cache_re(a)            S_cache_re(aTHX_ a)
-#define reghop(a,b)            S_reghop(aTHX_ a,b)
 #define reghop3                        S_reghop3
-#define reghopmaybe(a,b)       S_reghopmaybe(aTHX_ a,b)
 #define reghopmaybe3           S_reghopmaybe3
 #define find_byclass(a,b,c,d,e)        S_find_byclass(aTHX_ a,b,c,d,e)
 #define to_utf8_substr(a)      S_to_utf8_substr(aTHX_ a)
diff --git a/proto.h b/proto.h
index 528bcf6..6bd5955 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -1265,10 +1265,12 @@ PERL_CALLCONV void      Perl_qerror(pTHX_ SV* err)
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV void     Perl_sortsv(pTHX_ SV** array, size_t num_elts, SVCOMPARE_t cmp)
-                       __attribute__nonnull__(pTHX_1);
+                       __attribute__nonnull__(pTHX_1)
+                       __attribute__nonnull__(pTHX_3);
 
 PERL_CALLCONV void     Perl_sortsv_flags(pTHX_ SV** array, size_t num_elts, SVCOMPARE_t cmp, U32 flags)
-                       __attribute__nonnull__(pTHX_1);
+                       __attribute__nonnull__(pTHX_1)
+                       __attribute__nonnull__(pTHX_3);
 
 PERL_CALLCONV int      Perl_mg_clear(pTHX_ SV* sv)
                        __attribute__nonnull__(pTHX_1);
@@ -3617,19 +3619,11 @@ STATIC char*    S_regcppop(pTHX);
 STATIC void    S_cache_re(pTHX_ regexp *prog)
                        __attribute__nonnull__(pTHX_1);
 
-STATIC U8*     S_reghop(pTHX_ U8 *pos, I32 off)
-                       __attribute__warn_unused_result__
-                       __attribute__nonnull__(pTHX_1);
-
 STATIC U8*     S_reghop3(U8 *pos, I32 off, U8 *lim)
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(1)
                        __attribute__nonnull__(3);
 
-STATIC U8*     S_reghopmaybe(pTHX_ U8 *pos, I32 off)
-                       __attribute__warn_unused_result__
-                       __attribute__nonnull__(pTHX_1);
-
 STATIC U8*     S_reghopmaybe3(U8 *pos, I32 off, U8 *lim)
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(1)
index f5fdd8d..4010b34 100644 (file)
--- a/regexec.c
+++ b/regexec.c
 #define CHR_SVLEN(sv) (do_utf8 ? sv_len_utf8(sv) : SvCUR(sv))
 #define CHR_DIST(a,b) (PL_reg_match_utf8 ? utf8_distance(a,b) : a - b)
 
-#define reghop_c(pos,off) ((char*)reghop((U8*)pos, off))
-#define reghopmaybe_c(pos,off) ((char*)reghopmaybe((U8*)pos, off))
-#define HOP(pos,off) (PL_reg_match_utf8 ? reghop((U8*)pos, off) : (U8*)(pos + off))
-#define HOPMAYBE(pos,off) (PL_reg_match_utf8 ? reghopmaybe((U8*)pos, off) : (U8*)(pos + off))
-#define HOPc(pos,off) ((char*)HOP(pos,off))
-#define HOPMAYBEc(pos,off) ((char*)HOPMAYBE(pos,off))
-
-#define HOPBACK(pos, off) (            \
-    (PL_reg_match_utf8)                        \
-       ? reghopmaybe((U8*)pos, -off)   \
+#define HOPc(pos,off) ((char *)(PL_reg_match_utf8 \
+           ? reghop3((U8*)pos, off, (U8*)(off >= 0 ? PL_regeol : PL_bostr)) \
+           : (U8*)(pos + off)))
+#define HOPBACKc(pos, off) ((char*)    \
+    ((PL_reg_match_utf8)               \
+       ? reghopmaybe3((U8*)pos, -off, ((U8*)(off < 0 ? PL_regeol : PL_bostr))) \
     : (pos - off >= PL_bostr)          \
        ? (U8*)(pos - off)              \
-    : (U8*)NULL                                \
+    : (U8*)NULL)                       \
 )
-#define HOPBACKc(pos, off) (char*)HOPBACK(pos, off)
 
-#define reghop3_c(pos,off,lim) ((char*)reghop3((U8*)pos, off, (U8*)lim))
 #define reghopmaybe3_c(pos,off,lim) ((char*)reghopmaybe3((U8*)pos, off, (U8*)lim))
 #define HOP3(pos,off,lim) (PL_reg_match_utf8 ? reghop3((U8*)pos, off, (U8*)lim) : (U8*)(pos + off))
-#define HOPMAYBE3(pos,off,lim) (PL_reg_match_utf8 ? reghopmaybe3((U8*)pos, off, (U8*)lim) : (U8*)(pos + off))
 #define HOP3c(pos,off,lim) ((char*)HOP3(pos,off,lim))
-#define HOPMAYBE3c(pos,off,lim) ((char*)HOPMAYBE3(pos,off,lim))
 
 #define LOAD_UTF8_CHARCLASS(class,str) STMT_START { \
     if (!CAT2(PL_utf8_,class)) { bool ok; ENTER; save_re_context(); ok=CAT2(is_utf8_,class)((const U8*)str); assert(ok); LEAVE; } } STMT_END
@@ -1898,10 +1890,10 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *
                s = HOPc(s, -back_max);
            }
            else {
-               char *t = (last1 >= PL_bostr) ? HOPc(last1, 1) : last1 + 1;
+               char * const t = (last1 >= PL_bostr) ? HOPc(last1, 1) : last1 + 1;
 
                last1 = HOPc(s, -back_min);
-               s = t;          
+               s = t;
            }
            if (do_utf8) {
                while (s <= last1) {
@@ -4363,7 +4355,7 @@ S_regmatch(pTHX_ regnode *prog)
        case UNLESSM:
            n = 0;
            if (scan->flags) {
-               char *s = HOPBACKc(locinput, scan->flags);
+               char * const s = HOPBACKc(locinput, scan->flags);
                if (!s)
                    goto say_yes;
                PL_reginput = s;
@@ -4374,7 +4366,7 @@ S_regmatch(pTHX_ regnode *prog)
        case IFMATCH:
            n = 1;
            if (scan->flags) {
-               char *s = HOPBACKc(locinput, scan->flags);
+               char * const s = HOPBACKc(locinput, scan->flags);
                if (!s)
                    goto say_no;
                PL_reginput = s;
@@ -5085,13 +5077,6 @@ S_reginclass(pTHX_ register const regnode *n, register const U8* p, STRLEN* lenp
 }
 
 STATIC U8 *
-S_reghop(pTHX_ U8 *s, I32 off)
-{
-    dVAR;
-    return S_reghop3(s, off, (U8*)(off >= 0 ? PL_regeol : PL_bostr));
-}
-
-STATIC U8 *
 S_reghop3(U8 *s, I32 off, U8* lim)
 {
     dVAR;
@@ -5117,13 +5102,6 @@ S_reghop3(U8 *s, I32 off, U8* lim)
 }
 
 STATIC U8 *
-S_reghopmaybe(pTHX_ U8 *s, I32 off)
-{
-    dVAR;
-    return S_reghopmaybe3(s, off, (U8*)(off >= 0 ? PL_regeol : PL_bostr));
-}
-
-STATIC U8 *
 S_reghopmaybe3(U8* s, I32 off, U8* lim)
 {
     dVAR;