| 1888 | }; |
| 1889 | |
| 1890 | cbm_sem_doc_format_t cbm_sem_doc_format(const char *path) { |
| 1891 | static const struct { |
| 1892 | const char *ext; |
| 1893 | cbm_sem_doc_format_t fmt; |
| 1894 | } exts[] = {{".md", CBM_SEM_DOC_FMT_MARKDOWN}, {".mdx", CBM_SEM_DOC_FMT_MARKDOWN}, |
| 1895 | {".markdown", CBM_SEM_DOC_FMT_MARKDOWN}, {".rst", CBM_SEM_DOC_FMT_RST}, |
| 1896 | {".rest", CBM_SEM_DOC_FMT_RST}, {".txt", CBM_SEM_DOC_FMT_RST}, |
| 1897 | {".adoc", CBM_SEM_DOC_FMT_ADOC}, {".asciidoc", CBM_SEM_DOC_FMT_ADOC}, |
| 1898 | {".asc", CBM_SEM_DOC_FMT_ADOC}, {".pdf", CBM_SEM_DOC_FMT_PDF}}; |
| 1899 | const char *dot = path ? strrchr(path, '.') : NULL; |
| 1900 | if (!dot || strchr(dot, '/')) { |
| 1901 | return CBM_SEM_DOC_FMT_OTHER; |
| 1902 | } |
| 1903 | for (size_t i = 0; i < sizeof(exts) / sizeof(exts[0]); i++) { |
| 1904 | if (strcasecmp(dot, exts[i].ext) == 0) { |
| 1905 | return exts[i].fmt; |
| 1906 | } |
| 1907 | } |
| 1908 | return CBM_SEM_DOC_FMT_OTHER; |
| 1909 | } |
| 1910 | |
| 1911 | double cbm_sem_p_2dp(float p) { |
| 1912 | /* 1e-4 on the x100 scale: a float holds 0.325 as 0.32499998..., 1.2e-6 |
no outgoing calls
no test coverage detected