shithub: rgbds

Download patch

ref: a1107fc5cfa552f9e1958de688f82aa5129adbcd
parent: 969412af246eb7ca8fe1f5799281eb0df67a6102
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Sat Oct 1 10:09:02 EDT 2022

Refactor `!!x` to `x != 0`

Also limit comments and docs to single "!"s

--- a/include/link/section.h
+++ b/include/link/section.h
@@ -10,7 +10,7 @@
 #ifndef RGBDS_LINK_SECTION_H
 #define RGBDS_LINK_SECTION_H
 
-// GUIDELINE: external code MUST NOT BE AWARE of the data structure used!!
+// GUIDELINE: external code MUST NOT BE AWARE of the data structure used!
 
 #include <stdint.h>
 #include <stdbool.h>
--- a/include/link/symbol.h
+++ b/include/link/symbol.h
@@ -10,7 +10,7 @@
 #ifndef RGBDS_LINK_SYMBOL_H
 #define RGBDS_LINK_SYMBOL_H
 
-// GUIDELINE: external code MUST NOT BE AWARE of the data structure used!!
+// GUIDELINE: external code MUST NOT BE AWARE of the data structure used!
 
 #include <stdint.h>
 
--- a/man/rgbasm.5
+++ b/man/rgbasm.5
@@ -1327,7 +1327,7 @@
 .Ss Purging symbols
 .Ic PURGE
 allows you to completely remove a symbol from the symbol table as if it had never existed.
-.Em USE WITH EXTREME CAUTION!!!
+.Em USE WITH EXTREME CAUTION!
 I can't stress this enough,
 .Sy you seriously need to know what you are doing .
 DON'T purge a symbol that you use in expressions the linker needs to calculate.
--- a/src/asm/charmap.c
+++ b/src/asm/charmap.c
@@ -27,7 +27,7 @@
 struct Charnode {
 	bool isTerminal; // Whether there exists a mapping that ends here
 	uint8_t value; // If the above is true, its corresponding value
-	// This MUST be indexes and not pointers, because pointers get invalidated by `realloc`!!
+	// This MUST be indexes and not pointers, because pointers get invalidated by `realloc`!
 	size_t next[255]; // Indexes of where to go next, 0 = nowhere
 };
 
--- a/src/asm/format.c
+++ b/src/asm/format.c
@@ -249,7 +249,7 @@
 	}
 
 	size_t len = strlen(valueBuf);
-	size_t numLen = !!sign + !!prefix + len;
+	size_t numLen = (sign != 0) + (prefix != 0) + len;
 	size_t totalLen = fmt->width > numLen ? fmt->width : numLen;
 
 	if (totalLen > bufLen - 1) { // bufLen includes terminator
--- a/src/asm/fstack.c
+++ b/src/asm/fstack.c
@@ -291,7 +291,7 @@
 }
 
 // Make sure not to switch the lexer state before calling this, so the saved line no is correct.
-// BE CAREFUL!! This modifies the file stack directly, you should have set up the file info first.
+// BE CAREFUL! This modifies the file stack directly, you should have set up the file info first.
 // Callers should set contextStack->lexerState after this so it is not NULL.
 static void newContext(struct FileStackNode *fileInfo)
 {
@@ -313,7 +313,7 @@
 	context->forName = NULL;
 
 	// Link new entry to its parent so it's reachable later
-	// ERRORS SHOULD NOT OCCUR AFTER THIS!!
+	// ERRORS SHOULD NOT OCCUR AFTER THIS!
 	context->parent = contextStack;
 	contextStack = context;
 }
--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -101,7 +101,7 @@
 		// Account for the extra backslash inserted below
 		if (fileName[i] == '"')
 			j++;
-		// Ensure there will be enough room; DO NOT PRINT ANYTHING ABOVE THIS!!
+		// Ensure there will be enough room; DO NOT PRINT ANYTHING ABOVE THIS!
 		if (j + 2 >= bufsize) { // Always keep room for 2 tail chars
 			bufsize = bufsize ? bufsize * 2 : 64;
 			buf = realloc(buf, bufsize);
@@ -590,7 +590,7 @@
 	}
 	char name[MAXSYMLEN + 1];
 
-	sym_WriteAnonLabelName(name, 0, true); // The direction is important!!
+	sym_WriteAnonLabelName(name, 0, true); // The direction is important!
 	anonLabelID++;
 	return addLabel(name);
 }
--- a/src/link/patch.c
+++ b/src/link/patch.c
@@ -146,7 +146,7 @@
 		isError = false;
 
 		// Be VERY careful with two `popRPN` in the same expression.
-		// C does not guarantee order of evaluation of operands!!
+		// C does not guarantee order of evaluation of operands!
 		// So, if there are two `popRPN` in the same expression, make
 		// sure the operation is commutative.
 		switch (command) {