Hi Henrik,

> ATM I'm trying with the following:
> 
> void tst(char *strs[2]){
>       strs[0] = "foo";
>       strs[1] = "bar";
> }
> 
> (native "pcre/main.so" "tst" NIL '(X (8 . S)))
> 
> X contains "foo" but I can't seem to get at "bar".

Right. (8 . S) is a structure of size 8, consisting of a single string
pointer.


You should use

   (native "pcre/main.so" "tst" NIL '(X (16 S S)))

i.e. a size of 16 (two pointers) with two string pointers. Alternatively
(especially when more strings are involved) you can pass an element
count (here 2):

   (native "pcre/main.so" "tst" NIL '(X (16 S . 2)))



BTW, if you want to call a regexp library (though I don't think using
regexps in general is a good idea ;), why not use the standard 'regexec'
functions?

>From http://rosettacode.org/wiki/Regular_expressions#PicoLisp

   (let (Pat "a[0-9]z"  String "a7z")
      (use Preg
         (native "@" "regcomp" 'I '(Preg (64 B . 64)) Pat 1)  # Compile regex
         (when (=0 (native "@" "regexec" 'I (cons NIL (64) Preg) String 0 0 0))
            (prinl "String \"" String "\" matches regex \"" Pat "\"") ) ) )

   Output:

   String "a7z" matches pattern "a[0-9]z"

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to