[mapserver-commits] r8006 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Tue Nov 4 14:24:49 EST 2008
Author: pramsey
Date: 2008-11-04 14:24:49 -0500 (Tue, 04 Nov 2008)
New Revision: 8006
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mappostgis.c
trunk/mapserver/mapserver.h
trunk/mapserver/mapstring.c
Log:
msStringTrim for trimming parsed PostGIS parameters
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2008-11-04 06:48:07 UTC (rev 8005)
+++ trunk/mapserver/HISTORY.TXT 2008-11-04 19:24:49 UTC (rev 8006)
@@ -12,6 +12,8 @@
Current Version (5.3-dev, SVN trunk):
------------------------------------
+- mapstring.c: msStringTrim(*char str), front-and-back whitespace trimmer
+
- mappostgis.c: re-write to remove binary cursors and break up
logic into smaller parts, add support for maxfeatures
Modified: trunk/mapserver/mappostgis.c
===================================================================
--- trunk/mapserver/mappostgis.c 2008-11-04 06:48:07 UTC (rev 8005)
+++ trunk/mapserver/mappostgis.c 2008-11-04 19:24:49 UTC (rev 8006)
@@ -594,6 +594,7 @@
layerinfo->uid = (char*) malloc((tmp - (pos_uid + 14)) + 1);
strncpy(layerinfo->uid, pos_uid + 14, tmp - (pos_uid + 14));
(layerinfo->uid)[tmp - (pos_uid + 14)] = '\0'; /* null terminate it */
+ msStringTrim(layerinfo->uid);
}
/*
@@ -612,6 +613,7 @@
layerinfo->srid = (char*) malloc(slength + 1);
strncpy(layerinfo->srid, pos_srid + 12, slength);
(layerinfo->srid)[slength] = '\0'; /* null terminate it */
+ msStringTrim(layerinfo->srid);
}
}
@@ -646,11 +648,13 @@
layerinfo->geomcolumn = (char*) malloc((pos_scn - data) + 1);
strncpy(layerinfo->geomcolumn, data, pos_scn - data);
(layerinfo->geomcolumn)[pos_scn - data] = '\0';
+ msStringTrim(layerinfo->geomcolumn);
/* Copy the table name or sub-select clause */
layerinfo->fromsource = (char*) malloc((pos_opt - (pos_scn + 6)) + 1);
strncpy(layerinfo->fromsource, pos_scn + 6, pos_opt - (pos_scn + 6));
(layerinfo->fromsource)[pos_opt - (pos_scn + 6)] = '\0';
+ msStringTrim(layerinfo->fromsource);
/* Something is wrong, our goemetry column and table references are not there. */
if (strlen(layerinfo->fromsource) < 1 || strlen(layerinfo->geomcolumn) < 1) {
Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h 2008-11-04 06:48:07 UTC (rev 8005)
+++ trunk/mapserver/mapserver.h 2008-11-04 19:24:49 UTC (rev 8006)
@@ -1602,8 +1602,9 @@
MS_DLL_EXPORT int msRasterQueryByPoint(mapObj *map, layerObj *layer, int mode,
pointObj p, double buffer );
-
-MS_DLL_EXPORT void msStringTrimBlanks(char *string); /* in mapstring.c */
+/* in mapstring.c */
+MS_DLL_EXPORT void msStringTrim(char *str);
+MS_DLL_EXPORT void msStringTrimBlanks(char *string);
MS_DLL_EXPORT char *msStringTrimLeft(char *string);
MS_DLL_EXPORT char *msStringChop(char *string);
MS_DLL_EXPORT void msStringTrimEOL(char *string);
Modified: trunk/mapserver/mapstring.c
===================================================================
--- trunk/mapserver/mapstring.c 2008-11-04 06:48:07 UTC (rev 8005)
+++ trunk/mapserver/mapstring.c 2008-11-04 19:24:49 UTC (rev 8006)
@@ -352,10 +352,38 @@
return(string);
}
-/**
- * remove leading white spaces and shif evey thing to the left
- */
+/*
+** Trim leading and trailing white space.
+*/
+void msStringTrim(char *str)
+{
+ int i;
+ /* Send nulls home without supper. */
+ if( ! str ) return;
+
+ /* Move non-white string to the front. */
+ i = strspn(str, " ");
+ if(i) {
+ memmove(str, str + i, strlen(str) - i + 1);
+ }
+ /* Nothing left? Exit. */
+ if(strlen(str) == 0) {
+ return;
+ }
+ /* Null-terminate end of non-white string. */
+ for(i=strlen(str)-1; i>=0; i--) { /* step backwards from end */
+ if(str[i] != ' ') {
+ str[i+1] = '\0';
+ return;
+ }
+ }
+ return;
+}
+
+/*
+** Remove leading white spaces and shift everything to the left.
+*/
char *msStringTrimLeft(char *string)
{
char *read, *write;
@@ -390,7 +418,7 @@
}
/* ------------------------------------------------------------------------------- */
-/* Trims leading blanks from a string */
+/* Trims trailing blanks from a string */
/* ------------------------------------------------------------------------------- */
void msStringTrimBlanks(char *string)
{
More information about the mapserver-commits
mailing list