| 197 | | switch (item->type) { |
| 198 | | case CI_CLOSE_GROUP: |
| 199 | | pos += 2; |
| 200 | | break; |
| 201 | | |
| 202 | | case CI_UNKNOWN: |
| 203 | | error = GBS_global_string_copy("Unknown flag '%c'", label); |
| 204 | | break; |
| 205 | | |
| 206 | | default: { |
| 207 | | const char *start_of_name = str+pos+2; |
| 208 | | const char *behind_name = strchr(start_of_name, '\1'); |
| 209 | | |
| 210 | | if (!behind_name) behind_name = strchr(start_of_name, '\0'); // eos |
| 211 | | gb_assert(behind_name); |
| 212 | | |
| 213 | | item->name = (char*)GB_calloc(1, behind_name-start_of_name+1); |
| 214 | | memcpy(item->name, start_of_name, behind_name-start_of_name); |
| 215 | | pos = behind_name-str; |
| 216 | | break; |
| | 197 | if (item->type == CI_CLOSE_GROUP) { |
| | 198 | pos += 2; |
| | 199 | } |
| | 200 | else { |
| | 201 | const char *start_of_name = str+pos+2; |
| | 202 | const char *behind_name = strchr(start_of_name, '\1'); |
| | 203 | |
| | 204 | if (!behind_name) behind_name = strchr(start_of_name, '\0'); // eos |
| | 205 | gb_assert(behind_name); |
| | 206 | |
| | 207 | char *data = GB_strpartdup(start_of_name, behind_name-1); |
| | 208 | if (item->type == CI_UNKNOWN) { |
| | 209 | error = GBS_global_string_copy("Unknown flag '%c' (followed by '%s')", label, data); |
| | 210 | free(data); |
| | 211 | } |
| | 212 | else { |
| | 213 | item->name = data; |
| | 214 | pos = behind_name-str; |