changeset 14968:6a50b304996b draft

(svn r19576) -Codechange: Unduplicating parse_intlist().
author alberth <alberth@openttd.org>
date Wed, 07 Apr 2010 20:09:53 +0000
parents da88904d198e
children 9b0bb3e5357b
files src/newgrf_gui.cpp src/settings.cpp src/settings_func.h
diffstat 3 files changed, 3 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -49,30 +49,6 @@
 	}
 }
 
-/** Parse an integerlist string and set each found value
- * @param p the string to be parsed. Each element in the list is seperated by a
- * comma or a space character
- * @param items pointer to the integerlist-array that will be filled with values
- * @param maxitems the maximum number of elements the integerlist-array has
- * @return returns the number of items found, or -1 on an error */
-static int parse_intlist(const char *p, int *items, int maxitems)
-{
-	int n = 0, v;
-	char *end;
-
-	for (;;) {
-		while (*p == ' ' || *p == ',') p++;
-		if (*p == '\0') break;
-		v = strtol(p, &end, 0);
-		if (p == end || n == maxitems) return -1;
-		p = end;
-		items[n++] = v;
-	}
-
-	return n;
-}
-
-
 static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint right, uint bottom, bool show_params)
 {
 	char buff[256];
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -156,7 +156,7 @@
  * @param items pointer to the integerlist-array that will be filled with values
  * @param maxitems the maximum number of elements the integerlist-array has
  * @return returns the number of items found, or -1 on an error */
-static int parse_intlist(const char *p, int *items, int maxitems)
+int parse_intlist(const char *p, int *items, int maxitems)
 {
 	int n = 0, v;
 	char *end;
--- a/src/settings_func.h
+++ b/src/settings_func.h
@@ -20,6 +20,8 @@
 void IConsoleGetSetting(const char *name, bool force_newgame = false);
 void IConsoleListSettings(const char *prefilter);
 
+int parse_intlist(const char *p, int *items, int maxitems);
+
 void LoadFromConfig();
 void SaveToConfig();
 void CheckConfig();