commit b20cdad1bc7fa4e17fd9d8b54310ad910a6b0243
parent 2f872228bad7363152400fcc1d2eeaeb62d4c83f
Author: Byron Torres <b@torresjrjr.com>
Date: Thu, 25 Nov 2021 03:30:18 +0000
Update for io::handle and strings::hassuffix
Update code base to compile with:
0563d5ea64239a5434a4592763642158432ffcaf harec
6507fa604db4cb304daaa6ba2f3ae86e3706557c hare
Diffstat:
5 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/basename.ha b/basename.ha
@@ -17,7 +17,7 @@ export fn utilmain() (main::error | void) = {
os::exit(1);
};
let basename = path::basename(cmd.args[0]);
- if (len(cmd.args) == 2 && strings::has_suffix(basename, cmd.args[1])) {
+ 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);
diff --git a/cat.ha b/cat.ha
@@ -22,7 +22,7 @@ export fn utilmain() (main::error | void) = {
case file: io::file =>
yield file;
};
- defer io::close(&file);
- io::copy(os::stdout, &file)?;
+ defer io::close(file);
+ io::copy(os::stdout, file)?;
};
};
diff --git a/head.ha b/head.ha
@@ -37,15 +37,15 @@ export fn utilmain() (void | main::error) = {
case file: io::file =>
yield file;
};
- defer io::close(&file);
+ defer io::close(file);
static let buf: [os::BUFSIZ]u8 = [0...];
- const file = bufio::buffered(&file, buf, []);
+ const file = bufio::buffered(file, buf, []);
defer io::close(file);
head(file, n)?;
};
};
-fn head(in: *io::stream, n: uint) (void | main::error) = {
+fn head(in: io::handle, n: uint) (void | main::error) = {
for (n > 0; n -= 1) {
let line = match (bufio::scanline(in)) {
case err: io::error =>
diff --git a/nl.ha b/nl.ha
@@ -61,6 +61,7 @@ export fn utilmain() (void | main::error) = {
let startnum = 1;
const ctx = context {
+ linenum = 0,
conblanks = 0,
maxblanks = 1,
sep = "\t",
@@ -176,7 +177,7 @@ export fn utilmain() (void | main::error) = {
case file: io::file =>
static const rbuf: [os::BUFSIZ]u8 = [0...];
static const wbuf: [os::BUFSIZ]u8 = [0...];
- yield bufio::buffered(&file, rbuf, wbuf);
+ yield bufio::buffered(file, rbuf, wbuf);
}
else
os::stdin;
diff --git a/tee.ha b/tee.ha
@@ -31,7 +31,7 @@ export fn utilmain() (main::error | void) = {
let files: []io::file = [];
defer {
for (let i = 0z; i < len(files); i += 1) {
- io::close(&files[i]);
+ io::close(files[i]);
};
free(files);
};
@@ -44,7 +44,7 @@ export fn utilmain() (main::error | void) = {
case file: io::file =>
yield file;
};
- source = &io::tee(source, &file);
+ source = &io::tee(source, file);
append(files, file);
};