Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 1549

Show
Ignore:
Timestamp:
05/24/10 04:26:55 (15 years ago)
Author:
rsinfu
Message:

Fixed bugzilla 3088: std.xml.check() fails on xml comments.

Fixed wrong array indexing; s[0..n] scraps entire input after "--"!
Test case by Andrew Talbot.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/docsrc/changelog.dd

    r1547 r1549  
    55 
    66$(VERSION 047, May 9, 2010, =================================================, 
    77 
    88    $(WHATSNEW 
    99    $(LI std.functional: toDelegate now accepts callable(function pointers, delegates and objects implement opCall) ) 
    1010    $(LI std.traits: Added templates to get compile-time information about functions.) 
    1111    $(LI std.typecons: Added tie and AutoImplement.) 
    1212    ) 
    1313    $(BUGSFIXED 
    1414    $(LI $(BUGZILLA 2835): std.socket.TcpSocket doesn't actually connect) 
     15    $(LI $(BUGZILLA 3088): std.xml.check() fails on xml comments) 
    1516    $(LI $(BUGZILLA 3200): std.xml doesn't follow spec for Tag.text) 
    1617    $(LI $(BUGZILLA 3873): std.range.repeat should have popBack defined) 
    1718    $(LI $(BUGZILLA 3880): std.regex functions with const/immutable Regex object) 
    1819    $(LI $(BUGZILLA 4109): writeln doesn't work with empty static array) 
    1920    $(LI $(BUGZILLA 4202): Changset 1517 doesn't compile) 
    2021    $(LI $(BUGZILLA 4228): std.array.replace contains 2 bugs) 
    2122    ) 
    2223) 
    2324 
    2425<div id=version> 
  • trunk/phobos/std/xml.d

    r1544 r1549  
    21472147        } 
    21482148    } 
    21492149 
    21502150    void checkComment(ref string s) // rule 15 
    21512151    { 
    21522152        mixin Check!("Comment"); 
    21532153 
    21542154        try { checkLiteral("<!--",s); } catch(Err e) { fail(e); } 
    21552155        int n = s.indexOf("--"); 
    21562156        if (n == -1) fail("unterminated comment"); 
    2157         s = s[0..n]; 
     2157        s = s[n..$]; 
    21582158        try { checkLiteral("-->",s); } catch(Err e) { fail(e); } 
    21592159    } 
    21602160 
    21612161    void checkPI(ref string s) // rule 16 
    21622162    { 
    21632163        mixin Check!("PI"); 
    21642164 
    21652165        try 
    21662166        { 
    21672167            checkLiteral("<?",s); 
     
    26112611        ]"); 
    26122612    assert(false); 
    26132613    } 
    26142614    catch(CheckException e) 
    26152615    { 
    26162616        int n = e.toString().indexOf("end tag name \"genres\" differs" 
    26172617            " from start tag name \"genre\""); 
    26182618        assert(n != -1); 
    26192619    } 
    26202620  } 
     2621} 
     2622 
     2623unittest 
     2624{ 
     2625    string s = q"EOS 
     2626<?xml version="1.0"?> 
     2627<set> 
     2628    <one>A</one> 
     2629    <!-- comment --> 
     2630    <two>B</two> 
     2631</set> 
     2632EOS"; 
     2633    try 
     2634    { 
     2635        check(s); 
     2636    } 
     2637    catch (CheckException e) 
     2638    { 
     2639        assert(0, e.toString()); 
     2640    } 
    26212641} 
    26222642 
    26232643unittest 
    26242644{ 
    26252645    string s = q"EOS 
    26262646<?xml version="1.0" encoding="utf-8"?> <Tests> 
    26272647    <Test thing="What &amp; Up">What &amp; Up Second</Test> 
    26282648</Tests> 
    26292649EOS"; 
    26302650    auto xml = new DocumentParser(s);