Initial release of Maemo 5 port of gnuplot
[gnuplot] / src / unset.c
1 #ifndef lint
2 static char *RCSid() { return RCSid("$Id: unset.c,v 1.99.2.7 2008/12/15 03:44:22 sfeam Exp $"); }
3 #endif
4
5 /* GNUPLOT - unset.c */
6
7 /*[
8  * Copyright 1986 - 1993, 1998, 2004   Thomas Williams, Colin Kelley
9  *
10  * Permission to use, copy, and distribute this software and its
11  * documentation for any purpose with or without fee is hereby granted,
12  * provided that the above copyright notice appear in all copies and
13  * that both that copyright notice and this permission notice appear
14  * in supporting documentation.
15  *
16  * Permission to modify the software is granted, but not the right to
17  * distribute the complete modified source code.  Modifications are to
18  * be distributed as patches to the released version.  Permission to
19  * distribute binaries produced by compiling modified sources is granted,
20  * provided you
21  *   1. distribute the corresponding source modifications from the
22  *    released version in the form of a patch file along with the binaries,
23  *   2. add special version identification to distinguish your version
24  *    in addition to the base release version number,
25  *   3. provide your name and address as the primary contact for the
26  *    support of your modified version, and
27  *   4. retain our contact information in regard to use of the base
28  *    software.
29  * Permission to distribute the released version of the source code along
30  * with corresponding source modifications in the form of a patch file is
31  * granted with same provisions 2 through 4 for binary distributions.
32  *
33  * This software is provided "as is" without express or implied warranty
34  * to the extent permitted by applicable law.
35 ]*/
36
37 #include "setshow.h"
38
39 #include "axis.h"
40 #include "command.h"
41 #include "contour.h"
42 #include "datafile.h"
43 #include "fit.h"
44 #include "gp_hist.h"
45 #include "hidden3d.h"
46 #include "misc.h"
47 #include "parse.h"
48 #include "plot.h"
49 #include "plot2d.h"
50 #include "plot3d.h"
51 #include "tables.h"
52 #include "term_api.h"
53 #include "util.h"
54 #include "variable.h"
55 #include "pm3d.h"
56 #ifdef BINARY_DATA_FILE
57 #  include "datafile.h"
58 #endif
59
60 static void unset_angles __PROTO((void));
61 static void unset_arrow __PROTO((void));
62 static void unset_arrowstyles __PROTO((void));
63 static void free_arrowstyle __PROTO((struct arrowstyle_def *));
64 static void delete_arrow __PROTO((struct arrow_def *, struct arrow_def *));
65 static void unset_autoscale __PROTO((void));
66 static void unset_bars __PROTO((void));
67 static void unset_border __PROTO((void));
68
69 static void unset_boxwidth __PROTO((void));
70 static void unset_fillstyle __PROTO((void));
71 static void unset_clabel __PROTO((void));
72 static void unset_clip __PROTO((void));
73 static void unset_cntrparam __PROTO((void));
74 static void unset_contour __PROTO((void));
75 static void unset_dgrid3d __PROTO((void));
76 static void unset_dummy __PROTO((void));
77 static void unset_encoding __PROTO((void));
78 static void unset_decimalsign __PROTO((void));
79 static void unset_fit __PROTO((void));
80 static void unset_format __PROTO((void));
81 static void unset_grid __PROTO((void));
82 static void unset_hidden3d __PROTO((void));
83 #ifdef EAM_HISTOGRAMS
84 static void unset_histogram __PROTO((void));
85 #endif
86 static void unset_historysize __PROTO((void));
87 static void unset_isosamples __PROTO((void));
88 static void unset_key __PROTO((void));
89 static void unset_keytitle __PROTO((void));
90 static void unset_label __PROTO((void));
91 static void delete_label __PROTO((struct text_label * prev, struct text_label * this));
92 #ifdef EAM_OBJECTS
93 static void unset_object __PROTO((void));
94 static void delete_object __PROTO((struct object * prev, struct object * this));
95 static void unset_style_rectangle __PROTO(());
96 #endif
97 static void unset_loadpath __PROTO((void));
98 static void unset_locale __PROTO((void));
99 static void reset_logscale __PROTO((AXIS_INDEX));
100 static void unset_logscale __PROTO((void));
101 #ifdef GP_MACROS
102 static void unset_macros __PROTO((void));
103 #endif
104 static void unset_mapping __PROTO((void));
105 static void unset_margin __PROTO((t_position *));
106 static void unset_missing __PROTO((void));
107 #ifdef USE_MOUSE
108 static void unset_mouse __PROTO((void));
109 #endif
110 #if 0
111 static void unset_multiplot __PROTO((void));
112 #endif
113
114 static void unset_month_day_tics __PROTO((AXIS_INDEX));
115 static void unset_minitics __PROTO((AXIS_INDEX));
116 #ifdef OLDUNSETTICS
117 static void unset_tics_in __PROTO((void));
118 #endif /* OLDUNSETTICS */
119
120 static void unset_offsets __PROTO((void));
121 static void unset_origin __PROTO((void));
122 static void unset_output __PROTO((void));
123 static void unset_parametric __PROTO((void));
124 static void unset_pm3d __PROTO((void));
125 static void unset_palette __PROTO((void));
126 static void reset_colorbox __PROTO((void));
127 static void unset_colorbox __PROTO((void));
128 static void unset_pointsize __PROTO((void));
129 static void unset_polar __PROTO((void));
130 static void unset_print __PROTO((void));
131 static void unset_samples __PROTO((void));
132 static void unset_size __PROTO((void));
133 static void unset_style __PROTO((void));
134 static void unset_surface __PROTO((void));
135 static void unset_table __PROTO((void));
136 static void unset_terminal __PROTO((void));
137 static void unset_tics __PROTO((AXIS_INDEX));
138 static void unset_ticscale __PROTO((void));
139 static void unset_ticslevel __PROTO((void));
140 static void unset_timefmt __PROTO((void));
141 static void unset_timestamp __PROTO((void));
142 static void unset_view __PROTO((void));
143 static void unset_zero __PROTO((void));
144 static void unset_timedata __PROTO((AXIS_INDEX));
145 static void unset_range __PROTO((AXIS_INDEX));
146 static void unset_zeroaxis __PROTO((AXIS_INDEX));
147 static void unset_all_zeroaxes __PROTO((void));
148
149 static void unset_axislabel_or_title __PROTO((text_label *));
150 static void unset_axislabel __PROTO((AXIS_INDEX));
151
152 /******** The 'unset' command ********/
153 void
154 unset_command()
155 {
156     static char GPFAR unsetmess[] =
157     "valid unset options:  [] = choose one, {} means optional\n\n\
158 \t'angles', 'arrow', 'autoscale', 'bar', 'border', 'boxwidth', 'clabel',\n\
159 \t'clip', 'cntrparam', 'colorbox', 'contour', 'dgrid3d', 'decimalsign',\n\
160 \t'dummy', 'encoding', 'fit', 'format', 'grid', 'hidden3d', 'historysize',\n\
161 \t'isosamples', 'key', 'label', 'loadpath', 'locale', 'logscale',\n\
162 \t'[blrt]margin', 'mapping', 'missing', 'mouse', 'multiplot', 'offsets',\n\
163 \t'origin', 'output', 'palette', 'parametric', 'pm3d', 'pointsize',\n\
164 \t'polar', 'print', '[rtuv]range', 'samples', 'size', 'style', 'surface',\n\
165 \t'terminal', 'tics', 'ticscale', 'ticslevel', 'timestamp', 'timefmt',\n\
166 \t'title', 'view', '[xyz,cb]{2}data', '[xyz,cb]{2}label',\n\
167 \t'[xyz,cb]{2}range', '{m}[xyz,cb]{2}tics', '[xyz,cb]{2}[md]tics',\n\
168 \t'{[xyz]{2}}zeroaxis', 'zero'";
169
170     int found_token;
171
172     c_token++;
173
174     found_token = lookup_table(&set_tbl[0],c_token);
175
176     /* HBB 20000506: rationalize occurences of c_token++ ... */
177     if (found_token != S_INVALID)
178         c_token++;
179
180     switch(found_token) {
181     case S_ANGLES:
182         unset_angles();
183         break;
184     case S_ARROW:
185         unset_arrow();
186         break;
187     case S_AUTOSCALE:
188         unset_autoscale();
189         break;
190     case S_BARS:
191         unset_bars();
192         break;
193     case S_BORDER:
194         unset_border();
195         break;
196     case S_BOXWIDTH:
197         unset_boxwidth();
198         break;
199     case S_CLABEL:
200         unset_clabel();
201         break;
202     case S_CLIP:
203         unset_clip();
204         break;
205     case S_CNTRPARAM:
206         unset_cntrparam();
207         break;
208     case S_CONTOUR:
209         unset_contour();
210         break;
211     case S_DGRID3D:
212         unset_dgrid3d();
213         break;
214     case S_DUMMY:
215         unset_dummy();
216         break;
217     case S_ENCODING:
218         unset_encoding();
219         break;
220     case S_DECIMALSIGN:
221         unset_decimalsign();
222         break;
223     case S_FIT:
224         unset_fit();
225         break;
226     case S_FORMAT:
227         unset_format();
228         break;
229     case S_GRID:
230         unset_grid();
231         break;
232     case S_HIDDEN3D:
233         unset_hidden3d();
234         break;
235     case S_HISTORYSIZE:
236         unset_historysize();
237         break;
238     case S_ISOSAMPLES:
239         unset_isosamples();
240         break;
241     case S_KEY:
242         unset_key();
243         break;
244     case S_KEYTITLE:
245         unset_keytitle();
246         break;
247     case S_LABEL:
248         unset_label();
249         break;
250     case S_LOADPATH:
251         unset_loadpath();
252         break;
253     case S_LOCALE:
254         unset_locale();
255         break;
256     case S_LOGSCALE:
257         unset_logscale();
258         break;
259 #ifdef GP_MACROS
260     case S_MACROS:
261         unset_macros();
262         break;
263 #endif
264     case S_MAPPING:
265         unset_mapping();
266         break;
267     case S_BMARGIN:
268         unset_margin(&bmargin);
269         break;
270     case S_LMARGIN:
271         unset_margin(&lmargin);
272         break;
273     case S_RMARGIN:
274         unset_margin(&rmargin);
275         break;
276     case S_TMARGIN:
277         unset_margin(&tmargin);
278         break;
279     case S_DATAFILE:
280         if (almost_equals(c_token,"fort$ran")) {
281             df_fortran_constants = FALSE;
282             c_token++;
283             break;
284         }
285         df_fortran_constants = FALSE;
286         unset_missing();
287         df_separator = '\0';
288         free(df_commentschars);
289         df_commentschars = gp_strdup(DEFAULT_COMMENTS_CHARS);
290 #ifdef BINARY_DATA_FILE
291         df_unset_datafile_binary();
292 #endif
293         break;
294 #ifdef USE_MOUSE
295     case S_MOUSE:
296         unset_mouse();
297         break;
298 #endif
299     case S_MULTIPLOT:
300 /*      unset_multiplot(); */
301         term_end_multiplot();
302         break;
303     case S_OFFSETS:
304         unset_offsets();
305         break;
306     case S_ORIGIN:
307         unset_origin();
308         break;
309     case SET_OUTPUT:
310         unset_output();
311         break;
312     case S_PARAMETRIC:
313         unset_parametric();
314         break;
315     case S_PM3D:
316         unset_pm3d();
317         break;
318     case S_PALETTE:
319         unset_palette();
320         break;
321     case S_COLORBOX:
322         unset_colorbox();
323         break;
324     case S_POINTSIZE:
325         unset_pointsize();
326         break;
327     case S_POLAR:
328         unset_polar();
329         break;
330     case S_PRINT:
331         unset_print();
332         break;
333 #ifdef EAM_OBJECTS
334     case S_OBJECT:
335         unset_object();
336         break;
337 #endif
338     case S_SAMPLES:
339         unset_samples();
340         break;
341     case S_SIZE:
342         unset_size();
343         break;
344     case S_STYLE:
345         unset_style();
346         break;
347     case S_SURFACE:
348         unset_surface();
349         break;
350     case S_TABLE:
351         unset_table();
352         break;
353     case S_TERMINAL:
354         unset_terminal();
355         break;
356     case S_TICS:
357 #ifdef OLDUNSETTICS
358         unset_tics_in();
359 #else
360         unset_tics(AXIS_ARRAY_SIZE);
361 #endif /* OLDUNSETTICS */
362         break;
363     case S_TICSCALE:
364         unset_ticscale();
365         break;
366     case S_TICSLEVEL:
367         unset_ticslevel();
368         break;
369     case S_TIMEFMT:
370         unset_timefmt();
371         break;
372     case S_TIMESTAMP:
373         unset_timestamp();
374         break;
375     case S_TITLE:
376         unset_axislabel_or_title(&title);
377         break;
378     case S_VIEW:
379         unset_view();
380         break;
381     case S_ZERO:
382         unset_zero();
383         break;
384 /* FIXME - are the tics correct? */
385     case S_MXTICS:
386         unset_minitics(FIRST_X_AXIS);
387         break;
388     case S_XTICS:
389         unset_tics(FIRST_X_AXIS);
390         break;
391     case S_XDTICS:
392     case S_XMTICS:
393         unset_month_day_tics(FIRST_X_AXIS);
394         break;
395     case S_MYTICS:
396         unset_minitics(FIRST_Y_AXIS);
397         break;
398     case S_YTICS:
399         unset_tics(FIRST_Y_AXIS);
400         break;
401     case S_YDTICS:
402     case S_YMTICS:
403         unset_month_day_tics(FIRST_X_AXIS);
404         break;
405     case S_MX2TICS:
406         unset_minitics(SECOND_X_AXIS);
407         break;
408     case S_X2TICS:
409         unset_tics(SECOND_X_AXIS);
410         break;
411     case S_X2DTICS:
412     case S_X2MTICS:
413         unset_month_day_tics(FIRST_X_AXIS);
414         break;
415     case S_MY2TICS:
416         unset_minitics(SECOND_Y_AXIS);
417         break;
418     case S_Y2TICS:
419         unset_tics(SECOND_Y_AXIS);
420         break;
421     case S_Y2DTICS:
422     case S_Y2MTICS:
423         unset_month_day_tics(FIRST_X_AXIS);
424         break;
425     case S_MZTICS:
426         unset_minitics(FIRST_Z_AXIS);
427         break;
428     case S_ZTICS:
429         unset_tics(FIRST_Z_AXIS);
430         break;
431     case S_ZDTICS:
432     case S_ZMTICS:
433         unset_month_day_tics(FIRST_X_AXIS);
434         break;
435     case S_MCBTICS:
436         unset_minitics(COLOR_AXIS);
437         break;
438     case S_CBTICS:
439         unset_tics(COLOR_AXIS);
440         break;
441     case S_CBDTICS:
442     case S_CBMTICS:
443         unset_month_day_tics(FIRST_X_AXIS);
444         break;
445     case S_XDATA:
446         unset_timedata(FIRST_X_AXIS);
447         /* FIXME HBB 20000506: does unsetting these axes make *any*
448          * sense?  After all, their content is never displayed, so
449          * what would they need a corrected format for? */
450         unset_timedata(T_AXIS);
451         unset_timedata(U_AXIS);
452         break;
453     case S_YDATA:
454         unset_timedata(FIRST_Y_AXIS);
455         /* FIXME: see above */
456         unset_timedata(V_AXIS);
457         break;
458     case S_ZDATA:
459         unset_timedata(FIRST_Z_AXIS);
460         break;
461     case S_CBDATA:
462         unset_timedata(COLOR_AXIS);
463         break;
464     case S_X2DATA:
465         unset_timedata(SECOND_X_AXIS);
466         break;
467     case S_Y2DATA:
468         unset_timedata(SECOND_Y_AXIS);
469         break;
470     case S_XLABEL:
471         unset_axislabel(FIRST_X_AXIS);
472         break;
473     case S_YLABEL:
474         unset_axislabel(FIRST_Y_AXIS);
475         break;
476     case S_ZLABEL:
477         unset_axislabel(FIRST_Z_AXIS);
478         break;
479     case S_CBLABEL:
480         unset_axislabel(COLOR_AXIS);
481         break;
482     case S_X2LABEL:
483         unset_axislabel(SECOND_X_AXIS);
484         break;
485     case S_Y2LABEL:
486         unset_axislabel(SECOND_Y_AXIS);
487         break;
488     case S_XRANGE:
489         unset_range(FIRST_X_AXIS);
490         break;
491     case S_X2RANGE:
492         unset_range(SECOND_X_AXIS);
493         break;
494     case S_YRANGE:
495         unset_range(FIRST_Y_AXIS);
496         break;
497     case S_Y2RANGE:
498         unset_range(SECOND_Y_AXIS);
499         break;
500     case S_ZRANGE:
501         unset_range(FIRST_Z_AXIS);
502         break;
503     case S_CBRANGE:
504         unset_range(COLOR_AXIS);
505         break;
506     case S_RRANGE:
507         unset_range(R_AXIS);
508         break;
509     case S_TRANGE:
510         unset_range(T_AXIS);
511         break;
512     case S_URANGE:
513         unset_range(U_AXIS);
514         break;
515     case S_VRANGE:
516         unset_range(V_AXIS);
517         break;
518     case S_XZEROAXIS:
519         unset_zeroaxis(FIRST_X_AXIS);
520         break;
521     case S_YZEROAXIS:
522         unset_zeroaxis(FIRST_Y_AXIS);
523         break;
524     case S_ZZEROAXIS:
525         unset_zeroaxis(FIRST_Z_AXIS);
526         break;
527     case S_X2ZEROAXIS:
528         unset_zeroaxis(SECOND_X_AXIS);
529         break;
530     case S_Y2ZEROAXIS:
531         unset_zeroaxis(SECOND_Y_AXIS);
532         break;
533     case S_ZEROAXIS:
534         unset_all_zeroaxes();
535         break;
536     case S_INVALID:
537     default:
538         int_error(c_token, unsetmess);
539         break;
540     }
541     update_gpval_variables(0); /* update GPVAL_ inner variables */
542 }
543
544
545 /* process 'unset angles' command */
546 static void
547 unset_angles()
548 {
549     ang2rad = 1.0;
550 }
551
552
553 /* process 'unset arrow' command */
554 static void
555 unset_arrow()
556 {
557     struct value a;
558     struct arrow_def *this_arrow;
559     struct arrow_def *prev_arrow;
560     int tag;
561
562     if (END_OF_COMMAND) {
563         /* delete all arrows */
564         while (first_arrow != NULL)
565             delete_arrow((struct arrow_def *) NULL, first_arrow);
566     } else {
567         /* get tag */
568         tag = (int) real(const_express(&a));
569         if (!END_OF_COMMAND)
570             int_error(c_token, "extraneous arguments to unset arrow");
571         for (this_arrow = first_arrow, prev_arrow = NULL;
572              this_arrow != NULL;
573              prev_arrow = this_arrow, this_arrow = this_arrow->next) {
574             if (this_arrow->tag == tag) {
575                 delete_arrow(prev_arrow, this_arrow);
576                 return;         /* exit, our job is done */
577             }
578         }
579         int_error(c_token, "arrow not found");
580     }
581 }
582
583
584 /* delete arrow from linked list started by first_arrow.
585  * called with pointers to the previous arrow (prev) and the
586  * arrow to delete (this).
587  * If there is no previous arrow (the arrow to delete is
588  * first_arrow) then call with prev = NULL.
589  */
590 static void
591 delete_arrow(struct arrow_def *prev, struct arrow_def *this)
592 {
593     if (this != NULL) {         /* there really is something to delete */
594         if (prev != NULL)       /* there is a previous arrow */
595             prev->next = this->next;
596         else                    /* this = first_arrow so change first_arrow */
597             first_arrow = this->next;
598         free(this);
599     }
600 }
601
602 /* delete the whole list of arrow styles */
603 static void
604 unset_arrowstyles()
605 {
606     free_arrowstyle(first_arrowstyle);
607     first_arrowstyle = NULL;
608 }
609
610 static void
611 free_arrowstyle(struct arrowstyle_def *arrowstyle)
612 {
613     if (arrowstyle) {
614         free_arrowstyle(arrowstyle->next);
615         free(arrowstyle);
616     }
617 }
618
619 /* process 'unset autoscale' command */
620 static void
621 unset_autoscale()
622 {
623     if (END_OF_COMMAND) {
624         INIT_AXIS_ARRAY(set_autoscale, FALSE);
625     } else if (equals(c_token, "xy") || equals(c_token, "tyx")) {
626         axis_array[FIRST_X_AXIS].set_autoscale
627             = axis_array[FIRST_Y_AXIS].set_autoscale = AUTOSCALE_NONE;
628         c_token++;
629     } else {
630         /* HBB 20000506: parse axis name, and unset the right element
631          * of the array: */
632         int axis = lookup_table(axisname_tbl, c_token);
633         if (axis >= 0) {
634             axis_array[axis].set_autoscale = AUTOSCALE_NONE;
635         c_token++;
636         }
637     }
638 }
639
640
641 /* process 'unset bars' command */
642 static void
643 unset_bars()
644 {
645     bar_size = 0.0;
646 }
647
648
649 /* process 'unset border' command */
650 static void
651 unset_border()
652 {
653     /* this is not the effect as with reset, as the border is enabled,
654      * by default */
655     draw_border = 0;
656 }
657
658
659 /* process 'unset boxwidth' command */
660 static void
661 unset_boxwidth()
662 {
663     boxwidth = -1.0;
664     boxwidth_is_absolute = TRUE;
665 }
666
667
668 /* process 'unset fill' command */
669 static void
670 unset_fillstyle()
671 {
672     default_fillstyle.fillstyle = FS_EMPTY;
673     default_fillstyle.filldensity = 100;
674     default_fillstyle.fillpattern = 0;
675     default_fillstyle.border_linetype = LT_UNDEFINED;
676 }
677
678
679 /* process 'unset clabel' command */
680 static void
681 unset_clabel()
682 {
683     /* FIXME? reset_command() uses TRUE */
684     label_contours = FALSE;
685 }
686
687
688 /* process 'unset clip' command */
689 static void
690 unset_clip()
691 {
692     if (END_OF_COMMAND) {
693         /* same as all three */
694         clip_points = FALSE;
695         clip_lines1 = FALSE;
696         clip_lines2 = FALSE;
697     } else if (almost_equals(c_token, "p$oints"))
698         clip_points = FALSE;
699     else if (almost_equals(c_token, "o$ne"))
700         clip_lines1 = FALSE;
701     else if (almost_equals(c_token, "t$wo"))
702         clip_lines2 = FALSE;
703     else
704         int_error(c_token, "expecting 'points', 'one', or 'two'");
705     c_token++;
706 }
707
708
709 /* process 'unset cntrparam' command */
710 static void
711 unset_cntrparam()
712 {
713     contour_pts = DEFAULT_NUM_APPROX_PTS;
714     contour_kind = CONTOUR_KIND_LINEAR;
715     contour_order = DEFAULT_CONTOUR_ORDER;
716     contour_levels = DEFAULT_CONTOUR_LEVELS;
717     contour_levels_kind = LEVELS_AUTO;
718 }
719
720
721 /* process 'unset contour' command */
722 static void
723 unset_contour()
724 {
725     draw_contour = CONTOUR_NONE;
726 }
727
728
729 /* process 'unset dgrid3d' command */
730 static void
731 unset_dgrid3d()
732 {
733     dgrid3d_row_fineness = 10;
734     dgrid3d_col_fineness = 10;
735     dgrid3d_norm_value = 1;
736     dgrid3d = FALSE;
737 }
738
739
740 /* process 'unset dummy' command */
741 static void
742 unset_dummy()
743 {
744     strcpy(set_dummy_var[0], "x");
745     strcpy(set_dummy_var[1], "y");
746 }
747
748
749 /* process 'unset encoding' command */
750 static void
751 unset_encoding()
752 {
753     encoding = S_ENC_DEFAULT;
754 }
755
756
757 /* process 'unset decimalsign' command */
758 static void
759 unset_decimalsign()
760 {
761     if (decimalsign != NULL)
762         free(decimalsign);
763     decimalsign = NULL;
764 #ifdef HAVE_LOCALE_H
765     setlocale(LC_NUMERIC,"C");
766 #endif
767 }
768
769
770 /* process 'unset fit' command */
771 static void
772 unset_fit()
773 {
774     if (fitlogfile != NULL)
775         free(fitlogfile);
776     fitlogfile = NULL;
777 #if GP_FIT_ERRVARS
778     fit_errorvariables = FALSE;
779 #endif /* GP_FIT_ERRVARS */
780 }
781
782
783 /* process 'unset format' command */
784 /* FIXME: compare and merge with set.c::set_format */
785 static void
786 unset_format()
787 {
788     TBOOLEAN set_for_axis[AXIS_ARRAY_SIZE] = AXIS_ARRAY_INITIALIZER(FALSE);
789     int axis;
790
791     if ((axis = lookup_table(axisname_tbl, c_token)) >= 0) {
792         set_for_axis[axis] = TRUE;
793     } else if (equals(c_token,"xy") || equals(c_token,"yx")) {
794         set_for_axis[FIRST_X_AXIS]
795             = set_for_axis[FIRST_Y_AXIS]
796             = TRUE;
797         c_token++;
798     } else if (isstring(c_token) || END_OF_COMMAND) {
799         /* Assume he wants all */
800         for (axis = 0; axis < AXIS_ARRAY_SIZE; axis++)
801             set_for_axis[axis] = TRUE;
802     }
803
804     if (END_OF_COMMAND) {
805         SET_DEFFORMAT(FIRST_X_AXIS , set_for_axis);
806         SET_DEFFORMAT(FIRST_Y_AXIS , set_for_axis);
807         SET_DEFFORMAT(FIRST_Z_AXIS , set_for_axis);
808         SET_DEFFORMAT(SECOND_X_AXIS, set_for_axis);
809         SET_DEFFORMAT(SECOND_Y_AXIS, set_for_axis);
810         SET_DEFFORMAT(COLOR_AXIS   , set_for_axis);
811     }
812 }
813
814
815 /* process 'unset grid' command */
816 static void
817 unset_grid()
818 {
819     /* FIXME HBB 20000506: there is no command to explicitly reset the
820      * linetypes for major and minor gridlines. This function should
821      * do that, maybe... */
822     AXIS_INDEX i = 0;
823
824     /* grid_selection = GRID_OFF; */
825     for (; i < AXIS_ARRAY_SIZE; i++) {
826         axis_array[i].gridmajor = FALSE;
827         axis_array[i].gridminor = FALSE;
828     }
829 }
830
831
832 /* process 'unset hidden3d' command */
833 static void
834 unset_hidden3d()
835 {
836 #ifdef LITE
837     printf(" Hidden Line Removal Not Supported in LITE version\n");
838 #else
839     hidden3d = FALSE;
840 #endif
841 }
842
843 #ifdef EAM_HISTOGRAMS
844 static void
845 unset_histogram()
846 {
847     histogram_opts.type = HT_CLUSTERED;
848     histogram_opts.gap = 2;
849 }
850 #endif
851
852 /* process 'unset historysize' command */
853 static void
854 unset_historysize()
855 {
856 #ifdef GNUPLOT_HISTORY
857     gnuplot_history_size = -1; /* don't ever truncate the history. */
858 #else
859     int_error(c_token, "Command 'unset historysize' requires history support.");
860 #endif
861 }
862
863
864 /* process 'unset isosamples' command */
865 static void
866 unset_isosamples()
867 {
868     /* HBB 20000506: was freeing 2D data structures although
869      * isosamples are only used by 3D plots. */
870
871     sp_free(first_3dplot);
872     first_3dplot = NULL;
873
874     iso_samples_1 = ISO_SAMPLES;
875     iso_samples_2 = ISO_SAMPLES;
876 }
877
878
879 void
880 reset_key()
881 {
882     legend_key temp_key = DEFAULT_KEY_PROPS;
883     memcpy(&keyT, &temp_key, sizeof(keyT));
884 }
885
886 /* process 'unset key' command */
887 static void
888 unset_key()
889 {
890     legend_key *key = &keyT;
891     key->visible = FALSE;
892 }
893
894
895 /* process 'unset keytitle' command */
896 static void
897 unset_keytitle()
898 {
899     legend_key *key = &keyT;
900     key->title[0] = '\0';       /* empty string */
901 }
902
903
904 /* process 'unset label' command */
905 static void
906 unset_label()
907 {
908     struct value a;
909     struct text_label *this_label;
910     struct text_label *prev_label;
911     int tag;
912
913     if (END_OF_COMMAND) {
914         /* delete all labels */
915         while (first_label != NULL)
916             delete_label((struct text_label *) NULL, first_label);
917     } else {
918         /* get tag */
919         tag = (int) real(const_express(&a));
920         if (!END_OF_COMMAND)
921             int_error(c_token, "extraneous arguments to unset label");
922         for (this_label = first_label, prev_label = NULL;
923              this_label != NULL;
924              prev_label = this_label, this_label = this_label->next) {
925             if (this_label->tag == tag) {
926                 delete_label(prev_label, this_label);
927                 return;         /* exit, our job is done */
928             }
929         }
930         /* int_warn(c_token, "label not found"); */
931     }
932 }
933
934
935 /* delete label from linked list started by first_label.
936  * called with pointers to the previous label (prev) and the
937  * label to delete (this).
938  * If there is no previous label (the label to delete is
939  * first_label) then call with prev = NULL.
940  */
941 static void
942 delete_label(struct text_label *prev, struct text_label *this)
943 {
944     if (this != NULL) {         /* there really is something to delete */
945         if (prev != NULL)       /* there is a previous label */
946             prev->next = this->next;
947         else                    /* this = first_label so change first_label */
948             first_label = this->next;
949         if (this->text) free (this->text);
950         if (this->font) free (this->font);
951         free (this);
952     }
953 }
954
955 #ifdef EAM_OBJECTS
956 /* process 'unset rectangle' command */
957 static void
958 unset_object()
959 {
960     struct value a;
961     struct object *this_object;
962     struct object *prev_object;
963     int tag;
964
965     if (END_OF_COMMAND) {
966         /* delete all objects */
967         while (first_object != NULL)
968             delete_object((struct object *) NULL, first_object);
969     } else {
970         /* get tag */
971         tag = (int) real(const_express(&a));
972         if (!END_OF_COMMAND)
973             int_error(c_token, "extraneous arguments to unset rectangle");
974         for (this_object = first_object, prev_object = NULL;
975              this_object != NULL;
976              prev_object = this_object, this_object = this_object->next) {
977             if (this_object->tag == tag) {
978                 delete_object(prev_object, this_object);
979                 return;         /* exit, our job is done */
980             }
981         }
982         int_error(c_token, "object not found");
983     }
984 }
985
986
987 /* delete object from linked list started by first_object.
988  * called with pointers to the previous object (prev) and the
989  * object to delete (this).
990  * If there is no previous object (the object to delete is
991  * first_object) then call with prev = NULL.
992  */
993 static void
994 delete_object(struct object *prev, struct object *this)
995 {
996     if (this != NULL) {         /* there really is something to delete */
997         if (prev != NULL)       /* there is a previous rectangle */
998             prev->next = this->next;
999         else                    /* this = first_object so change first_object */
1000             first_object = this->next;
1001         /* FIXME:  Must free contents as well */
1002         free (this);
1003     }
1004 }
1005 #endif
1006
1007
1008 /* process 'unset loadpath' command */
1009 static void
1010 unset_loadpath()
1011 {
1012     clear_loadpath();
1013 }
1014
1015
1016 /* process 'unset locale' command */
1017 static void
1018 unset_locale()
1019 {
1020     init_locale();
1021 }
1022
1023 static void
1024 reset_logscale(AXIS_INDEX axis)
1025 {
1026     axis_array[axis].log = FALSE;
1027     axis_array[axis].base = 0.0;
1028 }
1029
1030 /* process 'unset logscale' command */
1031 static void
1032 unset_logscale()
1033 {
1034     int axis;
1035
1036     if (END_OF_COMMAND) {
1037         /* clean all the islog flags. This will hit some currently
1038          * unused ones, too, but that's actually a good thing, IMHO */
1039         for(axis = 0; axis < AXIS_ARRAY_SIZE; axis++)
1040             reset_logscale(axis);
1041     } else {
1042         int i = 0;
1043
1044         /* do reverse search because of "x", "x1", "x2" sequence in
1045          * axisname_tbl */
1046         while (i < token[c_token].length) {
1047             axis = lookup_table_nth_reverse(axisname_tbl, AXIS_ARRAY_SIZE,
1048                                             gp_input_line + token[c_token].start_index + i);
1049             if (axis < 0) {
1050                 token[c_token].start_index += i;
1051                 int_error(c_token, "unknown axis");
1052             }
1053             reset_logscale(axisname_tbl[axis].value);
1054             i += strlen(axisname_tbl[axis].key);
1055         }
1056         ++c_token;
1057     }
1058 }
1059
1060 #ifdef GP_MACROS
1061 /* process 'unset macros' command */
1062 static void
1063 unset_macros()
1064 {
1065     expand_macros = FALSE;
1066 }
1067 #endif
1068
1069 /* process 'unset mapping3d' command */
1070 static void
1071 unset_mapping()
1072 {
1073     /* assuming same as points */
1074     mapping3d = MAP3D_CARTESIAN;
1075 }
1076
1077 /* process 'unset {blrt}margin' command */
1078 static void
1079 unset_margin(t_position *margin)
1080 {
1081     margin->scalex = character;
1082     margin->x = -1;
1083 }
1084
1085 /* process 'unset datafile' command */
1086 static void
1087 unset_missing()
1088 {
1089     free(missing_val);
1090     missing_val = NULL;
1091 }
1092
1093 #ifdef USE_MOUSE
1094 /* process 'unset mouse' command */
1095 static void
1096 unset_mouse()
1097 {
1098     mouse_setting.on = 0;
1099 #ifdef OS2
1100     PM_update_menu_items();
1101 #endif
1102     UpdateStatusline(); /* wipe status line */
1103 }
1104 #endif
1105
1106 /* process 'unset mxtics' command */
1107 static void
1108 unset_minitics(AXIS_INDEX axis)
1109 {
1110     axis_array[axis].minitics = MINI_OFF;
1111     axis_array[axis].mtic_freq = 10.0;
1112 }
1113
1114
1115 /*process 'unset {x|y|x2|y2|z}tics' command */
1116 static void
1117 unset_tics(AXIS_INDEX axis)
1118 {
1119     struct position tics_nooffset = { character, character, character, 0., 0., 0.};
1120     unsigned int istart = 0;
1121     unsigned int iend = AXIS_ARRAY_SIZE;
1122     unsigned int i;
1123
1124     if (axis < AXIS_ARRAY_SIZE) {
1125         istart = axis;
1126         iend = axis + 1;
1127     }
1128         
1129     for (i = istart; i < iend; ++i) {
1130         axis_array[i].ticmode = NO_TICS;
1131
1132         if (axis_array[i].ticdef.font) {
1133             free(axis_array[i].ticdef.font);
1134             axis_array[i].ticdef.font = NULL;
1135         }
1136         axis_array[i].ticdef.textcolor.type = TC_DEFAULT;
1137         axis_array[i].ticdef.textcolor.lt = 0;
1138         axis_array[i].ticdef.textcolor.value = 0;
1139         axis_array[i].ticdef.offset = tics_nooffset;
1140         axis_array[i].ticdef.rangelimited = FALSE;
1141         axis_array[i].tic_rotate = 0;
1142         axis_array[i].ticscale = 1.0;
1143         axis_array[i].miniticscale = 0.5;
1144         axis_array[i].tic_in = TRUE;
1145
1146         free_marklist(axis_array[i].ticdef.def.user);
1147         axis_array[i].ticdef.def.user = NULL;
1148     }
1149 }
1150
1151 static void
1152 unset_month_day_tics(AXIS_INDEX axis)
1153 {
1154     axis_array[axis].ticdef.type = TIC_COMPUTED;
1155 }
1156
1157 /* process 'unset offsets' command */
1158 static void
1159 unset_offsets()
1160 {
1161     loff = roff = toff = boff = 0.0;
1162 }
1163
1164
1165 /* process 'unset origin' command */
1166 static void
1167 unset_origin()
1168 {
1169     xoffset = 0.0;
1170     yoffset = 0.0;
1171 }
1172
1173
1174 /* process 'unset output' command */
1175 static void
1176 unset_output()
1177 {
1178     if (multiplot) {
1179         int_error(c_token, "you can't change the output in multiplot mode");
1180         return;
1181     }
1182
1183     term_set_output(NULL);
1184     if (outstr) {
1185         free(outstr);
1186         outstr = NULL; /* means STDOUT */
1187     }
1188 }
1189
1190
1191 /* process 'unset print' command */
1192 static void
1193 unset_print()
1194 {
1195     print_set_output(NULL, FALSE);
1196 }
1197
1198
1199 /* process 'unset parametric' command */
1200 static void
1201 unset_parametric()
1202 {
1203     if (parametric) {
1204         parametric = FALSE;
1205         if (!polar) { /* keep t for polar */
1206             unset_dummy();
1207             if (interactive)
1208                 (void) fprintf(stderr,"\n\tdummy variable is x for curves, x/y for surfaces\n");
1209         }
1210     }
1211 }
1212
1213 /* process 'unset palette' command */
1214 static void
1215 unset_palette()
1216 {
1217     c_token++;
1218     fprintf(stderr, "you can't unset the palette.\n");
1219 }
1220
1221
1222 /* reset colorbox to default settings */
1223 static void
1224 reset_colorbox()
1225 {
1226     color_box = default_color_box;
1227 }
1228
1229
1230 /* process 'unset colorbox' command: reset to default settings and then
1231  * switch it off */
1232 static void
1233 unset_colorbox()
1234 {
1235     reset_colorbox();
1236     color_box.where = SMCOLOR_BOX_NO;
1237 }
1238
1239
1240 /* process 'unset pm3d' command */
1241 static void
1242 unset_pm3d()
1243 {
1244     pm3d.implicit = PM3D_EXPLICIT;
1245     /* reset styles, required to 'plot something' after e.g. 'set pm3d map' */
1246     if (data_style == PM3DSURFACE) data_style = POINTSTYLE;
1247     if (func_style == PM3DSURFACE) func_style = LINES;
1248 }
1249
1250
1251 /* process 'unset pointsize' command */
1252 static void
1253 unset_pointsize()
1254 {
1255     pointsize = 1.0;
1256 }
1257
1258
1259 /* process 'unset polar' command */
1260 static void
1261 unset_polar()
1262 {
1263     if (polar) {
1264         polar = FALSE;
1265         if (parametric && axis_array[T_AXIS].set_autoscale) {
1266             /* only if user has not set an explicit range */
1267             axis_array[T_AXIS].set_min = axis_defaults[T_AXIS].min;
1268             axis_array[T_AXIS].set_max = axis_defaults[T_AXIS].min;
1269         }
1270         if (!parametric) {
1271             strcpy (set_dummy_var[0], "x");
1272             if (interactive)
1273                 (void) fprintf(stderr,"\n\tdummy variable is x for curves\n");
1274         }
1275     }
1276 }
1277
1278
1279 /* process 'unset samples' command */
1280 static void
1281 unset_samples()
1282 {
1283     /* HBB 20000506: unlike unset_isosamples(), this one *has* to
1284      * clear 2D data structues! */
1285     cp_free(first_plot);
1286     first_plot = NULL;
1287
1288     sp_free(first_3dplot);
1289     first_3dplot = NULL;
1290
1291     samples_1 = SAMPLES;
1292     samples_2 = SAMPLES;
1293 }
1294
1295
1296 /* process 'unset size' command */
1297 static void
1298 unset_size()
1299 {
1300     xsize = 1.0;
1301     ysize = 1.0;
1302     zsize = 1.0;
1303 }
1304
1305
1306 /* process 'unset style' command */
1307 static void
1308 unset_style()
1309 {
1310     if (END_OF_COMMAND) {
1311         data_style = POINTSTYLE;
1312         func_style = LINES;
1313         while (first_linestyle != NULL)
1314             delete_linestyle((struct linestyle_def *) NULL, first_linestyle);
1315         unset_fillstyle();
1316 #ifdef EAM_OBJECTS
1317         unset_style_rectangle();
1318 #endif
1319 #ifdef EAM_HISTOGRAMS
1320         unset_histogram();
1321 #endif
1322         c_token++;
1323         return;
1324     }
1325
1326     switch(lookup_table(show_style_tbl, c_token)){
1327     case SHOW_STYLE_DATA:
1328         data_style = POINTSTYLE;
1329         c_token++;
1330         break;
1331     case SHOW_STYLE_FUNCTION:
1332         func_style = LINES;
1333         c_token++;
1334         break;
1335     case SHOW_STYLE_LINE:
1336         c_token++;
1337         if (END_OF_COMMAND) {
1338             while (first_linestyle != NULL)
1339                 delete_linestyle((struct linestyle_def *) NULL, first_linestyle);
1340         } else {
1341             struct value a;
1342             int tag = (int) real(const_express(&a));
1343             struct linestyle_def *this, *prev;
1344             for (this = first_linestyle, prev = NULL; this != NULL; 
1345                  prev = this, this = this->next) {
1346                 if (this->tag == tag) {
1347                     delete_linestyle(prev, this);
1348                     break;
1349                 }
1350             }
1351         }
1352         break;
1353     case SHOW_STYLE_FILLING:
1354         unset_fillstyle();
1355         c_token++;
1356         break;
1357 #ifdef EAM_HISTOGRAMS
1358     case SHOW_STYLE_HISTOGRAM:
1359         unset_histogram();
1360         c_token++;
1361         break;
1362 #endif
1363     case SHOW_STYLE_ARROW:
1364         unset_arrowstyles();
1365         c_token++;
1366         break;
1367 #ifdef EAM_OBJECTS
1368     case SHOW_STYLE_RECTANGLE:
1369         unset_style_rectangle();
1370         c_token++;
1371         break;
1372 #endif
1373     default:
1374         int_error(c_token, "expecting 'data', 'function', 'line', 'fill' or 'arrow'");
1375     }
1376 }
1377
1378
1379 /* process 'unset surface' command */
1380 static void
1381 unset_surface()
1382 {
1383     draw_surface = FALSE;
1384 }
1385
1386
1387 /* process 'unset table' command */
1388 static void
1389 unset_table()
1390 {
1391     if (table_outfile)
1392         fclose(table_outfile);
1393     table_outfile = NULL;
1394     table_mode = FALSE;
1395 }
1396
1397
1398 /* process 'unset terminal' comamnd */
1399 static void
1400 unset_terminal()
1401 {
1402     /* This is a problematic case */
1403 /* FIXME */
1404     if (multiplot)
1405         int_error(c_token, "You can't change the terminal in multiplot mode");
1406
1407     list_terms();
1408     screen_ok = FALSE;
1409 }
1410
1411
1412 #ifdef OLDUNSETTICS
1413 /* process 'unset tics' command */
1414 static void
1415 unset_tics_in()
1416 {
1417     unsigned int i = AXIS_ARRAY_SIZE;
1418     c_token++;
1419
1420     if (equals(c_token,"x"))
1421         i = FIRST_X_AXIS;
1422     else if (equals(c_token,"y"))
1423         i = FIRST_Y_AXIS;
1424     else if (equals(c_token,"z"))
1425         i = FIRST_Z_AXIS;
1426     else if (equals(c_token,"x2"))
1427         i = SECOND_X_AXIS;
1428     else if (equals(c_token,"y2"))
1429         i = SECOND_Y_AXIS;
1430     else if (equals(c_token,"cb"))
1431         i = COLOR_AXIS;
1432     if (i < AXIS_ARRAY_SIZE)
1433         c_token++;
1434
1435     if (i < AXIS_ARRAY_SIZE)
1436         axis_array[i].tic_in = TRUE;
1437     else {
1438         for (i = 0; i < AXIS_ARRAY_SIZE; ++i)
1439             axis_array[i].tic_in = TRUE;
1440     }
1441 }
1442 #endif /* OLDUNSETTICS */
1443
1444
1445 /* process 'unset ticscale' command */
1446 static void
1447 unset_ticscale()
1448 {
1449     unsigned int i;
1450
1451     int_warn(c_token,
1452              "Deprecated syntax - please use 'set tics scale default'");
1453
1454     for (i = 0; i < AXIS_ARRAY_SIZE; ++i) {
1455         axis_array[i].ticscale = 1.0;
1456         axis_array[i].miniticscale = 0.5;
1457     }
1458 }
1459
1460
1461 /* process 'unset ticslevel' command */
1462 static void
1463 unset_ticslevel()
1464 {
1465     xyplane.ticslevel = 0.5;
1466     xyplane.absolute = FALSE;
1467 }
1468
1469
1470 /* Process 'unset timefmt' command */
1471 static void
1472 unset_timefmt()
1473 {
1474     int axis;
1475
1476     if (END_OF_COMMAND)
1477         for (axis=0; axis < AXIS_ARRAY_SIZE; axis++)
1478             strcpy(axis_array[axis].timefmt,TIMEFMT);
1479     else if ((axis=lookup_table(axisname_tbl, c_token)) >= 0) {
1480         strcpy(axis_array[axis].timefmt, TIMEFMT);
1481         c_token++;
1482     }
1483     else
1484         /* int_error() from inside 'reset' would cause problems */
1485         int_warn(c_token, "expected optional axis name");
1486
1487 }
1488
1489
1490 /* process 'unset timestamp' command */
1491 static void
1492 unset_timestamp()
1493 {
1494     unset_axislabel_or_title(&timelabel);
1495     timelabel_rotate = 0;
1496     timelabel_bottom = TRUE;
1497 }
1498
1499
1500 /* process 'unset view' command */
1501 static void
1502 unset_view()
1503 {
1504     splot_map_deactivate();
1505     splot_map = FALSE;
1506     aspect_ratio_3D = 0;
1507     surface_rot_z = 30.0;
1508     surface_rot_x = 60.0;
1509     surface_scale = 1.0;
1510     surface_zscale = 1.0;
1511 }
1512
1513
1514 /* process 'unset zero' command */
1515 static void
1516 unset_zero()
1517 {
1518     zero = ZERO;
1519 }
1520
1521 /* process 'unset {x|y|z|x2|y2}data' command */
1522 static void
1523 unset_timedata(AXIS_INDEX axis)
1524 {
1525     axis_array[axis].is_timedata = FALSE;
1526 }
1527
1528
1529 /* process 'unset {x|y|z|x2|y2|t|u|v|r}range' command */
1530 static void
1531 unset_range(AXIS_INDEX axis)
1532 {
1533     /* FIXME HBB 20000506: do we want to reset the axis autoscale and
1534      * min/max, too?  */
1535     axis_array[axis].range_flags = 0;
1536 }
1537
1538 /* process 'unset {x|y|x2|y2|z}zeroaxis' command */
1539 static void
1540 unset_zeroaxis(AXIS_INDEX axis)
1541 {
1542     axis_array[axis].zeroaxis = default_axis_zeroaxis;
1543 }
1544
1545
1546 /* process 'unset zeroaxis' command */
1547 static void
1548 unset_all_zeroaxes()
1549 {
1550     AXIS_INDEX axis;
1551
1552     for(axis = 0; axis < AXIS_ARRAY_SIZE; axis++)
1553         unset_zeroaxis(axis);
1554 }
1555
1556
1557 /* process 'unset [xyz]{2}label command */
1558 static void
1559 unset_axislabel_or_title(text_label *label)
1560 {
1561     struct position default_offset = { character, character, character, 
1562                                        0., 0., 0. };
1563     if (label) {
1564         free(label->text);
1565         label->text = NULL;
1566         free(label->font);
1567         label->font = NULL;
1568         label->offset = default_offset;
1569         label->textcolor.type = TC_DEFAULT;
1570     }
1571 }
1572
1573 static void
1574 unset_axislabel(AXIS_INDEX axis)
1575 {
1576     unset_axislabel_or_title(&axis_array[axis].label);
1577     axis_array[axis].label = default_axis_label;
1578     if (axis == FIRST_Y_AXIS || axis == SECOND_Y_AXIS || axis == COLOR_AXIS)
1579         axis_array[axis].label.rotate = TEXT_VERTICAL;
1580 }
1581
1582 /******** The 'reset' command ********/
1583 /* HBB 20000506: I moved this here, from set.c, because 'reset' really
1584  * is more like a big lot of 'unset' commands, rather than a bunch of
1585  * 'set's. The benefit is that it can make use of many of the
1586  * unset_something() contained in this module, i.e. you now have one
1587  * place less to keep in sync if the semantics or defaults of any
1588  * option is changed. This is only true for options for which 'unset'
1589  * state is the default, however, e.g. not for 'surface', 'bars' and
1590  * some others. */
1591 void
1592 reset_command()
1593 {
1594     AXIS_INDEX axis;
1595     TBOOLEAN save_interactive = interactive;
1596     static const TBOOLEAN set_for_axis[AXIS_ARRAY_SIZE]
1597         = AXIS_ARRAY_INITIALIZER(TRUE);
1598
1599     c_token++;
1600
1601     /* Kludge alert, HBB 20000506: set to noninteractive mode, to
1602      * suppress some of the commentary output by the individual
1603      * unset_...() routines. */
1604     interactive = FALSE;
1605
1606     unset_samples();
1607     unset_isosamples();
1608
1609     /* delete arrows */
1610     while (first_arrow != NULL)
1611         delete_arrow((struct arrow_def *) NULL, first_arrow);
1612     unset_arrowstyles();
1613     /* delete labels */
1614     while (first_label != NULL)
1615         delete_label((struct text_label *) NULL, first_label);
1616     /* delete linestyles */
1617     while (first_linestyle != NULL)
1618         delete_linestyle((struct linestyle_def *) NULL, first_linestyle);
1619 #ifdef EAM_OBJECTS
1620     /* delete objects */
1621     while (first_object != NULL)
1622         delete_object((struct object *) NULL, first_object);
1623     unset_style_rectangle();
1624 #endif
1625
1626     /* 'polar', 'parametric' and 'dummy' are interdependent, so be
1627      * sure to keep the order intact */
1628     unset_polar();
1629     unset_parametric();
1630     unset_dummy();
1631
1632     unset_axislabel_or_title(&title);
1633
1634     reset_key();
1635     unset_keytitle();
1636
1637     unset_timefmt();
1638     unset_view(); /* has to be called in advance to reset reversed yrange if splot_map_active */
1639
1640     for (axis=0; axis<AXIS_ARRAY_SIZE; axis++) {
1641         SET_DEFFORMAT(axis, set_for_axis);
1642         unset_timedata(axis);
1643         unset_zeroaxis(axis);
1644         unset_range(axis);
1645         unset_axislabel(axis);
1646
1647         axis_array[axis].set_autoscale = AUTOSCALE_BOTH;
1648         axis_array[axis].writeback_min = axis_array[axis].set_min
1649             = axis_defaults[axis].min;
1650         axis_array[axis].writeback_max = axis_array[axis].set_max
1651             = axis_defaults[axis].max;
1652
1653         /* 'tics' default is on for some, off for the other axes: */
1654         unset_tics(axis);
1655         axis_array[axis].ticmode = axis_defaults[axis].ticmode;
1656         unset_minitics(axis);
1657         axis_array[axis].ticdef = default_axis_ticdef;
1658         axis_array[axis].minitics = MINI_DEFAULT;
1659
1660         reset_logscale(axis);
1661     }
1662
1663     unset_boxwidth();
1664
1665     clip_points = FALSE;
1666     clip_lines1 = TRUE;
1667     clip_lines2 = FALSE;
1668
1669     border_lp = default_border_lp;
1670     draw_border = 31;
1671
1672     draw_surface = 1.0;
1673
1674     data_style = POINTSTYLE;
1675     func_style = LINES;
1676
1677     bar_size = 1.0;
1678
1679     unset_grid();
1680     grid_lp = default_grid_lp;
1681     mgrid_lp = default_grid_lp;
1682     polar_grid_angle = 0;
1683     grid_layer = -1;
1684
1685     reset_hidden3doptions();
1686     hidden3d = FALSE;
1687
1688     label_contours = TRUE;
1689     strcpy(contour_format, "%8.3g");
1690
1691     unset_angles();
1692     unset_mapping();
1693
1694     unset_size();
1695     aspect_ratio = 0.0;         /* don't force it */
1696
1697     unset_origin();
1698     unset_timestamp();
1699     unset_offsets();
1700     unset_contour();
1701     unset_cntrparam();
1702     unset_zero();
1703     unset_dgrid3d();
1704     unset_ticslevel();
1705 #ifdef OLDUNSETTICS
1706     unset_tics_in();
1707 #endif /* OLDUNSETTICS */
1708     unset_margin(&bmargin);
1709     unset_margin(&lmargin);
1710     unset_margin(&rmargin);
1711     unset_margin(&tmargin);
1712     unset_pointsize();
1713     unset_encoding();
1714     unset_decimalsign();
1715     pm3d_reset();
1716     reset_colorbox();
1717     reset_palette();
1718 #ifdef BINARY_DATA_FILE
1719     df_unset_datafile_binary();
1720 #endif
1721     unset_fillstyle();
1722 #ifdef EAM_HISTOGRAMS
1723     unset_histogram();
1724 #endif
1725
1726     unset_missing();
1727     df_separator = '\0';
1728     free(df_commentschars);
1729     df_commentschars = gp_strdup(DEFAULT_COMMENTS_CHARS);
1730
1731     unset_locale();
1732 #if 0
1733     /* 2003-18-04: Don't reset non-graphics settings, like set term, out,
1734      * loadpath and fontpath. */
1735     unset_loadpath();
1736 #endif
1737     unset_fit();
1738
1739 #if 0
1740     /* 01-Jun-2006: Deleting undefined user variables can break user functions.
1741      * E.g.    f(x) = a + b;  reset;
1742      * f(x) is still defined, sort of, but it holds pointers to a and b, which
1743      * have been deleted. Evaluation after a reset can trigger a segfault.
1744      */
1745     /* Garbage collection on space allocated for user variables */
1746     cleanup_udvlist();
1747 #endif
1748
1749     update_gpval_variables(0); /* update GPVAL_ inner variables */
1750
1751     /* HBB 20000506: set 'interactive' back to its real value: */
1752     interactive = save_interactive;
1753 }
1754
1755 #ifdef EAM_OBJECTS
1756 static void
1757 unset_style_rectangle()
1758 {
1759     struct object foo = DEFAULT_RECTANGLE_STYLE;
1760     default_rectangle = foo;
1761     return;
1762 }
1763 #endif