Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/babel/blob/main/src/65-exclude.om # babel aien-dev/babel Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `babel / src / 65-exclude.om` 365 lines ยท 6678 bytes Raw Blame History 1 note babel 75-exclude: the --exclude manifest. One " " per line; blank lines and lines 2 note starting with # are ignored. is relative to the walked root and is an exact path or a 3 note directory prefix (a trailing / is optional); globs are refused. A matched walked file or skipped 4 note entry stays in the completion denominator with verdict EXCLUDED and the manifest's reason. 5 note Source babel recognises (and so every split item) can never be excluded, hidden or symlinked or 6 note not. A line without a reason, an entry that matches nothing, a glob or an entry that names source 7 note is diagnosed with its line number, and babel exits 2 before writing anything. 8 global Ex0 ulong 1 9 global Exn ulong 1 10 global Exa0 ulong 1 11 global Exan ulong 1 12 global Exr0 ulong 1 13 global Exrn ulong 1 14 global Exh uchar 32 15 note entries: path Me0/Men, reason Mr0/Mrn (pool), manifest line Mln, matches Mht 16 global Me0 ulong 256 17 global Men ulong 256 18 global Mr0 ulong 256 19 global Mrn ulong 256 20 global Mln ulong 256 21 global Mht ulong 256 22 global Nme ulong 1 23 note per walked file / skipped entry: matching entry + 1 (0 none) 24 global Fex ulong 2048 25 global Skx ulong 2048 26 note the manifest itself when it lies in the walked tree: file index + 1, skipped index + 1 27 global Mfi ulong 1 28 global Msk ulong 1 29 global Nexe ulong 1 30 text EMh "babel: --exclude " 31 text EMl " line " 32 text EMc ": " 33 text EMa " -> " 34 text EMrd "cannot be read" 35 text EMcp "has more than 256 entries" 36 text EMnr "entry has no reason (each line is ): " 37 text EMgl "globs are not supported (an exact path or a dir/ prefix): " 38 text EMst "entry matches nothing in the walked tree (stale manifest): " 39 text EMsr "entry names source babel splits, which cannot be excluded: " 40 41 note --exclude given: read, hash, parse and match the manifest against the walk of root Pl[d, d+dn); 42 note false after reporting every problem 43 fn exload d ulong dn ulong to bool 44 put Nexe 0 0 45 if eq get Exn 0 0 46 ret true 47 end 48 m = mark 49 absob get Ex0 0 get Exn 0 50 put Exa0 0 psave m sub mark m 51 put Exan 0 sub mark m 52 e = mark 53 r = hfile m e 54 if ge r 0 55 for i ulong 32 56 put Exh i get Hash i 57 end 58 r = rfile m e 59 end 60 reset m 61 if lt r 0 62 exdiag 0 EMrd 0 0 63 ret false 64 end 65 exrel d dn 66 if not exparse 67 exdiag 0 EMcp 0 0 68 ret false 69 end 70 exmatch 71 ret eq get Nexe 0 0 72 end 73 74 note the manifest's path relative to the walked root Pl[d, d+dn), when it lies inside it (else Exrn 0) 75 fn exrel d ulong dn ulong to void 76 put Exrn 0 0 77 a = get Exa0 0 78 an = get Exan 0 79 if le an add dn 1 80 ret 81 end 82 if not pleq a dn d dn 83 ret 84 end 85 if ne get Pl add a dn 47 86 ret 87 end 88 put Exr0 0 add a add dn 1 89 put Exrn 0 sub an add dn 1 90 end 91 92 note split Fb[0, Fn) into lines; false when the entry table is full 93 fn exparse to bool 94 put Nme 0 0 95 n = get Fn 0 96 s = ulong 0 97 lno = ulong 1 98 while lt s n bound 999999 99 k = s 100 while lt k n bound 999999 101 if eq get Fb k 10 102 break 103 end 104 k = add k 1 105 end 106 if not exline s k lno 107 ret false 108 end 109 s = add k 1 110 lno = add lno 1 111 end 112 ret true 113 end 114 115 fn exws c uchar to bool 116 if eq c 32 117 ret true 118 end 119 if eq c 9 120 ret true 121 end 122 ret eq c 13 123 end 124 125 note one line Fb[a, b): trimmed, comment or blank skipped, else and recorded 126 fn exline a ulong b ulong lno ulong to bool 127 s = a 128 while lt s b bound 999999 129 if not exws get Fb s 130 break 131 end 132 s = add s 1 133 end 134 e = b 135 while gt e s bound 999999 136 if not exws get Fb sub e 1 137 break 138 end 139 e = sub e 1 140 end 141 if ge s e 142 ret true 143 end 144 if eq get Fb s 35 145 ret true 146 end 147 p = s 148 while lt p e bound 999999 149 if exws get Fb p 150 break 151 end 152 p = add p 1 153 end 154 q = p 155 while lt q e bound 999999 156 if not exws get Fb q 157 break 158 end 159 q = add q 1 160 end 161 ret exadd s p q e lno 162 end 163 164 note record entry path Fb[s, p) ("./" prefix and trailing "/" removed) and reason Fb[q, e) 165 fn exadd s ulong p ulong q ulong e ulong lno ulong to bool 166 i = get Nme 0 167 if ge i 256 168 ret false 169 end 170 a = s 171 if gt sub p a 2 172 if eq get Fb a 46 173 if eq get Fb add a 1 47 174 a = add a 2 175 end 176 end 177 end 178 z = p 179 while gt sub z a 1 bound 4096 180 if ne get Fb sub z 1 47 181 break 182 end 183 z = sub z 1 184 end 185 m = mark 186 bfb a sub z a 187 put Me0 i psave m sub mark m 188 put Men i sub mark m 189 reset m 190 bfb q sub e q 191 put Mr0 i psave m sub mark m 192 put Mrn i sub mark m 193 reset m 194 put Mln i lno 195 put Mht i 0 196 put Nme 0 add i 1 197 ret true 198 end 199 200 note match every entry against the walked files and the skipped entries 201 fn exmatch to void 202 put Mfi 0 0 203 put Msk 0 0 204 for f ulong get Nf 0 205 put Fex f 0 206 if gt get Exrn 0 0 207 if pleq get F0 f get Fl f get Exr0 0 get Exrn 0 208 put Mfi 0 add f 1 209 end 210 end 211 end 212 for i ulong get Nsk 0 213 put Skx i 0 214 if gt get Exrn 0 0 215 if pleq get Sk0 i get Skl i get Exr0 0 get Exrn 0 216 put Msk 0 add i 1 217 end 218 end 219 end 220 for e ulong get Nme 0 221 exent e 222 end 223 end 224 225 fn exent e ulong to void 226 if eq get Mrn e 0 227 exdiag add e 1 EMnr 0 0 228 ret 229 end 230 if exglob e 231 exdiag add e 1 EMgl 0 0 232 ret 233 end 234 for f ulong get Nf 0 235 if exhit e get F0 f get Fl f 236 exfile e f 237 end 238 end 239 for i ulong get Nsk 0 240 if exhit e get Sk0 i get Skl i 241 exsk e i 242 end 243 end 244 if eq get Mht e 0 245 exdiag add e 1 EMst 0 0 246 end 247 end 248 249 note entry e covers walked file f, unless f is source (diagnosed) or the manifest itself 250 fn exfile e ulong f ulong to void 251 put Mht e add get Mht e 1 252 if ne get Flg f 0 253 exdiag add e 1 EMsr get F0 f get Fl f 254 ret 255 end 256 if eq get Mfi 0 add f 1 257 ret 258 end 259 if eq get Fex f 0 260 put Fex f add e 1 261 end 262 end 263 264 note entry e covers skipped entry i, unless its name is source (hidden or symlinked source) 265 fn exsk e ulong i ulong to void 266 put Mht e add get Mht e 1 267 if ne langof get Sk0 i get Skl i 0 268 exdiag add e 1 EMsr get Sk0 i get Skl i 269 ret 270 end 271 if eq get Msk 0 add i 1 272 ret 273 end 274 if eq get Skx i 0 275 put Skx i add e 1 276 end 277 end 278 279 note path Pl[o, o+n) is the entry or lies below it 280 fn exhit e ulong o ulong n ulong to bool 281 a = get Me0 e 282 k = get Men e 283 if eq k 0 284 ret false 285 end 286 if pleq o n a k 287 ret true 288 end 289 if le n k 290 ret false 291 end 292 if not pleq o k a k 293 ret false 294 end 295 ret eq get Pl add o k 47 296 end 297 298 fn exglob e ulong to bool 299 a = get Me0 e 300 for i ulong get Men e 301 c = get Pl add a i 302 if eq c 42 303 ret true 304 end 305 if eq c 63 306 ret true 307 end 308 if eq c 91 309 ret true 310 end 311 end 312 ret false 313 end 314 315 note "babel: --exclude FILE[ line N]: [][ -> ]" on stderr; ln1 = entry index + 1 (0: whole file) 316 fn exdiag ln1 ulong s view uchar * o ulong n ulong to void 317 m = mark 318 bs EMh 319 bpl get Ex0 0 get Exn 0 320 if gt ln1 0 321 bs EMl 322 bu get Mln sub ln1 1 323 end 324 bs EMc 325 bs s 326 if gt ln1 0 327 e = sub ln1 1 328 bpl get Me0 e get Men e 329 end 330 if gt n 0 331 bs EMa 332 bpl o n 333 end 334 bc 10 335 flush 2 m 336 put Nexe 0 add get Nexe 0 1 337 end 338 339 note first k bytes of the manifest's sha256 in hex 340 fn exhex k ulong to void 341 for i ulong k 342 c = get Exh i 343 bhex ulong shr c 4 344 bhex ulong and c 15 345 end 346 end 347 348 text CxA "{\"path\": " 349 text CxB ", \"sha256\": \"" 350 text CxC "\", \"walked_as\": " 351 text CxN "null" 352 353 fn exjson to void 354 if eq get Exn 0 0 355 bs CxN 356 ret 357 end 358 bs CxA 359 bjq get Ex0 0 get Exn 0 360 bs CxB 361 exhex 32 362 bs CxC 363 bqnull get Exr0 0 get Exrn 0 364 bc 125 365 end