diff options
author | Karl Williamson <khw@cpan.org> | 2016-05-10 22:17:22 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2016-05-12 20:24:55 -0600 |
commit | b8070b0795640313148acfe846c5f9320bec5745 (patch) | |
tree | efdf6391485e5c57c05afc70e0e0bc16e4e054bf | |
parent | 5f81fa4069cb15ccd77b1c4253c870df84c1788a (diff) | |
download | perl-b8070b0795640313148acfe846c5f9320bec5745.tar.gz |
Use memmem() if available on the platform for Perl_ninstr()
-rw-r--r-- | embed.fnc | 5 | ||||
-rw-r--r-- | embed.h | 4 | ||||
-rw-r--r-- | proto.h | 19 | ||||
-rw-r--r-- | util.c | 8 | ||||
-rw-r--r-- | util.h | 5 |
5 files changed, 35 insertions, 6 deletions
@@ -1093,8 +1093,13 @@ Apd |SV* |vstringify |NN SV *vs Apd |int |vcmp |NN SV *lhv|NN SV *rhv : Used in pp_hot.c and pp_sys.c p |PerlIO*|nextargv |NN GV* gv|bool nomagicopen +#ifdef HAS_MEMMEM +AdnopP |char* |ninstr |NN const char* big|NN const char* bigend \ + |NN const char* little|NN const char* lend +#else AdnpP |char* |ninstr |NN const char* big|NN const char* bigend \ |NN const char* little|NN const char* lend +#endif Apd |void |op_free |NULLOK OP* arg Mp |OP* |op_unscope |NULLOK OP* o #ifdef PERL_CORE @@ -420,7 +420,6 @@ #define new_numeric(a) Perl_new_numeric(aTHX_ a) #define new_stackinfo(a,b) Perl_new_stackinfo(aTHX_ a,b) #define new_version(a) Perl_new_version(aTHX_ a) -#define ninstr Perl_ninstr #define nothreadhook() Perl_nothreadhook(aTHX) #define op_append_elem(a,b,c) Perl_op_append_elem(aTHX_ a,b,c) #define op_append_list(a,b,c) Perl_op_append_list(aTHX_ a,b,c) @@ -760,6 +759,9 @@ #define whichsig_pvn(a,b) Perl_whichsig_pvn(aTHX_ a,b) #define whichsig_sv(a) Perl_whichsig_sv(aTHX_ a) #define wrap_op_checker(a,b,c) Perl_wrap_op_checker(aTHX_ a,b,c) +#if !(defined(HAS_MEMMEM)) +#define ninstr Perl_ninstr +#endif #if !(defined(HAS_SIGACTION) && defined(SA_SIGINFO)) #define csighandler Perl_csighandler #endif @@ -2319,11 +2319,6 @@ PERL_CALLCONV STRLEN * Perl_new_warnings_bitfield(pTHX_ STRLEN *buffer, const ch PERL_CALLCONV PerlIO* Perl_nextargv(pTHX_ GV* gv, bool nomagicopen); #define PERL_ARGS_ASSERT_NEXTARGV \ assert(gv) -PERL_CALLCONV char* Perl_ninstr(const char* big, const char* bigend, const char* little, const char* lend) - __attribute__pure__; -#define PERL_ARGS_ASSERT_NINSTR \ - assert(big); assert(bigend); assert(little); assert(lend) - PERL_CALLCONV_NO_RET void Perl_noperl_die(const char* pat, ...) __attribute__noreturn__ __attribute__format__(__printf__,1,2); @@ -3690,6 +3685,13 @@ STATIC int S_sv_2iuv_non_preserve(pTHX_ SV *const sv); # endif # endif #endif +#if !(defined(HAS_MEMMEM)) +PERL_CALLCONV char* Perl_ninstr(const char* big, const char* bigend, const char* little, const char* lend) + __attribute__pure__; +#define PERL_ARGS_ASSERT_NINSTR \ + assert(big); assert(bigend); assert(little); assert(lend) + +#endif #if !(defined(HAS_SIGACTION) && defined(SA_SIGINFO)) PERL_CALLCONV Signal_t Perl_csighandler(int sig); PERL_CALLCONV Signal_t Perl_sighandler(int sig); @@ -4037,6 +4039,13 @@ PERL_CALLCONV void Perl_dump_sv_child(pTHX_ SV *sv); #define PERL_ARGS_ASSERT_DUMP_SV_CHILD \ assert(sv) #endif +#if defined(HAS_MEMMEM) +PERL_CALLCONV char* Perl_ninstr(const char* big, const char* bigend, const char* little, const char* lend) + __attribute__pure__; +#define PERL_ARGS_ASSERT_NINSTR \ + assert(big); assert(bigend); assert(little); assert(lend) + +#endif #if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM) PERL_CALLCONV I32 Perl_do_ipcctl(pTHX_ I32 optype, SV** mark, SV** sp); #define PERL_ARGS_ASSERT_DO_IPCCTL \ @@ -584,6 +584,11 @@ char * Perl_ninstr(const char *big, const char *bigend, const char *little, const char *lend) { PERL_ARGS_ASSERT_NINSTR; + +#ifdef HAS_MEMMEM + return ninstr(big, bigend, little, lend); +#else + if (little >= lend) return (char*)big; { @@ -602,6 +607,9 @@ Perl_ninstr(const char *big, const char *bigend, const char *little, const char } } return NULL; + +#endif + } /* @@ -231,6 +231,11 @@ means arg not present, 1 is empty string/null byte */ #define instr(haystack, needle) strstr(haystack, needle) +#ifdef HAS_MEMMEM +# define ninstr(big, bigend, little, lend) \ + ((char *) memmem(big, bigend - big, little, lend - little)) +#endif + /* * ex: set ts=8 sts=4 sw=4 et: */ |