examples: Use GRegex instead of POSIX regex

They are not available on Windows.
This commit is contained in:
Sebastian Dröge 2012-08-09 10:14:57 +02:00
parent 7f3ba3d9f8
commit c537fa12bb
2 changed files with 7 additions and 9 deletions

View file

@ -25,7 +25,6 @@
#include <glib.h> #include <glib.h>
#include <glib/gprintf.h> #include <glib/gprintf.h>
#include <ges/ges.h> #include <ges/ges.h>
#include <regex.h>
/* Application Data ********************************************************/ /* Application Data ********************************************************/
@ -501,16 +500,16 @@ bus_message_cb (GstBus * bus, GstMessage * message, App * app)
static gboolean static gboolean
check_time (const gchar * time) check_time (const gchar * time)
{ {
static regex_t re; static GRegex *re = NULL;
static gboolean compiled = FALSE;
if (!compiled) { if (!re) {
compiled = TRUE; if (NULL == (re =
regcomp (&re, "^[0-9][0-9]:[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?$", g_regex_new ("^[0-9][0-9]:[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?$",
REG_EXTENDED | REG_NOSUB); 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 TRUE;
return FALSE; return FALSE;
} }

View file

@ -28,7 +28,6 @@
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include <ges/ges.h> #include <ges/ges.h>
#include <gst/pbutils/encoding-profile.h> #include <gst/pbutils/encoding-profile.h>
#include <regex.h>
/* GLOBAL VARIABLE */ /* GLOBAL VARIABLE */
static guint repeat = 0; static guint repeat = 0;