shithub: scc

Download patch

ref: 7b11f1552037238aed78c142731722182f6e0ddc
parent: 60c8089ebc884a96d6a89c7388c579973d3e59fd
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Feb 2 02:25:06 EST 2018

[as] Fix getline

It was generating strings without end of line

--- a/as/main.c
+++ b/as/main.c
@@ -74,6 +74,7 @@
 	extern int nerrors;
 	extern jmp_buf recover;
 
+	/* TODO: reset line number */
 	if ((fp = fopen(fname, "r")) == NULL)
 		die("as: error opening '%s'", fname);
 	cleansecs();
--- a/as/parser.c
+++ b/as/parser.c
@@ -387,6 +387,7 @@
 		if (c == '/') {
 			if ((c = getc(fp)) != '*') {
 				ungetc(c, fp);
+				c = '/';
 			} else {
 				comment(fp);
 				c = ' ';
@@ -394,9 +395,11 @@
 		} else if (c > UCHAR_MAX) {
 			error("invalid character '%x'", c);
 		}
-		if (bp == &buff[MAXLINE])
+		if (bp == &buff[MAXLINE-1])
 			error("line too long");
 	}
+	*bp = '\0';
+
 	return bp - buff;
 }