* edit-widget.h (struct WEdit): Add GTree *defines field.
* syntax.c: Use edit->defines instead of static defines.
Этот коммит содержится в:
родитель
55b48c7d74
Коммит
ad84a71c64
@ -1,3 +1,8 @@
|
|||||||
|
2003-10-23 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||||
|
|
||||||
|
* edit-widget.h (struct WEdit): Add GTree *defines field.
|
||||||
|
* syntax.c: Use edit->defines instead of static defines.
|
||||||
|
|
||||||
2003-10-16 Andrew V. Samoilov <sav@bcs.zp.ua>
|
2003-10-16 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||||
|
|
||||||
* syntax.c (compare_word_to_right): More checks for braces and
|
* syntax.c (compare_word_to_right): More checks for braces and
|
||||||
|
@ -95,6 +95,7 @@ struct WEdit {
|
|||||||
long last_get_rule;
|
long last_get_rule;
|
||||||
struct syntax_rule rule;
|
struct syntax_rule rule;
|
||||||
char *syntax_type; /* description of syntax highlighting type being used */
|
char *syntax_type; /* description of syntax highlighting type being used */
|
||||||
|
GTree *defines; /* List of defines */
|
||||||
|
|
||||||
/* macro stuff */
|
/* macro stuff */
|
||||||
int macro_i; /* index to macro[], -1 if not recording a macro */
|
int macro_i; /* index to macro[], -1 if not recording a macro */
|
||||||
|
@ -88,9 +88,6 @@ int option_syntax_highlighting = 1;
|
|||||||
|
|
||||||
#define syntax_g_free(x) do {if(x) {g_free(x); (x)=0;}} while (0)
|
#define syntax_g_free(x) do {if(x) {g_free(x); (x)=0;}} while (0)
|
||||||
|
|
||||||
/* List of defines */
|
|
||||||
static GTree *defines;
|
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
mc_defines_destroy (gpointer key, gpointer value, gpointer data)
|
mc_defines_destroy (gpointer key, gpointer value, gpointer data)
|
||||||
{
|
{
|
||||||
@ -106,11 +103,11 @@ mc_defines_destroy (gpointer key, gpointer value, gpointer data)
|
|||||||
|
|
||||||
/* Completely destroys the defines tree */
|
/* Completely destroys the defines tree */
|
||||||
static inline void
|
static inline void
|
||||||
destroy_defines (void)
|
destroy_defines (GTree **defines)
|
||||||
{
|
{
|
||||||
g_tree_traverse (defines, mc_defines_destroy, G_POST_ORDER, NULL);
|
g_tree_traverse (*defines, mc_defines_destroy, G_POST_ORDER, NULL);
|
||||||
g_tree_destroy (defines);
|
g_tree_destroy (*defines);
|
||||||
defines = 0;
|
*defines = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -668,8 +665,8 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args)
|
|||||||
|
|
||||||
r = edit->rules = g_malloc0 (MAX_CONTEXTS * sizeof (struct context_rule *));
|
r = edit->rules = g_malloc0 (MAX_CONTEXTS * sizeof (struct context_rule *));
|
||||||
|
|
||||||
if (!defines)
|
if (!edit->defines)
|
||||||
defines = g_tree_new ((GCompareFunc) strcmp);
|
edit->defines = g_tree_new ((GCompareFunc) strcmp);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char **a;
|
char **a;
|
||||||
@ -778,7 +775,7 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args)
|
|||||||
#endif
|
#endif
|
||||||
num_words = 1;
|
num_words = 1;
|
||||||
c->keyword[0] = g_malloc0 (sizeof (struct key_word));
|
c->keyword[0] = g_malloc0 (sizeof (struct key_word));
|
||||||
subst_defines (defines, a, &args[1024]);
|
subst_defines (edit->defines, a, &args[1024]);
|
||||||
fg = *a;
|
fg = *a;
|
||||||
if (*a)
|
if (*a)
|
||||||
a++;
|
a++;
|
||||||
@ -827,7 +824,7 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args)
|
|||||||
}
|
}
|
||||||
k->keyword = g_strdup (*a++);
|
k->keyword = g_strdup (*a++);
|
||||||
k->first = *k->keyword;
|
k->first = *k->keyword;
|
||||||
subst_defines (defines, a, &args[1024]);
|
subst_defines (edit->defines, a, &args[1024]);
|
||||||
fg = *a;
|
fg = *a;
|
||||||
if (*a)
|
if (*a)
|
||||||
a++;
|
a++;
|
||||||
@ -851,13 +848,13 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args)
|
|||||||
|
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
break_a;
|
break_a;
|
||||||
if ((argv = g_tree_lookup (defines, key))) {
|
if ((argv = g_tree_lookup (edit->defines, key))) {
|
||||||
mc_defines_destroy (NULL, argv, NULL);
|
mc_defines_destroy (NULL, argv, NULL);
|
||||||
} else {
|
} else {
|
||||||
key = g_strdup (key);
|
key = g_strdup (key);
|
||||||
}
|
}
|
||||||
argv = g_new (char *, argc - 1);
|
argv = g_new (char *, argc - 1);
|
||||||
g_tree_insert (defines, key, argv);
|
g_tree_insert (edit->defines, key, argv);
|
||||||
while (*a) {
|
while (*a) {
|
||||||
*argv++ = g_strdup (*a++);
|
*argv++ = g_strdup (*a++);
|
||||||
};
|
};
|
||||||
@ -902,8 +899,8 @@ void edit_free_syntax_rules (WEdit * edit)
|
|||||||
int i, j;
|
int i, j;
|
||||||
if (!edit)
|
if (!edit)
|
||||||
return;
|
return;
|
||||||
if (defines)
|
if (edit->defines)
|
||||||
destroy_defines ();
|
destroy_defines (&edit->defines);
|
||||||
if (!edit->rules)
|
if (!edit->rules)
|
||||||
return;
|
return;
|
||||||
edit_get_rule (edit, -1);
|
edit_get_rule (edit, -1);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user