From: Graham Knop Date: Thu, 25 Jan 2018 13:11:44 +0000 (+0100) Subject: more clear variable usage for counting quotes X-Git-Tag: v0.24~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2fa237057a1b9c375ee0e4fb13696c8e6645e474;p=p5sagit%2FSub-Name.git more clear variable usage for counting quotes Use a boolean to track when we need to generate a normal :: separated package name, rather than an int. And rename the seen_quote variable to make it clear that it is a count rather than a boolean. --- diff --git a/Name.xs b/Name.xs index 59a62e8..5f7c06e 100644 --- a/Name.xs +++ b/Name.xs @@ -72,7 +72,8 @@ subname(name, sub) STRLEN namelen; const char* nameptr = SvPV(name, namelen); int utf8flag = SvUTF8(name); - int seen_quote = 0, need_subst = 0; + int quotes_seen = 0; + bool need_subst = FALSE; PPCODE: if (!SvROK(sub) && SvGMAGICAL(sub)) mg_get(sub); @@ -96,21 +97,21 @@ subname(name, sub) if (s > nameptr && *s == ':' && s[-1] == ':') { end = s - 1; begin = ++s; - if (seen_quote) - need_subst++; + if (quotes_seen) + need_subst = TRUE; } else if (s > nameptr && *s != '\0' && s[-1] == '\'') { end = s - 1; begin = s; - if (seen_quote++) - need_subst++; + if (quotes_seen++) + need_subst = TRUE; } } s--; if (end) { SV* tmp; if (need_subst) { - STRLEN length = end - nameptr + seen_quote - (*end == '\'' ? 1 : 0); + STRLEN length = end - nameptr + quotes_seen - (*end == '\'' ? 1 : 0); char* left; int i, j; tmp = newSV(length);