--- /dev/null
+// 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;
+}
+
#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)
name[0] = 0;
- while (fgets(line, sizeof(line), fasm))
+ while (my_fgets(line, sizeof(line), fasm))
{
wordc = 0;
asmln++;
if (*p == 0)
continue;
- if (*p == ';') {
- while (strlen(line) == sizeof(line) - 1) {
- // one of those long comment lines..
- if (!fgets(line, sizeof(line), fasm))
- break;
- }
+ if (*p == ';')
continue;
- }
for (wordc = 0; wordc < ARRAY_SIZE(words); wordc++) {
p = sskip(next_word(words[wordc], sizeof(words[0]), p));
frlist = fopen(argv[arg], "r");
my_assert_not(frlist, NULL);
- while (fgets(line, sizeof(line), frlist)) {
+ while (my_fgets(line, sizeof(line), frlist)) {
p = sskip(line);
if (*p == 0 || *p == ';')
continue;
if (!header_mode)
fprintf(fout, ".align %d\n", align_value(4));
- while (fgets(line, sizeof(line), fasm))
+ while (my_fgets(line, sizeof(line), fasm))
{
sym = NULL;
asmln++;
#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)
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)
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));