| 92 | } |
| 93 | |
| 94 | static int ParseScanSet(const char* format, char (*cs)[32]) |
| 95 | { |
| 96 | const char* f = format; |
| 97 | bool is_neg = *f == '^'; |
| 98 | if (is_neg) { |
| 99 | memset(cs, 0xFF, sizeof(*cs)); |
| 100 | ++f; |
| 101 | } else { |
| 102 | memset(cs, 0, sizeof(*cs)); |
| 103 | } |
| 104 | |
| 105 | while (*f != ']') { |
| 106 | if (f - format > 256) { |
| 107 | LOG(DFATAL) << "Invalid scanset, too long to see the ending ']'"; |
| 108 | return 0; |
| 109 | } |
| 110 | if (*f == '\0') { |
| 111 | LOG(DFATAL) << "Invalid scanset, unexpected end before ']'"; |
| 112 | return 0; |
| 113 | } |
| 114 | |
| 115 | if (f[1] == '-' && f[2] != '\0' && f[2] != ']') { |
| 116 | // Process char range |
| 117 | ScanSetSetCharRange(cs, f[0], f[2], !is_neg); |
| 118 | f += 3; |
| 119 | } else { |
| 120 | // Single char |
| 121 | ScanSetSetChar(cs, *f, !is_neg); |
| 122 | f += 1; |
| 123 | } |
| 124 | } |
| 125 | ++f; |
| 126 | |
| 127 | return f - format; |
| 128 | } |
| 129 | |
| 130 | static int ParseSpecifier(const char* format, char* specifier) |
| 131 | { |
no test coverage detected