~sircmpwn/himitsu-devel

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

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

Details
Message ID
<20240122124434.29708-1-contact+sr.ht@hacktivis.me>
DKIM signature
pass
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 {
					fmt::printf("!");
				};
			};
			fmt::println()!;

			return dupkeys;
		};
		prev = keys[i];
-- 
2.43.0
Details
Message ID
<CYLAIKTD5Y3F.BJ5GSB9LSBY8@strohwolke.at>
In-Reply-To
<20240122124434.29708-1-contact+sr.ht@hacktivis.me> (view parent)
DKIM signature
pass
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)