examples: Use GRegex instead of POSIX regex
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 9 Aug 2012 08:14:57 +0000 (10:14 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 9 Aug 2012 08:16:05 +0000 (10:16 +0200)
They are not available on Windows.

tests/examples/ges-ui.c
tests/examples/thumbnails.c

index 1af2764..249a0f2 100644 (file)
@@ -25,7 +25,6 @@
 #include <glib.h>
 #include <glib/gprintf.h>
 #include <ges/ges.h>
-#include <regex.h>
 
 /* Application Data ********************************************************/
 
@@ -501,16 +500,16 @@ bus_message_cb (GstBus * bus, GstMessage * message, App * app)
 static gboolean
 check_time (const gchar * time)
 {
-  static regex_t re;
-  static gboolean compiled = FALSE;
+  static GRegex *re = NULL;
 
-  if (!compiled) {
-    compiled = TRUE;
-    regcomp (&re, "^[0-9][0-9]:[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?$",
-        REG_EXTENDED | REG_NOSUB);
+  if (!re) {
+    if (NULL == (re =
+            g_regex_new ("^[0-9][0-9]:[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?$",
+                G_REGEX_EXTENDED, 0, NULL)))
+      return FALSE;
   }
 
-  if (!regexec (&re, time, (size_t) 0, NULL, 0))
+  if (g_regex_match (re, time, 0, NULL))
     return TRUE;
   return FALSE;
 }
index 2a64575..601e187 100644 (file)
@@ -28,7 +28,6 @@
 #include <glib/gstdio.h>
 #include <ges/ges.h>
 #include <gst/pbutils/encoding-profile.h>
-#include <regex.h>
 
 /* GLOBAL VARIABLE */
 static guint repeat = 0;