~chrisppy/hare-rss

0380d257eff2df36e97cb058ebb89a0c114175bc — Chris Palmer 9 months ago 2fc2dfa
Updates from stdlib
4 files changed, 18 insertions(+), 18 deletions(-)

M format/rss/+test.ha
M format/rss/finish.ha
M format/rss/scan.ha
M format/rss/types.ha
M format/rss/+test.ha => format/rss/+test.ha +4 -4
@@ 1,13 1,13 @@
// License: MPL-2.0
// (c) 2022 Chris Palmer <chris@red-oxide.org>
use bufio;
// (c) 2022-2023 Chris Palmer <chris@red-oxide.org>
use encoding::utf8;
use fmt;
use io;
use memio;
use strings;

@test fn extended() void = {
	const buf = bufio::fixed(strings::toutf8(
	const buf = memio::fixed(strings::toutf8(
`<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>


@@ 47,7 47,7 @@ use strings;
			<enclosure url="http://www.scripting.com/mp3s/weatherReportSuite.mp3" length="12216320" type="audio/mpeg" />
		</item>
	</channel>
</rss>`), io::mode::READ);
</rss>`));

	const f = scan(&buf)!;
	defer finish(&f);

M format/rss/finish.ha => format/rss/finish.ha +1 -1
@@ 1,5 1,5 @@
// License: MPL-2.0
// (c) 2022 Chris Palmer <chris@red-oxide.org>
// (c) 2022-2023 Chris Palmer <chris@red-oxide.org>

// Frees resources associated with a [[rss]].
export fn finish(r: *rss) void = {

M format/rss/scan.ha => format/rss/scan.ha +11 -11
@@ 1,9 1,9 @@
// License: MPL-2.0
// (c) 2022 Chris Palmer <chris@red-oxide.org>
// (c) 2022-2023 Chris Palmer <chris@red-oxide.org>
use format::xml;
use io;
use memio;
use strings;
use strio;

// Scans a RSS feed XML definition.
export fn scan(in: io::handle) (rss | error) = {


@@ 216,7 216,7 @@ fn scan_image(p: *xml::parser) (image | error) = {
};

fn scan_guid(p: *xml::parser) (guid | error) = {
	let val = strio::dynamic(), pl = "true";
	let val = memio::dynamic(), pl = "true";
	for (true) {
		match (xml::scan(p)?) {
		case void =>


@@ 231,7 231,7 @@ fn scan_guid(p: *xml::parser) (guid | error) = {
					continue;
				};
			case let txt: xml::text =>
				strio::concat(&val, txt)?;
				memio::concat(&val, txt)?;
			case let e: xml::elementend =>
				break;
			case =>


@@ 240,11 240,11 @@ fn scan_guid(p: *xml::parser) (guid | error) = {
		};
	};

	return (strio::string(&val), pl);
	return (memio::string(&val)?, pl);
};

fn scan_category(p: *xml::parser) (category | error) = {
	let val = strio::dynamic(), d = "";
	let val = memio::dynamic(), d = "";
	for (true) {
		match (xml::scan(p)?) {
		case void =>


@@ 259,7 259,7 @@ fn scan_category(p: *xml::parser) (category | error) = {
					continue;
				};
			case let txt: xml::text =>
				strio::concat(&val, txt)?;
				memio::concat(&val, txt)?;
			case let e: xml::elementend =>
				break;
			case =>


@@ 268,11 268,11 @@ fn scan_category(p: *xml::parser) (category | error) = {
		};
	};

	return (strio::string(&val), d);
	return (memio::string(&val)?, d);
};

fn scan_text(p: *xml::parser) (str | error) = {
	let val = strio::dynamic();
	let val = memio::dynamic();
	for (true) {
		match (xml::scan(p)?) {
		case void =>


@@ 280,7 280,7 @@ fn scan_text(p: *xml::parser) (str | error) = {
		case let tok: xml::token =>
			match (tok) {
			case let txt: xml::text =>
				strio::concat(&val, txt)?;
				memio::concat(&val, txt)?;
			case let e: xml::elementend =>
				break;
			case =>


@@ 289,7 289,7 @@ fn scan_text(p: *xml::parser) (str | error) = {
		};
	};

	return strio::string(&val);
	return memio::string(&val)?;
};

fn want(p: *xml::parser) (xml::token | error) = {

M format/rss/types.ha => format/rss/types.ha +2 -2
@@ 1,9 1,9 @@
// License: MPL-2.0
// (c) 2022 Chris Palmer <chris@red-oxide.org>
// (c) 2022-2023 Chris Palmer <chris@red-oxide.org>
use format::xml;
use io;

// A RSS parent element. Channel has been collapsed into this structure. 
// A RSS parent element. Channel has been collapsed into this structure.
export type rss = struct {
	version: str,
	title: str,