Search data from left to right. ( One time search mode. ) */
| 316 | |
| 317 | /* Search data from left to right. ( One time search mode. ) */ |
| 318 | UTSTRING_UNUSED static long utstring_find( |
| 319 | UT_string *s, |
| 320 | long P_StartPosition, /* Start from 0. -1 means last position. */ |
| 321 | const char *P_Needle, |
| 322 | size_t P_NeedleLen) |
| 323 | { |
| 324 | long V_StartPosition; |
| 325 | long V_HaystackLen; |
| 326 | long *V_KMP_Table; |
| 327 | long V_FindPosition = -1; |
| 328 | |
| 329 | if (P_StartPosition < 0) |
| 330 | { |
| 331 | V_StartPosition = s->i + P_StartPosition; |
| 332 | } |
| 333 | else |
| 334 | { |
| 335 | V_StartPosition = P_StartPosition; |
| 336 | } |
| 337 | V_HaystackLen = s->i - V_StartPosition; |
| 338 | if ( (V_HaystackLen >= (long) P_NeedleLen) && (P_NeedleLen > 0) ) |
| 339 | { |
| 340 | V_KMP_Table = (long *)malloc(sizeof(long) * (P_NeedleLen + 1)); |
| 341 | if (V_KMP_Table != NULL) |
| 342 | { |
| 343 | _utstring_BuildTable(P_Needle, P_NeedleLen, V_KMP_Table); |
| 344 | |
| 345 | V_FindPosition = _utstring_find(s->d + V_StartPosition, |
| 346 | V_HaystackLen, |
| 347 | P_Needle, |
| 348 | P_NeedleLen, |
| 349 | V_KMP_Table); |
| 350 | if (V_FindPosition >= 0) |
| 351 | { |
| 352 | V_FindPosition += V_StartPosition; |
| 353 | } |
| 354 | |
| 355 | free(V_KMP_Table); |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | return V_FindPosition; |
| 360 | } |
| 361 | |
| 362 | |
| 363 | /* Search data from right to left. ( One time search mode. ) */ |
nothing calls this directly
no test coverage detected