MCPcopy Create free account
hub / github.com/acl-dev/acl / acl_vstring_rstrstr

Function acl_vstring_rstrstr

lib_acl/src/stdlib/acl_vstring.c:702–733  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

700/* acl_vstring_rstrstr - locate byte in buffer */
701
702char *acl_vstring_rstrstr(ACL_VSTRING *vp, const char *needle)
703{
704 unsigned char *cp;
705 const unsigned char *np = 0, *needle_end;
706
707 if (vp == NULL || needle == NULL || *needle == 0) {
708 return NULL;
709 }
710
711 needle_end = (const unsigned char *) needle + strlen(needle) - 1;
712
713 for (cp = (unsigned char *) acl_vstring_end(vp) - 1;
714 cp >= (unsigned char *) acl_vstring_str(vp); cp--) {
715 if (np) {
716 if (*cp == *np) {
717 if (--np < (const unsigned char *) needle) {
718 return (char *) cp;
719 }
720 } else {
721 np = 0;
722 }
723 }
724 if (!np && *cp == *needle_end) {
725 np = needle_end - 1;
726 if (np < (const unsigned char *) needle) {
727 return (char *) cp;
728 }
729 }
730 }
731
732 return NULL;
733}
734
735/* acl_vstring_rstrcasestr - locate byte in buffer */
736

Callers 2

string_rfindFunction · 0.85
rfindMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…