hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 5a24cf7cfac0882727ec0f14c114a5274b6fd22a
parent c43b34f8013b3366708cd438c86d4cd1c11049d6
Author: Umar Getagazov <umar@handlerug.me>
Date:   Wed, 30 Mar 2022 09:31:07 +0700

haredoc: fix newline trimming

strings::sub works on runes, not bytes (which is what the return value
of len(str) is counted in). Use strings::rtrim instead.

While in there, make the break condition in scantext more specific.

Signed-off-by: Umar Getagazov <umar@handlerug.me>

Diffstat:
Mcmd/haredoc/docstr.ha | 8++------
Mscripts/gen-docs | 5-----
2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/cmd/haredoc/docstr.ha b/cmd/haredoc/docstr.ha @@ -109,7 +109,7 @@ fn scantext(par: *parser) (token | void) = { break; }; bufio::unreadrune(&par.src, rn); - if (par.state == docstate::LIST) { + if (rn == '-' && par.state == docstate::LIST) { break; }; case => @@ -223,12 +223,8 @@ fn scansample(par: *parser) (token | void) = { }; let buf = strio::string(&buf); - // Trim trailing newlines - for (strings::hassuffix(buf, "\n")) { - buf = strings::sub(buf, 0, len(buf) - 1); - }; - + buf = strings::rtrim(buf, '\n'); return buf: sample; }; diff --git a/scripts/gen-docs b/scripts/gen-docs @@ -26,11 +26,6 @@ mkdir -p docs/html/ haredoc -Fhtml > docs/html/index.html for mod in $modules compress format encoding math crypto hare rt iobus do - if [ $mod = "format::ini" ] - then - # https://todo.sr.ht/~sircmpwn/hare/598 - continue - fi echo $mod path="$(echo $mod | sed -e 's?::?/?g')" mkdir -p docs/html/$path