diff mc-macro.c @ 343:11f8f2e6bb72

fix eof and multi-file, mc-parse else-if switch
author kono
date Sun, 27 Jun 2004 10:39:18 +0900
parents da2e3f2d127d
children 969089695850
line wrap: on
line diff
--- a/mc-macro.c	Sat Jun 26 12:35:35 2004 +0900
+++ b/mc-macro.c	Sun Jun 27 10:39:18 2004 +0900
@@ -163,12 +163,18 @@
     return 0;
 }
 
+static int next_eof;
+
 extern void
 getline(void)
 {
     int i;
     int c;
 
+    if (next_eof) {
+	next_eof=0;
+	error(EOFERR);
+    }
     do {
 	if (chinput) {
 	    if (! *chinput) {
@@ -188,13 +194,14 @@
 	    while ((*chptr++ = c = getc(filep->fcb)) != '\n') {
 		if (++i > LBUFSIZE-2) error(LNERR);
 		if (c==EOF) {
-			error(EOFERR);
-			--chptr;
+		    next_eof=1;
+		    --chptr;
+		    break;
 		}
 	    }
 	}
 	*chptr = '\0';
-	if (lsrc && !asmf && !macro_if_skip) gen_comment(linebuf);
+	if (lsrc && !asmf && !macro_if_skip && linebuf[0]) gen_comment(linebuf);
 	if (*(chptr = linebuf) == '#' && !in_comment && !in_quote) {
 	    if (macro_processing()) return;
 	}