MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / _utstring_findR

Function _utstring_findR

libCacheSim/dataStructure/ut/utstring.h:284–314  ·  view source on GitHub ↗

Search data from right to left. ( Multiple search mode. ) */

Source from the content-addressed store, hash-verified

282
283/* Search data from right to left. ( Multiple search mode. ) */
284UTSTRING_UNUSED static long _utstring_findR(
285 const char *P_Haystack,
286 size_t P_HaystackLen,
287 const char *P_Needle,
288 size_t P_NeedleLen,
289 long *P_KMP_Table)
290{
291 long i, j;
292 long V_FindPosition = -1;
293
294 /* Search from right to left. */
295 j = (P_HaystackLen - 1);
296 i = (P_NeedleLen - 1);
297 while ( (j >= 0) && (j >= i) )
298 {
299 while ( (i < (int)P_NeedleLen) && (P_Needle[i] != P_Haystack[j]) )
300 {
301 i = P_KMP_Table[i + 1];
302 }
303 i--;
304 j--;
305 if (i < 0)
306 {
307 /* Found. */
308 V_FindPosition = j + 1;
309 break;
310 }
311 }
312
313 return V_FindPosition;
314}
315
316
317/* Search data from left to right. ( One time search mode. ) */

Callers 1

utstring_findRFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected