wordexp: correctly handle string containing only whitespace
Turns out the "x" hack was necessary after all.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
bytes: simplify reverse
Also updates the docstring to clarify that the slice is reversed in
place.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
strings: simplify ltrim and rtrim
Taking advantage of labelled loops
Signed-off-by: Sebastian <sebastian@sebsite.pw>
strings: remove pre-allocation
The slice's length will be less than len(s) if the string isn't ASCII.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
strings: simplify sub
sub also now aborts when one of the indices exceeds the string's length.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
strings: remove duplicate allocation in multireplace
Signed-off-by: Sebastian <sebastian@sebsite.pw>
strings: take direction into account in iterstr
So it returns a slice from the current position to the beginning of the
string for reverse iterators
Signed-off-by: Sebastian <sebastian@sebsite.pw>
strings: consistently use fromutf8_unsafe
strings used to use the unsafe variant in some places, and the safe
variant in other places, with no pattern as to which is used where. I've
changed all fromutf8 calls to fromutf8_unsafe calls, so calls to
strings:: functions don't repeatedly iterate through the string to check
that it's valid UTF-8 when it's already been proven that it is.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
strings: drop pad functions
>From what I could find, these were used in exactly one place:
hautils:nl.ha, where it was used to allocate a string of one character
repeated n times (so not even using the function for padding).
Signed-off-by: Sebastian <sebastian@sebsite.pw>
encoding::utf8: operate exclusively on byte slices
Previously, utf8::decode and utf8::valid accepted (str | []u8). This has
been changed, so they now only accept []u8.
utf8::decode with a string operand duplicates the functionality of
strings::iter.
utf8::valid only makes sense on byte slices, since str can't hold
invalid UTF-8. If code really wants to check if the contents of a string
are valid, it's simple enough to just call strings::toutf8 on the str
first.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
rt: simplify frame-walking functions
This simplifies the implementation, changes the interface of nextframe
to return a frame rather than a tagged union (so on aarch64 it fits
within two registers), makes the address in the frame nullable (to
account for what was previously a void result to nextframe), and makes
the docs consistent across all architectures.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
crypto::sha1: document BLOCKSZ
For consistency witih other crypto:: submodules
Signed-off-by: Sebastian <sebastian@sebsite.pw>