summaryrefslogtreecommitdiffstats
path: root/contrib/less/cmdbuf.c
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2009-05-09 01:35:27 +0000
committerdelphij <delphij@FreeBSD.org>2009-05-09 01:35:27 +0000
commit810e5a84b4607c4d0fc76e9a418ae9fd2b0eeeb2 (patch)
tree5e0628caeff31611fab89dbdf72053148a59a873 /contrib/less/cmdbuf.c
parent8583a840068803e7fd9e0fc2452605bca6e822d8 (diff)
downloadFreeBSD-src-810e5a84b4607c4d0fc76e9a418ae9fd2b0eeeb2.zip
FreeBSD-src-810e5a84b4607c4d0fc76e9a418ae9fd2b0eeeb2.tar.gz
Update to less v429.
Diffstat (limited to 'contrib/less/cmdbuf.c')
-rw-r--r--contrib/less/cmdbuf.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/contrib/less/cmdbuf.c b/contrib/less/cmdbuf.c
index ad79ce9..1609ef7 100644
--- a/contrib/less/cmdbuf.c
+++ b/contrib/less/cmdbuf.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2007 Mark Nudelman
+ * Copyright (C) 1984-2008 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@@ -662,12 +662,14 @@ set_mlist(mlist, cmdflags)
void *mlist;
int cmdflags;
{
+#if CMD_HISTORY
curr_mlist = (struct mlist *) mlist;
curr_cmdflags = cmdflags;
/* Make sure the next up-arrow moves to the last string in the mlist. */
if (curr_mlist != NULL)
curr_mlist->curr_mp = curr_mlist;
+#endif
}
#if CMD_HISTORY
@@ -1303,6 +1305,7 @@ get_cmdbuf()
return (cmdbuf);
}
+#if CMD_HISTORY
/*
* Return the last (most recent) string in the current command history.
*/
@@ -1313,6 +1316,7 @@ cmd_lastpattern()
return (NULL);
return (curr_mlist->curr_mp->prev->string);
}
+#endif
#if CMD_HISTORY
/*
@@ -1465,8 +1469,19 @@ save_cmdhist()
if (f == NULL)
return;
#if HAVE_FCHMOD
+{
/* Make history file readable only by owner. */
- fchmod(fileno(f), 0600);
+ int do_chmod = 1;
+#if HAVE_STAT
+ struct stat statbuf;
+ int r = fstat(fileno(f), &statbuf);
+ if (r < 0 || !S_ISREG(statbuf.st_mode))
+ /* Don't chmod if not a regular file. */
+ do_chmod = 0;
+#endif
+ if (do_chmod)
+ fchmod(fileno(f), 0600);
+}
#endif
fprintf(f, "%s\n", HISTFILE_FIRST_LINE);
OpenPOWER on IntegriCloud