Commit a8fb4f0c authored by Manish Singh's avatar Manish Singh Committed by Manish Singh

app/core/gimpcontainer-filter.c app/pdb/gimppdb-query.c replace usage of

2007-11-01  Manish Singh  <yosh@gimp.org>

        * app/core/gimpcontainer-filter.c
        * app/pdb/gimppdb-query.c
        * app/plug-in/gimppluginmanager-query.c: replace usage of POSIX
        regex API with GRegex.

        * configure.in: remove check for regex support in glibc.

        * app/Makefile.am
        * plug-ins/script-fu/Makefile.am: remove REGEXREPL references.

        * tools/pdbgen/app.pl: remove code that references HAVE_GLIBC_REGEX.

        * regexrepl/*
        * makefile.msc
        * Makefile.am: remove regexrepl directory.

svn path=/trunk/; revision=24024
parent 88013f3f
2007-11-01 Manish Singh <yosh@gimp.org>
* app/core/gimpcontainer-filter.c
* app/pdb/gimppdb-query.c
* app/plug-in/gimppluginmanager-query.c: replace usage of POSIX
regex API with GRegex.
* configure.in: remove check for regex support in glibc.
* app/Makefile.am
* plug-ins/script-fu/Makefile.am: remove REGEXREPL references.
* tools/pdbgen/app.pl: remove code that references HAVE_GLIBC_REGEX.
* regexrepl/*
* makefile.msc
* Makefile.am: remove regexrepl directory.
2007-10-31 Sven Neumann <sven@gimp.org>
* app/core/gimp-user-install.c: improved detection of old gimp
......
......@@ -3,7 +3,6 @@
SUBDIRS = \
m4macros \
tools \
regexrepl \
cursors \
themes \
po \
......
......@@ -61,13 +61,6 @@ EXTRA_DIST = \
fileicon.ico \
wilber.ico
if HAVE_GLIBC_REGEX
REGEXREPL =
else
REGEXREPL = $(top_builddir)/regexrepl/libregex.a
endif
if OS_WIN32
mwindows = -mwindows
endif
......
......@@ -25,12 +25,6 @@
#include <glib-object.h>
#ifdef HAVE_GLIBC_REGEX
#include <regex.h>
#else
#include "regexrepl/regex.h"
#endif
#include "core-types.h"
#include "gimpcontainer.h"
......@@ -101,10 +95,9 @@ gimp_container_filter (const GimpContainer *container,
static gboolean
gimp_object_filter_by_name (const GimpObject *object,
const regex_t *regex)
const GRegex *regex)
{
return (regexec (regex,
gimp_object_get_name (object), 0, NULL, 0) != REG_NOMATCH);
return g_regex_match (regex, gimp_object_get_name (object), 0, NULL);
}
/**
......@@ -124,38 +117,24 @@ gimp_container_filter_by_name (const GimpContainer *container,
GError **error)
{
GimpContainer *result;
gint ret;
regex_t regex;
GRegex *regex;
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
g_return_val_if_fail (regexp != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
ret = regcomp (&regex, regexp, REG_EXTENDED | REG_ICASE | REG_NOSUB);
if (ret)
{
gsize error_len;
gchar *error_buf;
error_len = regerror (ret, &regex, NULL, 0);
error_buf = g_new (gchar, error_len);
regerror (ret, &regex, error_buf, error_len);
regex = g_regex_new (regexp, G_REGEX_CASELESS | G_REGEX_OPTIMIZE, 0,
error);
g_set_error (error, 0, 0, error_buf);
g_free (error_buf);
regfree (&regex);
return NULL;
}
if (! regex)
return NULL;
result =
gimp_container_filter (container,
(GimpObjectFilterFunc) gimp_object_filter_by_name,
&regex);
regex);
regfree (&regex);
g_regex_unref (regex);
return result;
}
......
......@@ -22,12 +22,6 @@
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_GLIBC_REGEX
#include <regex.h>
#else
#include "regexrepl/regex.h"
#endif
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
......@@ -44,7 +38,7 @@
#include "gimp-intl.h"
#define PDB_REGCOMP_FLAGS REG_ICASE
#define PDB_REGEX_FLAGS (G_REGEX_CASELESS | G_REGEX_OPTIMIZE)
#define COMPAT_BLURB "This procedure is deprecated! Use '%s' instead."
......@@ -65,13 +59,13 @@ struct _PDBQuery
{
GimpPDB *pdb;
regex_t name_regex;
regex_t blurb_regex;
regex_t help_regex;
regex_t author_regex;
regex_t copyright_regex;
regex_t date_regex;
regex_t proc_type_regex;
GRegex *name_regex;
GRegex *blurb_regex;
GRegex *help_regex;
GRegex *author_regex;
GRegex *copyright_regex;
GRegex *date_regex;
GRegex *proc_type_regex;
gchar **list_of_procs;
gint num_procs;
......@@ -169,20 +163,27 @@ gimp_pdb_query (GimpPDB *pdb,
*num_procs = 0;
*procs = NULL;
if (regcomp (&pdb_query.name_regex, name, PDB_REGCOMP_FLAGS))
goto free_name;
if (regcomp (&pdb_query.blurb_regex, blurb, PDB_REGCOMP_FLAGS))
goto free_blurb;
if (regcomp (&pdb_query.help_regex, help, PDB_REGCOMP_FLAGS))
goto free_help;
if (regcomp (&pdb_query.author_regex, author, PDB_REGCOMP_FLAGS))
goto free_author;
if (regcomp (&pdb_query.copyright_regex, copyright, PDB_REGCOMP_FLAGS))
goto free_copyright;
if (regcomp (&pdb_query.date_regex, date, PDB_REGCOMP_FLAGS))
goto free_date;
if (regcomp (&pdb_query.proc_type_regex, proc_type, PDB_REGCOMP_FLAGS))
goto free_proc_type;
pdb_query.name_regex = g_regex_new (name, PDB_REGEX_FLAGS, 0, NULL);
if (! pdb_query.name_regex)
goto cleanup_after_name;
pdb_query.blurb_regex = g_regex_new (blurb, PDB_REGEX_FLAGS, 0, NULL);
if (! pdb_query.blurb_regex)
goto cleanup_after_blurb;
pdb_query.help_regex = g_regex_new (help, PDB_REGEX_FLAGS, 0, NULL);
if (! pdb_query.help_regex)
goto cleanup_after_help;
pdb_query.author_regex = g_regex_new (author, PDB_REGEX_FLAGS, 0, NULL);
if (! pdb_query.author_regex)
goto cleanup_after_author;
pdb_query.copyright_regex = g_regex_new (copyright, PDB_REGEX_FLAGS, 0, NULL);
if (! pdb_query.copyright_regex)
goto cleanup_after_copyright;
pdb_query.date_regex = g_regex_new (date, PDB_REGEX_FLAGS, 0, NULL);
if (! pdb_query.date_regex)
goto cleanup_after_date;
pdb_query.proc_type_regex = g_regex_new (proc_type, PDB_REGEX_FLAGS, 0, NULL);
if (! pdb_query.proc_type_regex)
goto cleanup_after_proc_type;
success = TRUE;
......@@ -199,20 +200,20 @@ gimp_pdb_query (GimpPDB *pdb,
g_hash_table_foreach (pdb->compat_proc_names,
gimp_pdb_query_entry, &pdb_query);
free_proc_type:
regfree (&pdb_query.proc_type_regex);
free_date:
regfree (&pdb_query.date_regex);
free_copyright:
regfree (&pdb_query.copyright_regex);
free_author:
regfree (&pdb_query.author_regex);
free_help:
regfree (&pdb_query.help_regex);
free_blurb:
regfree (&pdb_query.blurb_regex);
free_name:
regfree (&pdb_query.name_regex);
g_regex_unref (pdb_query.proc_type_regex);
cleanup_after_proc_type:
g_regex_unref (pdb_query.date_regex);
cleanup_after_date:
g_regex_unref (pdb_query.copyright_regex);
cleanup_after_copyright:
g_regex_unref (pdb_query.author_regex);
cleanup_after_author:
g_regex_unref (pdb_query.help_regex);
cleanup_after_help:
g_regex_unref (pdb_query.blurb_regex);
cleanup_after_blurb:
g_regex_unref (pdb_query.name_regex);
cleanup_after_name:
if (success)
{
......@@ -282,14 +283,14 @@ gimp_pdb_proc_info (GimpPDB *pdb,
/* private functions */
static int
match_strings (regex_t *preg,
const gchar *a)
static gboolean
match_string (GRegex *regex,
const gchar *string)
{
if (!a)
a = "";
if (! string)
string = "";
return regexec (preg, a, 0, NULL, 0);
return g_regex_match (regex, string, 0, NULL);
}
static void
......@@ -323,13 +324,13 @@ gimp_pdb_query_entry (gpointer key,
type_desc = gimp_enum_get_desc (enum_class, procedure->proc_type);
g_type_class_unref (enum_class);
if (! match_strings (&pdb_query->name_regex, proc_name) &&
! match_strings (&pdb_query->blurb_regex, strings.blurb) &&
! match_strings (&pdb_query->help_regex, strings.help) &&
! match_strings (&pdb_query->author_regex, strings.author) &&
! match_strings (&pdb_query->copyright_regex, strings.copyright) &&
! match_strings (&pdb_query->date_regex, strings.date) &&
! match_strings (&pdb_query->proc_type_regex, type_desc->value_desc))
if (match_string (pdb_query->name_regex, proc_name) &&
match_string (pdb_query->blurb_regex, strings.blurb) &&
match_string (pdb_query->help_regex, strings.help) &&
match_string (pdb_query->author_regex, strings.author) &&
match_string (pdb_query->copyright_regex, strings.copyright) &&
match_string (pdb_query->date_regex, strings.date) &&
match_string (pdb_query->proc_type_regex, type_desc->value_desc))
{
pdb_query->num_procs++;
pdb_query->list_of_procs = g_renew (gchar *, pdb_query->list_of_procs,
......
......@@ -22,12 +22,6 @@
#include <string.h>
#ifdef HAVE_GLIBC_REGEX
#include <regex.h>
#else
#include "regexrepl/regex.h"
#endif
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
......@@ -39,11 +33,11 @@
#include "gimppluginprocedure.h"
static int
match_strings (regex_t *preg,
gchar *a)
static gboolean
match_string (GRegex *regex,
gchar *string)
{
return regexec (preg, a, 0, NULL, 0);
return g_regex_match (regex, string, 0, NULL);
}
gint
......@@ -60,7 +54,7 @@ gimp_plug_in_manager_query (GimpPlugInManager *manager,
GSList *list;
GSList *matched = NULL;
gint i = 0;
regex_t sregex;
GRegex *sregex = NULL;
g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), 0);
g_return_val_if_fail (menu_strs != NULL, 0);
......@@ -80,8 +74,13 @@ gimp_plug_in_manager_query (GimpPlugInManager *manager,
if (search_str && ! strlen (search_str))
search_str = NULL;
if (search_str && regcomp (&sregex, search_str, REG_ICASE))
return 0;
if (search_str)
{
sregex = g_regex_new (search_str, G_REGEX_CASELESS | G_REGEX_OPTIMIZE, 0,
NULL);
if (! sregex)
return 0;
}
/* count number of plugin entries, then allocate arrays of correct size
* where we can store the strings.
......@@ -111,7 +110,7 @@ gimp_plug_in_manager_query (GimpPlugInManager *manager,
name = gimp_strip_uline (name);
if (! search_str || ! match_strings (&sregex, name))
if (! search_str || match_string (sregex, name))
{
num_plugins++;
matched = g_slist_prepend (matched, proc);
......@@ -156,8 +155,8 @@ gimp_plug_in_manager_query (GimpPlugInManager *manager,
g_slist_free (matched);
if (search_str)
regfree (&sregex);
if (sregex)
g_regex_unref (sregex);
return num_plugins;
}
......@@ -829,33 +829,6 @@ fi
AC_SUBST(SYMPREFIX)
##################################
# Check for regex support in glibc
##################################
AC_MSG_CHECKING(checking for regex in glibc)
AC_TRY_RUN([
#include <features.h>
#include <stdio.h>
#include <regex.h>
int main()
{
#if __GLIBC__ >= 2
return (0);
#else
return (1);
#endif
}], AC_DEFINE(HAVE_GLIBC_REGEX, 1,
[Define to 1 if glibc has regex support.])
have_glibc_regex=yes
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no),
AC_MSG_RESULT(assuming no))
AM_CONDITIONAL(HAVE_GLIBC_REGEX, test "x$have_glibc_regex" = xyes)
AC_SUBST(HAVE_GLIBC_REGEX)
############################
# Check for select and fdset
############################
......@@ -1887,7 +1860,6 @@ AC_CONFIG_FILES([
gimptool-win32.c
tools/Makefile
tools/pdbgen/Makefile
regexrepl/Makefile
libgimp/Makefile
libgimpbase/Makefile
libgimpconfig/Makefile
......
......@@ -18,7 +18,6 @@ SUBDIRS = \
libgimp \
# libgimptool \
libgimpmodule \
regexrepl \
cursors \
app \
# plug-ins \
......
......@@ -52,12 +52,6 @@ script_fu_SOURCES = \
scheme-wrapper.c \
scheme-wrapper.h
if HAVE_GLIBC_REGEX
REGEXREPL =
else
REGEXREPL = $(top_builddir)/regexrepl/libregex.a
endif
LDADD = \
$(libgimpui) \
$(libgimpwidgets) \
......
noinst_LIBRARIES = libregex.a
if HAVE_GLIBC_REGEX
libregex_a_SOURCES =
else
libregex_a_SOURCES = regex.c regex.h
endif
INCLUDES = \
-I$(top_srcdir) \
-I$(includedir)
AM_CPPFLAGS = \
-DREGEX_MALLOC
EXTRA_DIST = \
regex.c \
regex.h \
makefile.msc
# autogenerated from automake.am with automake.py
# and slightly modifies
TOP = ..\..
PRJ_TOP = ..
PACKAGE = regexrepl
!INCLUDE $(TOP)\glib\build\win32\make.msc
PKG_CFLAGS = -I ..
OBJECTS = \
regex.obj \
regex.obj : regex.c regex.h
$(CC) $(CFLAGS) -GD -c -DREGEX_MALLOC -DHAVE_STRING_H $(PKG_CFLAGS) regex.c
all : \
$(PRJ_TOP)\config.h \
$(PACKAGE).dll
$(PRJ_TOP)\config.h: $(PRJ_TOP)\config.h.win32
copy $(PRJ_TOP)\config.h.win32 $(PRJ_TOP)\config.h
RESOURCE = $(PACKAGE).res
$(PACKAGE).lib : $(OBJECTS)
lib /out:$(PACKAGE).lib $(OBJECTS)
$(PACKAGE).dll : $(OBJECTS) $(PACKAGE).def
$(CC) $(CFLAGS) -LD -Fe$(PACKAGE).dll $(OBJECTS) $(PKG_LINK) user32.lib advapi32.lib wsock32.lib $(LDFLAGS) /def:$(PACKAGE).def
$(PACKAGE).exe : $(OBJECTS) $(PACKAGE).def $(PACKAGE).res
$(CC) $(CFLAGS) -Fe$(PACKAGE).exe $(PACKAGE).res $(OBJECTS) $(PKG_LINK) \
user32.lib advapi32.lib shell32.lib wsock32.lib winspool.lib $(LDFLAGS) /def:$(PACKAGE).def
.c.obj :
$(CC) $(CFLAGS) -GD -c $(PKG_CFLAGS) $<
This diff is collapsed.
This diff is collapsed.
EXPORTS
; re_comp
re_compile_fastmap
re_compile_pattern
; re_exec
re_match
re_match_2
re_search
re_search_2
re_set_registers
re_set_syntax
regcomp
regerror
regexec
regfree
......@@ -729,20 +729,8 @@ GPL
}
}
if ($_ eq '"regexrepl/regex.h"') {
$headers .= "\n";
$headers .= "#ifdef HAVE_GLIBC_REGEX\n";
$headers .= "#include <regex.h>\n";
$headers .= "#else\n";
}
$headers .= "#include $_\n";
if ($_ eq '"regexrepl/regex.h"') {
$headers .= "#endif\n";
$nl = 1;
}
if ($_ eq '<unistd.h>') {
$headers .= "#endif\n";
$seen = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment