diff options
51 files changed, 134 insertions, 134 deletions
diff --git a/lib/crypto/test/aes.myr b/lib/crypto/test/aes.myr index 1ad9036..5d3da89 100644 --- a/lib/crypto/test/aes.myr +++ b/lib/crypto/test/aes.myr @@ -40,7 +40,7 @@ const enctest = {t : aestest crypto.aeskeysched(&ctx, t.key) crypto.aesencrypt(&ctx, t.inp[:], out[:]) - if !std.sleq(out[:], t.out[:]) + if !std.eq(out[:], t.out[:]) std.fatal("test failed: got {r}, expected {r}\n", out[:], t.out[:]) ;; } @@ -51,7 +51,7 @@ const dectest = {t : aestest crypto.aeskeysched(&ctx, t.key) crypto.aesdecrypt(&ctx, t.inp[:], out[:]) - if !std.sleq(out[:], t.out[:]) + if !std.eq(out[:], t.out[:]) std.fatal("test failed: got {r}, expected {r}\n", out[:], t.out[:]) ;; } @@ -61,7 +61,7 @@ const bigenctest = {t : aestest crypto.aeskeysched(&ctx, t.key) crypto.aesencrypt(&ctx, t.inp[:], out[:]) - if !std.sleq(out[:], t.out[:]) + if !std.eq(out[:], t.out[:]) std.fatal("test failed: got {r}, expected {r}\n", out[:], t.out[:]) ;; } @@ -72,7 +72,7 @@ const bigdectest = {t : aestest crypto.aeskeysched(&ctx, t.key) crypto.aesdecrypt(&ctx, t.inp[:], out[:]) - if !std.sleq(out[:], t.out[:]) + if !std.eq(out[:], t.out[:]) std.fatal("test failed: got {r}, expected {r}\n", out[:], t.out[:]) ;; } diff --git a/lib/crypto/test/chacha20.myr b/lib/crypto/test/chacha20.myr index 7ca349f..8fece64 100644 --- a/lib/crypto/test/chacha20.myr +++ b/lib/crypto/test/chacha20.myr @@ -853,9 +853,9 @@ const check = {chk ;; crypto.chacha20encrypt(&st, data[:], result[:]) - std.assert(std.sleq(result[:], chk.stream0), "mismatched stream0") + std.assert(std.eq(result[:], chk.stream0), "mismatched stream0") crypto.chacha20encrypt(&st, data[:], result[:]) - std.assert(std.sleq(result[:], chk.stream1), "mismatched stream1") + std.assert(std.eq(result[:], chk.stream1), "mismatched stream1") } diff --git a/lib/crypto/test/md5.myr b/lib/crypto/test/md5.myr index 380c531..c042363 100644 --- a/lib/crypto/test/md5.myr +++ b/lib/crypto/test/md5.myr @@ -22,7 +22,7 @@ const hasheq = {got, expected std.sbfmt(sb, "{p=0,w=2,x}", x) ;; str = std.sbfin(sb) - if (!std.sleq(str, expected)) + if (!std.eq(str, expected)) std.fatal("mismatched hashes:\n\tgot:\t{}\n\texpected:\t{}\n", str, expected) ;; std.slfree(str) diff --git a/lib/crypto/test/sha1.myr b/lib/crypto/test/sha1.myr index 75361f8..0cd3bd8 100644 --- a/lib/crypto/test/sha1.myr +++ b/lib/crypto/test/sha1.myr @@ -22,7 +22,7 @@ const hasheq = {got, expected std.sbfmt(sb, "{p=0,w=2,x}", x) ;; str = std.sbfin(sb) - if (!std.sleq(str, expected)) + if (!std.eq(str, expected)) std.fatal("mismatched hashes:\n\tgot:\t{}\n\texpected:\t{}\n", str, expected) ;; std.slfree(str) diff --git a/lib/crypto/test/sha256.myr b/lib/crypto/test/sha256.myr index 32142d1..9b2e27a 100644 --- a/lib/crypto/test/sha256.myr +++ b/lib/crypto/test/sha256.myr @@ -33,7 +33,7 @@ const hasheq = {got, expected std.sbfmt(sb, "{p=0,w=2,x}", x) ;; str = std.sbfin(sb) - if (!std.sleq(str, expected)) + if (!std.eq(str, expected)) std.fatal("mismatched hashes:\n\tgot:\t{}\n\texpected:\t{}\n", str, expected) ;; std.slfree(str) diff --git a/lib/crypto/test/sha3.myr b/lib/crypto/test/sha3.myr index cf15111..eb7eefd 100644 --- a/lib/crypto/test/sha3.myr +++ b/lib/crypto/test/sha3.myr @@ -9,7 +9,7 @@ const main = { ret = crypto.keccak224("") testr.check(ctx, \ - std.sleq(\ + std.eq(\ ret[:], \ "\xf7\x18\x37\x50\x2b\xa8\xe1\x08\x37\xbd\xd8\xd3\x65\xad" \ "\xb8\x55\x91\x89\x56\x02\xfc\x55\x2b\x48\xb7\x39\x0a\xbd"), \ @@ -20,7 +20,7 @@ const main = { ret = crypto.keccak256("") testr.check(ctx, \ - std.sleq(\ + std.eq(\ ret[:], \ "\xC5\xD2\x46\x01\x86\xF7\x23\x3C\x92\x7E\x7D\xB2\xDC\xC7\x03\xC0" \ "\xE5\x00\xB6\x53\xCA\x82\x27\x3B\x7B\xFA\xD8\x04\x5D\x85\xA4\x70"), \ @@ -31,7 +31,7 @@ const main = { ret = crypto.keccak384("") testr.check(ctx, \ - std.sleq(\ + std.eq(\ ret[:], \ "\x2C\x23\x14\x6A\x63\xA2\x9A\xCF" \ "\x99\xE7\x3B\x88\xF8\xC2\x4E\xAA" \ @@ -46,7 +46,7 @@ const main = { ret = crypto.keccak512("") testr.check(ctx, \ - std.sleq(\ + std.eq(\ ret[:], \ "\x0E\xAB\x42\xDE\x4C\x3C\xEB\x92" \ "\x35\xFC\x91\xAC\xFF\xE7\x46\xB2" \ @@ -64,7 +64,7 @@ const main = { ret = crypto.keccak224("Keccak-224 Test Hash") testr.check(ctx, \ - std.sleq(\ + std.eq(\ ret[:], \ "\x30\x04\x5B\x34\x94\x6E\x1B\x2E\x09\x16\x13\x36\x2F\xD2" \ "\x2A\xA0\x8E\x2B\xEA\xFE\xC5\xE8\xDA\xEE\x42\xC2\xE6\x65"), \ @@ -75,7 +75,7 @@ const main = { ret = crypto.keccak256("Keccak-256 Test Hash") testr.check(ctx, \ - std.sleq(\ + std.eq(\ ret[:], \ "\xA8\xD7\x1B\x07\xF4\xAF\x26\xA4\xFF\x21\x02\x7F\x62\xFF\x60\x26" \ "\x7F\xF9\x55\xC9\x63\xF0\x42\xC4\x6D\xA5\x2E\xE3\xCF\xAF\x3D\x3C"), \ @@ -86,7 +86,7 @@ const main = { ret = crypto.keccak384("Keccak-384 Test Hash") testr.check(ctx, \ - std.sleq(\ + std.eq(\ ret[:], \ "\xE2\x13\xFD\x74\xAF\x0C\x5F\xF9" \ "\x1B\x42\x3C\x8B\xCE\xEC\xD7\x01" \ @@ -101,7 +101,7 @@ const main = { ret = crypto.keccak512("Keccak-512 Test Hash") testr.check(ctx, \ - std.sleq(\ + std.eq(\ ret[:], \ "\x96\xEE\x47\x18\xDC\xBA\x3C\x74" \ "\x61\x9B\xA1\xFA\x7F\x57\xDF\xE7" \ diff --git a/lib/crypto/test/sha512.myr b/lib/crypto/test/sha512.myr index cec12f8..46ef2ba 100644 --- a/lib/crypto/test/sha512.myr +++ b/lib/crypto/test/sha512.myr @@ -34,7 +34,7 @@ const hasheq = {got, expected std.sbfmt(sb, "{p=0,w=2,x}", x) ;; str = std.sbfin(sb) - if (!std.sleq(str, expected)) + if (!std.eq(str, expected)) std.fatal("mismatched hashes:\n\tgot:\t{}\n\texpected:\t{}\n", str, expected) ;; std.slfree(str) diff --git a/lib/crypto/util.myr b/lib/crypto/util.myr index 2170029..e5bd689 100644 --- a/lib/crypto/util.myr +++ b/lib/crypto/util.myr @@ -12,7 +12,7 @@ const hasheq = {got, expected std.sbfmt(sb, "{p=0,w=2,x}", x) ;; str = std.sbfin(sb) - if (!std.sleq(str, expected)) + if (!std.eq(str, expected)) std.fatal("mismatched hashes:\n\tgot:\t{}\n\texpected:\t{}\n", str, expected) ;; std.slfree(str) diff --git a/lib/date/parse.myr b/lib/date/parse.myr index d7d8af3..57b5dcb 100644 --- a/lib/date/parse.myr +++ b/lib/date/parse.myr @@ -182,9 +182,9 @@ const tzoffset = {dst, s, err err# = `std.Some `Badzone s -> "" ;; - if std.sleq(s[:1], "-") + if std.eq(s[:1], "-") sgn = -1 - elif std.sleq(s[:1], "+") + elif std.eq(s[:1], "+") sgn = 1 else err# = `std.Some `Badzone s @@ -216,7 +216,7 @@ const tzstring = {d, s, err const matchstr = {s, str, err - if s.len <= str.len || !std.sleq(s[:str.len], str) + if s.len <= str.len || !std.eq(s[:str.len], str) err# = `std.Some `Badchar -> s ;; @@ -228,10 +228,10 @@ const matchampm = {d, s, am, err err# = `std.Some `Badampm -> s ;; - if std.sleq(s[:2], "am") || std.sleq(s[:2], "AM") + if std.eq(s[:2], "am") || std.eq(s[:2], "AM") am# = `std.Some true -> s[2:] - elif std.sleq(s[:2], "pm") || std.sleq(s[:2], "PM") + elif std.eq(s[:2], "pm") || std.eq(s[:2], "PM") am# = `std.Some false -> s[2:] else diff --git a/lib/date/test/fmt.myr b/lib/date/test/fmt.myr index 45d845a..ba90f56 100644 --- a/lib/date/test/fmt.myr +++ b/lib/date/test/fmt.myr @@ -88,7 +88,7 @@ const main = { } const eq = {expected, actual - if !std.sleq(expected, actual) + if !std.eq(expected, actual) std.fatal("expected date {}, got {}\n", expected, actual) ;; } diff --git a/lib/date/test/parse.myr b/lib/date/test/parse.myr index dc34707..f910b27 100644 --- a/lib/date/test/parse.myr +++ b/lib/date/test/parse.myr @@ -49,7 +49,7 @@ const main = { } const eq = {actual, expected - if !std.sleq(expected, actual) + if !std.eq(expected, actual) std.fatal("expected date {}, got {}\n", expected, actual) ;; } diff --git a/lib/date/zoneinfo+posixy.myr b/lib/date/zoneinfo+posixy.myr index 33edd03..e2b8f6c 100644 --- a/lib/date/zoneinfo+posixy.myr +++ b/lib/date/zoneinfo+posixy.myr @@ -50,9 +50,9 @@ const findtzoff = {tz, tm -> std.option(date.duration) zone = z | `std.None: /* load zone */ - if std.sleq(tz, "") || std.sleq(tz, "UTC") + if std.eq(tz, "") || std.eq(tz, "UTC") -> `std.Some 0 - elif std.sleq(tz, "local") + elif std.eq(tz, "local") path = std.sldup("/etc/localtime") else path = "" diff --git a/lib/escfmt/test/eschtml.myr b/lib/escfmt/test/eschtml.myr index c3911db..fd58638 100644 --- a/lib/escfmt/test/eschtml.myr +++ b/lib/escfmt/test/eschtml.myr @@ -6,22 +6,22 @@ const main = { testr.run([\ [.name="nop", .fn={ctx var s = std.fmt("{}", escfmt.html("word")) - testr.check(ctx, std.sleq("word", s), "mismatched escape") + testr.check(ctx, std.eq("word", s), "mismatched escape") std.slfree(s) }], [.name="twowords", .fn={ctx var s = std.fmt("{}", escfmt.html("spaced word")) - testr.check(ctx, std.sleq("spaced word", s), "mismatched escape") + testr.check(ctx, std.eq("spaced word", s), "mismatched escape") std.slfree(s) }], [.name="quoted", .fn={ctx var s = std.fmt("{}", escfmt.html("<stuff> </stuff>")) - testr.check(ctx, std.sleq("<stuff>&nbsp;</stuff>", s), std.fmt("mismatched escape {}", s)) + testr.check(ctx, std.eq("<stuff>&nbsp;</stuff>", s), std.fmt("mismatched escape {}", s)) std.slfree(s) }], [.name="doublequoted", .fn={ctx var s = std.fmt("{}", escfmt.html("<stuff>&nbsp;</stuff>")) - testr.check(ctx, std.sleq("&lt;stuff&gt;&amp;nbsp;&lt;&#x2f;stuff&gt;", s), std.fmt("mismatched escape {}", s)) + testr.check(ctx, std.eq("&lt;stuff&gt;&amp;nbsp;&lt;&#x2f;stuff&gt;", s), std.fmt("mismatched escape {}", s)) std.slfree(s) }], ][:]) diff --git a/lib/escfmt/test/escre.myr b/lib/escfmt/test/escre.myr index 6e7598c..0ded033 100644 --- a/lib/escfmt/test/escre.myr +++ b/lib/escfmt/test/escre.myr @@ -6,13 +6,13 @@ const main = { testr.run([\ [.name="unchanged", .fn={ctx var s = std.fmt("{}", escfmt.url("word")) - testr.check(ctx, std.sleq("word", s), std.fmt("mismatched escape {}", s)) + testr.check(ctx, std.eq("word", s), std.fmt("mismatched escape {}", s)) std.slfree(s) }], [.name="randomcrud", .fn={ctx var s = std.fmt("{}", escfmt.re("^:/?#[]@!$&'()*+,;=%")) testr.check(ctx, \ - std.sleq("\\^:/\\?#\\[\\]@!\\$&'\\(\\)\\*\\+,;=%", s), \ + std.eq("\\^:/\\?#\\[\\]@!\\$&'\\(\\)\\*\\+,;=%", s), \ std.fmt("mismatched escape {}", s)) std.slfree(s) }], diff --git a/lib/escfmt/test/escsh.myr b/lib/escfmt/test/escsh.myr index 0071ec2..0be0629 100644 --- a/lib/escfmt/test/escsh.myr +++ b/lib/escfmt/test/escsh.myr @@ -6,22 +6,22 @@ const main = { testr.run([ [.name="basic", .fn={ctx var s = std.fmt("{}", escfmt.sh("word")) - testr.check(ctx, std.sleq("'word'", s), "mismatched escape") + testr.check(ctx, std.eq("'word'", s), "mismatched escape") std.slfree(s) }], [.name="twowords", .fn={ctx var s = std.fmt("{}", escfmt.sh("two words")) - testr.check(ctx, std.sleq("'two words'", s), "mismatched escape") + testr.check(ctx, std.eq("'two words'", s), "mismatched escape") std.slfree(s) }], [.name="simplequote", .fn={ctx var s = std.fmt("{}", escfmt.sh("two'words")) - testr.check(ctx, std.sleq("'two'\\''words'", s), "mismatched escape") + testr.check(ctx, std.eq("'two'\\''words'", s), "mismatched escape") std.slfree(s) }], [.name="quotequote", .fn={ctx var s = std.fmt("{}", escfmt.sh("two'\\''words")) - testr.check(ctx, std.sleq("'two'\\''\\'\\'''\\''words'", s), "mismatched escape") + testr.check(ctx, std.eq("'two'\\''\\'\\'''\\''words'", s), "mismatched escape") std.slfree(s) }] ][:]) diff --git a/lib/escfmt/test/escurl.myr b/lib/escfmt/test/escurl.myr index 9645754..33965f0 100644 --- a/lib/escfmt/test/escurl.myr +++ b/lib/escfmt/test/escurl.myr @@ -6,20 +6,20 @@ const main = { testr.run([\ [.name="unchanged", .fn={ctx var s = std.fmt("{}", escfmt.url("word")) - testr.check(ctx, std.sleq("word", s), std.fmt("mismatched escape {}", s)) + testr.check(ctx, std.eq("word", s), std.fmt("mismatched escape {}", s)) std.slfree(s) }], [.name="allspecials", .fn={ctx var s = std.fmt("{}", escfmt.url(":/?#[]@!$&'()*+,;=%")) testr.check(ctx, \ - std.sleq("%3a%2f%3f%23%5b%5d%40%21%24%26%27%28%29%2a%2b%2c%3b%3d%25", s), \ + std.eq("%3a%2f%3f%23%5b%5d%40%21%24%26%27%28%29%2a%2b%2c%3b%3d%25", s), \ std.fmt("mismatched escape {}", s)) std.slfree(s) }], [.name="unicodes", .fn={ctx var s = std.fmt("{}", escfmt.url("᚛᚛ᚉᚑᚅᚔᚉᚉᚔ")) testr.check(ctx, \ - std.sleq("%e1%9a%9b%e1%9a%9b%e1%9a%89%e1%9a%91%e1%9a%85%e1%9a%94%e1%9a%89%e1%9a%89%e1%9a%94", s), \ + std.eq("%e1%9a%9b%e1%9a%9b%e1%9a%89%e1%9a%91%e1%9a%85%e1%9a%94%e1%9a%89%e1%9a%89%e1%9a%94", s), \ std.fmt("mismatched escape {}", s)) std.slfree(s) }], diff --git a/lib/inifile/test/inifile.myr b/lib/inifile/test/inifile.myr index ccc43f9..96ccd3b 100644 --- a/lib/inifile/test/inifile.myr +++ b/lib/inifile/test/inifile.myr @@ -57,7 +57,7 @@ const itersects = { const checkval = {ini, sect, key, expected match inifile.get(ini, sect, key) | `std.Some val: - if !std.sleq(val, expected) + if !std.eq(val, expected) std.fatal("{}.{}: expected {}, got {}\n", sect, key, expected, val) ;; | `std.None: diff --git a/lib/inifile/write.myr b/lib/inifile/write.myr index ab4042c..8dc55dd 100644 --- a/lib/inifile/write.myr +++ b/lib/inifile/write.myr @@ -46,7 +46,7 @@ const writeini = {f, ini oldsect = "" for (sect, key) : keys std.put("sect={}, oldsect={}\n", sect, oldsect) - if !std.sleq(sect, oldsect) + if !std.eq(sect, oldsect) bio.put(f, "[{}]\n", sect) ;; oldsect = sect diff --git a/lib/json/test/parse.myr b/lib/json/test/parse.myr index 893398d..8106f07 100644 --- a/lib/json/test/parse.myr +++ b/lib/json/test/parse.myr @@ -124,7 +124,7 @@ const filetest = { | 'i': std.put("ignoring implementation defined test {}\n", f) | wat: - if !std.sleq(f, "LICENSE") + if !std.eq(f, "LICENSE") std.fatal("unknown test '{}': needs to start with y or n\n", f) ;; ;; diff --git a/lib/regex/compile.myr b/lib/regex/compile.myr index 29e53a2..3887f63 100644 --- a/lib/regex/compile.myr +++ b/lib/regex/compile.myr @@ -705,20 +705,20 @@ const unicodeclass = {re, neg ;; s = s[:n] /* letters */ - if std.sleq(s, "L") || std.sleq(s, "Letter") + if std.eq(s, "L") || std.eq(s, "Letter") tab = _ranges.tabalpha[:] - elif std.sleq(s, "Lu") || std.sleq(s, "Uppercase_Letter") + elif std.eq(s, "Lu") || std.eq(s, "Uppercase_Letter") tab = _ranges.tabupper[:] - elif std.sleq(s, "Ll") || std.sleq(s, "Lowercase_Letter") + elif std.eq(s, "Ll") || std.eq(s, "Lowercase_Letter") tab = _ranges.tablower[:] - elif std.sleq(s, "Lt") || std.sleq(s, "Titlecase_Letter") + elif std.eq(s, "Lt") || std.eq(s, "Titlecase_Letter") tab = _ranges.tablower[:] /* numbers (incomplete) */ - elif std.sleq(s, "N") || std.sleq(s, "Number") + elif std.eq(s, "N") || std.eq(s, "Number") tab = _ranges.tabdigit[:] - elif std.sleq(s, "Z") || std.sleq(s, "Separator") + elif std.eq(s, "Z") || std.eq(s, "Separator") tab = _ranges.tabspace[:] - elif std.sleq(s, "Zs") || std.sleq(s, "Space_Separator") + elif std.eq(s, "Zs") || std.eq(s, "Space_Separator") tab = _ranges.tabblank[:] else -> `Err (`Badrange s) diff --git a/lib/regex/test/testmatch.myr b/lib/regex/test/testmatch.myr index 6957a9b..18cb78a 100644 --- a/lib/regex/test/testmatch.myr +++ b/lib/regex/test/testmatch.myr @@ -79,7 +79,7 @@ const subst = {restr, pat, text, sub, expected, all std.put("res: {}\n", res) match expected | `std.Some e: - if !std.sleq(res, e) + if !std.eq(res, e) std.fatal("bad subst: expected {}, got {}\n", e, res) ;; | `std.None: @@ -157,7 +157,7 @@ const run = {restr, pat, text, expected, search std.put("\t{}: {}\n", i, res[i]) ;; | `std.Some exp: - if !search && !std.sleq(res[0], text) + if !search && !std.eq(res[0], text) std.put("whole match does not match text!\n") std.fatal("failed matching {} over {}\n", pat, text) ;; @@ -167,7 +167,7 @@ const run = {restr, pat, text, expected, search std.fatal("failed matching {} over {}\n", pat, text) ;; for i = 0; i < exp.len; i++ - if !std.sleq(res[i], exp[i]) + if !std.eq(res[i], exp[i]) std.put("mismatch on {}: expected {}, got {}\n", i, exp[i], res[i]) std.fatal("failed matching {} over {}\n", pat, text) ;; diff --git a/lib/std/dial+plan9.myr b/lib/std/dial+plan9.myr index cfdd2ba..0fa91bd 100644 --- a/lib/std/dial+plan9.myr +++ b/lib/std/dial+plan9.myr @@ -6,7 +6,6 @@ use "fmt" use "option" use "pathjoin" use "result" -use "sleq" use "strfind" use "strstrip" use "syswrap" diff --git a/lib/std/dial+posixy.myr b/lib/std/dial+posixy.myr index 386dac5..286ab43 100644 --- a/lib/std/dial+posixy.myr +++ b/lib/std/dial+posixy.myr @@ -8,7 +8,6 @@ use "endian" use "option" use "result" use "slcp" -use "sleq" use "strfind" use "striter" use "syswrap" diff --git a/lib/std/dialparse+posixy.myr b/lib/std/dialparse+posixy.myr index 2d0a695..be68b9f 100644 --- a/lib/std/dialparse+posixy.myr +++ b/lib/std/dialparse+posixy.myr @@ -3,13 +3,14 @@ use "chartype" use "hasprefix" use "intparse" use "slcp" -use "sleq" use "strfind" use "striter" use "option" use "result" use "ipparse" use "resolve" +use "traits" +use "hashfuncs" pkg std = pkglocal const parseport : (port : byte[:] -> option(uint16)) @@ -22,13 +23,13 @@ const parseport = {port | `Some n: -> `Some n | `None: /* a small number of hardcoded ports */ - if sleq(port, "http") + if eq(port, "http") -> `Some 80 - elif sleq(port, "https") + elif eq(port, "https") -> `Some 443 - elif sleq(port, "ircd") + elif eq(port, "ircd") -> `Some 6667 - elif sleq(port, "dns") + elif eq(port, "dns") -> `Some 53 ;; ;; diff --git a/lib/std/env+plan9.myr b/lib/std/env+plan9.myr index 23d3714..0afe3c7 100644 --- a/lib/std/env+plan9.myr +++ b/lib/std/env+plan9.myr @@ -9,7 +9,6 @@ use "option" use "result" use "slcp" use "sldup" -use "sleq" use "slpush" use "slurp" use "blat" diff --git a/lib/std/env+posixy.myr b/lib/std/env+posixy.myr index fe73c7e..94b5456 100644 --- a/lib/std/env+posixy.myr +++ b/lib/std/env+posixy.myr @@ -9,7 +9,8 @@ use "memops" use "option" use "sldup" use "slcp" -use "sleq" +use "traits" +use "hashfuncs" pkg std = const getenv : (name : byte[:] -> option(byte[:])) @@ -29,7 +30,7 @@ const getenv = {name for envp : environ env = cstrconvp(envp) n = min(name.len, env.len) - if sleq(name, env[:n]) && sleq(env[n:n+1], "=") + if eq(name, env[:n]) && eq(env[n:n+1], "=") -> `Some env[n+1:] ;; ;; @@ -51,7 +52,7 @@ const setenv = {name, val for envp : environ env = cstrconvp(envp) n = min(name.len, env.len) - if sleq(name, env[:n]) && sleq(env[n:n+1], "=") + if eq(name, env[:n]) && eq(env[n:n+1], "=") break ;; idx++ diff --git a/lib/std/fmt.myr b/lib/std/fmt.myr index b4cacb5..2cf9500 100644 --- a/lib/std/fmt.myr +++ b/lib/std/fmt.myr @@ -13,7 +13,6 @@ use "memops" use "option" use "result" use "sldup" -use "sleq" use "slpush" use "strbuf" use "strfind" @@ -233,7 +232,7 @@ const parseparams = {paramstr, optdesc found = false /* verify and add the arg */ for (opt, hasarg) : optdesc - if !std.sleq(opt, o) + if !std.eq(opt, o) continue ;; found = true diff --git a/lib/std/hashfuncs.myr b/lib/std/hashfuncs.myr index 5ad1180..f76ebda 100644 --- a/lib/std/hashfuncs.myr +++ b/lib/std/hashfuncs.myr @@ -2,18 +2,22 @@ use "alloc" use "chartype" use "die" use "getint" -use "sleq" use "slpush" use "traits" use "types" use "utf" +use "memops" pkg std = const siphash24 : (data : byte[:], seed : byte[16] -> uint64) impl equatable @a[:] = eq = {a, b - -> sleq(a, b) + if a.len == b.len + -> memeq((a : byte#), (b : byte#), a.len * sizeof(@a)) + else + -> false + ;; } ;; diff --git a/lib/std/hassuffix.myr b/lib/std/hassuffix.myr index 6f32d1d..622f024 100644 --- a/lib/std/hassuffix.myr +++ b/lib/std/hassuffix.myr @@ -1,4 +1,6 @@ -use "sleq" +use "traits" +use "hashfuncs" + pkg std = const hassuffix : (s : byte[:], suff : byte[:] -> bool) ;; @@ -8,7 +10,7 @@ const hassuffix = {s, suff if suff.len <= s.len tail = s[s.len - suff.len:] - -> sleq(tail, suff) + -> eq(tail, suff) ;; -> false } diff --git a/lib/std/ipparse.myr b/lib/std/ipparse.myr index 163d72e..0c6bf20 100644 --- a/lib/std/ipparse.myr +++ b/lib/std/ipparse.myr @@ -4,15 +4,12 @@ use "fmt" use "intparse" use "option" use "slcp" -use "sleq" use "slfill" use "strfind" use "striter" use "types" - - /* FIXME: needed for decls which should be pulled in as hidden */ -use "hasprefix" -use "utf" +use "traits" +use "hashfuncs" pkg std = @@ -61,7 +58,7 @@ const ip6parse = {ip ok = true expand = false split = 0 - if ip.len > 2 && std.sleq(ip[:2], "::") + if ip.len > 2 && eq(ip[:2], "::") expand = true split = 0 ;; @@ -105,8 +102,8 @@ const expandsplit = {ip, split, len var width width = 16 - len - std.slcp(ip[split:len], ip[split+width:len+width]) - std.slfill(ip[len:len+width], 0) + slcp(ip[split:len], ip[split+width:len+width]) + slfill(ip[len:len+width], 0) } const delim = {ip, sep, ok @@ -130,12 +127,12 @@ generic num = {ip, lo, hi, base, sep, ok -> (@a::(numeric,integral), byte[:], bo ;; ;; match intparsebase(ip[:len], base) - | `std.Some v: + | `Some v: if v < lo || v > hi -> (0, "", false) ;; -> ((v : @a::(numeric,integral)), ip[len:], true) - | `std.None: + | `None: -> (0, "", false) ;; } diff --git a/lib/std/listen+posixy.myr b/lib/std/listen+posixy.myr index 49d1054..9214c66 100644 --- a/lib/std/listen+posixy.myr +++ b/lib/std/listen+posixy.myr @@ -10,10 +10,11 @@ use "option" use "resolve" use "result" use "slcp" -use "sleq" use "strfind" use "striter" use "syswrap" +use "traits" +use "hashfuncs" use "utf" pkg std = @@ -62,7 +63,7 @@ const announcesock = {proto, str | `None: -> `Err("invalid port") ;; - if std.sleq(hoststr, "*") + if eq(hoststr, "*") sa6=[.fam=sys.Afinet6, .port=hosttonet(port)] sa = (&sa6 : sys.sockaddr#) sz = sizeof(sys.sockaddr_in6) diff --git a/lib/std/optparse.myr b/lib/std/optparse.myr index 6202aa4..c02d166 100644 --- a/lib/std/optparse.myr +++ b/lib/std/optparse.myr @@ -4,12 +4,13 @@ use "extremum" use "fmt" use "strbuf" use "option" -use "sleq" use "slpush" use "syswrap-ss" use "syswrap" use "types" use "utf" +use "traits" +use "hashfuncs" pkg std = type optdef = struct @@ -166,7 +167,7 @@ const next = {ctx for i = ctx.argidx + 1; i < ctx.optargs.len; i++ if !ctx.optdone && decode(ctx.optargs[i]) == '-' - if sleq(ctx.optargs[i], "--") + if eq(ctx.optargs[i], "--") ctx.optdone = true else goto foundopt diff --git a/lib/std/pathjoin.myr b/lib/std/pathjoin.myr index eb5e6fd..1b1cf6a 100644 --- a/lib/std/pathjoin.myr +++ b/lib/std/pathjoin.myr @@ -2,12 +2,13 @@ use "alloc" use "extremum" use "strjoin" use "strsplit" -use "sleq" use "sljoin" use "sldup" use "slcp" use "die" use "fmt" +use "traits" +use "hashfuncs" pkg std = const pathcat : (a : byte[:], b : byte[:] -> byte[:]) @@ -45,7 +46,7 @@ const pathnorm = {p and remove it later on. */ for i = 0; i < comps.len; i++ - if sleq(comps[i], ".") + if eq(comps[i], ".") comps[i] = "" ;; ;; @@ -59,11 +60,11 @@ const pathnorm = {p get mangled. */ for i = 0; i < comps.len; i++ - if !sleq(comps[i], "..") + if !eq(comps[i], "..") continue ;; for del = 1; del <= i; del++ - if comps[i - del].len > 0 && !sleq(comps[i-del], "..") + if comps[i - del].len > 0 && !eq(comps[i-del], "..") comps[i - del] = "" comps[i] = "" break @@ -85,9 +86,9 @@ const pathnorm = {p make it absolute. If we have an empty path, return ".". Otherwise, just return the path. */ - if p.len > 0 && sleq(p[:1], "/") + if p.len > 0 && eq(p[:1], "/") for i = 0; i < comps.len; i++ - if !sleq(comps[i], "..") + if !eq(comps[i], "..") break ;; ;; diff --git a/lib/std/resolve+posixy.myr b/lib/std/resolve+posixy.myr index 6aee9d7..cc3429e 100644 --- a/lib/std/resolve+posixy.myr +++ b/lib/std/resolve+posixy.myr @@ -12,7 +12,6 @@ use "option" use "result" use "slcp" use "sldup" -use "sleq" use "slpush" use "slurp" use "strfind" diff --git a/lib/std/test/bigint.myr b/lib/std/test/bigint.myr index ba8eaa1..33e1b91 100644 --- a/lib/std/test/bigint.myr +++ b/lib/std/test/bigint.myr @@ -35,7 +35,7 @@ const main = { std.bigfree(e) n = std.bigbfmt(buf[:], a, 0) - std.assert(std.sleq(buf[:n], "517347321949036993306"), "simple smoke test failed") + std.assert(std.eq(buf[:n], "517347321949036993306"), "simple smoke test failed") /* some comparison tests */ a = try(std.bigparse("1234_5678_1234_6789_6666_7777_8888")) @@ -119,7 +119,7 @@ const run = {e : cmd#, res : byte[:] v = eval(e) n = std.bigbfmt(buf[:], v, 0) - if !std.sleq(buf[:n], res) + if !std.eq(buf[:n], res) std.fatal("{} != {}\n", buf[:n], res) ;; } diff --git a/lib/std/test/bytebuf.myr b/lib/std/test/bytebuf.myr index 94a31c3..d08bb9c 100644 --- a/lib/std/test/bytebuf.myr +++ b/lib/std/test/bytebuf.myr @@ -3,7 +3,6 @@ use "bytebuf" /* support */ use "die" use "fmt" -use "sleq" const main = { var bb, v diff --git a/lib/std/test/chomp.myr b/lib/std/test/chomp.myr index 6bc9aa5..1816012 100644 --- a/lib/std/test/chomp.myr +++ b/lib/std/test/chomp.myr @@ -11,6 +11,6 @@ const check = {sl, pfx, expected r = sl std.chomp(&r, pfx) - std.assert(std.sleq(r, expected), \ + std.assert(std.eq(r, expected), \ "expected chomp({}, {}) => {}, got {}\n", sl, pfx, expected, r) } diff --git a/lib/std/test/dirname.myr b/lib/std/test/dirname.myr index 8930f46..6795ec0 100644 --- a/lib/std/test/dirname.myr +++ b/lib/std/test/dirname.myr @@ -17,7 +17,7 @@ const main = { } const eq = {a, e - if !std.sleq(e, a) + if !std.eq(e, a) std.fatal("expected '{}', got '{}'\n", e, a) ;; } diff --git a/lib/std/test/fmt.myr b/lib/std/test/fmt.myr index be83952..17c75af 100644 --- a/lib/std/test/fmt.myr +++ b/lib/std/test/fmt.myr @@ -21,7 +21,7 @@ const check = {expected, fmt, args : ... ap = std.vastart(&args) sl = std.bfmtv(buf[:], fmt, &ap) - if !std.sleq(expected, sl) + if !std.eq(expected, sl) std.fatal("mismatched fmt: got \"{}\", expected \"{}\"\n", sl, expected) ;; } diff --git a/lib/std/test/ipparse.myr b/lib/std/test/ipparse.myr index fd6140a..dfed4d6 100644 --- a/lib/std/test/ipparse.myr +++ b/lib/std/test/ipparse.myr @@ -66,7 +66,7 @@ const eq = {ip, expected parsed = std.ipparse(ip) p = ipbytes(parsed) e = ipbytes(expected) - if !std.sleq(p, e) + if !std.eq(p, e) std.fput(1, "misparsed ip {}\n", ip) std.put("parsed: ") for b : p diff --git a/lib/std/test/netaddr.myr b/lib/std/test/netaddr.myr index fd9ab84..1d6cac0 100644 --- a/lib/std/test/netaddr.myr +++ b/lib/std/test/netaddr.myr @@ -16,7 +16,7 @@ const matches = {ctx, expected, addr, net, port var s s = std.netaddr(addr, net, port) - testr.check(ctx, std.sleq(expected, s), \ + testr.check(ctx, std.eq(expected, s), \ "mismatch: expected {}, got {} from ({}, {}, {})\n", \ expected, s, addr, net, port) std.slfree(s) diff --git a/lib/std/test/pathjoin.myr b/lib/std/test/pathjoin.myr index 0204184..4522af7 100644 --- a/lib/std/test/pathjoin.myr +++ b/lib/std/test/pathjoin.myr @@ -49,14 +49,14 @@ const norm = {a, b var p p = std.pathnorm(a) - if !std.sleq(p, b) + if !std.eq(p, b) std.fatal("mismatched paths: '{}' => '{}' != '{}'\n", a, p, b) ;; std.slfree(p) } const eq = {a, b - if !std.sleq(a, b) + if !std.eq(a, b) std.fatal("mismatched paths: '{}' != '{}'\n", a, b) ;; } diff --git a/lib/std/test/slcp.myr b/lib/std/test/slcp.myr index 07381c3..edb8050 100644 --- a/lib/std/test/slcp.myr +++ b/lib/std/test/slcp.myr @@ -18,7 +18,7 @@ const main = { std.slcp(a[:a.len-2], a[2:]) std.slcp(b[2:], b[:b.len-2]) std.slcp(c[1:15], c[0:14]) - std.assert(std.sleq(a[:], a_cped[:]), "slcp of a failed: got {}, wanted {}", a[:], a_cped[:]) - std.assert(std.sleq(b[:], b_cped[:]), "slcp of b failed: got {}, wanted {}", b[:], b_cped[:]) - std.assert(std.sleq(c[:], c_cped[:]), "slcp of b failed: got {r}, wanted {r}", c[:], c_cped[:]) + std.assert(std.eq(a[:], a_cped[:]), "slcp of a failed: got {}, wanted {}", a[:], a_cped[:]) + std.assert(std.eq(b[:], b_cped[:]), "slcp of b failed: got {}, wanted {}", b[:], b_cped[:]) + std.assert(std.eq(c[:], c_cped[:]), "slcp of b failed: got {r}, wanted {r}", c[:], c_cped[:]) } diff --git a/lib/std/test/sleq.myr b/lib/std/test/sleq.myr index c15807f..e9ffb59 100644 --- a/lib/std/test/sleq.myr +++ b/lib/std/test/sleq.myr @@ -12,14 +12,14 @@ const main = { const wide = {c var a : uint[3] = [ 0, 1, 2] var b : uint[3] = [ 0, 1, 3] - testr.check(c, !std.sleq(a[:], b[:]), "expected {} != {} as uint[:]", a, b) + testr.check(c, !std.eq(a[:], b[:]), "expected {} != {} as uint[:]", a, b) } const slices = {c var a : int8[8] = [ 0, 0, 3, 1, 0, 3, 1, 2 ] var b : int8[3] = [ 1, 0, 3] - testr.check(c, std.sleq(a[1:4], a[4:7]), "expected {} = {}", a[1:4], a[4:7]) - testr.check(c, !std.sleq(a[0:4], a[3:7]), "expected {} = {}", a[0:4], a[3:7]) - testr.check(c, !std.sleq(a[:], b[:]), "expected {} = {}", a, b) - testr.check(c, !std.sleq(a[3:7], b[:]), "expected {} = {}", a[3:7], b) + testr.check(c, std.eq(a[1:4], a[4:7]), "expected {} = {}", a[1:4], a[4:7]) + testr.check(c, !std.eq(a[0:4], a[3:7]), "expected {} = {}", a[0:4], a[3:7]) + testr.check(c, !std.eq(a[:], b[:]), "expected {} = {}", a, b) + testr.check(c, !std.eq(a[3:7], b[:]), "expected {} = {}", a[3:7], b) } diff --git a/lib/std/test/sort.myr b/lib/std/test/sort.myr index e814623..61e39ae 100644 --- a/lib/std/test/sort.myr +++ b/lib/std/test/sort.myr @@ -12,16 +12,16 @@ const main = { /* with custom intcmp */ std.sort(a[:], intcmp) - std.assert(std.sleq(a[:], a_sorted[:]), "a was missorted") + std.assert(std.eq(a[:], a_sorted[:]), "a was missorted") /* with libstd generic numcmp */ std.sort(b[:], std.numcmp) - std.assert(std.sleq(b[:], b_sorted[:]), "b was missorted") + std.assert(std.eq(b[:], b_sorted[:]), "b was missorted") /* string sorting */ std.sort(c[:], std.strcmp) for i = 0; i < c.len; i++ - std.assert(std.sleq(c[i], c_sorted[i]), "c was missorted") + std.assert(std.eq(c[i], c_sorted[i]), "c was missorted") ;; } diff --git a/lib/std/test/strbuf.myr b/lib/std/test/strbuf.myr index 2643da5..741ed39 100644 --- a/lib/std/test/strbuf.myr +++ b/lib/std/test/strbuf.myr @@ -5,36 +5,36 @@ const main = { var buf : byte[16] sb = std.mksb() - std.assert(std.sleq(std.sbpeek(sb), ""), "mismatched empty str\n") + std.assert(std.eq(std.sbpeek(sb), ""), "mismatched empty str\n") std.sbputs(sb, "hello") - std.assert(std.sleq(std.sbpeek(sb), "hello"), "mismatched hello\n") + std.assert(std.eq(std.sbpeek(sb), "hello"), "mismatched hello\n") std.sbputs(sb, ", hello") - std.assert(std.sleq(std.sbpeek(sb), "hello, hello"), "mismatched double hello\n") + std.assert(std.eq(std.sbpeek(sb), "hello, hello"), "mismatched double hello\n") std.sbtrim(sb, 7) - std.assert(std.sleq(std.sbpeek(sb), "hello, "), "mismatched trim\n") + std.assert(std.eq(std.sbpeek(sb), "hello, "), "mismatched trim\n") std.sbputs(sb, "world") - std.assert(std.sleq(std.sbpeek(sb), "hello, world"), "mismatched hello world\n") + std.assert(std.eq(std.sbpeek(sb), "hello, world"), "mismatched hello world\n") std.sbtrim(sb, -5) - std.assert(std.sleq(std.sbpeek(sb), "hello, "), "mismatched rtrim\n") + std.assert(std.eq(std.sbpeek(sb), "hello, "), "mismatched rtrim\n") std.sbputc(sb, '世') std.sbputc(sb, '界') - std.assert(std.sleq(std.sbpeek(sb), "hello, 世界"), "mismatched unicode\n") + std.assert(std.eq(std.sbpeek(sb), "hello, 世界"), "mismatched unicode\n") std.sbputb(sb, 10) - std.assert(std.sleq(std.sbpeek(sb), "hello, 世界\n"), "mismatched byte\n") + std.assert(std.eq(std.sbpeek(sb), "hello, 世界\n"), "mismatched byte\n") sb = std.mkbufsb(buf[:]) std.assert(std.sbputs(sb, "hello"), "failed to add hello\n") /* 5 characters */ std.assert(std.sbputs(sb, "hello"), "failed to add hello\n") /* 10 characters */ std.assert(std.sbputs(sb, "hello"), "failed to add hello\n") /* 15 characters */ std.assert(!std.sbputs(sb, "hello"), "erronous success\n") /* 16 characters */ - std.assert(std.sleq(std.sbpeek(sb), "hellohellohelloh"), "failed to copy as much as possible\n") + std.assert(std.eq(std.sbpeek(sb), "hellohellohelloh"), "failed to copy as much as possible\n") std.sbtrim(sb, -1) - std.assert(std.sleq(std.sbpeek(sb), "hellohellohello"), "failed rtrim\n") + std.assert(std.eq(std.sbpeek(sb), "hellohellohello"), "failed rtrim\n") std.sbputc(sb, '世') - std.assert(std.sleq(std.sbpeek(sb), "hellohellohello"), "modified overflowed putc\n") + std.assert(std.eq(std.sbpeek(sb), "hellohellohello"), "modified overflowed putc\n") std.sbtrim(sb, -2) - std.assert(std.sleq(std.sbpeek(sb), "hellohellohel"), "failed rtrim\n") + std.assert(std.eq(std.sbpeek(sb), "hellohellohel"), "failed rtrim\n") std.sbputc(sb, '世') - std.assert(std.sleq(std.sbpeek(sb), "hellohellohel世"), "failed to append with putc\n") + std.assert(std.eq(std.sbpeek(sb), "hellohellohel世"), "failed to append with putc\n") } diff --git a/lib/std/test/strsplit.myr b/lib/std/test/strsplit.myr index c70f6f6..bf81f41 100644 --- a/lib/std/test/strsplit.myr +++ b/lib/std/test/strsplit.myr @@ -36,7 +36,7 @@ const check = {a, b std.fatal("length mismatch: {} != {}: {}\n", a.len, b.len) ;; for var i = 0; i < a.len; i++ - if !std.sleq(a[i], b[i]) + if !std.eq(a[i], b[i]) std.fatal("element {} mismatched: '{}' != '{}'\n", i, a[i], b[i]) ;; ;; diff --git a/lib/std/varargs.myr b/lib/std/varargs.myr index 1710444..f7c54b4 100644 --- a/lib/std/varargs.myr +++ b/lib/std/varargs.myr @@ -1,6 +1,5 @@ use "types" use "introspect" -use "sleq" use "die" pkg std = diff --git a/lib/std/wait+plan9.myr b/lib/std/wait+plan9.myr index 2097c00..1befb11 100644 --- a/lib/std/wait+plan9.myr +++ b/lib/std/wait+plan9.myr @@ -13,7 +13,6 @@ use "strsplit" use "striter" use "syswrap" use "utf" -use "sleq" use "fmt" use "threadhooks" diff --git a/mbld/deps.myr b/mbld/deps.myr index 066fb3c..5746008 100644 --- a/mbld/deps.myr +++ b/mbld/deps.myr @@ -439,7 +439,7 @@ const linkcmd = {b, n, mt, bin, libs, dynlibs, istest std.slpush(&n.cmd, std.sldup(mt.ldscript)) ;; - if mt.runtime.len == 0 || std.sleq(mt.runtime, "none") + if mt.runtime.len == 0 || std.eq(mt.runtime, "none") std.slpush(&n.cmd, std.sldup(opt_runtime)) else std.slpush(&n.cmd, std.sldup(mt.runtime)) @@ -455,10 +455,10 @@ const linkcmd = {b, n, mt, bin, libs, dynlibs, istest ;; /* OSX warns if we don't add a version */ - if std.sleq(opt_sys, "osx") + if std.eq(opt_sys, "osx") std.slpush(&n.cmd, std.sldup("-macosx_version_min")) std.slpush(&n.cmd, std.sldup("10.6")) - elif std.sleq(opt_sys, "linux") && dynlibs.len != 0 + elif std.eq(opt_sys, "linux") && dynlibs.len != 0 std.slpush(&n.cmd, std.sldup("-dynamic-linker")) std.slpush(&n.cmd, std.sldup("/lib64/ld-linux-x86-64.so.2")) ;; diff --git a/mbld/main.myr b/mbld/main.myr index 3362d3a..ecd2b40 100644 --- a/mbld/main.myr +++ b/mbld/main.myr @@ -158,14 +158,14 @@ const findproj = {b var dir dir = std.getcwd() - while dir.len > 0 && !std.sleq(dir, "/") + while dir.len > 0 && !std.eq(dir, "/") if std.chdir(dir) && std.fexists("bld.proj") b.basedir = dir break ;; dir = std.dirname(dir) ;; - if dir.len > 0 && std.sleq(b.basedir, "/") + if dir.len > 0 && std.eq(b.basedir, "/") std.fatal("could not find bld.proj\n") ;; } |