diff mc-macro.c @ 469:cf1c2c42b7c8

fix iassop
author kono
date Sat, 30 Jul 2005 20:54:40 +0900
parents b8f95294eb77
children e58848f6ebc1
line wrap: on
line diff
--- a/mc-macro.c	Sat Jul 30 16:22:00 2005 +0900
+++ b/mc-macro.c	Sat Jul 30 20:54:40 2005 +0900
@@ -112,7 +112,7 @@
  */
 
 static FILE *
-getfname(void)
+getfname(int next)
 {
     int i,end='"',err=0;
     char *s,*p,**pp,*name;
@@ -135,13 +135,20 @@
     cheap = increment_cheap(cheap,&name);
     save_cheap(&scheap,cheap);
     fp = fopen(name,"r") ;
+    if (next && fp) { fclose(fp); fp=0; next=0; }
     if (fp) {
 	p = name; 
     } else {
 	for(pp=(end=='>'||filep->inc=='>') ?l_include_path:include_path;
 		*pp;pp++) {
 	    p = expand_file_name(*pp,name);
-	    if ((fp = fopen(p,"r"))) break ;
+	    if ((fp = fopen(p,"r"))) {
+		if (next) {
+		    fclose(fp); fp=0; next=0; 
+		    continue;
+		} else
+		    break ;
+	    }
 	}
     }
     if(!fp) { error(FILERR); return filep->fcb; }
@@ -331,6 +338,7 @@
     int i;
     int c;
     int mode_save;
+    int next;
 
     ++chptr;
     while (*chptr==' '||*chptr=='\t') ++chptr;
@@ -426,9 +434,10 @@
 	}
 	break;
     case 'i':
-	if (macroeq("include")) {
+	next = 1;
+	if (macroeq("include_next")|| (next=0, macroeq("include"))) {
 	    if(filep+1 >= filestack + FILES) error(FILERR);
-	    if ( ((filep+1)->fcb=getfname()) == NULL) error(FILERR);
+	    if ( ((filep+1)->fcb=getfname(next)) == NULL) error(FILERR);
 	    (filep+1)->ln=lineno;
 	    lineno=0;
 	    ++filep;