translate: stop data parse on imports
[ia32rtools.git] / tools / translate.c
index cc6795a..1fa3d95 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "my_assert.h"
 #include "my_str.h"
+#include "common.h"
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
 #define IS(w, y) !strcmp(w, y)
@@ -6350,30 +6351,6 @@ static void output_hdr(FILE *fout)
     fwrite(line, 1, strlen(line), fout);
 }
 
-// read a line, truncating it if it doesn't fit
-static char *my_fgets(char *s, size_t size, FILE *stream)
-{
-  char *ret, *ret2;
-  char buf[64];
-  int p;
-
-  p = size - 2;
-  if (p >= 0)
-    s[p] = 0;
-
-  ret = fgets(s, size, stream);
-  if (ret != NULL && p >= 0 && s[p] != 0 && s[p] != '\n') {
-    p = sizeof(buf) - 2;
-    do {
-      buf[p] = 0;
-      ret2 = fgets(buf, sizeof(buf), stream);
-    }
-    while (ret2 != NULL && buf[p] != 0 && buf[p] != '\n');
-  }
-
-  return ret;
-}
-
 // '=' needs special treatment
 // also ' quote
 static char *next_word_s(char *w, size_t wsize, char *s)
@@ -6473,6 +6450,11 @@ static void scan_variables(FILE *fasm)
       if (wordc < 2)
         continue;
 
+      if (IS_START(words[0], "__IMPORT_DESCRIPTOR_")) {
+        // when this starts, we don't need anything from this section
+        break;
+      }
+
       if ((hg_var_cnt & 0xff) == 0) {
         hg_vars = realloc(hg_vars, sizeof(hg_vars[0])
                    * (hg_var_cnt + 0x100));