bpsm / edn-java

a reader for extensible data notation
Eclipse Public License 1.0
100 stars 24 forks source link

Comma character prints incorrectly #45

Closed lverns closed 8 years ago

lverns commented 8 years ago
import us.bpsm.edn.printer.Printers;

public class CommaBug {

    public static void main(String[] args){
        System.out.println(Printers.printString(','));
    }
}

Running this program produces the following output

Exception in thread "main" us.bpsm.edn.EdnException: Whitespace character 0x2c is unsupported.
        at us.bpsm.edn.printer.Printers$11.eval(Printers.java:384)
        at us.bpsm.edn.printer.Printers$11.eval(Printers.java:357)
        at us.bpsm.edn.printer.Printers$1.printValue(Printers.java:142)
        at us.bpsm.edn.printer.Printers.printString(Printers.java:74)
        at us.bpsm.edn.printer.Printers.printString(Printers.java:56)

The expected output is

\,
lverns commented 8 years ago

Note that the parser handles commas correctly.

import us.bpsm.edn.parser.*;
import java.io.*;

public class CommaGood {

    public static void main(String[] args){
        Parseable pbr = Parsers.newParseable("\\,");
        Parser p = Parsers.newParser(Parsers.defaultConfiguration());
        char val = (char) p.nextValue(pbr);

        System.out.println(val == ',');
    }
}

This produces true as expected.

bpsm commented 8 years ago

Thanks very much for the bug report. I'll get a fix out this week.

bpsm commented 8 years ago

Fixed with release 0.4.7 I've published it to Maven Central via oss.sonatype.org; It should appear there soon.