editors/nasmtok.pl: break nasmtok.json into lines

Instead of generating one single huge line of text, add newlines after
suitable commas to make it at least a manageable text file.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel) 2026-07-04 19:58:07 -07:00
parent 620dd315ee
commit 87968c3596

View file

@ -367,10 +367,24 @@ sub write_output_json {
$ver{$vn} = $vv;
}
print $out $json->encode({
my $txt = $json->encode({
'$comment' => "NASM syntax information extracted from ${whoami}",
'tokens' => \%tokens, 'version' => \%ver});
print $out "\n";
# $json->encode() creates a single long line; break up the lines
# at least...
my @txt = split(/\,/, $txt);
my $last = shift @txt;
foreach my $t (@txt) {
if (length($last)+length($t) > 77) {
print $out $last, ",\n";
$last = $t;
} else {
$last .= ",$t";
}
}
print $out $last, "\n";
return 0;
}