Map an interpreter basename to a language, or CBM_LANG_COUNT if unrecognized. * Non-python interpreters are matched exactly (no prefix/suffix logic). */
| 1118 | /* Map an interpreter basename to a language, or CBM_LANG_COUNT if unrecognized. |
| 1119 | * Non-python interpreters are matched exactly (no prefix/suffix logic). */ |
| 1120 | static CBMLanguage lang_for_interpreter(const char *base) { |
| 1121 | if (is_python_interp(base)) { |
| 1122 | return CBM_LANG_PYTHON; |
| 1123 | } |
| 1124 | static const struct { |
| 1125 | const char *name; |
| 1126 | CBMLanguage lang; |
| 1127 | } INTERP_TABLE[] = { |
| 1128 | {"sh", CBM_LANG_BASH}, {"bash", CBM_LANG_BASH}, {"dash", CBM_LANG_BASH}, |
| 1129 | {"ksh", CBM_LANG_BASH}, {"zsh", CBM_LANG_BASH}, {"node", CBM_LANG_JAVASCRIPT}, |
| 1130 | {"nodejs", CBM_LANG_JAVASCRIPT}, {"ruby", CBM_LANG_RUBY}, {"perl", CBM_LANG_PERL}, |
| 1131 | {"php", CBM_LANG_PHP}, {"lua", CBM_LANG_LUA}, |
| 1132 | }; |
| 1133 | for (size_t i = 0; i < sizeof(INTERP_TABLE) / sizeof(INTERP_TABLE[0]); i++) { |
| 1134 | if (strcmp(base, INTERP_TABLE[i].name) == 0) { |
| 1135 | return INTERP_TABLE[i].lang; |
| 1136 | } |
| 1137 | } |
| 1138 | return CBM_LANG_COUNT; |
| 1139 | } |
| 1140 | |
| 1141 | /* Advance *cursor past leading blanks and return the next whitespace-delimited |
| 1142 | * token (NUL-terminated in place), or NULL when the line is exhausted. */ |
no test coverage detected