MCPcopy Create free account
hub / github.com/pydata/numexpr / stringcmp

Function stringcmp

numexpr3/string_functions.hpp:448–472  ·  view source on GitHub ↗

//////////////////////////////////////////////////////// Original string functions in interpreter.cpp below here:// ////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

446// Original string functions in interpreter.cpp below here://
447/////////////////////////////////////////////////////////////
448int
449stringcmp(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
474int
475stringcontains(const char *haystack_start, const char *needle_start, npy_intp max_haystack_len, npy_intp max_needle_len)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…