annotate liboctave/util/oct-rl-hist.c @ 21202:f7121e111991

maint: indent #ifdef blocks in liboctave and src directories. * Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc, Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc, Array-voidp.cc, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc, CSparse.h, DiagArray2.cc, MArray-C.cc, MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc, MArray-s.cc, MArray.cc, MDiagArray2.cc, MSparse-C.cc, MSparse-d.cc, MSparse.h, MatrixType.cc, PermMatrix.cc, Range.cc, Sparse-C.cc, Sparse-b.cc, Sparse-d.cc, Sparse.cc, boolMatrix.cc, boolNDArray.cc, boolSparse.cc, chMatrix.cc, chNDArray.cc, dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc, dSparse.h, dim-vector.cc, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, int16NDArray.cc, int32NDArray.cc, int64NDArray.cc, int8NDArray.cc, intNDArray.cc, uint16NDArray.cc, uint32NDArray.cc, uint64NDArray.cc, uint8NDArray.cc, blaswrap.c, cquit.c, f77-extern.cc, f77-fcn.c, f77-fcn.h, lo-error.c, quit.cc, quit.h, CmplxAEPBAL.cc, CmplxCHOL.cc, CmplxGEPBAL.cc, CmplxHESS.cc, CmplxLU.cc, CmplxQR.cc, CmplxQRP.cc, CmplxSCHUR.cc, CmplxSVD.cc, CollocWt.cc, DASPK.cc, DASRT.cc, DASSL.cc, EIG.cc, LSODE.cc, ODES.cc, Quad.cc, base-lu.cc, base-qr.cc, dbleAEPBAL.cc, dbleCHOL.cc, dbleGEPBAL.cc, dbleHESS.cc, dbleLU.cc, dbleQR.cc, dbleQRP.cc, dbleSCHUR.cc, dbleSVD.cc, eigs-base.cc, fCmplxAEPBAL.cc, fCmplxCHOL.cc, fCmplxGEPBAL.cc, fCmplxHESS.cc, fCmplxLU.cc, fCmplxQR.cc, fCmplxQRP.cc, fCmplxSCHUR.cc, fCmplxSVD.cc, fEIG.cc, floatAEPBAL.cc, floatCHOL.cc, floatGEPBAL.cc, floatHESS.cc, floatLU.cc, floatQR.cc, floatQRP.cc, floatSCHUR.cc, floatSVD.cc, lo-mappers.cc, lo-specfun.cc, oct-convn.cc, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-rand.cc, oct-spparms.cc, randgamma.c, randmtzig.c, randpoisson.c, sparse-chol.cc, sparse-dmsolve.cc, sparse-lu.cc, sparse-qr.cc, mx-defs.h, dir-ops.cc, file-ops.cc, file-stat.cc, lo-sysdep.cc, mach-info.cc, oct-env.cc, oct-group.cc, oct-openmp.h, oct-passwd.cc, oct-syscalls.cc, oct-time.cc, oct-uname.cc, pathlen.h, sysdir.h, syswait.h, cmd-edit.cc, cmd-hist.cc, data-conv.cc, f2c-main.c, glob-match.cc, lo-array-errwarn.cc, lo-array-gripes.cc, lo-cutils.c, lo-cutils.h, lo-ieee.cc, lo-math.h, lo-regexp.cc, lo-utils.cc, oct-base64.cc, oct-glob.cc, oct-inttypes.cc, oct-inttypes.h, oct-locbuf.cc, oct-mutex.cc, oct-refcount.h, oct-rl-edit.c, oct-rl-hist.c, oct-shlib.cc, oct-sort.cc, pathsearch.cc, singleton-cleanup.cc, sparse-sort.cc, sparse-util.cc, statdefs.h, str-vec.cc, unwind-prot.cc, url-transfer.cc, display-available.h, main-cli.cc, main-gui.cc, main.in.cc, mkoctfile.in.cc, octave-config.in.cc, shared-fcns.h: indent #ifdef blocks in liboctave and src directories.
author Rik <rik@octave.org>
date Sat, 06 Feb 2016 06:40:13 -0800
parents cfb58d9805fa
children 40de9f8f23a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
1 /*
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
3 Copyright (C) 2000-2015 John W. Eaton
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
4
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
6
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
10 option) any later version.
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
11
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
15 for more details.
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
16
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
19 <http://www.gnu.org/licenses/>.
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
20
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
21 */
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
22
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
21202
f7121e111991 maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents: 20919
diff changeset
24 # include <config.h>
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
25 #endif
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
26
11486
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
27 #include "oct-rl-hist.h"
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
28
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
29 #if defined (USE_READLINE)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
30
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
31 #include <stdio.h>
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
32 #include <stdlib.h>
4587
7b957b442818 [project @ 2003-11-10 15:50:39 by jwe]
jwe
parents: 3598
diff changeset
33 #include <string.h>
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
34
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
35 #include <readline/history.h>
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
36
11486
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
37 /* check_history_control, hc_erasedup, and the core of
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
38 octave_add_history were borrowed from Bash. */
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
39
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
40 /* Check LINE against what HISTCONTROL says to do. Returns 1 if the line
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
41 should be saved; 0 if it should be discarded. */
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
42 static int
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
43 check_history_control (const char *line, int history_control)
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
44 {
11486
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
45 HIST_ENTRY *temp;
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
46 int r;
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
47
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
48 if (history_control == 0)
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
49 return 1;
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
50
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
51 /* ignorespace or ignoreboth */
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
52 if ((history_control & HC_IGNSPACE) && *line == ' ')
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
53 return 0;
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
54
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
55 /* ignoredups or ignoreboth */
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
56 if (history_control & HC_IGNDUPS)
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
57 {
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
58 using_history ();
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
59 temp = previous_history ();
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
60
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
61 r = (temp == 0 || strcmp (temp->line, line));
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
62
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
63 using_history ();
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
64
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
65 if (r == 0)
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
66 return r;
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
67 }
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
68
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
69 return 1;
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
70 }
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
71
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
72 /* Remove all entries matching LINE from the history list. Triggered when
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
73 HISTCONTROL includes `erasedups'. */
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
74
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
75 static void
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
76 hc_erasedups (const char *line)
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
77 {
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
78 HIST_ENTRY *temp;
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
79 int r;
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
80
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
81 using_history ();
11490
0a4dfc867e60 avoid GCC warning for oct-rl-hist.c
John W. Eaton <jwe@octave.org>
parents: 11486
diff changeset
82 while ((temp = previous_history ()))
11486
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
83 {
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
84 if (! strcmp (temp->line, line))
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
85 {
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
86 r = where_history ();
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
87 remove_history (r);
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
88 }
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
89 }
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
90 using_history ();
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
91 }
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
92
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
93 /* Check LINE against HISTCONTROL and add it to the history if it's OK.
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
94 Returns 1 if the line was saved in the history, 0 otherwise. */
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
95
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
96 int
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
97 octave_add_history (const char *line, int history_control)
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
98 {
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
99 if (check_history_control (line, history_control))
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
100 {
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
101 /* We're committed to saving the line. If the user has requested it,
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
102 remove other matching lines from the history. */
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
103
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
104 if (history_control & HC_ERASEDUPS)
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
105 hc_erasedups (line);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
106
11486
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
107 add_history (line);
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
108
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
109 return 1;
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
110 }
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
111
a1deab9a6e71 bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents: 10317
diff changeset
112 return 0;
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
113 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
114
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
115 int
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
116 octave_where_history (void)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
117 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
118 return where_history ();
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
119 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
120
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
121 int
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
122 octave_history_length (void)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
123 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
124 return history_length;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
125 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
126
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
127 int
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
128 octave_max_input_history (void)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
129 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
130 return max_input_history;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
131 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
132
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
133 int
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
134 octave_history_base (void)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
135 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
136 return history_base;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
137 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
138
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
139 void
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
140 octave_stifle_history (int n)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
141 {
3520
b153b9fa7f1a [project @ 2000-02-02 06:04:27 by jwe]
jwe
parents: 3519
diff changeset
142 stifle_history (n);
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
143 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
144
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
145 int
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
146 octave_unstifle_history (void)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
147 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
148 return unstifle_history ();
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
149 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
150
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
151 int
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
152 octave_history_is_stifled (void)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
153 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
154 return history_is_stifled ();
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
155 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
156
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
157 int
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
158 octave_history_set_pos (int n)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
159 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
160 return history_set_pos (n);
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
161 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
162
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
163 int
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
164 octave_read_history (const char *f)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
165 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
166 return read_history (f);
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
167 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
168
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
169 void
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
170 octave_using_history (void)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
171 {
3520
b153b9fa7f1a [project @ 2000-02-02 06:04:27 by jwe]
jwe
parents: 3519
diff changeset
172 using_history ();
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
173 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
174
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
175 int
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
176 octave_read_history_range (const char *f, int b, int e)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
177 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
178 return read_history_range (f, b, e);
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
179 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
180
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
181 int
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
182 octave_write_history (const char *f)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
183 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
184 return write_history (f);
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
185 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
186
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
187 int
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
188 octave_append_history (int n, const char *f)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
189 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
190 return append_history (n, f);
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
191 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
192
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
193 int
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
194 octave_history_truncate_file (const char *f, int n)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
195 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
196 return history_truncate_file (f, n);
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
197 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
198
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
199 void
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
200 octave_remove_history (int n)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
201 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
202 HIST_ENTRY *discard = remove_history (n);
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
203
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
204 if (discard)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
205 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
206 if (discard->line)
10317
42d098307c30 untabify additional source files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
207 free (discard->line);
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
208
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
209 free (discard);
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
210 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
211 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
212
15397
231d8d3b8225 provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
213 void
231d8d3b8225 provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
214 octave_clear_history (void)
231d8d3b8225 provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
215 {
231d8d3b8225 provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
216 clear_history ();
231d8d3b8225 provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
217 }
231d8d3b8225 provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
218
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
219 char *
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
220 octave_history_goto_mark (int n)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
221 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
222 HIST_ENTRY *h;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
223
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
224 char *retval = 0;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
225
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
226 if (history_set_pos (n))
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
227 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
228 h = current_history ();
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
229
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
230 if (h)
10317
42d098307c30 untabify additional source files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
231 retval = h->line;
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
232 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
233
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
234 return retval;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
235 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
236
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
237 char *
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
238 octave_history_get (int n)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
239 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
240 char *retval = 0;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
241
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
242 HIST_ENTRY *h = history_get (n);
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
243
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
244 if (h)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
245 retval = h->line;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
246
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
247 return retval;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
248 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
249
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
250 char **
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
251 octave_history_list (int limit, int number_lines)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
252 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
253 static char **retval = 0;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
254
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
255 HIST_ENTRY **hlist = 0;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
256
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
257 if (retval)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
258 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
259 char **p = retval;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
260
3598
0ae310231c46 [project @ 2000-02-19 08:07:08 by jwe]
jwe
parents: 3541
diff changeset
261 while (*p)
10317
42d098307c30 untabify additional source files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
262 free (*p++);
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
263
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
264 free (retval);
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
265
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
266 retval = 0;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
267 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
268
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
269 hlist = history_list ();
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
270
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
271 if (hlist)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
272 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
273 int i, k;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
274
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
275 int beg = 0;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
276 int end = 0;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
277 while (hlist[end])
10317
42d098307c30 untabify additional source files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
278 end++;
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
279
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
280 beg = (limit < 0 || end < limit) ? 0 : (end - limit);
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
281
20919
cfb58d9805fa eliminate some type conversion warnings
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
282 retval = malloc ((size_t) (end - beg + 1) * sizeof (char **));
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
283
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
284 k = 0;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
285 for (i = beg; i < end; i++)
10317
42d098307c30 untabify additional source files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
286 {
42d098307c30 untabify additional source files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
287 char *line = hlist[i]->line;
20919
cfb58d9805fa eliminate some type conversion warnings
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
288 size_t len = line ? strlen (line) : 0;
10317
42d098307c30 untabify additional source files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
289 char *tmp = malloc (len + 64);
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
290
10317
42d098307c30 untabify additional source files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
291 if (number_lines)
17225
06824c3b1ff3 Remove spurious leading space in unnumbered history list (bug #39724)
Mike Miller <mtmiller@ieee.org>
parents: 15397
diff changeset
292 sprintf (tmp, "%5d %s", i + history_base,
10317
42d098307c30 untabify additional source files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
293 line ? line : "");
42d098307c30 untabify additional source files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
294 else
17225
06824c3b1ff3 Remove spurious leading space in unnumbered history list (bug #39724)
Mike Miller <mtmiller@ieee.org>
parents: 15397
diff changeset
295 strcpy (tmp, line ? line : "");
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
296
10317
42d098307c30 untabify additional source files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
297 retval[k++] = tmp;
42d098307c30 untabify additional source files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
298 }
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
299
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
300 retval[k] = 0;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
301 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
302
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
303 return retval;
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
304 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
305
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
306 void
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
307 octave_replace_history_entry (int which, const char *line)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
308 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
309 HIST_ENTRY *discard = replace_history_entry (which, line, 0);
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
310
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
311 if (discard)
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
312 {
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
313 if (discard->line)
10317
42d098307c30 untabify additional source files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
314 free (discard->line);
3519
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
315
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
316 free (discard);
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
317 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
318 }
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
319
957d7d6ab0e0 [project @ 2000-02-02 06:00:09 by jwe]
jwe
parents:
diff changeset
320 #endif