| 3026 | |
| 3027 | #if 0 // Currently unused. |
| 3028 | bool IsStringInList(LPTSTR aStr, LPTSTR aList, bool aFindExactMatch) |
| 3029 | // Checks if aStr exists in aList (which is a comma-separated list). |
| 3030 | // If aStr is blank, aList must start with a delimiting comma for there to be a match. |
| 3031 | { |
| 3032 | // Must use a temp. buffer because otherwise there's no easy way to properly match upon strings |
| 3033 | // such as the following: |
| 3034 | // if var in string,,with,,literal,,commas |
| 3035 | TCHAR buf[LINE_SIZE]; |
| 3036 | TCHAR *next_field, *cp, *end_buf = buf + _countof(buf) - 1; |
| 3037 | |
| 3038 | // v1.0.48.01: Performance improved by Lexikos. |
| 3039 | for (TCHAR *this_field = aList; *this_field; this_field = next_field) // For each field in aList. |
| 3040 | { |
| 3041 | for (cp = buf, next_field = this_field; *next_field && cp < end_buf; ++cp, ++next_field) // For each char in the field, copy it over to temporary buffer. |
| 3042 | { |
| 3043 | if (*next_field == ',') // This is either a delimiter (,) or a literal comma (,,). |
| 3044 | { |
| 3045 | ++next_field; |
| 3046 | if (*next_field != ',') // It's "," instead of ",," so treat it as the end of this field. |
| 3047 | break; |
| 3048 | // Otherwise it's ",," and next_field now points at the second comma; so copy that comma |
| 3049 | // over as a literal comma then continue copying. |
| 3050 | } |
| 3051 | *cp = *next_field; |
| 3052 | } |
| 3053 | |
| 3054 | // The end of this field has been reached (or reached the capacity of the buffer), so terminate the string |
| 3055 | // in the buffer. |
| 3056 | *cp = '\0'; |
| 3057 | |
| 3058 | if (*buf) // It is possible for this to be blank only for the first field. Example: if var in ,abc |
| 3059 | { |
| 3060 | if (aFindExactMatch) |
| 3061 | { |
| 3062 | if (!g_tcscmp(aStr, buf)) // Match found |
| 3063 | return true; |
| 3064 | } |
| 3065 | else // Substring match |
| 3066 | if (g_tcsstr(aStr, buf)) // Match found |
| 3067 | return true; |
| 3068 | } |
| 3069 | else // First item in the list is the empty string. |
| 3070 | if (aFindExactMatch) // In this case, this is a match if aStr is also blank. |
| 3071 | { |
| 3072 | if (!*aStr) |
| 3073 | return true; |
| 3074 | } |
| 3075 | else // Empty string is always found as a substring in any other string. |
| 3076 | return true; |
| 3077 | } // for() |
| 3078 | |
| 3079 | return false; // No match found. |
| 3080 | } |
| 3081 | #endif |
| 3082 | |
| 3083 |
nothing calls this directly
no outgoing calls
no test coverage detected