aboutsummaryrefslogtreecommitdiff
path: root/libmm-glib/mm-common-helpers.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-03-24 06:17:34 +0100
committerAleksander Morgado <aleksander@aleksander.es>2020-04-09 12:38:50 +0000
commit539562af0181f12343f6ebe2e3ffd44c5efb2fce (patch)
treebb13e74553368a5ea3305f39b588d8163c911e5f /libmm-glib/mm-common-helpers.c
parent44ace9642cd8a2a80c65655a6d543c69169b2a06 (diff)
libmm-glib,helpers: skip quotes when reading numbers from match infos
Useful when the regex applied to the parseable strings don't have an special ignore rule for the quotes.
Diffstat (limited to 'libmm-glib/mm-common-helpers.c')
-rw-r--r--libmm-glib/mm-common-helpers.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/libmm-glib/mm-common-helpers.c b/libmm-glib/mm-common-helpers.c
index 5bdb6df4..cdb9115c 100644
--- a/libmm-glib/mm-common-helpers.c
+++ b/libmm-glib/mm-common-helpers.c
@@ -1356,17 +1356,10 @@ mm_get_int_from_match_info (GMatchInfo *match_info,
guint32 match_index,
gint *out)
{
- gchar *s;
- gboolean ret;
+ g_autofree gchar *s = NULL;
- s = g_match_info_fetch (match_info, match_index);
- if (!s)
- return FALSE;
-
- ret = mm_get_int_from_str (s, out);
- g_free (s);
-
- return ret;
+ s = mm_get_string_unquoted_from_match_info (match_info, match_index);
+ return (s ? mm_get_int_from_str (s, out) : FALSE);
}
gboolean
@@ -1492,17 +1485,10 @@ mm_get_u64_from_match_info (GMatchInfo *match_info,
guint32 match_index,
guint64 *out)
{
- gchar *s;
- gboolean ret;
-
- s = g_match_info_fetch (match_info, match_index);
- if (!s)
- return FALSE;
+ g_autofree gchar *s = NULL;
- ret = mm_get_u64_from_str (s, out);
- g_free (s);
-
- return ret;
+ s = mm_get_string_unquoted_from_match_info (match_info, match_index);
+ return (s ? mm_get_u64_from_str (s, out) : FALSE);
}
gboolean
@@ -1549,17 +1535,10 @@ mm_get_double_from_match_info (GMatchInfo *match_info,
guint32 match_index,
gdouble *out)
{
- gchar *s;
- gboolean ret;
-
- s = g_match_info_fetch (match_info, match_index);
- if (!s)
- return FALSE;
-
- ret = mm_get_double_from_str (s, out);
- g_free (s);
+ g_autofree gchar *s = NULL;
- return ret;
+ s = mm_get_string_unquoted_from_match_info (match_info, match_index);
+ return (s ? mm_get_double_from_str (s, out) : FALSE);
}
gchar *