commit 9232dc4ce2496e0616515b01c22bbb4680646f92
parent 1d12e3bc0e39a5809b233fcf39ea0bb17e6b8384
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 28 Sep 2017 09:47:31 +0100
[as] Set recovery point
Diffstat:
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git 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,12 +59,16 @@ dopass(char *fname)
struct line line;
FILE *fp;
extern int nerrors;
+ extern jmp_buf recover;
if ((fp = fopen(fname, "r")) == NULL)
die("as: error opening '%s'", fname);
isections();
while (nextline(fp, &line)) {
+ if (setjmp(recover))
+ continue;
+
linesym = NULL;
if (line.label)
diff --git 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 @@ static char sccsid[] = "@(#) ./as/parser.c";
char *filename;
int nerrors;
+jmp_buf recover;
static unsigned lineno;
@@ -30,6 +32,7 @@ error(char *msg, ...)
if (nerrors == 10)
die("as: too many errors");
+ longjmp(recover, 1);
}
Node **