File tree Expand file tree Collapse file tree 1 file changed +5
-16
lines changed Expand file tree Collapse file tree 1 file changed +5
-16
lines changed Original file line number Diff line number Diff line change @@ -48,25 +48,14 @@ int jq_set_colors(const char *code_str) {
48
48
49
49
for (num_colors = 0 ;; num_colors ++ ) {
50
50
codes [num_colors ] = code_str ;
51
- letter :
52
- switch (code_str [0 ]) {
53
- // technically posix doesn't specify ascii so a range wouldn't be portable
54
- case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : case ';' :
55
- code_str ++ ;
56
- goto letter ; // loops until end of color code
57
- case ':' :
58
- code_str ++ ;
59
- continue ; // next color
60
- case '\0' :
61
- goto set_codes_end ; // done
62
- default :
51
+ code_str += strspn (code_str , "0123456789;" );
52
+ if (code_str [0 ] == '\0' || num_colors + 1 >= COLORS_LEN ) {
53
+ break ;
54
+ } else if (code_str [0 ] != ':' ) {
63
55
return 0 ; // invalid character
64
56
}
65
- if (num_colors + 1 >= COLORS_LEN ) {
66
- goto set_codes_end ; // done
67
- }
57
+ code_str ++ ;
68
58
}
69
- set_codes_end :
70
59
if (codes [num_colors ] != code_str ) {
71
60
// count the last color and store its end (plus one byte for consistency with starts)
72
61
// an empty last color would be ignored (for cases like "" and "0:")
You can’t perform that action at this time.
0 commit comments