|
From: Juergen W. <wie...@fr...> - 2005-07-10 20:35:13
|
On Tuesday 28 June 2005, Ethan Merritt wrote:
> I will consolidate the (isstring() || isstringvar()) test into a single
> call isstringvalue(). This simplifies the code, which is good.
> If/when Juergen comes up with a fully working isstringfunc(), that can be
> added at a single point in isstringvalue().
I have uploaded a patch addressing the plot/splot problem [#1231847,
str_or_express-2005-07-09.patch]. As far as I can see, it works
sensible in almost all cases. The only known failure case is
gnuplot> x = "file"
gnuplot> f(x) = x . ".dat"
gnuplot> plot f(x)
where it assumes f(x) to be a function plot. But anyone careless
enough to use a dummy name in such a way ...
The second patch [#1231847, get_string-2005-07-09.patch] introduces
the function isexpr(). The idea is to provide a set of functions,
which do as many work as possible.
For example:
* get_string():
Read in string. If there is none, int_error().
Probably a more concise error message could be given from the
calling function.
* try_to_get_string()
Read in string if there is one. If there is none, no operation.
Implementation draft:
save_token = c_token;
result = NULL;
if (isexpr()) {
struct value a;
const_expr(&a);
if (a.type == STRING)
result = a.v.string_val;
else
c_token = save_token;
gpfree_string(&a);
}
* get_number()
* try_to_get_number()
* get_number_or_string():
Well, basically the same as const_expr() now.
* try_to_get_number_or_string()
The latter two functions would be easier to implement without the
GP_STRING_VARS conditionals. They can also be written similar to
str_or_express(), though.
In my opinion such functions should allow for some simplification to
the current code. What do you think? Is this worth going on?
Juergen
PS: I won't read my mails a week or so because I'm on holiday.
|