MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / InStrAny

Function InStrAny

source/util.cpp:3085–3112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3083
3084
3085LPTSTR InStrAny(LPTSTR aStr, LPTSTR aNeedle[], int aNeedleCount, size_t &aFoundLen)
3086{
3087 // For each character in aStr:
3088 for ( ; *aStr; ++aStr)
3089 // For each needle:
3090 for (int i = 0; i < aNeedleCount; ++i)
3091 // For each character in this needle:
3092 for (LPTSTR needle_pos = aNeedle[i], str_pos = aStr; ; ++needle_pos, ++str_pos)
3093 {
3094 if (!*needle_pos)
3095 {
3096 // All characters in needle matched aStr at this position, so we've
3097 // found our string. If this needle is empty, it implicitly matches
3098 // at the first position in the string.
3099 aFoundLen = needle_pos - aNeedle[i];
3100 return aStr;
3101 }
3102 // Otherwise, we haven't reached the end of the needle. If we've reached
3103 // the end of aStr, *str_pos and *needle_pos won't match, so the check
3104 // below will break out of the loop.
3105 if (*needle_pos != *str_pos)
3106 // Not a match: continue on to the next needle, or the next starting
3107 // position in aStr if this is the last needle.
3108 break;
3109 }
3110 // If the above loops completed without returning, no matches were found.
3111 return NULL;
3112}
3113
3114
3115

Callers 1

BIF_DECLFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected