From 5dbdbea94ec48a0f023a75bb69d96288e3e14892 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Fri, 8 Jun 2012 15:21:41 +0400 Subject: [PATCH] GList for longtable params --- c/longtable_params/longtable_params.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/c/longtable_params/longtable_params.c b/c/longtable_params/longtable_params.c index b23cc88..1e8f403 100644 --- a/c/longtable_params/longtable_params.c +++ b/c/longtable_params/longtable_params.c @@ -9,6 +9,8 @@ int main (int argc, char *argv[]) GRegex *regex; GMatchInfo *match_info; GError *error = NULL; + GList *list_params = NULL, + *it = NULL; gchar *reverse_params = g_strdup (params); reverse_params = g_strreverse (reverse_params); @@ -27,9 +29,7 @@ int main (int argc, char *argv[]) g_regex_match_full (regex, reverse_params, -1, 0, 0, &match_info, &error); while (g_match_info_matches (match_info)) { - gchar *word = g_strreverse (g_match_info_fetch (match_info, 0)); - g_print ("Found: %s\n", word); - g_free (word); + list_params = g_list_prepend (list_params, g_strreverse (g_match_info_fetch (match_info, 0))); g_match_info_next (match_info, &error); } g_match_info_free (match_info); @@ -40,7 +40,12 @@ int main (int argc, char *argv[]) g_error_free (error); } + g_printf ("%s\n", params); + for (it = g_list_first (list_params); it; it = g_list_next (it)) + g_printf ("Found: %s\n", (const gchar *) it->data); + g_free (reverse_params); + g_list_free_full (list_params, g_free); return 0; }