Re: [xslt] str:replace implementation



On Mon, Jan 08, 2007 at 04:04:40PM -0500, joel reed wrote:
> Please find attached an implementation of the exslt.org str:replace 
> function and 7 test cases.

  Okay, thanks !

> Documentation on the function can be found here:
>   http://www.exslt.org/str/functions/replace/index.html
> 
> In that spec, I did not implement these last two sentences: "The longest 
> search strings are replaced first. If a search string is empty, then the 
> equivalently positioned replacement node is inserted between every 
> character in the string." I felt the added code complexity and 
> performance hit was not worth the impact at this time.

  I guess there is a bug there:
    xmlUTF8Strlen() counts the number of characters in an UTF-8 encoded
    string, not the number of bytes. So you should not use it as the
    value of the increment of the xmlChar * , but use xmlStrlen() instead in
    exsltStrReplaceInternal()
I also added the rest to the makefile.am in tests/exslt/strings, in my version
compiled with memory debug it points out a memory leak:

paphio:~/XSLT/tests/exslt/strings -> make tests
## Running exslt string tests
replace.1 result
MEMORY ALLOCATED : 1218, MAX was 171024
paphio:~/XSLT/tests/exslt/strings -> cat .memdump 
      03:04:43 PM

      MEMORY ALLOCATED : 1218, MAX was 171020
BLOCK  NUMBER   SIZE  TYPE
0        1203     11 malloc()  in none(0) "j, j, j, j"
1        1200     66 malloc()  in none(0) "fum"
2        1197     66 malloc()  in none(0) "fo"
3        1194     66 malloc()  in none(0) "fi"
4        1191     66 malloc()  in none(0) "fee"
5        1188     17 malloc()  in none(0) "fee, fi, fo, fum"
6        1187      2 malloc()  in none(0) "j"
7        1185     40 malloc()  in none(0)
8        1184     12 malloc()  in none(0) pointer to #1185 at index 8
9        1179     34 malloc()  in none(0) "tee, eye, billow, a longe"
10       1176     66 malloc()  in none(0) "a longer string"
11       1174     66 malloc()  in none(0) "fum"
12       1171     66 malloc()  in none(0) "billow"
13       1169     66 malloc()  in none(0) "fo"
etc...

  I start looking at the code with the debugger (following the instructions
at http://xmlsoft.org/xmlmem.html) and it is clear:
   - that the argument popped from XPath stack are not freed in the normal path
   - it seems that there is no free either in case of error, just doing
     xmlXPathSetTypeError() and return but no deallocations

Plus there is a number of case, where the args can be strings or nodesets, it's
probably better if you could check all the deallocation paths and provide
another patch once those issues have been checked that would be nice !

> The other 11 sentences are implemented and add a useful capability to 
> libexslt (imho)!
> 
> Daniel and Bill: I hope you are both doing well.

  Thanks, I'm fine :-)

> I'm not subscribed to 
> the xslt mailing list, and the mailman server seems to be busted with 
> reagards to new subscriptions.

 Hum, weird, so I resubscribed you manually with your new address.

   thanks, but there is still a bit of work to be done before commiting it.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]