MCPcopy Create free account
hub / github.com/numpy/numpy / fromstr_skip_separator

Function fromstr_skip_separator

numpy/core/src/multiarray/ctors.c:177–219  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

175 * Otherwise, return 0.
176 */
177static int
178fromstr_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
221static int
222fromfile_skip_separator(FILE **fp, const char *sep, void *NPY_UNUSED(stream_data))

Callers

nothing calls this directly

Calls 2

string_is_fully_readFunction · 0.85
isspaceFunction · 0.85

Tested by

no test coverage detected