> c)I didn't optimize for size or use any of the switches that make gcc
> create leaner C++ executables because I don't know if they're safe to
> use with pcreppp
> d)my build has UTF-8 support

On MSVC, removing exception support and debug support can make a big 
difference.

I have attached a test script which shows that the plugin is almost 
working.

The only problem I am sure if is that the form
re.create(...).fullmatch("stuff", "v1", "", "v3")
does not properly set v3.  I think the reason is the switch statement 
just before all the re->fullmatch calls; as per your suggestion it 
should be switch(nargs).  In fact, the preceding for loop to set n is 
not needed, I think.  Same for partialmatch.

I also don't understand how extract is supposed to work.

Anyway, here is the test script.  Watch for unwanted line breaks long 
calls to fullmatch and partialmatch

/////////////////////////////////////////////////
static num_errors=0

//test error message processing
local hre=re.create("(ggg","","error")
[EMAIL PROTECTED]("e1", error, "Missing )")
local hre=re.create("ggg","","error")
[EMAIL PROTECTED]("e2", error, "")
hre.destroy

//test matches stored correctly for fullmatch

local hre=re.create("(0)(1)(2)(3)(4)(5)(6)(7)(8)(9)(a)(b)(c)(d)(e)(f)")
hre.FullMatch
("0123456789abcdef","v0","v1","v2","v3","v4","v5","v6","v7","v8","v9","
va", ;;+
"vb","vc","vd","ve","vf")
[EMAIL PROTECTED]("fs0", v0, 0)
[EMAIL PROTECTED]("fs1", v1, 1)
[EMAIL PROTECTED]("fs2", v2, 2)

[EMAIL PROTECTED]("fs3", v3, 3)
[EMAIL PROTECTED]("fs4", v4, 4)
[EMAIL PROTECTED]("fs5", v5, 5)

[EMAIL PROTECTED]("fs6", v6, 6)
[EMAIL PROTECTED]("fs6", v7, 7)
[EMAIL PROTECTED]("fs7", v8, 8)

[EMAIL PROTECTED]("fs9", v9, "9")
[EMAIL PROTECTED]("fsa", va, "a")
[EMAIL PROTECTED]("fsb", vb, "b")


[EMAIL PROTECTED]("fsc", vc, "c")
[EMAIL PROTECTED]("fsd", vd, "d")
[EMAIL PROTECTED]("fse", ve, "e")
[EMAIL PROTECTED]("fsf", vf, "f")


v0=""
v1="x"
v2=""
hre.FullMatch("0123456789abcdef","v0","","v2")

[EMAIL PROTECTED]("fs10", v0, 0)

[EMAIL PROTECTED]("fs12", v2, 2)  // currently fails

v0=""
v2=""
//test matches stored correctly for partialmatch
hre.PartialMatch
("xxx0123456789abcdef","v0","w1","v2","w3","w4","w5","w6","w7","w8","w9
","wa", ;;+
"wb","wc","wd","we","wf")
[EMAIL PROTECTED]("fs0", v0, 0)
[EMAIL PROTECTED]("fs1", w1, 1)
[EMAIL PROTECTED]("fs2", v2, 2)

[EMAIL PROTECTED]("fs3", w3, 3)
[EMAIL PROTECTED]("fs4", w4, 4)
[EMAIL PROTECTED]("fs5", w5, 5)

[EMAIL PROTECTED]("fs6", w6, 6)
[EMAIL PROTECTED]("fs6", w7, 7)
[EMAIL PROTECTED]("fs7", w8, 8)

[EMAIL PROTECTED]("fs9", w9, "9")
[EMAIL PROTECTED]("fsa", wa, "a")
[EMAIL PROTECTED]("fsb", wb, "b")


[EMAIL PROTECTED]("fsc", wc, "c")
[EMAIL PROTECTED]("fsd", wd, "d")
[EMAIL PROTECTED]("fse", we, "e")
[EMAIL PROTECTED]("fsf", wf, "f")

//test examples from pcrecpp.h file
//successful match

   local hre2=re.create("h.*o")
   [EMAIL PROTECTED]("ex1",hre2.FullMatch("hello"), 1)

// Example: unsuccessful match (requires full match)
   local hre3 = re.create("e")
   [EMAIL PROTECTED]("ex2",!hre3.FullMatch("hello"),1)


//
// Example: creating a temporary RE object:
    [EMAIL PROTECTED]("ex3",re.create("h.*o").FullMatch("hello"),1)

//
// Example: extracting
   local hre4=re.create("(\\w+):(\\d+)")
    hre4.FullMatch("ruby:1234", "s","i")
   [EMAIL PROTECTED]("ex4",s, "ruby")
   [EMAIL PROTECTED]("ex5",i, 1234)


//
// Example: does not try to extract any extra sub-patterns
    s="" // to make sure it is reset in following
    hre4.FullMatch("ruby:1234", "s")
    [EMAIL PROTECTED]("ex6", s, "ruby")


// Example: does not try to extract into NULL
    i=0
    hre4.FullMatch("ruby:1234", "", "i")
    [EMAIL PROTECTED]("ex7", i, 1234) //currently fails


//
// Example: fails because there aren't enough sub-patterns:
    [EMAIL PROTECTED]("ex8",re.create("\\w+:\\d+").FullMatch
("ruby:1234", "s"),0)



//Example: simple search for a string:
     [EMAIL PROTECTED]("ex9",re.create("ell").PartialMatch("hello"),1)

// Example: find first number in a string:

     local hre5 = re.create("(\\d+)")
      hre5.PartialMatch("x*100 + 20", "number")
     [EMAIL PROTECTED]("ex10", number, 100)

// check replace
   local s = "yabba dabba doo"
   local did=re.create("b+").Replace("d", "s")
   [EMAIL PROTECTED]("ex11", did, 1)
   [EMAIL PROTECTED]("ex12",s, "yada dabba doo")

//  confirm return is zero for no replace
   local s = "yabba dabba doo"
   local did=re.create("q+").Replace("d", "s")
   [EMAIL PROTECTED]("ex13", did, 0)
   [EMAIL PROTECTED]("ex14",s, "yabba dabba doo")


// check global replace
   s = "yabba dabba doo"
   local num=re.create("b+").GlobalReplace("d", "s")
   [EMAIL PROTECTED]("ex15",s, "yada dada doo")
   [EMAIL PROTECTED]("ex16", num, 4)

    s = "yabba dabba doo"
   local num=re.create("q+").GlobalReplace("d", "s")
   [EMAIL PROTECTED]("ex15",s, "yabba dabba doo")
   [EMAIL PROTECTED]("ex16", num, 0)

   local out="xx"
   s = "yabba dabba doo"
   local num=re.create("b+").Extract("\0", s, "out")
   win.debug(s, out)
   [EMAIL PROTECTED]("ex17",out, "yada dabba doo")
   [EMAIL PROTECTED]("ex18", num, 1)




if (num_errors==0)
win.debugshow("Successful")

quit

@assert args id, a, b
static num_errors
if (a!=b) do
win.debugshow(id, a, b)
num_errors++
endif
>


Reply via email to