|
1 | 1 | #ifndef lint |
2 | | -static char *RCSid() { return RCSid("$Id: axis.c,v 1.243 2017-09-10 03:40:01 sfeam Exp $"); } |
| 2 | +static char *RCSid() { return RCSid("$Id: axis.c,v 1.244 2017-09-10 03:49:31 sfeam Exp $"); } |
3 | 3 | #endif |
4 | 4 |
|
5 | 5 | /* GNUPLOT - axis.c */ |
@@ -2226,49 +2226,58 @@ int |
2226 | 2226 | parse_range(AXIS_INDEX axis) |
2227 | 2227 | { |
2228 | 2228 | struct axis *this_axis = &axis_array[axis]; |
| 2229 | + int dummy_token = -1; |
2229 | 2230 |
|
2230 | | - if (equals(c_token, "[")) { |
2231 | | - int dummy_token = -1; |
2232 | | - c_token++; |
2233 | | - /* If the range starts with "[var=" return the token of the named variable. */ |
2234 | | - if (isletter(c_token) && equals(c_token + 1, "=")) { |
2235 | | - dummy_token = c_token; |
2236 | | - c_token += 2; |
2237 | | - } |
2238 | | - this_axis->autoscale = |
2239 | | - load_range(this_axis, &this_axis->min, &this_axis->max, this_axis->autoscale); |
2240 | | - if (this_axis->linked_to_primary) { |
2241 | | - AXIS *primary = this_axis->linked_to_primary; |
2242 | | - primary->min = eval_link_function(primary, this_axis->min); |
2243 | | - primary->max = eval_link_function(primary, this_axis->max); |
2244 | | - } |
| 2231 | + /* No range present */ |
| 2232 | + if (!equals(c_token, "[")) |
| 2233 | + return 0; |
2245 | 2234 |
|
2246 | | - /* DEBUG 2 Sep 2017 |
2247 | | - * This handles (imperfectly) the problem case |
2248 | | - * set link x2 via f(x) inv g(x) |
2249 | | - * plot [x=min:max][] something that involves x2 |
2250 | | - * Other cases of in-line range changes on a linked axis may fail |
2251 | | - */ |
2252 | | - else if (this_axis->linked_to_secondary) { |
2253 | | - AXIS *secondary = this_axis->linked_to_secondary; |
2254 | | - if (secondary->link_udf != NULL && secondary->link_udf->at != NULL) |
2255 | | - clone_linked_axes(this_axis, secondary); |
2256 | | - } |
| 2235 | + /* Empty brackets serve as a place holder */ |
| 2236 | + if (equals(c_token, "[]")) { |
| 2237 | + c_token += 2; |
| 2238 | + return 0; |
| 2239 | + } |
2257 | 2240 |
|
2258 | | - if (axis == SAMPLE_AXIS || axis == T_AXIS || axis == U_AXIS || axis == V_AXIS) { |
2259 | | - this_axis->SAMPLE_INTERVAL = 0; |
2260 | | - if (equals(c_token, ":")) { |
2261 | | - c_token++; |
2262 | | - this_axis->SAMPLE_INTERVAL = real_expression(); |
2263 | | - } |
| 2241 | + /* If the range starts with "[var=" return the token of the named variable. */ |
| 2242 | + c_token++; |
| 2243 | + if (isletter(c_token) && equals(c_token + 1, "=")) { |
| 2244 | + dummy_token = c_token; |
| 2245 | + c_token += 2; |
| 2246 | + } |
| 2247 | + |
| 2248 | + this_axis->autoscale = load_range(this_axis, &this_axis->min, &this_axis->max, |
| 2249 | + this_axis->autoscale); |
| 2250 | + |
| 2251 | + /* Nonlinear axis - find the linear range equivalent */ |
| 2252 | + if (this_axis->linked_to_primary) { |
| 2253 | + AXIS *primary = this_axis->linked_to_primary; |
| 2254 | + clone_linked_axes(this_axis, primary); |
| 2255 | + } |
| 2256 | + |
| 2257 | + /* This handles (imperfectly) the problem case |
| 2258 | + * set link x2 via f(x) inv g(x) |
| 2259 | + * plot [x=min:max][] something that involves x2 |
| 2260 | + * Other cases of in-line range changes on a linked axis may fail |
| 2261 | + */ |
| 2262 | + else if (this_axis->linked_to_secondary) { |
| 2263 | + AXIS *secondary = this_axis->linked_to_secondary; |
| 2264 | + if (secondary->link_udf != NULL && secondary->link_udf->at != NULL) |
| 2265 | + clone_linked_axes(this_axis, secondary); |
| 2266 | + } |
| 2267 | + |
| 2268 | + if (axis == SAMPLE_AXIS || axis == T_AXIS || axis == U_AXIS || axis == V_AXIS) { |
| 2269 | + this_axis->SAMPLE_INTERVAL = 0; |
| 2270 | + if (equals(c_token, ":")) { |
| 2271 | + c_token++; |
| 2272 | + this_axis->SAMPLE_INTERVAL = real_expression(); |
2264 | 2273 | } |
| 2274 | + } |
2265 | 2275 |
|
2266 | | - if (!equals(c_token, "]")) |
2267 | | - int_error(c_token, "']' expected"); |
2268 | | - c_token++; |
2269 | | - return dummy_token; |
2270 | | - } else |
2271 | | - return 0; |
| 2276 | + if (!equals(c_token, "]")) |
| 2277 | + int_error(c_token, "']' expected"); |
| 2278 | + c_token++; |
| 2279 | + |
| 2280 | + return dummy_token; |
2272 | 2281 | } |
2273 | 2282 |
|
2274 | 2283 | /* Called if an in-line range is encountered while inside a zoom command */ |
|
0 commit comments