[prev in list] [next in list] [prev in thread] [next in thread]
List: gnuplot-info-beta
Subject: patch for any order of options in plot and splot
From: Petr Mikulik <mikulik () monoceros ! physics ! muni ! cz>
Date: 2001-11-25 19:59:48
[Download RAW message or body]
Enclosed is a patch that allows any order of options in plot and splot
commands.
Please test this patch as well as the 'set arrow' which now supports
any order of options too.
---
Petr Mikulik
["any_opt_order_plot.diff" (TEXT/PLAIN)]
any order of options and plot and splot
Enclosed is a patch that allows any order of options in plot and splot
commands.
Please test this patch as well as the 'set arrow' which now supports
any order of options too.
======================================================================
--- datafile-orig.c Wed Nov 7 19:50:38 2001
+++ datafile.c Sun Nov 25 16:37:20 2001
@@ -527,6 +527,10 @@
int i;
int name_token;
+ TBOOLEAN duplication = FALSE;
+ TBOOLEAN set_index = FALSE, set_every = FALSE, set_thru = FALSE;
+ TBOOLEAN set_using = FALSE;
+
fast_columns = 1; /* corey@cac */
/*{{{ close file if necessary */
@@ -584,48 +588,71 @@
/* defer opening until we have parsed the modifiers... */
- /*{{{ look for binary / matrix */
+ if (ydata_func.at) /* something for thru (?) */
+ free(ydata_func.at);
+ ydata_func.at = NULL;
+
df_binary = df_matrix = FALSE;
+ /* pm 25.11.2001 allow any order of options */
+ while (1) {
+
+ /* look for binary / matrix */
if (almost_equals(c_token, "bin$ary")) {
- ++c_token;
+ if (df_matrix) { duplication=TRUE; break; }
+ c_token++;
df_binary = TRUE;
df_matrix = TRUE;
- } else if (almost_equals(c_token, "mat$rix")) {
- ++c_token;
+ continue;
+ }
+
+ /* deal with matrix */
+ if (almost_equals(c_token, "mat$rix")) {
+ if (df_matrix) { duplication=TRUE; break; }
+ c_token++;
df_matrix = TRUE;
+ continue;
}
- /*}}} */
- /*{{{ deal with index */
+ /* deal with index */
if (almost_equals(c_token, "i$ndex")) {
+ if (set_index) { duplication=TRUE; break; }
plot_option_index();
+ set_index = TRUE;
+ continue;
}
- /*}}} */
- /*{{{ deal with every */
+ /* deal with every */
if (almost_equals(c_token, "ev$ery")) {
+ if (set_every) { duplication=TRUE; break; }
plot_option_every();
+ set_every = TRUE;
+ continue;
}
- /*}}} */
- /*{{{ deal with thru */
+ /* deal with thru */
/* jev -- support for passing data from file thru user function */
-
- if (ydata_func.at)
- free(ydata_func.at);
- ydata_func.at = NULL;
-
if (almost_equals(c_token, "thru$")) {
+ if (set_thru) { duplication=TRUE; break; }
plot_option_thru();
+ set_thru = TRUE;
+ continue;
}
- /*}}} */
- /*{{{ deal with using */
+ /* deal with using */
if (almost_equals(c_token, "u$sing")) {
+ if (set_using) { duplication=TRUE; break; }
plot_option_using(max_using);
+ set_using = TRUE;
+ continue;
}
- /*}}} */
+
+ break; /* unknown option */
+
+ } /* while (1) */
+
+ if (duplication)
+ int_error(c_token, "duplicated or contradicting arguments in datafile options");
/*{{{ more variable inits */
point_count = -1; /* we preincrement */
--- plot2d-orig.c Mon Aug 27 17:02:14 2001
+++ plot2d.c Sun Nov 25 18:10:30 2001
@@ -914,6 +914,10 @@
/* for datafile plot, record datafile spec for title */
int start_token = c_token, end_token;
+ TBOOLEAN duplication = FALSE;
+ TBOOLEAN set_smooth = FALSE, set_axes = FALSE, set_title = FALSE;
+ TBOOLEAN set_with = FALSE;
+
plot_num++;
if (isstring(c_token)) { /* data file to plot */
@@ -967,10 +971,16 @@
x_axis = FIRST_X_AXIS;
y_axis = FIRST_Y_AXIS;
+ /* pm 25.11.2001 allow any order of options */
+ while (1) {
+
+ if (END_OF_COMMAND) break;
+
/* deal with smooth */
if (almost_equals(c_token, "s$mooth")) {
- int found_token =
- lookup_table(plot_smooth_tbl, ++c_token);
+ int found_token;
+ if (set_smooth) { duplication=TRUE; break; }
+ found_token = lookup_table(plot_smooth_tbl, ++c_token);
switch(found_token) {
case SMOOTH_ACSPLINES:
@@ -988,10 +998,13 @@
}
this_plot->plot_style = LINES;
c_token++; /* skip format */
+ set_smooth = TRUE;
+ continue;
}
/* look for axes/axis */
if (almost_equals(c_token, "ax$es") || almost_equals(c_token, "ax$is")) {
+ if (set_axes) { duplication=TRUE; break; }
if (parametric && xparam)
int_error(c_token, "previous parametric function not fully specified");
@@ -1022,9 +1035,13 @@
int_error(c_token, "axes must be x1y1, x1y2, x2y1 or x2y2");
break;
}
+ set_axes = TRUE;
+ continue;
}
+ /* deal with title */
if (almost_equals(c_token, "t$itle")) {
+ if (set_title) { duplication=TRUE; break; }
this_plot->title_no_enhanced = 0; /* can be enhanced */
if (parametric) {
if (xparam)
@@ -1039,18 +1056,22 @@
int_error(c_token, "expecting \"title\" for plot");
}
c_token++;
- } else if (almost_equals(c_token, "not$itle")) {
+ set_title = TRUE;
+ continue;
+ }
+
+ if (almost_equals(c_token, "not$itle")) {
+ if (set_title) { duplication=TRUE; break; }
if (xtitle != NULL)
xtitle[0] = '\0';
c_token++;
- } else {
- this_plot->title_no_enhanced = 1; /* filename or function cannot be enhanced */
- m_capture(&(this_plot->title), start_token, end_token);
- if (xparam)
- xtitle = this_plot->title;
+ set_title = TRUE;
+ continue;
}
+ /* deal with style */
if (almost_equals(c_token, "w$ith")) {
+ if (set_with) { duplication=TRUE; break; }
if (parametric && xparam)
int_error(c_token, "\"with\" allowed only after parametric function fully \
specified"); this_plot->plot_style = get_style();
@@ -1060,15 +1081,41 @@
int_warn(c_token, "This plot style is only for datafiles, reverting to \
\"points\""); this_plot->plot_style = POINTSTYLE;
}
+ set_with = TRUE;
+ continue;
}
/* pick up line/point specs
* - point spec allowed if style uses points, ie style&2 != 0
* - keywords for lt and pt are optional
*/
- lp_parse(&(this_plot->lp_properties), 1,
+ {
+ int stored_token = c_token;
+
+ lp_parse(&this_plot->lp_properties, 1,
this_plot->plot_style & PLOT_STYLE_HAS_POINT,
line_num, point_num);
+ if (stored_token != c_token) {
+ /* the following would be just too restrictive */
+ /* set_line = TRUE; */
+ continue;
+ }
+ }
+
+ break; /* unknown option */
+
+ } /* while (1) */
+
+ if (duplication)
+ int_error(c_token, "duplicated or contradicting arguments in plot options");
+
+ /* set default values for title if this has not been specified */
+ if (!set_title) {
+ this_plot->title_no_enhanced = 1; /* filename or function cannot be enhanced */
+ m_capture(&(this_plot->title), start_token, end_token);
+ if (xparam)
+ xtitle = this_plot->title;
+ }
/* allow old-style syntax too - ignore case lt 3 4 for example */
if (!equals(c_token, ",") && !END_OF_COMMAND) {
--- plot3d-orig.c Fri Oct 5 18:58:55 2001
+++ plot3d.c Sun Nov 25 18:11:03 2001
@@ -943,6 +943,9 @@
int specs;
struct surface_points *this_plot;
+ TBOOLEAN duplication = FALSE;
+ TBOOLEAN set_title = FALSE, set_with = FALSE;
+
if (isstring(c_token)) { /* data file to plot */
/*{{{ data file */
@@ -1042,13 +1045,27 @@
} /* end of IS THIS A FILE OR A FUNC block */
-
- /*{{{ title */
+ /* clear current title, if exist */
if (this_plot->title) {
free(this_plot->title);
this_plot->title = NULL;
}
+
+ /* default line and point types, no palette */
+#ifdef PM3D
+ this_plot->lp_properties.use_palette = 0;
+#endif
+ this_plot->lp_properties.l_type = line_num;
+ this_plot->lp_properties.p_type = point_num;
+
+
+ /* pm 25.11.2001 allow any order of options */
+ while (1) {
+
+ if (END_OF_COMMAND) break;
+ /* deal with title */
if (almost_equals(c_token, "t$itle")) {
+ if (set_title) { duplication=TRUE; break; }
this_plot->title_no_enhanced = 0; /* can be enhanced */
if (parametric) {
if (crnt_param != 0)
@@ -1065,33 +1082,26 @@
else
int_error(c_token, "expecting \"title\" for plot");
/* end of new method */
- ++c_token;
- } else if (almost_equals(c_token, "not$itle")) {
+ c_token++;
+ set_title = TRUE;
+ continue;
+ }
+
+ if (almost_equals(c_token, "not$itle")) {
+ if (set_title) { duplication=TRUE; break; }
if (xtitle != NULL)
xtitle[0] = '\0';
if (ytitle != NULL)
ytitle[0] = '\0';
/* this_plot->title = NULL; */
- ++c_token;
- } else {
- this_plot->title_no_enhanced = 1; /* filename or function cannot be enhanced */
- m_capture(&(this_plot->title), start_token, end_token);
- if (crnt_param == 2)
- xtitle = this_plot->title;
- else if (crnt_param == 1)
- ytitle = this_plot->title;
+ c_token++;
+ set_title = TRUE;
+ continue;
}
- /*}}} */
-
-
- /*{{{ line types, widths, ... */
-#ifdef PM3D
- this_plot->lp_properties.use_palette = 0;
-#endif
- this_plot->lp_properties.l_type = line_num;
- this_plot->lp_properties.p_type = point_num;
+ /* deal with style */
if (almost_equals(c_token, "w$ith")) {
+ if (set_with) { duplication=TRUE; break; }
this_plot->plot_style = get_style();
if ((this_plot->plot_type == FUNC3D)
&& (this_plot->plot_style & PLOT_STYLE_HAS_ERRORBAR))
@@ -1099,14 +1109,43 @@
int_warn(c_token, "This plot style is only for datafiles , \
reverting to \"points\""); this_plot->plot_style = POINTSTYLE;
}
+ set_with = TRUE;
+ continue;
}
+
/* pick up line/point specs
* - point spec allowed if style uses points, ie style&2 != 0
* - keywords are optional
*/
+ {
+ int stored_token = c_token;
+
lp_parse(&this_plot->lp_properties, 1,
this_plot->plot_style & PLOT_STYLE_HAS_POINT,
line_num, point_num);
+ if (stored_token != c_token) {
+ /* the following would be just too restrictive */
+ /* set_line = TRUE; */
+ continue;
+ }
+ }
+
+ break; /* unknown option */
+
+ } /* while (1) */
+
+ if (duplication)
+ int_error(c_token, "duplicated or contradicting arguments in plot options");
+
+ /* set default values for title if this has not been specified */
+ if (!set_title) {
+ this_plot->title_no_enhanced = 1; /* filename or function cannot be enhanced */
+ m_capture(&(this_plot->title), start_token, end_token);
+ if (crnt_param == 2)
+ xtitle = this_plot->title;
+ else if (crnt_param == 1)
+ ytitle = this_plot->title;
+ }
/* allow old-style syntax too - ignore case lt 3 4 for example */
if (!equals(c_token, ",") && !END_OF_COMMAND) {
@@ -1126,7 +1165,6 @@
if (crnt_param == 0)
line_num += 1 + (draw_contour != 0)
+ (hidden3d != 0);
- /*}}} */
/* now get the data... having to think hard here...
[[[[ unsubscribe from info-gnuplot-beta via majordomo@dartmouth.edu ]]]]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic