| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | static const struct FileInterpreterMap { | ||
| 2 | const char key[8]; | ||
| 3 | const FileTypeEnum filetype; | ||
| 4 | } interpreters[] = { | ||
| 5 | {"ash", SH}, | ||
| 6 | {"awk", AWK}, | ||
| 7 | {"bash", SH}, | ||
| 8 | {"bats", SH}, // https://github.com/bats-core/bats-core | ||
| 9 | {"bigloo", SCHEME}, | ||
| 10 | {"bun", TYPESCRIPT}, | ||
| 11 | {"ccl", LISP}, | ||
| 12 | {"chicken", SCHEME}, | ||
| 13 | {"clisp", LISP}, | ||
| 14 | {"coffee", COFFEESCRIPT}, | ||
| 15 | {"crystal", RUBY}, | ||
| 16 | {"csh", CSH}, | ||
| 17 | {"dart", DART}, | ||
| 18 | {"dash", SH}, | ||
| 19 | {"deno", TYPESCRIPT}, | ||
| 20 | {"ecl", LISP}, | ||
| 21 | {"elixir", ELIXIR}, | ||
| 22 | {"escript", ERLANG}, | ||
| 23 | {"fish", FISH}, | ||
| 24 | {"gawk", AWK}, | ||
| 25 | {"gjs", JAVASCRIPT}, | ||
| 26 | {"gmake", MAKE}, | ||
| 27 | {"gnuplot", GNUPLOT}, | ||
| 28 | {"gojq", JQ}, // https://github.com/itchyny/gojq | ||
| 29 | {"groovy", GROOVY}, | ||
| 30 | {"gsed", SED}, | ||
| 31 | {"guile", SCHEME}, | ||
| 32 | {"jaq", JQ}, // https://github.com/01mf02/jaq | ||
| 33 | {"jq", JQ}, | ||
| 34 | {"jruby", RUBY}, | ||
| 35 | {"julia", JULIA}, | ||
| 36 | {"ksh", SH}, | ||
| 37 | {"lisp", LISP}, | ||
| 38 | {"lua", LUA}, | ||
| 39 | {"luajit", LUA}, | ||
| 40 | {"macruby", RUBY}, | ||
| 41 | {"make", MAKE}, | ||
| 42 | {"mawk", AWK}, | ||
| 43 | {"mksh", SH}, | ||
| 44 | {"moon", MOONSCRIPT}, | ||
| 45 | {"nawk", AWK}, | ||
| 46 | {"nft", NFTABLES}, | ||
| 47 | {"node", JAVASCRIPT}, | ||
| 48 | {"nodejs", JAVASCRIPT}, | ||
| 49 | {"ocaml", OCAML}, | ||
| 50 | {"pdksh", SH}, | ||
| 51 | {"perl", PERL}, | ||
| 52 | {"php", PHP}, | ||
| 53 | {"pwsh", POWERSHELL}, | ||
| 54 | {"pypy", PYTHON}, | ||
| 55 | {"python", PYTHON}, | ||
| 56 | {"qjs", JAVASCRIPT}, | ||
| 57 | {"r6rs", SCHEME}, | ||
| 58 | {"racket", SCHEME}, | ||
| 59 | {"rake", RUBY}, | ||
| 60 | {"rbx", RUBY}, | ||
| 61 | {"ruby", RUBY}, | ||
| 62 | {"runghc", HASKELL}, | ||
| 63 | {"sbcl", LISP}, | ||
| 64 | {"scala", SCALA}, | ||
| 65 | {"scheme", SCHEME}, | ||
| 66 | {"sed", SED}, | ||
| 67 | {"sh", SH}, | ||
| 68 | {"tcc", C}, | ||
| 69 | {"tclsh", TCL}, | ||
| 70 | {"tcsh", CSH}, | ||
| 71 | {"ts-node", TYPESCRIPT}, | ||
| 72 | {"wish", TCL}, | ||
| 73 | {"zsh", SH}, | ||
| 74 | }; | ||
| 75 | |||
| 76 | 277 | static FileTypeEnum filetype_from_interpreter(const StringView name) | |
| 77 | { | ||
| 78 |
2/2✓ Branch 2 → 3 taken 67 times.
✓ Branch 2 → 14 taken 210 times.
|
277 | if (name.length < 2) { |
| 79 | return NONE; | ||
| 80 | } | ||
| 81 | |||
| 82 |
2/2✓ Branch 3 → 4 taken 5 times.
✓ Branch 3 → 11 taken 62 times.
|
67 | if (name.length >= ARRAYLEN(interpreters[0].key)) { |
| 83 |
2/2✓ Branch 5 → 6 taken 4 times.
✓ Branch 5 → 14 taken 1 time.
|
5 | if (strview_equal_cstring(name, "openrc-run")) { |
| 84 | return SH; | ||
| 85 |
2/2✓ Branch 7 → 8 taken 3 times.
✓ Branch 7 → 14 taken 1 time.
|
4 | } else if (strview_equal_cstring(name, "runhaskell")) { |
| 86 | return HASKELL; | ||
| 87 |
2/2✓ Branch 9 → 10 taken 2 times.
✓ Branch 9 → 14 taken 1 time.
|
3 | } else if (strview_equal_cstring(name, "rust-script")) { |
| 88 | return RUST; | ||
| 89 | } | ||
| 90 | 2 | return NONE; | |
| 91 | } | ||
| 92 | |||
| 93 | 62 | const struct FileInterpreterMap *e = BSEARCH(&name, interpreters, ft_compare); | |
| 94 |
2/2✓ Branch 12 → 13 taken 59 times.
✓ Branch 12 → 14 taken 3 times.
|
62 | return e ? e->filetype : NONE; |
| 95 | } | ||
| 96 |