Reuse isWhitespace and isNewline, also refactoring readAtFile

This commit is contained in:
Rangi42
2025-08-05 13:46:53 -04:00
parent 98c5c7f776
commit 504a45a4ed
5 changed files with 34 additions and 61 deletions

View File

@@ -5,6 +5,14 @@
#include <stdint.h>
#include <stdio.h>
bool isWhitespace(int c) {
return c == ' ' || c == '\t';
}
bool isNewline(int c) {
return c == '\r' || c == '\n';
}
bool startsIdentifier(int c) {
// This returns false for anonymous labels, which internally start with a '!',
// and for section fragment literal labels, which internally start with a '$'.
@@ -25,7 +33,8 @@ char const *printChar(int c) {
return "EOF";
}
if (isprint(c)) {
// Handle printable ASCII characters
if (c >= ' ' && c <= '~') {
buf[0] = '\'';
buf[1] = c;
buf[2] = '\'';