3 * This file contains static inline functions that are related to
4 * parsing double-quotish expressions, but are used in more than
7 * It is currently #included by regcomp.c and toke.c.
10 #define PERL_IN_DQUOTE_STATIC_C
15 - regcurly - a little FSA that accepts {\d+,?\d*}
16 Pulled from regcomp.c.
18 PERL_STATIC_INLINE I32
19 S_regcurly(pTHX_ register const char *s)
21 PERL_ARGS_ASSERT_REGCURLY;
39 /* XXX Add documentation after final interface and behavior is decided */
40 /* May want to show context for error, so would pass Perl_bslash_c(pTHX_ const char* current, const char* start, const bool output_warning)
43 May want to add eg, WARN_REGEX
47 S_grok_bslash_c(pTHX_ const char source, const bool output_warning)
52 if (! isASCII(source)) {
53 Perl_croak(aTHX_ "Character following \"\\c\" must be ASCII");
56 result = toCTRL(source);
57 if (! isCNTRL(result)) {
59 Perl_croak(aTHX_ "It is proposed that \"\\c{\" no longer be valid. It has historically evaluated to\n \";\". If you disagree with this proposal, send email to perl5-porters@perl.org\nOtherwise, or in the meantime, you can work around this failure by changing\n\"\\c{\" to \";\"");
61 else if (output_warning) {
64 if (! isALNUM(result)) {
67 clearer[i++] = result;
70 Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED),
71 "\"\\c%c\" more clearly written simply as \"%s\"",
81 S_grok_bslash_o(pTHX_ const char *s,
84 const char** error_msg,
85 const bool output_warning)
88 /* Documentation to be supplied when interface nailed down finally
89 * This returns FALSE if there is an error which the caller need not recover
90 * from; , otherwise TRUE. In either case the caller should look at *len
92 * s points to a string that begins with 'o', and the previous character
94 * uv points to a UV that will hold the output value, valid only if the
95 * return from the function is TRUE
96 * len on success will point to the next character in the string past the
97 * end of this construct.
98 * on failure, it will point to the failure
99 * error_msg is a pointer that will be set to an internal buffer giving an
100 * error message upon failure (the return is FALSE). Untouched if
102 * output_warning says whether to output any warning messages, or suppress
107 I32 flags = PERL_SCAN_ALLOW_UNDERSCORES
108 | PERL_SCAN_DISALLOW_PREFIX
109 /* XXX Until the message is improved in grok_oct, handle errors
111 | PERL_SCAN_SILENT_ILLDIGIT;
113 PERL_ARGS_ASSERT_GROK_BSLASH_O;
120 *len = 1; /* Move past the o */
121 *error_msg = "Missing braces on \\o{}";
127 *len = 2; /* Move past the o{ */
128 *error_msg = "Missing right brace on \\o{";
132 /* Return past the '}' no matter what is inside the braces */
133 *len = e - s + 2; /* 2 = 1 for the o + 1 for the '}' */
135 s++; /* Point to first digit */
138 if (numbers_len == 0) {
139 *error_msg = "Number with no digits";
143 *uv = NATIVE_TO_UNI(grok_oct(s, &numbers_len, &flags, NULL));
144 /* Note that if has non-octal, will ignore everything starting with that up
147 if (output_warning && numbers_len != (STRLEN) (e - s)) {
148 Perl_ck_warner(aTHX_ packWARN(WARN_DIGIT),
149 /* diag_listed_as: Non-octal character '%c'. Resolved as "%s" */
150 "Non-octal character '%c'. Resolved as \"\\o{%.*s}\"",
161 * c-indentation-style: bsd
163 * indent-tabs-mode: t
166 * ex: set ts=8 sts=4 sw=4 noet: