mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-27 05:22:07 +00:00
Use QUOTEDSTRLEN macro instead of sizeof or strlen
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "helpers.hpp" // QUOTEDSTRLEN
|
||||
#include "util.hpp"
|
||||
|
||||
#include "asm/fixpoint.hpp"
|
||||
@@ -2233,7 +2234,7 @@ Capture lexer_CaptureRept() {
|
||||
endCapture(capture);
|
||||
// The final ENDR has been captured, but we don't want it!
|
||||
// We know we have read exactly "ENDR", not e.g. an EQUS
|
||||
capture.span.size -= strlen("ENDR");
|
||||
capture.span.size -= QUOTEDSTRLEN("ENDR");
|
||||
return capture;
|
||||
}
|
||||
depth--;
|
||||
@@ -2279,7 +2280,7 @@ Capture lexer_CaptureMacro() {
|
||||
endCapture(capture);
|
||||
// The ENDM has been captured, but we don't want it!
|
||||
// We know we have read exactly "ENDM", not e.g. an EQUS
|
||||
capture.span.size -= strlen("ENDM");
|
||||
capture.span.size -= QUOTEDSTRLEN("ENDM");
|
||||
return capture;
|
||||
|
||||
default:
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "error.hpp"
|
||||
#include "extern/getopt.hpp"
|
||||
#include "helpers.hpp" // Defer
|
||||
#include "helpers.hpp"
|
||||
#include "parser.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
@@ -45,7 +45,7 @@ static std::string make_escape(std::string &str) {
|
||||
break;
|
||||
escaped.append(str, pos, nextPos - pos);
|
||||
escaped.append("$$");
|
||||
pos = nextPos + sizeof("$") - 1;
|
||||
pos = nextPos + QUOTEDSTRLEN("$");
|
||||
}
|
||||
escaped.append(str, pos, str.length() - pos);
|
||||
return escaped;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "error.hpp"
|
||||
#include "helpers.hpp" // QUOTEDSTRLEN
|
||||
#include "itertools.hpp"
|
||||
|
||||
#include "asm/fstack.hpp"
|
||||
@@ -230,8 +231,8 @@ void processWarningFlag(char const *flag) {
|
||||
}
|
||||
|
||||
// If it's not a meta warning, specially check against `-Werror`
|
||||
if (!strncmp(flag, "error", strlen("error"))) {
|
||||
char const *errorFlag = flag + strlen("error");
|
||||
if (!strncmp(flag, "error", QUOTEDSTRLEN("error"))) {
|
||||
char const *errorFlag = flag + QUOTEDSTRLEN("error");
|
||||
|
||||
switch (*errorFlag) {
|
||||
case '\0':
|
||||
@@ -254,9 +255,9 @@ void processWarningFlag(char const *flag) {
|
||||
|
||||
WarningState state = setError ? WARNING_ERROR
|
||||
// Not an error, then check if this is a negation
|
||||
: strncmp(flag, "no-", strlen("no-")) ? WARNING_ENABLED
|
||||
: WARNING_DISABLED;
|
||||
char const *rootFlag = state == WARNING_DISABLED ? flag + strlen("no-") : flag;
|
||||
: strncmp(flag, "no-", QUOTEDSTRLEN("no-")) ? WARNING_ENABLED
|
||||
: WARNING_DISABLED;
|
||||
char const *rootFlag = state == WARNING_DISABLED ? flag + QUOTEDSTRLEN("no-") : flag;
|
||||
|
||||
// Is this a "parametric" warning?
|
||||
if (state != WARNING_DISABLED) { // The `no-` form cannot be parametrized
|
||||
|
||||
Reference in New Issue
Block a user