* Parse a language string (case-insensitive) to a CBMLanguage enum. * Returns CBM_LANG_COUNT if the string is not recognized. */
| 131 | * Returns CBM_LANG_COUNT if the string is not recognized. |
| 132 | */ |
| 133 | static CBMLanguage lang_from_string(const char *s) { |
| 134 | if (!s || !s[0]) { |
| 135 | return CBM_LANG_COUNT; |
| 136 | } |
| 137 | |
| 138 | /* Build a lowercase copy for comparison */ |
| 139 | char lower[CBM_SZ_64]; |
| 140 | size_t i; |
| 141 | for (i = 0; i < sizeof(lower) - SKIP_ONE && s[i]; i++) { |
| 142 | lower[i] = (char)tolower((unsigned char)s[i]); |
| 143 | } |
| 144 | lower[i] = '\0'; |
| 145 | |
| 146 | for (size_t j = 0; j < LANG_NAME_TABLE_SIZE; j++) { |
| 147 | if (strcmp(LANG_NAME_TABLE[j].name, lower) == 0) { |
| 148 | return LANG_NAME_TABLE[j].lang; |
| 149 | } |
| 150 | } |
| 151 | return CBM_LANG_COUNT; |
| 152 | } |
| 153 | |
| 154 | /* ── Config directory helper ─────────────────────────────────────── */ |
| 155 |
no outgoing calls
no test coverage detected