(uxnasm) Read characters into char buffers

This commit is contained in:
Devine Lu Linvega 2024-03-26 13:45:08 -07:00
parent 832ba26e30
commit 0ae8812680
1 changed files with 11 additions and 14 deletions

View File

@ -278,10 +278,9 @@ writehex(char *w)
static int static int
tokenize(FILE *f) tokenize(FILE *f)
{ {
unsigned int buf; char c;
char *cptr = token; char *cptr = token;
while(fread(&buf, 1, 1, f)) { while(fread(&c, 1, 1, f)) {
char c = (char)buf;
if(c < 0x21) { if(c < 0x21) {
*cptr++ = 0x00; *cptr++ = 0x00;
if(c == 0x0a) if(c == 0x0a)
@ -315,17 +314,15 @@ doinclude(char *filename)
static int static int
walkcomment(char *w, FILE *f) walkcomment(char *w, FILE *f)
{ {
int i = 1; int depth = 1;
unsigned int buf; char c;
if(slen(w) != 1) if(slen(w) == 1)
return 0; while(fread(&c, 1, 1, f)) {
while(fread(&buf, 1, 1, f)) { if(c == '(')
char c = (char)buf; depth++;
if(c == '(') else if(c == ')' && --depth < 1)
i++; return 1;
else if(c == ')' && --i < 1) }
return 1;
}
return 0; return 0;
} }