summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib.c2
-rw-r--r--tests/custom/03_bugs/14_incomplete_expression_at_eof16
2 files changed, 17 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 20a1b81..a9a61fa 100644
--- a/lib.c
+++ b/lib.c
@@ -131,7 +131,7 @@ format_source_context(uc_stringbuf_t *buf, uc_source *src, size_t off, bool comp
len = strlen(line);
rlen += len;
- if (rlen > off) {
+ if (rlen >= off) {
if (compact)
ucv_stringbuf_printf(buf, "\033[2;40;97m%17s %s",
source_filename(src, eline),
diff --git a/tests/custom/03_bugs/14_incomplete_expression_at_eof b/tests/custom/03_bugs/14_incomplete_expression_at_eof
new file mode 100644
index 0000000..474e87c
--- /dev/null
+++ b/tests/custom/03_bugs/14_incomplete_expression_at_eof
@@ -0,0 +1,16 @@
+When an incomplete expression was parsed at the very end of the input
+buffer, the source code context line was not properly printed.
+
+-- Expect stderr --
+Syntax error: Expecting expression
+In line 1, byte 7:
+
+ `{% 1+`
+ ^-- Near here
+
+
+-- End --
+
+-- Testcase --
+{% 1+
+-- End --