shithub: fnt

Download patch

ref: d80042223e0f2b2bdcd6342fbf1d76e36afcf9e7
parent: bae955e0041d1ed9d5f18fe90145f1b12ee0e16e
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Wed Jul 17 23:28:22 EDT 2024

tests: allow specifying rune as hex/dec number with -r

--- a/test.h
+++ b/test.h
@@ -1,3 +1,5 @@
+#include <ctype.h>
+
 static void
 printusage(Otfile *f)
 {
@@ -185,7 +187,7 @@
 		highlight = strtol(EARGF(usage(&out)), nil, 0); \
 		break; \
 	case 'i': \
-		if(rune != Runeerror){ \
+		if(rune != NoRune){ \
 errboth: \
 			out.print(out.aux, "can't specify both rune and glyph\n"); \
 			usage(&out); \
@@ -198,14 +200,17 @@
 	case 'p': \
 		ppem = strtod(EARGF(usage(&out)), nil); \
 		break; \
-	case 'r': \
+	case 'r': { \
+		char *s = EARGF(usage(&out)); \
 		if(gind >= 0) \
 			goto errboth; \
-		if(chartorune(&rune, EARGF(usage(&out))) == 1 && rune == Runeerror){ \
+		if(isdigit(*s) && strlen(s) > 1) \
+			rune = strtol(s, nil, 0); \
+		else if(chartorune(&rune, s) == 1 && rune == Runeerror){ \
 			out.print(out.aux, "invalid rune\n"); \
 			usage(&out); \
 		} \
-		break; \
+		} break; \
 	case 'R': \
 		runesonly++; \
 		break; \