« Return to Thread: Problem compiling with MinGW from SVN

Re: Problem compiling with MinGW from SVN

by Sandro Santilli :: Rate this Message:

Reply to Author | View in Thread

Nicklas,
Please try the attached patch, it uses the non-reentrant version
and manual scans for the inner loop. We shouldn't really need
reentrancy in postgis ...

--strk;

 Free GIS & Flash consultant/developer      ()  ASCII Ribbon Campaign
 http://foo.keybit.net/~strk/services.html  /\  Keep it simple!

On Sun, Jul 05, 2009 at 02:32:54PM +0200, strk wrote:
> On Sun, Jul 05, 2009 at 12:35:25PM +0200, nicklas.aven@... wrote:
> >
> > Hallo
> >  
> > I tried to compile from SVN wich has worked great before. I think the problem is strtok_r() used in lwgeom_geos, that is supposed to be found in string.h as I understand it. In my version in MinGW there is no strtok_r() in string.h, but strtok(). Is it a problem of versions or?
>
> According to my manual page, strtok_r is compatible with POSIX.1-2001.
> The non _r version is not reentrant, if other developers are fine with
> that I could change to use it.

Index: postgis/lwgeom_geos.c
===================================================================
--- postgis/lwgeom_geos.c (revision 4261)
+++ postgis/lwgeom_geos.c (working copy)
@@ -862,7 +862,6 @@
  int joinStyle  = DEFAULT_JOIN_STYLE;
  char *param;
  char *params = NULL;
- char *saveptr = NULL;
 
 
  PROFSTART(PROF_QRUN);
@@ -887,24 +886,21 @@
 
  for (param=params; ; param=NULL)
  {
- char *saveptr2, *key, *val;
- param = strtok_r(param, " ", &saveptr);
+ char *key, *val;
+ param = strtok(param, " ");
  if ( param == NULL ) break;
- /* lwnotice("Param: %s", param); */
+ POSTGIS_DEBUGF(3, "Param: %s", param);
 
- key = strtok_r(param, "=", &saveptr2);
- if ( key == NULL ) {
- lwerror("Malformed buffer parameter");
- break;
- }
- val = strtok_r(NULL, "=", &saveptr2);
- if ( val == NULL ) {
+ key = param;
+ val = strchr(key, '=');
+ if ( val == NULL || *(val+1) == '\0' ) {
  lwerror("Missing value for buffer "
         "parameter %s", key);
  break;
  }
+ *val = '\0'; ++val;
 
- /* lwnotice("Param: %s : %s", key, val); */
+ POSTGIS_DEBUGF(3, "Param: %s : %s", key, val);
 
  if ( !strcmp(key, "endcap") )
  {
@@ -926,7 +922,7 @@
  else
  {
  lwerror("Invalid buffer end cap "
-        "style: %s (accept "
+        "style: %s (accept: "
         "'round', 'flat' or 'square'"
         ")", val);
  break;
@@ -950,7 +946,7 @@
  else
  {
  lwerror("Invalid buffer end cap "
-        "style: %s (accept "
+        "style: %s (accept: "
         "'round', 'mitre' or 'bevel'"
         ")", val);
  break;
@@ -968,7 +964,7 @@
  }
  else
  {
- lwerror("Invalid buffer parameter: %s (accept"
+ lwerror("Invalid buffer parameter: %s (accept: "
         "'endcap', 'join', 'mitre_limit' and "
         "'quad_segs')", key);
  break;

_______________________________________________
postgis-devel mailing list
postgis-devel@...
http://postgis.refractions.net/mailman/listinfo/postgis-devel

 « Return to Thread: Problem compiling with MinGW from SVN