summaryrefslogtreecommitdiff
path: root/dquote_static.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2013-01-13 13:33:22 -0700
committerKarl Williamson <public@khwilliamson.com>2013-01-14 09:05:08 -0700
commit5e0a247b35271159d629ea8562732e0993ed4594 (patch)
tree237cc7c1643119f444e1e8fe99354454e129f578 /dquote_static.c
parent5a016e9bce6eb608ca967bcbb7eb953b81f13701 (diff)
downloadperl-5e0a247b35271159d629ea8562732e0993ed4594.tar.gz
Add warnings for "\08", /\017/
This was discussed in thread http://perl.markmail.org/thread/avtzvtpzemvg2ki2 but I never got around to this portion of the consensus, until now. I did a cpan grep http://grep.cpan.me/?q=%28^|[^\\]%29\\[0-7]{1%2C2}[8-9]&page=1 and eyeballing the results, saw three cases where this warning might show up; one of which was for EBCDIC. The others looked to be false positives, such as in .css files.
Diffstat (limited to 'dquote_static.c')
-rw-r--r--dquote_static.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/dquote_static.c b/dquote_static.c
index 61845ccc92..5a22993ac0 100644
--- a/dquote_static.c
+++ b/dquote_static.c
@@ -297,6 +297,35 @@ S_grok_bslash_x(pTHX_ char **s, UV *uv, const char** error_msg,
return TRUE;
}
+STATIC char*
+S_form_short_octal_warning(pTHX_
+ const char * const s, /* Points to first non-octal */
+ const STRLEN len /* Length of octals string, so
+ (s-len) points to first
+ octal */
+) {
+ /* Return a character string consisting of a warning message for when a
+ * string constant in octal is weird, like "\078". */
+
+ const char * sans_leading_zeros = s - len;
+
+ PERL_ARGS_ASSERT_FORM_SHORT_OCTAL_WARNING;
+
+ assert(*s == '8' || *s == '9');
+
+ /* Remove the leading zeros, retaining one zero so won't be zero length */
+ while (*sans_leading_zeros == '0') sans_leading_zeros++;
+ if (sans_leading_zeros == s) {
+ sans_leading_zeros--;
+ }
+
+ return Perl_form(aTHX_
+ "'%.*s' resolved to '\\o{%.*s}%c'",
+ (int) (len + 2), s - len - 1,
+ (int) (s - sans_leading_zeros), sans_leading_zeros,
+ *s);
+}
+
/*
* Local variables:
* c-indentation-style: bsd