Commit 97824930 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/plug-in/Makefile.am new files that parse pluginrc using a GScanner.

2001-12-28  Sven Neumann  <sven@gimp.org>

	* app/plug-in/Makefile.am
	* app/plug-in/plug-in-rc.[ch]: new files that parse pluginrc using a
	GScanner.

	* app/plug-in/plug-in.[ch]: made PlugInDef public again so we can use
	it from the pluginrc parser.

	* tools/pdbgen/pdb/procedural_db.pdb: made regex string matching
	robust against NULL pointers.

	* app/pdb/procedural_db_cmds.c: regenerated.

	* app/gimprc.c: removed old pluginrc parser.
parent f3b79372
2001-12-28 Sven Neumann <sven@gimp.org>
* app/plug-in/Makefile.am
* app/plug-in/plug-in-rc.[ch]: new files that parse pluginrc using a
GScanner.
* app/plug-in/plug-in.[ch]: made PlugInDef public again so we can use
it from the pluginrc parser.
* tools/pdbgen/pdb/procedural_db.pdb: made regex string matching
robust against NULL pointers.
* app/pdb/procedural_db_cmds.c: regenerated.
* app/gimprc.c: removed old pluginrc parser.
2001-12-27 DindinX <David@dindinx.org>
* app/tools/gimpmagnifytool.c: Added a threshold value determining by how
many pixels the mouse should move to use the window mode.
* app/tools/gimpmagnifytool.c: Added a threshold value determining
by how many pixels the mouse should move to use the window mode.
2001-12-27 Sven Neumann <sven@gimp.org>
......
......@@ -108,6 +108,7 @@
#include "plug-in.h"
#include "plug-in-proc.h"
#include "plug-in-rc.h"
#include "app_procs.h"
#include "gimpprogress.h"
......@@ -116,17 +117,6 @@
#include "libgimp/gimpintl.h"
struct _PlugInDef
{
gchar *prog;
GSList *proc_defs;
gchar *locale_domain;
gchar *locale_path;
gchar *help_path;
time_t mtime;
gboolean query;
};
typedef struct _PlugInBlocked PlugInBlocked;
......@@ -364,7 +354,7 @@ plug_in_init (Gimp *gimp,
filename = gimp_personal_rc_file ("pluginrc");
(* status_callback) (_("Resource configuration"), filename, -1);
gimprc_parse_file (filename);
plug_in_rc_parse (filename);
/* query any plug-ins that have changed since we last wrote out
* the pluginrc file.
......
......@@ -47,8 +47,6 @@
#include "core/gimpparasite.h"
#include "core/gimptoolinfo.h"
#include "plug-in/plug-in.h"
#include "widgets/gimpdevices.h"
#include "widgets/gimpdialogfactory.h"
......@@ -68,8 +66,6 @@
#define ERROR 0
#define DONE 1
#define OK 2
#define LOCALE_DEF 3
#define HELP_DEF 4
#define DEFAULT_IMAGE_TITLE_FORMAT "%f-%p.%i (%t)"
......@@ -90,7 +86,6 @@ typedef enum
TT_INTERP,
TT_XPREVSIZE,
TT_XUNIT,
TT_XPLUGINDEF,
TT_XMENUPATH,
TT_XDEVICE,
TT_XSESSIONINFO,
......@@ -141,7 +136,6 @@ static gint parse_interpolation_type (gpointer val1p, gpointer val2p)
static gint parse_preview_size (gpointer val1p, gpointer val2p);
static gint parse_nav_preview_size (gpointer val1p, gpointer val2p);
static gint parse_units (gpointer val1p, gpointer val2p);
static gint parse_plug_in_def (gpointer val1p, gpointer val2p);
static gint parse_device (gpointer val1p, gpointer val2p);
static gint parse_menu_path (gpointer val1p, gpointer val2p);
static gint parse_session_info (gpointer val1p, gpointer val2p);
......@@ -152,10 +146,6 @@ static gint parse_cursor_mode (gpointer val1p, gpointer val2p)
static gint parse_color_history (gpointer val1p, gpointer val2p);
static gint parse_document (gpointer val1p, gpointer val2p);
static gint parse_locale_def (PlugInDef *plug_in_def);
static gint parse_help_def (PlugInDef *plug_in_def);
static gint parse_proc_def (PlugInProcDef **proc_def);
static gint parse_proc_arg (ProcArg *arg);
static gint parse_color (GimpRGB *color);
static gint parse_unknown (gchar *token_sym);
......@@ -302,7 +292,6 @@ static ParseFunc funcs[] =
{ "theme", TT_STRING, &gimprc.theme, NULL },
{ "parasite", TT_XPARASITE, NULL, NULL },
{ "plug-in-def", TT_XPLUGINDEF, NULL, NULL },
{ "menu-path", TT_XMENUPATH, NULL, NULL },
{ "device", TT_XDEVICE, NULL, NULL },
{ "session-info", TT_XSESSIONINFO, NULL, NULL },
......@@ -915,8 +904,6 @@ parse_statement (void)
return parse_nav_preview_size (func->val1p, func->val2p);
case TT_XUNIT:
return parse_units (func->val1p, func->val2p);
case TT_XPLUGINDEF:
return parse_plug_in_def (func->val1p, func->val2p);
case TT_XMENUPATH:
return parse_menu_path (func->val1p, func->val2p);
case TT_XDEVICE:
......@@ -1399,333 +1386,6 @@ parse_units (gpointer val1p,
return OK;
}
static gint
parse_plug_in_def (gpointer val1p,
gpointer val2p)
{
PlugInDef *plug_in_def;
PlugInProcDef *proc_def;
gint token;
gint success;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
plug_in_def = plug_in_def_new (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
plug_in_def_set_mtime (plug_in_def, token_int);
success = OK;
while (success == OK)
{
success = parse_proc_def (&proc_def);
if (success == OK)
plug_in_def_add_proc_def (plug_in_def, proc_def);
else if (success == LOCALE_DEF)
success = parse_locale_def (plug_in_def);
else if (success == HELP_DEF)
success = parse_help_def (plug_in_def);
}
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
goto error;
token = get_next_token ();
plug_in_def_add (plug_in_def);
return OK;
error:
g_message (_("error parsing pluginrc"));
plug_in_def_free (plug_in_def, TRUE);
return ERROR;
}
static gint
parse_locale_def (PlugInDef *plug_in_def)
{
gint token;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
plug_in_def_set_locale_domain_name (plug_in_def, token_str);
token = peek_next_token ();
if (token && token == TOKEN_STRING)
{
token = get_next_token ();
plug_in_def_set_locale_domain_path (plug_in_def, token_str);
token = peek_next_token ();
}
if (!token || token != TOKEN_RIGHT_PAREN)
goto error;
token = get_next_token ();
return OK;
error:
plug_in_def_set_locale_domain_name (plug_in_def, NULL);
plug_in_def_set_locale_domain_path (plug_in_def, NULL);
return ERROR;
}
static gint
parse_help_def (PlugInDef *plug_in_def)
{
gint token;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
plug_in_def_set_help_path (plug_in_def, token_str);
token = peek_next_token ();
if (!token || token != TOKEN_RIGHT_PAREN)
goto error;
token = get_next_token ();
return OK;
error:
plug_in_def_set_help_path (plug_in_def, NULL);
return ERROR;
}
static gint
parse_proc_def (PlugInProcDef **proc_def)
{
PlugInProcDef *pd;
gint token;
gint i;
token = peek_next_token ();
if (!token || (token != TOKEN_LEFT_PAREN))
return ERROR;
token = get_next_token ();
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
return ERROR;
if ((strcmp ("locale-def", token_sym) == 0))
{
token = get_next_token ();
/* it's a locale_def, let parse_locale_def do the rest */
return LOCALE_DEF;
}
if ((strcmp ("help-def", token_sym) == 0))
{
token = get_next_token ();
/* it's a help_def, let parse_help_def do the rest */
return HELP_DEF;
}
else if (strcmp ("proc-def", token_sym) != 0)
return ERROR;
token = get_next_token ();
pd = g_new0 (PlugInProcDef, 1);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
pd->db_info.name = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
pd->db_info.proc_type = token_int;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
pd->db_info.blurb = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
pd->db_info.help = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
pd->db_info.author = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
pd->db_info.copyright = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
pd->db_info.date = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
if (token_str[0] != '\0')
pd->menu_path = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
if (token_str[0] != '\0')
pd->extensions = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
if (token_str[0] != '\0')
pd->prefixes = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
if (token_str[0] != '\0')
pd->magics = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
if (token_str[0] != '\0')
{
pd->image_types = g_strdup (token_str);
pd->image_types_val = plug_in_image_types_parse (token_str);
}
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
pd->db_info.num_args = token_int;
pd->db_info.args = g_new0 (ProcArg, pd->db_info.num_args);
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
pd->db_info.num_values = token_int;
pd->db_info.values = NULL;
if (pd->db_info.num_values > 0)
pd->db_info.values = g_new (ProcArg, pd->db_info.num_values);
for (i = 0; i < pd->db_info.num_args; i++)
if (!parse_proc_arg (&pd->db_info.args[i]))
goto error;
for (i = 0; i < pd->db_info.num_values; i++)
if (!parse_proc_arg (&pd->db_info.values[i]))
goto error;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
goto error;
token = get_next_token ();
*proc_def = pd;
return OK;
error:
plug_in_proc_def_destroy (pd, FALSE);
return ERROR;
}
static gint
parse_proc_arg (ProcArg *arg)
{
gint token;
arg->arg_type = -1;
arg->name = NULL;
arg->description = NULL;
token = peek_next_token ();
if (!token || (token != TOKEN_LEFT_PAREN))
return ERROR;
token = get_next_token ();
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL) ||
(strcmp ("proc-arg", token_sym) != 0))
return ERROR;
token = get_next_token ();
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
arg->arg_type = token_int;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
arg->name = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
arg->description = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
goto error;
token = get_next_token ();
return OK;
error:
g_free (arg->name);
g_free (arg->description);
return ERROR;
}
static gint
parse_color (GimpRGB *color)
{
......@@ -2803,7 +2463,6 @@ gimprc_value_to_str (const gchar *name)
return cursor_mode_to_str (func->val1p, func->val2p);
case TT_XCOMMENT:
return comment_to_str (func->val1p, func->val2p);
case TT_XPLUGINDEF:
case TT_XMENUPATH:
case TT_XDEVICE:
case TT_XSESSIONINFO:
......
......@@ -108,6 +108,7 @@
#include "plug-in.h"
#include "plug-in-proc.h"
#include "plug-in-rc.h"
#include "app_procs.h"
#include "gimpprogress.h"
......@@ -116,17 +117,6 @@
#include "libgimp/gimpintl.h"
struct _PlugInDef
{
gchar *prog;
GSList *proc_defs;
gchar *locale_domain;
gchar *locale_path;
gchar *help_path;
time_t mtime;
gboolean query;
};
typedef struct _PlugInBlocked PlugInBlocked;
......@@ -364,7 +354,7 @@ plug_in_init (Gimp *gimp,
filename = gimp_personal_rc_file ("pluginrc");
(* status_callback) (_("Resource configuration"), filename, -1);
gimprc_parse_file (filename);
plug_in_rc_parse (filename);
/* query any plug-ins that have changed since we last wrote out
* the pluginrc file.
......
......@@ -108,6 +108,7 @@
#include "plug-in.h"
#include "plug-in-proc.h"
#include "plug-in-rc.h"
#include "app_procs.h"
#include "gimpprogress.h"
......@@ -116,17 +117,6 @@
#include "libgimp/gimpintl.h"
struct _PlugInDef
{
gchar *prog;
GSList *proc_defs;
gchar *locale_domain;
gchar *locale_path;
gchar *help_path;
time_t mtime;
gboolean query;
};
typedef struct _PlugInBlocked PlugInBlocked;
......@@ -364,7 +354,7 @@ plug_in_init (Gimp *gimp,
filename = gimp_personal_rc_file ("pluginrc");
(* status_callback) (_("Resource configuration"), filename, -1);
gimprc_parse_file (filename);
plug_in_rc_parse (filename);
/* query any plug-ins that have changed since we last wrote out
* the pluginrc file.
......
......@@ -108,6 +108,7 @@
#include "plug-in.h"
#include "plug-in-proc.h"
#include "plug-in-rc.h"
#include "app_procs.h"
#include "gimpprogress.h"
......@@ -116,17 +117,6 @@
#include "libgimp/gimpintl.h"
struct _PlugInDef
{
gchar *prog;
GSList *proc_defs;
gchar *locale_domain;
gchar *locale_path;
gchar *help_path;
time_t mtime;
gboolean query;
};
typedef struct _PlugInBlocked PlugInBlocked;
......@@ -364,7 +354,7 @@ plug_in_init (Gimp *gimp,
filename = gimp_personal_rc_file ("pluginrc");
(* status_callback) (_("Resource configuration"), filename, -1);
gimprc_parse_file (filename);
plug_in_rc_parse (filename);
/* query any plug-ins that have changed since we last wrote out
* the pluginrc file.
......
......@@ -133,6 +133,9 @@ static int
match_strings (regex_t *preg,
gchar *a)
{
if (!a)
return 0;
return regexec (preg, a, 0, NULL, 0);
}
......
......@@ -21,4 +21,6 @@ libappplug_in_a_SOURCES = @STRIP_BEGIN@ \
plug-in.h \
plug-in-proc.c \
plug-in-proc.h \
plug-in-rc.c \
plug-in-rc.h \
@STRIP_END@
......@@ -108,6 +108,7 @@
#include "plug-in.h"
#include "plug-in-proc.h"
#include "plug-in-rc.h"
#include "app_procs.h"
#include "gimpprogress.h"
......@@ -116,17 +117,6 @@
#include "libgimp/gimpintl.h"
struct _PlugInDef
{
gchar *prog;
GSList *proc_defs;
gchar *locale_domain;
gchar *locale_path;
gchar *help_path;
time_t mtime;
gboolean query;
};
typedef struct _PlugInBlocked PlugInBlocked;
......@@ -364,7 +354,7 @@ plug_in_init (Gimp *gimp,
filename = gimp_personal_rc_file ("pluginrc");
(* status_callback) (_("Resource configuration"), filename, -1);
gimprc_parse_file (filename);
plug_in_rc_parse (filename);
/* query any plug-ins that have changed since we last wrote out
* the pluginrc file.
......
......@@ -108,6 +108,7 @@
#include "plug-in.h"
#include "plug-in-proc.h"
#include "plug-in-rc.h"
#include "app_procs.h"
#include "gimpprogress.h"
......@@ -116,17 +117,6 @@
#include "libgimp/gimpintl.h"