From 61b8750baed6c7da1740de3f3de3005458d871cd Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Wed, 25 Aug 2021 22:56:24 +0100 Subject: [PATCH] Allowed long tokens within comments (typically URLs) --- projects/examples/demos/prng.tal | 4 ++-- src/uxnasm.c | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/projects/examples/demos/prng.tal b/projects/examples/demos/prng.tal index 2565811..38eb81f 100644 --- a/projects/examples/demos/prng.tal +++ b/projects/examples/demos/prng.tal @@ -56,7 +56,7 @@ ( returns the next number in a 65,535-long sequence, which is never zero but every other 16-bit number appears once before the sequence repeats ) - ( http://www.retroprogramming.com/2017/07/ xorshift-pseudorandom-numbers-in-z80.html ) + ( http://www.retroprogramming.com/2017/07/xorshift-pseudorandom-numbers-in-z80.html ) ,&seed LDR2 DUP2 #70 SFT2 EOR2 DUP2 #09 SFT2 EOR2 @@ -68,7 +68,7 @@ @prng2 ( -- number* ) ( returns the next number in a (2^32-1)-long sequence ) - ( http://b2d-f9r.blogspot.com/2010/08/ 16-bit-xorshift-rng-now-with-more.html ) + ( http://b2d-f9r.blogspot.com/2010/08/16-bit-xorshift-rng-now-with-more.html ) ,&x LDR2 DUP2 #50 SFT2 EOR2 DUP2 #03 SFT2 EOR2 diff --git a/src/uxnasm.c b/src/uxnasm.c index 1520bf7..a220af2 100644 --- a/src/uxnasm.c +++ b/src/uxnasm.c @@ -157,12 +157,12 @@ makemacro(char *name, FILE *f) return error("Macro name is invalid", name); m = &p.macros[p.mlen++]; scpy(name, m->name, 64); - while(fscanf(f, "%s", word)) { + while(fscanf(f, "%63s", word)) { if(word[0] == '{') continue; if(word[0] == '}') break; if(m->len > 64) return error("Macro too large", name); - if(slen(word) >= 64) + if(slen(word) >= 63) return error("Word too long", name); scpy(word, m->items[m->len++], 64); } @@ -290,8 +290,10 @@ pass1(FILE *f) int ccmnt = 0; Uint16 addr = 0; char w[64], scope[64], subw[64]; - while(fscanf(f, "%s", w) == 1) { + while(fscanf(f, "%63s", w) == 1) { if(skipblock(w, &ccmnt, '(', ')')) continue; + if(slen(w) == 63) + fprintf(stderr, "Warning: token beginning with \"%s\" is too long\n", w); if(w[0] == '|') { if(!sihx(w + 1)) return error("Pass 1 - Invalid padding", w); @@ -320,7 +322,7 @@ pass2(FILE *f) { int ccmnt = 0, cmacr = 0; char w[64], scope[64], subw[64]; - while(fscanf(f, "%s", w) == 1) { + while(fscanf(f, "%63s", w) == 1) { if(w[0] == '%') continue; if(w[0] == '&') continue; if(w[0] == '[') continue;