* Parse a language string (case-insensitive) to a CBMLanguage enum. * Returns CBM_LANG_COUNT if the string is not recognized. */
| 177 | * Returns CBM_LANG_COUNT if the string is not recognized. |
| 178 | */ |
| 179 | static CBMLanguage lang_from_string(const char *s) { |
| 180 | if (!s || !s[0]) { |
| 181 | return CBM_LANG_COUNT; |
| 182 | } |
| 183 | |
| 184 | /* Build a lowercase copy for comparison */ |
| 185 | char lower[CBM_SZ_64]; |
| 186 | size_t i; |
| 187 | for (i = 0; i < sizeof(lower) - SKIP_ONE && s[i]; i++) { |
| 188 | lower[i] = (char)tolower((unsigned char)s[i]); |
| 189 | } |
| 190 | lower[i] = '\0'; |
| 191 | |
| 192 | for (size_t j = 0; j < LANG_NAME_TABLE_SIZE; j++) { |
| 193 | if (strcmp(LANG_NAME_TABLE[j].name, lower) == 0) { |
| 194 | return LANG_NAME_TABLE[j].lang; |
| 195 | } |
| 196 | } |
| 197 | return CBM_LANG_COUNT; |
| 198 | } |
| 199 | |
| 200 | /* ── Config directory helper ─────────────────────────────────────── */ |
| 201 |
no outgoing calls
no test coverage detected