diff --git a/spork/base64.janet b/spork/base64.janet index 81cb4b5..de74188 100644 --- a/spork/base64.janet +++ b/spork/base64.janet @@ -96,10 +96,10 @@ ``` [s] (if-not (empty? s) - (let [without-padding (peg/replace-all "=" "" s) + (let [without-padding (string/replace-all "=" "" s) padded? (not (zero? (% (length without-padding) 4))) quadruples (partition 4 without-padding) bytes (map quadruples->bytes quadruples) base64 (apply string bytes)] - (if padded? (slice base64 0 -2) base64)) + (if padded? (slice base64 0 (dec (length base64))) base64)) "")) diff --git a/spork/cjanet.janet b/spork/cjanet.janet index 82ae00a..7247552 100644 --- a/spork/cjanet.janet +++ b/spork/cjanet.janet @@ -509,7 +509,7 @@ (defn emit-declare "Emit a declaration of a variable or constant." [binding & form] - (def storage-classes (slice form 0 -2)) + (def storage-classes (slice form 0 (dec (length form)))) (def v (last form)) (when (next storage-classes) (emit-storage-classes storage-classes)) diff --git a/spork/httpf.janet b/spork/httpf.janet index f68db55..c2c87f0 100644 --- a/spork/httpf.janet +++ b/spork/httpf.janet @@ -116,7 +116,7 @@ (put mime-read-default path read-mime) (put mime-render-default path render-mime) (if (string/has-suffix? "/" path) - (add-route server (string/slice path 0 -2) docstring schema handler read-mime render-mime) + (add-route server (string/slice path 0 (dec (length path))) docstring schema handler read-mime render-mime) server)) (defn add-bindings-as-routes diff --git a/spork/misc.janet b/spork/misc.janet index 64155cd..adc4c04 100644 --- a/spork/misc.janet +++ b/spork/misc.janet @@ -28,7 +28,7 @@ "\n" (string/replace indent "" x))] # Remove trailing newline to mimic long string newline omission. (if (= (chr "\n") (last y)) - (slice y 0 -2) + (slice y 0 (dec (length y))) y)) x)) @@ -200,14 +200,14 @@ "Trim the specified prefix of a string if it has one" [prefix str] (if (string/has-prefix? prefix str) - (slice str (length prefix) -1) + (slice str (length prefix)) str)) (defn trim-suffix "Trim the specified suffix of a string if it has one" [suffix str] (if (string/has-suffix? suffix str) - (slice str 0 (* -1 (+ 1 (length suffix)))) + (slice str 0 (- (length str) (length suffix))) str)) (defmacro log @@ -278,7 +278,7 @@ 'if cnd (tuple 'set res (tuple (first ope) res - ;(tuple/slice ope 1 -1))))) + ;(tuple/slice ope 1))))) (partition 2 clauses)) ,res))) diff --git a/spork/path.janet b/spork/path.janet index f834cd7..48f2a14 100644 --- a/spork/path.janet +++ b/spork/path.janet @@ -18,7 +18,7 @@ (if-let [m (peg/match ext-peg path (length path))] (let [i (m 0)] (if (= (path i) 46) - (string/slice path (m 0) -1))))) + (string/slice path (m 0)))))) (defn- redef "Redef a value, keeping all metadata." @@ -63,7 +63,7 @@ path (length path))] (let [[p] m] - (string/slice path p -1)) + (string/slice path p)) path))) (defmacro- decl-parts @@ -130,7 +130,7 @@ (def target-parts (,(symbol pre "/parts") (,(symbol pre "/abspath") target))) (def same-parts (length (take-until identity (map not= source-parts target-parts)))) (def up-walk (array/new-filled (- (length source-parts) same-parts) "..")) - (def down-walk (tuple/slice target-parts same-parts -1)) + (def down-walk (tuple/slice target-parts same-parts)) (,(symbol pre "/join") ;up-walk ;down-walk))) #