commit 6a8fe0a32464e8f34c8d03d4df1d81e5089fb334
parent 654ef204a274cccc27328d100175390b72ec40d6
Author: Thomas Bracht Laumann Jespersen <t@laumann.xyz>
Date: Wed, 17 Nov 2021 09:14:40 +0100
strings: Rename has_{prefix,suffix} -> has{prefix,suffix}
To be a little more consistent with the style guide.
Signed-off-by: Thomas Bracht Laumann Jespersen <t@laumann.xyz>
Diffstat:
11 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/cmd/hare/schedule.ha b/cmd/hare/schedule.ha
@@ -75,7 +75,7 @@ fn sched_ld(plan: *plan, output: str, depend: *task...) *task = {
defer free(archives);
for (let i = 0z; i < len(depend); i += 1) {
- if (strings::has_suffix(depend[i].output, ".a")) {
+ if (strings::hassuffix(depend[i].output, ".a")) {
append(archives, depend[i].output);
} else {
append(task.cmd, depend[i].output);
@@ -97,7 +97,7 @@ fn sched_ar(plan: *plan, output: str, depend: *task...) *task = {
]),
});
for (let i = 0z; i < len(depend); i += 1) {
- assert(strings::has_suffix(depend[i].output, ".o"));
+ assert(strings::hassuffix(depend[i].output, ".o"));
append(task.cmd, depend[i].output);
};
append(plan.scheduled, task);
@@ -142,7 +142,7 @@ fn sched_hare_object(
// XXX: Do we care to support assembly-only modules?
let mixed = false;
for (let i = 0z; i < len(ver.inputs); i += 1) {
- if (strings::has_suffix(ver.inputs[i].path, ".s")) {
+ if (strings::hassuffix(ver.inputs[i].path, ".s")) {
mixed = true;
break;
};
@@ -229,7 +229,7 @@ fn sched_hare_object(
for (let i = 0z; i < len(ver.inputs); i += 1) {
let path = ver.inputs[i].path;
- if (strings::has_suffix(path, ".ha")) {
+ if (strings::hassuffix(path, ".ha")) {
append(harec.cmd, path);
};
};
@@ -259,7 +259,7 @@ fn sched_hare_object(
// but that may not be generally true. We may have to address
// this at some point.
let path = ver.inputs[i].path;
- if (!strings::has_suffix(path, ".s")) {
+ if (!strings::hassuffix(path, ".s")) {
continue;
};
append(objs, sched_as(plan, mkfile(plan, ns, "o"), path));
diff --git a/cmd/haredoc/docstr.ha b/cmd/haredoc/docstr.ha
@@ -206,7 +206,7 @@ fn scansample(par: *parser) (token | void) = {
let buf = strio::finish(buf);
// Trim trailing newlines
- for (strings::has_suffix(buf, "\n")) {
+ for (strings::hassuffix(buf, "\n")) {
buf = strings::sub(buf, 0, len(buf) - 1);
};
diff --git a/cmd/haredoc/html.ha b/cmd/haredoc/html.ha
@@ -328,7 +328,7 @@ fn markup_html(ctx: *context, in: io::handle) (void | io::error) = {
fmt::fprintln(ctx.out)?;
fmt::fprint(ctx.out, "<p>")?;
case tx: text =>
- if (strings::has_prefix(tx, "https://")) {
+ if (strings::hasprefix(tx, "https://")) {
// Temporary hack
fmt::fprint(ctx.out, "<a rel='nofollow noopener' href='")?;
html_escape(ctx.out, tx)?;
diff --git a/fnmatch/fnmatch.ha b/fnmatch/fnmatch.ha
@@ -115,8 +115,8 @@ fn fnmatch_internal(
fl: flags,
) (bool | errors::invalid | errors::unsupported) = {
if (fl & flags::PERIOD != 0) {
- if (strings::has_prefix(string, ".")
- && !strings::has_prefix(pattern, ".")) {
+ if (strings::hasprefix(string, ".")
+ && !strings::hasprefix(pattern, ".")) {
return false;
};
};
diff --git a/format/ini/scan.ha b/format/ini/scan.ha
@@ -60,11 +60,11 @@ export fn next(sc: *scanner) (entry | io::EOF | error) = {
const line = strings::trim(sc.line);
- if (len(line) == 0 || strings::has_prefix(line, "#")) {
+ if (len(line) == 0 || strings::hasprefix(line, "#")) {
continue;
};
- if (strings::has_prefix(line, "[")) {
+ if (strings::hasprefix(line, "[")) {
const end = match (strings::index(line, ']')) {
case idx: size =>
yield idx;
diff --git a/getopt/getopts.ha b/getopt/getopts.ha
@@ -115,7 +115,7 @@ export fn parse(args: []str, help: help...) command = {
for (i < len(args); i += 1) :arg {
const arg = args[i];
if (len(arg) == 0 || arg == "-"
- || !strings::has_prefix(arg, "-")) {
+ || !strings::hasprefix(arg, "-")) {
break;
};
if (arg == "--") {
diff --git a/hare/module/manifest.ha b/hare/module/manifest.ha
@@ -83,7 +83,7 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = {
yield s;
};
- if (strings::has_prefix(line, "#")) {
+ if (strings::hasprefix(line, "#")) {
continue;
};
diff --git a/hare/module/scan.ha b/hare/module/scan.ha
@@ -211,9 +211,9 @@ fn scan_directory(
let d = strings::toutf8(name);
if (len(d) == 0 || (
- !strings::has_prefix(name, "+") &&
- !strings::has_prefix(name, "-"))) {
- if (!strings::has_prefix(name, ".")) {
+ !strings::hasprefix(name, "+") &&
+ !strings::hasprefix(name, "-"))) {
+ if (!strings::hasprefix(name, ".")) {
append(ver.subdirs, strings::dup(name));
};
continue;
diff --git a/net/ip/ip.ha b/net/ip/ip.ha
@@ -56,7 +56,7 @@ fn parsev4(st: str) (addr4 | invalid) = {
let i = 0z;
for (i < 4; i += 1) {
let s = wanttoken(&tok)?;
- if (len(s) != 1 && strings::has_prefix(s, "0")) {
+ if (len(s) != 1 && strings::hasprefix(s, "0")) {
return invalid;
};
ret[i] = match (strconv::stou8(s)) {
@@ -79,11 +79,11 @@ fn parsev6(st: str) (addr6 | invalid) = {
return ret;
};
let ells = -1;
- if (strings::has_prefix(st, "::")) {
+ if (strings::hasprefix(st, "::")) {
wanttoken(&tok)?;
wanttoken(&tok)?;
ells = 0;
- } else if (strings::has_prefix(st, ":")) {
+ } else if (strings::hasprefix(st, ":")) {
return invalid;
};
let i = 0;
diff --git a/os/exec/cmd.ha b/os/exec/cmd.ha
@@ -108,7 +108,7 @@ export fn setenv(cmd: *command, key: str, value: str) void = {
let fullkey = strings::concat(key, "=");
defer free(fullkey);
for (let i = 0z; i < len(cmd.env); i += 1) {
- if (strings::has_prefix(cmd.env[i], fullkey)) {
+ if (strings::hasprefix(cmd.env[i], fullkey)) {
delete(cmd.env[i]);
break;
};
diff --git a/strings/suffix.ha b/strings/suffix.ha
@@ -1,7 +1,7 @@
use bytes;
// Returns true if 'in' has the given prefix.
-export fn has_prefix(in: str, prefix: str) bool = bytes::hasprefix(toutf8(in), toutf8(prefix));
+export fn hasprefix(in: str, prefix: str) bool = bytes::hasprefix(toutf8(in), toutf8(prefix));
// Returns true if 'in' has the given prefix.
-export fn has_suffix(in: str, suff: str) bool = bytes::hassuffix(toutf8(in), toutf8(suff));
+export fn hassuffix(in: str, suff: str) bool = bytes::hassuffix(toutf8(in), toutf8(suff));