mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
LexerState's 'size' and 'offset' for mmapped files are unsigned
These were using signed 'off_t' because that is the type of 'st_size' from 'stat()', but neither one can be negative.
This commit is contained in:
@@ -309,7 +309,7 @@ struct Expansion {
|
|||||||
char const *unowned;
|
char const *unowned;
|
||||||
char *owned;
|
char *owned;
|
||||||
} contents;
|
} contents;
|
||||||
size_t len;
|
size_t len; /* Length of the contents */
|
||||||
size_t totalLen;
|
size_t totalLen;
|
||||||
size_t distance; /* Distance between the beginning of this expansion and of its parent */
|
size_t distance; /* Distance between the beginning of this expansion and of its parent */
|
||||||
bool owned; /* Whether or not to free contents when this expansion is freed */
|
bool owned; /* Whether or not to free contents when this expansion is freed */
|
||||||
@@ -329,8 +329,8 @@ struct LexerState {
|
|||||||
union {
|
union {
|
||||||
struct { /* If mmap()ed */
|
struct { /* If mmap()ed */
|
||||||
char *ptr; /* Technically `const` during the lexer's execution */
|
char *ptr; /* Technically `const` during the lexer's execution */
|
||||||
off_t size;
|
size_t size;
|
||||||
off_t offset;
|
size_t offset;
|
||||||
bool isReferenced; /* If a macro in this file requires not unmapping it */
|
bool isReferenced; /* If a macro in this file requires not unmapping it */
|
||||||
};
|
};
|
||||||
struct { /* Otherwise */
|
struct { /* Otherwise */
|
||||||
@@ -501,7 +501,8 @@ struct LexerState *lexer_OpenFile(char const *path)
|
|||||||
state->isMmapped = true;
|
state->isMmapped = true;
|
||||||
state->isReferenced = false; // By default, a state isn't referenced
|
state->isReferenced = false; // By default, a state isn't referenced
|
||||||
state->ptr = mappingAddr;
|
state->ptr = mappingAddr;
|
||||||
state->size = fileInfo.st_size;
|
assert(fileInfo.st_size >= 0);
|
||||||
|
state->size = (size_t)fileInfo.st_size;
|
||||||
state->offset = 0;
|
state->offset = 0;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
@@ -876,7 +877,7 @@ restart:
|
|||||||
if (lexerState->macroArgScanDistance > 0)
|
if (lexerState->macroArgScanDistance > 0)
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
lexerState->macroArgScanDistance = 1; /* Do not consider again */
|
lexerState->macroArgScanDistance++; /* Do not consider again */
|
||||||
|
|
||||||
if (c == '\\' && !lexerState->disableMacroArgs) {
|
if (c == '\\' && !lexerState->disableMacroArgs) {
|
||||||
/* If character is a backslash, check for a macro arg */
|
/* If character is a backslash, check for a macro arg */
|
||||||
|
|||||||
Reference in New Issue
Block a user