| 168 | static const char16_t nulStr[] = { 0 }; |
| 169 | |
| 170 | static uint32_t parse_flags(const char16_t* str, size_t len, |
| 171 | const flag_entry* flags, bool* outError = NULL) |
| 172 | { |
| 173 | while (len > 0 && isspace(*str)) { |
| 174 | str++; |
| 175 | len--; |
| 176 | } |
| 177 | while (len > 0 && isspace(str[len-1])) { |
| 178 | len--; |
| 179 | } |
| 180 | |
| 181 | const char16_t* const end = str + len; |
| 182 | uint32_t value = 0; |
| 183 | |
| 184 | while (str < end) { |
| 185 | const char16_t* div = str; |
| 186 | while (div < end && *div != '|') { |
| 187 | div++; |
| 188 | } |
| 189 | |
| 190 | const flag_entry* cur = flags; |
| 191 | while (cur->name) { |
| 192 | if (strzcmp16(cur->name, cur->nameLen, str, div-str) == 0) { |
| 193 | value |= cur->value; |
| 194 | break; |
| 195 | } |
| 196 | cur++; |
| 197 | } |
| 198 | |
| 199 | if (!cur->name) { |
| 200 | if (outError) *outError = true; |
| 201 | return 0; |
| 202 | } |
| 203 | |
| 204 | str = div < end ? div+1 : div; |
| 205 | } |
| 206 | |
| 207 | if (outError) *outError = false; |
| 208 | return value; |
| 209 | } |
| 210 | |
| 211 | static String16 mayOrMust(int type, int flags) |
| 212 | { |
no outgoing calls
no test coverage detected