[mapserver-commits] r11190 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Thu Mar 17 10:24:24 EDT 2011


Author: pramsey
Date: 2011-03-17 07:24:24 -0700 (Thu, 17 Mar 2011)
New Revision: 11190

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapimageio.c
   trunk/mapserver/maplexer.c
   trunk/mapserver/mapogcfilter.c
   trunk/mapserver/mapogcsos.c
   trunk/mapserver/mapserver.h
   trunk/mapserver/mapstring.c
   trunk/mapserver/maptemplate.c
   trunk/mapserver/mapwms.c
Log:
Globally replace msCaseFindSubstring with strcasestr (#3255)


Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2011-03-17 14:19:39 UTC (rev 11189)
+++ trunk/mapserver/HISTORY.TXT	2011-03-17 14:24:24 UTC (rev 11190)
@@ -14,6 +14,8 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- Globally replace msCaseFindSubstring with strcasestr (#3255)
+
 - support GROUP layers in shp2img (#3746)
 
 - Honour MAXSIZE for WCS 2.0 responses (#3204).

Modified: trunk/mapserver/mapimageio.c
===================================================================
--- trunk/mapserver/mapimageio.c	2011-03-17 14:19:39 UTC (rev 11189)
+++ trunk/mapserver/mapimageio.c	2011-03-17 14:24:24 UTC (rev 11190)
@@ -770,21 +770,21 @@
     if(format->transparent)
         gdImageColorTransparent(ip, 0);
 
-    if(msCaseFindSubstring(format->driver, "/gif")) {
+    if(strcasestr(format->driver, "/gif")) {
 #ifdef USE_GD_GIF
         gdImageGif(ip, fp);
 #else
         msSetError(MS_MISCERR, "GIF output is not available.", "saveImageGD()");
         return(MS_FAILURE);
 #endif
-    } else if(msCaseFindSubstring(format->driver, "/png")) {
+    } else if(strcasestr(format->driver, "/png")) {
 #ifdef USE_GD_PNG
         gdImagePng(ip, fp);
 #else
         msSetError(MS_MISCERR, "PNG output is not available.", "saveImageGD()");
         return(MS_FAILURE);
 #endif
-    } else if(msCaseFindSubstring(format->driver, "/jpeg")) {
+    } else if(strcasestr(format->driver, "/jpeg")) {
 #ifdef USE_GD_JPEG
         gdImageJpeg(ip, fp, atoi(msGetOutputFormatOption( format, "QUALITY", "75")));
 #else
@@ -816,7 +816,7 @@
     if(format->transparent)
         gdImageColorTransparent(ip, 0);
 
-    if(msCaseFindSubstring(format->driver, "/gif")) {
+    if(strcasestr(format->driver, "/gif")) {
 #ifdef USE_GD_GIF
         gdImageGifCtx( ip, ctx );
 #else
@@ -824,7 +824,7 @@
         ctx->gd_free(ctx);
         return(MS_FAILURE);
 #endif
-    } else if(msCaseFindSubstring(format->driver, "/png")) {
+    } else if(strcasestr(format->driver, "/png")) {
 #ifdef USE_GD_PNG
         gdImagePngCtx(ip, ctx);
 #else
@@ -832,7 +832,7 @@
         ctx->gd_free(ctx);
         return(MS_FAILURE);
 #endif
-    } else if(msCaseFindSubstring(format->driver, "/jpeg")) {
+    } else if(strcasestr(format->driver, "/jpeg")) {
 #ifdef USE_GD_JPEG
         gdImageJpegCtx(ip, ctx, atoi(msGetOutputFormatOption( format, "QUALITY", "75")));
 #else
@@ -860,13 +860,13 @@
 	if(rb->type == MS_BUFFER_GD) {
 		return saveGdImage(rb->data.gd_img, stream, format);
 	}
-    if(msCaseFindSubstring(format->driver,"/png")) {
+    if(strcasestr(format->driver,"/png")) {
         streamInfo info;
         info.fp = stream;
         info.buffer = NULL;
         
         return saveAsPNG(rb,&info,format);
-    } else if(msCaseFindSubstring(format->driver,"/jpeg")) {
+    } else if(strcasestr(format->driver,"/jpeg")) {
         streamInfo info;
         info.fp = stream;
         info.buffer=NULL;
@@ -882,12 +882,12 @@
     if(data->type == MS_BUFFER_GD) {
 		return saveGdImageBuffer(data->data.gd_img, buffer, format);
 	}
-    if(msCaseFindSubstring(format->driver,"/png")) {
+    if(strcasestr(format->driver,"/png")) {
         streamInfo info;
         info.fp = NULL;
         info.buffer = buffer;
         return saveAsPNG(data,&info,format);
-    } else if(msCaseFindSubstring(format->driver,"/jpeg")) {
+    } else if(strcasestr(format->driver,"/jpeg")) {
         streamInfo info;
         info.fp = NULL;
         info.buffer=buffer;

Modified: trunk/mapserver/maplexer.c
===================================================================
--- trunk/mapserver/maplexer.c	2011-03-17 14:19:39 UTC (rev 11189)
+++ trunk/mapserver/maplexer.c	2011-03-17 14:24:24 UTC (rev 11190)
@@ -73,6 +73,7 @@
 typedef unsigned char flex_uint8_t; 
 typedef unsigned short int flex_uint16_t;
 typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
 
 /* Limits of integral types. */
 #ifndef INT8_MIN
@@ -103,8 +104,6 @@
 #define UINT32_MAX             (4294967295U)
 #endif
 
-#endif /* ! C99 */
-
 #endif /* ! FLEXINT_H */
 
 #ifdef __cplusplus
@@ -161,15 +160,7 @@
 
 /* Size of default input buffer. */
 #ifndef YY_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k.
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
- * Ditto for the __ia64__ case accordingly.
- */
-#define YY_BUF_SIZE 32768
-#else
 #define YY_BUF_SIZE 16384
-#endif /* __ia64__ */
 #endif
 
 /* The state buf must be large enough to hold one state per character in the main buffer.
@@ -181,8 +172,13 @@
 typedef struct yy_buffer_state *YY_BUFFER_STATE;
 #endif
 
-extern int msyyleng;
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
 
+extern yy_size_t msyyleng;
+
 extern FILE *msyyin, *msyyout;
 
 #define EOB_ACT_CONTINUE_SCAN 0
@@ -207,11 +203,6 @@
 
 #define unput(c) yyunput( c, (yytext_ptr)  )
 
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
 #ifndef YY_STRUCT_YY_BUFFER_STATE
 #define YY_STRUCT_YY_BUFFER_STATE
 struct yy_buffer_state
@@ -229,7 +220,7 @@
 	/* Number of characters read into yy_ch_buf, not including EOB
 	 * characters.
 	 */
-	int yy_n_chars;
+	yy_size_t yy_n_chars;
 
 	/* Whether we "own" the buffer - i.e., we know we created it,
 	 * and can realloc() it to grow it, and should free() it to
@@ -299,8 +290,8 @@
 
 /* yy_hold_char holds the character lost when msyytext is formed. */
 static char yy_hold_char;
-static int yy_n_chars;		/* number of characters read into yy_ch_buf */
-int msyyleng;
+static yy_size_t yy_n_chars;		/* number of characters read into yy_ch_buf */
+yy_size_t msyyleng;
 
 /* Points to current character in buffer. */
 static char *yy_c_buf_p = (char *) 0;
@@ -328,7 +319,7 @@
 
 YY_BUFFER_STATE msyy_scan_buffer (char *base,yy_size_t size  );
 YY_BUFFER_STATE msyy_scan_string (yyconst char *yy_str  );
-YY_BUFFER_STATE msyy_scan_bytes (yyconst char *bytes,int len  );
+YY_BUFFER_STATE msyy_scan_bytes (yyconst char *bytes,yy_size_t len  );
 
 void *msyyalloc (yy_size_t  );
 void *msyyrealloc (void *,yy_size_t  );
@@ -2109,7 +2100,7 @@
 
 void msyyset_out  (FILE * out_str  );
 
-int msyyget_leng (void );
+yy_size_t msyyget_leng (void );
 
 char *msyyget_text (void );
 
@@ -2151,12 +2142,7 @@
 
 /* Amount of stuff to slurp up with each read. */
 #ifndef YY_READ_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k */
-#define YY_READ_BUF_SIZE 16384
-#else
 #define YY_READ_BUF_SIZE 8192
-#endif /* __ia64__ */
 #endif
 
 /* Copy whatever the last rule matched to the standard output. */
@@ -2164,7 +2150,7 @@
 /* This used to be an fputs(), but since the string might contain NUL's,
  * we now use fwrite().
  */
-#define ECHO do { if (fwrite( msyytext, msyyleng, 1, msyyout )) {} } while (0)
+#define ECHO fwrite( msyytext, msyyleng, 1, msyyout )
 #endif
 
 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
@@ -2175,7 +2161,7 @@
 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
 		{ \
 		int c = '*'; \
-		size_t n; \
+		yy_size_t n; \
 		for ( n = 0; n < max_size && \
 			     (c = getc( msyyin )) != EOF && c != '\n'; ++n ) \
 			buf[n] = (char) c; \
@@ -4313,7 +4299,7 @@
 
 	else
 		{
-			int num_to_read =
+			yy_size_t num_to_read =
 			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
 
 		while ( num_to_read <= 0 )
@@ -4327,7 +4313,7 @@
 
 			if ( b->yy_is_our_buffer )
 				{
-				int new_size = b->yy_buf_size * 2;
+				yy_size_t new_size = b->yy_buf_size * 2;
 
 				if ( new_size <= 0 )
 					b->yy_buf_size += b->yy_buf_size / 8;
@@ -4358,7 +4344,7 @@
 
 		/* Read in more data. */
 		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
-			(yy_n_chars), (size_t) num_to_read );
+			(yy_n_chars), num_to_read );
 
 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
 		}
@@ -4468,7 +4454,7 @@
 	if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
 		{ /* need to shift things up to make room */
 		/* +2 for EOB chars. */
-		register int number_to_move = (yy_n_chars) + 2;
+		register yy_size_t number_to_move = (yy_n_chars) + 2;
 		register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
 					YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
 		register char *source =
@@ -4517,7 +4503,7 @@
 
 		else
 			{ /* need more input */
-			int offset = (yy_c_buf_p) - (yytext_ptr);
+			yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
 			++(yy_c_buf_p);
 
 			switch ( yy_get_next_buffer(  ) )
@@ -4541,7 +4527,7 @@
 				case EOB_ACT_END_OF_FILE:
 					{
 					if ( msyywrap( ) )
-						return EOF;
+						return 0;
 
 					if ( ! (yy_did_buffer_switch_on_eof) )
 						YY_NEW_FILE;
@@ -4793,7 +4779,7 @@
  */
 static void msyyensure_buffer_stack (void)
 {
-	int num_to_alloc;
+	yy_size_t num_to_alloc;
     
 	if (!(yy_buffer_stack)) {
 
@@ -4885,17 +4871,16 @@
 
 /** Setup the input buffer state to scan the given bytes. The next call to msyylex() will
  * scan from a @e copy of @a bytes.
- * @param yybytes the byte buffer to scan
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ * @param bytes the byte buffer to scan
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
  * 
  * @return the newly allocated buffer state object.
  */
-YY_BUFFER_STATE msyy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len )
+YY_BUFFER_STATE msyy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len )
 {
 	YY_BUFFER_STATE b;
 	char *buf;
-	yy_size_t n;
-	int i;
+	yy_size_t n, i;
     
 	/* Get memory for full buffer, including space for trailing EOB's. */
 	n = _yybytes_len + 2;
@@ -4977,7 +4962,7 @@
 /** Get the length of the current token.
  * 
  */
-int msyyget_leng  (void)
+yy_size_t msyyget_leng  (void)
 {
         return msyyleng;
 }

Modified: trunk/mapserver/mapogcfilter.c
===================================================================
--- trunk/mapserver/mapogcfilter.c	2011-03-17 14:19:39 UTC (rev 11189)
+++ trunk/mapserver/mapogcfilter.c	2011-03-17 14:24:24 UTC (rev 11190)
@@ -463,24 +463,24 @@
       
     if (lp->connectiontype ==  MS_ORACLESPATIAL && FLTIsSimpleFilterNoSpatial(psNode))
     {
-        if (msCaseFindSubstring(lp->data, "USING") == 0)
+        if (strcasestr(lp->data, "USING") == 0)
           lp->data = msStringConcatenate(lp->data, " USING NONE"); 
-        else if (msCaseFindSubstring(lp->data, "NONE") == 0)
+        else if (strcasestr(lp->data, "NONE") == 0)
         {
             /*if one of the functions is used, just replace it with NONE*/
-            if (msCaseFindSubstring(lp->data, "FILTER"))
+            if (strcasestr(lp->data, "FILTER"))
               lp->data = msCaseReplaceSubstring(lp->data, "FILTER", "NONE");
-            else if (msCaseFindSubstring(lp->data, "GEOMRELATE"))
+            else if (strcasestr(lp->data, "GEOMRELATE"))
               lp->data = msCaseReplaceSubstring(lp->data, "GEOMRELATE", "NONE");
-            else if (msCaseFindSubstring(lp->data, "RELATE"))
+            else if (strcasestr(lp->data, "RELATE"))
               lp->data = msCaseReplaceSubstring(lp->data, "RELATE", "NONE");
-            else if (msCaseFindSubstring(lp->data, "VERSION"))
+            else if (strcasestr(lp->data, "VERSION"))
             {
                 /*should add NONE just before the VERSION. Cases are:
                   DATA "ORA_GEOMETRY FROM data USING VERSION 10g
                   DATA "ORA_GEOMETRY FROM data  USING UNIQUE FID VERSION 10g"
                  */
-                pszTmp = (char *)msCaseFindSubstring(lp->data, "VERSION");
+                pszTmp = (char *)strcasestr(lp->data, "VERSION");
                 pszTmp2 = msStringConcatenate(pszTmp2, " NONE ");
                 pszTmp2 = msStringConcatenate(pszTmp2, pszTmp);
                 
@@ -489,7 +489,7 @@
                 msFree(pszTmp2);
                 
             }
-            else if (msCaseFindSubstring(lp->data, "SRID"))
+            else if (strcasestr(lp->data, "SRID"))
             {
                 lp->data = msStringConcatenate(lp->data, " NONE"); 
             }

Modified: trunk/mapserver/mapogcsos.c
===================================================================
--- trunk/mapserver/mapogcsos.c	2011-03-17 14:19:39 UTC (rev 11189)
+++ trunk/mapserver/mapogcsos.c	2011-03-17 14:24:24 UTC (rev 11190)
@@ -2669,7 +2669,7 @@
              within sos_describesensor_url */
           tmpstr = (char *)malloc(sizeof(char)*strlen("procedure") + 3);
           sprintf(tmpstr,"%%%s%%", "procedure");
-          if (msCaseFindSubstring(pszUrl, tmpstr) != NULL)
+          if (strcasestr(pszUrl, tmpstr) != NULL)
             pszTmp = msCaseReplaceSubstring(pszTmp, tmpstr, pszProcedureId);
           msFree(tmpstr);
 
@@ -2729,7 +2729,7 @@
                      within sos_describesensor_url */
                   tmpstr = (char *)malloc(sizeof(char)*strlen("procedure") + 3);
                   sprintf(tmpstr,"%%%s%%", "procedure");
-                  if (msCaseFindSubstring(pszUrl, tmpstr) != NULL)
+                  if (strcasestr(pszUrl, tmpstr) != NULL)
                     pszTmp = msCaseReplaceSubstring(pszTmp, tmpstr, pszProcedureId);
                   msFree(tmpstr);
 

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2011-03-17 14:19:39 UTC (rev 11189)
+++ trunk/mapserver/mapserver.h	2011-03-17 14:24:24 UTC (rev 11190)
@@ -1874,7 +1874,6 @@
 MS_DLL_EXPORT char *msJoinStrings(char **array, int arrayLength, const char *delimeter);
 MS_DLL_EXPORT char *msHashString(const char *pszStr);
 MS_DLL_EXPORT char *msCommifyString(char *str);
-MS_DLL_EXPORT const char *msCaseFindSubstring(const char *haystack, const char *needle);
 MS_DLL_EXPORT int msHexToInt(char *hex);
 MS_DLL_EXPORT char *msGetEncodedString(const char *string, const char *encoding);
 MS_DLL_EXPORT char *msConvertWideStringToUTF8 (const wchar_t* string, const char* encoding);

Modified: trunk/mapserver/mapstring.c
===================================================================
--- trunk/mapserver/mapstring.c	2011-03-17 14:19:39 UTC (rev 11189)
+++ trunk/mapserver/mapstring.c	2011-03-17 14:24:24 UTC (rev 11190)
@@ -1458,39 +1458,6 @@
 }
 
 
-/************************************************************************/
-/*                  case incensitive equivalent of strstr               */
-/************************************************************************/
-const char *msCaseFindSubstring(const char *haystack, const char *needle)
-{   
-    if ( !*needle )   
-    {      
-        return haystack;   
-    }   
-    for ( ; *haystack; ++haystack )   
-    {      
-        if ( toupper(*haystack) == toupper(*needle) )      
-        {         
-            /*          * Matched starting char -- loop through remaining chars.          */
-            const char *h, *n;         
-            for ( h = haystack, n = needle; *h && *n; ++h, ++n )         
-            {            
-                if ( toupper(*h) != toupper(*n) )            
-                {
-                    break;            
-                }         
-            }         
-            if ( !*n ) /* matched all of 'needle' to null termination */         
-            {            
-                return haystack; /* return the start of the match */         
-            }      
-        }   
-    }   
-    return 0;
-}
-
-
-
 /* ------------------------------------------------------------------------------- */
 /*       Replace all occurances of old with new in str.                            */
 /*       It is assumed that str was dynamically created using malloc.              */
@@ -1507,7 +1474,7 @@
       /*
       ** If old is not found then leave str alone
       */
-      if( (tmp_ptr = (char *) msCaseFindSubstring(str, old)) == NULL)
+      if( (tmp_ptr = (char *) strcasestr(str, old)) == NULL)
 	return(str);
 
       /*
@@ -1548,7 +1515,7 @@
         /*
         ** And look for more matches in the rest of the string
         */
-        tmp_ptr = (char *) msCaseFindSubstring(tmp_ptr + new_len, old);
+        tmp_ptr = (char *) strcasestr(tmp_ptr + new_len, old);
       }
 
       return(str);

Modified: trunk/mapserver/maptemplate.c
===================================================================
--- trunk/mapserver/maptemplate.c	2011-03-17 14:19:39 UTC (rev 11189)
+++ trunk/mapserver/maptemplate.c	2011-03-17 14:24:24 UTC (rev 11190)
@@ -80,7 +80,7 @@
   char buffer[MS_BUFFER_LENGTH];
 
   if(fgets(buffer, MS_BUFFER_LENGTH, stream) != NULL) {
-    if(!msCaseFindSubstring(buffer, MS_TEMPLATE_MAGIC_STRING)) {
+    if(!strcasestr(buffer, MS_TEMPLATE_MAGIC_STRING)) {
       msSetError(MS_WEBERR, "Missing magic string, %s doesn't look like a MapServer template.", "isValidTemplate()", filename);
       return MS_FALSE;
     }
@@ -1775,33 +1775,33 @@
 
           if (tShape.numlines > 0)
           {
-              if(msCaseFindSubstring(tagValue, "$x") != 0)
+              if(strcasestr(tagValue, "$x") != 0)
               {
                   snprintf(number, sizeof(number), numberFormat, tShape.line[0].point[0].x);
                   tagValue = msReplaceSubstring(tagValue, "$x", number);
               }
-              if(msCaseFindSubstring(tagValue, "$y") != 0)
+              if(strcasestr(tagValue, "$y") != 0)
               {
                   snprintf(number, sizeof(number), numberFormat, tShape.line[0].point[0].y);
                   tagValue = msReplaceSubstring(tagValue, "$y", number);
               }
           
-              if(msCaseFindSubstring(tagValue, "$minx") != 0)
+              if(strcasestr(tagValue, "$minx") != 0)
               {
                   snprintf(number, sizeof(number), numberFormat, tShape.line[0].point[0].x);
                   tagValue = msReplaceSubstring(tagValue, "$minx", number);
               }
-              if(msCaseFindSubstring(tagValue, "$miny") != 0)
+              if(strcasestr(tagValue, "$miny") != 0)
               {
                   snprintf(number, sizeof(number), numberFormat, tShape.line[0].point[0].y);
                   tagValue = msReplaceSubstring(tagValue, "$miny", number);
               }
-              if(msCaseFindSubstring(tagValue, "$maxx") != 0)
+              if(strcasestr(tagValue, "$maxx") != 0)
               {
                   snprintf(number, sizeof(number), numberFormat, tShape.line[0].point[1].x);
                   tagValue = msReplaceSubstring(tagValue, "$maxx", number);
               }
-              if(msCaseFindSubstring(tagValue, "$maxy") != 0)
+              if(strcasestr(tagValue, "$maxy") != 0)
               {
                   snprintf(number, sizeof(number), numberFormat, tShape.line[0].point[1].y);
                   tagValue = msReplaceSubstring(tagValue, "$maxy", number);

Modified: trunk/mapserver/mapwms.c
===================================================================
--- trunk/mapserver/mapwms.c	2011-03-17 14:19:39 UTC (rev 11189)
+++ trunk/mapserver/mapwms.c	2011-03-17 14:24:24 UTC (rev 11190)
@@ -2276,14 +2276,14 @@
             }
         }
         /*add text/plain and gml */
-        if (msCaseFindSubstring(format_list, "GML") == 0 &&
-            msCaseFindSubstring(format_list, "application/vnd.ogc.gml") == 0)
+        if (strcasestr(format_list, "GML") == 0 &&
+            strcasestr(format_list, "application/vnd.ogc.gml") == 0)
         {
             if (mime_count<max_mime)
               mime_list[mime_count++] = "application/vnd.ogc.gml";
         }
-        if (msCaseFindSubstring(format_list, "text/plain") == 0 &&
-            msCaseFindSubstring(format_list, "MIME") == 0)
+        if (strcasestr(format_list, "text/plain") == 0 &&
+            strcasestr(format_list, "MIME") == 0)
         {
             if (mime_count<max_mime)
               mime_list[mime_count++] = "text/plain";
@@ -3150,7 +3150,7 @@
         since old way of using template with web->header/footer and
         layer templates need to still be supported. 
         We can only validate if it was part of the format list*/
-      if (msCaseFindSubstring(format_list, info_format))
+      if (strcasestr(format_list, info_format))
         valid_format = MS_TRUE;
   }
    /*check to see if the format passed is text/plain or GML and if is



More information about the mapserver-commits mailing list