---
mods/moon+moon.ha | 2 +-
mods/path+path.ha | 47 ++++++++++++++++++-----------------------------
mods/sun+sun.ha | 4 ++--
prompt/prompt.ha | 40 ++++++++++++++++++----------------------
term/shell.ha | 6 +-----
5 files changed, 40 insertions(+), 59 deletions(-)
diff --git a/mods/moon+moon.ha b/mods/moon+moon.ha
index 9e7e4ea..56d9939 100644
--- a/mods/moon+moon.ha
+++ b/mods/moon+moon.ha
@@ -38,5 +38,5 @@ export fn mod_moon(pe: *env::env) str = {
case "N" => yield hemisphere::Northern;
case => return strings::dup("+moon.hemisphere:config error");
};
- return strings::dup(moon_phase(date::nowutc(), hemisphere));
+ return strings::dup(moon_phase(date::now(), hemisphere));
};
diff --git a/mods/path+path.ha b/mods/path+path.ha
index 28fa966..ba7158a 100644
--- a/mods/path+path.ha
+++ b/mods/path+path.ha
@@ -19,11 +19,8 @@ use env;
fn length(path: *path::buffer) size = {
let iter = path::iter(path);
let count = 0z;
- for (true) {
- match(path::nextiter(&iter)) {
- case void => break;
- case let s: str => count += 1;
- };
+ for (let s => path::nextiter(&iter)) {
+ count += 1;
};
return count;
};
@@ -45,17 +42,13 @@ fn shorten(p: str) str = {
let ct = 0z;
let iter = path::iter(&buf);
append(m, strings::toutf8("/")...);
- for(true) {
- match(path::nextiter(&iter)) {
- case void => break;
- case let s: str =>
- ct += 1;
- if(ct > limit) {
- append(m, strings::toutf8(s)...);
- };
- if (ct > limit && ct != l) {
- append(m, pathsep...);
- };
+ for(let s => path::nextiter(&iter)) {
+ ct += 1;
+ if(ct > limit) {
+ append(m, strings::toutf8(s)...);
+ };
+ if (ct > limit && ct != l) {
+ append(m, pathsep...);
};
};
return strings::dup(strings::fromutf8_unsafe(m));
@@ -73,19 +66,15 @@ fn shorten(p: str) str = {
let ct = 0z;
let iter = path::iter(&buf);
let m: []u8 = pbuf[..0];
- for(true) {
- match(path::nextiter(&iter)) {
- case void => break;
- case let s: str =>
- ct += 1;
- if(ct > limit) {
- append(m, strings::toutf8(s)...);
- } else {
- append(m, strings::toutf8(s)[0]);
- };
- if (ct != 1 && ct != l) {
- append(m, pathsep...);
- };
+ for(let s => path::nextiter(&iter)) {
+ ct += 1;
+ if(ct > limit) {
+ append(m, strings::toutf8(s)...);
+ } else {
+ append(m, strings::toutf8(s)[0]);
+ };
+ if (ct != 1 && ct != l) {
+ append(m, pathsep...);
};
};
return strings::dup(strings::fromutf8_unsafe(m));
diff --git a/mods/sun+sun.ha b/mods/sun+sun.ha
index 82b2a00..1f51ce1 100644
--- a/mods/sun+sun.ha
+++ b/mods/sun+sun.ha
@@ -31,7 +31,7 @@ fn readconfig() (f64, f64, str, str, str, str) = (
export fn mod_sunrise(pe: *env::env) str = {
const cfg = readconfig();
- match(sunrise_sunset(local_day_utc_noon(date::nowutc()), cfg.0, cfg.1)) {
+ match(sunrise_sunset(local_day_utc_noon(date::now()), cfg.0, cfg.1)) {
case let r: (date::date, date::date) =>
return strings::dup(date::asformat(cfg.2, &date::in(chrono::LOCAL, r.0)!)!);
case midnightsun =>
@@ -43,7 +43,7 @@ export fn mod_sunrise(pe: *env::env) str = {
export fn mod_sunset(pe: *env::env) str = {
const cfg = readconfig();
- match(sunrise_sunset(local_day_utc_noon(date::nowutc()), cfg.0, cfg.1)) {
+ match(sunrise_sunset(local_day_utc_noon(date::now()), cfg.0, cfg.1)) {
case let r: (date::date, date::date) =>
return strings::dup(date::asformat(cfg.3, &date::in(chrono::LOCAL, r.1)!)!);
case midnightsun =>
diff --git a/prompt/prompt.ha b/prompt/prompt.ha
index 253c111..a916559 100644
--- a/prompt/prompt.ha
+++ b/prompt/prompt.ha
@@ -29,28 +29,24 @@ export fn prompt(pe: *env::env) str = {
static let titlebuf:[1024]u8 = [0...];
let tstream: []u8 = titlebuf[..0];
// parse the spec and assemble the parts
- for(true) {
- match(strings::next_token(&ptok)) {
- case void => break;
- case let p: str =>
- let (t,c) = strings::cut(p, ":");
- static append(parts, switch(t) {
- case "m" =>
- const part = call_mod(c, pe);
- if (pe.control.wtitle == true &&
- config::setting(c, "no") == "yes") {
- static append(tstream, strings::toutf8(part)...);
- };
- yield part;
- case "t" => yield strings::dup(c);
- case "l" => yield strings::dup("__--nl--__");
- case "s" => let s = fromstr(c);
- defer free_style(s);
- yield wraps(s, pe);
- case "f" => yield strings::dup("__--expand--__");
- case => fmt::fatal("Unknown spec type %", t);
- });
- };
+ for(let p => strings::next_token(&ptok)) {
+ let (t,c) = strings::cut(p, ":");
+ static append(parts, switch(t) {
+ case "m" =>
+ const part = call_mod(c, pe);
+ if (pe.control.wtitle == true &&
+ config::setting(c, "no") == "yes") {
+ static append(tstream, strings::toutf8(part)...);
+ };
+ yield part;
+ case "t" => yield strings::dup(c);
+ case "l" => yield strings::dup("__--nl--__");
+ case "s" => let s = fromstr(c);
+ defer free_style(s);
+ yield wraps(s, pe);
+ case "f" => yield strings::dup("__--expand--__");
+ case => fmt::fatal("Unknown spec type %", t);
+ });
};
// calculate spacer lengths, if present
let lines = 1z;
diff --git a/term/shell.ha b/term/shell.ha
index 977ba09..5269e38 100644
--- a/term/shell.ha
+++ b/term/shell.ha
@@ -53,11 +53,7 @@ export fn strlen(s: str, pe: *env::env) size = {
case true => yield ('\x5C', '[', ']');
case false => yield ('%', '{', '}');
};
- for (true) {
- const r = match(strings::next(&i)) {
- case void => break;
- case let r: rune => yield r;
- };
+ for (let r => strings::next(&i)) {
runes += 1;
if (r == she.0) {
shexp = true;
--
2.39.2