hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 5ed3445361360773993f0895cd45c9a389093be5
parent 0429880ffbfaba2bb8ab9b2fd2ad64b24eadd756
Author: Ember Sawady <ecs@d2evs.net>
Date:   Tue,  3 Oct 2023 07:03:24 +0000

get rid of trailing whitespace

and add a check for it in the ci

Signed-off-by: Ember Sawady <ecs@d2evs.net>

Diffstat:
M.builds/alpine.yml | 4++--
Mcrypto/aes/+x86_64/ni.s | 68++++++++++++++++++++++++++++++++++----------------------------------
Mcrypto/bigint/arithm.ha | 22+++++++++++-----------
Mcrypto/bigint/encoding.ha | 8++++----
Mcrypto/bigint/monty.ha | 6+++---
Mcrypto/bigint/util.ha | 6+++---
Mcrypto/chachapoly/README | 2+-
Mcrypto/chachapoly/chachapoly.ha | 2+-
Mcrypto/cipher/ctr.ha | 2+-
Mcrypto/cipher/gcm.ha | 2+-
Mcrypto/cipher/ghash.ha | 6+++---
Mcrypto/cipher/stream.ha | 2+-
Mcrypto/hkdf/hkdf.ha | 2+-
Mcrypto/math/arithm.ha | 6+++---
Mcrypto/rsa/core.ha | 8++++----
Mcrypto/rsa/keys.ha | 8++++----
Mdocs/bdfl.md | 2+-
Mglob/glob.ha | 4++--
Mhare/module/types.ha | 2+-
Mos/exec/cmd.ha | 2+-
Mpath/buffer.ha | 2+-
Dscripts/copyright.sh | 38--------------------------------------
Ascripts/lint.sh | 42++++++++++++++++++++++++++++++++++++++++++
Mstrings/replace.ha | 6+++---
24 files changed, 128 insertions(+), 124 deletions(-)

diff --git a/.builds/alpine.yml b/.builds/alpine.yml @@ -38,9 +38,9 @@ tasks: - check_with_libc: | cd hare hare test -lc -- copyright: | +- lint: | cd hare - ./scripts/copyright.sh + ./scripts/lint.sh - bootstrap: | cd hare make -j2 bootstrap diff --git a/crypto/aes/+x86_64/ni.s b/crypto/aes/+x86_64/ni.s @@ -24,40 +24,40 @@ enc_key_128: movdqu %xmm1, (%rcx) aeskeygenassist $0x1, %xmm1, %xmm2 call key_expand_128 - movdqu %xmm1, 0x10(%rcx) + movdqu %xmm1, 0x10(%rcx) aeskeygenassist $0x2, %xmm1, %xmm2 call key_expand_128 - movdqu %xmm1, 0x20(%rcx) + movdqu %xmm1, 0x20(%rcx) aeskeygenassist $0x4, %xmm1, %xmm2 call key_expand_128 - movdqu %xmm1, 0x30(%rcx) + movdqu %xmm1, 0x30(%rcx) aeskeygenassist $0x8, %xmm1, %xmm2 call key_expand_128 - movdqu %xmm1, 0x40(%rcx) + movdqu %xmm1, 0x40(%rcx) aeskeygenassist $0x10, %xmm1, %xmm2 call key_expand_128 - movdqu %xmm1, 0x50(%rcx) + movdqu %xmm1, 0x50(%rcx) aeskeygenassist $0x20, %xmm1, %xmm2 call key_expand_128 - movdqu %xmm1, 0x60(%rcx) + movdqu %xmm1, 0x60(%rcx) aeskeygenassist $0x40, %xmm1, %xmm2 call key_expand_128 - movdqu %xmm1, 0x70(%rcx) + movdqu %xmm1, 0x70(%rcx) aeskeygenassist $0x80, %xmm1, %xmm2 call key_expand_128 - movdqu %xmm1, 0x80(%rcx) + movdqu %xmm1, 0x80(%rcx) aeskeygenassist $0x1b, %xmm1, %xmm2 call key_expand_128 - movdqu %xmm1, 0x90(%rcx) + movdqu %xmm1, 0x90(%rcx) aeskeygenassist $0x36, %xmm1, %xmm2 call key_expand_128 - movdqu %xmm1, 0xa0(%rcx) + movdqu %xmm1, 0xa0(%rcx) # return rklen mov $176, %rax jmp dec_key -key_expand_128: +key_expand_128: vpslldq $0x4, %xmm1, %xmm3 pxor %xmm3, %xmm1 vpslldq $0x4, %xmm1, %xmm3 @@ -205,30 +205,30 @@ enc_key_256: jmp dec_key key_expand_256_a: - movdqa %xmm1, %xmm4 - pslldq $4, %xmm4 - pxor %xmm4, %xmm1 - pslldq $4, %xmm4 - pxor %xmm4, %xmm1 - pslldq $4, %xmm4 - pxor %xmm4, %xmm1 + movdqa %xmm1, %xmm4 + pslldq $4, %xmm4 + pxor %xmm4, %xmm1 + pslldq $4, %xmm4 + pxor %xmm4, %xmm1 + pslldq $4, %xmm4 + pxor %xmm4, %xmm1 - pshufd $0xff, %xmm2, %xmm2 - pxor %xmm2, %xmm1 + pshufd $0xff, %xmm2, %xmm2 + pxor %xmm2, %xmm1 - ret + ret key_expand_256_b: - movdqa %xmm3, %xmm4 - pslldq $4, %xmm4 - pxor %xmm4, %xmm3 - pslldq $4, %xmm4 - pxor %xmm4, %xmm3 - pslldq $4, %xmm4 - pxor %xmm4, %xmm3 + movdqa %xmm3, %xmm4 + pslldq $4, %xmm4 + pxor %xmm4, %xmm3 + pslldq $4, %xmm4 + pxor %xmm4, %xmm3 + pslldq $4, %xmm4 + pxor %xmm4, %xmm3 - pshufd $0xaa, %xmm2, %xmm2 - pxor %xmm2, %xmm3 + pshufd $0xaa, %xmm2, %xmm2 + pxor %xmm2, %xmm3 ret @@ -349,7 +349,7 @@ crypto.aes.x86ni_asencrypt: movdqu (%rbx), %xmm1 pxor %xmm1, %xmm0 - movdqu 0x10(%rbx), %xmm1 + movdqu 0x10(%rbx), %xmm1 aesenc %xmm1, %xmm0 movdqu 0x20(%rbx), %xmm1 aesenc %xmm1, %xmm0 @@ -368,7 +368,7 @@ crypto.aes.x86ni_asencrypt: movdqu 0x90(%rbx), %xmm1 aesenc %xmm1, %xmm0 - mov $208, %rdx + mov $208, %rdx cmp %rax, %rdx jl encrypt_256 je encrypt_192 @@ -434,7 +434,7 @@ crypto.aes.x86ni_asdecrypt: movdqu (%rbx), %xmm1 pxor %xmm1, %xmm0 - movdqu 0x10(%rbx), %xmm1 + movdqu 0x10(%rbx), %xmm1 aesdec %xmm1, %xmm0 movdqu 0x20(%rbx), %xmm1 aesdec %xmm1, %xmm0 @@ -453,7 +453,7 @@ crypto.aes.x86ni_asdecrypt: movdqu 0x90(%rbx), %xmm1 aesdec %xmm1, %xmm0 - mov $208, %rdx + mov $208, %rdx cmp %rax, %rdx je decrypt_192 jl decrypt_256 diff --git a/crypto/bigint/arithm.ha b/crypto/bigint/arithm.ha @@ -4,17 +4,17 @@ // The following code was initially ported from BearSSL. // // Copyright (c) 2017 Thomas Pornin <pornin@bolet.org> -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -86,7 +86,7 @@ export fn rshift(x: []word, count: word) void = { // Multiply 'x' by 2^WORD_BITSZ and then add integer 'z', modulo 'm'. This // function assumes that 'x' and 'm' have the same announced bit length, and the // announced bit length of 'm' matches its true bit length. -// +// // 'x' and 'm' may not refer to the same array. // // This function runs in constant time for a given announced bit length of 'x' @@ -115,7 +115,7 @@ fn muladd_small(x: []word, z: word, m: const []word) void = { // Principle: we estimate the quotient (x*2^31+z)/m by // doing a 64/32 division with the high words. - // + // // Let: // w = 2^31 // a = (w*a0 + a1) * w^N + a2 @@ -130,7 +130,7 @@ fn muladd_small(x: []word, z: word, m: const []word) void = { // I.e. the two top words of a are a0:a1, the top word of b is // b0, we ensured that b0 is "full" (high bit set), and a is // such that the quotient q = a/b fits on one word (0 <= q < w). - // + // // If a = b*q + r (with 0 <= r < q), we can estimate q by // doing an Euclidean division on the top words: // a0*w+a1 = b0*u + v (with 0 <= v < b0) @@ -165,10 +165,10 @@ fn muladd_small(x: []word, z: word, m: const []word) void = { // -- otherwise, we set q = g - 1. // The properties described above then ensure that the true // quotient is q-1, q or q+1. - // + // // Take care that a0, a1 and b0 are 31-bit words, not 32-bit. We // must adjust the parameters to br_div() accordingly. - // + // const (g, _) = divu32(a0 >> 1, a1 | (a0 << 31), b0); const q = muxu32(equ32(a0, b0), WORD_BITMASK, muxu32(equ32(g, 0), 0, g - 1)); @@ -176,7 +176,7 @@ fn muladd_small(x: []word, z: word, m: const []word) void = { // We subtract q*m from x (with the extra high word of value 'hi'). // Since q may be off by 1 (in either direction), we may have to // add or subtract m afterwards. - // + // // The 'tb' flag will be true (1) at the end of the loop if the // result is greater than or equal to the modulus (not counting // 'hi' or the carry). @@ -199,7 +199,7 @@ fn muladd_small(x: []word, z: word, m: const []word) void = { // beyond the top array word), or cc == hi and tb is true (no // extra bit, but the result is not lower than the modulus). In // these cases we must subtract m once. - // + // // Otherwise, we may have overestimated, which will show as // cc > hi (thus a negative result). Correction is adding m once. const over = gtu32(cc, hi); @@ -216,7 +216,7 @@ fn mul31(x: u32, y: u32) u64 = x: u64 * y: u64; fn mul31_lo(x: u32, y: u32) u32 = (x: u32 * y: u32) & 0x7FFFFFFF; // Calculate "m0i" which is equal to -(1/m0) mod 2^WORD_BITSZ, where m0 is the -// least significant value word of m: []word. +// least significant value word of m: []word. fn ninv31(m0: u32) u32 = { let y: u32 = 2 - m0; y *= 2 - y * m0; diff --git a/crypto/bigint/encoding.ha b/crypto/bigint/encoding.ha @@ -4,17 +4,17 @@ // The following code was initially ported from BearSSL. // // Copyright (c) 2017 Thomas Pornin <pornin@bolet.org> -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -218,7 +218,7 @@ export fn encodemod(dest: []word, src: const []u8, m: const []word) u32 = { // When we reach this point at the end of the first pass: // r is either 0, 1 or -1; we want to set r to 0 if it // is equal to 0 or 1, and leave it to -1 otherwise. - // + // // When we reach this point at the end of the second pass: // r is either 0 or -1; we want to leave that value // untouched. This is a subcase of the previous. diff --git a/crypto/bigint/monty.ha b/crypto/bigint/monty.ha @@ -4,17 +4,17 @@ // The following code was initially ported from BearSSL. // // Copyright (c) 2017 Thomas Pornin <pornin@bolet.org> -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE diff --git a/crypto/bigint/util.ha b/crypto/bigint/util.ha @@ -4,17 +4,17 @@ // The following code was initially ported from BearSSL. // // Copyright (c) 2017 Thomas Pornin <pornin@bolet.org> -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE diff --git a/crypto/chachapoly/README b/crypto/chachapoly/README @@ -1,4 +1,4 @@ -This module provides Chacha20-Poly1305 and XChacha20-Poly1305 stream +This module provides Chacha20-Poly1305 and XChacha20-Poly1305 stream implementations as described in RFC 8439. A stream is created with [[chachapoly]]. [[init]] initializes a stream as a diff --git a/crypto/chachapoly/chachapoly.ha b/crypto/chachapoly/chachapoly.ha @@ -120,7 +120,7 @@ fn polypad(p: *poly1305::state, n: size) void = { mac::write(p, pad[..padlen]); }; -// Finishes encryption and writes the authentication code to 'tag'. After +// Finishes encryption and writes the authentication code to 'tag'. After // calling seal, the user must not write any more data to the stream. export fn seal(s: *stream, tag: []u8) void = writemac(s, tag); diff --git a/crypto/cipher/ctr.ha b/crypto/cipher/ctr.ha @@ -100,7 +100,7 @@ fn ctr_keybuf(s: *xorstream) []u8 = { fn ctr_advance(s: *xorstream, n: size) void = { let ctr = s: *ctr_stream; - // fill_xorbuf could be smarter, to skip multiple blocks at once. + // fill_xorbuf could be smarter, to skip multiple blocks at once. // It's of no use, since xorstream doesn't support skipping an arbritary // number of blocks. assert(n <= len(ctr.xorbuf)); diff --git a/crypto/cipher/gcm.ha b/crypto/cipher/gcm.ha @@ -212,7 +212,7 @@ export fn gcm_seal(s: *gcmstream, tag: []u8) void = { }; // Verifies the authentication tag against the decrypted data. Must be called -// after reading all data from the stream to ensure that the data was not +// after reading all data from the stream to ensure that the data was not // modified. If the data was modified, [[errors::invalid]] will be returned and // the data must not be trusted. export fn gcm_verify(s: *gcmstream, tag: []u8) (void | errors::invalid) = { diff --git a/crypto/cipher/ghash.ha b/crypto/cipher/ghash.ha @@ -4,17 +4,17 @@ // The following code was initially ported from BearSSL. // // Copyright (c) 2016 Thomas Pornin <pornin@bolet.org> -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE diff --git a/crypto/cipher/stream.ha b/crypto/cipher/stream.ha @@ -10,7 +10,7 @@ use crypto::math::{xor}; // // After initializing the xorstream can be written to with [[io::write]] to // encrypt data and write it to the handle 'h'. For decrpytion 'h' will provide -// the ciphertext and the plaintext can be read from the xorstream with +// the ciphertext and the plaintext can be read from the xorstream with // [[io::read]]. export type xorstream = struct { stream: io::stream, diff --git a/crypto/hkdf/hkdf.ha b/crypto/hkdf/hkdf.ha @@ -9,7 +9,7 @@ use hash; // Calls [[extract]] and [[expand]] to derive a single key from specified 'key' // material using HMAC with 'h' as underlying hash function and writes it to // 'dest'. The resulting key size is of the size of 'dest'. -// +// // 'info' binds the resulting key to the context in where it is being used and // therefore prevents the derivation of the same key for different contexts. It // should be independent of the input key. 'salt' does not need to be secret and diff --git a/crypto/math/arithm.ha b/crypto/math/arithm.ha @@ -4,17 +4,17 @@ // The following code was initially ported from BearSSL. // // Copyright (c) 2017 Thomas Pornin <pornin@bolet.org> -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE diff --git a/crypto/rsa/core.ha b/crypto/rsa/core.ha @@ -5,7 +5,7 @@ // // Copyright (c) 2016 Thomas Pornin <pornin@bolet.org> // -// Permission is hereby granted, free of charge, to any person obtaining +// Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, @@ -13,12 +13,12 @@ // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // -// The above copyright notice and this permission notice shall be +// The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN diff --git a/crypto/rsa/keys.ha b/crypto/rsa/keys.ha @@ -13,7 +13,7 @@ use types; // The default bit size of RSA keys is 4096-bit. Used as base for buffer sizes. export def BITSZ: size = 4096; -// The minimum bit size of RSA keys used only for validation during key init. +// The minimum bit size of RSA keys used only for validation during key init. // The default value is 1024-bit. export def MINBITSZ: size = 1024; @@ -27,7 +27,7 @@ export type pubparams = struct { }; // RSA key parameters for initializing private keys with [[privkey_init]]. If -// the private exponent d is available, [[privkey_initd]] may be used, which +// the private exponent d is available, [[privkey_initd]] may be used, which // derives 'dp' and 'dq'. All big integer values are in big-endian order. export type privparams = struct { // Bit length of the modulus n. If unknown, the modulus can be provided @@ -58,7 +58,7 @@ export def PUBKEYSZ: size = 5 + 2 * (BITSZ >> 3); // Initializes a public key from given [[pubparams]] 'x'. The data format // of 'pubkey' is subject to change and must not be used to serialize the key. // [[PUBKEYSZ]] defines the required size to store a key of [[BITSZ]]. -// +// // If given key does not fit into 'pubkey' or is too small, [[errors::overflow]] // is returned. Returns [[errors::invalid]], if given key parameters are // invalid. Returns the number of bytes written to 'pubkey' on success. @@ -258,7 +258,7 @@ export fn privkey_initd( let s = privkey_writehead(privkey, &x, n...)?; - // the order is important. The dmod operation uses the space for the + // the order is important. The dmod operation uses the space for the // remaining factors as buffer. s += privkey_dmod(privkey[s..], d, x.p); s += privkey_dmod(privkey[s..], d, x.q); diff --git a/docs/bdfl.md b/docs/bdfl.md @@ -16,7 +16,7 @@ resources, such as: - Overseeing the fiduciary responsibilities of the project - Setting (and clarifying) the broader vision and direction for the project -- Organizing participants and empowering them to roles for which they are suited +- Organizing participants and empowering them to roles for which they are suited - Planning long-term priorities and design goals - Mediating conflicts in the community - Providing the last word when consensus cannot be reached diff --git a/glob/glob.ha b/glob/glob.ha @@ -20,7 +20,7 @@ export type flag = enum uint { // If the pattern does not match any pathname, the pattern string is // returned. NOCHECK = 1 << 1, - // Backslash escaping is disabled. A backslash character is treated as + // Backslash escaping is disabled. A backslash character is treated as // an ordinary character. NOESCAPE = 1 << 2, // Pathname sorting is disabled. The order of pathnames returned is @@ -263,7 +263,7 @@ fn pattern_parse(p: *pattern, pstr: str, noesc: bool) void = { }; esc = false; }; - + // p.pat is the first path component which contains special // characters. memio::reset(&p.pat); diff --git a/hare/module/types.ha b/hare/module/types.ha @@ -69,7 +69,7 @@ export fn locstr(loc: location) str = { }; // XXX: this shouldn't be necessary, the language should have some built-in way -// to carry context with errors +// to carry context with errors fn attach(ctx: str, e: error) errcontext = (ctx, alloc(e)): errcontext; // Free the resources associated with an [[error]]. diff --git a/os/exec/cmd.ha b/os/exec/cmd.ha @@ -95,7 +95,7 @@ export fn clearenv(cmd: *command) void = { }; // Removes a variable in the command environment. This does not affect the -// current process environment. The key may not contain '=' or '\0'. +// current process environment. The key may not contain '=' or '\0'. export fn unsetenv(cmd: *command, key: str) (void | errors::invalid) = { if (strings::contains(key, '=', '\0')) return errors::invalid; diff --git a/path/buffer.ha b/path/buffer.ha @@ -23,7 +23,7 @@ export fn set(buf: *buffer, items: str...) (str | error) = { return push(buf, items...); }; -// Returns the current path stored in this buffer. +// Returns the current path stored in this buffer. // The return value is borrowed from the buffer. Use [[strings::dup]] to // extend the lifetime of the string. export fn string(buf: *buffer) str = { diff --git a/scripts/copyright.sh b/scripts/copyright.sh @@ -1,38 +0,0 @@ -#!/bin/sh -eu - -# XXX: technically doesn't work with paths that have newlines in them, but -# find -exec doesn't propagate the exit status -find . -name '*.ha' | while read -r f; do - awk 'BEGIN { state = "start" } - state == "start" { - if ($0 !~ /^\/\/ SPDX-License-Identifier: /) { - print "missing copyright header in " FILENAME - exit 1 - } - state = "author" - next - } - state == "author" { - if ($0 != "// (c) Hare authors <https://harelang.org>") { - print "invalid authorship information in " FILENAME - exit 1 - } - state = "comment" - next - } - state == "comment" && $0 !~ /^\/\// { - if ($0 != "") { - print "missing empty line after copyright header in " FILENAME - exit 1 - } - state = "postheader" - next - } - state == "postheader" { - if ($0 == "") { - print "extra empty line after copyright header in " FILENAME - exit 1 - } - exit 0 - }' "$f" -done diff --git a/scripts/lint.sh b/scripts/lint.sh @@ -0,0 +1,42 @@ +#!/bin/sh -eu + +# XXX: technically doesn't work with paths that have newlines in them, but +# find -exec doesn't propagate the exit status +find . -name '*.ha' | while read -r f; do + awk 'BEGIN { state = "start" } + /[ \t]$/ { + print "trailing whitespace in " FILENAME + exit 1 + } + state == "start" { + if ($0 !~ /^\/\/ SPDX-License-Identifier: /) { + print "missing copyright header in " FILENAME + exit 1 + } + state = "author" + next + } + state == "author" { + if ($0 != "// (c) Hare authors <https://harelang.org>") { + print "invalid authorship information in " FILENAME + exit 1 + } + state = "comment" + next + } + state == "comment" && $0 !~ /^\/\// { + if ($0 != "") { + print "missing empty line after copyright header in " FILENAME + exit 1 + } + state = "postheader" + next + } + state == "postheader" { + if ($0 == "") { + print "extra empty line after copyright header in " FILENAME + exit 1 + } + state = "body" + }' "$f" +done diff --git a/strings/replace.ha b/strings/replace.ha @@ -9,9 +9,9 @@ export fn replace(s: str, needle: str, target: str) str = { return multireplace(s, (needle, target)); }; -// Performs a replacement in 's' of each tuple given by 'repls'. Replacement -// occurs in a single pass of 's', and works like in [[replace]], except that -// replacement pairs found earlier in 'repls' will take precedence over later +// Performs a replacement in 's' of each tuple given by 'repls'. Replacement +// occurs in a single pass of 's', and works like in [[replace]], except that +// replacement pairs found earlier in 'repls' will take precedence over later // ones. For example: // // assert(multireplace("hello there", ("e", "a"), ("a", "x"), ("ell", "eww")) == "hallo thara");