[mapserver-commits] r7605 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Tue May 20 23:43:49 EDT 2008


Author: sdlime
Date: 2008-05-20 23:43:49 -0400 (Tue, 20 May 2008)
New Revision: 7605

Modified:
   trunk/mapserver/configure
   trunk/mapserver/configure.in
   trunk/mapserver/mapquery.c
   trunk/mapserver/mapserver.h
   trunk/mapserver/mapstring.c
   trunk/mapserver/maptemplate.c
Log:
Added support for 'trimlast' attribute of a [feature ...][/feature] tag. As part of that work a copy of the strrstr (and associated MIT license) function was also added as was configure support to detect it's presence. (#2576)

Modified: trunk/mapserver/configure
===================================================================
--- trunk/mapserver/configure	2008-05-20 19:24:32 UTC (rev 7604)
+++ trunk/mapserver/configure	2008-05-21 03:43:49 UTC (rev 7605)
@@ -4703,6 +4703,93 @@
   STRINGS="-DNEED_STRDUP $STRINGS"
 fi
 
+{ echo "$as_me:$LINENO: checking for strrstr" >&5
+echo $ECHO_N "checking for strrstr... $ECHO_C" >&6; }
+if test "${ac_cv_func_strrstr+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define strrstr to an innocuous variant, in case <limits.h> declares strrstr.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define strrstr innocuous_strrstr
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char strrstr (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef strrstr
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char strrstr ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_strrstr || defined __stub___strrstr
+choke me
+#endif
+
+int
+main ()
+{
+return strrstr ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_func_strrstr=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_func_strrstr=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_strrstr" >&5
+echo "${ECHO_T}$ac_cv_func_strrstr" >&6; }
+if test $ac_cv_func_strrstr = yes; then
+  :
+else
+  STRINGS="-DNEED_STRRSTR $STRINGS"
+fi
+
 { echo "$as_me:$LINENO: checking for strlcat" >&5
 echo $ECHO_N "checking for strlcat... $ECHO_C" >&6; }
 if test "${ac_cv_func_strlcat+set}" = set; then

Modified: trunk/mapserver/configure.in
===================================================================
--- trunk/mapserver/configure.in	2008-05-20 19:24:32 UTC (rev 7604)
+++ trunk/mapserver/configure.in	2008-05-21 03:43:49 UTC (rev 7605)
@@ -67,6 +67,7 @@
 AC_CHECK_FUNC(strcasecmp, ,  STRINGS="-DNEED_STRCASECMP $STRINGS")
 AC_CHECK_FUNC(strncasecmp, , STRINGS="-DNEED_STRNCASECMP $STRINGS")
 AC_CHECK_FUNC(strdup, ,      STRINGS="-DNEED_STRDUP $STRINGS")
+AC_CHECK_FUNC(strrstr, ,      STRINGS="-DNEED_STRRSTR $STRINGS")
 AC_CHECK_FUNC(strlcat, ,      STRINGS="-DNEED_STRLCAT $STRINGS")
 AC_CHECK_FUNC(vsnprintf, STRINGS="-DHAVE_VSNPRINTF $STRINGS", )
 AC_SUBST(STRINGS, $STRINGS)

Modified: trunk/mapserver/mapquery.c
===================================================================
--- trunk/mapserver/mapquery.c	2008-05-20 19:24:32 UTC (rev 7604)
+++ trunk/mapserver/mapquery.c	2008-05-21 03:43:49 UTC (rev 7605)
@@ -291,6 +291,8 @@
     return(MS_FAILURE);
   }
 
+  printf("ready to query...\n");
+
   /* save any previously defined filter */
   if(lp->filter.string) {
     old_filtertype = lp->filter.type;
@@ -324,6 +326,9 @@
   else
     lp->project = MS_FALSE;
 #endif
+
+  printf("search rect: %g,%g %g,%g\n", searchrect.minx,searchrect.miny, searchrect.maxx,searchrect.maxy);
+
   status = msLayerWhichShapes(lp, searchrect);
   if(status == MS_DONE) { /* no overlap */
     msLayerClose(lp);
@@ -346,12 +351,16 @@
 
   while((status = msLayerNextShape(lp, &shape)) == MS_SUCCESS) { /* step through the shapes */
 
+    printf("next shape\n");
+
     shape.classindex = msShapeGetClass(lp, &shape, map->scaledenom, classgroup, nclasses );    
     if(!(lp->template) && ((shape.classindex == -1) || (lp->class[shape.classindex]->status == MS_OFF))) { /* not a valid shape */
       msFreeShape(&shape);
       continue;
     }
     
+    printf("next shape (class ok)\n");
+
     if(!(lp->template) && !(lp->class[shape.classindex]->template)) { /* no valid template */
       msFreeShape(&shape);
       continue;

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2008-05-20 19:24:32 UTC (rev 7604)
+++ trunk/mapserver/mapserver.h	2008-05-21 03:43:49 UTC (rev 7605)
@@ -1631,6 +1631,10 @@
 MS_DLL_EXPORT char *strdup(char *s);
 #endif /* NEED_STRDUP */
 
+#ifdef NEED_STRRSTR
+MS_DLL_EXPORT char *strrstr(char *string, char *find);
+#endif /* NEED_STRRSTR */
+
 #ifdef NEED_STRNCASECMP
 MS_DLL_EXPORT int strncasecmp(const char *s1, const char *s2, int len);
 #endif /* NEED_STRNCASECMP */

Modified: trunk/mapserver/mapstring.c
===================================================================
--- trunk/mapserver/mapstring.c	2008-05-20 19:24:32 UTC (rev 7604)
+++ trunk/mapserver/mapstring.c	2008-05-21 03:43:49 UTC (rev 7605)
@@ -50,6 +50,61 @@
 
 #include "mapentities.h"
 
+#ifdef NEED_STRRSTR
+/* 
+** Copyright (c) 2000-2004  University of Illinois Board of Trustees
+** Copyright (c) 2000-2005  Mark D. Roth
+** All rights reserved.
+**
+** Developed by: Campus Information Technologies and Educational Services,
+** University of Illinois at Urbana-Champaign
+**
+** Permission is hereby granted, free of charge, to any person obtaining
+** a copy of this software and associated documentation files (the
+** ``Software''), to deal with the Software without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Software, and to
+** permit persons to whom the Software is furnished to do so, subject to
+** the following conditions:
+** 
+** * Redistributions of source code must retain the above copyright
+**   notice, this list of conditions and the following disclaimers.
+**
+** * Redistributions in binary form must reproduce the above copyright
+**   notice, this list of conditions and the following disclaimers in the
+**   documentation and/or other materials provided with the distribution.
+** 
+** * Neither the names of Campus Information Technologies and Educational
+**   Services, University of Illinois at Urbana-Champaign, nor the names
+**   of its contributors may be used to endorse or promote products derived
+**   from this Software without specific prior written permission.
+**
+** THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+** ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+** OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
+*/
+char *strrstr(char *string, char *find)
+{
+  size_t stringlen, findlen;
+  char *cp;
+
+  findlen = strlen(find);
+  stringlen = strlen(string);
+  if (findlen > stringlen)
+    return NULL;
+
+  for (cp = string + stringlen - findlen; cp >= string; cp--)
+    if (strncmp(cp, find, findlen) == 0)
+      return cp;
+
+  return NULL;
+}
+#endif
+
 #ifdef NEED_STRLCAT
 /*
  * Copyright (c) 1998 Todd C. Miller <Todd.Miller at courtesan.com>

Modified: trunk/mapserver/maptemplate.c
===================================================================
--- trunk/mapserver/maptemplate.c	2008-05-20 19:24:32 UTC (rev 7604)
+++ trunk/mapserver/maptemplate.c	2008-05-21 03:43:49 UTC (rev 7605)
@@ -829,7 +829,8 @@
   char *tag, *tagInstance, *tagStart;
   hashTableObj *tagArgs=NULL;
 
-  int limit = -1;
+  int limit=-1;
+  char *trimLast=NULL;
 
   int i, j, status;
 
@@ -846,6 +847,9 @@
   if(tagArgs) {
     argValue = msLookupHashTable(tagArgs, "limit");
     if(argValue) limit = atoi(argValue);
+
+    argValue = msLookupHashTable(tagArgs, "trimlast");
+    if(argValue) trimLast = argValue;
   }
 
   if(strstr(*line, "[/feature]") == NULL) { /* we know the closing tag must be here, if not throw an error */
@@ -902,6 +906,15 @@
       }
     }
 
+    /*
+    ** if necessary trim a few characters off the end of the tag
+    */
+    if(trimLast && (i == limit-1)) {    
+      char *ptr;
+      if((ptr = strrstr(tag, trimLast)) != NULL)
+        *ptr = '\0';
+    }
+
     /* process the tag */
     tagInstance = processLine(mapserv, tag, NULL, QUERY); /* do substitutions */
     *line = msStringConcatenate(*line, tagInstance); /* grow the line */
@@ -3336,10 +3349,10 @@
     return MS_FAILURE;
   }
 
-  tmpurl = processLine(ms, url, NULL, mode); /* URL templates can't handle multi-line tags, hence the NULL */
+  tmpurl = processLine(ms, url, NULL, mode); /* URL templates can't handle multi-line tags, hence the NULL file pointer */
  
   if(!tmpurl)
-     return MS_FAILURE;
+   return MS_FAILURE;
    
   msRedirect(tmpurl);
   free(tmpurl);
@@ -3352,9 +3365,9 @@
   int status;
   int i,j,k;
   char buffer[1024];
-  int   nBufferSize =0;
-  int   nCurrentSize = 0;
-  int   nExpandBuffer = 0;
+  int nBufferSize =0;
+  int nCurrentSize = 0;
+  int nExpandBuffer = 0;
 
   char *template;
 



More information about the mapserver-commits mailing list