intrinsics rewritten without ++, --, etc

This commit is contained in:
2026-02-10 07:19:45 -06:00
parent 3f7e34cd7a
commit c4ff0bc109
13 changed files with 545 additions and 468 deletions

17
fd.cm
View File

@@ -12,11 +12,11 @@ function last_pos(str, sep) {
// Helper to join paths
function join_paths(base, rel) {
base = replace(base, /\/+$/, "")
rel = replace(rel, /^\/+/, "")
if (!base) return rel
if (!rel) return base
return base + "/" + rel
var b = replace(base, /\/+$/, "")
var r = replace(rel, /^\/+/, "")
if (!b) return r
if (!r) return b
return b + "/" + r
}
fd.join_paths = join_paths
@@ -39,7 +39,8 @@ fd.stem = function stem(path) {
}
fd.globfs = function(globs, dir) {
if (dir == null) dir = "."
var _dir = dir
if (_dir == null) _dir = "."
var results = []
function check_neg(path) {
@@ -88,9 +89,9 @@ fd.globfs = function(globs, dir) {
});
}
var st = fd.stat(dir)
var st = fd.stat(_dir)
if (st && st.isDirectory) {
visit(dir, "")
visit(_dir, "")
}
return results