summaryrefslogtreecommitdiff
path: root/lib/psych/visitors/yaml_tree.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/psych/visitors/yaml_tree.rb')
-rw-r--r--lib/psych/visitors/yaml_tree.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb
index 63e14da..6ad30d2 100644
--- a/lib/psych/visitors/yaml_tree.rb
+++ b/lib/psych/visitors/yaml_tree.rb
@@ -70,6 +70,14 @@ module Psych
@ss = ss
@options = options
@line_width = options[:line_width]
+ if @line_width && @line_width < 0
+ if @line_width == -1
+ # Treat -1 as unlimited line-width, same as libyaml does.
+ @line_width = nil
+ else
+ fail(ArgumentError, "Invalid line_width #{@line_width}, must be non-negative or -1 for unlimited.")
+ end
+ end
@coders = []
@dispatch_cache = Hash.new do |h,klass|