Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't emit long non-complex hash keys in "complex" notation #90

Open
eserte opened this issue Apr 8, 2019 · 1 comment
Open

Don't emit long non-complex hash keys in "complex" notation #90

eserte opened this issue Apr 8, 2019 · 1 comment

Comments

@eserte
Copy link

eserte commented Apr 8, 2019

It seems that libyaml uses the ? ... : ... notation for long hash keys (with "long" being more than 128 characters). I think that this notation brings no readability advantage over the "normal" hash notation (in fact, this notation is quite surprising for most humans), and would vote to do a change here (this would probably be a return 1 in the YAML_SCALAR_EVENT case in yaml_emitter_check_simple_key.

After the change the following test script should pass:

#!/usr/bin/perl

use strict;
use warnings;
use YAML::XS qw(Dump);
use Test::More 'no_plan';

my $bla = '123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEFx';
is Dump({ $bla => 1 }), <<'EOF';
---
123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEFx: 1
EOF

__END__
@perlpunk
Copy link
Collaborator

This issue should probably be opened in https://github.com/yaml/libyaml instead, as the code you mention is in emitter.c of libyaml, and YAML::XS should usually not modify libyaml sources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants