Detect language for a file, handling .m disambiguation and JSON filtering. */
| 568 | |
| 569 | /* Detect language for a file, handling .m disambiguation and JSON filtering. */ |
| 570 | static CBMLanguage detect_file_language(const char *entry_name, const char *abs_path) { |
| 571 | CBMLanguage lang = cbm_language_for_filename(entry_name); |
| 572 | if (lang == CBM_LANG_COUNT) { |
| 573 | return CBM_LANG_COUNT; |
| 574 | } |
| 575 | /* Special: .m files need content-based disambiguation */ |
| 576 | const char *dot = strrchr(entry_name, '.'); |
| 577 | if (dot && strcmp(dot, ".m") == 0) { |
| 578 | lang = cbm_disambiguate_m(abs_path); |
| 579 | } |
| 580 | /* Check ignored JSON files */ |
| 581 | if (lang == CBM_LANG_JSON && str_in_list(entry_name, IGNORED_JSON_FILES)) { |
| 582 | return CBM_LANG_COUNT; |
| 583 | } |
| 584 | return lang; |
| 585 | } |
| 586 | |
| 587 | /* UTF-8-safe stat: wide API on Windows, regular stat on POSIX. */ |
| 588 | static int wide_stat(const char *path, struct stat *st) { |
no test coverage detected