|
From: Thomas S. <t.s...@fz...> - 2008-03-29 11:59:14
|
> in principle it should be possible to delete a variable, but only with some
> modification of the source code.
could somebody have a look into the attached patch?
seems to work, but i'm not sure if i did everything right.
--------------------------------- snip -------------------------------------
--- src/tables.c.orig 2008-03-29 10:28:07.000000000 +0100
+++ src/tables.c 2008-03-29 11:57:55.000000000 +0100
@@ -57,6 +57,7 @@
{ "cd", changedir_command },
{ "cl$ear", clear_command },
{ "ex$it", exit_command },
+ { "d$elete", delvar_command },
{ "f$it", fit_command },
{ "h$elp", help_command },
{ "?", help_command },
--- src/command.h.orig 2008-03-03 20:25:02.000000000 +0100
+++ src/command.h 2008-03-29 12:05:19.000000000 +0100
@@ -174,6 +174,7 @@
void test_command __PROTO((void));
void update_command __PROTO((void));
void do_shell __PROTO((void));
+void delvar_command __PROTO((void));
/* Prototypes for functions exported by command.c */
void extend_input_line __PROTO((void));
--- src/command.c.orig 2008-03-29 10:28:01.000000000 +0100
+++ src/command.c 2008-03-29 12:39:12.000000000 +0100
@@ -532,6 +532,33 @@
}
+void
+delvar_command()
+{
+ char *key = NULL;
+ struct udvt_entry **udv_ptr = &first_udv;
+ c_token++;
+ if (!END_OF_COMMAND) {
+ key = gp_input_line + token[c_token].start_index;
+ if (!key)
+ int_error(c_token, "expecting variable name");
+ if (!strncmp(key, "GPVAL_", 6) || !strncmp(key, "MOUSE_", 6))
+ int_error(c_token, "Cannot delete internal variables GPVAL_ and
MOUSE_");
+ while (*udv_ptr) {
+ if (!strcmp(key, (*udv_ptr)->udv_name)) {
+ (*udv_ptr)->udv_undef = TRUE;
+ cleanup_udvlist();
+ c_token++;
+ return;
+ }
+ udv_ptr = &((*udv_ptr)->next_udv);
+ }
+ int_error(c_token, "variable name not found");
+ }
+ int_error(c_token, "expecting variable name");
+}
+
+
static void
command()
{
--------------------------------- snip -------------------------------------
http://www.nabble.com/file/p16369153/delete_vars.patch delete_vars.patch
--
View this message in context: http://www.nabble.com/Question-on-variables-tp16360322p16369153.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|