[mapserver-commits] r7360 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Wed Feb 6 22:03:34 EST 2008


Author: tomkralidis
Date: 2008-02-06 22:03:34 -0500 (Wed, 06 Feb 2008)
New Revision: 7360

Modified:
   trunk/mapserver/mapserver.h
   trunk/mapserver/mapstring.c
Log:
add utility function for testing strings as ints (#2384)


Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2008-02-06 19:46:37 UTC (rev 7359)
+++ trunk/mapserver/mapserver.h	2008-02-07 03:03:34 UTC (rev 7360)
@@ -1620,6 +1620,7 @@
 MS_DLL_EXPORT int msGetNextGlyph(const char **in_ptr, char *out_string);
 MS_DLL_EXPORT int msGetNumGlyphs(const char *in_ptr);
 MS_DLL_EXPORT int msGetUnicodeEntity(const char *inptr, int *unicode);
+MS_DLL_EXPORT int msStringIsInteger(const char *string);
 MS_DLL_EXPORT int msUTF8ToUniChar(const char *str, int *chPtr); /* maptclutf.c */
 
 #ifdef NEED_STRDUP

Modified: trunk/mapserver/mapstring.c
===================================================================
--- trunk/mapserver/mapstring.c	2008-02-06 19:46:37 UTC (rev 7359)
+++ trunk/mapserver/mapstring.c	2008-02-07 03:03:34 UTC (rev 7360)
@@ -1429,3 +1429,30 @@
     }
     return 0;
 }
+
+/**
+ * msStringIsInteger()
+ *
+ * determines whether a given string is an integer
+ *
+ * @param string the string to be tested
+ *
+ * @return MS_SUCCESS or MS_FAILURE
+ */
+
+int msStringIsInteger(const char *string) {
+  int length, i;
+
+  length = strlen(string);
+
+  if (length == 0)
+    return MS_FAILURE;
+
+  for(i=0;i<length;i++) {
+    if (!isdigit(string[i]))
+      return MS_FAILURE;
+  }
+
+  return MS_SUCCESS;
+}
+



More information about the mapserver-commits mailing list