From 1d404f227253545710546fda8b708848c24a9d09 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Fri, 24 Feb 2017 09:12:48 -0600 Subject: Treat negative or zero-width as max possible width. Not sure why snakeyaml doesn't follow libyaml here. I'll follow up with them. --- ext/java/PsychEmitter.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/java/PsychEmitter.java b/ext/java/PsychEmitter.java index d9f3231..35eff96 100644 --- a/ext/java/PsychEmitter.java +++ b/ext/java/PsychEmitter.java @@ -101,7 +101,7 @@ public class PsychEmitter extends RubyObject { options.setCanonical(canonical.isTrue()); options.setIndent((int)level.convertToInteger().getLongValue()); - options.setWidth((int)width.convertToInteger().getLongValue()); + line_width_set(context, width); this.io = io; @@ -296,7 +296,9 @@ public class PsychEmitter extends RubyObject { @JRubyMethod(name = "line_width=") public IRubyObject line_width_set(ThreadContext context, IRubyObject width) { - options.setWidth((int)width.convertToInteger().getLongValue()); + int newWidth = (int)width.convertToInteger().getLongValue(); + if (newWidth <= 0) newWidth = Integer.MAX_VALUE; + options.setWidth(newWidth); return width; } -- cgit v1.2.3