[Mapserver-users] Problem with Mapserver 4 / regex in loadMapFile (FIXED)

Franck Martin franck at sopac.org
Sun Jul 6 23:00:54 EDT 2003


--=-D0pl64wiKB+o8FV5sV/Q
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

I modified msEvalRegex in mapfile.c as follows and now it works... I use
a regex_t *re instead of a regex_t re.

int msEvalRegex(char *e, char *s) {
  regex_t *re;

  if(!e || !s) return(MS_FALSE);
  re=malloc(sizeof(regex_t));
  if(regcomp(re, e, REG_EXTENDED||REG_NOSUB) != 0) {
    regfree(re);
    msSetError(MS_REGEXERR, "Failed to compile expression (%s).",
"msEvalRegex()", e);   
    return(MS_FALSE);
  }
  if(regexec(re, s, 0, NULL, 0) != 0) { // no match
    regfree(re);
    msSetError(MS_REGEXERR, "String (%s) failed expression test.",
"msEvalRegex()", s);
    return(MS_FALSE);
  }
  regfree(re);

  return(MS_TRUE);
}



-- 
Franck Martin <franck at sopac.org>
SOPAC

--=-D0pl64wiKB+o8FV5sV/Q
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/1.1.8">
</HEAD>
<BODY>
I modified msEvalRegex in mapfile.c as follows and now it works... I use a regex_t *re instead of a regex_t re.<BR>
<BR>
int msEvalRegex(char *e, char *s) {<BR>
&nbsp; regex_t *re;<BR>
<BR>
&nbsp; if(!e || !s) return(MS_FALSE);<BR>
&nbsp; re=malloc(sizeof(regex_t));<BR>
&nbsp; if(regcomp(re, e, REG_EXTENDED||REG_NOSUB) != 0) {<BR>
&nbsp;&nbsp;&nbsp; regfree(re);<BR>
&nbsp;&nbsp;&nbsp; msSetError(MS_REGEXERR, &quot;Failed to compile expression (%s).&quot;, &quot;msEvalRegex()&quot;, e);&nbsp;&nbsp; <BR>
&nbsp;&nbsp;&nbsp; return(MS_FALSE);<BR>
&nbsp; }<BR>
&nbsp; if(regexec(re, s, 0, NULL, 0) != 0) { // no match<BR>
&nbsp;&nbsp;&nbsp; regfree(re);<BR>
&nbsp;&nbsp;&nbsp; msSetError(MS_REGEXERR, &quot;String (%s) failed expression test.&quot;, &quot;msEvalRegex()&quot;, s);<BR>
&nbsp;&nbsp;&nbsp; return(MS_FALSE);<BR>
&nbsp; }<BR>
&nbsp; regfree(re);<BR>
<BR>
&nbsp; return(MS_TRUE);<BR>
}<BR>
<BR>
<BR>
<PRE><TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
-- <BR>
Franck Martin &lt;<A HREF="mailto:franck at sopac.org">franck at sopac.org</A>&gt;<BR>
SOPAC
</TD>
</TR>
</TABLE>
</PRE>
</BODY>
</HTML>

--=-D0pl64wiKB+o8FV5sV/Q--



More information about the mapserver-users mailing list