mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-24 03:52:08 +00:00
Improve some const correctness in RGBASM
This commit is contained in:
@@ -91,7 +91,7 @@ void charmap_Pop() {
|
||||
charmapStack.pop();
|
||||
}
|
||||
|
||||
void charmap_Add(char *mapping, uint8_t value) {
|
||||
void charmap_Add(char const *mapping, uint8_t value) {
|
||||
Charmap &charmap = *currentCharmap;
|
||||
size_t nodeIdx = 0;
|
||||
|
||||
|
||||
@@ -70,11 +70,11 @@ void opt_l(bool warn) {
|
||||
warnOnLdOpt = warn;
|
||||
}
|
||||
|
||||
void opt_W(char *flag) {
|
||||
void opt_W(char const *flag) {
|
||||
processWarningFlag(flag);
|
||||
}
|
||||
|
||||
void opt_Parse(char *s) {
|
||||
void opt_Parse(char const *s) {
|
||||
switch (s[0]) {
|
||||
case 'b':
|
||||
if (strlen(&s[1]) == 2)
|
||||
|
||||
@@ -210,7 +210,7 @@ static uint8_t const *metaWarningCommands[NB_META_WARNINGS] = {
|
||||
_weverythingCommands,
|
||||
};
|
||||
|
||||
void processWarningFlag(char *flag) {
|
||||
void processWarningFlag(char const *flag) {
|
||||
static bool setError = false;
|
||||
|
||||
// First, try to match against a "meta" warning
|
||||
@@ -235,7 +235,7 @@ void processWarningFlag(char *flag) {
|
||||
|
||||
// If it's not a meta warning, specially check against `-Werror`
|
||||
if (!strncmp(flag, "error", strlen("error"))) {
|
||||
char *errorFlag = flag + strlen("error");
|
||||
char const *errorFlag = flag + strlen("error");
|
||||
|
||||
switch (*errorFlag) {
|
||||
case '\0':
|
||||
@@ -260,12 +260,12 @@ void processWarningFlag(char *flag) {
|
||||
// Not an error, then check if this is a negation
|
||||
: strncmp(flag, "no-", strlen("no-")) ? WARNING_ENABLED
|
||||
: WARNING_DISABLED;
|
||||
char *rootFlag = state == WARNING_DISABLED ? flag + strlen("no-") : flag;
|
||||
char const *rootFlag = state == WARNING_DISABLED ? flag + strlen("no-") : flag;
|
||||
|
||||
// Is this a "parametric" warning?
|
||||
if (state != WARNING_DISABLED) { // The `no-` form cannot be parametrized
|
||||
// First, check if there is an "equals" sign followed by a decimal number
|
||||
char *equals = strchr(rootFlag, '=');
|
||||
char const *equals = strchr(rootFlag, '=');
|
||||
|
||||
if (equals && equals[1] != '\0') { // Ignore an equal sign at the very end as well
|
||||
// Is the rest of the string a decimal number?
|
||||
@@ -299,8 +299,13 @@ void processWarningFlag(char *flag) {
|
||||
warnx("Ignoring nonsensical warning flag \"%s\"\n", flag);
|
||||
return;
|
||||
}
|
||||
*equals = '\0'; // Truncate the param at the '='
|
||||
if (tryProcessParamWarning(rootFlag, param, param == 0 ? WARNING_DISABLED : state))
|
||||
|
||||
std::string truncFlag = rootFlag;
|
||||
|
||||
truncFlag.resize(equals - rootFlag); // Truncate the param at the '='
|
||||
if (tryProcessParamWarning(
|
||||
truncFlag.c_str(), param, param == 0 ? WARNING_DISABLED : state
|
||||
))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user