poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/5] Don't crash if the scanner fails


From: John Darrington
Subject: [PATCH 3/5] Don't crash if the scanner fails
Date: Mon, 11 Nov 2019 15:00:44 +0100

2019-11-11 John Darrington <address@hidden>

        * src/pkl-lex.c (YY_FATAL_ERROR): Redefine

Don't abort if the lexer fails for any reason.
---
 src/pkl-lex.l | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/pkl-lex.l b/src/pkl-lex.l
index f9dec2d..8746c9e 100644
--- a/src/pkl-lex.l
+++ b/src/pkl-lex.l
@@ -42,6 +42,8 @@
 #include <ctype.h>
 #include <xalloc.h>
 #include <assert.h>
+#include <gettext.h>
+#define _(str) gettext (str)
 #include "pkl-ast.h"
 #include "pkl-env.h"
 #include "pkl-parser.h"
@@ -50,6 +52,15 @@
 #include <pkl-tab.h>
 #include "pk-cmd.h"
 
+#define YY_FATAL_ERROR(msg)                              \
+  do \
+  { \
+    pk_term_class ("error");                             \
+    pk_printf (_("Fatal error: %s"), msg);               \
+    pk_term_end_class ("error");                         \
+    pk_puts ("\n");                                      \
+  } while (0);
+
 #define YY_USER_ACTION                                  \
   do                                                    \
     {                                                   \
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]