Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* lib/syck.c: memory leak in parser level domains.

* added extraneous files.
commit 819964aa9fdfb4f2ce23fc048a253e311996fe12 1 parent 1aa3ee8
_why authored
View
54 COPYING
@@ -0,0 +1,54 @@
+Copyright (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).
+
View
2  README
@@ -3,7 +3,7 @@
. syck .
- [ version 0.08 ]
+ [ version 0.28 ]
View
128 RELEASE
@@ -0,0 +1,128 @@
+released: { name: Syck, version: 0.28 }
+for: [ Ruby, PHP, Python ]
+by: why the lucky stiff
+about: >
+
+ Syck is a YAML parser, an extension for scripting
+ languages, written in C.
+
+ So what is YAML? YAML is a new language for data.
+ Describe objects in plain text. Load the data into
+ your scripting language as arrays, dictionaries,
+ classes, or primitives.
+
+links:
+ YAML: http://www.yaml.org/
+ YAML Cookbook: http://yaml4r.sf.net/cookbook/
+ YAML Type Repository: http://yaml.org/type/
+ YAML Specification: http://yaml.org/spec/
+ Syck: http://www.whytheluckystiff.net/syck/
+ Syck Benchmarks: http://www.whytheluckystiff.net/arch/2003/03/19
+ Tarball @ SourceForge: http://aleron.dl.sourceforge.net/sourceforge/yaml4r/syck-0.25.tar.gz
+
+status: >
+
+ Syck is about 80% compliant with the YAML spec. Syck currently
+ has a few issues with type families before an mapping. I've also
+ noticed some whitespace issues. The seq-in-map shortcut is not
+ yet supported.
+
+ The extensions are quite usable, though. Ruby, PHP and Python
+ can load from a string containing YAML. Ruby also has support
+ for stream loading from any IO object.
+
+ This release also introduces the YAML.rb 0.50 source code into
+ the Ruby extension. Which means: YPath, emitting, Okay.
+
+benchmarks: >
+
+ Syck is quite speedy, although not as swift as most language's
+ native serialization.
+
+ Syck runs at about:
+
+ 30-35% of the speed of Ruby's Marshal.
+ 35-90% of the speed of PHP's deserialize().
+ 600% of the speed of Python's Pickle.
+ 33-40% of the speed of Python's cPickle.
+
+ (Based on various types of structured data.)
+
+installation: >
+
+ Syck contains working extensions for the Ruby, PHP, and Python
+ languages. Each requires compilation of the libsyck library,
+ followed by compilation of the extension.
+
+ To compile libsyck, first download libsyck.
+
+ tar xzvf syck-0.25.tar.gz
+ cd syck-0.25
+ ./configure
+ make
+ sudo make install
+
+ To install the Ruby extension:
+
+ cd ext/ruby
+ ruby install.rb config
+ ruby install.rb setup
+ sudo ruby install.rb install
+
+ To install the Python extension:
+
+ cd ext/python
+ python setup.py build
+ sudo python setup.py install
+
+ To install the PHP extension:
+
+ sh make_module.sh
+ sudo make install (if you weren't root during make_module.sh)
+ php -q syck.php
+
+examples:
+
+ To load this document in Ruby: |
+
+ ($:~)$ irb
+ >> require 'syck'
+ => true
+ >> yp = YAML::Syck::Parser.new( {} )
+ => #<YAML::Syck::Parser:0x8058530>
+ >> yp.load( File.open( 'syck-0.25.yml' ) )
+ => {"status"=>"Syck is about 60% compliant ..."}
+
+ To load this document in PHP: |
+
+ ($:~)$ php -a
+ Interactive mode enabled
+
+ <? dl( 'syck.so' ); print_r( syck_load( implode( '', file( 'syck-0.25.yml' ) ) ) ); ?>
+
+ .. php then outputs ..
+
+ X-Powered-By: PHP/4.2.3
+ Content-type: text/html
+
+ Array
+ (
+ [released] => Array
+ (
+ [name] => Syck
+ [version] => 0.25
+ )
+
+ .. and so on ..
+
+ To load this document in Python: |
+
+ ($:~)$ python
+ Python 2.1.3 (#1, Jul 11 2002, 17:52:24)
+ [GCC 2.95.3 20010315 (release) [FreeBSD]] on freebsd4
+ Type "copyright", "credits" or "license" for more information.
+ >>> import syck
+ >>> f = open( 'syck-0.25.yml' )
+ >>> syck.load( f.read() )
+ {'by': 'why the lucky stiff', ... }
+
View
4 configure.in
@@ -1,9 +1,9 @@
# Process this file with autoconf to produce a configure script.
-AC_INIT(syck, 0.25)
+AC_INIT(syck, 0.28)
AC_CONFIG_AUX_DIR(config)
AC_PREREQ(2.50)
-AM_INIT_AUTOMAKE(syck, 0.25)
+AM_INIT_AUTOMAKE(syck, 0.28)
AM_CONFIG_HEADER(config.h)
# Checks for programs.
View
302 ext/ruby/CHANGELOG
@@ -0,0 +1,302 @@
+--- %YAML:1.0
+- version: 0.60
+ date: 2003-04-24
+ changes:
+ - New parser backed by Syck. [http://whytheluckystiff.net/syck/] 100x faster.
+
+- version: 0.50
+ date: 2003-01-13
+ changes:
+ - YAML::Store more like PStore fixes. Thank you, Eric Hodel.
+ - Bug fix to transfer methods, anchors, aliases in a seq-map shortcut. Thank you, Brad Hilton.
+ - Prototype YPath support nearly complete (still need to handle '..').
+ - New YAML::YamlNode#select! method will transform the results of a selection.
+ - No more '+' and '-' boolean implicits.
+ - Sequence-in-sequence shortcut nailed.
+ - Output YAML repaired for YTS.
+ - Radical 0.6 + YAML patches.
+
+- version: 0.49
+ date: 2003-01-12
+ changes:
+ - New, cleaner, more efficient tokenizer. Three months worth of work, kids.
+ - Line numbers now reported on errors.
+ - New map-seq shortcut.
+ - New collection types. !omap, !pairs, !set.
+ - New implicits for !null, !float, and !boolean.
+ - Merge token changed to '<<'.
+ - Added sexagecimal format (for time and degrees).
+ - Removed the 'undef' possibility.
+ - Fixed implicit empties in inline sequences.
+ - Flow values allowed in their own indentation.
+ - Parsing plain scalars better than ever.
+
+- version: 0.48
+ date: 2003-01-04
+ changes:
+ - Empty string implicit.
+ - New merge type rules! See http://www.yaml.org/type/merge/.
+ - URL encoding removed, replaced with YAML escaping.
+ - Binary type now does base64 exclusively.
+ - Removed parentheses syntax from !null, !bool and !float implicits.
+ - Fixes to the seq-map shortcut, addition of the new map-seq shortcut!
+ - Enhanced !okay/rpc's server.about return.
+ - The install script's --force command was removed.
+ - Directives now in %KEY:VALUE format.
+
+- version: 0.47
+ date: 2002-11-11
+ changes:
+ - New IO via StringIO and IO#readline. A change from 0.50 that's being merged in now for speed.
+ - Trailing document separator bugfix.
+ - DomainType class for handling undefined type families.
+ - YAML::each_document alias for YAML::load_documents
+ - YAML::each_node alias for YAML::parse_documents
+
+- version: 0.46
+ date: 2002-11-01
+ changes:
+ - RubyConf fluf release.
+ - In other words, no real changes.
+ - I'm talking about total jubilation.
+
+- version: 0.45
+ date: 2002-10-31
+ changes:
+ - Yod generates PDF (requires Ruby-ClibPDF).
+ - Speed improvement of 20-30% in yaml.rb parser.
+ - Support for Okay modules.
+ - Long single-line strings will be folded if emitter has folding on.
+
+- version: 0.44
+ date: 2002-10-10
+ changes:
+ - New !okay/news and !okay/rpc specifications.
+ - Racc no longer a run YAML.
+
+- version: 0.43
+ date: 2002-09-17
+ changes:
+ - Strings now anchored only if the string contains a new line.
+ - Prototype for the !okay/type schema validator now included.
+ - Typing and implicit checking system now wired to YAML::transfer_method.
+
+- version: 0.42
+ date: 2002-09-16
+ changes:
+ - Timestamp usec fixes galore from Michael Witrant.
+ - New API with parse_* and load_* for accessing the generic and native models, respectively.
+ - Basic YPath support checked in.
+
+- version: 0.41
+ date: 2002-09-06
+ changes:
+ - New taguri typing mechanism (from Last Call spec).
+ - The '/' character allowed to start unquoted strings (from Last Call spec).
+ - Added YAML::Pairs type which capitalizes on the seq-map shortcut in the spec.
+ - Repaired cases in which nested inline collections were screwing things up.
+ - Emitter now emits the seq-map shortcut when possible.
+ - Custom classes which extend from Array and Object should round-trip.
+
+- version: 0.40
+ date: 2002-08-28
+ changes:
+ - Added Emitter#map and Emitter#seq, along with YAML::quick_emit to ease writing to_yaml methods.
+ - Fixes to headless documents.
+ - Fix to PrivateType.
+ - Fix to empty classes extended from Array and Object.
+ - New reference checker uses anchors and aliases to prevent circular references.
+ - Binary data now emitting.
+ - Kernel::y method for dumping data as an alternative to Kernel::p.
+
+- version: 0.39
+ date: 2002-08-15
+ changes:
+ - 'Improved multi-line scalar emissions. Beware of Iconv module with large text blocks.
+ It appears to be cutting off after a few k.'
+ - Problem with space indicators emitted by String#to_yaml. Bug reported by Tom Sawyer.
+ - Bug in comment-handling code. YAML couldn't parse the README.
+ - Yod now generating compilable CHM.
+
+- version: 0.38
+ date: 2002-08-12
+ changes:
+ - Moved the Emitter into its own class. Thread-safe now.
+ - Added some basic Unicode support.
+ - More progress on Yod.
+
+- version: 0.37
+ date: 2002-08-04
+ changes:
+ - Finished descriptions in the Cookbook.
+ - Added simpler inline Regexp and Range serialization.
+
+- version: 0.36
+ date: 2002-08-01
+ changes:
+ - Renamed YAML.rb.
+ - Fixed slight inconsistency with space indicators in plain scalars.
+
+- version: 0.35
+ date: 2002-07-29
+ changes:
+ - Range#to_yaml added.
+ - Space indicators now required as the spec prescribes (http://yaml.org/spec/#space_indicators).
+ - Negative numbers parsing fixed.
+
+- version: 0.34
+ date: 2002-07-29
+ changes:
+ - Symbol#to_yaml added with abbreviated !ruby/sym syntax.
+ - Problems with NaN, Infinity, Floats emission.
+ - Complex keys, Symbol keys, Regexp keys bugfixes.
+ - Bug in Time#to_yaml. My bad.
+
+- version: 0.33
+ date: 2002-07-29
+ changes:
+ - Better String#to_yaml, uses the parser's implicit type checker now!
+ - Headless documents now skipping the initial newline properly.
+ - Turned off SortKeys by default; still turned on in the tests.
+
+- version: 0.32
+ date: 2002-07-28
+ changes:
+ - Opened up unquoted strings to more characters, is closer to spec now.
+ - Round tripping started with YTS.
+ - Problems with foreign characters fixed. Thanks, Robert Wagner.
+ - Problems with Array#to_yaml and Hash#to_yaml not giving a newline when nested. Again, RW.
+ - Bugs in positive timezones with Time#to_yaml fixed by Tobias Peters!
+
+- version: 0.31
+ date: 2002-07-27
+ changes:
+ - Fixed bug in multiline quoted strings.
+ - Added YTS cases for odd newline and spaced block scalars.
+
+- version: 0.30
+ date: 2002-07-26
+ changes:
+ - Added support for Steve's new YTS streams.
+ - Refactored newline handling across all blocks.
+
+- version: 0.29
+ date: 2002-07-24
+ changes:
+ - First stab at Unicode support.
+ - Basic tests fixed.
+
+- version: 0.28
+ date: 2002-07-24
+ changes:
+ - Special comment key and default key supported.
+ - Multiline unquoted supported in in-line constructs.
+
+- version: 0.27
+ date: 2002-07-24
+ changes:
+ - Handling of literal and folded blocks finally matches the spec for indented blocks.
+ - All indentation should be handled correctly.
+ - Indented comments properly handled.
+
+- version: 0.26
+ date: 2002-07-23
+ changes:
+ - Fixed Timestamps to handle single character usec.
+ - Complete spec now in YTS.
+
+- version: 0.25
+ date: 2002-07-21
+ changes:
+ - New Object#to_yaml provides a good generic export for most Ruby objects.
+ - Fixes to the TrueClass, FalseClass, NilClass export methods.
+ - Test harness for the YTS (YamlTestingSuite).
+ - Distribution now includes yaml4r.rb directly, use --force to remake.
+
+- version: 0.24
+ date: 2002-07-17
+ changes:
+ - Started CHM output for Yod.
+ - Better support for multiline scalars, multiline double-quoted strings, and multiline single-quoted strings.
+ - Cleaned up the parser code, its indentation and comments.
+
+- version: 0.23
+ date: 2002-07-16
+ changes:
+ - Major fixes to the Time emitter and parser. Time zones should work.
+ - Fixes to indentation at the start of a document.
+ - More Yod work.
+
+- version: 0.22
+ date: 2002-07-16
+ changes:
+ - Started Yod documentation.
+ - Working to fix indentation problems.
+
+- version: 0.21
+ date: 2002-07-15
+ changes:
+ - Private types now available via add_private_type or returns a PrivateType class.
+ - URI escaping.
+ - All ruby types now registered under the ruby.yaml.org domain as the spec describes.
+ - Fixed double-quoted string ending on last character of the document.
+
+- version: 0.20
+ date: 2002-07-14
+ changes:
+ - Better error reporting from the parser. Shows the sensitive area and sometimes a bit of advice.
+ - Binary data builtin now suported for strings and scalar blocks.
+ - Spanning quoted strings should be good.
+ - Pause marker supported.
+
+- version: 0.19
+ date: 2002-07-12
+ changes:
+ - Parsing of multiple documents via YAML4R::load_document and Parser#parse_documents.
+
+- version: 0.18
+ date: 2002-07-11
+ changes:
+ - New YAML4R::add_domain_type, YAML4R::add_ruby_type, YAML4R::add_builtin_type! Beginning of an era!
+ - Transfer method prefixing.
+ - Better support for commas, colons in unquoted strings.
+ - All supported types now added with add_builtin_type.
+ - Separators in scalars was throwing the parser off.
+ - Seperated unit tests into smaller, more specific functions.
+ - README and CHANGELOG now fully parsed by YAML4R.
+ - The install.rb now has a --force option to force Racc to remake the grammar.
+
+- version: 0.17
+ date: 2002-07-10
+ changes:
+ - Implicit Time elements added (without timezones).
+ - Folded and literal blocks alot closer.
+ - Spanned strings making progress.
+ - Struct fully round-trip.
+
+- version: 0.16
+ date: 2002-07-09
+ changes:
+ - Nearing completion of scalar blocks, literal and folded both implemented.
+ - Improvements to the Struct class round-trip.
+ - Adjunct words are combined to prevent odd errors.
+
+- version: 0.15
+ date: 2002-07-09
+ changes:
+ - Added ! explicit implicit operator.
+ - Added Struct#to_yaml.
+ - Fixes to double-quoted strings.
+ - Fixes to Regexp#to_yaml. Added unit tests to reflect.
+
+- version: 0.14
+ date: 2002-07-08
+ changes:
+ - Initial public release.
+ - README in YAML.
+ - Complex keys.
+ - Single-quoted, double-quoted scalars.
+ - Transfer methods now parsed.
+ - Cleaned up the grammar a bit more.
+ - Anchors and aliases.
+
View
400 ext/ruby/README
@@ -0,0 +1,400 @@
+#
+#
+# .. yaml.rb .....
+# . .
+# . .
+# . .
+# ....... v0.49 ..
+#
+#
+#
+# {o}
+# ^
+# {o}
+# ^
+#
+# Load this README!
+#
+# >> YAML::load( File.open( 'README' ) )
+#
+--- %YAML:1.0
+title: YAML.rb
+version: 0.49
+author: [Why the Lucky Stiff, yaml-core@whytheluckystiff.net]
+websites: [http://www.yaml.org, http://yaml4r.sf.net, http://sf.net/projects/yaml4r/]
+installation: >
+ YAML.rb depends on Racc, available in the RAA:
+
+ http://www.ruby-lang.org/en/raa-list.rhtml?name=Racc
+
+ Once Racc is installed, run the install.rb script in this
+ distribution:
+
+ ruby install.rb
+
+ To run the included unit tests:
+
+ ruby tests/basic.rb
+
+ To run the new YamlTestingSuite:
+
+ cd yts
+ ruby yts.rb
+
+about: >
+ From the specification:
+
+ "YAML(tm) (rhymes with 'camel') is a
+ straightforward machine parsable data serialization format designed for
+ human readability and interaction with scripting languages such as Perl
+ and Python. YAML is optimized for data serialization, formatted
+ dumping, configuration files, log files, Internet messaging and
+ filtering. This specification describes the YAML information model and
+ serialization format. Together with the Unicode standard for characters, it
+ provides all the information necessary to understand YAML Version 1.0
+ and construct computer programs to process it."
+
+ For Ruby developers, YAML is a natural fit for object serialization and
+ general data storage. Really, it's quite fantastic. Spreads right on
+ your Rubyware like butter on bread!
+
+ The possible uses for YAML are innumerable. Configuration files,
+ custom internet protocols, documentation, the list goes on and on.
+ Also, with YAML readers popping up for other languages (see YAML.pm
+ and others), you can pass data easily to colleagues in distant lands,
+ swamped in their archaic languages.
+
+ YAML is a beacon of light, reaching out to them all. ;)
+
+ If I can-- quickly, of course-- in the Pickaxe book-- my all-time favorite
+ coding book-- Dave Thomas and Andy Hunt say:
+
+ "When we discovered Ruby, we realized that we'd found what we'd been looking
+ for. More than any other language with which we have worked, Ruby stays
+ out of your way. You can concentrate on solving the problem at hand, instead
+ of struggling with compiler and language issues. That's how it can help you
+ become a better programmer: by giving you the chance to spend your time
+ creating solutions for your users, not for the compiler."
+
+ HeiL! So true. Ruby's elegance, its readability, its common sense! Such
+ it is with YAML. YAML is completely readable, in fact much of its syntax
+ parallels Ruby's own data structure syntax!
+
+ Another one from the Pickaxe:
+
+ "Ruby is easy to learn. Everyday tasks are simple to code and once you've done
+ them, they are easy to maintain and grow. Apparently difficult things often
+ turn out not to have been difficult after all. Ruby follows the Principle
+ of Least Surprise--things work the way you would expect them to, with very
+ few special cases or exceptions. And that really does make a difference
+ when you're programming."
+
+ A quick look at YAML and you can see your data structure immediately. If
+ I compare it to SOAP or XML-RPC, the difference is immense. With XML-RPC,
+ you can see the data structures, but its terribly verbose. More time is
+ spent describing the structure than anything else. Again, the Principle
+ of Least Surprise is wholly present in YAML. Thank God!
+
+ Well, welcome to YAML.rb. Now let's look at the API and see what we're
+ dealing with!
+
+lets show off:
+ - section: Exporting objects to YAML
+ explanation: >
+
+ Ruby encourages objects to have their own exporting methods. Hence, YAML.rb
+ adds #to_yaml methods for built-in types. The NilClass, FalseClass, TrueClass, Symbol, Range,
+ Numeric, Date, Time, Regexp, String, Array, and Hash all contain the to_yaml method.
+
+ example: |
+
+ require 'yaml'
+ h = { 'test' => 12, 'another' => 13 }
+ puts h.to_yaml
+
+ - section: Loading a single YAML document
+ explanation: >
+
+ Although you'll often want to store multiple YAML documents in a single
+ file, YAML.rb has a mechanism for loading and storing a single document in
+ a single file. I wanted to offer a simpler API for those who don't care
+ for the multiple document styling and just want to store a single object.
+
+ example: |
+
+ require 'yaml'
+ obj = YAML::load( File::open( "/tmp/yaml.store.1" ) )
+
+ - section: Loading an object from a string
+ explanation: >
+
+ Perhaps you get an object from an HTTP post. String objects can be
+ loaded through the same YAML::load used with the File object above.
+ You can also pass StringIO into YAML::load.
+
+ example: |
+
+ require 'yaml'
+ obj = YAML::load( <<EOY
+ --- %YAML:1.0
+ - armless
+ - falling
+ - birds
+ EOY
+ )
+ p obj
+ #=> [ 'armless', 'falling', 'birds' ]
+
+ - section: Replacing PStore with YAML
+ explanation: >
+
+ PStore is an excellent utility for Ruby developers. Akin to Python's pickle,
+ objects can be serialized to a file. In YAML.rb, the PStore API is replicated
+ identically, as a drop-in replacement for PStore code.
+
+ example: |
+
+ require 'yaml'
+ y = YAML::Store.new( "/tmp/yaml.store.1", :Indent => 2, :Separator => '---.pstore' )
+ y.transaction do
+ y['names'] = ['Crispin', 'Glover']
+ y['hello'] = {'hi' => 'hello', 'yes' => 'YES!!' }
+ end
+
+ - section: Exporting multiple documents to YAML
+ explanation: >
+
+ A single YAML file can store several documents, each opened with a YAML separator ('---').
+ This can be especially useful for streaming data over a socket or for separating
+ log file entries (as see in the spec -- http://yaml.org/spec/).
+
+ This release writes all documents out upon calling YAML::Stream#emit, but future
+ releases will allow document writing to stream individually.
+
+ example: |
+
+ y = YAML::Stream.new( :Indent => 2, :UseVersion => true )
+ y.add( {'my_regex' => /hello [Jj][Aa][Mm][Ee][Ss]/, 'my_age' => 90 } )
+ y.add( {'hi' => 'wow!', 'bye' => 'wow!'} )
+ y.add( {['Red Socks','Boston'] => ['One', 'Two', 'Three']} )
+ y.add( [true, false, false] )
+ puts y.emit
+
+ - section: Loading multiple documents at once into a YAML::Stream
+ explanation: >
+
+ In using YAML::Stream to write your objects, you may find that
+ you want a quick way to load several documents at once back into
+ a YAML::Stream, for editing and rewriting.
+
+ example: |
+
+ require 'yaml'
+ File.open( "/home/why/.personalrc", "rw" ) { |rc|
+ # Load the objects from the file
+ y = YAML::load_stream( rc )
+ # Make edits to the objects
+ doc2 = y.documents[2]
+ doc2['car'] = '1997 Subaru Outback'
+ y.edit( 2, doc2 )
+ # Save back out
+ rc.rewind
+ rc.write( y.emit )
+ rc.close
+ }
+
+ - section: Loading multiple documents from a YAML stream
+ explanation: |
+
+ When reading YAML from a socket or a pipe, you should
+ consider using the event-based parser, which will parse
+ documents one at a time.
+
+ example: |
+
+ require 'yaml'
+ log = File.open( "/var/log/apache.yaml" )
+ yp = YAML::load_documents( log ) { |doc|
+ puts "#{doc['at']} #{doc['type']} #{doc['url}"
+ }
+
+# Note the YAML document embedded in the YAML document!
+cheat sheet: |
+ # A YAML reference card
+ --- %YAML:1.0
+
+ Collection indicators:
+ '? ' : Key indicator.
+ ': ' : Key / value separator.
+ '- ' : Nested series entry indicator.
+ ', ' : Separate in-line branch entries.
+ '[]' : Surround in-line series branch.
+ '{}' : Surround in-line keyed branch.
+
+ Scalar indicators:
+ '''' : Surround in-line unescaped scalar ('' escaped ').
+ '"' : Surround in-line escaped scalar (see escape codes below).
+ '|' : Block scalar indicator.
+ '>' : Folded scalar indicator.
+ '-' : Strip chomp modifier ('|-' or '>-').
+ '+' : Keep chomp modifier ('|+' or '>+').
+ int : Explicit indentation modifier ('|10' or '>2').
+ # Modifiers can be combined ('|2-', '>+10').
+
+ Alias indicators:
+ '&' : Anchor property.
+ '*' : Alias indicator.
+
+ Transfer indicators:
+ '!' : Transfer method indicator.
+ '!!' : Transfer method with private type family.
+ '^' : Establish/use global type family prefix.
+ '|' : Separate global type family from format.
+
+ Document indicators:
+ '%' : Directive indicator.
+ '---' : Document separator.
+ '...' : Document terminator.
+
+ Misc indicators:
+ ' #' : Throwaway comment indicator.
+ '=' : Default value map key.
+ '<<' : Insert keys from map key.
+
+ Core types: ### Almost never given explicitly
+ '!map' : [ Hash table, dictionary, mapping ]
+ '!seq' : [ List, array, tuple, vector, sequence ]
+ '!str' : Unicode string
+
+ Language Independent Scalar types:
+ [ , ~, null ] : Null (no value).
+ [ 1,234, 0x4D2, 02333, 20:34 ] : [ Decimal int, Hexadecimal, Octal, Base60 ]
+ [ 1,230.15, 12.3015e+02, 20:20.15 ] : [ Fixed float, Exponential, Base60 ]
+ [ .inf, -.Inf, .NAN ] : [ Infinity (float), Negative, Not a number ]
+ [ +, true, Yes, ON ] : Boolean true
+ [ -, false, No, OFF ] : Boolean false
+ ? !binary >
+ R0lG...BADS=
+ :
+ Base 64 binary value.
+
+ Escape codes:
+ Numeric : { "\xXX": 8-bit, "\uXXXX": 16-bit, "\UXXXXXXXX": 32-bit }
+ Protective: { "\\": '\', "\"": '"', "\ ": ' ' }
+ C: { "\a": BEL, "\b": BS, "\f": FF, "\n": LF, "\r": CR, "\t": TAB, "\v": VTAB }
+ Additional: { "\e": ESC, "\0": NUL, "\_": NBSP, "\N": NEL, "\L": LS, "\P": PS }
+
+compliance:
+ - feature: YAML Separators
+ supported?: (Yes)
+ notes: Custom YAML separators are allowed and will be used in exporting multiple documents.
+ - feature: YAML directives
+ supported?: (Yes)
+ notes: >
+ Directives are parsed correctly, but are of little use. The TAB directive is completely
+ ignored, as tabs are not supported at this time.
+ - feature: Transfer methods
+ supported?: (Yes)
+ - feature: Private types
+ supported?: (Yes)
+ - feature: URI Escaping
+ supported?: (Yes)
+ - feature: URI Prefixing
+ supported?: (Yes)
+ - feature: Throwaway comments
+ supported?: (Yes)
+ - feature: Anchors
+ supported?: (Yes)
+ - feature: Aliases
+ supported?: (Yes)
+ - feature: Sequences
+ supported?: (Yes)
+ notes: Nested and flow both supported.
+ - feature: Mappings
+ supported?: (Yes)
+ notes: Nested and flow both supported.
+ - feature: Key indicators
+ supported?: (Yes)
+ - feature: Explicit indent
+ supported?: (Yes)
+ - feature: Chomping
+ supported?: (Yes)
+ - feature: Literal scalar
+ supported?: (Yes)
+ - feature: Folded scalar
+ supported?: (Yes)
+ - feature: Unquoted scalars
+ supported?: (Yes)
+ notes: No support for spanning unquoted.
+ - feature: Single-quoted scalars
+ supported?: (Yes)
+ - feature: Double-quoted scalars
+ supported?: (Yes)
+ - feature: Escape characters
+ supported?: (Yes)
+ notes: Most should be.
+ - feature: Strings
+ supported?: (Yes)
+ - feature: Null
+ supported?: (Yes)
+ feature: Canonical and english.
+ - feature: Boolean
+ supported?: (Yes)
+ notes: Canonical and english.
+ - feature: Integer
+ supported?: (Yes)
+ notes: Canonical, oct, dec, and hex.
+ - feature: Float
+ supported?: (Yes)
+ notes: Canonical, exp, fix, english
+ - feature: Time
+ supported?: (Yes)
+ notes: Canonical, iso8601, spaced and ymd (as Date).
+ - feature: Binary
+ supported?: (Yes)
+ - feature: Default key
+ supported?: (Yes)
+
+acknowledgements:
+ - who: Brian Ingerson
+ why?: |
+ Ingy's YAML.pm was INDISPENSABLE in writing this library. In fact,
+ most of the emitter code follows the YAML.pm code quite closely.
+ I also borrowed from his testing suite. Hopefully in the near
+ future, YAML.rb and YAML.pm will use the same testing suite.
+
+ Brian is also the creator of YAML. I'd say he's the free software
+ equivalent of an Olympic long jumper.
+ email: ingy@ttul.org
+
+ - who: Steve Howell
+ why?: |
+ Comrade on the Yaml-core mailing list. He's working on the
+ Python YAML implementation. Very encouraging of this project.
+ I plan on stealing his Ruby code to handle circular data structures.
+ Steve has also contributed to the YAML Testing Suite.
+ email: showell@zipcon.net
+
+ - who: Clark Evans
+ why?: |
+ Clark showed immediate excitement upon discovery of YAML.rb.
+ And at that point I hadn't really done much yet, but the
+ encouragement sure helped alot.
+
+ - who: Oren Ben-Kiki
+ why?: |
+ For his work on the spec and the quick reference. All three
+ of these guys have built a well-written specification, paying
+ great attention to details.
+
+ - who: Yukihiro Matsumoto
+ why?: |
+ Creator of the Ruby language. The most innovative man in
+ software development bar none!
+
+ - who: qwilk
+ why?: |
+ Long-time friend at desktopian.org, developer of Blackbox for
+ Windows, Robin Hood web server. Excellent chum, persistent
+ BeOS fanatic and leader of a generation of shell folk.
+
View
19 lib/syck.c
@@ -107,10 +107,18 @@ syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip )
void
syck_parser_reset_levels( SyckParser *p )
{
- p->lvl_idx = 1;
- p->levels[0].spaces = -1;
- p->levels[0].domain = syck_strndup( "", 1 ); // YAML_DOMAIN + "/";
- p->levels[0].status = syck_lvl_header;
+ 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].domain = ""; // YAML_DOMAIN + "/";
+ p->levels[0].status = syck_lvl_header;
+ }
}
void
@@ -153,6 +161,7 @@ syck_new_parser()
p->taguri_expansion = 0;
p->bufsize = SYCK_BUFFERSIZE;
p->buffer = NULL;
+ p->lvl_idx = 0;
syck_parser_reset_levels( p );
return p;
}
@@ -207,7 +216,9 @@ syck_free_parser( SyckParser *p )
//
// Free all else
//
+ syck_parser_reset_levels( p );
S_FREE( p->levels );
+
if ( p->buffer != NULL )
{
S_FREE( p->buffer );
View
3  lib/syck.h
@@ -10,7 +10,7 @@
#ifndef SYCK_H
#define SYCK_H
-#define SYCK_VERSION "0.25"
+#define SYCK_VERSION "0.28"
#define YAML_DOMAIN "yaml.org,2002"
#include <stdio.h>
@@ -229,6 +229,7 @@ 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 );
Please sign in to comment.
Something went wrong with that request. Please try again.