X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=blobdiff_plain;f=indirect.xs;h=e1961194bf1585b083f947d0201ceaca4bfed003;hp=494093e97cee9a2b1597b4d5efa8a84eae5fc548;hb=4e6baf6fb7035144cc8ae87da292f7db4e9f5713;hpb=ebfc299663332ad7232032d460b4fa60bd80e067 diff --git a/indirect.xs b/indirect.xs index 494093e..e196119 100644 --- a/indirect.xs +++ b/indirect.xs @@ -496,21 +496,28 @@ STATIC STRLEN indirect_nextline(const char *s, STRLEN len) { STATIC int indirect_find(pTHX_ SV *name_sv, const char *line_bufptr, STRLEN *name_pos) { #define indirect_find(NSV, LBP, NP) indirect_find(aTHX_ (NSV), (LBP), (NP)) - STRLEN name_len, line_len; - const char *name, *p, *t, *u; + STRLEN name_len, line_len; + const char *name, *name_end; + const char *line, *line_end; + const char *p, *t, *u; + + line = SvPV_const(PL_linestr, line_len); + line_end = line + line_len; name = SvPV_const(name_sv, name_len); if (name_len >= 1 && *name == '$') { ++name; --name_len; - line_bufptr = strchr(line_bufptr, '$'); - if (!line_bufptr) + while (line_bufptr < line_end && *line_bufptr != '$') + ++line_bufptr; + if (line_bufptr >= line_end) return 0; } + name_end = name + name_len; p = line_bufptr; while (1) { - p = strstr(p, name); + p = ninstr(p, line_end, name, name_end); if (!p) return 0; if (!isALNUM(p[name_len])) @@ -521,7 +528,7 @@ STATIC int indirect_find(pTHX_ SV *name_sv, const char *line_bufptr, STRLEN *nam ++p; } - t = SvPV_const(PL_linestr, line_len); + t = line; u = t; while (t <= p) { STRLEN i = indirect_nextline(t, line_len);