Orange check failling all of a sudden
Jacob Carlborg
doob at me.com
Tue Jun 19 12:00:27 UTC 2018
On 2018-06-11 20:00, DigitalDesigns wrote:
> Changed some things in my app but unrelated to serialization and now my
> app fails when trying to read the xml that was generated at the output
> of the previous run.
>
> Where it is failing is here:
>
> void checkSpace(ref string s) @safe pure // rule 3
> {
> import std.algorithm.searching : countUntil;
> import std.ascii : isWhite;
> import std.utf : byCodeUnit;
>
> mixin Check!("Whitespace");
> ptrdiff_t i = s.byCodeUnit.countUntil!(a => !isWhite(a));
> if (i == -1 && s.length > 0 && isWhite(s[0]))
> s = s[$ .. $];
> else if (i > -1)
> s = s[i .. $];
> if (s is old) fail();
> }
>
> s =
> ="1.0" encoding="UTF-8"?>
> <archive version="1.0.0" type="org.dsource.orange.xml">
> <data>
>
> Actual xml data(first 3 lines):
>
> <?xml version="1.0" encoding="UTF-8"?>
> <archive version="1.0.0" type="org.dsource.orange.xml">
> <data>
>
>
> It seems odd that it should fail when munching whitespace. It seems that
> the checker is getting off to a bad start from the get go.
>
>
>
> - [orange.xml.PhobosXml.CheckException] 0x03135880
> {err=0x00000000, tail="="1.0" encoding="UTF-8"?>
> <archive version="1.0.0" type="org.dsource.orange.xml">
> <data>
> orange.xml.PhobosXml.CheckException
> + orange.xml.PhobosXml.XMLException 0x03135880 {}
> orange.xml.PhobosXml.XMLException
> err 0x00000000 orange.xml.PhobosXml.CheckException
> + tail "="1.0" encoding="UTF-8"?>
> <archive version="1.0.0" type="org.dsource.orange.xml">
> <data>
> ... const(char)[]
> + msg "Whitespace" const(char)[]
> line 0 uint
> column 0 uint
>
>
> This was all working fine before and I'm not sure how it broke. The
> xmllint shows the xml is well formed so this is buggy code.
>
>
> Note that if I also remove all the xml inside data then the same error
> occurs, so this is my xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <archive version="1.0.0" type="org.dsource.orange.xml">
> <data>
> </data>
> </archive>
>
> that still fails when checking whitespace.
The XML parts all come from the standard library, slightly tweaked. Can
you please check if std.xml has the same problem?
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list