* Assuming that the separator is the next bit in the string (file), skip it. * * Single spaces in the separator are matched to arbitrary-long sequences * of whitespace in the input. If the separator consists only of spaces, * it matches one or more whitespace characters. * * If we can't match the separator, return -2. * If we hit the end of the string (file), return -1. * Otherwise, return
| 175 | * Otherwise, return 0. |
| 176 | */ |
| 177 | static int |
| 178 | fromstr_skip_separator(char **s, const char *sep, const char *end) |
| 179 | { |
| 180 | char *string = *s; |
| 181 | int result = 0; |
| 182 | |
| 183 | while (1) { |
| 184 | char c = *string; |
| 185 | if (string_is_fully_read(string, end)) { |
| 186 | result = -1; |
| 187 | break; |
| 188 | } |
| 189 | else if (*sep == '\0') { |
| 190 | if (string != *s) { |
| 191 | /* matched separator */ |
| 192 | result = 0; |
| 193 | break; |
| 194 | } |
| 195 | else { |
| 196 | /* separator was whitespace wildcard that didn't match */ |
| 197 | result = -2; |
| 198 | break; |
| 199 | } |
| 200 | } |
| 201 | else if (*sep == ' ') { |
| 202 | /* whitespace wildcard */ |
| 203 | if (!isspace(c)) { |
| 204 | sep++; |
| 205 | continue; |
| 206 | } |
| 207 | } |
| 208 | else if (*sep != c) { |
| 209 | result = -2; |
| 210 | break; |
| 211 | } |
| 212 | else { |
| 213 | sep++; |
| 214 | } |
| 215 | string++; |
| 216 | } |
| 217 | *s = string; |
| 218 | return result; |
| 219 | } |
| 220 | |
| 221 | static int |
| 222 | fromfile_skip_separator(FILE **fp, const char *sep, void *NPY_UNUSED(stream_data)) |
nothing calls this directly
no test coverage detected