History

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

Sigrid Solveig Haflínudóttir committed 2 years ago

Commit d8004221 parent bae955e1 file · +9 −4Browse files

Unified · Split

test.h+9−4
@@ -1,3 +1,5 @@
1+#include <ctype.h>
2+
13 static void
24 printusage(Otfile *f)
35 {
@@ -185,7 +187,7 @@ glypherr: · 181 unmodified lines
185187 highlight = strtol(EARGF(usage(&out)), nil, 0); \
186188 break; \
187189 case 'i': \
188− if(rune != Runeerror){ \
190+ if(rune != NoRune){ \
189191 errboth: \
190192 out.print(out.aux, "can't specify both rune and glyph\n"); \
191193 usage(&out); \
@@ -198,14 +200,17 @@ errboth: \ · 6 unmodified lines
198200 case 'p': \
199201 ppem = strtod(EARGF(usage(&out)), nil); \
200202 break; \
201− case 'r': \
203+ case 'r': { \
204+ char *s = EARGF(usage(&out)); \
202205 if(gind >= 0) \
203206 goto errboth; \
204− if(chartorune(&rune, EARGF(usage(&out))) == 1 && rune == Runeerror){ \
207+ if(isdigit(*s) && strlen(s) > 1) \
208+ rune = strtol(s, nil, 0); \
209+ else if(chartorune(&rune, s) == 1 && rune == Runeerror){ \
205210 out.print(out.aux, "invalid rune\n"); \
206211 usage(&out); \
207212 } \
208− break; \
213+ } break; \
209214 case 'R': \
210215 runesonly++; \
211216 break; \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t