shithub: puzzles

Download patch

ref: eac7fc1665ef07c4a8b009521034043ce6b422e7
parent: 88872fe806bb3700c8dc6372d66e1b6620f78da2
author: Simon Tatham <anakin@pobox.com>
date: Sat Jan 21 06:57:13 EST 2023

kaios/manifest.pl: canonicalise the JSON output.

The default behaviour of JSON::PP's encode_json output is to write the
keys of a hash in Perl's natural hash order, which isn't consistent
between runs of the same script due to hash function randomisation.
This causes my build system to complain when successive builds from
the same source revision don't produce the same output.

Easily fixed: JSON::PP already has a switch to ensure consistent
ordering, it's just a matter of finding it and turning it on.

--- a/kaios/manifest.pl
+++ b/kaios/manifest.pl
@@ -32,7 +32,7 @@
     $decvers = join('.', $1+0, $2+0, $3+0);
 }
 
-print encode_json({
+print JSON::PP->new->canonical->encode({
     name => $displayname,
     subtitle => $description,
     description => $objective,