#endif
+#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#define HINTK_NAME_ MY_PKG "/name:"
#define HINTK_SHIFT_ MY_PKG "/shift:"
+#define HAVE_PERL_VERSION(R, V, S) \
+ (PERL_REVISION > (R) || (PERL_REVISION == (R) && (PERL_VERSION > (V) || (PERL_VERSION == (V) && (PERL_SUBVERSION >= (S))))))
+
typedef struct {
enum {
FLAG_NAME_OPTIONAL = 1,
static int (*next_keyword_plugin)(pTHX_ char *, STRLEN, OP **);
-static int kw_flags(const char *kw_ptr, STRLEN kw_len, Spec *spec) {
+static int kw_flags(pTHX_ const char *kw_ptr, STRLEN kw_len, Spec *spec) {
HV *hints;
SV *sv, **psv;
const char *p, *kw_active;
#include "toke_on_crack.c.inc"
-static int parse_fun(OP **pop, const char *keyword_ptr, STRLEN keyword_len, const Spec *spec) {
+static int parse_fun(pTHX_ OP **pop, const char *keyword_ptr, STRLEN keyword_len, const Spec *spec) {
SV *gen, *declarator, *params, *sv;
line_t line_start;
int saw_name, saw_colon;
/* function name */
saw_name = 0;
s = PL_parser->bufptr;
- if (spec->name != FLAG_NAME_PROHIBITED && (len = S_scan_word(s, TRUE))) {
+ if (spec->name != FLAG_NAME_PROHIBITED && (len = S_scan_word(aTHX_ s, TRUE))) {
sv_catpvs(gen, " ");
sv_catpvn(gen, s, len);
sv_catpvs(declarator, " ");
lex_read_space(0);
s = PL_parser->bufptr;
- if (!(len = S_scan_word(s, FALSE))) {
+ if (!(len = S_scan_word(aTHX_ s, FALSE))) {
croak("In %.*s: missing identifier", (int)SvCUR(declarator), SvPV_nolen(declarator));
}
if (saw_slurpy) {
saw_colon = 1;
} else {
sv = sv_2mortal(newSVpvs(""));
- if (!S_scan_str(sv, TRUE, TRUE)) {
+ if (!S_scan_str(aTHX_ sv, TRUE, TRUE)) {
croak("In %.*s: malformed prototype", (int)SvCUR(declarator), SvPV_nolen(declarator));
}
sv_catsv(gen, sv);
if (saw_colon) {
for (;;) {
s = PL_parser->bufptr;
- if (!(len = S_scan_word(s, FALSE))) {
+ if (!(len = S_scan_word(aTHX_ s, FALSE))) {
break;
}
sv_catpvs(gen, ":");
c = lex_peek_unichar(0);
if (c == '(') {
sv = sv_2mortal(newSVpvs(""));
- if (!S_scan_str(sv, TRUE, TRUE)) {
+ if (!S_scan_str(aTHX_ sv, TRUE, TRUE)) {
croak("In %.*s: malformed attribute argument list", (int)SvCUR(declarator), SvPV_nolen(declarator));
}
sv_catsv(gen, sv);
SAVETMPS;
- if (kw_flags(keyword_ptr, keyword_len, &spec)) {
- ret = parse_fun(op_ptr, keyword_ptr, keyword_len, &spec);
+ if (kw_flags(aTHX_ keyword_ptr, keyword_len, &spec)) {
+ ret = parse_fun(aTHX_ op_ptr, keyword_ptr, keyword_len, &spec);
} else {
- ret = next_keyword_plugin(keyword_ptr, keyword_len, op_ptr);
+ ret = next_keyword_plugin(aTHX_ keyword_ptr, keyword_len, op_ptr);
}
FREETMPS;
* This code was copied from perl/toke.c and subsequently butchered
* by Lukas Mai (2012).
*/
+/* vi: set ft=c: */
/* vvvvvvvvvvvvvvvvvvvvv I HAVE NO IDEA WHAT I'M DOING vvvvvvvvvvvvvvvvvvvv */
#define PL_linestr (PL_parser->linestr)
# define UTF ((PL_linestr && DO_UTF8(PL_linestr)) || (PL_hints & HINT_UTF8))
#endif
-static STRLEN S_scan_word(const char *start, int allow_package) {
+static STRLEN S_scan_word(pTHX_ const char *start, int allow_package) {
const char *s = start;
for (;;) {
if (isALNUM(*s) || (!UTF && isALNUMC_L1(*s))) { /* UTF handled below */
termlen = 1;
}
else {
+#if HAVE_PERL_VERSION(5, 16, 0)
termcode = utf8_to_uvchr_buf((U8*)s, (U8*)PL_bufend, &termlen);
+#else
+ termcode = utf8_to_uvchr((U8*)s, &termlen);
+#endif
Copy(s, termstr, termlen, U8);
if (!UTF8_IS_INVARIANT(term))
has_utf8 = TRUE;
char * const svlast = SvEND(sv) - 1;
for (; s < ns; s++) {
- if (*s == '\n' && !PL_rsfp && !PL_parser->filtered)
+ if (*s == '\n' && !PL_rsfp
+#if HAVE_PERL_VERSION(5, 16, 0)
+ && !PL_parser->filtered
+#endif
+ )
CopLINE_inc(PL_curcop);
}
if (!found)
if (PL_multi_open == PL_multi_close) {
for (; s < PL_bufend; s++,to++) {
/* embedded newlines increment the current line number */
- if (*s == '\n' && !PL_rsfp && !PL_parser->filtered)
+ if (*s == '\n' && !PL_rsfp
+#if HAVE_PERL_VERSION(5, 16, 0)
+ && !PL_parser->filtered
+#endif
+ )
CopLINE_inc(PL_curcop);
/* handle quoted delimiters */
if (*s == '\\' && s+1 < PL_bufend && term != '\\') {
/* read until we run out of string, or we find the terminator */
for (; s < PL_bufend; s++,to++) {
/* embedded newlines increment the line count */
- if (*s == '\n' && !PL_rsfp && !PL_parser->filtered)
+ if (*s == '\n' && !PL_rsfp
+#if HAVE_PERL_VERSION(5, 16, 0)
+ && !PL_parser->filtered
+#endif
+ )
CopLINE_inc(PL_curcop);
/* backslashes can escape the open or closing characters */
if (*s == '\\' && s+1 < PL_bufend) {