diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-15 07:51:52 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-15 07:51:52 -0400 |
commit | 425568bfa9c5d50732ec872f4716fe9226992037 (patch) | |
tree | 9cfc77f3593594e7642b0fc1763a7d876c6b2797 /string_utils.c | |
parent | 79f06f62d4bdc3bcd62aee7527ed5730fac66d9f (diff) |
ran dos2unix
Diffstat (limited to 'string_utils.c')
-rw-r--r-- | string_utils.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/string_utils.c b/string_utils.c index e28ccfc..db077a7 100644 --- a/string_utils.c +++ b/string_utils.c @@ -1,48 +1,48 @@ -/* START LIBRARY DESCRIPTION *********************************************
-FLOAT.LIB
- Copyright (c) 2006, Avtech Electrosystems Ltd.
-
-DESCRIPTION:
- Functions that deal with strings and floating point numbers.
-
-SUPPORT LIB'S:
-END DESCRIPTION **********************************************************/
-
-
-#include <string.h>
-#include <ctype.h>
-#include <math.h>
-#include <glib/gprintf.h>
-#include "globals.h"
-#include "string_utils.h"
-
-void Float_To_Text(int decimal_digits,float number_in, gchar ** text_out)
-{
- g_assert (*text_out == NULL);
-
- if (fabs(number_in)<1.1*smallest_allowed_number) {
- if (number_in<0.0) {
- *text_out = g_strdup_printf("-0.%0*d",decimal_digits,0);
- } else {
- *text_out = g_strdup_printf("0.%0*d",decimal_digits,0);
- }
- return;
- }
-
- *text_out = g_strdup_printf("%.*e", decimal_digits, number_in);
-}
-
-
-/*----------------------------------------------------------------------------------------------------------*/
-gboolean String_is_it_numeric(char *parameter)
-{
-
- GRegex *numeric_regex = g_regex_new ( "\\s*[+-]?(\\d*\\.\\d+|\\d+(\\.\\d*)?)\\s*(e\\s*[+-]?\\d+)?\\s*",
- G_REGEX_CASELESS,
- 0,
- NULL);
-
- gboolean match = g_regex_match (numeric_regex, parameter, 0, NULL);
- g_regex_unref (numeric_regex);
- return match;
-}
+/* START LIBRARY DESCRIPTION ********************************************* +FLOAT.LIB + Copyright (c) 2006, Avtech Electrosystems Ltd. + +DESCRIPTION: + Functions that deal with strings and floating point numbers. + +SUPPORT LIB'S: +END DESCRIPTION **********************************************************/ + + +#include <string.h> +#include <ctype.h> +#include <math.h> +#include <glib/gprintf.h> +#include "globals.h" +#include "string_utils.h" + +void Float_To_Text(int decimal_digits,float number_in, gchar ** text_out) +{ + g_assert (*text_out == NULL); + + if (fabs(number_in)<1.1*smallest_allowed_number) { + if (number_in<0.0) { + *text_out = g_strdup_printf("-0.%0*d",decimal_digits,0); + } else { + *text_out = g_strdup_printf("0.%0*d",decimal_digits,0); + } + return; + } + + *text_out = g_strdup_printf("%.*e", decimal_digits, number_in); +} + + +/*----------------------------------------------------------------------------------------------------------*/ +gboolean String_is_it_numeric(char *parameter) +{ + + GRegex *numeric_regex = g_regex_new ( "\\s*[+-]?(\\d*\\.\\d+|\\d+(\\.\\d*)?)\\s*(e\\s*[+-]?\\d+)?\\s*", + G_REGEX_CASELESS, + 0, + NULL); + + gboolean match = g_regex_match (numeric_regex, parameter, 0, NULL); + g_regex_unref (numeric_regex); + return match; +} |