//////////////////////////////////////////////////////// Original string functions in interpreter.cpp below here:// ////////////////////////////////////////////////////////
| 446 | // Original string functions in interpreter.cpp below here:// |
| 447 | ///////////////////////////////////////////////////////////// |
| 448 | int |
| 449 | stringcmp(const char *s1, const char *s2, npy_intp maxlen1, npy_intp maxlen2) |
| 450 | { |
| 451 | npy_intp maxlen, nextpos; |
| 452 | // Point to this when the end of a string is found, to simulate infinte |
| 453 | // trailing NULL characters. |
| 454 | const char null = 0; |
| 455 | |
| 456 | // First check if some of the operands is the empty string and if so, |
| 457 | // just check that the first char of the other is the NULL one. |
| 458 | // Fixes #121 |
| 459 | if (maxlen2 == 0) return *s1 != null; |
| 460 | if (maxlen1 == 0) return *s2 != null; |
| 461 | |
| 462 | maxlen = (maxlen1 > maxlen2) ? maxlen1 : maxlen2; |
| 463 | for (nextpos = 1; nextpos <= maxlen; nextpos++) { |
| 464 | if (*s1 < *s2) |
| 465 | return -1; |
| 466 | if (*s1 > *s2) |
| 467 | return +1; |
| 468 | s1 = (nextpos >= maxlen1) ? &null : s1+1; |
| 469 | s2 = (nextpos >= maxlen2) ? &null : s2+1; |
| 470 | } |
| 471 | return 0; |
| 472 | } |
| 473 | |
| 474 | int |
| 475 | stringcontains(const char *haystack_start, const char *needle_start, npy_intp max_haystack_len, npy_intp max_needle_len) |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…