commit ebe39803bff0d717d10a505a3b2a1e8f43435d21
parent 1cfcab4c63a1cf8817261ca5564f65ccb661180f
Author: Sebastian <sebastian@sebsite.pw>
Date: Fri, 13 May 2022 22:45:24 -0400
haredoc: move utility functions from html.ha to util.ha
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
3 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/cmd/haredoc/html.ha b/cmd/haredoc/html.ha
@@ -489,19 +489,6 @@ fn unparse_html(out: io::handle, d: ast::decl) (size | io::error) = {
return n;
};
-// Forked from [[hare::unparse]].
-fn newline(out: io::handle, indent: size) (size | io::error) = {
- let n = 0z;
- n += fmt::fprint(out, "\n")?;
- for (let i = 0z; i < indent; i += 1) {
- n += fmt::fprint(out, "\t")?;
- };
- return n;
-};
-
-fn multiline_comment(s: str) bool =
- strings::byteindex(s, '\n') as size != len(s) - 1;
-
fn enum_html(
out: io::handle,
indent: size,
diff --git a/cmd/haredoc/tty.ha b/cmd/haredoc/tty.ha
@@ -273,8 +273,6 @@ fn prototype_tty(
return n;
};
-// newline(), builtin_type(), and multiline_comment() are from html.ha
-
// Forked from [[hare::unparse]]
fn struct_union_type_tty(
out: io::handle,
diff --git a/cmd/haredoc/util.ha b/cmd/haredoc/util.ha
@@ -0,0 +1,18 @@
+// License: GPL-3.0
+// (c) 2022 Sebastian <sebastian@sebsite.pw>
+use fmt;
+use io;
+use strings;
+
+// Forked from [[hare::unparse]].
+fn newline(out: io::handle, indent: size) (size | io::error) = {
+ let n = 0z;
+ n += fmt::fprint(out, "\n")?;
+ for (let i = 0z; i < indent; i += 1) {
+ n += fmt::fprint(out, "\t")?;
+ };
+ return n;
+};
+
+fn multiline_comment(s: str) bool =
+ strings::byteindex(s, '\n') as size != len(s) - 1;