hautils

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 3f2983684499156ccb8a7a8726930ac4d28b4dfd
parent 0d09a13faf0639530eebbe901a781f85b7b983e4
Author: Sebastian <sebastian@sebsite.pw>
Date:   Fri, 11 Mar 2022 18:44:31 -0500

basename: use strings::trimsuffix

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mbasename.ha | 8++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/basename.ha b/basename.ha @@ -17,12 +17,8 @@ export fn utilmain() (main::error | void) = { os::exit(1); }; let basename = path::basename(cmd.args[0]); - if (len(cmd.args) == 2 && strings::hassuffix(basename, cmd.args[1])) { - if (len(basename) == len(cmd.args[1])) yield; - // XXX: This should probably go in strings:: - let slice = strings::toutf8(basename); - slice = slice[..len(basename) - len(cmd.args[1])]; - basename = strings::fromutf8(slice); + if (len(cmd.args) == 2) { + basename = strings::trimsuffix(basename, cmd.args[1]); }; fmt::println(basename)?; return void;