mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Reuse isWhitespace and isNewline, also refactoring readAtFile
This commit is contained in:
11
src/util.cpp
11
src/util.cpp
@@ -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] = '\'';
|
||||
|
||||
Reference in New Issue
Block a user