FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Patch for crash bug and DMD 1.01x

 
Post new topic   Reply to topic     Forum Index -> TinyXPath
View previous topic :: View next topic  
Author Message
baxissimo



Joined: 23 Oct 2006
Posts: 241
Location: Tokyo, Japan

PostPosted: Tue May 01, 2007 12:58 am    Post subject: Patch for crash bug and DMD 1.01x Reply with quote

Here's a patch to the current SVN as of today that fixes that, plus some issues in the test program (it was using file.format(...) when it meant to be using file.writef(...). ) Also there were compilation issues with recent dmd vis-a-vis bug 1206. So this patch fixes those:


Code:

Index: action_store.d
===================================================================
--- action_store.d   (revision 33)
+++ action_store.d   (working copy)
@@ -27,7 +27,8 @@
    \author Yves Berquin
 */
 
-private import tinyxml;
+module xpath.action_store;
+private import xpath.tinyxml;
 public
 {
 
@@ -85,6 +86,7 @@
       aipp_list.length = 0;
       i_size = 0;
    }
+
    /// add an element on the placeholder, given its details
    void v_add (int i_1, int i_2, int i_3, char[] cp_string)
    {
Index: byte_stream.d
===================================================================
--- byte_stream.d   (revision 33)
+++ byte_stream.d   (working copy)
@@ -22,6 +22,7 @@
 distribution.
 */
 
+module xpath.byte_stream;
 
 private import std.c.string;
 
Index: htmlutil.d
===================================================================
--- htmlutil.d   (revision 33)
+++ htmlutil.d   (working copy)
@@ -21,8 +21,9 @@
 3. This notice may not be removed or altered from any source
 distribution.
 */
+module xpath.htmlutil;
 private import std.stream;
-private import tinyxml;
+private import xpath.tinyxml;
 public{
 
 void v_out_html (OutputStream Fp_out, TiXmlNode XNp_source, uint u_level)
Index: node_set.d
===================================================================
--- node_set.d   (revision 33)
+++ node_set.d   (working copy)
@@ -22,8 +22,8 @@
 distribution.
 */
 
-
-private import tinyxml;
+module xpath.node_set;
+private import xpath.tinyxml;
 private import std.c.stdlib;
 private import std.stdio;
 private {
@@ -60,11 +60,13 @@
    /// constructor : creates an empty set
    this ()
    {
+        //writefln("NODESET +1");
       u_nb_node = 0;
    }
    /// destructor
    ~ this()
    {
+        //writefln("NODESET -1");
       if (u_nb_node && vpp_node_set)
          vpp_node_set.length = 0;
       if (u_nb_node && op_attrib)
Index: test.d
===================================================================
--- test.d   (revision 33)
+++ test.d   (working copy)
@@ -13,10 +13,14 @@
 import xpath.xpath_static;
 import xpath.xpath_processor;
 import xpath.htmlutil;
-import std.stream;
+static import std.stream;
 import std.stdio;
-File out_html;
 
+import std.gc;
+
+std.stream.File out_html;
+
+
 void v_out_one_line (char[] cp_expr, char[] cp_res, char[] cp_expected, bool o_ok)
 {   
    out_html.writef("<tr><td>%s</td>", cp_expr);
@@ -41,8 +45,7 @@
 
 alias v_test_one_string_tiny v_test_one_string ;
 
-
-int main ()
+void do_test()
 {
    TiXmlDocument XDp_doc;
    TiXmlElement XEp_main;
@@ -67,6 +70,7 @@
    v_out_html (out_html, XDp_doc, 0);
    out_html.writeLine("<br /><br />");
    out_html.writeLine("<table border='1'><tr><th>Expression</th><th>Result</th><th>Expected (compiled)</th></tr>\n");
+
    XEp_main = XDp_doc . RootElement ();
 
    out_html.writeLine("<h2>Results</h2>");
@@ -77,8 +81,11 @@
    // v_test_one_string (XEp_main, "//x/y/text()", "inner text" );
    // v_test_one_string (XEp_main, "//x[/y/text()='inner text']/@target", "123" );
    v_test_one_string (XEp_main, "//x/text()", "sub text");
+
    v_test_one_string (XEp_main, "//*/comment()", " -122.0 ");
+
    v_test_one_string (XEp_main, "count(//*/comment())", "2");
+
    v_test_one_string (XEp_main, "sum(//@*)", "123");
    v_test_one_string (XEp_main, "sum(//*/comment())", "378");
    v_test_one_string (XEp_main, "true()", "true");
@@ -261,19 +268,28 @@
    char[] ca_expr;
 
    i_nb_news = i_xpath_int (XDp_doc . RootElement (), cp_rss_count);
-   out_html.format("RSS version (XPath expr : <b>%s</b>) : %s<br />\n",cp_rss_ver, S_xpath_string (XDp_doc . RootElement (), cp_rss_ver));
-   out_html.format("Nb of news messages (XPath expr : <b>%s</b>) : %d<br />\n",cp_rss_count, i_nb_news);
+   out_html.writef("RSS version (XPath expr : <b>%s</b>) : %s<br />\n",cp_rss_ver, S_xpath_string (XDp_doc . RootElement (), cp_rss_ver));
+   out_html.writef("Nb of news messages (XPath expr : <b>%s</b>) : %d<br />\n",cp_rss_count, i_nb_news);
    out_html.writeLine("<br /><table border='1'><tr><th>Xpath expr</th><th>value</th></tr>");
 
    for (i_news = 0; i_news < i_nb_news; i_news++)
    {
       ca_expr = format("concat(/rss/channel/item[%d]/pubDate/text(),' : ',/rss/channel/item[%d]/title/text())", i_news + 1, i_news + 1);
-      out_html.format("<tr><td>%s</td><td>%s</td></tr>\n", ca_expr, S_xpath_string (XDp_doc . RootElement (), ca_expr));
+      out_html.writef("<tr><td>%s</td><td>%s</td></tr>\n", ca_expr, S_xpath_string (XDp_doc . RootElement (), ca_expr));
    }
    out_html.writeLine("</table>");
 
    delete XDp_doc;
    out_html.writeLine("<br />&nbsp;<br /></body></html>");
+
    delete out_html;
-   return 0;
+
 }
+
+void main()
+{
+    do_test();
+    writefln("GC SWEEP---");
+    std.gc.fullCollect();
+    writefln("All done.");
+}
\ No newline at end of file
Index: test/test.d
===================================================================
--- test/test.d   (revision 33)
+++ test/test.d   (working copy)
@@ -261,14 +261,14 @@
    char[] ca_expr;
 
    i_nb_news = i_xpath_int (XDp_doc . RootElement (), cp_rss_count);
-   out_html.format("RSS version (XPath expr : <b>%s</b>) : %s<br />\n",cp_rss_ver, S_xpath_string (XDp_doc . RootElement (), cp_rss_ver));
-   out_html.format("Nb of news messages (XPath expr : <b>%s</b>) : %d<br />\n",cp_rss_count, i_nb_news);
+   out_html.writef("RSS version (XPath expr : <b>%s</b>) : %s<br />\n",cp_rss_ver, S_xpath_string (XDp_doc . RootElement (), cp_rss_ver));
+   out_html.writef("Nb of news messages (XPath expr : <b>%s</b>) : %d<br />\n",cp_rss_count, i_nb_news);
    out_html.writeLine("<br /><table border='1'><tr><th>Xpath expr</th><th>value</th></tr>");
 
    for (i_news = 0; i_news < i_nb_news; i_news++)
    {
       ca_expr = format("concat(/rss/channel/item[%d]/pubDate/text(),' : ',/rss/channel/item[%d]/title/text())", i_news + 1, i_news + 1);
-      out_html.format("<tr><td>%s</td><td>%s</td></tr>\n", ca_expr, S_xpath_string (XDp_doc . RootElement (), ca_expr));
+      out_html.writef("<tr><td>%s</td><td>%s</td></tr>\n", ca_expr, S_xpath_string (XDp_doc . RootElement (), ca_expr));
    }
    out_html.writeLine("</table>");
 
Index: tinyxml.d
===================================================================
--- tinyxml.d   (revision 33)
+++ tinyxml.d   (working copy)
@@ -21,6 +21,8 @@
 3. This notice may not be removed or altered from any source
 distribution.
 */
+module xpath.tinyxml;
+
 public import std.stream;
 public import std.string;
 
@@ -32,6 +34,7 @@
 private import std.ctype;
 public import std.cstream;
 public import xpath.xpath_stream;
+
 public {
 enum TiXmlEncoding
 {
@@ -54,6 +57,17 @@
    class TiXmlParsingData
    {
       
+      protected{
+      // Only used by the document!
+         this( char[] start, int _tabsize, int row, int col )
+         {
+            stamp = start;
+            tabsize = _tabsize;
+            cursor.row = row;
+            cursor.col = col;
+         }
+      }
+
       public {
          void Stamp( char[] now, TiXmlEncoding encoding )
          in { assert( ! (now is null) ); assert(now.length > 0); }
@@ -65,24 +79,13 @@
          
          TiXmlCursor Cursor()   { return cursor; }
       }
-      protected{
-      // Only used by the document!
-         this( char[] start, int _tabsize, int row, int col )
-         {
-            stamp = start;
-            tabsize = _tabsize;
-            cursor.row = row;
-            cursor.col = col;
-         }
-      }
-   
       TiXmlCursor      cursor;
       char[]      stamp;
       int            tabsize;
    };
 
+}
 
-}
 public {
 /+
 #ifndef USE_MMGR
@@ -385,13 +388,13 @@
                            
 
    // If an entity has been found, transform it into a character.
-   static int GetEntity( char[] sin, inout char[] value, inout int length, TiXmlEncoding encoding )
+   static int GetEntity( char[] sin, inout char[] value, inout int len, TiXmlEncoding encoding )
    {
       // Presume an entity, and pull it out.
       char[] ent;
       int delta;
       int i;
-      length = 0;
+      len = 0;
    
       if ( sin.length > 2 && sin[1] == '#' )
       {
@@ -404,7 +407,7 @@
             if (sin.length < 3) return 0;
             // Hexadecimal.
    
-            char[] q = sin[3..length];
+            char[] q = sin[3..$];
 
             delta = find(q, ';');
             if (delta == -1)
@@ -431,7 +434,7 @@
             // Decimal.
             if (sin.length < 3) return 0;
             
-            char[] q = sin[2..length];
+            char[] q = sin[2..$];
             delta = find(q, ';');
             if ( delta == -1 ) return 0;
             int _q = delta-1;
@@ -449,12 +452,12 @@
          }
          if ( encoding == TiXmlEncoding.TIXML_ENCODING_UTF8 )
          {
-            ConvertUTF32ToUTF8( ucs, value, length );
+            ConvertUTF32ToUTF8( ucs, value, len );
          }
          else
          {
             value[0] = cast(char)ucs;
-            length = 1;
+            len = 1;
          }
          return delta + 1;
       }
@@ -465,14 +468,14 @@
          if ( entity[i].str == sin )
          {
             value[0] = entity[i].chr;
-            length = 1;
+            len = 1;
             return entity[i].str.length;
          }
       }
    
       // So it wasn't an entity, its unrecognized, or something like that.
       value[0] = sin[0];   // Don't put back the last one, since we return it!
-      length = 1;         // Leave unrecognized entities - this doesn't really work.
+      len = 1;         // Leave unrecognized entities - this doesn't really work.
                   // Just writes strange XML.
       return 1;
    }
@@ -525,8 +528,6 @@
 
    static void PutString( char[] str, out char[] outString )
    {
-      int i=0;
-   
       foreach (int i,char c;str)
       {
          ubyte _c = cast(ubyte) str[i];
@@ -663,28 +664,28 @@
    {
       return std.ctype.tolower(v);
    }
-   static void ConvertUTF32ToUTF8( ulong input, inout char[] output, inout int length )
+   static void ConvertUTF32ToUTF8( ulong input, inout char[] output, inout int len )
    {
       const ulong BYTE_MASK = 0xBF;
       const ulong BYTE_MARK = 0x80;
       const ulong FIRST_BYTE_MARK[7] = [ 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC ];
    
       if (input < 0x80)
-         length = 1;
+         len = 1;
       else if ( input < 0x800 )
-         length = 2;
+         len = 2;
       else if ( input < 0x10000 )
-         length = 3;
+         len = 3;
       else if ( input < 0x200000 )
-         length = 4;
+         len = 4;
       else
-         { length = 0; return; }   // This code won't covert this correctly anyway.
+         { len = 0; return; }   // This code won't covert this correctly anyway.
       
       int o = 0;
-      o += length;
+      o += len;
    
       // Scary scary fall throughs.
-      switch (length)
+      switch (len)
       {
          case 4:
             --o;
@@ -700,7 +701,7 @@
             input >>= 6;
          case 1:
             --o;
-            output[o] = cast(char)(input | FIRST_BYTE_MARK[length]);
+            output[o] = cast(char)(input | FIRST_BYTE_MARK[len]);
       }
    }    
    }
@@ -773,7 +774,6 @@
          delete temp;
       }   
    }
-
    
 
    /** The meaning of 'value' changes for the specific type of
@@ -1557,6 +1557,7 @@
 public {
    this() { sentinel = new TiXmlAttribute; sentinel.next = sentinel; sentinel.prev = sentinel; }
    ~this() { delete sentinel; sentinel = null; }
+
    void Add( TiXmlAttribute addMe )
    {
       //assert( !Find( TIXML_STRING( addMe->Name() ) ) );   // Shouldn't be multiply adding to the set.
@@ -2637,7 +2638,7 @@
    {
       Clear();
       location.Clear();
-      uint length = file.available();
+      uint len = file.available();
       
       // Strange case, but good to handle up front.
       if ( file.eof )
@@ -2670,8 +2671,8 @@
          data += buf;
       }
       */
-      char[] buf = new char[length];
-      file.readExact(buf, length);
+      char[] buf = new char[len];
+      file.readExact(buf.ptr, len);
       
    
       int lastPos = 0;
@@ -3122,4 +3123,6 @@
 private:
    TiXmlNode* node;
 };+/
+
 }
+
Index: tokenlist.d
===================================================================
--- tokenlist.d   (revision 33)
+++ tokenlist.d   (working copy)
@@ -68,6 +68,7 @@
          v_delete_current ();
       delete ltp_first;
    }
+
    /// Adds a lexical token
    void v_add_token (lexico l_in_enum, ubyte[] bp_in_value, uint u_in_size)
    {
Index: utf8.d
===================================================================
--- utf8.d   (revision 33)
+++ utf8.d   (working copy)
@@ -1,3 +1,5 @@
+module xpath.utf8;
+
 public {
 int u8isUniAlpha(dchar u)
 {
Index: xml_util.d
===================================================================
--- xml_util.d   (revision 33)
+++ xml_util.d   (working copy)
@@ -27,6 +27,7 @@
    \author Yves Berquin
 */
 
+module xpath.xml_util;
 private import xpath.tinyxml;
 
 public {
Index: xpath_expression.d
===================================================================
--- xpath_expression.d   (revision 33)
+++ xpath_expression.d   (working copy)
@@ -61,7 +61,8 @@
       d_content = 0.0;
       ns_set = new node_set;
    }
-   ~this() { delete ns_set; }
+   //~this() { delete ns_set; }
+
    /// Set expression_result to a bool
    void v_set_bool (bool o_in)
    {
Index: xpath_stack.d
===================================================================
--- xpath_stack.d   (revision 33)
+++ xpath_stack.d   (working copy)
@@ -74,6 +74,9 @@
 class xpath_stack
 {
 public :
+   this() { rnp_first = null; u_size = 0; }
+   ~ this() { while (rnp_first) v_pop_one(); }
+
    debug
    void v_dump ()
    {
@@ -90,8 +93,6 @@
    }
 
 
-   this() { rnp_first = null; u_size = 0; }
-   ~ this() { while (rnp_first) v_pop_one(); }
    void v_push (expression_result er_res)
    {
       result_and_next rnp_new;
Index: xpath_stream.d
===================================================================
--- xpath_stream.d   (revision 33)
+++ xpath_stream.d   (working copy)
@@ -28,8 +28,8 @@
 */
 
 
+module xpath.xpath_stream;
 
-
 private import xpath.byte_stream;
 private import xpath.xpath_syntax;
 private import std.stream;
Index: xpath_syntax.d
===================================================================
--- xpath_syntax.d   (revision 33)
+++ xpath_syntax.d   (working copy)
@@ -27,6 +27,8 @@
    \author Yves Berquin
    XPath Syntax analyzer for TinyXPath project
 */
+module xpath.xpath_syntax;
+
 private import xpath.lex_util;
 private import xpath.tokenlist;
 private import xpath.lex_token;
@@ -58,7 +60,8 @@
    /// Nb of recursions
       uint u_nb_recurs;
       bool o_recognize (xpath_construct xc_current, bool o_final)
-      in { writefln("Recognizing: %s (par: %s)", cp_disp_construct(xc_current), (ltp_get(0) is null)?"(null)":cp_disp_class_lex(ltp_get(0).lex_get_value())); }
+            in {
+                debug writefln("Recognizing: %s (par: %s)", cp_disp_construct(xc_current), (ltp_get(0) is null)?"(null)":cp_disp_class_lex(ltp_get(0).lex_get_value())); }
       body
       {
          lex_token ltp_freeze = null;

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> TinyXPath All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group