#include "xsh/caps.h"
#include "xsh/util.h"
+#include "xsh/mem.h"
#include "xsh/ops.h"
/* ... op => source position map ........................................... */
} indirect_op_info_t;
#define PTABLE_NAME ptable
-#define PTABLE_VAL_FREE(V) if (V) { Safefree(((indirect_op_info_t *) (V))->buf); Safefree(V); }
+#define PTABLE_VAL_FREE(V) if (V) { indirect_op_info_t *oi = (V); XSH_LOCAL_FREE(oi->buf, oi->size, char); XSH_LOCAL_FREE(oi, 1, indirect_op_info_t); }
#define PTABLE_NEED_DELETE 1
#define PTABLE_NEED_WALK 0
#include "xsh/ptable.h"
-/* Safefree() always need aTHX */
+/* XSH_LOCAL_FREE() always need aTHX */
#define ptable_store(T, K, V) ptable_store(aTHX_ (T), (K), (V))
#define ptable_delete(T, K) ptable_delete(aTHX_ (T), (K))
#define ptable_clear(T) ptable_clear(aTHX_ (T))
/* --- Compatibility wrappers ---------------------------------------------- */
-#ifndef Newx
-# define Newx(v, n, c) New(0, v, n, c)
-#endif
-
#ifndef SvPV_const
# define SvPV_const SvPV
#endif
# ifndef PL_lex_inwhat
# define PL_lex_inwhat PL_parser->lex_inwhat
# endif
+# ifndef PL_multi_close
+# define PL_multi_close PL_parser->multi_close
+# endif
#else
# ifndef PL_linestr
# define PL_linestr PL_Ilinestr
# ifndef PL_lex_inwhat
# define PL_lex_inwhat PL_Ilex_inwhat
# endif
+# ifndef PL_multi_close
+# define PL_multi_close PL_Imulti_close
+# endif
#endif
/* ... Safe version of call_sv() ........................................... */
* guarded by indirect_hint(). */
if (!(oi = ptable_fetch(XSH_CXT.map, o))) {
- Newx(oi, 1, indirect_op_info_t);
+ XSH_LOCAL_ALLOC(oi, 1, indirect_op_info_t);
ptable_store(XSH_CXT.map, o, oi);
oi->buf = NULL;
oi->size = 0;
}
if (len > oi->size) {
- Safefree(oi->buf);
- Newx(oi->buf, len, char);
+ XSH_LOCAL_REALLOC(oi->buf, oi->size, len, char);
oi->size = len;
}
- Copy(s, oi->buf, len, char);
+ if (oi->buf)
+ Copy(s, oi->buf, len, char);
oi->len = len;
oi->pos = pos;
if (SvPOK(sv) && (SvTYPE(sv) >= SVt_PV)) {
STRLEN pos;
+ const char *bufptr;
+
+ bufptr = PL_multi_close == '<' ? PL_bufptr : PL_oldbufptr;
- if (indirect_find(sv, PL_oldbufptr, &pos)) {
+ if (indirect_find(sv, bufptr, &pos)) {
STRLEN len;
/* If the constant is equal to the current package name, try to look for