This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

[PATCH himitsu] himitsu::query: Add error message about duplicate keys

Message ID
DKIM signature
Download raw message
Patch: +12 -0
From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>

Otherwise it would silently abort.
 himitsu/query/parse.ha | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/himitsu/query/parse.ha b/himitsu/query/parse.ha
index e9c2722..a44cba8 100644
--- a/himitsu/query/parse.ha
+++ b/himitsu/query/parse.ha
@@ -122,6 +122,18 @@ export fn parse_items(items: []str) (query | error) = {
	let prev = keys[0];
	for (let i = 1z; i < len(keys); i += 1) {
		if (prev == keys[i]) {
			fmt::printf("himitsud: Duplicate key '{}' in entry:", prev)!;
			for (let i = 0z; i < len(query.items); i += 1) {
				let p = query.items[i];
				fmt::printf(" {}", p.key)!;
				if (!p.private) {
					fmt::printf("={}", p.value)!;
				} else {

			return dupkeys;
		prev = keys[i];
Message ID
<20240122124434.29708-1-contact+sr.ht@hacktivis.me> (view parent)
DKIM signature
Download raw message
query::parse_items should not have the side-effect of writing error
messages to stdout. It does not fail silently since it returns the
dupkeys error.

I think figuring out what keys are duplicates can easily be done by the
user. Though if this is really a desired feature, the output should be
done at the tool that uses query::parse. The tool must then figure out
the duplicates on their own, but then a method to find duplicates could
be provided by the query module.
Reply to thread Export thread (mbox)