txlyre 1 月之前
父節點
當前提交
063741f29c
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. 5 5
      qic.c

+ 5 - 5
qic.c

@@ -367,14 +367,12 @@ void consume_ignored(char *source, size_t *pos) {
 }
 
 list_t *FILES;
+list_t *REQUIRED;
 
 int is_required(char *path) {
-  for (size_t i = 0; i < FILES->length; i++) {
-    list_t *pair = FILES->data[i];
-
-    if (strcmp(pair->data[0], path) == 0)
+  for (size_t i = 0; i < REQUIRED->length; i++)
+    if (strcmp(REQUIRED->data[i], path) == 0)
       return 1;
-  }
 
   return 0;
 }
@@ -1846,6 +1844,7 @@ void compile_node(buffer_t *gbuf, buffer_t *buf, list_t *ctx, stack_t *lstk, nod
       compile_into(source, gbuf, buf, ctx, lstk);
 
       list_pop(FILES);
+      list_push(REQUIRED, path);
       } break;
 
     case N_IFEXPR:
@@ -1962,6 +1961,7 @@ char *compile_file(char *filename, FILE *fd) {
 
 int main(int argc, char **argv) {
   FILES = list_new();
+  REQUIRED = list_new();
 
   char *out = compile_file("<stdin>", stdin);