shithub: scc

Download patch

ref: d9ac6c3479972cda5337b5c65f8ee731c574c82b
parent: 105c3b4246bff03159094c8aea5221d3878be029
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Sep 28 05:47:31 EDT 2017

[as] Set recovery point

--- a/as/main.c
+++ b/as/main.c
@@ -1,6 +1,7 @@
 static char sccsid[] = "@(#) ./as/main.c";
 
 #include <ctype.h>
+#include <setjmp.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -58,6 +59,7 @@
 	struct line line;
 	FILE *fp;
 	extern int nerrors;
+	extern jmp_buf recover;
 
 	if ((fp = fopen(fname, "r")) == NULL)
 		die("as: error opening '%s'", fname);
@@ -64,6 +66,9 @@
 
 	isections();
 	while (nextline(fp, &line)) {
+		if (setjmp(recover))
+			continue;
+
 		linesym = NULL;
 
 		if (line.label)
--- a/as/parser.c
+++ b/as/parser.c
@@ -1,5 +1,6 @@
 static char sccsid[] = "@(#) ./as/parser.c";
 #include <ctype.h>
+#include <setjmp.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -13,6 +14,7 @@
 
 char *filename;
 int nerrors;
+jmp_buf recover;
 
 static unsigned lineno;
 
@@ -30,6 +32,7 @@
 
 	if (nerrors == 10)
 		die("as: too many errors");
+	longjmp(recover, 1);
 }
 
 Node **