[Mapserver-dev] Re: PHP Mapscript module and RegEx

Anthony Best abest at digitalflex.net
Mon Sep 27 12:43:23 EDT 2004

Franck Martin wrote:

> --__--__--
>> Message: 1
>> Date: Fri, 24 Sep 2004 16:46:59 -0600
>> From: Anthony Best <abest at digitalflex.net>
>> To: Mapserver-dev at lists.gis.umn.edu
>> Subject: [Mapserver-dev] PHP Mapscript module and RegEx
>> [Sent this to users list]
>> Hello,
>> I'm looking into fixing the problem with PHP4s Bundled RegEx and 
>> Mapscript.
>> I've hacked the source to compile with mapserver using the system regex,
>> while php is still using the builtin regex. The linking seems to be
>> correct, however I'm uncertain that this is the correct path to 
>> fixing this.
>> Is anyone else working on this?
>> What is the real problem that requires mapscript to use php's bundled 
>> regex?
>> Is there still a problem with thread-safety?
>> I'm also getting the impression that mapscript is incorrectly using the
>> php4 API. Is this true?
>> I'm willing to put the time and effort into fixing this issue (as well
>> as other issues).
> For the regex thing, when I compiled mapscript, I found out that it 
> uses only once or twice the regex functions, to check if the file 
> loaded ends up in .map and a couple of others...

Much of the regex code I've seen could be replaced however, the map file 
itself can have a regex for filtering data. This part would require regex.

> My suggestion, would be to remove this regex altogether and put your 
> own code there.
> I compiled mapscipt by patching the code and removing these regex 
> (quick and dirty) but it works...

I rewrote the regex functions to hack_regex(), etc, and wrote a simple 
wrapper for the functions. I had to do this because the include files 
for php had the same function names and structures.

After linking the symbols on my system at least don't conflict. This 
seems to be a characteristic of gcc and glibc's dynamic linker which 
probably behaves differently on other systems.

It seems to me, the solution would be to:

1. Remove internal usage of regular expressions such as "getNumeric()" 
from mapserv.c
and / or
2. Replace the usage of the system regex to another implementation such 
as pcre, or some other standard implementation, and ensure there is no 
symbol conflicts.

I generally avoid regular expressions as they can be too slow for some 
operations. And having optimizations and compatibility is difficult the 
achieve. When using regular expressions I avoid POSIX if at all 
possible. /Rant

I've been able to get this to compile and link correctly on a Linux 
2.4.22 glibc 2.3.2 system. Using Apache DSO and php's built in regex. 
However I suspect this isn't portable because of dynamic linking.

> Also, I'm willing to look at putting a bounty on this issue (mapserver 
> running as php/apache dso). I had one answer so far, which looks good. 
> However I will have to write a contract with the party that will solve 
> it and before I need to have 3 quotes. With the amount I can talk to 
> my management and see what they say. There is mainly one condition, 
> the party or his company must be EU or ACP national.
> Cheers

More information about the mapserver-dev mailing list