Deleted Added
sdiff udiff text old ( 161475 ) new ( 170256 )
full compact
1/*
2 * Copyright (C) 1984-2005 Mark Nudelman
3 *
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Less License, as specified in the README file.
6 *
7 * For more information about less, or for information on how to
8 * contact the author, see the README file.
9 */
10

--- 52 unchanged lines hidden (view full) ---

63 * A mlist structure represents a command history.
64 */
65struct mlist
66{
67 struct mlist *next;
68 struct mlist *prev;
69 struct mlist *curr_mp;
70 char *string;
71};
72
73/*
74 * These are the various command histories that exist.
75 */
76struct mlist mlist_search =
77 { &mlist_search, &mlist_search, &mlist_search, NULL };
78public void * constant ml_search = (void *) &mlist_search;
79
80struct mlist mlist_examine =
81 { &mlist_examine, &mlist_examine, &mlist_examine, NULL };
82public void * constant ml_examine = (void *) &mlist_examine;
83
84#if SHELL_ESCAPE || PIPEC
85struct mlist mlist_shell =
86 { &mlist_shell, &mlist_shell, &mlist_shell, NULL };
87public void * constant ml_shell = (void *) &mlist_shell;
88#endif
89
90#else /* CMD_HISTORY */
91
92/* If CMD_HISTORY is off, these are just flags. */
93public void * constant ml_search = (void *)1;
94public void * constant ml_examine = (void *)2;

--- 24 unchanged lines hidden (view full) ---

119 *cp = '\0';
120 cmd_col = 0;
121 cmd_offset = 0;
122 literal = 0;
123 cmd_mbc_buf_len = 0;
124}
125
126/*
127 * Clear command line on display.
128 */
129 public void
130clear_cmd()
131{
132 clear_bot();
133 cmd_col = prompt_col = 0;
134 cmd_mbc_buf_len = 0;
135}
136
137/*
138 * Display a string, usually as a prompt for input into the command buffer.
139 */
140 public void

--- 621 unchanged lines hidden (view full) ---

762{
763#if CMD_HISTORY
764 /*
765 * Nothing to do if there is no currently selected history list.
766 */
767 if (curr_mlist == NULL)
768 return;
769 cmd_addhist(curr_mlist, cmdbuf);
770#endif
771}
772
773/*
774 * Try to perform a line-edit function on the command buffer,
775 * using a specified char as a line-editing command.
776 * Returns:
777 * CC_PASS The char does not invoke a line edit function.

--- 492 unchanged lines hidden (view full) ---

1270 */
1271 return (cmd_ichar(cmd_mbc_buf, len));
1272}
1273
1274/*
1275 * Return the number currently in the command buffer.
1276 */
1277 public LINENUM
1278cmd_int()
1279{
1280 register char *p;
1281 LINENUM n = 0;
1282
1283 for (p = cmdbuf; *p != '\0'; p++)
1284 n = (10 * n) + (*p - '0');
1285 return (n);
1286}
1287
1288/*
1289 * Return a pointer to the command buffer.
1290 */
1291 public char *
1292get_cmdbuf()
1293{
1294 return (cmdbuf);
1295}
1296
1297#if CMD_HISTORY
1298/*
1299 * Get the name of the history file.
1300 */
1301 static char *
1302histfile_name()
1303{
1304 char *home;
1305 char *name;
1306 int len;
1307
1308 /* See if filename is explicitly specified by $LESSHISTFILE. */
1309 name = lgetenv("LESSHISTFILE");
1310 if (name != NULL && *name != '\0')
1311 {
1312 if (strcmp(name, "-") == 0)
1313 /* $LESSHISTFILE == "-" means don't use a history file. */
1314 return (NULL);
1315 return (save(name));
1316 }
1317
1318 /* Otherwise, file is in $HOME. */
1319 home = lgetenv("HOME");
1320 if (home == NULL || *home == '\0')

--- 102 unchanged lines hidden (view full) ---

1423{
1424#if CMD_HISTORY
1425 char *filename;
1426 FILE *f;
1427
1428 filename = histfile_name();
1429 if (filename == NULL)
1430 return;
1431 f = fopen(filename, "w");
1432 free(filename);
1433 if (f == NULL)
1434 return;
1435#if HAVE_FCHMOD
1436 /* Make history file readable only by owner. */
1437 fchmod(fileno(f), 0600);
1438#endif

--- 14 unchanged lines hidden ---