YAML-Syck-1.31/0000755000000000000000000000000013364413554011615 5ustar rootrootYAML-Syck-1.31/COMPATIBILITY0000644000000000000000000000142313364413554013551 0ustar rootrootYAML::Syck and YAML.pm 0.60 breaks compatibility with older versions by changing the tags that are output for serialized objects. This was the old way: --- !perl/Foo::Bar {} --- !perl/@Baz [] --- !perl/$Quux "" New way: --- !!perl/hash:Foo::Bar {} --- !!perl/array:Baz [] --- !!perl/scalar:Quux "" * This change was made after discussions with the Python and Ruby implementers to standardize on this form. * YAML::Syck was updated at the same time as YAML.pm so that they serialize objects the same way. * YAML.pm roundtrips the new format and still parses the old (now deprecated) format. * The best strategy is to update to the latest version. * There are potential problems if you use YAML for RPC and the server and client versions don't match. YAML-Syck-1.31/t/0000755000000000000000000000000013364413554012060 5ustar rootrootYAML-Syck-1.31/t/1-basic.t0000644000000000000000000000203713364413554013466 0ustar rootrootuse strict; use warnings; use Test::More tests => 11; use YAML::Syck; ok( YAML::Syck->VERSION ); is( Dump("Hello, world"), "--- Hello, world\n" ); is( Load("--- Hello, world\n"), "Hello, world" ); TODO: { local $TODO = 'RT 34073 - Parsing YAML without separator'; my $out = eval { Load("--\n") }; isnt( $@, '', "Bad data dies on Load" ); is( $out, undef, "Bad data fails load" ); } TODO: { my $out = eval { Load("") }; is( $out, undef, "Bad data fails load" ); local $TODO = 'Load fails on empty string'; isnt( $@, '', "Bad data dies on Load" ); } TODO: { my $out = eval { Load("feefifofum\n\n\ndkjdkdk") }; local $TODO = 'Load fails on empty string'; isnt( $@, '', "Bad data dies on Load" ); is( $out, undef, "Bad data fails load" ); } TODO: { my $out = eval { Load("---\n- ! >-\n") }; local $TODO = 'RT 23850 - META.yml of DMAKI/DateTime-Format-Japanese-0.01.tar.gz cannot be parsed'; is( $@, '', "Bad data dies on Load" ); is_deeply( $out, [''], "Bad data fails load" ); } YAML-Syck-1.31/t/bug/0000755000000000000000000000000013364413554012635 5ustar rootrootYAML-Syck-1.31/t/bug/rt-49404-double_free.t0000644000000000000000000000065613364413554016411 0ustar rootroot#!perl -T use strict; use warnings; use Test::More tests => 4; use YAML::Syck; my $entry = { a => 'b' }; my $db = [ $entry, $entry ]; my $dump = Dump($db); is( $dump, qq{--- \n- &1 \n a: b\n- *1\n} ); my $dbcopy = Load($dump); is_deeply( $dbcopy, $db ); $dbcopy->[1] = $dbcopy->[0]; my $dumpcopy = Dump($dbcopy); is( $dump, qq{--- \n- &1 \n a: b\n- *1\n} ); my $dbcopycopy = Load($dumpcopy); is_deeply( $dbcopy, $db ); YAML-Syck-1.31/t/bug/rt-54167.t0000644000000000000000000000131113364413554014127 0ustar rootroot#!/usr/bin/env perl use warnings; use strict; use Test::More tests => 2; use YAML::Syck; my $some_hashref = { a => 1, b => 2 }; my $expected_iterations = scalar keys %$some_hashref; is( count_each_iterations($some_hashref), $expected_iterations, "each() iterates properly before YAML::Syck::Dump", ); # Perform the Dump. my $some_yaml_dump = YAML::Syck::Dump($some_hashref); is( count_each_iterations($some_hashref), $expected_iterations, "each() iterates properly after YAML::Syck::Dump", ); exit; sub count_each_iterations { my $hashref = shift; my $iterations = 0; while ( my ( $k, $v ) = each %$hashref ) { $iterations++; } return $iterations; } YAML-Syck-1.31/t/bug/doesnt-stringify.t0000644000000000000000000000016513364413554016334 0ustar rootrootuse Test::More; use JSON::Syck qw(Dump); plan( tests => 2 ); $v = 42; is( Dump($v), "42" ); is( Dump($v), "42" ); YAML-Syck-1.31/t/bug/rt-41141.t0000644000000000000000000000120313364413554014113 0ustar rootroot#!/usr/bin/env perl use strict; use warnings; use Test::More; use YAML::Syck; use Data::Dumper; # Carrier returns after c-indicators aren't being handled properly. my %tests = ( # From the original bug report. Seems to have been fixed already. '42\\r' => "42\r", # These all produced bad YAML. '?\\r' => "?\r", '-\\r\\r' => "-\r\r", ',\\r\\r\\r' => ",\r\r\r", ); plan tests => scalar keys %tests; while (my ($test, $value) = each (%tests)) { my $yaml = YAML::Syck::Dump($value); my $decoded = eval { YAML::Syck::Load($yaml); }; is($decoded, $value, "Produces valid YAML: $test"); } note 'Done!'; YAML-Syck-1.31/t/yaml-blessed-ref.t0000644000000000000000000000062013364413554015376 0ustar rootrootuse strict; use FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML tests => 1; use YAML::Syck; use Data::Dumper; my $bref = bless \eval { my $scalar = 'YAML::Syck' }, 'foo'; my $bref2bref = bless \$bref, 'bar'; my $dd = Dumper $bref2bref; my $edd; { no strict 'vars'; $edd = eval $dd; } my $x = 42; bless \$x, "numifyffoo"; is Dumper( Load( Dump($bref2bref) ) ), $dd, 'YAML::Syck' YAML-Syck-1.31/t/json-loadfile.t0000644000000000000000000000551413364413554015000 0ustar rootrootuse FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML; use JSON::Syck; use Test::More; chdir $FindBin::RealBin; unless ( -w $FindBin::RealBin ) { plan skip_all => "Can't write to $FindBin::RealBin"; exit; } plan tests => 12; *::LoadFile = *JSON::Syck::LoadFile; # remember where *DATA begins my $pos = tell(DATA); die "tell(DATA) failed: $!" unless $pos != -1; # read via a GLOB is( LoadFile(*DATA), "a simple scalar", 'LoadFile(*DATA) works' ); # rewind *DATA seek( DATA, $pos, 0 ) == 1 or die "rewind *DATA failed: $!"; # read via a GLOB ref is( LoadFile( \*DATA ), "a simple scalar", 'LoadFile(\*DATA) works' ); sub write_file { my ( $fh, $contents ) = @_; local *H; open( H, "> $fh" ) or die $!; print H $contents; close(H); } # write YAML to a file write_file( 'loadfile.json', "---\na simple scalar" ); write_file( 'emptyfile.json', "" ); END { unlink 'loadfile.json' or die "can't delete 'loadfile.json': $!" if -e 'loadfile.json'; unlink 'emptyfile.json' or die "can't delete 'emptyfile.json': $!" if -e 'emptyfile.json'; } # using file names is( LoadFile('loadfile.json'), "a simple scalar", 'LoadFile works with file names' ); # read via IO::File { require IO::File; my $h = IO::File->new('loadfile.json'); is( LoadFile($h), "a simple scalar", 'LoadFile works with IO::File' ); close($h); } # read via indirect file handles SKIP: { skip "indirect file handles require 5.6 or later", 1 unless $] >= 5.006000; open( my $h, 'loadfile.json' ); is( LoadFile($h), "a simple scalar", 'LoadFile works with indirect filehandles' ); close($h); } # read via ordinary filehandles { local *H; open( H, 'loadfile.json' ); is( LoadFile(*H), "a simple scalar", 'LoadFile works with ordinary filehandles' ); close(H); } # read via ordinary filehandles (refs) { local *H; open( H, 'loadfile.json' ); is( LoadFile( \*H ), "a simple scalar", 'LoadFile works with glob refs' ); close(H); } # load from "in memory" file SKIP: { skip "in-memory files require 5.8 or later", 1 unless $] >= 5.00800; open( my $h, '<', \'a simple scalar' ); is( LoadFile($h), "a simple scalar", 'LoadFile works with in-memory files' ); close($h); } { # Load empty file fails my $json = eval { LoadFile('emptyfile.json') }; like( $@, qr/^'emptyfile.json' is non-existent or empty at/ms, "LoadFile dies loading an empty file" ); is( $json, undef, "LoadFile returns undef loading an empty file" ); } { # Load empty file handle fails with an obscure message. See RT 70933 open( my $fh, '<', 'emptyfile.json' ) or die; my $json = eval { LoadFile($fh) }; like( $@, qr/^Usage: YAML::Syck::LoadJSON\(s\) at /ms, "LoadFile dies loading an empty file" ); is( $json, undef, "LoadFile returns undef loading an empty file" ); } __DATA__ "a simple scalar" YAML-Syck-1.31/t/json-refs.t0000644000000000000000000000051713364413554014156 0ustar rootrootuse strict; use FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML (); use JSON::Syck; use Test::More; plan tests => 2; my $str = "foo"; my $r = { foo => \$str, bar => sub { return "bar" } }; local $SIG{__WARN__} = sub { 1 }; my $dump = JSON::Syck::Dump $r; like $dump, qr/"bar":null/; unlike $dump, qr[!perl/ref]; YAML-Syck-1.31/t/manifest.t0000644000000000000000000000047013364413554014054 0ustar rootroot#!perl -T use 5.006; use strict; use warnings; use Test::More; unless ( $ENV{RELEASE_TESTING} ) { plan( skip_all => "Author tests not required for installation" ); } my $min_tcm = 0.9; eval "use Test::CheckManifest $min_tcm"; plan skip_all => "Test::CheckManifest $min_tcm required" if $@; ok_manifest(); YAML-Syck-1.31/t/yaml-alias.t0000644000000000000000000000514313364413554014301 0ustar rootroot#!/usr/bin/perl use Test::More tests => 14; use YAML::Syck; my ( $undumped, $roundtripped ); $undumped = [ {} ]; $undumped->[1] = $undumped->[0]; $roundtripped = Load( Dump($undumped) ); is( Dump($roundtripped), Dump($undumped), "array with anchor" ); $undumped->[1] = 'xyz'; $roundtripped->[1] = 'xyz'; is( Dump($roundtripped), Dump($undumped), "touched array with anchor" ); $undumped = { abc => {} }; $undumped->{'def'} = $undumped->{'abc'}; $roundtripped = Load( Dump($undumped) ); is( Dump($roundtripped), Dump($undumped), "hash with anchor" ); $undumped->{'def'} = 'xyz'; $roundtripped->{'def'} = 'xyz'; is( Dump($roundtripped), Dump($undumped), "touched hash with anchor" ); $undumped = [ {} ]; push @$undumped, $undumped->[0] for ( 1 .. 10 ); $roundtripped = Load( Dump($undumped) ); is( Dump($roundtripped), Dump($undumped), "huge array with anchor" ); $undumped->[0] = 'xyz'; $roundtripped->[0] = 'xyz'; is( Dump($roundtripped), Dump($undumped), "touched huge array with anchor" ); $undumped = { abc => {}, def => {} }; $undumped->{abc}->{sibling} = $undumped->{def}; $undumped->{def}->{sibling} = $undumped->{abc}; $roundtripped = Load( Dump($undumped) ); is_deeply( $roundtripped, $undumped, "circular" ); $undumped->{def}->{sibling} = {}; $roundtripped->{def}->{sibling} = {}; is( Dump($roundtripped), Dump($undumped), "touched circular" ); $undumped = [ {}, {} ]; push @$undumped, $undumped->[0], $undumped->[1] for ( 1 .. 10 ); $roundtripped = Load( Dump($undumped) ); is( Dump($roundtripped), Dump($undumped), "many anchors" ); $undumped->[0] = 'abc'; $undumped->[3] = 'def'; $roundtripped->[0] = 'abc'; $roundtripped->[3] = 'def'; is( Dump($roundtripped), Dump($undumped), "touched many anchors" ); my $s = 'scal'; $undumped = [ \$s, \$s, \$s ]; $roundtripped = Load( Dump($undumped) ); is( Dump($roundtripped), Dump($undumped), "scalar reference" ); $undumped->[1] = 'hello'; $roundtripped->[1] = 'hello'; is( Dump($roundtripped), Dump($undumped), "touched scalar reference" ); my $os = bless \$s, 'obj_scal'; my $oa = bless ['array'], 'obj_array'; my $oh = bless { key => 'value' }, 'obj_hash'; $undumped = [ $os, $oa, $oh, $os, $oa, $oh ]; $roundtripped = Load( Dump($undumped) ); TODO: { local $TODO = "Skip this because anchor #1 is going to be truncated. no problem"; is( Dump($roundtripped), Dump($undumped), "object" ); } $undumped->[3] = 'mod'; $undumped->[4] = {}; $undumped->[5] = $undumped->[4]; $roundtripped->[3] = 'mod'; $roundtripped->[4] = {}; $roundtripped->[5] = $roundtripped->[4]; is( Dump($roundtripped), Dump($undumped), "touched object" ); YAML-Syck-1.31/t/json-numbers.t0000644000000000000000000000322513364413554014671 0ustar rootrootuse Test::More tests => 53; use JSON::Syck qw(Dump); my @arr1 = sort { $a cmp $b } qw/1 2 54 howdy/; is( Dump( \@arr1 ), '["1","2","54","howdy"]', "cmp sort causes numbers to coerce into strings and thus be quoted." ); { no warnings "numeric"; my @arr2 = sort { $a <=> $b } qw/1 2 54 howdy/; is( Dump( \@arr2 ), '["howdy","1","2","54"]', "Numeric sort doesn't coerce non-numeric strings into numbers because they still contain their valid string" ); } my @arr54 = ( "howdy", 1, 2, 54 ); is( Dump( \@arr54 ), '["howdy",1,2,54]', "Strings are quoted. Numbers are not" ); is( Dump('042'), '"042"', "Ocatls don't get treated as numbers" ); is( Dump('0x42'), '"0x42"', "Hex doesn't get treated as a number" ); is( Dump('0.42'), '"0.42"', "Floats with leading 0 don't get excluded by octal check" ); is( Dump('1_000_000'), '"1_000_000"', "numbers with underscores get quoted." ); is( Dump('1,000,000'), '"1,000,000"', "numbers with commas get quoted." ); is( Dump('1e+6'), '"1e+6"', "Scientific notation gets quoted." ); is( Dump('10e+6'), '"10e+6"', "Scientific notation gets quoted." ); is( Dump('0123'), '"0123"', "Scientific notation gets quoted." ); # for simple integers, we need to preserve their string state as perl knows it if possible. # JSON overloaded + for string concatenation. This means you get all sorts of wierdness if we try to strip quotes on strings not IVs # "0" is true 0 is false. 1 + 1 = 2 but "1" + "1" = "11" for ( -10 .. 10 ) { is( Dump($_), $_, '"0" != 0 in JSON. 0 is false "0" is true.' ); is( Dump("$_"), "\"$_\"", 'Strigified integer is stringified in JSON' ); } YAML-Syck-1.31/t/json-circular-ref.t0000755000000000000000000000274013364413554015600 0ustar rootrootuse strict; use warnings; use Test::More tests => 8; use JSON::Syck; { # Impossible circular blessed references in JSON my $foo = bless {}, "Foo"; my $bar = bless { foo => $foo }, "Bar"; $foo->{bar} = $bar; my $result = eval { JSON::Syck::Dump($foo) }; is( $result, undef, "A Structure should come back on a JSON dump with circular blessed references" ); like( $@, qr/^Dumping circular structures is not supported with JSON::Syck/, "Die is thrown when the circular blessed ref happens" ); } { # Circular references broken regardless of blessing my $foo = {}; my $bar = { foo => $foo }; $foo->{bar} = $bar; my $result = eval { JSON::Syck::Dump($foo) }; is( $result, undef, "A Structure should come back on a JSON dump with duplicate references" ); like( $@, qr/^Dumping circular structures is not supported with JSON::Syck/, "Die is thrown when the circular ref happens" ); } { my $foo = {}; my $result = eval { JSON::Syck::Dump( [ $foo, $foo ] ) }; is( $result, '[{},{}]', "A Structure should come back on a JSON dump with duplicate references" ); is( $@, '', "No die is thrown when the circular ref happens" ); } { my $foo = { 'a' => [ 1, 2 ] }; my $result = eval { JSON::Syck::Dump( [ $foo, $foo ] ) }; is( $result, '[{"a":[1,2]},{"a":[1,2]}]', "A Complex structure should come back on a JSON dump with duplicate references" ); is( $@, '', "No die is thrown when the circular ref happens" ); } YAML-Syck-1.31/t/json-newline.t0000644000000000000000000000021413364413554014652 0ustar rootrootuse JSON::Syck; use Test::More tests => 1; my $dump = JSON::Syck::Dump( { a => "hello\nworld\n" } ); is $dump, q({"a":"hello\nworld\n"}); YAML-Syck-1.31/t/yaml-str-colon-first.t0000644000000000000000000000050613364413554016253 0ustar rootrootuse strict; use Test::More tests => 129; use YAML::Syck; $YAML::Syck::ImplicitUnicode = 1; for ( my $i = 0; $i <= 2**12; $i += 32 ) { my $str = ":" . chr($i); my $dump = Dump( { foo => $str } ); my $load = Load $dump; is( $load->{foo}, $str, "our string #$i starting with a : survived the round-trip" ); } YAML-Syck-1.31/t/load-blessed.t0000644000000000000000000000356213364413554014611 0ustar rootrootuse FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML tests => 11; ok( YAML::Syck->VERSION ); my @tests = ( { msg => 'scalar', object => sub { my $str = "Hello"; return \$str; }, loadblessed_enabled => 'SCALAR', loadblessed_disabled => 'SCALAR', }, { msg => 'scalar blessed as object', object => sub { my $str = "Hello"; return bless \$str, "OBJ_STR"; }, loadblessed_enabled => 'OBJ_STR', loadblessed_disabled => 'SCALAR', }, { msg => 'array ref blessed as object', object => sub { my $ar = [ 'hello', 'world' ]; return bless $ar, "OBJ_ARRAY"; }, loadblessed_enabled => 'OBJ_ARRAY', loadblessed_disabled => 'ARRAY', }, { msg => 'regexp blessed as object', object => sub { my $regex = qr(xxyy); return bless $regex, "MY_REGEXP"; }, loadblessed_enabled => 'MY_REGEXP', loadblessed_disabled => 'Regexp', perl_version => 5.008 }, { msg => 'code blessed as object', object => sub { my $code = sub { return localtime() }; return bless $code, "MY_CODE"; }, loadblessed_enabled => 'MY_CODE', loadblessed_disabled => 'CODE', } ); foreach my $t (@tests) { SKIP: { Test::More::skip "only for perl >= $t->{perl_version}", 2 if $t->{perl_version} && $] < $t->{perl_version}; $YAML::Syck::LoadBlessed = 1; is ref Load( Dump( $t->{object}->() ) ) => $t->{loadblessed_enabled}, "$t->{msg} [ LoadBlessed = 1 ]"; $YAML::Syck::LoadBlessed = 0; is ref Load( Dump( $t->{object}->() ) ) => $t->{loadblessed_disabled}, "$t->{msg} [ LoadBlessed = 0 ]"; } } exit; YAML-Syck-1.31/t/json-dumpinto.t0000644000000000000000000000102513364413554015051 0ustar rootrootuse Test::More; use JSON::Syck qw(DumpInto Dump); plan tests => 7; sub same { my ($data) = @_; my $buf; DumpInto( \$buf, $data ); is( $buf, Dump($data) ); } same(42); # 1 same( \42 ); # 2 same(undef); # 3 same( { foo => [qw] } ); # 4 { my $buf; DumpInto( \$buf, 1 ); is( $buf, Dump(1) ); # 5 DumpInto( \$buf, 2 ); is( $buf, ( Dump(1) . Dump(2) ) ); # 6 } { my $buf = "HEWWO "; DumpInto( \$buf, 42 ); is( $buf, ( "HEWWO " . Dump(42) ) ); # 7 } YAML-Syck-1.31/t/yaml-dumpinto.t0000644000000000000000000000153213364413554015045 0ustar rootrootuse Test::More; use YAML::Syck qw(DumpInto); plan tests => 8; { my $buf; DumpInto( \$buf, 42 ); is( $buf, "--- 42\n" ); # 1 } { my $buf; DumpInto( \$buf, \42 ); is( $buf, "--- !!perl/ref \n=: 42\n" ); } { my $buf; DumpInto( \$buf, undef ); is( $buf, "--- ~\n" ); # 3 } { my $buf; DumpInto( \$buf, { foo => [qw] } ); is( $buf, "--- \nfoo: \n - bar\n - baz\n" ); # 4 } { my $buf; DumpInto( \$buf, 1, 2, undef, 3 ); is( $buf, "--- 1\n--- 2\n--- ~\n--- 3\n" ); # 5 } { my $buf; DumpInto( \$buf, 1 ); is( $buf, "--- 1\n" ); # 6 DumpInto( \$buf, 2 ); is( $buf, "--- 1\n--- 2\n" ); # 7 } { my $buf = "HEWWO\n"; DumpInto( \$buf, 42 ); is( $buf, "HEWWO\n--- 42\n" ); # 8 } YAML-Syck-1.31/t/2-scalars.t0000644000000000000000000001724413364413554014044 0ustar rootrootuse FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML tests => 134; ok( YAML::Syck->VERSION, "YAML::Syck has a version and is loaded" ); is( Dump(42), "--- 42\n", 'Dump a simple number' ); is( Load("--- 42\n"), 42, "Load a simple number"); is( Dump( \42 ), "--- !!perl/ref \n=: 42\n", "A pointer to 42 dumps" ); is( ${ Load("--- !!perl/ref \n=: 42\n") }, 42, "A pointer to 42 loads" ); my $x; $x = \$x; is( Dump($x), "--- &1 !!perl/ref \n=: *1\n", "A Circular Reference Loads." ); is( Dump( scalar Load( Dump($x) ) ), "--- &1 !!perl/ref \n=: *1\n", "A Circular Reference Round Trips." ); $YAML::Syck::DumpCode = 0; is( Dump( sub { 42 } ), "--- !!perl/code: '{ \"DUMMY\" }'\n" ); $YAML::Syck::DumpCode = 1; TODO: { local $TODO = "5.6 can't do code references in Syck right now" if ( $] < 5.007 ); Test::More::like( Dump( sub { 42 } ), qr#--- !!perl/code.*?{.*?42.*?}$#s ); } $YAML::Syck::LoadCode = 0; { my $not_sub = Load("--- !!perl/code:Some::Class '{ \"foo\" . shift }'\n"); is( ref $not_sub, "Some::Class" ); is( $not_sub->("bar"), undef ); } { my $sub = Load("--- !!perl/code '{ \"foo\" . shift }'\n"); is( ref $sub, "CODE" ); is( $sub->("bar"), undef ); } my $like_yaml_pm = 0; $YAML::Syck::LoadCode = 0; ok( my $not_sub = Load("--- !!perl/Class '{ \"foo\" . shift }'\n") ); if ($like_yaml_pm) { is( ref($not_sub), "code" ); is( eval { $$not_sub }, '{ "foo" . shift }' ); } else { is( $not_sub, '{ "foo" . shift }' ); ok(1); # stick with the plan } $YAML::Syck::LoadCode = 1; my $sub = Load("--- !!perl/code: '{ \"foo\" . \$_[0] }'\n"); ok( defined $sub ); is( ref($sub), "CODE" ); is( eval { $sub->("bar") }, "foobar" ); is( $@, "", "no error" ); $YAML::Syck::LoadCode = $YAML::Syck::DumpCode = 0; $YAML::Syck::UseCode = $YAML::Syck::UseCode = 1; TODO: { local $TODO; $TODO = "5.6 can't do code references in Syck right now" if ( $] < 5.007 ); is( eval { Load( Dump( sub { "foo" . shift } ) )->("bar"); }, "foobar" ); $TODO = ''; is( $@, "", "no error" ); $TODO = "5.6 can't do code references in Syck right now" if ( $] < 5.007 ); is( eval { Load( Dump( sub { shift()**3 } ) )->(3); }, 27 ); } is( Dump(undef), "--- ~\n" ); is( Dump('~'), "--- \'~\'\n" ); is( Dump('a:'), "--- \"a:\"\n" ); is( Dump('a: '), "--- \"a: \"\n" ); is( Dump('a '), "--- \"a \"\n" ); is( Dump('a: b'), "--- \"a: b\"\n" ); is( Dump('a:b'), "--- a:b\n" ); is( Load("--- ~\n"), undef ); is( Load("---\n"), undef ); is( Load("--- ''\n"), '' ); my $h = { bar => [qw] }; $h->{foo} = $h->{bar}; is( Dump($h), << '.'); --- bar: &1 - baz - troz foo: *1 . my $r; $r = \$r; is( Dump($r), << '.'); --- &1 !!perl/ref =: *1 . is( Dump( scalar Load( Dump($r) ) ), << '.'); --- &1 !!perl/ref =: *1 . # RT #17223 my $y = YAML::Syck::Load("SID:\n type: fixed\n default: ~\n"); eval { $y->{SID}{default} = 'abc' }; is( $y->{SID}{default}, 'abc' ); is( Load("--- true\n"), "true" ); is( Load("--- false\n"), "false" ); $YAML::Syck::ImplicitTyping = $YAML::Syck::ImplicitTyping = 1; is( Load("--- true\n"), 1 ); is( Load("--- false\n"), '' ); # Various edge cases at grok_number boundary is( Load("--- 42949672\n"), 42949672 ); is( Load("--- -42949672\n"), -42949672 ); is( Load("--- 429496729\n"), 429496729 ); is( Load("--- -429496729\n"), -429496729 ); is( Load("--- 4294967296\n"), 4294967296 ); is( Load("--- -4294967296\n"), -4294967296 ); # RT #18752 my $recurse1 = << '.'; --- &1 Foo: parent: *1 Troz: parent: *1 . is( Dump( scalar Load($recurse1) ), $recurse1, 'recurse 1' ); # We wanna verify the circular ref but we can't garuntuee numbering after 5.18.0 changed the hash algorithm my $recurse2 = << '.'; --- &1 Bar: parent: *1 Baz: parent: *1 Foo: parent: *1 Troz: parent: *1 Zort: &2 Poit: parent: *2 parent: *1 . my $recurse2want = qr{^---\s\&(\d+)\s*\n Bar:\s*\n \s\sparent:\s*\*\1\n Baz:\s*\n \s\sparent:\s*\*\1\n Foo:\s*\n \s\sparent:\s*\*\1\n Troz:\s*\n \s\sparent:\s*\*\1\n Zort:\s&(?!\1)(\d+)\s*\n \s\sPoit:\s\n \s\s\s\sparent:\s+\*\2\n \s\sparent:\s+\*\1 }xms; like( Dump( scalar Load($recurse2) ), $recurse2want, 'recurse 2' ); is( Dump( 1, 2, 3 ), "--- 1\n--- 2\n--- 3\n" ); is( "@{[Load(Dump(1, 2, 3))]}", "1 2 3" ); $YAML::Syck::ImplicitBinary = $YAML::Syck::ImplicitBinary = 1; is( Dump("\xff\xff"), "--- !binary //8=\n" ); is( Load("--- !binary //8=\n"), "\xff\xff" ); is( Dump("ascii"), "--- ascii\n" ); is( Dump("This is Perl 6 User's Golfing System\n"), q[--- "This is Perl 6 User's Golfing System\n"] . "\n" ); $YAML::Syck::SingleQuote = $YAML::Syck::SingleQuote = 1; is( Dump("This is Perl 6 User's Golfing System\n"), qq[--- 'This is Perl 6 User''s Golfing System\n\n'\n] ); is( Dump('042'), "--- '042'\n" ); roundtrip('042'); roundtrip("This\nis\na\ntest"); roundtrip("Newline\n"); roundtrip(" "); roundtrip("\n"); roundtrip("S p a c e"); roundtrip("Space \n Around"); roundtrip("042"); roundtrip("0x42"); roundtrip("0.42"); roundtrip(".42"); roundtrip("1,000,000"); roundtrip("1e+6"); roundtrip("10e+6"); # If implicit typing is on, quote strings corresponding to implicit boolean and null values $YAML::Syck::SingleQuote = 0; is( Dump('N'), "--- 'N'\n" ); is( Dump('NO'), "--- 'NO'\n" ); is( Dump('No'), "--- 'No'\n" ); is( Dump('no'), "--- 'no'\n" ); is( Dump('y'), "--- 'y'\n" ); is( Dump('YES'), "--- 'YES'\n" ); is( Dump('Yes'), "--- 'Yes'\n" ); is( Dump('yes'), "--- 'yes'\n" ); is( Dump('TRUE'), "--- 'TRUE'\n" ); is( Dump('false'), "--- 'false'\n" ); is( Dump('off'), "--- 'off'\n" ); is( Dump('null'), "--- 'null'\n" ); is( Dump('Null'), "--- 'Null'\n" ); is( Dump('NULL'), "--- 'NULL'\n" ); is( Dump('oN'), "--- oN\n" ); # invalid case is( Dump('oFF'), "--- oFF\n" ); # invalid case is( Dump('nULL'), "--- nULL\n" ); # invalid case # RT 52432 - '... X' my $bad_hash = { '... X' => '' }; my $bad_hash_should = "--- \n... X: ''\n"; TODO: { local $TODO; $TODO = "roundtrip is breaking for this right now: '$bad_hash_should'"; roundtrip($bad_hash); } is( Dump( { foo => "`bar" } ), qq{--- \nfoo: "`bar"\n}, 'RT 47944 - back quote is a reserved character' ); # quoted number corner cases: foreach (qw/1 2 3 1.0 1.0000 1.00004 2.2 3.7 42.0 0.123 0.0042 0...02 98765432109123 987654321091234 -98765432109123/) { roundtrip($_); } # Un-quoted number corner cases: foreach ( 1, 2, 3, 1.0, 1.0000, 1.00004, 2.2, 3.7, 42.0, 0.123, 0.0042, 0, 1, 98765432109123, 987654321091234 - 98765432109123 ) { roundtrip($_); } # Simple integers dump without quotes foreach ( 1, 2, 3, 0, -1, -2, -3 ) { is( Dump($_), "--- $_\n", "Dumped version of file is unquoted" ); } is( Dump('0x10'), "--- 0x10\n", "hex Dump preserves as string" ); is( Load("--- '0x10'\n"), "0x10", "hex Load preserves as string" ); is( Dump('080'), "--- '080'\n", "oct Dump preserves by quoting" ); is( Load("--- '080'\n"), "080", "oct Load preserves by quoting" ); is( Dump('00'), "--- '00'\n", "00 Dump preserves by quoting" ); is( Load("--- '00'\n"), "00", "00 Load preserves by quoting" ); # RT 54780 - double quoted loading style TODO: { my $input = q{--- "content\ \ string\n\ other\ \ content\n\ \ \nnew\n"}; my $expected = q{content string other content new }; local $TODO = "not handling double quoted style right"; is( Load($input), $expected, "RT 54780 - Wrong loading of YAML with double quoted style" ); } YAML-Syck-1.31/t/json-crlf.t0000644000000000000000000000124313364413554014142 0ustar rootrootuse strict; use FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML (); use Test::More tests => 6; use JSON::Syck; { $JSON::Syck::SingleQuote = 0; my $cr = JSON::Syck::Dump( { foo => "\r" } ); like $cr, qr/"\\r"/; my $lf = JSON::Syck::Dump( { foo => "\n" } ); like $lf, qr/"\\n"/; my $crlf = JSON::Syck::Dump( { foo => "\r\n" } ); like $crlf, qr/"\\r\\n"/; } { $JSON::Syck::SingleQuote = 1; my $cr = JSON::Syck::Dump( { foo => "\r" } ); like $cr, qr/'\\r'/; my $lf = JSON::Syck::Dump( { foo => "\n" } ); like $lf, qr/'\\n'/; my $crlf = JSON::Syck::Dump( { foo => "\r\n" } ); like $crlf, qr/'\\r\\n'/; } YAML-Syck-1.31/t/4-perl_tag_scheme.t0000644000000000000000000000453013364413554015531 0ustar rootrootuse FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML tests => 18; ok( YAML::Syck->VERSION ); #use YAML; #use Test::More 'no_plan'; # This file is based on pyyaml wiki entry for PerlTagScheme, and Ingy's # guidance. # http://pyyaml.org/wiki/PerlTagScheme says: # # !!perl/hash # hash reference # !!perl/array # array reference # !!perl/scalar # scalar reference # !!perl/code # code reference # !!perl/io # io reference # !!perl/glob # a glob (not a ref) # !!perl/regexp # a regexp (not a ref) # !!perl/ref # a container ref to any of the above # # All of the above types can be blessed: # # !!perl/hash:Foo::Bar # hash ref blessed with 'Foo::Bar' # !!perl/glob:Foo::Bar # glob blessed with 'Foo::Bar' # sub yaml_is { my ( $yaml, $expected, @args ) = @_; $yaml =~ s/\s+\n/\n/gs; @_ = ( $yaml, $expected, @args ); goto &is; } { my $hash = { foo => "bar" }; yaml_is( Dump($hash), "---\nfoo: bar\n" ); bless $hash, "Foo::Bar"; yaml_is( Dump($hash), "--- !!perl/hash:Foo::Bar\nfoo: bar\n" ); } { my $scalar = "foo"; yaml_is( Dump($scalar), "--- foo\n" ); my $ref = \$scalar; yaml_is( Dump($ref), "--- !!perl/ref\n=: foo\n" ); bless $ref, "Foo::Bar"; yaml_is( Dump($ref), "--- !!perl/scalar:Foo::Bar foo\n" ); } { my $hash = { foo => "bar" }; my $deep_scalar = \$hash; yaml_is( Dump($deep_scalar), "--- !!perl/ref\n=:\n foo: bar\n" ); bless $deep_scalar, "Foo::Bar"; yaml_is( Dump($deep_scalar), "--- !!perl/ref:Foo::Bar\n=:\n foo: bar\n" ); } { my $array = [ 23, 42 ]; yaml_is( Dump($array), "---\n- 23\n- 42\n" ); bless $array, "Foo::Bar"; yaml_is( Dump($array), "--- !!perl/array:Foo::Bar\n- 23\n- 42\n" ); } { # FIXME regexes my $regex = qr/a(b|c)d/; #print Dump($regex); bless $regex, "Foo::bar"; #print Dump($regex); } { my $hash = Load("--- !!perl/hash\nfoo: bar\n"); is( ref($hash), "HASH" ); is( $hash->{foo}, "bar" ); } { my $hash = Load("--- !!perl/hash:Foo::Bar\nfoo: bar\n"); is( ref($hash), "Foo::Bar" ); is( $hash->{foo}, "bar" ); } { my $array = Load("--- !!perl/array\n- 42\n- 3\n"); is( ref($array), "ARRAY" ); is( $array->[0], 42 ); } { my $array = Load("--- !!perl/array:Foo::Bar\n- 42\n- 3\n"); is( ref($array), "Foo::Bar" ); is( $array->[0], 42 ); } YAML-Syck-1.31/t/yaml-implicit-warnings.t0000644000000000000000000000031613364413554016645 0ustar rootrootuse strict; use warnings; use YAML::Syck; use Test::More 'no_plan'; my $warnings; BEGIN { $SIG{__WARN__} = sub { $warnings .= "@_" } } $YAML::Syck::ImplicitUnicode = 1; ok !$warnings, "no warnings"; YAML-Syck-1.31/t/yaml-tie.t0000644000000000000000000000231113364413554013763 0ustar rootrootuse strict; use Test::More tests => 6; use YAML::Syck; use Tie::Hash; { my %h; my $rh = \%h; %h = ( a => 1, b => '2', c => 3.1415, d => 4 ); bless $rh => 'Tie::StdHash'; is( Dump($rh), "--- !!perl/hash:Tie::StdHash \na: 1\nb: 2\nc: '3.1415'\nd: 4\n" ); is( Dump( \%h ), "--- !!perl/hash:Tie::StdHash \na: 1\nb: 2\nc: '3.1415'\nd: 4\n" ); } { my %h; my $th = tie %h, 'Tie::StdHash'; %h = ( a => 1, b => '2', c => 3.1415, d => 4 ); TODO: { local $TODO = "Perl 5.8 seems to sometimes coerce ints into strings." unless ( $] > '5.009888' || $] < '5.007' ); is( Dump($th), "--- !!perl/hash:Tie::StdHash \na: 1\nb: 2\nc: '3.1415'\nd: 4\n" ); } TODO: { local $TODO = "Tied hashes don't dump"; is( Dump( \%h ), "--- !!perl/hash:Tie::StdHash \na: 1\nb: 2\nc: '3.1415'\nd: 4\n" ); } } { my %h; my $th = tie %h, 'Tie::StdHash'; $h{a} = 1; $h{b} = '2'; $h{c} = 3.1415; $h{d} = 4; is( Dump($th), "--- !!perl/hash:Tie::StdHash \na: 1\nb: 2\nc: '3.1415'\nd: 4\n" ); TODO: { local $TODO = "Tied hashes don't dump"; is( Dump( \%h ), "--- !!perl/hash:Tie::StdHash \na: 1\nb: 2\nc: '3.1415'\nd: 4\n" ); } } YAML-Syck-1.31/t/json-null.t0000644000000000000000000000040613364413554014166 0ustar rootrootuse strict; use FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML (); use Test::More tests => 2; use JSON::Syck; my $dat = JSON::Syck::Dump( { foo => undef } ); like $dat, qr/null/; $dat = JSON::Syck::Dump( { foo => !1 } ); unlike $dat, qr/"foo":}/; YAML-Syck-1.31/t/leak.t0000644000000000000000000000660313364413554013166 0ustar rootroot#!/sw/bin/perl -w use strict; use YAML::Syck; use Test::More tests => 11; SKIP: { eval { require Devel::Leak; require 5.8.9; 1; } or skip( "Devel::Leak not installed or perl too old", 11 ); # check if arrays leak my $yaml = q{--- blah }; require Symbol; my $handle = Symbol::gensym(); my $diff; # For some reason we have to do a full test run of this loop and the # Devel::Leak test before it's stable. The first time diff ends up # being -2. This is probably Devel::Leak wonkiness. my $before = Devel::Leak::NoteSV($handle); foreach ( 1 .. 100 ) { Load($yaml); } $diff = Devel::Leak::NoteSV($handle) - $before; $before = Devel::Leak::NoteSV($handle); foreach ( 1 .. 100 ) { Load($yaml); } $diff = Devel::Leak::NoteSV($handle) - $before; is( $diff, 0, "No leaks - array" ); # Check if hashess leak $yaml = q{--- result: test }; $before = Devel::Leak::NoteSV($handle); foreach ( 1 .. 100 ) { Load($yaml); } $diff = Devel::Leak::NoteSV($handle) - $before; is( $diff, 0, "No leaks - hash" ); # Check if subs leak $YAML::Syck::UseCode = 1; $yaml = q#--- result: !perl/code: '{ 42 + $_[0] }' #; # Initial load to offset one-time load cost of B::Deparse Load($yaml); $before = Devel::Leak::NoteSV($handle); foreach ( 1 .. 100 ) { Load($yaml); } # Load in list context again foreach ( 1 .. 100 ) { () = Load($yaml); } $diff = Devel::Leak::NoteSV($handle) - $before; is( $diff, 0, "No leaks - code" ); $yaml = q{--- a: b c: - d - e ! }; ok( !eval { Load($yaml) }, "Load failed (expected)" ); $before = Devel::Leak::NoteSV($handle); eval { Load($yaml) } for ( 1 .. 10 ); $diff = Devel::Leak::NoteSV($handle) - $before; is( $diff, 0, "No leaks - Load failure" ); $yaml = q#--- result: !perl/code: '{ 42 + + 54ih a; $" }' #; { local $SIG{__WARN__} = sub { }; ok( !eval { Load($yaml) }, "Load failed on code syntax error (expected)" ); $before = Devel::Leak::NoteSV($handle); eval { Load($yaml) } for ( 1 .. 10 ); $diff = Devel::Leak::NoteSV($handle) - $before; local $TODO = "It looks like evals leak, but we're better than Storable" if $diff; is( $diff, 0, "No leaks - Load failure (code)" ); } my $todump = { a => [ { c => { nums => [ '1', '2', '3', '4', '5' ] }, b => 'foo' } ], d => 'e' }; ok( eval { Dump($todump) }, "Dump succeeded" ); $before = Devel::Leak::NoteSV($handle); foreach ( 1 .. 100 ) { Dump($todump); } $diff = Devel::Leak::NoteSV($handle) - $before; is( $diff, 0, "No leaks - Dump" ); $todump = sub { 42 }; ok( eval { Dump($todump) }, "Dump succeeded" ); # For some reason we have to do a full test run of this loop and the # Devel::Leak test before it's stable. The first time diff ends up # being -1. This is probably Devel::Leak wonkiness. foreach ( 1 .. 100 ) { Dump($todump); } $before = Devel::Leak::NoteSV($handle); foreach ( 1 .. 100 ) { Dump($todump); } $diff = Devel::Leak::NoteSV($handle) - $before; local $TODO = "It looks like evals leak, but we're better than Storable" if $diff; is( $diff, 0, "No leaks - Dump code" ); } YAML-Syck-1.31/t/yaml-utf.t0000644000000000000000000000127113364413554014004 0ustar rootrootuse strict; use warnings; use utf8; use FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML (); use Test::More tests => 3; use YAML::Syck; { # There was bug that caused Syck no to quote unprintables # when a wide character was present. my $dump; local $YAML::Syck::ImplicitUnicode = 1; my $thing = "♥\000"; $dump = YAML::Syck::Dump($thing); is( $dump, '--- "♥\0"' . "\n" ); } { my $dump; local $YAML::Syck::ImplicitUnicode = 1; my $thing = "♥"; $dump = YAML::Syck::Dump($thing); is( $dump, '--- ♥' . "\n" ); } { my $dump; my $thing = "\000"; $dump = YAML::Syck::Dump($thing); is( $dump, '--- "\0"' . "\n" ); } YAML-Syck-1.31/t/11-loadfile.t0000644000000000000000000000537013364413554014250 0ustar rootrootuse FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML; use Test::More; chdir $FindBin::RealBin; unless ( -w $FindBin::RealBin ) { plan skip_all => "Can't write to $FindBin::RealBin"; exit; } plan tests => 12; *::LoadFile = *YAML::Syck::LoadFile; # remember where *DATA begins my $pos = tell(DATA); die "tell(DATA) failed: $!" unless $pos != -1; # read via a GLOB is( LoadFile(*DATA), "a simple scalar", 'LoadFile(*DATA) works' ); # rewind *DATA seek( DATA, $pos, 0 ) == 1 or die "rewind *DATA failed: $!"; # read via a GLOB ref is( LoadFile( \*DATA ), "a simple scalar", 'LoadFile(\*DATA) works' ); sub write_file { my ( $fh, $contents ) = @_; local *H; open( H, "> $fh" ) or die $!; print H $contents; close(H); } # write YAML to a file write_file( 'loadfile.yml', "---\na simple scalar" ); write_file( 'emptyfile.yml', "" ); END { unlink 'loadfile.yml' or die "can't delete 'loadfile.yml': $!" if -e 'loadfile.yml'; unlink 'emptyfile.yml' or die "can't delete 'emptyfile.yml': $!" if -e 'emptyfile.yml'; } # using file names is( LoadFile('loadfile.yml'), "a simple scalar", 'LoadFile works with file names' ); # read via IO::File { require IO::File; my $h = IO::File->new('loadfile.yml'); is( LoadFile($h), "a simple scalar", 'LoadFile works with IO::File' ); close($h); } # read via indirect file handles SKIP: { skip "indirect file handles require 5.6 or later", 1 unless $] >= 5.006000; open( my $h, 'loadfile.yml' ); is( LoadFile($h), "a simple scalar", 'LoadFile works with indirect filehandles' ); close($h); } # read via ordinary filehandles { local *H; open( H, 'loadfile.yml' ); is( LoadFile(*H), "a simple scalar", 'LoadFile works with ordinary filehandles' ); close(H); } # read via ordinary filehandles (refs) { local *H; open( H, 'loadfile.yml' ); is( LoadFile( \*H ), "a simple scalar", 'LoadFile works with glob refs' ); close(H); } # load from "in memory" file SKIP: { skip "in-memory files require 5.8 or later", 1 unless $] >= 5.00800; my $string = 'a simple scalar'; open( my $h, '<', \$string ); is( LoadFile($h), "a simple scalar", 'LoadFile works with in-memory files' ); close($h); } { # Load empty file fails my $yml = eval { LoadFile('emptyfile.yml') }; like( $@, qr/^\'emptyfile.yml' is empty or non-existent at/ms, "LoadFile dies loading an empty file" ); is( $yml, undef, "LoadFile returns undef loading an empty file" ); } { # Load empty file handle succeeds open( my $fh, '<', 'emptyfile.yml' ) or die; my $yml = eval { LoadFile($fh) }; ok( !$@, "No failure reading an empty file handle" ); is( $yml, undef, "LoadFile returns undef loading an empty file" ); } __DATA__ --- a simple scalar YAML-Syck-1.31/t/TestYAML.pm0000644000000000000000000000107613364413554014024 0ustar rootrootpackage TestYAML; BEGIN { $ENV{PERL_DL_NONLAZY} = 0 } use strict; use Test::More; use YAML::Syck; sub import { shift; @_ or return; plan @_; *::ok = *ok; *::like = *like; *::is = *is; *::is_deeply = *is_deeply; *::roundtrip = *roundtrip; *::Dump = *YAML::Syck::Dump; *::Load = *YAML::Syck::Load; } sub roundtrip { @_ = ( YAML::Syck::Load( YAML::Syck::Dump( $_[0] ) ), $_[0] ); goto &main::is; } 1; #use Test::YAML 0.51 -Base; # #$Test::YAML::YAML = 'YAML::Syck'; #Test::YAML->load_yaml_pm; YAML-Syck-1.31/t/3-objects.t0000644000000000000000000000727013364413554014044 0ustar rootrootuse FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML tests => 51, ( ( $] < 5.008 ) ? ( todo => [ 19 .. 20, 26 .. 29 ] ) : () ); ok( YAML::Syck->VERSION ); is( Dump( bless( {}, 'foo' ) ), "--- !!perl/hash:foo {}\n\n" ); sub ref_ok { my $x = Load("--- $_[0] {a: b}\n"); is( ref($x), $_[1], "ref - $_[0]" ); is( $x->{a}, 'b', "data - $_[0]" ); } sub run_ref_ok { ref_ok( splice( @_, 0, 2 ) ) while @_; } run_ref_ok( qw( !!perl/hash:foo foo !perl/foo foo !hs/Foo hs::Foo !haskell.org/Foo haskell.org::Foo !haskell.org/^Foo haskell.org::Foo !!perl HASH !!moose moose !ruby/object:Test::Bear ruby::object:Test::Bear ) ); # perl 5.13.5 and later has fb85c04, which changed the regex # stringification syntax. This is also valid. use constant REGEX_CARET => qr// =~ /\Q(?^\E/; my $rx = qr/123/; if (REGEX_CARET) { ok( 1, "Testing regexes with the >=5.13.5 caret syntax" ); is( Dump($rx), "--- !!perl/regexp (?^:123)\n" ); is( Dump( Load( Dump($rx) ) ), "--- !!perl/regexp (?^:(?^:123))\n" ); } else { ok( 1, "Testing regexes with the old <5.13.5 syntax" ); is( Dump($rx), "--- !!perl/regexp (?-xism:123)\n" ); is( Dump( Load( Dump($rx) ) ), "--- !!perl/regexp (?-xism:123)\n" ); } SKIP: { Test::More::skip "5.6 doesn't support printing regexes", 2 if ( $] < 5.007 ); my $rx_obj = bless qr/123/i => 'Foo'; if (REGEX_CARET) { is( Dump($rx_obj), "--- !!perl/regexp:Foo (?^i:123)\n" ); is( Dump( Load( Dump($rx_obj) ) ), "--- !!perl/regexp:Foo (?^:(?^i:123))\n" ); } else { is( Dump($rx_obj), "--- !!perl/regexp:Foo (?i-xsm:123)\n" ); is( Dump( Load( Dump($rx_obj) ) ), "--- !!perl/regexp:Foo (?i-xsm:123)\n" ); } } my $obj = bless( \( my $undef ) => 'Foo' ); is( Dump($obj), "--- !!perl/scalar:Foo ~\n" ); is( Dump( Load( Dump($obj) ) ), "--- !!perl/scalar:Foo ~\n" ); is( Dump( bless( { 1 .. 10 }, 'foo' ) ), "--- !!perl/hash:foo \n1: 2\n3: 4\n5: 6\n7: 8\n9: 10\n" ); $YAML::Syck::UseCode = 1; { my $hash = Load( Dump( bless( { 1 .. 4 }, "code" ) ) ); is( ref($hash), "code", "blessed to code" ); is( eval { $hash->{1} }, 2, "it's a hash" ); } TODO: { my $sub = eval { Load( Dump( bless( sub { 42 }, "foobar" ) ) ); }; is( ref($sub), "foobar", "blessed to foobar" ); local $TODO = "5.6 can't do code references in Syck right now" if ( $] < 5.007 ); is( eval { $sub->() }, 42, "it's a CODE" ); } TODO: { my $sub = eval { Load( Dump( bless( sub { 42 }, "code" ) ) ); }; is( ref($sub), "code", "blessed to code" ); local $TODO = "5.6 can't do code references in Syck right now" if ( $] < 5.007 ); is( eval { $sub->() }, 42, "it's a CODE" ); } $YAML::Syck::LoadBlessed = 0; run_ref_ok( qw( !!perl/hash:foo HASH !perl/foo HASH !hs/Foo HASH !haskell.org/Foo HASH !haskell.org/^Foo HASH !!perl HASH !!moose HASH !ruby/object:Test::Bear HASH ) ); my $hash = { a => [ 42, [], {} ], h => { 53, 12 } }; my $loaded = Load( Dump($hash) ); is_deeply $loaded => $hash, "Deep hash round trips"; my $blesshash = bless { a => [ 42, [], bless( {}, 'foo' ) ], h => { 53, 12 } }, 'bar'; my $stripped = Load( Dump($blesshash) ); is_deeply $stripped => $hash, "Deep hash round trips and strip blessings"; $YAML::Syck::LoadBlessed = 1; my $not_stripped = Load( Dump($blesshash) ); is_deeply $not_stripped => $blesshash, "Deep hash round trips and doesn't strips blessings"; exit; YAML-Syck-1.31/t/json-basic.t0000644000000000000000000000615513364413554014304 0ustar rootrootuse strict; use FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML (); use Data::Dumper; use Test::More; use JSON::Syck; my $HAS_JSON = 0; BEGIN { unless ( defined &utf8::encode ) { plan skip_all => 'No Unicode support'; exit; } eval { require JSON; $HAS_JSON = 1 }; if ( $HAS_JSON && $JSON::VERSION >= 2 && $JSON::VERSION < 2.11 ) { plan skip_all => 'JSON compatibility broken since JSON 2.0'; exit; } } use Storable; $Data::Dumper::Indent = 0; $Data::Dumper::Terse = 1; my @tests = ( '"foo"', '[1, 2, 3]', '[1, 2, 3]', '2', '"foo\'bar"', '[1,2,3]', '{"foo": "bar"}', '{"foo":"bar"}', '[{"foo": 2}, {"foo": "bar"}]', qq("\xe5\xaa\xbe"), 'null', '{"foo":null}', '""', '[null,null]', '["",null]', '{"foo":""}', '["\"://\""]', '"~foo"', { TEST => '"\/"', TODO => "backslashed char not working yet" }, # escaped solidus '"\""', { TEST => '"\b"', TODO => "backslashed char not working yet" }, { TEST => '"\f"', TODO => "backslashed char not working yet" }, { TEST => '"\n"', TODO => "backslashed char not working yet" }, { TEST => '"\r"', TODO => "backslashed char not working yet" }, { TEST => '"\t"', TODO => "backslashed \\t not working yet" }, { TEST => '"\u0001"', TODO => "backslashed \\u not working yet" }, ); plan tests => scalar @tests * ( 2 + $HAS_JSON ) * 2; TODO: { for my $test_orig (@tests) { for my $single_quote ( 0, 1 ) { for my $unicode ( 0, 1 ) { local $JSON::Syck::SingleQuote = $single_quote; local $JSON::Syck::ImplicitUnicode = $unicode; my $test = $test_orig; local $TODO; if ( ref $test eq 'HASH' ) { if ($single_quote or substr($test->{TEST},2,1) =~ m|[u/]|) { $TODO = $test->{TODO}; } $test = $test->{TEST}; } if ($single_quote) { $test =~ s/'/\\'/g; $test =~ s/"/'/g; } my $data = eval { JSON::Syck::Load($test) }; my $json = JSON::Syck::Dump($data); #diag("json: $json"); utf8::encode($json) if !ref($json) && $unicode; # don't bother white spaces for ( $test, $json ) { s/([,:]) /$1/eg; } my $desc = "roundtrip $test -> " . Dumper($data) . " -> $json -> sq:$single_quote utf8:$unicode "; utf8::encode($desc); is $json, $test, $desc; # try parsing the data with JSON.pm if ( $HAS_JSON and !$single_quote ) { $SIG{__WARN__} = sub { 1 }; utf8::encode($data) if defined($data) && !ref($data) && $unicode; my $data_pp = eval { JSON::jsonToObj($json) }; is_deeply $data_pp, $data, "compatibility with JSON.pm $test"; } } } } } YAML-Syck-1.31/t/json-indent.t0000644000000000000000000000034313364413554014475 0ustar rootrootuse strict; use FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML (); use JSON::Syck; use Test::More tests => 1; my $str = "foo\nbar\nbaz\n"; my $json = JSON::Syck::Dump( { str => $str } ); unlike $json, qr/^ bar/m; YAML-Syck-1.31/t/json-empty.t0000644000000000000000000000126213364413554014353 0ustar rootrootuse strict; use FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML (); use Test::More tests => 1; use JSON::Syck; my $data = JSON::Syck::Load( q({"i":{"cid":"123","sid":"123","cd":"","v":"2.0","m":"h01iSTI5"},"r":{"adbox1":{"w":320,"h":200},"adbox2":{"w":320,"h":200},"adbox3":{"w":320,"h":200},"adbox1_info":{"w":320,"h":32},"adbox2_info":{"w":320,"h":32},"adbox3_info":{"w":320,"h":32},"adbox4":{"w":320,"h":200},"adbox5":{"w":320,"h":200},"adbox6":{"w":320,"h":200},"adbox4_info":{"w":320,"h":32},"adbox5_info":{"w":320,"h":32},"adbox6_info":{"w":320,"h":32},"adbox4_pick":{"w":320,"h":32},"adbox5_pick":{"w":320,"h":32},"adbox6_rate":{"w":320,"h":32}}}) ); ok keys %$data; YAML-Syck-1.31/t/meta.t0000644000000000000000000000043013364413554013170 0ustar rootrootuse strict; use warnings; use Test::More tests => 1; use FindBin; use YAML::Syck; my $yaml = YAML::Syck::LoadFile( $FindBin::Bin . '/../META.yml' ); is( $yaml->{'version'}, $YAML::Syck::VERSION, "META.yml file is correct - To regenerate, run: 'make purge; perl Makefile.pl'" ); YAML-Syck-1.31/t/json-minus.t0000644000000000000000000000026713364413554014354 0ustar rootrootuse strict; use FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML (); use JSON::Syck; use Test::More tests => 1; my $data = JSON::Syck::Load('{"i":-2}'); is $data->{i}, -2; YAML-Syck-1.31/t/12-dumpfile.t0000644000000000000000000000416313364413554014276 0ustar rootrootuse FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML; use Test::More; chdir $FindBin::RealBin; unless ( -w $FindBin::RealBin ) { plan skip_all => "Can't write to $FindBin::RealBin"; exit; } plan tests => 6; *::DumpFile = *YAML::Syck::DumpFile; sub file_contents_is { my ( $fn, $expected, $test_name ) = @_; local *FH; open FH, $fn or die $!; my $contents = do { local $/; }; is( $contents, $expected, $test_name ); close FH; } my $scalar = 'a simple scalar'; my $expected_yaml = <new('>dumpfile.yml'); DumpFile( $h, $scalar ); close $h; file_contents_is( 'dumpfile.yml', $expected_yaml, 'DumpFile works with IO::File' ); unlink 'dumpfile.yml' or die $!; } # dump to indirect file handles SKIP: { skip "indirect file handles require 5.6 or later", 1 unless $] >= 5.006000; eval q[ open(my $h, '>', 'dumpfile.yml'); DumpFile($h, $scalar); close $h; file_contents_is('dumpfile.yml', $expected_yaml, 'DumpFile works with indirect file handles'); unlink 'dumpfile.yml' or die $!; ]; } # dump to ordinary filehandles { local *H; open( H, '>dumpfile.yml' ); DumpFile( *H, $scalar ); close(H); file_contents_is( 'dumpfile.yml', $expected_yaml, 'DumpFile works with ordinary file handles' ); unlink 'dumpfile.yml' or die $!; } # dump to ordinary filehandles (refs) { local *H; open( H, '>dumpfile.yml' ); DumpFile( \*H, $scalar ); close(H); file_contents_is( 'dumpfile.yml', $expected_yaml, 'DumpFile works with glob refs' ); unlink 'dumpfile.yml' or die $!; } # dump to "in memory" file SKIP: { skip "in-memory files require 5.8 or later", 1 unless $] >= 5.00800; eval q[ open(my $h, '>', \my $s); DumpFile($h, $scalar); close($h); is($s, $expected_yaml, 'DumpFile works with in-memory files'); ]; } YAML-Syck-1.31/t/json-singlequote.t0000644000000000000000000000152713364413554015560 0ustar rootrootuse strict; use warnings; use FindBin; BEGIN { push @INC, $FindBin::Bin } use TestYAML (); use Test::More tests => 5; use JSON::Syck; { $JSON::Syck::SingleQuote = 1; my $dump; $dump = JSON::Syck::Dump(q{Some string}); is( $dump, q{'Some string'} ); #Test escaping my $thing = q{I'm sorry, Dave.}; $dump = JSON::Syck::Dump($thing); is( JSON::Syck::Load($dump), $thing ); } { $JSON::Syck::SingleQuote = 0; my $dump; $dump = JSON::Syck::Dump(q{Some string}); is( $dump, q{"Some string"} ); #Test escaping my $thing = q{I'm sorry, Dave.}; $dump = JSON::Syck::Dump($thing); is( JSON::Syck::Load($dump), $thing ); } { my $url = 'http://www.pugscode.org'; my $var = JSON::Syck::Load(<<"_EOC_"); { url: '$url' } _EOC_ is $var->{url}, $url, "no extra space in the URL"; } YAML-Syck-1.31/ppport.h0000644000000000000000000052540613364413554013326 0ustar rootroot#if 0 <<'SKIP'; #endif /* ---------------------------------------------------------------------- ppport.h -- Perl/Pollution/Portability Version 3.19 Automatically created by Devel::PPPort running under perl 5.013007. Do NOT edit this file directly! -- Edit PPPort_pm.PL and the includes in parts/inc/ instead. Use 'perldoc ppport.h' to view the documentation below. ---------------------------------------------------------------------- SKIP =pod =head1 NAME ppport.h - Perl/Pollution/Portability version 3.19 =head1 SYNOPSIS perl ppport.h [options] [source files] Searches current directory for files if no [source files] are given --help show short help --version show version --patch=file write one patch file with changes --copy=suffix write changed copies with suffix --diff=program use diff program and options --compat-version=version provide compatibility with Perl version --cplusplus accept C++ comments --quiet don't output anything except fatal errors --nodiag don't show diagnostics --nohints don't show hints --nochanges don't suggest changes --nofilter don't filter input files --strip strip all script and doc functionality from ppport.h --list-provided list provided API --list-unsupported list unsupported API --api-info=name show Perl API portability information =head1 COMPATIBILITY This version of F is designed to support operation with Perl installations back to 5.003, and has been tested up to 5.10.0. =head1 OPTIONS =head2 --help Display a brief usage summary. =head2 --version Display the version of F. =head2 --patch=I If this option is given, a single patch file will be created if any changes are suggested. This requires a working diff program to be installed on your system. =head2 --copy=I If this option is given, a copy of each file will be saved with the given suffix that contains the suggested changes. This does not require any external programs. Note that this does not automagially add a dot between the original filename and the suffix. If you want the dot, you have to include it in the option argument. If neither C<--patch> or C<--copy> are given, the default is to simply print the diffs for each file. This requires either C or a C program to be installed. =head2 --diff=I Manually set the diff program and options to use. The default is to use C, when installed, and output unified context diffs. =head2 --compat-version=I Tell F to check for compatibility with the given Perl version. The default is to check for compatibility with Perl version 5.003. You can use this option to reduce the output of F if you intend to be backward compatible only down to a certain Perl version. =head2 --cplusplus Usually, F will detect C++ style comments and replace them with C style comments for portability reasons. Using this option instructs F to leave C++ comments untouched. =head2 --quiet Be quiet. Don't print anything except fatal errors. =head2 --nodiag Don't output any diagnostic messages. Only portability alerts will be printed. =head2 --nohints Don't output any hints. Hints often contain useful portability notes. Warnings will still be displayed. =head2 --nochanges Don't suggest any changes. Only give diagnostic output and hints unless these are also deactivated. =head2 --nofilter Don't filter the list of input files. By default, files not looking like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped. =head2 --strip Strip all script and documentation functionality from F. This reduces the size of F dramatically and may be useful if you want to include F in smaller modules without increasing their distribution size too much. The stripped F will have a C<--unstrip> option that allows you to undo the stripping, but only if an appropriate C module is installed. =head2 --list-provided Lists the API elements for which compatibility is provided by F. Also lists if it must be explicitly requested, if it has dependencies, and if there are hints or warnings for it. =head2 --list-unsupported Lists the API elements that are known not to be supported by F and below which version of Perl they probably won't be available or work. =head2 --api-info=I Show portability information for API elements matching I. If I is surrounded by slashes, it is interpreted as a regular expression. =head1 DESCRIPTION In order for a Perl extension (XS) module to be as portable as possible across differing versions of Perl itself, certain steps need to be taken. =over 4 =item * Including this header is the first major one. This alone will give you access to a large part of the Perl API that hasn't been available in earlier Perl releases. Use perl ppport.h --list-provided to see which API elements are provided by ppport.h. =item * You should avoid using deprecated parts of the API. For example, using global Perl variables without the C prefix is deprecated. Also, some API functions used to have a C prefix. Using this form is also deprecated. You can safely use the supported API, as F will provide wrappers for older Perl versions. =item * If you use one of a few functions or variables that were not present in earlier versions of Perl, and that can't be provided using a macro, you have to explicitly request support for these functions by adding one or more C<#define>s in your source code before the inclusion of F. These functions or variables will be marked C in the list shown by C<--list-provided>. Depending on whether you module has a single or multiple files that use such functions or variables, you want either C or global variants. For a C function or variable (used only in a single source file), use: #define NEED_function #define NEED_variable For a global function or variable (used in multiple source files), use: #define NEED_function_GLOBAL #define NEED_variable_GLOBAL Note that you mustn't have more than one global request for the same function or variable in your project. Function / Variable Static Request Global Request ----------------------------------------------------------------------------------------- PL_parser NEED_PL_parser NEED_PL_parser_GLOBAL PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL grok_number() NEED_grok_number NEED_grok_number_GLOBAL grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL load_module() NEED_load_module NEED_load_module_GLOBAL my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL my_sprintf() NEED_my_sprintf NEED_my_sprintf_GLOBAL my_strlcat() NEED_my_strlcat NEED_my_strlcat_GLOBAL my_strlcpy() NEED_my_strlcpy NEED_my_strlcpy_GLOBAL newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL newSV_type() NEED_newSV_type NEED_newSV_type_GLOBAL newSVpvn_flags() NEED_newSVpvn_flags NEED_newSVpvn_flags_GLOBAL newSVpvn_share() NEED_newSVpvn_share NEED_newSVpvn_share_GLOBAL pv_display() NEED_pv_display NEED_pv_display_GLOBAL pv_escape() NEED_pv_escape NEED_pv_escape_GLOBAL pv_pretty() NEED_pv_pretty NEED_pv_pretty_GLOBAL sv_2pv_flags() NEED_sv_2pv_flags NEED_sv_2pv_flags_GLOBAL sv_2pvbyte() NEED_sv_2pvbyte NEED_sv_2pvbyte_GLOBAL sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL sv_pvn_force_flags() NEED_sv_pvn_force_flags NEED_sv_pvn_force_flags_GLOBAL sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL vload_module() NEED_vload_module NEED_vload_module_GLOBAL vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL warner() NEED_warner NEED_warner_GLOBAL To avoid namespace conflicts, you can change the namespace of the explicitly exported functions / variables using the C macro. Just C<#define> the macro before including C: #define DPPP_NAMESPACE MyOwnNamespace_ #include "ppport.h" The default namespace is C. =back The good thing is that most of the above can be checked by running F on your source code. See the next section for details. =head1 EXAMPLES To verify whether F is needed for your module, whether you should make any changes to your code, and whether any special defines should be used, F can be run as a Perl script to check your source code. Simply say: perl ppport.h The result will usually be a list of patches suggesting changes that should at least be acceptable, if not necessarily the most efficient solution, or a fix for all possible problems. If you know that your XS module uses features only available in newer Perl releases, if you're aware that it uses C++ comments, and if you want all suggestions as a single patch file, you could use something like this: perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff If you only want your code to be scanned without any suggestions for changes, use: perl ppport.h --nochanges You can specify a different C program or options, using the C<--diff> option: perl ppport.h --diff='diff -C 10' This would output context diffs with 10 lines of context. If you want to create patched copies of your files instead, use: perl ppport.h --copy=.new To display portability information for the C function, use: perl ppport.h --api-info=newSVpvn Since the argument to C<--api-info> can be a regular expression, you can use perl ppport.h --api-info=/_nomg$/ to display portability information for all C<_nomg> functions or perl ppport.h --api-info=/./ to display information for all known API elements. =head1 BUGS If this version of F is causing failure during the compilation of this module, please check if newer versions of either this module or C are available on CPAN before sending a bug report. If F was generated using the latest version of C and is causing failure of this module, please file a bug report using the CPAN Request Tracker at L. Please include the following information: =over 4 =item 1. The complete output from running "perl -V" =item 2. This file. =item 3. The name and version of the module you were trying to build. =item 4. A full log of the build that failed. =item 5. Any other information that you think could be relevant. =back For the latest version of this code, please get the C module from CPAN. =head1 COPYRIGHT Version 3.x, Copyright (c) 2004-2009, Marcus Holland-Moritz. Version 2.x, Copyright (C) 2001, Paul Marquess. Version 1.x, Copyright (C) 1999, Kenneth Albanowski. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO See L. =cut use strict; # Disable broken TRIE-optimization BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if $] >= 5.009004 && $] <= 5.009005 } my $VERSION = 3.19; my %opt = ( quiet => 0, diag => 1, hints => 1, changes => 1, cplusplus => 0, filter => 1, strip => 0, version => 0, ); my($ppport) = $0 =~ /([\w.]+)$/; my $LF = '(?:\r\n|[\r\n])'; # line feed my $HS = "[ \t]"; # horizontal whitespace # Never use C comments in this file! my $ccs = '/'.'*'; my $cce = '*'.'/'; my $rccs = quotemeta $ccs; my $rcce = quotemeta $cce; eval { require Getopt::Long; Getopt::Long::GetOptions(\%opt, qw( help quiet diag! filter! hints! changes! cplusplus strip version patch=s copy=s diff=s compat-version=s list-provided list-unsupported api-info=s )) or usage(); }; if ($@ and grep /^-/, @ARGV) { usage() if "@ARGV" =~ /^--?h(?:elp)?$/; die "Getopt::Long not found. Please don't use any options.\n"; } if ($opt{version}) { print "This is $0 $VERSION.\n"; exit 0; } usage() if $opt{help}; strip() if $opt{strip}; if (exists $opt{'compat-version'}) { my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) }; if ($@) { die "Invalid version number format: '$opt{'compat-version'}'\n"; } die "Only Perl 5 is supported\n" if $r != 5; die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $s >= 1000; $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s; } else { $opt{'compat-version'} = 5; } my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/ ? ( $1 => { ($2 ? ( base => $2 ) : ()), ($3 ? ( todo => $3 ) : ()), (index($4, 'v') >= 0 ? ( varargs => 1 ) : ()), (index($4, 'p') >= 0 ? ( provided => 1 ) : ()), (index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()), } ) : die "invalid spec: $_" } qw( AvFILLp|5.004050||p AvFILL||| CLASS|||n CPERLscope|5.005000||p CX_CURPAD_SAVE||| CX_CURPAD_SV||| CopFILEAV|5.006000||p CopFILEGV_set|5.006000||p CopFILEGV|5.006000||p CopFILESV|5.006000||p CopFILE_set|5.006000||p CopFILE|5.006000||p CopSTASHPV_set|5.006000||p CopSTASHPV|5.006000||p CopSTASH_eq|5.006000||p CopSTASH_set|5.006000||p CopSTASH|5.006000||p CopyD|5.009002||p Copy||| CvPADLIST||| CvSTASH||| CvWEAKOUTSIDE||| DEFSV_set|5.011000||p DEFSV|5.004050||p END_EXTERN_C|5.005000||p ENTER||| ERRSV|5.004050||p EXTEND||| EXTERN_C|5.005000||p F0convert|||n FREETMPS||| GIMME_V||5.004000|n GIMME|||n GROK_NUMERIC_RADIX|5.007002||p G_ARRAY||| G_DISCARD||| G_EVAL||| G_METHOD|5.006001||p G_NOARGS||| G_SCALAR||| G_VOID||5.004000| GetVars||| GvSVn|5.009003||p GvSV||| Gv_AMupdate||| HEf_SVKEY||5.004000| HeHASH||5.004000| HeKEY||5.004000| HeKLEN||5.004000| HePV||5.004000| HeSVKEY_force||5.004000| HeSVKEY_set||5.004000| HeSVKEY||5.004000| HeUTF8||5.011000| HeVAL||5.004000| HvNAMELEN_get|5.009003||p HvNAME_get|5.009003||p HvNAME||| INT2PTR|5.006000||p IN_LOCALE_COMPILETIME|5.007002||p IN_LOCALE_RUNTIME|5.007002||p IN_LOCALE|5.007002||p IN_PERL_COMPILETIME|5.008001||p IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p IS_NUMBER_INFINITY|5.007002||p IS_NUMBER_IN_UV|5.007002||p IS_NUMBER_NAN|5.007003||p IS_NUMBER_NEG|5.007002||p IS_NUMBER_NOT_INT|5.007002||p IVSIZE|5.006000||p IVTYPE|5.006000||p IVdf|5.006000||p LEAVE||| LVRET||| MARK||| MULTICALL||5.011000| MY_CXT_CLONE|5.009002||p MY_CXT_INIT|5.007003||p MY_CXT|5.007003||p MoveD|5.009002||p Move||| NOOP|5.005000||p NUM2PTR|5.006000||p NVTYPE|5.006000||p NVef|5.006001||p NVff|5.006001||p NVgf|5.006001||p Newxc|5.009003||p Newxz|5.009003||p Newx|5.009003||p Nullav||| Nullch||| Nullcv||| Nullhv||| Nullsv||| ORIGMARK||| PAD_BASE_SV||| PAD_CLONE_VARS||| PAD_COMPNAME_FLAGS||| PAD_COMPNAME_GEN_set||| PAD_COMPNAME_GEN||| PAD_COMPNAME_OURSTASH||| PAD_COMPNAME_PV||| PAD_COMPNAME_TYPE||| PAD_DUP||| PAD_RESTORE_LOCAL||| PAD_SAVE_LOCAL||| PAD_SAVE_SETNULLPAD||| PAD_SETSV||| PAD_SET_CUR_NOSAVE||| PAD_SET_CUR||| PAD_SVl||| PAD_SV||| PERLIO_FUNCS_CAST|5.009003||p PERLIO_FUNCS_DECL|5.009003||p PERL_ABS|5.008001||p PERL_BCDVERSION|5.011000||p PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p PERL_HASH|5.004000||p PERL_INT_MAX|5.004000||p PERL_INT_MIN|5.004000||p PERL_LONG_MAX|5.004000||p PERL_LONG_MIN|5.004000||p PERL_MAGIC_arylen|5.007002||p PERL_MAGIC_backref|5.007002||p PERL_MAGIC_bm|5.007002||p PERL_MAGIC_collxfrm|5.007002||p PERL_MAGIC_dbfile|5.007002||p PERL_MAGIC_dbline|5.007002||p PERL_MAGIC_defelem|5.007002||p PERL_MAGIC_envelem|5.007002||p PERL_MAGIC_env|5.007002||p PERL_MAGIC_ext|5.007002||p PERL_MAGIC_fm|5.007002||p PERL_MAGIC_glob|5.011000||p PERL_MAGIC_isaelem|5.007002||p PERL_MAGIC_isa|5.007002||p PERL_MAGIC_mutex|5.011000||p PERL_MAGIC_nkeys|5.007002||p PERL_MAGIC_overload_elem|5.007002||p PERL_MAGIC_overload_table|5.007002||p PERL_MAGIC_overload|5.007002||p PERL_MAGIC_pos|5.007002||p PERL_MAGIC_qr|5.007002||p PERL_MAGIC_regdata|5.007002||p PERL_MAGIC_regdatum|5.007002||p PERL_MAGIC_regex_global|5.007002||p PERL_MAGIC_shared_scalar|5.007003||p PERL_MAGIC_shared|5.007003||p PERL_MAGIC_sigelem|5.007002||p PERL_MAGIC_sig|5.007002||p PERL_MAGIC_substr|5.007002||p PERL_MAGIC_sv|5.007002||p PERL_MAGIC_taint|5.007002||p PERL_MAGIC_tiedelem|5.007002||p PERL_MAGIC_tiedscalar|5.007002||p PERL_MAGIC_tied|5.007002||p PERL_MAGIC_utf8|5.008001||p PERL_MAGIC_uvar_elem|5.007003||p PERL_MAGIC_uvar|5.007002||p PERL_MAGIC_vec|5.007002||p PERL_MAGIC_vstring|5.008001||p PERL_PV_ESCAPE_ALL|5.009004||p PERL_PV_ESCAPE_FIRSTCHAR|5.009004||p PERL_PV_ESCAPE_NOBACKSLASH|5.009004||p PERL_PV_ESCAPE_NOCLEAR|5.009004||p PERL_PV_ESCAPE_QUOTE|5.009004||p PERL_PV_ESCAPE_RE|5.009005||p PERL_PV_ESCAPE_UNI_DETECT|5.009004||p PERL_PV_ESCAPE_UNI|5.009004||p PERL_PV_PRETTY_DUMP|5.009004||p PERL_PV_PRETTY_ELLIPSES|5.010000||p PERL_PV_PRETTY_LTGT|5.009004||p PERL_PV_PRETTY_NOCLEAR|5.010000||p PERL_PV_PRETTY_QUOTE|5.009004||p PERL_PV_PRETTY_REGPROP|5.009004||p PERL_QUAD_MAX|5.004000||p PERL_QUAD_MIN|5.004000||p PERL_REVISION|5.006000||p PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p PERL_SCAN_DISALLOW_PREFIX|5.007003||p PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p PERL_SCAN_SILENT_ILLDIGIT|5.008001||p PERL_SHORT_MAX|5.004000||p PERL_SHORT_MIN|5.004000||p PERL_SIGNALS_UNSAFE_FLAG|5.008001||p PERL_SUBVERSION|5.006000||p PERL_SYS_INIT3||5.006000| PERL_SYS_INIT||| PERL_SYS_TERM||5.011000| PERL_UCHAR_MAX|5.004000||p PERL_UCHAR_MIN|5.004000||p PERL_UINT_MAX|5.004000||p PERL_UINT_MIN|5.004000||p PERL_ULONG_MAX|5.004000||p PERL_ULONG_MIN|5.004000||p PERL_UNUSED_ARG|5.009003||p PERL_UNUSED_CONTEXT|5.009004||p PERL_UNUSED_DECL|5.007002||p PERL_UNUSED_VAR|5.007002||p PERL_UQUAD_MAX|5.004000||p PERL_UQUAD_MIN|5.004000||p PERL_USE_GCC_BRACE_GROUPS|5.009004||p PERL_USHORT_MAX|5.004000||p PERL_USHORT_MIN|5.004000||p PERL_VERSION|5.006000||p PL_DBsignal|5.005000||p PL_DBsingle|||pn PL_DBsub|||pn PL_DBtrace|||pn PL_Sv|5.005000||p PL_bufend|5.011000||p PL_bufptr|5.011000||p PL_compiling|5.004050||p PL_copline|5.011000||p PL_curcop|5.004050||p PL_curstash|5.004050||p PL_debstash|5.004050||p PL_defgv|5.004050||p PL_diehook|5.004050||p PL_dirty|5.004050||p PL_dowarn|||pn PL_errgv|5.004050||p PL_error_count|5.011000||p PL_expect|5.011000||p PL_hexdigit|5.005000||p PL_hints|5.005000||p PL_in_my_stash|5.011000||p PL_in_my|5.011000||p PL_last_in_gv|||n PL_laststatval|5.005000||p PL_lex_state|5.011000||p PL_lex_stuff|5.011000||p PL_linestr|5.011000||p PL_modglobal||5.005000|n PL_na|5.004050||pn PL_no_modify|5.006000||p PL_ofsgv|||n PL_parser|5.009005||p PL_perl_destruct_level|5.004050||p PL_perldb|5.004050||p PL_ppaddr|5.006000||p PL_rsfp_filters|5.004050||p PL_rsfp|5.004050||p PL_rs|||n PL_signals|5.008001||p PL_stack_base|5.004050||p PL_stack_sp|5.004050||p PL_statcache|5.005000||p PL_stdingv|5.004050||p PL_sv_arenaroot|5.004050||p PL_sv_no|5.004050||pn PL_sv_undef|5.004050||pn PL_sv_yes|5.004050||pn PL_tainted|5.004050||p PL_tainting|5.004050||p PL_tokenbuf|5.011000||p POP_MULTICALL||5.011000| POPi|||n POPl|||n POPn|||n POPpbytex||5.007001|n POPpx||5.005030|n POPp|||n POPs|||n PTR2IV|5.006000||p PTR2NV|5.006000||p PTR2UV|5.006000||p PTR2nat|5.009003||p PTR2ul|5.007001||p PTRV|5.006000||p PUSHMARK||| PUSH_MULTICALL||5.011000| PUSHi||| PUSHmortal|5.009002||p PUSHn||| PUSHp||| PUSHs||| PUSHu|5.004000||p PUTBACK||| PerlIO_clearerr||5.007003| PerlIO_close||5.007003| PerlIO_context_layers||5.009004| PerlIO_eof||5.007003| PerlIO_error||5.007003| PerlIO_fileno||5.007003| PerlIO_fill||5.007003| PerlIO_flush||5.007003| PerlIO_get_base||5.007003| PerlIO_get_bufsiz||5.007003| PerlIO_get_cnt||5.007003| PerlIO_get_ptr||5.007003| PerlIO_read||5.007003| PerlIO_seek||5.007003| PerlIO_set_cnt||5.007003| PerlIO_set_ptrcnt||5.007003| PerlIO_setlinebuf||5.007003| PerlIO_stderr||5.007003| PerlIO_stdin||5.007003| PerlIO_stdout||5.007003| PerlIO_tell||5.007003| PerlIO_unread||5.007003| PerlIO_write||5.007003| Perl_signbit||5.009005|n PoisonFree|5.009004||p PoisonNew|5.009004||p PoisonWith|5.009004||p Poison|5.008000||p RETVAL|||n Renewc||| Renew||| SAVECLEARSV||| SAVECOMPPAD||| SAVEPADSV||| SAVETMPS||| SAVE_DEFSV|5.004050||p SPAGAIN||| SP||| START_EXTERN_C|5.005000||p START_MY_CXT|5.007003||p STMT_END|||p STMT_START|||p STR_WITH_LEN|5.009003||p ST||| SV_CONST_RETURN|5.009003||p SV_COW_DROP_PV|5.008001||p SV_COW_SHARED_HASH_KEYS|5.009005||p SV_GMAGIC|5.007002||p SV_HAS_TRAILING_NUL|5.009004||p SV_IMMEDIATE_UNREF|5.007001||p SV_MUTABLE_RETURN|5.009003||p SV_NOSTEAL|5.009002||p SV_SMAGIC|5.009003||p SV_UTF8_NO_ENCODING|5.008001||p SVfARG|5.009005||p SVf_UTF8|5.006000||p SVf|5.006000||p SVt_IV||| SVt_NV||| SVt_PVAV||| SVt_PVCV||| SVt_PVHV||| SVt_PVMG||| SVt_PV||| Safefree||| Slab_Alloc||| Slab_Free||| Slab_to_rw||| StructCopy||| SvCUR_set||| SvCUR||| SvEND||| SvGAMAGIC||5.006001| SvGETMAGIC|5.004050||p SvGROW||| SvIOK_UV||5.006000| SvIOK_notUV||5.006000| SvIOK_off||| SvIOK_only_UV||5.006000| SvIOK_only||| SvIOK_on||| SvIOKp||| SvIOK||| SvIVX||| SvIV_nomg|5.009001||p SvIV_set||| SvIVx||| SvIV||| SvIsCOW_shared_hash||5.008003| SvIsCOW||5.008003| SvLEN_set||| SvLEN||| SvLOCK||5.007003| SvMAGIC_set|5.009003||p SvNIOK_off||| SvNIOKp||| SvNIOK||| SvNOK_off||| SvNOK_only||| SvNOK_on||| SvNOKp||| SvNOK||| SvNVX||| SvNV_set||| SvNVx||| SvNV||| SvOK||| SvOOK_offset||5.011000| SvOOK||| SvPOK_off||| SvPOK_only_UTF8||5.006000| SvPOK_only||| SvPOK_on||| SvPOKp||| SvPOK||| SvPVX_const|5.009003||p SvPVX_mutable|5.009003||p SvPVX||| SvPV_const|5.009003||p SvPV_flags_const_nolen|5.009003||p SvPV_flags_const|5.009003||p SvPV_flags_mutable|5.009003||p SvPV_flags|5.007002||p SvPV_force_flags_mutable|5.009003||p SvPV_force_flags_nolen|5.009003||p SvPV_force_flags|5.007002||p SvPV_force_mutable|5.009003||p SvPV_force_nolen|5.009003||p SvPV_force_nomg_nolen|5.009003||p SvPV_force_nomg|5.007002||p SvPV_force|||p SvPV_mutable|5.009003||p SvPV_nolen_const|5.009003||p SvPV_nolen|5.006000||p SvPV_nomg_const_nolen|5.009003||p SvPV_nomg_const|5.009003||p SvPV_nomg|5.007002||p SvPV_renew|5.009003||p SvPV_set||| SvPVbyte_force||5.009002| SvPVbyte_nolen||5.006000| SvPVbytex_force||5.006000| SvPVbytex||5.006000| SvPVbyte|5.006000||p SvPVutf8_force||5.006000| SvPVutf8_nolen||5.006000| SvPVutf8x_force||5.006000| SvPVutf8x||5.006000| SvPVutf8||5.006000| SvPVx||| SvPV||| SvREFCNT_dec||| SvREFCNT_inc_NN|5.009004||p SvREFCNT_inc_simple_NN|5.009004||p SvREFCNT_inc_simple_void_NN|5.009004||p SvREFCNT_inc_simple_void|5.009004||p SvREFCNT_inc_simple|5.009004||p SvREFCNT_inc_void_NN|5.009004||p SvREFCNT_inc_void|5.009004||p SvREFCNT_inc|||p SvREFCNT||| SvROK_off||| SvROK_on||| SvROK||| SvRV_set|5.009003||p SvRV||| SvRXOK||5.009005| SvRX||5.009005| SvSETMAGIC||| SvSHARED_HASH|5.009003||p SvSHARE||5.007003| SvSTASH_set|5.009003||p SvSTASH||| SvSetMagicSV_nosteal||5.004000| SvSetMagicSV||5.004000| SvSetSV_nosteal||5.004000| SvSetSV||| SvTAINTED_off||5.004000| SvTAINTED_on||5.004000| SvTAINTED||5.004000| SvTAINT||| SvTRUE||| SvTYPE||| SvUNLOCK||5.007003| SvUOK|5.007001|5.006000|p SvUPGRADE||| SvUTF8_off||5.006000| SvUTF8_on||5.006000| SvUTF8||5.006000| SvUVXx|5.004000||p SvUVX|5.004000||p SvUV_nomg|5.009001||p SvUV_set|5.009003||p SvUVx|5.004000||p SvUV|5.004000||p SvVOK||5.008001| SvVSTRING_mg|5.009004||p THIS|||n UNDERBAR|5.009002||p UTF8_MAXBYTES|5.009002||p UVSIZE|5.006000||p UVTYPE|5.006000||p UVXf|5.007001||p UVof|5.006000||p UVuf|5.006000||p UVxf|5.006000||p WARN_ALL|5.006000||p WARN_AMBIGUOUS|5.006000||p WARN_ASSERTIONS|5.011000||p WARN_BAREWORD|5.006000||p WARN_CLOSED|5.006000||p WARN_CLOSURE|5.006000||p WARN_DEBUGGING|5.006000||p WARN_DEPRECATED|5.006000||p WARN_DIGIT|5.006000||p WARN_EXEC|5.006000||p WARN_EXITING|5.006000||p WARN_GLOB|5.006000||p WARN_INPLACE|5.006000||p WARN_INTERNAL|5.006000||p WARN_IO|5.006000||p WARN_LAYER|5.008000||p WARN_MALLOC|5.006000||p WARN_MISC|5.006000||p WARN_NEWLINE|5.006000||p WARN_NUMERIC|5.006000||p WARN_ONCE|5.006000||p WARN_OVERFLOW|5.006000||p WARN_PACK|5.006000||p WARN_PARENTHESIS|5.006000||p WARN_PIPE|5.006000||p WARN_PORTABLE|5.006000||p WARN_PRECEDENCE|5.006000||p WARN_PRINTF|5.006000||p WARN_PROTOTYPE|5.006000||p WARN_QW|5.006000||p WARN_RECURSION|5.006000||p WARN_REDEFINE|5.006000||p WARN_REGEXP|5.006000||p WARN_RESERVED|5.006000||p WARN_SEMICOLON|5.006000||p WARN_SEVERE|5.006000||p WARN_SIGNAL|5.006000||p WARN_SUBSTR|5.006000||p WARN_SYNTAX|5.006000||p WARN_TAINT|5.006000||p WARN_THREADS|5.008000||p WARN_UNINITIALIZED|5.006000||p WARN_UNOPENED|5.006000||p WARN_UNPACK|5.006000||p WARN_UNTIE|5.006000||p WARN_UTF8|5.006000||p WARN_VOID|5.006000||p XCPT_CATCH|5.009002||p XCPT_RETHROW|5.009002||p XCPT_TRY_END|5.009002||p XCPT_TRY_START|5.009002||p XPUSHi||| XPUSHmortal|5.009002||p XPUSHn||| XPUSHp||| XPUSHs||| XPUSHu|5.004000||p XSPROTO|5.010000||p XSRETURN_EMPTY||| XSRETURN_IV||| XSRETURN_NO||| XSRETURN_NV||| XSRETURN_PV||| XSRETURN_UNDEF||| XSRETURN_UV|5.008001||p XSRETURN_YES||| XSRETURN|||p XST_mIV||| XST_mNO||| XST_mNV||| XST_mPV||| XST_mUNDEF||| XST_mUV|5.008001||p XST_mYES||| XS_VERSION_BOOTCHECK||| XS_VERSION||| XSprePUSH|5.006000||p XS||| ZeroD|5.009002||p Zero||| _aMY_CXT|5.007003||p _pMY_CXT|5.007003||p aMY_CXT_|5.007003||p aMY_CXT|5.007003||p aTHXR_|5.011000||p aTHXR|5.011000||p aTHX_|5.006000||p aTHX|5.006000||p add_data|||n addmad||| allocmy||| amagic_call||| amagic_cmp_locale||| amagic_cmp||| amagic_i_ncmp||| amagic_ncmp||| any_dup||| ao||| append_elem||| append_list||| append_madprops||| apply_attrs_my||| apply_attrs_string||5.006001| apply_attrs||| apply||| atfork_lock||5.007003|n atfork_unlock||5.007003|n av_arylen_p||5.009003| av_clear||| av_create_and_push||5.009005| av_create_and_unshift_one||5.009005| av_delete||5.006000| av_exists||5.006000| av_extend||| av_fetch||| av_fill||| av_iter_p||5.011000| av_len||| av_make||| av_pop||| av_push||| av_reify||| av_shift||| av_store||| av_undef||| av_unshift||| ax|||n bad_type||| bind_match||| block_end||| block_gimme||5.004000| block_start||| boolSV|5.004000||p boot_core_PerlIO||| boot_core_UNIVERSAL||| boot_core_mro||| bytes_from_utf8||5.007001| bytes_to_uni|||n bytes_to_utf8||5.006001| call_argv|5.006000||p call_atexit||5.006000| call_list||5.004000| call_method|5.006000||p call_pv|5.006000||p call_sv|5.006000||p calloc||5.007002|n cando||| cast_i32||5.006000| cast_iv||5.006000| cast_ulong||5.006000| cast_uv||5.006000| check_type_and_open||| check_uni||| checkcomma||| checkposixcc||| ckWARN|5.006000||p ck_anoncode||| ck_bitop||| ck_concat||| ck_defined||| ck_delete||| ck_die||| ck_each||| ck_eof||| ck_eval||| ck_exec||| ck_exists||| ck_exit||| ck_ftst||| ck_fun||| ck_glob||| ck_grep||| ck_index||| ck_join||| ck_lfun||| ck_listiob||| ck_match||| ck_method||| ck_null||| ck_open||| ck_readline||| ck_repeat||| ck_require||| ck_return||| ck_rfun||| ck_rvconst||| ck_sassign||| ck_select||| ck_shift||| ck_sort||| ck_spair||| ck_split||| ck_subr||| ck_substr||| ck_svconst||| ck_trunc||| ck_unpack||| ckwarn_d||5.009003| ckwarn||5.009003| cl_and|||n cl_anything|||n cl_init_zero|||n cl_init|||n cl_is_anything|||n cl_or|||n clear_placeholders||| closest_cop||| convert||| cop_free||| cr_textfilter||| create_eval_scope||| croak_nocontext|||vn croak_xs_usage||5.011000| croak|||v csighandler||5.009003|n curmad||| custom_op_desc||5.007003| custom_op_name||5.007003| cv_ckproto_len||| cv_clone||| cv_const_sv||5.004000| cv_dump||| cv_undef||| cx_dump||5.005000| cx_dup||| cxinc||| dAXMARK|5.009003||p dAX|5.007002||p dITEMS|5.007002||p dMARK||| dMULTICALL||5.009003| dMY_CXT_SV|5.007003||p dMY_CXT|5.007003||p dNOOP|5.006000||p dORIGMARK||| dSP||| dTHR|5.004050||p dTHXR|5.011000||p dTHXa|5.006000||p dTHXoa|5.006000||p dTHX|5.006000||p dUNDERBAR|5.009002||p dVAR|5.009003||p dXCPT|5.009002||p dXSARGS||| dXSI32||| dXSTARG|5.006000||p deb_curcv||| deb_nocontext|||vn deb_stack_all||| deb_stack_n||| debop||5.005000| debprofdump||5.005000| debprof||| debstackptrs||5.007003| debstack||5.007003| debug_start_match||| deb||5.007003|v del_sv||| delete_eval_scope||| delimcpy||5.004000| deprecate_old||| deprecate||| despatch_signals||5.007001| destroy_matcher||| die_nocontext|||vn die_where||| die|||v dirp_dup||| div128||| djSP||| do_aexec5||| do_aexec||| do_aspawn||| do_binmode||5.004050| do_chomp||| do_chop||| do_close||| do_dump_pad||| do_eof||| do_exec3||| do_execfree||| do_exec||| do_gv_dump||5.006000| do_gvgv_dump||5.006000| do_hv_dump||5.006000| do_ipcctl||| do_ipcget||| do_join||| do_kv||| do_magic_dump||5.006000| do_msgrcv||| do_msgsnd||| do_oddball||| do_op_dump||5.006000| do_op_xmldump||| do_open9||5.006000| do_openn||5.007001| do_open||5.004000| do_pmop_dump||5.006000| do_pmop_xmldump||| do_print||| do_readline||| do_seek||| do_semop||| do_shmio||| do_smartmatch||| do_spawn_nowait||| do_spawn||| do_sprintf||| do_sv_dump||5.006000| do_sysseek||| do_tell||| do_trans_complex_utf8||| do_trans_complex||| do_trans_count_utf8||| do_trans_count||| do_trans_simple_utf8||| do_trans_simple||| do_trans||| do_vecget||| do_vecset||| do_vop||| docatch||| doeval||| dofile||| dofindlabel||| doform||| doing_taint||5.008001|n dooneliner||| doopen_pm||| doparseform||| dopoptoeval||| dopoptogiven||| dopoptolabel||| dopoptoloop||| dopoptosub_at||| dopoptowhen||| doref||5.009003| dounwind||| dowantarray||| dump_all||5.006000| dump_eval||5.006000| dump_exec_pos||| dump_fds||| dump_form||5.006000| dump_indent||5.006000|v dump_mstats||| dump_packsubs||5.006000| dump_sub||5.006000| dump_sv_child||| dump_trie_interim_list||| dump_trie_interim_table||| dump_trie||| dump_vindent||5.006000| dumpuntil||| dup_attrlist||| emulate_cop_io||| eval_pv|5.006000||p eval_sv|5.006000||p exec_failed||| expect_number||| fbm_compile||5.005000| fbm_instr||5.005000| feature_is_enabled||| fetch_cop_label||5.011000| filter_add||| filter_del||| filter_gets||| filter_read||| find_and_forget_pmops||| find_array_subscript||| find_beginning||| find_byclass||| find_hash_subscript||| find_in_my_stash||| find_runcv||5.008001| find_rundefsvoffset||5.009002| find_script||| find_uninit_var||| first_symbol|||n fold_constants||| forbid_setid||| force_ident||| force_list||| force_next||| force_version||| force_word||| forget_pmop||| form_nocontext|||vn form||5.004000|v fp_dup||| fprintf_nocontext|||vn free_global_struct||| free_tied_hv_pool||| free_tmps||| gen_constant_list||| get_arena||| get_aux_mg||| get_av|5.006000||p get_context||5.006000|n get_cvn_flags||5.009005| get_cv|5.006000||p get_db_sub||| get_debug_opts||| get_hash_seed||| get_hv|5.006000||p get_isa_hash||| get_mstats||| get_no_modify||| get_num||| get_op_descs||5.005000| get_op_names||5.005000| get_opargs||| get_ppaddr||5.006000| get_re_arg||| get_sv|5.006000||p get_vtbl||5.005030| getcwd_sv||5.007002| getenv_len||| glob_2number||| glob_assign_glob||| glob_assign_ref||| gp_dup||| gp_free||| gp_ref||| grok_bin|5.007003||p grok_hex|5.007003||p grok_number|5.007002||p grok_numeric_radix|5.007002||p grok_oct|5.007003||p group_end||| gv_AVadd||| gv_HVadd||| gv_IOadd||| gv_SVadd||| gv_autoload4||5.004000| gv_check||| gv_const_sv||5.009003| gv_dump||5.006000| gv_efullname3||5.004000| gv_efullname4||5.006001| gv_efullname||| gv_ename||| gv_fetchfile_flags||5.009005| gv_fetchfile||| gv_fetchmeth_autoload||5.007003| gv_fetchmethod_autoload||5.004000| gv_fetchmethod_flags||5.011000| gv_fetchmethod||| gv_fetchmeth||| gv_fetchpvn_flags|5.009002||p gv_fetchpvs|5.009004||p gv_fetchpv||| gv_fetchsv||5.009002| gv_fullname3||5.004000| gv_fullname4||5.006001| gv_fullname||| gv_get_super_pkg||| gv_handler||5.007001| gv_init_sv||| gv_init||| gv_name_set||5.009004| gv_stashpvn|5.004000||p gv_stashpvs|5.009003||p gv_stashpv||| gv_stashsv||| he_dup||| hek_dup||| hfreeentries||| hsplit||| hv_assert||5.011000| hv_auxinit|||n hv_backreferences_p||| hv_clear_placeholders||5.009001| hv_clear||| hv_common_key_len||5.010000| hv_common||5.010000| hv_copy_hints_hv||| hv_delayfree_ent||5.004000| hv_delete_common||| hv_delete_ent||5.004000| hv_delete||| hv_eiter_p||5.009003| hv_eiter_set||5.009003| hv_exists_ent||5.004000| hv_exists||| hv_fetch_ent||5.004000| hv_fetchs|5.009003||p hv_fetch||| hv_free_ent||5.004000| hv_iterinit||| hv_iterkeysv||5.004000| hv_iterkey||| hv_iternext_flags||5.008000| hv_iternextsv||| hv_iternext||| hv_iterval||| hv_kill_backrefs||| hv_ksplit||5.004000| hv_magic_check|||n hv_magic||| hv_name_set||5.009003| hv_notallowed||| hv_placeholders_get||5.009003| hv_placeholders_p||5.009003| hv_placeholders_set||5.009003| hv_riter_p||5.009003| hv_riter_set||5.009003| hv_scalar||5.009001| hv_store_ent||5.004000| hv_store_flags||5.008000| hv_stores|5.009004||p hv_store||| hv_undef||| ibcmp_locale||5.004000| ibcmp_utf8||5.007003| ibcmp||| incline||| incpush_if_exists||| incpush_use_sep||| incpush||| ingroup||| init_argv_symbols||| init_debugger||| init_global_struct||| init_i18nl10n||5.006000| init_i18nl14n||5.006000| init_ids||| init_interp||| init_main_stash||| init_perllib||| init_postdump_symbols||| init_predump_symbols||| init_stacks||5.005000| init_tm||5.007002| instr||| intro_my||| intuit_method||| intuit_more||| invert||| io_close||| isALNUMC|5.006000||p isALNUM||| isALPHA||| isASCII|5.006000||p isBLANK|5.006001||p isCNTRL|5.006000||p isDIGIT||| isGRAPH|5.006000||p isGV_with_GP|5.009004||p isLOWER||| isPRINT|5.004000||p isPSXSPC|5.006001||p isPUNCT|5.006000||p isSPACE||| isUPPER||| isXDIGIT|5.006000||p is_an_int||| is_gv_magical_sv||| is_handle_constructor|||n is_list_assignment||| is_lvalue_sub||5.007001| is_uni_alnum_lc||5.006000| is_uni_alnumc_lc||5.006000| is_uni_alnumc||5.006000| is_uni_alnum||5.006000| is_uni_alpha_lc||5.006000| is_uni_alpha||5.006000| is_uni_ascii_lc||5.006000| is_uni_ascii||5.006000| is_uni_cntrl_lc||5.006000| is_uni_cntrl||5.006000| is_uni_digit_lc||5.006000| is_uni_digit||5.006000| is_uni_graph_lc||5.006000| is_uni_graph||5.006000| is_uni_idfirst_lc||5.006000| is_uni_idfirst||5.006000| is_uni_lower_lc||5.006000| is_uni_lower||5.006000| is_uni_print_lc||5.006000| is_uni_print||5.006000| is_uni_punct_lc||5.006000| is_uni_punct||5.006000| is_uni_space_lc||5.006000| is_uni_space||5.006000| is_uni_upper_lc||5.006000| is_uni_upper||5.006000| is_uni_xdigit_lc||5.006000| is_uni_xdigit||5.006000| is_utf8_alnumc||5.006000| is_utf8_alnum||5.006000| is_utf8_alpha||5.006000| is_utf8_ascii||5.006000| is_utf8_char_slow|||n is_utf8_char||5.006000| is_utf8_cntrl||5.006000| is_utf8_common||| is_utf8_digit||5.006000| is_utf8_graph||5.006000| is_utf8_idcont||5.008000| is_utf8_idfirst||5.006000| is_utf8_lower||5.006000| is_utf8_mark||5.006000| is_utf8_print||5.006000| is_utf8_punct||5.006000| is_utf8_space||5.006000| is_utf8_string_loclen||5.009003| is_utf8_string_loc||5.008001| is_utf8_string||5.006001| is_utf8_upper||5.006000| is_utf8_xdigit||5.006000| isa_lookup||| items|||n ix|||n jmaybe||| join_exact||| keyword||| leave_scope||| lex_end||| lex_start||| linklist||| listkids||| list||| load_module_nocontext|||vn load_module|5.006000||pv localize||| looks_like_bool||| looks_like_number||| lop||| mPUSHi|5.009002||p mPUSHn|5.009002||p mPUSHp|5.009002||p mPUSHs|5.011000||p mPUSHu|5.009002||p mXPUSHi|5.009002||p mXPUSHn|5.009002||p mXPUSHp|5.009002||p mXPUSHs|5.011000||p mXPUSHu|5.009002||p mad_free||| madlex||| madparse||| magic_clear_all_env||| magic_clearenv||| magic_clearhint||| magic_clearisa||| magic_clearpack||| magic_clearsig||| magic_dump||5.006000| magic_existspack||| magic_freearylen_p||| magic_freeovrld||| magic_getarylen||| magic_getdefelem||| magic_getnkeys||| magic_getpack||| magic_getpos||| magic_getsig||| magic_getsubstr||| magic_gettaint||| magic_getuvar||| magic_getvec||| magic_get||| magic_killbackrefs||| magic_len||| magic_methcall||| magic_methpack||| magic_nextpack||| magic_regdata_cnt||| magic_regdatum_get||| magic_regdatum_set||| magic_scalarpack||| magic_set_all_env||| magic_setamagic||| magic_setarylen||| magic_setcollxfrm||| magic_setdbline||| magic_setdefelem||| magic_setenv||| magic_sethint||| magic_setisa||| magic_setmglob||| magic_setnkeys||| magic_setpack||| magic_setpos||| magic_setregexp||| magic_setsig||| magic_setsubstr||| magic_settaint||| magic_setutf8||| magic_setuvar||| magic_setvec||| magic_set||| magic_sizepack||| magic_wipepack||| make_matcher||| make_trie_failtable||| make_trie||| malloc_good_size|||n malloced_size|||n malloc||5.007002|n markstack_grow||| matcher_matches_sv||| measure_struct||| memEQ|5.004000||p memNE|5.004000||p mem_collxfrm||| mem_log_common|||n mess_alloc||| mess_nocontext|||vn mess||5.006000|v method_common||| mfree||5.007002|n mg_clear||| mg_copy||| mg_dup||| mg_find||| mg_free||| mg_get||| mg_length||5.005000| mg_localize||| mg_magical||| mg_set||| mg_size||5.005000| mini_mktime||5.007002| missingterm||| mode_from_discipline||| modkids||| mod||| more_bodies||| more_sv||| moreswitches||| mro_get_from_name||5.011000| mro_get_linear_isa_dfs||| mro_get_linear_isa||5.009005| mro_get_private_data||5.011000| mro_isa_changed_in||| mro_meta_dup||| mro_meta_init||| mro_method_changed_in||5.009005| mro_register||5.011000| mro_set_mro||5.011000| mro_set_private_data||5.011000| mul128||| mulexp10|||n my_atof2||5.007002| my_atof||5.006000| my_attrs||| my_bcopy|||n my_betoh16|||n my_betoh32|||n my_betoh64|||n my_betohi|||n my_betohl|||n my_betohs|||n my_bzero|||n my_chsize||| my_clearenv||| my_cxt_index||| my_cxt_init||| my_dirfd||5.009005| my_exit_jump||| my_exit||| my_failure_exit||5.004000| my_fflush_all||5.006000| my_fork||5.007003|n my_htobe16|||n my_htobe32|||n my_htobe64|||n my_htobei|||n my_htobel|||n my_htobes|||n my_htole16|||n my_htole32|||n my_htole64|||n my_htolei|||n my_htolel|||n my_htoles|||n my_htonl||| my_kid||| my_letoh16|||n my_letoh32|||n my_letoh64|||n my_letohi|||n my_letohl|||n my_letohs|||n my_lstat||| my_memcmp||5.004000|n my_memset|||n my_ntohl||| my_pclose||5.004000| my_popen_list||5.007001| my_popen||5.004000| my_setenv||| my_snprintf|5.009004||pvn my_socketpair||5.007003|n my_sprintf|5.009003||pvn my_stat||| my_strftime||5.007002| my_strlcat|5.009004||pn my_strlcpy|5.009004||pn my_swabn|||n my_swap||| my_unexec||| my_vsnprintf||5.009004|n need_utf8|||n newANONATTRSUB||5.006000| newANONHASH||| newANONLIST||| newANONSUB||| newASSIGNOP||| newATTRSUB||5.006000| newAVREF||| newAV||| newBINOP||| newCONDOP||| newCONSTSUB|5.004050||p newCVREF||| newDEFSVOP||| newFORM||| newFOROP||| newGIVENOP||5.009003| newGIVWHENOP||| newGP||| newGVOP||| newGVREF||| newGVgen||| newHVREF||| newHVhv||5.005000| newHV||| newIO||| newLISTOP||| newLOGOP||| newLOOPEX||| newLOOPOP||| newMADPROP||| newMADsv||| newMYSUB||| newNULLLIST||| newOP||| newPADOP||| newPMOP||| newPROG||| newPVOP||| newRANGE||| newRV_inc|5.004000||p newRV_noinc|5.004000||p newRV||| newSLICEOP||| newSTATEOP||| newSUB||| newSVOP||| newSVREF||| newSV_type|5.009005||p newSVhek||5.009003| newSViv||| newSVnv||| newSVpvf_nocontext|||vn newSVpvf||5.004000|v newSVpvn_flags|5.011000||p newSVpvn_share|5.007001||p newSVpvn_utf8|5.011000||p newSVpvn|5.004050||p newSVpvs_flags|5.011000||p newSVpvs_share||5.009003| newSVpvs|5.009003||p newSVpv||| newSVrv||| newSVsv||| newSVuv|5.006000||p newSV||| newTOKEN||| newUNOP||| newWHENOP||5.009003| newWHILEOP||5.009003| newXS_flags||5.009004| newXSproto||5.006000| newXS||5.006000| new_collate||5.006000| new_constant||| new_ctype||5.006000| new_he||| new_logop||| new_numeric||5.006000| new_stackinfo||5.005000| new_version||5.009000| new_warnings_bitfield||| next_symbol||| nextargv||| nextchar||| ninstr||| no_bareword_allowed||| no_fh_allowed||| no_op||| not_a_number||| nothreadhook||5.008000| nuke_stacks||| num_overflow|||n offer_nice_chunk||| oopsAV||| oopsHV||| op_clear||| op_const_sv||| op_dump||5.006000| op_free||| op_getmad_weak||| op_getmad||| op_null||5.007002| op_refcnt_dec||| op_refcnt_inc||| op_refcnt_lock||5.009002| op_refcnt_unlock||5.009002| op_xmldump||| open_script||| pMY_CXT_|5.007003||p pMY_CXT|5.007003||p pTHX_|5.006000||p pTHX|5.006000||p packWARN|5.007003||p pack_cat||5.007003| pack_rec||| package||| packlist||5.008001| pad_add_anon||| pad_add_name||| pad_alloc||| pad_block_start||| pad_check_dup||| pad_compname_type||| pad_findlex||| pad_findmy||| pad_fixup_inner_anons||| pad_free||| pad_leavemy||| pad_new||| pad_peg|||n pad_push||| pad_reset||| pad_setsv||| pad_sv||5.011000| pad_swipe||| pad_tidy||| pad_undef||| parse_body||| parse_unicode_opts||| parser_dup||| parser_free||| path_is_absolute|||n peep||| pending_Slabs_to_ro||| perl_alloc_using|||n perl_alloc|||n perl_clone_using|||n perl_clone|||n perl_construct|||n perl_destruct||5.007003|n perl_free|||n perl_parse||5.006000|n perl_run|||n pidgone||| pm_description||| pmflag||| pmop_dump||5.006000| pmop_xmldump||| pmruntime||| pmtrans||| pop_scope||| pregcomp||5.009005| pregexec||| pregfree2||5.011000| pregfree||| prepend_elem||| prepend_madprops||| printbuf||| printf_nocontext|||vn process_special_blocks||| ptr_table_clear||5.009005| ptr_table_fetch||5.009005| ptr_table_find|||n ptr_table_free||5.009005| ptr_table_new||5.009005| ptr_table_split||5.009005| ptr_table_store||5.009005| push_scope||| put_byte||| pv_display|5.006000||p pv_escape|5.009004||p pv_pretty|5.009004||p pv_uni_display||5.007003| qerror||| qsortsvu||| re_compile||5.009005| re_croak2||| re_dup_guts||| re_intuit_start||5.009005| re_intuit_string||5.006000| readpipe_override||| realloc||5.007002|n reentrant_free||| reentrant_init||| reentrant_retry|||vn reentrant_size||| ref_array_or_hash||| refcounted_he_chain_2hv||| refcounted_he_fetch||| refcounted_he_free||| refcounted_he_new_common||| refcounted_he_new||| refcounted_he_value||| refkids||| refto||| ref||5.011000| reg_check_named_buff_matched||| reg_named_buff_all||5.009005| reg_named_buff_exists||5.009005| reg_named_buff_fetch||5.009005| reg_named_buff_firstkey||5.009005| reg_named_buff_iter||| reg_named_buff_nextkey||5.009005| reg_named_buff_scalar||5.009005| reg_named_buff||| reg_namedseq||| reg_node||| reg_numbered_buff_fetch||| reg_numbered_buff_length||| reg_numbered_buff_store||| reg_qr_package||| reg_recode||| reg_scan_name||| reg_skipcomment||| reg_temp_copy||| reganode||| regatom||| regbranch||| regclass_swash||5.009004| regclass||| regcppop||| regcppush||| regcurly|||n regdump_extflags||| regdump||5.005000| regdupe_internal||| regexec_flags||5.005000| regfree_internal||5.009005| reghop3|||n reghop4|||n reghopmaybe3|||n reginclass||| reginitcolors||5.006000| reginsert||| regmatch||| regnext||5.005000| regpiece||| regpposixcc||| regprop||| regrepeat||| regtail_study||| regtail||| regtry||| reguni||| regwhite|||n reg||| repeatcpy||| report_evil_fh||| report_uninit||| require_pv||5.006000| require_tie_mod||| restore_magic||| rninstr||| rsignal_restore||| rsignal_save||| rsignal_state||5.004000| rsignal||5.004000| run_body||| run_user_filter||| runops_debug||5.005000| runops_standard||5.005000| rvpv_dup||| rxres_free||| rxres_restore||| rxres_save||| safesyscalloc||5.006000|n safesysfree||5.006000|n safesysmalloc||5.006000|n safesysrealloc||5.006000|n same_dirent||| save_I16||5.004000| save_I32||| save_I8||5.006000| save_adelete||5.011000| save_aelem||5.004050| save_alloc||5.006000| save_aptr||| save_ary||| save_bool||5.008001| save_clearsv||| save_delete||| save_destructor_x||5.006000| save_destructor||5.006000| save_freeop||| save_freepv||| save_freesv||| save_generic_pvref||5.006001| save_generic_svref||5.005030| save_gp||5.004000| save_hash||| save_hek_flags|||n save_helem_flags||5.011000| save_helem||5.004050| save_hints||| save_hptr||| save_int||| save_item||| save_iv||5.005000| save_lines||| save_list||| save_long||| save_magic||| save_mortalizesv||5.007001| save_nogv||| save_op||| save_padsv_and_mortalize||5.011000| save_pptr||| save_pushi32ptr||| save_pushptri32ptr||| save_pushptrptr||| save_pushptr||5.011000| save_re_context||5.006000| save_scalar_at||| save_scalar||| save_set_svflags||5.009000| save_shared_pvref||5.007003| save_sptr||| save_svref||| save_vptr||5.006000| savepvn||| savepvs||5.009003| savepv||| savesharedpvn||5.009005| savesharedpv||5.007003| savestack_grow_cnt||5.008001| savestack_grow||| savesvpv||5.009002| sawparens||| scalar_mod_type|||n scalarboolean||| scalarkids||| scalarseq||| scalarvoid||| scalar||| scan_bin||5.006000| scan_commit||| scan_const||| scan_formline||| scan_heredoc||| scan_hex||| scan_ident||| scan_inputsymbol||| scan_num||5.007001| scan_oct||| scan_pat||| scan_str||| scan_subst||| scan_trans||| scan_version||5.009001| scan_vstring||5.009005| scan_word||| scope||| screaminstr||5.005000| search_const||| seed||5.008001| sequence_num||| sequence_tail||| sequence||| set_context||5.006000|n set_numeric_local||5.006000| set_numeric_radix||5.006000| set_numeric_standard||5.006000| setdefout||| share_hek_flags||| share_hek||5.004000| si_dup||| sighandler|||n simplify_sort||| skipspace0||| skipspace1||| skipspace2||| skipspace||| softref2xv||| sortcv_stacked||| sortcv_xsub||| sortcv||| sortsv_flags||5.009003| sortsv||5.007003| space_join_names_mortal||| ss_dup||| stack_grow||| start_force||| start_glob||| start_subparse||5.004000| stashpv_hvname_match||5.011000| stdize_locale||| store_cop_label||| strEQ||| strGE||| strGT||| strLE||| strLT||| strNE||| str_to_version||5.006000| strip_return||| strnEQ||| strnNE||| study_chunk||| sub_crush_depth||| sublex_done||| sublex_push||| sublex_start||| sv_2bool||| sv_2cv||| sv_2io||| sv_2iuv_common||| sv_2iuv_non_preserve||| sv_2iv_flags||5.009001| sv_2iv||| sv_2mortal||| sv_2num||| sv_2nv||| sv_2pv_flags|5.007002||p sv_2pv_nolen|5.006000||p sv_2pvbyte_nolen|5.006000||p sv_2pvbyte|5.006000||p sv_2pvutf8_nolen||5.006000| sv_2pvutf8||5.006000| sv_2pv||| sv_2uv_flags||5.009001| sv_2uv|5.004000||p sv_add_arena||| sv_add_backref||| sv_backoff||| sv_bless||| sv_cat_decode||5.008001| sv_catpv_mg|5.004050||p sv_catpvf_mg_nocontext|||pvn sv_catpvf_mg|5.006000|5.004000|pv sv_catpvf_nocontext|||vn sv_catpvf||5.004000|v sv_catpvn_flags||5.007002| sv_catpvn_mg|5.004050||p sv_catpvn_nomg|5.007002||p sv_catpvn||| sv_catpvs|5.009003||p sv_catpv||| sv_catsv_flags||5.007002| sv_catsv_mg|5.004050||p sv_catsv_nomg|5.007002||p sv_catsv||| sv_catxmlpvn||| sv_catxmlsv||| sv_chop||| sv_clean_all||| sv_clean_objs||| sv_clear||| sv_cmp_locale||5.004000| sv_cmp||| sv_collxfrm||| sv_compile_2op||5.008001| sv_copypv||5.007003| sv_dec||| sv_del_backref||| sv_derived_from||5.004000| sv_destroyable||5.010000| sv_does||5.009004| sv_dump||| sv_dup_inc_multiple||| sv_dup||| sv_eq||| sv_exp_grow||| sv_force_normal_flags||5.007001| sv_force_normal||5.006000| sv_free2||| sv_free_arenas||| sv_free||| sv_gets||5.004000| sv_grow||| sv_i_ncmp||| sv_inc||| sv_insert_flags||5.011000| sv_insert||| sv_isa||| sv_isobject||| sv_iv||5.005000| sv_kill_backrefs||| sv_len_utf8||5.006000| sv_len||| sv_magic_portable|5.011000|5.004000|p sv_magicext||5.007003| sv_magic||| sv_mortalcopy||| sv_ncmp||| sv_newmortal||| sv_newref||| sv_nolocking||5.007003| sv_nosharing||5.007003| sv_nounlocking||| sv_nv||5.005000| sv_peek||5.005000| sv_pos_b2u_midway||| sv_pos_b2u||5.006000| sv_pos_u2b_cached||| sv_pos_u2b_forwards|||n sv_pos_u2b_midway|||n sv_pos_u2b||5.006000| sv_pvbyten_force||5.006000| sv_pvbyten||5.006000| sv_pvbyte||5.006000| sv_pvn_force_flags|5.007002||p sv_pvn_force||| sv_pvn_nomg|5.007003|5.005000|p sv_pvn||5.005000| sv_pvutf8n_force||5.006000| sv_pvutf8n||5.006000| sv_pvutf8||5.006000| sv_pv||5.006000| sv_recode_to_utf8||5.007003| sv_reftype||| sv_release_COW||| sv_replace||| sv_report_used||| sv_reset||| sv_rvweaken||5.006000| sv_setiv_mg|5.004050||p sv_setiv||| sv_setnv_mg|5.006000||p sv_setnv||| sv_setpv_mg|5.004050||p sv_setpvf_mg_nocontext|||pvn sv_setpvf_mg|5.006000|5.004000|pv sv_setpvf_nocontext|||vn sv_setpvf||5.004000|v sv_setpviv_mg||5.008001| sv_setpviv||5.008001| sv_setpvn_mg|5.004050||p sv_setpvn||| sv_setpvs|5.009004||p sv_setpv||| sv_setref_iv||| sv_setref_nv||| sv_setref_pvn||| sv_setref_pv||| sv_setref_uv||5.007001| sv_setsv_cow||| sv_setsv_flags||5.007002| sv_setsv_mg|5.004050||p sv_setsv_nomg|5.007002||p sv_setsv||| sv_setuv_mg|5.004050||p sv_setuv|5.004000||p sv_tainted||5.004000| sv_taint||5.004000| sv_true||5.005000| sv_unglob||| sv_uni_display||5.007003| sv_unmagic||| sv_unref_flags||5.007001| sv_unref||| sv_untaint||5.004000| sv_upgrade||| sv_usepvn_flags||5.009004| sv_usepvn_mg|5.004050||p sv_usepvn||| sv_utf8_decode||5.006000| sv_utf8_downgrade||5.006000| sv_utf8_encode||5.006000| sv_utf8_upgrade_flags_grow||5.011000| sv_utf8_upgrade_flags||5.007002| sv_utf8_upgrade_nomg||5.007002| sv_utf8_upgrade||5.007001| sv_uv|5.005000||p sv_vcatpvf_mg|5.006000|5.004000|p sv_vcatpvfn||5.004000| sv_vcatpvf|5.006000|5.004000|p sv_vsetpvf_mg|5.006000|5.004000|p sv_vsetpvfn||5.004000| sv_vsetpvf|5.006000|5.004000|p sv_xmlpeek||| svtype||| swallow_bom||| swap_match_buff||| swash_fetch||5.007002| swash_get||| swash_init||5.006000| sys_init3||5.010000|n sys_init||5.010000|n sys_intern_clear||| sys_intern_dup||| sys_intern_init||| sys_term||5.010000|n taint_env||| taint_proper||| tmps_grow||5.006000| toLOWER||| toUPPER||| to_byte_substr||| to_uni_fold||5.007003| to_uni_lower_lc||5.006000| to_uni_lower||5.007003| to_uni_title_lc||5.006000| to_uni_title||5.007003| to_uni_upper_lc||5.006000| to_uni_upper||5.007003| to_utf8_case||5.007003| to_utf8_fold||5.007003| to_utf8_lower||5.007003| to_utf8_substr||| to_utf8_title||5.007003| to_utf8_upper||5.007003| token_free||| token_getmad||| tokenize_use||| tokeq||| tokereport||| too_few_arguments||| too_many_arguments||| uiv_2buf|||n unlnk||| unpack_rec||| unpack_str||5.007003| unpackstring||5.008001| unshare_hek_or_pvn||| unshare_hek||| unsharepvn||5.004000| unwind_handler_stack||| update_debugger_info||| upg_version||5.009005| usage||| utf16_to_utf8_reversed||5.006001| utf16_to_utf8||5.006001| utf8_distance||5.006000| utf8_hop||5.006000| utf8_length||5.007001| utf8_mg_pos_cache_update||| utf8_to_bytes||5.006001| utf8_to_uvchr||5.007001| utf8_to_uvuni||5.007001| utf8n_to_uvchr||| utf8n_to_uvuni||5.007001| utilize||| uvchr_to_utf8_flags||5.007003| uvchr_to_utf8||| uvuni_to_utf8_flags||5.007003| uvuni_to_utf8||5.007001| validate_suid||| varname||| vcmp||5.009000| vcroak||5.006000| vdeb||5.007003| vdie_common||| vdie_croak_common||| vdie||| vform||5.006000| visit||| vivify_defelem||| vivify_ref||| vload_module|5.006000||p vmess||5.006000| vnewSVpvf|5.006000|5.004000|p vnormal||5.009002| vnumify||5.009000| vstringify||5.009000| vverify||5.009003| vwarner||5.006000| vwarn||5.006000| wait4pid||| warn_nocontext|||vn warner_nocontext|||vn warner|5.006000|5.004000|pv warn|||v watch||| whichsig||| write_no_mem||| write_to_stderr||| xmldump_all||| xmldump_attr||| xmldump_eval||| xmldump_form||| xmldump_indent|||v xmldump_packsubs||| xmldump_sub||| xmldump_vindent||| yyerror||| yylex||| yyparse||| yywarn||| ); if (exists $opt{'list-unsupported'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{todo}; print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n"; } exit 0; } # Scan for possible replacement candidates my(%replace, %need, %hints, %warnings, %depends); my $replace = 0; my($hint, $define, $function); sub find_api { my $code = shift; $code =~ s{ / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]*) | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' }{}egsx; grep { exists $API{$_} } $code =~ /(\w+)/mg; } while () { if ($hint) { my $h = $hint->[0] eq 'Hint' ? \%hints : \%warnings; if (m{^\s*\*\s(.*?)\s*$}) { for (@{$hint->[1]}) { $h->{$_} ||= ''; # suppress warning with older perls $h->{$_} .= "$1\n"; } } else { undef $hint } } $hint = [$1, [split /,?\s+/, $2]] if m{^\s*$rccs\s+(Hint|Warning):\s+(\w+(?:,?\s+\w+)*)\s*$}; if ($define) { if ($define->[1] =~ /\\$/) { $define->[1] .= $_; } else { if (exists $API{$define->[0]} && $define->[1] !~ /^DPPP_\(/) { my @n = find_api($define->[1]); push @{$depends{$define->[0]}}, @n if @n } undef $define; } } $define = [$1, $2] if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(.*)}; if ($function) { if (/^}/) { if (exists $API{$function->[0]}) { my @n = find_api($function->[1]); push @{$depends{$function->[0]}}, @n if @n } undef $function; } else { $function->[1] .= $_; } } $function = [$1, ''] if m{^DPPP_\(my_(\w+)\)}; $replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$}; $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)}; $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce}; $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$}; if (m{^\s*$rccs\s+(\w+(\s*,\s*\w+)*)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) { my @deps = map { s/\s+//g; $_ } split /,/, $3; my $d; for $d (map { s/\s+//g; $_ } split /,/, $1) { push @{$depends{$d}}, @deps; } } $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)}; } for (values %depends) { my %s; $_ = [sort grep !$s{$_}++, @$_]; } if (exists $opt{'api-info'}) { my $f; my $count = 0; my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$"; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $f =~ /$match/; print "\n=== $f ===\n\n"; my $info = 0; if ($API{$f}{base} || $API{$f}{todo}) { my $base = format_version($API{$f}{base} || $API{$f}{todo}); print "Supported at least starting from perl-$base.\n"; $info++; } if ($API{$f}{provided}) { my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003"; print "Support by $ppport provided back to perl-$todo.\n"; print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f}; print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f}; print "\n$hints{$f}" if exists $hints{$f}; print "\nWARNING:\n$warnings{$f}" if exists $warnings{$f}; $info++; } print "No portability information available.\n" unless $info; $count++; } $count or print "Found no API matching '$opt{'api-info'}'."; print "\n"; exit 0; } if (exists $opt{'list-provided'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{provided}; my @flags; push @flags, 'explicit' if exists $need{$f}; push @flags, 'depend' if exists $depends{$f}; push @flags, 'hint' if exists $hints{$f}; push @flags, 'warning' if exists $warnings{$f}; my $flags = @flags ? ' ['.join(', ', @flags).']' : ''; print "$f$flags\n"; } exit 0; } my @files; my @srcext = qw( .xs .c .h .cc .cpp -c.inc -xs.inc ); my $srcext = join '|', map { quotemeta $_ } @srcext; if (@ARGV) { my %seen; for (@ARGV) { if (-e) { if (-f) { push @files, $_ unless $seen{$_}++; } else { warn "'$_' is not a file.\n" } } else { my @new = grep { -f } glob $_ or warn "'$_' does not exist.\n"; push @files, grep { !$seen{$_}++ } @new; } } } else { eval { require File::Find; File::Find::find(sub { $File::Find::name =~ /($srcext)$/i and push @files, $File::Find::name; }, '.'); }; if ($@) { @files = map { glob "*$_" } @srcext; } } if (!@ARGV || $opt{filter}) { my(@in, @out); my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files; for (@files) { my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i; push @{ $out ? \@out : \@in }, $_; } if (@ARGV && @out) { warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out); } @files = @in; } die "No input files given!\n" unless @files; my(%files, %global, %revreplace); %revreplace = reverse %replace; my $filename; my $patch_opened = 0; for $filename (@files) { unless (open IN, "<$filename") { warn "Unable to read from $filename: $!\n"; next; } info("Scanning $filename ..."); my $c = do { local $/; }; close IN; my %file = (orig => $c, changes => 0); # Temporarily remove C/XS comments and strings from the code my @ccom; $c =~ s{ ( ^$HS*\#$HS*include\b[^\r\n]+\b(?:\Q$ppport\E|XSUB\.h)\b[^\r\n]* | ^$HS*\#$HS*(?:define|elif|if(?:def)?)\b[^\r\n]* ) | ( ^$HS*\#[^\r\n]* | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' | / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]* ) ) }{ defined $2 and push @ccom, $2; defined $1 ? $1 : "$ccs$#ccom$cce" }mgsex; $file{ccom} = \@ccom; $file{code} = $c; $file{has_inc_ppport} = $c =~ /^$HS*#$HS*include[^\r\n]+\b\Q$ppport\E\b/m; my $func; for $func (keys %API) { my $match = $func; $match .= "|$revreplace{$func}" if exists $revreplace{$func}; if ($c =~ /\b(?:Perl_)?($match)\b/) { $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func}; $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/; if (exists $API{$func}{provided}) { $file{uses_provided}{$func}++; if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) { $file{uses}{$func}++; my @deps = rec_depend($func); if (@deps) { $file{uses_deps}{$func} = \@deps; for (@deps) { $file{uses}{$_} = 0 unless exists $file{uses}{$_}; } } for ($func, @deps) { $file{needs}{$_} = 'static' if exists $need{$_}; } } } if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) { if ($c =~ /\b$func\b/) { $file{uses_todo}{$func}++; } } } } while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) { if (exists $need{$2}) { $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++; } else { warning("Possibly wrong #define $1 in $filename") } } for (qw(uses needs uses_todo needed_global needed_static)) { for $func (keys %{$file{$_}}) { push @{$global{$_}{$func}}, $filename; } } $files{$filename} = \%file; } # Globally resolve NEED_'s my $need; for $need (keys %{$global{needs}}) { if (@{$global{needs}{$need}} > 1) { my @targets = @{$global{needs}{$need}}; my @t = grep $files{$_}{needed_global}{$need}, @targets; @targets = @t if @t; @t = grep /\.xs$/i, @targets; @targets = @t if @t; my $target = shift @targets; $files{$target}{needs}{$need} = 'global'; for (@{$global{needs}{$need}}) { $files{$_}{needs}{$need} = 'extern' if $_ ne $target; } } } for $filename (@files) { exists $files{$filename} or next; info("=== Analyzing $filename ==="); my %file = %{$files{$filename}}; my $func; my $c = $file{code}; my $warnings = 0; for $func (sort keys %{$file{uses_Perl}}) { if ($API{$func}{varargs}) { unless ($API{$func}{nothxarg}) { my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))} { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge); if ($changes) { warning("Doesn't pass interpreter argument aTHX to Perl_$func"); $file{changes} += $changes; } } } else { warning("Uses Perl_$func instead of $func"); $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*} {$func$1(}g); } } for $func (sort keys %{$file{uses_replace}}) { warning("Uses $func instead of $replace{$func}"); $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g); } for $func (sort keys %{$file{uses_provided}}) { if ($file{uses}{$func}) { if (exists $file{uses_deps}{$func}) { diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}})); } else { diag("Uses $func"); } } $warnings += hint($func); } unless ($opt{quiet}) { for $func (sort keys %{$file{uses_todo}}) { print "*** WARNING: Uses $func, which may not be portable below perl ", format_version($API{$func}{todo}), ", even with '$ppport'\n"; $warnings++; } } for $func (sort keys %{$file{needed_static}}) { my $message = ''; if (not exists $file{uses}{$func}) { $message = "No need to define NEED_$func if $func is never used"; } elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') { $message = "No need to define NEED_$func when already needed globally"; } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg); } } for $func (sort keys %{$file{needed_global}}) { my $message = ''; if (not exists $global{uses}{$func}) { $message = "No need to define NEED_${func}_GLOBAL if $func is never used"; } elsif (exists $file{needs}{$func}) { if ($file{needs}{$func} eq 'extern') { $message = "No need to define NEED_${func}_GLOBAL when already needed globally"; } elsif ($file{needs}{$func} eq 'static') { $message = "No need to define NEED_${func}_GLOBAL when only used in this file"; } } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg); } } $file{needs_inc_ppport} = keys %{$file{uses}}; if ($file{needs_inc_ppport}) { my $pp = ''; for $func (sort keys %{$file{needs}}) { my $type = $file{needs}{$func}; next if $type eq 'extern'; my $suffix = $type eq 'global' ? '_GLOBAL' : ''; unless (exists $file{"needed_$type"}{$func}) { if ($type eq 'global') { diag("Files [@{$global{needs}{$func}}] need $func, adding global request"); } else { diag("File needs $func, adding static request"); } $pp .= "#define NEED_$func$suffix\n"; } } if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) { $pp = ''; $file{changes}++; } unless ($file{has_inc_ppport}) { diag("Needs to include '$ppport'"); $pp .= qq(#include "$ppport"\n) } if ($pp) { $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms) || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m) || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m) || ($c =~ s/^/$pp/); } } else { if ($file{has_inc_ppport}) { diag("No need to include '$ppport'"); $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m); } } # put back in our C comments my $ix; my $cppc = 0; my @ccom = @{$file{ccom}}; for $ix (0 .. $#ccom) { if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) { $cppc++; $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/; } else { $c =~ s/$rccs$ix$rcce/$ccom[$ix]/; } } if ($cppc) { my $s = $cppc != 1 ? 's' : ''; warning("Uses $cppc C++ style comment$s, which is not portable"); } my $s = $warnings != 1 ? 's' : ''; my $warn = $warnings ? " ($warnings warning$s)" : ''; info("Analysis completed$warn"); if ($file{changes}) { if (exists $opt{copy}) { my $newfile = "$filename$opt{copy}"; if (-e $newfile) { error("'$newfile' already exists, refusing to write copy of '$filename'"); } else { local *F; if (open F, ">$newfile") { info("Writing copy of '$filename' with changes to '$newfile'"); print F $c; close F; } else { error("Cannot open '$newfile' for writing: $!"); } } } elsif (exists $opt{patch} || $opt{changes}) { if (exists $opt{patch}) { unless ($patch_opened) { if (open PATCH, ">$opt{patch}") { $patch_opened = 1; } else { error("Cannot open '$opt{patch}' for writing: $!"); delete $opt{patch}; $opt{changes} = 1; goto fallback; } } mydiff(\*PATCH, $filename, $c); } else { fallback: info("Suggested changes:"); mydiff(\*STDOUT, $filename, $c); } } else { my $s = $file{changes} == 1 ? '' : 's'; info("$file{changes} potentially required change$s detected"); } } else { info("Looks good"); } } close PATCH if $patch_opened; exit 0; sub try_use { eval "use @_;"; return $@ eq '' } sub mydiff { local *F = shift; my($file, $str) = @_; my $diff; if (exists $opt{diff}) { $diff = run_diff($opt{diff}, $file, $str); } if (!defined $diff and try_use('Text::Diff')) { $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' }); $diff = <
$tmp") { print F $str; close F; if (open F, "$prog $file $tmp |") { while () { s/\Q$tmp\E/$file.patched/; $diff .= $_; } close F; unlink $tmp; return $diff; } unlink $tmp; } else { error("Cannot open '$tmp' for writing: $!"); } return undef; } sub rec_depend { my($func, $seen) = @_; return () unless exists $depends{$func}; $seen = {%{$seen||{}}}; return () if $seen->{$func}++; my %s; grep !$s{$_}++, map { ($_, rec_depend($_, $seen)) } @{$depends{$func}}; } sub parse_version { my $ver = shift; if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) { return ($1, $2, $3); } elsif ($ver !~ /^\d+\.[\d_]+$/) { die "cannot parse version '$ver'\n"; } $ver =~ s/_//g; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "cannot parse version '$ver'\n"; } } return ($r, $v, $s); } sub format_version { my $ver = shift; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "invalid version '$ver'\n"; } $s /= 10; $ver = sprintf "%d.%03d", $r, $v; $s > 0 and $ver .= sprintf "_%02d", $s; return $ver; } return sprintf "%d.%d.%d", $r, $v, $s; } sub info { $opt{quiet} and return; print @_, "\n"; } sub diag { $opt{quiet} and return; $opt{diag} and print @_, "\n"; } sub warning { $opt{quiet} and return; print "*** ", @_, "\n"; } sub error { print "*** ERROR: ", @_, "\n"; } my %given_hints; my %given_warnings; sub hint { $opt{quiet} and return; my $func = shift; my $rv = 0; if (exists $warnings{$func} && !$given_warnings{$func}++) { my $warn = $warnings{$func}; $warn =~ s!^!*** !mg; print "*** WARNING: $func\n", $warn; $rv++; } if ($opt{hints} && exists $hints{$func} && !$given_hints{$func}++) { my $hint = $hints{$func}; $hint =~ s/^/ /mg; print " --- hint for $func ---\n", $hint; } $rv; } sub usage { my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms; my %M = ( 'I' => '*' ); $usage =~ s/^\s*perl\s+\S+/$^X $0/; $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g; print < }; my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms; $copy =~ s/^(?=\S+)/ /gms; $self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms; $self =~ s/^SKIP.*(?=^__DATA__)/SKIP if (\@ARGV && \$ARGV[0] eq '--unstrip') { eval { require Devel::PPPort }; \$@ and die "Cannot require Devel::PPPort, please install.\\n"; if (eval \$Devel::PPPort::VERSION < $VERSION) { die "$0 was originally generated with Devel::PPPort $VERSION.\\n" . "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n" . "Please install a newer version, or --unstrip will not work.\\n"; } Devel::PPPort::WriteFile(\$0); exit 0; } print <$0" or die "cannot strip $0: $!\n"; print OUT "$pl$c\n"; exit 0; } __DATA__ */ #ifndef _P_P_PORTABILITY_H_ #define _P_P_PORTABILITY_H_ #ifndef DPPP_NAMESPACE # define DPPP_NAMESPACE DPPP_ #endif #define DPPP_CAT2(x,y) CAT2(x,y) #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name) #ifndef PERL_REVISION # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) # define PERL_PATCHLEVEL_H_IMPLICIT # include # endif # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) # include # endif # ifndef PERL_REVISION # define PERL_REVISION (5) /* Replace: 1 */ # define PERL_VERSION PATCHLEVEL # define PERL_SUBVERSION SUBVERSION /* Replace PERL_PATCHLEVEL with PERL_VERSION */ /* Replace: 0 */ # endif #endif #define _dpppDEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10)) #define PERL_BCDVERSION ((_dpppDEC2BCD(PERL_REVISION)<<24)|(_dpppDEC2BCD(PERL_VERSION)<<12)|_dpppDEC2BCD(PERL_SUBVERSION)) /* It is very unlikely that anyone will try to use this with Perl 6 (or greater), but who knows. */ #if PERL_REVISION != 5 # error ppport.h only works with Perl version 5 #endif /* PERL_REVISION != 5 */ #ifndef dTHR # define dTHR dNOOP #endif #ifndef dTHX # define dTHX dNOOP #endif #ifndef dTHXa # define dTHXa(x) dNOOP #endif #ifndef pTHX # define pTHX void #endif #ifndef pTHX_ # define pTHX_ #endif #ifndef aTHX # define aTHX #endif #ifndef aTHX_ # define aTHX_ #endif #if (PERL_BCDVERSION < 0x5006000) # ifdef USE_THREADS # define aTHXR thr # define aTHXR_ thr, # else # define aTHXR # define aTHXR_ # endif # define dTHXR dTHR #else # define aTHXR aTHX # define aTHXR_ aTHX_ # define dTHXR dTHX #endif #ifndef dTHXoa # define dTHXoa(x) dTHXa(x) #endif #ifdef I_LIMITS # include #endif #ifndef PERL_UCHAR_MIN # define PERL_UCHAR_MIN ((unsigned char)0) #endif #ifndef PERL_UCHAR_MAX # ifdef UCHAR_MAX # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX) # else # ifdef MAXUCHAR # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR) # else # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0) # endif # endif #endif #ifndef PERL_USHORT_MIN # define PERL_USHORT_MIN ((unsigned short)0) #endif #ifndef PERL_USHORT_MAX # ifdef USHORT_MAX # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX) # else # ifdef MAXUSHORT # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT) # else # ifdef USHRT_MAX # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX) # else # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0) # endif # endif # endif #endif #ifndef PERL_SHORT_MAX # ifdef SHORT_MAX # define PERL_SHORT_MAX ((short)SHORT_MAX) # else # ifdef MAXSHORT /* Often used in */ # define PERL_SHORT_MAX ((short)MAXSHORT) # else # ifdef SHRT_MAX # define PERL_SHORT_MAX ((short)SHRT_MAX) # else # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1)) # endif # endif # endif #endif #ifndef PERL_SHORT_MIN # ifdef SHORT_MIN # define PERL_SHORT_MIN ((short)SHORT_MIN) # else # ifdef MINSHORT # define PERL_SHORT_MIN ((short)MINSHORT) # else # ifdef SHRT_MIN # define PERL_SHORT_MIN ((short)SHRT_MIN) # else # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif #ifndef PERL_UINT_MAX # ifdef UINT_MAX # define PERL_UINT_MAX ((unsigned int)UINT_MAX) # else # ifdef MAXUINT # define PERL_UINT_MAX ((unsigned int)MAXUINT) # else # define PERL_UINT_MAX (~(unsigned int)0) # endif # endif #endif #ifndef PERL_UINT_MIN # define PERL_UINT_MIN ((unsigned int)0) #endif #ifndef PERL_INT_MAX # ifdef INT_MAX # define PERL_INT_MAX ((int)INT_MAX) # else # ifdef MAXINT /* Often used in */ # define PERL_INT_MAX ((int)MAXINT) # else # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1)) # endif # endif #endif #ifndef PERL_INT_MIN # ifdef INT_MIN # define PERL_INT_MIN ((int)INT_MIN) # else # ifdef MININT # define PERL_INT_MIN ((int)MININT) # else # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3)) # endif # endif #endif #ifndef PERL_ULONG_MAX # ifdef ULONG_MAX # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX) # else # ifdef MAXULONG # define PERL_ULONG_MAX ((unsigned long)MAXULONG) # else # define PERL_ULONG_MAX (~(unsigned long)0) # endif # endif #endif #ifndef PERL_ULONG_MIN # define PERL_ULONG_MIN ((unsigned long)0L) #endif #ifndef PERL_LONG_MAX # ifdef LONG_MAX # define PERL_LONG_MAX ((long)LONG_MAX) # else # ifdef MAXLONG # define PERL_LONG_MAX ((long)MAXLONG) # else # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1)) # endif # endif #endif #ifndef PERL_LONG_MIN # ifdef LONG_MIN # define PERL_LONG_MIN ((long)LONG_MIN) # else # ifdef MINLONG # define PERL_LONG_MIN ((long)MINLONG) # else # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3)) # endif # endif #endif #if defined(HAS_QUAD) && (defined(convex) || defined(uts)) # ifndef PERL_UQUAD_MAX # ifdef ULONGLONG_MAX # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX) # else # ifdef MAXULONGLONG # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG) # else # define PERL_UQUAD_MAX (~(unsigned long long)0) # endif # endif # endif # ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN ((unsigned long long)0L) # endif # ifndef PERL_QUAD_MAX # ifdef LONGLONG_MAX # define PERL_QUAD_MAX ((long long)LONGLONG_MAX) # else # ifdef MAXLONGLONG # define PERL_QUAD_MAX ((long long)MAXLONGLONG) # else # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1)) # endif # endif # endif # ifndef PERL_QUAD_MIN # ifdef LONGLONG_MIN # define PERL_QUAD_MIN ((long long)LONGLONG_MIN) # else # ifdef MINLONGLONG # define PERL_QUAD_MIN ((long long)MINLONGLONG) # else # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif /* This is based on code from 5.003 perl.h */ #ifdef HAS_QUAD # ifdef cray #ifndef IVTYPE # define IVTYPE int #endif #ifndef IV_MIN # define IV_MIN PERL_INT_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_INT_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UINT_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UINT_MAX #endif # ifdef INTSIZE #ifndef IVSIZE # define IVSIZE INTSIZE #endif # endif # else # if defined(convex) || defined(uts) #ifndef IVTYPE # define IVTYPE long long #endif #ifndef IV_MIN # define IV_MIN PERL_QUAD_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_QUAD_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UQUAD_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UQUAD_MAX #endif # ifdef LONGLONGSIZE #ifndef IVSIZE # define IVSIZE LONGLONGSIZE #endif # endif # else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif # ifdef LONGSIZE #ifndef IVSIZE # define IVSIZE LONGSIZE #endif # endif # endif # endif #ifndef IVSIZE # define IVSIZE 8 #endif #ifndef PERL_QUAD_MIN # define PERL_QUAD_MIN IV_MIN #endif #ifndef PERL_QUAD_MAX # define PERL_QUAD_MAX IV_MAX #endif #ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN UV_MIN #endif #ifndef PERL_UQUAD_MAX # define PERL_UQUAD_MAX UV_MAX #endif #else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif #endif #ifndef IVSIZE # ifdef LONGSIZE # define IVSIZE LONGSIZE # else # define IVSIZE 4 /* A bold guess, but the best we can make. */ # endif #endif #ifndef UVTYPE # define UVTYPE unsigned IVTYPE #endif #ifndef UVSIZE # define UVSIZE IVSIZE #endif #ifndef sv_setuv # define sv_setuv(sv, uv) \ STMT_START { \ UV TeMpUv = uv; \ if (TeMpUv <= IV_MAX) \ sv_setiv(sv, TeMpUv); \ else \ sv_setnv(sv, (double)TeMpUv); \ } STMT_END #endif #ifndef newSVuv # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv)) #endif #ifndef sv_2uv # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv))) #endif #ifndef SvUVX # define SvUVX(sv) ((UV)SvIVX(sv)) #endif #ifndef SvUVXx # define SvUVXx(sv) SvUVX(sv) #endif #ifndef SvUV # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv)) #endif #ifndef SvUVx # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv)) #endif /* Hint: sv_uv * Always use the SvUVx() macro instead of sv_uv(). */ #ifndef sv_uv # define sv_uv(sv) SvUVx(sv) #endif #if !defined(SvUOK) && defined(SvIOK_UV) # define SvUOK(sv) SvIOK_UV(sv) #endif #ifndef XST_mUV # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) ) #endif #ifndef XSRETURN_UV # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END #endif #ifndef PUSHu # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END #endif #ifndef XPUSHu # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END #endif #ifdef HAS_MEMCMP #ifndef memNE # define memNE(s1,s2,l) (memcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!memcmp(s1,s2,l)) #endif #else #ifndef memNE # define memNE(s1,s2,l) (bcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!bcmp(s1,s2,l)) #endif #endif #ifndef MoveD # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifndef CopyD # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifdef HAS_MEMSET #ifndef ZeroD # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t)) #endif #else #ifndef ZeroD # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d) #endif #endif #ifndef PoisonWith # define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t)) #endif #ifndef PoisonNew # define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB) #endif #ifndef PoisonFree # define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF) #endif #ifndef Poison # define Poison(d,n,t) PoisonFree(d,n,t) #endif #ifndef Newx # define Newx(v,n,t) New(0,v,n,t) #endif #ifndef Newxc # define Newxc(v,n,t,c) Newc(0,v,n,t,c) #endif #ifndef Newxz # define Newxz(v,n,t) Newz(0,v,n,t) #endif #ifndef PERL_UNUSED_DECL # ifdef HASATTRIBUTE # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER) # define PERL_UNUSED_DECL # else # define PERL_UNUSED_DECL __attribute__((unused)) # endif # else # define PERL_UNUSED_DECL # endif #endif #ifndef PERL_UNUSED_ARG # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */ # include # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) # else # define PERL_UNUSED_ARG(x) ((void)x) # endif #endif #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR(x) ((void)x) #endif #ifndef PERL_UNUSED_CONTEXT # ifdef USE_ITHREADS # define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl) # else # define PERL_UNUSED_CONTEXT # endif #endif #ifndef NOOP # define NOOP /*EMPTY*/(void)0 #endif #ifndef dNOOP # define dNOOP extern int /*@unused@*/ Perl___notused PERL_UNUSED_DECL #endif #ifndef NVTYPE # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) # define NVTYPE long double # else # define NVTYPE double # endif typedef NVTYPE NV; #endif #ifndef INT2PTR # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) # define PTRV UV # define INT2PTR(any,d) (any)(d) # else # if PTRSIZE == LONGSIZE # define PTRV unsigned long # else # define PTRV unsigned # endif # define INT2PTR(any,d) (any)(PTRV)(d) # endif #endif #ifndef PTR2ul # if PTRSIZE == LONGSIZE # define PTR2ul(p) (unsigned long)(p) # else # define PTR2ul(p) INT2PTR(unsigned long,p) # endif #endif #ifndef PTR2nat # define PTR2nat(p) (PTRV)(p) #endif #ifndef NUM2PTR # define NUM2PTR(any,d) (any)PTR2nat(d) #endif #ifndef PTR2IV # define PTR2IV(p) INT2PTR(IV,p) #endif #ifndef PTR2UV # define PTR2UV(p) INT2PTR(UV,p) #endif #ifndef PTR2NV # define PTR2NV(p) NUM2PTR(NV,p) #endif #undef START_EXTERN_C #undef END_EXTERN_C #undef EXTERN_C #ifdef __cplusplus # define START_EXTERN_C extern "C" { # define END_EXTERN_C } # define EXTERN_C extern "C" #else # define START_EXTERN_C # define END_EXTERN_C # define EXTERN_C extern #endif #if defined(PERL_GCC_PEDANTIC) # ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN # define PERL_GCC_BRACE_GROUPS_FORBIDDEN # endif #endif #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus) # ifndef PERL_USE_GCC_BRACE_GROUPS # define PERL_USE_GCC_BRACE_GROUPS # endif #endif #undef STMT_START #undef STMT_END #ifdef PERL_USE_GCC_BRACE_GROUPS # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */ # define STMT_END ) #else # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__) # define STMT_START if (1) # define STMT_END else (void)0 # else # define STMT_START do # define STMT_END while (0) # endif #endif #ifndef boolSV # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no) #endif /* DEFSV appears first in 5.004_56 */ #ifndef DEFSV # define DEFSV GvSV(PL_defgv) #endif #ifndef SAVE_DEFSV # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv)) #endif #ifndef DEFSV_set # define DEFSV_set(sv) (DEFSV = (sv)) #endif /* Older perls (<=5.003) lack AvFILLp */ #ifndef AvFILLp # define AvFILLp AvFILL #endif #ifndef ERRSV # define ERRSV get_sv("@",FALSE) #endif /* Hint: gv_stashpvn * This function's backport doesn't support the length parameter, but * rather ignores it. Portability can only be ensured if the length * parameter is used for speed reasons, but the length can always be * correctly computed from the string argument. */ #ifndef gv_stashpvn # define gv_stashpvn(str,len,create) gv_stashpv(str,create) #endif /* Replace: 1 */ #ifndef get_cv # define get_cv perl_get_cv #endif #ifndef get_sv # define get_sv perl_get_sv #endif #ifndef get_av # define get_av perl_get_av #endif #ifndef get_hv # define get_hv perl_get_hv #endif /* Replace: 0 */ #ifndef dUNDERBAR # define dUNDERBAR dNOOP #endif #ifndef UNDERBAR # define UNDERBAR DEFSV #endif #ifndef dAX # define dAX I32 ax = MARK - PL_stack_base + 1 #endif #ifndef dITEMS # define dITEMS I32 items = SP - MARK #endif #ifndef dXSTARG # define dXSTARG SV * targ = sv_newmortal() #endif #ifndef dAXMARK # define dAXMARK I32 ax = POPMARK; \ register SV ** const mark = PL_stack_base + ax++ #endif #ifndef XSprePUSH # define XSprePUSH (sp = PL_stack_base + ax - 1) #endif #if (PERL_BCDVERSION < 0x5005000) # undef XSRETURN # define XSRETURN(off) \ STMT_START { \ PL_stack_sp = PL_stack_base + ax + ((off) - 1); \ return; \ } STMT_END #endif #ifndef XSPROTO # define XSPROTO(name) void name(pTHX_ CV* cv) #endif #ifndef SVfARG # define SVfARG(p) ((void*)(p)) #endif #ifndef PERL_ABS # define PERL_ABS(x) ((x) < 0 ? -(x) : (x)) #endif #ifndef dVAR # define dVAR dNOOP #endif #ifndef SVf # define SVf "_" #endif #ifndef UTF8_MAXBYTES # define UTF8_MAXBYTES UTF8_MAXLEN #endif #ifndef CPERLscope # define CPERLscope(x) x #endif #ifndef PERL_HASH # define PERL_HASH(hash,str,len) \ STMT_START { \ const char *s_PeRlHaSh = str; \ I32 i_PeRlHaSh = len; \ U32 hash_PeRlHaSh = 0; \ while (i_PeRlHaSh--) \ hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \ (hash) = hash_PeRlHaSh; \ } STMT_END #endif #ifndef PERLIO_FUNCS_DECL # ifdef PERLIO_FUNCS_CONST # define PERLIO_FUNCS_DECL(funcs) const PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (PerlIO_funcs*)(funcs) # else # define PERLIO_FUNCS_DECL(funcs) PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (funcs) # endif #endif /* provide these typedefs for older perls */ #if (PERL_BCDVERSION < 0x5009003) # ifdef ARGSproto typedef OP* (CPERLscope(*Perl_ppaddr_t))(ARGSproto); # else typedef OP* (CPERLscope(*Perl_ppaddr_t))(pTHX); # endif typedef OP* (CPERLscope(*Perl_check_t)) (pTHX_ OP*); #endif #ifndef isPSXSPC # define isPSXSPC(c) (isSPACE(c) || (c) == '\v') #endif #ifndef isBLANK # define isBLANK(c) ((c) == ' ' || (c) == '\t') #endif #ifdef EBCDIC #ifndef isALNUMC # define isALNUMC(c) isalnum(c) #endif #ifndef isASCII # define isASCII(c) isascii(c) #endif #ifndef isCNTRL # define isCNTRL(c) iscntrl(c) #endif #ifndef isGRAPH # define isGRAPH(c) isgraph(c) #endif #ifndef isPRINT # define isPRINT(c) isprint(c) #endif #ifndef isPUNCT # define isPUNCT(c) ispunct(c) #endif #ifndef isXDIGIT # define isXDIGIT(c) isxdigit(c) #endif #else # if (PERL_BCDVERSION < 0x5010000) /* Hint: isPRINT * The implementation in older perl versions includes all of the * isSPACE() characters, which is wrong. The version provided by * Devel::PPPort always overrides a present buggy version. */ # undef isPRINT # endif #ifndef isALNUMC # define isALNUMC(c) (isALPHA(c) || isDIGIT(c)) #endif #ifndef isASCII # define isASCII(c) ((c) <= 127) #endif #ifndef isCNTRL # define isCNTRL(c) ((c) < ' ' || (c) == 127) #endif #ifndef isGRAPH # define isGRAPH(c) (isALNUM(c) || isPUNCT(c)) #endif #ifndef isPRINT # define isPRINT(c) (((c) >= 32 && (c) < 127)) #endif #ifndef isPUNCT # define isPUNCT(c) (((c) >= 33 && (c) <= 47) || ((c) >= 58 && (c) <= 64) || ((c) >= 91 && (c) <= 96) || ((c) >= 123 && (c) <= 126)) #endif #ifndef isXDIGIT # define isXDIGIT(c) (isDIGIT(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) #endif #endif #ifndef PERL_SIGNALS_UNSAFE_FLAG #define PERL_SIGNALS_UNSAFE_FLAG 0x0001 #if (PERL_BCDVERSION < 0x5008000) # define D_PPP_PERL_SIGNALS_INIT PERL_SIGNALS_UNSAFE_FLAG #else # define D_PPP_PERL_SIGNALS_INIT 0 #endif #if defined(NEED_PL_signals) static U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #elif defined(NEED_PL_signals_GLOBAL) U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #else extern U32 DPPP_(my_PL_signals); #endif #define PL_signals DPPP_(my_PL_signals) #endif /* Hint: PL_ppaddr * Calling an op via PL_ppaddr requires passing a context argument * for threaded builds. Since the context argument is different for * 5.005 perls, you can use aTHXR (supplied by ppport.h), which will * automatically be defined as the correct argument. */ #if (PERL_BCDVERSION <= 0x5005005) /* Replace: 1 */ # define PL_ppaddr ppaddr # define PL_no_modify no_modify /* Replace: 0 */ #endif #if (PERL_BCDVERSION <= 0x5004005) /* Replace: 1 */ # define PL_DBsignal DBsignal # define PL_DBsingle DBsingle # define PL_DBsub DBsub # define PL_DBtrace DBtrace # define PL_Sv Sv # define PL_bufend bufend # define PL_bufptr bufptr # define PL_compiling compiling # define PL_copline copline # define PL_curcop curcop # define PL_curstash curstash # define PL_debstash debstash # define PL_defgv defgv # define PL_diehook diehook # define PL_dirty dirty # define PL_dowarn dowarn # define PL_errgv errgv # define PL_error_count error_count # define PL_expect expect # define PL_hexdigit hexdigit # define PL_hints hints # define PL_in_my in_my # define PL_laststatval laststatval # define PL_lex_state lex_state # define PL_lex_stuff lex_stuff # define PL_linestr linestr # define PL_na na # define PL_perl_destruct_level perl_destruct_level # define PL_perldb perldb # define PL_rsfp_filters rsfp_filters # define PL_rsfp rsfp # define PL_stack_base stack_base # define PL_stack_sp stack_sp # define PL_statcache statcache # define PL_stdingv stdingv # define PL_sv_arenaroot sv_arenaroot # define PL_sv_no sv_no # define PL_sv_undef sv_undef # define PL_sv_yes sv_yes # define PL_tainted tainted # define PL_tainting tainting # define PL_tokenbuf tokenbuf /* Replace: 0 */ #endif /* Warning: PL_parser * For perl versions earlier than 5.9.5, this is an always * non-NULL dummy. Also, it cannot be dereferenced. Don't * use it if you can avoid is and unless you absolutely know * what you're doing. * If you always check that PL_parser is non-NULL, you can * define DPPP_PL_parser_NO_DUMMY to avoid the creation of * a dummy parser structure. */ #if (PERL_BCDVERSION >= 0x5009005) # ifdef DPPP_PL_parser_NO_DUMMY # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (croak("panic: PL_parser == NULL in %s:%d", \ __FILE__, __LINE__), (yy_parser *) NULL))->var) # else # ifdef DPPP_PL_parser_NO_DUMMY_WARNING # define D_PPP_parser_dummy_warning(var) # else # define D_PPP_parser_dummy_warning(var) \ warn("warning: dummy PL_" #var " used in %s:%d", __FILE__, __LINE__), # endif # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (D_PPP_parser_dummy_warning(var) &DPPP_(dummy_PL_parser)))->var) #if defined(NEED_PL_parser) static yy_parser DPPP_(dummy_PL_parser); #elif defined(NEED_PL_parser_GLOBAL) yy_parser DPPP_(dummy_PL_parser); #else extern yy_parser DPPP_(dummy_PL_parser); #endif # endif /* PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf depends on PL_parser */ /* Warning: PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf * Do not use this variable unless you know exactly what you're * doint. It is internal to the perl parser and may change or even * be removed in the future. As of perl 5.9.5, you have to check * for (PL_parser != NULL) for this variable to have any effect. * An always non-NULL PL_parser dummy is provided for earlier * perl versions. * If PL_parser is NULL when you try to access this variable, a * dummy is being accessed instead and a warning is issued unless * you define DPPP_PL_parser_NO_DUMMY_WARNING. * If DPPP_PL_parser_NO_DUMMY is defined, the code trying to access * this variable will croak with a panic message. */ # define PL_expect D_PPP_my_PL_parser_var(expect) # define PL_copline D_PPP_my_PL_parser_var(copline) # define PL_rsfp D_PPP_my_PL_parser_var(rsfp) # define PL_rsfp_filters D_PPP_my_PL_parser_var(rsfp_filters) # define PL_linestr D_PPP_my_PL_parser_var(linestr) # define PL_bufptr D_PPP_my_PL_parser_var(bufptr) # define PL_bufend D_PPP_my_PL_parser_var(bufend) # define PL_lex_state D_PPP_my_PL_parser_var(lex_state) # define PL_lex_stuff D_PPP_my_PL_parser_var(lex_stuff) # define PL_tokenbuf D_PPP_my_PL_parser_var(tokenbuf) # define PL_in_my D_PPP_my_PL_parser_var(in_my) # define PL_in_my_stash D_PPP_my_PL_parser_var(in_my_stash) # define PL_error_count D_PPP_my_PL_parser_var(error_count) #else /* ensure that PL_parser != NULL and cannot be dereferenced */ # define PL_parser ((void *) 1) #endif #ifndef mPUSHs # define mPUSHs(s) PUSHs(sv_2mortal(s)) #endif #ifndef PUSHmortal # define PUSHmortal PUSHs(sv_newmortal()) #endif #ifndef mPUSHp # define mPUSHp(p,l) sv_setpvn(PUSHmortal, (p), (l)) #endif #ifndef mPUSHn # define mPUSHn(n) sv_setnv(PUSHmortal, (NV)(n)) #endif #ifndef mPUSHi # define mPUSHi(i) sv_setiv(PUSHmortal, (IV)(i)) #endif #ifndef mPUSHu # define mPUSHu(u) sv_setuv(PUSHmortal, (UV)(u)) #endif #ifndef mXPUSHs # define mXPUSHs(s) XPUSHs(sv_2mortal(s)) #endif #ifndef XPUSHmortal # define XPUSHmortal XPUSHs(sv_newmortal()) #endif #ifndef mXPUSHp # define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn(PUSHmortal, (p), (l)); } STMT_END #endif #ifndef mXPUSHn # define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END #endif #ifndef mXPUSHi # define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END #endif #ifndef mXPUSHu # define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END #endif /* Replace: 1 */ #ifndef call_sv # define call_sv perl_call_sv #endif #ifndef call_pv # define call_pv perl_call_pv #endif #ifndef call_argv # define call_argv perl_call_argv #endif #ifndef call_method # define call_method perl_call_method #endif #ifndef eval_sv # define eval_sv perl_eval_sv #endif /* Replace: 0 */ #ifndef PERL_LOADMOD_DENY # define PERL_LOADMOD_DENY 0x1 #endif #ifndef PERL_LOADMOD_NOIMPORT # define PERL_LOADMOD_NOIMPORT 0x2 #endif #ifndef PERL_LOADMOD_IMPORT_OPS # define PERL_LOADMOD_IMPORT_OPS 0x4 #endif #ifndef G_METHOD # define G_METHOD 64 # ifdef call_sv # undef call_sv # endif # if (PERL_BCDVERSION < 0x5006000) # define call_sv(sv, flags) ((flags) & G_METHOD ? perl_call_method((char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : perl_call_sv(sv, flags)) # else # define call_sv(sv, flags) ((flags) & G_METHOD ? Perl_call_method(aTHX_ (char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : Perl_call_sv(aTHX_ sv, flags)) # endif #endif /* Replace perl_eval_pv with eval_pv */ #ifndef eval_pv #if defined(NEED_eval_pv) static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); static #else extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); #endif #ifdef eval_pv # undef eval_pv #endif #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b) #define Perl_eval_pv DPPP_(my_eval_pv) #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL) SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error) { dSP; SV* sv = newSVpv(p, 0); PUSHMARK(sp); eval_sv(sv, G_SCALAR); SvREFCNT_dec(sv); SPAGAIN; sv = POPs; PUTBACK; if (croak_on_error && SvTRUE(GvSV(errgv))) croak(SvPVx(GvSV(errgv), na)); return sv; } #endif #endif #ifndef vload_module #if defined(NEED_vload_module) static void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); static #else extern void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); #endif #ifdef vload_module # undef vload_module #endif #define vload_module(a,b,c,d) DPPP_(my_vload_module)(aTHX_ a,b,c,d) #define Perl_vload_module DPPP_(my_vload_module) #if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL) void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args) { dTHR; dVAR; OP *veop, *imop; OP * const modname = newSVOP(OP_CONST, 0, name); /* 5.005 has a somewhat hacky force_normal that doesn't croak on SvREADONLY() if PL_compling is true. Current perls take care in ck_require() to correctly turn off SvREADONLY before calling force_normal_flags(). This seems a better fix than fudging PL_compling */ SvREADONLY_off(((SVOP*)modname)->op_sv); modname->op_private |= OPpCONST_BARE; if (ver) { veop = newSVOP(OP_CONST, 0, ver); } else veop = NULL; if (flags & PERL_LOADMOD_NOIMPORT) { imop = sawparens(newNULLLIST()); } else if (flags & PERL_LOADMOD_IMPORT_OPS) { imop = va_arg(*args, OP*); } else { SV *sv; imop = NULL; sv = va_arg(*args, SV*); while (sv) { imop = append_elem(OP_LIST, imop, newSVOP(OP_CONST, 0, sv)); sv = va_arg(*args, SV*); } } { const line_t ocopline = PL_copline; COP * const ocurcop = PL_curcop; const int oexpect = PL_expect; #if (PERL_BCDVERSION >= 0x5004000) utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(FALSE, 0), veop, modname, imop); #else utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(), modname, imop); #endif PL_expect = oexpect; PL_copline = ocopline; PL_curcop = ocurcop; } } #endif #endif #ifndef load_module #if defined(NEED_load_module) static void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); static #else extern void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); #endif #ifdef load_module # undef load_module #endif #define load_module DPPP_(my_load_module) #define Perl_load_module DPPP_(my_load_module) #if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL) void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...) { va_list args; va_start(args, ver); vload_module(flags, name, ver, &args); va_end(args); } #endif #endif #ifndef newRV_inc # define newRV_inc(sv) newRV(sv) /* Replace */ #endif #ifndef newRV_noinc #if defined(NEED_newRV_noinc) static SV * DPPP_(my_newRV_noinc)(SV *sv); static #else extern SV * DPPP_(my_newRV_noinc)(SV *sv); #endif #ifdef newRV_noinc # undef newRV_noinc #endif #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a) #define Perl_newRV_noinc DPPP_(my_newRV_noinc) #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL) SV * DPPP_(my_newRV_noinc)(SV *sv) { SV *rv = (SV *)newRV(sv); SvREFCNT_dec(sv); return rv; } #endif #endif /* Hint: newCONSTSUB * Returns a CV* as of perl-5.7.1. This return value is not supported * by Devel::PPPort. */ /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */ #if (PERL_BCDVERSION < 0x5004063) && (PERL_BCDVERSION != 0x5004005) #if defined(NEED_newCONSTSUB) static void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); static #else extern void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); #endif #ifdef newCONSTSUB # undef newCONSTSUB #endif #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c) #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB) #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) /* This is just a trick to avoid a dependency of newCONSTSUB on PL_parser */ /* (There's no PL_parser in perl < 5.005, so this is completely safe) */ #define D_PPP_PL_copline PL_copline void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv) { U32 oldhints = PL_hints; HV *old_cop_stash = PL_curcop->cop_stash; HV *old_curstash = PL_curstash; line_t oldline = PL_curcop->cop_line; PL_curcop->cop_line = D_PPP_PL_copline; PL_hints &= ~HINT_BLOCK_SCOPE; if (stash) PL_curstash = PL_curcop->cop_stash = stash; newSUB( #if (PERL_BCDVERSION < 0x5003022) start_subparse(), #elif (PERL_BCDVERSION == 0x5003022) start_subparse(0), #else /* 5.003_23 onwards */ start_subparse(FALSE, 0), #endif newSVOP(OP_CONST, 0, newSVpv((char *) name, 0)), newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */ newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) ); PL_hints = oldhints; PL_curcop->cop_stash = old_cop_stash; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; } #endif #endif /* * Boilerplate macros for initializing and accessing interpreter-local * data from C. All statics in extensions should be reworked to use * this, if you want to make the extension thread-safe. See ext/re/re.xs * for an example of the use of these macros. * * Code that uses these macros is responsible for the following: * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts" * 2. Declare a typedef named my_cxt_t that is a structure that contains * all the data that needs to be interpreter-local. * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t. * 4. Use the MY_CXT_INIT macro such that it is called exactly once * (typically put in the BOOT: section). * 5. Use the members of the my_cxt_t structure everywhere as * MY_CXT.member. * 6. Use the dMY_CXT macro (a declaration) in all the functions that * access MY_CXT. */ #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \ defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT) #ifndef START_MY_CXT /* This must appear in all extensions that define a my_cxt_t structure, * right after the definition (i.e. at file scope). The non-threads * case below uses it to declare the data as static. */ #define START_MY_CXT #if (PERL_BCDVERSION < 0x5004068) /* Fetches the SV that keeps the per-interpreter data. */ #define dMY_CXT_SV \ SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE) #else /* >= perl5.004_68 */ #define dMY_CXT_SV \ SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \ sizeof(MY_CXT_KEY)-1, TRUE) #endif /* < perl5.004_68 */ /* This declaration should be used within all functions that use the * interpreter-local data. */ #define dMY_CXT \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv)) /* Creates and zeroes the per-interpreter data. * (We allocate my_cxtp in a Perl SV so that it will be released when * the interpreter goes away.) */ #define MY_CXT_INIT \ dMY_CXT_SV; \ /* newSV() allocates one more than needed */ \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Zero(my_cxtp, 1, my_cxt_t); \ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) /* This macro must be used to access members of the my_cxt_t structure. * e.g. MYCXT.some_data */ #define MY_CXT (*my_cxtp) /* Judicious use of these macros can reduce the number of times dMY_CXT * is used. Use is similar to pTHX, aTHX etc. */ #define pMY_CXT my_cxt_t *my_cxtp #define pMY_CXT_ pMY_CXT, #define _pMY_CXT ,pMY_CXT #define aMY_CXT my_cxtp #define aMY_CXT_ aMY_CXT, #define _aMY_CXT ,aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE /* Clones the per-interpreter data. */ #define MY_CXT_CLONE \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) #endif #else /* single interpreter */ #ifndef START_MY_CXT #define START_MY_CXT static my_cxt_t my_cxt; #define dMY_CXT_SV dNOOP #define dMY_CXT dNOOP #define MY_CXT_INIT NOOP #define MY_CXT my_cxt #define pMY_CXT void #define pMY_CXT_ #define _pMY_CXT #define aMY_CXT #define aMY_CXT_ #define _aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE #define MY_CXT_CLONE NOOP #endif #endif #ifndef IVdf # if IVSIZE == LONGSIZE # define IVdf "ld" # define UVuf "lu" # define UVof "lo" # define UVxf "lx" # define UVXf "lX" # else # if IVSIZE == INTSIZE # define IVdf "d" # define UVuf "u" # define UVof "o" # define UVxf "x" # define UVXf "X" # endif # endif #endif #ifndef NVef # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \ defined(PERL_PRIfldbl) && (PERL_BCDVERSION != 0x5006000) /* Not very likely, but let's try anyway. */ # define NVef PERL_PRIeldbl # define NVff PERL_PRIfldbl # define NVgf PERL_PRIgldbl # else # define NVef "e" # define NVff "f" # define NVgf "g" # endif #endif #ifndef SvREFCNT_inc # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (SvREFCNT(_sv))++; \ _sv; \ }) # else # define SvREFCNT_inc(sv) \ ((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL) # endif #endif #ifndef SvREFCNT_inc_simple # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_simple(sv) \ ({ \ if (sv) \ (SvREFCNT(sv))++; \ (SV *)(sv); \ }) # else # define SvREFCNT_inc_simple(sv) \ ((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL) # endif #endif #ifndef SvREFCNT_inc_NN # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_NN(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ SvREFCNT(_sv)++; \ _sv; \ }) # else # define SvREFCNT_inc_NN(sv) \ (PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv) # endif #endif #ifndef SvREFCNT_inc_void # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_void(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (void)(SvREFCNT(_sv)++); \ }) # else # define SvREFCNT_inc_void(sv) \ (void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0) # endif #endif #ifndef SvREFCNT_inc_simple_void # define SvREFCNT_inc_simple_void(sv) STMT_START { if (sv) SvREFCNT(sv)++; } STMT_END #endif #ifndef SvREFCNT_inc_simple_NN # define SvREFCNT_inc_simple_NN(sv) (++SvREFCNT(sv), (SV*)(sv)) #endif #ifndef SvREFCNT_inc_void_NN # define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef SvREFCNT_inc_simple_void_NN # define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef newSV_type #if defined(NEED_newSV_type) static SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); static #else extern SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); #endif #ifdef newSV_type # undef newSV_type #endif #define newSV_type(a) DPPP_(my_newSV_type)(aTHX_ a) #define Perl_newSV_type DPPP_(my_newSV_type) #if defined(NEED_newSV_type) || defined(NEED_newSV_type_GLOBAL) SV* DPPP_(my_newSV_type)(pTHX_ svtype const t) { SV* const sv = newSV(0); sv_upgrade(sv, t); return sv; } #endif #endif #if (PERL_BCDVERSION < 0x5006000) # define D_PPP_CONSTPV_ARG(x) ((char *) (x)) #else # define D_PPP_CONSTPV_ARG(x) (x) #endif #ifndef newSVpvn # define newSVpvn(data,len) ((data) \ ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \ : newSV(0)) #endif #ifndef newSVpvn_utf8 # define newSVpvn_utf8(s, len, u) newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0) #endif #ifndef SVf_UTF8 # define SVf_UTF8 0 #endif #ifndef newSVpvn_flags #if defined(NEED_newSVpvn_flags) static SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); static #else extern SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); #endif #ifdef newSVpvn_flags # undef newSVpvn_flags #endif #define newSVpvn_flags(a,b,c) DPPP_(my_newSVpvn_flags)(aTHX_ a,b,c) #define Perl_newSVpvn_flags DPPP_(my_newSVpvn_flags) #if defined(NEED_newSVpvn_flags) || defined(NEED_newSVpvn_flags_GLOBAL) SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags) { SV *sv = newSVpvn(D_PPP_CONSTPV_ARG(s), len); SvFLAGS(sv) |= (flags & SVf_UTF8); return (flags & SVs_TEMP) ? sv_2mortal(sv) : sv; } #endif #endif /* Backwards compatibility stuff... :-( */ #if !defined(NEED_sv_2pv_flags) && defined(NEED_sv_2pv_nolen) # define NEED_sv_2pv_flags #endif #if !defined(NEED_sv_2pv_flags_GLOBAL) && defined(NEED_sv_2pv_nolen_GLOBAL) # define NEED_sv_2pv_flags_GLOBAL #endif /* Hint: sv_2pv_nolen * Use the SvPV_nolen() or SvPV_nolen_const() macros instead of sv_2pv_nolen(). */ #ifndef sv_2pv_nolen # define sv_2pv_nolen(sv) SvPV_nolen(sv) #endif #ifdef SvPVbyte /* Hint: SvPVbyte * Does not work in perl-5.6.1, ppport.h implements a version * borrowed from perl-5.7.3. */ #if (PERL_BCDVERSION < 0x5007000) #if defined(NEED_sv_2pvbyte) static char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); static #else extern char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); #endif #ifdef sv_2pvbyte # undef sv_2pvbyte #endif #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b) #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte) #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL) char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp) { sv_utf8_downgrade(sv,0); return SvPV(sv,*lp); } #endif /* Hint: sv_2pvbyte * Use the SvPVbyte() macro instead of sv_2pvbyte(). */ #undef SvPVbyte #define SvPVbyte(sv, lp) \ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp)) #endif #else # define SvPVbyte SvPV # define sv_2pvbyte sv_2pv #endif #ifndef sv_2pvbyte_nolen # define sv_2pvbyte_nolen(sv) sv_2pv_nolen(sv) #endif /* Hint: sv_pvn * Always use the SvPV() macro instead of sv_pvn(). */ /* Hint: sv_pvn_force * Always use the SvPV_force() macro instead of sv_pvn_force(). */ /* If these are undefined, they're not handled by the core anyway */ #ifndef SV_IMMEDIATE_UNREF # define SV_IMMEDIATE_UNREF 0 #endif #ifndef SV_GMAGIC # define SV_GMAGIC 0 #endif #ifndef SV_COW_DROP_PV # define SV_COW_DROP_PV 0 #endif #ifndef SV_UTF8_NO_ENCODING # define SV_UTF8_NO_ENCODING 0 #endif #ifndef SV_NOSTEAL # define SV_NOSTEAL 0 #endif #ifndef SV_CONST_RETURN # define SV_CONST_RETURN 0 #endif #ifndef SV_MUTABLE_RETURN # define SV_MUTABLE_RETURN 0 #endif #ifndef SV_SMAGIC # define SV_SMAGIC 0 #endif #ifndef SV_HAS_TRAILING_NUL # define SV_HAS_TRAILING_NUL 0 #endif #ifndef SV_COW_SHARED_HASH_KEYS # define SV_COW_SHARED_HASH_KEYS 0 #endif #if (PERL_BCDVERSION < 0x5007002) #if defined(NEED_sv_2pv_flags) static char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_2pv_flags # undef sv_2pv_flags #endif #define sv_2pv_flags(a,b,c) DPPP_(my_sv_2pv_flags)(aTHX_ a,b,c) #define Perl_sv_2pv_flags DPPP_(my_sv_2pv_flags) #if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL) char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_2pv(sv, lp ? lp : &n_a); } #endif #if defined(NEED_sv_pvn_force_flags) static char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_pvn_force_flags # undef sv_pvn_force_flags #endif #define sv_pvn_force_flags(a,b,c) DPPP_(my_sv_pvn_force_flags)(aTHX_ a,b,c) #define Perl_sv_pvn_force_flags DPPP_(my_sv_pvn_force_flags) #if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL) char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_pvn_force(sv, lp ? lp : &n_a); } #endif #endif #if (PERL_BCDVERSION < 0x5008008) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5009003) ) # define DPPP_SVPV_NOLEN_LP_ARG &PL_na #else # define DPPP_SVPV_NOLEN_LP_ARG 0 #endif #ifndef SvPV_const # define SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_mutable # define SvPV_mutable(sv, lp) SvPV_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_flags # define SvPV_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv_flags(sv, &lp, flags)) #endif #ifndef SvPV_flags_const # define SvPV_flags_const(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_const(sv)) : \ (const char*) sv_2pv_flags(sv, &lp, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_const_nolen # define SvPV_flags_const_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : \ (const char*) sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_mutable # define SvPV_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) : \ sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_force # define SvPV_force(sv, lp) SvPV_force_flags(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nolen # define SvPV_force_nolen(sv) SvPV_force_flags_nolen(sv, SV_GMAGIC) #endif #ifndef SvPV_force_mutable # define SvPV_force_mutable(sv, lp) SvPV_force_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nomg # define SvPV_force_nomg(sv, lp) SvPV_force_flags(sv, lp, 0) #endif #ifndef SvPV_force_nomg_nolen # define SvPV_force_nomg_nolen(sv) SvPV_force_flags_nolen(sv, 0) #endif #ifndef SvPV_force_flags # define SvPV_force_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force_flags(sv, &lp, flags)) #endif #ifndef SvPV_force_flags_nolen # define SvPV_force_flags_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? SvPVX(sv) : sv_pvn_force_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags)) #endif #ifndef SvPV_force_flags_mutable # define SvPV_force_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) \ : sv_pvn_force_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_nolen # define SvPV_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC)) #endif #ifndef SvPV_nolen_const # define SvPV_nolen_const(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC|SV_CONST_RETURN)) #endif #ifndef SvPV_nomg # define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0) #endif #ifndef SvPV_nomg_const # define SvPV_nomg_const(sv, lp) SvPV_flags_const(sv, lp, 0) #endif #ifndef SvPV_nomg_const_nolen # define SvPV_nomg_const_nolen(sv) SvPV_flags_const_nolen(sv, 0) #endif #ifndef SvPV_renew # define SvPV_renew(sv,n) STMT_START { SvLEN_set(sv, n); \ SvPV_set((sv), (char *) saferealloc( \ (Malloc_t)SvPVX(sv), (MEM_SIZE)((n)))); \ } STMT_END #endif #ifndef SvMAGIC_set # define SvMAGIC_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5009003) #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*) (0 + SvPVX(sv))) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) (0 + SvPVX(sv)) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ (((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END #endif #else #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv)) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ ((sv)->sv_u.svu_rv = (val)); } STMT_END #endif #endif #ifndef SvSTASH_set # define SvSTASH_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5004000) #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END #endif #else #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(vnewSVpvf) #if defined(NEED_vnewSVpvf) static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); static #else extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); #endif #ifdef vnewSVpvf # undef vnewSVpvf #endif #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b) #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf) #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL) SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args) { register SV *sv = newSV(0); sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); return sv; } #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf) # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf) # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL) void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) static void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_catpvf_mg depends on sv_catpvf_mg_nocontext */ #ifndef sv_catpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext # else # define sv_catpvf_mg Perl_sv_catpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf_mg) # define sv_vcatpvf_mg(sv, pat, args) \ STMT_START { \ sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL) void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) static void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_setpvf_mg depends on sv_setpvf_mg_nocontext */ #ifndef sv_setpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext # else # define sv_setpvf_mg Perl_sv_setpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf_mg) # define sv_vsetpvf_mg(sv, pat, args) \ STMT_START { \ sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif #ifndef newSVpvn_share #if defined(NEED_newSVpvn_share) static SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); static #else extern SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); #endif #ifdef newSVpvn_share # undef newSVpvn_share #endif #define newSVpvn_share(a,b,c) DPPP_(my_newSVpvn_share)(aTHX_ a,b,c) #define Perl_newSVpvn_share DPPP_(my_newSVpvn_share) #if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL) SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash) { SV *sv; if (len < 0) len = -len; if (!hash) PERL_HASH(hash, (char*) src, len); sv = newSVpvn((char *) src, len); sv_upgrade(sv, SVt_PVIV); SvIVX(sv) = hash; SvREADONLY_on(sv); SvPOK_on(sv); return sv; } #endif #endif #ifndef SvSHARED_HASH # define SvSHARED_HASH(sv) (0 + SvUVX(sv)) #endif #ifndef HvNAME_get # define HvNAME_get(hv) HvNAME(hv) #endif #ifndef HvNAMELEN_get # define HvNAMELEN_get(hv) (HvNAME_get(hv) ? (I32)strlen(HvNAME_get(hv)) : 0) #endif #ifndef GvSVn # define GvSVn(gv) GvSV(gv) #endif #ifndef isGV_with_GP # define isGV_with_GP(gv) isGV(gv) #endif #ifndef WARN_ALL # define WARN_ALL 0 #endif #ifndef WARN_CLOSURE # define WARN_CLOSURE 1 #endif #ifndef WARN_DEPRECATED # define WARN_DEPRECATED 2 #endif #ifndef WARN_EXITING # define WARN_EXITING 3 #endif #ifndef WARN_GLOB # define WARN_GLOB 4 #endif #ifndef WARN_IO # define WARN_IO 5 #endif #ifndef WARN_CLOSED # define WARN_CLOSED 6 #endif #ifndef WARN_EXEC # define WARN_EXEC 7 #endif #ifndef WARN_LAYER # define WARN_LAYER 8 #endif #ifndef WARN_NEWLINE # define WARN_NEWLINE 9 #endif #ifndef WARN_PIPE # define WARN_PIPE 10 #endif #ifndef WARN_UNOPENED # define WARN_UNOPENED 11 #endif #ifndef WARN_MISC # define WARN_MISC 12 #endif #ifndef WARN_NUMERIC # define WARN_NUMERIC 13 #endif #ifndef WARN_ONCE # define WARN_ONCE 14 #endif #ifndef WARN_OVERFLOW # define WARN_OVERFLOW 15 #endif #ifndef WARN_PACK # define WARN_PACK 16 #endif #ifndef WARN_PORTABLE # define WARN_PORTABLE 17 #endif #ifndef WARN_RECURSION # define WARN_RECURSION 18 #endif #ifndef WARN_REDEFINE # define WARN_REDEFINE 19 #endif #ifndef WARN_REGEXP # define WARN_REGEXP 20 #endif #ifndef WARN_SEVERE # define WARN_SEVERE 21 #endif #ifndef WARN_DEBUGGING # define WARN_DEBUGGING 22 #endif #ifndef WARN_INPLACE # define WARN_INPLACE 23 #endif #ifndef WARN_INTERNAL # define WARN_INTERNAL 24 #endif #ifndef WARN_MALLOC # define WARN_MALLOC 25 #endif #ifndef WARN_SIGNAL # define WARN_SIGNAL 26 #endif #ifndef WARN_SUBSTR # define WARN_SUBSTR 27 #endif #ifndef WARN_SYNTAX # define WARN_SYNTAX 28 #endif #ifndef WARN_AMBIGUOUS # define WARN_AMBIGUOUS 29 #endif #ifndef WARN_BAREWORD # define WARN_BAREWORD 30 #endif #ifndef WARN_DIGIT # define WARN_DIGIT 31 #endif #ifndef WARN_PARENTHESIS # define WARN_PARENTHESIS 32 #endif #ifndef WARN_PRECEDENCE # define WARN_PRECEDENCE 33 #endif #ifndef WARN_PRINTF # define WARN_PRINTF 34 #endif #ifndef WARN_PROTOTYPE # define WARN_PROTOTYPE 35 #endif #ifndef WARN_QW # define WARN_QW 36 #endif #ifndef WARN_RESERVED # define WARN_RESERVED 37 #endif #ifndef WARN_SEMICOLON # define WARN_SEMICOLON 38 #endif #ifndef WARN_TAINT # define WARN_TAINT 39 #endif #ifndef WARN_THREADS # define WARN_THREADS 40 #endif #ifndef WARN_UNINITIALIZED # define WARN_UNINITIALIZED 41 #endif #ifndef WARN_UNPACK # define WARN_UNPACK 42 #endif #ifndef WARN_UNTIE # define WARN_UNTIE 43 #endif #ifndef WARN_UTF8 # define WARN_UTF8 44 #endif #ifndef WARN_VOID # define WARN_VOID 45 #endif #ifndef WARN_ASSERTIONS # define WARN_ASSERTIONS 46 #endif #ifndef packWARN # define packWARN(a) (a) #endif #ifndef ckWARN # ifdef G_WARN_ON # define ckWARN(a) (PL_dowarn & G_WARN_ON) # else # define ckWARN(a) PL_dowarn # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(warner) #if defined(NEED_warner) static void DPPP_(my_warner)(U32 err, const char *pat, ...); static #else extern void DPPP_(my_warner)(U32 err, const char *pat, ...); #endif #define Perl_warner DPPP_(my_warner) #if defined(NEED_warner) || defined(NEED_warner_GLOBAL) void DPPP_(my_warner)(U32 err, const char *pat, ...) { SV *sv; va_list args; PERL_UNUSED_ARG(err); va_start(args, pat); sv = vnewSVpvf(pat, &args); va_end(args); sv_2mortal(sv); warn("%s", SvPV_nolen(sv)); } #define warner Perl_warner #define Perl_warner_nocontext Perl_warner #endif #endif /* concatenating with "" ensures that only literal strings are accepted as argument * note that STR_WITH_LEN() can't be used as argument to macros or functions that * under some configurations might be macros */ #ifndef STR_WITH_LEN # define STR_WITH_LEN(s) (s ""), (sizeof(s)-1) #endif #ifndef newSVpvs # define newSVpvs(str) newSVpvn(str "", sizeof(str) - 1) #endif #ifndef newSVpvs_flags # define newSVpvs_flags(str, flags) newSVpvn_flags(str "", sizeof(str) - 1, flags) #endif #ifndef sv_catpvs # define sv_catpvs(sv, str) sv_catpvn(sv, str "", sizeof(str) - 1) #endif #ifndef sv_setpvs # define sv_setpvs(sv, str) sv_setpvn(sv, str "", sizeof(str) - 1) #endif #ifndef hv_fetchs # define hv_fetchs(hv, key, lval) hv_fetch(hv, key "", sizeof(key) - 1, lval) #endif #ifndef hv_stores # define hv_stores(hv, key, val) hv_store(hv, key "", sizeof(key) - 1, val, 0) #endif #ifndef gv_fetchpvn_flags # define gv_fetchpvn_flags(name, len, flags, svt) gv_fetchpv(name, flags, svt) #endif #ifndef gv_fetchpvs # define gv_fetchpvs(name, flags, svt) gv_fetchpvn_flags(name "", sizeof(name) - 1, flags, svt) #endif #ifndef gv_stashpvs # define gv_stashpvs(name, flags) gv_stashpvn(name "", sizeof(name) - 1, flags) #endif #ifndef SvGETMAGIC # define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END #endif #ifndef PERL_MAGIC_sv # define PERL_MAGIC_sv '\0' #endif #ifndef PERL_MAGIC_overload # define PERL_MAGIC_overload 'A' #endif #ifndef PERL_MAGIC_overload_elem # define PERL_MAGIC_overload_elem 'a' #endif #ifndef PERL_MAGIC_overload_table # define PERL_MAGIC_overload_table 'c' #endif #ifndef PERL_MAGIC_bm # define PERL_MAGIC_bm 'B' #endif #ifndef PERL_MAGIC_regdata # define PERL_MAGIC_regdata 'D' #endif #ifndef PERL_MAGIC_regdatum # define PERL_MAGIC_regdatum 'd' #endif #ifndef PERL_MAGIC_env # define PERL_MAGIC_env 'E' #endif #ifndef PERL_MAGIC_envelem # define PERL_MAGIC_envelem 'e' #endif #ifndef PERL_MAGIC_fm # define PERL_MAGIC_fm 'f' #endif #ifndef PERL_MAGIC_regex_global # define PERL_MAGIC_regex_global 'g' #endif #ifndef PERL_MAGIC_isa # define PERL_MAGIC_isa 'I' #endif #ifndef PERL_MAGIC_isaelem # define PERL_MAGIC_isaelem 'i' #endif #ifndef PERL_MAGIC_nkeys # define PERL_MAGIC_nkeys 'k' #endif #ifndef PERL_MAGIC_dbfile # define PERL_MAGIC_dbfile 'L' #endif #ifndef PERL_MAGIC_dbline # define PERL_MAGIC_dbline 'l' #endif #ifndef PERL_MAGIC_mutex # define PERL_MAGIC_mutex 'm' #endif #ifndef PERL_MAGIC_shared # define PERL_MAGIC_shared 'N' #endif #ifndef PERL_MAGIC_shared_scalar # define PERL_MAGIC_shared_scalar 'n' #endif #ifndef PERL_MAGIC_collxfrm # define PERL_MAGIC_collxfrm 'o' #endif #ifndef PERL_MAGIC_tied # define PERL_MAGIC_tied 'P' #endif #ifndef PERL_MAGIC_tiedelem # define PERL_MAGIC_tiedelem 'p' #endif #ifndef PERL_MAGIC_tiedscalar # define PERL_MAGIC_tiedscalar 'q' #endif #ifndef PERL_MAGIC_qr # define PERL_MAGIC_qr 'r' #endif #ifndef PERL_MAGIC_sig # define PERL_MAGIC_sig 'S' #endif #ifndef PERL_MAGIC_sigelem # define PERL_MAGIC_sigelem 's' #endif #ifndef PERL_MAGIC_taint # define PERL_MAGIC_taint 't' #endif #ifndef PERL_MAGIC_uvar # define PERL_MAGIC_uvar 'U' #endif #ifndef PERL_MAGIC_uvar_elem # define PERL_MAGIC_uvar_elem 'u' #endif #ifndef PERL_MAGIC_vstring # define PERL_MAGIC_vstring 'V' #endif #ifndef PERL_MAGIC_vec # define PERL_MAGIC_vec 'v' #endif #ifndef PERL_MAGIC_utf8 # define PERL_MAGIC_utf8 'w' #endif #ifndef PERL_MAGIC_substr # define PERL_MAGIC_substr 'x' #endif #ifndef PERL_MAGIC_defelem # define PERL_MAGIC_defelem 'y' #endif #ifndef PERL_MAGIC_glob # define PERL_MAGIC_glob '*' #endif #ifndef PERL_MAGIC_arylen # define PERL_MAGIC_arylen '#' #endif #ifndef PERL_MAGIC_pos # define PERL_MAGIC_pos '.' #endif #ifndef PERL_MAGIC_backref # define PERL_MAGIC_backref '<' #endif #ifndef PERL_MAGIC_ext # define PERL_MAGIC_ext '~' #endif /* That's the best we can do... */ #ifndef sv_catpvn_nomg # define sv_catpvn_nomg sv_catpvn #endif #ifndef sv_catsv_nomg # define sv_catsv_nomg sv_catsv #endif #ifndef sv_setsv_nomg # define sv_setsv_nomg sv_setsv #endif #ifndef sv_pvn_nomg # define sv_pvn_nomg sv_pvn #endif #ifndef SvIV_nomg # define SvIV_nomg SvIV #endif #ifndef SvUV_nomg # define SvUV_nomg SvUV #endif #ifndef sv_catpv_mg # define sv_catpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catpvn_mg # define sv_catpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catsv_mg # define sv_catsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_catsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setiv_mg # define sv_setiv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setiv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setnv_mg # define sv_setnv_mg(sv, num) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setnv(TeMpSv,num); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpv_mg # define sv_setpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpvn_mg # define sv_setpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setsv_mg # define sv_setsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_setsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setuv_mg # define sv_setuv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setuv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_usepvn_mg # define sv_usepvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_usepvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef SvVSTRING_mg # define SvVSTRING_mg(sv) (SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_vstring) : NULL) #endif /* Hint: sv_magic_portable * This is a compatibility function that is only available with * Devel::PPPort. It is NOT in the perl core. * Its purpose is to mimic the 5.8.0 behaviour of sv_magic() when * it is being passed a name pointer with namlen == 0. In that * case, perl 5.8.0 and later store the pointer, not a copy of it. * The compatibility can be provided back to perl 5.004. With * earlier versions, the code will not compile. */ #if (PERL_BCDVERSION < 0x5004000) /* code that uses sv_magic_portable will not compile */ #elif (PERL_BCDVERSION < 0x5008000) # define sv_magic_portable(sv, obj, how, name, namlen) \ STMT_START { \ SV *SvMp_sv = (sv); \ char *SvMp_name = (char *) (name); \ I32 SvMp_namlen = (namlen); \ if (SvMp_name && SvMp_namlen == 0) \ { \ MAGIC *mg; \ sv_magic(SvMp_sv, obj, how, 0, 0); \ mg = SvMAGIC(SvMp_sv); \ mg->mg_len = -42; /* XXX: this is the tricky part */ \ mg->mg_ptr = SvMp_name; \ } \ else \ { \ sv_magic(SvMp_sv, obj, how, SvMp_name, SvMp_namlen); \ } \ } STMT_END #else # define sv_magic_portable(a, b, c, d, e) sv_magic(a, b, c, d, e) #endif #ifdef USE_ITHREADS #ifndef CopFILE # define CopFILE(c) ((c)->cop_file) #endif #ifndef CopFILEGV # define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) ((c)->cop_stashpv) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch)) #endif #ifndef CopSTASH # define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \ || (CopSTASHPV(c) && HvNAME(hv) \ && strEQ(CopSTASHPV(c), HvNAME(hv))))) #endif #else #ifndef CopFILEGV # define CopFILEGV(c) ((c)->cop_filegv) #endif #ifndef CopFILEGV_set # define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv)) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav) #endif #ifndef CopFILE # define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch) #endif #ifndef CopSTASH # define CopSTASH(c) ((c)->cop_stash) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) ((c)->cop_stash = (hv)) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD)) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv)) #endif #endif /* USE_ITHREADS */ #ifndef IN_PERL_COMPILETIME # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling) #endif #ifndef IN_LOCALE_RUNTIME # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE) #endif #ifndef IN_LOCALE_COMPILETIME # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE) #endif #ifndef IN_LOCALE # define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME) #endif #ifndef IS_NUMBER_IN_UV # define IS_NUMBER_IN_UV 0x01 #endif #ifndef IS_NUMBER_GREATER_THAN_UV_MAX # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02 #endif #ifndef IS_NUMBER_NOT_INT # define IS_NUMBER_NOT_INT 0x04 #endif #ifndef IS_NUMBER_NEG # define IS_NUMBER_NEG 0x08 #endif #ifndef IS_NUMBER_INFINITY # define IS_NUMBER_INFINITY 0x10 #endif #ifndef IS_NUMBER_NAN # define IS_NUMBER_NAN 0x20 #endif #ifndef GROK_NUMERIC_RADIX # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send) #endif #ifndef PERL_SCAN_GREATER_THAN_UV_MAX # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02 #endif #ifndef PERL_SCAN_SILENT_ILLDIGIT # define PERL_SCAN_SILENT_ILLDIGIT 0x04 #endif #ifndef PERL_SCAN_ALLOW_UNDERSCORES # define PERL_SCAN_ALLOW_UNDERSCORES 0x01 #endif #ifndef PERL_SCAN_DISALLOW_PREFIX # define PERL_SCAN_DISALLOW_PREFIX 0x02 #endif #ifndef grok_numeric_radix #if defined(NEED_grok_numeric_radix) static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); static #else extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); #endif #ifdef grok_numeric_radix # undef grok_numeric_radix #endif #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b) #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix) #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL) bool DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send) { #ifdef USE_LOCALE_NUMERIC #ifdef PL_numeric_radix_sv if (PL_numeric_radix_sv && IN_LOCALE) { STRLEN len; char* radix = SvPV(PL_numeric_radix_sv, len); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #else /* older perls don't have PL_numeric_radix_sv so the radix * must manually be requested from locale.h */ #include dTHR; /* needed for older threaded perls */ struct lconv *lc = localeconv(); char *radix = lc->decimal_point; if (radix && IN_LOCALE) { STRLEN len = strlen(radix); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #endif #endif /* USE_LOCALE_NUMERIC */ /* always try "." if numeric radix didn't match because * we may have data from different locales mixed */ if (*sp < send && **sp == '.') { ++*sp; return TRUE; } return FALSE; } #endif #endif #ifndef grok_number #if defined(NEED_grok_number) static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); static #else extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); #endif #ifdef grok_number # undef grok_number #endif #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c) #define Perl_grok_number DPPP_(my_grok_number) #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL) int DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) { const char *s = pv; const char *send = pv + len; const UV max_div_10 = UV_MAX / 10; const char max_mod_10 = UV_MAX % 10; int numtype = 0; int sawinf = 0; int sawnan = 0; while (s < send && isSPACE(*s)) s++; if (s == send) { return 0; } else if (*s == '-') { s++; numtype = IS_NUMBER_NEG; } else if (*s == '+') s++; if (s == send) return 0; /* next must be digit or the radix separator or beginning of infinity */ if (isDIGIT(*s)) { /* UVs are at least 32 bits, so the first 9 decimal digits cannot overflow. */ UV value = *s - '0'; /* This construction seems to be more optimiser friendly. (without it gcc does the isDIGIT test and the *s - '0' separately) With it gcc on arm is managing 6 instructions (6 cycles) per digit. In theory the optimiser could deduce how far to unroll the loop before checking for overflow. */ if (++s < send) { int digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { /* Now got 9 digits, so need to check each time for overflow. */ digit = *s - '0'; while (digit >= 0 && digit <= 9 && (value < max_div_10 || (value == max_div_10 && digit <= max_mod_10))) { value = value * 10 + digit; if (++s < send) digit = *s - '0'; else break; } if (digit >= 0 && digit <= 9 && (s < send)) { /* value overflowed. skip the remaining digits, don't worry about setting *valuep. */ do { s++; } while (s < send && isDIGIT(*s)); numtype |= IS_NUMBER_GREATER_THAN_UV_MAX; goto skip_value; } } } } } } } } } } } } } } } } } } numtype |= IS_NUMBER_IN_UV; if (valuep) *valuep = value; skip_value: if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT; while (s < send && isDIGIT(*s)) /* optional digits after the radix */ s++; } } else if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */ /* no digits before the radix means we need digits after it */ if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); if (valuep) { /* integer approximation is valid - it's 0. */ *valuep = 0; } } else return 0; } else if (*s == 'I' || *s == 'i') { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'F' && *s != 'f')) return 0; s++; if (s < send && (*s == 'I' || *s == 'i')) { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'I' && *s != 'i')) return 0; s++; if (s == send || (*s != 'T' && *s != 't')) return 0; s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0; s++; } sawinf = 1; } else if (*s == 'N' || *s == 'n') { /* XXX TODO: There are signaling NaNs and quiet NaNs. */ s++; if (s == send || (*s != 'A' && *s != 'a')) return 0; s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; sawnan = 1; } else return 0; if (sawinf) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT; } else if (sawnan) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT; } else if (s < send) { /* we can have an optional exponent part */ if (*s == 'e' || *s == 'E') { /* The only flag we keep is sign. Blow away any "it's UV" */ numtype &= IS_NUMBER_NEG; numtype |= IS_NUMBER_NOT_INT; s++; if (s < send && (*s == '-' || *s == '+')) s++; if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); } else return 0; } } while (s < send && isSPACE(*s)) s++; if (s >= send) return numtype; if (len == 10 && memEQ(pv, "0 but true", 10)) { if (valuep) *valuep = 0; return IS_NUMBER_IN_UV; } return 0; } #endif #endif /* * The grok_* routines have been modified to use warn() instead of * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit, * which is why the stack variable has been renamed to 'xdigit'. */ #ifndef grok_bin #if defined(NEED_grok_bin) static UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_bin # undef grok_bin #endif #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d) #define Perl_grok_bin DPPP_(my_grok_bin) #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL) UV DPPP_(my_grok_bin)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_2 = UV_MAX / 2; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading b or 0b. for compatibility silently suffer "b" and "0b" as valid binary numbers. */ if (len >= 1) { if (s[0] == 'b') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'b') { s+=2; len-=2; } } } for (; len-- && *s; s++) { char bit = *s; if (bit == '0' || bit == '1') { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_bin. */ redo: if (!overflowed) { if (value <= max_div_2) { value = (value << 1) | (bit - '0'); continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in binary number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 2.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount. */ value_nv += (NV)(bit - '0'); continue; } if (bit == '_' && len && allow_underscores && (bit = s[1]) && (bit == '0' || bit == '1')) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal binary digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Binary number > 0b11111111111111111111111111111111 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_hex #if defined(NEED_grok_hex) static UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_hex # undef grok_hex #endif #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d) #define Perl_grok_hex DPPP_(my_grok_hex) #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL) UV DPPP_(my_grok_hex)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_16 = UV_MAX / 16; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; const char *xdigit; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading x or 0x. for compatibility silently suffer "x" and "0x" as valid hex numbers. */ if (len >= 1) { if (s[0] == 'x') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'x') { s+=2; len-=2; } } } for (; len-- && *s; s++) { xdigit = strchr((char *) PL_hexdigit, *s); if (xdigit) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_hex. */ redo: if (!overflowed) { if (value <= max_div_16) { value = (value << 4) | ((xdigit - PL_hexdigit) & 15); continue; } warn("Integer overflow in hexadecimal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 16.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 16-tuples. */ value_nv += (NV)((xdigit - PL_hexdigit) & 15); continue; } if (*s == '_' && len && allow_underscores && s[1] && (xdigit = strchr((char *) PL_hexdigit, s[1]))) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal hexadecimal digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Hexadecimal number > 0xffffffff non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_oct #if defined(NEED_grok_oct) static UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_oct # undef grok_oct #endif #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d) #define Perl_grok_oct DPPP_(my_grok_oct) #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL) UV DPPP_(my_grok_oct)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_8 = UV_MAX / 8; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; for (; len-- && *s; s++) { /* gcc 2.95 optimiser not smart enough to figure that this subtraction out front allows slicker code. */ int digit = *s - '0'; if (digit >= 0 && digit <= 7) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. */ redo: if (!overflowed) { if (value <= max_div_8) { value = (value << 3) | digit; continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in octal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 8.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 8-tuples. */ value_nv += (NV)digit; continue; } if (digit == ('_' - '0') && len && allow_underscores && (digit = s[1] - '0') && (digit >= 0 && digit <= 7)) { --len; ++s; goto redo; } /* Allow \octal to work the DWIM way (that is, stop scanning * as soon as non-octal characters are seen, complain only iff * someone seems to want to use the digits eight and nine). */ if (digit == 8 || digit == 9) { if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal octal digit '%c' ignored", *s); } break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Octal number > 037777777777 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #if !defined(my_snprintf) #if defined(NEED_my_snprintf) static int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); static #else extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); #endif #define my_snprintf DPPP_(my_my_snprintf) #define Perl_my_snprintf DPPP_(my_my_snprintf) #if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL) int DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...) { dTHX; int retval; va_list ap; va_start(ap, format); #ifdef HAS_VSNPRINTF retval = vsnprintf(buffer, len, format, ap); #else retval = vsprintf(buffer, format, ap); #endif va_end(ap); if (retval < 0 || (len > 0 && (Size_t)retval >= len)) Perl_croak(aTHX_ "panic: my_snprintf buffer overflow"); return retval; } #endif #endif #if !defined(my_sprintf) #if defined(NEED_my_sprintf) static int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); static #else extern int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); #endif #define my_sprintf DPPP_(my_my_sprintf) #define Perl_my_sprintf DPPP_(my_my_sprintf) #if defined(NEED_my_sprintf) || defined(NEED_my_sprintf_GLOBAL) int DPPP_(my_my_sprintf)(char *buffer, const char* pat, ...) { va_list args; va_start(args, pat); vsprintf(buffer, pat, args); va_end(args); return strlen(buffer); } #endif #endif #ifdef NO_XSLOCKS # ifdef dJMPENV # define dXCPT dJMPENV; int rEtV = 0 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0) # define XCPT_TRY_END JMPENV_POP; # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW JMPENV_JUMP(rEtV) # else # define dXCPT Sigjmp_buf oldTOP; int rEtV = 0 # define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0) # define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf); # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW Siglongjmp(top_env, rEtV) # endif #endif #if !defined(my_strlcat) #if defined(NEED_my_strlcat) static Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); #endif #define my_strlcat DPPP_(my_my_strlcat) #define Perl_my_strlcat DPPP_(my_my_strlcat) #if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL) Size_t DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size) { Size_t used, length, copy; used = strlen(dst); length = strlen(src); if (size > 0 && used < size - 1) { copy = (length >= size - used) ? size - used - 1 : length; memcpy(dst + used, src, copy); dst[used + copy] = '\0'; } return used + length; } #endif #endif #if !defined(my_strlcpy) #if defined(NEED_my_strlcpy) static Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); #endif #define my_strlcpy DPPP_(my_my_strlcpy) #define Perl_my_strlcpy DPPP_(my_my_strlcpy) #if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL) Size_t DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size) { Size_t length, copy; length = strlen(src); if (size > 0) { copy = (length >= size) ? size - 1 : length; memcpy(dst, src, copy); dst[copy] = '\0'; } return length; } #endif #endif #ifndef PERL_PV_ESCAPE_QUOTE # define PERL_PV_ESCAPE_QUOTE 0x0001 #endif #ifndef PERL_PV_PRETTY_QUOTE # define PERL_PV_PRETTY_QUOTE PERL_PV_ESCAPE_QUOTE #endif #ifndef PERL_PV_PRETTY_ELLIPSES # define PERL_PV_PRETTY_ELLIPSES 0x0002 #endif #ifndef PERL_PV_PRETTY_LTGT # define PERL_PV_PRETTY_LTGT 0x0004 #endif #ifndef PERL_PV_ESCAPE_FIRSTCHAR # define PERL_PV_ESCAPE_FIRSTCHAR 0x0008 #endif #ifndef PERL_PV_ESCAPE_UNI # define PERL_PV_ESCAPE_UNI 0x0100 #endif #ifndef PERL_PV_ESCAPE_UNI_DETECT # define PERL_PV_ESCAPE_UNI_DETECT 0x0200 #endif #ifndef PERL_PV_ESCAPE_ALL # define PERL_PV_ESCAPE_ALL 0x1000 #endif #ifndef PERL_PV_ESCAPE_NOBACKSLASH # define PERL_PV_ESCAPE_NOBACKSLASH 0x2000 #endif #ifndef PERL_PV_ESCAPE_NOCLEAR # define PERL_PV_ESCAPE_NOCLEAR 0x4000 #endif #ifndef PERL_PV_ESCAPE_RE # define PERL_PV_ESCAPE_RE 0x8000 #endif #ifndef PERL_PV_PRETTY_NOCLEAR # define PERL_PV_PRETTY_NOCLEAR PERL_PV_ESCAPE_NOCLEAR #endif #ifndef PERL_PV_PRETTY_DUMP # define PERL_PV_PRETTY_DUMP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_QUOTE #endif #ifndef PERL_PV_PRETTY_REGPROP # define PERL_PV_PRETTY_REGPROP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_LTGT|PERL_PV_ESCAPE_RE #endif /* Hint: pv_escape * Note that unicode functionality is only backported to * those perl versions that support it. For older perl * versions, the implementation will fall back to bytes. */ #ifndef pv_escape #if defined(NEED_pv_escape) static char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); static #else extern char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); #endif #ifdef pv_escape # undef pv_escape #endif #define pv_escape(a,b,c,d,e,f) DPPP_(my_pv_escape)(aTHX_ a,b,c,d,e,f) #define Perl_pv_escape DPPP_(my_pv_escape) #if defined(NEED_pv_escape) || defined(NEED_pv_escape_GLOBAL) char * DPPP_(my_pv_escape)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags) { const char esc = flags & PERL_PV_ESCAPE_RE ? '%' : '\\'; const char dq = flags & PERL_PV_ESCAPE_QUOTE ? '"' : esc; char octbuf[32] = "%123456789ABCDF"; STRLEN wrote = 0; STRLEN chsize = 0; STRLEN readsize = 1; #if defined(is_utf8_string) && defined(utf8_to_uvchr) bool isuni = flags & PERL_PV_ESCAPE_UNI ? 1 : 0; #endif const char *pv = str; const char * const end = pv + count; octbuf[0] = esc; if (!(flags & PERL_PV_ESCAPE_NOCLEAR)) sv_setpvs(dsv, ""); #if defined(is_utf8_string) && defined(utf8_to_uvchr) if ((flags & PERL_PV_ESCAPE_UNI_DETECT) && is_utf8_string((U8*)pv, count)) isuni = 1; #endif for (; pv < end && (!max || wrote < max) ; pv += readsize) { const UV u = #if defined(is_utf8_string) && defined(utf8_to_uvchr) isuni ? utf8_to_uvchr((U8*)pv, &readsize) : #endif (U8)*pv; const U8 c = (U8)u & 0xFF; if (u > 255 || (flags & PERL_PV_ESCAPE_ALL)) { if (flags & PERL_PV_ESCAPE_FIRSTCHAR) chsize = my_snprintf(octbuf, sizeof octbuf, "%"UVxf, u); else chsize = my_snprintf(octbuf, sizeof octbuf, "%cx{%"UVxf"}", esc, u); } else if (flags & PERL_PV_ESCAPE_NOBACKSLASH) { chsize = 1; } else { if (c == dq || c == esc || !isPRINT(c)) { chsize = 2; switch (c) { case '\\' : /* fallthrough */ case '%' : if (c == esc) octbuf[1] = esc; else chsize = 1; break; case '\v' : octbuf[1] = 'v'; break; case '\t' : octbuf[1] = 't'; break; case '\r' : octbuf[1] = 'r'; break; case '\n' : octbuf[1] = 'n'; break; case '\f' : octbuf[1] = 'f'; break; case '"' : if (dq == '"') octbuf[1] = '"'; else chsize = 1; break; default: chsize = my_snprintf(octbuf, sizeof octbuf, pv < end && isDIGIT((U8)*(pv+readsize)) ? "%c%03o" : "%c%o", esc, c); } } else { chsize = 1; } } if (max && wrote + chsize > max) { break; } else if (chsize > 1) { sv_catpvn(dsv, octbuf, chsize); wrote += chsize; } else { char tmp[2]; my_snprintf(tmp, sizeof tmp, "%c", c); sv_catpvn(dsv, tmp, 1); wrote++; } if (flags & PERL_PV_ESCAPE_FIRSTCHAR) break; } if (escaped != NULL) *escaped= pv - str; return SvPVX(dsv); } #endif #endif #ifndef pv_pretty #if defined(NEED_pv_pretty) static char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); static #else extern char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); #endif #ifdef pv_pretty # undef pv_pretty #endif #define pv_pretty(a,b,c,d,e,f,g) DPPP_(my_pv_pretty)(aTHX_ a,b,c,d,e,f,g) #define Perl_pv_pretty DPPP_(my_pv_pretty) #if defined(NEED_pv_pretty) || defined(NEED_pv_pretty_GLOBAL) char * DPPP_(my_pv_pretty)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags) { const U8 dq = (flags & PERL_PV_PRETTY_QUOTE) ? '"' : '%'; STRLEN escaped; if (!(flags & PERL_PV_PRETTY_NOCLEAR)) sv_setpvs(dsv, ""); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, "<"); if (start_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(start_color)); pv_escape(dsv, str, count, max, &escaped, flags | PERL_PV_ESCAPE_NOCLEAR); if (end_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(end_color)); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, ">"); if ((flags & PERL_PV_PRETTY_ELLIPSES) && escaped < count) sv_catpvs(dsv, "..."); return SvPVX(dsv); } #endif #endif #ifndef pv_display #if defined(NEED_pv_display) static char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); static #else extern char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); #endif #ifdef pv_display # undef pv_display #endif #define pv_display(a,b,c,d,e) DPPP_(my_pv_display)(aTHX_ a,b,c,d,e) #define Perl_pv_display DPPP_(my_pv_display) #if defined(NEED_pv_display) || defined(NEED_pv_display_GLOBAL) char * DPPP_(my_pv_display)(pTHX_ SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pvlim) { pv_pretty(dsv, pv, cur, pvlim, NULL, NULL, PERL_PV_PRETTY_DUMP); if (len > cur && pv[cur] == '\0') sv_catpvs(dsv, "\\0"); return SvPVX(dsv); } #endif #endif #endif /* _P_P_PORTABILITY_H_ */ /* End of File ppport.h */ YAML-Syck-1.31/syck_.c0000644000000000000000000002524613364413554013102 0ustar rootroot/* * syck.c * * $Author: why $ * $Date: 2005-01-01 10:06:25 +0800 (六, 01 1 2005) $ * * Copyright (C) 2003 why the lucky stiff */ #include #include #include "syck.h" void syck_parser_pop_level( SyckParser * ); /* * Custom assert */ void syck_assert( char *file_name, unsigned line_num ) { fflush( NULL ); fprintf( stderr, "\nAssertion failed: %s, line %u\n", file_name, line_num ); fflush( stderr ); abort(); } /* * Allocates and copies a string */ char * syck_strndup( char *buf, long len ) { char *new = S_ALLOC_N( char, len + 1 ); S_MEMZERO( new, char, len + 1 ); S_MEMCPY( new, buf, char, len ); return new; } /* * Default FILE IO function */ long syck_io_file_read( char *buf, SyckIoFile *file, long max_size, long skip ) { long len = 0; ASSERT( file != NULL ); max_size -= skip; len = fread( buf + skip, sizeof( char ), max_size, file->ptr ); len += skip; buf[len] = '\0'; return len; } /* * Default string IO function */ long syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip ) { char *beg; long len = 0; ASSERT( str != NULL ); beg = str->ptr; if ( max_size >= 0 ) { max_size -= skip; if ( max_size <= 0 ) max_size = 0; else str->ptr += max_size; if ( str->ptr > str->end ) { str->ptr = str->end; } } else { /* Use exact string length */ while ( str->ptr < str->end ) { if (*(str->ptr++) == '\n') break; } } if ( beg < str->ptr ) { len = ( str->ptr - beg ); S_MEMCPY( buf + skip, beg, char, len ); } len += skip; buf[len] = '\0'; return len; } void syck_parser_reset_levels( SyckParser *p ) { while ( p->lvl_idx > 1 ) { syck_parser_pop_level( p ); } if ( p->lvl_idx < 1 ) { p->lvl_idx = 1; p->levels[0].spaces = -1; p->levels[0].ncount = 0; p->levels[0].domain = syck_strndup( "", 0 ); } p->levels[0].status = syck_lvl_header; } void syck_parser_reset_cursor( SyckParser *p ) { if ( p->buffer == NULL ) { p->buffer = S_ALLOC_N( char, p->bufsize ); S_MEMZERO( p->buffer, char, p->bufsize ); } p->buffer[0] = '\0'; p->cursor = NULL; p->lineptr = NULL; p->linectptr = NULL; p->token = NULL; p->toktmp = NULL; p->marker = NULL; p->limit = NULL; p->root = 0; p->root_on_error = 0; p->linect = 0; p->eof = 0; p->last_token = 0; p->force_token = 0; } /* * Value to return on a parse error */ void syck_parser_set_root_on_error( SyckParser *p, SYMID roer ) { p->root_on_error = roer; } /* * Allocate the parser */ SyckParser * syck_new_parser() { SyckParser *p; p = S_ALLOC( SyckParser ); S_MEMZERO( p, SyckParser, 1 ); p->lvl_capa = ALLOC_CT; p->levels = S_ALLOC_N( SyckLevel, p->lvl_capa ); p->input_type = syck_yaml_utf8; p->io_type = syck_io_str; p->io.str = NULL; p->syms = NULL; p->anchors = NULL; p->bad_anchors = NULL; p->implicit_typing = 1; p->taguri_expansion = 0; p->bufsize = SYCK_BUFFERSIZE; p->buffer = NULL; p->lvl_idx = 0; syck_parser_reset_levels( p ); return p; } int syck_add_sym( SyckParser *p, char *data ) { SYMID id = 0; if ( p->syms == NULL ) { p->syms = st_init_numtable(); } id = p->syms->num_entries + 1; st_insert( p->syms, id, (st_data_t)data ); return id; } int syck_lookup_sym( SyckParser *p, SYMID id, char **data ) { if ( p->syms == NULL ) return 0; return st_lookup( p->syms, id, (st_data_t *)data ); } int syck_st_free_nodes( char *key, SyckNode *n, char *arg ) { if ( n != (void *)1 ) syck_free_node( n ); n = NULL; return ST_CONTINUE; } void syck_st_free( SyckParser *p ) { /* * Free the anchor tables */ if ( p->anchors != NULL ) { st_foreach( p->anchors, syck_st_free_nodes, 0 ); st_free_table( p->anchors ); p->anchors = NULL; } if ( p->bad_anchors != NULL ) { st_foreach( p->bad_anchors, syck_st_free_nodes, 0 ); st_free_table( p->bad_anchors ); p->bad_anchors = NULL; } } void syck_free_parser( SyckParser *p ) { /* * Free the adhoc symbol table */ if ( p->syms != NULL ) { st_free_table( p->syms ); p->syms = NULL; } /* * Free tables, levels */ syck_st_free( p ); syck_parser_reset_levels( p ); S_FREE( p->levels[0].domain ); S_FREE( p->levels ); if ( p->buffer != NULL ) { S_FREE( p->buffer ); } free_any_io( p ); S_FREE( p ); } void syck_parser_handler( SyckParser *p, SyckNodeHandler hdlr ) { ASSERT( p != NULL ); p->handler = hdlr; } void syck_parser_implicit_typing( SyckParser *p, int flag ) { p->implicit_typing = ( flag == 0 ? 0 : 1 ); } void syck_parser_taguri_expansion( SyckParser *p, int flag ) { p->taguri_expansion = ( flag == 0 ? 0 : 1 ); } void syck_parser_error_handler( SyckParser *p, SyckErrorHandler hdlr ) { ASSERT( p != NULL ); p->error_handler = hdlr; } void syck_parser_bad_anchor_handler( SyckParser *p, SyckBadAnchorHandler hdlr ) { ASSERT( p != NULL ); p->bad_anchor_handler = hdlr; } void syck_parser_set_input_type( SyckParser *p, enum syck_parser_input input_type ) { ASSERT( p != NULL ); p->input_type = input_type; } void syck_parser_file( SyckParser *p, FILE *fp, SyckIoFileRead read ) { ASSERT( p != NULL ); free_any_io( p ); syck_parser_reset_cursor( p ); p->io_type = syck_io_file; p->io.file = S_ALLOC( SyckIoFile ); p->io.file->ptr = fp; if ( read != NULL ) { p->io.file->read = read; } else { p->io.file->read = syck_io_file_read; } } void syck_parser_str( SyckParser *p, char *ptr, long len, SyckIoStrRead read ) { ASSERT( p != NULL ); free_any_io( p ); syck_parser_reset_cursor( p ); p->io_type = syck_io_str; p->io.str = S_ALLOC( SyckIoStr ); p->io.str->beg = ptr; p->io.str->ptr = ptr; p->io.str->end = ptr + len; if ( read != NULL ) { p->io.str->read = read; } else { p->io.str->read = syck_io_str_read; } } void syck_parser_str_auto( SyckParser *p, char *ptr, SyckIoStrRead read ) { syck_parser_str( p, ptr, strlen( ptr ), read ); } SyckLevel * syck_parser_current_level( SyckParser *p ) { return &p->levels[p->lvl_idx-1]; } void syck_parser_pop_level( SyckParser *p ) { ASSERT( p != NULL ); /* The root level should never be popped */ if ( p->lvl_idx <= 1 ) return; p->lvl_idx -= 1; free( p->levels[p->lvl_idx].domain ); } void syck_parser_add_level( SyckParser *p, int len, enum syck_level_status status ) { ASSERT( p != NULL ); if ( p->lvl_idx + 1 > p->lvl_capa ) { p->lvl_capa += ALLOC_CT; S_REALLOC_N( p->levels, SyckLevel, p->lvl_capa ); } ASSERT( len > p->levels[p->lvl_idx-1].spaces ); p->levels[p->lvl_idx].spaces = len; p->levels[p->lvl_idx].ncount = 0; p->levels[p->lvl_idx].domain = syck_strndup( p->levels[p->lvl_idx-1].domain, strlen( p->levels[p->lvl_idx-1].domain ) ); p->levels[p->lvl_idx].status = status; p->lvl_idx += 1; } void free_any_io( SyckParser *p ) { ASSERT( p != NULL ); switch ( p->io_type ) { case syck_io_str: if ( p->io.str != NULL ) { S_FREE( p->io.str ); p->io.str = NULL; } break; case syck_io_file: if ( p->io.file != NULL ) { S_FREE( p->io.file ); p->io.file = NULL; } break; } } long syck_move_tokens( SyckParser *p ) { long count, skip; ASSERT( p->buffer != NULL ); if ( p->token == NULL ) return 0; skip = p->limit - p->token; if ( skip < 0 ) return 0; if ( ( count = p->token - p->buffer ) ) { S_MEMMOVE( p->buffer, p->token, char, skip ); p->token = p->buffer; p->marker -= count; p->cursor -= count; p->toktmp -= count; p->limit -= count; p->lineptr -= count; p->linectptr -= count; } return skip; } void syck_check_limit( SyckParser *p, long len ) { if ( p->cursor == NULL ) { p->cursor = p->buffer; p->lineptr = p->buffer; p->linectptr = p->buffer; p->marker = p->buffer; } p->limit = p->buffer + len; } long syck_parser_read( SyckParser *p ) { long len = 0; long skip = 0; ASSERT( p != NULL ); switch ( p->io_type ) { case syck_io_str: skip = syck_move_tokens( p ); len = (p->io.str->read)( p->buffer, p->io.str, SYCK_BUFFERSIZE - 1, skip ); break; case syck_io_file: skip = syck_move_tokens( p ); len = (p->io.file->read)( p->buffer, p->io.file, SYCK_BUFFERSIZE - 1, skip ); break; } syck_check_limit( p, len ); return len; } long syck_parser_readlen( SyckParser *p, long max_size ) { long len = 0; long skip = 0; ASSERT( p != NULL ); switch ( p->io_type ) { case syck_io_str: skip = syck_move_tokens( p ); len = (p->io.str->read)( p->buffer, p->io.str, max_size, skip ); break; case syck_io_file: skip = syck_move_tokens( p ); len = (p->io.file->read)( p->buffer, p->io.file, max_size, skip ); break; } syck_check_limit( p, len ); return len; } SYMID syck_parse( SyckParser *p ) { ASSERT( p != NULL ); syck_st_free( p ); syck_parser_reset_levels( p ); syckparse( p ); return p->root; } void syck_default_error_handler( SyckParser *p, char *msg ) { printf( "Error at [Line %d, Col %ld]: %s\n", p->linect, p->cursor - p->lineptr, msg ); } int syck_str_is_unquotable_integer(char* str, long len) { int idx; if(!str) return 0; /* Don't parse null strings */ if(len < 1) return 0; /* empty strings can't be numbers */ if(len > 9) return 0; /* Ints larger than 9 digits (32bit) might not portable. Force a string. */ if(str[0] == '0' && len == 1) return 1; /* 0 is unquoted. */ if(str[0] == '-') {str++; len --;} /* supress the leading '-' sign if detected for testing purposes only. */ if(str[0] == '0') return 0; /* Octals need to be quoted or you lose data converting them to an integer. This also accidentally blocks -0 which probably needs to be quoted. */ /* Look for illegal characters */ for ( idx = 1; idx < len; idx++ ) { if(!isdigit(str[idx])) return 0; } return 1; } YAML-Syck-1.31/implicit.c0000644000000000000000000013045313364413554013601 0ustar rootroot/* Generated by re2c 0.10.4 on Wed Aug 8 01:06:52 2007 */ #line 1 "implicit.re" /* * implicit.re * * $Author: why $ * $Date: 2006-10-14 14:58:02 +0800 (Sat, 14 Oct 2006) $ * * Copyright (C) 2003 why the lucky stiff */ #include "syck.h" #define YYCTYPE char #define YYCURSOR cursor #define YYMARKER marker #define YYLIMIT limit #define YYFILL(n) void try_tag_implicit( SyckNode *n, int taguri ) { char *tid = ""; switch ( n->kind ) { case syck_str_kind: tid = syck_match_implicit( n->data.str->ptr, n->data.str->len ); break; case syck_seq_kind: tid = "seq"; break; case syck_map_kind: tid = "map"; break; } if ( n->type_id != NULL ) S_FREE( n->type_id ); if ( taguri == 1 ) { n->type_id = syck_taguri( YAML_DOMAIN, tid, strlen( tid ) ); } else { n->type_id = syck_strndup( tid, strlen( tid ) ); } } char *syck_match_implicit( char *str, size_t len ) { char *cursor, *limit, *marker; cursor = str; limit = str + len; #line 55 "" { YYCTYPE yych; if((YYLIMIT - YYCURSOR) < 26) YYFILL(26); yych = *YYCURSOR; switch(yych) { case 0x00: goto yy6; case '+': goto yy16; case '-': goto yy17; case '.': goto yy20; case '0': goto yy18; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy19; case '<': goto yy22; case '=': goto yy21; case 'F': goto yy15; case 'N': goto yy5; case 'O': goto yy13; case 'T': goto yy11; case 'Y': goto yy8; case 'f': goto yy14; case 'n': goto yy4; case 'o': goto yy12; case 't': goto yy10; case 'y': goto yy9; case '~': goto yy2; default: goto yy23; } yy2: ++YYCURSOR; if((yych = *YYCURSOR) <= 0x00) goto yy6; yy3: #line 123 "implicit.re" { return "str"; } #line 97 "" yy4: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case 0x00: goto yy173; case 'o': goto yy172; case 'u': goto yy200; default: goto yy3; } yy5: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case 0x00: goto yy173; case 'O': case 'o': goto yy172; case 'U': goto yy195; case 'u': goto yy196; default: goto yy3; } yy6: ++YYCURSOR; #line 85 "implicit.re" { return "null"; } #line 120 "" yy8: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case 0x00: goto yy183; case 'E': goto yy193; case 'e': goto yy194; default: goto yy3; } yy9: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case 0x00: goto yy183; case 'e': goto yy192; default: goto yy3; } yy10: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case 'r': goto yy190; default: goto yy3; } yy11: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case 'R': goto yy186; case 'r': goto yy187; default: goto yy3; } yy12: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case 'f': goto yy185; case 'n': goto yy182; default: goto yy3; } yy13: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case 'F': goto yy180; case 'N': case 'n': goto yy182; case 'f': goto yy181; default: goto yy3; } yy14: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case 'a': goto yy177; default: goto yy3; } yy15: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case 'A': goto yy168; case 'a': goto yy169; default: goto yy3; } yy16: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case '.': goto yy167; case '0': goto yy158; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy47; default: goto yy3; } yy17: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case '.': goto yy157; case '0': goto yy158; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy47; default: goto yy3; } yy18: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case 0x00: goto yy52; case ',': goto yy142; case '.': goto yy50; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': goto yy140; case '8': case '9': goto yy141; case ':': goto yy49; case 'x': goto yy144; default: goto yy3; } yy19: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case 0x00: goto yy52; case ',': goto yy47; case '.': goto yy50; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy46; case ':': goto yy49; default: goto yy3; } yy20: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case 'I': goto yy33; case 'N': goto yy31; case 'i': goto yy32; case 'n': goto yy30; default: goto yy3; } yy21: yych = *++YYCURSOR; if(yych <= 0x00) goto yy28; goto yy3; yy22: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case '<': goto yy24; default: goto yy3; } yy23: yych = *++YYCURSOR; goto yy3; yy24: yych = *++YYCURSOR; if(yych <= 0x00) goto yy26; yy25: YYCURSOR = YYMARKER; goto yy3; yy26: ++YYCURSOR; #line 121 "implicit.re" { return "merge"; } #line 281 "" yy28: ++YYCURSOR; #line 119 "implicit.re" { return "default"; } #line 286 "" yy30: yych = *++YYCURSOR; switch(yych) { case 'a': goto yy45; default: goto yy25; } yy31: yych = *++YYCURSOR; switch(yych) { case 'A': goto yy40; case 'a': goto yy41; default: goto yy25; } yy32: yych = *++YYCURSOR; switch(yych) { case 'n': goto yy39; default: goto yy25; } yy33: yych = *++YYCURSOR; switch(yych) { case 'N': goto yy34; case 'n': goto yy35; default: goto yy25; } yy34: yych = *++YYCURSOR; switch(yych) { case 'F': goto yy36; default: goto yy25; } yy35: yych = *++YYCURSOR; switch(yych) { case 'f': goto yy36; default: goto yy25; } yy36: yych = *++YYCURSOR; if(yych >= 0x01) goto yy25; ++YYCURSOR; #line 105 "implicit.re" { return "float#inf"; } #line 331 "" yy39: yych = *++YYCURSOR; switch(yych) { case 'f': goto yy36; default: goto yy25; } yy40: yych = *++YYCURSOR; switch(yych) { case 'N': goto yy42; default: goto yy25; } yy41: yych = *++YYCURSOR; switch(yych) { case 'N': goto yy42; default: goto yy25; } yy42: yych = *++YYCURSOR; if(yych >= 0x01) goto yy25; ++YYCURSOR; #line 109 "implicit.re" { return "float#nan"; } #line 356 "" yy45: yych = *++YYCURSOR; switch(yych) { case 'n': goto yy42; default: goto yy25; } yy46: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy74; default: goto yy48; } yy47: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy48: switch(yych) { case 0x00: goto yy52; case ',': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy47; case '.': goto yy50; case ':': goto yy49; default: goto yy25; } yy49: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': goto yy66; case '6': case '7': case '8': case '9': goto yy67; default: goto yy25; } yy50: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch(yych) { case 0x00: goto yy56; case ',': goto yy54; case '.': goto yy58; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy50; case 'E': case 'e': goto yy60; default: goto yy25; } yy52: ++YYCURSOR; #line 97 "implicit.re" { return "int"; } #line 443 "" yy54: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych) { case 0x00: goto yy56; case ',': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy54; default: goto yy25; } yy56: ++YYCURSOR; #line 99 "implicit.re" { return "float#fix"; } #line 467 "" yy58: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch(yych) { case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy58; case 'E': case 'e': goto yy60; default: goto yy25; } yy60: yych = *++YYCURSOR; switch(yych) { case '+': case '-': goto yy61; default: goto yy25; } yy61: yych = *++YYCURSOR; if(yych <= 0x00) goto yy25; goto yy63; yy62: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy63: switch(yych) { case 0x00: goto yy64; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy62; default: goto yy25; } yy64: ++YYCURSOR; #line 101 "implicit.re" { return "float#exp"; } #line 522 "" yy66: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych) { case 0x00: goto yy70; case '.': goto yy68; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy67; case ':': goto yy49; default: goto yy25; } yy67: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych) { case 0x00: goto yy70; case '.': goto yy68; case ':': goto yy49; default: goto yy25; } yy68: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych) { case 0x00: goto yy72; case ',': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy68; default: goto yy25; } yy70: ++YYCURSOR; #line 95 "implicit.re" { return "int#base60"; } #line 576 "" yy72: ++YYCURSOR; #line 103 "implicit.re" { return "float#base60"; } #line 581 "" yy74: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy75; default: goto yy48; } yy75: yych = *++YYCURSOR; switch(yych) { case '-': goto yy76; default: goto yy48; } yy76: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy77; default: goto yy25; } yy77: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy78; default: goto yy25; } yy78: yych = *++YYCURSOR; switch(yych) { case '-': goto yy79; default: goto yy25; } yy79: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy80; default: goto yy25; } yy80: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy81; default: goto yy25; } yy81: yych = *++YYCURSOR; switch(yych) { case 0x00: goto yy82; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy25; case 'T': goto yy84; case 't': goto yy85; default: goto yy87; } yy82: ++YYCURSOR; #line 111 "implicit.re" { return "timestamp#ymd"; } #line 691 "" yy84: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy126; default: goto yy25; } yy85: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy108; default: goto yy25; } yy86: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 9) YYFILL(9); yych = *YYCURSOR; yy87: switch(yych) { case 0x09: case ' ': goto yy86; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy88; default: goto yy25; } yy88: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy89; default: goto yy25; } yy89: yych = *++YYCURSOR; switch(yych) { case ':': goto yy90; default: goto yy25; } yy90: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy91; default: goto yy25; } yy91: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy92; default: goto yy25; } yy92: yych = *++YYCURSOR; switch(yych) { case ':': goto yy93; default: goto yy25; } yy93: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy94; default: goto yy25; } yy94: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy95; default: goto yy25; } yy95: yych = *++YYCURSOR; switch(yych) { case 0x09: case ' ': goto yy98; case '.': goto yy96; default: goto yy25; } yy96: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych) { case 0x09: case ' ': goto yy98; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy96; default: goto yy25; } yy98: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); yych = *YYCURSOR; switch(yych) { case 0x09: case ' ': goto yy98; case '+': case '-': goto yy101; case 'Z': goto yy100; default: goto yy25; } yy100: yych = *++YYCURSOR; if(yych <= 0x00) goto yy105; goto yy25; yy101: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy102; default: goto yy25; } yy102: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy103; default: goto yy25; } yy103: yych = *++YYCURSOR; switch(yych) { case 0x00: goto yy105; case ':': goto yy104; default: goto yy25; } yy104: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy107; default: goto yy25; } yy105: ++YYCURSOR; #line 115 "implicit.re" { return "timestamp#spaced"; } #line 928 "" yy107: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy100; default: goto yy25; } yy108: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy109; default: goto yy25; } yy109: yych = *++YYCURSOR; switch(yych) { case ':': goto yy110; default: goto yy25; } yy110: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy111; default: goto yy25; } yy111: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy112; default: goto yy25; } yy112: yych = *++YYCURSOR; switch(yych) { case ':': goto yy113; default: goto yy25; } yy113: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy114; default: goto yy25; } yy114: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy115; default: goto yy25; } yy115: yych = *++YYCURSOR; switch(yych) { case '.': goto yy116; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy25; default: goto yy117; } yy116: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); yych = *YYCURSOR; yy117: switch(yych) { case '+': case '-': goto yy119; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy116; case 'Z': goto yy118; default: goto yy25; } yy118: yych = *++YYCURSOR; if(yych <= 0x00) goto yy123; goto yy25; yy119: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy120; default: goto yy25; } yy120: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy121; default: goto yy25; } yy121: yych = *++YYCURSOR; switch(yych) { case 0x00: goto yy123; case ':': goto yy122; default: goto yy25; } yy122: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy125; default: goto yy25; } yy123: ++YYCURSOR; yy124: #line 113 "implicit.re" { return "timestamp#iso8601"; } #line 1129 "" yy125: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy118; default: goto yy25; } yy126: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy127; default: goto yy25; } yy127: yych = *++YYCURSOR; switch(yych) { case ':': goto yy128; default: goto yy25; } yy128: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy129; default: goto yy25; } yy129: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy130; default: goto yy25; } yy130: yych = *++YYCURSOR; switch(yych) { case ':': goto yy131; default: goto yy25; } yy131: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy132; default: goto yy25; } yy132: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy133; default: goto yy25; } yy133: yych = *++YYCURSOR; switch(yych) { case '.': goto yy134; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy25; case 'Z': goto yy136; default: goto yy135; } yy134: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); yych = *YYCURSOR; yy135: switch(yych) { case '+': case '-': goto yy119; case '0': goto yy134; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy138; case 'Z': goto yy118; default: goto yy25; } yy136: yych = *++YYCURSOR; if(yych >= 0x01) goto yy25; yych = *++YYCURSOR; goto yy124; yy138: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); yych = *YYCURSOR; switch(yych) { case '+': case '-': goto yy119; case '0': goto yy134; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy138; case 'Z': goto yy136; default: goto yy25; } yy140: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': goto yy155; case '8': case '9': goto yy153; default: goto yy143; } yy141: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy153; default: goto yy152; } yy142: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy143: switch(yych) { case 0x00: goto yy149; case ',': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': goto yy142; case '.': goto yy50; case '8': case '9': goto yy151; case ':': goto yy49; default: goto yy25; } yy144: yych = *++YYCURSOR; if(yych <= 0x00) goto yy25; goto yy146; yy145: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy146: switch(yych) { case 0x00: goto yy147; case ',': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': goto yy145; default: goto yy25; } yy147: ++YYCURSOR; #line 91 "implicit.re" { return "int#hex"; } #line 1387 "" yy149: ++YYCURSOR; #line 93 "implicit.re" { return "int#oct"; } #line 1392 "" yy151: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy152: switch(yych) { case ',': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy151; case '.': goto yy50; case ':': goto yy49; default: goto yy25; } yy153: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy154; default: goto yy152; } yy154: yych = *++YYCURSOR; switch(yych) { case '-': goto yy76; default: goto yy152; } yy155: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': goto yy156; case '8': case '9': goto yy154; default: goto yy143; } yy156: yych = *++YYCURSOR; switch(yych) { case '-': goto yy76; default: goto yy143; } yy157: yych = *++YYCURSOR; switch(yych) { case 'I': goto yy160; case 'i': goto yy159; default: goto yy25; } yy158: yych = *++YYCURSOR; switch(yych) { case 0x00: goto yy52; case 'x': goto yy144; default: goto yy143; } yy159: yych = *++YYCURSOR; switch(yych) { case 'n': goto yy166; default: goto yy25; } yy160: yych = *++YYCURSOR; switch(yych) { case 'N': goto yy161; case 'n': goto yy162; default: goto yy25; } yy161: yych = *++YYCURSOR; switch(yych) { case 'F': goto yy163; default: goto yy25; } yy162: yych = *++YYCURSOR; switch(yych) { case 'f': goto yy163; default: goto yy25; } yy163: yych = *++YYCURSOR; if(yych >= 0x01) goto yy25; ++YYCURSOR; #line 107 "implicit.re" { return "float#neginf"; } #line 1501 "" yy166: yych = *++YYCURSOR; switch(yych) { case 'f': goto yy163; default: goto yy25; } yy167: yych = *++YYCURSOR; switch(yych) { case 'I': goto yy33; case 'i': goto yy32; default: goto yy25; } yy168: yych = *++YYCURSOR; switch(yych) { case 'L': goto yy175; default: goto yy25; } yy169: yych = *++YYCURSOR; switch(yych) { case 'l': goto yy170; default: goto yy25; } yy170: yych = *++YYCURSOR; switch(yych) { case 's': goto yy171; default: goto yy25; } yy171: yych = *++YYCURSOR; switch(yych) { case 'e': goto yy172; default: goto yy25; } yy172: yych = *++YYCURSOR; if(yych >= 0x01) goto yy25; yy173: ++YYCURSOR; #line 89 "implicit.re" { return "bool#no"; } #line 1546 "" yy175: yych = *++YYCURSOR; switch(yych) { case 'S': goto yy176; default: goto yy25; } yy176: yych = *++YYCURSOR; switch(yych) { case 'E': goto yy172; default: goto yy25; } yy177: yych = *++YYCURSOR; switch(yych) { case 'l': goto yy178; default: goto yy25; } yy178: yych = *++YYCURSOR; switch(yych) { case 's': goto yy179; default: goto yy25; } yy179: yych = *++YYCURSOR; switch(yych) { case 'e': goto yy172; default: goto yy25; } yy180: yych = *++YYCURSOR; switch(yych) { case 'F': goto yy172; default: goto yy25; } yy181: yych = *++YYCURSOR; switch(yych) { case 'f': goto yy172; default: goto yy25; } yy182: yych = *++YYCURSOR; if(yych >= 0x01) goto yy25; yy183: ++YYCURSOR; #line 87 "implicit.re" { return "bool#yes"; } #line 1596 "" yy185: yych = *++YYCURSOR; switch(yych) { case 'f': goto yy172; default: goto yy25; } yy186: yych = *++YYCURSOR; switch(yych) { case 'U': goto yy189; default: goto yy25; } yy187: yych = *++YYCURSOR; switch(yych) { case 'u': goto yy188; default: goto yy25; } yy188: yych = *++YYCURSOR; switch(yych) { case 'e': goto yy182; default: goto yy25; } yy189: yych = *++YYCURSOR; switch(yych) { case 'E': goto yy182; default: goto yy25; } yy190: yych = *++YYCURSOR; switch(yych) { case 'u': goto yy191; default: goto yy25; } yy191: yych = *++YYCURSOR; switch(yych) { case 'e': goto yy182; default: goto yy25; } yy192: yych = *++YYCURSOR; switch(yych) { case 's': goto yy182; default: goto yy25; } yy193: yych = *++YYCURSOR; switch(yych) { case 'S': goto yy182; default: goto yy25; } yy194: yych = *++YYCURSOR; switch(yych) { case 's': goto yy182; default: goto yy25; } yy195: yych = *++YYCURSOR; switch(yych) { case 'L': goto yy199; default: goto yy25; } yy196: yych = *++YYCURSOR; switch(yych) { case 'l': goto yy197; default: goto yy25; } yy197: yych = *++YYCURSOR; switch(yych) { case 'l': goto yy198; default: goto yy25; } yy198: yych = *++YYCURSOR; if(yych <= 0x00) goto yy6; goto yy25; yy199: yych = *++YYCURSOR; switch(yych) { case 'L': goto yy198; default: goto yy25; } yy200: yych = *++YYCURSOR; switch(yych) { case 'l': goto yy201; default: goto yy25; } yy201: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 'l': goto yy198; default: goto yy25; } } #line 125 "implicit.re" } /* Remove ending fragment and compare types */ int syck_tagcmp( const char *tag1, const char *tag2 ) { if ( tag1 == tag2 ) return 1; if ( tag1 == NULL || tag2 == NULL ) return 0; else { int i; char *othorpe; char *tmp1 = syck_strndup( (char*)tag1, strlen( tag1 ) ); char *tmp2 = syck_strndup( (char*)tag2, strlen( tag2 ) ); othorpe = strstr( tmp1, "#" ); if ( othorpe != NULL ) { othorpe[0] = '\0'; } othorpe = strstr( tmp2, "#" ); if ( othorpe != NULL ) { othorpe[0] = '\0'; } i = strcmp( tmp1, tmp2 ); S_FREE( tmp1 ); S_FREE( tmp2 ); return i; } } char * syck_type_id_to_uri( char *type_id ) { char *cursor, *limit, *marker; cursor = type_id; limit = type_id + strlen( type_id ); #line 1737 "" { YYCTYPE yych; if((YYLIMIT - YYCURSOR) < 21) YYFILL(21); yych = *YYCURSOR; switch(yych) { case 0x00: goto yy204; case '!': goto yy208; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 'u': case 'v': case 'w': case 'y': case 'z': goto yy210; case 't': goto yy205; case 'x': goto yy207; default: goto yy211; } yy204: YYCURSOR = YYMARKER; goto yy206; yy205: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case ',': goto yy216; case '-': goto yy212; case '.': goto yy217; case '/': goto yy218; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy214; case 'a': goto yy246; default: goto yy206; } yy206: #line 202 "implicit.re" { return syck_taguri( YAML_DOMAIN, type_id, strlen( type_id ) ); } #line 1888 "" yy207: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case ',': case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy215; case '-': goto yy236; default: goto yy206; } yy208: ++YYCURSOR; #line 176 "implicit.re" { return syck_xprivate( type_id + 1, strlen( type_id ) - 1 ); } #line 1965 "" yy210: yych = *(YYMARKER = ++YYCURSOR); switch(yych) { case ',': goto yy216; case '-': goto yy212; case '.': goto yy217; case '/': goto yy218; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy214; default: goto yy206; } yy211: yych = *++YYCURSOR; goto yy206; yy212: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy213: switch(yych) { case '-': goto yy212; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy214; default: goto yy204; } yy214: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 12) YYFILL(12); yych = *YYCURSOR; yy215: switch(yych) { case ',': goto yy216; case '-': goto yy212; case '.': goto yy217; case '/': goto yy218; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy214; default: goto yy204; } yy216: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy224; default: goto yy204; } yy217: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy220; default: goto yy204; } yy218: ++YYCURSOR; #line 178 "implicit.re" { char *domain = S_ALLOC_N( char, ( YYCURSOR - type_id ) + 15 ); char *uri; domain[0] = '\0'; strncat( domain, type_id, ( YYCURSOR - type_id ) - 1 ); strcat( domain, "." ); strcat( domain, YAML_DOMAIN ); uri = syck_taguri( domain, YYCURSOR, YYLIMIT - YYCURSOR ); S_FREE( domain ); return uri; } #line 2288 "" yy220: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 12) YYFILL(12); yych = *YYCURSOR; switch(yych) { case ',': goto yy216; case '-': goto yy222; case '.': goto yy217; case '/': goto yy218; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy220; default: goto yy204; } yy222: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych) { case '-': goto yy222; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy220; default: goto yy204; } yy224: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy225; default: goto yy204; } yy225: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy226; default: goto yy204; } yy226: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy227; default: goto yy204; } yy227: yych = *++YYCURSOR; switch(yych) { case '-': goto yy228; case '/': goto yy229; default: goto yy204; } yy228: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy231; default: goto yy204; } yy229: ++YYCURSOR; #line 191 "implicit.re" { char *domain = S_ALLOC_N( char, YYCURSOR - type_id ); char *uri; domain[0] = '\0'; strncat( domain, type_id, ( YYCURSOR - type_id ) - 1 ); uri = syck_taguri( domain, YYCURSOR, YYLIMIT - YYCURSOR ); S_FREE( domain ); return uri; } #line 2514 "" yy231: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy232; default: goto yy204; } yy232: yych = *++YYCURSOR; switch(yych) { case '-': goto yy233; case '/': goto yy229; default: goto yy204; } yy233: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy234; default: goto yy204; } yy234: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy235; default: goto yy204; } yy235: yych = *++YYCURSOR; switch(yych) { case '/': goto yy229; default: goto yy204; } yy236: yych = *++YYCURSOR; switch(yych) { case 'p': goto yy237; default: goto yy213; } yy237: yych = *++YYCURSOR; switch(yych) { case ',': goto yy216; case '.': goto yy217; case '/': goto yy218; case 'r': goto yy238; default: goto yy213; } yy238: yych = *++YYCURSOR; switch(yych) { case ',': goto yy216; case '.': goto yy217; case '/': goto yy218; case 'i': goto yy239; default: goto yy213; } yy239: yych = *++YYCURSOR; switch(yych) { case ',': goto yy216; case '.': goto yy217; case '/': goto yy218; case 'v': goto yy240; default: goto yy213; } yy240: yych = *++YYCURSOR; switch(yych) { case ',': goto yy216; case '.': goto yy217; case '/': goto yy218; case 'a': goto yy241; default: goto yy213; } yy241: yych = *++YYCURSOR; switch(yych) { case ',': goto yy216; case '.': goto yy217; case '/': goto yy218; case 't': goto yy242; default: goto yy213; } yy242: yych = *++YYCURSOR; switch(yych) { case ',': goto yy216; case '.': goto yy217; case '/': goto yy218; case 'e': goto yy243; default: goto yy213; } yy243: yych = *++YYCURSOR; switch(yych) { case ',': goto yy216; case '.': goto yy217; case '/': goto yy218; case ':': goto yy244; default: goto yy213; } yy244: ++YYCURSOR; #line 174 "implicit.re" { return syck_strndup( type_id, strlen( type_id ) ); } #line 2646 "" yy246: yych = *++YYCURSOR; switch(yych) { case ',': goto yy216; case '.': goto yy217; case '/': goto yy218; case 'g': goto yy247; default: goto yy213; } yy247: yych = *++YYCURSOR; switch(yych) { case ',': goto yy216; case '.': goto yy217; case '/': goto yy218; case ':': goto yy248; default: goto yy213; } yy248: yych = *++YYCURSOR; switch(yych) { case ',': case '-': case '.': goto yy204; default: goto yy250; } yy249: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 12) YYFILL(12); yych = *YYCURSOR; yy250: switch(yych) { case ',': goto yy253; case '-': goto yy251; case '.': goto yy254; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy249; default: goto yy204; } yy251: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych) { case '-': goto yy251; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy249; default: goto yy204; } yy253: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy259; default: goto yy204; } yy254: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy255; default: goto yy204; } yy255: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 12) YYFILL(12); yych = *YYCURSOR; switch(yych) { case ',': goto yy253; case '-': goto yy257; case '.': goto yy254; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy255; default: goto yy204; } yy257: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych) { case '-': goto yy257; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy255; default: goto yy204; } yy259: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy260; default: goto yy204; } yy260: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy261; default: goto yy204; } yy261: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy262; default: goto yy204; } yy262: yych = *++YYCURSOR; switch(yych) { case '-': goto yy263; case ':': goto yy264; default: goto yy204; } yy263: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy266; default: goto yy204; } yy264: ++YYCURSOR; #line 172 "implicit.re" { return syck_strndup( type_id, strlen( type_id ) ); } #line 3118 "" yy266: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy267; default: goto yy204; } yy267: yych = *++YYCURSOR; switch(yych) { case '-': goto yy268; case ':': goto yy264; default: goto yy204; } yy268: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy269; default: goto yy204; } yy269: yych = *++YYCURSOR; switch(yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy270; default: goto yy204; } yy270: ++YYCURSOR; switch((yych = *YYCURSOR)) { case ':': goto yy264; default: goto yy204; } } #line 204 "implicit.re" } YAML-Syck-1.31/Changes0000644000000000000000000007065313364413554013123 0ustar rootroot [Changes for 1.31 - 2018-10-25] * Switch to ExtUtils::MakeMaker for builder * Switch official issue tracker and repo to github. * MANIFEST warning is now fixed. Also shipping additional tests because of this. [Changes for 1.30] * ??? [Changes for 1.29_02 - 2016-03-03] * Fix handling carriage return after c-indicator RT 41141 * Fix CHECK_UTF8 SEGV with empty len=0 strings RT 61562 * Add missing function declarations * Tighten the TODO tests, no passing TODOs now. But still JSON SingleQuote and \/ and \u roundtrips do fail. [Changes for 1.29_01 - 2014-12-14] * Experimentally try patch from RT 83825. Will release if no test failures or complaints. * Fix crash in syck_emit on platforms with long long pointers [Changes for 1.28 - 2014-12-11] * Bump to release version 1.28 for production release to CPAN [Changes for 1.28_01 - 2014-06-11] * Update inc modules to avoid precedence warnings in newer perl: RT 87034 [Changes for 1.27 - 2013-05-20] * Resolve RT#84466 not fixed in 1.26 It failed about 10% of the time. [Changes for 1.26 - 2013-05-20] * Resolve RT#84882 and RT#84466 hash randomisation in yaml-alias.t on perl 5.18.0 [Changes for 1.25 - 2013-03-10] * Bump version number and release to fix a MANIFEST mistake in 1.24 [Changes for 1.24 - 2013-03-07] * Tests all green on CPAN Testers. releasing to public. [Changes for 1.24_02 - 2013-03-01] * Apply patch from RT 78363 - MinGW64 compatibility [Changes for 1.24_01 - 2013-03-01] * Implement $JSON::Syck::MaxDepth * Prevent failure when the same object is seen twice during Dump. * Prevent YAML from being influnced by the previous change [Changes for 1.23 - 2013-02-26] * Tests all green on CPAN Testers. releasing to public. [Changes for 1.23_01 - 2013-02-21] * Make sure that LoadBlessed=0 blocks all blessing. * Start listing primary repo as toddr on github ( http://github.com/toddr/YAML-Syck ) * README refreshed via perldoc -t [Changes for 1.22 - 2012-12-04] * Tests all green on CPAN Testers. releasing to public. [Changes for 1.22_01 - 2012-11-27] * Fix error message typo: s/existant/existent/g * Fix for non-printable character detection * Quote if non-printable characters are present * Change LoadBlessed=0 to not bless under ANY circumstances [Changes for 1.21 - 2012-09-20] * Tests all green on CPAN Testers. releasing to public. [Changes for 1.21_01 - 2012-06-22] * Synchronize JSON::Syck with YAML::Syck version number * Add DumpInto functions (YAML+Syck) which dump into a provided scalar instead of a newly allocated one * Modify DumpFile functions to output directly to the specified file/filehandle instead of buffering all output in memory. * Avoid modifying numbers into strings when emitting [Changes for 1.20 (JSON::Syck 0.43) - 2012-02-14] * Tests all green on CPAN Testers. releasing to public. [Changes for 1.20_01 (JSON::Syck 0.43_01) - 2012-02-11] * Add test to assure META.yml is up to date before release * Fix for RT 70933 - disable check for empty file handle in LoadFile calls * Remove call to non-existent code YAML::Syck::_is_openhandle. * Fix for RT 74785 - compiling with -Werror=format-security fails [Changes for 1.19 (JSON::Syck 0.42 ) - 2011-11-08] * Do not run t/leak.t on perls prior to 5.8.9 as 5.8.8 and Devel::Leak apparently do not mix (perl RT #102606). [Changes for 1.18 (JSON::Syck 0.41 ) - 2011-11-05] * Promote to stable release. [Changes for 1.17_02 (JSON::Syck 0.40_02 ) - 2011-11-03] * perl RT #102606 - Only lvalue subroutines are supposed to return the argument to "return" without copying it. Stop relying on a pre-5.15 bug. [Father Chrysostomos] [Changes for 1.17_01 (JSON::Syck 0.40_01 ) - 2011-02-28] * Break YAML::Syck dependency on Scalar::Util [Changes for 1.17 (JSON::Syck 0.40 ) - 2010-11-21] * Change a C99 comment to a C89 comment * Upgrade ppport.h from 3.13 to 3.19 * Remove inc/Test/Builder/IO/Scalar.pm from MANIFEST [Changes for 1.16 (JSON::Syck 0.39 ) - 2010-11-21] * POD formatting fixes contributed by Justin Hunter [Changes for 1.15 (JSON::Syck 0.38 ) - 2010-09-23] * perl RT #78008 - The 5.13.5 development release of perl changed how regexes are stringified, breaking our tests. Update the tests to deal with the new syntax. See fb85c04 (http://perl5.git.perl.org/perl.git/commit/fb85c04) in perl.git for context. [Changes for 1.14 (JSON::Syck 0.37 ) - 2010-08-03] * RT RT60771 - Further refactor for JSON. if a number is a valid perl string, quote it. "1" + "1" = "11" in javascript. * add YAML tests to make sure HEX and octal preserve their information [Changes for 1.13 (JSON::Syck 0.36 ) - 2010-08-03] * RT RT60771 - quoted negative integer and quoted zeroes. This was breaking JSON since "0" is true in javascript. [Changes for 1.12 (JSON::Syck 0.35 ) - 2010-08-03] * The tie test proved to be very unstable for 5.8 and it's not relevant for tie actually. I'm converting it to a TODO for [Changes for 1.11 (JSON::Syck 0.35 ) - 2010-08-03] * Tests are now stable. releasing 1.11 [Changes for 1.10_07 (JSON::Syck 0.34 ) - 2010-07-29] * META.yml missing [Changes for 1.10_06 (JSON::Syck 0.34 ) - 2010-07-29] * Load of in-memory file handles not previously tested (was eval'd out of existance) Corrected code and test to behave correctly. * Perl 5.8 required to YAML-ify code refs * Perl 5.6 requires {} to print to a scalar GLOB * use SvNIOK to test for int or float if we know it's not a string * Attempt again to get 5.8.7 skipped for tie test [Changes for 1.10_05 (JSON::Syck 0.34 ) - 2010-07-28] * Skip failing tie test on perl < 5.8.8 && perl >= 5.7.0x [Changes for 1.10_04 (JSON::Syck 0.34 ) - 2010-07-19] * RT 23850 - META.yml of DMAKI/DateTime-Format-Japanese-0.01.tar.gz cannot be parsed * RT 34073 - TODO Tests - Parsing YAML without separator * RT 20969 - Document die behavior differences with YAML [Changes for 1.10_03 (JSON::Syck 0.34 ) - 2010-07-19] * TODO tests to cover noted deficiencies in RT #'s 26182, 54780, 49404, 42390 * RT 23909 - Loaded self-refererring document is corrupted [Changes for 1.10_02 (JSON::Syck 0.34 ) - 2010-07-19] * RT 50227 - Logic bug in deciding what numbers to quote led to some interesting corner cases. Now only 9digit integers are supported as unquoted. Everything else will be forced to quote * RT 59458 - convert \%d to \%ld in code to prevent compiler warnings [Changes for 1.10_01 (JSON::Syck 0.34) - 2010-07-15] * LoadFile aborts loading an empty file * RT 50227 - Not quoting strings when data has been sorted numerically before being passed to JSON::Syck::Dump * RT 48327 - use 3 arg form of open() instead of the 2 argument form * Add TODO tests for RT 52432 - '... X' breaks round trip * RT 59432 - use lexical file handles for read/write to files * RT 37236 - Re-enable JSON-basic tests for JSON >= 2.11 * RT 47944 - back quote is a reserved character * RT 36288 - ability to disable blessing datastructures on load * Tone down the WARNING section in YAML::Syck's documentation that was added in 1.08 [Changes for 1.10 (JSON::Syck 0.33) - 2010-06-06] 1.09 was released with version 0.97 of Module::Install. It had a critical bug that I reported which broke installations on perl 5.8.3 and older. This release is equivalent to 1.09 aside from bumping Module::Install to 0.99 which fixed the bug. [Changes for 1.09 (JSON::Syck 0.32) - 2010-05-29] * Exactly equivalent to 1.08_01, aside from bumping the version numbers [Changes for 1.08_01 (JSON::Syck 0.31_01) - 2010-05-23] * Reset the hash iterator after dumping hashes. Solves RT #54167 and the duplicate RT #34166. * RT #39572: Only print 0.60 compatibility warning if 0.60 or earlier is installed. [Changes for 1.08 (JSON::Syck 0.31) - 2010-05-23] Like the 1.07_01 test release aside from small documentation improvements. * POD link to JSON::XS from JSON::Syck * Include a WARNING section in the YAML::Syck pod that mentions that the module hasn't been actively maintained since 2007, and that perhaps prospective users might want to turn elsewhere. [Changes for 1.07_01 (JSON::Syck 0.30) - 2010-05-20] About: First release by new maintainer (AVAR). The source repository is now hosted in Git at http://github.com/avar/YAML-Syck YAML::Syck is still pretty much abandonware, all its bugs likely to get fixed any time soon. Code fixes: * Strings starting with : are now always quoted. Ruby will interpret anything starting with a colon as a symbol. Before this fix strings exported from YAML::Syck would be interpreted as Ruby symbols when read by Ruby's syck. Release engineering fixes: * Upgrade from Module::Install 0.68 to 0.97 * Bump included Test::More dependency * Remove included inc/attributes.pm dependency. Nothing in our dependencies used this anymore. * Add homepage, bugtracker, and repository metadata to META.yml * Bump perl dependency from 5.00307 to 5.006. 5.005 is all Module::Install supported, and YAML::Syck depends on Scalar::Util which only goes as low as 5.006. [Changes for 1.07 (JSON::Syck 0.30) - 2009-04-25] * Added the missing Loadfile function to JSON::Syck. Reported by: Dan McCormick [Changes for 1.05 (JSON::Syck 0.29) - 2008-06-09] * Loading a YAML stream containing Regexp nodes under -d:DProf should not fail with "panic: Devel::DProf inconsistent subroutine return". Reported by: Richard Jelinek [Changes for 1.04 (JSON::Syck 0.29) - 2008-02-17] * The 'Name "YAML::Syck::ImplicitBinary" used only once: possible typo' warnings no longer triggers in Perl 5.10 when running with perl -w. Reported by: Jesse Vincent [Changes for 1.03 (JSON::Syck 0.29) - 2008-02-16] * JSON::Syck: When $JSON::Syck::SingleQuote is false, implicit booleans such as "yes" and "no" should be dumped with double quotes, instead of single quotes (which breaks RFC 4627). Reported by: cho45 [Changes for 1.02 (JSON::Syck 0.28) - 2008-02-16] * JSON::Syck: Colons in single-quoted strings are no longer loaded with an extra space after it. Reported by: Agent Zhang [Changes for 1.01 (JSON::Syck 0.27) - 2008-01-19] * JSON::XS is now promoted prominiently in JSON::Syck's documentation. * Added support for Perl 5.11 and its first-class Regexp objects. Contributed by: Andreas Koenig * Tests no longer fail incorrectly when JSON.pm 2.00+ is installed. Contributed by: Andreas Koenig * Removed the unused Syck bytecode modules (yamlbyte.h and yaml2byte.c) to further reduce our memory footprint. [Changes for 1.00 (JSON::Syck 0.26) - 2007-12-10] * When $YAML::Syck::SingleQuote is set to true, Dump() now emits newlines in strings correctly. (Previously it would emit extra newlines.) [Changes for 0.99 (JSON::Syck 0.26) - 2007-10-23] * TODOify tests as appropriate for Perl 5.005 and Perl 5.6.x. [Changes for 0.98 (JSON::Syck 0.26) - 2007-10-13] * Restore support for Perl 5.005 and earlier. [Changes for 0.97 (JSON::Syck 0.26) - 2007-09-03] * When loading !!perl/code with $YAML::Syck::LoadCode set to false, YAML::Syck now returns a coderef that does nothing (i.e. sub {}), in accordance with YAML.pm's treatment, instead of returning the actual code of the sub as a string. Contributed by: Florian Ragwitz [Changes for 0.96 (JSON::Syck 0.26) - 2007-08-08] * The always-quote rule now applies to all implicit booleans and null values, i.e. strings that match the following regex: /y|Y |n|N |yes|Yes|YES |no|No|NO |true|True|TRUE |false|False|FALSE |on|On|ON |off|Off|OFF |null|Null|NULL |~ /x * Bare literals "Y", "N", "y" and "n" are now recognized as booleans when loading with implicit typing turned on. * Mixed case strings that does not represent implicit boolean values, such as "yES" and "nO", are no longer always-quoted. Contributed by: Malcolm Studd [Changes for 0.95 (JSON::Syck 0.26) - 2007-08-04] * "Yes" and "no" (including all upper/lower case forms) are now always dumped in quoted form to avoid ambiguities when loaded by loaders with ImplicitTyping set to true. Reported by: Malcolm Studd * lib/YAML/Syck.pod is merged back into lib/YAML/Syck.pm. (No functional changes.) [Changes for 0.94 (JSON::Syck 0.26) - 2007-07-10] * Repair broken PAUSE upload, again. (Sigh.) [Changes for 0.93 (JSON::Syck 0.26) - 2007-07-10] * Repair broken PAUSE upload. [Changes for 0.92 (JSON::Syck 0.26) - 2007-07-10] * Allow for LoadFile(*FH) and DumpFile(*FH), in addition to ($fh) and (\*FH). Also, new tests for LoadFile and DumpFile. Contributed by: Adriano Ferreira [Changes for 0.91 (JSON::Syck 0.26) - 2007-06-23] * Corrected loading Regexps with all combinations of quantifiers. Contributed by: Ingy döt Net [Changes for 0.90 (JSON::Syck 0.26) - 2007-06-22] * Regexes are now dump/loaded correctly with modifiers, with a new representation: "--- !!perl/regexp:main (?i-xsm:1)", instead of the old mapping with a REGEXP key. The old form still loads correctly; the new form corresponds to YAML.pm 0.63 and later. Requested by: Ingy döt Net * Loading regexes with modifiers no longer involves an eval"" call. [Changes for 0.88 (JSON::Syck 0.26) - 2007-06-17] * New dependency: Scalar::Util, for LoadFile and DumpFile functions. You can safely do without that module if you do not make use of the two functions. * LoadFile and DumpFile now accept glob values, and reject unopened handles properly instead of silently ignores it. Contributed by: Adriano Ferreira [Changes for 0.87 (JSON::Syck 0.25) - 2007-06-17] * New LoadFile and DumpFile functions for JSON::Syck. * JSON::Syck now actually exports its functions if you ask for it. * LoadFile and DumpFile now accept IO objects in addition to file names. Requested by: Adriano Ferreira [Changes for 0.86 (JSON::Syck 0.24) - 2007-06-16] * Support for dumping and loading regexps created by qr//, including blessed once. Note that loading Regexp values dumped by YAML.pm currently discards modifiers. [Changes for 0.85 (JSON::Syck 0.24) - 2007-04-20] * Strings containing both single quotes and newlines were incorrectly quoted with backslash-escaped single quotes. This is a regression introduced in YAML::Syck 0.84. Reported by: Agent Zhang [Changes for 0.84 (JSON::Syck 0.23) - 2007-04-02] * New $YAML::Syck::SingleQuote flag: When it is set to true, Dump will always emit quotes instead of bare strings. Requested by: Ingo Bax * When $JSON::Syck::SingleQuote is set to true, special characters such as \r\n are still escaped as usual, because JavaScript allows the same form of escaping in strings with either quotes. Reported by: Dobrica Pavlinusic [Changes for 0.83 (JSON::Syck 0.22) - 2007-02-05] * Under JSON::Syck, as well as YAML::Syck when $ImplicitTyping is set to true, integer numbers larger than an unsigned integer (>=4294967296 on 32-bit platforms) was erroneously loaded as 0. Reported by: Markus Wörle [Changes for 0.82 (JSON::Syck 0.21) - 2007-01-26] * Bytestrings containing no high bit bytes are no longer dumped as "!binary". [Changes for 0.81 (JSON::Syck 0.21) - 2007-01-26] * Support for loading Base64-encoded "!binary" type. * Support for dumping non-unicode bytes containing high bits as Base64-encoded "!binary" type. * JSON::Syck now raises an exception, instead of segfaults, when dumping a circular structure. [Changes for 0.80 (JSON::Syck 0.20) - 2007-01-26] * LICENSING CHANGE: This compilation and all individual files in it (except for the bundled libsyck code) are now under the permissive "MIT" license. See the COPYRIGHT section in README for the new terms. * Load("!! []") no longer segfaults due to empty tag names. * Load("!!Foo []") now blesses into "Foo", not "Foo::\0". * Load("!!perl/scalar 123") is now \123, not 123. * Load("!!perl/scalar:Foo ~") is now \"Foo", not undef. * Dump(bless(\$undef, 'Foo')) is now "!!perl/scalar:Foo ~", not "~". [Changes for 0.72 (JSON::Syck 0.15) - 2006-11-26] * $JSON::Syck::SingleQuote did not take effect for Unicode strings. * Squashed "mentioned only once" warnings for $ImplicitUnicode and $Headless. Reported by: Agent Zhang [Changes for 0.71 (JSON::Syck 0.14) - 2006-10-03] * Double-quoted strings in YAML output no longer contains continuation lines, which confused YAML.pm terribly. Reported by: Nelson Elhage [Changes for 0.70 (JSON::Syck 0.14) - 2006-10-02] * Load()/Dump()/LoadFile()/DumpFile() in YAML::Syck now support multiple YAML streams -- i.e. dumping multiple Perl values into a string composed of several YAML streams, and loading such a string into several values under list context. [Changes for 0.66 (JSON::Syck 0.14) - 2006-07-29] * Further improvements of loading semantics for explicitly tagged nodes. Contributed by: Yuval Kogman [Changes for 0.66 (JSON::Syck 0.14) - 2006-07-29] * The initialization sequence could cause segfaults on FreeBSD systems. Reported by: Chia-Liang Kao * Emit '!perl/ref' instead of '!perl/ref:' for consistency with other language's tagging systems. Contributed by: Yuval Kogman [Changes for 0.65 (JSON::Syck 0.14) - 2006-07-28] * Delay initialization of B::Deparse objects until the first time UseCode or LoadCode is in active use. Reported by: Chia-Liang Kao [Changes for 0.64 (JSON::Syck 0.14) - 2006-07-22] * Deparsing code references was erroneously generating extra NUL bytes on 64-bit platforms. Reported by: Jesse Vincent [Changes for 0.63 (JSON::Syck 0.14) - 2006-07-20] * When JSON's SingleQuote mode is set to true, single quotes inside JSON strings is now escaped properly. Reported by: [Changes for 0.70 (JSON::Syck 0.14) - 2006-10-02] * Load()/Dump()/LoadFile()/DumpFile() in YAML::Syck now support multiple YAML streams -- i.e. dumping multiple Perl values into a string composed of several YAML streams, and loading such a string into several values under list context. [Changes for 0.66 (JSON::Syck 0.14) - 2006-07-29] * Further improvements of loading semantics for explicitly tagged nodes. Contributed by: Yuval Kogman [Changes for 0.66 (JSON::Syck 0.14) - 2006-07-29] * The initialization sequence could cause segfaults on FreeBSD systems. Reported by: Chia-Liang Kao * Emit '!perl/ref' instead of '!perl/ref:' for consistency with other language's tagging systems. Contributed by: Yuval Kogman [Changes for 0.65 (JSON::Syck 0.14) - 2006-07-28] * Delay initialization of B::Deparse objects until the first time UseCode or LoadCode is in active use. Reported by: Chia-Liang Kao [Changes for 0.64 (JSON::Syck 0.14) - 2006-07-22] * Deparsing code references was erroneously generating extra NUL bytes on 64-bit platforms. Reported by: Jesse Vincent [Changes for 0.63 (JSON::Syck 0.14) - 2006-07-20] * When JSON's SingleQuote mode is set to true, single quotes inside JSON strings is now escaped properly. Reported by: Nelson Elhage [Changes for 0.62 (JSON::Syck 0.13) - 2006-07-11] * Fix compilation with Microsoft Visual C++. Reported by: Nilson Santos Figueiredo Junior [Changes for 0.61 (JSON::Syck 0.13) - 2006-07-01] * Fix segmentation faults introduced by pre-loading B::Deparse. Reported by: Randal Schwartz, Tatsuhiko Miyagawa [Changes for 0.60 (JSON::Syck 0.13) - 2006-06-30] * Completely change the way YAML tagging of references again, this time using !!perl instead of !perl for compatibility with YAML.pm and other YAML 1.1 implementations. [Changes for 0.46_02 (JSON::Syck 0.13) - 2006-06-29] * Completely change the way YAML tagging of references and blessed references work: See http://pyyaml.org/wiki/PerlTagScheme for the new specification. Note that this means the emitter BREAKS COMPATIBILITY with earlier versions of YAML loaders (both YAML::Syck and YAML.pm), although it will still load YAML streams produced by earlier loaders. Contributed by: Yuval Kogman [Changes for 0.46_01 (JSON::Syck 0.13) - 2006-06-25] * Add support for code references in YAML Contributed by: Yuval Kogman, based on Storable.xs [Changes for 0.45 (JSON::Syck 0.13) - 2006-05-27] * Bogus indentations are no longer emitted for JSON for strings containing newlines. Reported by: Tatsuhiko Miyagawa * Fix memory leaks on Dump. Contributed by: Andrew Danforth * Upgrade to upstream Syck 0.56-trunk; no functional changes. [Changes for 0.44 (JSON::Syck 0.12) - 2006-05-04] * Fix tests so they work warninglessly on 5.005. * Fix incorrect indentation level for scalars initialized twice -- once as string and once as references -- such as the ones produced by YAML.pm's Load() function. Reported by: Alex Vandiver * Multilevel self-recursive structures now no longer generate redundant anchor names. Reported by: Alex Vandiver * Fix memory leaks when linking child nodes to parent hashes and arrays. Also fix leaks when libsyck parser encounters an error. Contributed by: Andrew Danforth * Added test cases to validate the memory leak fixes. Devel::Leak is an optional dependency for these tests. Contributed by: Clayton O'Neill [Changes for 0.43 (JSON::Syck 0.11) - 2006-04-29] * Loading self-recursive structures no longer trigger an "Use of uninitialized value" warning. * Tests now pass for real on Perl 5.005. Reported by: Anton Berezin * Setting $JSON::Syck::SingleQuote to true did not work for strings ending in whitespaces. Contributed by: Alex Vandiver [Changes for 0.42 (JSON::Syck 0.10) - 2006-04-25] * Support for loading recursive structures. Reminded by: Adam Kennedy * Regained support for Perl 5.005. [Changes for 0.41 (JSON::Syck 0.10) - 2006-04-01] * Correctly dump circular structures in array and hash references. Reported by: Jesse Vincent * Support for loading blessed scalar references. Requested by: Dan Kogai * 0.40 was missing included Test::More, so tests could fail on a freshly installed Perl 5.6.x. Reported by: Uri Guttman [Changes for 0.40 (JSON::Syck 0.10) - 2006-03-31] * Merge YAML::Syck and JSON::Syck to a single distribution. Unified our svn repo codebase onto openfoundry[1] as well. [1] http://svn.openfoundry.org/perlsyck * Fixed JSON null serialization bug [rt:18021], unsigned integer bug [rt:18464]. * Under JSON, scalar references are dereferenced eplicitly and subroutine refefrences are serialized to null. * Fixed bug that integer elements in tied hashes were not correctly serialized. Reported by: Dan Kogai [Changes for 0.38 - 2006-03-14] * Documentation change: in the POD text, stress the importance of setting $YAML::Syck::ImplicitTyping to true, for interoperability with other language's YAML/Syck bindings is desired. Requested by: "dgaramond2" on Perlmonks. [Changes for 0.37 - 2006-03-14] * Fix build on Win32 caused by upstream Syck header changes. Reported by: Nilson Santos F. Jr. [Changes for 0.36 - 2006-03-10] * YAML.pm 0.35 or earlier emitted "--- #YAML:1.0" instead of "--- %YAML:1.0" as the version string; work around it to maintain compatibility.. Reported by: Chia-Liang Kao [Changes for 0.35 - 2006-03-09] * Under implicit typing, hex and octal integers triggered segfaults. Reported by: Rachwal Waldemar [Changes for 0.34 - 2006-03-07] * Upgrade to Module::Install 0.59. * Corrected copyright notices. [Changes for 0.33 - 2006-02-14] * Plain strings beginning with "~" was loaded as undef. Reported by: Stephen Quinney [Changes for 0.32 - 2006-02-11] * Synchronize to upstream r231 (Ruby 1.8.4), with improved parsing of block scalars, trailing colons/tabs, and support for complex keys (although not enabled in Perl 5 yet.) [Changes for 0.31 - 2006-02-10] * Strings ending in colons, spaces or tabs was not quoted properly. Reported by: Stephen Quinney [Changes for 0.30 - 2006-02-06] * When loading anchors pointing to a hash reference, reference count did not increment accordingly. Reported by: Johan Vromans * After loading hashes or arrays containing null elements, assigning into those elements triggered a "modification of non-creatable value" error. Reported by: Clinton Gormley * The string '~' is now emitted as a quoted "~" instead of bare ~ (which would be loaded as undef.) Reported by: Stephen Quinney [Changes for 0.29 - 2006-02-05] * Proper quoting support (for the JSON branch only). Reported by: Anton Berezin * Switch to XSLoader on Perl 5.6.0+ for faster loading. [Changes for 0.28 - 2006-01-16] * Undef hash values is now emitted as "~" instead of "". Reported by: Tatsuhiko Miyagawa * FETCH magic of tied variables and loop iterators is now respected. Reported by: Tatsuhiko Miyagawa [Changes for 0.27 - 2006-01-16] * $YAML::Syck::SortKeys is now on by default. Requested by: Brian Ingerson [Changes for 0.26 - 2006-01-16] * Add a $YAML::Syck::SortKeys flag to enable sorting hash keys. Requested by: Brian Ingerson [Changes for 0.25 - 2006-01-14] * Loading foreign objects from YAML tags: For example, "--- !hs/Foo {a: b}" is blessed into hs::Foo. [Changes for 0.24 - 2006-01-14] * Silence warnings on 64-bit machines. Reported by: Anton Berezin [Changes for 0.23 - 2006-01-14] * Fix build for 5.6.x again. Reported by: Anton Berezin [Changes for 0.22 - 2006-01-12] * Dump numbers without quoting even when under Unicode flag. Conversely, a scalar with Unicode bit set is dumped as Unicode even if it had stored a number before. Reported by: Tatsuhiko Miyagawa [Changes for 0.21 - 2006-01-11] * Support for loading and dumping unicode strings. Requested by: Tatsuhiko Miyagawa * Add a $YAML::Syck::ImplicitUnicode flag to control implicit setting of unicode flags. [Changes for 0.20 - 2006-01-11] * Support for loading and dumping scalar references. * Support for dumping self-recursive data structures. [Changes for 0.19 - 2006-01-11] * More efficient memory use and allocation for the JSON branch. * Fix build on Perl 5.6.x again. Reported by: Anton Berezin [Changes for 0.18 - 2006-01-11] * Allow installation for people with older Module::Install versions. Reported by: Brian Ingerson [Changes for 0.17 - 2006-01-11] * Use the correct style for dual vars and tied scalars. Reported by: Tatsuhiko Miyagawa [Changes for 0.16 - 2006-01-11] * Proper Headless/chomping/quoting support for Miyagawa's JSON::Syck branch. JSON::Syck and YAML::Syck now shares a codebase completely. Requested by: Tatsuhiko Miyagawa [Changes for 0.15 - 2006-01-10] * Add a $YAML::Syck::Headless flag to control emission of "---\n" headers, for easier JSON interoperability. * Fix mis-dumping references as strings if the same pad position has stored a previous dump result as string. Reported by: Tatsuhiko Miyagawa * Fix build on Perl 5.6.x and on platforms without NAN/INF support. Reported by: Anton Berezin [Changes for 0.14 - 2006-01-09] * Add a $YAML::Syck::ImplicitTyping flag to control recognition of implicit types. Currently supports null, bool, float, int; if it's turned off (as per default) only null is recognized. Reported by: Brian Ingerson * Fix potential emission of redundant "--- " headings in large dumped documents. * We no longer ship Storable.xs with the distribution. [Changes for 0.13 - 2006-01-09] * Parsing an empty string no longer causes bus error in threaded Perls. Reported by: Tatsuhiko Miyagawa [Changes for 0.12 - 2006-01-09] * Parser errors now raises proper exceptions instead of segfaults. Reported by: Tatsuhiko Miyagawa [Changes for 0.11 - 2006-01-09] * Trailing newlines were not outputted by emitters. Reported by: Chia-Liang Kao [Changes for 0.10 - 2006-01-09] * Fix emitting of empty strings; they are now always quoted. Reported by: Chia-Liang Kao [Changes for 0.09 - 2006-01-09] * Downgrade to the last stable release of libsyck to fix the hash dumping layout problem. Reported by: Gaal Yahas [Changes for 0.08 - 2006-01-09] * Fix double-free problem in object dumping. Reported by: Chia-Liang Kao [Changes for 0.07 - 2006-01-09] * Loading of blessed hash and array references. * Do away with Test::More as testing dependency. [Changes for 0.06 - 2006-01-08] * Fix building problems on case-insensitive filesystems. Reported by: Chia-Liang Kao [Changes for 0.05 - 2006-01-08] * DumpFile() and LoadFile() is exported by default. * Undef now dumps as '~'; also supports dumping blessed references as 'perl/!type'. (Loading them doesn't work at this moment.) Implemented by: Gaal Yahas * Loading hashes and arrays no longer creates dangling references that caused memory leaks. Reported by: Tatsuhiko Miyagawa [Changes for 0.04 - 2005-12-28] * Truly support Perl versions before 5.7.3, thanks to ppport.h. Reported by: Anton Berezin [Changes for 0.03 - 2005-12-27] * Make syck.h compile with a Perl built with -DDEBUG. Reported by: Slaven Rezic [Changes for 0.02 - 2005-12-26] * Move from SWIG to much lighter-weight native XS implementation. * Begins bundling Storable.xs to use the same serialization logic. [Changes for 0.01 - 2005-12-26] * Initial release to CPAN of this six-hours-old hack. YAML-Syck-1.31/inc/0000755000000000000000000000000013364413554012366 5ustar rootrootYAML-Syck-1.31/inc/Module/0000755000000000000000000000000013364413554013613 5ustar rootrootYAML-Syck-1.31/inc/Module/Install/0000755000000000000000000000000013364413554015221 5ustar rootrootYAML-Syck-1.31/inc/ExtUtils/0000755000000000000000000000000013364413554014147 5ustar rootrootYAML-Syck-1.31/inc/ExtUtils/HasCompiler.pm0000644000000000000000000002203113364413554016711 0ustar rootrootpackage ExtUtils::HasCompiler; $ExtUtils::HasCompiler::VERSION = '0.021'; use strict; use warnings; use base 'Exporter'; our @EXPORT_OK = qw/can_compile_loadable_object can_compile_static_library can_compile_extension/; our %EXPORT_TAGS = (all => \@EXPORT_OK); use Config; use Carp 'carp'; use File::Basename 'basename'; use File::Spec::Functions qw/catfile catdir rel2abs/; use File::Temp qw/tempdir tempfile/; my $tempdir = tempdir('HASCOMPILERXXXX', CLEANUP => 1, DIR => '.'); my $loadable_object_format = <<'END'; #define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #ifndef PERL_UNUSED_VAR #define PERL_UNUSED_VAR(var) #endif XS(exported) { #ifdef dVAR dVAR; #endif dXSARGS; PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(items); /* -W */ XSRETURN_IV(42); } #ifndef XS_EXTERNAL #define XS_EXTERNAL(foo) XS(foo) #endif /* we don't want to mess with .def files on mingw */ #if defined(WIN32) && defined(__GNUC__) # define EXPORT __declspec(dllexport) #else # define EXPORT #endif EXPORT XS_EXTERNAL(boot_%s) { #ifdef dVAR dVAR; #endif dXSARGS; PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(items); /* -W */ newXS("%s::exported", exported, __FILE__); } END my $counter = 1; my %prelinking = map { $_ => 1 } qw/MSWin32 VMS aix/; sub can_compile_loadable_object { my %args = @_; my $output = $args{output} || \*STDOUT; my $config = $args{config} || 'ExtUtils::HasCompiler::Config'; return if not $config->get('usedl'); my ($source_handle, $source_name) = tempfile('TESTXXXX', DIR => $tempdir, SUFFIX => '.c', UNLINK => 1); my $basename = basename($source_name, '.c'); my $abs_basename = catfile($tempdir, $basename); my ($cc, $ccflags, $optimize, $cccdlflags, $ld, $ldflags, $lddlflags, $libperl, $perllibs, $archlibexp, $_o, $dlext) = map { $config->get($_) } qw/cc ccflags optimize cccdlflags ld ldflags lddlflags libperl perllibs archlibexp _o dlext/; my $incdir = catdir($archlibexp, 'CORE'); my $object_file = $abs_basename.$_o; my $loadable_object = "$abs_basename.$dlext"; my @commands; if ($^O eq 'MSWin32' && $cc =~ /^cl/) { push @commands, qq{$cc $ccflags $cccdlflags $optimize /I "$incdir" /c $source_name /Fo$object_file}; push @commands, qq{$ld $object_file $lddlflags $libperl $perllibs /out:$loadable_object /def:$abs_basename.def /pdb:$abs_basename.pdb}; } elsif ($^O eq 'VMS') { # Mksymlists is only the beginning of the story. open my $opt_fh, '>>', "$abs_basename.opt" or do { carp "Couldn't append to '$abs_basename.opt'"; return }; print $opt_fh "PerlShr/Share\n"; close $opt_fh; my $incdirs = $ccflags =~ s{ /inc[^=]+ (?:=)+ (?:\()? ( [^\/\)]* ) }{}xi ? "$1,$incdir" : $incdir; push @commands, qq{$cc $ccflags $optimize /include=($incdirs) $cccdlflags $source_name /obj=$object_file}; push @commands, qq{$ld $ldflags $lddlflags=$loadable_object $object_file,$abs_basename.opt/OPTIONS,${incdir}perlshr_attr.opt/OPTIONS' $perllibs}; } else { my @extra; if ($^O eq 'MSWin32') { my $lib = '-l' . ($libperl =~ /lib([^.]+)\./)[0]; push @extra, "$abs_basename.def", $lib, $perllibs; } elsif ($^O eq 'cygwin') { push @extra, catfile($incdir, $config->get('useshrplib') ? 'libperl.dll.a' : 'libperl.a'); } elsif ($^O eq 'aix') { $lddlflags =~ s/\Q$(BASEEXT)\E/$abs_basename/; $lddlflags =~ s/\Q$(PERL_INC)\E/$incdir/; } elsif ($^O eq 'android') { push @extra, qq{"-L$incdir"}, '-lperl', $perllibs; } push @commands, qq{$cc $ccflags $optimize "-I$incdir" $cccdlflags -c $source_name -o $object_file}; push @commands, qq{$ld $object_file -o $loadable_object $lddlflags @extra}; } if ($prelinking{$^O}) { require ExtUtils::Mksymlists; ExtUtils::Mksymlists::Mksymlists(NAME => $basename, FILE => $abs_basename, IMPORTS => {}); } my $shortname = '_Loadable' . $counter++; my $package = "ExtUtils::HasCompiler::$shortname"; printf $source_handle $loadable_object_format, $basename, $package or do { carp "Couldn't write to $source_name: $!"; return }; close $source_handle or do { carp "Couldn't close $source_name: $!"; return }; for my $command (@commands) { print $output "$command\n" if not $args{quiet}; system $command and do { carp "Couldn't execute $command: $!"; return }; } # Skip loading when cross-compiling return 1 if exists $args{skip_load} ? $args{skip_load} : $config->get('usecrosscompile'); require DynaLoader; local @DynaLoader::dl_require_symbols = "boot_$basename"; my $handle = DynaLoader::dl_load_file(rel2abs($loadable_object), 0); if ($handle) { my $symbol = DynaLoader::dl_find_symbol($handle, "boot_$basename") or do { carp "Couldn't find boot symbol for $basename"; return }; my $compilet = DynaLoader::dl_install_xsub('__ANON__::__ANON__', $symbol, $source_name); my $ret = eval { $compilet->(); $package->exported } or carp $@; delete $ExtUtils::HasCompiler::{"$shortname\::"}; eval { DynaLoader::dl_unload_file($handle) } or carp $@; return defined $ret && $ret == 42; } else { carp "Couldn't load $loadable_object: " . DynaLoader::dl_error(); return; } } my %static_unsupported_on = map { $_ => 1 } qw/VMS aix MSWin32 cygwin/; sub can_compile_static_library { my %args = @_; my $output = $args{output} || \*STDOUT; my $config = $args{config} || 'ExtUtils::HasCompiler::Config'; return if $config->get('useshrplib') eq 'true'; my ($source_handle, $source_name) = tempfile('TESTXXXX', DIR => $tempdir, SUFFIX => '.c', UNLINK => 1); my $basename = basename($source_name, '.c'); my $abs_basename = catfile($tempdir, $basename); my ($cc, $ccflags, $optimize, $ar, $full_ar, $ranlib, $archlibexp, $_o, $lib_ext) = map { $config->get($_) } qw/cc ccflags optimize ar full_ar ranlib archlibexp _o lib_ext/; my $incdir = catdir($archlibexp, 'CORE'); my $object_file = "$abs_basename$_o"; my $static_library = $abs_basename.$lib_ext; my @commands; if ($static_unsupported_on{$^O}) { return; } else { my $my_ar = length $full_ar ? $full_ar : $ar; push @commands, qq{$cc $ccflags $optimize "-I$incdir" -c $source_name -o $object_file}; push @commands, qq{$my_ar cr $static_library $object_file}; push @commands, qq{$ranlib $static_library} if $ranlib ne ':'; } my $shortname = '_Loadable' . $counter++; my $package = "ExtUtils::HasCompiler::$shortname"; printf $source_handle $loadable_object_format, $basename, $package or do { carp "Couldn't write to $source_name: $!"; return }; close $source_handle or do { carp "Couldn't close $source_name: $!"; return }; for my $command (@commands) { print $output "$command\n" if not $args{quiet}; system $command and do { carp "Couldn't execute $command: $!"; return }; } return 1; } sub can_compile_extension { my %args = @_; $args{config} ||= 'ExtUtils::HasCompiler::Config'; my $linktype = $args{linktype} || ($args{config}->get('usedl') ? 'dynamic' : 'static'); return $linktype eq 'static' ? can_compile_static_library(%args) : can_compile_loadable_object(%args); } sub ExtUtils::HasCompiler::Config::get { my (undef, $key) = @_; return $ENV{uc $key} || $Config{$key}; } 1; # ABSTRACT: Check for the presence of a compiler __END__ =pod =encoding UTF-8 =head1 NAME ExtUtils::HasCompiler - Check for the presence of a compiler =head1 VERSION version 0.021 =head1 SYNOPSIS use ExtUtils::HasCompiler 'can_compile_extension'; if (can_compile_extension()) { ... } else { ... } =head1 DESCRIPTION This module tries to check if the current system is capable of compiling, linking and loading an XS module. B: this is an early release, interface stability isn't guaranteed yet. =head1 FUNCTIONS =head2 can_compile_loadable_object(%opts) This checks if the system can compile, link and load a perl loadable object. It may take the following options: =over 4 =item * quiet Do not output the executed compilation commands. =item * config An L (compatible) object for configuration. =item * skip_load This causes can_compile_loadable_object to not try to load the generated object. This defaults to true on a cross-compiling perl. =back =head2 can_compile_static_library(%opts) This checks if the system can compile and link a perl static library. It does not check it it can compile a new perl with it. It may take the following options: =over 4 =item * quiet Do not output the executed compilation commands. =item * config An L (compatible) object for configuration. =back =head2 can_compile_extension(%opts) This will call either C, or C, depending on which is the default on your configuration. In addition to the arguments listed above, it can take one more optional argument: =over 4 =item * linktype This will force the linktype to be either static or dynamic. Dynamic compilation on a static perl won't work, but static libraries can be viable on a dynamic perl. =back =head1 AUTHOR Leon Timmermans =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Leon Timmermans. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut YAML-Syck-1.31/inc/Test/0000755000000000000000000000000013364413554013305 5ustar rootrootYAML-Syck-1.31/inc/Test/Builder/0000755000000000000000000000000013364413554014673 5ustar rootrootYAML-Syck-1.31/inc/Test/Builder/IO/0000755000000000000000000000000013364413554015202 5ustar rootrootYAML-Syck-1.31/inc/Scalar/0000755000000000000000000000000013364413554013573 5ustar rootrootYAML-Syck-1.31/gram.h0000644000000000000000000000441213364413554012715 0ustar rootroot/* A Bison parser, made by GNU Bison 1.875d. */ /* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { YAML_ANCHOR = 258, YAML_ALIAS = 259, YAML_TRANSFER = 260, YAML_TAGURI = 261, YAML_ITRANSFER = 262, YAML_WORD = 263, YAML_PLAIN = 264, YAML_BLOCK = 265, YAML_DOCSEP = 266, YAML_IOPEN = 267, YAML_INDENT = 268, YAML_IEND = 269 }; #endif #define YAML_ANCHOR 258 #define YAML_ALIAS 259 #define YAML_TRANSFER 260 #define YAML_TAGURI 261 #define YAML_ITRANSFER 262 #define YAML_WORD 263 #define YAML_PLAIN 264 #define YAML_BLOCK 265 #define YAML_DOCSEP 266 #define YAML_IOPEN 267 #define YAML_INDENT 268 #define YAML_IEND 269 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) #line 35 "gram.y" typedef union YYSTYPE { SYMID nodeId; SyckNode *nodeData; char *name; } YYSTYPE; /* Line 1285 of yacc.c. */ #line 71 "gram.h" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif int sycklex( YYSTYPE *sycklval, SyckParser *parser ); YAML-Syck-1.31/lib/0000755000000000000000000000000013364413554012363 5ustar rootrootYAML-Syck-1.31/lib/YAML/0000755000000000000000000000000013364413554013125 5ustar rootrootYAML-Syck-1.31/lib/YAML/Loader/0000755000000000000000000000000013364413554014333 5ustar rootrootYAML-Syck-1.31/lib/YAML/Loader/Syck.pm0000644000000000000000000000015513364413554015603 0ustar rootrootpackage YAML::Loader::Syck; use strict; sub new { $_[0] } sub load { shift; YAML::Syck::Load( $_[0] ) } 1; YAML-Syck-1.31/lib/YAML/Syck.pm0000644000000000000000000002336313364413117014376 0ustar rootrootpackage YAML::Syck; # See documentation after the __END__ mark. use strict; use vars qw( @ISA @EXPORT @EXPORT_OK $VERSION $Headless $SortKeys $SingleQuote $ImplicitBinary $ImplicitTyping $ImplicitUnicode $UseCode $LoadCode $DumpCode $DeparseObject $LoadBlessed ); use 5.006; use Exporter; BEGIN { $VERSION = '1.31'; @EXPORT = qw( Dump Load DumpFile LoadFile ); @EXPORT_OK = qw( DumpInto ); @ISA = qw( Exporter ); $SortKeys = 1; $LoadBlessed = 1; local $@; eval { require XSLoader; XSLoader::load( __PACKAGE__, $VERSION ); 1; } or do { require DynaLoader; push @ISA, 'DynaLoader'; __PACKAGE__->bootstrap($VERSION); }; } use constant QR_MAP => { '' => sub { qr{$_[0]} }, x => sub { qr{$_[0]}x }, i => sub { qr{$_[0]}i }, s => sub { qr{$_[0]}s }, m => sub { qr{$_[0]}m }, ix => sub { qr{$_[0]}ix }, sx => sub { qr{$_[0]}sx }, mx => sub { qr{$_[0]}mx }, si => sub { qr{$_[0]}si }, mi => sub { qr{$_[0]}mi }, ms => sub { qr{$_[0]}sm }, six => sub { qr{$_[0]}six }, mix => sub { qr{$_[0]}mix }, msx => sub { qr{$_[0]}msx }, msi => sub { qr{$_[0]}msi }, msix => sub { qr{$_[0]}msix }, }; sub __qr_helper { if ( $_[0] =~ /\A \(\? ([ixsm]*) (?:- (?:[ixsm]*))? : (.*) \) \z/x ) { my $sub = QR_MAP()->{$1} || QR_MAP()->{''}; &$sub($2); } else { qr/$_[0]/; } } sub Dump { $#_ ? join( '', map { YAML::Syck::DumpYAML($_) } @_ ) : YAML::Syck::DumpYAML( $_[0] ); } sub Load { if (wantarray) { my ($rv) = YAML::Syck::LoadYAML( $_[0] ); @{$rv}; } else { @_ = $_[0]; goto &YAML::Syck::LoadYAML; } } sub _is_glob { my $h = shift; return 1 if ( ref($h) eq 'GLOB' ); return 1 if ( ref( \$h ) eq 'GLOB' ); return 1 if ( ref($h) =~ m/^IO::/ ); return; } sub DumpFile { my $file = shift; if ( _is_glob($file) ) { for (@_) { my $err = YAML::Syck::DumpYAMLFile( $_, $file ); if ($err) { $! = 0 + $err; die "Error writing to filehandle $file: $!\n"; } } } else { open( my $fh, '>', $file ) or die "Cannot write to $file: $!"; for (@_) { my $err = YAML::Syck::DumpYAMLFile( $_, $fh ); if ($err) { $! = 0 + $err; die "Error writing to file $file: $!\n"; } } close $fh or die "Error writing to file $file: $!\n"; } return 1; } sub LoadFile { my $file = shift; if ( _is_glob($file) ) { Load( do { local $/; <$file> } ); } else { if ( !-e $file || -z $file ) { die("'$file' is empty or non-existent"); } open( my $fh, '<', $file ) or die "Cannot read from $file: $!"; Load( do { local $/; <$fh> } ); } } sub DumpInto { my $bufref = shift; ( ref $bufref ) or die "DumpInto not given reference to output buffer\n"; YAML::Syck::DumpYAMLInto( $_, $bufref ) for @_; 1; } 1; __END__ =pod =head1 NAME YAML::Syck - Fast, lightweight YAML loader and dumper =head1 SYNOPSIS use YAML::Syck; # Set this for interoperability with other YAML/Syck bindings: # e.g. Load('Yes') becomes 1 and Load('No') becomes ''. $YAML::Syck::ImplicitTyping = 1; $data = Load($yaml); $yaml = Dump($data); # $file can be an IO object, or a filename $data = LoadFile($file); DumpFile($file, $data); # A string with multiple YAML streams in it $yaml = Dump(@data); @data = Load($yaml); # Dumping into a pre-existing output buffer my $yaml; DumpInto(\$yaml, @data); =head1 DESCRIPTION This module provides a Perl interface to the B data serialization library. It exports the C and C functions for converting Perl data structures to YAML strings, and the other way around. B: If you are working with other language's YAML/Syck bindings (such as Ruby), please set C<$YAML::Syck::ImplicitTyping> to C<1> before calling the C/C functions. The default setting is for preserving backward-compatibility with C. =head1 Differences Between YAML::Syck and YAML =head2 Error handling Some calls are designed to die rather than returning YAML. You should wrap your calls in eval to assure you do not get unexpected results. =head1 FLAGS =head2 $YAML::Syck::Headless Defaults to false. Setting this to a true value will make C omit the leading C<---\n> marker. =head2 $YAML::Syck::SortKeys Defaults to false. Setting this to a true value will make C sort hash keys. =head2 $YAML::Syck::SingleQuote Defaults to false. Setting this to a true value will make C always emit single quotes instead of bare strings. =head2 $YAML::Syck::ImplicitTyping Defaults to false. Setting this to a true value will make C recognize various implicit types in YAML, such as unquoted C, C, as well as integers and floating-point numbers. Otherwise, only C<~> is recognized to be C. =head2 $YAML::Syck::ImplicitUnicode Defaults to false. For Perl 5.8.0 or later, setting this to a true value will make C set Unicode flag on for every string that contains valid UTF8 sequences, and make C return a unicode string. Regardless of this flag, Unicode strings are dumped verbatim without escaping; byte strings with high-bit set will be dumped with backslash escaping. However, because YAML does not distinguish between these two kinds of strings, so this flag will affect loading of both variants of strings. If you want to use LoadFile or DumpFile with unicode, you are required to open your own file in order to assure it's UTF8 encoded: open(my $fh, ">:encoding(UTF-8)", "out.yml"); DumpFile($fh, $hashref); =head2 $YAML::Syck::ImplicitBinary Defaults to false. For Perl 5.8.0 or later, setting this to a true value will make C generate Base64-encoded C data for all non-Unicode scalars containing high-bit bytes. =head2 $YAML::Syck::UseCode / $YAML::Syck::LoadCode / $YAML::Syck::DumpCode These flags control whether or not to try and eval/deparse perl source code; each of them defaults to false. Setting C<$YAML::Syck::UseCode> to a true value is equivalent to setting both C<$YAML::Syck::LoadCode> and C<$YAML::Syck::DumpCode> to true. =head2 $YAML::Syck::LoadBlessed Defaults to true. Setting to false will block YAML::Syck from doing ANY blessing. This is an interface change since 1.21. The variable name was misleading, implying that no blessing would happen when in fact it did. Prior to 1.22, setting this to a false value only prevented C from blessing tag names that did not begin with C or C;. =head1 BUGS Dumping Glob/IO values do not work yet. Dumping of Tied variables is unsupported. Dumping into tied (or other magic variables) with C might not work properly in all cases. =head1 CAVEATS This module implements the YAML 1.0 spec. To deal with data in YAML 1.1, please use the C module instead. The current implementation bundles libsyck source code; if your system has a site-wide shared libsyck, it will I be used. Tag names such as C is blessed into the package C, but the C and C tags are blessed into C. Note that this holds true even if the tag contains non-word characters; for example, C is blessed into C. Please use L to cast it into other user-defined packages. You can also set the LoadBlessed flag false to disable all blessing. This module has L and has only been semi-actively maintained since 2007. If you encounter an issue with it probably won't be fixed unless you L in Git that's ready for release. There are still good reasons to use this module, such as better interoperability with other syck wrappers (like Ruby's), or some edge case of YAML's syntax that it handles better. It'll probably work perfectly for you, but if it doesn't you may want to look at L, or perhaps at looking another serialization format like L. =head1 SEE ALSO L, L L =head1 AUTHORS Audrey Tang Ecpan@audreyt.orgE =head1 COPYRIGHT Copyright 2005-2009 by Audrey Tang Ecpan@audreyt.orgE. This software is released under the MIT license cited below. The F code bundled with this library is released by "why the lucky stiff", under a BSD-style license. See the F file for details. =head2 The "MIT" License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =cut YAML-Syck-1.31/lib/YAML/Dumper/0000755000000000000000000000000013364413554014361 5ustar rootrootYAML-Syck-1.31/lib/YAML/Dumper/Syck.pm0000644000000000000000000000015513364413554015631 0ustar rootrootpackage YAML::Dumper::Syck; use strict; sub new { $_[0] } sub dump { shift; YAML::Syck::Dump( $_[0] ) } 1; YAML-Syck-1.31/lib/JSON/0000755000000000000000000000000013364413554013134 5ustar rootrootYAML-Syck-1.31/lib/JSON/Syck.pm0000644000000000000000000001520113364413117014375 0ustar rootrootpackage JSON::Syck; use strict; use vars qw( $VERSION @EXPORT_OK @ISA ); use Exporter; use YAML::Syck (); BEGIN { $VERSION = '1.31'; @EXPORT_OK = qw( Load Dump LoadFile DumpFile DumpInto ); @ISA = 'Exporter'; *Load = \&YAML::Syck::LoadJSON; *Dump = \&YAML::Syck::DumpJSON; } sub DumpFile { my $file = shift; if ( YAML::Syck::_is_glob($file) ) { my $err = YAML::Syck::DumpJSONFile( $_[0], $file ); if ($err) { $! = 0 + $err; die "Error writing to filehandle $file: $!\n"; } } else { open( my $fh, '>', $file ) or die "Cannot write to $file: $!"; my $err = YAML::Syck::DumpJSONFile( $_[0], $fh ); if ($err) { $! = 0 + $err; die "Error writing to file $file: $!\n"; } close $fh or die "Error writing to file $file: $!\n"; } return 1; } sub LoadFile { my $file = shift; if ( YAML::Syck::_is_glob($file) ) { YAML::Syck::LoadJSON( do { local $/; <$file> } ); } else { if ( !-e $file || -z $file ) { die("'$file' is non-existent or empty"); } open( my $fh, '<', $file ) or die "Cannot read from $file: $!"; YAML::Syck::LoadJSON( do { local $/; <$fh> } ); } } sub DumpInto { my $bufref = shift; ( ref $bufref ) or die "DumpInto not given reference to output buffer\n"; YAML::Syck::DumpJSONInto( $_[0], $bufref ); 1; } $JSON::Syck::ImplicitTyping = 1; $JSON::Syck::MaxDepth = 512; $JSON::Syck::Headless = 1; $JSON::Syck::ImplicitUnicode = 0; $JSON::Syck::SingleQuote = 0; 1; __END__ =head1 NAME JSON::Syck - JSON is YAML (but consider using L instead!) =head1 SYNOPSIS use JSON::Syck; # no exports by default my $data = JSON::Syck::Load($json); my $json = JSON::Syck::Dump($data); # $file can be an IO object, or a filename my $data = JSON::Syck::LoadFile($file); JSON::Syck::DumpFile($file, $data); # Dump into a pre-existing buffer my $json; JSON::Syck::DumpInto(\$json, $data); =head1 DESCRIPTION JSON::Syck is a syck implementation of JSON parsing and generation. Because JSON is YAML (L), using syck gives you a fast and memory-efficient parser and dumper for JSON data representation. However, a newer module L, has since emerged. It is more flexible, efficient and robust, so please consider using it instead of this module. =head1 DIFFERENCE WITH JSON You might want to know the difference between the I module and this one. Since JSON is a pure-perl module and JSON::Syck is based on libsyck, JSON::Syck is supposed to be very fast and memory efficient. See chansen's benchmark table at L JSON.pm comes with dozens of ways to do the same thing and lots of options, while JSON::Syck doesn't. There's only C and C. Oh, and JSON::Syck doesn't use camelCase method names :-) =head1 REFERENCES =head2 SCALAR REFERENCE For now, when you pass a scalar reference to JSON::Syck, it dereferences to get the actual scalar value. JSON::Syck raises an exception when you pass in circular references. If you want to serialize self referencing stuff, you should use YAML which supports it. =head2 SUBROUTINE REFERENCE When you pass subroutine reference, JSON::Syck dumps it as null. =head1 UTF-8 FLAGS By default this module doesn't touch any of utf-8 flags set in strings, and assumes UTF-8 bytes to be passed and emit. However, when you set C<$JSON::Syck::ImplicitUnicode> to 1, this module properly decodes UTF-8 binaries and sets UTF-8 flag everywhere, as in: JSON (UTF-8 bytes) => Perl (UTF-8 flagged) JSON (UTF-8 flagged) => Perl (UTF-8 flagged) Perl (UTF-8 bytes) => JSON (UTF-8 flagged) Perl (UTF-8 flagged) => JSON (UTF-8 flagged) By default, JSON::Syck::Dump will only transverse up to 512 levels of a datastructure in order to avoid an infinite loop when it is presented with an circular reference. However, you set C<$JSON::Syck::MaxLevels> to a larger value if you have very complex structures. Unfortunately, there's no implicit way to dump Perl UTF-8 flagged data structure to utf-8 encoded JSON. To do this, simply use Encode module, e.g.: use Encode; use JSON::Syck qw(Dump); my $json = encode_utf8( Dump($data) ); Alternatively you can use Encode::JavaScript::UCS to encode Unicode strings as in I<%uXXXX> form. use Encode; use Encode::JavaScript::UCS; use JSON::Syck qw(Dump); my $json_unicode_escaped = encode( 'JavaScript-UCS', Dump($data) ); =head1 QUOTING According to the JSON specification, all JSON strings are to be double-quoted. However, when embedding JavaScript in HTML attributes, it may be more convenient to use single quotes. Set C<$JSON::Syck::SingleQuote> to 1 will make both C and C expect single-quoted string literals. =head1 BUGS Dumping into tied (or other magic variables) with C might not work properly in all cases. When dumping with C, some spacing might be wrong and C<$JSON::Syck::SingleQuote> might be handled incorrectly. =head1 SEE ALSO L, L =head1 AUTHORS Audrey Tang Ecpan@audreyt.orgE Tatsuhiko Miyagawa Emiyagawa@gmail.comE =head1 COPYRIGHT Copyright 2005-2009 by Audrey Tang Ecpan@audreyt.orgE. This software is released under the MIT license cited below. The F code bundled with this library is released by "why the lucky stiff", under a BSD-style license. See the F file for details. =head2 The "MIT" License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =cut YAML-Syck-1.31/ppport_math.h0000644000000000000000000000242513364413554014326 0ustar rootroot#if !defined(NV_INF) && defined(USE_LONG_DOUBLE) && defined(LDBL_INFINITY) # define NV_INF LDBL_INFINITY #endif #if !defined(NV_INF) && defined(DBL_INFINITY) # define NV_INF (NV)DBL_INFINITY #endif #if !defined(NV_INF) && defined(INFINITY) # define NV_INF (NV)INFINITY #endif #if !defined(NV_INF) && defined(INF) # define NV_INF (NV)INF #endif #if !defined(NV_INF) && defined(USE_LONG_DOUBLE) && defined(HUGE_VALL) # define NV_INF (NV)HUGE_VALL #endif #if !defined(NV_INF) && defined(HUGE_VAL) # define NV_INF (NV)HUGE_VAL #endif #if !defined(NV_NAN) && defined(USE_LONG_DOUBLE) # if !defined(NV_NAN) && defined(LDBL_NAN) # define NV_NAN LDBL_NAN # endif # if !defined(NV_NAN) && defined(LDBL_QNAN) # define NV_NAN LDBL_QNAN # endif # if !defined(NV_NAN) && defined(LDBL_SNAN) # define NV_NAN LDBL_SNAN # endif #endif #if !defined(NV_NAN) && defined(DBL_NAN) # define NV_NAN (NV)DBL_NAN #endif #if !defined(NV_NAN) && defined(DBL_QNAN) # define NV_NAN (NV)DBL_QNAN #endif #if !defined(NV_NAN) && defined(DBL_SNAN) # define NV_NAN (NV)DBL_SNAN #endif #if !defined(NV_NAN) && defined(QNAN) # define NV_NAN (NV)QNAN #endif #if !defined(NV_NAN) && defined(SNAN) # define NV_NAN (NV)SNAN #endif #if !defined(NV_NAN) && defined(NAN) # define NV_NAN (NV)NAN #endif YAML-Syck-1.31/bytecode.c0000644000000000000000000005177213364413554013573 0ustar rootroot/* Generated by re2c 0.10.1 on Mon May 8 21:26:42 2006 */ #line 1 "bytecode.re" /* * bytecode.re * * $Author: why $ * $Date: 2005-09-20 13:21:06 +0800 (二, 20 9 2005) $ * * Copyright (C) 2003 why the lucky stiff */ #include "syck.h" #include "gram.h" #define QUOTELEN 128 /* * They do my bidding... */ #define YYCTYPE char #define YYCURSOR parser->cursor #define YYMARKER parser->marker #define YYLIMIT parser->limit #define YYTOKEN parser->token #define YYTOKTMP parser->toktmp #define YYLINEPTR parser->lineptr #define YYLINECTPTR parser->linectptr #define YYLINE parser->linect #define YYFILL(n) syck_parser_read(parser) extern SyckParser *syck_parser_ptr; char *get_inline( SyckParser *parser ); /* * Repositions the cursor at `n' offset from the token start. * Only works in `Header' and `Document' sections. */ #define YYPOS(n) YYCURSOR = YYTOKEN + n /* * Track line numbers */ #define CHK_NL(ptr) if ( *( ptr - 1 ) == '\n' && ptr > YYLINECTPTR ) { YYLINEPTR = ptr; YYLINE++; YYLINECTPTR = YYLINEPTR; } /* * I like seeing the level operations as macros... */ #define ADD_LEVEL(len, status) syck_parser_add_level( parser, len, status ) #define POP_LEVEL() syck_parser_pop_level( parser ) #define CURRENT_LEVEL() syck_parser_current_level( parser ) /* * Force a token next time around sycklex() */ #define FORCE_NEXT_TOKEN(tok) parser->force_token = tok; /* * Adding levels in bytecode requires us to make sure * we've got all our tokens worked out. */ #define ADD_BYTE_LEVEL(lvl, len, s ) \ switch ( lvl->status ) \ { \ case syck_lvl_seq: \ lvl->ncount++; \ ADD_LEVEL(len, syck_lvl_open); \ YYPOS(0); \ return '-'; \ \ case syck_lvl_map: \ lvl->ncount++; \ ADD_LEVEL(len, s); \ break; \ \ case syck_lvl_open: \ lvl->status = s; \ break; \ \ default: \ ADD_LEVEL(len, s); \ break; \ } /* * Nice little macro to ensure we're YAML_IOPENed to the current level. * * Only use this macro in the "Document" section * */ #define ENSURE_YAML_IOPEN(last_lvl, lvl_type, to_len, reset) \ if ( last_lvl->spaces < to_len ) \ { \ if ( last_lvl->status == syck_lvl_iseq || last_lvl->status == syck_lvl_imap ) \ { \ goto Document; \ } \ else \ { \ ADD_LEVEL( to_len, lvl_type ); \ if ( reset == 1 ) YYPOS(0); \ return YAML_IOPEN; \ } \ } /* * Nice little macro to ensure closure of levels. * * Only use this macro in the "Document" section * */ #define ENSURE_YAML_IEND(last_lvl, to_len) \ if ( last_lvl->spaces > to_len ) \ { \ syck_parser_pop_level( parser ); \ YYPOS(0); \ return YAML_IEND; \ } /* * Concatenates string items and manages allocation * to the string */ #define CAT(s, c, i, l) \ { \ if ( i + 1 >= c ) \ { \ c += QUOTELEN; \ S_REALLOC_N( s, char, c ); \ } \ s[i++] = l; \ s[i] = '\0'; \ } /* * Parser for standard YAML Bytecode [UTF-8] */ int sycklex_bytecode_utf8( YYSTYPE *sycklval, SyckParser *parser ) { SyckLevel *lvl; syck_parser_ptr = parser; if ( YYCURSOR == NULL ) { syck_parser_read( parser ); } if ( parser->force_token != 0 ) { int t = parser->force_token; parser->force_token = 0; return t; } #line 172 "bytecode.re" lvl = CURRENT_LEVEL(); if ( lvl->status == syck_lvl_doc ) { goto Document; } /* Header: */ YYTOKEN = YYCURSOR; #line 165 "" { YYCTYPE yych; unsigned int yyaccept = 0; if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy2; case 'D': goto yy3; default: goto yy5; } yy2: YYCURSOR = YYMARKER; switch(yyaccept){ case 0: goto yy4; } yy3: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ case 0x0A: goto yy6; case 0x0D: goto yy8; default: goto yy4; } yy4: #line 199 "bytecode.re" { YYPOS(0); goto Document; } #line 195 "" yy5: yych = *++YYCURSOR; goto yy4; yy6: ++YYCURSOR; #line 186 "bytecode.re" { if ( lvl->status == syck_lvl_header ) { CHK_NL(YYCURSOR); goto Directive; } else { ENSURE_YAML_IEND(lvl, -1); YYPOS(0); return 0; } } #line 214 "" yy8: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy6; default: goto yy2; } } #line 203 "bytecode.re" Document: { lvl = CURRENT_LEVEL(); if ( lvl->status == syck_lvl_header ) { lvl->status = syck_lvl_doc; } YYTOKEN = YYCURSOR; #line 236 "" { YYCTYPE yych; if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy30; case 0x0A: goto yy27; case 0x0D: goto yy29; case 'A': goto yy19; case 'D': goto yy12; case 'E': goto yy16; case 'M': goto yy14; case 'P': goto yy13; case 'Q': goto yy15; case 'R': goto yy21; case 'S': goto yy17; case 'T': goto yy23; case 'c': goto yy25; default: goto yy11; } yy11: yy12: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy41; case 0x0D: goto yy44; default: goto yy11; } yy13: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy41; case 0x0D: goto yy43; default: goto yy11; } yy14: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy38; case 0x0D: goto yy40; default: goto yy11; } yy15: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy35; case 0x0D: goto yy37; default: goto yy11; } yy16: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy32; case 0x0D: goto yy34; default: goto yy11; } yy17: ++YYCURSOR; #line 288 "bytecode.re" { ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_str); goto Scalar; } #line 299 "" yy19: ++YYCURSOR; #line 292 "bytecode.re" { ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_open); sycklval->name = get_inline( parser ); syck_hdlr_remove_anchor( parser, sycklval->name ); CHK_NL(YYCURSOR); return YAML_ANCHOR; } #line 309 "" yy21: ++YYCURSOR; #line 299 "bytecode.re" { ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_str); sycklval->name = get_inline( parser ); POP_LEVEL(); if ( *( YYCURSOR - 1 ) == '\n' ) YYCURSOR--; return YAML_ALIAS; } #line 319 "" yy23: ++YYCURSOR; #line 306 "bytecode.re" { char *qstr; ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_open); qstr = get_inline( parser ); CHK_NL(YYCURSOR); if ( qstr[0] == '!' ) { int qidx = strlen( qstr ); if ( qstr[1] == '\0' ) { free( qstr ); return YAML_ITRANSFER; } lvl = CURRENT_LEVEL(); /* * URL Prefixing */ if ( qstr[1] == '^' ) { sycklval->name = S_ALLOC_N( char, qidx + strlen( lvl->domain ) ); sycklval->name[0] = '\0'; strcat( sycklval->name, lvl->domain ); strncat( sycklval->name, qstr + 2, qidx - 2 ); free( qstr ); } else { char *carat = qstr + 1; char *qend = qstr + qidx; while ( (++carat) < qend ) { if ( *carat == '^' ) break; } if ( carat < qend ) { free( lvl->domain ); lvl->domain = syck_strndup( qstr + 1, carat - ( qstr + 1 ) ); sycklval->name = S_ALLOC_N( char, ( qend - carat ) + strlen( lvl->domain ) ); sycklval->name[0] = '\0'; strcat( sycklval->name, lvl->domain ); strncat( sycklval->name, carat + 1, ( qend - carat ) - 1 ); free( qstr ); } else { sycklval->name = S_ALLOC_N( char, strlen( qstr ) ); sycklval->name[0] = '\0'; S_MEMCPY( sycklval->name, qstr + 1, char, strlen( qstr ) ); free( qstr ); } } return YAML_TRANSFER; } sycklval->name = qstr; return YAML_TAGURI; } #line 382 "" yy25: ++YYCURSOR; #line 366 "bytecode.re" { goto Comment; } #line 387 "" yy27: ++YYCURSOR; #line 368 "bytecode.re" { CHK_NL(YYCURSOR); if ( lvl->status == syck_lvl_seq ) { return YAML_INDENT; } else if ( lvl->status == syck_lvl_map ) { if ( lvl->ncount % 2 == 1 ) return ':'; else return YAML_INDENT; } goto Document; } #line 403 "" yy29: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy27; default: goto yy11; } yy30: ++YYCURSOR; #line 381 "bytecode.re" { ENSURE_YAML_IEND(lvl, -1); YYPOS(0); return 0; } #line 417 "" yy32: ++YYCURSOR; #line 252 "bytecode.re" { if ( lvl->status == syck_lvl_seq && lvl->ncount == 0 ) { lvl->ncount++; YYPOS(0); FORCE_NEXT_TOKEN( ']' ); return '['; } else if ( lvl->status == syck_lvl_map && lvl->ncount == 0 ) { lvl->ncount++; YYPOS(0); FORCE_NEXT_TOKEN( '}' ); return '{'; } POP_LEVEL(); lvl = CURRENT_LEVEL(); if ( lvl->status == syck_lvl_seq ) { FORCE_NEXT_TOKEN(YAML_INDENT); } else if ( lvl->status == syck_lvl_map ) { if ( lvl->ncount % 2 == 1 ) { FORCE_NEXT_TOKEN(':'); } else { FORCE_NEXT_TOKEN(YAML_INDENT); } } CHK_NL(YYCURSOR); return YAML_IEND; } #line 456 "" yy34: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy32; default: goto yy11; } yy35: ++YYCURSOR; #line 237 "bytecode.re" { int complex = 0; if ( lvl->ncount % 2 == 0 && ( lvl->status == syck_lvl_map || lvl->status == syck_lvl_seq ) ) { complex = 1; } ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_seq); CHK_NL(YYCURSOR); if ( complex ) { FORCE_NEXT_TOKEN( YAML_IOPEN ); return '?'; } return YAML_IOPEN; } #line 480 "" yy37: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy35; default: goto yy11; } yy38: ++YYCURSOR; #line 222 "bytecode.re" { int complex = 0; if ( lvl->ncount % 2 == 0 && ( lvl->status == syck_lvl_map || lvl->status == syck_lvl_seq ) ) { complex = 1; } ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_map); CHK_NL(YYCURSOR); if ( complex ) { FORCE_NEXT_TOKEN( YAML_IOPEN ); return '?'; } return YAML_IOPEN; } #line 504 "" yy40: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy38; default: goto yy11; } yy41: ++YYCURSOR; #line 217 "bytecode.re" { ENSURE_YAML_IEND(lvl, -1); YYPOS(0); return 0; } #line 518 "" yy43: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy41; default: goto yy11; } yy44: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy41; default: goto yy11; } } #line 386 "bytecode.re" } Directive: { YYTOKEN = YYCURSOR; #line 542 "" { YYCTYPE yych; unsigned int yyaccept = 0; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy47; case 'V': goto yy48; default: goto yy50; } yy47: YYCURSOR = YYMARKER; switch(yyaccept){ case 0: goto yy49; } yy48: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case ';': case '<': case '=': case '>': case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy51; default: goto yy49; } yy49: #line 399 "bytecode.re" { YYCURSOR = YYTOKEN; return YAML_DOCSEP; } #line 645 "" yy50: yych = *++YYCURSOR; goto yy49; yy51: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ';': case '<': case '=': case '>': case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy51; case ':': goto yy53; default: goto yy47; } yy53: yych = *++YYCURSOR; switch(yych){ case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case ';': case '<': case '=': case '>': case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy54; default: goto yy47; } yy54: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ case 0x0A: goto yy56; case 0x0D: goto yy58; case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case ';': case '<': case '=': case '>': case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy54; default: goto yy47; } yy56: ++YYCURSOR; #line 396 "bytecode.re" { CHK_NL(YYCURSOR); goto Directive; } #line 903 "" yy58: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy56; default: goto yy47; } } #line 402 "bytecode.re" } Comment: { YYTOKEN = YYCURSOR; #line 921 "" { YYCTYPE yych; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy61; case 0x0A: goto yy62; case 0x0D: goto yy64; default: goto yy66; } yy61: yy62: ++YYCURSOR; yy63: #line 412 "bytecode.re" { CHK_NL(YYCURSOR); goto Document; } #line 939 "" yy64: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy67; default: goto yy65; } yy65: #line 415 "bytecode.re" { goto Comment; } #line 949 "" yy66: yych = *++YYCURSOR; goto yy65; yy67: ++YYCURSOR; yych = *YYCURSOR; goto yy63; } #line 417 "bytecode.re" } Scalar: { int idx = 0; int cap = 100; char *str = S_ALLOC_N( char, cap ); char *tok; str[0] = '\0'; Scalar2: tok = YYCURSOR; #line 976 "" { YYCTYPE yych; if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy74; case 0x0A: goto yy70; case 0x0D: goto yy72; default: goto yy76; } yy70: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 'C': goto yy78; case 'N': goto yy80; case 'Z': goto yy83; default: goto yy71; } yy71: #line 461 "bytecode.re" { YYCURSOR = tok; goto ScalarEnd; } #line 1000 "" yy72: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy77; default: goto yy73; } yy73: #line 469 "bytecode.re" { CAT(str, cap, idx, tok[0]); goto Scalar2; } #line 1012 "" yy74: ++YYCURSOR; #line 465 "bytecode.re" { YYCURSOR = tok; goto ScalarEnd; } #line 1019 "" yy76: yych = *++YYCURSOR; goto yy73; yy77: yych = *++YYCURSOR; switch(yych){ case 'C': goto yy78; case 'N': goto yy80; case 'Z': goto yy83; default: goto yy71; } yy78: ++YYCURSOR; #line 435 "bytecode.re" { CHK_NL(tok+1); goto Scalar2; } #line 1036 "" yy80: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy80; default: goto yy82; } yy82: #line 438 "bytecode.re" { CHK_NL(tok+1); if ( tok + 2 < YYCURSOR ) { char *count = tok + 2; int total = strtod( count, NULL ); int i; for ( i = 0; i < total; i++ ) { CAT(str, cap, idx, '\n'); } } else { CAT(str, cap, idx, '\n'); } goto Scalar2; } #line 1073 "" yy83: ++YYCURSOR; #line 456 "bytecode.re" { CHK_NL(tok+1); CAT(str, cap, idx, '\0'); goto Scalar2; } #line 1081 "" } #line 473 "bytecode.re" ScalarEnd: { SyckNode *n = syck_alloc_str(); n->data.str->ptr = str; n->data.str->len = idx; sycklval->nodeData = n; POP_LEVEL(); if ( parser->implicit_typing == 1 ) { try_tag_implicit( sycklval->nodeData, parser->taguri_expansion ); } return YAML_PLAIN; } } } char * get_inline( SyckParser *parser ) { int idx = 0; int cap = 100; char *str = S_ALLOC_N( char, cap ); char *tok; str[0] = '\0'; Inline: { tok = YYCURSOR; #line 1118 "" { YYCTYPE yych; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy91; case 0x0A: goto yy87; case 0x0D: goto yy89; default: goto yy93; } yy87: ++YYCURSOR; yy88: #line 508 "bytecode.re" { CHK_NL(YYCURSOR); return str; } #line 1135 "" yy89: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy94; default: goto yy90; } yy90: #line 515 "bytecode.re" { CAT(str, cap, idx, tok[0]); goto Inline; } #line 1147 "" yy91: ++YYCURSOR; #line 511 "bytecode.re" { YYCURSOR = tok; return str; } #line 1154 "" yy93: yych = *++YYCURSOR; goto yy90; yy94: ++YYCURSOR; yych = *YYCURSOR; goto yy88; } #line 519 "bytecode.re" } } YAML-Syck-1.31/perl_syck.h0000644000000000000000000012754013364413554013772 0ustar rootroot/* Implementation-specific variables */ #undef PACKAGE_NAME #undef NULL_LITERAL #undef NULL_LITERAL_LENGTH #undef SCALAR_NUMBER #undef SCALAR_STRING #undef SCALAR_QUOTED #undef SCALAR_UTF8 #undef SEQ_NONE #undef MAP_NONE #undef IS_UTF8 #undef TYPE_IS_NULL #undef OBJOF #undef PERL_SYCK_PARSER_HANDLER #undef PERL_SYCK_EMITTER_HANDLER #undef PERL_SYCK_INDENT_LEVEL #undef PERL_SYCK_MARK_EMITTER #undef PERL_SYCK_EMITTER_MARK_NODE_FLAGS #ifdef YAML_IS_JSON # define PACKAGE_NAME "JSON::Syck" # define NULL_LITERAL "null" # define NULL_LITERAL_LENGTH 4 # define SCALAR_NUMBER scalar_none # define PERL_SYCK_EMITTER_MARK_NODE_FLAGS EMITTER_MARK_NODE_FLAG_PERMIT_DUPLICATE_NODES int json_max_depth = 512; char json_quote_char = '"'; static enum scalar_style json_quote_style = scalar_2quote; # define SCALAR_STRING json_quote_style # define SCALAR_QUOTED json_quote_style # define SCALAR_UTF8 scalar_fold # define SEQ_NONE seq_inline # define MAP_NONE map_inline # define IS_UTF8(x) TRUE # define TYPE_IS_NULL(x) ((x == NULL) || strEQ( x, "str" )) # define OBJOF(a) (a) # define PERL_SYCK_PARSER_HANDLER json_syck_parser_handler # define PERL_SYCK_EMITTER_HANDLER json_syck_emitter_handler # define PERL_SYCK_MARK_EMITTER json_syck_mark_emitter # define PERL_SYCK_INDENT_LEVEL 0 #else # define PACKAGE_NAME "YAML::Syck" # define REGEXP_LITERAL "REGEXP" # define REGEXP_LITERAL_LENGTH 6 # define REF_LITERAL "=" # define REF_LITERAL_LENGTH 1 # define NULL_LITERAL "~" # define NULL_LITERAL_LENGTH 1 # define SCALAR_NUMBER scalar_none # define PERL_SYCK_EMITTER_MARK_NODE_FLAGS 0 static enum scalar_style yaml_quote_style = scalar_none; # define SCALAR_STRING yaml_quote_style # define SCALAR_QUOTED scalar_1quote # define SCALAR_UTF8 scalar_fold # define SEQ_NONE seq_none # define MAP_NONE map_none #ifdef SvUTF8 # define IS_UTF8(x) (SvUTF8(sv)) #else # define IS_UTF8(x) (FALSE) #endif # define TYPE_IS_NULL(x) (x == NULL) # define OBJOF(a) (*tag ? tag : a) # define PERL_SYCK_PARSER_HANDLER yaml_syck_parser_handler # define PERL_SYCK_EMITTER_HANDLER yaml_syck_emitter_handler # define PERL_SYCK_MARK_EMITTER yaml_syck_mark_emitter # define PERL_SYCK_INDENT_LEVEL 2 #endif #define TRACK_OBJECT(sv) (av_push(((struct parser_xtra *)p->bonus)->objects, sv)) #define USE_OBJECT(sv) (SvREFCNT_inc(sv)) #ifndef YAML_IS_JSON #ifndef SvRV_set /* prior to 5.8.7; thx charsbar! */ #define SvRV_set(sv, val) \ STMT_START { \ (SvRV(sv) = (val)); } STMT_END #endif static const char * is_bad_alias_object( SV *sv ) { SV *hv, **psv; if (! sv_isobject(sv)) return NULL; hv = SvRV(sv); if (! strnEQ(sv_reftype(hv, 1), "YAML::Syck::BadAlias", 20-1)) return NULL; psv = hv_fetch((HV *) hv, "name", 4, 0); if (! psv) return NULL; return SvPVX(*psv); } static void register_bad_alias( SyckParser *p, const char *anchor, SV *sv ) { HV *map; SV **pref_av, *new_rvav; AV *rvs; map = ((struct parser_xtra *)p->bonus)->bad_anchors; pref_av = hv_fetch(map, anchor, strlen(anchor), 0); if (! pref_av) { new_rvav = newRV_noinc((SV *) newAV()); hv_store(map, anchor, strlen(anchor), new_rvav, 0); pref_av = &new_rvav; } rvs = (AV *) SvRV(*pref_av); SvREFCNT_inc(sv); av_push(rvs, sv); } static void resolve_bad_alias( SyckParser *p, const char *anchor, SV *sv ) { HV *map; SV **pref_av, *entity; AV *rvs; I32 len, i; entity = SvRV(sv); map = ((struct parser_xtra *)p->bonus)->bad_anchors; pref_av = hv_fetch(map, anchor, strlen(anchor), 0); if (! pref_av) return; rvs = (AV *) SvRV(*pref_av); len = av_len(rvs)+1; for (i = 0; i < len; i ++) { SV **prv = av_fetch(rvs, i, 0); if (prv) { SvREFCNT_dec(SvRV(*prv)); SvRV_set(*prv, entity); SvREFCNT_inc(entity); } } av_clear(rvs); } #endif SYMID #ifdef YAML_IS_JSON json_syck_parser_handler #else yaml_syck_parser_handler #endif (SyckParser *p, SyckNode *n) { SV *sv = NULL; AV *seq; HV *map; long i; char *id = n->type_id; #ifndef YAML_IS_JSON struct parser_xtra *bonus = (struct parser_xtra *)p->bonus; bool load_code = bonus->load_code; bool load_blessed = bonus->load_blessed; #endif while (id && (*id == '!')) { id++; } switch (n->kind) { case syck_str_kind: if (TYPE_IS_NULL(id)) { if (strnEQ( n->data.str->ptr, NULL_LITERAL, 1+NULL_LITERAL_LENGTH) && (n->data.str->style == scalar_plain)) { sv = newSV(0); } else { sv = newSVpvn(n->data.str->ptr, n->data.str->len); CHECK_UTF8; } } else if (strEQ( id, "null" )) { sv = newSV(0); } else if (strEQ( id, "bool#yes" )) { sv = newSVsv(&PL_sv_yes); } else if (strEQ( id, "bool#no" )) { sv = newSVsv(&PL_sv_no); } else if (strEQ( id, "default" )) { sv = newSVpvn(n->data.str->ptr, n->data.str->len); CHECK_UTF8; } else if (strEQ( id, "float#base60" )) { char *ptr, *end; UV sixty = 1; NV total = 0.0; syck_str_blow_away_commas( n ); ptr = n->data.str->ptr; end = n->data.str->ptr + n->data.str->len; while ( end > ptr ) { NV bnum = 0; char *colon = end - 1; while ( colon >= ptr && *colon != ':' ) { colon--; } if ( *colon == ':' ) *colon = '\0'; bnum = strtod( colon + 1, NULL ); total += bnum * sixty; sixty *= 60; end = colon; } sv = newSVnv(total); #ifdef NV_NAN } else if (strEQ( id, "float#nan" )) { sv = newSVnv(NV_NAN); #endif #ifdef NV_INF } else if (strEQ( id, "float#inf" )) { sv = newSVnv(NV_INF); } else if (strEQ( id, "float#neginf" )) { sv = newSVnv(-NV_INF); #endif } else if (strnEQ( id, "float", 5 )) { NV f; syck_str_blow_away_commas( n ); f = strtod( n->data.str->ptr, NULL ); sv = newSVnv( f ); } else if (strEQ( id, "int#base60" )) { char *ptr, *end; UV sixty = 1; UV total = 0; syck_str_blow_away_commas( n ); ptr = n->data.str->ptr; end = n->data.str->ptr + n->data.str->len; while ( end > ptr ) { long bnum = 0; char *colon = end - 1; while ( colon >= ptr && *colon != ':' ) { colon--; } if ( *colon == ':' ) *colon = '\0'; bnum = strtol( colon + 1, NULL, 10 ); total += bnum * sixty; sixty *= 60; end = colon; } sv = newSVuv(total); } else if (strEQ( id, "int#hex" )) { I32 flags = 0; STRLEN len = n->data.str->len; syck_str_blow_away_commas( n ); sv = newSVuv( grok_hex( n->data.str->ptr, &len, &flags, NULL) ); } else if (strEQ( id, "int#oct" )) { I32 flags = 0; STRLEN len = n->data.str->len; syck_str_blow_away_commas( n ); sv = newSVuv( grok_oct( n->data.str->ptr, &len, &flags, NULL) ); } else if (strEQ( id, "int" ) ) { UV uv; int flags; syck_str_blow_away_commas( n ); flags = grok_number( n->data.str->ptr, n->data.str->len, &uv); if (flags == IS_NUMBER_IN_UV) { if (uv <= IV_MAX) { sv = newSViv(uv); } else { sv = newSVuv(uv); } } else if ((flags == (IS_NUMBER_IN_UV | IS_NUMBER_NEG)) && (uv <= (UV) IV_MIN)) { sv = newSViv(-(IV)uv); } else { sv = newSVnv(Atof( n->data.str->ptr )); } } else if (strEQ( id, "binary" )) { long len = 0; char *blob = syck_base64dec(n->data.str->ptr, n->data.str->len, &len); sv = newSVpv(blob, len); #ifndef YAML_IS_JSON #ifdef PERL_LOADMOD_NOIMPORT } else if (strEQ(id, "perl/code") || strnEQ(id, "perl/code:", 10)) { SV *cv; SV *sub; char *pkg = id + 10; if (load_code) { SV *text; /* This code is copypasted from Storable.xs */ /* * prepend "sub " to the source */ text = newSVpvn(n->data.str->ptr, n->data.str->len); sub = newSVpvn("sub ", 4); sv_catpv(sub, SvPV_nolen(text)); /* XXX no sv_catsv! */ SvREFCNT_dec(text); } else { sub = newSVpvn("sub {}", 6); } ENTER; SAVETMPS; cv = eval_pv(SvPV_nolen(sub), TRUE); sv_2mortal(sub); if (cv && SvROK(cv) && SvTYPE(SvRV(cv)) == SVt_PVCV) { sv = cv; } else { croak("code %s did not evaluate to a subroutine reference\n", SvPV_nolen(sub)); } SvREFCNT_inc(sv); /* XXX seems to be necessary */ FREETMPS; LEAVE; if ( load_blessed && (*(pkg - 1) != '\0') && (*pkg != '\0') ) { sv_bless(sv, gv_stashpv(pkg, TRUE)); } /* END Storable */ } else if (strnEQ( n->data.str->ptr, REF_LITERAL, 1+REF_LITERAL_LENGTH)) { /* type tag in a scalar ref */ char *lang = strtok(id, "/:"); char *type = strtok(NULL, ""); if (lang == NULL || (strEQ(lang, "perl"))) { sv = newSVpv(type, 0); } else { sv = newSVpv(form((type == NULL) ? "%s" : "%s::%s", lang, type), 0); } } else if ( strEQ( id, "perl/scalar" ) || strnEQ( id, "perl/scalar:", 12 ) ) { char *pkg = id + 12; if (strnEQ( n->data.str->ptr, NULL_LITERAL, 1+NULL_LITERAL_LENGTH) && (n->data.str->style == scalar_plain)) { sv = newSV(0); } else { sv = newSVpvn(n->data.str->ptr, n->data.str->len); CHECK_UTF8; } sv = newRV_inc(sv); if ( load_blessed && (*(pkg - 1) != '\0') && (*pkg != '\0') ) { sv_bless(sv, gv_stashpv(id + 12, TRUE)); } } else if ( (strEQ(id, "perl/regexp") || strnEQ( id, "perl/regexp:", 12 ) ) ) { dSP; SV *val = newSVpvn(n->data.str->ptr, n->data.str->len); char *lang = strtok(id, "/:"); char *type = strtok(NULL, ""); ENTER; SAVETMPS; PUSHMARK(sp); XPUSHs(val); PUTBACK; call_pv("YAML::Syck::__qr_helper", G_SCALAR); SPAGAIN; sv = newSVsv(POPs); PUTBACK; FREETMPS; LEAVE; /* bless it if necessary */ if ( type != NULL && strnEQ(type, "regexp:", 7)) { /* !perl/regexp:Foo::Bar blesses into Foo::Bar */ type += 7; } if ( load_blessed ) { if (lang == NULL || (strEQ(lang, "perl"))) { /* !perl/regexp on it's own causes no blessing */ if ( (type != NULL) && strNE(type, "regexp") && (*type != '\0')) { sv_bless(sv, gv_stashpv(type, TRUE)); } } else { sv_bless(sv, gv_stashpv(form((type == NULL) ? "%s" : "%s::%s", lang, type), TRUE)); } } #endif /* PERL_LOADMOD_NOIMPORT */ #endif /* !YAML_IS_JSON */ } else { /* croak("unknown node type: %s", id); */ sv = newSVpvn(n->data.str->ptr, n->data.str->len); CHECK_UTF8; } break; case syck_seq_kind: /* load the seq into a new AV and place a ref to it in the SV */ seq = newAV(); for (i = 0; i < n->data.list->idx; i++) { SV *a = perl_syck_lookup_sym(p, syck_seq_read(n, i)); #ifndef YAML_IS_JSON const char *forward_anchor; a = sv_2mortal(newSVsv(a)); forward_anchor = is_bad_alias_object(a); if (forward_anchor) register_bad_alias(p, forward_anchor, a); #endif av_push(seq, a); USE_OBJECT(a); } /* create the ref to the new array in the sv */ sv = newRV_noinc((SV*)seq); #ifndef YAML_IS_JSON if (id) { /* bless it if necessary */ char *lang = strtok(id, "/:"); char *type = strtok(NULL, ""); if ( type != NULL ) { if (strnEQ(type, "array:", 6)) { /* !perl/array:Foo::Bar blesses into Foo::Bar */ type += 6; } /* FIXME deprecated - here compatibility with @Foo::Bar style blessing */ while ( *type == '@' ) { type++; } } if (load_blessed) { if (lang == NULL || (strEQ(lang, "perl"))) { /* !perl/array on it's own causes no blessing */ if ( (type != NULL) && strNE(type, "array") && *type != '\0' ) { sv_bless(sv, gv_stashpv(type, TRUE)); } } else { sv_bless(sv, gv_stashpv(form((type == NULL) ? "%s" : "%s::%s", lang, type), TRUE)); } } } #endif break; case syck_map_kind: #ifndef YAML_IS_JSON if ( (id != NULL) && (strEQ(id, "perl/ref") || strnEQ( id, "perl/ref:", 9 ) ) ) { /* handle scalar references, that are a weird type of mappings */ SV* key = perl_syck_lookup_sym(p, syck_map_read(n, map_key, 0)); SV* val = perl_syck_lookup_sym(p, syck_map_read(n, map_value, 0)); char *ref_type = SvPVX(key); #if 0 /* need not to duplicate scalar reference */ const char *forward_anchor; val = sv_2mortal(newSVsv(val)); forward_anchor = is_bad_alias_object(val); if (forward_anchor) register_bad_alias(p, forward_anchor, val); #endif sv = newRV_noinc(val); USE_OBJECT(val); if ( load_blessed ) { if ( strnNE(ref_type, REF_LITERAL, REF_LITERAL_LENGTH+1)) { /* handle the weird audrey scalar ref stuff */ sv_bless(sv, gv_stashpv(ref_type, TRUE)); } else { /* bless it if necessary */ char *lang = strtok(id, "/:"); char *type = strtok(NULL, ""); if ( type != NULL && strnEQ(type, "ref:", 4)) { /* !perl/ref:Foo::Bar blesses into Foo::Bar */ type += 4; } if (lang == NULL || (strEQ(lang, "perl"))) { /* !perl/ref on it's own causes no blessing */ if ( (type != NULL) && strNE(type, "ref") && (*type != '\0')) { sv_bless(sv, gv_stashpv(type, TRUE)); } } else { sv_bless(sv, gv_stashpv(form((type == NULL) ? "%s" : "%s::%s", lang, type), TRUE)); } } } } else if ( (id != NULL) && (strEQ(id, "perl/regexp") || strnEQ( id, "perl/regexp:", 12 ) ) ) { /* handle regexp references, that are a weird type of mappings */ dSP; SV* key = perl_syck_lookup_sym(p, syck_map_read(n, map_key, 0)); SV* val = perl_syck_lookup_sym(p, syck_map_read(n, map_value, 0)); char *ref_type = SvPVX(key); ENTER; SAVETMPS; PUSHMARK(sp); XPUSHs(val); PUTBACK; call_pv("YAML::Syck::__qr_helper", G_SCALAR); SPAGAIN; sv = newSVsv(POPs); PUTBACK; FREETMPS; LEAVE; if ( load_blessed ) { if (strnNE(ref_type, REGEXP_LITERAL, REGEXP_LITERAL_LENGTH+1)) { /* handle the weird audrey scalar ref stuff */ sv_bless(sv, gv_stashpv(ref_type, TRUE)); } else { /* bless it if necessary */ char *lang = strtok(id, "/:"); char *type = strtok(NULL, ""); if ( type != NULL && strnEQ(type, "regexp:", 7)) { /* !perl/regexp:Foo::Bar blesses into Foo::Bar */ type += 7; } if (lang == NULL || (strEQ(lang, "perl"))) { /* !perl/regexp on it's own causes no blessing */ if ( (type != NULL) && strNE(type, "regexp") && (*type != '\0')) { sv_bless(sv, gv_stashpv(type, TRUE)); } } else { sv_bless(sv, gv_stashpv(form((type == NULL) ? "%s" : "%s::%s", lang, type), TRUE)); } } } } else if (id && strnEQ(id, "perl:YAML::Syck::BadAlias", 25-1)) { SV* key = (SV *) syck_map_read(n, map_key, 0); SV* val = (SV *) syck_map_read(n, map_value, 0); map = newHV(); if (hv_store_ent(map, key, val, 0) != NULL) USE_OBJECT(val); sv = newRV_noinc((SV*)map); if ( load_blessed ) sv_bless(sv, gv_stashpv("YAML::Syck::BadAlias", TRUE)); } else #endif { /* load the map into a new HV and place a ref to it in the SV */ map = newHV(); for (i = 0; i < n->data.pairs->idx; i++) { SV* key = perl_syck_lookup_sym(p, syck_map_read(n, map_key, i)); SV* val = perl_syck_lookup_sym(p, syck_map_read(n, map_value, i)); #ifndef YAML_IS_JSON const char *forward_anchor; val = sv_2mortal(newSVsv(val)); forward_anchor = is_bad_alias_object(val); if (forward_anchor) register_bad_alias(p, forward_anchor, val); #endif if (hv_store_ent(map, key, val, 0) != NULL) USE_OBJECT(val); } sv = newRV_noinc((SV*)map); #ifndef YAML_IS_JSON if (id) { /* bless it if necessary */ char *lang = strtok(id, "/:"); char *type = strtok(NULL, ""); if ( type != NULL ) { if (strnEQ(type, "hash:", 5)) { /* !perl/hash:Foo::Bar blesses into Foo::Bar */ type += 5; } /* FIXME deprecated - here compatibility with %Foo::Bar style blessing */ while ( *type == '%' ) { type++; } } if (load_blessed) { if (lang == NULL || (strEQ(lang, "perl"))) { /* !perl/hash on it's own causes no blessing */ if ( (type != NULL) && strNE(type, "hash") && *type != '\0' ) { sv_bless(sv, gv_stashpv(type, TRUE)); } } else { sv_bless(sv, gv_stashpv(form((type == NULL) ? "%s" : "%s::%s", lang, type), TRUE)); } } } #endif } break; } #ifndef YAML_IS_JSON /* Fix bad anchors using sv_setsv */ if (n->id) { if (n->anchor) resolve_bad_alias(p, n->anchor, sv); sv_setsv( perl_syck_lookup_sym(p, n->id), sv ); } #endif TRACK_OBJECT(sv); return syck_add_sym(p, (char *)sv); } #ifdef YAML_IS_JSON static char* perl_json_preprocess(char *s) { int i; char *out; char ch; char in_string = '\0'; bool in_quote = 0; char *pos; STRLEN len = strlen(s); New(2006, out, len*2+1, char); pos = out; for (i = 0; i < len; i++) { ch = *(s+i); *pos++ = ch; if (in_quote) { in_quote = !in_quote; if (ch == '\'') { *(pos - 2) = '\''; } } else if (ch == '\\') { in_quote = 1; } else if (in_string == '\0') { switch (ch) { case ':': { *pos++ = ' '; break; } case ',': { *pos++ = ' '; break; } case '"': { in_string = '"'; break; } case '\'': { in_string = '\''; break; } } } else if (ch == in_string) { in_string = '\0'; } } *pos = '\0'; return out; } void perl_json_postprocess(SV *sv) { int i; char ch; bool in_string = 0; bool in_quote = 0; char *pos; char *s = SvPVX(sv); STRLEN len = sv_len(sv); STRLEN final_len = len; pos = s; /* Horrible kluge if your quote char does not match what's wrapping this line */ if ( (json_quote_char == '\'') && (len > 1) && (*s == '\"') && (*(s+len-2) == '\"') ) { *s = '\''; *(s+len-2) = '\''; } /* 2010-07-20 - TODDR: This for loop doesn't appear to do anything other than shorten * the line if it sees [,:] when not in quotes. Even then it appears that the \0 isn't * being placed right if that happens. TODO: need test case to prove this does not work * as expected. */ for (i = 0; i < len; i++) { ch = *(s+i); *pos++ = ch; if (in_quote) { in_quote = !in_quote; } else if (ch == '\\') { in_quote = 1; } else if (ch == json_quote_char) { in_string = !in_string; } else if ((ch == ':' || ch == ',') && !in_string) { i++; /* has to be a space afterwards */ final_len--; } } /* Remove the trailing newline */ if (final_len > 0) { final_len--; pos--; } *pos = '\0'; SvCUR_set(sv, final_len); } #endif #ifdef YAML_IS_JSON static SV * LoadJSON (char *s) { #else static SV * LoadYAML (char *s) { #endif SYMID v; SyckParser *parser; struct parser_xtra bonus; SV *obj = &PL_sv_undef; SV *use_code = GvSV(gv_fetchpv(form("%s::UseCode", PACKAGE_NAME), TRUE, SVt_PV)); SV *load_code = GvSV(gv_fetchpv(form("%s::LoadCode", PACKAGE_NAME), TRUE, SVt_PV)); SV *implicit_typing = GvSV(gv_fetchpv(form("%s::ImplicitTyping", PACKAGE_NAME), TRUE, SVt_PV)); SV *implicit_unicode = GvSV(gv_fetchpv(form("%s::ImplicitUnicode", PACKAGE_NAME), TRUE, SVt_PV)); SV *singlequote = GvSV(gv_fetchpv(form("%s::SingleQuote", PACKAGE_NAME), TRUE, SVt_PV)); SV *load_blessed = GvSV(gv_fetchpv(form("%s::LoadBlessed", PACKAGE_NAME), TRUE, SVt_PV)); json_quote_char = (SvTRUE(singlequote) ? '\'' : '"' ); ENTER; SAVETMPS; /* Don't even bother if the string is empty. */ if (*s == '\0') { return &PL_sv_undef; } #ifdef YAML_IS_JSON s = perl_json_preprocess(s); #else /* Special preprocessing to maintain compat with YAML.pm <= 0.35 */ if (strnEQ( s, "--- #YAML:1.0", 13)) { s[4] = '%'; } #endif parser = syck_new_parser(); syck_parser_str_auto(parser, s, NULL); syck_parser_handler(parser, PERL_SYCK_PARSER_HANDLER); syck_parser_error_handler(parser, perl_syck_error_handler); syck_parser_bad_anchor_handler( parser, perl_syck_bad_anchor_handler ); syck_parser_implicit_typing(parser, SvTRUE(implicit_typing)); syck_parser_taguri_expansion(parser, 0); bonus.objects = (AV*)sv_2mortal((SV*)newAV()); bonus.implicit_unicode = SvTRUE(implicit_unicode); bonus.load_code = SvTRUE(use_code) || SvTRUE(load_code); bonus.load_blessed = SvTRUE(load_blessed); parser->bonus = &bonus; #ifndef YAML_IS_JSON bonus.bad_anchors = (HV*)sv_2mortal((SV*)newHV()); if (GIMME_V == G_ARRAY) { SYMID prev_v = 0; obj = (SV*)newAV(); while ((v = syck_parse(parser)) && (v != prev_v)) { SV *cur = &PL_sv_undef; if (!syck_lookup_sym(parser, v, (char **)&cur)) { break; } av_push((AV*)obj, cur); USE_OBJECT(cur); prev_v = v; } obj = newRV_noinc(obj); } else #endif { v = syck_parse(parser); if (syck_lookup_sym(parser, v, (char **)&obj)) { USE_OBJECT(obj); } } syck_free_parser(parser); #ifdef YAML_IS_JSON Safefree(s); #endif FREETMPS; LEAVE; return obj; } void #ifdef YAML_IS_JSON json_syck_mark_emitter #else yaml_syck_mark_emitter #endif (SyckEmitter *e, SV *sv) { #ifdef YAML_IS_JSON e->depth++; #endif if (syck_emitter_mark_node(e, (st_data_t)sv, PERL_SYCK_EMITTER_MARK_NODE_FLAGS) == 0) { #ifdef YAML_IS_JSON e->depth--; #endif return; } #ifdef YAML_IS_JSON if (e->depth >= e->max_depth) { croak("Dumping circular structures is not supported with JSON::Syck, consider increasing $JSON::Syck::MaxDepth higher then %d.", e->max_depth); } #endif if (SvROK(sv)) { PERL_SYCK_MARK_EMITTER(e, SvRV(sv)); #ifdef YAML_IS_JSON st_insert(e->markers, (st_data_t)sv, 0); e->depth--; #endif return; } switch (SvTYPE(sv)) { case SVt_PVAV: { I32 len, i; len = av_len((AV*)sv) + 1; for (i = 0; i < len; i++) { SV** sav = av_fetch((AV*)sv, i, 0); if (sav != NULL) { PERL_SYCK_MARK_EMITTER( e, *sav ); } } break; } case SVt_PVHV: { I32 len, i; #ifdef HAS_RESTRICTED_HASHES len = HvTOTALKEYS((HV*)sv); #else len = HvKEYS((HV*)sv); #endif hv_iterinit((HV*)sv); for (i = 0; i < len; i++) { #ifdef HV_ITERNEXT_WANTPLACEHOLDERS HE *he = hv_iternext_flags((HV*)sv, HV_ITERNEXT_WANTPLACEHOLDERS); #else HE *he = hv_iternext((HV*)sv); #endif SV *val = hv_iterval((HV*)sv, he); PERL_SYCK_MARK_EMITTER( e, val ); } break; } } #ifdef YAML_IS_JSON st_insert(e->markers, (st_data_t)sv, 0); --e->depth; #endif } void #ifdef YAML_IS_JSON json_syck_emitter_handler #else yaml_syck_emitter_handler #endif (SyckEmitter *e, st_data_t data) { I32 len, i; SV* sv = (SV*)data; struct emitter_xtra *bonus = (struct emitter_xtra *)e->bonus; char* tag = bonus->tag; svtype ty = SvTYPE(sv); #ifndef YAML_IS_JSON char dump_code = bonus->dump_code; char implicit_binary = bonus->implicit_binary; char* ref = NULL; #endif #define OBJECT_TAG "tag:!perl:" if (SvMAGICAL(sv)) { mg_get(sv); } #ifndef YAML_IS_JSON /* Handle blessing into the right class */ if (sv_isobject(sv)) { ref = savepv(sv_reftype(SvRV(sv), TRUE)); *tag = '\0'; strcat(tag, OBJECT_TAG); switch (SvTYPE(SvRV(sv))) { case SVt_PVAV: { strcat(tag, "array:"); break; } case SVt_PVHV: { strcat(tag, "hash:"); break; } case SVt_PVCV: { strcat(tag, "code:"); break; } case SVt_PVGV: { strcat(tag, "glob:"); break; } #if PERL_VERSION > 10 case SVt_REGEXP: { if (strEQ(ref, "Regexp")) { strcat(tag, "regexp"); ref += 6; /* empty string */ } else { strcat(tag, "regexp:"); } break; } #endif /* flatten scalar ref objects so that they dump as !perl/scalar:Foo::Bar foo */ case SVt_PVMG: { if ( SvROK(SvRV(sv)) ) { strcat(tag, "ref:"); break; } #if PERL_VERSION > 10 else { strcat(tag, "scalar:"); sv = SvRV(sv); ty = SvTYPE(sv); break; } #else else { MAGIC *mg; if ( (mg = mg_find(SvRV(sv), PERL_MAGIC_qr) ) ) { if (strEQ(ref, "Regexp")) { strcat(tag, "regexp"); ref += 6; /* empty string */ } else { strcat(tag, "regexp:"); } sv = newSVpvn(SvPV_nolen(sv), sv_len(sv)); ty = SvTYPE(sv); } else { strcat(tag, "scalar:"); sv = SvRV(sv); ty = SvTYPE(sv); } break; } #endif } } strcat(tag, ref); } #endif if (SvROK(sv)) { /* emit a scalar ref */ #ifdef YAML_IS_JSON PERL_SYCK_EMITTER_HANDLER(e, (st_data_t)SvRV(sv)); #else switch (SvTYPE(SvRV(sv))) { case SVt_PVAV: case SVt_PVHV: case SVt_PVCV: { /* Arrays, hashes and code values are inlined, and will be wrapped by a ref in the undumping */ e->indent = 0; syck_emit_item(e, (st_data_t)SvRV(sv)); e->indent = PERL_SYCK_INDENT_LEVEL; break; } #if PERL_VERSION > 10 case SVt_REGEXP: { STRLEN len = sv_len(sv); syck_emit_scalar( e, OBJOF("tag:!perl:regexp"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), len ); syck_emit_end(e); break; } #endif default: { syck_emit_map(e, OBJOF("tag:!perl:ref"), MAP_NONE); *tag = '\0'; syck_emit_item( e, (st_data_t)newSVpvn_share(REF_LITERAL, REF_LITERAL_LENGTH, 0) ); syck_emit_item( e, (st_data_t)SvRV(sv) ); syck_emit_end(e); } } #endif } else if (ty == SVt_NULL) { /* emit an undef */ syck_emit_scalar(e, "str", scalar_plain, 0, 0, 0, NULL_LITERAL, NULL_LITERAL_LENGTH); } else if ((ty == SVt_PVMG) && !SvOK(sv)) { /* emit an undef (typically pointed from a blesed SvRV) */ syck_emit_scalar(e, OBJOF("str"), scalar_plain, 0, 0, 0, NULL_LITERAL, NULL_LITERAL_LENGTH); } else if (SvPOK(sv)) { /* emit a string */ STRLEN len = sv_len(sv); /* JSON should preserve quotes even on simple integers ("0" is true in javascript) */ #ifndef YAML_IS_JSON if (looks_like_number(sv)) { if(syck_str_is_unquotable_integer(SvPV_nolen(sv), sv_len(sv))) { /* emit an unquoted number only if it's a very basic integer. /^-?[1-9][0-9]*$/ */ syck_emit_scalar(e, OBJOF("str"), SCALAR_NUMBER, 0, 0, 0, SvPV_nolen(sv), len); } else { /* Even though it looks like a number, quote it or it won't round trip correctly. */ syck_emit_scalar(e, OBJOF("str"), SCALAR_QUOTED, 0, 0, 0, SvPV_nolen(sv), len); } } else #endif if (len == 0) { syck_emit_scalar(e, OBJOF("str"), SCALAR_QUOTED, 0, 0, 0, "", 0); } else if (IS_UTF8(sv)) { /* if we support UTF8 and the string contains UTF8 */ enum scalar_style old_s = e->style; e->style = SCALAR_UTF8; syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), len); e->style = old_s; } #ifndef YAML_IS_JSON else if (implicit_binary) { /* scan string for high-bits in the SV */ bool is_ascii = TRUE; char *str = SvPV_nolen(sv); STRLEN len = sv_len(sv); for (i = 0; i < len; i++) { if (*(str + i) & 0x80) { /* Binary here */ char *base64 = syck_base64enc( str, len ); syck_emit_scalar(e, "tag:yaml.org,2002:binary", SCALAR_STRING, 0, 0, 0, base64, strlen(base64)); is_ascii = FALSE; break; } } if (is_ascii) { syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, str, len); } } #endif else { syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), len); } } else if (SvNIOK(sv)) { /* Stringify the sv, being careful not to overwrite its PV part */ SV *sv2 = newSVsv(sv); STRLEN len; char *str = SvPV(sv2, len); if (SvIOK(sv) /* original SV was an int */ && syck_str_is_unquotable_integer(str, len)) /* small enough to safely round-trip */ { syck_emit_scalar(e, OBJOF("str"), SCALAR_NUMBER, 0, 0, 0, str, len); } else { /* We need to quote it */ syck_emit_scalar(e, OBJOF("str"), SCALAR_QUOTED, 0, 0, 0, str, len); } SvREFCNT_dec(sv2); } else { switch (ty) { case SVt_PVAV: { /* array */ syck_emit_seq(e, OBJOF("array"), SEQ_NONE); e->indent = PERL_SYCK_INDENT_LEVEL; *tag = '\0'; len = av_len((AV*)sv) + 1; for (i = 0; i < len; i++) { SV** sav = av_fetch((AV*)sv, i, 0); if (sav == NULL) { syck_emit_item( e, (st_data_t)(&PL_sv_undef) ); } else { syck_emit_item( e, (st_data_t)(*sav) ); } } syck_emit_end(e); return; } case SVt_PVHV: { /* hash */ HV *hv = (HV*)sv; syck_emit_map(e, OBJOF("hash"), MAP_NONE); e->indent = PERL_SYCK_INDENT_LEVEL; *tag = '\0'; #ifdef HAS_RESTRICTED_HASHES len = HvTOTALKEYS((HV*)sv); #else len = HvKEYS((HV*)sv); #endif hv_iterinit((HV*)sv); if (e->sort_keys) { AV *av = (AV*)sv_2mortal((SV*)newAV()); for (i = 0; i < len; i++) { #ifdef HAS_RESTRICTED_HASHES HE *he = hv_iternext_flags(hv, HV_ITERNEXT_WANTPLACEHOLDERS); #else HE *he = hv_iternext(hv); #endif SV *key = hv_iterkeysv(he); av_store(av, AvFILLp(av)+1, key); /* av_push(), really */ } STORE_HASH_SORT; for (i = 0; i < len; i++) { #ifdef HAS_RESTRICTED_HASHES int placeholders = (int)HvPLACEHOLDERS_get(hv); #endif SV *key = av_shift(av); HE *he = hv_fetch_ent(hv, key, 0, 0); SV *val = HeVAL(he); if (val == NULL) { val = &PL_sv_undef; } syck_emit_item( e, (st_data_t)key ); syck_emit_item( e, (st_data_t)val ); } } else { for (i = 0; i < len; i++) { #ifdef HV_ITERNEXT_WANTPLACEHOLDERS HE *he = hv_iternext_flags(hv, HV_ITERNEXT_WANTPLACEHOLDERS); #else HE *he = hv_iternext(hv); #endif SV *key = hv_iterkeysv(he); SV *val = hv_iterval(hv, he); syck_emit_item( e, (st_data_t)key ); syck_emit_item( e, (st_data_t)val ); } } /* reset the hash pointer */ hv_iterinit(hv); syck_emit_end(e); return; } case SVt_PVCV: { /* code */ #ifdef YAML_IS_JSON syck_emit_scalar(e, "str", scalar_plain, 0, 0, 0, NULL_LITERAL, NULL_LITERAL_LENGTH); #else /* This following code is mostly copypasted from Storable */ #if PERL_VERSION < 8 syck_emit_scalar(e, OBJOF("tag:!perl:code:"), SCALAR_QUOTED, 0, 0, 0, "{ \"DUMMY\" }", 11); #else if ( !dump_code ) { syck_emit_scalar(e, OBJOF("tag:!perl:code:"), SCALAR_QUOTED, 0, 0, 0, "{ \"DUMMY\" }", 11); } else { dSP; I32 len; int count, reallen; SV *text; CV *cv = (CV*)sv; SV *bdeparse = GvSV(gv_fetchpv(form("%s::DeparseObject", PACKAGE_NAME), TRUE, SVt_PV)); if (!SvTRUE(bdeparse)) { croak("B::Deparse initialization failed -- cannot dump code object"); } ENTER; SAVETMPS; /* * call the coderef2text method */ PUSHMARK(sp); XPUSHs(bdeparse); /* XXX is this already mortal? */ XPUSHs(sv_2mortal(newRV_inc((SV*)cv))); PUTBACK; count = call_method("coderef2text", G_SCALAR); SPAGAIN; if (count != 1) { croak("Unexpected return value from B::Deparse::coderef2text\n"); } text = POPs; len = SvLEN(text); reallen = strlen(SvPV_nolen(text)); /* * Empty code references or XS functions are deparsed as * "(prototype) ;" or ";". */ if (len == 0 || *(SvPV_nolen(text)+reallen-1) == ';') { croak("The result of B::Deparse::coderef2text was empty - maybe you're trying to serialize an XS function?\n"); } /* * Now store the source code. */ syck_emit_scalar(e, OBJOF("tag:!perl:code:"), SCALAR_UTF8, 0, 0, 0, SvPV_nolen(text), reallen); FREETMPS; LEAVE; /* END Storable */ } #endif #endif *tag = '\0'; break; } case SVt_PVGV: /* glob (not a filehandle, a symbol table entry) */ case SVt_PVFM: { /* format */ /* XXX TODO XXX */ syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), sv_len(sv)); break; } case SVt_PVIO: { /* filehandle */ syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), sv_len(sv)); break; } default: { syck_emit_scalar(e, "str", scalar_plain, 0, 0, 0, NULL_LITERAL, NULL_LITERAL_LENGTH); } } } /* cleanup: */ *tag = '\0'; } void #ifdef YAML_IS_JSON DumpJSONImpl #else DumpYAMLImpl #endif (SV *sv, struct emitter_xtra *bonus, SyckOutputHandler output_handler) { SyckEmitter *emitter = syck_new_emitter(); SV *headless = GvSV(gv_fetchpv(form("%s::Headless", PACKAGE_NAME), TRUE, SVt_PV)); SV *implicit_binary = GvSV(gv_fetchpv(form("%s::ImplicitBinary", PACKAGE_NAME), TRUE, SVt_PV)); SV *use_code = GvSV(gv_fetchpv(form("%s::UseCode", PACKAGE_NAME), TRUE, SVt_PV)); SV *dump_code = GvSV(gv_fetchpv(form("%s::DumpCode", PACKAGE_NAME), TRUE, SVt_PV)); SV *sortkeys = GvSV(gv_fetchpv(form("%s::SortKeys", PACKAGE_NAME), TRUE, SVt_PV)); #ifdef YAML_IS_JSON SV *singlequote = GvSV(gv_fetchpv(form("%s::SingleQuote", PACKAGE_NAME), TRUE, SVt_PV)); SV *max_depth = GvSV(gv_fetchpv(form("%s::MaxDepth", PACKAGE_NAME), TRUE, SVt_PV)); json_quote_char = (SvTRUE(singlequote) ? '\'' : '"' ); json_quote_style = (SvTRUE(singlequote) ? scalar_2quote_1 : scalar_2quote ); emitter->indent = PERL_SYCK_INDENT_LEVEL; emitter->max_depth = SvIOK(max_depth) ? SvIV(max_depth) : json_max_depth; #else SV *singlequote = GvSV(gv_fetchpv(form("%s::SingleQuote", PACKAGE_NAME), TRUE, SVt_PV)); yaml_quote_style = (SvTRUE(singlequote) ? scalar_1quote : scalar_none); #endif ENTER; SAVETMPS; #ifndef YAML_IS_JSON if (SvTRUE(use_code) || SvTRUE(dump_code)) { SV *bdeparse = GvSV(gv_fetchpv(form("%s::DeparseObject", PACKAGE_NAME), TRUE, SVt_PV)); if (!SvTRUE(bdeparse)) { eval_pv(form( "local $@; require B::Deparse; $%s::DeparseObject = B::Deparse->new", PACKAGE_NAME ), 1); } } #endif emitter->headless = SvTRUE(headless); emitter->sort_keys = SvTRUE(sortkeys); emitter->anchor_format = "%d"; New(801, bonus->tag, 512, char); *(bonus->tag) = '\0'; bonus->dump_code = SvTRUE(use_code) || SvTRUE(dump_code); bonus->implicit_binary = SvTRUE(implicit_binary); emitter->bonus = bonus; syck_emitter_handler( emitter, PERL_SYCK_EMITTER_HANDLER ); syck_output_handler( emitter, output_handler ); PERL_SYCK_MARK_EMITTER( emitter, sv ); #ifdef YAML_IS_JSON st_free_table(emitter->markers); emitter->markers = st_init_numtable(); #endif syck_emit( emitter, (st_data_t)sv ); syck_emitter_flush( emitter, 0 ); syck_free_emitter( emitter ); Safefree(bonus->tag); FREETMPS; LEAVE; return; } SV* #ifdef YAML_IS_JSON DumpJSON #else DumpYAML #endif (SV *sv) { SV *implicit_unicode = GvSV(gv_fetchpv(form("%s::ImplicitUnicode", PACKAGE_NAME), TRUE, SVt_PV)); struct emitter_xtra bonus; SV *out = newSVpvn("", 0); bonus.out.outsv = out; #ifdef YAML_IS_JSON DumpJSONImpl(sv, &bonus, perl_syck_output_handler_pv); if (SvCUR(out) > 0) { perl_json_postprocess(out); } #else DumpYAMLImpl(sv, &bonus, perl_syck_output_handler_pv); #endif #ifdef SvUTF8_on if (SvTRUE(implicit_unicode)) { SvUTF8_on(out); } #endif return out; } int #ifdef YAML_IS_JSON DumpJSONFile #else DumpYAMLFile #endif (SV *sv, PerlIO *out) { struct emitter_xtra bonus; bonus.out.outio = out; bonus.ioerror = 0; #ifdef YAML_IS_JSON DumpJSONImpl(sv, &bonus, perl_syck_output_handler_io); /* TODO: how do we do perl_json_postprocess? */ #else DumpYAMLImpl(sv, &bonus, perl_syck_output_handler_io); #endif return bonus.ioerror; } int #ifdef YAML_IS_JSON DumpJSONInto #else DumpYAMLInto #endif (SV *sv, SV *out) { SV *implicit_unicode = GvSV(gv_fetchpv(form("%s::ImplicitUnicode", PACKAGE_NAME), TRUE, SVt_PV)); struct emitter_xtra bonus; if (SvROK(out)) { out = SvRV(out); if (! SvPOK(out)) { sv_setpv(out, ""); } } else { return 0; /* perl wrapper should die for us */ } bonus.out.outsv = out; #ifdef YAML_IS_JSON DumpJSONImpl(sv, &bonus, perl_syck_output_handler_mg); if (SvCUR(out) > 0) { /* XXX: needs to handle magic? */ perl_json_postprocess(out); } #else DumpYAMLImpl(sv, &bonus, perl_syck_output_handler_mg); #endif #ifdef SvUTF8_on if (SvTRUE(implicit_unicode)) { SvUTF8_on(out); /* XXX: needs to handle magic? */ } #endif return 1; } YAML-Syck-1.31/handler.c0000644000000000000000000000652013364413554013401 0ustar rootroot/* * handler.c * * $Author: why $ * $Date: 2005-09-20 13:21:06 +0800 (二, 20 9 2005) $ * * Copyright (C) 2003 why the lucky stiff */ #include "syck.h" SYMID syck_hdlr_add_node( SyckParser *p, SyckNode *n ) { SYMID id; if ( ! n->id ) { n->id = (p->handler)( p, n ); } id = n->id; if ( n->anchor == NULL ) { syck_free_node( n ); } return id; } SyckNode * syck_hdlr_add_anchor( SyckParser *p, char *a, SyckNode *n ) { SyckNode *ntmp = NULL; n->anchor = a; if ( p->bad_anchors != NULL ) { SyckNode *bad; if ( st_lookup( p->bad_anchors, (st_data_t)a, (st_data_t *)&bad ) ) { if ( n->kind != syck_str_kind ) { n->id = bad->id; (p->handler)( p, n ); } } } if ( p->anchors == NULL ) { p->anchors = st_init_strtable(); } if ( st_lookup( p->anchors, (st_data_t)a, (st_data_t *)&ntmp ) ) { if ( ntmp != (void *)1 ) { syck_free_node( ntmp ); } } st_insert( p->anchors, (st_data_t)a, (st_data_t)n ); return n; } void syck_hdlr_remove_anchor( SyckParser *p, char *a ) { char *atmp = a; SyckNode *ntmp; if ( p->anchors == NULL ) { p->anchors = st_init_strtable(); } if ( st_delete( p->anchors, (st_data_t *)&atmp, (st_data_t *)&ntmp ) ) { if ( ntmp != (void *)1 ) { syck_free_node( ntmp ); } } st_insert( p->anchors, (st_data_t)a, (st_data_t)1 ); } SyckNode * syck_hdlr_get_anchor( SyckParser *p, char *a ) { SyckNode *n = NULL; if ( p->anchors != NULL ) { if ( st_lookup( p->anchors, (st_data_t)a, (st_data_t *)&n ) ) { if ( n != (void *)1 ) { S_FREE( a ); return n; } else { if ( p->bad_anchors == NULL ) { p->bad_anchors = st_init_strtable(); } if ( ! st_lookup( p->bad_anchors, (st_data_t)a, (st_data_t *)&n ) ) { n = (p->bad_anchor_handler)( p, a ); st_insert( p->bad_anchors, (st_data_t)a, (st_data_t)n ); } } } } if ( n == NULL ) { n = (p->bad_anchor_handler)( p, a ); } if ( n->anchor ) { S_FREE( a ); } else { n->anchor = a; } return n; } void syck_add_transfer( char *uri, SyckNode *n, int taguri ) { if ( n->type_id != NULL ) { S_FREE( n->type_id ); } if ( taguri == 0 ) { n->type_id = uri; return; } n->type_id = syck_type_id_to_uri( uri ); S_FREE( uri ); } char * syck_xprivate( char *type_id, int type_len ) { char *uri = S_ALLOC_N( char, type_len + 14 ); uri[0] = '\0'; strcat( uri, "x-private:" ); strncat( uri, type_id, type_len ); return uri; } char * syck_taguri( const char *domain, const char *type_id, int type_len ) { char *uri = S_ALLOC_N( char, strlen( domain ) + type_len + 14 ); uri[0] = '\0'; strcat( uri, "tag:" ); strcat( uri, domain ); strcat( uri, ":" ); strncat( uri, type_id, type_len ); return uri; } int syck_try_implicit( SyckNode *n ) { return 1; } YAML-Syck-1.31/gram.c0000644000000000000000000016466713364413554012733 0ustar rootroot/* A Bison parser, made by GNU Bison 1.875d. */ /* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ /* Written by Richard Stallman by simplifying the original so called ``semantic'' parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 1 /* Using locations. */ #define YYLSP_NEEDED 0 /* If NAME_PREFIX is specified substitute the variables and functions names. */ #define yyparse syckparse #define yylex sycklex #define yyerror syckerror #define yylval sycklval #define yychar syckchar #define yydebug syckdebug #define yynerrs sycknerrs /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { YAML_ANCHOR = 258, YAML_ALIAS = 259, YAML_TRANSFER = 260, YAML_TAGURI = 261, YAML_ITRANSFER = 262, YAML_WORD = 263, YAML_PLAIN = 264, YAML_BLOCK = 265, YAML_DOCSEP = 266, YAML_IOPEN = 267, YAML_INDENT = 268, YAML_IEND = 269 }; #endif #define YAML_ANCHOR 258 #define YAML_ALIAS 259 #define YAML_TRANSFER 260 #define YAML_TAGURI 261 #define YAML_ITRANSFER 262 #define YAML_WORD 263 #define YAML_PLAIN 264 #define YAML_BLOCK 265 #define YAML_DOCSEP 266 #define YAML_IOPEN 267 #define YAML_INDENT 268 #define YAML_IEND 269 /* Copy the first part of user declarations. */ #line 14 "gram.y" #include "syck.h" void apply_seq_in_map( SyckParser *parser, SyckNode *n ); #define YYPARSE_PARAM parser #define YYLEX_PARAM parser #define NULL_NODE(parser, node) \ SyckNode *node = syck_new_str( "", scalar_plain ); \ if ( ((SyckParser *)parser)->taguri_expansion == 1 ) \ { \ node->type_id = syck_taguri( YAML_DOMAIN, "null", 4 ); \ } \ else \ { \ node->type_id = syck_strndup( "null", 4 ); \ } /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 #endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) #line 35 "gram.y" typedef union YYSTYPE { SYMID nodeId; SyckNode *nodeData; char *name; } YYSTYPE; /* Line 191 of yacc.c. */ #line 140 "gram.c" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif int sycklex( YYSTYPE *sycklval, SyckParser *parser ); /* Copy the second part of user declarations. */ /* Line 214 of yacc.c. */ #line 152 "gram.c" #if ! defined (yyoverflow) || YYERROR_VERBOSE # ifndef YYFREE # define YYFREE free # endif # ifndef YYMALLOC # define YYMALLOC malloc # endif /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # define YYSTACK_ALLOC alloca # endif # else # if defined (alloca) || defined (_ALLOCA_H) # define YYSTACK_ALLOC alloca # else # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # else # if defined (__STDC__) || defined (__cplusplus) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # endif #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ #if (! defined (yyoverflow) \ && (! defined (__cplusplus) \ || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { short int yyss; YYSTYPE yyvs; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if defined (__GNUC__) && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ register YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (0) # endif # endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif #if defined (__STDC__) || defined (__cplusplus) typedef signed char yysigned_char; #else typedef short int yysigned_char; #endif /* YYFINAL -- State number of the termination state. */ #define YYFINAL 52 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 396 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 23 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 29 /* YYNRULES -- Number of rules. */ #define YYNRULES 79 /* YYNRULES -- Number of states. */ #define YYNSTATES 128 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 269 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const unsigned char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 21, 15, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 2, 2, 2, 2, 22, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 17, 2, 18, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 19, 2, 20, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const unsigned char yyprhs[] = { 0, 0, 3, 5, 8, 9, 11, 13, 15, 18, 21, 24, 28, 30, 32, 36, 37, 40, 43, 46, 49, 51, 54, 56, 58, 60, 63, 66, 69, 72, 75, 77, 79, 81, 85, 87, 89, 91, 93, 95, 99, 103, 106, 110, 113, 117, 120, 124, 127, 129, 133, 136, 140, 143, 145, 149, 151, 153, 157, 161, 165, 168, 172, 175, 179, 182, 184, 188, 190, 194, 196, 200, 204, 207, 211, 215, 218, 220, 224, 226 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yysigned_char yyrhs[] = { 24, 0, -1, 25, -1, 11, 27, -1, -1, 33, -1, 26, -1, 34, -1, 5, 26, -1, 6, 26, -1, 3, 26, -1, 29, 26, 32, -1, 25, -1, 28, -1, 29, 28, 30, -1, -1, 7, 28, -1, 5, 28, -1, 6, 28, -1, 3, 28, -1, 12, -1, 29, 13, -1, 14, -1, 13, -1, 14, -1, 31, 32, -1, 5, 33, -1, 6, 33, -1, 7, 33, -1, 3, 33, -1, 4, -1, 8, -1, 9, -1, 29, 33, 32, -1, 10, -1, 35, -1, 39, -1, 42, -1, 49, -1, 29, 37, 30, -1, 29, 38, 30, -1, 15, 27, -1, 5, 31, 38, -1, 5, 37, -1, 6, 31, 38, -1, 6, 37, -1, 3, 31, 38, -1, 3, 37, -1, 36, -1, 38, 31, 36, -1, 38, 31, -1, 17, 40, 18, -1, 17, 18, -1, 41, -1, 40, 21, 41, -1, 25, -1, 48, -1, 29, 43, 30, -1, 29, 47, 30, -1, 5, 31, 47, -1, 5, 43, -1, 6, 31, 47, -1, 6, 43, -1, 3, 31, 47, -1, 3, 43, -1, 33, -1, 22, 25, 31, -1, 27, -1, 44, 16, 45, -1, 46, -1, 47, 31, 36, -1, 47, 31, 46, -1, 47, 31, -1, 25, 16, 27, -1, 19, 50, 20, -1, 19, 20, -1, 51, -1, 50, 21, 51, -1, 25, -1, 48, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const unsigned short int yyrline[] = { 0, 56, 56, 60, 65, 70, 71, 74, 75, 80, 85, 94, 100, 101, 104, 109, 113, 121, 126, 131, 145, 146, 149, 152, 155, 156, 164, 169, 174, 182, 186, 194, 207, 208, 218, 219, 220, 221, 222, 228, 232, 238, 244, 249, 254, 259, 264, 268, 274, 278, 283, 292, 296, 302, 306, 313, 314, 320, 325, 332, 337, 342, 347, 352, 356, 362, 363, 369, 379, 396, 397, 409, 417, 426, 434, 438, 444, 445, 454, 461 }; #endif #if YYDEBUG || YYERROR_VERBOSE /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "YAML_ANCHOR", "YAML_ALIAS", "YAML_TRANSFER", "YAML_TAGURI", "YAML_ITRANSFER", "YAML_WORD", "YAML_PLAIN", "YAML_BLOCK", "YAML_DOCSEP", "YAML_IOPEN", "YAML_INDENT", "YAML_IEND", "'-'", "':'", "'['", "']'", "'{'", "'}'", "','", "'?'", "$accept", "doc", "atom", "ind_rep", "atom_or_empty", "empty", "indent_open", "indent_end", "indent_sep", "indent_flex_end", "word_rep", "struct_rep", "implicit_seq", "basic_seq", "top_imp_seq", "in_implicit_seq", "inline_seq", "in_inline_seq", "inline_seq_atom", "implicit_map", "top_imp_map", "complex_key", "complex_value", "complex_mapping", "in_implicit_map", "basic_mapping", "inline_map", "in_inline_map", "inline_map_atom", 0 }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ static const unsigned short int yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 45, 58, 91, 93, 123, 125, 44, 63 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const unsigned char yyr1[] = { 0, 23, 24, 24, 24, 25, 25, 26, 26, 26, 26, 26, 27, 27, 28, 28, 28, 28, 28, 28, 29, 29, 30, 31, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 36, 37, 37, 37, 37, 37, 37, 38, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 43, 43, 43, 43, 44, 44, 45, 46, 47, 47, 47, 47, 48, 49, 49, 50, 50, 51, 51 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const unsigned char yyr2[] = { 0, 2, 1, 2, 0, 1, 1, 1, 2, 2, 2, 3, 1, 1, 3, 0, 2, 2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 3, 3, 2, 3, 2, 3, 2, 3, 2, 1, 3, 2, 3, 2, 1, 3, 1, 1, 3, 3, 3, 2, 3, 2, 3, 2, 1, 3, 1, 3, 1, 3, 3, 2, 3, 3, 2, 1, 3, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const unsigned char yydefact[] = { 4, 0, 30, 0, 0, 0, 31, 32, 34, 15, 20, 0, 0, 0, 2, 6, 0, 5, 7, 35, 36, 37, 38, 10, 29, 8, 26, 9, 27, 0, 0, 0, 0, 28, 15, 15, 15, 15, 12, 3, 13, 15, 52, 55, 0, 53, 56, 75, 78, 79, 0, 76, 1, 0, 0, 0, 21, 15, 0, 0, 65, 48, 0, 0, 0, 0, 69, 0, 0, 19, 17, 18, 15, 15, 15, 16, 15, 15, 15, 15, 0, 15, 51, 0, 74, 0, 23, 0, 47, 64, 0, 43, 60, 0, 45, 62, 41, 0, 24, 0, 11, 33, 22, 39, 40, 50, 57, 15, 58, 72, 14, 73, 54, 77, 65, 46, 63, 42, 59, 44, 61, 66, 25, 49, 67, 68, 70, 71 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yysigned_char yydefgoto[] = { -1, 13, 38, 15, 39, 40, 16, 103, 99, 101, 17, 18, 19, 61, 62, 63, 20, 44, 45, 21, 64, 65, 125, 66, 67, 46, 22, 50, 51 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -97 static const short int yypact[] = { 250, 318, -97, 318, 318, 374, -97, -97, -97, 335, -97, 267, 232, 7, -97, -97, 192, -97, -97, -97, -97, -97, -97, -97, -97, -97, -97, -97, -97, 374, 374, 374, 352, -97, 335, 335, 335, 384, -97, -97, -97, 212, -97, 10, 0, -97, -97, -97, 10, -97, -4, -97, -97, 284, 284, 284, -97, 335, 318, 30, 30, -97, -2, 36, -2, 16, -97, 36, 30, -97, -97, -97, 384, 384, 384, -97, 363, 301, 301, 301, -2, 335, -97, 318, -97, 318, -97, 158, -97, -97, 158, -97, -97, 158, -97, -97, -97, 24, -97, 30, -97, -97, -97, -97, -97, 26, -97, 335, -97, 158, -97, -97, -97, -97, -97, 24, 24, 24, 24, 24, 24, -97, -97, -97, -97, -97, -97, -97 }; /* YYPGOTO[NTERM-NUM]. */ static const yysigned_char yypgoto[] = { -97, -97, 8, 81, -56, 109, 33, -53, 74, -54, -1, -97, -97, -96, -31, -32, -97, -97, -44, -97, 77, -97, -97, -52, 9, -6, -97, -97, -29 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -1 static const unsigned char yytable[] = { 24, 96, 26, 28, 33, 100, 49, 52, 14, 123, 104, 106, 102, 126, 108, 60, 84, 85, 82, 43, 48, 83, 88, 91, 94, 111, 81, 110, 24, 26, 28, 68, 107, 24, 26, 28, 33, 86, 32, 112, 60, 57, 41, 86, 98, 122, 88, 91, 94, 86, 102, 124, 24, 26, 28, 115, 113, 127, 117, 0, 0, 119, 32, 32, 32, 32, 97, 41, 41, 41, 76, 24, 26, 28, 41, 68, 24, 26, 28, 49, 0, 0, 23, 0, 25, 27, 114, 0, 0, 114, 41, 43, 114, 48, 0, 0, 116, 59, 0, 118, 0, 0, 120, 0, 0, 76, 76, 76, 114, 76, 41, 41, 41, 0, 41, 23, 25, 27, 0, 0, 32, 0, 59, 32, 0, 0, 32, 87, 90, 93, 89, 92, 95, 0, 23, 25, 27, 105, 0, 0, 41, 109, 32, 69, 70, 71, 75, 0, 0, 0, 80, 87, 90, 93, 89, 92, 95, 0, 23, 25, 27, 29, 2, 30, 31, 5, 6, 7, 0, 0, 10, 121, 0, 57, 0, 0, 0, 0, 0, 0, 58, 69, 70, 71, 0, 80, 69, 70, 71, 105, 109, 105, 109, 105, 109, 53, 2, 54, 55, 5, 6, 7, 8, 0, 10, 56, 0, 57, 0, 11, 0, 12, 0, 0, 58, 77, 2, 78, 79, 37, 6, 7, 8, 0, 10, 56, 0, 57, 0, 11, 0, 12, 0, 0, 58, 1, 2, 3, 4, 5, 6, 7, 8, 0, 10, 0, 0, 0, 0, 11, 0, 12, 47, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 11, 0, 12, 1, 2, 3, 4, 5, 6, 7, 8, 0, 10, 0, 0, 0, 0, 11, 42, 12, 53, 2, 54, 55, 5, 6, 7, 8, 0, 10, 86, 0, 0, 0, 11, 0, 12, 77, 2, 78, 79, 37, 6, 7, 8, 0, 10, 86, 0, 0, 0, 11, 0, 12, 1, 2, 3, 4, 5, 6, 7, 8, 0, 10, 0, 0, 0, 0, 11, 0, 12, 34, 2, 35, 36, 37, 6, 7, 8, 0, 10, 0, 0, 0, 0, 11, 0, 12, 29, 2, 30, 31, 5, 6, 7, 0, 0, 10, 56, 72, 2, 73, 74, 37, 6, 7, 0, 0, 10, 56, 29, 2, 30, 31, 5, 6, 7, 0, 0, 10, 72, 2, 73, 74, 37, 6, 7, 0, 0, 10 }; static const yysigned_char yycheck[] = { 1, 57, 3, 4, 5, 59, 12, 0, 0, 105, 63, 64, 14, 109, 67, 16, 20, 21, 18, 11, 12, 21, 53, 54, 55, 81, 16, 80, 29, 30, 31, 32, 16, 34, 35, 36, 37, 13, 5, 83, 41, 15, 9, 13, 14, 99, 77, 78, 79, 13, 14, 107, 53, 54, 55, 87, 85, 109, 90, -1, -1, 93, 29, 30, 31, 32, 58, 34, 35, 36, 37, 72, 73, 74, 41, 76, 77, 78, 79, 85, -1, -1, 1, -1, 3, 4, 87, -1, -1, 90, 57, 83, 93, 85, -1, -1, 87, 16, -1, 90, -1, -1, 93, -1, -1, 72, 73, 74, 109, 76, 77, 78, 79, -1, 81, 34, 35, 36, -1, -1, 87, -1, 41, 90, -1, -1, 93, 53, 54, 55, 53, 54, 55, -1, 53, 54, 55, 63, -1, -1, 107, 67, 109, 34, 35, 36, 37, -1, -1, -1, 41, 77, 78, 79, 77, 78, 79, -1, 77, 78, 79, 3, 4, 5, 6, 7, 8, 9, -1, -1, 12, 97, -1, 15, -1, -1, -1, -1, -1, -1, 22, 72, 73, 74, -1, 76, 77, 78, 79, 115, 116, 117, 118, 119, 120, 3, 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, -1, 15, -1, 17, -1, 19, -1, -1, 22, 3, 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, -1, 15, -1, 17, -1, 19, -1, -1, 22, 3, 4, 5, 6, 7, 8, 9, 10, -1, 12, -1, -1, -1, -1, 17, -1, 19, 20, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, -1, -1, -1, -1, 17, -1, 19, 3, 4, 5, 6, 7, 8, 9, 10, -1, 12, -1, -1, -1, -1, 17, 18, 19, 3, 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, -1, -1, -1, 17, -1, 19, 3, 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, -1, -1, -1, 17, -1, 19, 3, 4, 5, 6, 7, 8, 9, 10, -1, 12, -1, -1, -1, -1, 17, -1, 19, 3, 4, 5, 6, 7, 8, 9, 10, -1, 12, -1, -1, -1, -1, 17, -1, 19, 3, 4, 5, 6, 7, 8, 9, -1, -1, 12, 13, 3, 4, 5, 6, 7, 8, 9, -1, -1, 12, 13, 3, 4, 5, 6, 7, 8, 9, -1, -1, 12, 3, 4, 5, 6, 7, 8, 9, -1, -1, 12 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const unsigned char yystos[] = { 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17, 19, 24, 25, 26, 29, 33, 34, 35, 39, 42, 49, 26, 33, 26, 33, 26, 33, 3, 5, 6, 29, 33, 3, 5, 6, 7, 25, 27, 28, 29, 18, 25, 40, 41, 48, 20, 25, 48, 50, 51, 0, 3, 5, 6, 13, 15, 22, 26, 33, 36, 37, 38, 43, 44, 46, 47, 33, 28, 28, 28, 3, 5, 6, 28, 29, 3, 5, 6, 28, 16, 18, 21, 20, 21, 13, 31, 37, 43, 31, 37, 43, 31, 37, 43, 27, 25, 14, 31, 32, 32, 14, 30, 30, 31, 30, 16, 30, 31, 30, 27, 41, 51, 33, 38, 47, 38, 47, 38, 47, 31, 32, 36, 27, 45, 36, 46 }; #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) # define YYSIZE_T __SIZE_TYPE__ #endif #if ! defined (YYSIZE_T) && defined (size_t) # define YYSIZE_T size_t #endif #if ! defined (YYSIZE_T) # if defined (__STDC__) || defined (__cplusplus) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif #endif #if ! defined (YYSIZE_T) # define YYSIZE_T unsigned int #endif #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ yyerror ("syntax error: cannot back up");\ YYERROR; \ } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Compute the default location (before the actions are run). */ #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ ((Current).first_line = (Rhs)[1].first_line, \ (Current).first_column = (Rhs)[1].first_column, \ (Current).last_line = (Rhs)[N].last_line, \ (Current).last_column = (Rhs)[N].last_column) #endif /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, YYLEX_PARAM) #else # define YYLEX yylex (&yylval) #endif /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) # define YYDSYMPRINT(Args) \ do { \ if (yydebug) \ yysymprint Args; \ } while (0) # define YYDSYMPRINTF(Title, Token, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yysymprint (stderr, \ Token, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yy_stack_print (short int *bottom, short int *top) #else static void yy_stack_print (bottom, top) short int *bottom; short int *top; #endif { YYFPRINTF (stderr, "Stack now"); for (/* Nothing. */; bottom <= top; ++bottom) YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yy_reduce_print (int yyrule) #else static void yy_reduce_print (yyrule) int yyrule; #endif { int yyi; unsigned int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", yyrule - 1, yylno); /* Print the symbols being reduced, and their result. */ for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (Rule); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YYDSYMPRINT(Args) # define YYDSYMPRINTF(Title, Token, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 # undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined (__GLIBC__) && defined (_STRING_H) # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T # if defined (__STDC__) || defined (__cplusplus) yystrlen (const char *yystr) # else yystrlen (yystr) const char *yystr; # endif { register const char *yys = yystr; while (*yys++ != '\0') continue; return yys - yystr - 1; } # endif # endif # ifndef yystpcpy # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * # if defined (__STDC__) || defined (__cplusplus) yystpcpy (char *yydest, const char *yysrc) # else yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; # endif { register char *yyd = yydest; register const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif #endif /* !YYERROR_VERBOSE */ #if YYDEBUG /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) #else static void yysymprint (yyoutput, yytype, yyvaluep) FILE *yyoutput; int yytype; YYSTYPE *yyvaluep; #endif { /* Pacify ``unused variable'' warnings. */ (void) yyvaluep; if (yytype < YYNTOKENS) { YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); # ifdef YYPRINT YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif } else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); switch (yytype) { default: break; } YYFPRINTF (yyoutput, ")"); } #endif /* ! YYDEBUG */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yydestruct (int yytype, YYSTYPE *yyvaluep) #else static void yydestruct (yytype, yyvaluep) int yytype; YYSTYPE *yyvaluep; #endif { /* Pacify ``unused variable'' warnings. */ (void) yyvaluep; switch (yytype) { default: break; } } /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) int yyparse (void *YYPARSE_PARAM); # else int yyparse (); # endif #else /* ! YYPARSE_PARAM */ #if defined (__STDC__) || defined (__cplusplus) int yyparse (void); #else int yyparse (); #endif #endif /* ! YYPARSE_PARAM */ /*----------. | yyparse. | `----------*/ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) int yyparse (void *YYPARSE_PARAM) # else int yyparse (YYPARSE_PARAM) void *YYPARSE_PARAM; # endif #else /* ! YYPARSE_PARAM */ #if defined (__STDC__) || defined (__cplusplus) int yyparse (void) #else int yyparse () #endif #endif { /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; register int yystate; register int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; /* Three stacks and their tools: `yyss': related to states, `yyvs': related to semantic values, `yyls': related to locations. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ short int yyssa[YYINITDEPTH]; short int *yyss = yyssa; register short int *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; register YYSTYPE *yyvsp; #define YYPOPSTACK (yyvsp--, yyssp--) YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; /* When reducing, the number of symbols on the RHS of the reduced rule. */ int yylen; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; short int *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow ("parser stack overflow", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyoverflowlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyoverflowlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { short int *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyoverflowlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* yyresume: */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: #line 57 "gram.y" { ((SyckParser *)parser)->root = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ); } break; case 3: #line 61 "gram.y" { ((SyckParser *)parser)->root = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ); } break; case 4: #line 65 "gram.y" { ((SyckParser *)parser)->eof = 1; } break; case 8: #line 76 "gram.y" { syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); yyval.nodeData = yyvsp[0].nodeData; } break; case 9: #line 81 "gram.y" { syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 ); yyval.nodeData = yyvsp[0].nodeData; } break; case 10: #line 86 "gram.y" { /* * _Anchors_: The language binding must keep a separate symbol table * for anchors. The actual ID in the symbol table is returned to the * higher nodes, though. */ yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData ); } break; case 11: #line 95 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; case 14: #line 105 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; case 15: #line 109 "gram.y" { NULL_NODE( parser, n ); yyval.nodeData = n; } break; case 16: #line 114 "gram.y" { if ( ((SyckParser *)parser)->implicit_typing == 1 ) { try_tag_implicit( yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); } yyval.nodeData = yyvsp[0].nodeData; } break; case 17: #line 122 "gram.y" { syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); yyval.nodeData = yyvsp[0].nodeData; } break; case 18: #line 127 "gram.y" { syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 ); yyval.nodeData = yyvsp[0].nodeData; } break; case 19: #line 132 "gram.y" { /* * _Anchors_: The language binding must keep a separate symbol table * for anchors. The actual ID in the symbol table is returned to the * higher nodes, though. */ yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData ); } break; case 26: #line 165 "gram.y" { syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); yyval.nodeData = yyvsp[0].nodeData; } break; case 27: #line 170 "gram.y" { syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 ); yyval.nodeData = yyvsp[0].nodeData; } break; case 28: #line 175 "gram.y" { if ( ((SyckParser *)parser)->implicit_typing == 1 ) { try_tag_implicit( yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); } yyval.nodeData = yyvsp[0].nodeData; } break; case 29: #line 183 "gram.y" { yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData ); } break; case 30: #line 187 "gram.y" { /* * _Aliases_: The anchor symbol table is scanned for the anchor name. * The anchor's ID in the language's symbol table is returned. */ yyval.nodeData = syck_hdlr_get_anchor( (SyckParser *)parser, yyvsp[0].name ); } break; case 31: #line 195 "gram.y" { SyckNode *n = yyvsp[0].nodeData; if ( ((SyckParser *)parser)->taguri_expansion == 1 ) { n->type_id = syck_taguri( YAML_DOMAIN, "str", 3 ); } else { n->type_id = syck_strndup( "str", 3 ); } yyval.nodeData = n; } break; case 33: #line 209 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; case 39: #line 229 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; case 40: #line 233 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; case 41: #line 239 "gram.y" { yyval.nodeId = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ); } break; case 42: #line 245 "gram.y" { syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); yyval.nodeData = yyvsp[0].nodeData; } break; case 43: #line 250 "gram.y" { syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); yyval.nodeData = yyvsp[0].nodeData; } break; case 44: #line 255 "gram.y" { syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, 0 ); yyval.nodeData = yyvsp[0].nodeData; } break; case 45: #line 260 "gram.y" { syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 ); yyval.nodeData = yyvsp[0].nodeData; } break; case 46: #line 265 "gram.y" { yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-2].name, yyvsp[0].nodeData ); } break; case 47: #line 269 "gram.y" { yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData ); } break; case 48: #line 275 "gram.y" { yyval.nodeData = syck_new_seq( yyvsp[0].nodeId ); } break; case 49: #line 279 "gram.y" { syck_seq_add( yyvsp[-2].nodeData, yyvsp[0].nodeId ); yyval.nodeData = yyvsp[-2].nodeData; } break; case 50: #line 284 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; case 51: #line 293 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; case 52: #line 297 "gram.y" { yyval.nodeData = syck_alloc_seq(); } break; case 53: #line 303 "gram.y" { yyval.nodeData = syck_new_seq( syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) ); } break; case 54: #line 307 "gram.y" { syck_seq_add( yyvsp[-2].nodeData, syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) ); yyval.nodeData = yyvsp[-2].nodeData; } break; case 57: #line 321 "gram.y" { apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData ); yyval.nodeData = yyvsp[-1].nodeData; } break; case 58: #line 326 "gram.y" { apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData ); yyval.nodeData = yyvsp[-1].nodeData; } break; case 59: #line 333 "gram.y" { syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); yyval.nodeData = yyvsp[0].nodeData; } break; case 60: #line 338 "gram.y" { syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); yyval.nodeData = yyvsp[0].nodeData; } break; case 61: #line 343 "gram.y" { syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, 0 ); yyval.nodeData = yyvsp[0].nodeData; } break; case 62: #line 348 "gram.y" { syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 ); yyval.nodeData = yyvsp[0].nodeData; } break; case 63: #line 353 "gram.y" { yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-2].name, yyvsp[0].nodeData ); } break; case 64: #line 357 "gram.y" { yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData ); } break; case 66: #line 364 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; case 68: #line 380 "gram.y" { yyval.nodeData = syck_new_map( syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ), syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) ); } break; case 70: #line 398 "gram.y" { if ( yyvsp[-2].nodeData->shortcut == NULL ) { yyvsp[-2].nodeData->shortcut = syck_new_seq( yyvsp[0].nodeId ); } else { syck_seq_add( yyvsp[-2].nodeData->shortcut, yyvsp[0].nodeId ); } yyval.nodeData = yyvsp[-2].nodeData; } break; case 71: #line 410 "gram.y" { apply_seq_in_map( (SyckParser *)parser, yyvsp[-2].nodeData ); syck_map_update( yyvsp[-2].nodeData, yyvsp[0].nodeData ); syck_free_node( yyvsp[0].nodeData ); yyvsp[0].nodeData = NULL; yyval.nodeData = yyvsp[-2].nodeData; } break; case 72: #line 418 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; case 73: #line 427 "gram.y" { yyval.nodeData = syck_new_map( syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ), syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) ); } break; case 74: #line 435 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; case 75: #line 439 "gram.y" { yyval.nodeData = syck_alloc_map(); } break; case 77: #line 446 "gram.y" { syck_map_update( yyvsp[-2].nodeData, yyvsp[0].nodeData ); syck_free_node( yyvsp[0].nodeData ); yyvsp[0].nodeData = NULL; yyval.nodeData = yyvsp[-2].nodeData; } break; case 78: #line 455 "gram.y" { NULL_NODE( parser, n ); yyval.nodeData = syck_new_map( syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ), syck_hdlr_add_node( (SyckParser *)parser, n ) ); } break; } /* Line 1010 of yacc.c. */ #line 1651 "gram.c" yyvsp -= yylen; yyssp -= yylen; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if YYERROR_VERBOSE yyn = yypact[yystate]; if (YYPACT_NINF < yyn && yyn < YYLAST) { YYSIZE_T yysize = 0; int yytype = YYTRANSLATE (yychar); const char* yyprefix; char *yymsg; int yyx; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yycount = 0; yyprefix = ", expecting "; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); yycount += 1; if (yycount == 5) { yysize = 0; break; } } yysize += (sizeof ("syntax error, unexpected ") + yystrlen (yytname[yytype])); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); yyp = yystpcpy (yyp, yytname[yytype]); if (yycount < 5) { yyprefix = ", expecting "; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { yyp = yystpcpy (yyp, yyprefix); yyp = yystpcpy (yyp, yytname[yyx]); yyprefix = " or "; } } yyerror (yymsg); YYSTACK_FREE (yymsg); } else yyerror ("syntax error; also virtual memory exhausted"); } else #endif /* YYERROR_VERBOSE */ yyerror ("syntax error"); } if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* If at end of input, pop the error token, then the rest of the stack, then return failure. */ if (yychar == YYEOF) for (;;) { YYPOPSTACK; if (yyssp == yyss) YYABORT; YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); yydestruct (yystos[*yyssp], yyvsp); } } else { YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); yydestruct (yytoken, &yylval); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: #ifdef __GNUC__ /* Pacify GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (0) goto yyerrorlab; #endif yyvsp -= yylen; yyssp -= yylen; yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); yydestruct (yystos[yystate], yyvsp); YYPOPSTACK; yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } if (yyn == YYFINAL) YYACCEPT; YYDPRINTF ((stderr, "Shifting error token, ")); *++yyvsp = yylval; yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #ifndef yyoverflow /*----------------------------------------------. | yyoverflowlab -- parser overflow comes here. | `----------------------------------------------*/ yyoverflowlab: yyerror ("parser stack overflow"); yyresult = 2; /* Fall through. */ #endif yyreturn: #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif return yyresult; } #line 464 "gram.y" void apply_seq_in_map( SyckParser *parser, SyckNode *n ) { long map_len; if ( n->shortcut == NULL ) { return; } map_len = syck_map_count( n ); syck_map_assign( n, map_value, map_len - 1, syck_hdlr_add_node( parser, n->shortcut ) ); n->shortcut = NULL; } YAML-Syck-1.31/perl_common.h0000644000000000000000000000500613364413554014301 0ustar rootroot#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #define NEED_eval_pv #define NEED_grok_hex #define NEED_grok_number #define NEED_grok_numeric_radix #define NEED_grok_oct #define NEED_newRV_noinc #define NEED_newSVpvn_share #define NEED_sv_2pv_flags #include "ppport.h" #include "ppport_math.h" #include "ppport_sort.h" #ifndef is_utf8_string #define is_utf8_string(x, y) (0==1) #endif #undef DEBUG /* maybe defined in perl.h */ #include #ifndef newSVpvn_share #define newSVpvn_share(x, y, z) newSVpvn(x, y) #endif /* #undef ASSERT #include "Storable.xs" */ struct emitter_xtra { union { SV* outsv; PerlIO* outio; } out; char* tag; char dump_code; bool implicit_binary; int ioerror; }; struct parser_xtra { AV *objects; bool implicit_unicode; bool load_code; bool load_blessed; HV *bad_anchors; }; SV* perl_syck_lookup_sym( SyckParser *p, SYMID v) { /* Not "undef" becase otherwise we have a warning on self-recursive nodes */ SV *obj = &PL_sv_no; syck_lookup_sym(p, v, (char **)&obj); return obj; } #ifdef SvUTF8_on #define CHECK_UTF8 \ if (((struct parser_xtra *)p->bonus)->implicit_unicode \ && n->data.str->len \ && is_utf8_string((U8*)n->data.str->ptr, n->data.str->len)) \ SvUTF8_on(sv); #else #define CHECK_UTF8 ; #endif SyckNode * perl_syck_bad_anchor_handler(SyckParser *p, char *a) { SyckNode *badanc = syck_new_map( (SYMID)newSVpvn_share("name", 4, 0), (SYMID)newSVpvn_share(a, strlen(a), 0) ); badanc->type_id = syck_strndup( "!perl:YAML::Syck::BadAlias", 26 ); return badanc; } void perl_syck_error_handler(SyckParser *p, char *msg) { croak("%s parser (line %d, column %ld): %s", "Syck", p->linect + 1, (long) (p->cursor - p->lineptr), msg ); } void perl_syck_output_handler_pv(SyckEmitter *e, char *str, long len) { struct emitter_xtra *bonus = (struct emitter_xtra *)e->bonus; sv_catpvn_nomg(bonus->out.outsv, str, len); } void perl_syck_output_handler_mg(SyckEmitter *e, char *str, long len) { struct emitter_xtra *bonus = (struct emitter_xtra *)e->bonus; sv_catpvn_mg(bonus->out.outsv, str, len); } void perl_syck_output_handler_io(SyckEmitter *e, char *str, long len) { struct emitter_xtra *bonus = (struct emitter_xtra *)e->bonus; if (bonus->ioerror) { return; } else { int wrote = PerlIO_write(bonus->out.outio, str, len); if (wrote != len) bonus->ioerror = (errno ? errno : -1); } } YAML-Syck-1.31/MANIFEST0000644000000000000000000000270513364413554012752 0ustar rootrootbytecode.c Changes COMPATIBILITY COPYING emitter.c gram.c gram.h handler.c implicit.c inc/ExtUtils/HasCompiler.pm inc/Module/Install.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm inc/Module/Install/Compiler.pm inc/Module/Install/Fetch.pm inc/Module/Install/Include.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm inc/parent.pm inc/PerlIO.pm inc/Scalar/Util.pm inc/Test/Builder.pm inc/Test/Builder/IO/Scalar.pm inc/Test/Builder/Module.pm inc/Test/More.pm lib/JSON/Syck.pm lib/YAML/Dumper/Syck.pm lib/YAML/Loader/Syck.pm lib/YAML/Syck.pm Makefile.PL MANIFEST This list of files META.yml node.c perl_common.h perl_syck.h ppport.h ppport_math.h ppport_sort.h README syck.h Syck.xs syck_.c syck_st.c syck_st.h t/1-basic.t t/11-loadfile.t t/12-dumpfile.t t/2-scalars.t t/3-objects.t t/4-perl_tag_scheme.t t/bug/doesnt-stringify.t t/bug/rt-41141.t t/bug/rt-49404-double_free.t t/bug/rt-54167.t t/json-basic.t t/json-circular-ref.t t/json-crlf.t t/json-dumpinto.t t/json-empty.t t/json-indent.t t/json-loadfile.t t/json-minus.t t/json-newline.t t/json-null.t t/json-numbers.t t/json-refs.t t/json-singlequote.t t/leak.t t/load-blessed.t t/manifest.t t/meta.t t/TestYAML.pm t/yaml-alias.t t/yaml-blessed-ref.t t/yaml-dumpinto.t t/yaml-implicit-warnings.t t/yaml-str-colon-first.t t/yaml-tie.t t/yaml-utf.t token.c META.json Module JSON meta-data (added by MakeMaker) YAML-Syck-1.31/token.c0000644000000000000000000016157113364413554013114 0ustar rootroot/* Generated by re2c 0.10.1 on Mon May 8 21:26:43 2006 */ #line 1 "token.re" /* * token.re * * $Author: why $ * $Date: 2005-09-21 07:42:51 +0800 (三, 21 9 2005) $ * * Copyright (C) 2003 why the lucky stiff */ #include "syck.h" #include "gram.h" /* * Allocate quoted strings in chunks */ #define QUOTELEN 1024 /* * They do my bidding... */ #define YYCTYPE char #define YYCURSOR parser->cursor #define YYMARKER parser->marker #define YYLIMIT parser->limit #define YYTOKEN parser->token #define YYTOKTMP parser->toktmp #define YYLINEPTR parser->lineptr #define YYLINECTPTR parser->linectptr #define YYLINE parser->linect #define YYFILL(n) syck_parser_read(parser) /* * Repositions the cursor at `n' offset from the token start. * Only works in `Header' and `Document' sections. */ #define YYPOS(n) YYCURSOR = YYTOKEN + n /* * Track line numbers */ #define NEWLINE(ptr) YYLINEPTR = ptr + newline_len(ptr); if ( YYLINEPTR > YYLINECTPTR ) { YYLINE++; YYLINECTPTR = YYLINEPTR; } /* * I like seeing the level operations as macros... */ #define ADD_LEVEL(len, status) syck_parser_add_level( parser, len, status ) #define POP_LEVEL() syck_parser_pop_level( parser ) #define CURRENT_LEVEL() syck_parser_current_level( parser ) /* * Force a token next time around sycklex() */ #define FORCE_NEXT_TOKEN(tok) parser->force_token = tok; /* * Nice little macro to ensure we're YAML_IOPENed to the current level. * * Only use this macro in the "Document" section * */ #define ENSURE_YAML_IOPEN(last_lvl, to_len, reset) \ if ( last_lvl->spaces < to_len ) \ { \ if ( last_lvl->status == syck_lvl_iseq || last_lvl->status == syck_lvl_imap ) \ { \ goto Document; \ } \ else \ { \ ADD_LEVEL( to_len, syck_lvl_doc ); \ if ( reset == 1 ) YYPOS(0); \ return YAML_IOPEN; \ } \ } /* * Nice little macro to ensure closure of levels. * * Only use this macro in the "Document" section * */ #define ENSURE_YAML_IEND(last_lvl, to_len) \ if ( last_lvl->spaces > to_len ) \ { \ syck_parser_pop_level( parser ); \ YYPOS(0); \ return YAML_IEND; \ } /* * Concatenates quoted string items and manages allocation * to the quoted string */ #define QUOTECAT(s, c, i, l) \ { \ if ( i + 1 >= c ) \ { \ c += QUOTELEN; \ S_REALLOC_N( s, char, c ); \ } \ s[i++] = l; \ s[i] = '\0'; \ } #define QUOTECATS(s, c, i, cs, cl) \ { \ while ( i + cl >= c ) \ { \ c += QUOTELEN; \ S_REALLOC_N( s, char, c ); \ } \ S_MEMCPY( s + i, cs, char, cl ); \ i += cl; \ s[i] = '\0'; \ } /* * Tags a plain scalar with a transfer method * * Use only in "Plain" section * */ #define RETURN_IMPLICIT() \ { \ SyckNode *n = syck_alloc_str(); \ YYCURSOR = YYTOKEN; \ n->data.str->ptr = qstr; \ n->data.str->len = qidx; \ n->data.str->style = scalar_plain; \ sycklval->nodeData = n; \ if ( parser->implicit_typing == 1 ) \ { \ try_tag_implicit( sycklval->nodeData, parser->taguri_expansion ); \ } \ return YAML_PLAIN; \ } /* concat the inline characters to the plain scalar */ #define PLAIN_NOT_INL() \ if ( *(YYCURSOR - 1) == ' ' || is_newline( YYCURSOR - 1 ) ) \ { \ YYCURSOR--; \ } \ QUOTECATS(qstr, qcapa, qidx, YYTOKEN, YYCURSOR - YYTOKEN); \ goto Plain2; /* trim spaces off the end in case of indent */ #define PLAIN_IS_INL() \ char *walker = qstr + qidx - 1; \ while ( walker > qstr && ( *walker == '\n' || *walker == ' ' || *walker == '\t' ) ) \ { \ qidx--; \ walker[0] = '\0'; \ walker--; \ } /* * Keep or chomp block? * * Use only in "ScalarBlock" section * */ #define RETURN_YAML_BLOCK() \ { \ SyckNode *n = syck_alloc_str(); \ if ( ((SyckParser *)parser)->taguri_expansion == 1 ) \ { \ n->type_id = syck_taguri( YAML_DOMAIN, "str", 3 ); \ } \ else \ { \ n->type_id = syck_strndup( "str", 3 ); \ } \ n->data.str->ptr = qstr; \ n->data.str->len = qidx; \ if ( blockType == BLOCK_LIT ) { \ n->data.str->style = scalar_literal; \ } else { \ n->data.str->style = scalar_fold; \ } \ if ( qidx > 0 ) \ { \ if ( nlDoWhat != NL_KEEP ) \ { \ char *fc = n->data.str->ptr + n->data.str->len - 1; \ while ( is_newline( fc ) ) fc--; \ if ( nlDoWhat != NL_CHOMP && fc < n->data.str->ptr + n->data.str->len - 1 ) \ fc += 1; \ n->data.str->len = fc - n->data.str->ptr + 1; \ } \ } \ sycklval->nodeData = n; \ return YAML_BLOCK; \ } /* * Handles newlines, calculates indent */ #define GOBBLE_UP_YAML_INDENT( ict, start ) \ char *indent = start; \ NEWLINE(indent); \ while ( indent < YYCURSOR ) \ { \ if ( is_newline( ++indent ) ) \ { \ NEWLINE(indent); \ } \ } \ ict = 0; \ if ( *YYCURSOR == '\0' ) \ { \ ict = -1; \ start = YYCURSOR - 1; \ } \ else if ( *YYLINEPTR == ' ' ) \ { \ ict = YYCURSOR - YYLINEPTR; \ } /* * If an indent exists at the current level, back up. */ #define GET_TRUE_YAML_INDENT(indt_len) \ { \ SyckLevel *lvl_deep = CURRENT_LEVEL(); \ indt_len = lvl_deep->spaces; \ if ( lvl_deep->status == syck_lvl_seq || ( indt_len == YYCURSOR - YYLINEPTR && lvl_deep->status != syck_lvl_map ) ) \ { \ SyckLevel *lvl_over; \ parser->lvl_idx--; \ lvl_over = CURRENT_LEVEL(); \ indt_len = lvl_over->spaces; \ parser->lvl_idx++; \ } \ } /* * Argjh! I hate globals! Here for syckerror() only! */ SyckParser *syck_parser_ptr = NULL; /* * Accessory funcs later in this file. */ void eat_comments( SyckParser * ); char escape_seq( char ); int is_newline( char *ptr ); int newline_len( char *ptr ); int sycklex_yaml_utf8( YYSTYPE *, SyckParser * ); int sycklex_bytecode_utf8( YYSTYPE *, SyckParser * ); int syckwrap(); /* * My own re-entrant sycklex() using re2c. * You really get used to the limited regexp. * It's really nice to not rely on backtracking and such. */ int sycklex( YYSTYPE *sycklval, SyckParser *parser ) { switch ( parser->input_type ) { case syck_yaml_utf8: return sycklex_yaml_utf8( sycklval, parser ); case syck_yaml_utf16: syckerror( "UTF-16 is not currently supported in Syck.\nPlease contribute code to help this happen!" ); break; case syck_yaml_utf32: syckerror( "UTF-32 is not currently supported in Syck.\nPlease contribute code to help this happen!" ); break; case syck_bytecode_utf8: return sycklex_bytecode_utf8( sycklval, parser ); } return YAML_DOCSEP; } /* * Parser for standard YAML [UTF-8] */ int sycklex_yaml_utf8( YYSTYPE *sycklval, SyckParser *parser ) { int doc_level = 0; syck_parser_ptr = parser; if ( YYCURSOR == NULL ) { syck_parser_read( parser ); } if ( parser->force_token != 0 ) { int t = parser->force_token; parser->force_token = 0; return t; } #line 315 "token.re" if ( YYLINEPTR != YYCURSOR ) { goto Document; } Header: YYTOKEN = YYCURSOR; #line 307 "" { YYCTYPE yych; unsigned int yyaccept = 0; if((YYLIMIT - YYCURSOR) < 5) YYFILL(5); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy7; case 0x09: case ' ': goto yy12; case 0x0A: goto yy9; case 0x0D: goto yy11; case '#': goto yy5; case '-': goto yy2; case '.': goto yy4; default: goto yy14; } yy2: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ case '-': goto yy28; default: goto yy3; } yy3: #line 374 "token.re" { YYPOS(0); goto Document; } #line 337 "" yy4: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ case '.': goto yy21; default: goto yy3; } yy5: ++YYCURSOR; #line 356 "token.re" { eat_comments( parser ); goto Header; } #line 351 "" yy7: ++YYCURSOR; #line 360 "token.re" { SyckLevel *lvl = CURRENT_LEVEL(); ENSURE_YAML_IEND(lvl, -1); YYPOS(0); return 0; } #line 360 "" yy9: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); goto yy18; yy10: #line 366 "token.re" { GOBBLE_UP_YAML_INDENT( doc_level, YYTOKEN ); goto Header; } #line 370 "" yy11: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy17; default: goto yy3; } yy12: ++YYCURSOR; yych = *YYCURSOR; goto yy16; yy13: #line 370 "token.re" { doc_level = YYCURSOR - YYLINEPTR; goto Header; } #line 386 "" yy14: yych = *++YYCURSOR; goto yy3; yy15: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy16: switch(yych){ case 0x09: case ' ': goto yy15; default: goto yy13; } yy17: yyaccept = 1; YYMARKER = ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy18: switch(yych){ case 0x0A: case ' ': goto yy17; case 0x0D: goto yy19; default: goto yy10; } yy19: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case 0x0A: goto yy17; default: goto yy20; } yy20: YYCURSOR = YYMARKER; switch(yyaccept){ case 1: goto yy10; case 0: goto yy3; } yy21: yych = *++YYCURSOR; switch(yych){ case '.': goto yy22; default: goto yy20; } yy22: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy23; case 0x0D: goto yy27; case ' ': goto yy25; default: goto yy20; } yy23: ++YYCURSOR; yy24: #line 342 "token.re" { SyckLevel *lvl = CURRENT_LEVEL(); if ( lvl->status == syck_lvl_header ) { goto Header; } else { ENSURE_YAML_IEND(lvl, -1); YYPOS(0); return 0; } return 0; } #line 457 "" yy25: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case ' ': goto yy25; default: goto yy24; } yy27: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy23; default: goto yy20; } yy28: yych = *++YYCURSOR; switch(yych){ case '-': goto yy29; default: goto yy20; } yy29: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy30; case 0x0D: goto yy34; case ' ': goto yy32; default: goto yy20; } yy30: ++YYCURSOR; yy31: #line 328 "token.re" { SyckLevel *lvl = CURRENT_LEVEL(); if ( lvl->status == syck_lvl_header ) { YYPOS(3); goto Directive; } else { ENSURE_YAML_IEND(lvl, -1); YYPOS(0); return 0; } } #line 503 "" yy32: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case ' ': goto yy32; default: goto yy31; } yy34: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy30; default: goto yy20; } } #line 378 "token.re" Document: { SyckLevel *lvl = CURRENT_LEVEL(); if ( lvl->status == syck_lvl_header ) { lvl->status = syck_lvl_doc; } YYTOKEN = YYCURSOR; #line 533 "" { YYCTYPE yych; unsigned int yyaccept = 0; if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy62; case 0x09: case ' ': goto yy60; case 0x0A: goto yy37; case 0x0D: goto yy39; case '!': goto yy51; case '"': goto yy55; case '#': goto yy58; case '&': goto yy49; case '\'': goto yy53; case '*': goto yy50; case ',': case ':': goto yy47; case '-': case '?': goto yy48; case '>': case '|': goto yy57; case '[': goto yy41; case ']': case '}': goto yy45; case '{': goto yy43; default: goto yy64; } yy37: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy92; yy38: #line 392 "token.re" { /* Isolate spaces */ int indt_len; GOBBLE_UP_YAML_INDENT( indt_len, YYTOKEN ); lvl = CURRENT_LEVEL(); doc_level = 0; /* XXX: Comment lookahead */ if ( *YYCURSOR == '#' ) { goto Document; } /* Ignore indentation inside inlines */ if ( lvl->status == syck_lvl_iseq || lvl->status == syck_lvl_imap ) { goto Document; } /* Check for open indent */ ENSURE_YAML_IEND(lvl, indt_len); ENSURE_YAML_IOPEN(lvl, indt_len, 0); if ( indt_len == -1 ) { return 0; } return YAML_INDENT; } #line 596 "" yy39: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy91; default: goto yy40; } yy40: #line 500 "token.re" { ENSURE_YAML_IOPEN(lvl, doc_level, 1); goto Plain; } #line 608 "" yy41: ++YYCURSOR; #line 420 "token.re" { ENSURE_YAML_IOPEN(lvl, doc_level, 1); lvl = CURRENT_LEVEL(); ADD_LEVEL(lvl->spaces + 1, syck_lvl_iseq); return YYTOKEN[0]; } #line 617 "" yy43: ++YYCURSOR; #line 426 "token.re" { ENSURE_YAML_IOPEN(lvl, doc_level, 1); lvl = CURRENT_LEVEL(); ADD_LEVEL(lvl->spaces + 1, syck_lvl_imap); return YYTOKEN[0]; } #line 626 "" yy45: ++YYCURSOR; #line 432 "token.re" { POP_LEVEL(); return YYTOKEN[0]; } #line 633 "" yy47: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ case 0x0A: goto yy86; case 0x0D: goto yy90; case ' ': goto yy88; default: goto yy40; } yy48: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ case 0x0A: goto yy81; case 0x0D: goto yy85; case ' ': goto yy83; default: goto yy40; } yy49: yych = *++YYCURSOR; switch(yych){ case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy78; default: goto yy40; } yy50: yych = *++YYCURSOR; switch(yych){ case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy75; default: goto yy40; } yy51: ++YYCURSOR; #line 474 "token.re" { goto TransferMethod; } #line 794 "" yy53: ++YYCURSOR; #line 476 "token.re" { ENSURE_YAML_IOPEN(lvl, doc_level, 1); goto SingleQuote; } #line 800 "" yy55: ++YYCURSOR; #line 479 "token.re" { ENSURE_YAML_IOPEN(lvl, doc_level, 1); goto DoubleQuote; } #line 806 "" yy57: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ case 0x0A: goto yy70; case 0x0D: goto yy74; case ' ': goto yy72; case '+': case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy67; default: goto yy40; } yy58: ++YYCURSOR; #line 489 "token.re" { eat_comments( parser ); goto Document; } #line 834 "" yy60: ++YYCURSOR; yych = *YYCURSOR; goto yy66; yy61: #line 493 "token.re" { goto Document; } #line 842 "" yy62: ++YYCURSOR; #line 495 "token.re" { ENSURE_YAML_IEND(lvl, -1); YYPOS(0); return 0; } #line 850 "" yy64: yych = *++YYCURSOR; goto yy40; yy65: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy66: switch(yych){ case 0x09: case ' ': goto yy65; default: goto yy61; } yy67: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ case 0x0A: goto yy70; case 0x0D: goto yy74; case ' ': goto yy72; case '+': case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy67; default: goto yy69; } yy69: YYCURSOR = YYMARKER; switch(yyaccept){ case 0: goto yy38; case 1: goto yy40; } yy70: ++YYCURSOR; yy71: #line 482 "token.re" { if ( is_newline( YYCURSOR - 1 ) ) { YYCURSOR--; } goto ScalarBlock; } #line 902 "" yy72: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case ' ': goto yy72; default: goto yy71; } yy74: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy70; default: goto yy69; } yy75: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy75; default: goto yy77; } yy77: #line 469 "token.re" { ENSURE_YAML_IOPEN(lvl, doc_level, 1); sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); return YAML_ALIAS; } #line 994 "" yy78: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy78; default: goto yy80; } yy80: #line 458 "token.re" { sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); /* * Remove previous anchors of the same name. Since the parser will likely * construct deeper nodes first, we want those nodes to be placed in the * queue for matching at a higher level of indentation. */ syck_hdlr_remove_anchor(parser, sycklval->name); return YAML_ANCHOR; } #line 1078 "" yy81: ++YYCURSOR; yy82: #line 444 "token.re" { ENSURE_YAML_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1); FORCE_NEXT_TOKEN(YAML_IOPEN); if ( *YYCURSOR == '#' || is_newline( YYCURSOR ) || is_newline( YYCURSOR - 1 ) ) { YYCURSOR--; ADD_LEVEL((YYTOKEN + 1) - YYLINEPTR, syck_lvl_seq); } else /* spaces followed by content uses the space as indentation */ { ADD_LEVEL(YYCURSOR - YYLINEPTR, syck_lvl_seq); } return YYTOKEN[0]; } #line 1096 "" yy83: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case ' ': goto yy83; default: goto yy82; } yy85: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy81; default: goto yy69; } yy86: ++YYCURSOR; yy87: #line 436 "token.re" { if ( *YYTOKEN == ':' && lvl->status != syck_lvl_imap && lvl->status != syck_lvl_iseq ) { lvl->status = syck_lvl_map; } YYPOS(1); return YYTOKEN[0]; } #line 1122 "" yy88: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case ' ': goto yy88; default: goto yy87; } yy90: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy86; default: goto yy69; } yy91: yyaccept = 0; YYMARKER = ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy92: switch(yych){ case 0x0A: case ' ': goto yy91; case 0x0D: goto yy93; default: goto yy38; } yy93: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case 0x0A: goto yy91; default: goto yy69; } } #line 504 "token.re" } Directive: { YYTOKTMP = YYCURSOR; #line 1167 "" { YYCTYPE yych; unsigned int yyaccept = 0; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy96; case 0x09: case ' ': goto yy99; case '%': goto yy97; default: goto yy101; } yy96: YYCURSOR = YYMARKER; switch(yyaccept){ case 0: goto yy98; } yy97: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case ';': case '<': case '=': case '>': case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy104; default: goto yy98; } yy98: #line 517 "token.re" { YYCURSOR = YYTOKTMP; return YAML_DOCSEP; } #line 1272 "" yy99: ++YYCURSOR; yych = *YYCURSOR; goto yy103; yy100: #line 515 "token.re" { goto Directive; } #line 1280 "" yy101: yych = *++YYCURSOR; goto yy98; yy102: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy103: switch(yych){ case 0x09: case ' ': goto yy102; default: goto yy100; } yy104: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ';': case '<': case '=': case '>': case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy104; case ':': goto yy106; default: goto yy96; } yy106: yych = *++YYCURSOR; switch(yych){ case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case ';': case '<': case '=': case '>': case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy107; default: goto yy96; } yy107: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case ';': case '<': case '=': case '>': case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto yy107; default: goto yy109; } yy109: #line 513 "token.re" { goto Directive; } #line 1544 "" } #line 520 "token.re" } Plain: { int qidx = 0; int qcapa = 100; char *qstr = S_ALLOC_N( char, qcapa ); SyckLevel *plvl; int parentIndent; YYCURSOR = YYTOKEN; plvl = CURRENT_LEVEL(); GET_TRUE_YAML_INDENT(parentIndent); Plain2: YYTOKEN = YYCURSOR; Plain3: #line 1569 "" { YYCTYPE yych; unsigned int yyaccept = 0; if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy124; case 0x09: goto yy126; case 0x0A: goto yy112; case 0x0D: goto yy114; case ' ': goto yy122; case ',': goto yy117; case ':': goto yy116; case ']': goto yy120; case '}': goto yy118; default: goto yy127; } yy112: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy142; yy113: #line 543 "token.re" { int indt_len, nl_count = 0; SyckLevel *lvl; char *tok = YYTOKEN; GOBBLE_UP_YAML_INDENT( indt_len, tok ); lvl = CURRENT_LEVEL(); if ( indt_len <= parentIndent ) { RETURN_IMPLICIT(); } while ( YYTOKEN < YYCURSOR ) { int nl_len = newline_len( YYTOKEN++ ); if ( nl_len ) { nl_count++; YYTOKEN += nl_len - 1; } } if ( nl_count <= 1 ) { QUOTECAT(qstr, qcapa, qidx, ' '); } else { int i; for ( i = 0; i < nl_count - 1; i++ ) { QUOTECAT(qstr, qcapa, qidx, '\n'); } } goto Plain2; } #line 1628 "" yy114: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy141; default: goto yy115; } yy115: #line 630 "token.re" { QUOTECATS(qstr, qcapa, qidx, YYTOKEN, YYCURSOR - YYTOKEN); goto Plain2; } #line 1640 "" yy116: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ case 0x0A: goto yy136; case 0x0D: goto yy140; case ' ': goto yy138; default: goto yy115; } yy117: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ case 0x0A: goto yy130; case 0x0D: goto yy134; case ' ': goto yy132; default: goto yy115; } yy118: ++YYCURSOR; #line 592 "token.re" { if ( plvl->status != syck_lvl_imap ) { PLAIN_NOT_INL(); } else { PLAIN_IS_INL(); } RETURN_IMPLICIT(); } #line 1672 "" yy120: ++YYCURSOR; #line 603 "token.re" { if ( plvl->status != syck_lvl_iseq ) { PLAIN_NOT_INL(); } else { PLAIN_IS_INL(); } RETURN_IMPLICIT(); } #line 1686 "" yy122: ++YYCURSOR; switch((yych = *YYCURSOR)) { case '#': goto yy128; default: goto yy123; } yy123: #line 620 "token.re" { if ( qidx == 0 ) { goto Plain2; } else { goto Plain3; } } #line 1704 "" yy124: ++YYCURSOR; #line 618 "token.re" { RETURN_IMPLICIT(); } #line 1709 "" yy126: yych = *++YYCURSOR; goto yy123; yy127: yych = *++YYCURSOR; goto yy115; yy128: ++YYCURSOR; #line 614 "token.re" { eat_comments( parser ); RETURN_IMPLICIT(); } #line 1722 "" yy130: ++YYCURSOR; yy131: #line 581 "token.re" { if ( plvl->status != syck_lvl_iseq && plvl->status != syck_lvl_imap ) { PLAIN_NOT_INL(); } else { PLAIN_IS_INL(); } RETURN_IMPLICIT(); } #line 1737 "" yy132: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case ' ': goto yy132; default: goto yy131; } yy134: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy130; default: goto yy135; } yy135: YYCURSOR = YYMARKER; switch(yyaccept){ case 0: goto yy113; case 1: goto yy115; } yy136: ++YYCURSOR; yy137: #line 579 "token.re" { RETURN_IMPLICIT(); } #line 1763 "" yy138: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case ' ': goto yy138; default: goto yy137; } yy140: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy136; default: goto yy135; } yy141: yyaccept = 0; YYMARKER = ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy142: switch(yych){ case 0x0A: case ' ': goto yy141; case 0x0D: goto yy143; default: goto yy113; } yy143: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case 0x0A: goto yy141; default: goto yy135; } } #line 634 "token.re" } SingleQuote: { int qidx = 0; int qcapa = 100; char *qstr = S_ALLOC_N( char, qcapa ); SingleQuote2: YYTOKEN = YYCURSOR; #line 1813 "" { YYCTYPE yych; unsigned int yyaccept = 0; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy152; case 0x0A: goto yy146; case 0x0D: goto yy148; case '\'': goto yy150; default: goto yy153; } yy146: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy157; yy147: #line 648 "token.re" { int indt_len; int nl_count = 0; SyckLevel *lvl; GOBBLE_UP_YAML_INDENT( indt_len, YYTOKEN ); lvl = CURRENT_LEVEL(); if ( lvl->status != syck_lvl_str ) { ADD_LEVEL( indt_len, syck_lvl_str ); } else if ( indt_len < lvl->spaces ) { /* Error! */ } while ( YYTOKEN < YYCURSOR ) { int nl_len = newline_len( YYTOKEN++ ); if ( nl_len ) { nl_count++; YYTOKEN += nl_len - 1; } } if ( nl_count <= 1 ) { QUOTECAT(qstr, qcapa, qidx, ' '); } else { int i; for ( i = 0; i < nl_count - 1; i++ ) { QUOTECAT(qstr, qcapa, qidx, '\n'); } } goto SingleQuote2; } #line 1871 "" yy148: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy156; default: goto yy149; } yy149: #line 715 "token.re" { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto SingleQuote2; } #line 1883 "" yy150: ++YYCURSOR; switch((yych = *YYCURSOR)) { case '\'': goto yy154; default: goto yy151; } yy151: #line 692 "token.re" { SyckLevel *lvl; SyckNode *n = syck_alloc_str(); lvl = CURRENT_LEVEL(); if ( lvl->status == syck_lvl_str ) { POP_LEVEL(); } if ( ((SyckParser *)parser)->taguri_expansion == 1 ) { n->type_id = syck_taguri( YAML_DOMAIN, "str", 3 ); } else { n->type_id = syck_strndup( "str", 3 ); } n->data.str->ptr = qstr; n->data.str->len = qidx; n->data.str->style = scalar_1quote; sycklval->nodeData = n; return YAML_PLAIN; } #line 1914 "" yy152: yych = *++YYCURSOR; goto yy151; yy153: yych = *++YYCURSOR; goto yy149; yy154: ++YYCURSOR; #line 688 "token.re" { QUOTECAT(qstr, qcapa, qidx, '\''); goto SingleQuote2; } #line 1927 "" yy156: yyaccept = 0; YYMARKER = ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy157: switch(yych){ case 0x0A: case ' ': goto yy156; case 0x0D: goto yy158; default: goto yy147; } yy158: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case 0x0A: goto yy156; default: goto yy159; } yy159: YYCURSOR = YYMARKER; switch(yyaccept){ case 0: goto yy147; } } #line 719 "token.re" } DoubleQuote: { int keep_nl = 1; int qidx = 0; int qcapa = 100; char *qstr = S_ALLOC_N( char, qcapa ); DoubleQuote2: YYTOKEN = YYCURSOR; #line 1972 "" { YYCTYPE yych; unsigned int yyaccept = 0; if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy167; case 0x0A: goto yy162; case 0x0D: goto yy164; case '"': goto yy169; case '\\': goto yy166; default: goto yy170; } yy162: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy184; yy163: #line 737 "token.re" { int indt_len; int nl_count = 0; SyckLevel *lvl; GOBBLE_UP_YAML_INDENT( indt_len, YYTOKEN ); lvl = CURRENT_LEVEL(); if ( lvl->status != syck_lvl_str ) { ADD_LEVEL( indt_len, syck_lvl_str ); } else if ( indt_len < lvl->spaces ) { /* FIXME */ } if ( keep_nl == 1 ) { while ( YYTOKEN < YYCURSOR ) { int nl_len = newline_len( YYTOKEN++ ); if ( nl_len ) { nl_count++; YYTOKEN += nl_len - 1; } } if ( nl_count <= 1 ) { QUOTECAT(qstr, qcapa, qidx, ' '); } else { int i; for ( i = 0; i < nl_count - 1; i++ ) { QUOTECAT(qstr, qcapa, qidx, '\n'); } } } keep_nl = 1; goto DoubleQuote2; } #line 2035 "" yy164: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy183; default: goto yy165; } yy165: #line 823 "token.re" { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto DoubleQuote2; } #line 2047 "" yy166: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ case 0x0A: goto yy174; case 0x0D: goto yy176; case ' ': goto yy171; case '"': case '0': case '\\': case 'a': case 'b': case 'e': case 'f': case 'n': case 'r': case 't': case 'v': goto yy178; case 'x': goto yy177; default: goto yy165; } yy167: ++YYCURSOR; yy168: #line 800 "token.re" { SyckLevel *lvl; SyckNode *n = syck_alloc_str(); lvl = CURRENT_LEVEL(); if ( lvl->status == syck_lvl_str ) { POP_LEVEL(); } if ( ((SyckParser *)parser)->taguri_expansion == 1 ) { n->type_id = syck_taguri( YAML_DOMAIN, "str", 3 ); } else { n->type_id = syck_strndup( "str", 3 ); } n->data.str->ptr = qstr; n->data.str->len = qidx; n->data.str->style = scalar_2quote; sycklval->nodeData = n; return YAML_PLAIN; } #line 2095 "" yy169: yych = *++YYCURSOR; goto yy168; yy170: yych = *++YYCURSOR; goto yy165; yy171: ++YYCURSOR; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ case 0x0A: goto yy174; case 0x0D: goto yy176; case ' ': goto yy171; default: goto yy173; } yy173: YYCURSOR = YYMARKER; switch(yyaccept){ case 0: goto yy163; case 1: goto yy165; } yy174: ++YYCURSOR; #line 795 "token.re" { keep_nl = 0; YYCURSOR--; goto DoubleQuote2; } #line 2125 "" yy176: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy174; default: goto yy173; } yy177: yych = *++YYCURSOR; switch(yych){ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': goto yy180; default: goto yy173; } yy178: ++YYCURSOR; #line 781 "token.re" { char ch = *( YYCURSOR - 1 ); QUOTECAT(qstr, qcapa, qidx, escape_seq( ch )); goto DoubleQuote2; } #line 2166 "" yy180: yych = *++YYCURSOR; switch(yych){ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': goto yy181; default: goto yy173; } yy181: ++YYCURSOR; #line 786 "token.re" { long ch; char *chr_text = syck_strndup( YYTOKEN, 4 ); chr_text[0] = '0'; ch = strtol( chr_text, NULL, 16 ); free( chr_text ); QUOTECAT(qstr, qcapa, qidx, ch); goto DoubleQuote2; } #line 2205 "" yy183: yyaccept = 0; YYMARKER = ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy184: switch(yych){ case 0x0A: case ' ': goto yy183; case 0x0D: goto yy185; default: goto yy163; } yy185: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case 0x0A: goto yy183; default: goto yy173; } } #line 827 "token.re" } TransferMethod: { int qidx = 0; int qcapa = 100; char *qstr = S_ALLOC_N( char, qcapa ); TransferMethod2: YYTOKTMP = YYCURSOR; #line 2241 "" { YYCTYPE yych; unsigned int yyaccept = 0; if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy188; case 0x0A: goto yy190; case 0x0D: goto yy192; case ' ': goto yy191; case '\\': goto yy194; default: goto yy195; } yy188: ++YYCURSOR; yy189: #line 841 "token.re" { SyckLevel *lvl; YYCURSOR = YYTOKTMP; if ( YYCURSOR == YYTOKEN + 1 ) { free( qstr ); return YAML_ITRANSFER; } lvl = CURRENT_LEVEL(); /* * URL Prefixing */ if ( *qstr == '^' ) { sycklval->name = S_ALLOC_N( char, qidx + strlen( lvl->domain ) ); sycklval->name[0] = '\0'; strcat( sycklval->name, lvl->domain ); strncat( sycklval->name, qstr + 1, qidx - 1 ); free( qstr ); } else { char *carat = qstr; char *qend = qstr + qidx; while ( (++carat) < qend ) { if ( *carat == '^' ) break; } if ( carat < qend ) { free( lvl->domain ); lvl->domain = syck_strndup( qstr, carat - qstr ); sycklval->name = S_ALLOC_N( char, ( qend - carat ) + strlen( lvl->domain ) ); sycklval->name[0] = '\0'; strcat( sycklval->name, lvl->domain ); strncat( sycklval->name, carat + 1, ( qend - carat ) - 1 ); free( qstr ); } else { sycklval->name = qstr; } } return YAML_TRANSFER; } #line 2308 "" yy190: yych = *++YYCURSOR; goto yy189; yy191: yych = *++YYCURSOR; goto yy204; yy192: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy188; default: goto yy193; } yy193: #line 908 "token.re" { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto TransferMethod2; } #line 2326 "" yy194: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ case '"': case '0': case '\\': case 'a': case 'b': case 'e': case 'f': case 'n': case 'r': case 't': case 'v': goto yy198; case 'x': goto yy196; default: goto yy193; } yy195: yych = *++YYCURSOR; goto yy193; yy196: yych = *++YYCURSOR; switch(yych){ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': goto yy200; default: goto yy197; } yy197: YYCURSOR = YYMARKER; switch(yyaccept){ case 0: goto yy193; } yy198: ++YYCURSOR; #line 894 "token.re" { char ch = *( YYCURSOR - 1 ); QUOTECAT(qstr, qcapa, qidx, escape_seq( ch )); goto TransferMethod2; } #line 2387 "" yy200: yych = *++YYCURSOR; switch(yych){ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': goto yy201; default: goto yy197; } yy201: ++YYCURSOR; #line 899 "token.re" { long ch; char *chr_text = syck_strndup( YYTOKTMP, 4 ); chr_text[0] = '0'; ch = strtol( chr_text, NULL, 16 ); free( chr_text ); QUOTECAT(qstr, qcapa, qidx, ch); goto TransferMethod2; } #line 2426 "" yy203: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy204: switch(yych){ case ' ': goto yy203; default: goto yy189; } } #line 913 "token.re" } ScalarBlock: { int qidx = 0; int qcapa = 100; char *qstr = S_ALLOC_N( char, qcapa ); int blockType = 0; int nlDoWhat = 0; int lastIndent = 0; int forceIndent = -1; char *yyt = YYTOKEN; SyckLevel *lvl = CURRENT_LEVEL(); int parentIndent = -1; switch ( *yyt ) { case '|': blockType = BLOCK_LIT; break; case '>': blockType = BLOCK_FOLD; break; } while ( ++yyt <= YYCURSOR ) { if ( *yyt == '-' ) { nlDoWhat = NL_CHOMP; } else if ( *yyt == '+' ) { nlDoWhat = NL_KEEP; } else if ( isdigit( *yyt ) ) { forceIndent = strtol( yyt, NULL, 10 ); } } qstr[0] = '\0'; YYTOKEN = YYCURSOR; ScalarBlock2: YYTOKEN = YYCURSOR; #line 2483 "" { YYCTYPE yych; unsigned int yyaccept = 0; if((YYLIMIT - YYCURSOR) < 5) YYFILL(5); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy213; case 0x0A: goto yy207; case 0x0D: goto yy209; case '#': goto yy211; case '-': goto yy215; default: goto yy216; } yy207: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy226; yy208: #line 959 "token.re" { char *pacer; char *tok = YYTOKEN; int indt_len = 0, nl_count = 0, fold_nl = 0, nl_begin = 0; GOBBLE_UP_YAML_INDENT( indt_len, tok ); lvl = CURRENT_LEVEL(); if ( lvl->status != syck_lvl_block ) { GET_TRUE_YAML_INDENT(parentIndent); if ( forceIndent > 0 ) forceIndent += parentIndent; if ( indt_len > parentIndent ) { int new_spaces = forceIndent > 0 ? forceIndent : indt_len; ADD_LEVEL( new_spaces, syck_lvl_block ); lastIndent = indt_len - new_spaces; nl_begin = 1; lvl = CURRENT_LEVEL(); } else { YYCURSOR = YYTOKEN; RETURN_YAML_BLOCK(); } } /* * Fold only in the event of two lines being on the leftmost * indentation. */ if ( blockType == BLOCK_FOLD && lastIndent == 0 && ( indt_len - lvl->spaces ) == 0 ) { fold_nl = 1; } pacer = YYTOKEN; while ( pacer < YYCURSOR ) { int nl_len = newline_len( pacer++ ); if ( nl_len ) { nl_count++; pacer += nl_len - 1; } } if ( fold_nl == 1 || nl_begin == 1 ) { nl_count--; } if ( nl_count < 1 && nl_begin == 0 ) { QUOTECAT(qstr, qcapa, qidx, ' '); } else { int i; for ( i = 0; i < nl_count; i++ ) { QUOTECAT(qstr, qcapa, qidx, '\n'); } } lastIndent = indt_len - lvl->spaces; YYCURSOR -= lastIndent; if ( indt_len < lvl->spaces ) { POP_LEVEL(); YYCURSOR = YYTOKEN; RETURN_YAML_BLOCK(); } goto ScalarBlock2; } #line 2577 "" yy209: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy225; default: goto yy210; } yy210: #line 1073 "token.re" { QUOTECAT(qstr, qcapa, qidx, *YYTOKEN); goto ScalarBlock2; } #line 2589 "" yy211: ++YYCURSOR; #line 1035 "token.re" { lvl = CURRENT_LEVEL(); if ( lvl->status != syck_lvl_block ) { eat_comments( parser ); YYTOKEN = YYCURSOR; } else { QUOTECAT(qstr, qcapa, qidx, *YYTOKEN); } goto ScalarBlock2; } #line 2605 "" yy213: ++YYCURSOR; #line 1049 "token.re" { YYCURSOR--; POP_LEVEL(); RETURN_YAML_BLOCK(); } #line 2613 "" yy215: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ case '-': goto yy217; default: goto yy210; } yy216: yych = *++YYCURSOR; goto yy210; yy217: yych = *++YYCURSOR; switch(yych){ case '-': goto yy219; default: goto yy218; } yy218: YYCURSOR = YYMARKER; switch(yyaccept){ case 0: goto yy208; case 1: goto yy210; } yy219: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy220; case 0x0D: goto yy224; case ' ': goto yy222; default: goto yy218; } yy220: ++YYCURSOR; yy221: #line 1054 "token.re" { if ( YYTOKEN == YYLINEPTR ) { if ( blockType == BLOCK_FOLD && qidx > 0 ) { qidx -= 1; } QUOTECAT(qstr, qcapa, qidx, '\n'); POP_LEVEL(); YYCURSOR = YYTOKEN; RETURN_YAML_BLOCK(); } else { QUOTECAT(qstr, qcapa, qidx, *YYTOKEN); YYCURSOR = YYTOKEN + 1; goto ScalarBlock2; } } #line 2666 "" yy222: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case ' ': goto yy222; default: goto yy221; } yy224: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy220; default: goto yy218; } yy225: yyaccept = 0; YYMARKER = ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy226: switch(yych){ case 0x0A: case ' ': goto yy225; case 0x0D: goto yy227; default: goto yy208; } yy227: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case 0x0A: goto yy225; default: goto yy218; } } #line 1078 "token.re" } return 0; } void eat_comments( SyckParser *parser ) { Comment: { YYTOKEN = YYCURSOR; #line 2718 "" { YYCTYPE yych; unsigned int yyaccept = 0; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy230; case 0x0A: goto yy232; case 0x0D: goto yy233; default: goto yy235; } yy230: ++YYCURSOR; yy231: #line 1094 "token.re" { YYCURSOR = YYTOKEN; return; } #line 2737 "" yy232: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy237; yy233: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy236; default: goto yy234; } yy234: #line 1098 "token.re" { goto Comment; } #line 2752 "" yy235: yych = *++YYCURSOR; goto yy234; yy236: yyaccept = 0; YYMARKER = ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy237: switch(yych){ case 0x0A: goto yy236; case 0x0D: goto yy238; default: goto yy231; } yy238: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ case 0x0A: goto yy236; default: goto yy239; } yy239: YYCURSOR = YYMARKER; switch(yyaccept){ case 0: goto yy231; } } #line 1101 "token.re" } } char escape_seq( char ch ) { switch ( ch ) { case '0': return '\0'; case 'a': return 7; case 'b': return '\010'; case 'e': return '\033'; case 'f': return '\014'; case 'n': return '\n'; case 'r': return '\015'; case 't': return '\t'; case 'v': return '\013'; default: return ch; } } int is_newline( char *ptr ) { return newline_len( ptr ); } int newline_len( char *ptr ) { if ( *ptr == '\n' ) return 1; if ( *ptr == '\r' && *( ptr + 1 ) == '\n' ) return 2; return 0; } int syckwrap() { return 1; } void syckerror( char *msg ) { if ( syck_parser_ptr->error_handler == NULL ) syck_parser_ptr->error_handler = syck_default_error_handler; syck_parser_ptr->root = syck_parser_ptr->root_on_error; (syck_parser_ptr->error_handler)(syck_parser_ptr, msg); } YAML-Syck-1.31/COPYING0000644000000000000000000000527513364413554012661 0ustar rootrootCopyright (c) 2003 why the lucky stiff This software is subject to either of two licenses (BSD or D&R), which you can choose from in your use of the code. The terms for each of these licenses is listed below: BSD License =========== Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. D&R (Death and Repudiation) License =================================== This software may not be used directly by any living being. ANY use of this software (even perfectly legitimate and non-commercial uses) until after death is explicitly restricted. Any living being using (or attempting to use) this software will be punished to the fullest extent of the law. For your protection, corpses will not be punished. We respectfully request that you submit your uses (revisions, uses, distributions, uses, etc.) to your children, who may vicariously perform these uses on your behalf. If you use this software and you are found to be not dead, you will be punished to the fullest extent of the law. If you are found to be a ghost or angel, you will be punished to the fullest extent of the law. After your following the terms of this license, the author has vowed to repudiate your claim, meaning that the validity of this contract will no longer be recognized. This license will be unexpectedly revoked (at a time which is designated to be most inconvenient) and involved heirs will be punished to the fullest extent of the law. Furthermore, if any parties (related or non-related) escape the punishments outlined herein, they will be severely punished to the fullest extent of a new revised law that (1) expands the statement "fullest extent of the law" to encompass an infinite duration of infinite punishments and (2) exacts said punishments upon all parties (related or non-related). YAML-Syck-1.31/ppport_sort.h0000644000000000000000000000176613364413554014373 0ustar rootroot#ifndef PATCHLEVEL #include /* Perl's one, needed since 5.6 */ #endif #if (PATCHLEVEL <= 6) #if defined(USE_ITHREADS) #define STORE_HASH_SORT \ ENTER; { \ PerlInterpreter *orig_perl = PERL_GET_CONTEXT; \ SAVESPTR(orig_perl); \ PERL_SET_CONTEXT(aTHX); \ qsort((char *) AvARRAY(av), len, sizeof(SV *), sortcmp); \ } LEAVE; #else /* ! USE_ITHREADS */ #define STORE_HASH_SORT \ qsort((char *) AvARRAY(av), len, sizeof(SV *), sortcmp); #endif /* USE_ITHREADS */ #else /* PATCHLEVEL > 6 */ #define STORE_HASH_SORT \ sortsv(AvARRAY(av), len, Perl_sv_cmp); #endif /* PATCHLEVEL <= 6 */ #if (PATCHLEVEL <= 6) /* * sortcmp * * Sort two SVs * Borrowed from perl source file pp_ctl.c, where it is used by pp_sort. */ static int sortcmp(const void *a, const void *b) { #if defined(USE_ITHREADS) dTHX; #endif /* USE_ITHREADS */ return sv_cmp(*(SV * const *) a, *(SV * const *) b); } #endif /* PATCHLEVEL <= 6 */ YAML-Syck-1.31/Syck.xs0000644000000000000000000000117713364413554013110 0ustar rootroot/* #define YAML_IS_JSON 1 */ #include "perl_common.h" #define YAML_IS_JSON 1 #include "perl_syck.h" #undef YAML_IS_JSON #include "perl_syck.h" typedef PerlIO * OutputStream; MODULE = YAML::Syck PACKAGE = YAML::Syck PROTOTYPES: DISABLE SV * LoadYAML (s) char * s SV * DumpYAML (sv) SV * sv int DumpYAMLInto (in, out) SV * in SV * out int DumpYAMLFile (in, out) SV * in OutputStream out SV * LoadJSON (s) char * s SV * DumpJSON (sv) SV * sv int DumpJSONInto (in, out) SV * in SV * out int DumpJSONFile (in, out) SV * in OutputStream out YAML-Syck-1.31/syck.h0000644000000000000000000003123213364413554012740 0ustar rootroot#include "config.h" #ifdef I_STDLIB #define HAVE_STDLIB_H #endif #ifdef I_STRING #define HAVE_STRING_H #endif /* * syck.h * * $Author: why $ * $Date: 2005-11-14 07:43:56 +0800 (一, 14 11 2005) $ * * Copyright (C) 2003 why the lucky stiff */ #ifndef SYCK_H #define SYCK_H #define SYCK_YAML_MAJOR 1 #define SYCK_YAML_MINOR 0 #define SYCK_VERSION "0.61" #define YAML_DOMAIN "yaml.org,2002" #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_STRING_H # include #else # include #endif #ifdef HAVE_INTRINSICS_H # include #endif #include #include #include #include #ifdef HAVE_ST_H #include #else #include "syck_st.h" #endif #if defined(__cplusplus) extern "C" { #endif /* * Memory Allocation */ #if defined(HAVE_ALLOCA_H) && !defined(__GNUC__) #include #endif #if DEBUG void syck_assert( char *, unsigned ); # define ASSERT(f) \ if ( f ) \ {} \ else \ syck_assert( __FILE__, __LINE__ ) #else # define ASSERT(f) #endif #ifndef NULL # define NULL (void *)0 #endif #define ALLOC_CT 8 #define SYCK_BUFFERSIZE 4096 #define S_ALLOC_N(type,n) (type*)malloc(sizeof(type)*(n)) #define S_ALLOC(type) (type*)malloc(sizeof(type)) #define S_REALLOC_N(var,type,n) (var)=(type*)realloc((char*)(var),sizeof(type)*(n)) #define S_FREE(n) free(n); n = NULL; #define S_ALLOCA_N(type,n) (type*)alloca(sizeof(type)*(n)) #define S_MEMZERO(p,type,n) memset((p), 0, sizeof(type)*(n)) #define S_MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n)) #define S_MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(n)) #define S_MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(n)) #define BLOCK_FOLD 10 #define BLOCK_LIT 20 #define BLOCK_PLAIN 30 #define NL_CHOMP 40 #define NL_KEEP 50 #define EMITTER_MARK_NODE_FLAG_PERMIT_DUPLICATE_NODES 1 /* * Node definitions */ #ifndef ST_DATA_T_DEFINED typedef uintptr_t st_data_t; #endif #define SYMID uintptr_t typedef struct _syck_node SyckNode; enum syck_kind_tag { syck_map_kind, syck_seq_kind, syck_str_kind }; enum map_part { map_key, map_value }; enum map_style { map_none, map_inline }; enum seq_style { seq_none, seq_inline }; enum scalar_style { scalar_none, scalar_1quote, scalar_2quote, scalar_fold, scalar_literal, scalar_plain, scalar_2quote_1 /* Added by Audrey Tang to support JSON's single quoting */ }; /* * Node metadata struct */ struct _syck_node { /* Symbol table ID */ SYMID id; /* Underlying kind */ enum syck_kind_tag kind; /* Fully qualified tag-uri for type */ char *type_id; /* Anchor name */ char *anchor; union { /* Storage for map data */ struct SyckMap { enum map_style style; SYMID *keys; SYMID *values; long capa; long idx; } *pairs; /* Storage for sequence data */ struct SyckSeq { enum seq_style style; SYMID *items; long capa; long idx; } *list; /* Storage for string data */ struct SyckStr { enum scalar_style style; char *ptr; long len; } *str; } data; /* Shortcut node */ void *shortcut; }; /* * Parser definitions */ typedef struct _syck_parser SyckParser; typedef struct _syck_file SyckIoFile; typedef struct _syck_str SyckIoStr; typedef struct _syck_level SyckLevel; typedef SYMID (*SyckNodeHandler)(SyckParser *, SyckNode *); typedef void (*SyckErrorHandler)(SyckParser *, char *); typedef SyckNode * (*SyckBadAnchorHandler)(SyckParser *, char *); typedef long (*SyckIoFileRead)(char *, SyckIoFile *, long, long); typedef long (*SyckIoStrRead)(char *, SyckIoStr *, long, long); enum syck_io_type { syck_io_str, syck_io_file }; enum syck_parser_input { syck_yaml_utf8, syck_yaml_utf16, syck_yaml_utf32, syck_bytecode_utf8 }; enum syck_level_status { syck_lvl_header, syck_lvl_doc, syck_lvl_open, syck_lvl_seq, syck_lvl_map, syck_lvl_block, syck_lvl_str, syck_lvl_iseq, syck_lvl_imap, syck_lvl_end, syck_lvl_pause, syck_lvl_anctag, syck_lvl_mapx, syck_lvl_seqx }; /* * Parser structs */ struct _syck_file { /* File pointer */ FILE *ptr; /* Function which FILE -> buffer */ SyckIoFileRead read; }; struct _syck_str { /* String buffer pointers */ char *beg, *ptr, *end; /* Function which string -> buffer */ SyckIoStrRead read; }; struct _syck_level { /* Indent */ int spaces; /* Counts nodes emitted at this level, useful for parsing * keys and pairs in bytecode */ int ncount; /* Does node have anchors or tags? */ int anctag; /* Domain prefixing at the given level */ char *domain; /* Keeps a node status */ enum syck_level_status status; }; struct _syck_parser { /* Root node */ SYMID root, root_on_error; /* Implicit typing flag */ int implicit_typing, taguri_expansion; /* Scripting language function to handle nodes */ SyckNodeHandler handler; /* Error handler */ SyckErrorHandler error_handler; /* InvalidAnchor handler */ SyckBadAnchorHandler bad_anchor_handler; /* Parser input type */ enum syck_parser_input input_type; /* IO type */ enum syck_io_type io_type; /* Custom buffer size */ size_t bufsize; /* Buffer pointers */ char *buffer, *linectptr, *lineptr, *toktmp, *token, *cursor, *marker, *limit; /* Line counter */ int linect; /* Last token from yylex() */ int last_token; /* Force a token upon next call to yylex() */ int force_token; /* EOF flag */ int eof; union { SyckIoFile *file; SyckIoStr *str; } io; /* Symbol table for anchors */ st_table *anchors, *bad_anchors; /* Optional symbol table for SYMIDs */ st_table *syms; /* Levels of indentation */ SyckLevel *levels; int lvl_idx; int lvl_capa; /* Pointer for extension's use */ void *bonus; }; /* * Emitter definitions */ typedef struct _syck_emitter SyckEmitter; typedef struct _syck_emitter_node SyckEmitterNode; typedef void (*SyckOutputHandler)(SyckEmitter *, char *, long); typedef void (*SyckEmitterHandler)(SyckEmitter *, st_data_t); enum doc_stage { doc_open, doc_processing }; /* * Emitter struct */ struct _syck_emitter { /* Headerless doc flag */ int headless; /* Force header? */ int use_header; /* Force version? */ int use_version; /* Sort hash keys */ int sort_keys; /* Anchor format */ char *anchor_format; /* Explicit typing on all collections? */ int explicit_typing; /* Best width on folded scalars */ int best_width; /* Use literal[1] or folded[2] blocks on all text? */ enum scalar_style style; /* Stage of written document */ enum doc_stage stage; /* Level counter */ int level; /* Default indentation */ int indent; /* Object ignore ID */ SYMID ignore_id; /* Symbol table for anchors */ st_table *markers, *anchors, *anchored; /* Custom buffer size */ size_t bufsize; /* Buffer */ char *buffer, *marker; /* Absolute position of the buffer */ long bufpos; /* Handler for emitter nodes */ SyckEmitterHandler emitter_handler; /* Handler for output */ SyckOutputHandler output_handler; /* Levels of indentation */ SyckLevel *levels; int lvl_idx; int lvl_capa; int max_depth; int depth; /* Pointer for extension's use */ void *bonus; }; /* * Emitter node metadata struct */ struct _syck_emitter_node { /* Node buffer position */ long pos; /* Current indent */ long indent; /* Collection? */ int is_shortcut; }; /* * Handler prototypes */ SYMID syck_hdlr_add_node( SyckParser *, SyckNode * ); SyckNode *syck_hdlr_add_anchor( SyckParser *, char *, SyckNode * ); void syck_hdlr_remove_anchor( SyckParser *, char * ); SyckNode *syck_hdlr_get_anchor( SyckParser *, char * ); void syck_add_transfer( char *, SyckNode *, int ); char *syck_xprivate( char *, int ); char *syck_taguri( const char *, const char *, int ); int syck_tagcmp( const char *, const char * ); int syck_add_sym( SyckParser *, char * ); int syck_lookup_sym( SyckParser *, SYMID, char ** ); int syck_try_implicit( SyckNode * ); char *syck_type_id_to_uri( char * ); void try_tag_implicit( SyckNode *, int ); char *syck_match_implicit( char *, size_t ); /* * API prototypes */ char *syck_strndup( char *, long ); int syck_str_is_unquotable_integer(char*, long); long syck_io_file_read( char *, SyckIoFile *, long, long ); long syck_io_str_read( char *, SyckIoStr *, long, long ); char *syck_base64enc( char *, long ); char *syck_base64dec( char *, long, long * ); SyckEmitter *syck_new_emitter( void ); SYMID syck_emitter_mark_node( SyckEmitter *, st_data_t, int ); void syck_emitter_ignore_id( SyckEmitter *, SYMID ); void syck_output_handler( SyckEmitter *, SyckOutputHandler ); void syck_emitter_handler( SyckEmitter *, SyckEmitterHandler ); void syck_free_emitter( SyckEmitter * ); void syck_emitter_clear( SyckEmitter * ); void syck_emitter_write( SyckEmitter *, const char *, long ); void syck_emitter_escape( SyckEmitter *, unsigned char *, long ); void syck_emitter_flush( SyckEmitter *, long ); void syck_emit( SyckEmitter *, st_data_t ); void syck_emit_scalar( SyckEmitter *, char *, enum scalar_style, int, int, char, char *, long ); void syck_emit_1quoted( SyckEmitter *, int, char *, long ); void syck_emit_2quoted( SyckEmitter *, int, char *, long ); void syck_emit_2quoted_1( SyckEmitter *, int, char *, long ); void syck_emit_folded( SyckEmitter *, int, char, char *, long ); void syck_emit_literal( SyckEmitter *, char, char *, long ); void syck_emit_seq( SyckEmitter *, char *, enum seq_style ); void syck_emit_item( SyckEmitter *, st_data_t ); void syck_emit_map( SyckEmitter *, char *, enum map_style ); void syck_emit_end( SyckEmitter * ); void syck_emit_tag( SyckEmitter *, const char *, const char * ); void syck_emit_indent( SyckEmitter * ); SyckLevel *syck_emitter_current_level( SyckEmitter * ); SyckLevel *syck_emitter_parent_level( SyckEmitter * ); void syck_emitter_pop_level( SyckEmitter * ); void syck_emitter_add_level( SyckEmitter *, int, enum syck_level_status ); void syck_emitter_reset_levels( SyckEmitter * ); SyckParser *syck_new_parser(); void syck_free_parser( SyckParser * ); void syck_parser_set_root_on_error( SyckParser *, SYMID ); void syck_parser_implicit_typing( SyckParser *, int ); void syck_parser_taguri_expansion( SyckParser *, int ); int syck_scan_scalar( int, char *, long ); void syck_parser_handler( SyckParser *, SyckNodeHandler ); void syck_parser_error_handler( SyckParser *, SyckErrorHandler ); void syck_parser_bad_anchor_handler( SyckParser *, SyckBadAnchorHandler ); void syck_parser_file( SyckParser *, FILE *, SyckIoFileRead ); void syck_parser_str( SyckParser *, char *, long, SyckIoStrRead ); void syck_parser_str_auto( SyckParser *, char *, SyckIoStrRead ); SyckLevel *syck_parser_current_level( SyckParser * ); void syck_parser_add_level( SyckParser *, int, enum syck_level_status ); void syck_parser_pop_level( SyckParser * ); void free_any_io( SyckParser * ); long syck_parser_read( SyckParser * ); long syck_parser_readlen( SyckParser *, long ); SYMID syck_parse( SyckParser * ); void syck_default_error_handler( SyckParser *, char * ); SYMID syck_yaml2byte_handler( SyckParser *, SyckNode * ); char *syck_yaml2byte( char * ); /* * Allocation prototypes */ SyckNode *syck_alloc_map(); SyckNode *syck_alloc_seq(); SyckNode *syck_alloc_str(); void syck_free_node( SyckNode * ); void syck_free_members( SyckNode * ); SyckNode *syck_new_str( const char *, enum scalar_style ); SyckNode *syck_new_str2( const char *, long, enum scalar_style ); void syck_replace_str( SyckNode *, char *, enum scalar_style ); void syck_replace_str2( SyckNode *, char *, long, enum scalar_style ); void syck_str_blow_away_commas( SyckNode * ); char *syck_str_read( SyckNode * ); SyckNode *syck_new_map( SYMID, SYMID ); void syck_map_empty( SyckNode * ); void syck_map_add( SyckNode *, SYMID, SYMID ); SYMID syck_map_read( SyckNode *, enum map_part, long ); void syck_map_assign( SyckNode *, enum map_part, long, SYMID ); long syck_map_count( SyckNode * ); void syck_map_update( SyckNode *, SyckNode * ); SyckNode *syck_new_seq( SYMID ); void syck_seq_empty( SyckNode * ); void syck_seq_add( SyckNode *, SYMID ); void syck_seq_assign( SyckNode *, long, SYMID ); SYMID syck_seq_read( SyckNode *, long ); long syck_seq_count( SyckNode * ); /* * Lexer prototypes */ void syckerror( char * ); int syckparse( void * ); #if defined(__cplusplus) } /* extern "C" { */ #endif #endif /* ifndef SYCK_H */ YAML-Syck-1.31/META.yml0000644000000000000000000000136013364413554013066 0ustar rootroot--- abstract: 'Fast, lightweight YAML loader and dumper' author: - 'Todd Rinaldo ' build_requires: Test::More: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010' license: mit meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: YAML-Syck no_index: directory: - t - inc requires: perl: '5.006' resources: bugtracker: https://github.com/toddr/YAML-Syck/issues homepage: http://github.com/toddr/YAML-Syck license: http://dev.perl.org/licenses/ repository: http://github.com/toddr/YAML-Syck version: '1.31' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' YAML-Syck-1.31/node.c0000644000000000000000000001677213364413554012723 0ustar rootroot/* * node.c * * $Author: why $ * $Date: 2005-09-17 02:59:53 +0800 (六, 17 9 2005) $ * * Copyright (C) 2003 why the lucky stiff */ #include "syck.h" /* * Node allocation functions */ SyckNode * syck_alloc_node( enum syck_kind_tag type ) { SyckNode *s; s = S_ALLOC( SyckNode ); s->kind = type; s->id = 0; s->type_id = NULL; s->anchor = NULL; s->shortcut = NULL; return s; } void syck_free_node( SyckNode *n ) { syck_free_members( n ); if ( n->type_id != NULL ) { S_FREE( n->type_id ); n->type_id = NULL; } if ( n->anchor != NULL ) { S_FREE( n->anchor ); n->anchor = NULL; } S_FREE( n ); } SyckNode * syck_alloc_map() { SyckNode *n; struct SyckMap *m; m = S_ALLOC( struct SyckMap ); m->style = map_none; m->idx = 0; m->capa = ALLOC_CT; m->keys = S_ALLOC_N( SYMID, m->capa ); m->values = S_ALLOC_N( SYMID, m->capa ); n = syck_alloc_node( syck_map_kind ); n->data.pairs = m; return n; } SyckNode * syck_alloc_seq() { SyckNode *n; struct SyckSeq *s; s = S_ALLOC( struct SyckSeq ); s->style = seq_none; s->idx = 0; s->capa = ALLOC_CT; s->items = S_ALLOC_N( SYMID, s->capa ); n = syck_alloc_node( syck_seq_kind ); n->data.list = s; return n; } SyckNode * syck_alloc_str() { SyckNode *n; struct SyckStr *s; s = S_ALLOC( struct SyckStr ); s->len = 0; s->ptr = NULL; s->style = scalar_none; n = syck_alloc_node( syck_str_kind ); n->data.str = s; return n; } SyckNode * syck_new_str( const char *str, enum scalar_style style ) { return syck_new_str2( str, strlen( str ), style ); } SyckNode * syck_new_str2( const char *str, long len, enum scalar_style style ) { SyckNode *n; n = syck_alloc_str(); n->data.str->ptr = S_ALLOC_N( char, len + 1 ); n->data.str->len = len; n->data.str->style = style; memcpy( n->data.str->ptr, str, len ); n->data.str->ptr[len] = '\0'; return n; } void syck_replace_str( SyckNode *n, char *str, enum scalar_style style ) { syck_replace_str2( n, str, strlen( str ), style ); } void syck_replace_str2( SyckNode *n, char *str, long len, enum scalar_style style ) { if ( n->data.str != NULL ) { S_FREE( n->data.str->ptr ); n->data.str->ptr = NULL; n->data.str->len = 0; } n->data.str->ptr = S_ALLOC_N( char, len + 1 ); n->data.str->len = len; n->data.str->style = style; memcpy( n->data.str->ptr, str, len ); n->data.str->ptr[len] = '\0'; } void syck_str_blow_away_commas( SyckNode *n ) { char *go, *end; go = n->data.str->ptr; end = go + n->data.str->len; while ( *(++go) != '\0' ) { if ( *go == ',' ) { n->data.str->len -= 1; memmove( go, go + 1, end - go ); end -= 1; } } } char * syck_str_read( SyckNode *n ) { ASSERT( n != NULL ); return n->data.str->ptr; } SyckNode * syck_new_map( SYMID key, SYMID value ) { SyckNode *n; n = syck_alloc_map(); syck_map_add( n, key, value ); return n; } void syck_map_empty( SyckNode *n ) { struct SyckMap *m; ASSERT( n != NULL ); ASSERT( n->data.list != NULL ); S_FREE( n->data.pairs->keys ); S_FREE( n->data.pairs->values ); m = n->data.pairs; m->idx = 0; m->capa = ALLOC_CT; m->keys = S_ALLOC_N( SYMID, m->capa ); m->values = S_ALLOC_N( SYMID, m->capa ); } void syck_map_add( SyckNode *map, SYMID key, SYMID value ) { struct SyckMap *m; long idx; ASSERT( map != NULL ); ASSERT( map->data.pairs != NULL ); m = map->data.pairs; idx = m->idx; m->idx += 1; if ( m->idx > m->capa ) { m->capa += ALLOC_CT; S_REALLOC_N( m->keys, SYMID, m->capa ); S_REALLOC_N( m->values, SYMID, m->capa ); } m->keys[idx] = key; m->values[idx] = value; } void syck_map_update( SyckNode *map1, SyckNode *map2 ) { struct SyckMap *m1, *m2; long new_idx, new_capa; ASSERT( map1 != NULL ); ASSERT( map2 != NULL ); m1 = map1->data.pairs; m2 = map2->data.pairs; if ( m2->idx < 1 ) return; new_idx = m1->idx; new_idx += m2->idx; new_capa = m1->capa; while ( new_idx > new_capa ) { new_capa += ALLOC_CT; } if ( new_capa > m1->capa ) { m1->capa = new_capa; S_REALLOC_N( m1->keys, SYMID, m1->capa ); S_REALLOC_N( m1->values, SYMID, m1->capa ); } for ( new_idx = 0; new_idx < m2->idx; m1->idx++, new_idx++ ) { m1->keys[m1->idx] = m2->keys[new_idx]; m1->values[m1->idx] = m2->values[new_idx]; } } long syck_map_count( SyckNode *map ) { ASSERT( map != NULL ); ASSERT( map->data.pairs != NULL ); return map->data.pairs->idx; } void syck_map_assign( SyckNode *map, enum map_part p, long idx, SYMID id ) { struct SyckMap *m; ASSERT( map != NULL ); m = map->data.pairs; ASSERT( m != NULL ); if ( p == map_key ) { m->keys[idx] = id; } else { m->values[idx] = id; } } SYMID syck_map_read( SyckNode *map, enum map_part p, long idx ) { struct SyckMap *m; ASSERT( map != NULL ); m = map->data.pairs; ASSERT( m != NULL ); if ( p == map_key ) { return m->keys[idx]; } else { return m->values[idx]; } } SyckNode * syck_new_seq( SYMID value ) { SyckNode *n; n = syck_alloc_seq(); syck_seq_add( n, value ); return n; } void syck_seq_empty( SyckNode *n ) { struct SyckSeq *s; ASSERT( n != NULL ); ASSERT( n->data.list != NULL ); S_FREE( n->data.list->items ); s = n->data.list; s->idx = 0; s->capa = ALLOC_CT; s->items = S_ALLOC_N( SYMID, s->capa ); } void syck_seq_add( SyckNode *arr, SYMID value ) { struct SyckSeq *s; long idx; ASSERT( arr != NULL ); ASSERT( arr->data.list != NULL ); s = arr->data.list; idx = s->idx; s->idx += 1; if ( s->idx > s->capa ) { s->capa += ALLOC_CT; S_REALLOC_N( s->items, SYMID, s->capa ); } s->items[idx] = value; } long syck_seq_count( SyckNode *seq ) { ASSERT( seq != NULL ); ASSERT( seq->data.list != NULL ); return seq->data.list->idx; } void syck_seq_assign( SyckNode *seq, long idx, SYMID id ) { struct SyckSeq *s; ASSERT( map != NULL ); s = seq->data.list; ASSERT( m != NULL ); s->items[idx] = id; } SYMID syck_seq_read( SyckNode *seq, long idx ) { struct SyckSeq *s; ASSERT( seq != NULL ); s = seq->data.list; ASSERT( s != NULL ); return s->items[idx]; } void syck_free_members( SyckNode *n ) { if ( n == NULL ) return; switch ( n->kind ) { case syck_str_kind: if ( n->data.str != NULL ) { S_FREE( n->data.str->ptr ); n->data.str->ptr = NULL; n->data.str->len = 0; S_FREE( n->data.str ); n->data.str = NULL; } break; case syck_seq_kind: if ( n->data.list != NULL ) { S_FREE( n->data.list->items ); S_FREE( n->data.list ); n->data.list = NULL; } break; case syck_map_kind: if ( n->data.pairs != NULL ) { S_FREE( n->data.pairs->keys ); S_FREE( n->data.pairs->values ); S_FREE( n->data.pairs ); n->data.pairs = NULL; } break; } } YAML-Syck-1.31/emitter.c0000644000000000000000000011534013364413554013436 0ustar rootroot/* * emitter.c * * $Author: why $ * $Date: 2006-05-09 12:03:50 +0800 (二, 09 5 2006) $ * * Copyright (C) 2003 why the lucky stiff * * All Base64 code from Ruby's pack.c. * Ruby is Copyright (C) 1993-2003 Yukihiro Matsumoto */ #include #include #include "syck.h" #define DEFAULT_ANCHOR_FORMAT "id%03d" const unsigned char hex_table[] = "0123456789ABCDEF"; static unsigned char b64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /* * Built-in base64 (from Ruby's pack.c) */ char * syck_base64enc( char *s, long len ) { long i = 0; int padding = '='; char *buff = S_ALLOC_N(char, len * 4 / 3 + 6); while (len >= 3) { buff[i++] = b64_table[077 & (*s >> 2)]; buff[i++] = b64_table[077 & (((*s << 4) & 060) | ((s[1] >> 4) & 017))]; buff[i++] = b64_table[077 & (((s[1] << 2) & 074) | ((s[2] >> 6) & 03))]; buff[i++] = b64_table[077 & s[2]]; s += 3; len -= 3; } if (len == 2) { buff[i++] = b64_table[077 & (*s >> 2)]; buff[i++] = b64_table[077 & (((*s << 4) & 060) | ((s[1] >> 4) & 017))]; buff[i++] = b64_table[077 & (((s[1] << 2) & 074) | (('\0' >> 6) & 03))]; buff[i++] = padding; } else if (len == 1) { buff[i++] = b64_table[077 & (*s >> 2)]; buff[i++] = b64_table[077 & (((*s << 4) & 060) | (('\0' >> 4) & 017))]; buff[i++] = padding; buff[i++] = padding; } /* XXX - Changed by Audrey Tang to terminate the string instead of adding an useless \n */ buff[i++] = '\0'; return buff; } /* XXX - Changed by Audrey Tang to deal with \0 in decoded base64 buffers */ char * syck_base64dec( char *s, long len, long *out_len ) { int a = -1,b = -1,c = 0,d; static int first = 1; static int b64_xtable[256]; char *ptr = syck_strndup( s, len ); char *end = ptr; char *send = s + len; if (first) { int i; first = 0; for (i = 0; i < 256; i++) { b64_xtable[i] = -1; } for (i = 0; i < 64; i++) { b64_xtable[(int)b64_table[i]] = i; } } while (s < send) { while (s[0] == '\r' || s[0] == '\n') { s++; } if ((a = b64_xtable[(int)s[0]]) == -1) break; if ((b = b64_xtable[(int)s[1]]) == -1) break; if ((c = b64_xtable[(int)s[2]]) == -1) break; if ((d = b64_xtable[(int)s[3]]) == -1) break; *end++ = a << 2 | b >> 4; *end++ = b << 4 | c >> 2; *end++ = c << 6 | d; s += 4; } if (a != -1 && b != -1) { if (s + 2 < send && s[2] == '=') *end++ = a << 2 | b >> 4; if (c != -1 && s + 3 < send && s[3] == '=') { *end++ = a << 2 | b >> 4; *end++ = b << 4 | c >> 2; } } *end = '\0'; /*RSTRING(buf)->len = ptr - RSTRING(buf)->ptr;*/ *out_len = end - ptr; return ptr; } /* * Allocate an emitter */ SyckEmitter * syck_new_emitter() { SyckEmitter *e; e = S_ALLOC( SyckEmitter ); e->headless = 0; e->use_header = 0; e->use_version = 0; e->sort_keys = 0; e->anchor_format = NULL; e->explicit_typing = 0; e->best_width = 80; e->style = scalar_none; e->stage = doc_open; e->depth = 0; e->max_depth = 512; e->indent = 2; e->level = -1; e->anchors = NULL; e->markers = NULL; e->anchored = NULL; e->bufsize = SYCK_BUFFERSIZE; e->buffer = NULL; e->marker = NULL; e->bufpos = 0; e->emitter_handler = NULL; e->output_handler = NULL; e->lvl_idx = 0; e->lvl_capa = ALLOC_CT; e->levels = S_ALLOC_N( SyckLevel, e->lvl_capa ); syck_emitter_reset_levels( e ); e->bonus = NULL; return e; } int syck_st_free_anchors( char *key, char *name, char *arg ) { S_FREE( name ); return ST_CONTINUE; } void syck_emitter_st_free( SyckEmitter *e ) { /* * Free the anchor tables */ if ( e->anchors != NULL ) { st_foreach( e->anchors, syck_st_free_anchors, 0 ); st_free_table( e->anchors ); e->anchors = NULL; } if ( e->anchored != NULL ) { st_free_table( e->anchored ); e->anchored = NULL; } /* * Free the markers tables */ if ( e->markers != NULL ) { st_free_table( e->markers ); e->markers = NULL; } } SyckLevel * syck_emitter_current_level( SyckEmitter *e ) { return &e->levels[e->lvl_idx-1]; } SyckLevel * syck_emitter_parent_level( SyckEmitter *e ) { return &e->levels[e->lvl_idx-2]; } void syck_emitter_pop_level( SyckEmitter *e ) { ASSERT( e != NULL ); /* The root level should never be popped */ if ( e->lvl_idx <= 1 ) return; e->lvl_idx -= 1; free( e->levels[e->lvl_idx].domain ); } void syck_emitter_add_level( SyckEmitter *e, int len, enum syck_level_status status ) { ASSERT( e != NULL ); if ( e->lvl_idx + 1 > e->lvl_capa ) { e->lvl_capa += ALLOC_CT; S_REALLOC_N( e->levels, SyckLevel, e->lvl_capa ); } ASSERT( len > e->levels[e->lvl_idx-1].spaces ); e->levels[e->lvl_idx].spaces = len; e->levels[e->lvl_idx].ncount = 0; e->levels[e->lvl_idx].domain = syck_strndup( e->levels[e->lvl_idx-1].domain, strlen( e->levels[e->lvl_idx-1].domain ) ); e->levels[e->lvl_idx].status = status; e->levels[e->lvl_idx].anctag = 0; e->lvl_idx += 1; } void syck_emitter_reset_levels( SyckEmitter *e ) { while ( e->lvl_idx > 1 ) { syck_emitter_pop_level( e ); } if ( e->lvl_idx < 1 ) { e->lvl_idx = 1; e->levels[0].spaces = -1; e->levels[0].ncount = 0; e->levels[0].domain = syck_strndup( "", 0 ); e->levels[0].anctag = 0; } e->levels[0].status = syck_lvl_header; } void syck_emitter_handler( SyckEmitter *e, SyckEmitterHandler hdlr ) { e->emitter_handler = hdlr; } void syck_output_handler( SyckEmitter *e, SyckOutputHandler hdlr ) { e->output_handler = hdlr; } void syck_free_emitter( SyckEmitter *e ) { /* * Free tables */ syck_emitter_st_free( e ); syck_emitter_reset_levels( e ); S_FREE( e->levels[0].domain ); S_FREE( e->levels ); if ( e->buffer != NULL ) { S_FREE( e->buffer ); } S_FREE( e ); } void syck_emitter_clear( SyckEmitter *e ) { if ( e->buffer == NULL ) { e->buffer = S_ALLOC_N( char, e->bufsize ); S_MEMZERO( e->buffer, char, e->bufsize ); } e->buffer[0] = '\0'; e->marker = e->buffer; e->bufpos = 0; } /* * Raw write to the emitter buffer. */ void syck_emitter_write( SyckEmitter *e, const char *str, long len ) { long at; ASSERT( str != NULL ) if ( e->buffer == NULL ) { syck_emitter_clear( e ); } /* * Flush if at end of buffer */ at = e->marker - e->buffer; if ( len + at >= e->bufsize ) { syck_emitter_flush( e, 0 ); for (;;) { long rest = e->bufsize - (e->marker - e->buffer); if (len <= rest) break; S_MEMCPY( e->marker, str, char, rest ); e->marker += rest; str += rest; len -= rest; syck_emitter_flush( e, 0 ); } } /* * Write to buffer */ S_MEMCPY( e->marker, str, char, len ); e->marker += len; } /* * Write a chunk of data out. */ void syck_emitter_flush( SyckEmitter *e, long check_room ) { /* * Check for enough space in the buffer for check_room length. */ if ( check_room > 0 ) { if ( e->bufsize > ( e->marker - e->buffer ) + check_room ) { return; } } else { check_room = e->bufsize; } /* * Commit buffer. */ if ( check_room > e->marker - e->buffer ) { check_room = e->marker - e->buffer; } (e->output_handler)( e, e->buffer, check_room ); e->bufpos += check_room; e->marker -= check_room; } /* * Start emitting from the given node, check for anchoring and then * issue the callback to the emitter handler. */ void syck_emit( SyckEmitter *e, st_data_t n ) { SYMID oid; char *anchor_name = NULL; int indent = 0; SyckLevel *parent; SyckLevel *lvl = syck_emitter_current_level( e ); /* * Determine headers. */ if ( e->stage == doc_open && ( e->headless == 0 || e->use_header == 1 ) ) { if ( e->use_version == 1 ) { char *header = S_ALLOC_N( char, 64 ); S_MEMZERO( header, char, 64 ); sprintf( header, "--- %%YAML:%d.%d ", SYCK_YAML_MAJOR, SYCK_YAML_MINOR ); syck_emitter_write( e, header, strlen( header ) ); S_FREE( header ); } else { syck_emitter_write( e, "--- ", 4 ); } e->stage = doc_processing; } /* Add new level */ if ( lvl->spaces >= 0 ) { indent = lvl->spaces + e->indent; } syck_emitter_add_level( e, indent, syck_lvl_open ); parent = lvl; lvl = syck_emitter_current_level( e ); /* Look for anchor */ if ( e->anchors != NULL && st_lookup( e->markers, n, (st_data_t *)&oid ) && st_lookup( e->anchors, (st_data_t)oid, (st_data_t *)&anchor_name ) ) { if ( e->anchored == NULL ) { e->anchored = st_init_numtable(); } if ( ! st_lookup( e->anchored, (st_data_t)anchor_name, 0 ) ) { char *an = S_ALLOC_N( char, strlen( anchor_name ) + 3 ); sprintf( an, "&%s ", anchor_name ); /* Complex key */ if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1) { syck_emitter_write( e, "? ", 2 ); parent->status = syck_lvl_mapx; } syck_emitter_write( e, an, strlen( anchor_name ) + 2 ); free( an ); st_insert( e->anchored, (st_data_t)anchor_name, 0 ); lvl->anctag = 1; } else { char *an = S_ALLOC_N( char, strlen( anchor_name ) + 2 ); sprintf( an, "*%s", anchor_name ); syck_emitter_write( e, an, strlen( anchor_name ) + 1 ); free( an ); goto end_emit; } } (e->emitter_handler)( e, n ); /* Pop the level */ end_emit: syck_emitter_pop_level( e ); if ( e->lvl_idx == 1 ) { syck_emitter_write( e, "\n", 1 ); e->headless = 0; e->stage = doc_open; } } /* * Determine what tag needs to be written, based on the taguri of the node * and the implicit tag which would be assigned to this node. If a tag is * required, write the tag. */ void syck_emit_tag( SyckEmitter *e, const char *tag, const char *ignore ) { SyckLevel *lvl; if ( tag == NULL ) return; if ( ignore != NULL && syck_tagcmp( tag, ignore ) == 0 && e->explicit_typing == 0 ) return; lvl = syck_emitter_current_level( e ); /* implicit */ if ( strlen( tag ) == 0 ) { syck_emitter_write( e, "! ", 2 ); /* global types */ } else if ( strncmp( tag, "tag:", 4 ) == 0 ) { int taglen = strlen( tag ); syck_emitter_write( e, "!", 1 ); if ( strncmp( tag + 4, YAML_DOMAIN, strlen( YAML_DOMAIN ) ) == 0 ) { int skip = 4 + strlen( YAML_DOMAIN ) + 1; syck_emitter_write( e, tag + skip, taglen - skip ); } else { const char *subd = tag + 4; while ( *subd != ':' && *subd != '\0' ) subd++; if ( *subd == ':' ) { if ( subd - tag > ( strlen( YAML_DOMAIN ) + 5 ) && strncmp( subd - strlen( YAML_DOMAIN ), YAML_DOMAIN, strlen( YAML_DOMAIN ) ) == 0 ) { syck_emitter_write( e, tag + 4, subd - strlen( YAML_DOMAIN ) - ( tag + 4 ) - 1 ); syck_emitter_write( e, "/", 1 ); syck_emitter_write( e, subd + 1, ( tag + taglen ) - ( subd + 1 ) ); } else { syck_emitter_write( e, tag + 4, subd - ( tag + 4 ) ); syck_emitter_write( e, "/", 1 ); syck_emitter_write( e, subd + 1, ( tag + taglen ) - ( subd + 1 ) ); } } else { /* TODO: Invalid tag (no colon after domain) */ return; } } syck_emitter_write( e, " ", 1 ); /* private types */ } else if ( strncmp( tag, "x-private:", 10 ) == 0 ) { syck_emitter_write( e, "!!", 2 ); syck_emitter_write( e, tag + 10, strlen( tag ) - 10 ); syck_emitter_write( e, " ", 1 ); } lvl->anctag = 1; } /* * Emit a newline and an appropriately spaced indent. */ void syck_emit_indent( SyckEmitter *e ) { int i; SyckLevel *lvl = syck_emitter_current_level( e ); if ( e->bufpos == 0 && ( e->marker - e->buffer ) == 0 ) return; if ( lvl->spaces >= 0 ) { char *spcs = S_ALLOC_N( char, lvl->spaces + 2 ); spcs[0] = '\n'; spcs[lvl->spaces + 1] = '\0'; for ( i = 0; i < lvl->spaces; i++ ) spcs[i+1] = ' '; syck_emitter_write( e, spcs, lvl->spaces + 1 ); free( spcs ); } } /* Clear the scan */ #define SCAN_NONE 0 /* All printable characters? */ #define SCAN_NONPRINT 1 /* Any indented lines? */ #define SCAN_INDENTED 2 /* Larger than the requested width? */ #define SCAN_WIDE 4 /* Opens or closes with whitespace? */ #define SCAN_WHITEEDGE 8 /* Contains a newline */ #define SCAN_NEWLINE 16 /* Contains a single quote */ #define SCAN_SINGLEQ 32 /* Contains a double quote */ #define SCAN_DOUBLEQ 64 /* Starts with a token */ #define SCAN_INDIC_S 128 /* Contains a flow indicator */ #define SCAN_INDIC_C 256 /* Ends without newlines */ #define SCAN_NONL_E 512 /* Ends with many newlines */ #define SCAN_MANYNL_E 1024 /* Contains flow map indicators */ #define SCAN_FLOWMAP 2048 /* Contains flow seq indicators */ #define SCAN_FLOWSEQ 4096 /* Contains a valid doc separator */ #define SCAN_DOCSEP 8192 /* * Basic printable test for LATIN-1 characters. */ int syck_scan_scalar( int req_width, char *cursor, long len ) { long i = 0, start = 0; int flags = SCAN_NONE; if ( len < 1 ) return flags; /* c-indicators from the spec */ if ( cursor[0] == '[' || cursor[0] == ']' || cursor[0] == '{' || cursor[0] == '}' || cursor[0] == '!' || cursor[0] == '*' || cursor[0] == '&' || cursor[0] == '|' || cursor[0] == '>' || cursor[0] == '\'' || cursor[0] == '"' || cursor[0] == '#' || cursor[0] == '%' || cursor[0] == '@' || cursor[0] == '`' || cursor[0] == '&' || cursor[0] == '^' ) { flags |= SCAN_INDIC_S; } if ( ( cursor[0] == '-' || cursor[0] == ':' || cursor[0] == '?' || cursor[0] == ',' ) && ( cursor[1] == ' ' || cursor[1] == '\n' || cursor[1] == '\r' || len == 1 ) ) { flags |= SCAN_INDIC_S; } /* whitespace edges */ if ( cursor[len-1] != '\n' ) { flags |= SCAN_NONL_E; } else if ( len > 1 && cursor[len-2] == '\n' ) { flags |= SCAN_MANYNL_E; } if ( ( len > 0 && ( cursor[0] == ' ' || cursor[0] == '\t' ) ) || ( len > 1 && ( cursor[len-1] == ' ' || cursor[len-1] == '\t' ) ) ) { flags |= SCAN_WHITEEDGE; } /* opening doc sep */ if ( len >= 3 && strncmp( cursor, "---", 3 ) == 0 ) flags |= SCAN_DOCSEP; /* scan string */ for ( i = 0; i < len; i++ ) { if ( ! ( (unsigned char)cursor[i] == 0x9 || (unsigned char)cursor[i] == 0xA || (unsigned char)cursor[i] == 0xD || ( (unsigned char)cursor[i] >= 0x20 && (unsigned char)cursor[i] <= 0x7E ) || (unsigned char)cursor[i] >= 0x80 ) ) { flags |= SCAN_NONPRINT; } else if ( cursor[i] == '\n' ) { flags |= SCAN_NEWLINE; if ( len - i >= 3 && strncmp( &cursor[i+1], "---", 3 ) == 0 ) flags |= SCAN_DOCSEP; if ( cursor[i+1] == ' ' || cursor[i+1] == '\t' ) flags |= SCAN_INDENTED; if ( req_width > 0 && i - start > req_width ) flags |= SCAN_WIDE; start = i; } else if ( cursor[i] == '\'' ) { flags |= SCAN_SINGLEQ; } else if ( cursor[i] == '"' ) { flags |= SCAN_DOUBLEQ; } else if ( cursor[i] == ']' ) { flags |= SCAN_FLOWSEQ; } else if ( cursor[i] == '}' ) { flags |= SCAN_FLOWMAP; } /* remember, if plain collections get implemented, to add nb-plain-flow-char */ else if ( ( cursor[i] == ' ' && cursor[i+1] == '#' ) || ( cursor[i] == ':' && ( cursor[i+1] == ' ' || cursor[i+1] == '\n' || i == len - 1 ) ) ) { flags |= SCAN_INDIC_C; } else if ( cursor[i] == ',' && ( cursor[i+1] == ' ' || cursor[i+1] == '\n' || i == len - 1 ) ) { flags |= SCAN_FLOWMAP; flags |= SCAN_FLOWSEQ; } } /* printf( "---STR---\n%s\nFLAGS: %d\n", cursor, flags ); */ return flags; } /* * All scalars should be emitted through this function, which determines an appropriate style, * tag and indent. */ void syck_emit_scalar( SyckEmitter *e, char *tag, enum scalar_style force_style, int force_indent, int force_width, char keep_nl, char *str, long len ) { enum scalar_style favor_style = scalar_literal; SyckLevel *parent = syck_emitter_parent_level( e ); SyckLevel *lvl = syck_emitter_current_level( e ); int scan = 0; char *implicit; if ( str == NULL ) str = ""; /* No empty nulls as map keys */ if ( len == 0 && ( parent->status == syck_lvl_map || parent->status == syck_lvl_imap ) && parent->ncount % 2 == 1 && syck_tagcmp( tag, "tag:yaml.org,2002:null" ) == 0 ) { str = "~"; len = 1; } scan = syck_scan_scalar( force_width, str, len ); implicit = syck_match_implicit( str, len ); /* quote strings which default to implicits */ if ( ( (strncmp( implicit, "bool", 4 ) == 0) || (strncmp( implicit, "null", 4 ) == 0) ) && (force_style != scalar_plain) && (len > 0) ) { force_style = (force_style == scalar_2quote) ? scalar_2quote : scalar_1quote; } else { /* complex key -- disabled by Audrey Tang -/ if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1 && ( !( tag == NULL || ( implicit != NULL && syck_tagcmp( tag, implicit ) == 0 && e->explicit_typing == 0 ) ) ) ) { syck_emitter_write( e, "? ", 2 ); parent->status = syck_lvl_mapx; } */ syck_emit_tag( e, tag, implicit ); } /* if still arbitrary, sniff a good block style. */ if ( force_style == scalar_none ) { if ( scan & SCAN_NEWLINE ) { force_style = scalar_literal; } else { force_style = scalar_plain; } } if ( e->style == scalar_fold ) { favor_style = scalar_fold; } /* Determine block style */ if ( scan & SCAN_NONPRINT ) { force_style = scalar_2quote; } else if ( force_style != scalar_1quote && force_style != scalar_2quote_1 && ( scan & SCAN_WHITEEDGE ) ) { force_style = scalar_2quote; } else if ( force_style != scalar_fold && ( scan & SCAN_INDENTED ) ) { force_style = scalar_literal; } else if ( force_style == scalar_plain && ( scan & SCAN_NEWLINE ) ) { force_style = favor_style; } else if ( force_style == scalar_plain && parent->status == syck_lvl_iseq && ( scan & SCAN_FLOWSEQ ) ) { force_style = scalar_2quote; } else if ( force_style == scalar_plain && parent->status == syck_lvl_imap && ( scan & SCAN_FLOWMAP ) ) { force_style = scalar_2quote; /* } else if ( force_style == scalar_fold && ( ! ( scan & SCAN_WIDE ) ) ) { force_style = scalar_literal; */ } else if ( force_style == scalar_plain && ( scan & SCAN_INDIC_S || scan & SCAN_INDIC_C ) ) { if ( scan & SCAN_NEWLINE ) { force_style = favor_style; } else { force_style = scalar_2quote; } } if ( force_indent > 0 ) { lvl->spaces = parent->spaces + force_indent; } else if ( scan & SCAN_DOCSEP ) { lvl->spaces = parent->spaces + e->indent; } /* For now, all ambiguous keys are going to be double-quoted */ if ( ( parent->status == syck_lvl_map || parent->status == syck_lvl_mapx ) && parent->ncount % 2 == 1 ) { if ( force_style != scalar_plain ) { force_style = scalar_2quote; } } /* If the parent is an inline, double quote anything complex */ if ( parent->status == syck_lvl_imap || parent->status == syck_lvl_iseq ) { if ( force_style != scalar_plain && force_style != scalar_1quote && force_style != scalar_2quote_1) { force_style = scalar_2quote; } } /* Fix the ending newlines */ if ( scan & SCAN_NONL_E ) { keep_nl = NL_CHOMP; } else if ( scan & SCAN_MANYNL_E ) { keep_nl = NL_KEEP; } /* A key/value like C will be interpreted as ":bar" by Perl, but * Ruby will treat it as the symbol :bar. For compatability with Ruby emit * these with quotes. */ if ( force_style == scalar_plain && strncmp( implicit, "str", 4 ) == 0 && str[0] == ':' ) { force_style = scalar_literal; } /* Write the text node */ switch ( force_style ) { case scalar_1quote: syck_emit_1quoted( e, force_width, str, len ); break; case scalar_none: case scalar_2quote: syck_emit_2quoted( e, force_width, str, len ); break; case scalar_fold: syck_emit_folded( e, force_width, keep_nl, str, len ); break; case scalar_2quote_1: syck_emit_2quoted_1( e, force_width, str, len ); break; case scalar_literal: /* syck_emit_literal( e, keep_nl, str, len ); */ syck_emit_2quoted( e, force_width, str, len ); break; case scalar_plain: syck_emitter_write( e, str, len ); break; } if ( parent->status == syck_lvl_mapx ) { syck_emitter_write( e, "\n", 1 ); } } void syck_emitter_escape( SyckEmitter *e, unsigned char *src, long len ) { int i; for( i = 0; i < len; i++ ) { /* XXX - scalar_fold overloaded to mean utf8 from Audrey Tang */ if( (e->style == scalar_fold) ? ((src[i] < 0x20) && (0 < src[i])) : ((src[i] < 0x20) || (0x7E < src[i])) ) { syck_emitter_write( e, "\\", 1 ); if( '\0' == src[i] ) syck_emitter_write( e, "0", 1 ); else { syck_emitter_write( e, "x", 1 ); syck_emitter_write( e, (char *)hex_table + ((src[i] & 0xF0) >> 4), 1 ); syck_emitter_write( e, (char *)hex_table + (src[i] & 0x0F), 1 ); } } else { syck_emitter_write( e, src + i, 1 ); if( '\\' == src[i] ) syck_emitter_write( e, "\\", 1 ); } } } /* * Outputs a single-quoted block. */ void syck_emit_1quoted( SyckEmitter *e, int width, char *str, long len ) { char do_indent = 0; char *mark = str; char *start = str; syck_emitter_write( e, "'", 1 ); while ( mark < str + len ) { switch ( *mark ) { case '\'': syck_emitter_write( e, "''", 2 ); break; case '\n': if ( *start != '\n' || start == str ) { syck_emitter_write( e, "\n\n", 2 ); } else { syck_emitter_write( e, "\n", 1 ); } start = mark + 1; break; default: syck_emitter_write( e, mark, 1 ); break; } mark++; } syck_emitter_write( e, "'", 1 ); } /* * Outputs a double-quoted block. */ void syck_emit_2quoted_1( SyckEmitter *e, int width, char *str, long len ) { char do_indent = 0; char *mark = str; char *start = str; char *end = str; syck_emitter_write( e, "\'", 1 ); while ( mark < str + len ) { if ( do_indent > 0 ) { if ( do_indent == 2 ) { syck_emitter_write( e, "\\", 1 ); } syck_emit_indent( e ); do_indent = 0; } switch ( *mark ) { /* Escape sequences allowed within double quotes. */ case '\'': syck_emitter_write( e, "\\\'", 2 ); break; case '\\': syck_emitter_write( e, "\\\\", 2 ); break; case '\0': syck_emitter_write( e, "\\0", 2 ); break; case '\a': syck_emitter_write( e, "\\a", 2 ); break; case '\b': syck_emitter_write( e, "\\b", 2 ); break; case '\f': syck_emitter_write( e, "\\f", 2 ); break; case '\r': syck_emitter_write( e, "\\r", 2 ); break; case '\t': syck_emitter_write( e, "\\t", 2 ); break; case '\v': syck_emitter_write( e, "\\v", 2 ); break; case 0x1b: syck_emitter_write( e, "\\e", 2 ); break; case '\n': syck_emitter_write( e, "\\n", 2 ); break; /* XXX - Disabled by Audrey Tang for YAML.pm compat case '\n': end = mark + 1; syck_emitter_write( e, "\\n", 2 ); do_indent = e->indent; start = mark + 1; if ( start < str + len && ( *start == ' ' || *start == '\n' ) ) { do_indent = 0; } break; */ case ' ': if ( width > 0 && *start != ' ' && mark - end > width ) { do_indent = 1; end = mark + 1; } else { syck_emitter_write( e, " ", 1 ); } break; default: syck_emitter_escape( e, (unsigned char *)mark, 1 ); break; } mark++; } syck_emitter_write( e, "\'", 1 ); } /* * Outputs a double-quoted block. */ void syck_emit_2quoted( SyckEmitter *e, int width, char *str, long len ) { char do_indent = 0; char *mark = str; char *start = str; char *end = str; syck_emitter_write( e, "\"", 1 ); while ( mark < str + len ) { if ( do_indent > 0 ) { if ( do_indent == 2 ) { syck_emitter_write( e, "\\", 1 ); } syck_emit_indent( e ); do_indent = 0; } switch ( *mark ) { /* Escape sequences allowed within double quotes. */ case '"': syck_emitter_write( e, "\\\"", 2 ); break; case '\\': syck_emitter_write( e, "\\\\", 2 ); break; case '\0': syck_emitter_write( e, "\\0", 2 ); break; case '\a': syck_emitter_write( e, "\\a", 2 ); break; case '\b': syck_emitter_write( e, "\\b", 2 ); break; case '\f': syck_emitter_write( e, "\\f", 2 ); break; case '\r': syck_emitter_write( e, "\\r", 2 ); break; case '\t': syck_emitter_write( e, "\\t", 2 ); break; case '\v': syck_emitter_write( e, "\\v", 2 ); break; case 0x1b: syck_emitter_write( e, "\\e", 2 ); break; case '\n': syck_emitter_write( e, "\\n", 2 ); break; /* XXX - Disabled by Audrey Tang for YAML.pm compat case '\n': end = mark + 1; syck_emitter_write( e, "\\n", 2 ); do_indent = e->indent; start = mark + 1; if ( start < str + len && ( *start == ' ' || *start == '\n' ) ) { do_indent = 0; } break; */ case ' ': if ( width > 0 && *start != ' ' && mark - end > width ) { do_indent = 1; end = mark + 1; } else { syck_emitter_write( e, " ", 1 ); } break; default: syck_emitter_escape( e, (unsigned char*)mark, 1 ); break; } mark++; } syck_emitter_write( e, "\"", 1 ); } /* * Outputs a literal block. */ void syck_emit_literal( SyckEmitter *e, char keep_nl, char *str, long len ) { char *mark = str; char *start = str; char *end = str; syck_emitter_write( e, "|", 1 ); if ( keep_nl == NL_CHOMP ) { syck_emitter_write( e, "-", 1 ); } else if ( keep_nl == NL_KEEP ) { syck_emitter_write( e, "+", 1 ); } syck_emit_indent( e ); while ( mark < str + len ) { if ( *mark == '\n' ) { end = mark; if ( *start != ' ' && *start != '\n' && *end != '\n' && *end != ' ' ) end += 1; syck_emitter_write( e, start, end - start ); if ( mark + 1 == str + len ) { if ( keep_nl != NL_KEEP ) syck_emitter_write( e, "\n", 1 ); } else { syck_emit_indent( e ); } start = mark + 1; } mark++; } end = str + len; if ( start < end ) { syck_emitter_write( e, start, end - start ); } } /* * Outputs a folded block. */ void syck_emit_folded( SyckEmitter *e, int width, char keep_nl, char *str, long len ) { char *mark = str; char *start = str; char *end = str; syck_emitter_write( e, ">", 1 ); if ( keep_nl == NL_CHOMP ) { syck_emitter_write( e, "-", 1 ); } else if ( keep_nl == NL_KEEP ) { syck_emitter_write( e, "+", 1 ); } syck_emit_indent( e ); if ( width <= 0 ) width = e->best_width; while ( mark < str + len ) { switch ( *mark ) { case '\n': syck_emitter_write( e, end, mark - end ); end = mark + 1; if ( *start != ' ' && *start != '\n' && *end != '\n' && *end != ' ' ) { syck_emitter_write( e, "\n", 1 ); } if ( mark + 1 == str + len ) { if ( keep_nl != NL_KEEP ) syck_emitter_write( e, "\n", 1 ); } else { syck_emit_indent( e ); } start = mark + 1; break; case ' ': if ( *start != ' ' ) { if ( mark - end > width ) { syck_emitter_write( e, end, mark - end ); syck_emit_indent( e ); end = mark + 1; } } break; } mark++; } if ( end < mark ) { syck_emitter_write( e, end, mark - end ); } } /* * Begins emission of a sequence. */ void syck_emit_seq( SyckEmitter *e, char *tag, enum seq_style style ) { SyckLevel *parent = syck_emitter_parent_level( e ); SyckLevel *lvl = syck_emitter_current_level( e ); /* complex key * There should also be the check "&& style == seq_none", * but unfortunately syck cannot parse flow collections as simple keys * now, so we will make a complex key. * Add the check when syck is able to parse "[]: foo" */ if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1 ) { syck_emitter_write( e, "? ", 2 ); parent->status = syck_lvl_mapx; } syck_emit_tag( e, tag, "tag:yaml.org,2002:seq" ); if ( style == seq_inline || ( parent->status == syck_lvl_imap || parent->status == syck_lvl_iseq ) ) { syck_emitter_write( e, "[", 1 ); lvl->status = syck_lvl_iseq; } else { lvl->status = syck_lvl_seq; } } /* * Begins emission of a mapping. */ void syck_emit_map( SyckEmitter *e, char *tag, enum map_style style ) { SyckLevel *parent = syck_emitter_parent_level( e ); SyckLevel *lvl = syck_emitter_current_level( e ); /* complex key * There should also be the check "&& style == map_none", * but unfortunately syck cannot parse flow collections as simple keys * now, so we will make a complex key. * Add the check when syck is able to parse "{}: foo". */ if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1 ) { syck_emitter_write( e, "? ", 2 ); parent->status = syck_lvl_mapx; } syck_emit_tag( e, tag, "tag:yaml.org,2002:map" ); if ( style == map_inline || ( parent->status == syck_lvl_imap || parent->status == syck_lvl_iseq ) ) { syck_emitter_write( e, "{", 1 ); lvl->status = syck_lvl_imap; } else { lvl->status = syck_lvl_map; } } /* * Handles emitting of a collection item (for both * sequences and maps) */ void syck_emit_item( SyckEmitter *e, st_data_t n ) { SyckLevel *lvl = syck_emitter_current_level( e ); switch ( lvl->status ) { case syck_lvl_seq: { SyckLevel *parent = syck_emitter_parent_level( e ); /* seq-in-map shortcut */ if ( parent->status == syck_lvl_mapx && lvl->ncount == 0 ) { /* shortcut -- the lvl->anctag check should be unneccesary but * there is a nasty shift/reduce in the parser on this point and * i'm not ready to tickle it. */ if ( parent->ncount % 2 == 0 && lvl->anctag == 0 ) { lvl->spaces = parent->spaces; } } /* seq-in-seq shortcut */ else if ( lvl->anctag == 0 && parent->status == syck_lvl_seq && lvl->ncount == 0 ) { int spcs = ( lvl->spaces - parent->spaces ) - 2; if ( spcs >= 0 ) { int i = 0; for ( i = 0; i < spcs; i++ ) { syck_emitter_write( e, " ", 1 ); } syck_emitter_write( e, "- ", 2 ); break; } } syck_emit_indent( e ); syck_emitter_write( e, "- ", 2 ); } break; case syck_lvl_iseq: { if ( lvl->ncount > 0 ) { syck_emitter_write( e, ", ", 2 ); } } break; case syck_lvl_map: { SyckLevel *parent = syck_emitter_parent_level( e ); /* map-in-seq shortcut */ if ( lvl->anctag == 0 && parent->status == syck_lvl_seq && lvl->ncount == 0 ) { int spcs = ( lvl->spaces - parent->spaces ) - 2; if ( spcs >= 0 ) { int i = 0; for ( i = 0; i < spcs; i++ ) { syck_emitter_write( e, " ", 1 ); } break; } } if ( lvl->ncount % 2 == 0 ) { syck_emit_indent( e ); } else { syck_emitter_write( e, ": ", 2 ); } } break; case syck_lvl_mapx: { if ( lvl->ncount % 2 == 0 ) { syck_emit_indent( e ); lvl->status = syck_lvl_map; } else { int i; if ( lvl->spaces > 0 ) { char *spcs = S_ALLOC_N( char, lvl->spaces + 1 ); spcs[lvl->spaces] = '\0'; for ( i = 0; i < lvl->spaces; i++ ) spcs[i] = ' '; syck_emitter_write( e, spcs, lvl->spaces ); S_FREE( spcs ); } syck_emitter_write( e, ": ", 2 ); } } break; case syck_lvl_imap: { if ( lvl->ncount > 0 ) { if ( lvl->ncount % 2 == 0 ) { syck_emitter_write( e, ", ", 2 ); } else { syck_emitter_write( e, ": ", 2 ); } } } break; default: break; } lvl->ncount++; syck_emit( e, n ); } /* * Closes emission of a collection. */ void syck_emit_end( SyckEmitter *e ) { SyckLevel *lvl = syck_emitter_current_level( e ); SyckLevel *parent = syck_emitter_parent_level( e ); switch ( lvl->status ) { case syck_lvl_seq: if ( lvl->ncount == 0 ) { syck_emitter_write( e, "[]\n", 3 ); } else if ( parent->status == syck_lvl_mapx ) { syck_emitter_write( e, "\n", 1 ); } break; case syck_lvl_iseq: syck_emitter_write( e, "]", 1 ); if ( parent->status == syck_lvl_mapx ) { syck_emitter_write( e, "\n", 1 ); } break; case syck_lvl_map: if ( lvl->ncount == 0 ) { syck_emitter_write( e, "{}\n", 3 ); } else if ( lvl->ncount % 2 == 1 ) { syck_emitter_write( e, ":", 1 ); } else if ( parent->status == syck_lvl_mapx ) { syck_emitter_write( e, "\n", 1 ); } break; case syck_lvl_imap: syck_emitter_write( e, "}", 1 ); if ( parent->status == syck_lvl_mapx ) { syck_emitter_write( e, "\n", 1 ); } break; default: break; } } /* * Fill markers table with emitter nodes in the * soon-to-be-emitted tree. */ SYMID syck_emitter_mark_node( SyckEmitter *e, st_data_t n, int flags ) { SYMID oid = 0; char *anchor_name = NULL; /* * Ensure markers table is initialized. */ if ( e->markers == NULL ) { e->markers = st_init_numtable(); } /* * Markers table initially marks the string position of the * object. Doesn't yet create an anchor, simply notes the * position. */ if ( ! st_lookup( e->markers, n, (st_data_t *)&oid ) ) { /* * Store all markers */ oid = e->markers->num_entries + 1; st_insert( e->markers, n, (st_data_t)oid ); } else { if ( e->anchors == NULL ) { e->anchors = st_init_numtable(); } if ( ! st_lookup( e->anchors, (st_data_t)oid, (st_data_t *)&anchor_name ) ) { int idx = 0; char *anc = ( e->anchor_format == NULL ? DEFAULT_ANCHOR_FORMAT : e->anchor_format ); /* * Second time hitting this object, let's give it an anchor */ idx = e->anchors->num_entries + 1; anchor_name = S_ALLOC_N( char, strlen( anc ) + 10 ); S_MEMZERO( anchor_name, char, strlen( anc ) + 10 ); sprintf( anchor_name, anc, idx ); /* * Insert into anchors table */ st_insert( e->anchors, (st_data_t)oid, (st_data_t)anchor_name ); } /* XXX - Flag added by BDRACO as the perl_syck.h now has a max_depth - XXX */ if (! (flags & EMITTER_MARK_NODE_FLAG_PERMIT_DUPLICATE_NODES) ) { return 0; } /* XXX - Added by Audrey Tang to handle self-recursive structures - XXX */ } return oid; } YAML-Syck-1.31/syck_st.c0000644000000000000000000002550113364413554013443 0ustar rootroot/* This is a public domain general purpose hash table package written by Peter Moore @ UCB. */ /* static char sccsid[] = "@(#) st.c 5.1 89/12/14 Crucible"; */ #include "config.h" #include #include #include "syck_st.h" #ifdef NT #include #endif #define SIZE32 4 #if SIZEOF_LONG == SIZE32 typedef long I32; typedef unsigned long U32; #define NUM2I32(x) NUM2LONG(x) #define NUM2U32(x) NUM2ULONG(x) #elif SIZEOF_INT == SIZE32 typedef int I32; typedef unsigned int U32; #define NUM2I32(x) NUM2INT(x) #define NUM2U32(x) NUM2UINT(x) #endif typedef struct st_table_entry st_table_entry; struct st_table_entry { unsigned int hash; char *key; char *record; st_table_entry *next; }; #define ST_DEFAULT_MAX_DENSITY 5 #define ST_DEFAULT_INIT_TABLE_SIZE 11 /* * DEFAULT_MAX_DENSITY is the default for the largest we allow the * average number of items per bin before increasing the number of * bins * * DEFAULT_INIT_TABLE_SIZE is the default for the number of bins * allocated initially * */ static int numcmp(); static int numhash(); static struct st_hash_type type_numhash = { numcmp, numhash, }; extern int strcmp(); static int strhash(); static struct st_hash_type type_strhash = { strcmp, strhash, }; static void rehash(); #define alloc(type) (type*)malloc((unsigned)sizeof(type)) #define Calloc(n,s) (char*)calloc((n),(s)) #define EQUAL(table,x,y) ((x)==(y) || (*table->type->compare)((x),(y)) == 0) #define do_hash(key,table) (unsigned int)(*(table)->type->hash)((key)) #define do_hash_bin(key,table) (do_hash(key, table)%(table)->num_bins) /* * MINSIZE is the minimum size of a dictionary. */ #define MINSIZE 8 /* Table of prime numbers 2^n+a, 2<=n<=30. */ static long primes[] = { 8 + 3, 16 + 3, 32 + 5, 64 + 3, 128 + 3, 256 + 27, 512 + 9, 1024 + 9, 2048 + 5, 4096 + 3, 8192 + 27, 16384 + 43, 32768 + 3, 65536 + 45, 131072 + 29, 262144 + 3, 524288 + 21, 1048576 + 7, 2097152 + 17, 4194304 + 15, 8388608 + 9, 16777216 + 43, 33554432 + 35, 67108864 + 15, 134217728 + 29, 268435456 + 3, 536870912 + 11, 1073741824 + 85, 0 }; static int new_size(size) int size; { int i; #if 0 for (i=3; i<31; i++) { if ((1< size) return 1< size) return primes[i]; } /* Ran out of polynomials */ return -1; /* should raise exception */ #endif } #ifdef HASH_LOG static int collision = 0; static int init_st = 0; static void stat_col() { FILE *f = fopen("/tmp/col", "w"); fprintf(f, "collision: %d\n", collision); fclose(f); } #endif st_table* st_init_table_with_size(type, size) struct st_hash_type *type; int size; { st_table *tbl; #ifdef HASH_LOG if (init_st == 0) { init_st = 1; atexit(stat_col); } #endif size = new_size(size); /* round up to prime number */ tbl = alloc(st_table); tbl->type = type; tbl->num_entries = 0; tbl->num_bins = size; tbl->bins = (st_table_entry **)Calloc(size, sizeof(st_table_entry*)); return tbl; } st_table* st_init_table(type) struct st_hash_type *type; { return st_init_table_with_size(type, 0); } st_table* st_init_numtable() { return st_init_table(&type_numhash); } st_table* st_init_numtable_with_size(size) int size; { return st_init_table_with_size(&type_numhash, size); } st_table* st_init_strtable() { return st_init_table(&type_strhash); } st_table* st_init_strtable_with_size(size) int size; { return st_init_table_with_size(&type_strhash, size); } void st_free_table(table) st_table *table; { register st_table_entry *ptr, *next; int i; for(i = 0; i < table->num_bins; i++) { ptr = table->bins[i]; while (ptr != 0) { next = ptr->next; free(ptr); ptr = next; } } free(table->bins); free(table); } #define PTR_NOT_EQUAL(table, ptr, hash_val, key) \ ((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key))) #ifdef HASH_LOG #define COLLISION collision++ #else #define COLLISION #endif #define FIND_ENTRY(table, ptr, hash_val, bin_pos) do {\ bin_pos = hash_val%(table)->num_bins;\ ptr = (table)->bins[bin_pos];\ if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\ COLLISION;\ while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\ ptr = ptr->next;\ }\ ptr = ptr->next;\ }\ } while (0) int st_lookup(table, key, value) st_table *table; register char *key; char **value; { unsigned int hash_val, bin_pos; register st_table_entry *ptr; hash_val = do_hash(key, table); FIND_ENTRY(table, ptr, hash_val, bin_pos); if (ptr == 0) { return 0; } else { if (value != 0) *value = ptr->record; return 1; } } #define ADD_DIRECT(table, key, value, hash_val, bin_pos)\ do {\ st_table_entry *entry;\ if (table->num_entries/(table->num_bins) > ST_DEFAULT_MAX_DENSITY) {\ rehash(table);\ bin_pos = hash_val % table->num_bins;\ }\ \ entry = alloc(st_table_entry);\ \ entry->hash = hash_val;\ entry->key = key;\ entry->record = value;\ entry->next = table->bins[bin_pos];\ table->bins[bin_pos] = entry;\ table->num_entries++;\ } while (0) int st_insert(table, key, value) register st_table *table; register char *key; char *value; { unsigned int hash_val, bin_pos; register st_table_entry *ptr; hash_val = do_hash(key, table); FIND_ENTRY(table, ptr, hash_val, bin_pos); if (ptr == 0) { ADD_DIRECT(table, key, value, hash_val, bin_pos); return 0; } else { ptr->record = value; return 1; } } void st_add_direct(table, key, value) st_table *table; char *key; char *value; { unsigned int hash_val, bin_pos; hash_val = do_hash(key, table); bin_pos = hash_val % table->num_bins; ADD_DIRECT(table, key, value, hash_val, bin_pos); } static void rehash(table) register st_table *table; { register st_table_entry *ptr, *next, **new_bins; int i, old_num_bins = table->num_bins, new_num_bins; unsigned int hash_val; new_num_bins = new_size(old_num_bins+1); new_bins = (st_table_entry**)Calloc(new_num_bins, sizeof(st_table_entry*)); for(i = 0; i < old_num_bins; i++) { ptr = table->bins[i]; while (ptr != 0) { next = ptr->next; hash_val = ptr->hash % new_num_bins; ptr->next = new_bins[hash_val]; new_bins[hash_val] = ptr; ptr = next; } } free(table->bins); table->num_bins = new_num_bins; table->bins = new_bins; } st_table* st_copy(old_table) st_table *old_table; { st_table *new_table; st_table_entry *ptr, *entry; int i, num_bins = old_table->num_bins; new_table = alloc(st_table); if (new_table == 0) { return 0; } *new_table = *old_table; new_table->bins = (st_table_entry**) Calloc((unsigned)num_bins, sizeof(st_table_entry*)); if (new_table->bins == 0) { free(new_table); return 0; } for(i = 0; i < num_bins; i++) { new_table->bins[i] = 0; ptr = old_table->bins[i]; while (ptr != 0) { entry = alloc(st_table_entry); if (entry == 0) { free(new_table->bins); free(new_table); return 0; } *entry = *ptr; entry->next = new_table->bins[i]; new_table->bins[i] = entry; ptr = ptr->next; } } return new_table; } int st_delete(table, key, value) register st_table *table; register char **key; char **value; { unsigned int hash_val; st_table_entry *tmp; register st_table_entry *ptr; hash_val = do_hash_bin(*key, table); ptr = table->bins[hash_val]; if (ptr == 0) { if (value != 0) *value = 0; return 0; } if (EQUAL(table, *key, ptr->key)) { table->bins[hash_val] = ptr->next; table->num_entries--; if (value != 0) *value = ptr->record; *key = ptr->key; free(ptr); return 1; } for(; ptr->next != 0; ptr = ptr->next) { if (EQUAL(table, ptr->next->key, *key)) { tmp = ptr->next; ptr->next = ptr->next->next; table->num_entries--; if (value != 0) *value = tmp->record; *key = tmp->key; free(tmp); return 1; } } return 0; } int st_delete_safe(table, key, value, never) register st_table *table; register char **key; char **value; char *never; { unsigned int hash_val; register st_table_entry *ptr; hash_val = do_hash_bin(*key, table); ptr = table->bins[hash_val]; if (ptr == 0) { if (value != 0) *value = 0; return 0; } for(; ptr != 0; ptr = ptr->next) { if ((ptr->key != never) && EQUAL(table, ptr->key, *key)) { table->num_entries--; *key = ptr->key; if (value != 0) *value = ptr->record; ptr->key = ptr->record = never; return 1; } } return 0; } static int delete_never(key, value, never) char *key, *value, *never; { if (value == never) return ST_DELETE; return ST_CONTINUE; } void st_cleanup_safe(table, never) st_table *table; char *never; { int num_entries = table->num_entries; st_foreach(table, (enum st_retval (*)())delete_never, never); table->num_entries = num_entries; } void st_foreach(table, func, arg) st_table *table; enum st_retval (*func)(); char *arg; { st_table_entry *ptr, *last, *tmp; enum st_retval retval; int i; for(i = 0; i < table->num_bins; i++) { last = 0; for(ptr = table->bins[i]; ptr != 0;) { retval = (*func)(ptr->key, ptr->record, arg); switch (retval) { case ST_CONTINUE: last = ptr; ptr = ptr->next; break; case ST_STOP: return; case ST_DELETE: tmp = ptr; if (last == 0) { table->bins[i] = ptr->next; } else { last->next = ptr->next; } ptr = ptr->next; free(tmp); table->num_entries--; } } } } static int strhash(string) register char *string; { register int c; #ifdef HASH_ELFHASH register unsigned int h = 0, g; while ((c = *string++) != '\0') { h = ( h << 4 ) + c; if ( g = h & 0xF0000000 ) h ^= g >> 24; h &= ~g; } return h; #elif HASH_PERL register int val = 0; while ((c = *string++) != '\0') { val = val*33 + c; } return val + (val>>5); #elif HASH_JENKINS register const unsigned char *s_PeRlHaSh = (const unsigned char *)string; register U32 hash_PeRlHaSh = 0; while ((c = *s_PeRlHaSh++) != '\0') { hash_PeRlHaSh += c; hash_PeRlHaSh += (hash_PeRlHaSh << 10); hash_PeRlHaSh ^= (hash_PeRlHaSh >> 6); } hash_PeRlHaSh += (hash_PeRlHaSh << 3); hash_PeRlHaSh ^= (hash_PeRlHaSh >> 11); return (hash_PeRlHaSh + (hash_PeRlHaSh << 15)); #else register int val = 0; while ((c = *string++) != '\0') { val = val*997 + c; } return val + (val>>5); #endif } static int numcmp(x, y) long x, y; { return x != y; } static int numhash(n) long n; { return n; } YAML-Syck-1.31/syck_st.h0000644000000000000000000000203113364413554013441 0ustar rootroot/* This is a public domain general purpose hash table package written by Peter Moore @ UCB. */ /* @(#) st.h 5.1 89/12/14 */ #ifndef ST_INCLUDED #define ST_INCLUDED typedef struct st_table st_table; struct st_hash_type { int (*compare)(); int (*hash)(); }; struct st_table { struct st_hash_type *type; int num_bins; int num_entries; struct st_table_entry **bins; }; #define st_is_member(table,key) st_lookup(table,key,(char **)0) enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE}; st_table *st_init_table(); st_table *st_init_table_with_size(); st_table *st_init_numtable(); st_table *st_init_numtable_with_size(); st_table *st_init_strtable(); st_table *st_init_strtable_with_size(); int st_delete(), st_delete_safe(); int st_insert(), st_lookup(); void st_foreach(), st_add_direct(), st_free_table(), st_cleanup_safe(); st_table *st_copy(); #define ST_NUMCMP ((int (*)()) 0) #define ST_NUMHASH ((int (*)()) -2) #define st_numcmp ST_NUMCMP #define st_numhash ST_NUMHASH int st_strhash(); #endif /* ST_INCLUDED */ YAML-Syck-1.31/Makefile.PL0000644000000000000000000000427713364413554013601 0ustar rootrootuse 5.006; use strict; use warnings; use ExtUtils::MakeMaker; require "./inc/ExtUtils/HasCompiler.pm"; my $can_xs = ExtUtils::HasCompiler::can_compile_loadable_object( quiet => 1 ) ? 1 : 0; if ( !$can_xs ) { print "Sorry! YAML::Syck requires a compiler in order to be built.\n"; exit 1; } my $bad; if ( eval { require YAML; $YAML::VERSION < 0.60 } ) { print "*** Pre-0.60 version of YAML.pm ($YAML::VERSION) detected.\n"; $bad++; } if ( eval { require YAML::Syck; $YAML::Syck::VERSION < 0.60 } ) { print "*** Pre-0.60 version of YAML::Syck ($YAML::Syck::VERSION) detected.\n"; $bad++; } if ($bad) { print << '_'; *** WARNING *** YAML::Syck version >=0.60 breaks compatibility with earlier versions of YAML::Syck and YAML.pm (<0.60) when serializing blessed references. See the COMPATIBILITY file for more information. _ my $ans = prompt( "Continue installing YAML::Syck?", "y" ); exit() unless $ans =~ /^y/i; } # One liner stolen from inc/Module/Install/Compiler.pm my $c_files = join ' ', map { substr( $_, 0, -2 ) . $Config::Config{_o} } ( glob("*.c"), ( -e 'Syck.c' ? () : 'Syck.c' ) ); WriteMakefile( NAME => 'YAML::Syck', AUTHOR => q{Todd Rinaldo }, VERSION_FROM => 'lib/YAML/Syck.pm', ABSTRACT_FROM => 'lib/YAML/Syck.pm', LICENSE => 'MIT', PL_FILES => {}, MIN_PERL_VERSION => '5.006', CONFIGURE_REQUIRES => { 'ExtUtils::MakeMaker' => '0', }, BUILD_REQUIRES => { 'Test::More' => '0', defined $ENV{'AUTOMATED_TESTING'} ? ( 'Devel::Leak' => 0 ) : (), }, INC => "-I.", OBJECT => $c_files, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Test-MockFile-*' }, $ExtUtils::MakeMaker::VERSION >= 6.46 ? ( 'META_MERGE' => { resources => { 'license' => 'http://dev.perl.org/licenses/', 'homepage' => 'http://github.com/toddr/YAML-Syck', 'bugtracker' => 'https://github.com/toddr/YAML-Syck/issues', 'repository' => 'http://github.com/toddr/YAML-Syck', } } ) : (), ); #-cc_files YAML-Syck-1.31/META.json0000644000000000000000000000234513364413554013242 0ustar rootroot{ "abstract" : "Fast, lightweight YAML loader and dumper", "author" : [ "Todd Rinaldo " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010", "license" : [ "mit" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "YAML-Syck", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "Test::More" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "perl" : "5.006" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/toddr/YAML-Syck/issues" }, "homepage" : "http://github.com/toddr/YAML-Syck", "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "url" : "http://github.com/toddr/YAML-Syck" } }, "version" : "1.31", "x_serialization_backend" : "JSON::PP version 2.97001" }