#ifdef WITH_VBOX
-# include <regex.h>
# include "vbox/vbox_snapshot_conf.h"
# define VIR_FROM_THIS VIR_FROM_NONE
static const char *testSnapshotXMLVariableLineRegexStr =
"lastStateChange=[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z";
-regex_t *testSnapshotXMLVariableLineRegex = NULL;
+GRegex *testSnapshotXMLVariableLineRegex = NULL;
static char *
testFilterXML(char *xml)
VIR_FREE(xml);
for (xmlLine = xmlLines; *xmlLine; xmlLine++) {
- if (regexec(testSnapshotXMLVariableLineRegex,
- *xmlLine, 0, NULL, 0) == 0)
+ if (g_regex_match(testSnapshotXMLVariableLineRegex, *xmlLine, 0, NULL))
continue;
virBufferStrcat(&buf, *xmlLine, "\n", NULL);
mymain(void)
{
int ret = 0;
- if (VIR_ALLOC(testSnapshotXMLVariableLineRegex) < 0)
- goto cleanup;
+ g_autoptr(GError) err = NULL;
+
+ testSnapshotXMLVariableLineRegex = g_regex_new(testSnapshotXMLVariableLineRegexStr,
+ 0, 0, &err);
- if (regcomp(testSnapshotXMLVariableLineRegex,
- testSnapshotXMLVariableLineRegexStr,
- REG_EXTENDED | REG_NOSUB) != 0) {
+ if (!testSnapshotXMLVariableLineRegex) {
ret = -1;
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
"failed to compile test regex");
DO_TEST("2disks-3snap-brother");
cleanup:
- if (testSnapshotXMLVariableLineRegex)
- regfree(testSnapshotXMLVariableLineRegex);
- VIR_FREE(testSnapshotXMLVariableLineRegex);
+ g_regex_unref(testSnapshotXMLVariableLineRegex);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}