From: Vincent Pit Date: Tue, 26 Feb 2013 14:31:20 +0000 (-0300) Subject: Clarify what indirect_find() does by renaming some variables X-Git-Tag: v0.28~3 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=commitdiff_plain;h=ebfc299663332ad7232032d460b4fa60bd80e067 Clarify what indirect_find() does by renaming some variables --- diff --git a/indirect.xs b/indirect.xs index 8ff064b..494093e 100644 --- a/indirect.xs +++ b/indirect.xs @@ -494,44 +494,44 @@ STATIC STRLEN indirect_nextline(const char *s, STRLEN len) { return i; } -STATIC int indirect_find(pTHX_ SV *sv, const char *s, STRLEN *pos) { -#define indirect_find(N, S, P) indirect_find(aTHX_ (N), (S), (P)) - STRLEN len; - const char *p, *r, *t, *u; - - r = SvPV_const(sv, len); - if (len >= 1 && *r == '$') { - ++r; - --len; - s = strchr(s, '$'); - if (!s) +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; + + name = SvPV_const(name_sv, name_len); + if (name_len >= 1 && *name == '$') { + ++name; + --name_len; + line_bufptr = strchr(line_bufptr, '$'); + if (!line_bufptr) return 0; } - p = s; + p = line_bufptr; while (1) { - p = strstr(p, r); + p = strstr(p, name); if (!p) return 0; - if (!isALNUM(p[len])) + if (!isALNUM(p[name_len])) break; - /* p points to a word that has r as prefix, skip the rest of the word */ - p += len + 1; + /* p points to a word that has name as prefix, skip the rest of the word */ + p += name_len + 1; while (isALNUM(*p)) ++p; } - t = SvPV_const(PL_linestr, len); + t = SvPV_const(PL_linestr, line_len); u = t; while (t <= p) { - STRLEN i = indirect_nextline(t, len); - if (i >= len) + STRLEN i = indirect_nextline(t, line_len); + if (i >= line_len) break; - u = t; - t += i; - len -= i; + u = t; + t += i; + line_len -= i; } - *pos = p - u; + *name_pos = p - u; return 1; }