Revision
16936
Author
mikej
Date
2010-03-08 02:12:12 -0600 (Mon, 08 Mar 2010)

Log Message

move functions to strip commas and non-numeric chars to switch_utils

Modified Paths

Diff

Modified: freeswitch/trunk/src/include/switch_utils.h (16935 => 16936)


--- freeswitch/trunk/src/include/switch_utils.h	2010-03-08 07:55:57 UTC (rev 16935)
+++ freeswitch/trunk/src/include/switch_utils.h	2010-03-08 08:12:12 UTC (rev 16936)
@@ -545,6 +545,8 @@
 
 SWITCH_DECLARE(switch_bool_t) switch_is_number(const char *str);
 SWITCH_DECLARE(char *) switch_strip_spaces(const char *str);
+SWITCH_DECLARE(char *) switch_strip_commas(char *in, char *out, switch_size_t len);
+SWITCH_DECLARE(char *) switch_strip_nonnumerics(char *in, char *out, switch_size_t len);
 SWITCH_DECLARE(char *) switch_separate_paren_args(char *str);
 SWITCH_DECLARE(const char *) switch_stristr(const char *instr, const char *str);
 SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip);

Modified: freeswitch/trunk/src/mod/say/mod_say_de/mod_say_de.c (16935 => 16936)


--- freeswitch/trunk/src/mod/say/mod_say_de/mod_say_de.c	2010-03-08 07:55:57 UTC (rev 16935)
+++ freeswitch/trunk/src/mod/say/mod_say_de/mod_say_de.c	2010-03-08 08:12:12 UTC (rev 16936)
@@ -122,49 +122,6 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58)) {
-			*q++ = *p;
-		} else if (*p != ',') {
-			ret = NULL;
-			break;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-	// valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
-			*q++ = *p;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
 static switch_status_t de_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
 	int in;
@@ -173,7 +130,7 @@
 	char sbuf[13] = "";
 	switch_status_t status;
 
-	if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+	if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -408,7 +365,7 @@
 	char *dollars = NULL;
 	char *cents = NULL;
 
-	if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}

Modified: freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c (16935 => 16936)


--- freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c	2010-03-08 07:55:57 UTC (rev 16935)
+++ freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c	2010-03-08 08:12:12 UTC (rev 16936)
@@ -117,49 +117,6 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58)) {
-			*q++ = *p;
-		} else if (*p != ',') {
-			ret = NULL;
-			break;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-	// valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
-			*q++ = *p;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
 static switch_status_t en_say_general_count(switch_core_session_t *session,	char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
 	int in;
@@ -169,7 +126,7 @@
 	switch_status_t status;
 
 	if (say_args->method == SSM_ITERATED) {
-		if ((tosay = strip_commas(tosay, sbuf, sizeof(sbuf)))) {
+		if ((tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)))) {
 			char *p;
 			for (p = tosay; p && *p; p++) {
 				say_file("digits/%c.wav", *p);
@@ -181,7 +138,7 @@
 		return SWITCH_STATUS_SUCCESS;
 	}
 
-	if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+	if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -475,7 +432,7 @@
 	char *dollars = NULL;
 	char *cents = NULL;
 
-	if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}

Modified: freeswitch/trunk/src/mod/say/mod_say_es/mod_say_es.c (16935 => 16936)


--- freeswitch/trunk/src/mod/say/mod_say_es/mod_say_es.c	2010-03-08 07:55:57 UTC (rev 16935)
+++ freeswitch/trunk/src/mod/say/mod_say_es/mod_say_es.c	2010-03-08 08:12:12 UTC (rev 16936)
@@ -142,49 +142,6 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58)) {
-			*q++ = *p;
-		} else if (*p != ',') {
-			ret = NULL;
-			break;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-	// valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
-			*q++ = *p;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
 static switch_status_t es_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
 	int in;
@@ -193,7 +150,7 @@
 	char sbuf[13] = "";
 	switch_status_t status;
 
-	if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+	if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -429,7 +386,7 @@
 	char *dollars = NULL;
 	char *cents = NULL;
 
-	if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}

Modified: freeswitch/trunk/src/mod/say/mod_say_fr/mod_say_fr.c (16935 => 16936)


--- freeswitch/trunk/src/mod/say/mod_say_fr/mod_say_fr.c	2010-03-08 07:55:57 UTC (rev 16935)
+++ freeswitch/trunk/src/mod/say/mod_say_fr/mod_say_fr.c	2010-03-08 08:12:12 UTC (rev 16936)
@@ -139,49 +139,6 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58)) {
-			*q++ = *p;
-		} else if (*p != ',') {
-			ret = NULL;
-			break;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-	/* valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others */
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
-			*q++ = *p;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
 static switch_status_t fr_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
 	int in;
@@ -190,7 +147,7 @@
 	char sbuf[13] = "";
 	switch_status_t status;
 
-	if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+	if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -480,7 +437,7 @@
 	char *dollars = NULL;
 	char *cents = NULL;
 
-	if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}

Modified: freeswitch/trunk/src/mod/say/mod_say_hu/mod_say_hu.c (16935 => 16936)


--- freeswitch/trunk/src/mod/say/mod_say_hu/mod_say_hu.c	2010-03-08 07:55:57 UTC (rev 16935)
+++ freeswitch/trunk/src/mod/say/mod_say_hu/mod_say_hu.c	2010-03-08 08:12:12 UTC (rev 16936)
@@ -117,49 +117,6 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58)) {
-			*q++ = *p;
-		} else if (*p != ',') {
-			ret = NULL;
-			break;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-	// valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
-			*q++ = *p;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
 static switch_status_t hu_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
 	int in;
@@ -169,7 +126,7 @@
 	int number;
 	switch_status_t status;
 
-	if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+	if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -437,7 +394,7 @@
 	char sbuf[16] = "";
 	char *forint;
 
-	if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}

Modified: freeswitch/trunk/src/mod/say/mod_say_it/mod_say_it.c (16935 => 16936)


--- freeswitch/trunk/src/mod/say/mod_say_it/mod_say_it.c	2010-03-08 07:55:57 UTC (rev 16935)
+++ freeswitch/trunk/src/mod/say/mod_say_it/mod_say_it.c	2010-03-08 08:12:12 UTC (rev 16936)
@@ -126,49 +126,6 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58)) {
-			*q++ = *p;
-		} else if (*p != ',') {
-			ret = NULL;
-			break;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-	/* valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others */
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
-			*q++ = *p;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
 static switch_status_t it_say_general_count(switch_core_session_t *session,	char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
 	int in;
@@ -177,7 +134,7 @@
 	char sbuf[13] = "";
 	switch_status_t status;
 
-	if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+	if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -436,7 +393,7 @@
 	char *dollars = NULL;
 	char *cents = NULL;
 
-	if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}

Modified: freeswitch/trunk/src/mod/say/mod_say_nl/mod_say_nl.c (16935 => 16936)


--- freeswitch/trunk/src/mod/say/mod_say_nl/mod_say_nl.c	2010-03-08 07:55:57 UTC (rev 16935)
+++ freeswitch/trunk/src/mod/say/mod_say_nl/mod_say_nl.c	2010-03-08 08:12:12 UTC (rev 16936)
@@ -113,49 +113,6 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58)) {
-			*q++ = *p;
-		} else if (*p != ',') {
-			ret = NULL;
-			break;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-	// valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
-			*q++ = *p;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
 static switch_status_t nl_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
 	int in;
@@ -164,7 +121,7 @@
 	char sbuf[13] = "";
 	switch_status_t status;
 
-	if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+	if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -400,7 +357,7 @@
 	char *dollars = NULL;
 	char *cents = NULL;
 
-	if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}

Modified: freeswitch/trunk/src/mod/say/mod_say_ru/mod_say_ru.c (16935 => 16936)


--- freeswitch/trunk/src/mod/say/mod_say_ru/mod_say_ru.c	2010-03-08 07:55:57 UTC (rev 16935)
+++ freeswitch/trunk/src/mod/say/mod_say_ru/mod_say_ru.c	2010-03-08 08:12:12 UTC (rev 16936)
@@ -72,45 +72,6 @@
 			return SWITCH_STATUS_FALSE;\
 		}}
 
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58)) {
-			*q++ = *p;
-		} else if (*p != ',') {
-			ret = NULL;
-			break;
-		}
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-	return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
-	char *p = in, *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-	/* valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others */
-	for (; p && *p; p++) {
-		if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
-			*q++ = *p;
-		}
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-	return ret;
-}
-
 static switch_status_t play_group(say_type_t say_type, casus_t casus, int a, int b, int c,
 								  unit_t what, switch_core_session_t *session, switch_input_args_t *args)
 {
@@ -203,7 +164,7 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ru_say_count %s!\n", tosay);
 
-	if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+	if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -300,7 +261,7 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_money %s\n", tosay);
 
-	if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}

Modified: freeswitch/trunk/src/mod/say/mod_say_th/mod_say_th.c (16935 => 16936)


--- freeswitch/trunk/src/mod/say/mod_say_th/mod_say_th.c	2010-03-08 07:55:57 UTC (rev 16935)
+++ freeswitch/trunk/src/mod/say/mod_say_th/mod_say_th.c	2010-03-08 08:12:12 UTC (rev 16936)
@@ -87,52 +87,6 @@
 			return SWITCH_STATUS_FALSE;									\
 		}}																\
 
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
-	char *p = in;
-	char *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-
-	for (; p && *p; p++) {
-		if ((*p >= '0' && *p <= '9')) {
-			*q++ = *p;
-		} else if (*p != ',') {
-			ret = NULL;
-			break;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
-	char *p = in;
-	char *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-
-	/* valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others */
-	for (; p && *p; p++) {
-		if ((*p >= '0' && *p <= '9') || *p == '.' || *p == '-' || *p == '+') {
-			*q++ = *p;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
 static switch_status_t th_say_general_count(switch_core_session_t *session,	char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
 	int in;
@@ -140,7 +94,7 @@
 	char digits[11];
 	int i;
 
-	if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+	if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -505,7 +459,7 @@
 	char *dollars = NULL;
 	char *cents = NULL;
 
-	if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}

Modified: freeswitch/trunk/src/mod/say/mod_say_zh/mod_say_zh.c (16935 => 16936)


--- freeswitch/trunk/src/mod/say/mod_say_zh/mod_say_zh.c	2010-03-08 07:55:57 UTC (rev 16935)
+++ freeswitch/trunk/src/mod/say/mod_say_zh/mod_say_zh.c	2010-03-08 08:12:12 UTC (rev 16936)
@@ -86,53 +86,6 @@
 			return SWITCH_STATUS_FALSE;									\
 		}}																\
 
-
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
-	char *p = in;
-	char *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-
-	for (; p && *p; p++) {
-		if ((*p >= '0' && *p <= '9')) {
-			*q++ = *p;
-		} else if (*p != ',') {
-			ret = NULL;
-			break;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
-	char *p = in;
-	char *q = out;
-	char *ret = out;
-	switch_size_t x = 0;
-
-	/* valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others */
-	for (; p && *p; p++) {
-		if ((*p >= '0' && *p <= '9') || *p == '.' || *p == '-' || *p == '+') {
-			*q++ = *p;
-		}
-
-		if (++x > len) {
-			ret = NULL;
-			break;
-		}
-	}
-
-	return ret;
-}
-
 static switch_status_t zh_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
 	int in;
@@ -140,7 +93,7 @@
 	char digits[11];
 	int i;
 
-	if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+	if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -485,7 +438,7 @@
 	char *dollars = NULL;
 	char *cents = NULL;
 
-	if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
 		return SWITCH_STATUS_GENERR;
 	}

Modified: freeswitch/trunk/src/switch_utils.c (16935 => 16936)


--- freeswitch/trunk/src/switch_utils.c	2010-03-08 07:55:57 UTC (rev 16935)
+++ freeswitch/trunk/src/switch_utils.c	2010-03-08 08:12:12 UTC (rev 16936)
@@ -742,6 +742,49 @@
 	return s;
 }
 
+SWITCH_DECLARE(char *) switch_strip_commas(char *in, char *out, switch_size_t len)
+{
+	char *p = in, *q = out;
+	char *ret = out;
+	switch_size_t x = 0;
+
+	for (; p && *p; p++) {
+		if ((*p > 47 && *p < 58)) {
+			*q++ = *p;
+		} else if (*p != ',') {
+			ret = NULL;
+			break;
+		}
+
+		if (++x > len) {
+			ret = NULL;
+			break;
+		}
+	}
+
+	return ret;
+}
+
+SWITCH_DECLARE(char *) switch_strip_nonnumerics(char *in, char *out, switch_size_t len)
+{
+	char *p = in, *q = out;
+	char *ret = out;
+	switch_size_t x = 0;
+	/* valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others */
+	for (; p && *p; p++) {
+		if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
+			*q++ = *p;
+		}
+
+		if (++x > len) {
+			ret = NULL;
+			break;
+		}
+	}
+
+	return ret;
+}
+
 SWITCH_DECLARE(char *) switch_separate_paren_args(char *str)
 {
 	char *e, *args;