%code top {
-#include "php_psi_stdinc.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#else
+# include "php_config.h"
+#endif
}
%code {
psi_plist_get(tokens, last, &T);
if (T) {
+ size_t i = (last >= 5) ? last - 5 : 0;
+
P->error(PSI_DATA(P), T, PSI_WARNING, "PSI %s at col %u", msg, T->col);
+ while (i <= last || T->type != PSI_T_EOS) {
+ const char *pos;
+
+ if (!psi_plist_get(tokens, i++, &T)) {
+ break;
+ }
+
+ if (i < last + 1) {
+ pos = "preceding";
+ } else if (i > last + 1) {
+ pos = "following";
+ } else {
+ pos = "offending";
+ }
+
+ P->error(PSI_DATA(P), T, PSI_WARNING, "PSI %s token '%s' at col %u",
+ pos, T ? T->text->val : "<deleted>", T ? T->col : 0);
+ }
} else {
P->error(PSI_DATA(P), NULL, PSI_WARNING, "PSI %s", msg);
}