| 1 |
|
| /* |
| 2 |
|
| * eshu_file.h — File and directory level indentation operations |
| 3 |
|
| * |
| 4 |
|
| * Pure C (POSIX), no Perl dependencies. |
| 5 |
|
| * Requires: eshu.h, eshu_c.h, eshu_pl.h, eshu_xs.h, eshu_xml.h, |
| 6 |
|
| * eshu_css.h, eshu_bash.h, eshu_go.h, eshu_diff.h |
| 7 |
|
| */ |
| 8 |
|
| |
| 9 |
|
| #ifndef ESHU_FILE_H |
| 10 |
|
| #define ESHU_FILE_H |
| 11 |
|
| |
| 12 |
|
| #include "eshu.h" |
| 13 |
|
| #include "eshu_diff.h" |
| 14 |
|
| |
| 15 |
|
| /* Perl redefines fopen/fclose/fread/fwrite/fprintf via PerlSIO on Windows |
| 16 |
|
| * with MULTIPLICITY, which requires my_perl in scope. This header contains |
| 17 |
|
| * plain C static functions that must use the real CRT stdio. */ |
| 18 |
|
| #ifdef WIN32 |
| 19 |
|
| # ifdef fopen |
| 20 |
|
| # undef fopen |
| 21 |
|
| # endif |
| 22 |
|
| # ifdef fclose |
| 23 |
|
| # undef fclose |
| 24 |
|
| # endif |
| 25 |
|
| # ifdef fread |
| 26 |
|
| # undef fread |
| 27 |
|
| # endif |
| 28 |
|
| # ifdef fwrite |
| 29 |
|
| # undef fwrite |
| 30 |
|
| # endif |
| 31 |
|
| # ifdef fprintf |
| 32 |
|
| # undef fprintf |
| 33 |
|
| # endif |
| 34 |
|
| #endif |
| 35 |
|
| |
| 36 |
|
| #include <stdio.h> |
| 37 |
|
| #include <sys/types.h> |
| 38 |
|
| #include <sys/stat.h> |
| 39 |
|
| #ifndef _WIN32 |
| 40 |
|
| # include <dirent.h> |
| 41 |
|
| # include <unistd.h> |
| 42 |
|
| /* the walker uses the eshu_ spellings everywhere so the Windows shim |
| 43 |
|
| * never has to reuse (or fight) the ambient names - see dirent_win.h |
| 44 |
|
| * for the two releases of scar tissue behind that decision */ |
| 45 |
|
| # define EshuDIR DIR |
| 46 |
|
| # define eshu_dirent dirent |
| 47 |
|
| # define eshu_opendir opendir |
| 48 |
|
| # define eshu_readdir readdir |
| 49 |
|
| # define eshu_closedir closedir |
| 50 |
|
| #else |
| 51 |
|
| # include <io.h> |
| 52 |
|
| # include <direct.h> |
| 53 |
|
| # include "dirent_win.h" |
| 54 |
|
| # ifndef S_ISREG |
| 55 |
|
| # define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) |
| 56 |
|
| # endif |
| 57 |
|
| # ifndef S_ISDIR |
| 58 |
|
| # define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) |
| 59 |
|
| # endif |
| 60 |
|
| # ifndef S_ISLNK |
| 61 |
|
| # define S_ISLNK(m) 0 /* Windows has no symlinks via stat */ |
| 62 |
|
| # endif |
| 63 |
|
| # define lstat stat |
| 64 |
|
| #endif |
| 65 |
|
| |
| 66 |
|
| #define ESHU_MAX_FILE_SIZE 1048576 /* 1MB */ |
| 67 |
|
| #define ESHU_BINARY_SAMPLE 8192 |
| 68 |
|
| |
| 69 |
|
| /* ══════════════════════════════════════════════════════════════════ |
| 70 |
|
| * Status codes for indent_file results |
| 71 |
|
| * ══════════════════════════════════════════════════════════════════ */ |
| 72 |
|
| |
| 73 |
|
| enum eshu_file_status { |
| 74 |
|
| ESHU_STATUS_UNCHANGED = 0, |
| 75 |
|
| ESHU_STATUS_CHANGED = 1, |
| 76 |
|
| ESHU_STATUS_NEEDS_FIXING = 2, |
| 77 |
|
| ESHU_STATUS_SKIPPED = 3, |
| 78 |
|
| ESHU_STATUS_ERROR = 4 |
| 79 |
|
| }; |
| 80 |
|
| |
| 81 |
|
| /* ══════════════════════════════════════════════════════════════════ |
| 82 |
|
| * File result |
| 83 |
|
| * ══════════════════════════════════════════════════════════════════ */ |
| 84 |
|
| |
| 85 |
|
| typedef struct { |
| 86 |
|
| char *file; /* path (strdup'd, caller frees) */ |
| 87 |
|
| int status; /* eshu_file_status */ |
| 88 |
|
| char *lang; /* language string or NULL */ |
| 89 |
|
| char *reason; /* skip reason or NULL */ |
| 90 |
|
| char *error; /* error message or NULL */ |
| 91 |
|
| char *diff; /* diff string or NULL */ |
| 92 |
|
| size_t diff_len; |
| 93 |
|
| } eshu_file_result_t; |
| 94 |
|
| |
| 95 |
47 |
| static void eshu_file_result_init(eshu_file_result_t *r) { |
| 96 |
47 |
| memset(r, 0, sizeof(*r)); |
| 97 |
47 |
| } |
| 98 |
|
| |
| 99 |
47 |
| static void eshu_file_result_free(eshu_file_result_t *r) { |
| 100 |
47 |
▶ | if (r->file) free(r->file); |
Branch: 1 branch
| Branch | True | False | Total |
| if (r->file) free(r->file); |
47 |
0 |
47 |
|
| 101 |
47 |
▶ | if (r->lang) free(r->lang); |
Branch: 1 branch
| Branch | True | False | Total |
| if (r->lang) free(r->lang); |
41 |
6 |
47 |
|
| 102 |
47 |
▶ | if (r->reason) free(r->reason); |
Branch: 1 branch
| Branch | True | False | Total |
| if (r->reason) free(r->reason); |
5 |
42 |
47 |
|
| 103 |
47 |
▶ | if (r->error) free(r->error); |
Branch: 1 branch
| Branch | True | False | Total |
| if (r->error) free(r->error); |
1 |
46 |
47 |
|
| 104 |
47 |
▶ | if (r->diff) free(r->diff); |
Branch: 1 branch
| Branch | True | False | Total |
| if (r->diff) free(r->diff); |
2 |
45 |
47 |
|
| 105 |
47 |
| memset(r, 0, sizeof(*r)); |
| 106 |
47 |
| } |
| 107 |
|
| |
| 108 |
|
| /* ══════════════════════════════════════════════════════════════════ |
| 109 |
|
| * Directory report |
| 110 |
|
| * ══════════════════════════════════════════════════════════════════ */ |
| 111 |
|
| |
| 112 |
|
| typedef struct { |
| 113 |
|
| int files_checked; |
| 114 |
|
| int files_changed; |
| 115 |
|
| int files_skipped; |
| 116 |
|
| int files_errored; |
| 117 |
|
| eshu_file_result_t *changes; |
| 118 |
|
| size_t changes_count; |
| 119 |
|
| size_t changes_cap; |
| 120 |
|
| } eshu_dir_report_t; |
| 121 |
|
| |
| 122 |
16 |
| static void eshu_dir_report_init(eshu_dir_report_t *r) { |
| 123 |
16 |
| memset(r, 0, sizeof(*r)); |
| 124 |
16 |
| r->changes_cap = 64; |
| 125 |
16 |
| r->changes = (eshu_file_result_t *)malloc(r->changes_cap * sizeof(eshu_file_result_t)); |
| 126 |
16 |
| } |
| 127 |
|
| |
| 128 |
0 |
| static void eshu_dir_report_push(eshu_dir_report_t *r, eshu_file_result_t *res) { |
| 129 |
0 |
▶ | if (r->changes_count >= r->changes_cap) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (r->changes_count >= r->changes_cap) { |
0 |
0 |
0 |
|
| 130 |
0 |
| r->changes_cap *= 2; |
| 131 |
0 |
| r->changes = (eshu_file_result_t *)realloc(r->changes, |
| 132 |
0 |
| r->changes_cap * sizeof(eshu_file_result_t)); |
| 133 |
|
| } |
| 134 |
0 |
| r->changes[r->changes_count++] = *res; |
| 135 |
|
| /* Transfer ownership — caller should not free res fields */ |
| 136 |
0 |
| } |
| 137 |
|
| |
| 138 |
0 |
| static void eshu_dir_report_free(eshu_dir_report_t *r) { |
| 139 |
|
| size_t i; |
| 140 |
0 |
▶ | for (i = 0; i < r->changes_count; i++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < r->changes_count; i++) |
0 |
0 |
0 |
|
| 141 |
0 |
| eshu_file_result_free(&r->changes[i]); |
| 142 |
0 |
| free(r->changes); |
| 143 |
0 |
| memset(r, 0, sizeof(*r)); |
| 144 |
0 |
| } |
| 145 |
|
| |
| 146 |
|
| /* ══════════════════════════════════════════════════════════════════ |
| 147 |
|
| * Language detection from extension (pure C) |
| 148 |
|
| * ══════════════════════════════════════════════════════════════════ */ |
| 149 |
|
| |
| 150 |
|
| /* Case-insensitive single-char compare */ |
| 151 |
199 |
| static int eshu_ci(char a, char b) { |
| 152 |
199 |
▶ | if (a >= 'A' && a <= 'Z') a += 32; |
Branch: 2 branches
| Branch | True | False | Total |
| if (a >= 'A' && a <= 'Z') a += 32; |
199 |
0 |
199 |
| if (a >= 'A' && a <= 'Z') a += 32; |
0 |
199 |
199 |
|
| 153 |
199 |
▶ | if (b >= 'A' && b <= 'Z') b += 32; |
Branch: 2 branches
| Branch | True | False | Total |
| if (b >= 'A' && b <= 'Z') b += 32; |
199 |
0 |
199 |
| if (b >= 'A' && b <= 'Z') b += 32; |
0 |
199 |
199 |
|
| 154 |
199 |
| return a == b; |
| 155 |
|
| } |
| 156 |
|
| |
| 157 |
|
| /* Returns a static string: "c","xs","perl","xml","xhtml","html","css" or NULL */ |
| 158 |
43 |
| static const char *eshu_detect_lang_ext(const char *path) { |
| 159 |
43 |
| const char *dot = NULL; |
| 160 |
43 |
| const char *p = path + strlen(path); |
| 161 |
|
| size_t ext_len; |
| 162 |
|
| |
| 163 |
129 |
▶ | while (p > path) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (p > path) { |
129 |
0 |
129 |
|
| 164 |
129 |
| p--; |
| 165 |
129 |
▶ | if (*p == '.') { dot = p + 1; break; } |
Branch: 1 branch
| Branch | True | False | Total |
| if (*p == '.') { dot = p + 1; break; } |
43 |
86 |
129 |
|
| 166 |
86 |
▶ | if (*p == '/' || *p == '\\') break; |
Branch: 2 branches
| Branch | True | False | Total |
| if (*p == '/' || *p == '\\') break; |
86 |
0 |
86 |
| if (*p == '/' || *p == '\\') break; |
86 |
0 |
86 |
|
| 167 |
|
| } |
| 168 |
43 |
▶ | if (!dot) return NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!dot) return NULL; |
0 |
43 |
43 |
|
| 169 |
43 |
| ext_len = strlen(dot); |
| 170 |
|
| |
| 171 |
|
| /* c, h */ |
| 172 |
43 |
▶ | if (ext_len == 1 && (eshu_ci(dot[0], 'c') || eshu_ci(dot[0], 'h'))) |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 1 && (eshu_ci(dot[0], 'c') || eshu_ci(dot[0], 'h'))) |
5 |
38 |
43 |
| if (ext_len == 1 && (eshu_ci(dot[0], 'c') || eshu_ci(dot[0], 'h'))) |
0 |
5 |
5 |
| if (ext_len == 1 && (eshu_ci(dot[0], 'c') || eshu_ci(dot[0], 'h'))) |
0 |
0 |
0 |
|
| 173 |
5 |
| return "c"; |
| 174 |
|
| /* xs */ |
| 175 |
38 |
▶ | if (ext_len == 2 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's')) |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 2 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's')) |
33 |
5 |
38 |
| if (ext_len == 2 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's')) |
0 |
33 |
33 |
| if (ext_len == 2 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's')) |
0 |
0 |
0 |
|
| 176 |
0 |
| return "xs"; |
| 177 |
|
| /* pl, pm */ |
| 178 |
38 |
▶ | if (ext_len == 2 && eshu_ci(dot[0], 'p') |
Branch: 2 branches
| Branch | True | False | Total |
| if (ext_len == 2 && eshu_ci(dot[0], 'p') |
33 |
5 |
38 |
| if (ext_len == 2 && eshu_ci(dot[0], 'p') |
33 |
0 |
33 |
|
| 179 |
33 |
▶ | && (eshu_ci(dot[1], 'l') || eshu_ci(dot[1], 'm'))) |
Branch: 2 branches
| Branch | True | False | Total |
| && (eshu_ci(dot[1], 'l') || eshu_ci(dot[1], 'm'))) |
26 |
7 |
33 |
| && (eshu_ci(dot[1], 'l') || eshu_ci(dot[1], 'm'))) |
26 |
0 |
26 |
|
| 180 |
33 |
| return "perl"; |
| 181 |
|
| /* t */ |
| 182 |
5 |
▶ | if (ext_len == 1 && eshu_ci(dot[0], 't')) |
Branch: 2 branches
| Branch | True | False | Total |
| if (ext_len == 1 && eshu_ci(dot[0], 't')) |
0 |
5 |
5 |
| if (ext_len == 1 && eshu_ci(dot[0], 't')) |
0 |
0 |
0 |
|
| 183 |
0 |
| return "perl"; |
| 184 |
|
| /* xml */ |
| 185 |
5 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'm') && eshu_ci(dot[2], 'l')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'm') && eshu_ci(dot[2], 'l')) |
5 |
0 |
5 |
| if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'm') && eshu_ci(dot[2], 'l')) |
1 |
4 |
5 |
| if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'm') && eshu_ci(dot[2], 'l')) |
1 |
0 |
1 |
| if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'm') && eshu_ci(dot[2], 'l')) |
1 |
0 |
1 |
|
| 186 |
1 |
| return "xml"; |
| 187 |
|
| /* xsl */ |
| 188 |
4 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'l')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'l')) |
4 |
0 |
4 |
| if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'l')) |
0 |
4 |
4 |
| if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'l')) |
0 |
0 |
0 |
| if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'l')) |
0 |
0 |
0 |
|
| 189 |
0 |
| return "xml"; |
| 190 |
|
| /* xslt */ |
| 191 |
4 |
▶ | if (ext_len == 4 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 4 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's') |
0 |
4 |
4 |
| if (ext_len == 4 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's') |
0 |
0 |
0 |
| if (ext_len == 4 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's') |
0 |
0 |
0 |
|
| 192 |
0 |
▶ | && eshu_ci(dot[2], 'l') && eshu_ci(dot[3], 't')) |
Branch: 2 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 'l') && eshu_ci(dot[3], 't')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 'l') && eshu_ci(dot[3], 't')) |
0 |
0 |
0 |
|
| 193 |
0 |
| return "xml"; |
| 194 |
|
| /* svg */ |
| 195 |
4 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'v') && eshu_ci(dot[2], 'g')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'v') && eshu_ci(dot[2], 'g')) |
4 |
0 |
4 |
| if (ext_len == 3 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'v') && eshu_ci(dot[2], 'g')) |
0 |
4 |
4 |
| if (ext_len == 3 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'v') && eshu_ci(dot[2], 'g')) |
0 |
0 |
0 |
| if (ext_len == 3 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'v') && eshu_ci(dot[2], 'g')) |
0 |
0 |
0 |
|
| 196 |
0 |
| return "xml"; |
| 197 |
|
| /* xhtml */ |
| 198 |
4 |
▶ | if (ext_len == 5 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'h') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 5 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'h') |
0 |
4 |
4 |
| if (ext_len == 5 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'h') |
0 |
0 |
0 |
| if (ext_len == 5 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'h') |
0 |
0 |
0 |
|
| 199 |
0 |
▶ | && eshu_ci(dot[2], 't') && eshu_ci(dot[3], 'm') && eshu_ci(dot[4], 'l')) |
Branch: 3 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 't') && eshu_ci(dot[3], 'm') && eshu_ci(dot[4], 'l')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 't') && eshu_ci(dot[3], 'm') && eshu_ci(dot[4], 'l')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 't') && eshu_ci(dot[3], 'm') && eshu_ci(dot[4], 'l')) |
0 |
0 |
0 |
|
| 200 |
0 |
| return "xhtml"; |
| 201 |
|
| /* html */ |
| 202 |
4 |
▶ | if (ext_len == 4 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 4 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't') |
0 |
4 |
4 |
| if (ext_len == 4 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't') |
0 |
0 |
0 |
| if (ext_len == 4 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't') |
0 |
0 |
0 |
|
| 203 |
0 |
▶ | && eshu_ci(dot[2], 'm') && eshu_ci(dot[3], 'l')) |
Branch: 2 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 'm') && eshu_ci(dot[3], 'l')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 'm') && eshu_ci(dot[3], 'l')) |
0 |
0 |
0 |
|
| 204 |
0 |
| return "html"; |
| 205 |
|
| /* htm */ |
| 206 |
4 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 'm')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 'm')) |
4 |
0 |
4 |
| if (ext_len == 3 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 'm')) |
0 |
4 |
4 |
| if (ext_len == 3 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 'm')) |
0 |
0 |
0 |
| if (ext_len == 3 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 'm')) |
0 |
0 |
0 |
|
| 207 |
0 |
| return "html"; |
| 208 |
|
| /* tmpl */ |
| 209 |
4 |
▶ | if (ext_len == 4 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 'm') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 4 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 'm') |
0 |
4 |
4 |
| if (ext_len == 4 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 'm') |
0 |
0 |
0 |
| if (ext_len == 4 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 'm') |
0 |
0 |
0 |
|
| 210 |
0 |
▶ | && eshu_ci(dot[2], 'p') && eshu_ci(dot[3], 'l')) |
Branch: 2 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 'p') && eshu_ci(dot[3], 'l')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 'p') && eshu_ci(dot[3], 'l')) |
0 |
0 |
0 |
|
| 211 |
0 |
| return "html"; |
| 212 |
|
| /* tt */ |
| 213 |
4 |
▶ | if (ext_len == 2 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 't')) |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 2 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 't')) |
0 |
4 |
4 |
| if (ext_len == 2 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 't')) |
0 |
0 |
0 |
| if (ext_len == 2 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 't')) |
0 |
0 |
0 |
|
| 214 |
0 |
| return "html"; |
| 215 |
|
| /* ep */ |
| 216 |
4 |
▶ | if (ext_len == 2 && eshu_ci(dot[0], 'e') && eshu_ci(dot[1], 'p')) |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 2 && eshu_ci(dot[0], 'e') && eshu_ci(dot[1], 'p')) |
0 |
4 |
4 |
| if (ext_len == 2 && eshu_ci(dot[0], 'e') && eshu_ci(dot[1], 'p')) |
0 |
0 |
0 |
| if (ext_len == 2 && eshu_ci(dot[0], 'e') && eshu_ci(dot[1], 'p')) |
0 |
0 |
0 |
|
| 217 |
0 |
| return "html"; |
| 218 |
|
| /* css */ |
| 219 |
4 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 's')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 's')) |
4 |
0 |
4 |
| if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 's')) |
2 |
2 |
4 |
| if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 's')) |
2 |
0 |
2 |
| if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 's')) |
1 |
1 |
2 |
|
| 220 |
1 |
| return "css"; |
| 221 |
|
| /* scss */ |
| 222 |
3 |
▶ | if (ext_len == 4 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'c') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 4 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'c') |
0 |
3 |
3 |
| if (ext_len == 4 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'c') |
0 |
0 |
0 |
| if (ext_len == 4 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'c') |
0 |
0 |
0 |
|
| 223 |
0 |
▶ | && eshu_ci(dot[2], 's') && eshu_ci(dot[3], 's')) |
Branch: 2 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 's') && eshu_ci(dot[3], 's')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 's') && eshu_ci(dot[3], 's')) |
0 |
0 |
0 |
|
| 224 |
0 |
| return "css"; |
| 225 |
|
| /* less */ |
| 226 |
3 |
▶ | if (ext_len == 4 && eshu_ci(dot[0], 'l') && eshu_ci(dot[1], 'e') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 4 && eshu_ci(dot[0], 'l') && eshu_ci(dot[1], 'e') |
0 |
3 |
3 |
| if (ext_len == 4 && eshu_ci(dot[0], 'l') && eshu_ci(dot[1], 'e') |
0 |
0 |
0 |
| if (ext_len == 4 && eshu_ci(dot[0], 'l') && eshu_ci(dot[1], 'e') |
0 |
0 |
0 |
|
| 227 |
0 |
▶ | && eshu_ci(dot[2], 's') && eshu_ci(dot[3], 's')) |
Branch: 2 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 's') && eshu_ci(dot[3], 's')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 's') && eshu_ci(dot[3], 's')) |
0 |
0 |
0 |
|
| 228 |
0 |
| return "css"; |
| 229 |
|
| |
| 230 |
|
| /* js */ |
| 231 |
3 |
▶ | if (ext_len == 2 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's')) |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 2 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's')) |
0 |
3 |
3 |
| if (ext_len == 2 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's')) |
0 |
0 |
0 |
| if (ext_len == 2 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's')) |
0 |
0 |
0 |
|
| 232 |
0 |
| return "js"; |
| 233 |
|
| /* jsx */ |
| 234 |
3 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x')) |
3 |
0 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x')) |
0 |
3 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x')) |
0 |
0 |
0 |
| if (ext_len == 3 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x')) |
0 |
0 |
0 |
|
| 235 |
0 |
| return "js"; |
| 236 |
|
| /* mjs */ |
| 237 |
3 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's')) |
3 |
0 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's')) |
0 |
3 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's')) |
0 |
0 |
0 |
| if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's')) |
0 |
0 |
0 |
|
| 238 |
0 |
| return "js"; |
| 239 |
|
| /* cjs */ |
| 240 |
3 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's')) |
3 |
0 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's')) |
1 |
2 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's')) |
0 |
1 |
1 |
| if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's')) |
0 |
0 |
0 |
|
| 241 |
0 |
| return "js"; |
| 242 |
|
| /* ts */ |
| 243 |
3 |
▶ | if (ext_len == 2 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's')) |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 2 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's')) |
0 |
3 |
3 |
| if (ext_len == 2 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's')) |
0 |
0 |
0 |
| if (ext_len == 2 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's')) |
0 |
0 |
0 |
|
| 244 |
0 |
| return "ts"; |
| 245 |
|
| /* tsx */ |
| 246 |
3 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x')) |
3 |
0 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x')) |
2 |
1 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x')) |
0 |
2 |
2 |
| if (ext_len == 3 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x')) |
0 |
0 |
0 |
|
| 247 |
0 |
| return "ts"; |
| 248 |
|
| /* mts */ |
| 249 |
3 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 's')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 's')) |
3 |
0 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 's')) |
0 |
3 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 's')) |
0 |
0 |
0 |
| if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 's')) |
0 |
0 |
0 |
|
| 250 |
0 |
| return "ts"; |
| 251 |
|
| |
| 252 |
|
| /* pod */ |
| 253 |
3 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'o') && eshu_ci(dot[2], 'd')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'o') && eshu_ci(dot[2], 'd')) |
3 |
0 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'o') && eshu_ci(dot[2], 'd')) |
0 |
3 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'o') && eshu_ci(dot[2], 'd')) |
0 |
0 |
0 |
| if (ext_len == 3 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'o') && eshu_ci(dot[2], 'd')) |
0 |
0 |
0 |
|
| 254 |
0 |
| return "pod"; |
| 255 |
|
| |
| 256 |
|
| /* sh */ |
| 257 |
3 |
▶ | if (ext_len == 2 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'h')) |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 2 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'h')) |
0 |
3 |
3 |
| if (ext_len == 2 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'h')) |
0 |
0 |
0 |
| if (ext_len == 2 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'h')) |
0 |
0 |
0 |
|
| 258 |
0 |
| return "bash"; |
| 259 |
|
| /* bash */ |
| 260 |
3 |
▶ | if (ext_len == 4 && eshu_ci(dot[0], 'b') && eshu_ci(dot[1], 'a') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 4 && eshu_ci(dot[0], 'b') && eshu_ci(dot[1], 'a') |
0 |
3 |
3 |
| if (ext_len == 4 && eshu_ci(dot[0], 'b') && eshu_ci(dot[1], 'a') |
0 |
0 |
0 |
| if (ext_len == 4 && eshu_ci(dot[0], 'b') && eshu_ci(dot[1], 'a') |
0 |
0 |
0 |
|
| 261 |
0 |
▶ | && eshu_ci(dot[2], 's') && eshu_ci(dot[3], 'h')) |
Branch: 2 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 's') && eshu_ci(dot[3], 'h')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 's') && eshu_ci(dot[3], 'h')) |
0 |
0 |
0 |
|
| 262 |
0 |
| return "bash"; |
| 263 |
|
| /* zsh */ |
| 264 |
3 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'z') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'h')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'z') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'h')) |
3 |
0 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'z') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'h')) |
0 |
3 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'z') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'h')) |
0 |
0 |
0 |
| if (ext_len == 3 && eshu_ci(dot[0], 'z') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'h')) |
0 |
0 |
0 |
|
| 265 |
0 |
| return "bash"; |
| 266 |
|
| /* ksh */ |
| 267 |
3 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'k') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'h')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'k') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'h')) |
3 |
0 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'k') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'h')) |
0 |
3 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'k') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'h')) |
0 |
0 |
0 |
| if (ext_len == 3 && eshu_ci(dot[0], 'k') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'h')) |
0 |
0 |
0 |
|
| 268 |
0 |
| return "bash"; |
| 269 |
|
| |
| 270 |
|
| /* go */ |
| 271 |
3 |
▶ | if (ext_len == 2 && eshu_ci(dot[0], 'g') && eshu_ci(dot[1], 'o')) |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 2 && eshu_ci(dot[0], 'g') && eshu_ci(dot[1], 'o')) |
0 |
3 |
3 |
| if (ext_len == 2 && eshu_ci(dot[0], 'g') && eshu_ci(dot[1], 'o')) |
0 |
0 |
0 |
| if (ext_len == 2 && eshu_ci(dot[0], 'g') && eshu_ci(dot[1], 'o')) |
0 |
0 |
0 |
|
| 272 |
0 |
| return "go"; |
| 273 |
|
| |
| 274 |
|
| /* rs (Rust) */ |
| 275 |
3 |
▶ | if (ext_len == 2 && eshu_ci(dot[0], 'r') && eshu_ci(dot[1], 's')) |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 2 && eshu_ci(dot[0], 'r') && eshu_ci(dot[1], 's')) |
0 |
3 |
3 |
| if (ext_len == 2 && eshu_ci(dot[0], 'r') && eshu_ci(dot[1], 's')) |
0 |
0 |
0 |
| if (ext_len == 2 && eshu_ci(dot[0], 'r') && eshu_ci(dot[1], 's')) |
0 |
0 |
0 |
|
| 276 |
0 |
| return "rust"; |
| 277 |
|
| |
| 278 |
|
| /* lua */ |
| 279 |
3 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'l') && eshu_ci(dot[1], 'u') && eshu_ci(dot[2], 'a')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'l') && eshu_ci(dot[1], 'u') && eshu_ci(dot[2], 'a')) |
3 |
0 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'l') && eshu_ci(dot[1], 'u') && eshu_ci(dot[2], 'a')) |
0 |
3 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'l') && eshu_ci(dot[1], 'u') && eshu_ci(dot[2], 'a')) |
0 |
0 |
0 |
| if (ext_len == 3 && eshu_ci(dot[0], 'l') && eshu_ci(dot[1], 'u') && eshu_ci(dot[2], 'a')) |
0 |
0 |
0 |
|
| 280 |
0 |
| return "lua"; |
| 281 |
|
| |
| 282 |
|
| /* json */ |
| 283 |
3 |
▶ | if (ext_len == 4 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 4 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') |
0 |
3 |
3 |
| if (ext_len == 4 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') |
0 |
0 |
0 |
| if (ext_len == 4 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') |
0 |
0 |
0 |
|
| 284 |
0 |
▶ | && eshu_ci(dot[2], 'o') && eshu_ci(dot[3], 'n')) |
Branch: 2 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 'o') && eshu_ci(dot[3], 'n')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 'o') && eshu_ci(dot[3], 'n')) |
0 |
0 |
0 |
|
| 285 |
0 |
| return "json"; |
| 286 |
|
| /* jsonc */ |
| 287 |
3 |
▶ | if (ext_len == 5 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 5 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') |
0 |
3 |
3 |
| if (ext_len == 5 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') |
0 |
0 |
0 |
| if (ext_len == 5 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') |
0 |
0 |
0 |
|
| 288 |
0 |
▶ | && eshu_ci(dot[2], 'o') && eshu_ci(dot[3], 'n') && eshu_ci(dot[4], 'c')) |
Branch: 3 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 'o') && eshu_ci(dot[3], 'n') && eshu_ci(dot[4], 'c')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 'o') && eshu_ci(dot[3], 'n') && eshu_ci(dot[4], 'c')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 'o') && eshu_ci(dot[3], 'n') && eshu_ci(dot[4], 'c')) |
0 |
0 |
0 |
|
| 289 |
0 |
| return "json"; |
| 290 |
|
| |
| 291 |
|
| /* java */ |
| 292 |
3 |
▶ | if (ext_len == 4 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 'a') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 4 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 'a') |
0 |
3 |
3 |
| if (ext_len == 4 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 'a') |
0 |
0 |
0 |
| if (ext_len == 4 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 'a') |
0 |
0 |
0 |
|
| 293 |
0 |
▶ | && eshu_ci(dot[2], 'v') && eshu_ci(dot[3], 'a')) |
Branch: 2 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 'v') && eshu_ci(dot[3], 'a')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 'v') && eshu_ci(dot[3], 'a')) |
0 |
0 |
0 |
|
| 294 |
0 |
| return "java"; |
| 295 |
|
| |
| 296 |
|
| /* php */ |
| 297 |
3 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'h') && eshu_ci(dot[2], 'p')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'h') && eshu_ci(dot[2], 'p')) |
3 |
0 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'h') && eshu_ci(dot[2], 'p')) |
0 |
3 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'h') && eshu_ci(dot[2], 'p')) |
0 |
0 |
0 |
| if (ext_len == 3 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'h') && eshu_ci(dot[2], 'p')) |
0 |
0 |
0 |
|
| 298 |
0 |
| return "php"; |
| 299 |
|
| /* phtml */ |
| 300 |
3 |
▶ | if (ext_len == 5 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'h') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 5 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'h') |
0 |
3 |
3 |
| if (ext_len == 5 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'h') |
0 |
0 |
0 |
| if (ext_len == 5 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'h') |
0 |
0 |
0 |
|
| 301 |
0 |
▶ | && eshu_ci(dot[2], 't') && eshu_ci(dot[3], 'm') && eshu_ci(dot[4], 'l')) |
Branch: 3 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 't') && eshu_ci(dot[3], 'm') && eshu_ci(dot[4], 'l')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 't') && eshu_ci(dot[3], 'm') && eshu_ci(dot[4], 'l')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 't') && eshu_ci(dot[3], 'm') && eshu_ci(dot[4], 'l')) |
0 |
0 |
0 |
|
| 302 |
0 |
| return "php"; |
| 303 |
|
| /* php3/4/5 */ |
| 304 |
3 |
▶ | if (ext_len == 4 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'h') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 4 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'h') |
0 |
3 |
3 |
| if (ext_len == 4 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'h') |
0 |
0 |
0 |
| if (ext_len == 4 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'h') |
0 |
0 |
0 |
|
| 305 |
0 |
▶ | && eshu_ci(dot[2], 'p') && (dot[3] >= '3' && dot[3] <= '5')) |
Branch: 3 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 'p') && (dot[3] >= '3' && dot[3] <= '5')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 'p') && (dot[3] >= '3' && dot[3] <= '5')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 'p') && (dot[3] >= '3' && dot[3] <= '5')) |
0 |
0 |
0 |
|
| 306 |
0 |
| return "php"; |
| 307 |
|
| |
| 308 |
|
| /* rb */ |
| 309 |
3 |
▶ | if (ext_len == 2 && eshu_ci(dot[0], 'r') && eshu_ci(dot[1], 'b')) |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 2 && eshu_ci(dot[0], 'r') && eshu_ci(dot[1], 'b')) |
0 |
3 |
3 |
| if (ext_len == 2 && eshu_ci(dot[0], 'r') && eshu_ci(dot[1], 'b')) |
0 |
0 |
0 |
| if (ext_len == 2 && eshu_ci(dot[0], 'r') && eshu_ci(dot[1], 'b')) |
0 |
0 |
0 |
|
| 310 |
0 |
| return "ruby"; |
| 311 |
|
| /* rake */ |
| 312 |
3 |
▶ | if (ext_len == 4 && eshu_ci(dot[0], 'r') && eshu_ci(dot[1], 'a') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 4 && eshu_ci(dot[0], 'r') && eshu_ci(dot[1], 'a') |
0 |
3 |
3 |
| if (ext_len == 4 && eshu_ci(dot[0], 'r') && eshu_ci(dot[1], 'a') |
0 |
0 |
0 |
| if (ext_len == 4 && eshu_ci(dot[0], 'r') && eshu_ci(dot[1], 'a') |
0 |
0 |
0 |
|
| 313 |
0 |
▶ | && eshu_ci(dot[2], 'k') && eshu_ci(dot[3], 'e')) |
Branch: 2 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 'k') && eshu_ci(dot[3], 'e')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 'k') && eshu_ci(dot[3], 'e')) |
0 |
0 |
0 |
|
| 314 |
0 |
| return "ruby"; |
| 315 |
|
| |
| 316 |
|
| /* sql */ |
| 317 |
3 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'q') && eshu_ci(dot[2], 'l')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'q') && eshu_ci(dot[2], 'l')) |
3 |
0 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'q') && eshu_ci(dot[2], 'l')) |
0 |
3 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'q') && eshu_ci(dot[2], 'l')) |
0 |
0 |
0 |
| if (ext_len == 3 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'q') && eshu_ci(dot[2], 'l')) |
0 |
0 |
0 |
|
| 318 |
0 |
| return "sql"; |
| 319 |
|
| /* psql */ |
| 320 |
3 |
▶ | if (ext_len == 4 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 's') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 4 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 's') |
0 |
3 |
3 |
| if (ext_len == 4 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 's') |
0 |
0 |
0 |
| if (ext_len == 4 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 's') |
0 |
0 |
0 |
|
| 321 |
0 |
▶ | && eshu_ci(dot[2], 'q') && eshu_ci(dot[3], 'l')) |
Branch: 2 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 'q') && eshu_ci(dot[3], 'l')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 'q') && eshu_ci(dot[3], 'l')) |
0 |
0 |
0 |
|
| 322 |
0 |
| return "sql"; |
| 323 |
|
| /* ddl */ |
| 324 |
3 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'd') && eshu_ci(dot[1], 'd') && eshu_ci(dot[2], 'l')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'd') && eshu_ci(dot[1], 'd') && eshu_ci(dot[2], 'l')) |
3 |
0 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'd') && eshu_ci(dot[1], 'd') && eshu_ci(dot[2], 'l')) |
0 |
3 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'd') && eshu_ci(dot[1], 'd') && eshu_ci(dot[2], 'l')) |
0 |
0 |
0 |
| if (ext_len == 3 && eshu_ci(dot[0], 'd') && eshu_ci(dot[1], 'd') && eshu_ci(dot[2], 'l')) |
0 |
0 |
0 |
|
| 325 |
0 |
| return "sql"; |
| 326 |
|
| |
| 327 |
|
| /* yaml */ |
| 328 |
3 |
▶ | if (ext_len == 4 && eshu_ci(dot[0], 'y') && eshu_ci(dot[1], 'a') |
Branch: 3 branches
| Branch | True | False | Total |
| if (ext_len == 4 && eshu_ci(dot[0], 'y') && eshu_ci(dot[1], 'a') |
0 |
3 |
3 |
| if (ext_len == 4 && eshu_ci(dot[0], 'y') && eshu_ci(dot[1], 'a') |
0 |
0 |
0 |
| if (ext_len == 4 && eshu_ci(dot[0], 'y') && eshu_ci(dot[1], 'a') |
0 |
0 |
0 |
|
| 329 |
0 |
▶ | && eshu_ci(dot[2], 'm') && eshu_ci(dot[3], 'l')) |
Branch: 2 branches
| Branch | True | False | Total |
| && eshu_ci(dot[2], 'm') && eshu_ci(dot[3], 'l')) |
0 |
0 |
0 |
| && eshu_ci(dot[2], 'm') && eshu_ci(dot[3], 'l')) |
0 |
0 |
0 |
|
| 330 |
0 |
| return "yaml"; |
| 331 |
|
| /* yml */ |
| 332 |
3 |
▶ | if (ext_len == 3 && eshu_ci(dot[0], 'y') && eshu_ci(dot[1], 'm') && eshu_ci(dot[2], 'l')) |
Branch: 4 branches
| Branch | True | False | Total |
| if (ext_len == 3 && eshu_ci(dot[0], 'y') && eshu_ci(dot[1], 'm') && eshu_ci(dot[2], 'l')) |
3 |
0 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'y') && eshu_ci(dot[1], 'm') && eshu_ci(dot[2], 'l')) |
0 |
3 |
3 |
| if (ext_len == 3 && eshu_ci(dot[0], 'y') && eshu_ci(dot[1], 'm') && eshu_ci(dot[2], 'l')) |
0 |
0 |
0 |
| if (ext_len == 3 && eshu_ci(dot[0], 'y') && eshu_ci(dot[1], 'm') && eshu_ci(dot[2], 'l')) |
0 |
0 |
0 |
|
| 333 |
0 |
| return "yaml"; |
| 334 |
|
| |
| 335 |
3 |
| return NULL; |
| 336 |
|
| } |
| 337 |
|
| |
| 338 |
|
| /* ══════════════════════════════════════════════════════════════════ |
| 339 |
|
| * Config from lang string |
| 340 |
|
| * ══════════════════════════════════════════════════════════════════ */ |
| 341 |
|
| |
| 342 |
|
| /* Forward declarations for engine functions — headers must already be included */ |
| 343 |
|
| |
| 344 |
41 |
| static int eshu_lang_from_string(const char *lang) { |
| 345 |
41 |
▶ | if (!lang) return -1; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!lang) return -1; |
0 |
41 |
41 |
|
| 346 |
41 |
▶ | if (strcmp(lang, "c") == 0) return ESHU_LANG_C; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "c") == 0) return ESHU_LANG_C; |
5 |
36 |
41 |
|
| 347 |
36 |
▶ | if (strcmp(lang, "perl") == 0) return ESHU_LANG_PERL; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "perl") == 0) return ESHU_LANG_PERL; |
34 |
2 |
36 |
|
| 348 |
2 |
▶ | if (strcmp(lang, "pl") == 0) return ESHU_LANG_PERL; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "pl") == 0) return ESHU_LANG_PERL; |
0 |
2 |
2 |
|
| 349 |
2 |
▶ | if (strcmp(lang, "xs") == 0) return ESHU_LANG_XS; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "xs") == 0) return ESHU_LANG_XS; |
0 |
2 |
2 |
|
| 350 |
2 |
▶ | if (strcmp(lang, "xml") == 0) return ESHU_LANG_XML; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "xml") == 0) return ESHU_LANG_XML; |
1 |
1 |
2 |
|
| 351 |
1 |
▶ | if (strcmp(lang, "xsl") == 0) return ESHU_LANG_XML; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "xsl") == 0) return ESHU_LANG_XML; |
0 |
1 |
1 |
|
| 352 |
1 |
▶ | if (strcmp(lang, "xslt") == 0) return ESHU_LANG_XML; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "xslt") == 0) return ESHU_LANG_XML; |
0 |
1 |
1 |
|
| 353 |
1 |
▶ | if (strcmp(lang, "svg") == 0) return ESHU_LANG_XML; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "svg") == 0) return ESHU_LANG_XML; |
0 |
1 |
1 |
|
| 354 |
1 |
▶ | if (strcmp(lang, "xhtml") == 0) return ESHU_LANG_XML; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "xhtml") == 0) return ESHU_LANG_XML; |
0 |
1 |
1 |
|
| 355 |
1 |
▶ | if (strcmp(lang, "html") == 0) return ESHU_LANG_HTML; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "html") == 0) return ESHU_LANG_HTML; |
0 |
1 |
1 |
|
| 356 |
1 |
▶ | if (strcmp(lang, "htm") == 0) return ESHU_LANG_HTML; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "htm") == 0) return ESHU_LANG_HTML; |
0 |
1 |
1 |
|
| 357 |
1 |
▶ | if (strcmp(lang, "tmpl") == 0) return ESHU_LANG_HTML; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "tmpl") == 0) return ESHU_LANG_HTML; |
0 |
1 |
1 |
|
| 358 |
1 |
▶ | if (strcmp(lang, "tt") == 0) return ESHU_LANG_HTML; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "tt") == 0) return ESHU_LANG_HTML; |
0 |
1 |
1 |
|
| 359 |
1 |
▶ | if (strcmp(lang, "ep") == 0) return ESHU_LANG_HTML; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "ep") == 0) return ESHU_LANG_HTML; |
0 |
1 |
1 |
|
| 360 |
1 |
▶ | if (strcmp(lang, "css") == 0) return ESHU_LANG_CSS; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "css") == 0) return ESHU_LANG_CSS; |
1 |
0 |
1 |
|
| 361 |
0 |
▶ | if (strcmp(lang, "scss") == 0) return ESHU_LANG_CSS; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "scss") == 0) return ESHU_LANG_CSS; |
0 |
0 |
0 |
|
| 362 |
0 |
▶ | if (strcmp(lang, "less") == 0) return ESHU_LANG_CSS; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "less") == 0) return ESHU_LANG_CSS; |
0 |
0 |
0 |
|
| 363 |
0 |
▶ | if (strcmp(lang, "js") == 0) return ESHU_LANG_JS; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "js") == 0) return ESHU_LANG_JS; |
0 |
0 |
0 |
|
| 364 |
0 |
▶ | if (strcmp(lang, "javascript") == 0) return ESHU_LANG_JS; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "javascript") == 0) return ESHU_LANG_JS; |
0 |
0 |
0 |
|
| 365 |
0 |
▶ | if (strcmp(lang, "jsx") == 0) return ESHU_LANG_JS; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "jsx") == 0) return ESHU_LANG_JS; |
0 |
0 |
0 |
|
| 366 |
0 |
▶ | if (strcmp(lang, "mjs") == 0) return ESHU_LANG_JS; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "mjs") == 0) return ESHU_LANG_JS; |
0 |
0 |
0 |
|
| 367 |
0 |
▶ | if (strcmp(lang, "cjs") == 0) return ESHU_LANG_JS; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "cjs") == 0) return ESHU_LANG_JS; |
0 |
0 |
0 |
|
| 368 |
0 |
▶ | if (strcmp(lang, "ts") == 0) return ESHU_LANG_TS; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "ts") == 0) return ESHU_LANG_TS; |
0 |
0 |
0 |
|
| 369 |
0 |
▶ | if (strcmp(lang, "typescript") == 0) return ESHU_LANG_TS; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "typescript") == 0) return ESHU_LANG_TS; |
0 |
0 |
0 |
|
| 370 |
0 |
▶ | if (strcmp(lang, "tsx") == 0) return ESHU_LANG_TS; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "tsx") == 0) return ESHU_LANG_TS; |
0 |
0 |
0 |
|
| 371 |
0 |
▶ | if (strcmp(lang, "mts") == 0) return ESHU_LANG_TS; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "mts") == 0) return ESHU_LANG_TS; |
0 |
0 |
0 |
|
| 372 |
0 |
▶ | if (strcmp(lang, "pod") == 0) return ESHU_LANG_POD; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "pod") == 0) return ESHU_LANG_POD; |
0 |
0 |
0 |
|
| 373 |
0 |
▶ | if (strcmp(lang, "bash") == 0) return ESHU_LANG_BASH; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "bash") == 0) return ESHU_LANG_BASH; |
0 |
0 |
0 |
|
| 374 |
0 |
▶ | if (strcmp(lang, "sh") == 0) return ESHU_LANG_BASH; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "sh") == 0) return ESHU_LANG_BASH; |
0 |
0 |
0 |
|
| 375 |
0 |
▶ | if (strcmp(lang, "shell") == 0) return ESHU_LANG_BASH; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "shell") == 0) return ESHU_LANG_BASH; |
0 |
0 |
0 |
|
| 376 |
0 |
▶ | if (strcmp(lang, "zsh") == 0) return ESHU_LANG_BASH; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "zsh") == 0) return ESHU_LANG_BASH; |
0 |
0 |
0 |
|
| 377 |
0 |
▶ | if (strcmp(lang, "ksh") == 0) return ESHU_LANG_BASH; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "ksh") == 0) return ESHU_LANG_BASH; |
0 |
0 |
0 |
|
| 378 |
0 |
▶ | if (strcmp(lang, "go") == 0) return ESHU_LANG_GO; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "go") == 0) return ESHU_LANG_GO; |
0 |
0 |
0 |
|
| 379 |
0 |
▶ | if (strcmp(lang, "rust") == 0) return ESHU_LANG_RUST; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "rust") == 0) return ESHU_LANG_RUST; |
0 |
0 |
0 |
|
| 380 |
0 |
▶ | if (strcmp(lang, "rs") == 0) return ESHU_LANG_RUST; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "rs") == 0) return ESHU_LANG_RUST; |
0 |
0 |
0 |
|
| 381 |
0 |
▶ | if (strcmp(lang, "lua") == 0) return ESHU_LANG_LUA; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "lua") == 0) return ESHU_LANG_LUA; |
0 |
0 |
0 |
|
| 382 |
0 |
▶ | if (strcmp(lang, "json") == 0) return ESHU_LANG_JSON; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "json") == 0) return ESHU_LANG_JSON; |
0 |
0 |
0 |
|
| 383 |
0 |
▶ | if (strcmp(lang, "jsonc") == 0) return ESHU_LANG_JSON; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "jsonc") == 0) return ESHU_LANG_JSON; |
0 |
0 |
0 |
|
| 384 |
0 |
▶ | if (strcmp(lang, "java") == 0) return ESHU_LANG_JAVA; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "java") == 0) return ESHU_LANG_JAVA; |
0 |
0 |
0 |
|
| 385 |
0 |
▶ | if (strcmp(lang, "php") == 0) return ESHU_LANG_PHP; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "php") == 0) return ESHU_LANG_PHP; |
0 |
0 |
0 |
|
| 386 |
0 |
▶ | if (strcmp(lang, "phtml") == 0) return ESHU_LANG_PHP; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "phtml") == 0) return ESHU_LANG_PHP; |
0 |
0 |
0 |
|
| 387 |
0 |
▶ | if (strcmp(lang, "sql") == 0) return ESHU_LANG_SQL; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "sql") == 0) return ESHU_LANG_SQL; |
0 |
0 |
0 |
|
| 388 |
0 |
▶ | if (strcmp(lang, "psql") == 0) return ESHU_LANG_SQL; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "psql") == 0) return ESHU_LANG_SQL; |
0 |
0 |
0 |
|
| 389 |
0 |
▶ | if (strcmp(lang, "ddl") == 0) return ESHU_LANG_SQL; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "ddl") == 0) return ESHU_LANG_SQL; |
0 |
0 |
0 |
|
| 390 |
0 |
▶ | if (strcmp(lang, "ruby") == 0) return ESHU_LANG_RUBY; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "ruby") == 0) return ESHU_LANG_RUBY; |
0 |
0 |
0 |
|
| 391 |
0 |
▶ | if (strcmp(lang, "rb") == 0) return ESHU_LANG_RUBY; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "rb") == 0) return ESHU_LANG_RUBY; |
0 |
0 |
0 |
|
| 392 |
0 |
▶ | if (strcmp(lang, "rake") == 0) return ESHU_LANG_RUBY; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "rake") == 0) return ESHU_LANG_RUBY; |
0 |
0 |
0 |
|
| 393 |
0 |
▶ | if (strcmp(lang, "yaml") == 0) return ESHU_LANG_YAML; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "yaml") == 0) return ESHU_LANG_YAML; |
0 |
0 |
0 |
|
| 394 |
0 |
▶ | if (strcmp(lang, "yml") == 0) return ESHU_LANG_YAML; |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(lang, "yml") == 0) return ESHU_LANG_YAML; |
0 |
0 |
0 |
|
| 395 |
0 |
| return -1; |
| 396 |
|
| } |
| 397 |
|
| |
| 398 |
|
| /* Dispatch to the correct indentation engine. |
| 399 |
|
| * Returns malloc'd result; caller must free. */ |
| 400 |
41 |
| static char *eshu_indent_dispatch(const char *src, size_t src_len, |
| 401 |
|
| eshu_config_t *cfg, size_t *out_len) |
| 402 |
|
| { |
| 403 |
41 |
| switch (cfg->lang) { |
| 404 |
34 |
| case ESHU_LANG_PERL: |
| 405 |
34 |
| return eshu_indent_pl(src, src_len, cfg, out_len); |
| 406 |
0 |
| case ESHU_LANG_XS: |
| 407 |
0 |
| return eshu_indent_xs(src, src_len, cfg, out_len); |
| 408 |
1 |
| case ESHU_LANG_XML: |
| 409 |
|
| case ESHU_LANG_HTML: |
| 410 |
1 |
| return eshu_indent_xml(src, src_len, cfg, out_len); |
| 411 |
1 |
| case ESHU_LANG_CSS: |
| 412 |
1 |
| return eshu_indent_css(src, src_len, cfg, out_len); |
| 413 |
0 |
| case ESHU_LANG_JS: |
| 414 |
0 |
| return eshu_indent_js(src, src_len, cfg, out_len); |
| 415 |
0 |
| case ESHU_LANG_POD: |
| 416 |
0 |
| return eshu_indent_pod(src, src_len, cfg, out_len); |
| 417 |
0 |
| case ESHU_LANG_BASH: |
| 418 |
0 |
| return eshu_indent_bash(src, src_len, cfg, out_len); |
| 419 |
0 |
| case ESHU_LANG_PYTHON: |
| 420 |
0 |
| return eshu_indent_python(src, src_len, cfg, out_len); |
| 421 |
0 |
| case ESHU_LANG_GO: |
| 422 |
0 |
| return eshu_indent_go(src, src_len, cfg, out_len); |
| 423 |
0 |
| case ESHU_LANG_RUST: |
| 424 |
0 |
| return eshu_indent_rust(src, src_len, cfg, out_len); |
| 425 |
0 |
| case ESHU_LANG_TS: |
| 426 |
0 |
| return eshu_indent_ts(src, src_len, cfg, out_len); |
| 427 |
0 |
| case ESHU_LANG_LUA: |
| 428 |
0 |
| return eshu_indent_lua(src, src_len, cfg, out_len); |
| 429 |
0 |
| case ESHU_LANG_JSON: |
| 430 |
0 |
| return eshu_indent_json(src, src_len, cfg, out_len); |
| 431 |
0 |
| case ESHU_LANG_JAVA: |
| 432 |
0 |
| return eshu_indent_java(src, src_len, cfg, out_len); |
| 433 |
0 |
| case ESHU_LANG_PHP: |
| 434 |
0 |
| return eshu_indent_php(src, src_len, cfg, out_len); |
| 435 |
0 |
| case ESHU_LANG_SQL: |
| 436 |
0 |
| return eshu_indent_sql(src, src_len, cfg, out_len); |
| 437 |
0 |
| case ESHU_LANG_YAML: |
| 438 |
0 |
| return eshu_indent_yaml(src, src_len, cfg, out_len); |
| 439 |
0 |
| case ESHU_LANG_RUBY: |
| 440 |
0 |
| return eshu_indent_ruby(src, src_len, cfg, out_len); |
| 441 |
5 |
| default: |
| 442 |
5 |
| return eshu_indent_c(src, src_len, cfg, out_len); |
| 443 |
|
| } |
| 444 |
|
| } |
| 445 |
|
| |
| 446 |
|
| /* ══════════════════════════════════════════════════════════════════ |
| 447 |
|
| * indent_file — process a single file |
| 448 |
|
| * ══════════════════════════════════════════════════════════════════ */ |
| 449 |
|
| |
| 450 |
|
| /* opts bitflags */ |
| 451 |
|
| #define ESHU_OPT_FIX 1 |
| 452 |
|
| #define ESHU_OPT_DIFF 2 |
| 453 |
|
| |
| 454 |
47 |
| static void eshu_indent_file(const char *path, const eshu_config_t *cfg, |
| 455 |
|
| const char *force_lang, int opts, |
| 456 |
|
| eshu_file_result_t *result) |
| 457 |
|
| { |
| 458 |
|
| struct stat st; |
| 459 |
|
| FILE *fp; |
| 460 |
|
| char *src; |
| 461 |
|
| size_t src_len, out_len; |
| 462 |
|
| char *fixed; |
| 463 |
|
| const char *lang_str; |
| 464 |
|
| int lang_id; |
| 465 |
|
| eshu_config_t file_cfg; |
| 466 |
|
| |
| 467 |
47 |
| eshu_file_result_init(result); |
| 468 |
47 |
| result->file = strdup(path); |
| 469 |
|
| |
| 470 |
|
| /* Check file exists and is regular */ |
| 471 |
47 |
▶ | if (stat(path, &st) != 0 || !S_ISREG(st.st_mode)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (stat(path, &st) != 0 || !S_ISREG(st.st_mode)) { |
46 |
1 |
47 |
| if (stat(path, &st) != 0 || !S_ISREG(st.st_mode)) { |
0 |
46 |
46 |
|
| 472 |
1 |
| result->status = ESHU_STATUS_ERROR; |
| 473 |
1 |
| result->error = strdup("not a readable file"); |
| 474 |
6 |
| return; |
| 475 |
|
| } |
| 476 |
|
| |
| 477 |
|
| /* Size limit */ |
| 478 |
46 |
▶ | if (st.st_size > ESHU_MAX_FILE_SIZE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (st.st_size > ESHU_MAX_FILE_SIZE) { |
0 |
46 |
46 |
|
| 479 |
0 |
| result->status = ESHU_STATUS_SKIPPED; |
| 480 |
0 |
| result->reason = strdup("file too large"); |
| 481 |
0 |
| return; |
| 482 |
|
| } |
| 483 |
|
| |
| 484 |
|
| /* Read file */ |
| 485 |
46 |
| fp = fopen(path, "rb"); |
| 486 |
46 |
▶ | if (!fp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!fp) { |
0 |
46 |
46 |
|
| 487 |
0 |
| result->status = ESHU_STATUS_ERROR; |
| 488 |
0 |
| result->error = strdup("cannot open file"); |
| 489 |
0 |
| return; |
| 490 |
|
| } |
| 491 |
46 |
| src_len = (size_t)st.st_size; |
| 492 |
46 |
| src = (char *)malloc(src_len + 1); |
| 493 |
46 |
▶ | if (fread(src, 1, src_len, fp) != src_len) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fread(src, 1, src_len, fp) != src_len) { |
0 |
46 |
46 |
|
| 494 |
0 |
| fclose(fp); |
| 495 |
0 |
| free(src); |
| 496 |
0 |
| result->status = ESHU_STATUS_ERROR; |
| 497 |
0 |
| result->error = strdup("read error"); |
| 498 |
0 |
| return; |
| 499 |
|
| } |
| 500 |
46 |
| fclose(fp); |
| 501 |
46 |
| src[src_len] = '\0'; |
| 502 |
|
| |
| 503 |
|
| /* Binary detection: NUL in first 8KB */ |
| 504 |
46 |
▶ | if (src_len > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (src_len > 0) { |
46 |
0 |
46 |
|
| 505 |
46 |
| size_t check = src_len < ESHU_BINARY_SAMPLE ? src_len : ESHU_BINARY_SAMPLE; |
| 506 |
46 |
▶ | if (memchr(src, '\0', check) != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (memchr(src, '\0', check) != NULL) { |
2 |
44 |
46 |
|
| 507 |
2 |
| free(src); |
| 508 |
2 |
| result->status = ESHU_STATUS_SKIPPED; |
| 509 |
2 |
| result->reason = strdup("binary file"); |
| 510 |
2 |
| return; |
| 511 |
|
| } |
| 512 |
|
| } |
| 513 |
|
| |
| 514 |
|
| /* Detect language */ |
| 515 |
44 |
▶ | lang_str = force_lang ? force_lang : eshu_detect_lang_ext(path); |
Branch: 1 branch
| Branch | True | False | Total |
| lang_str = force_lang ? force_lang : eshu_detect_lang_ext(path); |
43 |
1 |
44 |
|
| 516 |
44 |
▶ | if (!lang_str) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!lang_str) { |
3 |
41 |
44 |
|
| 517 |
3 |
| free(src); |
| 518 |
3 |
| result->status = ESHU_STATUS_SKIPPED; |
| 519 |
3 |
| result->reason = strdup("unrecognised extension"); |
| 520 |
3 |
| return; |
| 521 |
|
| } |
| 522 |
41 |
| lang_id = eshu_lang_from_string(lang_str); |
| 523 |
41 |
▶ | if (lang_id < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (lang_id < 0) { |
0 |
41 |
41 |
|
| 524 |
0 |
| free(src); |
| 525 |
0 |
| result->status = ESHU_STATUS_SKIPPED; |
| 526 |
0 |
| result->reason = strdup("unrecognised extension"); |
| 527 |
0 |
| return; |
| 528 |
|
| } |
| 529 |
41 |
| result->lang = strdup(lang_str); |
| 530 |
|
| |
| 531 |
|
| /* Build config */ |
| 532 |
41 |
| file_cfg = *cfg; |
| 533 |
41 |
| file_cfg.lang = lang_id; |
| 534 |
|
| |
| 535 |
|
| /* Indent */ |
| 536 |
41 |
| fixed = eshu_indent_dispatch(src, src_len, &file_cfg, &out_len); |
| 537 |
|
| |
| 538 |
41 |
▶ | if (out_len == src_len && memcmp(fixed, src, src_len) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (out_len == src_len && memcmp(fixed, src, src_len) == 0) { |
3 |
38 |
41 |
| if (out_len == src_len && memcmp(fixed, src, src_len) == 0) { |
3 |
0 |
3 |
|
| 539 |
3 |
| result->status = ESHU_STATUS_UNCHANGED; |
| 540 |
|
| } else { |
| 541 |
76 |
| result->status = (opts & ESHU_OPT_FIX) |
| 542 |
38 |
▶ | ? ESHU_STATUS_CHANGED : ESHU_STATUS_NEEDS_FIXING; |
Branch: 1 branch
| Branch | True | False | Total |
| ? ESHU_STATUS_CHANGED : ESHU_STATUS_NEEDS_FIXING; |
13 |
25 |
38 |
|
| 543 |
|
| |
| 544 |
38 |
▶ | if (opts & ESHU_OPT_FIX) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (opts & ESHU_OPT_FIX) { |
13 |
25 |
38 |
|
| 545 |
13 |
| fp = fopen(path, "wb"); |
| 546 |
13 |
▶ | if (!fp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!fp) { |
0 |
13 |
13 |
|
| 547 |
0 |
| result->status = ESHU_STATUS_ERROR; |
| 548 |
0 |
| result->error = strdup("cannot write file"); |
| 549 |
0 |
| free(src); |
| 550 |
0 |
| free(fixed); |
| 551 |
0 |
| return; |
| 552 |
|
| } |
| 553 |
13 |
| fwrite(fixed, 1, out_len, fp); |
| 554 |
13 |
| fclose(fp); |
| 555 |
|
| } |
| 556 |
38 |
▶ | if (opts & ESHU_OPT_DIFF) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (opts & ESHU_OPT_DIFF) { |
2 |
36 |
38 |
|
| 557 |
2 |
| result->diff = eshu_simple_diff(path, src, src_len, |
| 558 |
|
| fixed, out_len, &result->diff_len); |
| 559 |
|
| } |
| 560 |
|
| } |
| 561 |
|
| |
| 562 |
41 |
| free(src); |
| 563 |
41 |
| free(fixed); |
| 564 |
|
| } |
| 565 |
|
| |
| 566 |
|
| /* ══════════════════════════════════════════════════════════════════ |
| 567 |
|
| * Sorted string list (for collecting file paths) |
| 568 |
|
| * ══════════════════════════════════════════════════════════════════ */ |
| 569 |
|
| |
| 570 |
|
| typedef struct { |
| 571 |
|
| char **items; |
| 572 |
|
| size_t count; |
| 573 |
|
| size_t cap; |
| 574 |
|
| } eshu_strlist_t; |
| 575 |
|
| |
| 576 |
16 |
| static void eshu_strlist_init(eshu_strlist_t *l) { |
| 577 |
16 |
| l->cap = 256; |
| 578 |
16 |
| l->count = 0; |
| 579 |
16 |
| l->items = (char **)malloc(l->cap * sizeof(char *)); |
| 580 |
16 |
| } |
| 581 |
|
| |
| 582 |
46 |
| static void eshu_strlist_push(eshu_strlist_t *l, const char *s) { |
| 583 |
46 |
▶ | if (l->count >= l->cap) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (l->count >= l->cap) { |
0 |
46 |
46 |
|
| 584 |
0 |
| l->cap *= 2; |
| 585 |
0 |
| l->items = (char **)realloc(l->items, l->cap * sizeof(char *)); |
| 586 |
|
| } |
| 587 |
46 |
| l->items[l->count++] = strdup(s); |
| 588 |
46 |
| } |
| 589 |
|
| |
| 590 |
40 |
| static int eshu_strcmp_ptr(const void *a, const void *b) { |
| 591 |
40 |
| return strcmp(*(const char **)a, *(const char **)b); |
| 592 |
|
| } |
| 593 |
|
| |
| 594 |
16 |
| static void eshu_strlist_sort(eshu_strlist_t *l) { |
| 595 |
16 |
| qsort(l->items, l->count, sizeof(char *), eshu_strcmp_ptr); |
| 596 |
16 |
| } |
| 597 |
|
| |
| 598 |
16 |
| static void eshu_strlist_free(eshu_strlist_t *l) { |
| 599 |
|
| size_t i; |
| 600 |
62 |
▶ | for (i = 0; i < l->count; i++) free(l->items[i]); |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < l->count; i++) free(l->items[i]); |
46 |
16 |
62 |
|
| 601 |
16 |
| free(l->items); |
| 602 |
16 |
| l->items = NULL; |
| 603 |
16 |
| l->count = l->cap = 0; |
| 604 |
16 |
| } |
| 605 |
|
| |
| 606 |
|
| /* ══════════════════════════════════════════════════════════════════ |
| 607 |
|
| * Recursive directory walk |
| 608 |
|
| * ══════════════════════════════════════════════════════════════════ */ |
| 609 |
|
| |
| 610 |
|
| /* The separator to join a child name onto dir_path with. The reported |
| 611 |
|
| * paths are what the caller gets back keyed by file, so a directory |
| 612 |
|
| * handed to us as C:\foo has to come back as C:\foo\bar.c, not the |
| 613 |
|
| * mixed C:\foo/bar.c that a hardcoded slash produces. Mirror whichever |
| 614 |
|
| * separator the caller already used, defaulting to the native one. */ |
| 615 |
22 |
| static char eshu_path_sep(const char *dir_path) { |
| 616 |
|
| #ifdef _WIN32 |
| 617 |
|
| const char *p = dir_path + strlen(dir_path); |
| 618 |
|
| while (p-- > dir_path) { |
| 619 |
|
| if (*p == '\\') return '\\'; |
| 620 |
|
| if (*p == '/') return '/'; |
| 621 |
|
| } |
| 622 |
|
| return '\\'; |
| 623 |
|
| #else |
| 624 |
|
| (void)dir_path; |
| 625 |
22 |
| return '/'; |
| 626 |
|
| #endif |
| 627 |
|
| } |
| 628 |
|
| |
| 629 |
|
| #ifdef _WIN32 |
| 630 |
|
| /* stat() cannot tell a junction or a directory symlink from a real |
| 631 |
|
| * directory, and S_ISLNK is a constant 0 here, so ask Windows itself |
| 632 |
|
| * rather than walk into a reparse point and risk a cycle. */ |
| 633 |
|
| static int eshu_is_reparse_dir(const char *path) { |
| 634 |
|
| DWORD attr = GetFileAttributesA(path); |
| 635 |
|
| return attr != INVALID_FILE_ATTRIBUTES |
| 636 |
|
| && (attr & FILE_ATTRIBUTE_REPARSE_POINT) |
| 637 |
|
| && (attr & FILE_ATTRIBUTE_DIRECTORY); |
| 638 |
|
| } |
| 639 |
|
| #endif |
| 640 |
|
| |
| 641 |
22 |
| static void eshu_walk_dir(const char *dir_path, eshu_strlist_t *files, |
| 642 |
|
| int recursive) |
| 643 |
|
| { |
| 644 |
|
| EshuDIR *d; |
| 645 |
|
| struct eshu_dirent *ent; |
| 646 |
|
| struct stat st; |
| 647 |
|
| char pathbuf[4096]; |
| 648 |
22 |
| size_t dir_len = strlen(dir_path); |
| 649 |
22 |
| char sep = eshu_path_sep(dir_path); |
| 650 |
|
| |
| 651 |
|
| /* a trailing separator on the caller's path is theirs to keep, but |
| 652 |
|
| * it must not become a doubled one in the paths we report */ |
| 653 |
22 |
▶ | if (dir_len && (dir_path[dir_len - 1] == '/' || |
Branch: 2 branches
| Branch | True | False | Total |
| if (dir_len && (dir_path[dir_len - 1] == '/' || |
22 |
0 |
22 |
| if (dir_len && (dir_path[dir_len - 1] == '/' || |
22 |
0 |
22 |
|
| 654 |
22 |
▶ | dir_path[dir_len - 1] == '\\')) sep = '\0'; |
Branch: 1 branch
| Branch | True | False | Total |
| dir_path[dir_len - 1] == '\\')) sep = '\0'; |
0 |
22 |
22 |
|
| 655 |
|
| |
| 656 |
22 |
| d = eshu_opendir(dir_path); |
| 657 |
22 |
▶ | if (!d) return; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!d) return; |
0 |
22 |
22 |
|
| 658 |
|
| |
| 659 |
121 |
▶ | while ((ent = eshu_readdir(d)) != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ((ent = eshu_readdir(d)) != NULL) { |
99 |
22 |
121 |
|
| 660 |
99 |
▶ | if (ent->d_name[0] == '.') continue; |
Branch: 1 branch
| Branch | True | False | Total |
| if (ent->d_name[0] == '.') continue; |
44 |
55 |
99 |
|
| 661 |
|
| |
| 662 |
55 |
▶ | if (sep) |
Branch: 1 branch
| Branch | True | False | Total |
| if (sep) |
55 |
0 |
55 |
|
| 663 |
55 |
| snprintf(pathbuf, sizeof(pathbuf), "%s%c%s", |
| 664 |
55 |
| dir_path, sep, ent->d_name); |
| 665 |
|
| else |
| 666 |
0 |
| snprintf(pathbuf, sizeof(pathbuf), "%s%s", |
| 667 |
0 |
| dir_path, ent->d_name); |
| 668 |
|
| |
| 669 |
55 |
▶ | if (lstat(pathbuf, &st) != 0) continue; |
Branch: 1 branch
| Branch | True | False | Total |
| if (lstat(pathbuf, &st) != 0) continue; |
0 |
55 |
55 |
|
| 670 |
|
| |
| 671 |
55 |
▶ | if (S_ISLNK(st.st_mode)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (S_ISLNK(st.st_mode)) { |
4 |
51 |
55 |
|
| 672 |
|
| /* Symlink: follow to files only, never to directories */ |
| 673 |
|
| struct stat tgt; |
| 674 |
4 |
▶ | if (stat(pathbuf, &tgt) == 0 && S_ISREG(tgt.st_mode)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (stat(pathbuf, &tgt) == 0 && S_ISREG(tgt.st_mode)) { |
4 |
0 |
4 |
| if (stat(pathbuf, &tgt) == 0 && S_ISREG(tgt.st_mode)) { |
2 |
2 |
4 |
|
| 675 |
2 |
| eshu_strlist_push(files, pathbuf); |
| 676 |
|
| } |
| 677 |
51 |
▶ | } else if (S_ISREG(st.st_mode)) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if (S_ISREG(st.st_mode)) { |
44 |
7 |
51 |
|
| 678 |
44 |
| eshu_strlist_push(files, pathbuf); |
| 679 |
7 |
▶ | } else if (recursive && S_ISDIR(st.st_mode)) { |
Branch: 2 branches
| Branch | True | False | Total |
| } else if (recursive && S_ISDIR(st.st_mode)) { |
6 |
1 |
7 |
| } else if (recursive && S_ISDIR(st.st_mode)) { |
6 |
0 |
6 |
|
| 680 |
|
| #ifdef _WIN32 |
| 681 |
|
| if (eshu_is_reparse_dir(pathbuf)) continue; |
| 682 |
|
| #endif |
| 683 |
6 |
| eshu_walk_dir(pathbuf, files, recursive); |
| 684 |
|
| } |
| 685 |
|
| } |
| 686 |
22 |
| eshu_closedir(d); |
| 687 |
|
| } |
| 688 |
|
| |
| 689 |
|
| /* Check if symlinked dir — lstat shows symlink, stat shows dir */ |
| 690 |
0 |
| static int eshu_is_symlinked_dir(const char *path) { |
| 691 |
|
| struct stat lst, st; |
| 692 |
0 |
▶ | if (lstat(path, &lst) != 0) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (lstat(path, &lst) != 0) return 0; |
0 |
0 |
0 |
|
| 693 |
0 |
▶ | if (!S_ISLNK(lst.st_mode)) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!S_ISLNK(lst.st_mode)) return 0; |
0 |
0 |
0 |
|
| 694 |
0 |
▶ | if (stat(path, &st) != 0) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (stat(path, &st) != 0) return 0; |
0 |
0 |
0 |
|
| 695 |
0 |
| return S_ISDIR(st.st_mode); |
| 696 |
|
| } |
| 697 |
|
| |
| 698 |
|
| /* ══════════════════════════════════════════════════════════════════ |
| 699 |
|
| * indent_dir — process a directory tree |
| 700 |
|
| * ══════════════════════════════════════════════════════════════════ */ |
| 701 |
|
| |
| 702 |
|
| /* Note: exclude/include regex filtering is handled at the XSUB level |
| 703 |
|
| * since PCRE/regex matching is more natural from Perl. This C function |
| 704 |
|
| * collects all files and processes them; the XSUB wrapper handles |
| 705 |
|
| * filtering before calling eshu_indent_file for each file. */ |
| 706 |
|
| |
| 707 |
|
| #endif /* ESHU_FILE_H */ |