[redland-dev] Problems with SPARQL's OPTIONAL pattern matching - PATCH

fiandro at tiscali.it fiandro at tiscali.it
Tue Mar 14 09:54:17 GMT 2006


Attilio Fiandrotti wrote:
<snip>

> in pure C the same query executed on the same document doesn't 
produce a call to librdf_new_node_from_node(NULL), only C#, so i 
suppose this can still be considered a bug in the C# port.
> I'll try to dig deeper in this bug next week.

This patch includes Arjan's hints and fixes the previously reported 
OPTIONAL crash in C# bindings for me

attilio at attilaptop:~/redland/bindings/csharp$ cvs diff Node.cs 
QueryResults.cs
Index: Node.cs
===================================================================
RCS file: /cvsroot/redland/bindings/csharp/Node.cs,v
retrieving revision 1.18
diff -r1.18 Node.cs
222,223c222,228
<                       IntPtr newnode = librdf_new_node_from_node 
(node);
<                       handle = new HandleRef (this, newnode);
---
>                       if (node!=IntPtr.Zero) {
>                               IntPtr newnode = 
librdf_new_node_from_node (node);
>                               handle = new HandleRef (this, 
newnode);
>                       }
>                       else {
>                               handle = new HandleRef (this, IntPtr.
Zero);
>                       }
242,243c247,253
<                       IntPtr istr = librdf_node_to_string (handle);
<                       return Util.UTF8PtrToString (istr);
---
>                       if (handle.Handle!=IntPtr.Zero) {
>                               IntPtr istr = librdf_node_to_string 
(handle);
>                               return Util.UTF8PtrToString (istr);
>                       }
>                       else {
>                        return "NULL";
>                       }
Index: QueryResults.cs
===================================================================
RCS file: /cvsroot/redland/bindings/csharp/QueryResults.cs,v
retrieving revision 1.9
diff -r1.9 QueryResults.cs
48c48,52
<                               h.Add (name, new Node (v));
---
>                               if (v!=IntPtr.Zero) {
>                                       h.Add (name, null);
>                               } else {
>                                       h.Add (name, new Node (v));
>                               }

as i'm not a C# nor redland expert, could someone please test this 
patch and maybe commit if it's proved to fix the bug and not to 
harmful? (specifically, i'm not sure returning a "NULL" string is 
really clean ).

friendly

Attilio




		
Tiscali ADSL 4 Mega Flat
Naviga senza limiti con l'unica Adsl a 4 Mega di velocità a soli 19,95 € al mese!
Attivala subito e hai GRATIS 2 MESI e l'ATTIVAZIONE. 
http://abbonati.tiscali.it/banner/middlepagetracking.html?c=webmailadsl&r=http://abbonati.tiscali.it/adsl/sa/4flat_tc/&a=webmail&z=webmail&t=14


More information about the redland-dev mailing list