handle .ds correctly, and forward refs in .if

This commit is contained in:
curt mayer
2020-02-20 11:38:32 -08:00
parent 2cc61c3804
commit a03d15fd2f
2 changed files with 47 additions and 2 deletions

View File

@@ -631,7 +631,7 @@ static void pif(const char *p)
return;
p = skipws(p + sizeof(IFSTR) - 1);
if (!expr(p, &v, s_pc, 0, &ex_ec, &ep)) {
if (!expr(p, &v, s_pc, 1, &ex_ec, &ep)) {
s_skipon = 1;
exprint(ex_ec, s_line, ep);
newerr();

View File

@@ -51,6 +51,7 @@ static const char *d_export(const char *);
static const char *d_end(const char *);
static const char *d_equ(const char *);
static const char *d_fill(const char *);
static const char *d_ds(const char *);
static const char *d_list(const char *);
static const char *d_lsfirst(const char *);
static const char *d_module(const char *);
@@ -76,7 +77,7 @@ static struct direc {
{ "CHK", d_chk },
{ "CODES", d_codes },
{ "DB", d_byte },
{ "DS", d_fill },
{ "DS", d_ds },
{ "DW", d_word },
{ "ECHO", d_echo },
{ "EJECT", d_eject },
@@ -681,6 +682,50 @@ static const char *d_fill(const char *p)
return p;
}
static const char *d_ds(const char *p)
{
int n, v, er;
const char *q;
enum expr_ecode ecode;
const char *ep, *eps;
eps = p;
er = 0;
p = expr(p, &n, s_pc, 0, &ecode, &ep);
if (p == NULL) {
exprint(ecode, s_pline, ep);
newerr();
return NULL;
}
if (n < 0) {
eprint(_("number of positions to space over is negative (%d)\n"), n);
eprcol(s_pline, eps);
exit(EXIT_FAILURE);
}
v = 255;
p = skipws(p);
if (*p == ',') {
p = skipws(p + 1);
q = expr(p, &v, s_pc, s_pass == 0, &ecode, &ep);
if (q == NULL) {
er = 1;
exprint(ecode, s_pline, ep);
newerr();
} else {
p = q;
}
}
s_pc += n;
if (er)
return NULL;
else
return p;
}
static const char *d_lsfirst(const char *p)
{
s_msbword = 0;