126775d61f
This is the GNOME Build Framework (GBF).
191 lines
5.9 KiB
Text
191 lines
5.9 KiB
Text
$NetBSD: patch-ab,v 1.1.1.1 2007/01/04 02:51:02 rillig Exp $
|
|
|
|
Replaced the GNU regular expressions with POSIX regular expressions,
|
|
since the latter are more portable.
|
|
|
|
--- src/backends/libgbf_mkfile/gbf-mkfile-build.c.orig 2005-09-22 13:18:46.000000000 +0200
|
|
+++ src/backends/libgbf_mkfile/gbf-mkfile-build.c 2007-01-04 03:28:10.000000000 +0100
|
|
@@ -43,10 +43,11 @@ typedef struct {
|
|
GList *callbacks;
|
|
|
|
/* Regex structures. */
|
|
- struct re_pattern_buffer dir_buf;
|
|
- struct re_pattern_buffer warn_buf;
|
|
- struct re_pattern_buffer err_buf;
|
|
- struct re_registers reg;
|
|
+ regex_t dir_buf;
|
|
+ regex_t warn_buf;
|
|
+ regex_t err_buf;
|
|
+#define N_GROUPS 5 /* 1 + maximum number of groups + 1 */
|
|
+ regmatch_t reg[N_GROUPS];
|
|
|
|
/* Build info. */
|
|
char *build_dir;
|
|
@@ -60,12 +61,9 @@ build_info_free (BuildInfo *info)
|
|
|
|
if (info->build_dir)
|
|
g_free (info->build_dir);
|
|
- if (info->dir_buf.fastmap)
|
|
- g_free (info->dir_buf.fastmap);
|
|
- if (info->warn_buf.fastmap)
|
|
- g_free (info->warn_buf.fastmap);
|
|
- if (info->err_buf.fastmap)
|
|
- g_free (info->err_buf.fastmap);
|
|
+ regfree (&info->dir_buf);
|
|
+ regfree (&info->warn_buf);
|
|
+ regfree (&info->err_buf);
|
|
g_free (info);
|
|
}
|
|
|
|
@@ -84,6 +82,11 @@ build_msg (BuildInfo *info,
|
|
}
|
|
}
|
|
|
|
+/* Returns a copy of the ''n''th captured group. */
|
|
+#define GBF_GETGROUP(n) \
|
|
+ g_strndup (line + info->reg[n].rm_so, \
|
|
+ info->reg[n].rm_eo - info->reg[n].rm_so)
|
|
+
|
|
static void
|
|
parse_output (BuildInfo *info,
|
|
const char *line)
|
|
@@ -91,26 +94,20 @@ parse_output (BuildInfo *info,
|
|
int line_length = strlen (line);
|
|
|
|
/* Check for directory changes. */
|
|
- if (re_search (&info->dir_buf, line, line_length, 0,
|
|
- line_length, &info->reg) != -1) {
|
|
- if (info->reg.num_regs >= 2) {
|
|
- if (info->build_dir)
|
|
- g_free (info->build_dir);
|
|
- info->build_dir = g_strndup (line + info->reg.start[1],
|
|
- info->reg.end[1] - info->reg.start[1]);
|
|
- }
|
|
+ if (regexec (&info->dir_buf, line, N_GROUPS, info->reg, 0) == 0) {
|
|
+ g_assert(info->reg[1].rm_so != -1);
|
|
+ g_free (info->build_dir);
|
|
+ info->build_dir = GBF_GETGROUP(1);
|
|
}
|
|
|
|
/* Check for warnings & errors. */
|
|
- if (re_search (&info->warn_buf, line, line_length, 0,
|
|
- line_length, &info->reg) != -1) {
|
|
+ if (regexec (&info->warn_buf, line, N_GROUPS, info->reg, 0) == 0) {
|
|
GbfBuildWarning *warn;
|
|
char *text;
|
|
|
|
/* Create new warning. */
|
|
warn = g_new0 (GbfBuildWarning, 1);
|
|
- text = g_strndup (line + info->reg.start[1],
|
|
- info->reg.end[1] - info->reg.start[1]);
|
|
+ text = GBF_GETGROUP(1);
|
|
if (text[0] != '/') { /* only prepend build_dir if path not absolute */
|
|
warn->filename = g_strconcat (info->build_dir, "/", text, NULL);
|
|
g_free (text);
|
|
@@ -118,25 +115,21 @@ parse_output (BuildInfo *info,
|
|
warn->filename = text;
|
|
}
|
|
|
|
- text = g_strndup (line + info->reg.start[2],
|
|
- info->reg.end[2] - info->reg.start[2]);
|
|
+ text = GBF_GETGROUP(2);
|
|
warn->line = atoi (text);
|
|
g_free (text);
|
|
- warn->warning = g_strndup (line + info->reg.start[3],
|
|
- info->reg.end[3] - info->reg.start[3]);
|
|
+ warn->warning = GBF_GETGROUP(3);
|
|
warn->output = g_strdup (line);
|
|
|
|
build_msg (info, GBF_BUILD_WARNING, warn);
|
|
/* FIXME: We should free warn here, and make copy in gbf-build-info.c. */
|
|
- } else if (re_search (&info->err_buf, line, line_length, 0,
|
|
- line_length, &info->reg) != -1) {
|
|
+ } else if (regexec(&info->err_buf, line, N_GROUPS, info->reg, 0) == 0) {
|
|
GbfBuildError *err;
|
|
char *text;
|
|
|
|
/* Create new error. */
|
|
err = g_new0 (GbfBuildError, 1);
|
|
- text = g_strndup (line + info->reg.start[1],
|
|
- info->reg.end[1] - info->reg.start[1]);
|
|
+ text = GBF_GETGROUP(1);
|
|
if (text[0] != '/') { /* only prepend build_dir if path not absolute */
|
|
err->filename = g_strconcat (info->build_dir, "/", text, NULL);
|
|
g_free (text);
|
|
@@ -144,12 +137,10 @@ parse_output (BuildInfo *info,
|
|
err->filename = text;
|
|
}
|
|
|
|
- text = g_strndup (line + info->reg.start[2],
|
|
- info->reg.end[2] - info->reg.start[2]);
|
|
+ text = GBF_GETGROUP(2);
|
|
err->line = atoi (text);
|
|
g_free (text);
|
|
- err->error = g_strndup (line + info->reg.start[3],
|
|
- info->reg.end[3] - info->reg.start[3]);
|
|
+ err->error = GBF_GETGROUP(3);
|
|
err->output = g_strdup (line);
|
|
|
|
build_msg (info, GBF_BUILD_ERROR, err);
|
|
@@ -158,6 +149,7 @@ parse_output (BuildInfo *info,
|
|
build_msg (info, GBF_BUILD_OUTPUT, (gpointer)line);
|
|
}
|
|
}
|
|
+#undef GBF_GETGROUP
|
|
|
|
static gboolean
|
|
build_output_cb (GIOChannel *chan,
|
|
@@ -197,24 +189,10 @@ build_output_cb (GIOChannel *chan,
|
|
}
|
|
|
|
static gboolean
|
|
-compile_pattern (struct re_pattern_buffer *buf,
|
|
+compile_pattern (regex_t *buf,
|
|
const char *pattern)
|
|
{
|
|
- memset (buf, 0, sizeof (struct re_pattern_buffer));
|
|
- buf->translate = NULL;
|
|
- buf->fastmap = g_malloc (256);
|
|
- buf->allocated = 0;
|
|
- buf->buffer = NULL;
|
|
- buf->can_be_null = 0;
|
|
- buf->no_sub = 0;
|
|
-
|
|
- if (!re_compile_pattern (pattern, strlen (pattern), buf)) {
|
|
- if (re_compile_fastmap (buf) != 0) {
|
|
- g_warning ("IMPORTANT REGEX FAILED TO CREASTE FASTMAP");
|
|
- g_free (buf->fastmap);
|
|
- buf->fastmap = NULL;
|
|
- }
|
|
- } else {
|
|
+ if (regcomp(buf, pattern, REG_EXTENDED) != 0) {
|
|
g_warning ("IMPORTANT REGEX FAILED TO COMPILE");
|
|
return FALSE;
|
|
}
|
|
@@ -239,7 +217,6 @@ gbf_build_run (GbfMkfileProject *proj
|
|
char *tmp, *msg;
|
|
int output, err, pid;
|
|
GIOChannel *out_channel, *err_channel;
|
|
- reg_syntax_t old_options;
|
|
GError *error = NULL;
|
|
const char *charset;
|
|
GNode *g_node;
|
|
@@ -342,9 +319,6 @@ gbf_build_run (GbfMkfileProject *proj
|
|
info->build_dir = NULL;
|
|
|
|
/* Intialize regexs. */
|
|
- old_options = re_syntax_options;
|
|
- re_syntax_options = RE_SYNTAX_EGREP;
|
|
-
|
|
if (!compile_pattern (&info->dir_buf, dir_regex) ||
|
|
!compile_pattern (&info->warn_buf, warn_regex) ||
|
|
!compile_pattern (&info->err_buf, err_regex)) {
|
|
@@ -355,8 +329,6 @@ gbf_build_run (GbfMkfileProject *proj
|
|
return -1;
|
|
}
|
|
|
|
- re_syntax_options = old_options;
|
|
-
|
|
g_signal_emit_by_name (G_OBJECT (project), "build_start");
|
|
|
|
tmp = g_strjoinv (" ", (char **) argv);
|