|
From: Petr M. <mi...@ph...> - 2003-10-21 10:19:24
|
> > I wanted to let the "save" command to save to file only differences wrt
> > "reset" status of gnuplot, so I've patched save_command() + surrounding
> > routines to allow write to pipe. In the attached file, there is that
> > patch + my favourite script "gpsavediff".
>
> I'm somewhat surprised it doesn't already support the "| command" syntax
> already. Given that, I'm all for integrating this patch ASAP.
I've commited the patch.
> > Do you do such a diff-save in a similar way?
>
> Yes. I salvaged a script similar to yours ages ago, from a mail to
> info-gnuplot IIRC. It's called 'reduce-gnuplot-output', it's a
> csh script (of all things), and it only works for named files.
I've been using that mine script for years using REXX, and just recently
rewritten it into shell. BTW, yesterday I've even managed to replace
the pipe "grep | grep -v | sed" into a single sed invocation .. how cool...
> A better approach to the whole task would almost certainly be to integrate
> it into gnuplot itself. But for that to become feasible, we'ld need a
> massive refactoring of the whole internal status stuff:
>
> *) organize the set/show/save/unset/reset implementations by variable, not
> by command, i.e. the set, show, save, unset and reset (default status)
> for a given setting should all be in *one* place, not scattered over
> 4 files (set.c,show.c,unset.c,misc.c). This would make things a
> lot more OO-ish.
That'll be a long file then. Currently, one has to edit all the 3 files
simultaneously.
> *) Add a new method, or a flag to the 'save-variable' method of each
> setting, so it saves only the state different from the default.
Would that mean most variables need to have this_variable_default_value =
{...}?
> *) Add an option to 'save', or a new command 'savediffs' to call that
> new method.
>
> This would be a ton of work, unfortunately. I.e. I'd advise to delay this
> until after the 4.0 release we all still agree should happen soon ---
> right?
Yes.
Another method of the "diff" save would be to write the output into an array
of strings, then the same for invoking internally "reset", and write out
only diff's, and finally re-read internally the status before reset. That'd
emulate the need for external "diff" command, but require many sprintf's
instead of fprintf's.
---
Petr Mikulik
|