| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | static const struct FileBasenameMap { | ||
| 2 | const char name[16]; | ||
| 3 | uint8_t filetype; // FileTypeEnum | ||
| 4 | bool dotfile; // If true, name is matched with or without a leading dot | ||
| 5 | } basenames[] = { | ||
| 6 | {"APKBUILD", SH, false}, | ||
| 7 | {"BSDmakefile", MAKE, false}, | ||
| 8 | {"BUILD.bazel", PYTHON, false}, | ||
| 9 | {"Brewfile", RUBY, true}, | ||
| 10 | {"CMakeLists.txt", CMAKE, false}, | ||
| 11 | {"COMMIT_EDITMSG", GITCOMMIT, false}, | ||
| 12 | {"Capfile", RUBY, false}, | ||
| 13 | {"Cargo.lock", TOML, false}, | ||
| 14 | {"DIR_COLORS", CONFIG, false}, | ||
| 15 | {"Dangerfile", RUBY, false}, | ||
| 16 | {"Dockerfile", DOCKER, false}, | ||
| 17 | {"Doxyfile", CONFIG, false}, | ||
| 18 | {"GNUmakefile", MAKE, false}, | ||
| 19 | {"Gemfile", RUBY, false}, | ||
| 20 | {"Gemfile.lock", RUBY, false}, | ||
| 21 | {"Guardfile", RUBY, true}, | ||
| 22 | {"Kbuild", MAKE, false}, | ||
| 23 | {"Kconfig", CONFIG, false}, | ||
| 24 | {"Kconfig.debug", CONFIG, false}, | ||
| 25 | {"MERGE_MSG", GITCOMMIT, false}, | ||
| 26 | {"Makefile", MAKE, false}, | ||
| 27 | {"Makefile.am", MAKE, false}, | ||
| 28 | {"Makefile.in", MAKE, false}, | ||
| 29 | {"NOTES_EDITMSG", GITNOTE, false}, | ||
| 30 | {"PKGBUILD", SH, false}, | ||
| 31 | {"Pipfile", TOML, false}, | ||
| 32 | {"Pipfile.lock", JSON, false}, | ||
| 33 | {"Project.ede", LISP, false}, | ||
| 34 | {"Puppetfile", RUBY, false}, | ||
| 35 | {"Rakefile", RUBY, false}, | ||
| 36 | {"Steepfile", RUBY, false}, | ||
| 37 | {"Thorfile", RUBY, false}, | ||
| 38 | {"Vagrantfile", RUBY, false}, | ||
| 39 | {"XCompose", CONFIG, true}, | ||
| 40 | {"Xresources", XRESOURCES, true}, | ||
| 41 | {"ackrc", CONFIG, true}, | ||
| 42 | {"bash_aliases", SH, true}, | ||
| 43 | {"bash_functions", SH, true}, | ||
| 44 | {"bash_logout", SH, true}, | ||
| 45 | {"bash_profile", SH, true}, | ||
| 46 | {"bashrc", SH, true}, | ||
| 47 | {"bazelrc", CONFIG, true}, | ||
| 48 | {"btop.conf", CONFIG, true}, | ||
| 49 | {"build.gradle", GRADLE, false}, | ||
| 50 | {"buildozer.spec", INI, false}, | ||
| 51 | {"bun.lock", JSONC, false}, // https://bun.sh/blog/bun-lock-text-lockfile#tooling-compatibility | ||
| 52 | {"clang-format", YAML, true}, | ||
| 53 | {"clang-tidy", YAML, true}, | ||
| 54 | {"colordiffrc", CONFIG, true}, | ||
| 55 | {"composer.lock", JSON, false}, | ||
| 56 | {"config.ld", LUA, false}, | ||
| 57 | {"configure.ac", M4, false}, | ||
| 58 | {"coveragerc", INI, true}, | ||
| 59 | {"csh.login", CSH, true}, | ||
| 60 | {"csh.logout", CSH, true}, | ||
| 61 | {"cshdirs", CSH, true}, | ||
| 62 | {"cshrc", CSH, true}, | ||
| 63 | {"curlrc", CONFIG, true}, | ||
| 64 | {"deno.lock", JSON, false}, | ||
| 65 | {"dir_colors", CONFIG, true}, | ||
| 66 | {"dircolors", CONFIG, true}, | ||
| 67 | {"doas.conf", CONFIG, false}, | ||
| 68 | {"drirc", XML, true}, | ||
| 69 | {"dterc", DTE, true}, | ||
| 70 | {"editorconfig", INI, true}, | ||
| 71 | {"emacs", LISP, true}, | ||
| 72 | {"flake.lock", JSON, false}, | ||
| 73 | {"flake8", INI, true}, | ||
| 74 | {"fstab", CONFIG, false}, | ||
| 75 | {"gdbinit", CONFIG, true}, | ||
| 76 | {"gemrc", YAML, true}, | ||
| 77 | {"git-rebase-todo", GITREBASE, false}, | ||
| 78 | {"gitattributes", CONFIG, true}, | ||
| 79 | {"gitconfig", INI, true}, | ||
| 80 | {"gitignore", GITIGNORE, true}, | ||
| 81 | {"gitmodules", INI, true}, | ||
| 82 | {"gnus", LISP, true}, | ||
| 83 | {"go.mod", GOMODULE, false}, | ||
| 84 | {"hosts", CONFIG, false}, | ||
| 85 | {"htmlhintrc", JSON, true}, | ||
| 86 | {"indent.pro", INDENT, true}, | ||
| 87 | {"inputrc", CONFIG, true}, | ||
| 88 | {"ip6tables.rules", CONFIG, false}, | ||
| 89 | {"iptables.rules", CONFIG, false}, | ||
| 90 | {"jshintrc", JSON, true}, | ||
| 91 | {"krb5.conf", INI, false}, | ||
| 92 | {"lcovrc", CONFIG, true}, | ||
| 93 | {"lesskey", CONFIG, true}, | ||
| 94 | {"luacheckrc", LUA, true}, | ||
| 95 | {"luacov", LUA, true}, | ||
| 96 | {"makefile", MAKE, false}, | ||
| 97 | {"mcmod.info", JSON, false}, | ||
| 98 | {"menu.lst", CONFIG, false}, | ||
| 99 | {"meson.build", MESON, false}, | ||
| 100 | {"mimeapps.list", INI, false}, | ||
| 101 | {"mkinitcpio.conf", SH, false}, | ||
| 102 | {"muttrc", CONFIG, true}, | ||
| 103 | {"nanorc", CONFIG, true}, | ||
| 104 | {"nftables.conf", NFTABLES, false}, | ||
| 105 | {"nginx.conf", NGINX, false}, | ||
| 106 | {"pacman.conf", INI, false}, | ||
| 107 | {"pdm.lock", TOML, false}, | ||
| 108 | {"poetry.lock", TOML, false}, | ||
| 109 | {"profile", SH, true}, | ||
| 110 | {"pylintrc", INI, true}, | ||
| 111 | {"robots.txt", ROBOTSTXT, false}, | ||
| 112 | {"rockspec.in", LUA, false}, | ||
| 113 | {"shellcheckrc", CONFIG, true}, | ||
| 114 | {"shrc", SH, true}, | ||
| 115 | {"sudoers", CONFIG, false}, | ||
| 116 | {"sxhkdrc", CONFIG, true}, | ||
| 117 | {"tags", CTAGS, false}, | ||
| 118 | {"tcshrc", CSH, true}, | ||
| 119 | {"terminalrc", INI, false}, | ||
| 120 | {"terminfo.src", TERMINFO, false}, | ||
| 121 | {"texmf.cnf", TEXMFCNF, false}, | ||
| 122 | {"tigrc", CONFIG, true}, | ||
| 123 | {"tmux.conf", TMUX, true}, | ||
| 124 | {"user-dirs.conf", CONFIG, false}, | ||
| 125 | {"user-dirs.dirs", CONFIG, false}, | ||
| 126 | {"vconsole.conf", CONFIG, false}, | ||
| 127 | {"watchmanconfig", JSON, true}, | ||
| 128 | {"xinitrc", SH, true}, | ||
| 129 | {"xprofile", SH, true}, | ||
| 130 | {"xserverrc", SH, true}, | ||
| 131 | {"yum.conf", INI, false}, | ||
| 132 | {"zlogin", SH, true}, | ||
| 133 | {"zlogout", SH, true}, | ||
| 134 | {"zprofile", SH, true}, | ||
| 135 | {"zshenv", SH, true}, | ||
| 136 | {"zshrc", SH, true}, | ||
| 137 | }; | ||
| 138 | |||
| 139 | 215 | static FileTypeEnum filetype_from_basename(StringView name) | |
| 140 | { | ||
| 141 | 215 | size_t dotprefix = 0; | |
| 142 |
2/2✓ Branch 3 → 4 taken 186 times.
✓ Branch 3 → 7 taken 29 times.
|
215 | if (strview_has_prefix(name, ".")) { |
| 143 | dotprefix = 1; | ||
| 144 |
2/2✓ Branch 5 → 6 taken 6 times.
✓ Branch 5 → 7 taken 180 times.
|
186 | } else if (strview_has_prefix(name, "dot_")) { |
| 145 | 6 | dotprefix = 4; | |
| 146 | } | ||
| 147 | |||
| 148 | 215 | strview_remove_prefix(&name, dotprefix); | |
| 149 |
2/2✓ Branch 8 → 9 taken 140 times.
✓ Branch 8 → 25 taken 75 times.
|
215 | if (name.length < 4) { |
| 150 | return NONE; | ||
| 151 | } | ||
| 152 | |||
| 153 |
2/2✓ Branch 9 → 10 taken 6 times.
✓ Branch 9 → 20 taken 134 times.
|
140 | if (name.length >= ARRAYLEN(basenames[0].name)) { |
| 154 |
2/2✓ Branch 11 → 12 taken 1 time.
✓ Branch 11 → 15 taken 5 times.
|
6 | if (strview_equal_cstring(name, "meson_options.txt")) { |
| 155 |
1/2✓ Branch 12 → 13 taken 1 time.
✗ Branch 12 → 14 not taken.
|
1 | return dotprefix ? NONE : MESON; |
| 156 |
2/2✓ Branch 16 → 17 taken 1 time.
✓ Branch 16 → 25 taken 4 times.
|
5 | } else if (strview_equal_cstring(name, "git-blame-ignore-revs")) { |
| 157 |
1/2✗ Branch 17 → 18 not taken.
✓ Branch 17 → 19 taken 1 time.
|
1 | return dotprefix ? CONFIG : NONE; |
| 158 | } | ||
| 159 | return NONE; | ||
| 160 | } | ||
| 161 | |||
| 162 | 134 | const struct FileBasenameMap *e = BSEARCH(&name, basenames, ft_compare); | |
| 163 |
6/6✓ Branch 21 → 22 taken 38 times.
✓ Branch 21 → 25 taken 96 times.
✓ Branch 22 → 23 taken 20 times.
✓ Branch 22 → 24 taken 18 times.
✓ Branch 23 → 24 taken 19 times.
✓ Branch 23 → 25 taken 1 time.
|
134 | return (e && (dotprefix == 0 || e->dotfile)) ? e->filetype : NONE; |
| 164 | } | ||
| 165 |