Search data from left to right. ( Multiple search mode. ) */
| 249 | |
| 250 | /* Search data from left to right. ( Multiple search mode. ) */ |
| 251 | UTSTRING_UNUSED static long _utstring_find( |
| 252 | const char *P_Haystack, |
| 253 | size_t P_HaystackLen, |
| 254 | const char *P_Needle, |
| 255 | size_t P_NeedleLen, |
| 256 | long *P_KMP_Table) |
| 257 | { |
| 258 | long i, j; |
| 259 | long V_FindPosition = -1; |
| 260 | |
| 261 | /* Search from left to right. */ |
| 262 | i = j = 0; |
| 263 | while ( (j < (int)P_HaystackLen) && (((P_HaystackLen - j) + i) >= P_NeedleLen) ) |
| 264 | { |
| 265 | while ( (i > -1) && (P_Needle[i] != P_Haystack[j]) ) |
| 266 | { |
| 267 | i = P_KMP_Table[i]; |
| 268 | } |
| 269 | i++; |
| 270 | j++; |
| 271 | if (i >= (int)P_NeedleLen) |
| 272 | { |
| 273 | /* Found. */ |
| 274 | V_FindPosition = j - i; |
| 275 | break; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | return V_FindPosition; |
| 280 | } |
| 281 | |
| 282 | |
| 283 | /* Search data from right to left. ( Multiple search mode. ) */ |